@rjsf/chakra-ui 6.0.0-beta.1 → 6.0.0-beta.10
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/README.md +9 -9
- package/dist/chakra-ui.esm.js +104 -67
- package/dist/chakra-ui.esm.js.map +4 -4
- package/dist/chakra-ui.umd.js +90 -58
- package/dist/index.js +311 -274
- package/dist/index.js.map +4 -4
- package/lib/AddButton/AddButton.d.ts +1 -1
- package/lib/AddButton/AddButton.js +1 -1
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/AltDateWidget/AltDateWidget.js +5 -3
- package/lib/AltDateWidget/AltDateWidget.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +4 -2
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/ChakraFrameProvider.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +3 -1
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -2
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +5 -1
- package/lib/DescriptionField/DescriptionField.js +8 -6
- package/lib/DescriptionField/DescriptionField.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/RadioWidget/RadioWidget.js +4 -2
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +1 -1
- package/lib/RangeWidget/RangeWidget.js +4 -2
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectNativeWidget/NativeSelectWidget.js +4 -2
- package/lib/SelectNativeWidget/NativeSelectWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.js +8 -7
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.js +4 -2
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/UpDownWidget/UpDownWidget.js +3 -1
- package/lib/UpDownWidget/UpDownWidget.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/AddButton/AddButton.tsx +0 -1
- package/src/AltDateWidget/AltDateWidget.tsx +8 -5
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +5 -0
- package/src/ChakraFrameProvider.tsx +1 -4
- package/src/CheckboxWidget/CheckboxWidget.tsx +5 -2
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +10 -1
- package/src/DescriptionField/DescriptionField.tsx +11 -10
- package/src/RadioWidget/RadioWidget.tsx +5 -0
- package/src/RangeWidget/RangeWidget.tsx +5 -1
- package/src/SelectNativeWidget/NativeSelectWidget.tsx +5 -0
- package/src/SelectWidget/SelectWidget.tsx +9 -12
- package/src/TextareaWidget/TextareaWidget.tsx +5 -0
- package/src/UpDownWidget/UpDownWidget.tsx +4 -0
- package/src/index.ts +2 -0
package/README.md
CHANGED
|
@@ -64,11 +64,11 @@ Exports `chakra-ui` theme, fields and widgets for `react-jsonschema-form`.
|
|
|
64
64
|
|
|
65
65
|
### Prerequisites
|
|
66
66
|
|
|
67
|
-
- `@chakra-ui/react >=
|
|
68
|
-
- `chakra-react-select >=
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
- `@rjsf/
|
|
67
|
+
- `@chakra-ui/react >= 3`
|
|
68
|
+
- `chakra-react-select >= 6`
|
|
69
|
+
- `@rjsf/core >= 6`
|
|
70
|
+
- `@rjsf/utils >= 6`
|
|
71
|
+
- `@rjsf/validator-ajv8 >= 6`
|
|
72
72
|
|
|
73
73
|
Refer to the [rjsf installation guide](https://rjsf-team.github.io/react-jsonschema-form/docs/#installation) and [chakra-ui installation guide](https://chakra-ui.com/docs/getting-started#installation) and for more details.
|
|
74
74
|
|
|
@@ -77,17 +77,17 @@ Refer to the [rjsf installation guide](https://rjsf-team.github.io/react-jsonsch
|
|
|
77
77
|
### Installation
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
yarn add @chakra-ui/react
|
|
80
|
+
yarn add @chakra-ui/react chakra-react-select @rjsf/core @rjsf/utils @rjsf/validator-ajv8
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
83
85
|
```bash
|
|
84
|
-
yarn add @rjsf/chakra-ui
|
|
86
|
+
yarn add @rjsf/chakra-ui
|
|
85
87
|
```
|
|
86
88
|
|
|
87
89
|
<!-- USAGE EXAMPLES -->
|
|
88
90
|
|
|
89
|
-
## Usage
|
|
90
|
-
|
|
91
91
|
```js
|
|
92
92
|
import Form from '@rjsf/chakra-ui';
|
|
93
93
|
```
|
package/dist/chakra-ui.esm.js
CHANGED
|
@@ -7,7 +7,6 @@ import { Button } from "@chakra-ui/react";
|
|
|
7
7
|
import { PlusIcon } from "lucide-react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
function AddButton({
|
|
10
|
-
uiSchema,
|
|
11
10
|
registry,
|
|
12
11
|
...props
|
|
13
12
|
}) {
|
|
@@ -133,6 +132,20 @@ var Field = forwardRef(function Field2(props, ref) {
|
|
|
133
132
|
] });
|
|
134
133
|
});
|
|
135
134
|
|
|
135
|
+
// src/utils.ts
|
|
136
|
+
import { defaultSystem } from "@chakra-ui/react";
|
|
137
|
+
import shouldForwardProp from "@emotion/is-prop-valid";
|
|
138
|
+
var { isValidProperty } = defaultSystem;
|
|
139
|
+
function getChakra(uiSchema = {}) {
|
|
140
|
+
const chakraProps = uiSchema["ui:options"] && uiSchema["ui:options"].chakra || {};
|
|
141
|
+
Object.keys(chakraProps).forEach((key) => {
|
|
142
|
+
if (!isValidProperty(key) || shouldForwardProp(key)) {
|
|
143
|
+
delete chakraProps[key];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return chakraProps;
|
|
147
|
+
}
|
|
148
|
+
|
|
136
149
|
// src/BaseInputTemplate/BaseInputTemplate.tsx
|
|
137
150
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
138
151
|
function BaseInputTemplate(props) {
|
|
@@ -153,12 +166,14 @@ function BaseInputTemplate(props) {
|
|
|
153
166
|
rawErrors,
|
|
154
167
|
autofocus,
|
|
155
168
|
placeholder,
|
|
156
|
-
disabled
|
|
169
|
+
disabled,
|
|
170
|
+
uiSchema
|
|
157
171
|
} = props;
|
|
158
172
|
const inputProps = getInputProps(schema, type, options);
|
|
159
173
|
const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
|
|
160
174
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
161
175
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
176
|
+
const chakraProps = getChakra({ uiSchema });
|
|
162
177
|
return /* @__PURE__ */ jsxs5(
|
|
163
178
|
Field,
|
|
164
179
|
{
|
|
@@ -168,6 +183,7 @@ function BaseInputTemplate(props) {
|
|
|
168
183
|
readOnly: readonly,
|
|
169
184
|
invalid: rawErrors && rawErrors.length > 0,
|
|
170
185
|
label: labelValue(label, hideLabel || !label),
|
|
186
|
+
...chakraProps,
|
|
171
187
|
children: [
|
|
172
188
|
/* @__PURE__ */ jsx5(
|
|
173
189
|
Input,
|
|
@@ -194,16 +210,14 @@ function BaseInputTemplate(props) {
|
|
|
194
210
|
}
|
|
195
211
|
|
|
196
212
|
// src/DescriptionField/DescriptionField.tsx
|
|
213
|
+
import { RichDescription } from "@rjsf/core";
|
|
197
214
|
import { Text } from "@chakra-ui/react";
|
|
198
|
-
import {
|
|
199
|
-
function DescriptionField({ description, id }) {
|
|
215
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
216
|
+
function DescriptionField({ description, id, registry, uiSchema }) {
|
|
200
217
|
if (!description) {
|
|
201
218
|
return null;
|
|
202
219
|
}
|
|
203
|
-
|
|
204
|
-
return /* @__PURE__ */ jsx6(Text, { as: "sup", fontSize: "md", id, children: description });
|
|
205
|
-
}
|
|
206
|
-
return /* @__PURE__ */ jsx6(Fragment, { children: description });
|
|
220
|
+
return /* @__PURE__ */ jsx6(Text, { as: "sup", fontSize: "md", id, children: /* @__PURE__ */ jsx6(RichDescription, { description, registry, uiSchema }) });
|
|
207
221
|
}
|
|
208
222
|
|
|
209
223
|
// src/ErrorList/ErrorList.tsx
|
|
@@ -436,7 +450,7 @@ import {
|
|
|
436
450
|
getUiOptions as getUiOptions4,
|
|
437
451
|
titleId
|
|
438
452
|
} from "@rjsf/utils";
|
|
439
|
-
import { Fragment
|
|
453
|
+
import { Fragment, jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
440
454
|
function ObjectFieldTemplate(props) {
|
|
441
455
|
const {
|
|
442
456
|
description,
|
|
@@ -462,7 +476,7 @@ function ObjectFieldTemplate(props) {
|
|
|
462
476
|
const {
|
|
463
477
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
464
478
|
} = registry.templates;
|
|
465
|
-
return /* @__PURE__ */ jsxs9(
|
|
479
|
+
return /* @__PURE__ */ jsxs9(Fragment, { children: [
|
|
466
480
|
title && /* @__PURE__ */ jsx16(
|
|
467
481
|
TitleFieldTemplate,
|
|
468
482
|
{
|
|
@@ -616,7 +630,7 @@ function generateTemplates() {
|
|
|
616
630
|
var Templates_default = generateTemplates();
|
|
617
631
|
|
|
618
632
|
// src/AltDateWidget/AltDateWidget.tsx
|
|
619
|
-
import {
|
|
633
|
+
import { Box as Box5, Button as Button3, FieldsetRoot } from "@chakra-ui/react";
|
|
620
634
|
import {
|
|
621
635
|
ariaDescribedByIds as ariaDescribedByIds2,
|
|
622
636
|
dateRangeOptions,
|
|
@@ -625,7 +639,7 @@ import {
|
|
|
625
639
|
toDateString,
|
|
626
640
|
TranslatableString as TranslatableString5
|
|
627
641
|
} from "@rjsf/utils";
|
|
628
|
-
import {
|
|
642
|
+
import { useEffect, useState } from "react";
|
|
629
643
|
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
630
644
|
function DateElement(props) {
|
|
631
645
|
const { SelectWidget: SelectWidget2 } = props.registry.widgets;
|
|
@@ -683,7 +697,8 @@ function AltDateWidget(props) {
|
|
|
683
697
|
}
|
|
684
698
|
onChange(void 0);
|
|
685
699
|
};
|
|
686
|
-
|
|
700
|
+
const chakraProps = getChakra({ uiSchema: props.uiSchema });
|
|
701
|
+
return /* @__PURE__ */ jsxs12(FieldsetRoot, { ...chakraProps, children: [
|
|
687
702
|
/* @__PURE__ */ jsx20(Box5, { display: "flex", flexWrap: "wrap", alignItems: "center", children: getDateElementProps(
|
|
688
703
|
state,
|
|
689
704
|
showTime,
|
|
@@ -789,8 +804,9 @@ function CheckboxWidget(props) {
|
|
|
789
804
|
const _onChange = ({ checked }) => onChange(checked);
|
|
790
805
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
791
806
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
792
|
-
|
|
793
|
-
|
|
807
|
+
const chakraProps = getChakra({ uiSchema });
|
|
808
|
+
return /* @__PURE__ */ jsxs14(Field, { mb: 1, required, ...chakraProps, children: [
|
|
809
|
+
!hideLabel && description && /* @__PURE__ */ jsx23(
|
|
794
810
|
DescriptionFieldTemplate,
|
|
795
811
|
{
|
|
796
812
|
id: descriptionId2(id),
|
|
@@ -818,7 +834,7 @@ function CheckboxWidget(props) {
|
|
|
818
834
|
}
|
|
819
835
|
|
|
820
836
|
// src/CheckboxesWidget/CheckboxesWidget.tsx
|
|
821
|
-
import { CheckboxGroup, FieldsetRoot, Stack, Text as Text5 } from "@chakra-ui/react";
|
|
837
|
+
import { CheckboxGroup, FieldsetRoot as FieldsetRoot2, Stack, Text as Text5 } from "@chakra-ui/react";
|
|
822
838
|
import {
|
|
823
839
|
ariaDescribedByIds as ariaDescribedByIds4,
|
|
824
840
|
enumOptionsIndexForValue,
|
|
@@ -840,40 +856,51 @@ function CheckboxesWidget(props) {
|
|
|
840
856
|
required,
|
|
841
857
|
label,
|
|
842
858
|
hideLabel,
|
|
843
|
-
rawErrors = []
|
|
859
|
+
rawErrors = [],
|
|
860
|
+
uiSchema
|
|
844
861
|
} = props;
|
|
845
862
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
846
863
|
const _onBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
847
864
|
const _onFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
848
865
|
const row = options ? options.inline : false;
|
|
849
866
|
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
|
|
850
|
-
|
|
851
|
-
|
|
867
|
+
const chakraProps = getChakra({ uiSchema });
|
|
868
|
+
return /* @__PURE__ */ jsx24(
|
|
869
|
+
FieldsetRoot2,
|
|
852
870
|
{
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
871
|
+
mb: 1,
|
|
872
|
+
disabled: disabled || readonly,
|
|
873
|
+
invalid: rawErrors && rawErrors.length > 0,
|
|
874
|
+
...chakraProps,
|
|
875
|
+
children: /* @__PURE__ */ jsx24(
|
|
876
|
+
CheckboxGroup,
|
|
877
|
+
{
|
|
878
|
+
onValueChange: (option) => onChange(enumOptionsValueForIndex(option, enumOptions, emptyValue)),
|
|
879
|
+
value: selectedIndexes,
|
|
880
|
+
"aria-describedby": ariaDescribedByIds4(id),
|
|
881
|
+
readOnly: readonly,
|
|
882
|
+
required,
|
|
883
|
+
label: labelValue3(label, hideLabel || !label),
|
|
884
|
+
children: /* @__PURE__ */ jsx24(Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
885
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
886
|
+
return /* @__PURE__ */ jsx24(
|
|
887
|
+
Checkbox,
|
|
888
|
+
{
|
|
889
|
+
id: optionId(id, index),
|
|
890
|
+
name: id,
|
|
891
|
+
value: String(index),
|
|
892
|
+
disabled: disabled || itemDisabled || readonly,
|
|
893
|
+
onBlur: _onBlur,
|
|
894
|
+
onFocus: _onFocus,
|
|
895
|
+
children: option.label && /* @__PURE__ */ jsx24(Text5, { children: option.label })
|
|
896
|
+
},
|
|
897
|
+
index
|
|
898
|
+
);
|
|
899
|
+
}) })
|
|
900
|
+
}
|
|
901
|
+
)
|
|
875
902
|
}
|
|
876
|
-
)
|
|
903
|
+
);
|
|
877
904
|
}
|
|
878
905
|
|
|
879
906
|
// src/RadioWidget/RadioWidget.tsx
|
|
@@ -913,7 +940,8 @@ function RadioWidget({
|
|
|
913
940
|
hideLabel,
|
|
914
941
|
onChange,
|
|
915
942
|
onBlur,
|
|
916
|
-
onFocus
|
|
943
|
+
onFocus,
|
|
944
|
+
uiSchema
|
|
917
945
|
}) {
|
|
918
946
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
919
947
|
const _onChange = ({ target: { value: value2 } }) => onChange(enumOptionsValueForIndex2(value2, enumOptions, emptyValue));
|
|
@@ -921,6 +949,7 @@ function RadioWidget({
|
|
|
921
949
|
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, enumOptionsValueForIndex2(value2, enumOptions, emptyValue));
|
|
922
950
|
const row = options ? options.inline : false;
|
|
923
951
|
const selectedIndex = enumOptionsIndexForValue2(value, enumOptions) ?? null;
|
|
952
|
+
const chakraProps = getChakra({ uiSchema });
|
|
924
953
|
return /* @__PURE__ */ jsx26(
|
|
925
954
|
Field,
|
|
926
955
|
{
|
|
@@ -929,6 +958,7 @@ function RadioWidget({
|
|
|
929
958
|
required,
|
|
930
959
|
readOnly: readonly,
|
|
931
960
|
label: labelValue4(label, hideLabel || !label),
|
|
961
|
+
...chakraProps,
|
|
932
962
|
children: /* @__PURE__ */ jsx26(
|
|
933
963
|
RadioGroup,
|
|
934
964
|
{
|
|
@@ -967,7 +997,7 @@ import {
|
|
|
967
997
|
// src/components/ui/slider.tsx
|
|
968
998
|
import { forwardRef as forwardRef6 } from "react";
|
|
969
999
|
import { Slider as ChakraSlider, HStack as HStack2 } from "@chakra-ui/react";
|
|
970
|
-
import { Fragment as
|
|
1000
|
+
import { Fragment as Fragment2, jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
971
1001
|
var Slider = forwardRef6(function Slider2(props, ref) {
|
|
972
1002
|
const { marks: marksProp, showValue, ...rest } = props;
|
|
973
1003
|
const value = props.defaultValue ?? props.value;
|
|
@@ -989,7 +1019,7 @@ var Slider = forwardRef6(function Slider2(props, ref) {
|
|
|
989
1019
|
});
|
|
990
1020
|
function SliderThumbs(props) {
|
|
991
1021
|
const { value } = props;
|
|
992
|
-
return /* @__PURE__ */ jsx27(
|
|
1022
|
+
return /* @__PURE__ */ jsx27(Fragment2, { children: value?.map((_, index) => /* @__PURE__ */ jsx27(ChakraSlider.Thumb, { index, children: /* @__PURE__ */ jsx27(ChakraSlider.HiddenInput, {}) }, index)) });
|
|
993
1023
|
}
|
|
994
1024
|
var SliderMarks = forwardRef6(function SliderMarks2(props, ref) {
|
|
995
1025
|
const { marks } = props;
|
|
@@ -1019,12 +1049,14 @@ function RangeWidget({
|
|
|
1019
1049
|
onChange,
|
|
1020
1050
|
label,
|
|
1021
1051
|
hideLabel,
|
|
1022
|
-
id
|
|
1052
|
+
id,
|
|
1053
|
+
uiSchema
|
|
1023
1054
|
}) {
|
|
1024
1055
|
const _onChange = ({ value: value2 }) => onChange(value2 === void 0 ? options.emptyValue : value2[0]);
|
|
1025
1056
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
1026
1057
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
1027
|
-
|
|
1058
|
+
const chakraProps = getChakra({ uiSchema });
|
|
1059
|
+
return /* @__PURE__ */ jsx28(Field, { mb: 1, label: labelValue5(label, hideLabel || !label), ...chakraProps, children: /* @__PURE__ */ jsx28(
|
|
1028
1060
|
Slider,
|
|
1029
1061
|
{
|
|
1030
1062
|
...rangeSpec(schema),
|
|
@@ -1053,7 +1085,7 @@ import { createListCollection, Select as ChakraSelect2 } from "@chakra-ui/react"
|
|
|
1053
1085
|
// src/components/ui/select.tsx
|
|
1054
1086
|
import { forwardRef as forwardRef7 } from "react";
|
|
1055
1087
|
import { Select as ChakraSelect, Portal } from "@chakra-ui/react";
|
|
1056
|
-
import { Fragment as
|
|
1088
|
+
import { Fragment as Fragment3, jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1057
1089
|
var SelectTrigger = forwardRef7(function SelectTrigger2(props, ref) {
|
|
1058
1090
|
const { children, clearable, ...rest } = props;
|
|
1059
1091
|
return /* @__PURE__ */ jsxs17(ChakraSelect.Control, { ...rest, children: [
|
|
@@ -1097,7 +1129,7 @@ var SelectValueText = forwardRef7(function SelectValueText2(props, ref) {
|
|
|
1097
1129
|
} }) });
|
|
1098
1130
|
});
|
|
1099
1131
|
var SelectRoot = forwardRef7(function SelectRoot2(props, ref) {
|
|
1100
|
-
return /* @__PURE__ */ jsx29(ChakraSelect.Root, { ...props, ref, positioning: { sameWidth: true, ...props.positioning }, children: props.asChild ? props.children : /* @__PURE__ */ jsxs17(
|
|
1132
|
+
return /* @__PURE__ */ jsx29(ChakraSelect.Root, { ...props, ref, positioning: { sameWidth: true, ...props.positioning }, children: props.asChild ? props.children : /* @__PURE__ */ jsxs17(Fragment3, { children: [
|
|
1101
1133
|
/* @__PURE__ */ jsx29(ChakraSelect.HiddenSelect, {}),
|
|
1102
1134
|
props.children
|
|
1103
1135
|
] }) });
|
|
@@ -1131,23 +1163,17 @@ function SelectWidget(props) {
|
|
|
1131
1163
|
onBlur,
|
|
1132
1164
|
onFocus,
|
|
1133
1165
|
rawErrors = [],
|
|
1134
|
-
schema
|
|
1166
|
+
schema,
|
|
1167
|
+
uiSchema
|
|
1135
1168
|
} = props;
|
|
1136
1169
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1137
1170
|
const _onMultiChange = ({ value: value2 }) => {
|
|
1138
|
-
return onChange(
|
|
1139
|
-
enumOptionsValueForIndex3(
|
|
1140
|
-
value2.map((item) => {
|
|
1141
|
-
return item;
|
|
1142
|
-
}),
|
|
1143
|
-
enumOptions,
|
|
1144
|
-
emptyValue
|
|
1145
|
-
)
|
|
1146
|
-
);
|
|
1147
|
-
};
|
|
1148
|
-
const _onChange = ({ value: value2 }) => {
|
|
1149
1171
|
return onChange(enumOptionsValueForIndex3(value2, enumOptions, emptyValue));
|
|
1150
1172
|
};
|
|
1173
|
+
const _onSingleChange = ({ value: value2 }) => {
|
|
1174
|
+
const selected = enumOptionsValueForIndex3(value2, enumOptions, emptyValue);
|
|
1175
|
+
return onChange(Array.isArray(selected) && selected.length === 1 ? selected[0] : selected);
|
|
1176
|
+
};
|
|
1151
1177
|
const _onBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex3(target && target.value, enumOptions, emptyValue));
|
|
1152
1178
|
const _onFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex3(target && target.value, enumOptions, emptyValue));
|
|
1153
1179
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
@@ -1189,6 +1215,7 @@ function SelectWidget(props) {
|
|
|
1189
1215
|
items: displayEnumOptions.filter((item) => item.value)
|
|
1190
1216
|
});
|
|
1191
1217
|
const containerRef = useRef(null);
|
|
1218
|
+
const chakraProps = getChakra({ uiSchema });
|
|
1192
1219
|
return /* @__PURE__ */ jsx30(
|
|
1193
1220
|
Field,
|
|
1194
1221
|
{
|
|
@@ -1200,6 +1227,7 @@ function SelectWidget(props) {
|
|
|
1200
1227
|
invalid: rawErrors && rawErrors.length > 0,
|
|
1201
1228
|
label: labelValue6(label, hideLabel || !label),
|
|
1202
1229
|
position: "relative",
|
|
1230
|
+
...chakraProps,
|
|
1203
1231
|
children: /* @__PURE__ */ jsxs18(
|
|
1204
1232
|
SelectRoot,
|
|
1205
1233
|
{
|
|
@@ -1209,7 +1237,7 @@ function SelectWidget(props) {
|
|
|
1209
1237
|
multiple: isMultiple,
|
|
1210
1238
|
closeOnSelect: !isMultiple,
|
|
1211
1239
|
onBlur: _onBlur,
|
|
1212
|
-
onValueChange: isMultiple ? _onMultiChange :
|
|
1240
|
+
onValueChange: isMultiple ? _onMultiChange : _onSingleChange,
|
|
1213
1241
|
onFocus: _onFocus,
|
|
1214
1242
|
autoFocus: autofocus,
|
|
1215
1243
|
value: formValue,
|
|
@@ -1255,7 +1283,8 @@ function NativeSelectWidget(props) {
|
|
|
1255
1283
|
onBlur,
|
|
1256
1284
|
onFocus,
|
|
1257
1285
|
rawErrors = [],
|
|
1258
|
-
schema
|
|
1286
|
+
schema,
|
|
1287
|
+
uiSchema
|
|
1259
1288
|
} = props;
|
|
1260
1289
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1261
1290
|
const _onChange = ({ target }) => {
|
|
@@ -1294,6 +1323,7 @@ function NativeSelectWidget(props) {
|
|
|
1294
1323
|
const selectOptions = createListCollection2({
|
|
1295
1324
|
items: displayEnumOptions.filter((item) => item.value)
|
|
1296
1325
|
});
|
|
1326
|
+
const chakraProps = getChakra({ uiSchema });
|
|
1297
1327
|
return /* @__PURE__ */ jsx31(
|
|
1298
1328
|
Field,
|
|
1299
1329
|
{
|
|
@@ -1303,6 +1333,7 @@ function NativeSelectWidget(props) {
|
|
|
1303
1333
|
readOnly: readonly,
|
|
1304
1334
|
invalid: rawErrors && rawErrors.length > 0,
|
|
1305
1335
|
label: labelValue7(label, hideLabel || !label),
|
|
1336
|
+
...chakraProps,
|
|
1306
1337
|
children: /* @__PURE__ */ jsxs19(ChakraSelect3.Root, { children: [
|
|
1307
1338
|
/* @__PURE__ */ jsx31(
|
|
1308
1339
|
ChakraSelect3.Field,
|
|
@@ -1344,11 +1375,13 @@ function TextareaWidget({
|
|
|
1344
1375
|
onChange,
|
|
1345
1376
|
options,
|
|
1346
1377
|
required,
|
|
1347
|
-
rawErrors
|
|
1378
|
+
rawErrors,
|
|
1379
|
+
uiSchema
|
|
1348
1380
|
}) {
|
|
1349
1381
|
const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
|
|
1350
1382
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
1351
1383
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
1384
|
+
const chakraProps = getChakra({ uiSchema });
|
|
1352
1385
|
return /* @__PURE__ */ jsx32(
|
|
1353
1386
|
Field,
|
|
1354
1387
|
{
|
|
@@ -1358,6 +1391,7 @@ function TextareaWidget({
|
|
|
1358
1391
|
readOnly: readonly,
|
|
1359
1392
|
invalid: rawErrors && rawErrors.length > 0,
|
|
1360
1393
|
label: labelValue8(label, hideLabel || !label),
|
|
1394
|
+
...chakraProps,
|
|
1361
1395
|
children: /* @__PURE__ */ jsx32(
|
|
1362
1396
|
Textarea,
|
|
1363
1397
|
{
|
|
@@ -1410,6 +1444,7 @@ function UpDownWidget(props) {
|
|
|
1410
1444
|
const _onChange = ({ value: value2 }) => onChange(value2);
|
|
1411
1445
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
1412
1446
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
1447
|
+
const chakraProps = getChakra({ uiSchema: props.uiSchema });
|
|
1413
1448
|
return /* @__PURE__ */ jsx34(
|
|
1414
1449
|
Field,
|
|
1415
1450
|
{
|
|
@@ -1419,6 +1454,7 @@ function UpDownWidget(props) {
|
|
|
1419
1454
|
readOnly: readonly,
|
|
1420
1455
|
invalid: rawErrors && rawErrors.length > 0,
|
|
1421
1456
|
label: labelValue9(label, hideLabel || !label),
|
|
1457
|
+
...chakraProps,
|
|
1422
1458
|
children: /* @__PURE__ */ jsx34(
|
|
1423
1459
|
NumberInputRoot,
|
|
1424
1460
|
{
|
|
@@ -1471,14 +1507,14 @@ var Form_default = generateForm();
|
|
|
1471
1507
|
import { CacheProvider } from "@emotion/react";
|
|
1472
1508
|
import createCache from "@emotion/cache";
|
|
1473
1509
|
import weakMemoize from "@emotion/weak-memoize";
|
|
1474
|
-
import { ChakraProvider, defaultSystem } from "@chakra-ui/react";
|
|
1510
|
+
import { ChakraProvider, defaultSystem as defaultSystem2 } from "@chakra-ui/react";
|
|
1475
1511
|
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
1476
1512
|
var memoizedCreateCacheWithContainer = weakMemoize((container) => {
|
|
1477
1513
|
const newCache = createCache({ container, key: "rjsf" });
|
|
1478
1514
|
return newCache;
|
|
1479
1515
|
});
|
|
1480
1516
|
var __createChakraFrameProvider = (props) => ({ document }) => {
|
|
1481
|
-
return /* @__PURE__ */ jsx35("div", { style: { margin: 2 }, children: /* @__PURE__ */ jsx35(CacheProvider, { value: memoizedCreateCacheWithContainer(document.head), children: /* @__PURE__ */ jsx35(ChakraProvider, { value:
|
|
1517
|
+
return /* @__PURE__ */ jsx35("div", { style: { margin: 2 }, children: /* @__PURE__ */ jsx35(CacheProvider, { value: memoizedCreateCacheWithContainer(document.head), children: /* @__PURE__ */ jsx35(ChakraProvider, { value: defaultSystem2, children: props.children }) }) });
|
|
1482
1518
|
};
|
|
1483
1519
|
|
|
1484
1520
|
// src/index.ts
|
|
@@ -1493,6 +1529,7 @@ export {
|
|
|
1493
1529
|
generateForm,
|
|
1494
1530
|
generateTemplates,
|
|
1495
1531
|
generateTheme,
|
|
1496
|
-
generateWidgets
|
|
1532
|
+
generateWidgets,
|
|
1533
|
+
getChakra
|
|
1497
1534
|
};
|
|
1498
1535
|
//# sourceMappingURL=chakra-ui.esm.js.map
|