@rjsf/antd 6.4.2 → 6.5.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.
package/dist/antd.esm.js CHANGED
@@ -155,6 +155,7 @@ function BaseInputTemplate(props) {
155
155
  },
156
156
  [onChange, options.emptyValue]
157
157
  );
158
+ const { min, max, ...restInputProps } = inputProps;
158
159
  const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ jsx3(
159
160
  InputNumber,
160
161
  {
@@ -167,8 +168,12 @@ function BaseInputTemplate(props) {
167
168
  placeholder,
168
169
  required,
169
170
  style: INPUT_STYLE,
171
+ changeOnWheel: false,
170
172
  list: schema.examples ? examplesId(id) : void 0,
171
- ...inputProps,
173
+ ...restInputProps,
174
+ min: typeof min === "number" ? min : void 0,
175
+ max: typeof max === "number" ? max : void 0,
176
+ type: void 0,
172
177
  value,
173
178
  "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
174
179
  }
@@ -209,38 +214,49 @@ function DescriptionField(props) {
209
214
  }
210
215
 
211
216
  // src/templates/ErrorList/index.tsx
212
- import { Alert, List, Space as Space2 } from "antd";
213
- import ExclamationCircleOutlined from "@ant-design/icons/ExclamationCircleOutlined";
217
+ import { Alert, Space as Space2, theme, version } from "antd";
218
+ import { ExclamationCircleOutlined } from "@ant-design/icons";
214
219
  import { TranslatableString } from "@rjsf/utils";
215
220
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
221
+ var antdMajor = parseInt(version.split(".")[0], 10);
216
222
  function ErrorList({
217
223
  errors,
218
224
  registry
219
225
  }) {
220
226
  const { translateString } = registry;
221
- const renderErrors = () => /* @__PURE__ */ jsx5(List, { className: "list-group", size: "small", children: errors.map((error, index) => /* @__PURE__ */ jsx5(List.Item, { children: /* @__PURE__ */ jsxs4(Space2, { children: [
222
- /* @__PURE__ */ jsx5(ExclamationCircleOutlined, {}),
223
- error.stack
224
- ] }) }, index)) });
225
- return /* @__PURE__ */ jsx5(
226
- Alert,
227
+ const { token } = theme.useToken();
228
+ const itemBorder = `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`;
229
+ const renderErrors = () => /* @__PURE__ */ jsx5("ul", { style: { margin: 0, padding: 0, listStyle: "none" }, children: errors.map((error, index) => /* @__PURE__ */ jsx5(
230
+ "li",
227
231
  {
228
- className: "panel panel-danger errors",
229
- description: renderErrors(),
230
- message: translateString(TranslatableString.ErrorsLabel),
231
- type: "error"
232
- }
233
- );
232
+ style: {
233
+ display: "flex",
234
+ alignItems: "center",
235
+ padding: `${token.paddingXS}px ${token.padding}px`,
236
+ color: token.colorText,
237
+ borderBlockEnd: index < errors.length - 1 ? itemBorder : "none"
238
+ },
239
+ children: /* @__PURE__ */ jsxs4(Space2, { children: [
240
+ /* @__PURE__ */ jsx5(ExclamationCircleOutlined, {}),
241
+ error.stack
242
+ ] })
243
+ },
244
+ index
245
+ )) });
246
+ const headerProp = antdMajor >= 6 ? { title: translateString(TranslatableString.ErrorsLabel) } : { message: translateString(TranslatableString.ErrorsLabel) };
247
+ return /* @__PURE__ */ jsx5(Alert, { className: "panel panel-danger errors", description: renderErrors(), type: "error", ...headerProp });
234
248
  }
235
249
 
236
250
  // src/templates/IconButton/index.tsx
237
251
  import { Button } from "antd";
238
- import ArrowDownOutlined from "@ant-design/icons/ArrowDownOutlined";
239
- import ArrowUpOutlined from "@ant-design/icons/ArrowUpOutlined";
240
- import CopyOutlined from "@ant-design/icons/CopyOutlined";
241
- import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
242
- import PlusCircleOutlined from "@ant-design/icons/PlusCircleOutlined";
243
- import CloseOutlined from "@ant-design/icons/CloseOutlined";
252
+ import {
253
+ ArrowDownOutlined,
254
+ ArrowUpOutlined,
255
+ CopyOutlined,
256
+ DeleteOutlined,
257
+ PlusCircleOutlined,
258
+ CloseOutlined
259
+ } from "@ant-design/icons";
244
260
  import {
245
261
  getUiOptions as getUiOptions3,
246
262
  TranslatableString as TranslatableString2
@@ -723,7 +739,8 @@ function WrapIfAdditionalTemplate(props) {
723
739
  onBlur: !readonly ? onKeyRenameBlur : void 0,
724
740
  style: INPUT_STYLE2,
725
741
  type: "text"
726
- }
742
+ },
743
+ label
727
744
  )
728
745
  }
729
746
  ) }) }),
@@ -824,8 +841,10 @@ function AltDateWidget({ autofocus = false, disabled = false, options, readonly
824
841
  import { Checkbox } from "antd";
825
842
  import {
826
843
  ariaDescribedByIds as ariaDescribedByIds2,
827
- enumOptionsIndexForValue,
828
- enumOptionsValueForIndex,
844
+ enumOptionSelectedValue,
845
+ enumOptionValueDecoder,
846
+ enumOptionValueEncoder,
847
+ getOptionValueFormat,
829
848
  optionId
830
849
  } from "@rjsf/utils";
831
850
  import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
@@ -845,22 +864,23 @@ function CheckboxesWidget({
845
864
  const { formContext } = registry;
846
865
  const { readonlyAsDisabled = true } = formContext;
847
866
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
848
- const handleChange = (nextValue) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
849
- const handleBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
850
- const handleFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
867
+ const optionValueFormat = getOptionValueFormat(options);
868
+ const handleChange = (nextValue) => onChange(enumOptionValueDecoder(nextValue, enumOptions, optionValueFormat, emptyValue));
869
+ const handleBlur = ({ target }) => onBlur(id, enumOptionValueDecoder(target.value, enumOptions, optionValueFormat, emptyValue));
870
+ const handleFocus = ({ target }) => onFocus(id, enumOptionValueDecoder(target.value, enumOptions, optionValueFormat, emptyValue));
851
871
  const extraProps = {
852
872
  id,
853
873
  onBlur: !readonly ? handleBlur : void 0,
854
874
  onFocus: !readonly ? handleFocus : void 0
855
875
  };
856
- const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
876
+ const selectValue = enumOptionSelectedValue(value, enumOptions, true, optionValueFormat, []);
857
877
  return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ jsx18(Fragment3, { children: /* @__PURE__ */ jsx18(
858
878
  Checkbox.Group,
859
879
  {
860
880
  disabled: disabled || readonlyAsDisabled && readonly,
861
881
  name: htmlName || id,
862
882
  onChange: !readonly ? handleChange : void 0,
863
- value: selectedIndexes,
883
+ value: selectValue,
864
884
  ...extraProps,
865
885
  "aria-describedby": ariaDescribedByIds2(id),
866
886
  children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ jsxs10("span", { children: [
@@ -871,7 +891,7 @@ function CheckboxesWidget({
871
891
  name: htmlName || id,
872
892
  autoFocus: i === 0 ? autofocus : false,
873
893
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
874
- value: String(i),
894
+ value: enumOptionValueEncoder(option.value, i, optionValueFormat),
875
895
  children: option.label
876
896
  }
877
897
  ),
@@ -1023,8 +1043,10 @@ function PasswordWidget(props) {
1023
1043
  import { Radio } from "antd";
1024
1044
  import {
1025
1045
  ariaDescribedByIds as ariaDescribedByIds7,
1026
- enumOptionsIndexForValue as enumOptionsIndexForValue2,
1027
- enumOptionsValueForIndex as enumOptionsValueForIndex2,
1046
+ enumOptionSelectedValue as enumOptionSelectedValue2,
1047
+ enumOptionValueDecoder as enumOptionValueDecoder2,
1048
+ enumOptionValueEncoder as enumOptionValueEncoder2,
1049
+ getOptionValueFormat as getOptionValueFormat2,
1028
1050
  optionId as optionId2
1029
1051
  } from "@rjsf/utils";
1030
1052
  import { jsx as jsx23 } from "react/jsx-runtime";
@@ -1044,10 +1066,11 @@ function RadioWidget({
1044
1066
  const { formContext } = registry;
1045
1067
  const { readonlyAsDisabled = true } = formContext;
1046
1068
  const { enumOptions, enumDisabled, emptyValue } = options;
1047
- const handleChange = ({ target: { value: nextValue } }) => onChange(enumOptionsValueForIndex2(nextValue, enumOptions, emptyValue));
1048
- const handleBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
1049
- const handleFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
1050
- const selectedIndexes = enumOptionsIndexForValue2(value, enumOptions);
1069
+ const optionValueFormat = getOptionValueFormat2(options);
1070
+ const handleChange = ({ target: { value: nextValue } }) => onChange(enumOptionValueDecoder2(nextValue, enumOptions, optionValueFormat, emptyValue));
1071
+ const handleBlur = ({ target }) => onBlur(id, enumOptionValueDecoder2(target && target.value, enumOptions, optionValueFormat, emptyValue));
1072
+ const handleFocus = ({ target }) => onFocus(id, enumOptionValueDecoder2(target && target.value, enumOptions, optionValueFormat, emptyValue));
1073
+ const selectValue = enumOptionSelectedValue2(value, enumOptions, false, optionValueFormat, emptyValue);
1051
1074
  return /* @__PURE__ */ jsx23(
1052
1075
  Radio.Group,
1053
1076
  {
@@ -1057,7 +1080,7 @@ function RadioWidget({
1057
1080
  onChange: !readonly ? handleChange : void 0,
1058
1081
  onBlur: !readonly ? handleBlur : void 0,
1059
1082
  onFocus: !readonly ? handleFocus : void 0,
1060
- value: selectedIndexes,
1083
+ value: selectValue,
1061
1084
  "aria-describedby": ariaDescribedByIds7(id),
1062
1085
  children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ jsx23(
1063
1086
  Radio,
@@ -1066,7 +1089,7 @@ function RadioWidget({
1066
1089
  name: htmlName || id,
1067
1090
  autoFocus: i === 0 ? autofocus : false,
1068
1091
  disabled: disabled || Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
1069
- value: String(i),
1092
+ value: enumOptionValueEncoder2(option.value, i, optionValueFormat),
1070
1093
  children: option.label
1071
1094
  },
1072
1095
  i
@@ -1132,8 +1155,10 @@ import { useMemo, useState } from "react";
1132
1155
  import { Select } from "antd";
1133
1156
  import {
1134
1157
  ariaDescribedByIds as ariaDescribedByIds9,
1135
- enumOptionsIndexForValue as enumOptionsIndexForValue3,
1136
- enumOptionsValueForIndex as enumOptionsValueForIndex3
1158
+ enumOptionSelectedValue as enumOptionSelectedValue3,
1159
+ enumOptionValueDecoder as enumOptionValueDecoder3,
1160
+ enumOptionValueEncoder as enumOptionValueEncoder3,
1161
+ getOptionValueFormat as getOptionValueFormat3
1137
1162
  } from "@rjsf/utils";
1138
1163
  import isString2 from "lodash/isString";
1139
1164
  import { jsx as jsx25 } from "react/jsx-runtime";
@@ -1160,9 +1185,10 @@ function SelectWidget({
1160
1185
  const { formContext } = registry;
1161
1186
  const { readonlyAsDisabled = true } = formContext;
1162
1187
  const { enumOptions, enumDisabled, emptyValue } = options;
1163
- const handleChange = (nextValue) => onChange(enumOptionsValueForIndex3(nextValue, enumOptions, emptyValue));
1164
- const handleBlur = () => onBlur(id, enumOptionsValueForIndex3(value, enumOptions, emptyValue));
1165
- const handleFocus = () => onFocus(id, enumOptionsValueForIndex3(value, enumOptions, emptyValue));
1188
+ const optionValueFormat = getOptionValueFormat3(options);
1189
+ const handleChange = (nextValue) => onChange(enumOptionValueDecoder3(nextValue, enumOptions, optionValueFormat, emptyValue));
1190
+ const handleBlur = () => onBlur(id, enumOptionValueDecoder3(value, enumOptions, optionValueFormat, emptyValue));
1191
+ const handleFocus = () => onFocus(id, enumOptionValueDecoder3(value, enumOptions, optionValueFormat, emptyValue));
1166
1192
  const filterOption = (input, option) => {
1167
1193
  if (option && isString2(option.label)) {
1168
1194
  return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
@@ -1170,7 +1196,7 @@ function SelectWidget({
1170
1196
  return false;
1171
1197
  };
1172
1198
  const getPopupContainer = SelectWidget.getPopupContainerCallback();
1173
- const selectedIndexes = enumOptionsIndexForValue3(value, enumOptions, multiple);
1199
+ const selectValue = enumOptionSelectedValue3(value, enumOptions, !!multiple, optionValueFormat, emptyValue);
1174
1200
  const extraProps = {
1175
1201
  name: htmlName || id
1176
1202
  };
@@ -1180,7 +1206,7 @@ function SelectWidget({
1180
1206
  const options2 = enumOptions.map(({ value: optionValue, label: optionLabel }, index) => ({
1181
1207
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
1182
1208
  key: String(index),
1183
- value: String(index),
1209
+ value: enumOptionValueEncoder3(optionValue, index, optionValueFormat),
1184
1210
  label: optionLabel
1185
1211
  }));
1186
1212
  if (showPlaceholderOption) {
@@ -1189,7 +1215,7 @@ function SelectWidget({
1189
1215
  return options2;
1190
1216
  }
1191
1217
  return void 0;
1192
- }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
1218
+ }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
1193
1219
  return /* @__PURE__ */ jsx25(
1194
1220
  Select,
1195
1221
  {
@@ -1204,7 +1230,7 @@ function SelectWidget({
1204
1230
  onFocus: !readonly ? handleFocus : void 0,
1205
1231
  placeholder,
1206
1232
  style: SELECT_STYLE,
1207
- value: selectedIndexes,
1233
+ value: selectValue,
1208
1234
  ...extraProps,
1209
1235
  onOpenChange: setOpen,
1210
1236
  filterOption,