@rjsf/daisyui 6.0.0-beta.8 → 6.0.0
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 +22 -18
- package/dist/chakra-ui.esm.js +382 -472
- package/dist/chakra-ui.esm.js.map +4 -4
- package/dist/chakra-ui.umd.js +194 -287
- package/dist/{index.js → index.cjs} +404 -496
- package/dist/index.cjs.map +7 -0
- 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 +3 -4
- package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js +7 -3
- package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js.map +1 -1
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js +8 -2
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/templates/ButtonTemplates/AddButton.js +1 -1
- package/lib/templates/ButtonTemplates/AddButton.js.map +1 -1
- package/lib/templates/ButtonTemplates/IconButton.js +4 -4
- package/lib/templates/ButtonTemplates/IconButton.js.map +1 -1
- package/lib/templates/FieldTemplate/FieldTemplate.js +6 -3
- package/lib/templates/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -0
- package/lib/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +6 -0
- package/lib/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -0
- package/lib/templates/MultiSchemaFieldTemplate/index.d.ts +2 -0
- package/lib/templates/MultiSchemaFieldTemplate/index.js +3 -0
- package/lib/templates/MultiSchemaFieldTemplate/index.js.map +1 -0
- package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js +4 -3
- package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +10 -0
- package/lib/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +23 -0
- package/lib/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -0
- package/lib/templates/OptionalDataControlsTemplate/index.d.ts +2 -0
- package/lib/templates/OptionalDataControlsTemplate/index.js +3 -0
- package/lib/templates/OptionalDataControlsTemplate/index.js.map +1 -0
- package/lib/templates/Templates.js +4 -0
- package/lib/templates/Templates.js.map +1 -1
- package/lib/templates/TitleField/TitleField.js +6 -2
- package/lib/templates/TitleField/TitleField.js.map +1 -1
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +11 -11
- 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/DateTimeWidget/DateTimeWidget.js +2 -2
- package/lib/widgets/DateTimeWidget/DateTimeWidget.js.map +1 -1
- package/lib/widgets/DateWidget/DateWidget.js +2 -2
- package/lib/widgets/DateWidget/DateWidget.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 +25 -22
- package/src/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.tsx +15 -20
- package/src/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -3
- package/src/templates/ArrayFieldTemplate/ArrayFieldTemplate.tsx +9 -13
- package/src/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx +12 -2
- package/src/templates/BaseInputTemplate/BaseInputTemplate.tsx +14 -6
- package/src/templates/ButtonTemplates/AddButton.tsx +1 -1
- package/src/templates/ButtonTemplates/IconButton.tsx +4 -4
- package/src/templates/FieldTemplate/FieldTemplate.tsx +48 -19
- package/src/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +15 -0
- package/src/templates/MultiSchemaFieldTemplate/index.ts +2 -0
- package/src/templates/ObjectFieldTemplate/ObjectFieldTemplate.tsx +13 -9
- package/src/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +46 -0
- package/src/templates/OptionalDataControlsTemplate/index.ts +2 -0
- package/src/templates/Templates.tsx +4 -0
- package/src/templates/TitleField/TitleField.tsx +12 -3
- package/src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +38 -34
- package/src/widgets/AltDateWidget/AltDateWidget.tsx +18 -253
- package/src/widgets/CheckboxWidget/CheckboxWidget.tsx +5 -3
- package/src/widgets/CheckboxesWidget/CheckboxesWidget.tsx +2 -1
- package/src/widgets/DateTimeWidget/DateTimeWidget.tsx +2 -2
- package/src/widgets/DateWidget/DateWidget.tsx +2 -2
- package/src/widgets/RadioWidget/RadioWidget.tsx +2 -1
- package/src/widgets/TextareaWidget/TextareaWidget.tsx +2 -1
- package/src/widgets/Widgets.tsx +0 -3
- package/dist/index.js.map +0 -7
- 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";
|
|
@@ -18,20 +17,16 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
18
17
|
hasMoveDown,
|
|
19
18
|
hasMoveUp,
|
|
20
19
|
hasRemove,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
fieldPathId,
|
|
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";
|
|
@@ -40,10 +35,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
40
35
|
/* @__PURE__ */ jsx(
|
|
41
36
|
MoveUpButton2,
|
|
42
37
|
{
|
|
43
|
-
id: buttonId(
|
|
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
|
}
|
|
@@ -51,10 +46,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
51
46
|
/* @__PURE__ */ jsx(
|
|
52
47
|
MoveDownButton2,
|
|
53
48
|
{
|
|
54
|
-
id: buttonId(
|
|
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
|
}
|
|
@@ -63,10 +58,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
63
58
|
hasCopy && /* @__PURE__ */ jsx(
|
|
64
59
|
CopyButton2,
|
|
65
60
|
{
|
|
66
|
-
id: buttonId(
|
|
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
|
}
|
|
@@ -74,10 +69,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
74
69
|
hasRemove && /* @__PURE__ */ jsx(
|
|
75
70
|
RemoveButton2,
|
|
76
71
|
{
|
|
77
|
-
id: buttonId(
|
|
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
|
}
|
|
@@ -125,8 +120,9 @@ function ArrayFieldTemplate(props) {
|
|
|
125
120
|
canAdd,
|
|
126
121
|
className,
|
|
127
122
|
disabled,
|
|
128
|
-
|
|
123
|
+
fieldPathId,
|
|
129
124
|
items,
|
|
125
|
+
optionalDataControl,
|
|
130
126
|
onAddClick,
|
|
131
127
|
readonly,
|
|
132
128
|
registry,
|
|
@@ -141,16 +137,12 @@ function ArrayFieldTemplate(props) {
|
|
|
141
137
|
registry,
|
|
142
138
|
uiOptions
|
|
143
139
|
);
|
|
144
|
-
const ArrayFieldItemTemplate2 = getTemplate2(
|
|
145
|
-
"ArrayFieldItemTemplate",
|
|
146
|
-
registry,
|
|
147
|
-
uiOptions
|
|
148
|
-
);
|
|
149
140
|
const ArrayFieldTitleTemplate = getTemplate2(
|
|
150
141
|
"ArrayFieldTitleTemplate",
|
|
151
142
|
registry,
|
|
152
143
|
uiOptions
|
|
153
144
|
);
|
|
145
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
154
146
|
const {
|
|
155
147
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
156
148
|
} = registry.templates;
|
|
@@ -166,18 +158,19 @@ function ArrayFieldTemplate(props) {
|
|
|
166
158
|
/* @__PURE__ */ jsx3(
|
|
167
159
|
ArrayFieldTitleTemplate,
|
|
168
160
|
{
|
|
169
|
-
|
|
161
|
+
fieldPathId,
|
|
170
162
|
title: uiOptions.title || title,
|
|
171
163
|
schema,
|
|
172
164
|
uiSchema,
|
|
173
165
|
required,
|
|
174
|
-
registry
|
|
166
|
+
registry,
|
|
167
|
+
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
175
168
|
}
|
|
176
169
|
),
|
|
177
170
|
/* @__PURE__ */ jsx3(
|
|
178
171
|
ArrayFieldDescriptionTemplate,
|
|
179
172
|
{
|
|
180
|
-
|
|
173
|
+
fieldPathId,
|
|
181
174
|
description: uiOptions.description || schema.description,
|
|
182
175
|
schema,
|
|
183
176
|
uiSchema,
|
|
@@ -185,14 +178,15 @@ function ArrayFieldTemplate(props) {
|
|
|
185
178
|
}
|
|
186
179
|
),
|
|
187
180
|
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-4", children: [
|
|
181
|
+
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
188
182
|
/* @__PURE__ */ jsxs3("div", { className: "rjsf-array-item-list", children: [
|
|
189
|
-
items
|
|
183
|
+
items,
|
|
190
184
|
items && items.length === 0 && canAdd && /* @__PURE__ */ jsx3("div", { className: "text-center italic text-base-content/70", children: TranslatableString.EmptyArray })
|
|
191
185
|
] }),
|
|
192
186
|
canAdd && /* @__PURE__ */ jsx3("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx3(
|
|
193
187
|
AddButton2,
|
|
194
188
|
{
|
|
195
|
-
id: buttonId2(
|
|
189
|
+
id: buttonId2(fieldPathId, "add"),
|
|
196
190
|
className: "rjsf-array-item-add btn btn-primary btn-sm",
|
|
197
191
|
onClick: handleAddClick,
|
|
198
192
|
disabled: disabled || readonly,
|
|
@@ -215,6 +209,8 @@ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-run
|
|
|
215
209
|
function BaseInputTemplate(props) {
|
|
216
210
|
const {
|
|
217
211
|
id,
|
|
212
|
+
htmlName,
|
|
213
|
+
multiple,
|
|
218
214
|
value,
|
|
219
215
|
required,
|
|
220
216
|
disabled,
|
|
@@ -231,6 +227,12 @@ function BaseInputTemplate(props) {
|
|
|
231
227
|
placeholder
|
|
232
228
|
} = props;
|
|
233
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
|
+
}
|
|
234
236
|
const { step, min, max, accept, ...rest } = inputProps;
|
|
235
237
|
const htmlInputProps = { step, min, max, accept, ...schema.examples ? { list: examplesId(id) } : void 0 };
|
|
236
238
|
const _onChange = useCallback2(
|
|
@@ -252,13 +254,14 @@ function BaseInputTemplate(props) {
|
|
|
252
254
|
"input",
|
|
253
255
|
{
|
|
254
256
|
id,
|
|
255
|
-
name: id,
|
|
257
|
+
name: htmlName || id,
|
|
256
258
|
value: value || value === 0 ? value : "",
|
|
257
259
|
placeholder,
|
|
258
260
|
required,
|
|
259
261
|
disabled: disabled || readonly,
|
|
260
262
|
autoFocus: autofocus,
|
|
261
|
-
className
|
|
263
|
+
className,
|
|
264
|
+
multiple: isMulti,
|
|
262
265
|
...rest,
|
|
263
266
|
...htmlInputProps,
|
|
264
267
|
onChange: onChangeOverride || _onChange,
|
|
@@ -304,11 +307,11 @@ function AddButton({
|
|
|
304
307
|
return /* @__PURE__ */ jsx6("div", { className: "row", children: /* @__PURE__ */ jsx6("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsx6(
|
|
305
308
|
DaisyUIButton_default,
|
|
306
309
|
{
|
|
310
|
+
title: translateString(TranslatableString2.AddButton),
|
|
307
311
|
...otherProps,
|
|
308
312
|
iconType: "info",
|
|
309
313
|
icon: faPlus,
|
|
310
314
|
className: "btn-add col-xs-12 btn-primary btn-primary-content",
|
|
311
|
-
title: translateString(TranslatableString2.AddButton),
|
|
312
315
|
onClick,
|
|
313
316
|
disabled,
|
|
314
317
|
registry
|
|
@@ -343,7 +346,7 @@ function CopyButton(props) {
|
|
|
343
346
|
const {
|
|
344
347
|
registry: { translateString }
|
|
345
348
|
} = props;
|
|
346
|
-
return /* @__PURE__ */ jsx8(DaisyUIButton_default, {
|
|
349
|
+
return /* @__PURE__ */ jsx8(DaisyUIButton_default, { title: translateString(TranslatableString3.CopyButton), ...props, icon: faCopy2 });
|
|
347
350
|
}
|
|
348
351
|
function MoveDownButton(props) {
|
|
349
352
|
const {
|
|
@@ -352,8 +355,8 @@ function MoveDownButton(props) {
|
|
|
352
355
|
return /* @__PURE__ */ jsx8(
|
|
353
356
|
DaisyUIButton_default,
|
|
354
357
|
{
|
|
355
|
-
...props,
|
|
356
358
|
title: translateString(TranslatableString3.MoveDownButton),
|
|
359
|
+
...props,
|
|
357
360
|
icon: faArrowDown2
|
|
358
361
|
}
|
|
359
362
|
);
|
|
@@ -365,8 +368,8 @@ function MoveUpButton(props) {
|
|
|
365
368
|
return /* @__PURE__ */ jsx8(
|
|
366
369
|
DaisyUIButton_default,
|
|
367
370
|
{
|
|
368
|
-
...props,
|
|
369
371
|
title: translateString(TranslatableString3.MoveUpButton),
|
|
372
|
+
...props,
|
|
370
373
|
icon: faArrowUp2
|
|
371
374
|
}
|
|
372
375
|
);
|
|
@@ -378,8 +381,8 @@ function RemoveButton(props) {
|
|
|
378
381
|
return /* @__PURE__ */ jsx8(
|
|
379
382
|
DaisyUIButton_default,
|
|
380
383
|
{
|
|
381
|
-
...props,
|
|
382
384
|
title: translateString(TranslatableString3.RemoveButton),
|
|
385
|
+
...props,
|
|
383
386
|
iconType: "danger",
|
|
384
387
|
icon: faTrash2
|
|
385
388
|
}
|
|
@@ -419,6 +422,10 @@ function FieldHelpTemplate(props) {
|
|
|
419
422
|
}
|
|
420
423
|
|
|
421
424
|
// src/templates/FieldTemplate/FieldTemplate.tsx
|
|
425
|
+
import {
|
|
426
|
+
getTemplate as getTemplate3,
|
|
427
|
+
getUiOptions as getUiOptions3
|
|
428
|
+
} from "@rjsf/utils";
|
|
422
429
|
import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
423
430
|
function FieldTemplate(props) {
|
|
424
431
|
const {
|
|
@@ -426,37 +433,61 @@ function FieldTemplate(props) {
|
|
|
426
433
|
label,
|
|
427
434
|
children,
|
|
428
435
|
errors,
|
|
429
|
-
formContext,
|
|
430
436
|
formData,
|
|
431
437
|
help,
|
|
432
438
|
hideError,
|
|
433
439
|
displayLabel,
|
|
440
|
+
onKeyRename,
|
|
441
|
+
onKeyRenameBlur,
|
|
442
|
+
onRemoveProperty,
|
|
434
443
|
classNames,
|
|
435
|
-
// Destructure props we don't want to pass to div
|
|
436
|
-
onKeyChange,
|
|
437
|
-
onDropPropertyClick,
|
|
438
444
|
uiSchema,
|
|
439
445
|
schema,
|
|
440
446
|
readonly,
|
|
441
447
|
required,
|
|
448
|
+
registry,
|
|
449
|
+
// Destructure props we don't want to pass to div
|
|
450
|
+
description,
|
|
442
451
|
rawErrors,
|
|
443
452
|
rawHelp,
|
|
444
453
|
rawDescription,
|
|
445
454
|
hidden,
|
|
446
455
|
onChange,
|
|
447
|
-
registry,
|
|
448
456
|
...divProps
|
|
449
457
|
} = props;
|
|
450
458
|
const isCheckbox = schema.type === "boolean";
|
|
451
|
-
|
|
452
|
-
|
|
459
|
+
const uiOptions = getUiOptions3(uiSchema);
|
|
460
|
+
const WrapIfAdditionalTemplate2 = getTemplate3(
|
|
461
|
+
"WrapIfAdditionalTemplate",
|
|
462
|
+
registry,
|
|
463
|
+
uiOptions
|
|
464
|
+
);
|
|
465
|
+
return /* @__PURE__ */ jsx13(
|
|
466
|
+
WrapIfAdditionalTemplate2,
|
|
467
|
+
{
|
|
468
|
+
classNames,
|
|
469
|
+
disabled: divProps.disabled,
|
|
470
|
+
id,
|
|
453
471
|
label,
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
472
|
+
onKeyRename,
|
|
473
|
+
onKeyRenameBlur,
|
|
474
|
+
onRemoveProperty,
|
|
475
|
+
readonly,
|
|
476
|
+
required,
|
|
477
|
+
schema,
|
|
478
|
+
uiSchema,
|
|
479
|
+
registry,
|
|
480
|
+
children: /* @__PURE__ */ jsxs5("div", { className: `field-template mb-3 ${classNames || ""}`, ...divProps, children: [
|
|
481
|
+
displayLabel && !isCheckbox && /* @__PURE__ */ jsx13("label", { htmlFor: id, className: "label", children: /* @__PURE__ */ jsxs5("span", { className: "label-text font-medium", children: [
|
|
482
|
+
label,
|
|
483
|
+
required && /* @__PURE__ */ jsx13("span", { className: "text-error ml-1", children: "*" })
|
|
484
|
+
] }) }),
|
|
485
|
+
children,
|
|
486
|
+
errors,
|
|
487
|
+
help
|
|
488
|
+
] })
|
|
489
|
+
}
|
|
490
|
+
);
|
|
460
491
|
}
|
|
461
492
|
|
|
462
493
|
// src/templates/GridTemplate/GridTemplate.tsx
|
|
@@ -469,16 +500,26 @@ function GridTemplate(props) {
|
|
|
469
500
|
return /* @__PURE__ */ jsx14("div", { className: "flex flex-wrap gap-4", ...rest, children });
|
|
470
501
|
}
|
|
471
502
|
|
|
503
|
+
// src/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx
|
|
504
|
+
import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
505
|
+
function MultiSchemaFieldTemplate(props) {
|
|
506
|
+
const { optionSchemaField, selector } = props;
|
|
507
|
+
return /* @__PURE__ */ jsxs6("div", { className: "p-4 border rounded-sm shadow-sm", children: [
|
|
508
|
+
/* @__PURE__ */ jsx15("div", { className: "mb-4", children: selector }),
|
|
509
|
+
optionSchemaField
|
|
510
|
+
] });
|
|
511
|
+
}
|
|
512
|
+
|
|
472
513
|
// src/templates/ObjectFieldTemplate/ObjectFieldTemplate.tsx
|
|
473
514
|
import {
|
|
474
515
|
canExpand,
|
|
475
516
|
descriptionId,
|
|
476
|
-
getTemplate as
|
|
477
|
-
getUiOptions as
|
|
517
|
+
getTemplate as getTemplate4,
|
|
518
|
+
getUiOptions as getUiOptions4,
|
|
478
519
|
titleId,
|
|
479
520
|
buttonId as buttonId3
|
|
480
521
|
} from "@rjsf/utils";
|
|
481
|
-
import { jsx as
|
|
522
|
+
import { jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
482
523
|
function ObjectFieldTemplate(props) {
|
|
483
524
|
const {
|
|
484
525
|
description,
|
|
@@ -488,62 +529,66 @@ function ObjectFieldTemplate(props) {
|
|
|
488
529
|
disabled,
|
|
489
530
|
readonly,
|
|
490
531
|
uiSchema,
|
|
491
|
-
|
|
532
|
+
fieldPathId,
|
|
492
533
|
schema,
|
|
493
534
|
formData,
|
|
494
|
-
|
|
535
|
+
optionalDataControl,
|
|
536
|
+
onAddProperty,
|
|
495
537
|
registry
|
|
496
538
|
} = props;
|
|
497
|
-
const uiOptions =
|
|
498
|
-
const TitleFieldTemplate =
|
|
499
|
-
const DescriptionFieldTemplate =
|
|
539
|
+
const uiOptions = getUiOptions4(uiSchema);
|
|
540
|
+
const TitleFieldTemplate = getTemplate4("TitleFieldTemplate", registry, uiOptions);
|
|
541
|
+
const DescriptionFieldTemplate = getTemplate4(
|
|
500
542
|
"DescriptionFieldTemplate",
|
|
501
543
|
registry,
|
|
502
544
|
uiOptions
|
|
503
545
|
);
|
|
546
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
504
547
|
const {
|
|
505
548
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
506
549
|
} = registry.templates;
|
|
507
|
-
const isRoot =
|
|
508
|
-
return /* @__PURE__ */
|
|
509
|
-
title && /* @__PURE__ */
|
|
550
|
+
const isRoot = fieldPathId.$id === "root";
|
|
551
|
+
return /* @__PURE__ */ jsxs7("div", { className: `form-control ${isRoot ? "bg-base-100 p-6 rounded-xl shadow-lg" : ""}`, children: [
|
|
552
|
+
title && /* @__PURE__ */ jsx16(
|
|
510
553
|
TitleFieldTemplate,
|
|
511
554
|
{
|
|
512
|
-
id: titleId(
|
|
555
|
+
id: titleId(fieldPathId),
|
|
513
556
|
title,
|
|
514
557
|
required,
|
|
515
558
|
schema,
|
|
516
559
|
uiSchema,
|
|
517
|
-
registry
|
|
560
|
+
registry,
|
|
561
|
+
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
518
562
|
}
|
|
519
563
|
),
|
|
520
|
-
description && /* @__PURE__ */
|
|
564
|
+
description && /* @__PURE__ */ jsx16(
|
|
521
565
|
DescriptionFieldTemplate,
|
|
522
566
|
{
|
|
523
|
-
id: descriptionId(
|
|
567
|
+
id: descriptionId(fieldPathId),
|
|
524
568
|
description,
|
|
525
569
|
schema,
|
|
526
570
|
uiSchema,
|
|
527
571
|
registry
|
|
528
572
|
}
|
|
529
573
|
),
|
|
530
|
-
/* @__PURE__ */
|
|
574
|
+
/* @__PURE__ */ jsxs7("div", { className: `grid grid-cols-1 gap-${description ? 3 : 4} ${isRoot ? "" : "mb-4"}`, children: [
|
|
575
|
+
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
531
576
|
properties.map(
|
|
532
|
-
(element, index) => element.hidden ? element.content : /* @__PURE__ */
|
|
577
|
+
(element, index) => element.hidden ? element.content : /* @__PURE__ */ jsx16(
|
|
533
578
|
"div",
|
|
534
579
|
{
|
|
535
|
-
className:
|
|
580
|
+
className: fieldPathId.$id === "root" && element.name === "tasks" ? "mt-2" : "",
|
|
536
581
|
children: element.content
|
|
537
582
|
},
|
|
538
|
-
`${
|
|
583
|
+
`${fieldPathId.$id}-${element.name}-${index}`
|
|
539
584
|
)
|
|
540
585
|
),
|
|
541
|
-
canExpand(schema, uiSchema, formData) && /* @__PURE__ */
|
|
586
|
+
canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx16("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx16(
|
|
542
587
|
AddButton2,
|
|
543
588
|
{
|
|
544
|
-
id: buttonId3(
|
|
589
|
+
id: buttonId3(fieldPathId, "add"),
|
|
545
590
|
className: "rjsf-object-property-expand btn btn-primary btn-sm",
|
|
546
|
-
onClick:
|
|
591
|
+
onClick: onAddProperty,
|
|
547
592
|
disabled: disabled || readonly,
|
|
548
593
|
uiSchema,
|
|
549
594
|
registry
|
|
@@ -553,25 +598,65 @@ function ObjectFieldTemplate(props) {
|
|
|
553
598
|
] });
|
|
554
599
|
}
|
|
555
600
|
|
|
601
|
+
// src/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx
|
|
602
|
+
import { faPlus as faPlus2 } from "@fortawesome/free-solid-svg-icons";
|
|
603
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
604
|
+
function OptionalDataControlsTemplate(props) {
|
|
605
|
+
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
606
|
+
if (onAddClick) {
|
|
607
|
+
return /* @__PURE__ */ jsx17(
|
|
608
|
+
DaisyUIButton_default,
|
|
609
|
+
{
|
|
610
|
+
id,
|
|
611
|
+
registry,
|
|
612
|
+
iconType: "info",
|
|
613
|
+
icon: faPlus2,
|
|
614
|
+
className: "rjsf-add-optional-data",
|
|
615
|
+
onClick: onAddClick,
|
|
616
|
+
title: label
|
|
617
|
+
}
|
|
618
|
+
);
|
|
619
|
+
} else if (onRemoveClick) {
|
|
620
|
+
return /* @__PURE__ */ jsx17(
|
|
621
|
+
RemoveButton,
|
|
622
|
+
{
|
|
623
|
+
id,
|
|
624
|
+
registry,
|
|
625
|
+
className: "rjsf-remove-optional-data",
|
|
626
|
+
onClick: onRemoveClick,
|
|
627
|
+
title: label
|
|
628
|
+
}
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
return /* @__PURE__ */ jsx17("em", { id, children: label });
|
|
632
|
+
}
|
|
633
|
+
|
|
556
634
|
// src/templates/TitleField/TitleField.tsx
|
|
557
|
-
import { getUiOptions as
|
|
558
|
-
import { jsx as
|
|
635
|
+
import { getUiOptions as getUiOptions5 } from "@rjsf/utils";
|
|
636
|
+
import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
559
637
|
function TitleField(props) {
|
|
560
|
-
const { id, title, uiSchema } = props;
|
|
561
|
-
const uiOptions =
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
/* @__PURE__ */
|
|
638
|
+
const { id, title, uiSchema, optionalDataControl } = props;
|
|
639
|
+
const uiOptions = getUiOptions5(uiSchema);
|
|
640
|
+
let heading = /* @__PURE__ */ jsx18("h2", { className: "text-3xl font-bold text-primary mb-2", children: uiOptions.title || title });
|
|
641
|
+
if (optionalDataControl) {
|
|
642
|
+
heading = /* @__PURE__ */ jsxs8("div", { className: "flex", children: [
|
|
643
|
+
/* @__PURE__ */ jsx18("div", { className: "flex flex-auto", children: heading }),
|
|
644
|
+
/* @__PURE__ */ jsx18("div", { className: "flex justify-end", children: optionalDataControl })
|
|
645
|
+
] });
|
|
646
|
+
}
|
|
647
|
+
return /* @__PURE__ */ jsxs8("div", { id, className: "title-field mb-6", children: [
|
|
648
|
+
heading,
|
|
649
|
+
/* @__PURE__ */ jsx18("div", { className: "divider divider-primary my-0" })
|
|
565
650
|
] });
|
|
566
651
|
}
|
|
567
652
|
|
|
568
653
|
// src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx
|
|
569
|
-
import { useCallback as useCallback3 } from "react";
|
|
570
654
|
import {
|
|
571
|
-
|
|
572
|
-
|
|
655
|
+
buttonId as buttonId4,
|
|
656
|
+
ADDITIONAL_PROPERTY_FLAG,
|
|
657
|
+
TranslatableString as TranslatableString4
|
|
573
658
|
} from "@rjsf/utils";
|
|
574
|
-
import { jsx as
|
|
659
|
+
import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
575
660
|
function WrapIfAdditionalTemplate(props) {
|
|
576
661
|
const {
|
|
577
662
|
children,
|
|
@@ -582,47 +667,48 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
582
667
|
readonly,
|
|
583
668
|
required,
|
|
584
669
|
schema,
|
|
585
|
-
|
|
586
|
-
|
|
670
|
+
uiSchema,
|
|
671
|
+
onKeyRename,
|
|
672
|
+
onKeyRenameBlur,
|
|
673
|
+
onRemoveProperty,
|
|
587
674
|
registry,
|
|
588
675
|
...rest
|
|
589
676
|
} = props;
|
|
590
|
-
const
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
/* @__PURE__ */ jsxs8("div", { className: "flex items-center", children: [
|
|
602
|
-
/* @__PURE__ */ jsx17(
|
|
677
|
+
const additional = ADDITIONAL_PROPERTY_FLAG in schema;
|
|
678
|
+
const { templates, translateString } = registry;
|
|
679
|
+
const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
|
|
680
|
+
const keyLabel = translateString(TranslatableString4.KeyLabel, [label]);
|
|
681
|
+
if (!additional) {
|
|
682
|
+
return /* @__PURE__ */ jsx19("div", { className: classNames, children });
|
|
683
|
+
}
|
|
684
|
+
return /* @__PURE__ */ jsx19("div", { className: `wrap-if-additional-template ${classNames}`, ...rest, children: /* @__PURE__ */ jsxs9("div", { className: "flex items-baseline", style: { justifyContent: "space-between" }, children: [
|
|
685
|
+
/* @__PURE__ */ jsxs9("div", { children: [
|
|
686
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: `${id}-key`, className: "label", children: /* @__PURE__ */ jsx19("span", { className: "label-text", children: keyLabel }) }),
|
|
687
|
+
/* @__PURE__ */ jsx19(
|
|
603
688
|
"input",
|
|
604
689
|
{
|
|
605
690
|
type: "text",
|
|
606
691
|
className: "input input-bordered",
|
|
607
692
|
id: `${id}-key`,
|
|
608
|
-
onBlur:
|
|
693
|
+
onBlur: onKeyRenameBlur,
|
|
609
694
|
defaultValue: label,
|
|
610
695
|
disabled: disabled || readonly
|
|
611
696
|
}
|
|
612
|
-
),
|
|
613
|
-
schema.additionalProperties && /* @__PURE__ */ jsx17(
|
|
614
|
-
"button",
|
|
615
|
-
{
|
|
616
|
-
id: buttonId4(id, "remove"),
|
|
617
|
-
className: "rjsf-array-item-remove btn btn-danger ml-2",
|
|
618
|
-
onClick: handleRemove,
|
|
619
|
-
disabled: disabled || readonly,
|
|
620
|
-
children: translateString(TranslatableString4.RemoveButton)
|
|
621
|
-
}
|
|
622
697
|
)
|
|
623
698
|
] }),
|
|
624
|
-
children
|
|
625
|
-
|
|
699
|
+
children,
|
|
700
|
+
/* @__PURE__ */ jsx19("div", { className: "flex self-center", children: /* @__PURE__ */ jsx19(
|
|
701
|
+
RemoveButton2,
|
|
702
|
+
{
|
|
703
|
+
id: buttonId4(id, "remove"),
|
|
704
|
+
className: "rjsf-object-property-remove",
|
|
705
|
+
disabled: disabled || readonly,
|
|
706
|
+
onClick: onRemoveProperty,
|
|
707
|
+
uiSchema,
|
|
708
|
+
registry
|
|
709
|
+
}
|
|
710
|
+
) })
|
|
711
|
+
] }) });
|
|
626
712
|
}
|
|
627
713
|
|
|
628
714
|
// src/templates/Templates.tsx
|
|
@@ -646,7 +732,9 @@ function generateTemplates() {
|
|
|
646
732
|
FieldHelpTemplate,
|
|
647
733
|
FieldTemplate,
|
|
648
734
|
GridTemplate,
|
|
735
|
+
MultiSchemaFieldTemplate,
|
|
649
736
|
ObjectFieldTemplate,
|
|
737
|
+
OptionalDataControlsTemplate,
|
|
650
738
|
TitleFieldTemplate: TitleField,
|
|
651
739
|
WrapIfAdditionalTemplate
|
|
652
740
|
};
|
|
@@ -654,174 +742,46 @@ function generateTemplates() {
|
|
|
654
742
|
var Templates_default = generateTemplates();
|
|
655
743
|
|
|
656
744
|
// src/widgets/AltDateTimeWidget/AltDateTimeWidget.tsx
|
|
657
|
-
import { jsx as
|
|
745
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
658
746
|
function AltDateTimeWidget({
|
|
659
747
|
time = true,
|
|
660
748
|
...props
|
|
661
749
|
}) {
|
|
662
750
|
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
663
|
-
return /* @__PURE__ */
|
|
751
|
+
return /* @__PURE__ */ jsx20(AltDateWidget2, { time, ...props });
|
|
664
752
|
}
|
|
665
753
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
666
754
|
|
|
667
755
|
// src/widgets/AltDateWidget/AltDateWidget.tsx
|
|
668
|
-
import { useCallback as useCallback4, useEffect, useReducer, useState } from "react";
|
|
669
756
|
import {
|
|
670
|
-
|
|
757
|
+
DateElement,
|
|
671
758
|
TranslatableString as TranslatableString5,
|
|
672
|
-
|
|
673
|
-
toDateString,
|
|
674
|
-
dateRangeOptions
|
|
759
|
+
useAltDateWidgetProps
|
|
675
760
|
} from "@rjsf/utils";
|
|
676
|
-
import { jsx as
|
|
677
|
-
function
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
value: state[key],
|
|
690
|
-
range: key === "year" ? rangeOptions : key === "month" ? [1, 12] : key === "day" ? [1, 31] : [0, 59]
|
|
691
|
-
}));
|
|
692
|
-
if (time) {
|
|
693
|
-
dateElements.push(
|
|
694
|
-
{ type: "hour", value: state.hour, range: [0, 23] },
|
|
695
|
-
{ type: "minute", value: state.minute, range: [0, 59] },
|
|
696
|
-
{ type: "second", value: state.second, range: [0, 59] }
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
return dateElements;
|
|
700
|
-
}
|
|
701
|
-
function DateElement({
|
|
702
|
-
type,
|
|
703
|
-
range,
|
|
704
|
-
value,
|
|
705
|
-
select,
|
|
706
|
-
rootId,
|
|
707
|
-
name,
|
|
708
|
-
disabled,
|
|
709
|
-
readonly,
|
|
710
|
-
autofocus,
|
|
711
|
-
registry,
|
|
712
|
-
onBlur,
|
|
713
|
-
onFocus
|
|
714
|
-
}) {
|
|
715
|
-
const id = `${rootId}_${type}`;
|
|
716
|
-
const { SelectWidget: SelectWidget2 } = registry.widgets;
|
|
717
|
-
const handleChange = useCallback4(
|
|
718
|
-
(value2) => {
|
|
719
|
-
select(type, value2);
|
|
720
|
-
},
|
|
721
|
-
[select, type]
|
|
722
|
-
);
|
|
723
|
-
return /* @__PURE__ */ jsx19(
|
|
724
|
-
SelectWidget2,
|
|
725
|
-
{
|
|
726
|
-
schema: { type: "integer" },
|
|
727
|
-
id,
|
|
728
|
-
name,
|
|
729
|
-
className: "select select-bordered select-sm w-full",
|
|
730
|
-
options: { enumOptions: dateRangeOptions(range[0], range[1]) },
|
|
731
|
-
placeholder: type,
|
|
732
|
-
value,
|
|
733
|
-
disabled,
|
|
734
|
-
readonly,
|
|
735
|
-
autofocus,
|
|
736
|
-
onChange: handleChange,
|
|
737
|
-
onBlur,
|
|
738
|
-
onFocus,
|
|
739
|
-
registry,
|
|
740
|
-
label: "",
|
|
741
|
-
"aria-describedby": ariaDescribedByIds2(rootId),
|
|
742
|
-
required: false
|
|
743
|
-
}
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
function convertToRJSFDateObject(dateObj) {
|
|
747
|
-
return {
|
|
748
|
-
year: dateObj.year ? parseInt(dateObj.year) : 0,
|
|
749
|
-
month: dateObj.month ? parseInt(dateObj.month) : 0,
|
|
750
|
-
day: dateObj.day ? parseInt(dateObj.day) : 0,
|
|
751
|
-
hour: dateObj.hour ? parseInt(dateObj.hour) : 0,
|
|
752
|
-
minute: dateObj.minute ? parseInt(dateObj.minute) : 0,
|
|
753
|
-
second: dateObj.second ? parseInt(dateObj.second) : 0
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
function AltDateWidget({
|
|
757
|
-
time = false,
|
|
758
|
-
disabled = false,
|
|
759
|
-
readonly = false,
|
|
760
|
-
autofocus = false,
|
|
761
|
-
options = {},
|
|
762
|
-
id,
|
|
763
|
-
name,
|
|
764
|
-
registry,
|
|
765
|
-
onBlur,
|
|
766
|
-
onFocus,
|
|
767
|
-
onChange,
|
|
768
|
-
value
|
|
769
|
-
}) {
|
|
761
|
+
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
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;
|
|
770
774
|
const { translateString } = registry;
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
const [state, setState] = useReducer(dateReducer, initialState);
|
|
777
|
-
useEffect(() => {
|
|
778
|
-
const rjsfDateObj = convertToRJSFDateObject(state);
|
|
779
|
-
const stateValue = toDateString(rjsfDateObj, time);
|
|
780
|
-
if (readyForChange(state, time) && stateValue !== value) {
|
|
781
|
-
onChange(stateValue);
|
|
782
|
-
} else if (lastValue !== value) {
|
|
783
|
-
setLastValue(value);
|
|
784
|
-
setState(parseDateString(value, time));
|
|
785
|
-
}
|
|
786
|
-
}, [time, value, onChange, state, lastValue]);
|
|
787
|
-
const handleChange = useCallback4((property, value2) => {
|
|
788
|
-
setState({ [property]: value2 });
|
|
789
|
-
}, []);
|
|
790
|
-
const handleSetNow = useCallback4(
|
|
791
|
-
(event) => {
|
|
792
|
-
event.preventDefault();
|
|
793
|
-
if (disabled || readonly) {
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), time);
|
|
797
|
-
const rjsfDateObj = convertToRJSFDateObject(nextState);
|
|
798
|
-
onChange(toDateString(rjsfDateObj, time));
|
|
799
|
-
},
|
|
800
|
-
[disabled, readonly, time, onChange]
|
|
801
|
-
);
|
|
802
|
-
const handleClear = useCallback4(
|
|
803
|
-
(event) => {
|
|
804
|
-
event.preventDefault();
|
|
805
|
-
if (disabled || readonly) {
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
onChange(void 0);
|
|
809
|
-
},
|
|
810
|
-
[disabled, readonly, onChange]
|
|
811
|
-
);
|
|
812
|
-
return /* @__PURE__ */ jsxs9("div", { className: "space-y-3", children: [
|
|
813
|
-
/* @__PURE__ */ jsx19("div", { className: "grid grid-cols-3 gap-2", children: getDateElementProps(
|
|
814
|
-
state,
|
|
815
|
-
time,
|
|
816
|
-
options.yearsRange,
|
|
817
|
-
options.format
|
|
818
|
-
).map((elemProps, i) => /* @__PURE__ */ jsxs9("div", { className: "form-control", children: [
|
|
819
|
-
/* @__PURE__ */ jsx19("label", { className: "label", children: /* @__PURE__ */ jsx19("span", { className: "label-text capitalize", children: elemProps.type }) }),
|
|
820
|
-
/* @__PURE__ */ jsx19(
|
|
775
|
+
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps(props);
|
|
776
|
+
return /* @__PURE__ */ jsxs10("div", { className: "space-y-3", children: [
|
|
777
|
+
/* @__PURE__ */ jsx21("div", { className: "grid grid-cols-3 gap-2", children: elements.map((elemProps, i) => /* @__PURE__ */ jsxs10("div", { className: "form-control", children: [
|
|
778
|
+
/* @__PURE__ */ jsx21("label", { className: "label", children: /* @__PURE__ */ jsx21("span", { className: "label-text capitalize", children: elemProps.type }) }),
|
|
779
|
+
/* @__PURE__ */ jsx21(
|
|
821
780
|
DateElement,
|
|
822
781
|
{
|
|
823
782
|
rootId: id,
|
|
824
783
|
name,
|
|
784
|
+
className: "select select-bordered select-sm",
|
|
825
785
|
select: handleChange,
|
|
826
786
|
type: elemProps.type,
|
|
827
787
|
range: elemProps.range,
|
|
@@ -835,8 +795,8 @@ function AltDateWidget({
|
|
|
835
795
|
}
|
|
836
796
|
)
|
|
837
797
|
] }, i)) }),
|
|
838
|
-
/* @__PURE__ */
|
|
839
|
-
(options.hideNowButton !== void 0 ? !options.hideNowButton : true) && /* @__PURE__ */
|
|
798
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex justify-start space-x-2", children: [
|
|
799
|
+
(options.hideNowButton !== void 0 ? !options.hideNowButton : true) && /* @__PURE__ */ jsx21(
|
|
840
800
|
"button",
|
|
841
801
|
{
|
|
842
802
|
type: "button",
|
|
@@ -846,7 +806,7 @@ function AltDateWidget({
|
|
|
846
806
|
children: translateString(TranslatableString5.NowLabel)
|
|
847
807
|
}
|
|
848
808
|
),
|
|
849
|
-
(options.hideClearButton !== void 0 ? !options.hideClearButton : true) && /* @__PURE__ */
|
|
809
|
+
(options.hideClearButton !== void 0 ? !options.hideClearButton : true) && /* @__PURE__ */ jsx21(
|
|
850
810
|
"button",
|
|
851
811
|
{
|
|
852
812
|
type: "button",
|
|
@@ -861,12 +821,13 @@ function AltDateWidget({
|
|
|
861
821
|
}
|
|
862
822
|
|
|
863
823
|
// src/widgets/CheckboxWidget/CheckboxWidget.tsx
|
|
864
|
-
import { useCallback as
|
|
865
|
-
import { getTemplate as
|
|
866
|
-
import { jsx as
|
|
824
|
+
import { useCallback as useCallback3 } from "react";
|
|
825
|
+
import { getTemplate as getTemplate5, descriptionId as descriptionId2 } from "@rjsf/utils";
|
|
826
|
+
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
867
827
|
function CheckboxWidget(props) {
|
|
868
828
|
const {
|
|
869
829
|
id,
|
|
830
|
+
htmlName,
|
|
870
831
|
value,
|
|
871
832
|
required,
|
|
872
833
|
disabled,
|
|
@@ -881,33 +842,34 @@ function CheckboxWidget(props) {
|
|
|
881
842
|
onFocus,
|
|
882
843
|
onBlur
|
|
883
844
|
} = props;
|
|
884
|
-
const DescriptionFieldTemplate =
|
|
845
|
+
const DescriptionFieldTemplate = getTemplate5(
|
|
885
846
|
"DescriptionFieldTemplate",
|
|
886
847
|
registry,
|
|
887
848
|
options
|
|
888
849
|
);
|
|
889
850
|
const description = options.description || schema.description;
|
|
890
|
-
const handleFocus =
|
|
851
|
+
const handleFocus = useCallback3(() => {
|
|
891
852
|
if (onFocus) {
|
|
892
853
|
onFocus(id, value);
|
|
893
854
|
}
|
|
894
855
|
}, [onFocus, id, value]);
|
|
895
|
-
const handleBlur =
|
|
856
|
+
const handleBlur = useCallback3(() => {
|
|
896
857
|
if (onBlur) {
|
|
897
858
|
onBlur(id, value);
|
|
898
859
|
}
|
|
899
860
|
}, [onBlur, id, value]);
|
|
900
|
-
const handleChange =
|
|
861
|
+
const handleChange = useCallback3(
|
|
901
862
|
(event) => {
|
|
902
863
|
onChange(event.target.checked);
|
|
903
864
|
},
|
|
904
865
|
[onChange]
|
|
905
866
|
);
|
|
906
|
-
const input = /* @__PURE__ */
|
|
867
|
+
const input = /* @__PURE__ */ jsx22(
|
|
907
868
|
"input",
|
|
908
869
|
{
|
|
909
870
|
type: "checkbox",
|
|
910
871
|
id,
|
|
872
|
+
name: htmlName || id,
|
|
911
873
|
checked: value,
|
|
912
874
|
required,
|
|
913
875
|
disabled: disabled || readonly,
|
|
@@ -917,8 +879,8 @@ function CheckboxWidget(props) {
|
|
|
917
879
|
className: "checkbox"
|
|
918
880
|
}
|
|
919
881
|
);
|
|
920
|
-
return /* @__PURE__ */
|
|
921
|
-
!hideLabel && description && /* @__PURE__ */
|
|
882
|
+
return /* @__PURE__ */ jsxs11("div", { className: "form-control", children: [
|
|
883
|
+
!hideLabel && description && /* @__PURE__ */ jsx22(
|
|
922
884
|
DescriptionFieldTemplate,
|
|
923
885
|
{
|
|
924
886
|
id: descriptionId2(id),
|
|
@@ -928,21 +890,22 @@ function CheckboxWidget(props) {
|
|
|
928
890
|
registry
|
|
929
891
|
}
|
|
930
892
|
),
|
|
931
|
-
hideLabel || !label ? input : /* @__PURE__ */
|
|
932
|
-
/* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
893
|
+
hideLabel || !label ? input : /* @__PURE__ */ jsxs11("label", { className: "label cursor-pointer justify-start", children: [
|
|
894
|
+
/* @__PURE__ */ jsx22("div", { className: "mr-2", children: input }),
|
|
895
|
+
/* @__PURE__ */ jsxs11("span", { className: "label-text", children: [
|
|
934
896
|
label,
|
|
935
|
-
required && /* @__PURE__ */
|
|
897
|
+
required && /* @__PURE__ */ jsx22("span", { className: "text-error ml-1", children: "*" })
|
|
936
898
|
] })
|
|
937
899
|
] })
|
|
938
900
|
] });
|
|
939
901
|
}
|
|
940
902
|
|
|
941
903
|
// src/widgets/CheckboxesWidget/CheckboxesWidget.tsx
|
|
942
|
-
import { useCallback as
|
|
943
|
-
import { jsx as
|
|
904
|
+
import { useCallback as useCallback4 } from "react";
|
|
905
|
+
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
944
906
|
function CheckboxesWidget({
|
|
945
907
|
id,
|
|
908
|
+
htmlName,
|
|
946
909
|
disabled,
|
|
947
910
|
options,
|
|
948
911
|
value,
|
|
@@ -954,7 +917,7 @@ function CheckboxesWidget({
|
|
|
954
917
|
}) {
|
|
955
918
|
const { enumOptions } = options;
|
|
956
919
|
const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
|
|
957
|
-
const isChecked =
|
|
920
|
+
const isChecked = useCallback4(
|
|
958
921
|
(option) => {
|
|
959
922
|
if (!Array.isArray(value)) {
|
|
960
923
|
return false;
|
|
@@ -966,7 +929,7 @@ function CheckboxesWidget({
|
|
|
966
929
|
},
|
|
967
930
|
[value, isEnumeratedObject]
|
|
968
931
|
);
|
|
969
|
-
const handleChange =
|
|
932
|
+
const handleChange = useCallback4(
|
|
970
933
|
(event) => {
|
|
971
934
|
const index = Number(event.target.dataset.index);
|
|
972
935
|
const option = enumOptions?.[index];
|
|
@@ -983,7 +946,7 @@ function CheckboxesWidget({
|
|
|
983
946
|
},
|
|
984
947
|
[onChange, value, isChecked, isEnumeratedObject, enumOptions]
|
|
985
948
|
);
|
|
986
|
-
const handleFocus =
|
|
949
|
+
const handleFocus = useCallback4(
|
|
987
950
|
(event) => {
|
|
988
951
|
if (onFocus) {
|
|
989
952
|
const index = Number(event.target.dataset.index);
|
|
@@ -995,7 +958,7 @@ function CheckboxesWidget({
|
|
|
995
958
|
},
|
|
996
959
|
[onFocus, id, enumOptions]
|
|
997
960
|
);
|
|
998
|
-
const handleBlur =
|
|
961
|
+
const handleBlur = useCallback4(
|
|
999
962
|
(event) => {
|
|
1000
963
|
if (onBlur) {
|
|
1001
964
|
const index = Number(event.target.dataset.index);
|
|
@@ -1007,14 +970,14 @@ function CheckboxesWidget({
|
|
|
1007
970
|
},
|
|
1008
971
|
[onBlur, id, enumOptions]
|
|
1009
972
|
);
|
|
1010
|
-
return /* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
973
|
+
return /* @__PURE__ */ jsx23("div", { className: "form-control", children: /* @__PURE__ */ jsx23("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxs12("label", { className: "flex items-center cursor-pointer gap-2", children: [
|
|
974
|
+
/* @__PURE__ */ jsx23(
|
|
1012
975
|
"input",
|
|
1013
976
|
{
|
|
1014
977
|
type: "checkbox",
|
|
1015
978
|
id: `${id}-${option.value}`,
|
|
1016
979
|
className: "checkbox",
|
|
1017
|
-
name: id,
|
|
980
|
+
name: htmlName || id,
|
|
1018
981
|
checked: isChecked(option),
|
|
1019
982
|
required,
|
|
1020
983
|
disabled: disabled || readonly,
|
|
@@ -1024,25 +987,25 @@ function CheckboxesWidget({
|
|
|
1024
987
|
onBlur: handleBlur
|
|
1025
988
|
}
|
|
1026
989
|
),
|
|
1027
|
-
/* @__PURE__ */
|
|
990
|
+
/* @__PURE__ */ jsx23("span", { className: "label-text", children: option.label })
|
|
1028
991
|
] }, option.value)) }) });
|
|
1029
992
|
}
|
|
1030
993
|
|
|
1031
994
|
// src/widgets/DateTimeWidget/DateTimeWidget.tsx
|
|
1032
|
-
import { memo as memo2, useCallback as
|
|
995
|
+
import { memo as memo2, useCallback as useCallback5, useEffect, useMemo, useRef, useState } from "react";
|
|
1033
996
|
import { faCalendar } from "@fortawesome/free-solid-svg-icons";
|
|
1034
997
|
import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
|
|
1035
998
|
import { format, isSameDay, isToday, isValid } from "date-fns";
|
|
1036
999
|
import { DayPicker, UI } from "react-day-picker";
|
|
1037
1000
|
import "react-day-picker/dist/style.css";
|
|
1038
|
-
import { jsx as
|
|
1001
|
+
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1039
1002
|
function useDatePickerState(initialDate) {
|
|
1040
|
-
const [isOpen, setIsOpen] =
|
|
1041
|
-
const [month, setMonth] =
|
|
1003
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
1004
|
+
const [month, setMonth] = useState(initialDate ?? /* @__PURE__ */ new Date());
|
|
1042
1005
|
return { isOpen, setIsOpen, month, setMonth };
|
|
1043
1006
|
}
|
|
1044
1007
|
function useClickOutside(ref, callback) {
|
|
1045
|
-
|
|
1008
|
+
useEffect(() => {
|
|
1046
1009
|
const handleClickOutside = (event) => {
|
|
1047
1010
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1048
1011
|
callback();
|
|
@@ -1087,11 +1050,11 @@ function DateTimePickerPopup({ selectedDate, month, onMonthChange, onSelect, onT
|
|
|
1087
1050
|
...dayPickerStyles.modifiers,
|
|
1088
1051
|
"custom-today": "btn btn-outline btn-info min-h-0 h-full"
|
|
1089
1052
|
};
|
|
1090
|
-
const handleClick =
|
|
1053
|
+
const handleClick = useCallback5((e) => {
|
|
1091
1054
|
e.stopPropagation();
|
|
1092
1055
|
}, []);
|
|
1093
|
-
return /* @__PURE__ */
|
|
1094
|
-
/* @__PURE__ */
|
|
1056
|
+
return /* @__PURE__ */ jsxs13("div", { className: "p-3", children: [
|
|
1057
|
+
/* @__PURE__ */ jsx24(
|
|
1095
1058
|
DayPicker,
|
|
1096
1059
|
{
|
|
1097
1060
|
mode: "single",
|
|
@@ -1108,9 +1071,9 @@ function DateTimePickerPopup({ selectedDate, month, onMonthChange, onSelect, onT
|
|
|
1108
1071
|
modifiersClassNames: customModifiersClassNames
|
|
1109
1072
|
}
|
|
1110
1073
|
),
|
|
1111
|
-
/* @__PURE__ */
|
|
1112
|
-
/* @__PURE__ */
|
|
1113
|
-
/* @__PURE__ */
|
|
1074
|
+
/* @__PURE__ */ jsx24("div", { className: "mt-3 border-t border-base-300 pt-3", children: /* @__PURE__ */ jsxs13("div", { className: "form-control w-full", children: [
|
|
1075
|
+
/* @__PURE__ */ jsx24("label", { className: "label", children: /* @__PURE__ */ jsx24("span", { className: "label-text", children: "Time" }) }),
|
|
1076
|
+
/* @__PURE__ */ jsx24(
|
|
1114
1077
|
"input",
|
|
1115
1078
|
{
|
|
1116
1079
|
type: "time",
|
|
@@ -1126,9 +1089,9 @@ function DateTimePickerPopup({ selectedDate, month, onMonthChange, onSelect, onT
|
|
|
1126
1089
|
var MemoizedDateTimePickerPopup = memo2(DateTimePickerPopup);
|
|
1127
1090
|
function DateTimeWidget(props) {
|
|
1128
1091
|
const { id, value, onChange, onFocus, onBlur, schema } = props;
|
|
1129
|
-
const initialDate =
|
|
1130
|
-
const [localDate, setLocalDate] =
|
|
1131
|
-
|
|
1092
|
+
const initialDate = useMemo(() => value ? new Date(value) : void 0, [value]);
|
|
1093
|
+
const [localDate, setLocalDate] = useState(initialDate);
|
|
1094
|
+
useEffect(() => {
|
|
1132
1095
|
setLocalDate(initialDate);
|
|
1133
1096
|
}, [initialDate]);
|
|
1134
1097
|
const { isOpen, setIsOpen, month, setMonth } = useDatePickerState(initialDate);
|
|
@@ -1143,13 +1106,13 @@ function DateTimeWidget(props) {
|
|
|
1143
1106
|
}
|
|
1144
1107
|
}
|
|
1145
1108
|
});
|
|
1146
|
-
|
|
1109
|
+
useEffect(() => {
|
|
1147
1110
|
if (localDate) {
|
|
1148
1111
|
setMonth(localDate);
|
|
1149
1112
|
}
|
|
1150
1113
|
}, [localDate, setMonth]);
|
|
1151
|
-
const handleMonthChange =
|
|
1152
|
-
const handleSelect =
|
|
1114
|
+
const handleMonthChange = useCallback5((date) => setMonth(date), [setMonth]);
|
|
1115
|
+
const handleSelect = useCallback5(
|
|
1153
1116
|
(date) => {
|
|
1154
1117
|
if (date) {
|
|
1155
1118
|
if (localDate) {
|
|
@@ -1160,7 +1123,7 @@ function DateTimeWidget(props) {
|
|
|
1160
1123
|
},
|
|
1161
1124
|
[localDate]
|
|
1162
1125
|
);
|
|
1163
|
-
const handleTimeChange =
|
|
1126
|
+
const handleTimeChange = useCallback5(
|
|
1164
1127
|
(e) => {
|
|
1165
1128
|
if (localDate) {
|
|
1166
1129
|
const [hours, minutes] = e.target.value.split(":");
|
|
@@ -1171,7 +1134,7 @@ function DateTimeWidget(props) {
|
|
|
1171
1134
|
},
|
|
1172
1135
|
[localDate]
|
|
1173
1136
|
);
|
|
1174
|
-
const togglePicker =
|
|
1137
|
+
const togglePicker = useCallback5(
|
|
1175
1138
|
(e) => {
|
|
1176
1139
|
e.stopPropagation();
|
|
1177
1140
|
setIsOpen((prev) => !prev);
|
|
@@ -1181,17 +1144,17 @@ function DateTimeWidget(props) {
|
|
|
1181
1144
|
},
|
|
1182
1145
|
[isOpen, id, onFocus, setIsOpen, value]
|
|
1183
1146
|
);
|
|
1184
|
-
const handleFocus =
|
|
1147
|
+
const handleFocus = useCallback5(() => {
|
|
1185
1148
|
if (onFocus) {
|
|
1186
1149
|
onFocus(id, value);
|
|
1187
1150
|
}
|
|
1188
1151
|
}, [id, onFocus, value]);
|
|
1189
|
-
const handleBlur =
|
|
1152
|
+
const handleBlur = useCallback5(() => {
|
|
1190
1153
|
if (!isOpen && onBlur) {
|
|
1191
1154
|
onBlur(id, value);
|
|
1192
1155
|
}
|
|
1193
1156
|
}, [id, onBlur, value, isOpen]);
|
|
1194
|
-
const handleKeyDown =
|
|
1157
|
+
const handleKeyDown = useCallback5(
|
|
1195
1158
|
(e) => {
|
|
1196
1159
|
if (e.key === "Enter" || e.key === " ") {
|
|
1197
1160
|
togglePicker(e);
|
|
@@ -1199,10 +1162,10 @@ function DateTimeWidget(props) {
|
|
|
1199
1162
|
},
|
|
1200
1163
|
[togglePicker]
|
|
1201
1164
|
);
|
|
1202
|
-
const handleContainerClick =
|
|
1165
|
+
const handleContainerClick = useCallback5((e) => {
|
|
1203
1166
|
e.stopPropagation();
|
|
1204
1167
|
}, []);
|
|
1205
|
-
|
|
1168
|
+
useEffect(() => {
|
|
1206
1169
|
const handleEscape = (e) => {
|
|
1207
1170
|
if (e.key === "Escape" && isOpen) {
|
|
1208
1171
|
setIsOpen(false);
|
|
@@ -1213,16 +1176,16 @@ function DateTimeWidget(props) {
|
|
|
1213
1176
|
};
|
|
1214
1177
|
document.addEventListener("keydown", handleEscape);
|
|
1215
1178
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
1216
|
-
}, [id, isOpen, onBlur, value]);
|
|
1217
|
-
const handleDoneClick =
|
|
1179
|
+
}, [id, isOpen, setIsOpen, onBlur, value]);
|
|
1180
|
+
const handleDoneClick = useCallback5(() => {
|
|
1218
1181
|
setIsOpen(false);
|
|
1219
1182
|
onChange(localDate ? localDate.toISOString() : "");
|
|
1220
1183
|
if (onBlur) {
|
|
1221
1184
|
onBlur(id, value);
|
|
1222
1185
|
}
|
|
1223
1186
|
inputRef.current?.focus();
|
|
1224
|
-
}, [localDate, onChange, onBlur, id, value]);
|
|
1225
|
-
return /* @__PURE__ */
|
|
1187
|
+
}, [localDate, onChange, onBlur, id, value, setIsOpen]);
|
|
1188
|
+
return /* @__PURE__ */ jsx24("div", { className: "form-control my-4 w-full relative", children: /* @__PURE__ */ jsxs13(
|
|
1226
1189
|
"div",
|
|
1227
1190
|
{
|
|
1228
1191
|
className: "w-full",
|
|
@@ -1232,7 +1195,7 @@ function DateTimeWidget(props) {
|
|
|
1232
1195
|
onBlur: handleBlur,
|
|
1233
1196
|
ref: inputRef,
|
|
1234
1197
|
children: [
|
|
1235
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ jsxs13(
|
|
1236
1199
|
"div",
|
|
1237
1200
|
{
|
|
1238
1201
|
id,
|
|
@@ -1243,19 +1206,19 @@ function DateTimeWidget(props) {
|
|
|
1243
1206
|
"aria-expanded": isOpen,
|
|
1244
1207
|
tabIndex: -1,
|
|
1245
1208
|
children: [
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
/* @__PURE__ */
|
|
1209
|
+
/* @__PURE__ */ jsx24("span", { className: localDate && isValid(localDate) ? "" : "text-base-content/50", children: localDate && isValid(localDate) ? format(localDate, "PP p") : schema.title }),
|
|
1210
|
+
/* @__PURE__ */ jsx24(FontAwesomeIcon2, { icon: faCalendar, className: "ml-2 h-4 w-4 text-primary" })
|
|
1248
1211
|
]
|
|
1249
1212
|
}
|
|
1250
1213
|
),
|
|
1251
|
-
isOpen && /* @__PURE__ */
|
|
1214
|
+
isOpen && /* @__PURE__ */ jsxs13(
|
|
1252
1215
|
"div",
|
|
1253
1216
|
{
|
|
1254
1217
|
ref: containerRef,
|
|
1255
1218
|
className: "absolute z-[100] mt-2 w-full max-w-xs bg-base-100 border border-base-300 shadow-lg rounded-box",
|
|
1256
1219
|
onClick: handleContainerClick,
|
|
1257
1220
|
children: [
|
|
1258
|
-
/* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ jsx24(
|
|
1259
1222
|
MemoizedDateTimePickerPopup,
|
|
1260
1223
|
{
|
|
1261
1224
|
selectedDate: localDate,
|
|
@@ -1265,7 +1228,7 @@ function DateTimeWidget(props) {
|
|
|
1265
1228
|
onTimeChange: handleTimeChange
|
|
1266
1229
|
}
|
|
1267
1230
|
),
|
|
1268
|
-
/* @__PURE__ */
|
|
1231
|
+
/* @__PURE__ */ jsx24("div", { className: "p-3 flex justify-end border-t border-base-300", children: /* @__PURE__ */ jsx24("button", { type: "button", className: "btn btn-sm btn-primary", onClick: handleDoneClick, children: "Done" }) })
|
|
1269
1232
|
]
|
|
1270
1233
|
}
|
|
1271
1234
|
)
|
|
@@ -1275,20 +1238,20 @@ function DateTimeWidget(props) {
|
|
|
1275
1238
|
}
|
|
1276
1239
|
|
|
1277
1240
|
// src/widgets/DateWidget/DateWidget.tsx
|
|
1278
|
-
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";
|
|
1279
1242
|
import { faCalendar as faCalendar2 } from "@fortawesome/free-solid-svg-icons";
|
|
1280
1243
|
import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
|
|
1281
1244
|
import { format as format2, isSameDay as isSameDay2, isToday as isToday2, isValid as isValid2 } from "date-fns";
|
|
1282
1245
|
import { DayPicker as DayPicker2, UI as UI2 } from "react-day-picker";
|
|
1283
1246
|
import "react-day-picker/dist/style.css";
|
|
1284
|
-
import { jsx as
|
|
1247
|
+
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1285
1248
|
function useDatePickerState2(initialDate) {
|
|
1286
|
-
const [isOpen, setIsOpen] =
|
|
1287
|
-
const [month, setMonth] =
|
|
1249
|
+
const [isOpen, setIsOpen] = useState2(false);
|
|
1250
|
+
const [month, setMonth] = useState2(initialDate ?? /* @__PURE__ */ new Date());
|
|
1288
1251
|
return { isOpen, setIsOpen, month, setMonth };
|
|
1289
1252
|
}
|
|
1290
1253
|
function useClickOutside2(ref, callback) {
|
|
1291
|
-
|
|
1254
|
+
useEffect2(() => {
|
|
1292
1255
|
const handleClickOutside = (event) => {
|
|
1293
1256
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1294
1257
|
callback();
|
|
@@ -1333,7 +1296,7 @@ function DatePickerPopup({ selectedDate, month, onMonthChange, onSelect }) {
|
|
|
1333
1296
|
...dayPickerStyles2.modifiers,
|
|
1334
1297
|
"custom-today": "btn btn-outline btn-info min-h-0 h-full"
|
|
1335
1298
|
};
|
|
1336
|
-
return /* @__PURE__ */
|
|
1299
|
+
return /* @__PURE__ */ jsx25("div", { className: "p-3", style: { minWidth: "320px", minHeight: "350px" }, children: /* @__PURE__ */ jsx25(
|
|
1337
1300
|
DayPicker2,
|
|
1338
1301
|
{
|
|
1339
1302
|
mode: "single",
|
|
@@ -1354,9 +1317,9 @@ function DatePickerPopup({ selectedDate, month, onMonthChange, onSelect }) {
|
|
|
1354
1317
|
var MemoizedDatePickerPopup = memo3(DatePickerPopup);
|
|
1355
1318
|
function DateWidget(props) {
|
|
1356
1319
|
const { id, value, onChange, onFocus, onBlur, schema } = props;
|
|
1357
|
-
const initialDate =
|
|
1358
|
-
const [localDate, setLocalDate] =
|
|
1359
|
-
|
|
1320
|
+
const initialDate = useMemo2(() => value ? new Date(value) : void 0, [value]);
|
|
1321
|
+
const [localDate, setLocalDate] = useState2(initialDate);
|
|
1322
|
+
useEffect2(() => {
|
|
1360
1323
|
setLocalDate(initialDate);
|
|
1361
1324
|
}, [initialDate]);
|
|
1362
1325
|
const { isOpen, setIsOpen, month, setMonth } = useDatePickerState2(initialDate);
|
|
@@ -1371,19 +1334,19 @@ function DateWidget(props) {
|
|
|
1371
1334
|
}
|
|
1372
1335
|
}
|
|
1373
1336
|
});
|
|
1374
|
-
|
|
1337
|
+
useEffect2(() => {
|
|
1375
1338
|
if (localDate) {
|
|
1376
1339
|
setMonth(localDate);
|
|
1377
1340
|
}
|
|
1378
1341
|
}, [localDate, setMonth]);
|
|
1379
|
-
const handleMonthChange =
|
|
1380
|
-
const handleSelect =
|
|
1342
|
+
const handleMonthChange = useCallback6((date) => setMonth(date), [setMonth]);
|
|
1343
|
+
const handleSelect = useCallback6((date) => {
|
|
1381
1344
|
if (date) {
|
|
1382
1345
|
date.setHours(0, 0, 0, 0);
|
|
1383
1346
|
setLocalDate(date);
|
|
1384
1347
|
}
|
|
1385
1348
|
}, []);
|
|
1386
|
-
|
|
1349
|
+
useEffect2(() => {
|
|
1387
1350
|
let portalContainer = document.getElementById("date-picker-portal");
|
|
1388
1351
|
if (!portalContainer) {
|
|
1389
1352
|
portalContainer = document.createElement("div");
|
|
@@ -1415,7 +1378,7 @@ function DateWidget(props) {
|
|
|
1415
1378
|
}
|
|
1416
1379
|
return { doc, win };
|
|
1417
1380
|
};
|
|
1418
|
-
const renderCalendar =
|
|
1381
|
+
const renderCalendar = useCallback6(() => {
|
|
1419
1382
|
if (!containerRef.current || !inputRef.current) {
|
|
1420
1383
|
return;
|
|
1421
1384
|
}
|
|
@@ -1433,7 +1396,7 @@ function DateWidget(props) {
|
|
|
1433
1396
|
}
|
|
1434
1397
|
containerRef.current.style.zIndex = "99999";
|
|
1435
1398
|
}, [containerRef, inputRef]);
|
|
1436
|
-
|
|
1399
|
+
useEffect2(() => {
|
|
1437
1400
|
if (!isOpen) {
|
|
1438
1401
|
return;
|
|
1439
1402
|
}
|
|
@@ -1445,7 +1408,7 @@ function DateWidget(props) {
|
|
|
1445
1408
|
window.removeEventListener("scroll", renderCalendar);
|
|
1446
1409
|
};
|
|
1447
1410
|
}, [isOpen, renderCalendar]);
|
|
1448
|
-
const togglePicker =
|
|
1411
|
+
const togglePicker = useCallback6(
|
|
1449
1412
|
(e) => {
|
|
1450
1413
|
e.stopPropagation();
|
|
1451
1414
|
setIsOpen((prev) => !prev);
|
|
@@ -1455,17 +1418,17 @@ function DateWidget(props) {
|
|
|
1455
1418
|
},
|
|
1456
1419
|
[isOpen, id, onFocus, setIsOpen, value]
|
|
1457
1420
|
);
|
|
1458
|
-
const handleFocus =
|
|
1421
|
+
const handleFocus = useCallback6(() => {
|
|
1459
1422
|
if (onFocus) {
|
|
1460
1423
|
onFocus(id, value);
|
|
1461
1424
|
}
|
|
1462
1425
|
}, [id, onFocus, value]);
|
|
1463
|
-
const handleBlur =
|
|
1426
|
+
const handleBlur = useCallback6(() => {
|
|
1464
1427
|
if (!isOpen && onBlur) {
|
|
1465
1428
|
onBlur(id, value);
|
|
1466
1429
|
}
|
|
1467
1430
|
}, [id, onBlur, value, isOpen]);
|
|
1468
|
-
|
|
1431
|
+
useEffect2(() => {
|
|
1469
1432
|
const handleEscape = (e) => {
|
|
1470
1433
|
if (e.key === "Escape" && isOpen) {
|
|
1471
1434
|
setIsOpen(false);
|
|
@@ -1476,16 +1439,16 @@ function DateWidget(props) {
|
|
|
1476
1439
|
};
|
|
1477
1440
|
document.addEventListener("keydown", handleEscape);
|
|
1478
1441
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
1479
|
-
}, [id, isOpen, onBlur, value]);
|
|
1480
|
-
const handleDoneClick =
|
|
1442
|
+
}, [id, isOpen, setIsOpen, onBlur, value]);
|
|
1443
|
+
const handleDoneClick = useCallback6(() => {
|
|
1481
1444
|
setIsOpen(false);
|
|
1482
1445
|
onChange(localDate ? localDate.toISOString() : "");
|
|
1483
1446
|
if (onBlur) {
|
|
1484
1447
|
onBlur(id, value);
|
|
1485
1448
|
}
|
|
1486
1449
|
inputRef.current?.focus();
|
|
1487
|
-
}, [localDate, onChange, onBlur, id, value]);
|
|
1488
|
-
return /* @__PURE__ */
|
|
1450
|
+
}, [localDate, onChange, onBlur, id, value, setIsOpen]);
|
|
1451
|
+
return /* @__PURE__ */ jsx25("div", { className: "form-control my-4 w-full relative", children: /* @__PURE__ */ jsxs14(
|
|
1489
1452
|
"div",
|
|
1490
1453
|
{
|
|
1491
1454
|
className: "w-full",
|
|
@@ -1499,7 +1462,7 @@ function DateWidget(props) {
|
|
|
1499
1462
|
onBlur: handleBlur,
|
|
1500
1463
|
ref: inputRef,
|
|
1501
1464
|
children: [
|
|
1502
|
-
/* @__PURE__ */
|
|
1465
|
+
/* @__PURE__ */ jsxs14(
|
|
1503
1466
|
"div",
|
|
1504
1467
|
{
|
|
1505
1468
|
id,
|
|
@@ -1510,12 +1473,12 @@ function DateWidget(props) {
|
|
|
1510
1473
|
"aria-expanded": isOpen,
|
|
1511
1474
|
tabIndex: -1,
|
|
1512
1475
|
children: [
|
|
1513
|
-
/* @__PURE__ */
|
|
1514
|
-
/* @__PURE__ */
|
|
1476
|
+
/* @__PURE__ */ jsx25("span", { className: localDate && isValid2(localDate) ? "" : "text-base-content/50", children: localDate && isValid2(localDate) ? format2(localDate, "PP") : schema.title }),
|
|
1477
|
+
/* @__PURE__ */ jsx25(FontAwesomeIcon3, { icon: faCalendar2, className: "ml-2 h-4 w-4 text-primary" })
|
|
1515
1478
|
]
|
|
1516
1479
|
}
|
|
1517
1480
|
),
|
|
1518
|
-
isOpen && /* @__PURE__ */
|
|
1481
|
+
isOpen && /* @__PURE__ */ jsxs14(
|
|
1519
1482
|
"div",
|
|
1520
1483
|
{
|
|
1521
1484
|
ref: containerRef,
|
|
@@ -1526,7 +1489,7 @@ function DateWidget(props) {
|
|
|
1526
1489
|
},
|
|
1527
1490
|
onClick: (e) => e.stopPropagation(),
|
|
1528
1491
|
children: [
|
|
1529
|
-
/* @__PURE__ */
|
|
1492
|
+
/* @__PURE__ */ jsx25(
|
|
1530
1493
|
MemoizedDatePickerPopup,
|
|
1531
1494
|
{
|
|
1532
1495
|
selectedDate: localDate,
|
|
@@ -1535,7 +1498,7 @@ function DateWidget(props) {
|
|
|
1535
1498
|
onSelect: handleSelect
|
|
1536
1499
|
}
|
|
1537
1500
|
),
|
|
1538
|
-
/* @__PURE__ */
|
|
1501
|
+
/* @__PURE__ */ jsx25("div", { className: "p-3 flex justify-end border-t border-base-300", children: /* @__PURE__ */ jsx25("button", { type: "button", className: "btn btn-sm btn-primary", onClick: handleDoneClick, children: "Done" }) })
|
|
1539
1502
|
]
|
|
1540
1503
|
}
|
|
1541
1504
|
)
|
|
@@ -1544,65 +1507,12 @@ function DateWidget(props) {
|
|
|
1544
1507
|
) });
|
|
1545
1508
|
}
|
|
1546
1509
|
|
|
1547
|
-
// src/widgets/FileWidget/FileWidget.tsx
|
|
1548
|
-
import { useCallback as useCallback9 } from "react";
|
|
1549
|
-
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
1550
|
-
function FileWidget(props) {
|
|
1551
|
-
const { id, required, disabled, readonly, schema, onChange, onFocus, onBlur, options = {} } = props;
|
|
1552
|
-
const isMulti = schema.type === "array" || Boolean(options.multiple);
|
|
1553
|
-
const accept = typeof options.accept === "string" ? options.accept : void 0;
|
|
1554
|
-
const handleChange = useCallback9(
|
|
1555
|
-
(event) => {
|
|
1556
|
-
if (!event.target.files) {
|
|
1557
|
-
return;
|
|
1558
|
-
}
|
|
1559
|
-
const fileList = Array.from(event.target.files);
|
|
1560
|
-
if (isMulti) {
|
|
1561
|
-
onChange(fileList);
|
|
1562
|
-
} else {
|
|
1563
|
-
onChange(fileList[0] || null);
|
|
1564
|
-
}
|
|
1565
|
-
},
|
|
1566
|
-
[onChange, isMulti]
|
|
1567
|
-
);
|
|
1568
|
-
const handleFocus = useCallback9(
|
|
1569
|
-
(event) => {
|
|
1570
|
-
if (onFocus) {
|
|
1571
|
-
onFocus(id, event.target.files ? Array.from(event.target.files) : null);
|
|
1572
|
-
}
|
|
1573
|
-
},
|
|
1574
|
-
[onFocus, id]
|
|
1575
|
-
);
|
|
1576
|
-
const handleBlur = useCallback9(
|
|
1577
|
-
(event) => {
|
|
1578
|
-
if (onBlur) {
|
|
1579
|
-
onBlur(id, event.target.files ? Array.from(event.target.files) : null);
|
|
1580
|
-
}
|
|
1581
|
-
},
|
|
1582
|
-
[onBlur, id]
|
|
1583
|
-
);
|
|
1584
|
-
return /* @__PURE__ */ jsx24(
|
|
1585
|
-
"input",
|
|
1586
|
-
{
|
|
1587
|
-
id,
|
|
1588
|
-
type: "file",
|
|
1589
|
-
className: "file-input w-full",
|
|
1590
|
-
required,
|
|
1591
|
-
disabled: disabled || readonly,
|
|
1592
|
-
onChange: handleChange,
|
|
1593
|
-
onFocus: handleFocus,
|
|
1594
|
-
onBlur: handleBlur,
|
|
1595
|
-
multiple: isMulti,
|
|
1596
|
-
accept
|
|
1597
|
-
}
|
|
1598
|
-
);
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
1510
|
// src/widgets/RadioWidget/RadioWidget.tsx
|
|
1602
|
-
import { useCallback as
|
|
1603
|
-
import { jsx as
|
|
1511
|
+
import { useCallback as useCallback7 } from "react";
|
|
1512
|
+
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1604
1513
|
function RadioWidget({
|
|
1605
1514
|
id,
|
|
1515
|
+
htmlName,
|
|
1606
1516
|
options,
|
|
1607
1517
|
value,
|
|
1608
1518
|
required,
|
|
@@ -1623,7 +1533,7 @@ function RadioWidget({
|
|
|
1623
1533
|
}
|
|
1624
1534
|
return value === option.value;
|
|
1625
1535
|
};
|
|
1626
|
-
const handleFocus =
|
|
1536
|
+
const handleFocus = useCallback7(
|
|
1627
1537
|
(event) => {
|
|
1628
1538
|
if (onFocus) {
|
|
1629
1539
|
const index = Number(event.target.dataset.index);
|
|
@@ -1633,7 +1543,7 @@ function RadioWidget({
|
|
|
1633
1543
|
},
|
|
1634
1544
|
[onFocus, id, enumOptions]
|
|
1635
1545
|
);
|
|
1636
|
-
const handleBlur =
|
|
1546
|
+
const handleBlur = useCallback7(
|
|
1637
1547
|
(event) => {
|
|
1638
1548
|
if (onBlur) {
|
|
1639
1549
|
const index = Number(event.target.dataset.index);
|
|
@@ -1643,7 +1553,7 @@ function RadioWidget({
|
|
|
1643
1553
|
},
|
|
1644
1554
|
[onBlur, id, enumOptions]
|
|
1645
1555
|
);
|
|
1646
|
-
const handleChange =
|
|
1556
|
+
const handleChange = useCallback7(
|
|
1647
1557
|
(event) => {
|
|
1648
1558
|
const index = Number(event.target.dataset.index);
|
|
1649
1559
|
const option = enumOptions?.[index];
|
|
@@ -1654,14 +1564,14 @@ function RadioWidget({
|
|
|
1654
1564
|
},
|
|
1655
1565
|
[onChange, isEnumeratedObject, enumOptions]
|
|
1656
1566
|
);
|
|
1657
|
-
return /* @__PURE__ */
|
|
1658
|
-
/* @__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(
|
|
1659
1569
|
"input",
|
|
1660
1570
|
{
|
|
1661
1571
|
type: "radio",
|
|
1662
1572
|
id: `${id}-${option.value}`,
|
|
1663
1573
|
className: "radio",
|
|
1664
|
-
name: id,
|
|
1574
|
+
name: htmlName || id,
|
|
1665
1575
|
value: getValue(option),
|
|
1666
1576
|
checked: isChecked(option),
|
|
1667
1577
|
required,
|
|
@@ -1672,13 +1582,13 @@ function RadioWidget({
|
|
|
1672
1582
|
onBlur: handleBlur
|
|
1673
1583
|
}
|
|
1674
1584
|
),
|
|
1675
|
-
/* @__PURE__ */
|
|
1585
|
+
/* @__PURE__ */ jsx26("span", { className: "label-text", children: option.label })
|
|
1676
1586
|
] }, option.value)) }) });
|
|
1677
1587
|
}
|
|
1678
1588
|
|
|
1679
1589
|
// src/widgets/RangeWidget/RangeWidget.tsx
|
|
1680
|
-
import { useCallback as
|
|
1681
|
-
import { jsx as
|
|
1590
|
+
import { useCallback as useCallback8 } from "react";
|
|
1591
|
+
import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1682
1592
|
function RangeWidget({
|
|
1683
1593
|
id,
|
|
1684
1594
|
value,
|
|
@@ -1700,14 +1610,14 @@ function RangeWidget({
|
|
|
1700
1610
|
onBlur(id, event.target.value);
|
|
1701
1611
|
}
|
|
1702
1612
|
};
|
|
1703
|
-
const handleChange =
|
|
1613
|
+
const handleChange = useCallback8(
|
|
1704
1614
|
(event) => {
|
|
1705
1615
|
onChange(event.target.value);
|
|
1706
1616
|
},
|
|
1707
1617
|
[onChange]
|
|
1708
1618
|
);
|
|
1709
|
-
return /* @__PURE__ */
|
|
1710
|
-
/* @__PURE__ */
|
|
1619
|
+
return /* @__PURE__ */ jsx27("div", { className: "form-control", children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center", children: [
|
|
1620
|
+
/* @__PURE__ */ jsx27(
|
|
1711
1621
|
"input",
|
|
1712
1622
|
{
|
|
1713
1623
|
type: "range",
|
|
@@ -1724,13 +1634,13 @@ function RangeWidget({
|
|
|
1724
1634
|
onBlur: handleBlur
|
|
1725
1635
|
}
|
|
1726
1636
|
),
|
|
1727
|
-
/* @__PURE__ */
|
|
1637
|
+
/* @__PURE__ */ jsx27("span", { className: "label-text ml-4", children: value })
|
|
1728
1638
|
] }) });
|
|
1729
1639
|
}
|
|
1730
1640
|
|
|
1731
1641
|
// src/widgets/RatingWidget/RatingWidget.tsx
|
|
1732
|
-
import { useCallback as
|
|
1733
|
-
import { jsx as
|
|
1642
|
+
import { useCallback as useCallback9 } from "react";
|
|
1643
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1734
1644
|
function RatingWidget({
|
|
1735
1645
|
id,
|
|
1736
1646
|
value,
|
|
@@ -1749,13 +1659,13 @@ function RatingWidget({
|
|
|
1749
1659
|
const min = schema.minimum || 0;
|
|
1750
1660
|
const maskClass = shape === "heart" ? "mask-heart" : "mask-star-2";
|
|
1751
1661
|
const sizeClass = size === "md" ? "" : `rating-${size}`;
|
|
1752
|
-
const _onChange =
|
|
1662
|
+
const _onChange = useCallback9(
|
|
1753
1663
|
({ target: { value: value2 } }) => {
|
|
1754
1664
|
onChange(parseInt(value2));
|
|
1755
1665
|
},
|
|
1756
1666
|
[onChange]
|
|
1757
1667
|
);
|
|
1758
|
-
const handleFocus =
|
|
1668
|
+
const handleFocus = useCallback9(
|
|
1759
1669
|
(event) => {
|
|
1760
1670
|
if (onFocus) {
|
|
1761
1671
|
const starValue = Number(event.target.value);
|
|
@@ -1764,7 +1674,7 @@ function RatingWidget({
|
|
|
1764
1674
|
},
|
|
1765
1675
|
[onFocus, id]
|
|
1766
1676
|
);
|
|
1767
|
-
const handleBlur =
|
|
1677
|
+
const handleBlur = useCallback9(
|
|
1768
1678
|
(event) => {
|
|
1769
1679
|
if (onBlur) {
|
|
1770
1680
|
const starValue = Number(event.target.value);
|
|
@@ -1781,9 +1691,9 @@ function RatingWidget({
|
|
|
1781
1691
|
const colorIdx = Math.min(index, colors.length - 1);
|
|
1782
1692
|
return `bg-${colors[colorIdx]}-400`;
|
|
1783
1693
|
};
|
|
1784
|
-
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) => {
|
|
1785
1695
|
const starValue = min + index;
|
|
1786
|
-
return /* @__PURE__ */
|
|
1696
|
+
return /* @__PURE__ */ jsx28(
|
|
1787
1697
|
"input",
|
|
1788
1698
|
{
|
|
1789
1699
|
type: "radio",
|
|
@@ -1805,12 +1715,12 @@ function RatingWidget({
|
|
|
1805
1715
|
}
|
|
1806
1716
|
|
|
1807
1717
|
// src/widgets/SelectWidget/SelectWidget.tsx
|
|
1808
|
-
import { useCallback as
|
|
1718
|
+
import { useCallback as useCallback10 } from "react";
|
|
1809
1719
|
import {
|
|
1810
1720
|
enumOptionsIndexForValue,
|
|
1811
1721
|
enumOptionsValueForIndex
|
|
1812
1722
|
} from "@rjsf/utils";
|
|
1813
|
-
import { jsx as
|
|
1723
|
+
import { jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1814
1724
|
function SelectWidget({
|
|
1815
1725
|
schema,
|
|
1816
1726
|
id,
|
|
@@ -1840,7 +1750,7 @@ function SelectWidget({
|
|
|
1840
1750
|
return String(val);
|
|
1841
1751
|
};
|
|
1842
1752
|
const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
|
|
1843
|
-
const handleOptionClick =
|
|
1753
|
+
const handleOptionClick = useCallback10(
|
|
1844
1754
|
(event) => {
|
|
1845
1755
|
const index = Number(event.currentTarget.dataset.value);
|
|
1846
1756
|
if (isNaN(index)) {
|
|
@@ -1859,7 +1769,7 @@ function SelectWidget({
|
|
|
1859
1769
|
},
|
|
1860
1770
|
[value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, onChange]
|
|
1861
1771
|
);
|
|
1862
|
-
const _onBlur =
|
|
1772
|
+
const _onBlur = useCallback10(
|
|
1863
1773
|
({ target }) => {
|
|
1864
1774
|
const dataValue = target?.getAttribute("data-value");
|
|
1865
1775
|
if (dataValue !== null) {
|
|
@@ -1868,7 +1778,7 @@ function SelectWidget({
|
|
|
1868
1778
|
},
|
|
1869
1779
|
[onBlur, id, enumOptions, optEmptyVal]
|
|
1870
1780
|
);
|
|
1871
|
-
const _onFocus =
|
|
1781
|
+
const _onFocus = useCallback10(
|
|
1872
1782
|
({ target }) => {
|
|
1873
1783
|
const dataValue = target?.getAttribute("data-value");
|
|
1874
1784
|
if (dataValue !== null) {
|
|
@@ -1880,8 +1790,8 @@ function SelectWidget({
|
|
|
1880
1790
|
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1881
1791
|
const selectedValues = Array.isArray(selectedIndexes) ? selectedIndexes : [selectedIndexes];
|
|
1882
1792
|
const optionsList = enumOptions || (Array.isArray(schema.examples) ? schema.examples.map((example) => ({ value: example, label: example })) : []);
|
|
1883
|
-
return /* @__PURE__ */
|
|
1884
|
-
/* @__PURE__ */
|
|
1793
|
+
return /* @__PURE__ */ jsx29("div", { className: "form-control w-full", children: /* @__PURE__ */ jsxs17("div", { className: "dropdown w-full", children: [
|
|
1794
|
+
/* @__PURE__ */ jsxs17(
|
|
1885
1795
|
"div",
|
|
1886
1796
|
{
|
|
1887
1797
|
tabIndex: 0,
|
|
@@ -1890,12 +1800,12 @@ function SelectWidget({
|
|
|
1890
1800
|
onBlur: _onBlur,
|
|
1891
1801
|
onFocus: _onFocus,
|
|
1892
1802
|
children: [
|
|
1893
|
-
/* @__PURE__ */
|
|
1894
|
-
/* @__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" })
|
|
1895
1805
|
]
|
|
1896
1806
|
}
|
|
1897
1807
|
),
|
|
1898
|
-
/* @__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(
|
|
1899
1809
|
"li",
|
|
1900
1810
|
{
|
|
1901
1811
|
role: "button",
|
|
@@ -1903,8 +1813,8 @@ function SelectWidget({
|
|
|
1903
1813
|
className: `px-4 py-2 hover:bg-base-200 cursor-pointer ${selectedValues.includes(String(i)) ? "bg-primary/10" : ""}`,
|
|
1904
1814
|
onClick: handleOptionClick,
|
|
1905
1815
|
"data-value": i,
|
|
1906
|
-
children: /* @__PURE__ */
|
|
1907
|
-
multiple && /* @__PURE__ */
|
|
1816
|
+
children: /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
|
|
1817
|
+
multiple && /* @__PURE__ */ jsx29(
|
|
1908
1818
|
"input",
|
|
1909
1819
|
{
|
|
1910
1820
|
type: "checkbox",
|
|
@@ -1913,7 +1823,7 @@ function SelectWidget({
|
|
|
1913
1823
|
readOnly: true
|
|
1914
1824
|
}
|
|
1915
1825
|
),
|
|
1916
|
-
/* @__PURE__ */
|
|
1826
|
+
/* @__PURE__ */ jsx29("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
|
|
1917
1827
|
] })
|
|
1918
1828
|
},
|
|
1919
1829
|
i
|
|
@@ -1922,11 +1832,11 @@ function SelectWidget({
|
|
|
1922
1832
|
}
|
|
1923
1833
|
|
|
1924
1834
|
// src/widgets/TextareaWidget/TextareaWidget.tsx
|
|
1925
|
-
import { useCallback as
|
|
1926
|
-
import { jsx as
|
|
1835
|
+
import { useCallback as useCallback11 } from "react";
|
|
1836
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
1927
1837
|
function TextareaWidget(props) {
|
|
1928
|
-
const { id, value, required, disabled, readonly, onChange, onFocus, onBlur, options } = props;
|
|
1929
|
-
const handleFocus =
|
|
1838
|
+
const { id, htmlName, value, required, disabled, readonly, onChange, onFocus, onBlur, options } = props;
|
|
1839
|
+
const handleFocus = useCallback11(
|
|
1930
1840
|
(event) => {
|
|
1931
1841
|
if (onFocus) {
|
|
1932
1842
|
onFocus(id, event.target.value);
|
|
@@ -1934,7 +1844,7 @@ function TextareaWidget(props) {
|
|
|
1934
1844
|
},
|
|
1935
1845
|
[onFocus, id]
|
|
1936
1846
|
);
|
|
1937
|
-
const handleBlur =
|
|
1847
|
+
const handleBlur = useCallback11(
|
|
1938
1848
|
(event) => {
|
|
1939
1849
|
if (onBlur) {
|
|
1940
1850
|
onBlur(id, event.target.value);
|
|
@@ -1942,17 +1852,18 @@ function TextareaWidget(props) {
|
|
|
1942
1852
|
},
|
|
1943
1853
|
[onBlur, id]
|
|
1944
1854
|
);
|
|
1945
|
-
const handleChange =
|
|
1855
|
+
const handleChange = useCallback11(
|
|
1946
1856
|
(event) => {
|
|
1947
1857
|
onChange(event.target.value);
|
|
1948
1858
|
},
|
|
1949
1859
|
[onChange]
|
|
1950
1860
|
);
|
|
1951
1861
|
const rows = options?.rows || 5;
|
|
1952
|
-
return /* @__PURE__ */
|
|
1862
|
+
return /* @__PURE__ */ jsx30("div", { className: "form-control", children: /* @__PURE__ */ jsx30(
|
|
1953
1863
|
"textarea",
|
|
1954
1864
|
{
|
|
1955
1865
|
id,
|
|
1866
|
+
name: htmlName || id,
|
|
1956
1867
|
value: value || "",
|
|
1957
1868
|
required,
|
|
1958
1869
|
disabled: disabled || readonly,
|
|
@@ -1967,11 +1878,11 @@ function TextareaWidget(props) {
|
|
|
1967
1878
|
}
|
|
1968
1879
|
|
|
1969
1880
|
// src/widgets/TimeWidget/TimeWidget.tsx
|
|
1970
|
-
import { useCallback as
|
|
1971
|
-
import { jsx as
|
|
1881
|
+
import { useCallback as useCallback12 } from "react";
|
|
1882
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1972
1883
|
function TimeWidget(props) {
|
|
1973
1884
|
const { id, value, onChange, onFocus, onBlur, required, disabled, readonly } = props;
|
|
1974
|
-
const handleFocus =
|
|
1885
|
+
const handleFocus = useCallback12(
|
|
1975
1886
|
(event) => {
|
|
1976
1887
|
if (onFocus) {
|
|
1977
1888
|
onFocus(id, event.target.value);
|
|
@@ -1979,7 +1890,7 @@ function TimeWidget(props) {
|
|
|
1979
1890
|
},
|
|
1980
1891
|
[onFocus, id]
|
|
1981
1892
|
);
|
|
1982
|
-
const handleBlur =
|
|
1893
|
+
const handleBlur = useCallback12(
|
|
1983
1894
|
(event) => {
|
|
1984
1895
|
if (onBlur) {
|
|
1985
1896
|
onBlur(id, event.target.value);
|
|
@@ -1987,13 +1898,13 @@ function TimeWidget(props) {
|
|
|
1987
1898
|
},
|
|
1988
1899
|
[onBlur, id]
|
|
1989
1900
|
);
|
|
1990
|
-
const handleChange =
|
|
1901
|
+
const handleChange = useCallback12(
|
|
1991
1902
|
(event) => {
|
|
1992
1903
|
onChange(event.target.value);
|
|
1993
1904
|
},
|
|
1994
1905
|
[onChange]
|
|
1995
1906
|
);
|
|
1996
|
-
return /* @__PURE__ */
|
|
1907
|
+
return /* @__PURE__ */ jsx31("div", { className: "form-control", children: /* @__PURE__ */ jsx31(
|
|
1997
1908
|
"input",
|
|
1998
1909
|
{
|
|
1999
1910
|
type: "time",
|
|
@@ -2011,27 +1922,27 @@ function TimeWidget(props) {
|
|
|
2011
1922
|
}
|
|
2012
1923
|
|
|
2013
1924
|
// src/widgets/ToggleWidget/ToggleWidget.tsx
|
|
2014
|
-
import { useCallback as
|
|
2015
|
-
import { jsx as
|
|
1925
|
+
import { useCallback as useCallback13 } from "react";
|
|
1926
|
+
import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2016
1927
|
function ToggleWidget({ id, value, required, disabled, readonly, autofocus, onChange, onFocus, onBlur, options }) {
|
|
2017
|
-
const _onChange =
|
|
1928
|
+
const _onChange = useCallback13(
|
|
2018
1929
|
({ target: { checked } }) => onChange(checked),
|
|
2019
1930
|
[onChange]
|
|
2020
1931
|
);
|
|
2021
|
-
const handleFocus =
|
|
1932
|
+
const handleFocus = useCallback13(() => {
|
|
2022
1933
|
if (onFocus) {
|
|
2023
1934
|
onFocus(id, value);
|
|
2024
1935
|
}
|
|
2025
1936
|
}, [onFocus, id, value]);
|
|
2026
|
-
const handleBlur =
|
|
1937
|
+
const handleBlur = useCallback13(() => {
|
|
2027
1938
|
if (onBlur) {
|
|
2028
1939
|
onBlur(id, value);
|
|
2029
1940
|
}
|
|
2030
1941
|
}, [onBlur, id, value]);
|
|
2031
1942
|
const { size = "md" } = options;
|
|
2032
1943
|
const sizeClass = size !== "md" ? `toggle-${size}` : "";
|
|
2033
|
-
return /* @__PURE__ */
|
|
2034
|
-
/* @__PURE__ */
|
|
1944
|
+
return /* @__PURE__ */ jsx32("div", { className: "form-control", children: /* @__PURE__ */ jsxs18("label", { className: "cursor-pointer label my-auto", children: [
|
|
1945
|
+
/* @__PURE__ */ jsx32(
|
|
2035
1946
|
"input",
|
|
2036
1947
|
{
|
|
2037
1948
|
type: "checkbox",
|
|
@@ -2046,7 +1957,7 @@ function ToggleWidget({ id, value, required, disabled, readonly, autofocus, onCh
|
|
|
2046
1957
|
className: `toggle ${sizeClass}`
|
|
2047
1958
|
}
|
|
2048
1959
|
),
|
|
2049
|
-
/* @__PURE__ */
|
|
1960
|
+
/* @__PURE__ */ jsx32("span", { className: "label-text", children: options.label })
|
|
2050
1961
|
] }) });
|
|
2051
1962
|
}
|
|
2052
1963
|
|
|
@@ -2059,7 +1970,6 @@ function generateWidgets() {
|
|
|
2059
1970
|
CheckboxWidget,
|
|
2060
1971
|
DateTimeWidget,
|
|
2061
1972
|
DateWidget,
|
|
2062
|
-
FileWidget,
|
|
2063
1973
|
RadioWidget,
|
|
2064
1974
|
RangeWidget,
|
|
2065
1975
|
RatingWidget,
|
|
@@ -2072,7 +1982,7 @@ function generateWidgets() {
|
|
|
2072
1982
|
var Widgets_default = generateWidgets;
|
|
2073
1983
|
|
|
2074
1984
|
// src/theme/Theme.tsx
|
|
2075
|
-
import { jsx as
|
|
1985
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
2076
1986
|
function generateTheme() {
|
|
2077
1987
|
const { fields } = getDefaultRegistry();
|
|
2078
1988
|
const generatedWidgets = generateWidgets();
|
|
@@ -2094,21 +2004,21 @@ var ThemeContext = createContext({
|
|
|
2094
2004
|
}
|
|
2095
2005
|
});
|
|
2096
2006
|
function ThemeProvider({ children }) {
|
|
2097
|
-
const [theme, setTheme] =
|
|
2007
|
+
const [theme, setTheme] = useState3(() => {
|
|
2098
2008
|
try {
|
|
2099
2009
|
return localStorage.getItem("daisyui-theme") || "cupcake";
|
|
2100
2010
|
} catch {
|
|
2101
2011
|
return "cupcake";
|
|
2102
2012
|
}
|
|
2103
2013
|
});
|
|
2104
|
-
const handleSetTheme =
|
|
2014
|
+
const handleSetTheme = useCallback14((newTheme) => {
|
|
2105
2015
|
try {
|
|
2106
2016
|
localStorage.setItem("daisyui-theme", newTheme);
|
|
2107
2017
|
setTheme(newTheme);
|
|
2108
2018
|
} catch {
|
|
2109
2019
|
}
|
|
2110
2020
|
}, []);
|
|
2111
|
-
return /* @__PURE__ */
|
|
2021
|
+
return /* @__PURE__ */ jsx33(ThemeContext.Provider, { value: { theme, setTheme: handleSetTheme }, children });
|
|
2112
2022
|
}
|
|
2113
2023
|
var useTheme = () => useContext(ThemeContext);
|
|
2114
2024
|
|
|
@@ -2118,8 +2028,8 @@ var DaisyUIForm = withTheme(Theme_default);
|
|
|
2118
2028
|
var DaisyUIForm_default = DaisyUIForm;
|
|
2119
2029
|
|
|
2120
2030
|
// src/DaisyUIFrameProvider.tsx
|
|
2121
|
-
import { useEffect as
|
|
2122
|
-
import { jsx as
|
|
2031
|
+
import { useEffect as useEffect3 } from "react";
|
|
2032
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
2123
2033
|
function DaisyUIFrameComponent(props) {
|
|
2124
2034
|
const { children, subtheme = {}, document: document2 } = props;
|
|
2125
2035
|
const theme = (() => {
|
|
@@ -2133,7 +2043,7 @@ function DaisyUIFrameComponent(props) {
|
|
|
2133
2043
|
return "cupcake";
|
|
2134
2044
|
}
|
|
2135
2045
|
})();
|
|
2136
|
-
|
|
2046
|
+
useEffect3(() => {
|
|
2137
2047
|
if (document2) {
|
|
2138
2048
|
const configScript = document2.createElement("script");
|
|
2139
2049
|
configScript.textContent = `
|
|
@@ -2168,11 +2078,11 @@ function DaisyUIFrameComponent(props) {
|
|
|
2168
2078
|
}
|
|
2169
2079
|
return void 0;
|
|
2170
2080
|
}, [document2]);
|
|
2171
|
-
return /* @__PURE__ */
|
|
2081
|
+
return /* @__PURE__ */ jsx34("div", { "data-theme": theme, className: "daisy-ui-theme", children });
|
|
2172
2082
|
}
|
|
2173
2083
|
var __createDaisyUIFrameProvider = (props) => {
|
|
2174
2084
|
return function DaisyUIFrame({ document: document2 }) {
|
|
2175
|
-
return /* @__PURE__ */
|
|
2085
|
+
return /* @__PURE__ */ jsx34(DaisyUIFrameComponent, { document: document2, ...props });
|
|
2176
2086
|
};
|
|
2177
2087
|
};
|
|
2178
2088
|
|