@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.
- package/dist/core.umd.js +705 -471
- package/dist/{index.js → index.cjs} +1094 -844
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +1053 -774
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +88 -23
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +213 -151
- package/lib/components/fields/ArrayField.d.ts +17 -7
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +116 -70
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +7 -2
- package/lib/components/fields/LayoutGridField.d.ts +27 -25
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +83 -59
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.js +3 -3
- package/lib/components/fields/LayoutMultiSchemaField.js +6 -5
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +13 -9
- package/lib/components/fields/NullField.js +3 -3
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +3 -3
- package/lib/components/fields/ObjectField.d.ts +3 -3
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +34 -34
- package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
- package/lib/components/fields/OptionalDataControlsField.js +43 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +17 -17
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +7 -2
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +2 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +2 -2
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +4 -3
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js +2 -2
- package/lib/components/templates/FieldErrorTemplate.js +2 -2
- package/lib/components/templates/FieldHelpTemplate.js +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +3 -2
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
- package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/TitleField.js +2 -2
- package/lib/components/templates/UnsupportedField.js +3 -3
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +4 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +15 -18
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +2 -1
- package/lib/getTestRegistry.d.ts +5 -0
- package/lib/getTestRegistry.d.ts.map +1 -0
- package/lib/getTestRegistry.js +19 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -19
- package/src/components/Form.tsx +306 -177
- package/src/components/fields/ArrayField.tsx +127 -80
- package/src/components/fields/BooleanField.tsx +12 -3
- package/src/components/fields/LayoutGridField.tsx +95 -88
- package/src/components/fields/LayoutHeaderField.tsx +3 -3
- package/src/components/fields/LayoutMultiSchemaField.tsx +5 -5
- package/src/components/fields/MultiSchemaField.tsx +51 -35
- package/src/components/fields/NullField.tsx +3 -3
- package/src/components/fields/NumberField.tsx +11 -3
- package/src/components/fields/ObjectField.tsx +47 -53
- package/src/components/fields/OptionalDataControlsField.tsx +84 -0
- package/src/components/fields/SchemaField.tsx +24 -30
- package/src/components/fields/StringField.tsx +12 -3
- package/src/components/fields/index.ts +2 -0
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTemplate.tsx +9 -5
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
- package/src/components/templates/BaseInputTemplate.tsx +3 -3
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
- package/src/components/templates/FieldErrorTemplate.tsx +2 -2
- package/src/components/templates/FieldHelpTemplate.tsx +2 -2
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +10 -5
- package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
- package/src/components/templates/TitleField.tsx +6 -1
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +4 -0
- package/src/components/widgets/AltDateWidget.tsx +21 -23
- package/src/components/widgets/CheckboxWidget.tsx +2 -2
- package/src/components/widgets/CheckboxesWidget.tsx +3 -3
- package/src/components/widgets/RadioWidget.tsx +1 -1
- package/src/components/widgets/SelectWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +1 -1
- package/src/getDefaultRegistry.ts +10 -1
- package/src/getTestRegistry.tsx +34 -0
- package/src/index.ts +2 -1
- 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,
|
|
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:
|
|
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,
|
|
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,
|
|
10
|
+
const { schema, fieldPathId, reason, registry } = props;
|
|
11
11
|
const { translateString } = registry;
|
|
12
12
|
let translateEnum = TranslatableString.UnsupportedField;
|
|
13
13
|
const translateParams = [];
|
|
14
|
-
if (
|
|
14
|
+
if (fieldPathId && fieldPathId.$id) {
|
|
15
15
|
translateEnum = TranslatableString.UnsupportedFieldWithId;
|
|
16
|
-
translateParams.push(
|
|
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;
|
|
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,
|
|
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,
|
|
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 [
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
setLastValue(value);
|
|
30
|
-
setState(parseDateString(value, time));
|
|
29
|
+
else {
|
|
30
|
+
setState(nextState);
|
|
31
31
|
}
|
|
32
|
-
}, [
|
|
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,
|
|
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
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
5
|
+
import getTestRegistry from './getTestRegistry.js';
|
|
6
|
+
export { withTheme, getDefaultRegistry, getTestRegistry, RichDescription };
|
|
6
7
|
export default Form;
|