@rjsf/chakra-ui 6.0.0-beta.6 → 6.0.0-beta.8

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.
Files changed (48) hide show
  1. package/dist/chakra-ui.esm.js +88 -42
  2. package/dist/chakra-ui.esm.js.map +4 -4
  3. package/dist/chakra-ui.umd.js +82 -40
  4. package/dist/index.js +303 -257
  5. package/dist/index.js.map +4 -4
  6. package/lib/AddButton/AddButton.d.ts +1 -1
  7. package/lib/AddButton/AddButton.js +1 -1
  8. package/lib/AddButton/AddButton.js.map +1 -1
  9. package/lib/AltDateWidget/AltDateWidget.js +5 -3
  10. package/lib/AltDateWidget/AltDateWidget.js.map +1 -1
  11. package/lib/BaseInputTemplate/BaseInputTemplate.js +4 -2
  12. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  13. package/lib/CheckboxWidget/CheckboxWidget.js +3 -1
  14. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
  15. package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -2
  16. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  17. package/lib/RadioWidget/RadioWidget.d.ts +1 -1
  18. package/lib/RadioWidget/RadioWidget.js +4 -2
  19. package/lib/RadioWidget/RadioWidget.js.map +1 -1
  20. package/lib/RangeWidget/RangeWidget.d.ts +1 -1
  21. package/lib/RangeWidget/RangeWidget.js +4 -2
  22. package/lib/RangeWidget/RangeWidget.js.map +1 -1
  23. package/lib/SelectNativeWidget/NativeSelectWidget.js +4 -2
  24. package/lib/SelectNativeWidget/NativeSelectWidget.js.map +1 -1
  25. package/lib/SelectWidget/SelectWidget.js +4 -2
  26. package/lib/SelectWidget/SelectWidget.js.map +1 -1
  27. package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
  28. package/lib/TextareaWidget/TextareaWidget.js +4 -2
  29. package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
  30. package/lib/UpDownWidget/UpDownWidget.js +3 -1
  31. package/lib/UpDownWidget/UpDownWidget.js.map +1 -1
  32. package/lib/index.d.ts +1 -0
  33. package/lib/index.js +1 -0
  34. package/lib/index.js.map +1 -1
  35. package/lib/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +5 -5
  37. package/src/AddButton/AddButton.tsx +0 -1
  38. package/src/AltDateWidget/AltDateWidget.tsx +8 -5
  39. package/src/BaseInputTemplate/BaseInputTemplate.tsx +5 -0
  40. package/src/CheckboxWidget/CheckboxWidget.tsx +4 -1
  41. package/src/CheckboxesWidget/CheckboxesWidget.tsx +10 -1
  42. package/src/RadioWidget/RadioWidget.tsx +5 -0
  43. package/src/RangeWidget/RangeWidget.tsx +5 -1
  44. package/src/SelectNativeWidget/NativeSelectWidget.tsx +5 -0
  45. package/src/SelectWidget/SelectWidget.tsx +4 -0
  46. package/src/TextareaWidget/TextareaWidget.tsx +5 -0
  47. package/src/UpDownWidget/UpDownWidget.tsx +4 -0
  48. package/src/index.ts +2 -0
@@ -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,
@@ -614,7 +630,7 @@ function generateTemplates() {
614
630
  var Templates_default = generateTemplates();
615
631
 
616
632
  // src/AltDateWidget/AltDateWidget.tsx
617
- import { useEffect, useState } from "react";
633
+ import { Box as Box5, Button as Button3, FieldsetRoot } from "@chakra-ui/react";
618
634
  import {
619
635
  ariaDescribedByIds as ariaDescribedByIds2,
620
636
  dateRangeOptions,
@@ -623,7 +639,7 @@ import {
623
639
  toDateString,
624
640
  TranslatableString as TranslatableString5
625
641
  } from "@rjsf/utils";
626
- import { Box as Box5, Button as Button3 } from "@chakra-ui/react";
642
+ import { useEffect, useState } from "react";
627
643
  import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
628
644
  function DateElement(props) {
629
645
  const { SelectWidget: SelectWidget2 } = props.registry.widgets;
@@ -681,7 +697,8 @@ function AltDateWidget(props) {
681
697
  }
682
698
  onChange(void 0);
683
699
  };
684
- return /* @__PURE__ */ jsxs12(Box5, { children: [
700
+ const chakraProps = getChakra({ uiSchema: props.uiSchema });
701
+ return /* @__PURE__ */ jsxs12(FieldsetRoot, { ...chakraProps, children: [
685
702
  /* @__PURE__ */ jsx20(Box5, { display: "flex", flexWrap: "wrap", alignItems: "center", children: getDateElementProps(
686
703
  state,
687
704
  showTime,
@@ -787,7 +804,8 @@ function CheckboxWidget(props) {
787
804
  const _onChange = ({ checked }) => onChange(checked);
788
805
  const _onBlur = ({ target }) => onBlur(id, target && target.value);
789
806
  const _onFocus = ({ target }) => onFocus(id, target && target.value);
790
- return /* @__PURE__ */ jsxs14(Field, { mb: 1, required, children: [
807
+ const chakraProps = getChakra({ uiSchema });
808
+ return /* @__PURE__ */ jsxs14(Field, { mb: 1, required, ...chakraProps, children: [
791
809
  !hideLabel && description && /* @__PURE__ */ jsx23(
792
810
  DescriptionFieldTemplate,
793
811
  {
@@ -816,7 +834,7 @@ function CheckboxWidget(props) {
816
834
  }
817
835
 
818
836
  // src/CheckboxesWidget/CheckboxesWidget.tsx
819
- 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";
820
838
  import {
821
839
  ariaDescribedByIds as ariaDescribedByIds4,
822
840
  enumOptionsIndexForValue,
@@ -838,40 +856,51 @@ function CheckboxesWidget(props) {
838
856
  required,
839
857
  label,
840
858
  hideLabel,
841
- rawErrors = []
859
+ rawErrors = [],
860
+ uiSchema
842
861
  } = props;
843
862
  const { enumOptions, enumDisabled, emptyValue } = options;
844
863
  const _onBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
845
864
  const _onFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
846
865
  const row = options ? options.inline : false;
847
866
  const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
848
- return /* @__PURE__ */ jsx24(FieldsetRoot, { mb: 1, disabled: disabled || readonly, invalid: rawErrors && rawErrors.length > 0, children: /* @__PURE__ */ jsx24(
849
- CheckboxGroup,
867
+ const chakraProps = getChakra({ uiSchema });
868
+ return /* @__PURE__ */ jsx24(
869
+ FieldsetRoot2,
850
870
  {
851
- onValueChange: (option) => onChange(enumOptionsValueForIndex(option, enumOptions, emptyValue)),
852
- value: selectedIndexes,
853
- "aria-describedby": ariaDescribedByIds4(id),
854
- readOnly: readonly,
855
- required,
856
- label: labelValue3(label, hideLabel || !label),
857
- children: /* @__PURE__ */ jsx24(Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
858
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
859
- return /* @__PURE__ */ jsx24(
860
- Checkbox,
861
- {
862
- id: optionId(id, index),
863
- name: id,
864
- value: String(index),
865
- disabled: disabled || itemDisabled || readonly,
866
- onBlur: _onBlur,
867
- onFocus: _onFocus,
868
- children: option.label && /* @__PURE__ */ jsx24(Text5, { children: option.label })
869
- },
870
- index
871
- );
872
- }) })
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
+ )
873
902
  }
874
- ) });
903
+ );
875
904
  }
876
905
 
877
906
  // src/RadioWidget/RadioWidget.tsx
@@ -911,7 +940,8 @@ function RadioWidget({
911
940
  hideLabel,
912
941
  onChange,
913
942
  onBlur,
914
- onFocus
943
+ onFocus,
944
+ uiSchema
915
945
  }) {
916
946
  const { enumOptions, enumDisabled, emptyValue } = options;
917
947
  const _onChange = ({ target: { value: value2 } }) => onChange(enumOptionsValueForIndex2(value2, enumOptions, emptyValue));
@@ -919,6 +949,7 @@ function RadioWidget({
919
949
  const _onFocus = ({ target: { value: value2 } }) => onFocus(id, enumOptionsValueForIndex2(value2, enumOptions, emptyValue));
920
950
  const row = options ? options.inline : false;
921
951
  const selectedIndex = enumOptionsIndexForValue2(value, enumOptions) ?? null;
952
+ const chakraProps = getChakra({ uiSchema });
922
953
  return /* @__PURE__ */ jsx26(
923
954
  Field,
924
955
  {
@@ -927,6 +958,7 @@ function RadioWidget({
927
958
  required,
928
959
  readOnly: readonly,
929
960
  label: labelValue4(label, hideLabel || !label),
961
+ ...chakraProps,
930
962
  children: /* @__PURE__ */ jsx26(
931
963
  RadioGroup,
932
964
  {
@@ -1017,12 +1049,14 @@ function RangeWidget({
1017
1049
  onChange,
1018
1050
  label,
1019
1051
  hideLabel,
1020
- id
1052
+ id,
1053
+ uiSchema
1021
1054
  }) {
1022
1055
  const _onChange = ({ value: value2 }) => onChange(value2 === void 0 ? options.emptyValue : value2[0]);
1023
1056
  const _onBlur = ({ target }) => onBlur(id, target && target.value);
1024
1057
  const _onFocus = ({ target }) => onFocus(id, target && target.value);
1025
- return /* @__PURE__ */ jsx28(Field, { mb: 1, label: labelValue5(label, hideLabel || !label), children: /* @__PURE__ */ jsx28(
1058
+ const chakraProps = getChakra({ uiSchema });
1059
+ return /* @__PURE__ */ jsx28(Field, { mb: 1, label: labelValue5(label, hideLabel || !label), ...chakraProps, children: /* @__PURE__ */ jsx28(
1026
1060
  Slider,
1027
1061
  {
1028
1062
  ...rangeSpec(schema),
@@ -1129,7 +1163,8 @@ function SelectWidget(props) {
1129
1163
  onBlur,
1130
1164
  onFocus,
1131
1165
  rawErrors = [],
1132
- schema
1166
+ schema,
1167
+ uiSchema
1133
1168
  } = props;
1134
1169
  const { enumOptions, enumDisabled, emptyValue } = options;
1135
1170
  const _onMultiChange = ({ value: value2 }) => {
@@ -1187,6 +1222,7 @@ function SelectWidget(props) {
1187
1222
  items: displayEnumOptions.filter((item) => item.value)
1188
1223
  });
1189
1224
  const containerRef = useRef(null);
1225
+ const chakraProps = getChakra({ uiSchema });
1190
1226
  return /* @__PURE__ */ jsx30(
1191
1227
  Field,
1192
1228
  {
@@ -1198,6 +1234,7 @@ function SelectWidget(props) {
1198
1234
  invalid: rawErrors && rawErrors.length > 0,
1199
1235
  label: labelValue6(label, hideLabel || !label),
1200
1236
  position: "relative",
1237
+ ...chakraProps,
1201
1238
  children: /* @__PURE__ */ jsxs18(
1202
1239
  SelectRoot,
1203
1240
  {
@@ -1253,7 +1290,8 @@ function NativeSelectWidget(props) {
1253
1290
  onBlur,
1254
1291
  onFocus,
1255
1292
  rawErrors = [],
1256
- schema
1293
+ schema,
1294
+ uiSchema
1257
1295
  } = props;
1258
1296
  const { enumOptions, enumDisabled, emptyValue } = options;
1259
1297
  const _onChange = ({ target }) => {
@@ -1292,6 +1330,7 @@ function NativeSelectWidget(props) {
1292
1330
  const selectOptions = createListCollection2({
1293
1331
  items: displayEnumOptions.filter((item) => item.value)
1294
1332
  });
1333
+ const chakraProps = getChakra({ uiSchema });
1295
1334
  return /* @__PURE__ */ jsx31(
1296
1335
  Field,
1297
1336
  {
@@ -1301,6 +1340,7 @@ function NativeSelectWidget(props) {
1301
1340
  readOnly: readonly,
1302
1341
  invalid: rawErrors && rawErrors.length > 0,
1303
1342
  label: labelValue7(label, hideLabel || !label),
1343
+ ...chakraProps,
1304
1344
  children: /* @__PURE__ */ jsxs19(ChakraSelect3.Root, { children: [
1305
1345
  /* @__PURE__ */ jsx31(
1306
1346
  ChakraSelect3.Field,
@@ -1342,11 +1382,13 @@ function TextareaWidget({
1342
1382
  onChange,
1343
1383
  options,
1344
1384
  required,
1345
- rawErrors
1385
+ rawErrors,
1386
+ uiSchema
1346
1387
  }) {
1347
1388
  const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
1348
1389
  const _onBlur = ({ target }) => onBlur(id, target && target.value);
1349
1390
  const _onFocus = ({ target }) => onFocus(id, target && target.value);
1391
+ const chakraProps = getChakra({ uiSchema });
1350
1392
  return /* @__PURE__ */ jsx32(
1351
1393
  Field,
1352
1394
  {
@@ -1356,6 +1398,7 @@ function TextareaWidget({
1356
1398
  readOnly: readonly,
1357
1399
  invalid: rawErrors && rawErrors.length > 0,
1358
1400
  label: labelValue8(label, hideLabel || !label),
1401
+ ...chakraProps,
1359
1402
  children: /* @__PURE__ */ jsx32(
1360
1403
  Textarea,
1361
1404
  {
@@ -1408,6 +1451,7 @@ function UpDownWidget(props) {
1408
1451
  const _onChange = ({ value: value2 }) => onChange(value2);
1409
1452
  const _onBlur = ({ target }) => onBlur(id, target && target.value);
1410
1453
  const _onFocus = ({ target }) => onFocus(id, target && target.value);
1454
+ const chakraProps = getChakra({ uiSchema: props.uiSchema });
1411
1455
  return /* @__PURE__ */ jsx34(
1412
1456
  Field,
1413
1457
  {
@@ -1417,6 +1461,7 @@ function UpDownWidget(props) {
1417
1461
  readOnly: readonly,
1418
1462
  invalid: rawErrors && rawErrors.length > 0,
1419
1463
  label: labelValue9(label, hideLabel || !label),
1464
+ ...chakraProps,
1420
1465
  children: /* @__PURE__ */ jsx34(
1421
1466
  NumberInputRoot,
1422
1467
  {
@@ -1469,14 +1514,14 @@ var Form_default = generateForm();
1469
1514
  import { CacheProvider } from "@emotion/react";
1470
1515
  import createCache from "@emotion/cache";
1471
1516
  import weakMemoize from "@emotion/weak-memoize";
1472
- import { ChakraProvider, defaultSystem } from "@chakra-ui/react";
1517
+ import { ChakraProvider, defaultSystem as defaultSystem2 } from "@chakra-ui/react";
1473
1518
  import { jsx as jsx35 } from "react/jsx-runtime";
1474
1519
  var memoizedCreateCacheWithContainer = weakMemoize((container) => {
1475
1520
  const newCache = createCache({ container, key: "rjsf" });
1476
1521
  return newCache;
1477
1522
  });
1478
1523
  var __createChakraFrameProvider = (props) => ({ document }) => {
1479
- return /* @__PURE__ */ jsx35("div", { style: { margin: 2 }, children: /* @__PURE__ */ jsx35(CacheProvider, { value: memoizedCreateCacheWithContainer(document.head), children: /* @__PURE__ */ jsx35(ChakraProvider, { value: defaultSystem, children: props.children }) }) });
1524
+ return /* @__PURE__ */ jsx35("div", { style: { margin: 2 }, children: /* @__PURE__ */ jsx35(CacheProvider, { value: memoizedCreateCacheWithContainer(document.head), children: /* @__PURE__ */ jsx35(ChakraProvider, { value: defaultSystem2, children: props.children }) }) });
1480
1525
  };
1481
1526
 
1482
1527
  // src/index.ts
@@ -1491,6 +1536,7 @@ export {
1491
1536
  generateForm,
1492
1537
  generateTemplates,
1493
1538
  generateTheme,
1494
- generateWidgets
1539
+ generateWidgets,
1540
+ getChakra
1495
1541
  };
1496
1542
  //# sourceMappingURL=chakra-ui.esm.js.map