@rjsf/chakra-ui 6.0.1 → 6.1.0

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.
@@ -355,14 +355,14 @@ function FieldErrorTemplate(props) {
355
355
  // src/FieldHelpTemplate/FieldHelpTemplate.tsx
356
356
  import { Text as Text2 } from "@chakra-ui/react";
357
357
  import { helpId } from "@rjsf/utils";
358
+ import { RichHelp } from "@rjsf/core";
358
359
  import { jsx as jsx13 } from "react/jsx-runtime";
359
360
  function FieldHelpTemplate(props) {
360
- const { fieldPathId, help } = props;
361
+ const { fieldPathId, help, uiSchema, registry } = props;
361
362
  if (!help) {
362
363
  return null;
363
364
  }
364
- const id = helpId(fieldPathId);
365
- return /* @__PURE__ */ jsx13(Text2, { id, children: help });
365
+ return /* @__PURE__ */ jsx13(Text2, { as: "sup", fontSize: "md", id: helpId(fieldPathId), children: /* @__PURE__ */ jsx13(RichHelp, { help, registry, uiSchema }) });
366
366
  }
367
367
 
368
368
  // src/FieldTemplate/FieldTemplate.tsx
@@ -413,6 +413,8 @@ function FieldTemplate(props) {
413
413
  disabled,
414
414
  id,
415
415
  label,
416
+ displayLabel,
417
+ rawDescription,
416
418
  onKeyRename,
417
419
  onKeyRenameBlur,
418
420
  onRemoveProperty,
@@ -618,10 +620,12 @@ function WrapIfAdditionalTemplate(props) {
618
620
  classNames,
619
621
  style,
620
622
  disabled,
623
+ displayLabel,
621
624
  id,
622
625
  label,
623
626
  onRemoveProperty,
624
627
  onKeyRenameBlur,
628
+ rawDescription,
625
629
  readonly,
626
630
  registry,
627
631
  required,
@@ -630,37 +634,50 @@ function WrapIfAdditionalTemplate(props) {
630
634
  } = props;
631
635
  const { templates, translateString } = registry;
632
636
  const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
633
- const keyLabel = translateString(TranslatableString4.KeyLabel, [label]);
637
+ const keyLabel = displayLabel ? translateString(TranslatableString4.KeyLabel, [label]) : void 0;
634
638
  const additional = ADDITIONAL_PROPERTY_FLAG in schema;
639
+ const hasDescription = !!rawDescription;
640
+ const margin = hasDescription ? 58 : 22;
635
641
  if (!additional) {
636
642
  return /* @__PURE__ */ jsx21("div", { className: classNames, style, children });
637
643
  }
638
- return /* @__PURE__ */ jsxs11(Grid4, { className: classNames, style, alignItems: "center", gap: 2, children: [
639
- /* @__PURE__ */ jsx21(GridItem4, { children: /* @__PURE__ */ jsx21(Field, { required, label: keyLabel, children: /* @__PURE__ */ jsx21(
640
- Input2,
641
- {
642
- defaultValue: label,
643
- disabled: disabled || readonly,
644
- id: `${id}-key`,
645
- name: `${id}-key`,
646
- onBlur: !readonly ? onKeyRenameBlur : void 0,
647
- type: "text",
648
- mb: 1
649
- }
650
- ) }) }),
651
- /* @__PURE__ */ jsx21(GridItem4, { children }),
652
- /* @__PURE__ */ jsx21(GridItem4, { children: /* @__PURE__ */ jsx21(
653
- RemoveButton2,
654
- {
655
- id: buttonId3(id, "remove"),
656
- className: "rjsf-object-property-remove",
657
- disabled: disabled || readonly,
658
- onClick: onRemoveProperty,
659
- uiSchema,
660
- registry
661
- }
662
- ) })
663
- ] }, `${id}-key`);
644
+ return /* @__PURE__ */ jsxs11(
645
+ Grid4,
646
+ {
647
+ templateColumns: "repeat(11, 1fr)",
648
+ className: classNames,
649
+ style,
650
+ alignItems: "center",
651
+ gap: 2,
652
+ children: [
653
+ /* @__PURE__ */ jsx21(GridItem4, { colSpan: 5, style: { marginTop: hasDescription ? "36px" : void 0 }, children: /* @__PURE__ */ jsx21(Field, { required, label: keyLabel, children: /* @__PURE__ */ jsx21(
654
+ Input2,
655
+ {
656
+ defaultValue: label,
657
+ disabled: disabled || readonly,
658
+ id: `${id}-key`,
659
+ name: `${id}-key`,
660
+ onBlur: !readonly ? onKeyRenameBlur : void 0,
661
+ type: "text",
662
+ mb: 1
663
+ }
664
+ ) }) }),
665
+ /* @__PURE__ */ jsx21(GridItem4, { colSpan: 5, children }),
666
+ /* @__PURE__ */ jsx21(GridItem4, { justifySelf: "flex-end", style: { marginTop: displayLabel ? `${margin}px` : void 0 }, children: /* @__PURE__ */ jsx21(
667
+ RemoveButton2,
668
+ {
669
+ id: buttonId3(id, "remove"),
670
+ className: "rjsf-object-property-remove",
671
+ disabled: disabled || readonly,
672
+ onClick: onRemoveProperty,
673
+ uiSchema,
674
+ registry
675
+ }
676
+ ) })
677
+ ]
678
+ },
679
+ `${id}-key`
680
+ );
664
681
  }
665
682
 
666
683
  // src/Templates/Templates.ts
@@ -762,7 +779,8 @@ import {
762
779
  descriptionId as descriptionId2,
763
780
  getTemplate as getTemplate5,
764
781
  labelValue as labelValue2,
765
- schemaRequiresTrueValue
782
+ schemaRequiresTrueValue,
783
+ getUiOptions as getUiOptions5
766
784
  } from "@rjsf/utils";
767
785
 
768
786
  // src/components/ui/checkbox.tsx
@@ -803,7 +821,9 @@ function CheckboxWidget(props) {
803
821
  registry,
804
822
  options
805
823
  );
806
- const description = options.description || schema.description;
824
+ const uiOptions = getUiOptions5(uiSchema);
825
+ const isCheckbox = uiOptions.widget === "checkbox";
826
+ const description = isCheckbox ? void 0 : options.description ?? schema.description;
807
827
  const _onChange = ({ checked }) => onChange(checked);
808
828
  const _onBlur = ({ target }) => onBlur(id, target && target.checked);
809
829
  const _onFocus = ({ target }) => onFocus(id, target && target.checked);
@@ -837,15 +857,15 @@ function CheckboxWidget(props) {
837
857
  }
838
858
 
839
859
  // src/CheckboxesWidget/CheckboxesWidget.tsx
840
- import { CheckboxGroup, FieldsetRoot as FieldsetRoot2, Stack, Text as Text4 } from "@chakra-ui/react";
860
+ import { CheckboxGroup, FieldsetRoot as FieldsetRoot2, Stack, Text as Text4, FieldsetLegend } from "@chakra-ui/react";
841
861
  import {
842
862
  ariaDescribedByIds as ariaDescribedByIds3,
843
863
  enumOptionsIndexForValue,
844
864
  enumOptionsValueForIndex,
845
- labelValue as labelValue3,
846
- optionId
865
+ optionId,
866
+ labelValue as labelValue3
847
867
  } from "@rjsf/utils";
848
- import { jsx as jsx26 } from "react/jsx-runtime";
868
+ import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
849
869
  function CheckboxesWidget(props) {
850
870
  const {
851
871
  id,
@@ -859,8 +879,8 @@ function CheckboxesWidget(props) {
859
879
  onFocus,
860
880
  required,
861
881
  label,
862
- hideLabel,
863
882
  rawErrors = [],
883
+ hideLabel,
864
884
  uiSchema
865
885
  } = props;
866
886
  const { enumOptions, enumDisabled, emptyValue } = options;
@@ -869,40 +889,42 @@ function CheckboxesWidget(props) {
869
889
  const row = options ? options.inline : false;
870
890
  const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
871
891
  const chakraProps = getChakra({ uiSchema });
872
- return /* @__PURE__ */ jsx26(
892
+ return /* @__PURE__ */ jsxs15(
873
893
  FieldsetRoot2,
874
894
  {
875
895
  mb: 1,
876
896
  disabled: disabled || readonly,
877
897
  invalid: rawErrors && rawErrors.length > 0,
878
898
  ...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
- )
899
+ children: [
900
+ !hideLabel && label && /* @__PURE__ */ jsx26(FieldsetLegend, { children: labelValue3(label) }),
901
+ /* @__PURE__ */ jsx26(
902
+ CheckboxGroup,
903
+ {
904
+ onValueChange: (option) => onChange(enumOptionsValueForIndex(option, enumOptions, emptyValue)),
905
+ value: selectedIndexes,
906
+ "aria-describedby": ariaDescribedByIds3(id),
907
+ readOnly: readonly,
908
+ required,
909
+ children: /* @__PURE__ */ jsx26(Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
910
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
911
+ return /* @__PURE__ */ jsx26(
912
+ Checkbox,
913
+ {
914
+ id: optionId(id, index),
915
+ name: htmlName || id,
916
+ value: String(index),
917
+ disabled: disabled || itemDisabled || readonly,
918
+ onBlur: _onBlur,
919
+ onFocus: _onFocus,
920
+ children: option.label && /* @__PURE__ */ jsx26(Text4, { children: option.label })
921
+ },
922
+ index
923
+ );
924
+ }) })
925
+ }
926
+ )
927
+ ]
906
928
  }
907
929
  );
908
930
  }
@@ -920,10 +942,10 @@ import {
920
942
  // src/components/ui/radio.tsx
921
943
  import { forwardRef as forwardRef5 } from "react";
922
944
  import { RadioGroup as ChakraRadioGroup } from "@chakra-ui/react";
923
- import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
945
+ import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
924
946
  var Radio = forwardRef5(function Radio2(props, ref) {
925
947
  const { children, inputProps, rootRef, ...rest } = props;
926
- return /* @__PURE__ */ jsxs15(ChakraRadioGroup.Item, { ref: rootRef, ...rest, children: [
948
+ return /* @__PURE__ */ jsxs16(ChakraRadioGroup.Item, { ref: rootRef, ...rest, children: [
927
949
  /* @__PURE__ */ jsx27(ChakraRadioGroup.ItemHiddenInput, { ref, ...inputProps }),
928
950
  /* @__PURE__ */ jsx27(ChakraRadioGroup.ItemIndicator, {}),
929
951
  children && /* @__PURE__ */ jsx27(ChakraRadioGroup.ItemText, { children })
@@ -1002,7 +1024,7 @@ import {
1002
1024
  // src/components/ui/slider.tsx
1003
1025
  import { forwardRef as forwardRef6 } from "react";
1004
1026
  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";
1027
+ import { Fragment as Fragment2, jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
1006
1028
  var Slider = forwardRef6(function Slider2(props, ref) {
1007
1029
  const { marks: marksProp, showValue, ...rest } = props;
1008
1030
  const value = props.defaultValue ?? props.value;
@@ -1013,9 +1035,9 @@ var Slider = forwardRef6(function Slider2(props, ref) {
1013
1035
  return mark;
1014
1036
  });
1015
1037
  const hasMarkLabel = !!marks?.some((mark) => mark.label);
1016
- return /* @__PURE__ */ jsxs16(ChakraSlider.Root, { ref, width: "200px", thumbAlignment: "center", ...rest, children: [
1038
+ return /* @__PURE__ */ jsxs17(ChakraSlider.Root, { ref, width: "200px", thumbAlignment: "center", ...rest, children: [
1017
1039
  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: [
1040
+ /* @__PURE__ */ jsxs17(ChakraSlider.Control, { "data-has-mark-label": hasMarkLabel || void 0, children: [
1019
1041
  /* @__PURE__ */ jsx29(ChakraSlider.Track, { children: /* @__PURE__ */ jsx29(ChakraSlider.Range, {}) }),
1020
1042
  /* @__PURE__ */ jsx29(SliderThumbs, { value }),
1021
1043
  /* @__PURE__ */ jsx29(SliderMarks, { marks })
@@ -1034,7 +1056,7 @@ var SliderMarks = forwardRef6(function SliderMarks2(props, ref) {
1034
1056
  return /* @__PURE__ */ jsx29(ChakraSlider.MarkerGroup, { ref, children: marks.map((mark, index) => {
1035
1057
  const value = typeof mark === "number" ? mark : mark.value;
1036
1058
  const label = typeof mark === "number" ? void 0 : mark.label;
1037
- return /* @__PURE__ */ jsxs16(ChakraSlider.Marker, { value, children: [
1059
+ return /* @__PURE__ */ jsxs17(ChakraSlider.Marker, { value, children: [
1038
1060
  /* @__PURE__ */ jsx29(ChakraSlider.MarkerIndicator, {}),
1039
1061
  label
1040
1062
  ] }, index);
@@ -1090,12 +1112,12 @@ import { createListCollection, Select as ChakraSelect2 } from "@chakra-ui/react"
1090
1112
  // src/components/ui/select.tsx
1091
1113
  import { forwardRef as forwardRef7 } from "react";
1092
1114
  import { Select as ChakraSelect, Portal } from "@chakra-ui/react";
1093
- import { Fragment as Fragment3, jsx as jsx31, jsxs as jsxs17 } from "react/jsx-runtime";
1115
+ import { Fragment as Fragment3, jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
1094
1116
  var SelectTrigger = forwardRef7(function SelectTrigger2(props, ref) {
1095
1117
  const { children, clearable, ...rest } = props;
1096
- return /* @__PURE__ */ jsxs17(ChakraSelect.Control, { ...rest, children: [
1118
+ return /* @__PURE__ */ jsxs18(ChakraSelect.Control, { ...rest, children: [
1097
1119
  /* @__PURE__ */ jsx31(ChakraSelect.Trigger, { ref, children }),
1098
- /* @__PURE__ */ jsxs17(ChakraSelect.IndicatorGroup, { children: [
1120
+ /* @__PURE__ */ jsxs18(ChakraSelect.IndicatorGroup, { children: [
1099
1121
  clearable && /* @__PURE__ */ jsx31(SelectClearTrigger, {}),
1100
1122
  /* @__PURE__ */ jsx31(ChakraSelect.Indicator, {})
1101
1123
  ] })
@@ -1112,7 +1134,7 @@ var SelectContent = forwardRef7(function SelectContent2(props, ref) {
1112
1134
  });
1113
1135
  var SelectItem = forwardRef7(function SelectItem2(props, ref) {
1114
1136
  const { item, children, ...rest } = props;
1115
- return /* @__PURE__ */ jsxs17(ChakraSelect.Item, { item, ...rest, ref, children: [
1137
+ return /* @__PURE__ */ jsxs18(ChakraSelect.Item, { item, ...rest, ref, children: [
1116
1138
  children,
1117
1139
  /* @__PURE__ */ jsx31(ChakraSelect.ItemIndicator, {})
1118
1140
  ] }, item.value);
@@ -1134,14 +1156,14 @@ var SelectValueText = forwardRef7(function SelectValueText2(props, ref) {
1134
1156
  } }) });
1135
1157
  });
1136
1158
  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: [
1159
+ return /* @__PURE__ */ jsx31(ChakraSelect.Root, { ...props, ref, positioning: { sameWidth: true, ...props.positioning }, children: props.asChild ? props.children : /* @__PURE__ */ jsxs18(Fragment3, { children: [
1138
1160
  /* @__PURE__ */ jsx31(ChakraSelect.HiddenSelect, {}),
1139
1161
  props.children
1140
1162
  ] }) });
1141
1163
  });
1142
1164
  var SelectItemGroup = forwardRef7(function SelectItemGroup2(props, ref) {
1143
1165
  const { children, label, ...rest } = props;
1144
- return /* @__PURE__ */ jsxs17(ChakraSelect.ItemGroup, { ...rest, ref, children: [
1166
+ return /* @__PURE__ */ jsxs18(ChakraSelect.ItemGroup, { ...rest, ref, children: [
1145
1167
  /* @__PURE__ */ jsx31(ChakraSelect.ItemGroupLabel, { children: label }),
1146
1168
  children
1147
1169
  ] });
@@ -1150,7 +1172,7 @@ var SelectLabel = ChakraSelect.Label;
1150
1172
  var SelectItemText = ChakraSelect.ItemText;
1151
1173
 
1152
1174
  // src/SelectWidget/SelectWidget.tsx
1153
- import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
1175
+ import { jsx as jsx32, jsxs as jsxs19 } from "react/jsx-runtime";
1154
1176
  function SelectWidget(props) {
1155
1177
  const {
1156
1178
  id,
@@ -1234,7 +1256,7 @@ function SelectWidget(props) {
1234
1256
  label: labelValue6(label, hideLabel || !label),
1235
1257
  position: "relative",
1236
1258
  ...chakraProps,
1237
- children: /* @__PURE__ */ jsxs18(
1259
+ children: /* @__PURE__ */ jsxs19(
1238
1260
  SelectRoot,
1239
1261
  {
1240
1262
  collection: selectOptions,
@@ -1251,7 +1273,7 @@ function SelectWidget(props) {
1251
1273
  positioning: { placement: "bottom" },
1252
1274
  children: [
1253
1275
  /* @__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: [
1276
+ /* @__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
1277
  item.label,
1256
1278
  /* @__PURE__ */ jsx32(ChakraSelect2.ItemIndicator, {})
1257
1279
  ] }, item.value)) }) })
@@ -1271,7 +1293,7 @@ import {
1271
1293
  labelValue as labelValue7
1272
1294
  } from "@rjsf/utils";
1273
1295
  import { createListCollection as createListCollection2, NativeSelect as ChakraSelect3 } from "@chakra-ui/react";
1274
- import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
1296
+ import { jsx as jsx33, jsxs as jsxs20 } from "react/jsx-runtime";
1275
1297
  function NativeSelectWidget(props) {
1276
1298
  const {
1277
1299
  id,
@@ -1340,7 +1362,7 @@ function NativeSelectWidget(props) {
1340
1362
  invalid: rawErrors && rawErrors.length > 0,
1341
1363
  label: labelValue7(label, hideLabel || !label),
1342
1364
  ...chakraProps,
1343
- children: /* @__PURE__ */ jsxs19(ChakraSelect3.Root, { children: [
1365
+ children: /* @__PURE__ */ jsxs20(ChakraSelect3.Root, { children: [
1344
1366
  /* @__PURE__ */ jsx33(
1345
1367
  ChakraSelect3.Field,
1346
1368
  {
@@ -1427,7 +1449,7 @@ import {
1427
1449
  // src/components/ui/number-input.tsx
1428
1450
  import { forwardRef as forwardRef8, useEffect, useRef as useRef2 } from "react";
1429
1451
  import { NumberInput as ChakraNumberInput } from "@chakra-ui/react";
1430
- import { jsx as jsx35, jsxs as jsxs20 } from "react/jsx-runtime";
1452
+ import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
1431
1453
  var NumberInputRoot = forwardRef8(function NumberInput(props, ref) {
1432
1454
  const inputRef = useRef2(null);
1433
1455
  useEffect(() => {
@@ -1435,8 +1457,8 @@ var NumberInputRoot = forwardRef8(function NumberInput(props, ref) {
1435
1457
  inputRef.current.value = props.value || "";
1436
1458
  }
1437
1459
  }, [props.value]);
1438
- return /* @__PURE__ */ jsxs20(ChakraNumberInput.Root, { ref, variant: "outline", ...props, children: [
1439
- /* @__PURE__ */ jsxs20(ChakraNumberInput.Control, { children: [
1460
+ return /* @__PURE__ */ jsxs21(ChakraNumberInput.Root, { ref, variant: "outline", ...props, children: [
1461
+ /* @__PURE__ */ jsxs21(ChakraNumberInput.Control, { children: [
1440
1462
  /* @__PURE__ */ jsx35(ChakraNumberInput.IncrementTrigger, {}),
1441
1463
  /* @__PURE__ */ jsx35(ChakraNumberInput.DecrementTrigger, {})
1442
1464
  ] }),