@rjsf/chakra-ui 6.6.0 → 6.6.2
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 +147 -189
- package/dist/chakra-ui.esm.js.map +3 -3
- package/dist/chakra-ui.umd.js +135 -133
- package/dist/index.cjs +237 -234
- package/dist/index.cjs.map +3 -3
- package/lib/AddButton/AddButton.d.ts +1 -1
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/AltDateTimeWidget/AltDateTimeWidget.d.ts +1 -1
- package/lib/AltDateWidget/AltDateWidget.d.ts +1 -1
- package/lib/AltDateWidget/AltDateWidget.js +1 -1
- package/lib/AltDateWidget/AltDateWidget.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +5 -5
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/ChakraFrameProvider.js +1 -3
- package/lib/ChakraFrameProvider.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +4 -4
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -4
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +1 -1
- package/lib/ErrorList/ErrorList.d.ts +1 -1
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +1 -3
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/Form/Form.d.ts +3 -3
- package/lib/Form/Form.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.d.ts +1 -1
- package/lib/IconButton/ChakraIconButton.d.ts +2 -2
- package/lib/IconButton/ChakraIconButton.js.map +1 -1
- package/lib/IconButton/IconButton.d.ts +13 -7
- package/lib/IconButton/IconButton.js +11 -5
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/NativeSelectWidget/NativeSelectWidget.d.ts +1 -1
- package/lib/NativeSelectWidget/NativeSelectWidget.js +13 -15
- package/lib/NativeSelectWidget/NativeSelectWidget.js.map +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +2 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/RadioWidget/RadioWidget.js +6 -6
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +1 -1
- package/lib/RangeWidget/RangeWidget.js +5 -5
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +1 -1
- package/lib/SelectWidget/SelectWidget.js +15 -17
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.d.ts +1 -1
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/Templates/Templates.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.js +5 -5
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/Theme/Theme.d.ts +2 -2
- package/lib/TitleField/TitleField.d.ts +1 -1
- package/lib/UpDownWidget/UpDownWidget.d.ts +1 -1
- package/lib/UpDownWidget/UpDownWidget.js +5 -5
- package/lib/UpDownWidget/UpDownWidget.js.map +1 -1
- package/lib/Widgets/Widgets.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/components/ui/alert.d.ts +1 -1
- package/lib/components/ui/alert.js +1 -1
- package/lib/components/ui/alert.js.map +1 -1
- package/lib/components/ui/checkbox.d.ts +1 -1
- package/lib/components/ui/checkbox.js +1 -1
- package/lib/components/ui/checkbox.js.map +1 -1
- package/lib/components/ui/close-button.js +1 -1
- package/lib/components/ui/close-button.js.map +1 -1
- package/lib/components/ui/field.d.ts +1 -1
- package/lib/components/ui/field.js +1 -1
- package/lib/components/ui/field.js.map +1 -1
- package/lib/components/ui/number-input.js +1 -1
- package/lib/components/ui/number-input.js.map +1 -1
- package/lib/components/ui/radio.d.ts +1 -1
- package/lib/components/ui/radio.js +1 -1
- package/lib/components/ui/radio.js.map +1 -1
- package/lib/components/ui/select.d.ts +1 -1
- package/lib/components/ui/select.js +13 -17
- package/lib/components/ui/select.js.map +1 -1
- package/lib/components/ui/slider.d.ts +2 -2
- package/lib/components/ui/slider.js +19 -19
- package/lib/components/ui/slider.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils.d.ts +2 -2
- package/lib/utils.js.map +1 -1
- package/package.json +8 -9
- package/src/AddButton/AddButton.tsx +2 -1
- package/src/AltDateTimeWidget/AltDateTimeWidget.tsx +1 -1
- package/src/AltDateWidget/AltDateWidget.tsx +2 -10
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -9
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +2 -9
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +11 -18
- package/src/ChakraFrameProvider.tsx +7 -9
- package/src/CheckboxWidget/CheckboxWidget.tsx +10 -12
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +8 -11
- package/src/DescriptionField/DescriptionField.tsx +1 -1
- package/src/ErrorList/ErrorList.tsx +3 -1
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +8 -8
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -1
- package/src/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/Form/Form.tsx +4 -3
- package/src/GridTemplate/GridTemplate.tsx +1 -1
- package/src/IconButton/ChakraIconButton.tsx +9 -3
- package/src/IconButton/IconButton.tsx +15 -7
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/NativeSelectWidget/NativeSelectWidget.tsx +20 -29
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +4 -18
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
- package/src/RadioWidget/RadioWidget.tsx +13 -16
- package/src/RangeWidget/RangeWidget.tsx +11 -18
- package/src/SelectWidget/SelectWidget.tsx +24 -27
- package/src/SubmitButton/SubmitButton.tsx +2 -1
- package/src/Templates/Templates.ts +1 -1
- package/src/TextareaWidget/TextareaWidget.tsx +10 -16
- package/src/Theme/Theme.tsx +2 -2
- package/src/TitleField/TitleField.tsx +1 -1
- package/src/UpDownWidget/UpDownWidget.tsx +10 -16
- package/src/Widgets/Widgets.ts +1 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/ui/alert.tsx +3 -2
- package/src/components/ui/checkbox.tsx +3 -2
- package/src/components/ui/close-button.tsx +5 -7
- package/src/components/ui/field.tsx +3 -2
- package/src/components/ui/number-input.tsx +1 -1
- package/src/components/ui/radio.tsx +3 -2
- package/src/components/ui/select.tsx +31 -36
- package/src/components/ui/slider.tsx +37 -35
- package/src/utils.ts +3 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
2
|
import { Stack } from '@chakra-ui/react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
4
|
import {
|
|
4
5
|
ariaDescribedByIds,
|
|
5
6
|
enumOptionSelectedValue,
|
|
@@ -8,10 +9,6 @@ import {
|
|
|
8
9
|
getOptionValueFormat,
|
|
9
10
|
labelValue,
|
|
10
11
|
optionId,
|
|
11
|
-
FormContextType,
|
|
12
|
-
RJSFSchema,
|
|
13
|
-
StrictRJSFSchema,
|
|
14
|
-
WidgetProps,
|
|
15
12
|
} from '@rjsf/utils';
|
|
16
13
|
|
|
17
14
|
import { Field } from '../components/ui/field';
|
|
@@ -36,12 +33,12 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
36
33
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
37
34
|
const optionValueFormat = getOptionValueFormat(options);
|
|
38
35
|
|
|
39
|
-
const
|
|
40
|
-
onChange(enumOptionValueDecoder<S>(
|
|
41
|
-
const
|
|
42
|
-
onBlur(id, enumOptionValueDecoder<S>(
|
|
43
|
-
const
|
|
44
|
-
onFocus(id, enumOptionValueDecoder<S>(
|
|
36
|
+
const handleChange = ({ target: { value: enumValue } }: ChangeEvent<HTMLInputElement>) =>
|
|
37
|
+
onChange(enumOptionValueDecoder<S>(enumValue, enumOptions, optionValueFormat, emptyValue));
|
|
38
|
+
const handleBlur = ({ target: { value: enumValue } }: FocusEvent<HTMLInputElement>) =>
|
|
39
|
+
onBlur(id, enumOptionValueDecoder<S>(enumValue, enumOptions, optionValueFormat, emptyValue));
|
|
40
|
+
const handleFocus = ({ target: { value: enumValue } }: FocusEvent<HTMLInputElement>) =>
|
|
41
|
+
onFocus(id, enumOptionValueDecoder<S>(enumValue, enumOptions, optionValueFormat, emptyValue));
|
|
45
42
|
|
|
46
43
|
const row = options ? options.inline : false;
|
|
47
44
|
const selectValue = enumOptionSelectedValue<S>(value, enumOptions, false, optionValueFormat, null);
|
|
@@ -58,9 +55,9 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
58
55
|
{...chakraProps}
|
|
59
56
|
>
|
|
60
57
|
<RadioGroup
|
|
61
|
-
onChange={
|
|
62
|
-
onBlur={
|
|
63
|
-
onFocus={
|
|
58
|
+
onChange={handleChange}
|
|
59
|
+
onBlur={handleBlur}
|
|
60
|
+
onFocus={handleFocus}
|
|
64
61
|
value={selectValue}
|
|
65
62
|
name={htmlName || id}
|
|
66
63
|
aria-describedby={ariaDescribedByIds(id)}
|
|
@@ -68,12 +65,12 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
68
65
|
<Stack direction={row ? 'row' : 'column'}>
|
|
69
66
|
{Array.isArray(enumOptions) &&
|
|
70
67
|
enumOptions.map((option, index) => {
|
|
71
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
68
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
72
69
|
|
|
73
70
|
return (
|
|
74
71
|
<Radio
|
|
75
72
|
value={enumOptionValueEncoder(option.value, index, optionValueFormat)}
|
|
76
|
-
key={
|
|
73
|
+
key={String(option.value)}
|
|
77
74
|
id={optionId(id, index)}
|
|
78
75
|
disabled={disabled || itemDisabled || readonly}
|
|
79
76
|
>
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { FocusEvent } from 'react';
|
|
2
|
-
import { SliderValueChangeDetails } from '@chakra-ui/react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FormContextType,
|
|
6
|
-
labelValue,
|
|
7
|
-
rangeSpec,
|
|
8
|
-
RJSFSchema,
|
|
9
|
-
StrictRJSFSchema,
|
|
10
|
-
WidgetProps,
|
|
11
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import type { SliderValueChangeDetails } from '@chakra-ui/react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
4
|
+
import { ariaDescribedByIds, labelValue, rangeSpec } from '@rjsf/utils';
|
|
12
5
|
|
|
13
6
|
import { Field } from '../components/ui/field';
|
|
14
7
|
import { Slider } from '../components/ui/slider';
|
|
@@ -28,10 +21,10 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
28
21
|
id,
|
|
29
22
|
uiSchema,
|
|
30
23
|
}: WidgetProps<T, S, F>) {
|
|
31
|
-
const
|
|
32
|
-
onChange(
|
|
33
|
-
const
|
|
34
|
-
const
|
|
24
|
+
const handleChange = ({ value: newValue }: SliderValueChangeDetails) =>
|
|
25
|
+
onChange(newValue === undefined ? options.emptyValue : newValue[0]);
|
|
26
|
+
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
|
|
27
|
+
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
35
28
|
|
|
36
29
|
const chakraProps = getChakra({ uiSchema });
|
|
37
30
|
|
|
@@ -43,9 +36,9 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
43
36
|
name={id}
|
|
44
37
|
disabled={disabled || readonly}
|
|
45
38
|
value={[value]}
|
|
46
|
-
onValueChange={
|
|
47
|
-
onBlur={
|
|
48
|
-
onFocus={
|
|
39
|
+
onValueChange={handleChange}
|
|
40
|
+
onBlur={handleBlur}
|
|
41
|
+
onFocus={handleFocus}
|
|
49
42
|
aria-describedby={ariaDescribedByIds(id)}
|
|
50
43
|
/>
|
|
51
44
|
</Field>
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { FocusEvent
|
|
2
|
-
import {
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import { useMemo, useRef } from 'react';
|
|
3
|
+
import type { SelectValueChangeDetails } from '@chakra-ui/react';
|
|
4
|
+
import { createListCollection, Select as ChakraSelect } from '@chakra-ui/react';
|
|
5
|
+
import type { EnumOptionsType, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
6
|
import {
|
|
4
7
|
ariaDescribedByIds,
|
|
5
|
-
EnumOptionsType,
|
|
6
8
|
enumOptionSelectedValue,
|
|
7
9
|
enumOptionValueDecoder,
|
|
8
10
|
enumOptionValueEncoder,
|
|
9
11
|
getOptionValueFormat,
|
|
10
12
|
labelValue,
|
|
11
|
-
FormContextType,
|
|
12
|
-
RJSFSchema,
|
|
13
|
-
StrictRJSFSchema,
|
|
14
|
-
WidgetProps,
|
|
15
13
|
} from '@rjsf/utils';
|
|
16
|
-
import { OptionsOrGroups } from 'chakra-react-select';
|
|
14
|
+
import type { OptionsOrGroups } from 'chakra-react-select';
|
|
17
15
|
|
|
18
16
|
import { Field } from '../components/ui/field';
|
|
19
17
|
import { SelectRoot, SelectTrigger, SelectValueText } from '../components/ui/select';
|
|
@@ -45,41 +43,40 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
45
43
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
46
44
|
const optionValueFormat = getOptionValueFormat(options);
|
|
47
45
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
};
|
|
46
|
+
const handleMultiChange = ({ value: newValue }: SelectValueChangeDetails) =>
|
|
47
|
+
onChange(enumOptionValueDecoder<S>(newValue, enumOptions, optionValueFormat, emptyValue));
|
|
51
48
|
|
|
52
|
-
const
|
|
53
|
-
const selected = enumOptionValueDecoder<S>(
|
|
49
|
+
const handleSingleChange = ({ value: newValue }: SelectValueChangeDetails) => {
|
|
50
|
+
const selected = enumOptionValueDecoder<S>(newValue, enumOptions, optionValueFormat, emptyValue);
|
|
54
51
|
return onChange(Array.isArray(selected) && selected.length === 1 ? selected[0] : selected);
|
|
55
52
|
};
|
|
56
53
|
|
|
57
|
-
const
|
|
54
|
+
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
58
55
|
onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
59
56
|
|
|
60
|
-
const
|
|
57
|
+
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
61
58
|
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
62
59
|
|
|
63
60
|
const showPlaceholderOption = !multiple && schema.default === undefined;
|
|
64
61
|
const displayEnumOptions = useMemo((): OptionsOrGroups<any, any> => {
|
|
65
|
-
let
|
|
62
|
+
let computedOptions: OptionsOrGroups<any, any> = [];
|
|
66
63
|
if (Array.isArray(enumOptions)) {
|
|
67
|
-
|
|
68
|
-
const { value, label } = option;
|
|
64
|
+
computedOptions = enumOptions.map((option: EnumOptionsType<S>, index: number) => {
|
|
65
|
+
const { value: enumValue, label: enumLabel } = option;
|
|
69
66
|
return {
|
|
70
|
-
label,
|
|
71
|
-
value: enumOptionValueEncoder(
|
|
72
|
-
disabled: Array.isArray(enumDisabled) && enumDisabled.
|
|
67
|
+
label: enumLabel,
|
|
68
|
+
value: enumOptionValueEncoder(enumValue, index, optionValueFormat),
|
|
69
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.includes(enumValue),
|
|
73
70
|
};
|
|
74
71
|
});
|
|
75
72
|
if (showPlaceholderOption) {
|
|
76
|
-
(
|
|
73
|
+
(computedOptions as any[]).unshift({ value: '', label: placeholder || '' });
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
|
-
return
|
|
76
|
+
return computedOptions;
|
|
80
77
|
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
|
|
81
78
|
|
|
82
|
-
const isMultiple = typeof multiple !== 'undefined' && multiple
|
|
79
|
+
const isMultiple = typeof multiple !== 'undefined' && multiple && Boolean(enumOptions);
|
|
83
80
|
|
|
84
81
|
// Chakra's SelectRoot always expects a string array, so flatten the helper's
|
|
85
82
|
// single/multiple return shape and strip the empty-single case.
|
|
@@ -114,9 +111,9 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
114
111
|
name={htmlName || id}
|
|
115
112
|
multiple={isMultiple}
|
|
116
113
|
closeOnSelect={!isMultiple}
|
|
117
|
-
onBlur={
|
|
118
|
-
onValueChange={isMultiple ?
|
|
119
|
-
onFocus={
|
|
114
|
+
onBlur={handleBlur}
|
|
115
|
+
onValueChange={isMultiple ? handleMultiChange : handleSingleChange}
|
|
116
|
+
onFocus={handleFocus}
|
|
120
117
|
autoFocus={autofocus}
|
|
121
118
|
value={formValue}
|
|
122
119
|
aria-describedby={ariaDescribedByIds(id)}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Box, Button } from '@chakra-ui/react';
|
|
2
|
-
import { FormContextType,
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
|
|
3
|
+
import { getSubmitButtonOptions } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
export default function SubmitButton<
|
|
5
6
|
T = any,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import AddButton from '../AddButton';
|
|
4
4
|
import ArrayFieldItemTemplate from '../ArrayFieldItemTemplate';
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
2
|
import { Textarea } from '@chakra-ui/react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
labelValue,
|
|
6
|
-
FormContextType,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
WidgetProps,
|
|
10
|
-
} from '@rjsf/utils';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
4
|
+
import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
|
|
11
5
|
|
|
12
6
|
import { Field } from '../components/ui/field';
|
|
13
7
|
import { getChakra } from '../utils';
|
|
@@ -34,10 +28,10 @@ export default function TextareaWidget<
|
|
|
34
28
|
rawErrors,
|
|
35
29
|
uiSchema,
|
|
36
30
|
}: WidgetProps<T, S, F>) {
|
|
37
|
-
const
|
|
38
|
-
onChange(
|
|
39
|
-
const
|
|
40
|
-
const
|
|
31
|
+
const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLTextAreaElement>) =>
|
|
32
|
+
onChange(newValue === '' ? options.emptyValue : newValue);
|
|
33
|
+
const handleBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target && target.value);
|
|
34
|
+
const handleFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target && target.value);
|
|
41
35
|
|
|
42
36
|
const chakraProps = getChakra({ uiSchema });
|
|
43
37
|
|
|
@@ -57,9 +51,9 @@ export default function TextareaWidget<
|
|
|
57
51
|
value={value ?? ''}
|
|
58
52
|
placeholder={placeholder}
|
|
59
53
|
autoFocus={autofocus}
|
|
60
|
-
onChange={
|
|
61
|
-
onBlur={
|
|
62
|
-
onFocus={
|
|
54
|
+
onChange={handleChange}
|
|
55
|
+
onBlur={handleBlur}
|
|
56
|
+
onFocus={handleFocus}
|
|
63
57
|
rows={options.rows}
|
|
64
58
|
aria-describedby={ariaDescribedByIds(id)}
|
|
65
59
|
/>
|
package/src/Theme/Theme.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ThemeProps } from '@rjsf/core';
|
|
2
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ThemeProps } from '@rjsf/core';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
import { generateTemplates } from '../Templates';
|
|
5
5
|
import { generateWidgets } from '../Widgets';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Box, Flex, Heading, Separator, Spacer } from '@chakra-ui/react';
|
|
2
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
5
5
|
id,
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { FocusEvent } from 'react';
|
|
2
|
-
import { NumberInputValueChangeDetails } from '@chakra-ui/react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
labelValue,
|
|
6
|
-
FormContextType,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
WidgetProps,
|
|
10
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import type { NumberInputValueChangeDetails } from '@chakra-ui/react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
4
|
+
import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
|
|
11
5
|
|
|
12
6
|
import { Field } from '../components/ui/field';
|
|
13
7
|
import { NumberInputRoot } from '../components/ui/number-input';
|
|
@@ -18,9 +12,9 @@ export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
18
12
|
) {
|
|
19
13
|
const { id, readonly, disabled, label, hideLabel, value, onChange, onBlur, onFocus, rawErrors, required } = props;
|
|
20
14
|
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
15
|
+
const handleChange = ({ value: newValue }: NumberInputValueChangeDetails) => onChange(newValue);
|
|
16
|
+
const handleBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.value);
|
|
17
|
+
const handleFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.value);
|
|
24
18
|
|
|
25
19
|
const chakraProps = getChakra({ uiSchema: props.uiSchema });
|
|
26
20
|
|
|
@@ -36,9 +30,9 @@ export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
36
30
|
>
|
|
37
31
|
<NumberInputRoot
|
|
38
32
|
value={value}
|
|
39
|
-
onValueChange={
|
|
40
|
-
onBlur={
|
|
41
|
-
onFocus={
|
|
33
|
+
onValueChange={handleChange}
|
|
34
|
+
onBlur={handleBlur}
|
|
35
|
+
onFocus={handleFocus}
|
|
42
36
|
aria-describedby={ariaDescribedByIds(id)}
|
|
43
37
|
id={id}
|
|
44
38
|
name={id}
|
package/src/Widgets/Widgets.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import AltDateTimeWidget from '../AltDateTimeWidget/AltDateTimeWidget';
|
|
4
4
|
import AltDateWidget from '../AltDateWidget/AltDateWidget';
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { Grid, GridItem, Input } from '@chakra-ui/react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
buttonId,
|
|
5
|
-
FormContextType,
|
|
6
|
-
RJSFSchema,
|
|
7
|
-
StrictRJSFSchema,
|
|
8
|
-
TranslatableString,
|
|
9
|
-
WrapIfAdditionalTemplateProps,
|
|
10
|
-
} from '@rjsf/utils';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
|
|
3
|
+
import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString } from '@rjsf/utils';
|
|
11
4
|
|
|
12
5
|
import { Field } from '../components/ui/field';
|
|
13
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import { Alert as ChakraAlert } from '@chakra-ui/react';
|
|
3
4
|
|
|
4
5
|
import { CloseButton } from './close-button';
|
|
@@ -23,7 +24,7 @@ export interface AlertProps extends Omit<ChakraAlert.RootProps, 'title'> {
|
|
|
23
24
|
onClose?: () => void;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export const Alert = forwardRef<HTMLDivElement, AlertProps>(
|
|
27
|
+
export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
27
28
|
const { title, children, closable, onClose, startElement, endElement, ...rest } = props;
|
|
28
29
|
return (
|
|
29
30
|
<ChakraAlert.Root ref={ref} {...rest}>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import { Checkbox as ChakraCheckbox } from '@chakra-ui/react';
|
|
3
4
|
|
|
4
5
|
export interface CheckboxProps extends ChakraCheckbox.RootProps {
|
|
@@ -16,7 +17,7 @@ export interface CheckboxProps extends ChakraCheckbox.RootProps {
|
|
|
16
17
|
* @param {Ref<HTMLLabelElement>} [props.rootRef] - Ref for the root element of the checkbox.
|
|
17
18
|
* @returns {JSX.Element} The rendered checkbox component.
|
|
18
19
|
*/
|
|
19
|
-
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
|
|
20
|
+
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
|
|
20
21
|
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
21
22
|
return (
|
|
22
23
|
<ChakraCheckbox.Root ref={rootRef} {...rest}>
|
|
@@ -12,10 +12,8 @@ export type CloseButtonProps = ButtonProps;
|
|
|
12
12
|
* @param {ReactNode} [props.children] - The content to display inside the button.
|
|
13
13
|
* @returns {JSX.Element} The rendered close button component.
|
|
14
14
|
*/
|
|
15
|
-
export const CloseButton = forwardRef<HTMLButtonElement, CloseButtonProps>(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
21
|
-
});
|
|
15
|
+
export const CloseButton = forwardRef<HTMLButtonElement, CloseButtonProps>((props, ref) => (
|
|
16
|
+
<ChakraIconButton variant='ghost' aria-label='Close' ref={ref} {...props}>
|
|
17
|
+
{props.children ?? <LuX />}
|
|
18
|
+
</ChakraIconButton>
|
|
19
|
+
));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import { Field as ChakraField } from '@chakra-ui/react';
|
|
3
4
|
|
|
4
5
|
export interface FieldProps extends Omit<ChakraField.RootProps, 'label'> {
|
|
@@ -19,7 +20,7 @@ export interface FieldProps extends Omit<ChakraField.RootProps, 'label'> {
|
|
|
19
20
|
* @param {ReactNode} [props.optionalText] - Text to indicate that the field is optional.
|
|
20
21
|
* @returns {JSX.Element} The rendered field component.
|
|
21
22
|
*/
|
|
22
|
-
export const Field = forwardRef<HTMLDivElement, FieldProps>(
|
|
23
|
+
export const Field = forwardRef<HTMLDivElement, FieldProps>((props, ref) => {
|
|
23
24
|
const { label, children, helperText, errorText, optionalText, ...rest } = props;
|
|
24
25
|
return (
|
|
25
26
|
<ChakraField.Root ref={ref} {...rest}>
|
|
@@ -10,7 +10,7 @@ export type NumberInputProps = ChakraNumberInput.RootProps;
|
|
|
10
10
|
* @param {ReactNode} [props.children] - The content to display inside the number input.
|
|
11
11
|
* @returns {JSX.Element} The rendered number input component.
|
|
12
12
|
*/
|
|
13
|
-
export const NumberInputRoot = forwardRef<HTMLDivElement, NumberInputProps>(
|
|
13
|
+
export const NumberInputRoot = forwardRef<HTMLDivElement, NumberInputProps>((props, ref) => {
|
|
14
14
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
15
15
|
|
|
16
16
|
useEffect(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { InputHTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import { RadioGroup as ChakraRadioGroup } from '@chakra-ui/react';
|
|
3
4
|
|
|
4
5
|
export interface RadioProps extends ChakraRadioGroup.ItemProps {
|
|
@@ -14,7 +15,7 @@ export interface RadioProps extends ChakraRadioGroup.ItemProps {
|
|
|
14
15
|
* @param {Ref<HTMLDivElement>} [props.rootRef] - Ref for the root element of the radio.
|
|
15
16
|
* @returns {JSX.Element} The rendered radio component.
|
|
16
17
|
*/
|
|
17
|
-
export const Radio = forwardRef<HTMLInputElement, RadioProps>(
|
|
18
|
+
export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
|
|
18
19
|
const { children, inputProps, rootRef, ...rest } = props;
|
|
19
20
|
return (
|
|
20
21
|
<ChakraRadioGroup.Item ref={rootRef} {...rest}>
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import type { CollectionItem } from '@chakra-ui/react';
|
|
3
4
|
import { Select as ChakraSelect, Portal } from '@chakra-ui/react';
|
|
4
5
|
|
|
5
6
|
import { CloseButton } from './close-button';
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* SelectClearTrigger component that renders a clear button for the select component.
|
|
10
|
+
*
|
|
11
|
+
* @param props - The properties for the clear trigger component.
|
|
12
|
+
* @returns - The rendered select clear trigger component.
|
|
13
|
+
*/
|
|
14
|
+
const SelectClearTrigger = forwardRef<HTMLButtonElement, ChakraSelect.ClearTriggerProps>((props, ref) => (
|
|
15
|
+
<ChakraSelect.ClearTrigger asChild {...props} ref={ref}>
|
|
16
|
+
<CloseButton size='xs' variant='plain' focusVisibleRing='inside' focusRingWidth='2px' pointerEvents='auto' />
|
|
17
|
+
</ChakraSelect.ClearTrigger>
|
|
18
|
+
));
|
|
19
|
+
|
|
7
20
|
interface SelectTriggerProps extends ChakraSelect.ControlProps {
|
|
8
21
|
clearable?: boolean;
|
|
9
22
|
}
|
|
@@ -16,7 +29,7 @@ interface SelectTriggerProps extends ChakraSelect.ControlProps {
|
|
|
16
29
|
* @param {ReactNode} [props.children] - The content to display inside the trigger.
|
|
17
30
|
* @returns {JSX.Element} The rendered select trigger component.
|
|
18
31
|
*/
|
|
19
|
-
export const SelectTrigger = forwardRef<HTMLButtonElement, SelectTriggerProps>(
|
|
32
|
+
export const SelectTrigger = forwardRef<HTMLButtonElement, SelectTriggerProps>((props, ref) => {
|
|
20
33
|
const { children, clearable, ...rest } = props;
|
|
21
34
|
return (
|
|
22
35
|
<ChakraSelect.Control {...rest}>
|
|
@@ -29,22 +42,6 @@ export const SelectTrigger = forwardRef<HTMLButtonElement, SelectTriggerProps>(f
|
|
|
29
42
|
);
|
|
30
43
|
});
|
|
31
44
|
|
|
32
|
-
/**
|
|
33
|
-
* SelectClearTrigger component that renders a clear button for the select component.
|
|
34
|
-
*
|
|
35
|
-
* @param {ChakraSelect.ClearTriggerProps} props - The properties for the clear trigger component.
|
|
36
|
-
* @returns {JSX.Element} The rendered select clear trigger component.
|
|
37
|
-
*/
|
|
38
|
-
const SelectClearTrigger = forwardRef<HTMLButtonElement, ChakraSelect.ClearTriggerProps>(
|
|
39
|
-
function SelectClearTrigger(props, ref) {
|
|
40
|
-
return (
|
|
41
|
-
<ChakraSelect.ClearTrigger asChild {...props} ref={ref}>
|
|
42
|
-
<CloseButton size='xs' variant='plain' focusVisibleRing='inside' focusRingWidth='2px' pointerEvents='auto' />
|
|
43
|
-
</ChakraSelect.ClearTrigger>
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
);
|
|
47
|
-
|
|
48
45
|
interface SelectContentProps extends ChakraSelect.ContentProps {
|
|
49
46
|
portalled?: boolean;
|
|
50
47
|
portalRef?: RefObject<HTMLElement>;
|
|
@@ -58,7 +55,7 @@ interface SelectContentProps extends ChakraSelect.ContentProps {
|
|
|
58
55
|
* @param {RefObject<HTMLElement>} [props.portalRef] - The ref for the portal container.
|
|
59
56
|
* @returns {JSX.Element} The rendered select content component.
|
|
60
57
|
*/
|
|
61
|
-
export const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(
|
|
58
|
+
export const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>((props, ref) => {
|
|
62
59
|
const { portalled = true, portalRef, ...rest } = props;
|
|
63
60
|
return (
|
|
64
61
|
<Portal disabled={!portalled} container={portalRef}>
|
|
@@ -77,7 +74,7 @@ export const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(func
|
|
|
77
74
|
* @param {ReactNode} [props.children] - The content to display inside the item.
|
|
78
75
|
* @returns {JSX.Element} The rendered select item component.
|
|
79
76
|
*/
|
|
80
|
-
export const SelectItem = forwardRef<HTMLDivElement, ChakraSelect.ItemProps>(
|
|
77
|
+
export const SelectItem = forwardRef<HTMLDivElement, ChakraSelect.ItemProps>((props, ref) => {
|
|
81
78
|
const { item, children, ...rest } = props;
|
|
82
79
|
return (
|
|
83
80
|
<ChakraSelect.Item key={item.value} item={item} {...rest} ref={ref}>
|
|
@@ -99,7 +96,7 @@ interface SelectValueTextProps extends Omit<ChakraSelect.ValueTextProps, 'childr
|
|
|
99
96
|
* @param {ReactNode} [props.placeholder] - The placeholder text to display when no items are selected.
|
|
100
97
|
* @returns {JSX.Element} The rendered select value text component.
|
|
101
98
|
*/
|
|
102
|
-
export const SelectValueText = forwardRef<HTMLSpanElement, SelectValueTextProps>(
|
|
99
|
+
export const SelectValueText = forwardRef<HTMLSpanElement, SelectValueTextProps>((props, ref) => {
|
|
103
100
|
const { children, ...rest } = props;
|
|
104
101
|
return (
|
|
105
102
|
<ChakraSelect.ValueText {...rest} ref={ref}>
|
|
@@ -130,20 +127,18 @@ export const SelectValueText = forwardRef<HTMLSpanElement, SelectValueTextProps>
|
|
|
130
127
|
* @param {ReactNode} [props.children] - The content to display inside the select root.
|
|
131
128
|
* @returns {JSX.Element} The rendered select root component.
|
|
132
129
|
*/
|
|
133
|
-
export const SelectRoot = forwardRef<HTMLDivElement, ChakraSelect.RootProps>(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
);
|
|
146
|
-
}) as ChakraSelect.RootComponent;
|
|
130
|
+
export const SelectRoot = forwardRef<HTMLDivElement, ChakraSelect.RootProps>((props, ref) => (
|
|
131
|
+
<ChakraSelect.Root {...props} ref={ref} positioning={{ sameWidth: true, ...props.positioning }}>
|
|
132
|
+
{props.asChild ? (
|
|
133
|
+
props.children
|
|
134
|
+
) : (
|
|
135
|
+
<>
|
|
136
|
+
<ChakraSelect.HiddenSelect />
|
|
137
|
+
{props.children}
|
|
138
|
+
</>
|
|
139
|
+
)}
|
|
140
|
+
</ChakraSelect.Root>
|
|
141
|
+
)) as ChakraSelect.RootComponent;
|
|
147
142
|
|
|
148
143
|
interface SelectItemGroupProps extends ChakraSelect.ItemGroupProps {
|
|
149
144
|
label: React.ReactNode;
|
|
@@ -157,7 +152,7 @@ interface SelectItemGroupProps extends ChakraSelect.ItemGroupProps {
|
|
|
157
152
|
* @param {ReactNode} [props.children] - The content to display inside the item group.
|
|
158
153
|
* @returns {JSX.Element} The rendered select item group component.
|
|
159
154
|
*/
|
|
160
|
-
export const SelectItemGroup = forwardRef<HTMLDivElement, SelectItemGroupProps>(
|
|
155
|
+
export const SelectItemGroup = forwardRef<HTMLDivElement, SelectItemGroupProps>((props, ref) => {
|
|
161
156
|
const { children, label, ...rest } = props;
|
|
162
157
|
return (
|
|
163
158
|
<ChakraSelect.ItemGroup {...rest} ref={ref}>
|