@rjsf/chakra-ui 6.0.0 → 6.0.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.
@@ -762,7 +762,8 @@ import {
762
762
  descriptionId as descriptionId2,
763
763
  getTemplate as getTemplate5,
764
764
  labelValue as labelValue2,
765
- schemaRequiresTrueValue
765
+ schemaRequiresTrueValue,
766
+ getUiOptions as getUiOptions5
766
767
  } from "@rjsf/utils";
767
768
 
768
769
  // src/components/ui/checkbox.tsx
@@ -803,7 +804,9 @@ function CheckboxWidget(props) {
803
804
  registry,
804
805
  options
805
806
  );
806
- const description = options.description || schema.description;
807
+ const uiOptions = getUiOptions5(uiSchema);
808
+ const isCheckbox = uiOptions.widget === "checkbox";
809
+ const description = isCheckbox ? void 0 : options.description ?? schema.description;
807
810
  const _onChange = ({ checked }) => onChange(checked);
808
811
  const _onBlur = ({ target }) => onBlur(id, target && target.checked);
809
812
  const _onFocus = ({ target }) => onFocus(id, target && target.checked);
@@ -837,15 +840,15 @@ function CheckboxWidget(props) {
837
840
  }
838
841
 
839
842
  // src/CheckboxesWidget/CheckboxesWidget.tsx
840
- import { CheckboxGroup, FieldsetRoot as FieldsetRoot2, Stack, Text as Text4 } from "@chakra-ui/react";
843
+ import { CheckboxGroup, FieldsetRoot as FieldsetRoot2, Stack, Text as Text4, FieldsetLegend } from "@chakra-ui/react";
841
844
  import {
842
845
  ariaDescribedByIds as ariaDescribedByIds3,
843
846
  enumOptionsIndexForValue,
844
847
  enumOptionsValueForIndex,
845
- labelValue as labelValue3,
846
- optionId
848
+ optionId,
849
+ labelValue as labelValue3
847
850
  } from "@rjsf/utils";
848
- import { jsx as jsx26 } from "react/jsx-runtime";
851
+ import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
849
852
  function CheckboxesWidget(props) {
850
853
  const {
851
854
  id,
@@ -859,8 +862,8 @@ function CheckboxesWidget(props) {
859
862
  onFocus,
860
863
  required,
861
864
  label,
862
- hideLabel,
863
865
  rawErrors = [],
866
+ hideLabel,
864
867
  uiSchema
865
868
  } = props;
866
869
  const { enumOptions, enumDisabled, emptyValue } = options;
@@ -869,40 +872,42 @@ function CheckboxesWidget(props) {
869
872
  const row = options ? options.inline : false;
870
873
  const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
871
874
  const chakraProps = getChakra({ uiSchema });
872
- return /* @__PURE__ */ jsx26(
875
+ return /* @__PURE__ */ jsxs15(
873
876
  FieldsetRoot2,
874
877
  {
875
878
  mb: 1,
876
879
  disabled: disabled || readonly,
877
880
  invalid: rawErrors && rawErrors.length > 0,
878
881
  ...chakraProps,
879
- children: /* @__PURE__ */ jsx26(
880
- CheckboxGroup,
881
- {
882
- onValueChange: (option) => onChange(enumOptionsValueForIndex(option, enumOptions, emptyValue)),
883
- value: selectedIndexes,
884
- "aria-describedby": ariaDescribedByIds3(id),
885
- readOnly: readonly,
886
- required,
887
- label: labelValue3(label, hideLabel || !label),
888
- children: /* @__PURE__ */ jsx26(Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
889
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
890
- return /* @__PURE__ */ jsx26(
891
- Checkbox,
892
- {
893
- id: optionId(id, index),
894
- name: htmlName || id,
895
- value: String(index),
896
- disabled: disabled || itemDisabled || readonly,
897
- onBlur: _onBlur,
898
- onFocus: _onFocus,
899
- children: option.label && /* @__PURE__ */ jsx26(Text4, { children: option.label })
900
- },
901
- index
902
- );
903
- }) })
904
- }
905
- )
882
+ children: [
883
+ !hideLabel && label && /* @__PURE__ */ jsx26(FieldsetLegend, { children: labelValue3(label) }),
884
+ /* @__PURE__ */ jsx26(
885
+ CheckboxGroup,
886
+ {
887
+ onValueChange: (option) => onChange(enumOptionsValueForIndex(option, enumOptions, emptyValue)),
888
+ value: selectedIndexes,
889
+ "aria-describedby": ariaDescribedByIds3(id),
890
+ readOnly: readonly,
891
+ required,
892
+ children: /* @__PURE__ */ jsx26(Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
893
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
894
+ return /* @__PURE__ */ jsx26(
895
+ Checkbox,
896
+ {
897
+ id: optionId(id, index),
898
+ name: htmlName || id,
899
+ value: String(index),
900
+ disabled: disabled || itemDisabled || readonly,
901
+ onBlur: _onBlur,
902
+ onFocus: _onFocus,
903
+ children: option.label && /* @__PURE__ */ jsx26(Text4, { children: option.label })
904
+ },
905
+ index
906
+ );
907
+ }) })
908
+ }
909
+ )
910
+ ]
906
911
  }
907
912
  );
908
913
  }
@@ -920,10 +925,10 @@ import {
920
925
  // src/components/ui/radio.tsx
921
926
  import { forwardRef as forwardRef5 } from "react";
922
927
  import { RadioGroup as ChakraRadioGroup } from "@chakra-ui/react";
923
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
928
+ import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
924
929
  var Radio = forwardRef5(function Radio2(props, ref) {
925
930
  const { children, inputProps, rootRef, ...rest } = props;
926
- return /* @__PURE__ */ jsxs15(ChakraRadioGroup.Item, { ref: rootRef, ...rest, children: [
931
+ return /* @__PURE__ */ jsxs16(ChakraRadioGroup.Item, { ref: rootRef, ...rest, children: [
927
932
  /* @__PURE__ */ jsx27(ChakraRadioGroup.ItemHiddenInput, { ref, ...inputProps }),
928
933
  /* @__PURE__ */ jsx27(ChakraRadioGroup.ItemIndicator, {}),
929
934
  children && /* @__PURE__ */ jsx27(ChakraRadioGroup.ItemText, { children })
@@ -1002,7 +1007,7 @@ import {
1002
1007
  // src/components/ui/slider.tsx
1003
1008
  import { forwardRef as forwardRef6 } from "react";
1004
1009
  import { Slider as ChakraSlider, HStack as HStack2 } from "@chakra-ui/react";
1005
- import { Fragment as Fragment2, jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
1010
+ import { Fragment as Fragment2, jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
1006
1011
  var Slider = forwardRef6(function Slider2(props, ref) {
1007
1012
  const { marks: marksProp, showValue, ...rest } = props;
1008
1013
  const value = props.defaultValue ?? props.value;
@@ -1013,9 +1018,9 @@ var Slider = forwardRef6(function Slider2(props, ref) {
1013
1018
  return mark;
1014
1019
  });
1015
1020
  const hasMarkLabel = !!marks?.some((mark) => mark.label);
1016
- return /* @__PURE__ */ jsxs16(ChakraSlider.Root, { ref, width: "200px", thumbAlignment: "center", ...rest, children: [
1021
+ return /* @__PURE__ */ jsxs17(ChakraSlider.Root, { ref, width: "200px", thumbAlignment: "center", ...rest, children: [
1017
1022
  showValue && /* @__PURE__ */ jsx29(HStack2, { justify: "space-between", children: /* @__PURE__ */ jsx29(ChakraSlider.ValueText, {}) }),
1018
- /* @__PURE__ */ jsxs16(ChakraSlider.Control, { "data-has-mark-label": hasMarkLabel || void 0, children: [
1023
+ /* @__PURE__ */ jsxs17(ChakraSlider.Control, { "data-has-mark-label": hasMarkLabel || void 0, children: [
1019
1024
  /* @__PURE__ */ jsx29(ChakraSlider.Track, { children: /* @__PURE__ */ jsx29(ChakraSlider.Range, {}) }),
1020
1025
  /* @__PURE__ */ jsx29(SliderThumbs, { value }),
1021
1026
  /* @__PURE__ */ jsx29(SliderMarks, { marks })
@@ -1034,7 +1039,7 @@ var SliderMarks = forwardRef6(function SliderMarks2(props, ref) {
1034
1039
  return /* @__PURE__ */ jsx29(ChakraSlider.MarkerGroup, { ref, children: marks.map((mark, index) => {
1035
1040
  const value = typeof mark === "number" ? mark : mark.value;
1036
1041
  const label = typeof mark === "number" ? void 0 : mark.label;
1037
- return /* @__PURE__ */ jsxs16(ChakraSlider.Marker, { value, children: [
1042
+ return /* @__PURE__ */ jsxs17(ChakraSlider.Marker, { value, children: [
1038
1043
  /* @__PURE__ */ jsx29(ChakraSlider.MarkerIndicator, {}),
1039
1044
  label
1040
1045
  ] }, index);
@@ -1090,12 +1095,12 @@ import { createListCollection, Select as ChakraSelect2 } from "@chakra-ui/react"
1090
1095
  // src/components/ui/select.tsx
1091
1096
  import { forwardRef as forwardRef7 } from "react";
1092
1097
  import { Select as ChakraSelect, Portal } from "@chakra-ui/react";
1093
- import { Fragment as Fragment3, jsx as jsx31, jsxs as jsxs17 } from "react/jsx-runtime";
1098
+ import { Fragment as Fragment3, jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
1094
1099
  var SelectTrigger = forwardRef7(function SelectTrigger2(props, ref) {
1095
1100
  const { children, clearable, ...rest } = props;
1096
- return /* @__PURE__ */ jsxs17(ChakraSelect.Control, { ...rest, children: [
1101
+ return /* @__PURE__ */ jsxs18(ChakraSelect.Control, { ...rest, children: [
1097
1102
  /* @__PURE__ */ jsx31(ChakraSelect.Trigger, { ref, children }),
1098
- /* @__PURE__ */ jsxs17(ChakraSelect.IndicatorGroup, { children: [
1103
+ /* @__PURE__ */ jsxs18(ChakraSelect.IndicatorGroup, { children: [
1099
1104
  clearable && /* @__PURE__ */ jsx31(SelectClearTrigger, {}),
1100
1105
  /* @__PURE__ */ jsx31(ChakraSelect.Indicator, {})
1101
1106
  ] })
@@ -1112,7 +1117,7 @@ var SelectContent = forwardRef7(function SelectContent2(props, ref) {
1112
1117
  });
1113
1118
  var SelectItem = forwardRef7(function SelectItem2(props, ref) {
1114
1119
  const { item, children, ...rest } = props;
1115
- return /* @__PURE__ */ jsxs17(ChakraSelect.Item, { item, ...rest, ref, children: [
1120
+ return /* @__PURE__ */ jsxs18(ChakraSelect.Item, { item, ...rest, ref, children: [
1116
1121
  children,
1117
1122
  /* @__PURE__ */ jsx31(ChakraSelect.ItemIndicator, {})
1118
1123
  ] }, item.value);
@@ -1134,14 +1139,14 @@ var SelectValueText = forwardRef7(function SelectValueText2(props, ref) {
1134
1139
  } }) });
1135
1140
  });
1136
1141
  var SelectRoot = forwardRef7(function SelectRoot2(props, ref) {
1137
- return /* @__PURE__ */ jsx31(ChakraSelect.Root, { ...props, ref, positioning: { sameWidth: true, ...props.positioning }, children: props.asChild ? props.children : /* @__PURE__ */ jsxs17(Fragment3, { children: [
1142
+ return /* @__PURE__ */ jsx31(ChakraSelect.Root, { ...props, ref, positioning: { sameWidth: true, ...props.positioning }, children: props.asChild ? props.children : /* @__PURE__ */ jsxs18(Fragment3, { children: [
1138
1143
  /* @__PURE__ */ jsx31(ChakraSelect.HiddenSelect, {}),
1139
1144
  props.children
1140
1145
  ] }) });
1141
1146
  });
1142
1147
  var SelectItemGroup = forwardRef7(function SelectItemGroup2(props, ref) {
1143
1148
  const { children, label, ...rest } = props;
1144
- return /* @__PURE__ */ jsxs17(ChakraSelect.ItemGroup, { ...rest, ref, children: [
1149
+ return /* @__PURE__ */ jsxs18(ChakraSelect.ItemGroup, { ...rest, ref, children: [
1145
1150
  /* @__PURE__ */ jsx31(ChakraSelect.ItemGroupLabel, { children: label }),
1146
1151
  children
1147
1152
  ] });
@@ -1150,7 +1155,7 @@ var SelectLabel = ChakraSelect.Label;
1150
1155
  var SelectItemText = ChakraSelect.ItemText;
1151
1156
 
1152
1157
  // src/SelectWidget/SelectWidget.tsx
1153
- import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
1158
+ import { jsx as jsx32, jsxs as jsxs19 } from "react/jsx-runtime";
1154
1159
  function SelectWidget(props) {
1155
1160
  const {
1156
1161
  id,
@@ -1234,7 +1239,7 @@ function SelectWidget(props) {
1234
1239
  label: labelValue6(label, hideLabel || !label),
1235
1240
  position: "relative",
1236
1241
  ...chakraProps,
1237
- children: /* @__PURE__ */ jsxs18(
1242
+ children: /* @__PURE__ */ jsxs19(
1238
1243
  SelectRoot,
1239
1244
  {
1240
1245
  collection: selectOptions,
@@ -1251,7 +1256,7 @@ function SelectWidget(props) {
1251
1256
  positioning: { placement: "bottom" },
1252
1257
  children: [
1253
1258
  /* @__PURE__ */ jsx32(ChakraSelect2.Control, { children: /* @__PURE__ */ jsx32(SelectTrigger, { children: /* @__PURE__ */ jsx32(SelectValueText, { placeholder }) }) }),
1254
- /* @__PURE__ */ jsx32(ChakraSelect2.Positioner, { minWidth: "100% !important", zIndex: "2 !important", top: "calc(100% + 5px) !important", children: /* @__PURE__ */ jsx32(ChakraSelect2.Content, { children: selectOptions.items.map((item) => /* @__PURE__ */ jsxs18(ChakraSelect2.Item, { item, children: [
1259
+ /* @__PURE__ */ jsx32(ChakraSelect2.Positioner, { minWidth: "100% !important", zIndex: "2 !important", top: "calc(100% + 5px) !important", children: /* @__PURE__ */ jsx32(ChakraSelect2.Content, { children: selectOptions.items.map((item) => /* @__PURE__ */ jsxs19(ChakraSelect2.Item, { item, children: [
1255
1260
  item.label,
1256
1261
  /* @__PURE__ */ jsx32(ChakraSelect2.ItemIndicator, {})
1257
1262
  ] }, item.value)) }) })
@@ -1271,7 +1276,7 @@ import {
1271
1276
  labelValue as labelValue7
1272
1277
  } from "@rjsf/utils";
1273
1278
  import { createListCollection as createListCollection2, NativeSelect as ChakraSelect3 } from "@chakra-ui/react";
1274
- import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
1279
+ import { jsx as jsx33, jsxs as jsxs20 } from "react/jsx-runtime";
1275
1280
  function NativeSelectWidget(props) {
1276
1281
  const {
1277
1282
  id,
@@ -1340,7 +1345,7 @@ function NativeSelectWidget(props) {
1340
1345
  invalid: rawErrors && rawErrors.length > 0,
1341
1346
  label: labelValue7(label, hideLabel || !label),
1342
1347
  ...chakraProps,
1343
- children: /* @__PURE__ */ jsxs19(ChakraSelect3.Root, { children: [
1348
+ children: /* @__PURE__ */ jsxs20(ChakraSelect3.Root, { children: [
1344
1349
  /* @__PURE__ */ jsx33(
1345
1350
  ChakraSelect3.Field,
1346
1351
  {
@@ -1427,7 +1432,7 @@ import {
1427
1432
  // src/components/ui/number-input.tsx
1428
1433
  import { forwardRef as forwardRef8, useEffect, useRef as useRef2 } from "react";
1429
1434
  import { NumberInput as ChakraNumberInput } from "@chakra-ui/react";
1430
- import { jsx as jsx35, jsxs as jsxs20 } from "react/jsx-runtime";
1435
+ import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
1431
1436
  var NumberInputRoot = forwardRef8(function NumberInput(props, ref) {
1432
1437
  const inputRef = useRef2(null);
1433
1438
  useEffect(() => {
@@ -1435,8 +1440,8 @@ var NumberInputRoot = forwardRef8(function NumberInput(props, ref) {
1435
1440
  inputRef.current.value = props.value || "";
1436
1441
  }
1437
1442
  }, [props.value]);
1438
- return /* @__PURE__ */ jsxs20(ChakraNumberInput.Root, { ref, variant: "outline", ...props, children: [
1439
- /* @__PURE__ */ jsxs20(ChakraNumberInput.Control, { children: [
1443
+ return /* @__PURE__ */ jsxs21(ChakraNumberInput.Root, { ref, variant: "outline", ...props, children: [
1444
+ /* @__PURE__ */ jsxs21(ChakraNumberInput.Control, { children: [
1440
1445
  /* @__PURE__ */ jsx35(ChakraNumberInput.IncrementTrigger, {}),
1441
1446
  /* @__PURE__ */ jsx35(ChakraNumberInput.DecrementTrigger, {})
1442
1447
  ] }),