@rjsf/core 6.0.0-beta.2 → 6.0.0-beta.21

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 (114) hide show
  1. package/dist/core.umd.js +705 -471
  2. package/dist/{index.js → index.cjs} +1094 -844
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/index.esm.js +1053 -774
  5. package/dist/index.esm.js.map +4 -4
  6. package/lib/components/Form.d.ts +88 -23
  7. package/lib/components/Form.d.ts.map +1 -1
  8. package/lib/components/Form.js +213 -151
  9. package/lib/components/fields/ArrayField.d.ts +17 -7
  10. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  11. package/lib/components/fields/ArrayField.js +116 -70
  12. package/lib/components/fields/BooleanField.d.ts.map +1 -1
  13. package/lib/components/fields/BooleanField.js +7 -2
  14. package/lib/components/fields/LayoutGridField.d.ts +27 -25
  15. package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
  16. package/lib/components/fields/LayoutGridField.js +83 -59
  17. package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
  18. package/lib/components/fields/LayoutHeaderField.js +3 -3
  19. package/lib/components/fields/LayoutMultiSchemaField.js +6 -5
  20. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
  21. package/lib/components/fields/MultiSchemaField.js +13 -9
  22. package/lib/components/fields/NullField.js +3 -3
  23. package/lib/components/fields/NumberField.d.ts.map +1 -1
  24. package/lib/components/fields/NumberField.js +3 -3
  25. package/lib/components/fields/ObjectField.d.ts +3 -3
  26. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  27. package/lib/components/fields/ObjectField.js +34 -34
  28. package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
  29. package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
  30. package/lib/components/fields/OptionalDataControlsField.js +43 -0
  31. package/lib/components/fields/SchemaField.d.ts.map +1 -1
  32. package/lib/components/fields/SchemaField.js +17 -17
  33. package/lib/components/fields/StringField.d.ts.map +1 -1
  34. package/lib/components/fields/StringField.js +7 -2
  35. package/lib/components/fields/index.d.ts.map +1 -1
  36. package/lib/components/fields/index.js +2 -0
  37. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
  38. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
  39. package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +2 -2
  40. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
  41. package/lib/components/templates/ArrayFieldTemplate.js +4 -3
  42. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
  43. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
  44. package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
  45. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
  46. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
  47. package/lib/components/templates/ButtonTemplates/AddButton.js +2 -2
  48. package/lib/components/templates/FieldErrorTemplate.js +2 -2
  49. package/lib/components/templates/FieldHelpTemplate.js +2 -2
  50. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
  51. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
  52. package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
  53. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
  54. package/lib/components/templates/ObjectFieldTemplate.js +3 -2
  55. package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
  56. package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
  57. package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
  58. package/lib/components/templates/TitleField.d.ts.map +1 -1
  59. package/lib/components/templates/TitleField.js +2 -2
  60. package/lib/components/templates/UnsupportedField.js +3 -3
  61. package/lib/components/templates/index.d.ts.map +1 -1
  62. package/lib/components/templates/index.js +4 -0
  63. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
  64. package/lib/components/widgets/AltDateWidget.js +15 -18
  65. package/lib/components/widgets/CheckboxesWidget.js +2 -2
  66. package/lib/getDefaultRegistry.d.ts.map +1 -1
  67. package/lib/getDefaultRegistry.js +2 -1
  68. package/lib/getTestRegistry.d.ts +5 -0
  69. package/lib/getTestRegistry.d.ts.map +1 -0
  70. package/lib/getTestRegistry.js +19 -0
  71. package/lib/index.d.ts +2 -1
  72. package/lib/index.d.ts.map +1 -1
  73. package/lib/index.js +2 -1
  74. package/lib/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +18 -19
  76. package/src/components/Form.tsx +306 -177
  77. package/src/components/fields/ArrayField.tsx +127 -80
  78. package/src/components/fields/BooleanField.tsx +12 -3
  79. package/src/components/fields/LayoutGridField.tsx +95 -88
  80. package/src/components/fields/LayoutHeaderField.tsx +3 -3
  81. package/src/components/fields/LayoutMultiSchemaField.tsx +5 -5
  82. package/src/components/fields/MultiSchemaField.tsx +51 -35
  83. package/src/components/fields/NullField.tsx +3 -3
  84. package/src/components/fields/NumberField.tsx +11 -3
  85. package/src/components/fields/ObjectField.tsx +47 -53
  86. package/src/components/fields/OptionalDataControlsField.tsx +84 -0
  87. package/src/components/fields/SchemaField.tsx +24 -30
  88. package/src/components/fields/StringField.tsx +12 -3
  89. package/src/components/fields/index.ts +2 -0
  90. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
  91. package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
  92. package/src/components/templates/ArrayFieldTemplate.tsx +9 -5
  93. package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
  94. package/src/components/templates/BaseInputTemplate.tsx +3 -3
  95. package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
  96. package/src/components/templates/FieldErrorTemplate.tsx +2 -2
  97. package/src/components/templates/FieldHelpTemplate.tsx +2 -2
  98. package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
  99. package/src/components/templates/ObjectFieldTemplate.tsx +10 -5
  100. package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
  101. package/src/components/templates/TitleField.tsx +6 -1
  102. package/src/components/templates/UnsupportedField.tsx +3 -3
  103. package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
  104. package/src/components/templates/index.ts +4 -0
  105. package/src/components/widgets/AltDateWidget.tsx +21 -23
  106. package/src/components/widgets/CheckboxWidget.tsx +2 -2
  107. package/src/components/widgets/CheckboxesWidget.tsx +3 -3
  108. package/src/components/widgets/RadioWidget.tsx +1 -1
  109. package/src/components/widgets/SelectWidget.tsx +1 -1
  110. package/src/components/widgets/TextareaWidget.tsx +1 -1
  111. package/src/getDefaultRegistry.ts +10 -1
  112. package/src/getTestRegistry.tsx +34 -0
  113. package/src/index.ts +2 -1
  114. package/dist/index.js.map +0 -7
@@ -7,11 +7,12 @@ import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, buttonId,
7
7
  * @param props - The `ObjectFieldTemplateProps` for this component
8
8
  */
9
9
  export default function ObjectFieldTemplate(props) {
10
- const { description, disabled, formData, idSchema, onAddClick, properties, readonly, registry, required, schema, title, uiSchema, } = props;
10
+ const { className, description, disabled, formData, fieldPathId, onAddClick, optionalDataControl, properties, readonly, registry, required, schema, title, uiSchema, } = props;
11
11
  const options = getUiOptions(uiSchema);
12
12
  const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
13
13
  const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
14
+ const showOptionalDataControlInTitle = !readonly && !disabled;
14
15
  // Button templates are not overridden in the uiSchema
15
16
  const { ButtonTemplates: { AddButton }, } = registry.templates;
16
- return (_jsxs("fieldset", { id: idSchema.$id, children: [title && (_jsx(TitleFieldTemplate, { id: titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })), description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), properties.map((prop) => prop.content), canExpand(schema, uiSchema, formData) && (_jsx(AddButton, { id: buttonId(idSchema, 'add'), className: 'rjsf-object-property-expand', onClick: onAddClick(schema), disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }))] }));
17
+ return (_jsxs("fieldset", { className: className, id: fieldPathId.$id, children: [title && (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry, optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : undefined })), description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(fieldPathId), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), !showOptionalDataControlInTitle ? optionalDataControl : undefined, properties.map((prop) => prop.content), canExpand(schema, uiSchema, formData) && (_jsx(AddButton, { id: buttonId(fieldPathId, 'add'), className: 'rjsf-object-property-expand', onClick: onAddClick(schema), disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }))] }));
17
18
  }
@@ -0,0 +1,11 @@
1
+ import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ /** The OptionalDataControlsTemplate renders one of three different states. If
3
+ * there is an `onAddClick()` function, it renders the "Add" button. If there is
4
+ * an `onRemoveClick()` function, it renders the "Remove" button. Otherwise it
5
+ * renders the "No data found" section. All of them use the `label` as either
6
+ * the `title` of buttons or simply outputting it.
7
+ *
8
+ * @param props - The `OptionalDataControlsTemplateProps` for the template
9
+ */
10
+ export default function OptionalDataControlsTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: OptionalDataControlsTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=OptionalDataControlsTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionalDataControlsTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/OptionalDataControlsTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iCAAiC,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/G;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,4BAA4B,CAClD,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,iCAAiC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA0BlD"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import IconButton from './ButtonTemplates/IconButton.js';
3
+ /** The OptionalDataControlsTemplate renders one of three different states. If
4
+ * there is an `onAddClick()` function, it renders the "Add" button. If there is
5
+ * an `onRemoveClick()` function, it renders the "Remove" button. Otherwise it
6
+ * renders the "No data found" section. All of them use the `label` as either
7
+ * the `title` of buttons or simply outputting it.
8
+ *
9
+ * @param props - The `OptionalDataControlsTemplateProps` for the template
10
+ */
11
+ export default function OptionalDataControlsTemplate(props) {
12
+ const { id, registry, label, onAddClick, onRemoveClick } = props;
13
+ if (onAddClick) {
14
+ return (_jsx(IconButton, { id: id, registry: registry, icon: 'plus', className: 'rjsf-add-optional-data btn-sm', onClick: onAddClick, title: label }));
15
+ }
16
+ else if (onRemoveClick) {
17
+ return (_jsx(IconButton, { id: id, registry: registry, icon: 'remove', className: 'rjsf-remove-optional-data btn-sm', onClick: onRemoveClick, title: label }));
18
+ }
19
+ return _jsx("em", { id: id, children: label });
20
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"TitleField.d.ts","sourceRoot":"","sources":["../../../src/components/templates/TitleField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI7F;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAShC"}
1
+ {"version":3,"file":"TitleField.d.ts","sourceRoot":"","sources":["../../../src/components/templates/TitleField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI7F;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAchC"}
@@ -5,6 +5,6 @@ const REQUIRED_FIELD_SYMBOL = '*';
5
5
  * @param props - The `TitleFieldProps` for this component
6
6
  */
7
7
  export default function TitleField(props) {
8
- const { id, title, required } = props;
9
- return (_jsxs("legend", { id: id, children: [title, required && _jsx("span", { className: 'required', children: REQUIRED_FIELD_SYMBOL })] }));
8
+ const { id, title, required, optionalDataControl } = props;
9
+ return (_jsxs("legend", { id: id, children: [title, required && _jsx("span", { className: 'required', children: REQUIRED_FIELD_SYMBOL }), optionalDataControl && (_jsx("span", { className: 'pull-right', style: { marginBottom: '2px' }, children: optionalDataControl }))] }));
10
10
  }
@@ -7,13 +7,13 @@ import Markdown from 'markdown-to-jsx';
7
7
  * @param props - The `FieldProps` for this template
8
8
  */
9
9
  function UnsupportedField(props) {
10
- const { schema, idSchema, reason, registry } = props;
10
+ const { schema, fieldPathId, reason, registry } = props;
11
11
  const { translateString } = registry;
12
12
  let translateEnum = TranslatableString.UnsupportedField;
13
13
  const translateParams = [];
14
- if (idSchema && idSchema.$id) {
14
+ if (fieldPathId && fieldPathId.$id) {
15
15
  translateEnum = TranslatableString.UnsupportedFieldWithId;
16
- translateParams.push(idSchema.$id);
16
+ translateParams.push(fieldPathId.$id);
17
17
  }
18
18
  if (reason) {
19
19
  translateEnum =
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoB3F,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,KAAK,aAAa,CACpH,CAAC,EACD,CAAC,EACD,CAAC,CACF,CAoBA;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAsB3F,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,KAAK,aAAa,CACpH,CAAC,EACD,CAAC,EACD,CAAC,CACF,CAsBA;AAED,eAAe,SAAS,CAAC"}
@@ -11,7 +11,9 @@ import FieldTemplate from './FieldTemplate/index.js';
11
11
  import FieldErrorTemplate from './FieldErrorTemplate.js';
12
12
  import FieldHelpTemplate from './FieldHelpTemplate.js';
13
13
  import GridTemplate from './GridTemplate.js';
14
+ import MultiSchemaFieldTemplate from './MultiSchemaFieldTemplate.js';
14
15
  import ObjectFieldTemplate from './ObjectFieldTemplate.js';
16
+ import OptionalDataControlsTemplate from './OptionalDataControlsTemplate.js';
15
17
  import TitleField from './TitleField.js';
16
18
  import UnsupportedField from './UnsupportedField.js';
17
19
  import WrapIfAdditionalTemplate from './WrapIfAdditionalTemplate.js';
@@ -30,7 +32,9 @@ function templates() {
30
32
  FieldErrorTemplate,
31
33
  FieldHelpTemplate,
32
34
  GridTemplate,
35
+ MultiSchemaFieldTemplate,
33
36
  ObjectFieldTemplate,
37
+ OptionalDataControlsTemplate,
34
38
  TitleFieldTemplate: TitleField,
35
39
  UnsupportedFieldTemplate: UnsupportedField,
36
40
  WrapIfAdditionalTemplate,
@@ -1 +1 @@
1
- {"version":3,"file":"AltDateWidget.d.ts","sourceRoot":"","sources":["../../../src/components/widgets/AltDateWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAOL,eAAe,EACf,UAAU,EACV,gBAAgB,EAEhB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAsDrB;;GAEG;AACH,iBAAS,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACxG,IAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,SAAiB,EACjB,OAAO,EACP,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAwFtB;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"AltDateWidget.d.ts","sourceRoot":"","sources":["../../../src/components/widgets/AltDateWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAOL,eAAe,EACf,UAAU,EACV,gBAAgB,EAEhB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAsDrB;;GAEG;AACH,iBAAS,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACxG,IAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,SAAiB,EACjB,OAAO,EACP,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsFtB;AAED,eAAe,aAAa,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useReducer, useState } from 'react';
2
+ import { useCallback, useEffect, useState } from 'react';
3
3
  import { ariaDescribedByIds, dateRangeOptions, parseDateString, toDateString, TranslatableString, getDateElementProps, } from '@rjsf/utils';
4
4
  function readyForChange(state) {
5
5
  return Object.values(state).every((value) => value !== -1);
@@ -14,25 +14,22 @@ function DateElement({ type, range, value, select, rootId, name, disabled, reado
14
14
  */
15
15
  function AltDateWidget({ time = false, disabled = false, readonly = false, autofocus = false, options, id, name, registry, onBlur, onFocus, onChange, value, }) {
16
16
  const { translateString } = registry;
17
- const [lastValue, setLastValue] = useState(value);
18
- const [state, setState] = useReducer((state, action) => {
19
- return { ...state, ...action };
20
- }, parseDateString(value, time));
17
+ const [state, setState] = useState(parseDateString(value, time));
21
18
  useEffect(() => {
22
- const stateValue = toDateString(state, time);
23
- if (readyForChange(state) && stateValue !== value) {
24
- // The user changed the date to a new valid data via the comboboxes, so call onChange
25
- onChange(stateValue);
19
+ setState(parseDateString(value, time));
20
+ }, [time, value]);
21
+ const handleChange = useCallback((property, value) => {
22
+ const nextState = {
23
+ ...state,
24
+ [property]: typeof value === 'undefined' ? -1 : value,
25
+ };
26
+ if (readyForChange(nextState)) {
27
+ onChange(toDateString(nextState, time));
26
28
  }
27
- else if (lastValue !== value) {
28
- // We got a new value in the props
29
- setLastValue(value);
30
- setState(parseDateString(value, time));
29
+ else {
30
+ setState(nextState);
31
31
  }
32
- }, [time, value, onChange, state, lastValue]);
33
- const handleChange = useCallback((property, value) => {
34
- setState({ [property]: value });
35
- }, []);
32
+ }, [state, onChange, time]);
36
33
  const handleSetNow = useCallback((event) => {
37
34
  event.preventDefault();
38
35
  if (disabled || readonly) {
@@ -40,7 +37,7 @@ function AltDateWidget({ time = false, disabled = false, readonly = false, autof
40
37
  }
41
38
  const nextState = parseDateString(new Date().toJSON(), time);
42
39
  onChange(toDateString(nextState, time));
43
- }, [disabled, readonly, time]);
40
+ }, [disabled, readonly, time, onChange]);
44
41
  const handleClear = useCallback((event) => {
45
42
  event.preventDefault();
46
43
  if (disabled || readonly) {
@@ -8,8 +8,8 @@ import { ariaDescribedByIds, enumOptionsDeselectValue, enumOptionsIsSelected, en
8
8
  */
9
9
  function CheckboxesWidget({ id, disabled, options: { inline = false, enumOptions, enumDisabled, emptyValue }, value, autofocus = false, readonly, onChange, onBlur, onFocus, }) {
10
10
  const checkboxesValues = Array.isArray(value) ? value : [value];
11
- const handleBlur = useCallback(({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onBlur, id]);
12
- const handleFocus = useCallback(({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onFocus, id]);
11
+ const handleBlur = useCallback(({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onBlur, id, enumOptions, emptyValue]);
12
+ const handleFocus = useCallback(({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onFocus, id, enumOptions, emptyValue]);
13
13
  return (_jsx("div", { className: 'checkboxes', id: id, children: Array.isArray(enumOptions) &&
14
14
  enumOptions.map((option, index) => {
15
15
  const checked = enumOptionsIsSelected(option.value, checkboxesValues);
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultRegistry.d.ts","sourceRoot":"","sources":["../src/getDefaultRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/G;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,CAS1C"}
1
+ {"version":3,"file":"getDefaultRegistry.d.ts","sourceRoot":"","sources":["../src/getDefaultRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAMrB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,CAU1C"}
@@ -1,4 +1,4 @@
1
- import { englishStringTranslator } from '@rjsf/utils';
1
+ import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator, } from '@rjsf/utils';
2
2
  import fields from './components/fields/index.js';
3
3
  import templates from './components/templates/index.js';
4
4
  import widgets from './components/widgets/index.js';
@@ -14,5 +14,6 @@ export default function getDefaultRegistry() {
14
14
  rootSchema: {},
15
15
  formContext: {},
16
16
  translateString: englishStringTranslator,
17
+ globalFormOptions: { idPrefix: DEFAULT_ID_PREFIX, idSeparator: DEFAULT_ID_SEPARATOR },
17
18
  };
18
19
  }
@@ -0,0 +1,5 @@
1
+ import { Registry } from '@rjsf/utils';
2
+ /** Use for react testing library tests where we directly test the component rather than testing inside a Form
3
+ */
4
+ export default function getTestRegistry(rootSchema: Registry['rootSchema'], fields?: Registry['fields'], templates?: Partial<Registry['templates']>, widgets?: Registry['widgets'], formContext?: Registry['formContext'], globalFormOptions?: Registry['globalFormOptions']): Registry;
5
+ //# sourceMappingURL=getTestRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTestRegistry.d.ts","sourceRoot":"","sources":["../src/getTestRegistry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EACT,MAAM,aAAa,CAAC;AAKrB;GACG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC,EAClC,MAAM,GAAE,QAAQ,CAAC,QAAQ,CAAM,EAC/B,SAAS,GAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAM,EAC9C,OAAO,GAAE,QAAQ,CAAC,SAAS,CAAM,EACjC,WAAW,GAAE,QAAQ,CAAC,aAAa,CAAM,EACzC,iBAAiB,GAAE,QAAQ,CAAC,mBAAmB,CAAsE,GACpH,QAAQ,CAaV"}
@@ -0,0 +1,19 @@
1
+ import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, createSchemaUtils, englishStringTranslator, } from '@rjsf/utils';
2
+ import validator from '@rjsf/validator-ajv8';
3
+ import getDefaultRegistry from './getDefaultRegistry.js';
4
+ /** Use for react testing library tests where we directly test the component rather than testing inside a Form
5
+ */
6
+ export default function getTestRegistry(rootSchema, fields = {}, templates = {}, widgets = {}, formContext = {}, globalFormOptions = { idPrefix: DEFAULT_ID_PREFIX, idSeparator: DEFAULT_ID_SEPARATOR }) {
7
+ const defaults = getDefaultRegistry();
8
+ const schemaUtils = createSchemaUtils(validator, rootSchema);
9
+ return {
10
+ fields: { ...defaults.fields, ...fields },
11
+ templates: { ...defaults.templates, ...templates },
12
+ widgets: { ...defaults.widgets, ...widgets },
13
+ formContext,
14
+ rootSchema,
15
+ schemaUtils,
16
+ translateString: englishStringTranslator,
17
+ globalFormOptions,
18
+ };
19
+ }
package/lib/index.d.ts CHANGED
@@ -2,7 +2,8 @@ import Form, { FormProps, FormState, IChangeEvent } from './components/Form.js';
2
2
  import RichDescription, { RichDescriptionProps } from './components/RichDescription.js';
3
3
  import withTheme, { ThemeProps } from './withTheme.js';
4
4
  import getDefaultRegistry from './getDefaultRegistry.js';
5
+ import getTestRegistry from './getTestRegistry.js';
5
6
  export type { FormProps, FormState, IChangeEvent, ThemeProps, RichDescriptionProps };
6
- export { withTheme, getDefaultRegistry, RichDescription };
7
+ export { withTheme, getDefaultRegistry, getTestRegistry, RichDescription };
7
8
  export default Form;
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,eAAe,EAAE,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;AAErF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC;AAC1D,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,eAAe,EAAE,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;AAErF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAC3E,eAAe,IAAI,CAAC"}
package/lib/index.js CHANGED
@@ -2,5 +2,6 @@ import Form from './components/Form.js';
2
2
  import RichDescription from './components/RichDescription.js';
3
3
  import withTheme from './withTheme.js';
4
4
  import getDefaultRegistry from './getDefaultRegistry.js';
5
- export { withTheme, getDefaultRegistry, RichDescription };
5
+ import getTestRegistry from './getTestRegistry.js';
6
+ export { withTheme, getDefaultRegistry, getTestRegistry, RichDescription };
6
7
  export default Form;