@rjsf/antd 6.1.1 → 6.2.3
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 +53 -30
- package/dist/antd.esm.js.map +4 -4
- package/dist/antd.umd.js +47 -26
- package/dist/index.cjs +59 -36
- package/dist/index.cjs.map +4 -4
- package/lib/templates/BaseInputTemplate/index.js +11 -1
- package/lib/templates/BaseInputTemplate/index.js.map +1 -1
- package/lib/templates/IconButton/index.d.ts +1 -0
- package/lib/templates/IconButton/index.js +5 -0
- package/lib/templates/IconButton/index.js.map +1 -1
- package/lib/templates/index.js +2 -1
- package/lib/templates/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/AltDateTimeWidget/index.d.ts +1 -13
- package/lib/widgets/AltDateTimeWidget/index.js +2 -7
- package/lib/widgets/AltDateTimeWidget/index.js.map +1 -1
- package/lib/widgets/AltDateWidget/index.d.ts +1 -13
- package/lib/widgets/AltDateWidget/index.js +8 -12
- package/lib/widgets/AltDateWidget/index.js.map +1 -1
- package/lib/widgets/SelectWidget/index.d.ts +5 -1
- package/lib/widgets/SelectWidget/index.js +11 -3
- package/lib/widgets/SelectWidget/index.js.map +1 -1
- package/package.json +6 -6
- package/src/templates/BaseInputTemplate/index.tsx +16 -1
- package/src/templates/IconButton/index.tsx +17 -0
- package/src/templates/index.ts +2 -1
- package/src/widgets/AltDateTimeWidget/index.tsx +2 -9
- package/src/widgets/AltDateWidget/index.tsx +8 -13
- package/src/widgets/SelectWidget/index.tsx +12 -2
|
@@ -1,14 +1,2 @@
|
|
|
1
1
|
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
-
|
|
3
|
-
declare namespace AltDateTimeWidget {
|
|
4
|
-
var defaultProps: {
|
|
5
|
-
time: boolean;
|
|
6
|
-
autofocus: boolean;
|
|
7
|
-
disabled: boolean;
|
|
8
|
-
options: {
|
|
9
|
-
yearsRange: number[];
|
|
10
|
-
};
|
|
11
|
-
readonly: boolean;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export default AltDateTimeWidget;
|
|
2
|
+
export default function AltDateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ time, ...props }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
export default function AltDateTimeWidget(props) {
|
|
2
|
+
export default function AltDateTimeWidget({ time = true, ...props }) {
|
|
4
3
|
const { AltDateWidget } = props.registry.widgets;
|
|
5
|
-
return _jsx(AltDateWidget, { time:
|
|
4
|
+
return _jsx(AltDateWidget, { time: time, ...props });
|
|
6
5
|
}
|
|
7
|
-
AltDateTimeWidget.defaultProps = {
|
|
8
|
-
..._AltDateWidget.defaultProps,
|
|
9
|
-
time: true,
|
|
10
|
-
};
|
|
11
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/AltDateTimeWidget/index.tsx"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/AltDateTimeWidget/index.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAIvC,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,KAAK,EAAwB;IAC/C,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;IACjD,OAAO,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,KAAM,KAAK,GAAI,CAAC;AAClD,CAAC"}
|
|
@@ -1,14 +1,2 @@
|
|
|
1
1
|
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
-
|
|
3
|
-
declare namespace AltDateWidget {
|
|
4
|
-
var defaultProps: {
|
|
5
|
-
autofocus: boolean;
|
|
6
|
-
disabled: boolean;
|
|
7
|
-
options: {
|
|
8
|
-
yearsRange: number[];
|
|
9
|
-
};
|
|
10
|
-
readonly: boolean;
|
|
11
|
-
time: boolean;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export default AltDateWidget;
|
|
2
|
+
export default function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ autofocus, disabled, options, readonly, time, ...props }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Row, Col, Button } from 'antd';
|
|
3
3
|
import { DateElement, TranslatableString, useAltDateWidgetProps, } from '@rjsf/utils';
|
|
4
|
-
export default function AltDateWidget(props) {
|
|
5
|
-
const {
|
|
4
|
+
export default function AltDateWidget({ autofocus = false, disabled = false, options, readonly = false, time = false, ...props }) {
|
|
5
|
+
const { id, name, onBlur, onFocus, registry } = props;
|
|
6
6
|
const { formContext, translateString } = registry;
|
|
7
7
|
const { rowGutter = 24 } = formContext;
|
|
8
|
-
const {
|
|
8
|
+
const realOptions = { yearsRange: [1900, new Date().getFullYear() + 2], ...options };
|
|
9
|
+
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps({
|
|
10
|
+
...props,
|
|
11
|
+
autofocus,
|
|
12
|
+
options: realOptions,
|
|
13
|
+
});
|
|
9
14
|
return (_jsxs(Row, { gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)], children: [elements.map((elemProps, i) => {
|
|
10
15
|
const elemId = `${id}_${elemProps.type}`;
|
|
11
16
|
return (_jsx(Col, { flex: '88px', children: _jsx(DateElement, { rootId: id, name: name, select: handleChange, ...elemProps, disabled: disabled, readonly: readonly, registry: registry, onBlur: onBlur, onFocus: onFocus, autofocus: autofocus && i === 0 }) }, elemId));
|
|
12
17
|
}), !options.hideNowButton && (_jsx(Col, { flex: '88px', children: _jsx(Button, { block: true, className: 'btn-now', onClick: handleSetNow, type: 'primary', children: translateString(TranslatableString.NowLabel) }) })), !options.hideClearButton && (_jsx(Col, { flex: '88px', children: _jsx(Button, { block: true, className: 'btn-clear', danger: true, onClick: handleClear, type: 'primary', children: translateString(TranslatableString.ClearLabel) }) }))] }));
|
|
13
18
|
}
|
|
14
|
-
AltDateWidget.defaultProps = {
|
|
15
|
-
autofocus: false,
|
|
16
|
-
disabled: false,
|
|
17
|
-
options: {
|
|
18
|
-
yearsRange: [1900, new Date().getFullYear() + 2],
|
|
19
|
-
},
|
|
20
|
-
readonly: false,
|
|
21
|
-
time: false,
|
|
22
|
-
};
|
|
23
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/AltDateWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EACL,WAAW,EAKX,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,OAAO,UAAU,aAAa,CAInC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/AltDateWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EACL,WAAW,EAKX,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,OAAO,UAAU,aAAa,CAInC,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,EAAE,GAAG,KAAK,EAAwB;I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a,IAAI,CACzB,KAAC,GAAG,IAAC,IAAI,EAAC,MAAM,YACd,KAAC,MAAM,IAAC,KAAK,QAAC,SAAS,EAAC,SAAS,EAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAC,SAAS,YACpE,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GACtC,GACL,CACP,EACA,CAAC,OAAO,CAAC,eAAe,IAAI,CAC3B,KAAC,GAAG,IAAC,IAAI,EAAC,MAAM,YACd,KAAC,MAAM,IAAC,KAAK,QAAC,SAAS,EAAC,WAAW,EAAC,MAAM,QAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAC,SAAS,YAC5E,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC,GACxC,GACL,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -4,4 +4,8 @@ import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjs
|
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `WidgetProps` for this component
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ autofocus, disabled, registry, id, htmlName, multiple, onBlur, onChange, onFocus, options, placeholder, readonly, value, schema, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare namespace SelectWidget {
|
|
9
|
+
var getPopupContainerCallback: () => (node: any) => any;
|
|
10
|
+
}
|
|
11
|
+
export default SelectWidget;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
2
3
|
import { Select } from 'antd';
|
|
3
4
|
import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, } from '@rjsf/utils';
|
|
4
5
|
import isString from 'lodash-es/isString.js';
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
6
|
const SELECT_STYLE = {
|
|
7
7
|
width: '100%',
|
|
8
8
|
};
|
|
@@ -12,6 +12,7 @@ const SELECT_STYLE = {
|
|
|
12
12
|
* @param props - The `WidgetProps` for this component
|
|
13
13
|
*/
|
|
14
14
|
export default function SelectWidget({ autofocus, disabled, registry, id, htmlName, multiple, onBlur, onChange, onFocus, options, placeholder, readonly, value, schema, }) {
|
|
15
|
+
const [open, setOpen] = useState(false);
|
|
15
16
|
const { formContext } = registry;
|
|
16
17
|
const { readonlyAsDisabled = true } = formContext;
|
|
17
18
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
@@ -25,7 +26,7 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
|
|
|
25
26
|
}
|
|
26
27
|
return false;
|
|
27
28
|
};
|
|
28
|
-
const getPopupContainer = (
|
|
29
|
+
const getPopupContainer = SelectWidget.getPopupContainerCallback();
|
|
29
30
|
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
30
31
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
31
32
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
@@ -48,6 +49,13 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
|
|
|
48
49
|
}
|
|
49
50
|
return undefined;
|
|
50
51
|
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
|
|
51
|
-
return (_jsx(Select, { 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,
|
|
52
|
+
return (_jsx(Select, { open: open, 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,
|
|
53
|
+
// When the open change is called, set the open state, needed so that the select opens properly in the playground
|
|
54
|
+
onOpenChange: setOpen, filterOption: filterOption, "aria-describedby": ariaDescribedByIds(id), options: selectOptions }));
|
|
52
55
|
}
|
|
56
|
+
/** Give the playground a place to hook into the `getPopupContainer` callback generation function so that it can be
|
|
57
|
+
* disabled while in the playground. Since the callback is a simple function, it can be returned by this static
|
|
58
|
+
* "generator" function.
|
|
59
|
+
*/
|
|
60
|
+
SelectWidget.getPopupContainerCallback = () => (node) => node.parentElement;
|
|
53
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/SelectWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,MAAM,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GAMzB,MAAM,aAAa,CAAC;AACrB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/SelectWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAe,MAAM,MAAM,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GAMzB,MAAM,aAAa,CAAC;AACrB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,MAAM;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAIlC,EACA,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,Q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AAM,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,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,eAAe,KAClB,UAAU;QACd,iHAAiH;QACjH,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,YAAY,sBACR,kBAAkB,CAAC,EAAE,CAAC,EACxC,OAAO,EAAE,aAAa,GACtB,CACH,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,YAAY,CAAC,yBAAyB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/antd",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"description": "Ant Design theme, fields and widgets for react-jsonschema-form",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@ant-design/icons": "^6.0.0",
|
|
66
|
-
"@rjsf/core": "^6.x",
|
|
67
|
-
"@rjsf/utils": "^6.x",
|
|
66
|
+
"@rjsf/core": "^6.2.x",
|
|
67
|
+
"@rjsf/utils": "^6.2.x",
|
|
68
68
|
"antd": "^5.8.5",
|
|
69
69
|
"dayjs": "^1.8.0",
|
|
70
70
|
"react": ">=18"
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@ant-design/icons": "^6.1.0",
|
|
80
|
-
"@rjsf/core": "^6.
|
|
81
|
-
"@rjsf/snapshot-tests": "^6.
|
|
82
|
-
"@rjsf/utils": "^6.
|
|
80
|
+
"@rjsf/core": "^6.2.0",
|
|
81
|
+
"@rjsf/snapshot-tests": "^6.2.0",
|
|
82
|
+
"@rjsf/utils": "^6.2.0",
|
|
83
83
|
"@rjsf/validator-ajv8": "^6.x",
|
|
84
84
|
"@rollup/plugin-replace": "^6.0.3",
|
|
85
85
|
"antd": "^5.27.6",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
1
|
+
import { ChangeEvent, FocusEvent, MouseEvent, useCallback } from 'react';
|
|
2
2
|
import { Input, InputNumber } from 'antd';
|
|
3
3
|
import {
|
|
4
4
|
ariaDescribedByIds,
|
|
@@ -43,8 +43,11 @@ export default function BaseInputTemplate<
|
|
|
43
43
|
type,
|
|
44
44
|
} = props;
|
|
45
45
|
const { formContext } = registry;
|
|
46
|
+
// InputNumber doesn't use a native <input type="number"> directly - it wraps it and controls the stepping behavior
|
|
47
|
+
// through its own props. The step prop in Ant Design expects a number, not the string "any"
|
|
46
48
|
const inputProps = getInputProps<T, S, F>(schema, type, options, false);
|
|
47
49
|
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
|
|
50
|
+
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
48
51
|
|
|
49
52
|
const handleNumberChange = (nextValue: number | null) => onChange(nextValue);
|
|
50
53
|
|
|
@@ -56,6 +59,15 @@ export default function BaseInputTemplate<
|
|
|
56
59
|
|
|
57
60
|
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
58
61
|
|
|
62
|
+
const handleClear = useCallback(
|
|
63
|
+
(e: MouseEvent) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
onChange(options.emptyValue ?? '');
|
|
67
|
+
},
|
|
68
|
+
[onChange, options.emptyValue],
|
|
69
|
+
);
|
|
70
|
+
|
|
59
71
|
const input =
|
|
60
72
|
inputProps.type === 'number' || inputProps.type === 'integer' ? (
|
|
61
73
|
<InputNumber
|
|
@@ -92,6 +104,9 @@ export default function BaseInputTemplate<
|
|
|
92
104
|
return (
|
|
93
105
|
<>
|
|
94
106
|
{input}
|
|
107
|
+
{options.allowClearTextInputs && !readonly && !disabled && value && (
|
|
108
|
+
<ClearButton registry={registry} onClick={handleClear} />
|
|
109
|
+
)}
|
|
95
110
|
{Array.isArray(schema.examples) && (
|
|
96
111
|
<datalist id={examplesId(id)}>
|
|
97
112
|
{(schema.examples as string[])
|
|
@@ -4,6 +4,7 @@ import ArrowUpOutlined from '@ant-design/icons/ArrowUpOutlined';
|
|
|
4
4
|
import CopyOutlined from '@ant-design/icons/CopyOutlined';
|
|
5
5
|
import DeleteOutlined from '@ant-design/icons/DeleteOutlined';
|
|
6
6
|
import PlusCircleOutlined from '@ant-design/icons/PlusCircleOutlined';
|
|
7
|
+
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
|
7
8
|
import {
|
|
8
9
|
getUiOptions,
|
|
9
10
|
FormContextType,
|
|
@@ -102,3 +103,19 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
102
103
|
/>
|
|
103
104
|
);
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
108
|
+
props: AntdIconButtonProps<T, S, F>,
|
|
109
|
+
) {
|
|
110
|
+
const {
|
|
111
|
+
registry: { translateString },
|
|
112
|
+
} = props;
|
|
113
|
+
return (
|
|
114
|
+
<IconButton
|
|
115
|
+
title={translateString(TranslatableString.ClearButton)}
|
|
116
|
+
{...props}
|
|
117
|
+
iconType='link'
|
|
118
|
+
icon={<CloseOutlined />}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
package/src/templates/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import ArrayFieldTemplate from './ArrayFieldTemplate';
|
|
|
5
5
|
import BaseInputTemplate from './BaseInputTemplate';
|
|
6
6
|
import DescriptionField from './FieldDescriptionTemplate';
|
|
7
7
|
import ErrorList from './ErrorList';
|
|
8
|
-
import { AddButton, CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from './IconButton';
|
|
8
|
+
import { AddButton, CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from './IconButton';
|
|
9
9
|
import FieldErrorTemplate from './FieldErrorTemplate';
|
|
10
10
|
import FieldTemplate from './FieldTemplate';
|
|
11
11
|
import GridTemplate from './GridTemplate';
|
|
@@ -32,6 +32,7 @@ export function generateTemplates<
|
|
|
32
32
|
MoveUpButton,
|
|
33
33
|
RemoveButton,
|
|
34
34
|
SubmitButton,
|
|
35
|
+
ClearButton,
|
|
35
36
|
},
|
|
36
37
|
DescriptionFieldTemplate: DescriptionField,
|
|
37
38
|
ErrorListTemplate: ErrorList,
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
2
|
|
|
3
|
-
import _AltDateWidget from '../AltDateWidget';
|
|
4
|
-
|
|
5
3
|
export default function AltDateTimeWidget<
|
|
6
4
|
T = any,
|
|
7
5
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
8
6
|
F extends FormContextType = any,
|
|
9
|
-
>(props: WidgetProps<T, S, F>) {
|
|
7
|
+
>({ time = true, ...props }: WidgetProps<T, S, F>) {
|
|
10
8
|
const { AltDateWidget } = props.registry.widgets;
|
|
11
|
-
return <AltDateWidget time {...props} />;
|
|
9
|
+
return <AltDateWidget time={time} {...props} />;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
AltDateTimeWidget.defaultProps = {
|
|
15
|
-
..._AltDateWidget.defaultProps,
|
|
16
|
-
time: true,
|
|
17
|
-
};
|
|
@@ -14,11 +14,16 @@ export default function AltDateWidget<
|
|
|
14
14
|
T = any,
|
|
15
15
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
16
16
|
F extends FormContextType = any,
|
|
17
|
-
>(props: WidgetProps<T, S, F>) {
|
|
18
|
-
const {
|
|
17
|
+
>({ autofocus = false, disabled = false, options, readonly = false, time = false, ...props }: WidgetProps<T, S, F>) {
|
|
18
|
+
const { id, name, onBlur, onFocus, registry } = props;
|
|
19
19
|
const { formContext, translateString } = registry;
|
|
20
20
|
const { rowGutter = 24 } = formContext as GenericObjectType;
|
|
21
|
-
const {
|
|
21
|
+
const realOptions = { yearsRange: [1900, new Date().getFullYear() + 2], ...options };
|
|
22
|
+
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps({
|
|
23
|
+
...props,
|
|
24
|
+
autofocus,
|
|
25
|
+
options: realOptions,
|
|
26
|
+
});
|
|
22
27
|
|
|
23
28
|
return (
|
|
24
29
|
<Row gutter={[Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)]}>
|
|
@@ -58,13 +63,3 @@ export default function AltDateWidget<
|
|
|
58
63
|
</Row>
|
|
59
64
|
);
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
AltDateWidget.defaultProps = {
|
|
63
|
-
autofocus: false,
|
|
64
|
-
disabled: false,
|
|
65
|
-
options: {
|
|
66
|
-
yearsRange: [1900, new Date().getFullYear() + 2],
|
|
67
|
-
},
|
|
68
|
-
readonly: false,
|
|
69
|
-
time: false,
|
|
70
|
-
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
1
2
|
import { Select, SelectProps } from 'antd';
|
|
2
3
|
import {
|
|
3
4
|
ariaDescribedByIds,
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
} from '@rjsf/utils';
|
|
12
13
|
import isString from 'lodash/isString';
|
|
13
14
|
import { DefaultOptionType } from 'antd/es/select';
|
|
14
|
-
import { useMemo } from 'react';
|
|
15
15
|
|
|
16
16
|
const SELECT_STYLE = {
|
|
17
17
|
width: '100%',
|
|
@@ -42,6 +42,7 @@ export default function SelectWidget<
|
|
|
42
42
|
value,
|
|
43
43
|
schema,
|
|
44
44
|
}: WidgetProps<T, S, F>) {
|
|
45
|
+
const [open, setOpen] = useState(false);
|
|
45
46
|
const { formContext } = registry;
|
|
46
47
|
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
|
|
47
48
|
|
|
@@ -61,7 +62,7 @@ export default function SelectWidget<
|
|
|
61
62
|
return false;
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
const getPopupContainer = (
|
|
65
|
+
const getPopupContainer = SelectWidget.getPopupContainerCallback();
|
|
65
66
|
|
|
66
67
|
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
|
|
67
68
|
|
|
@@ -92,6 +93,7 @@ export default function SelectWidget<
|
|
|
92
93
|
|
|
93
94
|
return (
|
|
94
95
|
<Select
|
|
96
|
+
open={open}
|
|
95
97
|
autoFocus={autofocus}
|
|
96
98
|
disabled={disabled || (readonlyAsDisabled && readonly)}
|
|
97
99
|
getPopupContainer={getPopupContainer}
|
|
@@ -104,9 +106,17 @@ export default function SelectWidget<
|
|
|
104
106
|
style={SELECT_STYLE}
|
|
105
107
|
value={selectedIndexes}
|
|
106
108
|
{...extraProps}
|
|
109
|
+
// When the open change is called, set the open state, needed so that the select opens properly in the playground
|
|
110
|
+
onOpenChange={setOpen}
|
|
107
111
|
filterOption={filterOption}
|
|
108
112
|
aria-describedby={ariaDescribedByIds(id)}
|
|
109
113
|
options={selectOptions}
|
|
110
114
|
/>
|
|
111
115
|
);
|
|
112
116
|
}
|
|
117
|
+
|
|
118
|
+
/** Give the playground a place to hook into the `getPopupContainer` callback generation function so that it can be
|
|
119
|
+
* disabled while in the playground. Since the callback is a simple function, it can be returned by this static
|
|
120
|
+
* "generator" function.
|
|
121
|
+
*/
|
|
122
|
+
SelectWidget.getPopupContainerCallback = () => (node: any) => node.parentElement;
|