@rjsf/daisyui 6.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +231 -0
- package/dist/chakra-ui.esm.js +2192 -0
- package/dist/chakra-ui.esm.js.map +7 -0
- package/dist/chakra-ui.umd.js +2011 -0
- package/dist/index.js +2180 -0
- package/dist/index.js.map +7 -0
- package/lib/DaisyUIForm.d.ts +5 -0
- package/lib/DaisyUIForm.js +8 -0
- package/lib/DaisyUIForm.js.map +1 -0
- package/lib/DaisyUIFrameProvider.d.ts +35 -0
- package/lib/DaisyUIFrameProvider.js +93 -0
- package/lib/DaisyUIFrameProvider.js.map +1 -0
- package/lib/daisyForm/DaisyForm.d.ts +12 -0
- package/lib/daisyForm/DaisyForm.js +15 -0
- package/lib/daisyForm/DaisyForm.js.map +1 -0
- package/lib/daisyForm/index.d.ts +2 -0
- package/lib/daisyForm/index.js +3 -0
- package/lib/daisyForm/index.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.d.ts +7 -0
- package/lib/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.js +11 -0
- package/lib/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.js.map +1 -0
- package/lib/templates/ArrayFieldDescriptionTemplate/index.d.ts +2 -0
- package/lib/templates/ArrayFieldDescriptionTemplate/index.js +3 -0
- package/lib/templates/ArrayFieldDescriptionTemplate/index.js.map +1 -0
- package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.d.ts +5 -0
- package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js +20 -0
- package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js.map +1 -0
- package/lib/templates/ArrayFieldItemButtonsTemplate/index.d.ts +2 -0
- package/lib/templates/ArrayFieldItemButtonsTemplate/index.js +3 -0
- package/lib/templates/ArrayFieldItemButtonsTemplate/index.js.map +1 -0
- package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +14 -0
- package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +27 -0
- package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/templates/ArrayFieldItemTemplate/index.d.ts +2 -0
- package/lib/templates/ArrayFieldItemTemplate/index.js +3 -0
- package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -0
- package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +15 -0
- package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js +37 -0
- package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
- package/lib/templates/ArrayFieldTemplate/index.d.ts +2 -0
- package/lib/templates/ArrayFieldTemplate/index.js +3 -0
- package/lib/templates/ArrayFieldTemplate/index.js.map +1 -0
- package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.d.ts +7 -0
- package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js +11 -0
- package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js.map +1 -0
- package/lib/templates/ArrayFieldTitleTemplate/index.d.ts +2 -0
- package/lib/templates/ArrayFieldTitleTemplate/index.js +3 -0
- package/lib/templates/ArrayFieldTitleTemplate/index.js.map +1 -0
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.d.ts +16 -0
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js +33 -0
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
- package/lib/templates/BaseInputTemplate/index.d.ts +2 -0
- package/lib/templates/BaseInputTemplate/index.js +3 -0
- package/lib/templates/BaseInputTemplate/index.js.map +1 -0
- package/lib/templates/ButtonTemplates/AddButton.d.ts +6 -0
- package/lib/templates/ButtonTemplates/AddButton.js +15 -0
- package/lib/templates/ButtonTemplates/AddButton.js.map +1 -0
- package/lib/templates/ButtonTemplates/DaisyUIButton.d.ts +18 -0
- package/lib/templates/ButtonTemplates/DaisyUIButton.js +15 -0
- package/lib/templates/ButtonTemplates/DaisyUIButton.js.map +1 -0
- package/lib/templates/ButtonTemplates/IconButton.d.ts +5 -0
- package/lib/templates/ButtonTemplates/IconButton.js +21 -0
- package/lib/templates/ButtonTemplates/IconButton.js.map +1 -0
- package/lib/templates/ButtonTemplates/SubmitButton.d.ts +4 -0
- package/lib/templates/ButtonTemplates/SubmitButton.js +12 -0
- package/lib/templates/ButtonTemplates/SubmitButton.js.map +1 -0
- package/lib/templates/ButtonTemplates/index.d.ts +15 -0
- package/lib/templates/ButtonTemplates/index.js +17 -0
- package/lib/templates/ButtonTemplates/index.js.map +1 -0
- package/lib/templates/DescriptionField/DescriptionField.d.ts +8 -0
- package/lib/templates/DescriptionField/DescriptionField.js +16 -0
- package/lib/templates/DescriptionField/DescriptionField.js.map +1 -0
- package/lib/templates/DescriptionField/index.d.ts +2 -0
- package/lib/templates/DescriptionField/index.js +3 -0
- package/lib/templates/DescriptionField/index.js.map +1 -0
- package/lib/templates/ErrorList/ErrorList.d.ts +7 -0
- package/lib/templates/ErrorList/ErrorList.js +11 -0
- package/lib/templates/ErrorList/ErrorList.js.map +1 -0
- package/lib/templates/ErrorList/index.d.ts +2 -0
- package/lib/templates/ErrorList/index.js +3 -0
- package/lib/templates/ErrorList/index.js.map +1 -0
- package/lib/templates/FieldErrorTemplate/FieldErrorTemplate.d.ts +10 -0
- package/lib/templates/FieldErrorTemplate/FieldErrorTemplate.js +15 -0
- package/lib/templates/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
- package/lib/templates/FieldErrorTemplate/index.d.ts +2 -0
- package/lib/templates/FieldErrorTemplate/index.js +3 -0
- package/lib/templates/FieldErrorTemplate/index.js.map +1 -0
- package/lib/templates/FieldHelpTemplate/FieldHelpTemplate.d.ts +11 -0
- package/lib/templates/FieldHelpTemplate/FieldHelpTemplate.js +15 -0
- package/lib/templates/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
- package/lib/templates/FieldHelpTemplate/index.d.ts +2 -0
- package/lib/templates/FieldHelpTemplate/index.js +3 -0
- package/lib/templates/FieldHelpTemplate/index.js.map +1 -0
- package/lib/templates/FieldTemplate/FieldTemplate.d.ts +15 -0
- package/lib/templates/FieldTemplate/FieldTemplate.js +23 -0
- package/lib/templates/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/templates/FieldTemplate/index.d.ts +2 -0
- package/lib/templates/FieldTemplate/index.js +3 -0
- package/lib/templates/FieldTemplate/index.js.map +1 -0
- package/lib/templates/GridTemplate/GridTemplate.d.ts +7 -0
- package/lib/templates/GridTemplate/GridTemplate.js +16 -0
- package/lib/templates/GridTemplate/GridTemplate.js.map +1 -0
- package/lib/templates/GridTemplate/index.d.ts +2 -0
- package/lib/templates/GridTemplate/index.js +3 -0
- package/lib/templates/GridTemplate/index.js.map +1 -0
- package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +13 -0
- package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js +25 -0
- package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
- package/lib/templates/ObjectFieldTemplate/index.d.ts +2 -0
- package/lib/templates/ObjectFieldTemplate/index.js +3 -0
- package/lib/templates/ObjectFieldTemplate/index.js.map +1 -0
- package/lib/templates/Templates.d.ts +19 -0
- package/lib/templates/Templates.js +56 -0
- package/lib/templates/Templates.js.map +1 -0
- package/lib/templates/TitleField/TitleField.d.ts +13 -0
- package/lib/templates/TitleField/TitleField.js +19 -0
- package/lib/templates/TitleField/TitleField.js.map +1 -0
- package/lib/templates/TitleField/index.d.ts +2 -0
- package/lib/templates/TitleField/index.js +3 -0
- package/lib/templates/TitleField/index.js.map +1 -0
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +7 -0
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +20 -0
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +2 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.js +3 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -0
- package/lib/templates/index.d.ts +19 -0
- package/lib/templates/index.js +20 -0
- package/lib/templates/index.js.map +1 -0
- package/lib/theme/Theme.d.ts +43 -0
- package/lib/theme/Theme.js +68 -0
- package/lib/theme/Theme.js.map +1 -0
- package/lib/theme/index.d.ts +2 -0
- package/lib/theme/index.js +3 -0
- package/lib/theme/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/DaisyProps.d.ts +5 -0
- package/lib/types/DaisyProps.js +2 -0
- package/lib/types/DaisyProps.js.map +1 -0
- package/lib/utils.d.ts +13 -0
- package/lib/utils.js +5 -0
- package/lib/utils.js.map +1 -0
- package/lib/widgets/AltDateTimeWidget/AltDateTimeWidget.d.ts +6 -0
- package/lib/widgets/AltDateTimeWidget/AltDateTimeWidget.js +10 -0
- package/lib/widgets/AltDateTimeWidget/AltDateTimeWidget.js.map +1 -0
- package/lib/widgets/AltDateTimeWidget/index.d.ts +2 -0
- package/lib/widgets/AltDateTimeWidget/index.js +3 -0
- package/lib/widgets/AltDateTimeWidget/index.js.map +1 -0
- package/lib/widgets/AltDateWidget/AltDateWidget.d.ts +15 -0
- package/lib/widgets/AltDateWidget/AltDateWidget.js +138 -0
- package/lib/widgets/AltDateWidget/AltDateWidget.js.map +1 -0
- package/lib/widgets/AltDateWidget/index.d.ts +2 -0
- package/lib/widgets/AltDateWidget/index.js +3 -0
- package/lib/widgets/AltDateWidget/index.js.map +1 -0
- package/lib/widgets/CheckboxWidget/CheckboxWidget.d.ts +13 -0
- package/lib/widgets/CheckboxWidget/CheckboxWidget.js +43 -0
- package/lib/widgets/CheckboxWidget/CheckboxWidget.js.map +1 -0
- package/lib/widgets/CheckboxWidget/index.d.ts +2 -0
- package/lib/widgets/CheckboxWidget/index.js +3 -0
- package/lib/widgets/CheckboxWidget/index.js.map +1 -0
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.d.ts +16 -0
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js +73 -0
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
- package/lib/widgets/CheckboxesWidget/index.d.ts +2 -0
- package/lib/widgets/CheckboxesWidget/index.js +3 -0
- package/lib/widgets/CheckboxesWidget/index.js.map +1 -0
- package/lib/widgets/DateTimeWidget/DateTimeWidget.d.ts +14 -0
- package/lib/widgets/DateTimeWidget/DateTimeWidget.js +207 -0
- package/lib/widgets/DateTimeWidget/DateTimeWidget.js.map +1 -0
- package/lib/widgets/DateTimeWidget/index.d.ts +2 -0
- package/lib/widgets/DateTimeWidget/index.js +3 -0
- package/lib/widgets/DateTimeWidget/index.js.map +1 -0
- package/lib/widgets/DateWidget/DateWidget.d.ts +14 -0
- package/lib/widgets/DateWidget/DateWidget.js +274 -0
- package/lib/widgets/DateWidget/DateWidget.js.map +1 -0
- package/lib/widgets/DateWidget/index.d.ts +2 -0
- package/lib/widgets/DateWidget/index.js +3 -0
- package/lib/widgets/DateWidget/index.js.map +1 -0
- package/lib/widgets/FileWidget/FileWidget.d.ts +12 -0
- package/lib/widgets/FileWidget/FileWidget.js +57 -0
- package/lib/widgets/FileWidget/FileWidget.js.map +1 -0
- package/lib/widgets/FileWidget/index.d.ts +2 -0
- package/lib/widgets/FileWidget/index.js +3 -0
- package/lib/widgets/FileWidget/index.js.map +1 -0
- package/lib/widgets/RadioWidget/RadioWidget.d.ts +14 -0
- package/lib/widgets/RadioWidget/RadioWidget.js +67 -0
- package/lib/widgets/RadioWidget/RadioWidget.js.map +1 -0
- package/lib/widgets/RadioWidget/index.d.ts +2 -0
- package/lib/widgets/RadioWidget/index.js +3 -0
- package/lib/widgets/RadioWidget/index.js.map +1 -0
- package/lib/widgets/RangeWidget/RangeWidget.d.ts +13 -0
- package/lib/widgets/RangeWidget/RangeWidget.js +42 -0
- package/lib/widgets/RangeWidget/RangeWidget.js.map +1 -0
- package/lib/widgets/RangeWidget/index.d.ts +2 -0
- package/lib/widgets/RangeWidget/index.js +3 -0
- package/lib/widgets/RangeWidget/index.js.map +1 -0
- package/lib/widgets/RatingWidget/RatingWidget.d.ts +17 -0
- package/lib/widgets/RatingWidget/RatingWidget.js +64 -0
- package/lib/widgets/RatingWidget/RatingWidget.js.map +1 -0
- package/lib/widgets/RatingWidget/index.d.ts +2 -0
- package/lib/widgets/RatingWidget/index.js +3 -0
- package/lib/widgets/RatingWidget/index.js.map +1 -0
- package/lib/widgets/SelectWidget/SelectWidget.d.ts +14 -0
- package/lib/widgets/SelectWidget/SelectWidget.js +74 -0
- package/lib/widgets/SelectWidget/SelectWidget.js.map +1 -0
- package/lib/widgets/SelectWidget/index.d.ts +2 -0
- package/lib/widgets/SelectWidget/index.js +3 -0
- package/lib/widgets/SelectWidget/index.js.map +1 -0
- package/lib/widgets/TextareaWidget/TextareaWidget.d.ts +12 -0
- package/lib/widgets/TextareaWidget/TextareaWidget.js +44 -0
- package/lib/widgets/TextareaWidget/TextareaWidget.js.map +1 -0
- package/lib/widgets/TextareaWidget/index.d.ts +2 -0
- package/lib/widgets/TextareaWidget/index.js +3 -0
- package/lib/widgets/TextareaWidget/index.js.map +1 -0
- package/lib/widgets/TimeWidget/TimeWidget.d.ts +12 -0
- package/lib/widgets/TimeWidget/TimeWidget.js +42 -0
- package/lib/widgets/TimeWidget/TimeWidget.js.map +1 -0
- package/lib/widgets/TimeWidget/index.d.ts +2 -0
- package/lib/widgets/TimeWidget/index.js +3 -0
- package/lib/widgets/TimeWidget/index.js.map +1 -0
- package/lib/widgets/ToggleWidget/ToggleWidget.d.ts +13 -0
- package/lib/widgets/ToggleWidget/ToggleWidget.js +40 -0
- package/lib/widgets/ToggleWidget/ToggleWidget.js.map +1 -0
- package/lib/widgets/ToggleWidget/index.d.ts +2 -0
- package/lib/widgets/ToggleWidget/index.js +3 -0
- package/lib/widgets/ToggleWidget/index.js.map +1 -0
- package/lib/widgets/Widgets.d.ts +18 -0
- package/lib/widgets/Widgets.js +35 -0
- package/lib/widgets/Widgets.js.map +1 -0
- package/lib/widgets/index.d.ts +2 -0
- package/lib/widgets/index.js +3 -0
- package/lib/widgets/index.js.map +1 -0
- package/package.json +95 -0
- package/src/DaisyUIForm.tsx +9 -0
- package/src/DaisyUIFrameProvider.tsx +107 -0
- package/src/daisyForm/DaisyForm.tsx +20 -0
- package/src/daisyForm/index.ts +2 -0
- package/src/index.ts +13 -0
- package/src/styles.css +9 -0
- package/src/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.tsx +19 -0
- package/src/templates/ArrayFieldDescriptionTemplate/index.ts +2 -0
- package/src/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.tsx +89 -0
- package/src/templates/ArrayFieldItemButtonsTemplate/index.ts +2 -0
- package/src/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +55 -0
- package/src/templates/ArrayFieldItemTemplate/index.ts +2 -0
- package/src/templates/ArrayFieldTemplate/ArrayFieldTemplate.tsx +120 -0
- package/src/templates/ArrayFieldTemplate/index.ts +2 -0
- package/src/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx +15 -0
- package/src/templates/ArrayFieldTitleTemplate/index.ts +2 -0
- package/src/templates/BaseInputTemplate/BaseInputTemplate.tsx +104 -0
- package/src/templates/BaseInputTemplate/index.ts +2 -0
- package/src/templates/ButtonTemplates/AddButton.tsx +38 -0
- package/src/templates/ButtonTemplates/DaisyUIButton.tsx +31 -0
- package/src/templates/ButtonTemplates/IconButton.tsx +62 -0
- package/src/templates/ButtonTemplates/SubmitButton.tsx +25 -0
- package/src/templates/ButtonTemplates/index.ts +19 -0
- package/src/templates/DescriptionField/DescriptionField.tsx +26 -0
- package/src/templates/DescriptionField/index.ts +2 -0
- package/src/templates/ErrorList/ErrorList.tsx +21 -0
- package/src/templates/ErrorList/index.ts +2 -0
- package/src/templates/FieldErrorTemplate/FieldErrorTemplate.tsx +22 -0
- package/src/templates/FieldErrorTemplate/index.ts +2 -0
- package/src/templates/FieldHelpTemplate/FieldHelpTemplate.tsx +23 -0
- package/src/templates/FieldHelpTemplate/index.ts +2 -0
- package/src/templates/FieldTemplate/FieldTemplate.tsx +66 -0
- package/src/templates/FieldTemplate/index.ts +2 -0
- package/src/templates/GridTemplate/GridTemplate.tsx +26 -0
- package/src/templates/GridTemplate/index.ts +2 -0
- package/src/templates/ObjectFieldTemplate/ObjectFieldTemplate.tsx +108 -0
- package/src/templates/ObjectFieldTemplate/index.ts +2 -0
- package/src/templates/Templates.tsx +63 -0
- package/src/templates/TitleField/TitleField.tsx +26 -0
- package/src/templates/TitleField/index.ts +2 -0
- package/src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +74 -0
- package/src/templates/WrapIfAdditionalTemplate/index.ts +2 -0
- package/src/templates/index.ts +22 -0
- package/src/theme/Theme.tsx +93 -0
- package/src/theme/index.ts +2 -0
- package/src/tsconfig.json +26 -0
- package/src/types/DaisyProps.ts +5 -0
- package/src/types.d.ts +4 -0
- package/src/utils.ts +18 -0
- package/src/widgets/AltDateTimeWidget/AltDateTimeWidget.tsx +14 -0
- package/src/widgets/AltDateTimeWidget/index.ts +2 -0
- package/src/widgets/AltDateWidget/AltDateWidget.tsx +328 -0
- package/src/widgets/AltDateWidget/index.ts +2 -0
- package/src/widgets/CheckboxWidget/CheckboxWidget.tsx +108 -0
- package/src/widgets/CheckboxWidget/index.ts +2 -0
- package/src/widgets/CheckboxesWidget/CheckboxesWidget.tsx +124 -0
- package/src/widgets/CheckboxesWidget/index.ts +2 -0
- package/src/widgets/DateTimeWidget/DateTimeWidget.tsx +343 -0
- package/src/widgets/DateTimeWidget/index.ts +2 -0
- package/src/widgets/DateWidget/DateWidget.tsx +393 -0
- package/src/widgets/DateWidget/index.ts +2 -0
- package/src/widgets/FileWidget/FileWidget.tsx +86 -0
- package/src/widgets/FileWidget/index.ts +2 -0
- package/src/widgets/RadioWidget/RadioWidget.tsx +114 -0
- package/src/widgets/RadioWidget/index.ts +2 -0
- package/src/widgets/RangeWidget/RangeWidget.tsx +78 -0
- package/src/widgets/RangeWidget/index.ts +2 -0
- package/src/widgets/RatingWidget/RatingWidget.tsx +120 -0
- package/src/widgets/RatingWidget/index.ts +2 -0
- package/src/widgets/SelectWidget/SelectWidget.tsx +161 -0
- package/src/widgets/SelectWidget/index.ts +2 -0
- package/src/widgets/TextareaWidget/TextareaWidget.tsx +77 -0
- package/src/widgets/TextareaWidget/index.ts +2 -0
- package/src/widgets/TimeWidget/TimeWidget.tsx +72 -0
- package/src/widgets/TimeWidget/index.ts +2 -0
- package/src/widgets/ToggleWidget/ToggleWidget.tsx +70 -0
- package/src/widgets/ToggleWidget/index.ts +2 -0
- package/src/widgets/Widgets.tsx +58 -0
- package/src/widgets/index.ts +2 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
/** The `AltDateTimeWidget` is an alternative widget for rendering datetime properties.
|
|
3
|
+
* It uses the AltDateWidget for rendering, with the `time` prop set to true by default.
|
|
4
|
+
*/
|
|
5
|
+
declare function AltDateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ time, ...props }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default AltDateTimeWidget;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** The `AltDateTimeWidget` is an alternative widget for rendering datetime properties.
|
|
3
|
+
* It uses the AltDateWidget for rendering, with the `time` prop set to true by default.
|
|
4
|
+
*/
|
|
5
|
+
function AltDateTimeWidget({ time = true, ...props }) {
|
|
6
|
+
const { AltDateWidget } = props.registry.widgets;
|
|
7
|
+
return _jsx(AltDateWidget, { time: time, ...props });
|
|
8
|
+
}
|
|
9
|
+
export default AltDateTimeWidget;
|
|
10
|
+
//# sourceMappingURL=AltDateTimeWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AltDateTimeWidget.js","sourceRoot":"","sources":["../../../src/widgets/AltDateTimeWidget/AltDateTimeWidget.tsx"],"names":[],"mappings":";AAEA;;GAEG;AACH,SAAS,iBAAiB,CAAoF,EAC5G,IAAI,GAAG,IAAI,EACX,GAAG,KAAK,EACa;IACrB,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;IACjD,OAAO,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,KAAM,KAAK,GAAI,CAAC;AAClD,CAAC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/AltDateTimeWidget/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
/** The `AltDateWidget` component provides an alternative date/time input
|
|
3
|
+
* with individual fields for year, month, day, and optionally time components.
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Supports different date formats (YMD, MDY, DMY)
|
|
7
|
+
* - Optional time selection (hours, minutes, seconds)
|
|
8
|
+
* - "Set to now" and "Clear" buttons
|
|
9
|
+
* - Configurable year ranges
|
|
10
|
+
* - Accessible controls with proper labeling
|
|
11
|
+
* - DaisyUI styling for all elements
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `WidgetProps` for this component
|
|
14
|
+
*/
|
|
15
|
+
export default function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ time, disabled, readonly, autofocus, options, id, name, registry, onBlur, onFocus, onChange, value, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useReducer, useState } from 'react';
|
|
3
|
+
import { ariaDescribedByIds, TranslatableString, parseDateString, toDateString, dateRangeOptions, } from '@rjsf/utils';
|
|
4
|
+
/** Determines if the date object has all required fields to form a valid date
|
|
5
|
+
*
|
|
6
|
+
* @param state - The date object to check
|
|
7
|
+
* @param time - Whether to check time fields as well
|
|
8
|
+
* @returns True if all required fields are present
|
|
9
|
+
*/
|
|
10
|
+
function readyForChange(state, time = false) {
|
|
11
|
+
return state.year && state.month && state.day && (!time || (state.hour && state.minute && state.second));
|
|
12
|
+
}
|
|
13
|
+
/** Gets configuration for date elements based on format and ranges
|
|
14
|
+
*
|
|
15
|
+
* @param state - The current date object state
|
|
16
|
+
* @param time - Whether to include time elements
|
|
17
|
+
* @param yearsRange - Optional range of years to display
|
|
18
|
+
* @param format - Format for ordering date elements (year, month, day)
|
|
19
|
+
* @returns Array of element properties for rendering
|
|
20
|
+
*/
|
|
21
|
+
function getDateElementProps(state, time, yearsRange, format = 'YMD') {
|
|
22
|
+
const rangeOptions = yearsRange !== null && yearsRange !== void 0 ? yearsRange : [1900, new Date().getFullYear() + 2];
|
|
23
|
+
// Define the order based on the format
|
|
24
|
+
const formats = {
|
|
25
|
+
YMD: ['year', 'month', 'day'],
|
|
26
|
+
MDY: ['month', 'day', 'year'],
|
|
27
|
+
DMY: ['day', 'month', 'year'],
|
|
28
|
+
};
|
|
29
|
+
// Get the elements in the specified order
|
|
30
|
+
const dateElements = formats[format].map((key) => ({
|
|
31
|
+
type: key,
|
|
32
|
+
value: state[key],
|
|
33
|
+
range: key === 'year'
|
|
34
|
+
? rangeOptions
|
|
35
|
+
: key === 'month'
|
|
36
|
+
? [1, 12]
|
|
37
|
+
: key === 'day'
|
|
38
|
+
? [1, 31]
|
|
39
|
+
: [0, 59],
|
|
40
|
+
}));
|
|
41
|
+
// Add time elements if needed
|
|
42
|
+
if (time) {
|
|
43
|
+
dateElements.push({ type: 'hour', value: state.hour, range: [0, 23] }, { type: 'minute', value: state.minute, range: [0, 59] }, { type: 'second', value: state.second, range: [0, 59] });
|
|
44
|
+
}
|
|
45
|
+
return dateElements;
|
|
46
|
+
}
|
|
47
|
+
/** Component for rendering individual date/time elements (year, month, day, etc.)
|
|
48
|
+
*
|
|
49
|
+
* Renders a select input for each date component with appropriate options.
|
|
50
|
+
*
|
|
51
|
+
* @param props - The props for the component
|
|
52
|
+
*/
|
|
53
|
+
function DateElement({ type, range, value, select, rootId, name, disabled, readonly, autofocus, registry, onBlur, onFocus, }) {
|
|
54
|
+
const id = `${rootId}_${type}`;
|
|
55
|
+
const { SelectWidget } = registry.widgets;
|
|
56
|
+
// Memoize the onChange handler
|
|
57
|
+
const handleChange = useCallback((value) => {
|
|
58
|
+
select(type, value);
|
|
59
|
+
}, [select, type]);
|
|
60
|
+
return (_jsx(SelectWidget, { schema: { type: 'integer' }, id: id, name: name, className: 'select select-bordered select-sm w-full', options: { enumOptions: dateRangeOptions(range[0], range[1]) }, placeholder: type, value: value, disabled: disabled, readonly: readonly, autofocus: autofocus, onChange: handleChange, onBlur: onBlur, onFocus: onFocus, registry: registry, label: '', "aria-describedby": ariaDescribedByIds(rootId), required: false }));
|
|
61
|
+
}
|
|
62
|
+
/** Converts our DateObject to the expected format for toDateString
|
|
63
|
+
*
|
|
64
|
+
* @param dateObj - The internal DateObject
|
|
65
|
+
* @returns A properly formatted object for the utils toDateString function
|
|
66
|
+
*/
|
|
67
|
+
function convertToRJSFDateObject(dateObj) {
|
|
68
|
+
return {
|
|
69
|
+
year: dateObj.year ? parseInt(dateObj.year) : 0,
|
|
70
|
+
month: dateObj.month ? parseInt(dateObj.month) : 0,
|
|
71
|
+
day: dateObj.day ? parseInt(dateObj.day) : 0,
|
|
72
|
+
hour: dateObj.hour ? parseInt(dateObj.hour) : 0,
|
|
73
|
+
minute: dateObj.minute ? parseInt(dateObj.minute) : 0,
|
|
74
|
+
second: dateObj.second ? parseInt(dateObj.second) : 0,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** The `AltDateWidget` component provides an alternative date/time input
|
|
78
|
+
* with individual fields for year, month, day, and optionally time components.
|
|
79
|
+
*
|
|
80
|
+
* Features:
|
|
81
|
+
* - Supports different date formats (YMD, MDY, DMY)
|
|
82
|
+
* - Optional time selection (hours, minutes, seconds)
|
|
83
|
+
* - "Set to now" and "Clear" buttons
|
|
84
|
+
* - Configurable year ranges
|
|
85
|
+
* - Accessible controls with proper labeling
|
|
86
|
+
* - DaisyUI styling for all elements
|
|
87
|
+
*
|
|
88
|
+
* @param props - The `WidgetProps` for this component
|
|
89
|
+
*/
|
|
90
|
+
export default function AltDateWidget({ time = false, disabled = false, readonly = false, autofocus = false, options = {}, id, name, registry, onBlur, onFocus, onChange, value, }) {
|
|
91
|
+
const { translateString } = registry;
|
|
92
|
+
const [lastValue, setLastValue] = useState(value);
|
|
93
|
+
// Use a type-safe version of parseDateString result
|
|
94
|
+
const initialState = parseDateString(value, time);
|
|
95
|
+
// Create a reducer for date objects
|
|
96
|
+
const dateReducer = (state, action) => {
|
|
97
|
+
return { ...state, ...action };
|
|
98
|
+
};
|
|
99
|
+
const [state, setState] = useReducer(dateReducer, initialState);
|
|
100
|
+
// Handle changes in props or state
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
const rjsfDateObj = convertToRJSFDateObject(state);
|
|
103
|
+
const stateValue = toDateString(rjsfDateObj, time);
|
|
104
|
+
if (readyForChange(state, time) && stateValue !== value) {
|
|
105
|
+
// Valid date changed via the selects
|
|
106
|
+
onChange(stateValue);
|
|
107
|
+
}
|
|
108
|
+
else if (lastValue !== value) {
|
|
109
|
+
// New value from props
|
|
110
|
+
setLastValue(value);
|
|
111
|
+
setState(parseDateString(value, time));
|
|
112
|
+
}
|
|
113
|
+
}, [time, value, onChange, state, lastValue]);
|
|
114
|
+
// Handle individual field changes
|
|
115
|
+
const handleChange = useCallback((property, value) => {
|
|
116
|
+
setState({ [property]: value });
|
|
117
|
+
}, []);
|
|
118
|
+
// Set current date
|
|
119
|
+
const handleSetNow = useCallback((event) => {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
if (disabled || readonly) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const nextState = parseDateString(new Date().toJSON(), time);
|
|
125
|
+
const rjsfDateObj = convertToRJSFDateObject(nextState);
|
|
126
|
+
onChange(toDateString(rjsfDateObj, time));
|
|
127
|
+
}, [disabled, readonly, time, onChange]);
|
|
128
|
+
// Clear the date
|
|
129
|
+
const handleClear = useCallback((event) => {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
if (disabled || readonly) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
onChange(undefined);
|
|
135
|
+
}, [disabled, readonly, onChange]);
|
|
136
|
+
return (_jsxs("div", { className: 'space-y-3', children: [_jsx("div", { className: 'grid grid-cols-3 gap-2', children: getDateElementProps(state, time, options.yearsRange, options.format).map((elemProps, i) => (_jsxs("div", { className: 'form-control', children: [_jsx("label", { className: 'label', children: _jsx("span", { className: 'label-text capitalize', children: elemProps.type }) }), _jsx(DateElement, { rootId: id, name: name, select: handleChange, type: elemProps.type, range: elemProps.range, value: elemProps.value, disabled: disabled, readonly: readonly, registry: registry, onBlur: onBlur, onFocus: onFocus, autofocus: autofocus && i === 0 })] }, i))) }), _jsxs("div", { className: 'flex justify-start space-x-2', children: [(options.hideNowButton !== undefined ? !options.hideNowButton : true) && (_jsx("button", { type: 'button', className: 'btn btn-sm btn-primary', onClick: handleSetNow, disabled: disabled || readonly, children: translateString(TranslatableString.NowLabel) })), (options.hideClearButton !== undefined ? !options.hideClearButton : true) && (_jsx("button", { type: 'button', className: 'btn btn-sm btn-secondary', onClick: handleClear, disabled: disabled || readonly, children: translateString(TranslatableString.ClearLabel) }))] })] }));
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=AltDateWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AltDateWidget.js","sourceRoot":"","sources":["../../../src/widgets/AltDateWidget/AltDateWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EACL,kBAAkB,EAKlB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAGjB,MAAM,aAAa,CAAC;AAYrB;;;;;GAKG;AACH,SAAS,cAAc,CAAC,KAAiB,EAAE,IAAI,GAAG,KAAK;IACrD,OAAO,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3G,CAAC;AAKD;;;;;;;GAOG;AACH,SAAS,mBAAmB,CAC1B,KAAiB,EACjB,IAAa,EACb,UAA6B,EAC7B,SAA4B,KAAK;IAEjC,MAAM,YAAY,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IACxE,uCAAuC;IACvC,MAAM,OAAO,GAAuD;QAClE,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;QAC7B,GAAG,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC;QAC7B,GAAG,EAAE,CAAC,KAAK,E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b,SAAS,EAAC,wBAAwB,EAClC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,QAAQ,IAAI,QAAQ,YAE7B,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GACtC,CACV,EACA,CAAC,OAAO,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAC5E,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,0BAA0B,EACpC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,QAAQ,IAAI,QAAQ,YAE7B,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC,GACxC,CACV,IACG,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/AltDateWidget/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WidgetProps, StrictRJSFSchema, RJSFSchema, FormContextType } from '@rjsf/utils';
|
|
2
|
+
/** The `CheckboxWidget` component renders a single checkbox input with DaisyUI styling.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Simple boolean input with DaisyUI checkbox styling
|
|
6
|
+
* - Handles required, disabled, and readonly states
|
|
7
|
+
* - No label rendering (handled by the parent FieldTemplate)
|
|
8
|
+
* - Proper onChange handling for boolean values
|
|
9
|
+
* - Manages focus and blur events for accessibility
|
|
10
|
+
*
|
|
11
|
+
* @param props - The `WidgetProps` for this component
|
|
12
|
+
*/
|
|
13
|
+
export default function CheckboxWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { getTemplate, descriptionId } from '@rjsf/utils';
|
|
4
|
+
/** The `CheckboxWidget` component renders a single checkbox input with DaisyUI styling.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Simple boolean input with DaisyUI checkbox styling
|
|
8
|
+
* - Handles required, disabled, and readonly states
|
|
9
|
+
* - No label rendering (handled by the parent FieldTemplate)
|
|
10
|
+
* - Proper onChange handling for boolean values
|
|
11
|
+
* - Manages focus and blur events for accessibility
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `WidgetProps` for this component
|
|
14
|
+
*/
|
|
15
|
+
export default function CheckboxWidget(props) {
|
|
16
|
+
const { id, value, required, disabled, hideLabel, label, readonly, registry, options, schema, uiSchema, onChange, onFocus, onBlur, } = props;
|
|
17
|
+
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
18
|
+
const description = options.description || schema.description;
|
|
19
|
+
/** Handle focus events
|
|
20
|
+
*/
|
|
21
|
+
const handleFocus = useCallback(() => {
|
|
22
|
+
if (onFocus) {
|
|
23
|
+
onFocus(id, value);
|
|
24
|
+
}
|
|
25
|
+
}, [onFocus, id, value]);
|
|
26
|
+
/** Handle blur events
|
|
27
|
+
*/
|
|
28
|
+
const handleBlur = useCallback(() => {
|
|
29
|
+
if (onBlur) {
|
|
30
|
+
onBlur(id, value);
|
|
31
|
+
}
|
|
32
|
+
}, [onBlur, id, value]);
|
|
33
|
+
/** Handle change events
|
|
34
|
+
*
|
|
35
|
+
* @param event - The change event
|
|
36
|
+
*/
|
|
37
|
+
const handleChange = useCallback((event) => {
|
|
38
|
+
onChange(event.target.checked);
|
|
39
|
+
}, [onChange]);
|
|
40
|
+
const input = (_jsx("input", { type: 'checkbox', id: id, checked: value, required: required, disabled: disabled || readonly, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, className: 'checkbox' }));
|
|
41
|
+
return (_jsxs("div", { className: 'form-control', children: [!hideLabel && description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), hideLabel || !label ? (input) : (_jsxs("label", { className: 'label cursor-pointer justify-start', children: [_jsx("div", { className: 'mr-2', children: input }), _jsxs("span", { className: 'label-text', children: [label, required && _jsx("span", { className: 'text-error ml-1', children: "*" })] })] }))] }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=CheckboxWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxWidget.js","sourceRoot":"","sources":["../../../src/widgets/CheckboxWidget/CheckboxWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAA8D,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAErH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAIpC,KAA2B;IAC3B,MAAM,EACJ,EAAE,EACF,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,GACP,GAAG,KAAK,CAAC;IACV,MAAM,wBAAwB,GAAG,WAAW,CAC1C,0BAA0B,EAC1B,QAAQ,EACR,OAAO,CACR,CAAC;IACF,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC;IAE9D;OACG;IACH,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzB;OACG;IACH,MA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,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/CheckboxWidget/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WidgetProps, StrictRJSFSchema, RJSFSchema, FormContextType } from '@rjsf/utils';
|
|
2
|
+
/** The `CheckboxesWidget` component renders a set of checkboxes for multiple choice selection
|
|
3
|
+
* with DaisyUI styling.
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Supports both primitive values and objects in enum options
|
|
7
|
+
* - Handles array values with proper state management
|
|
8
|
+
* - Uses DaisyUI checkbox styling with accessible labels
|
|
9
|
+
* - Supports disabled and readonly states
|
|
10
|
+
* - Provides focus and blur event handling for accessibility
|
|
11
|
+
* - Uses vertical layout for better spacing and readability
|
|
12
|
+
* - Uses memoized handlers for optimal performance
|
|
13
|
+
*
|
|
14
|
+
* @param props - The `WidgetProps` for this component
|
|
15
|
+
*/
|
|
16
|
+
export default function CheckboxesWidget<T, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ id, disabled, options, value, readonly, required, onChange, onFocus, onBlur, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
/** The `CheckboxesWidget` component renders a set of checkboxes for multiple choice selection
|
|
4
|
+
* with DaisyUI styling.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Supports both primitive values and objects in enum options
|
|
8
|
+
* - Handles array values with proper state management
|
|
9
|
+
* - Uses DaisyUI checkbox styling with accessible labels
|
|
10
|
+
* - Supports disabled and readonly states
|
|
11
|
+
* - Provides focus and blur event handling for accessibility
|
|
12
|
+
* - Uses vertical layout for better spacing and readability
|
|
13
|
+
* - Uses memoized handlers for optimal performance
|
|
14
|
+
*
|
|
15
|
+
* @param props - The `WidgetProps` for this component
|
|
16
|
+
*/
|
|
17
|
+
export default function CheckboxesWidget({ id, disabled, options, value, readonly, required, onChange, onFocus, onBlur, }) {
|
|
18
|
+
var _a;
|
|
19
|
+
const { enumOptions } = options;
|
|
20
|
+
const isEnumeratedObject = enumOptions && ((_a = enumOptions[0]) === null || _a === void 0 ? void 0 : _a.value) && typeof enumOptions[0].value === 'object';
|
|
21
|
+
/** Determines if a checkbox option should be checked based on the current value
|
|
22
|
+
*
|
|
23
|
+
* @param option - The option to check
|
|
24
|
+
* @returns Whether the option should be checked
|
|
25
|
+
*/
|
|
26
|
+
const isChecked = useCallback((option) => {
|
|
27
|
+
if (!Array.isArray(value)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (isEnumeratedObject) {
|
|
31
|
+
return value.some((v) => v.name === option.value.name);
|
|
32
|
+
}
|
|
33
|
+
return value.includes(option.value);
|
|
34
|
+
}, [value, isEnumeratedObject]);
|
|
35
|
+
/** Handles changes to a checkbox's checked state */
|
|
36
|
+
const handleChange = useCallback((event) => {
|
|
37
|
+
const index = Number(event.target.dataset.index);
|
|
38
|
+
const option = enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions[index];
|
|
39
|
+
if (!option) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const newValue = Array.isArray(value) ? [...value] : [];
|
|
43
|
+
const optionValue = isEnumeratedObject ? option.value : option.value;
|
|
44
|
+
if (isChecked(option)) {
|
|
45
|
+
onChange(newValue.filter((v) => (isEnumeratedObject ? v.name !== optionValue.name : v !== optionValue)));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
onChange([...newValue, optionValue]);
|
|
49
|
+
}
|
|
50
|
+
}, [onChange, value, isChecked, isEnumeratedObject, enumOptions]);
|
|
51
|
+
/** Handles focus events for accessibility */
|
|
52
|
+
const handleFocus = useCallback((event) => {
|
|
53
|
+
if (onFocus) {
|
|
54
|
+
const index = Number(event.target.dataset.index);
|
|
55
|
+
const option = enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions[index];
|
|
56
|
+
if (option) {
|
|
57
|
+
onFocus(id, option.value);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, [onFocus, id, enumOptions]);
|
|
61
|
+
/** Handles blur events for accessibility */
|
|
62
|
+
const handleBlur = useCallback((event) => {
|
|
63
|
+
if (onBlur) {
|
|
64
|
+
const index = Number(event.target.dataset.index);
|
|
65
|
+
const option = enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions[index];
|
|
66
|
+
if (option) {
|
|
67
|
+
onBlur(id, option.value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, [onBlur, id, enumOptions]);
|
|
71
|
+
return (_jsx("div", { className: 'form-control', children: _jsx("div", { className: 'flex flex-col gap-2 mt-1', children: enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions.map((option, index) => (_jsxs("label", { className: 'flex items-center cursor-pointer gap-2', children: [_jsx("input", { type: 'checkbox', id: `${id}-${option.value}`, className: 'checkbox', name: id, checked: isChecked(option), required: required, disabled: disabled || readonly, "data-index": index, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur }), _jsx("span", { className: 'label-text', children: option.label })] }, option.value))) }) }));
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=CheckboxesWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxesWidget.js","sourceRoot":"","sources":["../../../src/widgets/CheckboxesWidget/CheckboxesWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,MAAM,OAAO,CAAC;AAGhD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAA8E,EACpH,EAAE,EACF,QAAQ,EACR,OAAO,EACP,KAAK,EACL,QAAQ,E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AAG,KAAK,CAAC,CAAC;YACpC,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC,EACD,CAAC,MAAM,EAAE,EAAE,EAAE,WAAW,CAAC,CAC1B,CAAC;IAEF,OAAO,CACL,cAAK,SAAS,EAAC,cAAc,YAE3B,cAAK,SAAS,EAAC,0BAA0B,YACtC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CACnC,iBAA0B,SAAS,EAAC,wCAAwC,aAC1E,gBACE,IAAI,EAAC,UAAU,EACf,EAAE,EAAE,GAAG,EAAE,IAAI,MAAM,CAAC,KAAK,EAAE,EAC3B,SAAS,EAAC,UAAU,EACpB,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,EAC1B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,IAAI,QAAQ,gBAClB,KAAK,EACjB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,GAClB,EACF,eAAM,SAAS,EAAC,YAAY,YAAE,MAAM,CAAC,KAAK,GAAQ,KAdxC,MAAM,CAAC,KAAK,CAehB,CACT,CAAC,GACE,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/CheckboxesWidget/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
import 'react-day-picker/dist/style.css';
|
|
3
|
+
/** The `DateTimeWidget` component provides a date and time picker with DaisyUI styling.
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Calendar popup with month/year navigation
|
|
7
|
+
* - Time input field
|
|
8
|
+
* - Accessible keyboard navigation
|
|
9
|
+
* - Date formatting using date-fns
|
|
10
|
+
* - Manages focus and blur events for accessibility
|
|
11
|
+
*
|
|
12
|
+
* @param props - The `WidgetProps` for this component
|
|
13
|
+
*/
|
|
14
|
+
export default function DateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { faCalendar } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import { format, isSameDay, isToday, isValid } from 'date-fns';
|
|
6
|
+
import { DayPicker, UI } from 'react-day-picker';
|
|
7
|
+
import 'react-day-picker/dist/style.css';
|
|
8
|
+
/**
|
|
9
|
+
* Custom hook to manage the picker's popup state and displayed month
|
|
10
|
+
*
|
|
11
|
+
* @param initialDate - Initial date to display, defaults to today
|
|
12
|
+
* @returns State and handlers for the date picker
|
|
13
|
+
*/
|
|
14
|
+
function useDatePickerState(initialDate) {
|
|
15
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
16
|
+
const [month, setMonth] = useState(initialDate !== null && initialDate !== void 0 ? initialDate : new Date());
|
|
17
|
+
return { isOpen, setIsOpen, month, setMonth };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Custom hook to detect clicks outside an element and run a callback
|
|
21
|
+
*
|
|
22
|
+
* @param ref - React ref to the element to monitor
|
|
23
|
+
* @param callback - Function to call when a click outside is detected
|
|
24
|
+
*/
|
|
25
|
+
function useClickOutside(ref, callback) {
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const handleClickOutside = (event) => {
|
|
28
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
29
|
+
callback();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
33
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
34
|
+
}, [ref, callback]);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Predefined DayPicker styles using DaisyUI classes
|
|
38
|
+
*/
|
|
39
|
+
const dayPickerStyles = {
|
|
40
|
+
classNames: {
|
|
41
|
+
[UI.Root]: 'relative',
|
|
42
|
+
[UI.Nav]: 'hidden',
|
|
43
|
+
[UI.Chevron]: 'hidden',
|
|
44
|
+
[UI.CaptionLabel]: 'hidden',
|
|
45
|
+
[UI.Dropdowns]: 'flex justify-between gap-4 px-4 pb-4',
|
|
46
|
+
[UI.Dropdown]: 'select select-bordered select-sm w-32',
|
|
47
|
+
[UI.MonthsDropdown]: 'select select-bordered select-sm',
|
|
48
|
+
[UI.YearsDropdown]: 'select select-bordered select-sm',
|
|
49
|
+
[UI.Months]: 'flex justify-center',
|
|
50
|
+
[UI.Month]: 'w-full',
|
|
51
|
+
[UI.MonthCaption]: 'flex justify-center',
|
|
52
|
+
[UI.MonthGrid]: 'w-full',
|
|
53
|
+
[UI.Weekdays]: 'grid grid-cols-7 text-center border-b mb-2 pb-1 text-base-content/60 uppercase',
|
|
54
|
+
[UI.Weekday]: 'p-1 font-medium text-base-content/60 text-sm',
|
|
55
|
+
[UI.Week]: 'grid grid-cols-7',
|
|
56
|
+
[UI.Day]: 'w-10 h-8 p-0 relative rounded-md',
|
|
57
|
+
[UI.DayButton]: 'btn btn-ghost absolute inset-0 flex items-center justify-center w-full h-full cursor-pointer rounded-md hover:btn-primary',
|
|
58
|
+
},
|
|
59
|
+
modifiers: {
|
|
60
|
+
selected: 'btn btn-accent min-h-0 h-full',
|
|
61
|
+
outside: 'text-base-content/30 hover:btn-ghost',
|
|
62
|
+
disabled: 'opacity-50 cursor-not-allowed hover:btn-disabled',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Popup component for the calendar and time input
|
|
67
|
+
*
|
|
68
|
+
* Renders a DayPicker calendar with time input for selecting date and time
|
|
69
|
+
*
|
|
70
|
+
* @param props - The DateTimePickerProps for this component
|
|
71
|
+
*/
|
|
72
|
+
function DateTimePickerPopup({ selectedDate, month, onMonthChange, onSelect, onTimeChange }) {
|
|
73
|
+
const customDayModifiers = {
|
|
74
|
+
selected: selectedDate,
|
|
75
|
+
'custom-today': (date) => isToday(date) && !(selectedDate && isSameDay(date, selectedDate)),
|
|
76
|
+
};
|
|
77
|
+
const customModifiersClassNames = {
|
|
78
|
+
...dayPickerStyles.modifiers,
|
|
79
|
+
'custom-today': 'btn btn-outline btn-info min-h-0 h-full',
|
|
80
|
+
};
|
|
81
|
+
// Memoize click handler to stop event propagation
|
|
82
|
+
const handleClick = useCallback((e) => {
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
}, []);
|
|
85
|
+
return (_jsxs("div", { className: 'p-3', children: [_jsx(DayPicker, { mode: 'single', selected: selectedDate, month: month, onMonthChange: onMonthChange, onSelect: onSelect, captionLayout: 'dropdown', fromYear: 1900, toYear: new Date().getFullYear() + 10, showOutsideDays: true, classNames: dayPickerStyles.classNames, modifiers: customDayModifiers, modifiersClassNames: customModifiersClassNames }), _jsx("div", { className: 'mt-3 border-t border-base-300 pt-3', children: _jsxs("div", { className: 'form-control w-full', children: [_jsx("label", { className: 'label', children: _jsx("span", { className: 'label-text', children: "Time" }) }), _jsx("input", { type: 'time', className: 'input input-bordered w-full', value: selectedDate ? format(selectedDate, 'HH:mm') : '', onChange: onTimeChange, onClick: handleClick })] }) })] }));
|
|
86
|
+
}
|
|
87
|
+
// Use memo to optimize re-renders
|
|
88
|
+
const MemoizedDateTimePickerPopup = memo(DateTimePickerPopup);
|
|
89
|
+
/** The `DateTimeWidget` component provides a date and time picker with DaisyUI styling.
|
|
90
|
+
*
|
|
91
|
+
* Features:
|
|
92
|
+
* - Calendar popup with month/year navigation
|
|
93
|
+
* - Time input field
|
|
94
|
+
* - Accessible keyboard navigation
|
|
95
|
+
* - Date formatting using date-fns
|
|
96
|
+
* - Manages focus and blur events for accessibility
|
|
97
|
+
*
|
|
98
|
+
* @param props - The `WidgetProps` for this component
|
|
99
|
+
*/
|
|
100
|
+
export default function DateTimeWidget(props) {
|
|
101
|
+
const { id, value, onChange, onFocus, onBlur, schema } = props;
|
|
102
|
+
// Initialize the local date from the parent's value.
|
|
103
|
+
const initialDate = useMemo(() => (value ? new Date(value) : undefined), [value]);
|
|
104
|
+
const [localDate, setLocalDate] = useState(initialDate);
|
|
105
|
+
// When the parent's value changes externally, update local state.
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
setLocalDate(initialDate);
|
|
108
|
+
}, [initialDate]);
|
|
109
|
+
const { isOpen, setIsOpen, month, setMonth } = useDatePickerState(initialDate);
|
|
110
|
+
const containerRef = useRef(null);
|
|
111
|
+
const inputRef = useRef(null);
|
|
112
|
+
// Close the popup when clicking outside and commit changes.
|
|
113
|
+
useClickOutside(containerRef, () => {
|
|
114
|
+
if (isOpen) {
|
|
115
|
+
setIsOpen(false);
|
|
116
|
+
onChange(localDate ? localDate.toISOString() : '');
|
|
117
|
+
// Manually invoke the blur handler to ensure blur event is triggered
|
|
118
|
+
if (onBlur) {
|
|
119
|
+
onBlur(id, value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
// When the local date changes, update the displayed month.
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (localDate) {
|
|
126
|
+
setMonth(localDate);
|
|
127
|
+
}
|
|
128
|
+
}, [localDate, setMonth]);
|
|
129
|
+
// Update the month when the user navigates the calendar.
|
|
130
|
+
const handleMonthChange = useCallback((date) => setMonth(date), [setMonth]);
|
|
131
|
+
// Update local state on day selection (but do not commit immediately).
|
|
132
|
+
const handleSelect = useCallback((date) => {
|
|
133
|
+
if (date) {
|
|
134
|
+
if (localDate) {
|
|
135
|
+
date.setHours(localDate.getHours(), localDate.getMinutes());
|
|
136
|
+
}
|
|
137
|
+
setLocalDate(date);
|
|
138
|
+
}
|
|
139
|
+
}, [localDate]);
|
|
140
|
+
// Update local state on time change.
|
|
141
|
+
const handleTimeChange = useCallback((e) => {
|
|
142
|
+
if (localDate) {
|
|
143
|
+
const [hours, minutes] = e.target.value.split(':');
|
|
144
|
+
const newDate = new Date(localDate);
|
|
145
|
+
newDate.setHours(parseInt(hours, 10), parseInt(minutes, 10));
|
|
146
|
+
setLocalDate(newDate);
|
|
147
|
+
}
|
|
148
|
+
}, [localDate]);
|
|
149
|
+
// Toggle popup visibility.
|
|
150
|
+
const togglePicker = useCallback((e) => {
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
setIsOpen((prev) => !prev);
|
|
153
|
+
if (!isOpen && onFocus) {
|
|
154
|
+
onFocus(id, value);
|
|
155
|
+
}
|
|
156
|
+
}, [isOpen, id, onFocus, setIsOpen, value]);
|
|
157
|
+
// Handle focus event
|
|
158
|
+
const handleFocus = useCallback(() => {
|
|
159
|
+
if (onFocus) {
|
|
160
|
+
onFocus(id, value);
|
|
161
|
+
}
|
|
162
|
+
}, [id, onFocus, value]);
|
|
163
|
+
// Handle blur event
|
|
164
|
+
const handleBlur = useCallback(() => {
|
|
165
|
+
if (!isOpen && onBlur) {
|
|
166
|
+
onBlur(id, value);
|
|
167
|
+
}
|
|
168
|
+
}, [id, onBlur, value, isOpen]);
|
|
169
|
+
// Handle keydown events for accessibility
|
|
170
|
+
const handleKeyDown = useCallback((e) => {
|
|
171
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
172
|
+
togglePicker(e);
|
|
173
|
+
}
|
|
174
|
+
}, [togglePicker]);
|
|
175
|
+
// Prevent event propagation for popup container
|
|
176
|
+
const handleContainerClick = useCallback((e) => {
|
|
177
|
+
e.stopPropagation();
|
|
178
|
+
}, []);
|
|
179
|
+
// Close popup on escape key
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
const handleEscape = (e) => {
|
|
182
|
+
if (e.key === 'Escape' && isOpen) {
|
|
183
|
+
setIsOpen(false);
|
|
184
|
+
if (onBlur) {
|
|
185
|
+
onBlur(id, value);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
// Need to use native DOM events since we're attaching to document
|
|
190
|
+
document.addEventListener('keydown', handleEscape);
|
|
191
|
+
return () => document.removeEventListener('keydown', handleEscape);
|
|
192
|
+
}, [id, isOpen, onBlur, value]);
|
|
193
|
+
// Add the handleDoneClick callback near the top of the component, with the other event handlers
|
|
194
|
+
/** Handle clicking the "Done" button
|
|
195
|
+
*/
|
|
196
|
+
const handleDoneClick = useCallback(() => {
|
|
197
|
+
var _a;
|
|
198
|
+
setIsOpen(false);
|
|
199
|
+
onChange(localDate ? localDate.toISOString() : '');
|
|
200
|
+
if (onBlur) {
|
|
201
|
+
onBlur(id, value);
|
|
202
|
+
}
|
|
203
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
204
|
+
}, [localDate, onChange, onBlur, id, value]);
|
|
205
|
+
return (_jsx("div", { className: 'form-control my-4 w-full relative', children: _jsxs("div", { className: 'w-full', tabIndex: 0, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, ref: inputRef, children: [_jsxs("div", { id: id, className: `input input-bordered w-full flex items-center justify-between cursor-pointer ${isOpen ? 'ring-2 ring-primary/50' : ''}`, onClick: togglePicker, role: 'button', "aria-haspopup": 'true', "aria-expanded": isOpen, tabIndex: -1, children: [_jsx("span", { className: localDate && isValid(localDate) ? '' : 'text-base-content/50', children: localDate && isValid(localDate) ? format(localDate, 'PP p') : schema.title }), _jsx(FontAwesomeIcon, { icon: faCalendar, className: 'ml-2 h-4 w-4 text-primary' })] }), isOpen && (_jsxs("div", { ref: containerRef, className: 'absolute z-[100] mt-2 w-full max-w-xs bg-base-100 border border-base-300 shadow-lg rounded-box', onClick: handleContainerClick, children: [_jsx(MemoizedDateTimePickerPopup, { selectedDate: localDate, month: month, onMonthChange: handleMonthChange, onSelect: handleSelect, onTimeChange: handleTimeChange }), _jsx("div", { className: 'p-3 flex justify-end border-t border-base-300', children: _jsx("button", { type: 'button', className: 'btn btn-sm btn-primary', onClick: handleDoneClick, children: "Done" }) })] }))] }) }));
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=DateTimeWidget.js.map
|