@rjsf/antd 6.4.1 → 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
@@ -134,6 +134,7 @@ function BaseInputTemplate(props) {
134
134
  options,
135
135
  placeholder,
136
136
  readonly,
137
+ required,
137
138
  schema,
138
139
  value,
139
140
  type
@@ -154,6 +155,7 @@ function BaseInputTemplate(props) {
154
155
  },
155
156
  [onChange, options.emptyValue]
156
157
  );
158
+ const { min, max, ...restInputProps } = inputProps;
157
159
  const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ jsx3(
158
160
  InputNumber,
159
161
  {
@@ -164,9 +166,14 @@ function BaseInputTemplate(props) {
164
166
  onChange: !readonly ? handleNumberChange : void 0,
165
167
  onFocus: !readonly ? handleFocus : void 0,
166
168
  placeholder,
169
+ required,
167
170
  style: INPUT_STYLE,
171
+ changeOnWheel: false,
168
172
  list: schema.examples ? examplesId(id) : void 0,
169
- ...inputProps,
173
+ ...restInputProps,
174
+ min: typeof min === "number" ? min : void 0,
175
+ max: typeof max === "number" ? max : void 0,
176
+ type: void 0,
170
177
  value,
171
178
  "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
172
179
  }
@@ -180,6 +187,7 @@ function BaseInputTemplate(props) {
180
187
  onChange: !readonly ? handleTextChange : void 0,
181
188
  onFocus: !readonly ? handleFocus : void 0,
182
189
  placeholder,
190
+ required,
183
191
  style: INPUT_STYLE,
184
192
  list: schema.examples ? examplesId(id) : void 0,
185
193
  ...inputProps,
@@ -206,38 +214,49 @@ function DescriptionField(props) {
206
214
  }
207
215
 
208
216
  // src/templates/ErrorList/index.tsx
209
- import { Alert, List, Space as Space2 } from "antd";
210
- import ExclamationCircleOutlined from "@ant-design/icons/ExclamationCircleOutlined";
217
+ import { Alert, Space as Space2, theme, version } from "antd";
218
+ import { ExclamationCircleOutlined } from "@ant-design/icons";
211
219
  import { TranslatableString } from "@rjsf/utils";
212
220
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
221
+ var antdMajor = parseInt(version.split(".")[0], 10);
213
222
  function ErrorList({
214
223
  errors,
215
224
  registry
216
225
  }) {
217
226
  const { translateString } = registry;
218
- const renderErrors = () => /* @__PURE__ */ jsx5(List, { className: "list-group", size: "small", children: errors.map((error, index) => /* @__PURE__ */ jsx5(List.Item, { children: /* @__PURE__ */ jsxs4(Space2, { children: [
219
- /* @__PURE__ */ jsx5(ExclamationCircleOutlined, {}),
220
- error.stack
221
- ] }) }, index)) });
222
- return /* @__PURE__ */ jsx5(
223
- 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",
224
231
  {
225
- className: "panel panel-danger errors",
226
- description: renderErrors(),
227
- message: translateString(TranslatableString.ErrorsLabel),
228
- type: "error"
229
- }
230
- );
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 });
231
248
  }
232
249
 
233
250
  // src/templates/IconButton/index.tsx
234
251
  import { Button } from "antd";
235
- import ArrowDownOutlined from "@ant-design/icons/ArrowDownOutlined";
236
- import ArrowUpOutlined from "@ant-design/icons/ArrowUpOutlined";
237
- import CopyOutlined from "@ant-design/icons/CopyOutlined";
238
- import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
239
- import PlusCircleOutlined from "@ant-design/icons/PlusCircleOutlined";
240
- 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";
241
260
  import {
242
261
  getUiOptions as getUiOptions3,
243
262
  TranslatableString as TranslatableString2
@@ -720,7 +739,8 @@ function WrapIfAdditionalTemplate(props) {
720
739
  onBlur: !readonly ? onKeyRenameBlur : void 0,
721
740
  style: INPUT_STYLE2,
722
741
  type: "text"
723
- }
742
+ },
743
+ label
724
744
  )
725
745
  }
726
746
  ) }) }),
@@ -821,8 +841,10 @@ function AltDateWidget({ autofocus = false, disabled = false, options, readonly
821
841
  import { Checkbox } from "antd";
822
842
  import {
823
843
  ariaDescribedByIds as ariaDescribedByIds2,
824
- enumOptionsIndexForValue,
825
- enumOptionsValueForIndex,
844
+ enumOptionSelectedValue,
845
+ enumOptionValueDecoder,
846
+ enumOptionValueEncoder,
847
+ getOptionValueFormat,
826
848
  optionId
827
849
  } from "@rjsf/utils";
828
850
  import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
@@ -842,22 +864,23 @@ function CheckboxesWidget({
842
864
  const { formContext } = registry;
843
865
  const { readonlyAsDisabled = true } = formContext;
844
866
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
845
- const handleChange = (nextValue) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
846
- const handleBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
847
- 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));
848
871
  const extraProps = {
849
872
  id,
850
873
  onBlur: !readonly ? handleBlur : void 0,
851
874
  onFocus: !readonly ? handleFocus : void 0
852
875
  };
853
- const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
876
+ const selectValue = enumOptionSelectedValue(value, enumOptions, true, optionValueFormat, []);
854
877
  return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ jsx18(Fragment3, { children: /* @__PURE__ */ jsx18(
855
878
  Checkbox.Group,
856
879
  {
857
880
  disabled: disabled || readonlyAsDisabled && readonly,
858
881
  name: htmlName || id,
859
882
  onChange: !readonly ? handleChange : void 0,
860
- value: selectedIndexes,
883
+ value: selectValue,
861
884
  ...extraProps,
862
885
  "aria-describedby": ariaDescribedByIds2(id),
863
886
  children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ jsxs10("span", { children: [
@@ -868,7 +891,7 @@ function CheckboxesWidget({
868
891
  name: htmlName || id,
869
892
  autoFocus: i === 0 ? autofocus : false,
870
893
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
871
- value: String(i),
894
+ value: enumOptionValueEncoder(option.value, i, optionValueFormat),
872
895
  children: option.label
873
896
  }
874
897
  ),
@@ -1020,8 +1043,10 @@ function PasswordWidget(props) {
1020
1043
  import { Radio } from "antd";
1021
1044
  import {
1022
1045
  ariaDescribedByIds as ariaDescribedByIds7,
1023
- enumOptionsIndexForValue as enumOptionsIndexForValue2,
1024
- enumOptionsValueForIndex as enumOptionsValueForIndex2,
1046
+ enumOptionSelectedValue as enumOptionSelectedValue2,
1047
+ enumOptionValueDecoder as enumOptionValueDecoder2,
1048
+ enumOptionValueEncoder as enumOptionValueEncoder2,
1049
+ getOptionValueFormat as getOptionValueFormat2,
1025
1050
  optionId as optionId2
1026
1051
  } from "@rjsf/utils";
1027
1052
  import { jsx as jsx23 } from "react/jsx-runtime";
@@ -1041,10 +1066,11 @@ function RadioWidget({
1041
1066
  const { formContext } = registry;
1042
1067
  const { readonlyAsDisabled = true } = formContext;
1043
1068
  const { enumOptions, enumDisabled, emptyValue } = options;
1044
- const handleChange = ({ target: { value: nextValue } }) => onChange(enumOptionsValueForIndex2(nextValue, enumOptions, emptyValue));
1045
- const handleBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
1046
- const handleFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
1047
- 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);
1048
1074
  return /* @__PURE__ */ jsx23(
1049
1075
  Radio.Group,
1050
1076
  {
@@ -1054,7 +1080,7 @@ function RadioWidget({
1054
1080
  onChange: !readonly ? handleChange : void 0,
1055
1081
  onBlur: !readonly ? handleBlur : void 0,
1056
1082
  onFocus: !readonly ? handleFocus : void 0,
1057
- value: selectedIndexes,
1083
+ value: selectValue,
1058
1084
  "aria-describedby": ariaDescribedByIds7(id),
1059
1085
  children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ jsx23(
1060
1086
  Radio,
@@ -1063,7 +1089,7 @@ function RadioWidget({
1063
1089
  name: htmlName || id,
1064
1090
  autoFocus: i === 0 ? autofocus : false,
1065
1091
  disabled: disabled || Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
1066
- value: String(i),
1092
+ value: enumOptionValueEncoder2(option.value, i, optionValueFormat),
1067
1093
  children: option.label
1068
1094
  },
1069
1095
  i
@@ -1129,8 +1155,10 @@ import { useMemo, useState } from "react";
1129
1155
  import { Select } from "antd";
1130
1156
  import {
1131
1157
  ariaDescribedByIds as ariaDescribedByIds9,
1132
- enumOptionsIndexForValue as enumOptionsIndexForValue3,
1133
- enumOptionsValueForIndex as enumOptionsValueForIndex3
1158
+ enumOptionSelectedValue as enumOptionSelectedValue3,
1159
+ enumOptionValueDecoder as enumOptionValueDecoder3,
1160
+ enumOptionValueEncoder as enumOptionValueEncoder3,
1161
+ getOptionValueFormat as getOptionValueFormat3
1134
1162
  } from "@rjsf/utils";
1135
1163
  import isString2 from "lodash/isString";
1136
1164
  import { jsx as jsx25 } from "react/jsx-runtime";
@@ -1157,9 +1185,10 @@ function SelectWidget({
1157
1185
  const { formContext } = registry;
1158
1186
  const { readonlyAsDisabled = true } = formContext;
1159
1187
  const { enumOptions, enumDisabled, emptyValue } = options;
1160
- const handleChange = (nextValue) => onChange(enumOptionsValueForIndex3(nextValue, enumOptions, emptyValue));
1161
- const handleBlur = () => onBlur(id, enumOptionsValueForIndex3(value, enumOptions, emptyValue));
1162
- 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));
1163
1192
  const filterOption = (input, option) => {
1164
1193
  if (option && isString2(option.label)) {
1165
1194
  return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
@@ -1167,7 +1196,7 @@ function SelectWidget({
1167
1196
  return false;
1168
1197
  };
1169
1198
  const getPopupContainer = SelectWidget.getPopupContainerCallback();
1170
- const selectedIndexes = enumOptionsIndexForValue3(value, enumOptions, multiple);
1199
+ const selectValue = enumOptionSelectedValue3(value, enumOptions, !!multiple, optionValueFormat, emptyValue);
1171
1200
  const extraProps = {
1172
1201
  name: htmlName || id
1173
1202
  };
@@ -1177,7 +1206,7 @@ function SelectWidget({
1177
1206
  const options2 = enumOptions.map(({ value: optionValue, label: optionLabel }, index) => ({
1178
1207
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
1179
1208
  key: String(index),
1180
- value: String(index),
1209
+ value: enumOptionValueEncoder3(optionValue, index, optionValueFormat),
1181
1210
  label: optionLabel
1182
1211
  }));
1183
1212
  if (showPlaceholderOption) {
@@ -1186,7 +1215,7 @@ function SelectWidget({
1186
1215
  return options2;
1187
1216
  }
1188
1217
  return void 0;
1189
- }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
1218
+ }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
1190
1219
  return /* @__PURE__ */ jsx25(
1191
1220
  Select,
1192
1221
  {
@@ -1201,7 +1230,7 @@ function SelectWidget({
1201
1230
  onFocus: !readonly ? handleFocus : void 0,
1202
1231
  placeholder,
1203
1232
  style: SELECT_STYLE,
1204
- value: selectedIndexes,
1233
+ value: selectValue,
1205
1234
  ...extraProps,
1206
1235
  onOpenChange: setOpen,
1207
1236
  filterOption,