@rjsf/antd 5.11.2 → 5.12.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/antd.esm.js +891 -1117
- package/dist/antd.esm.js.map +7 -1
- package/dist/antd.umd.js +1184 -0
- package/dist/index.js +1347 -5
- package/dist/index.js.map +7 -0
- package/lib/components/DatePicker/index.d.ts +48 -0
- package/lib/components/DatePicker/index.js +5 -0
- package/lib/components/DatePicker/index.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +17 -0
- package/lib/index.js.map +1 -0
- package/lib/templates/ArrayFieldItemTemplate/index.d.ts +7 -0
- package/lib/templates/ArrayFieldItemTemplate/index.js +21 -0
- package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -0
- package/lib/templates/ArrayFieldTemplate/index.d.ts +7 -0
- package/lib/templates/ArrayFieldTemplate/index.js +38 -0
- package/lib/templates/ArrayFieldTemplate/index.js.map +1 -0
- package/lib/templates/BaseInputTemplate/index.d.ts +9 -0
- package/lib/templates/BaseInputTemplate/index.js +31 -0
- package/lib/templates/BaseInputTemplate/index.js.map +1 -0
- package/lib/templates/DescriptionField/index.d.ts +7 -0
- package/lib/templates/DescriptionField/index.js +13 -0
- package/lib/templates/DescriptionField/index.js.map +1 -0
- package/lib/templates/ErrorList/index.d.ts +7 -0
- package/lib/templates/ErrorList/index.js +16 -0
- package/lib/templates/ErrorList/index.js.map +1 -0
- package/lib/templates/FieldErrorTemplate/index.d.ts +7 -0
- package/lib/templates/FieldErrorTemplate/index.js +15 -0
- package/lib/templates/FieldErrorTemplate/index.js.map +1 -0
- package/lib/templates/FieldTemplate/index.d.ts +8 -0
- package/lib/templates/FieldTemplate/index.js +34 -0
- package/lib/templates/FieldTemplate/index.js.map +1 -0
- package/lib/templates/IconButton/index.d.ts +10 -0
- package/lib/templates/IconButton/index.js +36 -0
- package/lib/templates/IconButton/index.js.map +1 -0
- package/lib/templates/ObjectFieldTemplate/index.d.ts +9 -0
- package/lib/templates/ObjectFieldTemplate/index.js +71 -0
- package/lib/templates/ObjectFieldTemplate/index.js.map +1 -0
- package/lib/templates/SubmitButton/index.d.ts +5 -0
- package/lib/templates/SubmitButton/index.js +13 -0
- package/lib/templates/SubmitButton/index.js.map +1 -0
- package/lib/templates/TitleField/index.d.ts +7 -0
- package/lib/templates/TitleField/index.js +34 -0
- package/lib/templates/TitleField/index.js.map +1 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +8 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.js +34 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.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/widgets/AltDateTimeWidget/index.d.ts +15 -0
- package/lib/widgets/AltDateTimeWidget/index.js +8 -0
- package/lib/widgets/AltDateTimeWidget/index.js.map +1 -0
- package/lib/widgets/AltDateWidget/index.d.ts +15 -0
- package/lib/widgets/AltDateWidget/index.js +89 -0
- package/lib/widgets/AltDateWidget/index.js.map +1 -0
- package/lib/widgets/CheckboxWidget/index.d.ts +8 -0
- package/lib/widgets/CheckboxWidget/index.js +23 -0
- package/lib/widgets/CheckboxWidget/index.js.map +1 -0
- package/lib/widgets/CheckboxesWidget/index.d.ts +8 -0
- package/lib/widgets/CheckboxesWidget/index.js +26 -0
- package/lib/widgets/CheckboxesWidget/index.js.map +1 -0
- package/lib/widgets/DateTimeWidget/index.d.ts +8 -0
- package/lib/widgets/DateTimeWidget/index.js +22 -0
- package/lib/widgets/DateTimeWidget/index.js.map +1 -0
- package/lib/widgets/DateWidget/index.d.ts +8 -0
- package/lib/widgets/DateWidget/index.js +22 -0
- package/lib/widgets/DateWidget/index.js.map +1 -0
- package/lib/widgets/PasswordWidget/index.d.ts +7 -0
- package/lib/widgets/PasswordWidget/index.js +17 -0
- package/lib/widgets/PasswordWidget/index.js.map +1 -0
- package/lib/widgets/RadioWidget/index.d.ts +8 -0
- package/lib/widgets/RadioWidget/index.js +19 -0
- package/lib/widgets/RadioWidget/index.js.map +1 -0
- package/lib/widgets/RangeWidget/index.d.ts +8 -0
- package/lib/widgets/RangeWidget/index.js +26 -0
- package/lib/widgets/RangeWidget/index.js.map +1 -0
- package/lib/widgets/SelectWidget/index.d.ts +8 -0
- package/lib/widgets/SelectWidget/index.js +36 -0
- package/lib/widgets/SelectWidget/index.js.map +1 -0
- package/lib/widgets/TextareaWidget/index.d.ts +7 -0
- package/lib/widgets/TextareaWidget/index.js +23 -0
- package/lib/widgets/TextareaWidget/index.js.map +1 -0
- package/lib/widgets/index.d.ts +4 -0
- package/lib/widgets/index.js +28 -0
- package/lib/widgets/index.js.map +1 -0
- package/package.json +24 -16
- package/src/components/DatePicker/index.ts +6 -0
- package/src/index.less +38 -0
- package/src/index.ts +33 -0
- package/src/templates/ArrayFieldItemTemplate/index.tsx +90 -0
- package/src/templates/ArrayFieldTemplate/index.tsx +132 -0
- package/src/templates/BaseInputTemplate/index.tsx +105 -0
- package/src/templates/DescriptionField/index.tsx +17 -0
- package/src/templates/ErrorList/index.tsx +37 -0
- package/src/templates/FieldErrorTemplate/index.tsx +25 -0
- package/src/templates/FieldTemplate/index.tsx +114 -0
- package/src/templates/IconButton/index.tsx +94 -0
- package/src/templates/ObjectFieldTemplate/index.tsx +175 -0
- package/src/templates/SubmitButton/index.tsx +20 -0
- package/src/templates/TitleField/index.tsx +57 -0
- package/src/templates/WrapIfAdditionalTemplate/index.tsx +124 -0
- package/src/templates/index.ts +43 -0
- package/src/widgets/AltDateTimeWidget/index.tsx +17 -0
- package/src/widgets/AltDateWidget/index.tsx +197 -0
- package/src/widgets/CheckboxWidget/index.tsx +52 -0
- package/src/widgets/CheckboxesWidget/index.tsx +75 -0
- package/src/widgets/DateTimeWidget/index.tsx +54 -0
- package/src/widgets/DateWidget/index.tsx +52 -0
- package/src/widgets/PasswordWidget/index.tsx +46 -0
- package/src/widgets/RadioWidget/index.tsx +73 -0
- package/src/widgets/RangeWidget/index.tsx +69 -0
- package/src/widgets/SelectWidget/index.tsx +97 -0
- package/src/widgets/TextareaWidget/index.tsx +67 -0
- package/src/widgets/index.ts +35 -0
- package/dist/antd.cjs.development.js +0 -1643
- package/dist/antd.cjs.development.js.map +0 -1
- package/dist/antd.cjs.production.min.js +0 -2
- package/dist/antd.cjs.production.min.js.map +0 -1
- package/dist/antd.umd.development.js +0 -1617
- package/dist/antd.umd.development.js.map +0 -1
- package/dist/antd.umd.production.min.js +0 -2
- package/dist/antd.umd.production.min.js.map +0 -1
- package/dist/index.d.ts +0 -16
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
4
|
+
* the value to/from utc using the appropriate utility functions.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `WidgetProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function DateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { ariaDescribedByIds, } from '@rjsf/utils';
|
|
4
|
+
import DatePicker from '../../components/DatePicker';
|
|
5
|
+
const DATE_PICKER_STYLE = {
|
|
6
|
+
width: '100%',
|
|
7
|
+
};
|
|
8
|
+
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
9
|
+
* the value to/from utc using the appropriate utility functions.
|
|
10
|
+
*
|
|
11
|
+
* @param props - The `WidgetProps` for this component
|
|
12
|
+
*/
|
|
13
|
+
export default function DateTimeWidget(props) {
|
|
14
|
+
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
|
|
15
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
16
|
+
const handleChange = (nextValue) => onChange(nextValue && nextValue.toISOString());
|
|
17
|
+
const handleBlur = () => onBlur(id, value);
|
|
18
|
+
const handleFocus = () => onFocus(id, value);
|
|
19
|
+
const getPopupContainer = (node) => node.parentNode;
|
|
20
|
+
return (_jsx(DatePicker, { disabled: disabled || (readonlyAsDisabled && readonly), getPopupContainer: getPopupContainer, id: id, name: id, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, showTime: true, style: DATE_PICKER_STYLE, value: value && dayjs(value), "aria-describedby": ariaDescribedByIds(id) }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/DateTimeWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,kBAAkB,GAMnB,MAAM,aAAa,CAAC;AAErB,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAErD,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,MAAM;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAIpC,KAA2B;IAC3B,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACrG,MAAM,EAAE,kBAAkB,GAAG,IAAI,EAAE,GAAG,WAAgC,CAAC;IAEvE,MAAM,YAAY,GAAG,CAAC,SAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;IAExF,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAE3C,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAE7C,MAAM,iBAAiB,GAAG,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;IAEzD,OAAO,CACL,KAAC,UAAU,IACT,QAAQ,EAAE,QAAQ,IAAI,CAAC,kBAAkB,IAAI,QAAQ,CAAC,EACtD,iBAAiB,EAAE,iBAAiB,EACpC,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,EAAE,EACR,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAC1C,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,EAC9C,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAC5C,WAAW,EAAE,WAAW,EACxB,QAAQ,QACR,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,sBACV,kBAAkB,CAAI,EAAE,CAAC,GAC3C,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
4
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `WidgetProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function DateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { ariaDescribedByIds, } from '@rjsf/utils';
|
|
4
|
+
import DatePicker from '../../components/DatePicker';
|
|
5
|
+
const DATE_PICKER_STYLE = {
|
|
6
|
+
width: '100%',
|
|
7
|
+
};
|
|
8
|
+
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
9
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
10
|
+
*
|
|
11
|
+
* @param props - The `WidgetProps` for this component
|
|
12
|
+
*/
|
|
13
|
+
export default function DateWidget(props) {
|
|
14
|
+
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
|
|
15
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
16
|
+
const handleChange = (nextValue) => onChange(nextValue && nextValue.format('YYYY-MM-DD'));
|
|
17
|
+
const handleBlur = () => onBlur(id, value);
|
|
18
|
+
const handleFocus = () => onFocus(id, value);
|
|
19
|
+
const getPopupContainer = (node) => node.parentNode;
|
|
20
|
+
return (_jsx(DatePicker, { disabled: disabled || (readonlyAsDisabled && readonly), getPopupContainer: getPopupContainer, id: id, name: id, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, showTime: false, style: DATE_PICKER_STYLE, value: value && dayjs(value), "aria-describedby": ariaDescribedByIds(id) }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/DateWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,kBAAkB,GAMnB,MAAM,aAAa,CAAC;AAErB,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAErD,MAAM,iBAAiB,GAAG;IACxB,KAAK,EA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B,CAAI,EAAE,CAAC,GAC3C,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
/** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `WidgetProps` for this component
|
|
6
|
+
*/
|
|
7
|
+
export default function PasswordWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Input from 'antd/lib/input';
|
|
3
|
+
import { ariaDescribedByIds, } from '@rjsf/utils';
|
|
4
|
+
/** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `WidgetProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function PasswordWidget(props) {
|
|
9
|
+
const { disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
|
|
10
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
11
|
+
const emptyValue = options.emptyValue || '';
|
|
12
|
+
const handleChange = ({ target }) => onChange(target.value === '' ? emptyValue : target.value);
|
|
13
|
+
const handleBlur = ({ target }) => onBlur(id, target.value);
|
|
14
|
+
const handleFocus = ({ target }) => onFocus(id, target.value);
|
|
15
|
+
return (_jsx(Input.Password, { disabled: disabled || (readonlyAsDisabled && readonly), id: id, name: id, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, value: value || '', "aria-describedby": ariaDescribedByIds(id) }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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Y,CAAC,CAAC,CAAC,SAAS,EAC9C,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAC5C,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,IAAI,EAAE,sBACA,kBAAkB,CAAI,EAAE,CAAC,GAC3C,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
4
|
+
* It is typically used with a string property constrained with enum options.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `WidgetProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, readonly, value, }: WidgetProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Radio from 'antd/lib/radio';
|
|
3
|
+
import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, optionId, } from '@rjsf/utils';
|
|
4
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
5
|
+
* It is typically used with a string property constrained with enum options.
|
|
6
|
+
*
|
|
7
|
+
* @param props - The `WidgetProps` for this component
|
|
8
|
+
*/
|
|
9
|
+
export default function RadioWidget({ autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, readonly, value, }) {
|
|
10
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
11
|
+
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
12
|
+
const handleChange = ({ target: { value: nextValue } }) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
13
|
+
const handleBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
14
|
+
const handleFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
15
|
+
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions);
|
|
16
|
+
return (_jsx(Radio.Group, Object.assign({ disabled: disabled || (readonlyAsDisabled && readonly), id: id, name: id, onChange: !readonly ? handleChange : undefined, onBlur: !readonly ? handleBlur : undefined, onFocus: !readonly ? handleFocus : undefined, value: selectedIndexes, "aria-describedby": ariaDescribedByIds(id) }, { children: Array.isArray(enumOptions) &&
|
|
17
|
+
enumOptions.map((option, i) => (_jsx(Radio, Object.assign({ id: optionId(id, i), name: id, autoFocus: i === 0 ? autofocus : false, disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1, value: String(i) }, { children: option.label }), i))) })));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/RadioWidget/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAA2B,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,QAAQ,GAMT,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAoF,EACrH,SAAS,EACT,QAAQ,EACR,WAAW,EACX,EAAE,EACF,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,GACgB;IACrB,MAAM,EAAE,kBAAkB,GAAG,IAAI,EAAE,GAAG,WAAgC,CAAC;IAEvE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE1D,MAAM,YAAY,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAoB,EAAE,EAAE,CAC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KAAK,EACtC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAE3E,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,gBAEf,MAAM,CAAC,KAAK,KAHR,CAAC,CAIA,CACT,CAAC,IACQ,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
4
|
+
* in a div, with the value along side it.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `WidgetProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Slider from 'antd/lib/slider';
|
|
3
|
+
import { ariaDescribedByIds, rangeSpec, } from '@rjsf/utils';
|
|
4
|
+
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
5
|
+
* in a div, with the value along side it.
|
|
6
|
+
*
|
|
7
|
+
* @param props - The `WidgetProps` for this component
|
|
8
|
+
*/
|
|
9
|
+
export default function RangeWidget(props) {
|
|
10
|
+
const { autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, schema, value, } = props;
|
|
11
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
12
|
+
const { min, max, step } = rangeSpec(schema);
|
|
13
|
+
const emptyValue = options.emptyValue || '';
|
|
14
|
+
const handleChange = (nextValue) => onChange(nextValue === '' ? emptyValue : nextValue);
|
|
15
|
+
const handleBlur = () => onBlur(id, value);
|
|
16
|
+
const handleFocus = () => onFocus(id, value);
|
|
17
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
18
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
19
|
+
const extraProps = {
|
|
20
|
+
placeholder,
|
|
21
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
22
|
+
onFocus: !readonly ? handleFocus : undefined,
|
|
23
|
+
};
|
|
24
|
+
return (_jsx(Slider, Object.assign({ autoFocus: autofocus, disabled: disabled || (readonlyAsDisabled && readonly), id: id, max: max, min: min, onChange: !readonly ? handleChange : undefined, range: false, step: step, value: value }, extraProps, { "aria-describedby": ariaDescribedByIds(id) })));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/RangeWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,SAAS,GAMV,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,KAA2B;IAE3B,MAAM,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,EAAE,EACF,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,GACN,GAAG,KAAK,CAAC;IACV,MAAM,EAAE,kBAAkB,GAAG,IAAI,EAAE,GAAG,WAAgC,CAAC;IAEvE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAE7C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;IAE5C,MAAM,YAAY,GAAG,CAAC,SAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAE7F,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAE3C,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAE7C,iHAAiH;IACjH,8GAA8G;IAC9G,MAAM,UAAU,GAAG;QACjB,WAAW;QACX,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;QAC1C,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;KAC7C,CAAC;IAEF,OAAO,CACL,KAAC,MAAM,kBACL,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,IAAI,CAAC,kBAAkB,IAAI,QAAQ,CAAC,EACtD,EAAE,EAAE,EAAE,EACN,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,EAC9C,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,IACR,UAAU,wBACI,kBAAkB,CAAI,EAAE,CAAC,IAC3C,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
4
|
+
* It is typically used with string properties constrained with enum options.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `WidgetProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ autofocus, disabled, formContext, id, multiple, onBlur, onChange, onFocus, options, placeholder, readonly, value, }: WidgetProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Select from 'antd/lib/select';
|
|
3
|
+
import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, } from '@rjsf/utils';
|
|
4
|
+
import isString from 'lodash/isString';
|
|
5
|
+
const SELECT_STYLE = {
|
|
6
|
+
width: '100%',
|
|
7
|
+
};
|
|
8
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
9
|
+
* It is typically used with string properties constrained with enum options.
|
|
10
|
+
*
|
|
11
|
+
* @param props - The `WidgetProps` for this component
|
|
12
|
+
*/
|
|
13
|
+
export default function SelectWidget({ autofocus, disabled, formContext = {}, id, multiple, onBlur, onChange, onFocus, options, placeholder, readonly, value, }) {
|
|
14
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
15
|
+
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
16
|
+
const handleChange = (nextValue) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
17
|
+
const handleBlur = () => onBlur(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
18
|
+
const handleFocus = () => onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
19
|
+
const filterOption = (input, option) => {
|
|
20
|
+
if (option && isString(option.label)) {
|
|
21
|
+
// labels are strings in this context
|
|
22
|
+
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
const getPopupContainer = (node) => node.parentNode;
|
|
27
|
+
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
28
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
29
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
30
|
+
const extraProps = {
|
|
31
|
+
name: id,
|
|
32
|
+
};
|
|
33
|
+
return (_jsx(Select, Object.assign({ autoFocus: autofocus, disabled: disabled || (readonlyAsDisabled && readonly), getPopupContainer: getPopupContainer, id: id, mode: multiple ? 'multiple' : undefined, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, style: SELECT_STYLE, value: selectedIndexes }, extraProps, { filterOption: filterOption, "aria-describedby": ariaDescribedByIds(id) }, { children: Array.isArray(enumOptions) &&
|
|
34
|
+
enumOptions.map(({ value: optionValue, label: optionLabel }, index) => (_jsx(Select.Option, Object.assign({ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1, value: String(index) }, { children: optionLabel }), String(index)))) })));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/SelectWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,MAA6B,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GAMzB,MAAM,aAAa,CAAC;AACrB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,MAAM;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAIlC,EACA,SAAS,EACT,QAAQ,EACR,WAAW,GAAG,EAAO,EACrB,EAAE,EACF,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,KAAK,GACgB;IACrB,MAAM,EAAE,kBAAkB,GAAG,IAAI,EAAE,GAAG,WAAgC,CAAC;IAEvE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE1D,MAAM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U,CAAC,CAAC,CAAC,SAAS,EAC1C,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,EAC9C,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAC5C,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,eAAe,IAClB,UAAU,IACd,YAAY,EAAE,YAAY,sBACR,kBAAkB,CAAI,EAAE,CAAC,gBAE1C,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YACzB,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CACrE,KAAC,MAAM,CAAC,MAAM,kBACZ,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAEjF,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,gBAEnB,WAAW,KAHP,MAAM,CAAC,KAAK,CAAC,CAIJ,CACjB,CAAC,IACG,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, 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>({ disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value, }: WidgetProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Input from 'antd/lib/input';
|
|
3
|
+
import { ariaDescribedByIds, } from '@rjsf/utils';
|
|
4
|
+
const INPUT_STYLE = {
|
|
5
|
+
width: '100%',
|
|
6
|
+
};
|
|
7
|
+
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
8
|
+
*
|
|
9
|
+
* @param props - The `WidgetProps` for this component
|
|
10
|
+
*/
|
|
11
|
+
export default function TextareaWidget({ disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value, }) {
|
|
12
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
13
|
+
const handleChange = ({ target }) => onChange(target.value === '' ? options.emptyValue : target.value);
|
|
14
|
+
const handleBlur = ({ target }) => onBlur(id, target.value);
|
|
15
|
+
const handleFocus = ({ target }) => onFocus(id, target.value);
|
|
16
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
17
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
18
|
+
const extraProps = {
|
|
19
|
+
type: 'textarea',
|
|
20
|
+
};
|
|
21
|
+
return (_jsx(Input.TextArea, Object.assign({ disabled: disabled || (readonlyAsDisabled && readonly), id: id, name: id, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, rows: options.rows || 4, style: INPUT_STYLE, value: value }, extraProps, { "aria-describedby": ariaDescribedByIds(id) })));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/TextareaWidget/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,EACL,kBAAkB,GAMnB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,U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KAAK,EAAE,KAAK,IACR,UAAU,wBACI,kBAAkB,CAAI,EAAE,CAAC,IAC3C,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,28 @@
|
|
|
1
|
+
import AltDateTimeWidget from './AltDateTimeWidget';
|
|
2
|
+
import AltDateWidget from './AltDateWidget';
|
|
3
|
+
import CheckboxesWidget from './CheckboxesWidget';
|
|
4
|
+
import CheckboxWidget from './CheckboxWidget';
|
|
5
|
+
import DateTimeWidget from './DateTimeWidget';
|
|
6
|
+
import DateWidget from './DateWidget';
|
|
7
|
+
import PasswordWidget from './PasswordWidget';
|
|
8
|
+
import RadioWidget from './RadioWidget';
|
|
9
|
+
import RangeWidget from './RangeWidget';
|
|
10
|
+
import SelectWidget from './SelectWidget';
|
|
11
|
+
import TextareaWidget from './TextareaWidget';
|
|
12
|
+
export function generateWidgets() {
|
|
13
|
+
return {
|
|
14
|
+
AltDateTimeWidget,
|
|
15
|
+
AltDateWidget,
|
|
16
|
+
CheckboxesWidget,
|
|
17
|
+
CheckboxWidget,
|
|
18
|
+
DateTimeWidget,
|
|
19
|
+
DateWidget,
|
|
20
|
+
PasswordWidget,
|
|
21
|
+
RadioWidget,
|
|
22
|
+
RangeWidget,
|
|
23
|
+
SelectWidget,
|
|
24
|
+
TextareaWidget,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export default generateWidgets();
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/widgets/index.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,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,MAAM,UAAU,eAAe;IAK7B,OAAO;QACL,iBAAiB;QACjB,aAAa;QACb,gBAAgB;QAChB,cAAc;QACd,cAAc;QACd,UAAU;QACV,cAAc;QACd,WAAW;QACX,WAAW;QACX,YAAY;QACZ,cAAc;KACf,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/antd",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.1",
|
|
4
4
|
"description": "Ant Design theme, fields and widgets for react-jsonschema-form",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"module": "
|
|
7
|
-
"typings": "
|
|
6
|
+
"module": "lib/index.js",
|
|
7
|
+
"typings": "lib/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "rimraf
|
|
9
|
+
"build:ts": "rimraf lib && tsc",
|
|
10
|
+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
|
|
11
|
+
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/antd.esm.js --sourcemap --packages=external --format=esm",
|
|
12
|
+
"build:umd": "rollup dist/antd.esm.js --format=umd --file=dist/antd.umd.js --name=@rjsf/antd",
|
|
13
|
+
"build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
|
|
10
14
|
"cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"",
|
|
11
15
|
"cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
|
|
12
16
|
"lint": "eslint src test",
|
|
@@ -21,7 +25,9 @@
|
|
|
21
25
|
]
|
|
22
26
|
},
|
|
23
27
|
"files": [
|
|
24
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"lib",
|
|
30
|
+
"src"
|
|
25
31
|
],
|
|
26
32
|
"engineStrict": false,
|
|
27
33
|
"engines": {
|
|
@@ -51,26 +57,28 @@
|
|
|
51
57
|
"@babel/preset-env": "^7.22.9",
|
|
52
58
|
"@babel/preset-react": "^7.22.5",
|
|
53
59
|
"@babel/preset-typescript": "^7.22.5",
|
|
54
|
-
"@rjsf/core": "^5.
|
|
55
|
-
"@rjsf/utils": "^5.
|
|
56
|
-
"@rjsf/validator-ajv8": "^5.
|
|
60
|
+
"@rjsf/core": "^5.12.1",
|
|
61
|
+
"@rjsf/utils": "^5.12.1",
|
|
62
|
+
"@rjsf/validator-ajv8": "^5.12.1",
|
|
57
63
|
"@rollup/plugin-replace": "^5.0.2",
|
|
58
|
-
"@types/lodash": "^4.14.
|
|
64
|
+
"@types/lodash": "^4.14.196",
|
|
59
65
|
"@types/react": "^17.0.62",
|
|
60
66
|
"@types/react-dom": "^17.0.20",
|
|
61
67
|
"@types/react-test-renderer": "^17.0.2",
|
|
62
|
-
"antd": "^4.24.
|
|
68
|
+
"antd": "^4.24.13",
|
|
63
69
|
"atob": "^2.1.2",
|
|
64
|
-
"babel-jest": "^29.6.
|
|
70
|
+
"babel-jest": "^29.6.2",
|
|
65
71
|
"dayjs": "^1.11.9",
|
|
66
|
-
"
|
|
67
|
-
"eslint": "^8.
|
|
68
|
-
"jest": "^29.6.
|
|
72
|
+
"esbuild": "^0.18.19",
|
|
73
|
+
"eslint": "^8.46.0",
|
|
74
|
+
"jest": "^29.6.2",
|
|
69
75
|
"jest-environment-jsdom": "^29.6.1",
|
|
70
76
|
"react": "^17.0.2",
|
|
71
77
|
"react-dom": "^17.0.2",
|
|
72
78
|
"react-test-renderer": "^17.0.2",
|
|
73
|
-
"rimraf": "^5.0.1"
|
|
79
|
+
"rimraf": "^5.0.1",
|
|
80
|
+
"rollup": "^3.27.2",
|
|
81
|
+
"typescript": "^4.9.5"
|
|
74
82
|
},
|
|
75
83
|
"repository": {
|
|
76
84
|
"type": "git",
|
|
@@ -98,5 +106,5 @@
|
|
|
98
106
|
"publishConfig": {
|
|
99
107
|
"access": "public"
|
|
100
108
|
},
|
|
101
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "de6477730fd16a07def501c2cb761af9c3f4c247"
|
|
102
110
|
}
|
package/src/index.less
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import '~antd/lib/style/themes/default.less';
|
|
2
|
+
|
|
3
|
+
.field-hidden {
|
|
4
|
+
display: none;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.form-group.field-object {
|
|
8
|
+
margin-bottom: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.form-group:not(.field) {
|
|
12
|
+
// Add margin below oneOf / anyOf dropdown.
|
|
13
|
+
margin-bottom: @form-item-margin-bottom;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.object-property-expand {
|
|
17
|
+
// Add margin below the `additionalProperties` related add button.
|
|
18
|
+
margin-bottom: @form-item-margin-bottom;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// .panel.panel-default.panel-body > .ant-row > fieldset > .ant-col.ant-form-item-label {
|
|
22
|
+
.panel.panel-default.panel-body fieldset > .ant-col.ant-form-item-label {
|
|
23
|
+
// Hide oneOf / anyOf object title.
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.panel.panel-danger.errors {
|
|
28
|
+
margin-bottom: @form-item-margin-bottom;
|
|
29
|
+
|
|
30
|
+
.list-group .ant-list-item {
|
|
31
|
+
margin-left: 0;
|
|
32
|
+
margin-right: 0;
|
|
33
|
+
|
|
34
|
+
.anticon.anticon-exclamation-circle {
|
|
35
|
+
color: @red-6;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { FormProps, ThemeProps, withTheme } from '@rjsf/core';
|
|
4
|
+
|
|
5
|
+
import Templates, { generateTemplates } from './templates';
|
|
6
|
+
import Widgets, { generateWidgets } from './widgets';
|
|
7
|
+
|
|
8
|
+
export function generateTheme<
|
|
9
|
+
T = any,
|
|
10
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
|
+
F extends FormContextType = any
|
|
12
|
+
>(): ThemeProps<T, S, F> {
|
|
13
|
+
return {
|
|
14
|
+
templates: generateTemplates<T, S, F>(),
|
|
15
|
+
widgets: generateWidgets<T, S, F>(),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Theme = generateTheme();
|
|
20
|
+
|
|
21
|
+
export function generateForm<
|
|
22
|
+
T = any,
|
|
23
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
24
|
+
F extends FormContextType = any
|
|
25
|
+
>(): ComponentType<FormProps<T, S, F>> {
|
|
26
|
+
return withTheme<T, S, F>(generateTheme<T, S, F>());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Form = generateForm();
|
|
30
|
+
|
|
31
|
+
export { Form, Templates, Theme, Widgets, generateTemplates, generateWidgets };
|
|
32
|
+
|
|
33
|
+
export default Form;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import Button from 'antd/lib/button';
|
|
2
|
+
import Col from 'antd/lib/col';
|
|
3
|
+
import Row from 'antd/lib/row';
|
|
4
|
+
import { ArrayFieldTemplateItemType, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
5
|
+
|
|
6
|
+
const BTN_GRP_STYLE = {
|
|
7
|
+
width: '100%',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const BTN_STYLE = {
|
|
11
|
+
width: 'calc(100% / 4)',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
17
|
+
*/
|
|
18
|
+
export default function ArrayFieldItemTemplate<
|
|
19
|
+
T = any,
|
|
20
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
21
|
+
F extends FormContextType = any
|
|
22
|
+
>(props: ArrayFieldTemplateItemType<T, S, F>) {
|
|
23
|
+
const {
|
|
24
|
+
children,
|
|
25
|
+
disabled,
|
|
26
|
+
hasCopy,
|
|
27
|
+
hasMoveDown,
|
|
28
|
+
hasMoveUp,
|
|
29
|
+
hasRemove,
|
|
30
|
+
hasToolbar,
|
|
31
|
+
index,
|
|
32
|
+
onCopyIndexClick,
|
|
33
|
+
onDropIndexClick,
|
|
34
|
+
onReorderClick,
|
|
35
|
+
readonly,
|
|
36
|
+
registry,
|
|
37
|
+
uiSchema,
|
|
38
|
+
} = props;
|
|
39
|
+
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
|
|
40
|
+
const { rowGutter = 24, toolbarAlign = 'top' } = registry.formContext;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Row align={toolbarAlign} key={`array-item-${index}`} gutter={rowGutter}>
|
|
44
|
+
<Col flex='1'>{children}</Col>
|
|
45
|
+
|
|
46
|
+
{hasToolbar && (
|
|
47
|
+
<Col flex='192px'>
|
|
48
|
+
<Button.Group style={BTN_GRP_STYLE}>
|
|
49
|
+
{(hasMoveUp || hasMoveDown) && (
|
|
50
|
+
<MoveUpButton
|
|
51
|
+
disabled={disabled || readonly || !hasMoveUp}
|
|
52
|
+
onClick={onReorderClick(index, index - 1)}
|
|
53
|
+
style={BTN_STYLE}
|
|
54
|
+
uiSchema={uiSchema}
|
|
55
|
+
registry={registry}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
{(hasMoveUp || hasMoveDown) && (
|
|
59
|
+
<MoveDownButton
|
|
60
|
+
disabled={disabled || readonly || !hasMoveDown}
|
|
61
|
+
onClick={onReorderClick(index, index + 1)}
|
|
62
|
+
style={BTN_STYLE}
|
|
63
|
+
uiSchema={uiSchema}
|
|
64
|
+
registry={registry}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
{hasCopy && (
|
|
68
|
+
<CopyButton
|
|
69
|
+
disabled={disabled || readonly}
|
|
70
|
+
onClick={onCopyIndexClick(index)}
|
|
71
|
+
style={BTN_STYLE}
|
|
72
|
+
uiSchema={uiSchema}
|
|
73
|
+
registry={registry}
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
{hasRemove && (
|
|
77
|
+
<RemoveButton
|
|
78
|
+
disabled={disabled || readonly}
|
|
79
|
+
onClick={onDropIndexClick(index)}
|
|
80
|
+
style={BTN_STYLE}
|
|
81
|
+
uiSchema={uiSchema}
|
|
82
|
+
registry={registry}
|
|
83
|
+
/>
|
|
84
|
+
)}
|
|
85
|
+
</Button.Group>
|
|
86
|
+
</Col>
|
|
87
|
+
)}
|
|
88
|
+
</Row>
|
|
89
|
+
);
|
|
90
|
+
}
|