@rjsf/antd 6.1.2 → 6.2.4
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 +47 -28
- package/dist/antd.esm.js.map +4 -4
- package/dist/antd.umd.js +42 -25
- package/dist/index.cjs +55 -36
- package/dist/index.cjs.map +4 -4
- package/lib/templates/BaseInputTemplate/index.js +9 -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/package.json +6 -6
- package/src/templates/BaseInputTemplate/index.tsx +14 -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
|
@@ -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;IAChH,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,EAAE,WAAW,EAAE,eAAe,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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/antd",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.4",
|
|
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,
|
|
@@ -47,6 +47,7 @@ export default function BaseInputTemplate<
|
|
|
47
47
|
// through its own props. The step prop in Ant Design expects a number, not the string "any"
|
|
48
48
|
const inputProps = getInputProps<T, S, F>(schema, type, options, false);
|
|
49
49
|
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
|
|
50
|
+
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
50
51
|
|
|
51
52
|
const handleNumberChange = (nextValue: number | null) => onChange(nextValue);
|
|
52
53
|
|
|
@@ -58,6 +59,15 @@ export default function BaseInputTemplate<
|
|
|
58
59
|
|
|
59
60
|
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
60
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
|
+
|
|
61
71
|
const input =
|
|
62
72
|
inputProps.type === 'number' || inputProps.type === 'integer' ? (
|
|
63
73
|
<InputNumber
|
|
@@ -94,6 +104,9 @@ export default function BaseInputTemplate<
|
|
|
94
104
|
return (
|
|
95
105
|
<>
|
|
96
106
|
{input}
|
|
107
|
+
{options.allowClearTextInputs && !readonly && !disabled && value && (
|
|
108
|
+
<ClearButton registry={registry} onClick={handleClear} />
|
|
109
|
+
)}
|
|
97
110
|
{Array.isArray(schema.examples) && (
|
|
98
111
|
<datalist id={examplesId(id)}>
|
|
99
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
|
-
};
|