@rjsf/daisyui 6.0.0-beta.21 → 6.0.0-beta.23
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/dist/chakra-ui.esm.js +169 -355
- package/dist/chakra-ui.esm.js.map +4 -4
- package/dist/chakra-ui.umd.js +60 -237
- package/dist/index.cjs +186 -370
- package/dist/index.cjs.map +4 -4
- package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.d.ts +2 -2
- package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js +2 -7
- package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js.map +1 -1
- package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +3 -3
- package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -2
- package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js +8 -2
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/templates/FieldTemplate/FieldTemplate.js +3 -3
- package/lib/templates/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js +2 -2
- package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +2 -9
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/AltDateWidget/AltDateWidget.d.ts +1 -1
- package/lib/widgets/AltDateWidget/AltDateWidget.js +5 -121
- package/lib/widgets/AltDateWidget/AltDateWidget.js.map +1 -1
- package/lib/widgets/CheckboxWidget/CheckboxWidget.js +2 -2
- package/lib/widgets/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js +2 -2
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/widgets/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/widgets/RadioWidget/RadioWidget.js +2 -2
- package/lib/widgets/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/widgets/TextareaWidget/TextareaWidget.js +2 -2
- package/lib/widgets/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/widgets/Widgets.d.ts +1 -2
- package/lib/widgets/Widgets.js +1 -3
- package/lib/widgets/Widgets.js.map +1 -1
- package/package.json +7 -7
- package/src/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.tsx +10 -15
- package/src/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -3
- package/src/templates/ArrayFieldTemplate/ArrayFieldTemplate.tsx +1 -8
- package/src/templates/BaseInputTemplate/BaseInputTemplate.tsx +11 -3
- package/src/templates/FieldTemplate/FieldTemplate.tsx +9 -7
- package/src/templates/ObjectFieldTemplate/ObjectFieldTemplate.tsx +2 -2
- package/src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +5 -16
- package/src/widgets/AltDateWidget/AltDateWidget.tsx +18 -253
- package/src/widgets/CheckboxWidget/CheckboxWidget.tsx +2 -0
- package/src/widgets/CheckboxesWidget/CheckboxesWidget.tsx +2 -1
- package/src/widgets/RadioWidget/RadioWidget.tsx +2 -1
- package/src/widgets/TextareaWidget/TextareaWidget.tsx +2 -1
- package/src/widgets/Widgets.tsx +0 -3
- package/lib/widgets/FileWidget/FileWidget.d.ts +0 -12
- package/lib/widgets/FileWidget/FileWidget.js +0 -57
- package/lib/widgets/FileWidget/FileWidget.js.map +0 -1
- package/lib/widgets/FileWidget/index.d.ts +0 -2
- package/lib/widgets/FileWidget/index.js +0 -3
- package/lib/widgets/FileWidget/index.js.map +0 -1
- package/src/widgets/FileWidget/FileWidget.tsx +0 -86
- package/src/widgets/FileWidget/index.ts +0 -2
package/dist/chakra-ui.esm.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import { withTheme as withTheme2 } from "@rjsf/core";
|
|
3
3
|
|
|
4
4
|
// src/theme/Theme.tsx
|
|
5
|
-
import { createContext, useCallback as
|
|
5
|
+
import { createContext, useCallback as useCallback14, useContext, useState as useState3 } from "react";
|
|
6
6
|
import { getDefaultRegistry } from "@rjsf/core";
|
|
7
7
|
|
|
8
8
|
// src/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.tsx
|
|
9
|
-
import { useMemo } from "react";
|
|
10
9
|
import {
|
|
11
10
|
buttonId
|
|
12
11
|
} from "@rjsf/utils";
|
|
@@ -19,19 +18,15 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
19
18
|
hasMoveUp,
|
|
20
19
|
hasRemove,
|
|
21
20
|
fieldPathId,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
onCopyItem,
|
|
22
|
+
onRemoveItem,
|
|
23
|
+
onMoveDownItem,
|
|
24
|
+
onMoveUpItem,
|
|
26
25
|
readonly,
|
|
27
26
|
registry,
|
|
28
27
|
uiSchema
|
|
29
28
|
} = props;
|
|
30
29
|
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
31
|
-
const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
|
|
32
|
-
const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
33
|
-
const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
34
|
-
const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
35
30
|
const renderMany = [hasMoveUp || hasMoveDown, hasCopy, hasRemove].filter(Boolean).length > 1;
|
|
36
31
|
const btnClass = renderMany ? "join-item btn btn-sm px-2" : "btn btn-sm px-2 rounded-sm";
|
|
37
32
|
const removeBtnClass = renderMany ? "join-item btn btn-sm btn-error px-2" : "btn btn-sm btn-error px-2 rounded-sm";
|
|
@@ -43,7 +38,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
43
38
|
id: buttonId(fieldPathId, "moveUp"),
|
|
44
39
|
className: `rjsf-array-item-move-up ${btnClass}`,
|
|
45
40
|
disabled: disabled || readonly || !hasMoveUp,
|
|
46
|
-
onClick:
|
|
41
|
+
onClick: onMoveUpItem,
|
|
47
42
|
uiSchema,
|
|
48
43
|
registry
|
|
49
44
|
}
|
|
@@ -54,7 +49,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
54
49
|
id: buttonId(fieldPathId, "moveDown"),
|
|
55
50
|
className: `rjsf-array-item-move-down ${btnClass}`,
|
|
56
51
|
disabled: disabled || readonly || !hasMoveDown,
|
|
57
|
-
onClick:
|
|
52
|
+
onClick: onMoveDownItem,
|
|
58
53
|
uiSchema,
|
|
59
54
|
registry
|
|
60
55
|
}
|
|
@@ -66,7 +61,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
66
61
|
id: buttonId(fieldPathId, "copy"),
|
|
67
62
|
className: `rjsf-array-item-copy ${btnClass}`,
|
|
68
63
|
disabled: disabled || readonly,
|
|
69
|
-
onClick:
|
|
64
|
+
onClick: onCopyItem,
|
|
70
65
|
uiSchema,
|
|
71
66
|
registry
|
|
72
67
|
}
|
|
@@ -77,7 +72,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
77
72
|
id: buttonId(fieldPathId, "remove"),
|
|
78
73
|
className: `rjsf-array-item-remove ${removeBtnClass}`,
|
|
79
74
|
disabled: disabled || readonly,
|
|
80
|
-
onClick:
|
|
75
|
+
onClick: onRemoveItem,
|
|
81
76
|
uiSchema,
|
|
82
77
|
registry
|
|
83
78
|
}
|
|
@@ -142,11 +137,6 @@ function ArrayFieldTemplate(props) {
|
|
|
142
137
|
registry,
|
|
143
138
|
uiOptions
|
|
144
139
|
);
|
|
145
|
-
const ArrayFieldItemTemplate2 = getTemplate2(
|
|
146
|
-
"ArrayFieldItemTemplate",
|
|
147
|
-
registry,
|
|
148
|
-
uiOptions
|
|
149
|
-
);
|
|
150
140
|
const ArrayFieldTitleTemplate = getTemplate2(
|
|
151
141
|
"ArrayFieldTitleTemplate",
|
|
152
142
|
registry,
|
|
@@ -190,7 +180,7 @@ function ArrayFieldTemplate(props) {
|
|
|
190
180
|
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-4", children: [
|
|
191
181
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
192
182
|
/* @__PURE__ */ jsxs3("div", { className: "rjsf-array-item-list", children: [
|
|
193
|
-
items
|
|
183
|
+
items,
|
|
194
184
|
items && items.length === 0 && canAdd && /* @__PURE__ */ jsx3("div", { className: "text-center italic text-base-content/70", children: TranslatableString.EmptyArray })
|
|
195
185
|
] }),
|
|
196
186
|
canAdd && /* @__PURE__ */ jsx3("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx3(
|
|
@@ -219,6 +209,8 @@ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-run
|
|
|
219
209
|
function BaseInputTemplate(props) {
|
|
220
210
|
const {
|
|
221
211
|
id,
|
|
212
|
+
htmlName,
|
|
213
|
+
multiple,
|
|
222
214
|
value,
|
|
223
215
|
required,
|
|
224
216
|
disabled,
|
|
@@ -235,6 +227,12 @@ function BaseInputTemplate(props) {
|
|
|
235
227
|
placeholder
|
|
236
228
|
} = props;
|
|
237
229
|
const inputProps = getInputProps(schema, type, options);
|
|
230
|
+
let className = "input input-bordered";
|
|
231
|
+
let isMulti = multiple;
|
|
232
|
+
if (type === "file") {
|
|
233
|
+
isMulti = schema.type === "array" || Boolean(options.multiple);
|
|
234
|
+
className = "file-input w-full";
|
|
235
|
+
}
|
|
238
236
|
const { step, min, max, accept, ...rest } = inputProps;
|
|
239
237
|
const htmlInputProps = { step, min, max, accept, ...schema.examples ? { list: examplesId(id) } : void 0 };
|
|
240
238
|
const _onChange = useCallback2(
|
|
@@ -256,13 +254,14 @@ function BaseInputTemplate(props) {
|
|
|
256
254
|
"input",
|
|
257
255
|
{
|
|
258
256
|
id,
|
|
259
|
-
name: id,
|
|
257
|
+
name: htmlName || id,
|
|
260
258
|
value: value || value === 0 ? value : "",
|
|
261
259
|
placeholder,
|
|
262
260
|
required,
|
|
263
261
|
disabled: disabled || readonly,
|
|
264
262
|
autoFocus: autofocus,
|
|
265
|
-
className
|
|
263
|
+
className,
|
|
264
|
+
multiple: isMulti,
|
|
266
265
|
...rest,
|
|
267
266
|
...htmlInputProps,
|
|
268
267
|
onChange: onChangeOverride || _onChange,
|
|
@@ -438,21 +437,22 @@ function FieldTemplate(props) {
|
|
|
438
437
|
help,
|
|
439
438
|
hideError,
|
|
440
439
|
displayLabel,
|
|
440
|
+
onKeyRename,
|
|
441
|
+
onKeyRenameBlur,
|
|
442
|
+
onRemoveProperty,
|
|
441
443
|
classNames,
|
|
442
|
-
// Destructure props we don't want to pass to div
|
|
443
|
-
description,
|
|
444
|
-
onKeyChange,
|
|
445
|
-
onDropPropertyClick,
|
|
446
444
|
uiSchema,
|
|
447
445
|
schema,
|
|
448
446
|
readonly,
|
|
449
447
|
required,
|
|
448
|
+
registry,
|
|
449
|
+
// Destructure props we don't want to pass to div
|
|
450
|
+
description,
|
|
450
451
|
rawErrors,
|
|
451
452
|
rawHelp,
|
|
452
453
|
rawDescription,
|
|
453
454
|
hidden,
|
|
454
455
|
onChange,
|
|
455
|
-
registry,
|
|
456
456
|
...divProps
|
|
457
457
|
} = props;
|
|
458
458
|
const isCheckbox = schema.type === "boolean";
|
|
@@ -469,8 +469,9 @@ function FieldTemplate(props) {
|
|
|
469
469
|
disabled: divProps.disabled,
|
|
470
470
|
id,
|
|
471
471
|
label,
|
|
472
|
-
|
|
473
|
-
|
|
472
|
+
onKeyRename,
|
|
473
|
+
onKeyRenameBlur,
|
|
474
|
+
onRemoveProperty,
|
|
474
475
|
readonly,
|
|
475
476
|
required,
|
|
476
477
|
schema,
|
|
@@ -532,7 +533,7 @@ function ObjectFieldTemplate(props) {
|
|
|
532
533
|
schema,
|
|
533
534
|
formData,
|
|
534
535
|
optionalDataControl,
|
|
535
|
-
|
|
536
|
+
onAddProperty,
|
|
536
537
|
registry
|
|
537
538
|
} = props;
|
|
538
539
|
const uiOptions = getUiOptions4(uiSchema);
|
|
@@ -587,7 +588,7 @@ function ObjectFieldTemplate(props) {
|
|
|
587
588
|
{
|
|
588
589
|
id: buttonId3(fieldPathId, "add"),
|
|
589
590
|
className: "rjsf-object-property-expand btn btn-primary btn-sm",
|
|
590
|
-
onClick:
|
|
591
|
+
onClick: onAddProperty,
|
|
591
592
|
disabled: disabled || readonly,
|
|
592
593
|
uiSchema,
|
|
593
594
|
registry
|
|
@@ -650,7 +651,6 @@ function TitleField(props) {
|
|
|
650
651
|
}
|
|
651
652
|
|
|
652
653
|
// src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx
|
|
653
|
-
import { useCallback as useCallback3 } from "react";
|
|
654
654
|
import {
|
|
655
655
|
buttonId as buttonId4,
|
|
656
656
|
ADDITIONAL_PROPERTY_FLAG,
|
|
@@ -668,8 +668,9 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
668
668
|
required,
|
|
669
669
|
schema,
|
|
670
670
|
uiSchema,
|
|
671
|
-
|
|
672
|
-
|
|
671
|
+
onKeyRename,
|
|
672
|
+
onKeyRenameBlur,
|
|
673
|
+
onRemoveProperty,
|
|
673
674
|
registry,
|
|
674
675
|
...rest
|
|
675
676
|
} = props;
|
|
@@ -677,15 +678,6 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
677
678
|
const { templates, translateString } = registry;
|
|
678
679
|
const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
|
|
679
680
|
const keyLabel = translateString(TranslatableString4.KeyLabel, [label]);
|
|
680
|
-
const handleBlur = useCallback3(
|
|
681
|
-
(event) => {
|
|
682
|
-
onKeyChange(event.target.value);
|
|
683
|
-
},
|
|
684
|
-
[onKeyChange]
|
|
685
|
-
);
|
|
686
|
-
const handleRemove = useCallback3(() => {
|
|
687
|
-
onDropPropertyClick(label)();
|
|
688
|
-
}, [onDropPropertyClick, label]);
|
|
689
681
|
if (!additional) {
|
|
690
682
|
return /* @__PURE__ */ jsx19("div", { className: classNames, children });
|
|
691
683
|
}
|
|
@@ -698,7 +690,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
698
690
|
type: "text",
|
|
699
691
|
className: "input input-bordered",
|
|
700
692
|
id: `${id}-key`,
|
|
701
|
-
onBlur:
|
|
693
|
+
onBlur: onKeyRenameBlur,
|
|
702
694
|
defaultValue: label,
|
|
703
695
|
disabled: disabled || readonly
|
|
704
696
|
}
|
|
@@ -711,7 +703,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
711
703
|
id: buttonId4(id, "remove"),
|
|
712
704
|
className: "rjsf-object-property-remove",
|
|
713
705
|
disabled: disabled || readonly,
|
|
714
|
-
onClick:
|
|
706
|
+
onClick: onRemoveProperty,
|
|
715
707
|
uiSchema,
|
|
716
708
|
registry
|
|
717
709
|
}
|
|
@@ -761,163 +753,35 @@ function AltDateTimeWidget({
|
|
|
761
753
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
762
754
|
|
|
763
755
|
// src/widgets/AltDateWidget/AltDateWidget.tsx
|
|
764
|
-
import { useCallback as useCallback4, useEffect, useReducer, useState } from "react";
|
|
765
756
|
import {
|
|
766
|
-
|
|
757
|
+
DateElement,
|
|
767
758
|
TranslatableString as TranslatableString5,
|
|
768
|
-
|
|
769
|
-
toDateString,
|
|
770
|
-
dateRangeOptions
|
|
759
|
+
useAltDateWidgetProps
|
|
771
760
|
} from "@rjsf/utils";
|
|
772
761
|
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
773
|
-
function
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
value: state[key],
|
|
786
|
-
range: key === "year" ? rangeOptions : key === "month" ? [1, 12] : key === "day" ? [1, 31] : [0, 59]
|
|
787
|
-
}));
|
|
788
|
-
if (time) {
|
|
789
|
-
dateElements.push(
|
|
790
|
-
{ type: "hour", value: state.hour, range: [0, 23] },
|
|
791
|
-
{ type: "minute", value: state.minute, range: [0, 59] },
|
|
792
|
-
{ type: "second", value: state.second, range: [0, 59] }
|
|
793
|
-
);
|
|
794
|
-
}
|
|
795
|
-
return dateElements;
|
|
796
|
-
}
|
|
797
|
-
function DateElement({
|
|
798
|
-
type,
|
|
799
|
-
range,
|
|
800
|
-
value,
|
|
801
|
-
select,
|
|
802
|
-
rootId,
|
|
803
|
-
name,
|
|
804
|
-
disabled,
|
|
805
|
-
readonly,
|
|
806
|
-
autofocus,
|
|
807
|
-
registry,
|
|
808
|
-
onBlur,
|
|
809
|
-
onFocus
|
|
810
|
-
}) {
|
|
811
|
-
const id = `${rootId}_${type}`;
|
|
812
|
-
const { SelectWidget: SelectWidget2 } = registry.widgets;
|
|
813
|
-
const handleChange = useCallback4(
|
|
814
|
-
(value2) => {
|
|
815
|
-
select(type, value2);
|
|
816
|
-
},
|
|
817
|
-
[select, type]
|
|
818
|
-
);
|
|
819
|
-
return /* @__PURE__ */ jsx21(
|
|
820
|
-
SelectWidget2,
|
|
821
|
-
{
|
|
822
|
-
schema: { type: "integer" },
|
|
823
|
-
id,
|
|
824
|
-
name,
|
|
825
|
-
className: "select select-bordered select-sm w-full",
|
|
826
|
-
options: { enumOptions: dateRangeOptions(range[0], range[1]) },
|
|
827
|
-
placeholder: type,
|
|
828
|
-
value,
|
|
829
|
-
disabled,
|
|
830
|
-
readonly,
|
|
831
|
-
autofocus,
|
|
832
|
-
onChange: handleChange,
|
|
833
|
-
onBlur,
|
|
834
|
-
onFocus,
|
|
835
|
-
registry,
|
|
836
|
-
label: "",
|
|
837
|
-
"aria-describedby": ariaDescribedByIds2(rootId),
|
|
838
|
-
required: false
|
|
839
|
-
}
|
|
840
|
-
);
|
|
841
|
-
}
|
|
842
|
-
function convertToRJSFDateObject(dateObj) {
|
|
843
|
-
return {
|
|
844
|
-
year: dateObj.year ? parseInt(dateObj.year) : 0,
|
|
845
|
-
month: dateObj.month ? parseInt(dateObj.month) : 0,
|
|
846
|
-
day: dateObj.day ? parseInt(dateObj.day) : 0,
|
|
847
|
-
hour: dateObj.hour ? parseInt(dateObj.hour) : 0,
|
|
848
|
-
minute: dateObj.minute ? parseInt(dateObj.minute) : 0,
|
|
849
|
-
second: dateObj.second ? parseInt(dateObj.second) : 0
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
function AltDateWidget({
|
|
853
|
-
time = false,
|
|
854
|
-
disabled = false,
|
|
855
|
-
readonly = false,
|
|
856
|
-
autofocus = false,
|
|
857
|
-
options = {},
|
|
858
|
-
id,
|
|
859
|
-
name,
|
|
860
|
-
registry,
|
|
861
|
-
onBlur,
|
|
862
|
-
onFocus,
|
|
863
|
-
onChange,
|
|
864
|
-
value
|
|
865
|
-
}) {
|
|
762
|
+
function AltDateWidget(props) {
|
|
763
|
+
const {
|
|
764
|
+
disabled = false,
|
|
765
|
+
readonly = false,
|
|
766
|
+
autofocus = false,
|
|
767
|
+
options = {},
|
|
768
|
+
id,
|
|
769
|
+
name,
|
|
770
|
+
registry,
|
|
771
|
+
onBlur,
|
|
772
|
+
onFocus
|
|
773
|
+
} = props;
|
|
866
774
|
const { translateString } = registry;
|
|
867
|
-
const
|
|
868
|
-
const initialState = parseDateString(value, time);
|
|
869
|
-
const dateReducer = (state2, action) => {
|
|
870
|
-
return { ...state2, ...action };
|
|
871
|
-
};
|
|
872
|
-
const [state, setState] = useReducer(dateReducer, initialState);
|
|
873
|
-
useEffect(() => {
|
|
874
|
-
const rjsfDateObj = convertToRJSFDateObject(state);
|
|
875
|
-
const stateValue = toDateString(rjsfDateObj, time);
|
|
876
|
-
if (readyForChange(state, time) && stateValue !== value) {
|
|
877
|
-
onChange(stateValue);
|
|
878
|
-
} else if (lastValue !== value) {
|
|
879
|
-
setLastValue(value);
|
|
880
|
-
setState(parseDateString(value, time));
|
|
881
|
-
}
|
|
882
|
-
}, [time, value, onChange, state, lastValue]);
|
|
883
|
-
const handleChange = useCallback4((property, value2) => {
|
|
884
|
-
setState({ [property]: value2 });
|
|
885
|
-
}, []);
|
|
886
|
-
const handleSetNow = useCallback4(
|
|
887
|
-
(event) => {
|
|
888
|
-
event.preventDefault();
|
|
889
|
-
if (disabled || readonly) {
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), time);
|
|
893
|
-
const rjsfDateObj = convertToRJSFDateObject(nextState);
|
|
894
|
-
onChange(toDateString(rjsfDateObj, time));
|
|
895
|
-
},
|
|
896
|
-
[disabled, readonly, time, onChange]
|
|
897
|
-
);
|
|
898
|
-
const handleClear = useCallback4(
|
|
899
|
-
(event) => {
|
|
900
|
-
event.preventDefault();
|
|
901
|
-
if (disabled || readonly) {
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
onChange(void 0);
|
|
905
|
-
},
|
|
906
|
-
[disabled, readonly, onChange]
|
|
907
|
-
);
|
|
775
|
+
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps(props);
|
|
908
776
|
return /* @__PURE__ */ jsxs10("div", { className: "space-y-3", children: [
|
|
909
|
-
/* @__PURE__ */ jsx21("div", { className: "grid grid-cols-3 gap-2", children:
|
|
910
|
-
state,
|
|
911
|
-
time,
|
|
912
|
-
options.yearsRange,
|
|
913
|
-
options.format
|
|
914
|
-
).map((elemProps, i) => /* @__PURE__ */ jsxs10("div", { className: "form-control", children: [
|
|
777
|
+
/* @__PURE__ */ jsx21("div", { className: "grid grid-cols-3 gap-2", children: elements.map((elemProps, i) => /* @__PURE__ */ jsxs10("div", { className: "form-control", children: [
|
|
915
778
|
/* @__PURE__ */ jsx21("label", { className: "label", children: /* @__PURE__ */ jsx21("span", { className: "label-text capitalize", children: elemProps.type }) }),
|
|
916
779
|
/* @__PURE__ */ jsx21(
|
|
917
780
|
DateElement,
|
|
918
781
|
{
|
|
919
782
|
rootId: id,
|
|
920
783
|
name,
|
|
784
|
+
className: "select select-bordered select-sm",
|
|
921
785
|
select: handleChange,
|
|
922
786
|
type: elemProps.type,
|
|
923
787
|
range: elemProps.range,
|
|
@@ -957,12 +821,13 @@ function AltDateWidget({
|
|
|
957
821
|
}
|
|
958
822
|
|
|
959
823
|
// src/widgets/CheckboxWidget/CheckboxWidget.tsx
|
|
960
|
-
import { useCallback as
|
|
824
|
+
import { useCallback as useCallback3 } from "react";
|
|
961
825
|
import { getTemplate as getTemplate5, descriptionId as descriptionId2 } from "@rjsf/utils";
|
|
962
826
|
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
963
827
|
function CheckboxWidget(props) {
|
|
964
828
|
const {
|
|
965
829
|
id,
|
|
830
|
+
htmlName,
|
|
966
831
|
value,
|
|
967
832
|
required,
|
|
968
833
|
disabled,
|
|
@@ -983,17 +848,17 @@ function CheckboxWidget(props) {
|
|
|
983
848
|
options
|
|
984
849
|
);
|
|
985
850
|
const description = options.description || schema.description;
|
|
986
|
-
const handleFocus =
|
|
851
|
+
const handleFocus = useCallback3(() => {
|
|
987
852
|
if (onFocus) {
|
|
988
853
|
onFocus(id, value);
|
|
989
854
|
}
|
|
990
855
|
}, [onFocus, id, value]);
|
|
991
|
-
const handleBlur =
|
|
856
|
+
const handleBlur = useCallback3(() => {
|
|
992
857
|
if (onBlur) {
|
|
993
858
|
onBlur(id, value);
|
|
994
859
|
}
|
|
995
860
|
}, [onBlur, id, value]);
|
|
996
|
-
const handleChange =
|
|
861
|
+
const handleChange = useCallback3(
|
|
997
862
|
(event) => {
|
|
998
863
|
onChange(event.target.checked);
|
|
999
864
|
},
|
|
@@ -1004,6 +869,7 @@ function CheckboxWidget(props) {
|
|
|
1004
869
|
{
|
|
1005
870
|
type: "checkbox",
|
|
1006
871
|
id,
|
|
872
|
+
name: htmlName || id,
|
|
1007
873
|
checked: value,
|
|
1008
874
|
required,
|
|
1009
875
|
disabled: disabled || readonly,
|
|
@@ -1035,10 +901,11 @@ function CheckboxWidget(props) {
|
|
|
1035
901
|
}
|
|
1036
902
|
|
|
1037
903
|
// src/widgets/CheckboxesWidget/CheckboxesWidget.tsx
|
|
1038
|
-
import { useCallback as
|
|
904
|
+
import { useCallback as useCallback4 } from "react";
|
|
1039
905
|
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1040
906
|
function CheckboxesWidget({
|
|
1041
907
|
id,
|
|
908
|
+
htmlName,
|
|
1042
909
|
disabled,
|
|
1043
910
|
options,
|
|
1044
911
|
value,
|
|
@@ -1050,7 +917,7 @@ function CheckboxesWidget({
|
|
|
1050
917
|
}) {
|
|
1051
918
|
const { enumOptions } = options;
|
|
1052
919
|
const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
|
|
1053
|
-
const isChecked =
|
|
920
|
+
const isChecked = useCallback4(
|
|
1054
921
|
(option) => {
|
|
1055
922
|
if (!Array.isArray(value)) {
|
|
1056
923
|
return false;
|
|
@@ -1062,7 +929,7 @@ function CheckboxesWidget({
|
|
|
1062
929
|
},
|
|
1063
930
|
[value, isEnumeratedObject]
|
|
1064
931
|
);
|
|
1065
|
-
const handleChange =
|
|
932
|
+
const handleChange = useCallback4(
|
|
1066
933
|
(event) => {
|
|
1067
934
|
const index = Number(event.target.dataset.index);
|
|
1068
935
|
const option = enumOptions?.[index];
|
|
@@ -1079,7 +946,7 @@ function CheckboxesWidget({
|
|
|
1079
946
|
},
|
|
1080
947
|
[onChange, value, isChecked, isEnumeratedObject, enumOptions]
|
|
1081
948
|
);
|
|
1082
|
-
const handleFocus =
|
|
949
|
+
const handleFocus = useCallback4(
|
|
1083
950
|
(event) => {
|
|
1084
951
|
if (onFocus) {
|
|
1085
952
|
const index = Number(event.target.dataset.index);
|
|
@@ -1091,7 +958,7 @@ function CheckboxesWidget({
|
|
|
1091
958
|
},
|
|
1092
959
|
[onFocus, id, enumOptions]
|
|
1093
960
|
);
|
|
1094
|
-
const handleBlur =
|
|
961
|
+
const handleBlur = useCallback4(
|
|
1095
962
|
(event) => {
|
|
1096
963
|
if (onBlur) {
|
|
1097
964
|
const index = Number(event.target.dataset.index);
|
|
@@ -1110,7 +977,7 @@ function CheckboxesWidget({
|
|
|
1110
977
|
type: "checkbox",
|
|
1111
978
|
id: `${id}-${option.value}`,
|
|
1112
979
|
className: "checkbox",
|
|
1113
|
-
name: id,
|
|
980
|
+
name: htmlName || id,
|
|
1114
981
|
checked: isChecked(option),
|
|
1115
982
|
required,
|
|
1116
983
|
disabled: disabled || readonly,
|
|
@@ -1125,7 +992,7 @@ function CheckboxesWidget({
|
|
|
1125
992
|
}
|
|
1126
993
|
|
|
1127
994
|
// src/widgets/DateTimeWidget/DateTimeWidget.tsx
|
|
1128
|
-
import { memo as memo2, useCallback as
|
|
995
|
+
import { memo as memo2, useCallback as useCallback5, useEffect, useMemo, useRef, useState } from "react";
|
|
1129
996
|
import { faCalendar } from "@fortawesome/free-solid-svg-icons";
|
|
1130
997
|
import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
|
|
1131
998
|
import { format, isSameDay, isToday, isValid } from "date-fns";
|
|
@@ -1133,12 +1000,12 @@ import { DayPicker, UI } from "react-day-picker";
|
|
|
1133
1000
|
import "react-day-picker/dist/style.css";
|
|
1134
1001
|
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1135
1002
|
function useDatePickerState(initialDate) {
|
|
1136
|
-
const [isOpen, setIsOpen] =
|
|
1137
|
-
const [month, setMonth] =
|
|
1003
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
1004
|
+
const [month, setMonth] = useState(initialDate ?? /* @__PURE__ */ new Date());
|
|
1138
1005
|
return { isOpen, setIsOpen, month, setMonth };
|
|
1139
1006
|
}
|
|
1140
1007
|
function useClickOutside(ref, callback) {
|
|
1141
|
-
|
|
1008
|
+
useEffect(() => {
|
|
1142
1009
|
const handleClickOutside = (event) => {
|
|
1143
1010
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1144
1011
|
callback();
|
|
@@ -1183,7 +1050,7 @@ function DateTimePickerPopup({ selectedDate, month, onMonthChange, onSelect, onT
|
|
|
1183
1050
|
...dayPickerStyles.modifiers,
|
|
1184
1051
|
"custom-today": "btn btn-outline btn-info min-h-0 h-full"
|
|
1185
1052
|
};
|
|
1186
|
-
const handleClick =
|
|
1053
|
+
const handleClick = useCallback5((e) => {
|
|
1187
1054
|
e.stopPropagation();
|
|
1188
1055
|
}, []);
|
|
1189
1056
|
return /* @__PURE__ */ jsxs13("div", { className: "p-3", children: [
|
|
@@ -1222,9 +1089,9 @@ function DateTimePickerPopup({ selectedDate, month, onMonthChange, onSelect, onT
|
|
|
1222
1089
|
var MemoizedDateTimePickerPopup = memo2(DateTimePickerPopup);
|
|
1223
1090
|
function DateTimeWidget(props) {
|
|
1224
1091
|
const { id, value, onChange, onFocus, onBlur, schema } = props;
|
|
1225
|
-
const initialDate =
|
|
1226
|
-
const [localDate, setLocalDate] =
|
|
1227
|
-
|
|
1092
|
+
const initialDate = useMemo(() => value ? new Date(value) : void 0, [value]);
|
|
1093
|
+
const [localDate, setLocalDate] = useState(initialDate);
|
|
1094
|
+
useEffect(() => {
|
|
1228
1095
|
setLocalDate(initialDate);
|
|
1229
1096
|
}, [initialDate]);
|
|
1230
1097
|
const { isOpen, setIsOpen, month, setMonth } = useDatePickerState(initialDate);
|
|
@@ -1239,13 +1106,13 @@ function DateTimeWidget(props) {
|
|
|
1239
1106
|
}
|
|
1240
1107
|
}
|
|
1241
1108
|
});
|
|
1242
|
-
|
|
1109
|
+
useEffect(() => {
|
|
1243
1110
|
if (localDate) {
|
|
1244
1111
|
setMonth(localDate);
|
|
1245
1112
|
}
|
|
1246
1113
|
}, [localDate, setMonth]);
|
|
1247
|
-
const handleMonthChange =
|
|
1248
|
-
const handleSelect =
|
|
1114
|
+
const handleMonthChange = useCallback5((date) => setMonth(date), [setMonth]);
|
|
1115
|
+
const handleSelect = useCallback5(
|
|
1249
1116
|
(date) => {
|
|
1250
1117
|
if (date) {
|
|
1251
1118
|
if (localDate) {
|
|
@@ -1256,7 +1123,7 @@ function DateTimeWidget(props) {
|
|
|
1256
1123
|
},
|
|
1257
1124
|
[localDate]
|
|
1258
1125
|
);
|
|
1259
|
-
const handleTimeChange =
|
|
1126
|
+
const handleTimeChange = useCallback5(
|
|
1260
1127
|
(e) => {
|
|
1261
1128
|
if (localDate) {
|
|
1262
1129
|
const [hours, minutes] = e.target.value.split(":");
|
|
@@ -1267,7 +1134,7 @@ function DateTimeWidget(props) {
|
|
|
1267
1134
|
},
|
|
1268
1135
|
[localDate]
|
|
1269
1136
|
);
|
|
1270
|
-
const togglePicker =
|
|
1137
|
+
const togglePicker = useCallback5(
|
|
1271
1138
|
(e) => {
|
|
1272
1139
|
e.stopPropagation();
|
|
1273
1140
|
setIsOpen((prev) => !prev);
|
|
@@ -1277,17 +1144,17 @@ function DateTimeWidget(props) {
|
|
|
1277
1144
|
},
|
|
1278
1145
|
[isOpen, id, onFocus, setIsOpen, value]
|
|
1279
1146
|
);
|
|
1280
|
-
const handleFocus =
|
|
1147
|
+
const handleFocus = useCallback5(() => {
|
|
1281
1148
|
if (onFocus) {
|
|
1282
1149
|
onFocus(id, value);
|
|
1283
1150
|
}
|
|
1284
1151
|
}, [id, onFocus, value]);
|
|
1285
|
-
const handleBlur =
|
|
1152
|
+
const handleBlur = useCallback5(() => {
|
|
1286
1153
|
if (!isOpen && onBlur) {
|
|
1287
1154
|
onBlur(id, value);
|
|
1288
1155
|
}
|
|
1289
1156
|
}, [id, onBlur, value, isOpen]);
|
|
1290
|
-
const handleKeyDown =
|
|
1157
|
+
const handleKeyDown = useCallback5(
|
|
1291
1158
|
(e) => {
|
|
1292
1159
|
if (e.key === "Enter" || e.key === " ") {
|
|
1293
1160
|
togglePicker(e);
|
|
@@ -1295,10 +1162,10 @@ function DateTimeWidget(props) {
|
|
|
1295
1162
|
},
|
|
1296
1163
|
[togglePicker]
|
|
1297
1164
|
);
|
|
1298
|
-
const handleContainerClick =
|
|
1165
|
+
const handleContainerClick = useCallback5((e) => {
|
|
1299
1166
|
e.stopPropagation();
|
|
1300
1167
|
}, []);
|
|
1301
|
-
|
|
1168
|
+
useEffect(() => {
|
|
1302
1169
|
const handleEscape = (e) => {
|
|
1303
1170
|
if (e.key === "Escape" && isOpen) {
|
|
1304
1171
|
setIsOpen(false);
|
|
@@ -1310,7 +1177,7 @@ function DateTimeWidget(props) {
|
|
|
1310
1177
|
document.addEventListener("keydown", handleEscape);
|
|
1311
1178
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
1312
1179
|
}, [id, isOpen, setIsOpen, onBlur, value]);
|
|
1313
|
-
const handleDoneClick =
|
|
1180
|
+
const handleDoneClick = useCallback5(() => {
|
|
1314
1181
|
setIsOpen(false);
|
|
1315
1182
|
onChange(localDate ? localDate.toISOString() : "");
|
|
1316
1183
|
if (onBlur) {
|
|
@@ -1371,7 +1238,7 @@ function DateTimeWidget(props) {
|
|
|
1371
1238
|
}
|
|
1372
1239
|
|
|
1373
1240
|
// src/widgets/DateWidget/DateWidget.tsx
|
|
1374
|
-
import { memo as memo3, useCallback as
|
|
1241
|
+
import { memo as memo3, useCallback as useCallback6, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
1375
1242
|
import { faCalendar as faCalendar2 } from "@fortawesome/free-solid-svg-icons";
|
|
1376
1243
|
import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
|
|
1377
1244
|
import { format as format2, isSameDay as isSameDay2, isToday as isToday2, isValid as isValid2 } from "date-fns";
|
|
@@ -1379,12 +1246,12 @@ import { DayPicker as DayPicker2, UI as UI2 } from "react-day-picker";
|
|
|
1379
1246
|
import "react-day-picker/dist/style.css";
|
|
1380
1247
|
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1381
1248
|
function useDatePickerState2(initialDate) {
|
|
1382
|
-
const [isOpen, setIsOpen] =
|
|
1383
|
-
const [month, setMonth] =
|
|
1249
|
+
const [isOpen, setIsOpen] = useState2(false);
|
|
1250
|
+
const [month, setMonth] = useState2(initialDate ?? /* @__PURE__ */ new Date());
|
|
1384
1251
|
return { isOpen, setIsOpen, month, setMonth };
|
|
1385
1252
|
}
|
|
1386
1253
|
function useClickOutside2(ref, callback) {
|
|
1387
|
-
|
|
1254
|
+
useEffect2(() => {
|
|
1388
1255
|
const handleClickOutside = (event) => {
|
|
1389
1256
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1390
1257
|
callback();
|
|
@@ -1450,9 +1317,9 @@ function DatePickerPopup({ selectedDate, month, onMonthChange, onSelect }) {
|
|
|
1450
1317
|
var MemoizedDatePickerPopup = memo3(DatePickerPopup);
|
|
1451
1318
|
function DateWidget(props) {
|
|
1452
1319
|
const { id, value, onChange, onFocus, onBlur, schema } = props;
|
|
1453
|
-
const initialDate =
|
|
1454
|
-
const [localDate, setLocalDate] =
|
|
1455
|
-
|
|
1320
|
+
const initialDate = useMemo2(() => value ? new Date(value) : void 0, [value]);
|
|
1321
|
+
const [localDate, setLocalDate] = useState2(initialDate);
|
|
1322
|
+
useEffect2(() => {
|
|
1456
1323
|
setLocalDate(initialDate);
|
|
1457
1324
|
}, [initialDate]);
|
|
1458
1325
|
const { isOpen, setIsOpen, month, setMonth } = useDatePickerState2(initialDate);
|
|
@@ -1467,19 +1334,19 @@ function DateWidget(props) {
|
|
|
1467
1334
|
}
|
|
1468
1335
|
}
|
|
1469
1336
|
});
|
|
1470
|
-
|
|
1337
|
+
useEffect2(() => {
|
|
1471
1338
|
if (localDate) {
|
|
1472
1339
|
setMonth(localDate);
|
|
1473
1340
|
}
|
|
1474
1341
|
}, [localDate, setMonth]);
|
|
1475
|
-
const handleMonthChange =
|
|
1476
|
-
const handleSelect =
|
|
1342
|
+
const handleMonthChange = useCallback6((date) => setMonth(date), [setMonth]);
|
|
1343
|
+
const handleSelect = useCallback6((date) => {
|
|
1477
1344
|
if (date) {
|
|
1478
1345
|
date.setHours(0, 0, 0, 0);
|
|
1479
1346
|
setLocalDate(date);
|
|
1480
1347
|
}
|
|
1481
1348
|
}, []);
|
|
1482
|
-
|
|
1349
|
+
useEffect2(() => {
|
|
1483
1350
|
let portalContainer = document.getElementById("date-picker-portal");
|
|
1484
1351
|
if (!portalContainer) {
|
|
1485
1352
|
portalContainer = document.createElement("div");
|
|
@@ -1511,7 +1378,7 @@ function DateWidget(props) {
|
|
|
1511
1378
|
}
|
|
1512
1379
|
return { doc, win };
|
|
1513
1380
|
};
|
|
1514
|
-
const renderCalendar =
|
|
1381
|
+
const renderCalendar = useCallback6(() => {
|
|
1515
1382
|
if (!containerRef.current || !inputRef.current) {
|
|
1516
1383
|
return;
|
|
1517
1384
|
}
|
|
@@ -1529,7 +1396,7 @@ function DateWidget(props) {
|
|
|
1529
1396
|
}
|
|
1530
1397
|
containerRef.current.style.zIndex = "99999";
|
|
1531
1398
|
}, [containerRef, inputRef]);
|
|
1532
|
-
|
|
1399
|
+
useEffect2(() => {
|
|
1533
1400
|
if (!isOpen) {
|
|
1534
1401
|
return;
|
|
1535
1402
|
}
|
|
@@ -1541,7 +1408,7 @@ function DateWidget(props) {
|
|
|
1541
1408
|
window.removeEventListener("scroll", renderCalendar);
|
|
1542
1409
|
};
|
|
1543
1410
|
}, [isOpen, renderCalendar]);
|
|
1544
|
-
const togglePicker =
|
|
1411
|
+
const togglePicker = useCallback6(
|
|
1545
1412
|
(e) => {
|
|
1546
1413
|
e.stopPropagation();
|
|
1547
1414
|
setIsOpen((prev) => !prev);
|
|
@@ -1551,17 +1418,17 @@ function DateWidget(props) {
|
|
|
1551
1418
|
},
|
|
1552
1419
|
[isOpen, id, onFocus, setIsOpen, value]
|
|
1553
1420
|
);
|
|
1554
|
-
const handleFocus =
|
|
1421
|
+
const handleFocus = useCallback6(() => {
|
|
1555
1422
|
if (onFocus) {
|
|
1556
1423
|
onFocus(id, value);
|
|
1557
1424
|
}
|
|
1558
1425
|
}, [id, onFocus, value]);
|
|
1559
|
-
const handleBlur =
|
|
1426
|
+
const handleBlur = useCallback6(() => {
|
|
1560
1427
|
if (!isOpen && onBlur) {
|
|
1561
1428
|
onBlur(id, value);
|
|
1562
1429
|
}
|
|
1563
1430
|
}, [id, onBlur, value, isOpen]);
|
|
1564
|
-
|
|
1431
|
+
useEffect2(() => {
|
|
1565
1432
|
const handleEscape = (e) => {
|
|
1566
1433
|
if (e.key === "Escape" && isOpen) {
|
|
1567
1434
|
setIsOpen(false);
|
|
@@ -1573,7 +1440,7 @@ function DateWidget(props) {
|
|
|
1573
1440
|
document.addEventListener("keydown", handleEscape);
|
|
1574
1441
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
1575
1442
|
}, [id, isOpen, setIsOpen, onBlur, value]);
|
|
1576
|
-
const handleDoneClick =
|
|
1443
|
+
const handleDoneClick = useCallback6(() => {
|
|
1577
1444
|
setIsOpen(false);
|
|
1578
1445
|
onChange(localDate ? localDate.toISOString() : "");
|
|
1579
1446
|
if (onBlur) {
|
|
@@ -1640,65 +1507,12 @@ function DateWidget(props) {
|
|
|
1640
1507
|
) });
|
|
1641
1508
|
}
|
|
1642
1509
|
|
|
1643
|
-
// src/widgets/FileWidget/FileWidget.tsx
|
|
1644
|
-
import { useCallback as useCallback9 } from "react";
|
|
1645
|
-
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
1646
|
-
function FileWidget(props) {
|
|
1647
|
-
const { id, required, disabled, readonly, schema, onChange, onFocus, onBlur, options = {} } = props;
|
|
1648
|
-
const isMulti = schema.type === "array" || Boolean(options.multiple);
|
|
1649
|
-
const accept = typeof options.accept === "string" ? options.accept : void 0;
|
|
1650
|
-
const handleChange = useCallback9(
|
|
1651
|
-
(event) => {
|
|
1652
|
-
if (!event.target.files) {
|
|
1653
|
-
return;
|
|
1654
|
-
}
|
|
1655
|
-
const fileList = Array.from(event.target.files);
|
|
1656
|
-
if (isMulti) {
|
|
1657
|
-
onChange(fileList);
|
|
1658
|
-
} else {
|
|
1659
|
-
onChange(fileList[0] || null);
|
|
1660
|
-
}
|
|
1661
|
-
},
|
|
1662
|
-
[onChange, isMulti]
|
|
1663
|
-
);
|
|
1664
|
-
const handleFocus = useCallback9(
|
|
1665
|
-
(event) => {
|
|
1666
|
-
if (onFocus) {
|
|
1667
|
-
onFocus(id, event.target.files ? Array.from(event.target.files) : null);
|
|
1668
|
-
}
|
|
1669
|
-
},
|
|
1670
|
-
[onFocus, id]
|
|
1671
|
-
);
|
|
1672
|
-
const handleBlur = useCallback9(
|
|
1673
|
-
(event) => {
|
|
1674
|
-
if (onBlur) {
|
|
1675
|
-
onBlur(id, event.target.files ? Array.from(event.target.files) : null);
|
|
1676
|
-
}
|
|
1677
|
-
},
|
|
1678
|
-
[onBlur, id]
|
|
1679
|
-
);
|
|
1680
|
-
return /* @__PURE__ */ jsx26(
|
|
1681
|
-
"input",
|
|
1682
|
-
{
|
|
1683
|
-
id,
|
|
1684
|
-
type: "file",
|
|
1685
|
-
className: "file-input w-full",
|
|
1686
|
-
required,
|
|
1687
|
-
disabled: disabled || readonly,
|
|
1688
|
-
onChange: handleChange,
|
|
1689
|
-
onFocus: handleFocus,
|
|
1690
|
-
onBlur: handleBlur,
|
|
1691
|
-
multiple: isMulti,
|
|
1692
|
-
accept
|
|
1693
|
-
}
|
|
1694
|
-
);
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
1510
|
// src/widgets/RadioWidget/RadioWidget.tsx
|
|
1698
|
-
import { useCallback as
|
|
1699
|
-
import { jsx as
|
|
1511
|
+
import { useCallback as useCallback7 } from "react";
|
|
1512
|
+
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1700
1513
|
function RadioWidget({
|
|
1701
1514
|
id,
|
|
1515
|
+
htmlName,
|
|
1702
1516
|
options,
|
|
1703
1517
|
value,
|
|
1704
1518
|
required,
|
|
@@ -1719,7 +1533,7 @@ function RadioWidget({
|
|
|
1719
1533
|
}
|
|
1720
1534
|
return value === option.value;
|
|
1721
1535
|
};
|
|
1722
|
-
const handleFocus =
|
|
1536
|
+
const handleFocus = useCallback7(
|
|
1723
1537
|
(event) => {
|
|
1724
1538
|
if (onFocus) {
|
|
1725
1539
|
const index = Number(event.target.dataset.index);
|
|
@@ -1729,7 +1543,7 @@ function RadioWidget({
|
|
|
1729
1543
|
},
|
|
1730
1544
|
[onFocus, id, enumOptions]
|
|
1731
1545
|
);
|
|
1732
|
-
const handleBlur =
|
|
1546
|
+
const handleBlur = useCallback7(
|
|
1733
1547
|
(event) => {
|
|
1734
1548
|
if (onBlur) {
|
|
1735
1549
|
const index = Number(event.target.dataset.index);
|
|
@@ -1739,7 +1553,7 @@ function RadioWidget({
|
|
|
1739
1553
|
},
|
|
1740
1554
|
[onBlur, id, enumOptions]
|
|
1741
1555
|
);
|
|
1742
|
-
const handleChange =
|
|
1556
|
+
const handleChange = useCallback7(
|
|
1743
1557
|
(event) => {
|
|
1744
1558
|
const index = Number(event.target.dataset.index);
|
|
1745
1559
|
const option = enumOptions?.[index];
|
|
@@ -1750,14 +1564,14 @@ function RadioWidget({
|
|
|
1750
1564
|
},
|
|
1751
1565
|
[onChange, isEnumeratedObject, enumOptions]
|
|
1752
1566
|
);
|
|
1753
|
-
return /* @__PURE__ */
|
|
1754
|
-
/* @__PURE__ */
|
|
1567
|
+
return /* @__PURE__ */ jsx26("div", { className: "form-control", children: /* @__PURE__ */ jsx26("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxs15("label", { className: "flex items-center cursor-pointer gap-2", children: [
|
|
1568
|
+
/* @__PURE__ */ jsx26(
|
|
1755
1569
|
"input",
|
|
1756
1570
|
{
|
|
1757
1571
|
type: "radio",
|
|
1758
1572
|
id: `${id}-${option.value}`,
|
|
1759
1573
|
className: "radio",
|
|
1760
|
-
name: id,
|
|
1574
|
+
name: htmlName || id,
|
|
1761
1575
|
value: getValue(option),
|
|
1762
1576
|
checked: isChecked(option),
|
|
1763
1577
|
required,
|
|
@@ -1768,13 +1582,13 @@ function RadioWidget({
|
|
|
1768
1582
|
onBlur: handleBlur
|
|
1769
1583
|
}
|
|
1770
1584
|
),
|
|
1771
|
-
/* @__PURE__ */
|
|
1585
|
+
/* @__PURE__ */ jsx26("span", { className: "label-text", children: option.label })
|
|
1772
1586
|
] }, option.value)) }) });
|
|
1773
1587
|
}
|
|
1774
1588
|
|
|
1775
1589
|
// src/widgets/RangeWidget/RangeWidget.tsx
|
|
1776
|
-
import { useCallback as
|
|
1777
|
-
import { jsx as
|
|
1590
|
+
import { useCallback as useCallback8 } from "react";
|
|
1591
|
+
import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1778
1592
|
function RangeWidget({
|
|
1779
1593
|
id,
|
|
1780
1594
|
value,
|
|
@@ -1796,14 +1610,14 @@ function RangeWidget({
|
|
|
1796
1610
|
onBlur(id, event.target.value);
|
|
1797
1611
|
}
|
|
1798
1612
|
};
|
|
1799
|
-
const handleChange =
|
|
1613
|
+
const handleChange = useCallback8(
|
|
1800
1614
|
(event) => {
|
|
1801
1615
|
onChange(event.target.value);
|
|
1802
1616
|
},
|
|
1803
1617
|
[onChange]
|
|
1804
1618
|
);
|
|
1805
|
-
return /* @__PURE__ */
|
|
1806
|
-
/* @__PURE__ */
|
|
1619
|
+
return /* @__PURE__ */ jsx27("div", { className: "form-control", children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center", children: [
|
|
1620
|
+
/* @__PURE__ */ jsx27(
|
|
1807
1621
|
"input",
|
|
1808
1622
|
{
|
|
1809
1623
|
type: "range",
|
|
@@ -1820,13 +1634,13 @@ function RangeWidget({
|
|
|
1820
1634
|
onBlur: handleBlur
|
|
1821
1635
|
}
|
|
1822
1636
|
),
|
|
1823
|
-
/* @__PURE__ */
|
|
1637
|
+
/* @__PURE__ */ jsx27("span", { className: "label-text ml-4", children: value })
|
|
1824
1638
|
] }) });
|
|
1825
1639
|
}
|
|
1826
1640
|
|
|
1827
1641
|
// src/widgets/RatingWidget/RatingWidget.tsx
|
|
1828
|
-
import { useCallback as
|
|
1829
|
-
import { jsx as
|
|
1642
|
+
import { useCallback as useCallback9 } from "react";
|
|
1643
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1830
1644
|
function RatingWidget({
|
|
1831
1645
|
id,
|
|
1832
1646
|
value,
|
|
@@ -1845,13 +1659,13 @@ function RatingWidget({
|
|
|
1845
1659
|
const min = schema.minimum || 0;
|
|
1846
1660
|
const maskClass = shape === "heart" ? "mask-heart" : "mask-star-2";
|
|
1847
1661
|
const sizeClass = size === "md" ? "" : `rating-${size}`;
|
|
1848
|
-
const _onChange =
|
|
1662
|
+
const _onChange = useCallback9(
|
|
1849
1663
|
({ target: { value: value2 } }) => {
|
|
1850
1664
|
onChange(parseInt(value2));
|
|
1851
1665
|
},
|
|
1852
1666
|
[onChange]
|
|
1853
1667
|
);
|
|
1854
|
-
const handleFocus =
|
|
1668
|
+
const handleFocus = useCallback9(
|
|
1855
1669
|
(event) => {
|
|
1856
1670
|
if (onFocus) {
|
|
1857
1671
|
const starValue = Number(event.target.value);
|
|
@@ -1860,7 +1674,7 @@ function RatingWidget({
|
|
|
1860
1674
|
},
|
|
1861
1675
|
[onFocus, id]
|
|
1862
1676
|
);
|
|
1863
|
-
const handleBlur =
|
|
1677
|
+
const handleBlur = useCallback9(
|
|
1864
1678
|
(event) => {
|
|
1865
1679
|
if (onBlur) {
|
|
1866
1680
|
const starValue = Number(event.target.value);
|
|
@@ -1877,9 +1691,9 @@ function RatingWidget({
|
|
|
1877
1691
|
const colorIdx = Math.min(index, colors.length - 1);
|
|
1878
1692
|
return `bg-${colors[colorIdx]}-400`;
|
|
1879
1693
|
};
|
|
1880
|
-
return /* @__PURE__ */
|
|
1694
|
+
return /* @__PURE__ */ jsx28("div", { className: "form-control w-full", children: /* @__PURE__ */ jsx28("div", { className: `rating gap-1 ${sizeClass}`, children: [...Array(numStars)].map((_, index) => {
|
|
1881
1695
|
const starValue = min + index;
|
|
1882
|
-
return /* @__PURE__ */
|
|
1696
|
+
return /* @__PURE__ */ jsx28(
|
|
1883
1697
|
"input",
|
|
1884
1698
|
{
|
|
1885
1699
|
type: "radio",
|
|
@@ -1901,12 +1715,12 @@ function RatingWidget({
|
|
|
1901
1715
|
}
|
|
1902
1716
|
|
|
1903
1717
|
// src/widgets/SelectWidget/SelectWidget.tsx
|
|
1904
|
-
import { useCallback as
|
|
1718
|
+
import { useCallback as useCallback10 } from "react";
|
|
1905
1719
|
import {
|
|
1906
1720
|
enumOptionsIndexForValue,
|
|
1907
1721
|
enumOptionsValueForIndex
|
|
1908
1722
|
} from "@rjsf/utils";
|
|
1909
|
-
import { jsx as
|
|
1723
|
+
import { jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1910
1724
|
function SelectWidget({
|
|
1911
1725
|
schema,
|
|
1912
1726
|
id,
|
|
@@ -1936,7 +1750,7 @@ function SelectWidget({
|
|
|
1936
1750
|
return String(val);
|
|
1937
1751
|
};
|
|
1938
1752
|
const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
|
|
1939
|
-
const handleOptionClick =
|
|
1753
|
+
const handleOptionClick = useCallback10(
|
|
1940
1754
|
(event) => {
|
|
1941
1755
|
const index = Number(event.currentTarget.dataset.value);
|
|
1942
1756
|
if (isNaN(index)) {
|
|
@@ -1955,7 +1769,7 @@ function SelectWidget({
|
|
|
1955
1769
|
},
|
|
1956
1770
|
[value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, onChange]
|
|
1957
1771
|
);
|
|
1958
|
-
const _onBlur =
|
|
1772
|
+
const _onBlur = useCallback10(
|
|
1959
1773
|
({ target }) => {
|
|
1960
1774
|
const dataValue = target?.getAttribute("data-value");
|
|
1961
1775
|
if (dataValue !== null) {
|
|
@@ -1964,7 +1778,7 @@ function SelectWidget({
|
|
|
1964
1778
|
},
|
|
1965
1779
|
[onBlur, id, enumOptions, optEmptyVal]
|
|
1966
1780
|
);
|
|
1967
|
-
const _onFocus =
|
|
1781
|
+
const _onFocus = useCallback10(
|
|
1968
1782
|
({ target }) => {
|
|
1969
1783
|
const dataValue = target?.getAttribute("data-value");
|
|
1970
1784
|
if (dataValue !== null) {
|
|
@@ -1976,7 +1790,7 @@ function SelectWidget({
|
|
|
1976
1790
|
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1977
1791
|
const selectedValues = Array.isArray(selectedIndexes) ? selectedIndexes : [selectedIndexes];
|
|
1978
1792
|
const optionsList = enumOptions || (Array.isArray(schema.examples) ? schema.examples.map((example) => ({ value: example, label: example })) : []);
|
|
1979
|
-
return /* @__PURE__ */
|
|
1793
|
+
return /* @__PURE__ */ jsx29("div", { className: "form-control w-full", children: /* @__PURE__ */ jsxs17("div", { className: "dropdown w-full", children: [
|
|
1980
1794
|
/* @__PURE__ */ jsxs17(
|
|
1981
1795
|
"div",
|
|
1982
1796
|
{
|
|
@@ -1986,12 +1800,12 @@ function SelectWidget({
|
|
|
1986
1800
|
onBlur: _onBlur,
|
|
1987
1801
|
onFocus: _onFocus,
|
|
1988
1802
|
children: [
|
|
1989
|
-
/* @__PURE__ */
|
|
1990
|
-
/* @__PURE__ */
|
|
1803
|
+
/* @__PURE__ */ jsx29("span", { className: "truncate", children: selectedValues.length > 0 ? selectedValues.map((index) => optionsList[Number(index)]?.label).join(", ") : placeholder || label || "Select..." }),
|
|
1804
|
+
/* @__PURE__ */ jsx29("span", { className: "ml-2", children: "\u25BC" })
|
|
1991
1805
|
]
|
|
1992
1806
|
}
|
|
1993
1807
|
),
|
|
1994
|
-
/* @__PURE__ */
|
|
1808
|
+
/* @__PURE__ */ jsx29("ul", { className: "dropdown-content z-[1] bg-base-100 w-full max-h-60 overflow-auto rounded-box shadow-lg", children: optionsList.map(({ label: label2 }, i) => /* @__PURE__ */ jsx29(
|
|
1995
1809
|
"li",
|
|
1996
1810
|
{
|
|
1997
1811
|
role: "button",
|
|
@@ -2000,7 +1814,7 @@ function SelectWidget({
|
|
|
2000
1814
|
onClick: handleOptionClick,
|
|
2001
1815
|
"data-value": i,
|
|
2002
1816
|
children: /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
|
|
2003
|
-
multiple && /* @__PURE__ */
|
|
1817
|
+
multiple && /* @__PURE__ */ jsx29(
|
|
2004
1818
|
"input",
|
|
2005
1819
|
{
|
|
2006
1820
|
type: "checkbox",
|
|
@@ -2009,7 +1823,7 @@ function SelectWidget({
|
|
|
2009
1823
|
readOnly: true
|
|
2010
1824
|
}
|
|
2011
1825
|
),
|
|
2012
|
-
/* @__PURE__ */
|
|
1826
|
+
/* @__PURE__ */ jsx29("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
|
|
2013
1827
|
] })
|
|
2014
1828
|
},
|
|
2015
1829
|
i
|
|
@@ -2018,11 +1832,11 @@ function SelectWidget({
|
|
|
2018
1832
|
}
|
|
2019
1833
|
|
|
2020
1834
|
// src/widgets/TextareaWidget/TextareaWidget.tsx
|
|
2021
|
-
import { useCallback as
|
|
2022
|
-
import { jsx as
|
|
1835
|
+
import { useCallback as useCallback11 } from "react";
|
|
1836
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2023
1837
|
function TextareaWidget(props) {
|
|
2024
|
-
const { id, value, required, disabled, readonly, onChange, onFocus, onBlur, options } = props;
|
|
2025
|
-
const handleFocus =
|
|
1838
|
+
const { id, htmlName, value, required, disabled, readonly, onChange, onFocus, onBlur, options } = props;
|
|
1839
|
+
const handleFocus = useCallback11(
|
|
2026
1840
|
(event) => {
|
|
2027
1841
|
if (onFocus) {
|
|
2028
1842
|
onFocus(id, event.target.value);
|
|
@@ -2030,7 +1844,7 @@ function TextareaWidget(props) {
|
|
|
2030
1844
|
},
|
|
2031
1845
|
[onFocus, id]
|
|
2032
1846
|
);
|
|
2033
|
-
const handleBlur =
|
|
1847
|
+
const handleBlur = useCallback11(
|
|
2034
1848
|
(event) => {
|
|
2035
1849
|
if (onBlur) {
|
|
2036
1850
|
onBlur(id, event.target.value);
|
|
@@ -2038,17 +1852,18 @@ function TextareaWidget(props) {
|
|
|
2038
1852
|
},
|
|
2039
1853
|
[onBlur, id]
|
|
2040
1854
|
);
|
|
2041
|
-
const handleChange =
|
|
1855
|
+
const handleChange = useCallback11(
|
|
2042
1856
|
(event) => {
|
|
2043
1857
|
onChange(event.target.value);
|
|
2044
1858
|
},
|
|
2045
1859
|
[onChange]
|
|
2046
1860
|
);
|
|
2047
1861
|
const rows = options?.rows || 5;
|
|
2048
|
-
return /* @__PURE__ */
|
|
1862
|
+
return /* @__PURE__ */ jsx30("div", { className: "form-control", children: /* @__PURE__ */ jsx30(
|
|
2049
1863
|
"textarea",
|
|
2050
1864
|
{
|
|
2051
1865
|
id,
|
|
1866
|
+
name: htmlName || id,
|
|
2052
1867
|
value: value || "",
|
|
2053
1868
|
required,
|
|
2054
1869
|
disabled: disabled || readonly,
|
|
@@ -2063,11 +1878,11 @@ function TextareaWidget(props) {
|
|
|
2063
1878
|
}
|
|
2064
1879
|
|
|
2065
1880
|
// src/widgets/TimeWidget/TimeWidget.tsx
|
|
2066
|
-
import { useCallback as
|
|
2067
|
-
import { jsx as
|
|
1881
|
+
import { useCallback as useCallback12 } from "react";
|
|
1882
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
2068
1883
|
function TimeWidget(props) {
|
|
2069
1884
|
const { id, value, onChange, onFocus, onBlur, required, disabled, readonly } = props;
|
|
2070
|
-
const handleFocus =
|
|
1885
|
+
const handleFocus = useCallback12(
|
|
2071
1886
|
(event) => {
|
|
2072
1887
|
if (onFocus) {
|
|
2073
1888
|
onFocus(id, event.target.value);
|
|
@@ -2075,7 +1890,7 @@ function TimeWidget(props) {
|
|
|
2075
1890
|
},
|
|
2076
1891
|
[onFocus, id]
|
|
2077
1892
|
);
|
|
2078
|
-
const handleBlur =
|
|
1893
|
+
const handleBlur = useCallback12(
|
|
2079
1894
|
(event) => {
|
|
2080
1895
|
if (onBlur) {
|
|
2081
1896
|
onBlur(id, event.target.value);
|
|
@@ -2083,13 +1898,13 @@ function TimeWidget(props) {
|
|
|
2083
1898
|
},
|
|
2084
1899
|
[onBlur, id]
|
|
2085
1900
|
);
|
|
2086
|
-
const handleChange =
|
|
1901
|
+
const handleChange = useCallback12(
|
|
2087
1902
|
(event) => {
|
|
2088
1903
|
onChange(event.target.value);
|
|
2089
1904
|
},
|
|
2090
1905
|
[onChange]
|
|
2091
1906
|
);
|
|
2092
|
-
return /* @__PURE__ */
|
|
1907
|
+
return /* @__PURE__ */ jsx31("div", { className: "form-control", children: /* @__PURE__ */ jsx31(
|
|
2093
1908
|
"input",
|
|
2094
1909
|
{
|
|
2095
1910
|
type: "time",
|
|
@@ -2107,27 +1922,27 @@ function TimeWidget(props) {
|
|
|
2107
1922
|
}
|
|
2108
1923
|
|
|
2109
1924
|
// src/widgets/ToggleWidget/ToggleWidget.tsx
|
|
2110
|
-
import { useCallback as
|
|
2111
|
-
import { jsx as
|
|
1925
|
+
import { useCallback as useCallback13 } from "react";
|
|
1926
|
+
import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2112
1927
|
function ToggleWidget({ id, value, required, disabled, readonly, autofocus, onChange, onFocus, onBlur, options }) {
|
|
2113
|
-
const _onChange =
|
|
1928
|
+
const _onChange = useCallback13(
|
|
2114
1929
|
({ target: { checked } }) => onChange(checked),
|
|
2115
1930
|
[onChange]
|
|
2116
1931
|
);
|
|
2117
|
-
const handleFocus =
|
|
1932
|
+
const handleFocus = useCallback13(() => {
|
|
2118
1933
|
if (onFocus) {
|
|
2119
1934
|
onFocus(id, value);
|
|
2120
1935
|
}
|
|
2121
1936
|
}, [onFocus, id, value]);
|
|
2122
|
-
const handleBlur =
|
|
1937
|
+
const handleBlur = useCallback13(() => {
|
|
2123
1938
|
if (onBlur) {
|
|
2124
1939
|
onBlur(id, value);
|
|
2125
1940
|
}
|
|
2126
1941
|
}, [onBlur, id, value]);
|
|
2127
1942
|
const { size = "md" } = options;
|
|
2128
1943
|
const sizeClass = size !== "md" ? `toggle-${size}` : "";
|
|
2129
|
-
return /* @__PURE__ */
|
|
2130
|
-
/* @__PURE__ */
|
|
1944
|
+
return /* @__PURE__ */ jsx32("div", { className: "form-control", children: /* @__PURE__ */ jsxs18("label", { className: "cursor-pointer label my-auto", children: [
|
|
1945
|
+
/* @__PURE__ */ jsx32(
|
|
2131
1946
|
"input",
|
|
2132
1947
|
{
|
|
2133
1948
|
type: "checkbox",
|
|
@@ -2142,7 +1957,7 @@ function ToggleWidget({ id, value, required, disabled, readonly, autofocus, onCh
|
|
|
2142
1957
|
className: `toggle ${sizeClass}`
|
|
2143
1958
|
}
|
|
2144
1959
|
),
|
|
2145
|
-
/* @__PURE__ */
|
|
1960
|
+
/* @__PURE__ */ jsx32("span", { className: "label-text", children: options.label })
|
|
2146
1961
|
] }) });
|
|
2147
1962
|
}
|
|
2148
1963
|
|
|
@@ -2155,7 +1970,6 @@ function generateWidgets() {
|
|
|
2155
1970
|
CheckboxWidget,
|
|
2156
1971
|
DateTimeWidget,
|
|
2157
1972
|
DateWidget,
|
|
2158
|
-
FileWidget,
|
|
2159
1973
|
RadioWidget,
|
|
2160
1974
|
RangeWidget,
|
|
2161
1975
|
RatingWidget,
|
|
@@ -2168,7 +1982,7 @@ function generateWidgets() {
|
|
|
2168
1982
|
var Widgets_default = generateWidgets;
|
|
2169
1983
|
|
|
2170
1984
|
// src/theme/Theme.tsx
|
|
2171
|
-
import { jsx as
|
|
1985
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
2172
1986
|
function generateTheme() {
|
|
2173
1987
|
const { fields } = getDefaultRegistry();
|
|
2174
1988
|
const generatedWidgets = generateWidgets();
|
|
@@ -2190,21 +2004,21 @@ var ThemeContext = createContext({
|
|
|
2190
2004
|
}
|
|
2191
2005
|
});
|
|
2192
2006
|
function ThemeProvider({ children }) {
|
|
2193
|
-
const [theme, setTheme] =
|
|
2007
|
+
const [theme, setTheme] = useState3(() => {
|
|
2194
2008
|
try {
|
|
2195
2009
|
return localStorage.getItem("daisyui-theme") || "cupcake";
|
|
2196
2010
|
} catch {
|
|
2197
2011
|
return "cupcake";
|
|
2198
2012
|
}
|
|
2199
2013
|
});
|
|
2200
|
-
const handleSetTheme =
|
|
2014
|
+
const handleSetTheme = useCallback14((newTheme) => {
|
|
2201
2015
|
try {
|
|
2202
2016
|
localStorage.setItem("daisyui-theme", newTheme);
|
|
2203
2017
|
setTheme(newTheme);
|
|
2204
2018
|
} catch {
|
|
2205
2019
|
}
|
|
2206
2020
|
}, []);
|
|
2207
|
-
return /* @__PURE__ */
|
|
2021
|
+
return /* @__PURE__ */ jsx33(ThemeContext.Provider, { value: { theme, setTheme: handleSetTheme }, children });
|
|
2208
2022
|
}
|
|
2209
2023
|
var useTheme = () => useContext(ThemeContext);
|
|
2210
2024
|
|
|
@@ -2214,8 +2028,8 @@ var DaisyUIForm = withTheme(Theme_default);
|
|
|
2214
2028
|
var DaisyUIForm_default = DaisyUIForm;
|
|
2215
2029
|
|
|
2216
2030
|
// src/DaisyUIFrameProvider.tsx
|
|
2217
|
-
import { useEffect as
|
|
2218
|
-
import { jsx as
|
|
2031
|
+
import { useEffect as useEffect3 } from "react";
|
|
2032
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
2219
2033
|
function DaisyUIFrameComponent(props) {
|
|
2220
2034
|
const { children, subtheme = {}, document: document2 } = props;
|
|
2221
2035
|
const theme = (() => {
|
|
@@ -2229,7 +2043,7 @@ function DaisyUIFrameComponent(props) {
|
|
|
2229
2043
|
return "cupcake";
|
|
2230
2044
|
}
|
|
2231
2045
|
})();
|
|
2232
|
-
|
|
2046
|
+
useEffect3(() => {
|
|
2233
2047
|
if (document2) {
|
|
2234
2048
|
const configScript = document2.createElement("script");
|
|
2235
2049
|
configScript.textContent = `
|
|
@@ -2264,11 +2078,11 @@ function DaisyUIFrameComponent(props) {
|
|
|
2264
2078
|
}
|
|
2265
2079
|
return void 0;
|
|
2266
2080
|
}, [document2]);
|
|
2267
|
-
return /* @__PURE__ */
|
|
2081
|
+
return /* @__PURE__ */ jsx34("div", { "data-theme": theme, className: "daisy-ui-theme", children });
|
|
2268
2082
|
}
|
|
2269
2083
|
var __createDaisyUIFrameProvider = (props) => {
|
|
2270
2084
|
return function DaisyUIFrame({ document: document2 }) {
|
|
2271
|
-
return /* @__PURE__ */
|
|
2085
|
+
return /* @__PURE__ */ jsx34(DaisyUIFrameComponent, { document: document2, ...props });
|
|
2272
2086
|
};
|
|
2273
2087
|
};
|
|
2274
2088
|
|