@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.
@@ -639,7 +639,9 @@
639
639
  registry,
640
640
  options
641
641
  );
642
- const description = options.description || schema.description;
642
+ const uiOptions = utils.getUiOptions(uiSchema);
643
+ const isCheckbox = uiOptions.widget === "checkbox";
644
+ const description = isCheckbox ? void 0 : options.description ?? schema.description;
643
645
  const _onChange = ({ checked }) => onChange(checked);
644
646
  const _onBlur = ({ target }) => onBlur(id, target && target.checked);
645
647
  const _onFocus = ({ target }) => onFocus(id, target && target.checked);
@@ -684,8 +686,8 @@
684
686
  onFocus,
685
687
  required,
686
688
  label,
687
- hideLabel,
688
689
  rawErrors = [],
690
+ hideLabel,
689
691
  uiSchema
690
692
  } = props;
691
693
  const { enumOptions, enumDisabled, emptyValue } = options;
@@ -694,40 +696,42 @@
694
696
  const row = options ? options.inline : false;
695
697
  const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
696
698
  const chakraProps = getChakra({ });
697
- return /* @__PURE__ */ jsxRuntime.jsx(
699
+ return /* @__PURE__ */ jsxRuntime.jsxs(
698
700
  react$1.FieldsetRoot,
699
701
  {
700
702
  mb: 1,
701
703
  disabled: disabled || readonly,
702
704
  invalid: rawErrors && rawErrors.length > 0,
703
705
  ...chakraProps,
704
- children: /* @__PURE__ */ jsxRuntime.jsx(
705
- react$1.CheckboxGroup,
706
- {
707
- onValueChange: (option) => onChange(utils.enumOptionsValueForIndex(option, enumOptions, emptyValue)),
708
- value: selectedIndexes,
709
- "aria-describedby": utils.ariaDescribedByIds(id),
710
- readOnly: readonly,
711
- required,
712
- label: utils.labelValue(label, hideLabel || !label),
713
- children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
714
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
715
- return /* @__PURE__ */ jsxRuntime.jsx(
716
- Checkbox,
717
- {
718
- id: utils.optionId(id, index),
719
- name: htmlName || id,
720
- value: String(index),
721
- disabled: disabled || itemDisabled || readonly,
722
- onBlur: _onBlur,
723
- onFocus: _onFocus,
724
- children: option.label && /* @__PURE__ */ jsxRuntime.jsx(react$1.Text, { children: option.label })
725
- },
726
- index
727
- );
728
- }) })
729
- }
730
- )
706
+ children: [
707
+ !hideLabel && label && /* @__PURE__ */ jsxRuntime.jsx(react$1.FieldsetLegend, { children: utils.labelValue(label) }),
708
+ /* @__PURE__ */ jsxRuntime.jsx(
709
+ react$1.CheckboxGroup,
710
+ {
711
+ onValueChange: (option) => onChange(utils.enumOptionsValueForIndex(option, enumOptions, emptyValue)),
712
+ value: selectedIndexes,
713
+ "aria-describedby": utils.ariaDescribedByIds(id),
714
+ readOnly: readonly,
715
+ required,
716
+ children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
717
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
718
+ return /* @__PURE__ */ jsxRuntime.jsx(
719
+ Checkbox,
720
+ {
721
+ id: utils.optionId(id, index),
722
+ name: htmlName || id,
723
+ value: String(index),
724
+ disabled: disabled || itemDisabled || readonly,
725
+ onBlur: _onBlur,
726
+ onFocus: _onFocus,
727
+ children: option.label && /* @__PURE__ */ jsxRuntime.jsx(react$1.Text, { children: option.label })
728
+ },
729
+ index
730
+ );
731
+ }) })
732
+ }
733
+ )
734
+ ]
731
735
  }
732
736
  );
733
737
  }
package/dist/index.cjs CHANGED
@@ -813,7 +813,9 @@ function CheckboxWidget(props) {
813
813
  registry,
814
814
  options
815
815
  );
816
- const description = options.description || schema.description;
816
+ const uiOptions = (0, import_utils16.getUiOptions)(uiSchema);
817
+ const isCheckbox = uiOptions.widget === "checkbox";
818
+ const description = isCheckbox ? void 0 : options.description ?? schema.description;
817
819
  const _onChange = ({ checked }) => onChange(checked);
818
820
  const _onBlur = ({ target }) => onBlur(id, target && target.checked);
819
821
  const _onFocus = ({ target }) => onFocus(id, target && target.checked);
@@ -863,8 +865,8 @@ function CheckboxesWidget(props) {
863
865
  onFocus,
864
866
  required,
865
867
  label,
866
- hideLabel,
867
868
  rawErrors = [],
869
+ hideLabel,
868
870
  uiSchema
869
871
  } = props;
870
872
  const { enumOptions, enumDisabled, emptyValue } = options;
@@ -873,40 +875,42 @@ function CheckboxesWidget(props) {
873
875
  const row = options ? options.inline : false;
874
876
  const selectedIndexes = (0, import_utils18.enumOptionsIndexForValue)(value, enumOptions, true);
875
877
  const chakraProps = getChakra({ uiSchema });
876
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
878
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
877
879
  import_react29.FieldsetRoot,
878
880
  {
879
881
  mb: 1,
880
882
  disabled: disabled || readonly,
881
883
  invalid: rawErrors && rawErrors.length > 0,
882
884
  ...chakraProps,
883
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
884
- import_react29.CheckboxGroup,
885
- {
886
- onValueChange: (option) => onChange((0, import_utils18.enumOptionsValueForIndex)(option, enumOptions, emptyValue)),
887
- value: selectedIndexes,
888
- "aria-describedby": (0, import_utils18.ariaDescribedByIds)(id),
889
- readOnly: readonly,
890
- required,
891
- label: (0, import_utils18.labelValue)(label, hideLabel || !label),
892
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react29.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__ */ (0, import_jsx_runtime26.jsx)(
895
- Checkbox,
896
- {
897
- id: (0, import_utils18.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__ */ (0, import_jsx_runtime26.jsx)(import_react29.Text, { children: option.label })
904
- },
905
- index
906
- );
907
- }) })
908
- }
909
- )
885
+ children: [
886
+ !hideLabel && label && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react29.FieldsetLegend, { children: (0, import_utils18.labelValue)(label) }),
887
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
888
+ import_react29.CheckboxGroup,
889
+ {
890
+ onValueChange: (option) => onChange((0, import_utils18.enumOptionsValueForIndex)(option, enumOptions, emptyValue)),
891
+ value: selectedIndexes,
892
+ "aria-describedby": (0, import_utils18.ariaDescribedByIds)(id),
893
+ readOnly: readonly,
894
+ required,
895
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react29.Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
896
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
897
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
898
+ Checkbox,
899
+ {
900
+ id: (0, import_utils18.optionId)(id, index),
901
+ name: htmlName || id,
902
+ value: String(index),
903
+ disabled: disabled || itemDisabled || readonly,
904
+ onBlur: _onBlur,
905
+ onFocus: _onFocus,
906
+ children: option.label && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react29.Text, { children: option.label })
907
+ },
908
+ index
909
+ );
910
+ }) })
911
+ }
912
+ )
913
+ ]
910
914
  }
911
915
  );
912
916
  }