Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DaisyUI v5 + Tailwind v4 + RJSF v6 #4498

Draft
wants to merge 2 commits into
base: rjsf-v6
Choose a base branch
from

Conversation

inchoate
Copy link

Reasons for making this change

[Please describe them here]

If this is related to existing tickets, include links to them as well. Use the syntax fixes #[issue number] (ex: fixes #123).

If your PR is non-trivial and you'd like to schedule a synchronous review, please add it to the weekly meeting agenda: https://docs.google.com/document/d/12PjTvv21k6LIky6bNQVnsplMLLnmEuypTLQF8a-8Wss/edit

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@inchoate inchoate changed the base branch from main to rjsf-v6 February 14, 2025 16:15
@inchoate
Copy link
Author

Copy of #4495 for RJSF v6. #4495

@nickgros
Copy link
Contributor

nickgros commented Feb 14, 2025

@heath-freenome Can you provide guidance to @inchoate about your new grid templating system in v6 and what other major changes (if any) he might expect to impact this PR? Would it make sense for us to prioritize merging this and #4497 to v6 before additional templating changes?

@inchoate
Copy link
Author

Forgot the v6 screenshots:

Themes and Subthemes
Screenshot 2025-02-14 at 4 11 11 PM
Screenshot 2025-02-14 at 4 11 28 PM

Simple Form in the Retro and Dark Themes
Screenshot 2025-02-14 at 4 11 54 PM
Screenshot 2025-02-14 at 4 12 20 PM

Numbers in the Pastel Theme
Screenshot 2025-02-14 at 4 13 00 PM

File Uploaders in the caramellatte Theme

  • supports single, multiple, and type filters
Screenshot 2025-02-14 at 4 13 45 PM

Datetime picker in the Cupcake, Dracula, and CMYK Themes

  • integrates w/react-date-picker
Screenshot 2025-02-14 at 4 14 59 PM Screenshot 2025-02-14 at 4 17 28 PM Screenshot 2025-02-14 at 4 18 03 PM

Enumerated Objects in the Light Theme
Screenshot 2025-02-14 at 4 16 07 PM

Hope this helps.

@heath-freenome
Copy link
Member

@heath-freenome Can you provide guidance to @inchoate about your new grid templating system in v6 and what other major changes (if any) he might expect to impact this PR? Would it make sense for us to prioritize merging this and #4497 to v6 before additional templating changes?

@nickgros @inchoate I've completed all of the template changes in V6 already. It seems like there needs to be an implementation of GridTemplate for this theme implementation.

<div className='card-body p-4'>
<div className='array-field-item-content mb-2'>{children}</div>
<div className='card-actions justify-end'>
{hasMoveUp && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will want to use the ArrayFieldItemButtonsTemplate in place of the buttons here. Although your implementation has additional behavior to the default implementation so maybe it is not necessary.

F extends FormContextType = any
>(): ComponentType<FormProps<T, S, F>> {
const theme = generateTheme<T, S, F>();
console.log('Generated theme:', theme); // Debug what templates are available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all of the console.log() statements before committing

console.log('DaisyUI ArrayFieldTitleTemplate');

props;
return <div>ArrayFieldTitleTemplate</div>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why you implemented this since it does nothing to display the TitleFieldTemplate

@@ -0,0 +1,2 @@
export { default } from './BaseInputTemplate';
export * from './BaseInputTemplate';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export * from './BaseInputTemplate';
export * from './BaseInputTemplate';

@@ -0,0 +1,2 @@
export { default } from './DescriptionField';
export * from './DescriptionField';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export * from './DescriptionField';
export * from './DescriptionField';

declare module '*.css?inline' {
const content: string;
export default content;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Comment on lines 17 to 28
// Object.keys(daisyProps).forEach((key) => {
// /**
// * Leveraging `shouldForwardProp` to remove props
// *
// * This is a utility function that's used in `@daisy-ui/react`'s factory function.
// * Normally, it prevents DaisyProps from being passed to the DOM.
// * In this case we just want to delete the unknown props. So we flip the boolean.
// */
// if (shouldForwardProp(key)) {
// delete (daisyProps as any)[key];
// }
// });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code meant to be commented out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

//
// Predefined DayPicker styles using DaisyUI classes
//
const dayPickerStyles: { classNames: Partial<ClassNames>; modifiers: Partial<ModifiersClassNames> } = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to DRY up this code into the DateTimeWidget with a flag to only show Date?

Comment on lines 10 to 29
import Ajv2019 from 'ajv/dist/2019.js';
import Ajv2020 from 'ajv/dist/2020.js';

import Layout from './layout';
import Playground, { PlaygroundProps } from './components';

// @ts-expect-error todo: error TS2345: Argument of type 'Localize' is not assignable to parameter of type 'Localizer'.
const esV8Validator = customizeValidator({}, localize_es);
const AJV8_2019 = customizeValidator({ AjvClass: Ajv2019 });
const AJV8_2020 = customizeValidator({ AjvClass: Ajv2020 });
const AJV8_DISC = customizeValidator({ ajvOptionsOverrides: { discriminator: true } });
const AJV8_DATA_REF = customizeValidator({ ajvOptionsOverrides: { $data: true } });

const validators: PlaygroundProps['validators'] = {
AJV8: v8Validator,
'AJV8 $data reference': AJV8_DATA_REF,
'AJV8 (discriminator)': AJV8_DISC,
AJV8_es: esV8Validator,
AJV8_2019,
AJV8_2020,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore all of these

@@ -41,4 +44,4 @@
"path": "./packages/snapshot-tests"
}
]
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

@inchoate
Copy link
Author

@heath-freenome thanks for your comments. I believe I addressed everything you brought up. Clearly my commit hooks were not set up correctly and, yet they still refuse to run.

I also added:

Toggle
Screenshot 2025-02-18 at 4 01 26 PM

Ratings
Screenshot 2025-02-18 at 3 59 20 PM

@nickgros

@heath-freenome
Copy link
Member

@inchoate I don't see an implementation of the GridTemplate.

FieldErrorTemplate,
FieldHelpTemplate,
FieldTemplate,
ObjectFieldTemplate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing a GridTemplate implementation.

@inchoate
Copy link
Author

@inchoate I don't see an implementation of the GridTemplate.

Sorry. Didn't see you make a comment about that. I'll just read the core implementation and go from there unless I hear otherwise.

@inchoate
Copy link
Author

@nickgros / @heath-freenome I'm kinda' flailing on the GridTemplate right now. How can I accurately test a different theme's implementation on the v6 branch?

@heath-freenome
Copy link
Member

I'm working on a new Field that will use it. Give me a few days to get it committed

@inchoate
Copy link
Author

inchoate commented Feb 19, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants