@rjsf/mantine 6.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -0
- package/dist/index.js +1918 -0
- package/dist/index.js.map +7 -0
- package/dist/mantine.esm.js +1967 -0
- package/dist/mantine.esm.js.map +7 -0
- package/dist/mantine.umd.js +1714 -0
- package/lib/Form/index.d.ts +6 -0
- package/lib/Form/index.js +7 -0
- package/lib/Form/index.js.map +1 -0
- package/lib/Theme/index.d.ts +5 -0
- package/lib/Theme/index.js +10 -0
- package/lib/Theme/index.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/templates/ArrayFieldItemTemplate.d.ts +6 -0
- package/lib/templates/ArrayFieldItemTemplate.js +14 -0
- package/lib/templates/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/templates/ArrayFieldTemplate.d.ts +6 -0
- package/lib/templates/ArrayFieldTemplate.js +20 -0
- package/lib/templates/ArrayFieldTemplate.js.map +1 -0
- package/lib/templates/ArrayFieldTitleTemplate.d.ts +7 -0
- package/lib/templates/ArrayFieldTitleTemplate.js +18 -0
- package/lib/templates/ArrayFieldTitleTemplate.js.map +1 -0
- package/lib/templates/BaseInputTemplate.d.ts +8 -0
- package/lib/templates/BaseInputTemplate.js +36 -0
- package/lib/templates/BaseInputTemplate.js.map +1 -0
- package/lib/templates/ButtonTemplates/AddButton.d.ts +4 -0
- package/lib/templates/ButtonTemplates/AddButton.js +11 -0
- package/lib/templates/ButtonTemplates/AddButton.js.map +1 -0
- package/lib/templates/ButtonTemplates/IconButton.d.ts +8 -0
- package/lib/templates/ButtonTemplates/IconButton.js +25 -0
- package/lib/templates/ButtonTemplates/IconButton.js.map +1 -0
- package/lib/templates/ButtonTemplates/SubmitButton.d.ts +4 -0
- package/lib/templates/ButtonTemplates/SubmitButton.js +13 -0
- package/lib/templates/ButtonTemplates/SubmitButton.js.map +1 -0
- package/lib/templates/ButtonTemplates/index.d.ts +3 -0
- package/lib/templates/ButtonTemplates/index.js +15 -0
- package/lib/templates/ButtonTemplates/index.js.map +1 -0
- package/lib/templates/DescriptionField.d.ts +6 -0
- package/lib/templates/DescriptionField.js +15 -0
- package/lib/templates/DescriptionField.js.map +1 -0
- package/lib/templates/ErrorList.d.ts +6 -0
- package/lib/templates/ErrorList.js +13 -0
- package/lib/templates/ErrorList.js.map +1 -0
- package/lib/templates/FieldErrorTemplate.d.ts +6 -0
- package/lib/templates/FieldErrorTemplate.js +16 -0
- package/lib/templates/FieldErrorTemplate.js.map +1 -0
- package/lib/templates/FieldHelpTemplate.d.ts +6 -0
- package/lib/templates/FieldHelpTemplate.js +13 -0
- package/lib/templates/FieldHelpTemplate.js.map +1 -0
- package/lib/templates/FieldTemplate.d.ts +7 -0
- package/lib/templates/FieldTemplate.js +18 -0
- package/lib/templates/FieldTemplate.js.map +1 -0
- package/lib/templates/GridTemplate.d.ts +7 -0
- package/lib/templates/GridTemplate.js +20 -0
- package/lib/templates/GridTemplate.js.map +1 -0
- package/lib/templates/MultiSchemaFieldTemplate.d.ts +2 -0
- package/lib/templates/MultiSchemaFieldTemplate.js +6 -0
- package/lib/templates/MultiSchemaFieldTemplate.js.map +1 -0
- package/lib/templates/ObjectFieldTemplate.d.ts +8 -0
- package/lib/templates/ObjectFieldTemplate.js +24 -0
- package/lib/templates/ObjectFieldTemplate.js.map +1 -0
- package/lib/templates/TitleField.d.ts +6 -0
- package/lib/templates/TitleField.js +11 -0
- package/lib/templates/TitleField.js.map +1 -0
- package/lib/templates/WrapIfAdditionalTemplate.d.ts +7 -0
- package/lib/templates/WrapIfAdditionalTemplate.js +29 -0
- package/lib/templates/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/templates/icons.d.ts +11 -0
- package/lib/templates/icons.js +20 -0
- package/lib/templates/icons.js.map +1 -0
- package/lib/templates/index.d.ts +4 -0
- package/lib/templates/index.js +36 -0
- package/lib/templates/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +35 -0
- package/lib/utils.js.map +1 -0
- package/lib/widgets/CheckboxWidget.d.ts +8 -0
- package/lib/widgets/CheckboxWidget.js +33 -0
- package/lib/widgets/CheckboxWidget.js.map +1 -0
- package/lib/widgets/CheckboxesWidget.d.ts +7 -0
- package/lib/widgets/CheckboxesWidget.js +33 -0
- package/lib/widgets/CheckboxesWidget.js.map +1 -0
- package/lib/widgets/ColorWidget.d.ts +6 -0
- package/lib/widgets/ColorWidget.js +28 -0
- package/lib/widgets/ColorWidget.js.map +1 -0
- package/lib/widgets/DateTime/AltDateTimeWidget.d.ts +13 -0
- package/lib/widgets/DateTime/AltDateTimeWidget.js +16 -0
- package/lib/widgets/DateTime/AltDateTimeWidget.js.map +1 -0
- package/lib/widgets/DateTime/AltDateWidget.d.ts +11 -0
- package/lib/widgets/DateTime/AltDateWidget.js +51 -0
- package/lib/widgets/DateTime/AltDateWidget.js.map +1 -0
- package/lib/widgets/DateTime/DateTimeInput.d.ts +5 -0
- package/lib/widgets/DateTime/DateTimeInput.js +39 -0
- package/lib/widgets/DateTime/DateTimeInput.js.map +1 -0
- package/lib/widgets/DateTime/DateTimeWidget.d.ts +6 -0
- package/lib/widgets/DateTime/DateTimeWidget.js +11 -0
- package/lib/widgets/DateTime/DateTimeWidget.js.map +1 -0
- package/lib/widgets/DateTime/DateWidget.d.ts +6 -0
- package/lib/widgets/DateTime/DateWidget.js +11 -0
- package/lib/widgets/DateTime/DateWidget.js.map +1 -0
- package/lib/widgets/DateTime/TimeWidget.d.ts +6 -0
- package/lib/widgets/DateTime/TimeWidget.js +27 -0
- package/lib/widgets/DateTime/TimeWidget.js.map +1 -0
- package/lib/widgets/DateTime/index.d.ts +5 -0
- package/lib/widgets/DateTime/index.js +6 -0
- package/lib/widgets/DateTime/index.js.map +1 -0
- package/lib/widgets/FileWidget.d.ts +7 -0
- package/lib/widgets/FileWidget.js +106 -0
- package/lib/widgets/FileWidget.js.map +1 -0
- package/lib/widgets/PasswordWidget.d.ts +7 -0
- package/lib/widgets/PasswordWidget.js +30 -0
- package/lib/widgets/PasswordWidget.js.map +1 -0
- package/lib/widgets/RadioWidget.d.ts +7 -0
- package/lib/widgets/RadioWidget.js +33 -0
- package/lib/widgets/RadioWidget.js.map +1 -0
- package/lib/widgets/RangeWidget.d.ts +7 -0
- package/lib/widgets/RangeWidget.js +34 -0
- package/lib/widgets/RangeWidget.js.map +1 -0
- package/lib/widgets/SelectWidget.d.ts +7 -0
- package/lib/widgets/SelectWidget.js +45 -0
- package/lib/widgets/SelectWidget.js.map +1 -0
- package/lib/widgets/TextareaWidget.d.ts +7 -0
- package/lib/widgets/TextareaWidget.js +30 -0
- package/lib/widgets/TextareaWidget.js.map +1 -0
- package/lib/widgets/index.d.ts +4 -0
- package/lib/widgets/index.js +34 -0
- package/lib/widgets/index.js.map +1 -0
- package/package.json +110 -0
- package/src/Form/index.ts +15 -0
- package/src/Theme/index.ts +18 -0
- package/src/index.ts +8 -0
- package/src/templates/ArrayFieldItemTemplate.tsx +40 -0
- package/src/templates/ArrayFieldTemplate.tsx +103 -0
- package/src/templates/ArrayFieldTitleTemplate.tsx +33 -0
- package/src/templates/BaseInputTemplate.tsx +134 -0
- package/src/templates/ButtonTemplates/AddButton.tsx +17 -0
- package/src/templates/ButtonTemplates/IconButton.tsx +87 -0
- package/src/templates/ButtonTemplates/SubmitButton.tsx +20 -0
- package/src/templates/ButtonTemplates/index.ts +21 -0
- package/src/templates/DescriptionField.tsx +24 -0
- package/src/templates/ErrorList.tsx +36 -0
- package/src/templates/FieldErrorTemplate.tsx +27 -0
- package/src/templates/FieldHelpTemplate.tsx +22 -0
- package/src/templates/FieldTemplate.tsx +66 -0
- package/src/templates/GridTemplate.tsx +30 -0
- package/src/templates/MultiSchemaFieldTemplate.tsx +15 -0
- package/src/templates/ObjectFieldTemplate.tsx +104 -0
- package/src/templates/TitleField.tsx +17 -0
- package/src/templates/WrapIfAdditionalTemplate.tsx +99 -0
- package/src/templates/icons.tsx +141 -0
- package/src/templates/index.ts +43 -0
- package/src/tsconfig.json +23 -0
- package/src/utils.ts +37 -0
- package/src/widgets/CheckboxWidget.tsx +110 -0
- package/src/widgets/CheckboxesWidget.tsx +112 -0
- package/src/widgets/ColorWidget.tsx +85 -0
- package/src/widgets/DateTime/AltDateTimeWidget.tsx +22 -0
- package/src/widgets/DateTime/AltDateWidget.tsx +139 -0
- package/src/widgets/DateTime/DateTimeInput.tsx +97 -0
- package/src/widgets/DateTime/DateTimeWidget.tsx +24 -0
- package/src/widgets/DateTime/DateWidget.tsx +22 -0
- package/src/widgets/DateTime/TimeWidget.tsx +83 -0
- package/src/widgets/DateTime/index.ts +5 -0
- package/src/widgets/FileWidget.tsx +176 -0
- package/src/widgets/PasswordWidget.tsx +88 -0
- package/src/widgets/RadioWidget.tsx +103 -0
- package/src/widgets/RangeWidget.tsx +95 -0
- package/src/widgets/SelectWidget.tsx +109 -0
- package/src/widgets/TextareaWidget.tsx +87 -0
- package/src/widgets/index.ts +42 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { ariaDescribedByIds, labelValue, } from '@rjsf/utils';
|
|
4
|
+
import { PasswordInput } from '@mantine/core';
|
|
5
|
+
import { cleanupOptions } from '../utils';
|
|
6
|
+
/**
|
|
7
|
+
* The `PasswordWidget` component renders a password input element.
|
|
8
|
+
*
|
|
9
|
+
* @param props - The `WidgetProps` for this component
|
|
10
|
+
*/
|
|
11
|
+
export default function PasswordWidget(props) {
|
|
12
|
+
const { id, name, value, placeholder, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, } = props;
|
|
13
|
+
const emptyValue = options.emptyValue || '';
|
|
14
|
+
const themeProps = cleanupOptions(options);
|
|
15
|
+
const handleChange = useCallback((e) => {
|
|
16
|
+
onChange(e.target.value === '' ? emptyValue : e.target.value);
|
|
17
|
+
}, [onChange, emptyValue]);
|
|
18
|
+
const handleBlur = useCallback(({ target }) => {
|
|
19
|
+
if (onBlur) {
|
|
20
|
+
onBlur(id, target && target.value);
|
|
21
|
+
}
|
|
22
|
+
}, [onBlur, id]);
|
|
23
|
+
const handleFocus = useCallback(({ target }) => {
|
|
24
|
+
if (onFocus) {
|
|
25
|
+
onFocus(id, target && target.value);
|
|
26
|
+
}
|
|
27
|
+
}, [onFocus, id]);
|
|
28
|
+
return (_jsx(PasswordInput, { id: id, name: name, value: value || '', placeholder: placeholder || undefined, required: required, disabled: disabled || readonly, autoFocus: autofocus, label: labelValue(label || undefined, hideLabel, false), onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, ...themeProps, "aria-describedby": ariaDescribedByIds(id) }));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=PasswordWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordWidget.js","sourceRoot":"","sources":["../../src/widgets/PasswordWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA2B,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAElB,UAAU,GAIX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAIpC,KAA2B;IAC3B,MAAM,EACJ,EAAE,EACF,IAAI,EACJ,KAAK,EACL,WAAW,EACX,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,UAAU,GAA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,EAAE,WAAW,EACpB,KAAK,EAAE,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,KACvE,UAAU,sBACI,kBAAkB,CAAI,EAAE,CAAC,GAC3C,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
3
|
+
* It is typically used with a string property constrained with enum options.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `WidgetProps` for this component
|
|
6
|
+
*/
|
|
7
|
+
export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, optionId, } from '@rjsf/utils';
|
|
4
|
+
import { Radio, Flex } from '@mantine/core';
|
|
5
|
+
import { cleanupOptions } from '../utils';
|
|
6
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
7
|
+
* It is typically used with a string property constrained with enum options.
|
|
8
|
+
*
|
|
9
|
+
* @param props - The `WidgetProps` for this component
|
|
10
|
+
*/
|
|
11
|
+
export default function RadioWidget(props) {
|
|
12
|
+
const { id, value, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, } = props;
|
|
13
|
+
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
14
|
+
const themeProps = cleanupOptions(options);
|
|
15
|
+
const handleChange = useCallback((nextValue) => {
|
|
16
|
+
if (!disabled && !readonly && onChange) {
|
|
17
|
+
onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
18
|
+
}
|
|
19
|
+
}, [onChange, disabled, readonly, enumOptions, emptyValue]);
|
|
20
|
+
const handleBlur = useCallback(({ target }) => {
|
|
21
|
+
if (onBlur) {
|
|
22
|
+
onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
23
|
+
}
|
|
24
|
+
}, [onBlur, id, enumOptions, emptyValue]);
|
|
25
|
+
const handleFocus = useCallback(({ target }) => {
|
|
26
|
+
if (onFocus) {
|
|
27
|
+
onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
28
|
+
}
|
|
29
|
+
}, [onFocus, id, enumOptions, emptyValue]);
|
|
30
|
+
const selected = enumOptionsIndexForValue(value, enumOptions);
|
|
31
|
+
return (_jsx(Radio.Group, { id: id, name: 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: String(i), label: option.label, disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1, autoFocus: i === 0 && autofocus, onBlur: handleBlur, onFocus: handleFocus }, i))) })) : null }));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=RadioWidget.js.map
|
|
@@ -0,0 +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,wBAAwB,EACxB,wBAAwB,EACxB,QAAQ,GAKT,MAAM,aAAa,CAAC;AACrB,OAAO,EA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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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
3
|
+
* in a div, with the value alongside it.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `WidgetProps` for this component
|
|
6
|
+
*/
|
|
7
|
+
export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { ariaDescribedByIds, rangeSpec, titleId, } from '@rjsf/utils';
|
|
4
|
+
import { Slider, Input } from '@mantine/core';
|
|
5
|
+
import { cleanupOptions } from '../utils';
|
|
6
|
+
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
7
|
+
* in a div, with the value alongside it.
|
|
8
|
+
*
|
|
9
|
+
* @param props - The `WidgetProps` for this component
|
|
10
|
+
*/
|
|
11
|
+
export default function RangeWidget(props) {
|
|
12
|
+
const { id, name, value, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, schema, } = props;
|
|
13
|
+
const themeProps = cleanupOptions(options);
|
|
14
|
+
const { min, max, step } = rangeSpec(schema);
|
|
15
|
+
const handleChange = useCallback((nextValue) => {
|
|
16
|
+
if (!disabled && !readonly && onChange) {
|
|
17
|
+
onChange(nextValue);
|
|
18
|
+
}
|
|
19
|
+
}, [onChange, disabled, readonly]);
|
|
20
|
+
const handleBlur = useCallback(() => {
|
|
21
|
+
if (onBlur) {
|
|
22
|
+
onBlur(id, value);
|
|
23
|
+
}
|
|
24
|
+
}, [onBlur, id, value]);
|
|
25
|
+
const handleFocus = useCallback(() => {
|
|
26
|
+
if (onFocus) {
|
|
27
|
+
onFocus(id, value);
|
|
28
|
+
}
|
|
29
|
+
}, [onFocus, id, value]);
|
|
30
|
+
return (_jsxs(_Fragment, { children: [!hideLabel && !!label && (_jsx(Input.Label, { id: titleId(id), required: required, children: label })), (options === null || options === void 0 ? void 0 : options.description) && _jsx(Input.Description, { children: options.description }), _jsx(Slider, { id: id, name: name, value: value, max: max, min: min, step: step, disabled: disabled || readonly, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, ...themeProps, "aria-describedby": ariaDescribedByIds(id) }), rawErrors &&
|
|
31
|
+
(rawErrors === null || rawErrors === void 0 ? void 0 : rawErrors.length) > 0 &&
|
|
32
|
+
rawErrors.map((error, index) => (_jsx(Input.Error, { children: error }, `range-widget-input-errors-${index}`)))] }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=RangeWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeWidget.js","sourceRoot":"","sources":["../../src/widgets/RangeWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,SAAS,EAKT,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,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CACf,EACA,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,KAAC,KAAK,CAAC,WAAW,cAAE,OAAO,CAAC,WAAW,GAAqB,EACrF,KAAC,MAAM,IACL,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,IAAI,QAAQ,EAC9B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,KAChB,UAAU,sBACI,kBAAkB,CAAI,EAAE,CAAC,GAC3C,EACD,SAAS;gBACR,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,IAAG,CAAC;gBACrB,SAAS,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,KAAa,EAAE,EAAE,CAAC,CAC9C,KAAC,KAAK,CAAC,KAAK,cAA6C,KAAK,IAA5C,6BAA6B,KAAK,EAAE,CAAuB,CAC9E,CAAC,IACH,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
3
|
+
* It is typically used with string properties constrained with enum options.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `WidgetProps` for this component
|
|
6
|
+
*/
|
|
7
|
+
export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, labelValue, } from '@rjsf/utils';
|
|
4
|
+
import { Select, MultiSelect } from '@mantine/core';
|
|
5
|
+
import { cleanupOptions } from '../utils';
|
|
6
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
7
|
+
* It is typically used with string properties constrained with enum options.
|
|
8
|
+
*
|
|
9
|
+
* @param props - The `WidgetProps` for this component
|
|
10
|
+
*/
|
|
11
|
+
export default function SelectWidget(props) {
|
|
12
|
+
const { id, value, placeholder, required, disabled, readonly, autofocus, label, hideLabel, multiple, rawErrors, options, onChange, onBlur, onFocus, } = props;
|
|
13
|
+
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
14
|
+
const themeProps = cleanupOptions(options);
|
|
15
|
+
const handleChange = useCallback((nextValue) => {
|
|
16
|
+
if (!disabled && !readonly && onChange) {
|
|
17
|
+
onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
18
|
+
}
|
|
19
|
+
}, [onChange, disabled, readonly, enumOptions, emptyValue]);
|
|
20
|
+
const handleBlur = useCallback(({ target }) => {
|
|
21
|
+
if (onBlur) {
|
|
22
|
+
onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
23
|
+
}
|
|
24
|
+
}, [onBlur, id, enumOptions, emptyValue]);
|
|
25
|
+
const handleFocus = useCallback(({ target }) => {
|
|
26
|
+
if (onFocus) {
|
|
27
|
+
onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
28
|
+
}
|
|
29
|
+
}, [onFocus, id, enumOptions, emptyValue]);
|
|
30
|
+
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
31
|
+
const selectOptions = useMemo(() => {
|
|
32
|
+
if (Array.isArray(enumOptions)) {
|
|
33
|
+
return enumOptions.map((option, index) => ({
|
|
34
|
+
key: String(index),
|
|
35
|
+
value: String(index),
|
|
36
|
+
label: option.label,
|
|
37
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
}, [enumDisabled, enumOptions]);
|
|
42
|
+
const Component = multiple ? MultiSelect : Select;
|
|
43
|
+
return (_jsx(Component, { id: id, name: id, label: labelValue(label || undefined, hideLabel, false), data: selectOptions, value: multiple ? selectedIndexes : selectedIndexes, onChange: !readonly ? handleChange : undefined, onBlur: !readonly ? handleBlur : undefined, onFocus: !readonly ? handleFocus : undefined, autoFocus: autofocus, placeholder: placeholder, disabled: disabled || readonly, required: required, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, searchable: true, ...themeProps, "aria-describedby": ariaDescribedByIds(id), comboboxProps: { withinPortal: false } }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=SelectWidget.js.map
|
|
@@ -0,0 +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,wBAAwB,EACxB,wBAAwB,EACxB,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,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,CAAC;IAC1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C,CAAC,CAAC,CAAC,SAAS,EAC3E,UAAU,WACN,UAAU,sBACI,kBAAkB,CAAI,EAAE,CAAC,EAC3C,aAAa,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,GACtC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { StrictRJSFSchema, RJSFSchema, FormContextType, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `WidgetProps` for this component
|
|
6
|
+
*/
|
|
7
|
+
export default function TextareaWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): ReactElement;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { labelValue, ariaDescribedByIds, } from '@rjsf/utils';
|
|
4
|
+
import { Textarea } from '@mantine/core';
|
|
5
|
+
import { cleanupOptions } from '../utils';
|
|
6
|
+
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
7
|
+
*
|
|
8
|
+
* @param props - The `WidgetProps` for this component
|
|
9
|
+
*/
|
|
10
|
+
export default function TextareaWidget(props) {
|
|
11
|
+
var _a;
|
|
12
|
+
const { id, name, value, placeholder, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, } = props;
|
|
13
|
+
const themeProps = cleanupOptions(options);
|
|
14
|
+
const emptyValue = (_a = options === null || options === void 0 ? void 0 : options.emptyValue) !== null && _a !== void 0 ? _a : '';
|
|
15
|
+
const handleChange = useCallback((e) => {
|
|
16
|
+
onChange(e.target.value === '' ? emptyValue : e.target.value);
|
|
17
|
+
}, [onChange, emptyValue]);
|
|
18
|
+
const handleBlur = useCallback(({ target }) => {
|
|
19
|
+
if (onBlur) {
|
|
20
|
+
onBlur(id, target && target.value);
|
|
21
|
+
}
|
|
22
|
+
}, [onBlur, id]);
|
|
23
|
+
const handleFocus = useCallback(({ target }) => {
|
|
24
|
+
if (onFocus) {
|
|
25
|
+
onFocus(id, target && target.value);
|
|
26
|
+
}
|
|
27
|
+
}, [onFocus, id]);
|
|
28
|
+
return (_jsx(Textarea, { id: id, name: name, value: value || '', placeholder: placeholder || undefined, required: required, disabled: disabled || readonly, autoFocus: autofocus, label: labelValue(label || undefined, hideLabel, false), onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, "aria-describedby": ariaDescribedByIds(id), ...themeProps }));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=TextareaWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextareaWidget.js","sourceRoot":"","sources":["../../src/widgets/TextareaWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAyC,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAKL,UAAU,EACV,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAIpC,KAA2B;;IAC3B,MAAM,EACJ,EAAE,EACF,IAAI,EACJ,KAAK,EACL,WAAW,EACX,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,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,mCAAI,EAAE,CAAC;I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S,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,sBACzD,kBAAkB,CAAI,EAAE,CAAC,KACvC,UAAU,GACd,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
export declare function generateWidgets<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(): RegistryWidgetsType<T, S, F>;
|
|
3
|
+
declare const _default: RegistryWidgetsType<any, RJSFSchema, any>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
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';
|
|
13
|
+
// This plugin is needed to support the parsing of date and time values in the `DateWidget` and `DateTimeWidget`
|
|
14
|
+
dayjs.extend(customParseFormat);
|
|
15
|
+
export function generateWidgets() {
|
|
16
|
+
return {
|
|
17
|
+
AltDateTimeWidget,
|
|
18
|
+
AltDateWidget,
|
|
19
|
+
CheckboxesWidget,
|
|
20
|
+
CheckboxWidget,
|
|
21
|
+
ColorWidget,
|
|
22
|
+
FileWidget,
|
|
23
|
+
DateTimeWidget,
|
|
24
|
+
DateWidget,
|
|
25
|
+
PasswordWidget,
|
|
26
|
+
RadioWidget,
|
|
27
|
+
RangeWidget,
|
|
28
|
+
SelectWidget,
|
|
29
|
+
TextareaWidget,
|
|
30
|
+
TimeWidget,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export default generateWidgets();
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/widgets/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtG,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,gHAAgH;AAChH,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEhC,MAAM,UAAU,eAAe;IAK7B,OAAO;QACL,iBAAiB;QACjB,aAAa;QACb,gBAAgB;QAChB,cAAc;QACd,WAAW;QACX,UAAU;QACV,cAAc;QACd,UAAU;QACV,cAAc;QACd,WAAW;QACX,WAAW;QACX,YAAY;QACZ,cAAc;QACd,UAAU;KACX,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rjsf/mantine",
|
|
3
|
+
"version": "6.0.0-beta.14",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "lib/index.js",
|
|
6
|
+
"typings": "lib/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"description": "Mantine theme, fields and widgets for react-jsonschema-form",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"import": "./lib/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./lib": {
|
|
16
|
+
"types": "./lib/index.d.ts",
|
|
17
|
+
"require": "./dist/index.js",
|
|
18
|
+
"import": "./lib/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./lib/*.js": {
|
|
21
|
+
"types": "./lib/*.d.ts",
|
|
22
|
+
"require": "./dist/*.js",
|
|
23
|
+
"import": "./lib/*.js"
|
|
24
|
+
},
|
|
25
|
+
"./dist": {
|
|
26
|
+
"types": "./lib/index.d.ts",
|
|
27
|
+
"require": "./dist/index.js",
|
|
28
|
+
"import": "./lib/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./dist/*.js": {
|
|
31
|
+
"types": "./lib/*.d.ts",
|
|
32
|
+
"require": "./dist/*.js",
|
|
33
|
+
"import": "./lib/*.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"lib",
|
|
39
|
+
"src"
|
|
40
|
+
],
|
|
41
|
+
"engineStrict": false,
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=20"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
47
|
+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
|
|
48
|
+
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/mantine.esm.js --sourcemap --packages=external --format=esm",
|
|
49
|
+
"build:umd": "rollup dist/mantine.esm.js --format=umd --file=dist/mantine.umd.js --name=@rjsf/mantine",
|
|
50
|
+
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
|
|
51
|
+
"cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"",
|
|
52
|
+
"cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
|
|
53
|
+
"lint": "eslint src test",
|
|
54
|
+
"precommit": "lint-staged",
|
|
55
|
+
"test": "jest",
|
|
56
|
+
"test:update": "jest --u"
|
|
57
|
+
},
|
|
58
|
+
"lint-staged": {
|
|
59
|
+
"{src,test}/**/*.ts?(x)": [
|
|
60
|
+
"eslint --fix"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@mantine/core": ">=8",
|
|
65
|
+
"@mantine/dates": ">=8",
|
|
66
|
+
"@mantine/hooks": ">=8",
|
|
67
|
+
"@rjsf/core": "^6.0.0-beta.14",
|
|
68
|
+
"@rjsf/utils": "^6.0.0-beta.14",
|
|
69
|
+
"react": ">=18"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@mantine/core": "^8.2.4",
|
|
73
|
+
"@mantine/dates": "^8.2.4",
|
|
74
|
+
"@mantine/hooks": "^8.2.4",
|
|
75
|
+
"@restart/hooks": "^0.6.2",
|
|
76
|
+
"@restart/ui": "^1.9.4",
|
|
77
|
+
"@rjsf/core": "^6.0.0-beta.14",
|
|
78
|
+
"@rjsf/snapshot-tests": "^6.0.0-beta.14",
|
|
79
|
+
"@rjsf/utils": "^6.0.0-beta.14",
|
|
80
|
+
"@rjsf/validator-ajv8": "^6.0.0-beta.14",
|
|
81
|
+
"eslint": "^8.57.1",
|
|
82
|
+
"uncontrollable": "^9.0.0"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
86
|
+
},
|
|
87
|
+
"author": "Farhad Zare <zfarhad.dev@gmail.com>",
|
|
88
|
+
"contributors": [
|
|
89
|
+
"Heath Chiavettone <heath.chiavettone@freenome.com",
|
|
90
|
+
"Algirdas Jokubauskas <sdkster@gmail.com"
|
|
91
|
+
],
|
|
92
|
+
"keywords": [
|
|
93
|
+
"Mantine",
|
|
94
|
+
"Mantine UI",
|
|
95
|
+
"react-jsonschema-form",
|
|
96
|
+
"jsonschema",
|
|
97
|
+
"json-schema",
|
|
98
|
+
"json",
|
|
99
|
+
"schema",
|
|
100
|
+
"form",
|
|
101
|
+
"react",
|
|
102
|
+
"mantine-ui",
|
|
103
|
+
"rjsf-mantine"
|
|
104
|
+
],
|
|
105
|
+
"repository": {
|
|
106
|
+
"type": "git",
|
|
107
|
+
"url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
|
|
108
|
+
},
|
|
109
|
+
"license": "Apache-2.0"
|
|
110
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { FormProps, withTheme } from '@rjsf/core';
|
|
3
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
|
+
|
|
5
|
+
import { generateTheme } from '../Theme';
|
|
6
|
+
|
|
7
|
+
export function generateForm<
|
|
8
|
+
T = any,
|
|
9
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
10
|
+
F extends FormContextType = any,
|
|
11
|
+
>(): ComponentType<FormProps<T, S, F>> {
|
|
12
|
+
return withTheme<T, S, F>(generateTheme<T, S, F>());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default generateForm();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ThemeProps } from '@rjsf/core';
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
import { generateTemplates } from '../templates';
|
|
5
|
+
import { generateWidgets } from '../widgets';
|
|
6
|
+
|
|
7
|
+
export function generateTheme<
|
|
8
|
+
T = any,
|
|
9
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
10
|
+
F extends FormContextType = any,
|
|
11
|
+
>(): ThemeProps<T, S, F> {
|
|
12
|
+
return {
|
|
13
|
+
templates: generateTemplates<T, S, F>(),
|
|
14
|
+
widgets: generateWidgets<T, S, F>(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default generateTheme();
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Form, { generateForm } from './Form';
|
|
2
|
+
import Templates, { generateTemplates } from './templates';
|
|
3
|
+
import Theme, { generateTheme } from './Theme';
|
|
4
|
+
import Widgets, { generateWidgets } from './widgets';
|
|
5
|
+
|
|
6
|
+
export { Form, Templates, Theme, Widgets, generateForm, generateTemplates, generateTheme, generateWidgets };
|
|
7
|
+
|
|
8
|
+
export default Form;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrayFieldItemTemplateType,
|
|
3
|
+
FormContextType,
|
|
4
|
+
getTemplate,
|
|
5
|
+
getUiOptions,
|
|
6
|
+
RJSFSchema,
|
|
7
|
+
StrictRJSFSchema,
|
|
8
|
+
} from '@rjsf/utils';
|
|
9
|
+
import { Box, Flex, Group } from '@mantine/core';
|
|
10
|
+
|
|
11
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
14
|
+
*/
|
|
15
|
+
export default function ArrayFieldItemTemplate<
|
|
16
|
+
T = any,
|
|
17
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
18
|
+
F extends FormContextType = any,
|
|
19
|
+
>(props: ArrayFieldItemTemplateType<T, S, F>) {
|
|
20
|
+
const { buttonsProps, className, hasToolbar, index, uiSchema, registry, children } = props;
|
|
21
|
+
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
22
|
+
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
|
|
23
|
+
'ArrayFieldItemButtonsTemplate',
|
|
24
|
+
registry,
|
|
25
|
+
uiOptions,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Box key={`array-item-${index}`} className={className || 'rjsf-array-item'} mb='xs'>
|
|
30
|
+
<Flex gap='xs' align='end' justify='center'>
|
|
31
|
+
<Box w='100%'>{children}</Box>
|
|
32
|
+
{hasToolbar && (
|
|
33
|
+
<Group wrap='nowrap' gap={2} mb={7}>
|
|
34
|
+
<ArrayFieldItemButtonsTemplate {...buttonsProps} />
|
|
35
|
+
</Group>
|
|
36
|
+
)}
|
|
37
|
+
</Flex>
|
|
38
|
+
</Box>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getTemplate,
|
|
3
|
+
getUiOptions,
|
|
4
|
+
ArrayFieldTemplateProps,
|
|
5
|
+
ArrayFieldItemTemplateType,
|
|
6
|
+
buttonId,
|
|
7
|
+
FormContextType,
|
|
8
|
+
RJSFSchema,
|
|
9
|
+
StrictRJSFSchema,
|
|
10
|
+
} from '@rjsf/utils';
|
|
11
|
+
import { Fieldset, Box, Group } from '@mantine/core';
|
|
12
|
+
|
|
13
|
+
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
14
|
+
*
|
|
15
|
+
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
16
|
+
*/
|
|
17
|
+
export default function ArrayFieldTemplate<
|
|
18
|
+
T = any,
|
|
19
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
20
|
+
F extends FormContextType = any,
|
|
21
|
+
>(props: ArrayFieldTemplateProps<T, S, F>) {
|
|
22
|
+
const {
|
|
23
|
+
canAdd,
|
|
24
|
+
className,
|
|
25
|
+
disabled,
|
|
26
|
+
idSchema,
|
|
27
|
+
items,
|
|
28
|
+
onAddClick,
|
|
29
|
+
readonly,
|
|
30
|
+
required,
|
|
31
|
+
schema,
|
|
32
|
+
uiSchema,
|
|
33
|
+
title,
|
|
34
|
+
registry,
|
|
35
|
+
} = props;
|
|
36
|
+
|
|
37
|
+
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
38
|
+
const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>(
|
|
39
|
+
'ArrayFieldDescriptionTemplate',
|
|
40
|
+
registry,
|
|
41
|
+
uiOptions,
|
|
42
|
+
);
|
|
43
|
+
const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
|
|
44
|
+
'ArrayFieldItemTemplate',
|
|
45
|
+
registry,
|
|
46
|
+
uiOptions,
|
|
47
|
+
);
|
|
48
|
+
const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
|
|
49
|
+
'ArrayFieldTitleTemplate',
|
|
50
|
+
registry,
|
|
51
|
+
uiOptions,
|
|
52
|
+
);
|
|
53
|
+
// Button templates are not overridden in the uiSchema
|
|
54
|
+
const {
|
|
55
|
+
ButtonTemplates: { AddButton },
|
|
56
|
+
} = registry.templates;
|
|
57
|
+
|
|
58
|
+
const legend = (uiOptions.title || title) && (
|
|
59
|
+
<ArrayFieldTitleTemplate
|
|
60
|
+
idSchema={idSchema}
|
|
61
|
+
required={required}
|
|
62
|
+
title={uiOptions.title || title}
|
|
63
|
+
schema={schema}
|
|
64
|
+
uiSchema={uiSchema}
|
|
65
|
+
registry={registry}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Fieldset legend={legend} className={className} id={idSchema.$id}>
|
|
71
|
+
{(uiOptions.description || schema.description) && (
|
|
72
|
+
<ArrayFieldDescriptionTemplate
|
|
73
|
+
description={uiOptions.description || schema.description}
|
|
74
|
+
idSchema={idSchema}
|
|
75
|
+
schema={schema}
|
|
76
|
+
uiSchema={uiSchema}
|
|
77
|
+
registry={registry}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
|
|
81
|
+
<Box className='row rjsf-array-item-list'>
|
|
82
|
+
{items &&
|
|
83
|
+
items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
|
|
84
|
+
<ArrayFieldItemTemplate key={key} {...itemProps} />
|
|
85
|
+
))}
|
|
86
|
+
</Box>
|
|
87
|
+
|
|
88
|
+
{canAdd && (
|
|
89
|
+
<Group justify='flex-end'>
|
|
90
|
+
<AddButton
|
|
91
|
+
id={buttonId<T>(idSchema, 'add')}
|
|
92
|
+
className='rjsf-array-item-add'
|
|
93
|
+
disabled={disabled || readonly}
|
|
94
|
+
onClick={onAddClick}
|
|
95
|
+
uiSchema={uiSchema}
|
|
96
|
+
registry={registry}
|
|
97
|
+
iconType='md'
|
|
98
|
+
/>
|
|
99
|
+
</Group>
|
|
100
|
+
)}
|
|
101
|
+
</Fieldset>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getUiOptions,
|
|
3
|
+
titleId,
|
|
4
|
+
ArrayFieldTitleProps,
|
|
5
|
+
FormContextType,
|
|
6
|
+
RJSFSchema,
|
|
7
|
+
StrictRJSFSchema,
|
|
8
|
+
} from '@rjsf/utils';
|
|
9
|
+
import { Title } from '@mantine/core';
|
|
10
|
+
|
|
11
|
+
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
12
|
+
* the `idSchema`.
|
|
13
|
+
*
|
|
14
|
+
* @param props - The `ArrayFieldTitleProps` for the component
|
|
15
|
+
*/
|
|
16
|
+
export default function ArrayFieldTitleTemplate<
|
|
17
|
+
T = any,
|
|
18
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
19
|
+
F extends FormContextType = any,
|
|
20
|
+
>(props: ArrayFieldTitleProps<T, S, F>) {
|
|
21
|
+
const { idSchema, title, uiSchema, registry } = props;
|
|
22
|
+
|
|
23
|
+
const options = getUiOptions<T, S, F>(uiSchema, registry.globalUiOptions);
|
|
24
|
+
const { label: displayLabel = true } = options;
|
|
25
|
+
if (!title || !displayLabel) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return (
|
|
29
|
+
<Title id={titleId<T>(idSchema)} order={4} fw='normal'>
|
|
30
|
+
{title}
|
|
31
|
+
</Title>
|
|
32
|
+
);
|
|
33
|
+
}
|