@rjsf/mantine 6.4.2 → 6.5.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.
- package/dist/index.cjs +59 -45
- package/dist/index.cjs.map +2 -2
- package/dist/mantine.esm.js +69 -49
- package/dist/mantine.esm.js.map +3 -3
- package/dist/mantine.umd.js +59 -45
- package/lib/Form/index.js +1 -1
- package/lib/Theme/index.js +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.js +4 -4
- package/lib/templates/BaseInputTemplate.js +3 -2
- package/lib/templates/BaseInputTemplate.js.map +1 -1
- package/lib/templates/ButtonTemplates/AddButton.js +2 -2
- package/lib/templates/ButtonTemplates/IconButton.js +1 -1
- package/lib/templates/ButtonTemplates/index.js +3 -3
- package/lib/templates/ErrorList.js +1 -1
- package/lib/templates/OptionalDataControlsTemplate.js +2 -2
- package/lib/templates/WrapIfAdditionalTemplate.js +1 -1
- package/lib/templates/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/templates/index.js +16 -16
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/CheckboxesWidget.js +10 -9
- package/lib/widgets/CheckboxesWidget.js.map +1 -1
- package/lib/widgets/ColorWidget.js +1 -1
- package/lib/widgets/DateTime/DateTimeWidget.js +1 -1
- package/lib/widgets/DateTime/DateWidget.js +1 -1
- package/lib/widgets/DateTime/index.d.ts +5 -5
- package/lib/widgets/DateTime/index.js +5 -5
- package/lib/widgets/FileWidget.js +1 -1
- package/lib/widgets/PasswordWidget.js +1 -1
- package/lib/widgets/RadioWidget.js +10 -9
- package/lib/widgets/RadioWidget.js.map +1 -1
- package/lib/widgets/RangeWidget.js +1 -1
- package/lib/widgets/SelectWidget.js +30 -13
- package/lib/widgets/SelectWidget.js.map +1 -1
- package/lib/widgets/TextareaWidget.js +1 -1
- package/lib/widgets/index.js +10 -10
- package/package.json +10 -10
- package/src/templates/BaseInputTemplate.tsx +5 -1
- package/src/templates/WrapIfAdditionalTemplate.tsx +1 -0
- package/src/widgets/CheckboxesWidget.tsx +11 -8
- package/src/widgets/RadioWidget.tsx +11 -8
- package/src/widgets/SelectWidget.tsx +40 -32
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { ariaDescribedByIds,
|
|
3
|
+
import { ariaDescribedByIds, enumOptionValueDecoder, enumOptionValueEncoder, enumOptionsIndexForValue, getOptionValueFormat, optionId, titleId, } from '@rjsf/utils';
|
|
4
4
|
import { Checkbox, Flex, Input } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
7
7
|
* It is typically used to represent an array of enums.
|
|
8
8
|
*
|
|
@@ -11,23 +11,24 @@ import { cleanupOptions } from '../utils';
|
|
|
11
11
|
export default function CheckboxesWidget(props) {
|
|
12
12
|
const { id, htmlName, value, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, } = props;
|
|
13
13
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
14
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
14
15
|
const themeProps = cleanupOptions(options);
|
|
15
16
|
const handleChange = useCallback((nextValue) => {
|
|
16
17
|
if (!disabled && !readonly && onChange) {
|
|
17
|
-
onChange(
|
|
18
|
+
onChange(enumOptionValueDecoder(nextValue, enumOptions, optionValueFormat, emptyValue));
|
|
18
19
|
}
|
|
19
|
-
}, [onChange, disabled, readonly, enumOptions, emptyValue]);
|
|
20
|
+
}, [onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat]);
|
|
20
21
|
const handleBlur = useCallback(({ target }) => {
|
|
21
22
|
if (onBlur) {
|
|
22
|
-
onBlur(id,
|
|
23
|
+
onBlur(id, enumOptionValueDecoder(target.value, enumOptions, optionValueFormat, emptyValue));
|
|
23
24
|
}
|
|
24
|
-
}, [onBlur, id, enumOptions, emptyValue]);
|
|
25
|
+
}, [onBlur, id, enumOptions, emptyValue, optionValueFormat]);
|
|
25
26
|
const handleFocus = useCallback(({ target }) => {
|
|
26
27
|
if (onFocus) {
|
|
27
|
-
onFocus(id,
|
|
28
|
+
onFocus(id, enumOptionValueDecoder(target.value, enumOptions, optionValueFormat, emptyValue));
|
|
28
29
|
}
|
|
29
|
-
}, [onFocus, id, enumOptions, emptyValue]);
|
|
30
|
+
}, [onFocus, id, enumOptions, emptyValue, optionValueFormat]);
|
|
30
31
|
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
|
|
31
|
-
return Array.isArray(enumOptions) && enumOptions.length > 0 ? (_jsxs(_Fragment, { children: [!hideLabel && !!label && (_jsx(Input.Label, { id: titleId(id), required: required, children: label })), _jsx(Checkbox.Group, { id: id, value: selectedIndexes, onChange: handleChange, required: required, readOnly: disabled || readonly, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, "aria-describedby": ariaDescribedByIds(id), ...themeProps, children: Array.isArray(enumOptions) ? (_jsx(Flex, { mt: 'xs', direction: inline ? 'row' : 'column', gap: 'xs', wrap: 'wrap', children: enumOptions.map((option, i) => (_jsx(Checkbox, { id: optionId(id, i), name: htmlName || id, value:
|
|
32
|
+
return Array.isArray(enumOptions) && enumOptions.length > 0 ? (_jsxs(_Fragment, { children: [!hideLabel && !!label && (_jsx(Input.Label, { id: titleId(id), required: required, children: label })), _jsx(Checkbox.Group, { id: id, value: selectedIndexes, onChange: handleChange, required: required, readOnly: disabled || readonly, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, "aria-describedby": ariaDescribedByIds(id), ...themeProps, children: Array.isArray(enumOptions) ? (_jsx(Flex, { mt: 'xs', direction: inline ? 'row' : 'column', gap: 'xs', wrap: 'wrap', children: enumOptions.map((option, i) => (_jsx(Checkbox, { id: optionId(id, i), name: htmlName || id, value: enumOptionValueEncoder(option.value, i, optionValueFormat), label: option.label, disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1, autoFocus: i === 0 && autofocus, onBlur: handleBlur, onFocus: handleFocus }, i))) })) : null })] })) : null;
|
|
32
33
|
}
|
|
33
34
|
//# sourceMappingURL=CheckboxesWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxesWidget.js","sourceRoot":"","sources":["../../src/widgets/CheckboxesWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"CheckboxesWidget.js","sourceRoot":"","sources":["../../src/widgets/CheckboxesWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,EACR,OAAO,GAKR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAItC,KAA2B;IAC3B,MAAM,EACJ,EAAE,EACF,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAClE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACx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C,KAAK,CAAC,IAAI,SAAS,EAC/B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,IARf,CAAC,CASN,CACH,CAAC,GACG,CACR,CAAC,CAAC,CAAC,IAAI,GACO,IAChB,CACJ,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { labelValue, ariaDescribedByIds, } from '@rjsf/utils';
|
|
4
4
|
import { ColorInput } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/** The `ColorWidget` component uses the `ColorInput` from Mantine, allowing users to pick a color.
|
|
7
7
|
*
|
|
8
8
|
* @param props - The `WidgetProps` for this component
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import DateTimeInput from './DateTimeInput';
|
|
2
|
+
import DateTimeInput from './DateTimeInput.js';
|
|
3
3
|
/** The `DateWidget` component uses the `DateTimeInput` changing the valueFormat to show `datetime`
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `WidgetProps` for this component
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import DateTimeInput from './DateTimeInput';
|
|
2
|
+
import DateTimeInput from './DateTimeInput.js';
|
|
3
3
|
/** The `DateWidget` component uses the `DateTimeInput` changing the valueFormat to show `date`
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `WidgetProps` for this component
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as AltDateTimeWidget } from './AltDateTimeWidget';
|
|
2
|
-
export { default as AltDateWidget } from './AltDateWidget';
|
|
3
|
-
export { default as DateWidget } from './DateWidget';
|
|
4
|
-
export { default as DateTimeWidget } from './DateTimeWidget';
|
|
5
|
-
export { default as TimeWidget } from './TimeWidget';
|
|
1
|
+
export { default as AltDateTimeWidget } from './AltDateTimeWidget.js';
|
|
2
|
+
export { default as AltDateWidget } from './AltDateWidget.js';
|
|
3
|
+
export { default as DateWidget } from './DateWidget.js';
|
|
4
|
+
export { default as DateTimeWidget } from './DateTimeWidget.js';
|
|
5
|
+
export { default as TimeWidget } from './TimeWidget.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as AltDateTimeWidget } from './AltDateTimeWidget';
|
|
2
|
-
export { default as AltDateWidget } from './AltDateWidget';
|
|
3
|
-
export { default as DateWidget } from './DateWidget';
|
|
4
|
-
export { default as DateTimeWidget } from './DateTimeWidget';
|
|
5
|
-
export { default as TimeWidget } from './TimeWidget';
|
|
1
|
+
export { default as AltDateTimeWidget } from './AltDateTimeWidget.js';
|
|
2
|
+
export { default as AltDateWidget } from './AltDateWidget.js';
|
|
3
|
+
export { default as DateWidget } from './DateWidget.js';
|
|
4
|
+
export { default as DateTimeWidget } from './DateTimeWidget.js';
|
|
5
|
+
export { default as TimeWidget } from './TimeWidget.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { ariaDescribedByIds, labelValue, useFileWidgetProps, } from '@rjsf/utils';
|
|
4
4
|
import { FileInput, Pill } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/**
|
|
7
7
|
* The `FileWidget` is a widget for rendering file upload fields.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { ariaDescribedByIds, labelValue, } from '@rjsf/utils';
|
|
4
4
|
import { PasswordInput } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/**
|
|
7
7
|
* The `PasswordWidget` component renders a password input element.
|
|
8
8
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { ariaDescribedByIds, enumOptionsIndexForValue,
|
|
3
|
+
import { ariaDescribedByIds, enumOptionValueDecoder, enumOptionValueEncoder, enumOptionsIndexForValue, getOptionValueFormat, optionId, } from '@rjsf/utils';
|
|
4
4
|
import { Radio, Flex } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
7
7
|
* It is typically used with a string property constrained with enum options.
|
|
8
8
|
*
|
|
@@ -11,23 +11,24 @@ import { cleanupOptions } from '../utils';
|
|
|
11
11
|
export default function RadioWidget(props) {
|
|
12
12
|
const { id, htmlName, value, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, } = props;
|
|
13
13
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
14
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
14
15
|
const themeProps = cleanupOptions(options);
|
|
15
16
|
const handleChange = useCallback((nextValue) => {
|
|
16
17
|
if (!disabled && !readonly && onChange) {
|
|
17
|
-
onChange(
|
|
18
|
+
onChange(enumOptionValueDecoder(nextValue, enumOptions, optionValueFormat, emptyValue));
|
|
18
19
|
}
|
|
19
|
-
}, [onChange, disabled, readonly, enumOptions, emptyValue]);
|
|
20
|
+
}, [onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat]);
|
|
20
21
|
const handleBlur = useCallback(({ target }) => {
|
|
21
22
|
if (onBlur) {
|
|
22
|
-
onBlur(id,
|
|
23
|
+
onBlur(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
23
24
|
}
|
|
24
|
-
}, [onBlur, id, enumOptions, emptyValue]);
|
|
25
|
+
}, [onBlur, id, enumOptions, emptyValue, optionValueFormat]);
|
|
25
26
|
const handleFocus = useCallback(({ target }) => {
|
|
26
27
|
if (onFocus) {
|
|
27
|
-
onFocus(id,
|
|
28
|
+
onFocus(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
28
29
|
}
|
|
29
|
-
}, [onFocus, id, enumOptions, emptyValue]);
|
|
30
|
+
}, [onFocus, id, enumOptions, emptyValue, optionValueFormat]);
|
|
30
31
|
const selected = enumOptionsIndexForValue(value, enumOptions);
|
|
31
|
-
return (_jsx(Radio.Group, { id: id, name: htmlName || id, value: selected, label: !hideLabel ? label : undefined, onChange: handleChange, required: required, readOnly: disabled || readonly, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, "aria-describedby": ariaDescribedByIds(id), ...themeProps, children: Array.isArray(enumOptions) ? (_jsx(Flex, { mt: 'xs', direction: inline ? 'row' : 'column', gap: 'xs', wrap: 'wrap', children: enumOptions.map((option, i) => (_jsx(Radio, { id: optionId(id, i), value:
|
|
32
|
+
return (_jsx(Radio.Group, { id: id, name: htmlName || id, value: selected, label: !hideLabel ? label : undefined, onChange: handleChange, required: required, readOnly: disabled || readonly, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, "aria-describedby": ariaDescribedByIds(id), ...themeProps, children: Array.isArray(enumOptions) ? (_jsx(Flex, { mt: 'xs', direction: inline ? 'row' : 'column', gap: 'xs', wrap: 'wrap', children: enumOptions.map((option, i) => (_jsx(Radio, { id: optionId(id, i), value: enumOptionValueEncoder(option.value, i, optionValueFormat), label: option.label, disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1, autoFocus: i === 0 && autofocus, onBlur: handleBlur, onFocus: handleFocus }, i))) })) : null }));
|
|
32
33
|
}
|
|
33
34
|
//# sourceMappingURL=RadioWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioWidget.js","sourceRoot":"","sources":["../../src/widgets/RadioWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"RadioWidget.js","sourceRoot":"","sources":["../../src/widgets/RadioWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,GAKT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,KAA2B;IAE3B,MAAM,EACJ,EAAE,EACF,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAClE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAE3C,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,SAAc,EAAE,EAAE;QACjB,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACvC,QAAQ,CAAC,sBAAsB,CAAI,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;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,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,sBACzD,kBAAkB,CAAC,EAAE,CAAC,KACpC,UAAU,YAEb,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAC5B,KAAC,IAAI,IAAC,EAAE,EAAC,IAAI,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAC,IAAI,EAAC,IAAI,EAAC,MAAM,YACrE,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAC9B,KAAC,KAAK,IAEJ,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EACnB,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,iBAAiB,CAAC,EACjE,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAClF,SAAS,EAAE,CAAC,KAAK,CAAC,IAAI,SAAS,EAC/B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,IAPf,CAAC,CAQN,CACH,CAAC,GACG,CACR,CAAC,CAAC,CAAC,IAAI,GACI,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { ariaDescribedByIds, rangeSpec, titleId, } from '@rjsf/utils';
|
|
4
4
|
import { Slider, Input } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
7
7
|
* in a div, with the value alongside it.
|
|
8
8
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
|
-
import { ariaDescribedByIds,
|
|
3
|
+
import { ariaDescribedByIds, enumOptionSelectedValue, enumOptionValueDecoder, enumOptionValueEncoder, getOptionValueFormat, labelValue, } from '@rjsf/utils';
|
|
4
4
|
import { Select, MultiSelect } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
7
7
|
* It is typically used with string properties constrained with enum options.
|
|
8
8
|
*
|
|
@@ -11,35 +11,52 @@ import { cleanupOptions } from '../utils';
|
|
|
11
11
|
export default function SelectWidget(props) {
|
|
12
12
|
const { id, htmlName, value, placeholder, required, disabled, readonly, autofocus, label, hideLabel, multiple, rawErrors, options, onChange, onBlur, onFocus, } = props;
|
|
13
13
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
14
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
14
15
|
const themeProps = cleanupOptions(options);
|
|
15
16
|
const handleChange = useCallback((nextValue) => {
|
|
16
17
|
if (!disabled && !readonly && onChange) {
|
|
17
|
-
onChange(
|
|
18
|
+
onChange(enumOptionValueDecoder(nextValue, enumOptions, optionValueFormat, emptyValue));
|
|
18
19
|
}
|
|
19
|
-
}, [onChange, disabled, readonly, enumOptions, emptyValue]);
|
|
20
|
+
}, [onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat]);
|
|
20
21
|
const handleBlur = useCallback(({ target }) => {
|
|
21
22
|
if (onBlur) {
|
|
22
|
-
onBlur(id,
|
|
23
|
+
onBlur(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
23
24
|
}
|
|
24
|
-
}, [onBlur, id, enumOptions, emptyValue]);
|
|
25
|
+
}, [onBlur, id, enumOptions, emptyValue, optionValueFormat]);
|
|
25
26
|
const handleFocus = useCallback(({ target }) => {
|
|
26
27
|
if (onFocus) {
|
|
27
|
-
onFocus(id,
|
|
28
|
+
onFocus(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
28
29
|
}
|
|
29
|
-
}, [onFocus, id, enumOptions, emptyValue]);
|
|
30
|
-
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
30
|
+
}, [onFocus, id, enumOptions, emptyValue, optionValueFormat]);
|
|
31
31
|
const selectOptions = useMemo(() => {
|
|
32
32
|
if (Array.isArray(enumOptions)) {
|
|
33
33
|
return enumOptions.map((option, index) => ({
|
|
34
34
|
key: String(index),
|
|
35
|
-
value:
|
|
35
|
+
value: enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
36
36
|
label: option.label,
|
|
37
37
|
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
40
|
return [];
|
|
41
|
-
}, [enumDisabled, enumOptions]);
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
}, [enumDisabled, enumOptions, optionValueFormat]);
|
|
42
|
+
const sharedProps = {
|
|
43
|
+
id,
|
|
44
|
+
name: htmlName || id,
|
|
45
|
+
label: labelValue(label || undefined, hideLabel, false),
|
|
46
|
+
data: selectOptions,
|
|
47
|
+
onChange: !readonly ? handleChange : undefined,
|
|
48
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
49
|
+
onFocus: !readonly ? handleFocus : undefined,
|
|
50
|
+
autoFocus: autofocus,
|
|
51
|
+
placeholder,
|
|
52
|
+
disabled: disabled || readonly,
|
|
53
|
+
required,
|
|
54
|
+
error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined,
|
|
55
|
+
searchable: true,
|
|
56
|
+
'aria-describedby': ariaDescribedByIds(id),
|
|
57
|
+
comboboxProps: { withinPortal: false },
|
|
58
|
+
...themeProps,
|
|
59
|
+
};
|
|
60
|
+
return multiple ? (_jsx(MultiSelect, { ...sharedProps, value: enumOptionSelectedValue(value, enumOptions, true, optionValueFormat, []) })) : (_jsx(Select, { ...sharedProps, value: enumOptionSelectedValue(value, enumOptions, false, optionValueFormat, null) }));
|
|
44
61
|
}
|
|
45
62
|
//# sourceMappingURL=SelectWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectWidget.js","sourceRoot":"","sources":["../../src/widgets/SelectWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"SelectWidget.js","sourceRoot":"","sources":["../../src/widgets/SelectWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,GAKX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,KAA2B;IAE3B,MAAM,EACJ,EAAE,EACF,QAAQ,EACR,KAAK,EACL,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAA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AkB,EAAE,kBAAkB,CAAC,EAAE,CAAC;QAC1C,aAAa,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE;QACtC,GAAG,UAAU;KACd,CAAC;IAEF,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,KAAC,WAAW,OACN,WAAW,EACf,KAAK,EAAE,uBAAuB,CAAI,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,CAAa,GAC9F,CACH,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,OACD,WAAW,EACf,KAAK,EAAE,uBAAuB,CAAI,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,CAAkB,GACtG,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { labelValue, ariaDescribedByIds, } from '@rjsf/utils';
|
|
4
4
|
import { Textarea } from '@mantine/core';
|
|
5
|
-
import { cleanupOptions } from '../utils';
|
|
5
|
+
import { cleanupOptions } from '../utils.js';
|
|
6
6
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
7
7
|
*
|
|
8
8
|
* @param props - The `WidgetProps` for this component
|
package/lib/widgets/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
3
|
-
import { AltDateTimeWidget, AltDateWidget, DateWidget, DateTimeWidget, TimeWidget } from './DateTime';
|
|
4
|
-
import CheckboxesWidget from './CheckboxesWidget';
|
|
5
|
-
import CheckboxWidget from './CheckboxWidget';
|
|
6
|
-
import ColorWidget from './ColorWidget';
|
|
7
|
-
import FileWidget from './FileWidget';
|
|
8
|
-
import PasswordWidget from './PasswordWidget';
|
|
9
|
-
import RadioWidget from './RadioWidget';
|
|
10
|
-
import RangeWidget from './RangeWidget';
|
|
11
|
-
import SelectWidget from './SelectWidget';
|
|
12
|
-
import TextareaWidget from './TextareaWidget';
|
|
3
|
+
import { AltDateTimeWidget, AltDateWidget, DateWidget, DateTimeWidget, TimeWidget } from './DateTime/index.js';
|
|
4
|
+
import CheckboxesWidget from './CheckboxesWidget.js';
|
|
5
|
+
import CheckboxWidget from './CheckboxWidget.js';
|
|
6
|
+
import ColorWidget from './ColorWidget.js';
|
|
7
|
+
import FileWidget from './FileWidget.js';
|
|
8
|
+
import PasswordWidget from './PasswordWidget.js';
|
|
9
|
+
import RadioWidget from './RadioWidget.js';
|
|
10
|
+
import RangeWidget from './RangeWidget.js';
|
|
11
|
+
import SelectWidget from './SelectWidget.js';
|
|
12
|
+
import TextareaWidget from './TextareaWidget.js';
|
|
13
13
|
// This plugin is needed to support the parsing of date and time values in the `DateWidget` and `DateTimeWidget`
|
|
14
14
|
dayjs.extend(customParseFormat);
|
|
15
15
|
export function generateWidgets() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/mantine",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -64,20 +64,20 @@
|
|
|
64
64
|
"@mantine/core": ">=8",
|
|
65
65
|
"@mantine/dates": ">=8",
|
|
66
66
|
"@mantine/hooks": ">=8",
|
|
67
|
-
"@rjsf/core": "^6.
|
|
68
|
-
"@rjsf/utils": "^6.
|
|
67
|
+
"@rjsf/core": "^6.5.x",
|
|
68
|
+
"@rjsf/utils": "^6.5.x",
|
|
69
69
|
"react": ">=18"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@mantine/core": "^8.3.
|
|
73
|
-
"@mantine/dates": "^8.3.
|
|
74
|
-
"@mantine/hooks": "^8.3.
|
|
72
|
+
"@mantine/core": "^8.3.18",
|
|
73
|
+
"@mantine/dates": "^8.3.18",
|
|
74
|
+
"@mantine/hooks": "^8.3.18",
|
|
75
75
|
"@restart/hooks": "^0.6.2",
|
|
76
76
|
"@restart/ui": "^1.9.4",
|
|
77
|
-
"@rjsf/core": "6.
|
|
78
|
-
"@rjsf/snapshot-tests": "6.
|
|
79
|
-
"@rjsf/utils": "6.
|
|
80
|
-
"@rjsf/validator-ajv8": "6.
|
|
77
|
+
"@rjsf/core": "6.5.1",
|
|
78
|
+
"@rjsf/snapshot-tests": "6.5.1",
|
|
79
|
+
"@rjsf/utils": "6.5.1",
|
|
80
|
+
"@rjsf/validator-ajv8": "6.5.1",
|
|
81
81
|
"eslint": "^8.57.1",
|
|
82
82
|
"uncontrollable": "^9.0.0"
|
|
83
83
|
},
|
|
@@ -101,17 +101,21 @@ export default function BaseInputTemplate<
|
|
|
101
101
|
list: schema.examples ? examplesId(id) : undefined,
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
const { min, max, ...restInputProps } = inputProps;
|
|
105
|
+
|
|
104
106
|
const input =
|
|
105
107
|
inputProps.type === 'number' || inputProps.type === 'integer' ? (
|
|
106
108
|
<NumberInput
|
|
107
109
|
onChange={!readonly ? handleNumberChange : undefined}
|
|
108
110
|
{...componentProps}
|
|
109
|
-
{...
|
|
111
|
+
{...restInputProps}
|
|
110
112
|
{...themeProps}
|
|
111
113
|
step={typeof inputProps.step === 'number' ? inputProps.step : 1}
|
|
112
114
|
type='text'
|
|
113
115
|
description={description}
|
|
114
116
|
value={value}
|
|
117
|
+
min={typeof min === 'number' ? min : undefined}
|
|
118
|
+
max={typeof max === 'number' ? max : undefined}
|
|
115
119
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
116
120
|
/>
|
|
117
121
|
) : (
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { FocusEvent, useCallback } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ariaDescribedByIds,
|
|
4
|
-
|
|
4
|
+
enumOptionValueDecoder,
|
|
5
|
+
enumOptionValueEncoder,
|
|
5
6
|
enumOptionsIndexForValue,
|
|
7
|
+
getOptionValueFormat,
|
|
6
8
|
optionId,
|
|
7
9
|
titleId,
|
|
8
10
|
FormContextType,
|
|
@@ -42,33 +44,34 @@ export default function CheckboxesWidget<
|
|
|
42
44
|
} = props;
|
|
43
45
|
|
|
44
46
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
47
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
45
48
|
const themeProps = cleanupOptions(options);
|
|
46
49
|
|
|
47
50
|
const handleChange = useCallback(
|
|
48
51
|
(nextValue: any) => {
|
|
49
52
|
if (!disabled && !readonly && onChange) {
|
|
50
|
-
onChange(
|
|
53
|
+
onChange(enumOptionValueDecoder<S>(nextValue, enumOptions, optionValueFormat, emptyValue));
|
|
51
54
|
}
|
|
52
55
|
},
|
|
53
|
-
[onChange, disabled, readonly, enumOptions, emptyValue],
|
|
56
|
+
[onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat],
|
|
54
57
|
);
|
|
55
58
|
|
|
56
59
|
const handleBlur = useCallback(
|
|
57
60
|
({ target }: FocusEvent<HTMLInputElement>) => {
|
|
58
61
|
if (onBlur) {
|
|
59
|
-
onBlur(id,
|
|
62
|
+
onBlur(id, enumOptionValueDecoder<S>(target.value, enumOptions, optionValueFormat, emptyValue));
|
|
60
63
|
}
|
|
61
64
|
},
|
|
62
|
-
[onBlur, id, enumOptions, emptyValue],
|
|
65
|
+
[onBlur, id, enumOptions, emptyValue, optionValueFormat],
|
|
63
66
|
);
|
|
64
67
|
|
|
65
68
|
const handleFocus = useCallback(
|
|
66
69
|
({ target }: FocusEvent<HTMLInputElement>) => {
|
|
67
70
|
if (onFocus) {
|
|
68
|
-
onFocus(id,
|
|
71
|
+
onFocus(id, enumOptionValueDecoder<S>(target.value, enumOptions, optionValueFormat, emptyValue));
|
|
69
72
|
}
|
|
70
73
|
},
|
|
71
|
-
[onFocus, id, enumOptions, emptyValue],
|
|
74
|
+
[onFocus, id, enumOptions, emptyValue, optionValueFormat],
|
|
72
75
|
);
|
|
73
76
|
|
|
74
77
|
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, true) as string[];
|
|
@@ -97,7 +100,7 @@ export default function CheckboxesWidget<
|
|
|
97
100
|
key={i}
|
|
98
101
|
id={optionId(id, i)}
|
|
99
102
|
name={htmlName || id}
|
|
100
|
-
value={
|
|
103
|
+
value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
|
|
101
104
|
label={option.label}
|
|
102
105
|
disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1}
|
|
103
106
|
autoFocus={i === 0 && autofocus}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { FocusEvent, useCallback } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ariaDescribedByIds,
|
|
4
|
+
enumOptionValueDecoder,
|
|
5
|
+
enumOptionValueEncoder,
|
|
4
6
|
enumOptionsIndexForValue,
|
|
5
|
-
|
|
7
|
+
getOptionValueFormat,
|
|
6
8
|
optionId,
|
|
7
9
|
FormContextType,
|
|
8
10
|
RJSFSchema,
|
|
@@ -39,33 +41,34 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
39
41
|
} = props;
|
|
40
42
|
|
|
41
43
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
44
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
42
45
|
const themeProps = cleanupOptions(options);
|
|
43
46
|
|
|
44
47
|
const handleChange = useCallback(
|
|
45
48
|
(nextValue: any) => {
|
|
46
49
|
if (!disabled && !readonly && onChange) {
|
|
47
|
-
onChange(
|
|
50
|
+
onChange(enumOptionValueDecoder<S>(nextValue, enumOptions, optionValueFormat, emptyValue));
|
|
48
51
|
}
|
|
49
52
|
},
|
|
50
|
-
[onChange, disabled, readonly, enumOptions, emptyValue],
|
|
53
|
+
[onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat],
|
|
51
54
|
);
|
|
52
55
|
|
|
53
56
|
const handleBlur = useCallback(
|
|
54
57
|
({ target }: FocusEvent<HTMLInputElement>) => {
|
|
55
58
|
if (onBlur) {
|
|
56
|
-
onBlur(id,
|
|
59
|
+
onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
57
60
|
}
|
|
58
61
|
},
|
|
59
|
-
[onBlur, id, enumOptions, emptyValue],
|
|
62
|
+
[onBlur, id, enumOptions, emptyValue, optionValueFormat],
|
|
60
63
|
);
|
|
61
64
|
|
|
62
65
|
const handleFocus = useCallback(
|
|
63
66
|
({ target }: FocusEvent<HTMLInputElement>) => {
|
|
64
67
|
if (onFocus) {
|
|
65
|
-
onFocus(id,
|
|
68
|
+
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
66
69
|
}
|
|
67
70
|
},
|
|
68
|
-
[onFocus, id, enumOptions, emptyValue],
|
|
71
|
+
[onFocus, id, enumOptions, emptyValue, optionValueFormat],
|
|
69
72
|
);
|
|
70
73
|
|
|
71
74
|
const selected = enumOptionsIndexForValue<S>(value, enumOptions) as string;
|
|
@@ -89,7 +92,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
89
92
|
<Radio
|
|
90
93
|
key={i}
|
|
91
94
|
id={optionId(id, i)}
|
|
92
|
-
value={
|
|
95
|
+
value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
|
|
93
96
|
label={option.label}
|
|
94
97
|
disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1}
|
|
95
98
|
autoFocus={i === 0 && autofocus}
|