@rjsf/daisyui 6.0.0-beta.9 → 6.0.1

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.
Files changed (99) hide show
  1. package/README.md +9 -16
  2. package/dist/chakra-ui.esm.js +382 -472
  3. package/dist/chakra-ui.esm.js.map +4 -4
  4. package/dist/chakra-ui.umd.js +194 -287
  5. package/dist/{index.js → index.cjs} +404 -496
  6. package/dist/index.cjs.map +7 -0
  7. package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.d.ts +2 -2
  8. package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js +2 -7
  9. package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js.map +1 -1
  10. package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +3 -3
  11. package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
  12. package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
  13. package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js +3 -4
  14. package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  15. package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js +7 -3
  16. package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js.map +1 -1
  17. package/lib/templates/BaseInputTemplate/BaseInputTemplate.js +8 -2
  18. package/lib/templates/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  19. package/lib/templates/ButtonTemplates/AddButton.js +1 -1
  20. package/lib/templates/ButtonTemplates/AddButton.js.map +1 -1
  21. package/lib/templates/ButtonTemplates/IconButton.js +4 -4
  22. package/lib/templates/ButtonTemplates/IconButton.js.map +1 -1
  23. package/lib/templates/FieldTemplate/FieldTemplate.js +6 -3
  24. package/lib/templates/FieldTemplate/FieldTemplate.js.map +1 -1
  25. package/lib/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -0
  26. package/lib/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +6 -0
  27. package/lib/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -0
  28. package/lib/templates/MultiSchemaFieldTemplate/index.d.ts +2 -0
  29. package/lib/templates/MultiSchemaFieldTemplate/index.js +3 -0
  30. package/lib/templates/MultiSchemaFieldTemplate/index.js.map +1 -0
  31. package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js +4 -3
  32. package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
  33. package/lib/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +10 -0
  34. package/lib/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +23 -0
  35. package/lib/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -0
  36. package/lib/templates/OptionalDataControlsTemplate/index.d.ts +2 -0
  37. package/lib/templates/OptionalDataControlsTemplate/index.js +3 -0
  38. package/lib/templates/OptionalDataControlsTemplate/index.js.map +1 -0
  39. package/lib/templates/Templates.js +4 -0
  40. package/lib/templates/Templates.js.map +1 -1
  41. package/lib/templates/TitleField/TitleField.js +6 -2
  42. package/lib/templates/TitleField/TitleField.js.map +1 -1
  43. package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +11 -11
  44. package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
  45. package/lib/tsconfig.tsbuildinfo +1 -1
  46. package/lib/widgets/AltDateWidget/AltDateWidget.d.ts +1 -1
  47. package/lib/widgets/AltDateWidget/AltDateWidget.js +5 -121
  48. package/lib/widgets/AltDateWidget/AltDateWidget.js.map +1 -1
  49. package/lib/widgets/CheckboxWidget/CheckboxWidget.js +2 -2
  50. package/lib/widgets/CheckboxWidget/CheckboxWidget.js.map +1 -1
  51. package/lib/widgets/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
  52. package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js +2 -2
  53. package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  54. package/lib/widgets/DateTimeWidget/DateTimeWidget.js +2 -2
  55. package/lib/widgets/DateTimeWidget/DateTimeWidget.js.map +1 -1
  56. package/lib/widgets/DateWidget/DateWidget.js +2 -2
  57. package/lib/widgets/DateWidget/DateWidget.js.map +1 -1
  58. package/lib/widgets/RadioWidget/RadioWidget.d.ts +1 -1
  59. package/lib/widgets/RadioWidget/RadioWidget.js +2 -2
  60. package/lib/widgets/RadioWidget/RadioWidget.js.map +1 -1
  61. package/lib/widgets/TextareaWidget/TextareaWidget.js +2 -2
  62. package/lib/widgets/TextareaWidget/TextareaWidget.js.map +1 -1
  63. package/lib/widgets/Widgets.d.ts +1 -2
  64. package/lib/widgets/Widgets.js +1 -3
  65. package/lib/widgets/Widgets.js.map +1 -1
  66. package/package.json +24 -22
  67. package/src/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.tsx +15 -20
  68. package/src/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -3
  69. package/src/templates/ArrayFieldTemplate/ArrayFieldTemplate.tsx +9 -13
  70. package/src/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx +12 -2
  71. package/src/templates/BaseInputTemplate/BaseInputTemplate.tsx +14 -6
  72. package/src/templates/ButtonTemplates/AddButton.tsx +1 -1
  73. package/src/templates/ButtonTemplates/IconButton.tsx +4 -4
  74. package/src/templates/FieldTemplate/FieldTemplate.tsx +48 -19
  75. package/src/templates/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +15 -0
  76. package/src/templates/MultiSchemaFieldTemplate/index.ts +2 -0
  77. package/src/templates/ObjectFieldTemplate/ObjectFieldTemplate.tsx +13 -9
  78. package/src/templates/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +46 -0
  79. package/src/templates/OptionalDataControlsTemplate/index.ts +2 -0
  80. package/src/templates/Templates.tsx +4 -0
  81. package/src/templates/TitleField/TitleField.tsx +12 -3
  82. package/src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +38 -34
  83. package/src/widgets/AltDateWidget/AltDateWidget.tsx +18 -253
  84. package/src/widgets/CheckboxWidget/CheckboxWidget.tsx +5 -3
  85. package/src/widgets/CheckboxesWidget/CheckboxesWidget.tsx +2 -1
  86. package/src/widgets/DateTimeWidget/DateTimeWidget.tsx +2 -2
  87. package/src/widgets/DateWidget/DateWidget.tsx +2 -2
  88. package/src/widgets/RadioWidget/RadioWidget.tsx +2 -1
  89. package/src/widgets/TextareaWidget/TextareaWidget.tsx +2 -1
  90. package/src/widgets/Widgets.tsx +0 -3
  91. package/dist/index.js.map +0 -7
  92. package/lib/widgets/FileWidget/FileWidget.d.ts +0 -12
  93. package/lib/widgets/FileWidget/FileWidget.js +0 -57
  94. package/lib/widgets/FileWidget/FileWidget.js.map +0 -1
  95. package/lib/widgets/FileWidget/index.d.ts +0 -2
  96. package/lib/widgets/FileWidget/index.js +0 -3
  97. package/lib/widgets/FileWidget/index.js.map +0 -1
  98. package/src/widgets/FileWidget/FileWidget.tsx +0 -86
  99. package/src/widgets/FileWidget/index.ts +0 -2
@@ -12,20 +12,16 @@
12
12
  hasMoveDown,
13
13
  hasMoveUp,
14
14
  hasRemove,
15
- idSchema,
16
- index,
17
- onCopyIndexClick,
18
- onDropIndexClick,
19
- onReorderClick,
15
+ fieldPathId,
16
+ onCopyItem,
17
+ onRemoveItem,
18
+ onMoveDownItem,
19
+ onMoveUpItem,
20
20
  readonly,
21
21
  registry,
22
22
  uiSchema
23
23
  } = props;
24
24
  const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
25
- const onCopyClick = react.useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
26
- const onRemoveClick = react.useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
27
- const onArrowUpClick = react.useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
28
- const onArrowDownClick = react.useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
29
25
  const renderMany = [hasMoveUp || hasMoveDown, hasCopy, hasRemove].filter(Boolean).length > 1;
30
26
  const btnClass = renderMany ? "join-item btn btn-sm px-2" : "btn btn-sm px-2 rounded-sm";
31
27
  const removeBtnClass = renderMany ? "join-item btn btn-sm btn-error px-2" : "btn btn-sm btn-error px-2 rounded-sm";
@@ -34,10 +30,10 @@
34
30
  /* @__PURE__ */ jsxRuntime.jsx(
35
31
  MoveUpButton2,
36
32
  {
37
- id: utils.buttonId(idSchema, "moveUp"),
33
+ id: utils.buttonId(fieldPathId, "moveUp"),
38
34
  className: `rjsf-array-item-move-up ${btnClass}`,
39
35
  disabled: disabled || readonly || !hasMoveUp,
40
- onClick: onArrowUpClick,
36
+ onClick: onMoveUpItem,
41
37
  uiSchema,
42
38
  registry
43
39
  }
@@ -45,10 +41,10 @@
45
41
  /* @__PURE__ */ jsxRuntime.jsx(
46
42
  MoveDownButton2,
47
43
  {
48
- id: utils.buttonId(idSchema, "moveDown"),
44
+ id: utils.buttonId(fieldPathId, "moveDown"),
49
45
  className: `rjsf-array-item-move-down ${btnClass}`,
50
46
  disabled: disabled || readonly || !hasMoveDown,
51
- onClick: onArrowDownClick,
47
+ onClick: onMoveDownItem,
52
48
  uiSchema,
53
49
  registry
54
50
  }
@@ -57,10 +53,10 @@
57
53
  hasCopy && /* @__PURE__ */ jsxRuntime.jsx(
58
54
  CopyButton2,
59
55
  {
60
- id: utils.buttonId(idSchema, "copy"),
56
+ id: utils.buttonId(fieldPathId, "copy"),
61
57
  className: `rjsf-array-item-copy ${btnClass}`,
62
58
  disabled: disabled || readonly,
63
- onClick: onCopyClick,
59
+ onClick: onCopyItem,
64
60
  uiSchema,
65
61
  registry
66
62
  }
@@ -68,10 +64,10 @@
68
64
  hasRemove && /* @__PURE__ */ jsxRuntime.jsx(
69
65
  RemoveButton2,
70
66
  {
71
- id: utils.buttonId(idSchema, "remove"),
67
+ id: utils.buttonId(fieldPathId, "remove"),
72
68
  className: `rjsf-array-item-remove ${removeBtnClass}`,
73
69
  disabled: disabled || readonly,
74
- onClick: onRemoveClick,
70
+ onClick: onRemoveItem,
75
71
  uiSchema,
76
72
  registry
77
73
  }
@@ -102,8 +98,9 @@
102
98
  canAdd,
103
99
  className,
104
100
  disabled,
105
- idSchema,
101
+ fieldPathId,
106
102
  items,
103
+ optionalDataControl,
107
104
  onAddClick,
108
105
  readonly,
109
106
  registry,
@@ -118,16 +115,12 @@
118
115
  registry,
119
116
  uiOptions
120
117
  );
121
- const ArrayFieldItemTemplate2 = utils.getTemplate(
122
- "ArrayFieldItemTemplate",
123
- registry,
124
- uiOptions
125
- );
126
118
  const ArrayFieldTitleTemplate = utils.getTemplate(
127
119
  "ArrayFieldTitleTemplate",
128
120
  registry,
129
121
  uiOptions
130
122
  );
123
+ const showOptionalDataControlInTitle = !readonly && !disabled;
131
124
  const {
132
125
  ButtonTemplates: { AddButton: AddButton2 }
133
126
  } = registry.templates;
@@ -143,18 +136,19 @@
143
136
  /* @__PURE__ */ jsxRuntime.jsx(
144
137
  ArrayFieldTitleTemplate,
145
138
  {
146
- idSchema,
139
+ fieldPathId,
147
140
  title: uiOptions.title || title,
148
141
  schema,
149
142
  uiSchema,
150
143
  required,
151
- registry
144
+ registry,
145
+ optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
152
146
  }
153
147
  ),
154
148
  /* @__PURE__ */ jsxRuntime.jsx(
155
149
  ArrayFieldDescriptionTemplate,
156
150
  {
157
- idSchema,
151
+ fieldPathId,
158
152
  description: uiOptions.description || schema.description,
159
153
  schema,
160
154
  uiSchema,
@@ -162,14 +156,15 @@
162
156
  }
163
157
  ),
164
158
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
159
+ !showOptionalDataControlInTitle ? optionalDataControl : void 0,
165
160
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rjsf-array-item-list", children: [
166
- items && items.map(({ key, ...itemProps }, index) => /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...itemProps, index, totalItems: items.length }, key)),
161
+ items,
167
162
  items && items.length === 0 && canAdd && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center italic text-base-content/70", children: utils.TranslatableString.EmptyArray })
168
163
  ] }),
169
164
  canAdd && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(
170
165
  AddButton2,
171
166
  {
172
- id: utils.buttonId(idSchema, "add"),
167
+ id: utils.buttonId(fieldPathId, "add"),
173
168
  className: "rjsf-array-item-add btn btn-primary btn-sm",
174
169
  onClick: handleAddClick,
175
170
  disabled: disabled || readonly,
@@ -183,6 +178,8 @@
183
178
  function BaseInputTemplate(props) {
184
179
  const {
185
180
  id,
181
+ htmlName,
182
+ multiple,
186
183
  value,
187
184
  required,
188
185
  disabled,
@@ -199,6 +196,12 @@
199
196
  placeholder
200
197
  } = props;
201
198
  const inputProps = utils.getInputProps(schema, type, options);
199
+ let className = "input input-bordered";
200
+ let isMulti = multiple;
201
+ if (type === "file") {
202
+ isMulti = schema.type === "array" || Boolean(options.multiple);
203
+ className = "file-input w-full";
204
+ }
202
205
  const { step, min, max, accept, ...rest } = inputProps;
203
206
  const htmlInputProps = { step, min, max, accept, ...schema.examples ? { list: utils.examplesId(id) } : void 0 };
204
207
  const _onChange = react.useCallback(
@@ -220,13 +223,14 @@
220
223
  "input",
221
224
  {
222
225
  id,
223
- name: id,
226
+ name: htmlName || id,
224
227
  value: value || value === 0 ? value : "",
225
228
  placeholder,
226
229
  required,
227
230
  disabled: disabled || readonly,
228
231
  autoFocus: autofocus,
229
- className: "input input-bordered",
232
+ className,
233
+ multiple: isMulti,
230
234
  ...rest,
231
235
  ...htmlInputProps,
232
236
  onChange: onChangeOverride || _onChange,
@@ -259,11 +263,11 @@
259
263
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "row", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx(
260
264
  DaisyUIButton_default,
261
265
  {
266
+ title: translateString(utils.TranslatableString.AddButton),
262
267
  ...otherProps,
263
268
  iconType: "info",
264
269
  icon: freeSolidSvgIcons.faPlus,
265
270
  className: "btn-add col-xs-12 btn-primary btn-primary-content",
266
- title: translateString(utils.TranslatableString.AddButton),
267
271
  onClick,
268
272
  disabled,
269
273
  registry
@@ -289,7 +293,7 @@
289
293
  const {
290
294
  registry: { translateString }
291
295
  } = props;
292
- return /* @__PURE__ */ jsxRuntime.jsx(DaisyUIButton_default, { ...props, title: translateString(utils.TranslatableString.CopyButton), icon: freeSolidSvgIcons.faCopy });
296
+ return /* @__PURE__ */ jsxRuntime.jsx(DaisyUIButton_default, { title: translateString(utils.TranslatableString.CopyButton), ...props, icon: freeSolidSvgIcons.faCopy });
293
297
  }
294
298
  function MoveDownButton(props) {
295
299
  const {
@@ -298,8 +302,8 @@
298
302
  return /* @__PURE__ */ jsxRuntime.jsx(
299
303
  DaisyUIButton_default,
300
304
  {
301
- ...props,
302
305
  title: translateString(utils.TranslatableString.MoveDownButton),
306
+ ...props,
303
307
  icon: freeSolidSvgIcons.faArrowDown
304
308
  }
305
309
  );
@@ -311,8 +315,8 @@
311
315
  return /* @__PURE__ */ jsxRuntime.jsx(
312
316
  DaisyUIButton_default,
313
317
  {
314
- ...props,
315
318
  title: translateString(utils.TranslatableString.MoveUpButton),
319
+ ...props,
316
320
  icon: freeSolidSvgIcons.faArrowUp
317
321
  }
318
322
  );
@@ -324,8 +328,8 @@
324
328
  return /* @__PURE__ */ jsxRuntime.jsx(
325
329
  DaisyUIButton_default,
326
330
  {
327
- ...props,
328
331
  title: translateString(utils.TranslatableString.RemoveButton),
332
+ ...props,
329
333
  iconType: "danger",
330
334
  icon: freeSolidSvgIcons.faTrash
331
335
  }
@@ -356,37 +360,61 @@
356
360
  label,
357
361
  children,
358
362
  errors,
359
- formContext,
360
363
  formData,
361
364
  help,
362
365
  hideError,
363
366
  displayLabel,
367
+ onKeyRename,
368
+ onKeyRenameBlur,
369
+ onRemoveProperty,
364
370
  classNames,
365
- // Destructure props we don't want to pass to div
366
- onKeyChange,
367
- onDropPropertyClick,
368
371
  uiSchema,
369
372
  schema,
370
373
  readonly,
371
374
  required,
375
+ registry,
376
+ // Destructure props we don't want to pass to div
377
+ description,
372
378
  rawErrors,
373
379
  rawHelp,
374
380
  rawDescription,
375
381
  hidden,
376
382
  onChange,
377
- registry,
378
383
  ...divProps
379
384
  } = props;
380
385
  const isCheckbox = schema.type === "boolean";
381
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `field-template mb-3 ${classNames || ""}`, ...divProps, children: [
382
- displayLabel && !isCheckbox && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "label", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "label-text font-medium", children: [
386
+ const uiOptions = utils.getUiOptions(uiSchema);
387
+ const WrapIfAdditionalTemplate2 = utils.getTemplate(
388
+ "WrapIfAdditionalTemplate",
389
+ registry,
390
+ uiOptions
391
+ );
392
+ return /* @__PURE__ */ jsxRuntime.jsx(
393
+ WrapIfAdditionalTemplate2,
394
+ {
395
+ classNames,
396
+ disabled: divProps.disabled,
397
+ id,
383
398
  label,
384
- required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-error ml-1", children: "*" })
385
- ] }) }),
386
- children,
387
- errors,
388
- help
389
- ] });
399
+ onKeyRename,
400
+ onKeyRenameBlur,
401
+ onRemoveProperty,
402
+ readonly,
403
+ required,
404
+ schema,
405
+ uiSchema,
406
+ registry,
407
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `field-template mb-3 ${classNames || ""}`, ...divProps, children: [
408
+ displayLabel && !isCheckbox && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "label", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "label-text font-medium", children: [
409
+ label,
410
+ required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-error ml-1", children: "*" })
411
+ ] }) }),
412
+ children,
413
+ errors,
414
+ help
415
+ ] })
416
+ }
417
+ );
390
418
  }
391
419
  function GridTemplate(props) {
392
420
  const { children, column, ...rest } = props;
@@ -395,6 +423,13 @@
395
423
  }
396
424
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-4", ...rest, children });
397
425
  }
426
+ function MultiSchemaFieldTemplate(props) {
427
+ const { optionSchemaField, selector } = props;
428
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 border rounded-sm shadow-sm", children: [
429
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4", children: selector }),
430
+ optionSchemaField
431
+ ] });
432
+ }
398
433
  function ObjectFieldTemplate(props) {
399
434
  const {
400
435
  description,
@@ -404,10 +439,11 @@
404
439
  disabled,
405
440
  readonly,
406
441
  uiSchema,
407
- idSchema,
442
+ fieldPathId,
408
443
  schema,
409
444
  formData,
410
- onAddClick,
445
+ optionalDataControl,
446
+ onAddProperty,
411
447
  registry
412
448
  } = props;
413
449
  const uiOptions = utils.getUiOptions(uiSchema);
@@ -417,26 +453,28 @@
417
453
  registry,
418
454
  uiOptions
419
455
  );
456
+ const showOptionalDataControlInTitle = !readonly && !disabled;
420
457
  const {
421
458
  ButtonTemplates: { AddButton: AddButton2 }
422
459
  } = registry.templates;
423
- const isRoot = idSchema.$id === "root";
460
+ const isRoot = fieldPathId.$id === "root";
424
461
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `form-control ${isRoot ? "bg-base-100 p-6 rounded-xl shadow-lg" : ""}`, children: [
425
462
  title && /* @__PURE__ */ jsxRuntime.jsx(
426
463
  TitleFieldTemplate,
427
464
  {
428
- id: utils.titleId(idSchema),
465
+ id: utils.titleId(fieldPathId),
429
466
  title,
430
467
  required,
431
468
  schema,
432
469
  uiSchema,
433
- registry
470
+ registry,
471
+ optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
434
472
  }
435
473
  ),
436
474
  description && /* @__PURE__ */ jsxRuntime.jsx(
437
475
  DescriptionFieldTemplate,
438
476
  {
439
- id: utils.descriptionId(idSchema),
477
+ id: utils.descriptionId(fieldPathId),
440
478
  description,
441
479
  schema,
442
480
  uiSchema,
@@ -444,22 +482,23 @@
444
482
  }
445
483
  ),
446
484
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `grid grid-cols-1 gap-${description ? 3 : 4} ${isRoot ? "" : "mb-4"}`, children: [
485
+ !showOptionalDataControlInTitle ? optionalDataControl : void 0,
447
486
  properties.map(
448
487
  (element, index) => element.hidden ? element.content : /* @__PURE__ */ jsxRuntime.jsx(
449
488
  "div",
450
489
  {
451
- className: idSchema.$id === "root" && element.name === "tasks" ? "mt-2" : "",
490
+ className: fieldPathId.$id === "root" && element.name === "tasks" ? "mt-2" : "",
452
491
  children: element.content
453
492
  },
454
- `${idSchema.$id}-${element.name}-${index}`
493
+ `${fieldPathId.$id}-${element.name}-${index}`
455
494
  )
456
495
  ),
457
496
  utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(
458
497
  AddButton2,
459
498
  {
460
- id: utils.buttonId(idSchema, "add"),
499
+ id: utils.buttonId(fieldPathId, "add"),
461
500
  className: "rjsf-object-property-expand btn btn-primary btn-sm",
462
- onClick: onAddClick(schema),
501
+ onClick: onAddProperty,
463
502
  disabled: disabled || readonly,
464
503
  uiSchema,
465
504
  registry
@@ -468,12 +507,48 @@
468
507
  ] })
469
508
  ] });
470
509
  }
510
+ function OptionalDataControlsTemplate(props) {
511
+ const { id, registry, label, onAddClick, onRemoveClick } = props;
512
+ if (onAddClick) {
513
+ return /* @__PURE__ */ jsxRuntime.jsx(
514
+ DaisyUIButton_default,
515
+ {
516
+ id,
517
+ registry,
518
+ iconType: "info",
519
+ icon: freeSolidSvgIcons.faPlus,
520
+ className: "rjsf-add-optional-data",
521
+ onClick: onAddClick,
522
+ title: label
523
+ }
524
+ );
525
+ } else if (onRemoveClick) {
526
+ return /* @__PURE__ */ jsxRuntime.jsx(
527
+ RemoveButton,
528
+ {
529
+ id,
530
+ registry,
531
+ className: "rjsf-remove-optional-data",
532
+ onClick: onRemoveClick,
533
+ title: label
534
+ }
535
+ );
536
+ }
537
+ return /* @__PURE__ */ jsxRuntime.jsx("em", { id, children: label });
538
+ }
471
539
  function TitleField(props) {
472
- const { id, title, uiSchema } = props;
540
+ const { id, title, uiSchema, optionalDataControl } = props;
473
541
  const uiOptions = utils.getUiOptions(uiSchema);
542
+ let heading = /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-3xl font-bold text-primary mb-2", children: uiOptions.title || title });
543
+ if (optionalDataControl) {
544
+ heading = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex", children: [
545
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-auto", children: heading }),
546
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: optionalDataControl })
547
+ ] });
548
+ }
474
549
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { id, className: "title-field mb-6", children: [
475
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-3xl font-bold text-primary mb-2", children: uiOptions.title || title }),
476
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divider divider-primary" })
550
+ heading,
551
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divider divider-primary my-0" })
477
552
  ] });
478
553
  }
479
554
  function WrapIfAdditionalTemplate(props) {
@@ -486,47 +561,48 @@
486
561
  readonly,
487
562
  required,
488
563
  schema,
489
- onKeyChange,
490
- onDropPropertyClick,
564
+ uiSchema,
565
+ onKeyRename,
566
+ onKeyRenameBlur,
567
+ onRemoveProperty,
491
568
  registry,
492
569
  ...rest
493
570
  } = props;
494
- const { translateString } = registry;
495
- const handleBlur = react.useCallback(
496
- (event) => {
497
- onKeyChange(event.target.value);
498
- },
499
- [onKeyChange]
500
- );
501
- const handleRemove = react.useCallback(() => {
502
- onDropPropertyClick(label)();
503
- }, [onDropPropertyClick, label]);
504
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `wrap-if-additional-template ${classNames}`, ...rest, children: [
505
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
571
+ const additional = utils.ADDITIONAL_PROPERTY_FLAG in schema;
572
+ const { templates, translateString } = registry;
573
+ const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
574
+ const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
575
+ if (!additional) {
576
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, children });
577
+ }
578
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `wrap-if-additional-template ${classNames}`, ...rest, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline", style: { justifyContent: "space-between" }, children: [
579
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
580
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: `${id}-key`, className: "label", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "label-text", children: keyLabel }) }),
506
581
  /* @__PURE__ */ jsxRuntime.jsx(
507
582
  "input",
508
583
  {
509
584
  type: "text",
510
585
  className: "input input-bordered",
511
586
  id: `${id}-key`,
512
- onBlur: handleBlur,
587
+ onBlur: onKeyRenameBlur,
513
588
  defaultValue: label,
514
589
  disabled: disabled || readonly
515
590
  }
516
- ),
517
- schema.additionalProperties && /* @__PURE__ */ jsxRuntime.jsx(
518
- "button",
519
- {
520
- id: utils.buttonId(id, "remove"),
521
- className: "rjsf-array-item-remove btn btn-danger ml-2",
522
- onClick: handleRemove,
523
- disabled: disabled || readonly,
524
- children: translateString(utils.TranslatableString.RemoveButton)
525
- }
526
591
  )
527
592
  ] }),
528
- children
529
- ] });
593
+ children,
594
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex self-center", children: /* @__PURE__ */ jsxRuntime.jsx(
595
+ RemoveButton2,
596
+ {
597
+ id: utils.buttonId(id, "remove"),
598
+ className: "rjsf-object-property-remove",
599
+ disabled: disabled || readonly,
600
+ onClick: onRemoveProperty,
601
+ uiSchema,
602
+ registry
603
+ }
604
+ ) })
605
+ ] }) });
530
606
  }
531
607
 
532
608
  // src/templates/Templates.tsx
@@ -550,7 +626,9 @@
550
626
  FieldHelpTemplate,
551
627
  FieldTemplate,
552
628
  GridTemplate,
629
+ MultiSchemaFieldTemplate,
553
630
  ObjectFieldTemplate,
631
+ OptionalDataControlsTemplate,
554
632
  TitleFieldTemplate: TitleField,
555
633
  WrapIfAdditionalTemplate
556
634
  };
@@ -564,154 +642,29 @@
564
642
  return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { time, ...props });
565
643
  }
566
644
  var AltDateTimeWidget_default = AltDateTimeWidget;
567
- function readyForChange(state, time = false) {
568
- return state.year && state.month && state.day && (!time || state.hour && state.minute && state.second);
569
- }
570
- function getDateElementProps(state, time, yearsRange, format3 = "YMD") {
571
- const rangeOptions = yearsRange ?? [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2];
572
- const formats = {
573
- YMD: ["year", "month", "day"],
574
- MDY: ["month", "day", "year"],
575
- DMY: ["day", "month", "year"]
576
- };
577
- const dateElements = formats[format3].map((key) => ({
578
- type: key,
579
- value: state[key],
580
- range: key === "year" ? rangeOptions : key === "month" ? [1, 12] : key === "day" ? [1, 31] : [0, 59]
581
- }));
582
- if (time) {
583
- dateElements.push(
584
- { type: "hour", value: state.hour, range: [0, 23] },
585
- { type: "minute", value: state.minute, range: [0, 59] },
586
- { type: "second", value: state.second, range: [0, 59] }
587
- );
588
- }
589
- return dateElements;
590
- }
591
- function DateElement({
592
- type,
593
- range,
594
- value,
595
- select,
596
- rootId,
597
- name,
598
- disabled,
599
- readonly,
600
- autofocus,
601
- registry,
602
- onBlur,
603
- onFocus
604
- }) {
605
- const id = `${rootId}_${type}`;
606
- const { SelectWidget: SelectWidget2 } = registry.widgets;
607
- const handleChange = react.useCallback(
608
- (value2) => {
609
- select(type, value2);
610
- },
611
- [select, type]
612
- );
613
- return /* @__PURE__ */ jsxRuntime.jsx(
614
- SelectWidget2,
615
- {
616
- schema: { type: "integer" },
617
- id,
618
- name,
619
- className: "select select-bordered select-sm w-full",
620
- options: { enumOptions: utils.dateRangeOptions(range[0], range[1]) },
621
- placeholder: type,
622
- value,
623
- disabled,
624
- readonly,
625
- autofocus,
626
- onChange: handleChange,
627
- onBlur,
628
- onFocus,
629
- registry,
630
- label: "",
631
- "aria-describedby": utils.ariaDescribedByIds(rootId),
632
- required: false
633
- }
634
- );
635
- }
636
- function convertToRJSFDateObject(dateObj) {
637
- return {
638
- year: dateObj.year ? parseInt(dateObj.year) : 0,
639
- month: dateObj.month ? parseInt(dateObj.month) : 0,
640
- day: dateObj.day ? parseInt(dateObj.day) : 0,
641
- hour: dateObj.hour ? parseInt(dateObj.hour) : 0,
642
- minute: dateObj.minute ? parseInt(dateObj.minute) : 0,
643
- second: dateObj.second ? parseInt(dateObj.second) : 0
644
- };
645
- }
646
- function AltDateWidget({
647
- time = false,
648
- disabled = false,
649
- readonly = false,
650
- autofocus = false,
651
- options = {},
652
- id,
653
- name,
654
- registry,
655
- onBlur,
656
- onFocus,
657
- onChange,
658
- value
659
- }) {
645
+ function AltDateWidget(props) {
646
+ const {
647
+ disabled = false,
648
+ readonly = false,
649
+ autofocus = false,
650
+ options = {},
651
+ id,
652
+ name,
653
+ registry,
654
+ onBlur,
655
+ onFocus
656
+ } = props;
660
657
  const { translateString } = registry;
661
- const [lastValue, setLastValue] = react.useState(value);
662
- const initialState = utils.parseDateString(value, time);
663
- const dateReducer = (state2, action) => {
664
- return { ...state2, ...action };
665
- };
666
- const [state, setState] = react.useReducer(dateReducer, initialState);
667
- react.useEffect(() => {
668
- const rjsfDateObj = convertToRJSFDateObject(state);
669
- const stateValue = utils.toDateString(rjsfDateObj, time);
670
- if (readyForChange(state, time) && stateValue !== value) {
671
- onChange(stateValue);
672
- } else if (lastValue !== value) {
673
- setLastValue(value);
674
- setState(utils.parseDateString(value, time));
675
- }
676
- }, [time, value, onChange, state, lastValue]);
677
- const handleChange = react.useCallback((property, value2) => {
678
- setState({ [property]: value2 });
679
- }, []);
680
- const handleSetNow = react.useCallback(
681
- (event) => {
682
- event.preventDefault();
683
- if (disabled || readonly) {
684
- return;
685
- }
686
- const nextState = utils.parseDateString((/* @__PURE__ */ new Date()).toJSON(), time);
687
- const rjsfDateObj = convertToRJSFDateObject(nextState);
688
- onChange(utils.toDateString(rjsfDateObj, time));
689
- },
690
- [disabled, readonly, time, onChange]
691
- );
692
- const handleClear = react.useCallback(
693
- (event) => {
694
- event.preventDefault();
695
- if (disabled || readonly) {
696
- return;
697
- }
698
- onChange(void 0);
699
- },
700
- [disabled, readonly, onChange]
701
- );
658
+ const { elements, handleChange, handleClear, handleSetNow } = utils.useAltDateWidgetProps(props);
702
659
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
703
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-3 gap-2", children: getDateElementProps(
704
- state,
705
- time,
706
- options.yearsRange,
707
- options.format
708
- ).map((elemProps, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "form-control", children: [
660
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-3 gap-2", children: elements.map((elemProps, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "form-control", children: [
709
661
  /* @__PURE__ */ jsxRuntime.jsx("label", { className: "label", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "label-text capitalize", children: elemProps.type }) }),
710
662
  /* @__PURE__ */ jsxRuntime.jsx(
711
- DateElement,
663
+ utils.DateElement,
712
664
  {
713
665
  rootId: id,
714
666
  name,
667
+ className: "select select-bordered select-sm",
715
668
  select: handleChange,
716
669
  type: elemProps.type,
717
670
  range: elemProps.range,
@@ -752,6 +705,7 @@
752
705
  function CheckboxWidget(props) {
753
706
  const {
754
707
  id,
708
+ htmlName,
755
709
  value,
756
710
  required,
757
711
  disabled,
@@ -793,6 +747,7 @@
793
747
  {
794
748
  type: "checkbox",
795
749
  id,
750
+ name: htmlName || id,
796
751
  checked: value,
797
752
  required,
798
753
  disabled: disabled || readonly,
@@ -824,6 +779,7 @@
824
779
  }
825
780
  function CheckboxesWidget({
826
781
  id,
782
+ htmlName,
827
783
  disabled,
828
784
  options,
829
785
  value,
@@ -895,7 +851,7 @@
895
851
  type: "checkbox",
896
852
  id: `${id}-${option.value}`,
897
853
  className: "checkbox",
898
- name: id,
854
+ name: htmlName || id,
899
855
  checked: isChecked(option),
900
856
  required,
901
857
  disabled: disabled || readonly,
@@ -1085,7 +1041,7 @@
1085
1041
  };
1086
1042
  document.addEventListener("keydown", handleEscape);
1087
1043
  return () => document.removeEventListener("keydown", handleEscape);
1088
- }, [id, isOpen, onBlur, value]);
1044
+ }, [id, isOpen, setIsOpen, onBlur, value]);
1089
1045
  const handleDoneClick = react.useCallback(() => {
1090
1046
  setIsOpen(false);
1091
1047
  onChange(localDate ? localDate.toISOString() : "");
@@ -1093,7 +1049,7 @@
1093
1049
  onBlur(id, value);
1094
1050
  }
1095
1051
  inputRef.current?.focus();
1096
- }, [localDate, onChange, onBlur, id, value]);
1052
+ }, [localDate, onChange, onBlur, id, value, setIsOpen]);
1097
1053
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-control my-4 w-full relative", children: /* @__PURE__ */ jsxRuntime.jsxs(
1098
1054
  "div",
1099
1055
  {
@@ -1339,7 +1295,7 @@
1339
1295
  };
1340
1296
  document.addEventListener("keydown", handleEscape);
1341
1297
  return () => document.removeEventListener("keydown", handleEscape);
1342
- }, [id, isOpen, onBlur, value]);
1298
+ }, [id, isOpen, setIsOpen, onBlur, value]);
1343
1299
  const handleDoneClick = react.useCallback(() => {
1344
1300
  setIsOpen(false);
1345
1301
  onChange(localDate ? localDate.toISOString() : "");
@@ -1347,7 +1303,7 @@
1347
1303
  onBlur(id, value);
1348
1304
  }
1349
1305
  inputRef.current?.focus();
1350
- }, [localDate, onChange, onBlur, id, value]);
1306
+ }, [localDate, onChange, onBlur, id, value, setIsOpen]);
1351
1307
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-control my-4 w-full relative", children: /* @__PURE__ */ jsxRuntime.jsxs(
1352
1308
  "div",
1353
1309
  {
@@ -1406,58 +1362,9 @@
1406
1362
  }
1407
1363
  ) });
1408
1364
  }
1409
- function FileWidget(props) {
1410
- const { id, required, disabled, readonly, schema, onChange, onFocus, onBlur, options = {} } = props;
1411
- const isMulti = schema.type === "array" || Boolean(options.multiple);
1412
- const accept = typeof options.accept === "string" ? options.accept : void 0;
1413
- const handleChange = react.useCallback(
1414
- (event) => {
1415
- if (!event.target.files) {
1416
- return;
1417
- }
1418
- const fileList = Array.from(event.target.files);
1419
- if (isMulti) {
1420
- onChange(fileList);
1421
- } else {
1422
- onChange(fileList[0] || null);
1423
- }
1424
- },
1425
- [onChange, isMulti]
1426
- );
1427
- const handleFocus = react.useCallback(
1428
- (event) => {
1429
- if (onFocus) {
1430
- onFocus(id, event.target.files ? Array.from(event.target.files) : null);
1431
- }
1432
- },
1433
- [onFocus, id]
1434
- );
1435
- const handleBlur = react.useCallback(
1436
- (event) => {
1437
- if (onBlur) {
1438
- onBlur(id, event.target.files ? Array.from(event.target.files) : null);
1439
- }
1440
- },
1441
- [onBlur, id]
1442
- );
1443
- return /* @__PURE__ */ jsxRuntime.jsx(
1444
- "input",
1445
- {
1446
- id,
1447
- type: "file",
1448
- className: "file-input w-full",
1449
- required,
1450
- disabled: disabled || readonly,
1451
- onChange: handleChange,
1452
- onFocus: handleFocus,
1453
- onBlur: handleBlur,
1454
- multiple: isMulti,
1455
- accept
1456
- }
1457
- );
1458
- }
1459
1365
  function RadioWidget({
1460
1366
  id,
1367
+ htmlName,
1461
1368
  options,
1462
1369
  value,
1463
1370
  required,
@@ -1516,7 +1423,7 @@
1516
1423
  type: "radio",
1517
1424
  id: `${id}-${option.value}`,
1518
1425
  className: "radio",
1519
- name: id,
1426
+ name: htmlName || id,
1520
1427
  value: getValue(option),
1521
1428
  checked: isChecked(option),
1522
1429
  required,
@@ -1760,7 +1667,7 @@
1760
1667
  ] }) });
1761
1668
  }
1762
1669
  function TextareaWidget(props) {
1763
- const { id, value, required, disabled, readonly, onChange, onFocus, onBlur, options } = props;
1670
+ const { id, htmlName, value, required, disabled, readonly, onChange, onFocus, onBlur, options } = props;
1764
1671
  const handleFocus = react.useCallback(
1765
1672
  (event) => {
1766
1673
  if (onFocus) {
@@ -1788,6 +1695,7 @@
1788
1695
  "textarea",
1789
1696
  {
1790
1697
  id,
1698
+ name: htmlName || id,
1791
1699
  value: value || "",
1792
1700
  required,
1793
1701
  disabled: disabled || readonly,
@@ -1886,7 +1794,6 @@
1886
1794
  CheckboxWidget,
1887
1795
  DateTimeWidget,
1888
1796
  DateWidget,
1889
- FileWidget,
1890
1797
  RadioWidget,
1891
1798
  RangeWidget,
1892
1799
  RatingWidget,