@rjsf/chakra-ui 6.1.2 → 6.2.5
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/chakra-ui.esm.js +52 -32
- package/dist/chakra-ui.esm.js.map +4 -4
- package/dist/chakra-ui.umd.js +42 -23
- package/dist/index.cjs +201 -181
- package/dist/index.cjs.map +4 -4
- package/lib/AltDateTimeWidget/AltDateTimeWidget.d.ts +1 -12
- package/lib/AltDateTimeWidget/AltDateTimeWidget.js +2 -7
- package/lib/AltDateTimeWidget/AltDateTimeWidget.js.map +1 -1
- package/lib/AltDateWidget/AltDateWidget.d.ts +1 -12
- package/lib/AltDateWidget/AltDateWidget.js +7 -12
- package/lib/AltDateWidget/AltDateWidget.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +10 -2
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/IconButton/IconButton.d.ts +1 -0
- package/lib/IconButton/IconButton.js +5 -1
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/Templates/Templates.js +2 -1
- package/lib/Templates/Templates.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -7
- package/src/AltDateTimeWidget/AltDateTimeWidget.tsx +5 -10
- package/src/AltDateWidget/AltDateWidget.tsx +14 -15
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +14 -1
- package/src/IconButton/IconButton.tsx +10 -1
- package/src/Templates/Templates.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/chakra-ui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.5",
|
|
4
4
|
"description": "Chakra UI theme, fields, and widgets for react-jsonschema-form",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@chakra-ui/react": ">=3.16.1",
|
|
67
|
-
"@rjsf/core": "^6.x",
|
|
68
|
-
"@rjsf/utils": "^6.x",
|
|
67
|
+
"@rjsf/core": "^6.2.x",
|
|
68
|
+
"@rjsf/utils": "^6.2.x",
|
|
69
69
|
"chakra-react-select": ">=6",
|
|
70
70
|
"react": ">=18"
|
|
71
71
|
},
|
|
@@ -79,6 +79,10 @@
|
|
|
79
79
|
"U.M Andrew <me@andrewmiracle.com>",
|
|
80
80
|
"Heath Chiavettone <heath.chiavettone@freenome.com"
|
|
81
81
|
],
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
|
|
85
|
+
},
|
|
82
86
|
"license": "Apache-2.0",
|
|
83
87
|
"devDependencies": {
|
|
84
88
|
"@chakra-ui/cli": "^3.28.0",
|
|
@@ -86,10 +90,10 @@
|
|
|
86
90
|
"@emotion/eslint-plugin": "^11.12.0",
|
|
87
91
|
"@emotion/jest": "^11.13.0",
|
|
88
92
|
"@emotion/react": "^11.14.0",
|
|
89
|
-
"@rjsf/core": "^6.
|
|
90
|
-
"@rjsf/snapshot-tests": "^6.
|
|
91
|
-
"@rjsf/utils": "^6.
|
|
92
|
-
"@rjsf/validator-ajv8": "^6.
|
|
93
|
+
"@rjsf/core": "^6.2.0",
|
|
94
|
+
"@rjsf/snapshot-tests": "^6.2.0",
|
|
95
|
+
"@rjsf/utils": "^6.2.0",
|
|
96
|
+
"@rjsf/validator-ajv8": "^6.2.0",
|
|
93
97
|
"chakra-react-select": "^6.1.0",
|
|
94
98
|
"eslint": "^8.57.1"
|
|
95
99
|
},
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import _AltDateWidget from '../AltDateWidget';
|
|
2
1
|
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
2
|
|
|
4
|
-
function AltDateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
function AltDateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
4
|
+
time = true,
|
|
5
|
+
...props
|
|
6
|
+
}: WidgetProps<T, S, F>) {
|
|
7
7
|
const { AltDateWidget } = props.registry.widgets;
|
|
8
|
-
return <AltDateWidget {...props} time />;
|
|
8
|
+
return <AltDateWidget {...props} time={time} />;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
AltDateTimeWidget.defaultProps = {
|
|
12
|
-
..._AltDateWidget.defaultProps,
|
|
13
|
-
time: true,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
11
|
export default AltDateTimeWidget;
|
|
@@ -11,12 +11,21 @@ import {
|
|
|
11
11
|
} from '@rjsf/utils';
|
|
12
12
|
import { getChakra } from '../utils';
|
|
13
13
|
|
|
14
|
-
function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
15
|
+
autofocus = false,
|
|
16
|
+
disabled = false,
|
|
17
|
+
readonly = false,
|
|
18
|
+
time = false,
|
|
19
|
+
options,
|
|
20
|
+
...props
|
|
21
|
+
}: WidgetProps<T, S, F>) {
|
|
22
|
+
const { id, onBlur, onFocus, registry } = props;
|
|
18
23
|
const { translateString } = registry;
|
|
19
|
-
const {
|
|
24
|
+
const realOptions = { yearsRange: [1900, new Date().getFullYear() + 2], ...options };
|
|
25
|
+
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps({
|
|
26
|
+
...props,
|
|
27
|
+
options: realOptions,
|
|
28
|
+
});
|
|
20
29
|
|
|
21
30
|
const chakraProps = getChakra({ uiSchema: props.uiSchema });
|
|
22
31
|
|
|
@@ -59,14 +68,4 @@ function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
59
68
|
);
|
|
60
69
|
}
|
|
61
70
|
|
|
62
|
-
AltDateWidget.defaultProps = {
|
|
63
|
-
autofocus: false,
|
|
64
|
-
disabled: false,
|
|
65
|
-
readonly: false,
|
|
66
|
-
time: false,
|
|
67
|
-
options: {
|
|
68
|
-
yearsRange: [1900, new Date().getFullYear() + 2],
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
71
|
export default AltDateWidget;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
1
|
+
import { ChangeEvent, FocusEvent, MouseEvent, useCallback } from 'react';
|
|
2
2
|
import { Input } from '@chakra-ui/react';
|
|
3
3
|
import {
|
|
4
4
|
ariaDescribedByIds,
|
|
@@ -39,13 +39,23 @@ export default function BaseInputTemplate<
|
|
|
39
39
|
placeholder,
|
|
40
40
|
disabled,
|
|
41
41
|
uiSchema,
|
|
42
|
+
registry,
|
|
42
43
|
} = props;
|
|
43
44
|
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
45
|
+
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
44
46
|
|
|
45
47
|
const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
|
|
46
48
|
onChange(value === '' ? options.emptyValue : value);
|
|
47
49
|
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
|
|
48
50
|
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
51
|
+
const onClear = useCallback(
|
|
52
|
+
(e: MouseEvent) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
onChange(options.emptyValue ?? '');
|
|
56
|
+
},
|
|
57
|
+
[onChange, options.emptyValue],
|
|
58
|
+
);
|
|
49
59
|
|
|
50
60
|
const chakraProps = getChakra({ uiSchema });
|
|
51
61
|
|
|
@@ -72,6 +82,9 @@ export default function BaseInputTemplate<
|
|
|
72
82
|
list={schema.examples ? examplesId(id) : undefined}
|
|
73
83
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
74
84
|
/>
|
|
85
|
+
{options.allowClearTextInputs && !readonly && !disabled && value && (
|
|
86
|
+
<ClearButton registry={registry} onClick={onClear} />
|
|
87
|
+
)}
|
|
75
88
|
{Array.isArray(schema.examples) ? (
|
|
76
89
|
<datalist id={examplesId(id)}>
|
|
77
90
|
{(schema.examples as string[])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
|
|
2
|
-
import { ArrowUpIcon, ArrowDownIcon, CopyIcon, DeleteIcon } from 'lucide-react';
|
|
2
|
+
import { ArrowUpIcon, ArrowDownIcon, CopyIcon, DeleteIcon, X } from 'lucide-react';
|
|
3
3
|
|
|
4
4
|
import ChakraIconButton, { ChakraIconButtonProps } from './ChakraIconButton';
|
|
5
5
|
|
|
@@ -58,3 +58,12 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
58
58
|
/>
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
63
|
+
props: ChakraIconButtonProps<T, S, F>,
|
|
64
|
+
) {
|
|
65
|
+
const {
|
|
66
|
+
registry: { translateString },
|
|
67
|
+
} = props;
|
|
68
|
+
return <ChakraIconButton<T, S, F> title={translateString(TranslatableString.ClearButton)} {...props} icon={<X />} />;
|
|
69
|
+
}
|
|
@@ -4,7 +4,7 @@ import ArrayFieldTemplate from '../ArrayFieldTemplate';
|
|
|
4
4
|
import BaseInputTemplate from '../BaseInputTemplate/BaseInputTemplate';
|
|
5
5
|
import DescriptionField from '../DescriptionField';
|
|
6
6
|
import ErrorList from '../ErrorList';
|
|
7
|
-
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from '../IconButton';
|
|
7
|
+
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from '../IconButton';
|
|
8
8
|
import FieldErrorTemplate from '../FieldErrorTemplate';
|
|
9
9
|
import FieldHelpTemplate from '../FieldHelpTemplate';
|
|
10
10
|
import FieldTemplate from '../FieldTemplate';
|
|
@@ -33,6 +33,7 @@ export function generateTemplates<
|
|
|
33
33
|
MoveUpButton,
|
|
34
34
|
RemoveButton,
|
|
35
35
|
SubmitButton,
|
|
36
|
+
ClearButton,
|
|
36
37
|
},
|
|
37
38
|
DescriptionFieldTemplate: DescriptionField,
|
|
38
39
|
ErrorListTemplate: ErrorList,
|