@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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Checkbox } from 'antd';
3
- import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, optionId, } from '@rjsf/utils';
3
+ import { ariaDescribedByIds, enumOptionSelectedValue, enumOptionValueDecoder, enumOptionValueEncoder, getOptionValueFormat, optionId, } from '@rjsf/utils';
4
4
  /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
5
5
  * It is typically used to represent an array of enums.
6
6
  *
@@ -10,9 +10,10 @@ export default function CheckboxesWidget({ autofocus, disabled, registry, id, ht
10
10
  const { formContext } = registry;
11
11
  const { readonlyAsDisabled = true } = formContext;
12
12
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
13
- const handleChange = (nextValue) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
14
- const handleBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
15
- const handleFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
13
+ const optionValueFormat = getOptionValueFormat(options);
14
+ const handleChange = (nextValue) => onChange(enumOptionValueDecoder(nextValue, enumOptions, optionValueFormat, emptyValue));
15
+ const handleBlur = ({ target }) => onBlur(id, enumOptionValueDecoder(target.value, enumOptions, optionValueFormat, emptyValue));
16
+ const handleFocus = ({ target }) => onFocus(id, enumOptionValueDecoder(target.value, enumOptions, optionValueFormat, emptyValue));
16
17
  // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
17
18
  // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
18
19
  const extraProps = {
@@ -20,8 +21,8 @@ export default function CheckboxesWidget({ autofocus, disabled, registry, id, ht
20
21
  onBlur: !readonly ? handleBlur : undefined,
21
22
  onFocus: !readonly ? handleFocus : undefined,
22
23
  };
23
- const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
24
- return Array.isArray(enumOptions) && enumOptions.length > 0 ? (_jsx(_Fragment, { children: _jsx(Checkbox.Group, { disabled: disabled || (readonlyAsDisabled && readonly), name: htmlName || id, onChange: !readonly ? handleChange : undefined, value: selectedIndexes, ...extraProps, "aria-describedby": ariaDescribedByIds(id), children: Array.isArray(enumOptions) &&
25
- enumOptions.map((option, i) => (_jsxs("span", { children: [_jsx(Checkbox, { id: optionId(id, i), name: htmlName || id, autoFocus: i === 0 ? autofocus : false, disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1, value: String(i), children: option.label }), !inline && _jsx("br", {})] }, i))) }) })) : null;
24
+ const selectValue = enumOptionSelectedValue(value, enumOptions, true, optionValueFormat, []);
25
+ return Array.isArray(enumOptions) && enumOptions.length > 0 ? (_jsx(_Fragment, { children: _jsx(Checkbox.Group, { disabled: disabled || (readonlyAsDisabled && readonly), name: htmlName || id, onChange: !readonly ? handleChange : undefined, value: selectValue, ...extraProps, "aria-describedby": ariaDescribedByIds(id), children: Array.isArray(enumOptions) &&
26
+ enumOptions.map((option, i) => (_jsxs("span", { children: [_jsx(Checkbox, { id: optionId(id, i), name: htmlName || id, autoFocus: i === 0 ? autofocus : false, disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1, value: enumOptionValueEncoder(option.value, i, optionValueFormat), children: option.label }), !inline && _jsx("br", {})] }, i))) }) })) : null;
26
27
  }
27
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/CheckboxesWidget/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,QAAQ,GAMT,MAAM,aAAa,CA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, enumOptionsIndexForValue, enumOptionsValueForIndex, optionId, } from '@rjsf/utils';
3
+ import { ariaDescribedByIds, enumOptionSelectedValue, enumOptionValueDecoder, enumOptionValueEncoder, getOptionValueFormat, optionId, } from '@rjsf/utils';
4
4
  /** The `RadioWidget` is a widget for rendering a radio group.
5
5
  * It is typically used with a string property constrained with enum options.
6
6
  *
@@ -10,11 +10,12 @@ export default function RadioWidget({ autofocus, disabled, registry, id, htmlNam
10
10
  const { formContext } = registry;
11
11
  const { readonlyAsDisabled = true } = formContext;
12
12
  const { enumOptions, enumDisabled, emptyValue } = options;
13
- const handleChange = ({ target: { value: nextValue } }) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
14
- const handleBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
15
- const handleFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
16
- const selectedIndexes = enumOptionsIndexForValue(value, enumOptions);
17
- return (_jsx(Radio.Group, { disabled: disabled || (readonlyAsDisabled && readonly), id: id, name: htmlName || id, onChange: !readonly ? handleChange : undefined, onBlur: !readonly ? handleBlur : undefined, onFocus: !readonly ? handleFocus : undefined, value: selectedIndexes, "aria-describedby": ariaDescribedByIds(id), children: Array.isArray(enumOptions) &&
18
- enumOptions.map((option, i) => (_jsx(Radio, { id: optionId(id, i), name: htmlName || id, autoFocus: i === 0 ? autofocus : false, disabled: disabled || (Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1), value: String(i), children: option.label }, i))) }));
13
+ const optionValueFormat = getOptionValueFormat(options);
14
+ const handleChange = ({ target: { value: nextValue } }) => onChange(enumOptionValueDecoder(nextValue, enumOptions, optionValueFormat, emptyValue));
15
+ const handleBlur = ({ target }) => onBlur(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
16
+ const handleFocus = ({ target }) => onFocus(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
17
+ const selectValue = enumOptionSelectedValue(value, enumOptions, false, optionValueFormat, emptyValue);
18
+ return (_jsx(Radio.Group, { disabled: disabled || (readonlyAsDisabled && readonly), id: id, name: htmlName || id, onChange: !readonly ? handleChange : undefined, onBlur: !readonly ? handleBlur : undefined, onFocus: !readonly ? handleFocus : undefined, value: selectValue, "aria-describedby": ariaDescribedByIds(id), children: Array.isArray(enumOptions) &&
19
+ enumOptions.map((option, i) => (_jsx(Radio, { id: optionId(id, i), name: htmlName || id, autoFocus: i === 0 ? autofocus : false, disabled: disabled || (Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1), value: enumOptionValueEncoder(option.value, i, optionValueFormat), children: option.label }, i))) }));
19
20
  }
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/RadioWidget/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAoB,MAAM,MAAM,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,QAAQ,GAMT,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAoF,EACrH,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,GACgB;IACrB,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IACjC,MAAM,EAAE,kBAAkB,GAAG,IAAI,EAAE,GAAG,WAAgC,CAAC;IAEvE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE1D,MAAM,YAAY,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAoB,EAAE,EAAE,CAC1E,QAAQ,CAAC,wBAAwB,CAAI,SAAS,EAAE,WA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E,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAEhG,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,iBAAiB,CAAC,YAEhE,MAAM,CAAC,KAAK,IAHR,CAAC,CAIA,CACT,CAAC,GACQ,CACf,CAAC;AACJ,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useMemo, useState } from 'react';
3
3
  import { Select } from 'antd';
4
- import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, } from '@rjsf/utils';
4
+ import { ariaDescribedByIds, enumOptionSelectedValue, enumOptionValueDecoder, enumOptionValueEncoder, getOptionValueFormat, } from '@rjsf/utils';
5
5
  import isString from 'lodash-es/isString.js';
6
6
  const SELECT_STYLE = {
7
7
  width: '100%',
@@ -16,9 +16,10 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
16
16
  const { formContext } = registry;
17
17
  const { readonlyAsDisabled = true } = formContext;
18
18
  const { enumOptions, enumDisabled, emptyValue } = options;
19
- const handleChange = (nextValue) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
20
- const handleBlur = () => onBlur(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
21
- const handleFocus = () => onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
19
+ const optionValueFormat = getOptionValueFormat(options);
20
+ const handleChange = (nextValue) => onChange(enumOptionValueDecoder(nextValue, enumOptions, optionValueFormat, emptyValue));
21
+ const handleBlur = () => onBlur(id, enumOptionValueDecoder(value, enumOptions, optionValueFormat, emptyValue));
22
+ const handleFocus = () => onFocus(id, enumOptionValueDecoder(value, enumOptions, optionValueFormat, emptyValue));
22
23
  const filterOption = (input, option) => {
23
24
  if (option && isString(option.label)) {
24
25
  // labels are strings in this context
@@ -27,7 +28,7 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
27
28
  return false;
28
29
  };
29
30
  const getPopupContainer = SelectWidget.getPopupContainerCallback();
30
- const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
31
+ const selectValue = enumOptionSelectedValue(value, enumOptions, !!multiple, optionValueFormat, emptyValue);
31
32
  // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
32
33
  // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
33
34
  const extraProps = {
@@ -39,7 +40,7 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
39
40
  const options = enumOptions.map(({ value: optionValue, label: optionLabel }, index) => ({
40
41
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
41
42
  key: String(index),
42
- value: String(index),
43
+ value: enumOptionValueEncoder(optionValue, index, optionValueFormat),
43
44
  label: optionLabel,
44
45
  }));
45
46
  if (showPlaceholderOption) {
@@ -48,8 +49,8 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
48
49
  return options;
49
50
  }
50
51
  return undefined;
51
- }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
52
- return (_jsx(Select, { open: open, autoFocus: autofocus, disabled: disabled || (readonlyAsDisabled && readonly), getPopupContainer: getPopupContainer, id: id, mode: multiple ? 'multiple' : undefined, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, style: SELECT_STYLE, value: selectedIndexes, ...extraProps,
52
+ }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
53
+ return (_jsx(Select, { open: open, autoFocus: autofocus, disabled: disabled || (readonlyAsDisabled && readonly), getPopupContainer: getPopupContainer, id: id, mode: multiple ? 'multiple' : undefined, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, style: SELECT_STYLE, value: selectValue, ...extraProps,
53
54
  // When the open change is called, set the open state, needed so that the select opens properly in the playground
54
55
  onOpenChange: setOpen, filterOption: filterOption, "aria-describedby": ariaDescribedByIds(id), options: selectOptions }));
55
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/SelectWidget/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAe,MAAM,MAAM,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GAMzB,MAAM,aAAa,CAAC;AACrB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,MAAM;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAIlC,EACA,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,KAAK,EACL,MAAM,GACe;IACrB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IACjC,MAAM,EAAE,kBAAkB,GAAG,IAAI,EAAE,GAAG,WAAgC,CAAC;IAEvE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE1D,MAAM,YAAY,GAAG,CAAC,SAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAI,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IAEnH,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,wBAAwB,C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;;GAGG;AACH,YAAY,CAAC,yBAAyB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/antd",
3
- "version": "6.4.2",
3
+ "version": "6.5.0",
4
4
  "description": "Ant Design theme, fields and widgets for react-jsonschema-form",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",
@@ -65,26 +65,26 @@
65
65
  "@ant-design/icons": "^6.0.0",
66
66
  "@rjsf/core": "^6.4.x",
67
67
  "@rjsf/utils": "^6.4.x",
68
- "antd": "^5.8.5",
68
+ "antd": "^5 || >6.3.5",
69
69
  "dayjs": "^1.8.0",
70
70
  "react": ">=18"
71
71
  },
72
72
  "dependencies": {
73
73
  "classnames": "^2.5.1",
74
- "lodash": "^4.17.23",
75
- "lodash-es": "^4.17.23",
74
+ "lodash": "^4.18.1",
75
+ "lodash-es": "^4.18.1",
76
76
  "rc-picker": "^4.11.3"
77
77
  },
78
78
  "devDependencies": {
79
- "@ant-design/icons": "^6.1.0",
80
- "@rjsf/core": "6.4.2",
81
- "@rjsf/snapshot-tests": "6.4.2",
82
- "@rjsf/utils": "6.4.2",
83
- "@rjsf/validator-ajv8": "6.4.2",
79
+ "@ant-design/icons": "^6.1.1",
80
+ "@rjsf/core": "6.5.0",
81
+ "@rjsf/snapshot-tests": "6.5.0",
82
+ "@rjsf/utils": "6.5.0",
83
+ "@rjsf/validator-ajv8": "6.5.0",
84
84
  "@rollup/plugin-replace": "^6.0.3",
85
- "antd": "^5.29.3",
85
+ "antd": "^6.3.6",
86
86
  "atob": "^2.1.2",
87
- "dayjs": "^1.11.19",
87
+ "dayjs": "^1.11.20",
88
88
  "eslint": "^8.57.1"
89
89
  },
90
90
  "repository": {
@@ -70,6 +70,8 @@ export default function BaseInputTemplate<
70
70
  [onChange, options.emptyValue],
71
71
  );
72
72
 
73
+ const { min, max, ...restInputProps } = inputProps;
74
+
73
75
  const input =
74
76
  inputProps.type === 'number' || inputProps.type === 'integer' ? (
75
77
  <InputNumber
@@ -82,8 +84,12 @@ export default function BaseInputTemplate<
82
84
  placeholder={placeholder}
83
85
  required={required}
84
86
  style={INPUT_STYLE}
87
+ changeOnWheel={false}
85
88
  list={schema.examples ? examplesId(id) : undefined}
86
- {...inputProps}
89
+ {...restInputProps}
90
+ min={typeof min === 'number' ? min : undefined}
91
+ max={typeof max === 'number' ? max : undefined}
92
+ type={undefined}
87
93
  value={value}
88
94
  aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
89
95
  />
@@ -1,5 +1,7 @@
1
- import { Alert, List, Space } from 'antd';
2
- import ExclamationCircleOutlined from '@ant-design/icons/ExclamationCircleOutlined';
1
+ import { Alert, Space, theme, version } from 'antd';
2
+
3
+ const antdMajor = parseInt(version.split('.')[0], 10);
4
+ import { ExclamationCircleOutlined } from '@ant-design/icons';
3
5
  import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
4
6
 
5
7
  /** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
@@ -11,25 +13,37 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
11
13
  registry,
12
14
  }: ErrorListProps<T, S, F>) {
13
15
  const { translateString } = registry;
16
+ // Antd's List component has been deprecated and waiting to be replaced: https://ant.design/components/list#faq-listy-replacement
17
+ // In the meantime we can mimic the Look & Feel of the List component by adding some inline CSS
18
+ const { token } = theme.useToken();
19
+ const itemBorder = `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`;
14
20
  const renderErrors = () => (
15
- <List className='list-group' size='small'>
21
+ <ul style={{ margin: 0, padding: 0, listStyle: 'none' }}>
16
22
  {errors.map((error, index) => (
17
- <List.Item key={index}>
23
+ <li
24
+ key={index}
25
+ style={{
26
+ display: 'flex',
27
+ alignItems: 'center',
28
+ padding: `${token.paddingXS}px ${token.padding}px`,
29
+ color: token.colorText,
30
+ borderBlockEnd: index < errors.length - 1 ? itemBorder : 'none',
31
+ }}
32
+ >
18
33
  <Space>
19
34
  <ExclamationCircleOutlined />
20
35
  {error.stack}
21
36
  </Space>
22
- </List.Item>
37
+ </li>
23
38
  ))}
24
- </List>
39
+ </ul>
25
40
  );
26
41
 
27
- return (
28
- <Alert
29
- className='panel panel-danger errors'
30
- description={renderErrors()}
31
- message={translateString(TranslatableString.ErrorsLabel)}
32
- type='error'
33
- />
34
- );
42
+ // Deal with the two versions of antd that we support (v5, v6). In RJSF v7, we will drop support for antd 5, so clean this up
43
+ const headerProp =
44
+ antdMajor >= 6
45
+ ? { title: translateString(TranslatableString.ErrorsLabel) }
46
+ : { message: translateString(TranslatableString.ErrorsLabel) };
47
+
48
+ return <Alert className='panel panel-danger errors' description={renderErrors()} type='error' {...headerProp} />;
35
49
  }
@@ -1,10 +1,12 @@
1
1
  import { Button, ButtonProps } from 'antd';
2
- import ArrowDownOutlined from '@ant-design/icons/ArrowDownOutlined';
3
- import ArrowUpOutlined from '@ant-design/icons/ArrowUpOutlined';
4
- import CopyOutlined from '@ant-design/icons/CopyOutlined';
5
- import DeleteOutlined from '@ant-design/icons/DeleteOutlined';
6
- import PlusCircleOutlined from '@ant-design/icons/PlusCircleOutlined';
7
- import CloseOutlined from '@ant-design/icons/CloseOutlined';
2
+ import {
3
+ ArrowDownOutlined,
4
+ ArrowUpOutlined,
5
+ CopyOutlined,
6
+ DeleteOutlined,
7
+ PlusCircleOutlined,
8
+ CloseOutlined,
9
+ } from '@ant-design/icons';
8
10
  import {
9
11
  getUiOptions,
10
12
  FormContextType,
@@ -90,6 +90,7 @@ export default function WrapIfAdditionalTemplate<
90
90
  wrapperCol={wrapperCol}
91
91
  >
92
92
  <Input
93
+ key={label}
93
94
  className='form-control'
94
95
  defaultValue={label}
95
96
  disabled={disabled || (readonlyAsDisabled && readonly)}
@@ -2,8 +2,10 @@ import { FocusEvent } from 'react';
2
2
  import { Checkbox } from 'antd';
3
3
  import {
4
4
  ariaDescribedByIds,
5
- enumOptionsIndexForValue,
6
- enumOptionsValueForIndex,
5
+ enumOptionSelectedValue,
6
+ enumOptionValueDecoder,
7
+ enumOptionValueEncoder,
8
+ getOptionValueFormat,
7
9
  optionId,
8
10
  FormContextType,
9
11
  WidgetProps,
@@ -38,14 +40,16 @@ export default function CheckboxesWidget<
38
40
  const { readonlyAsDisabled = true } = formContext as GenericObjectType;
39
41
 
40
42
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
43
+ const optionValueFormat = getOptionValueFormat(options);
41
44
 
42
- const handleChange = (nextValue: any) => onChange(enumOptionsValueForIndex<S>(nextValue, enumOptions, emptyValue));
45
+ const handleChange = (nextValue: any) =>
46
+ onChange(enumOptionValueDecoder<S>(nextValue, enumOptions, optionValueFormat, emptyValue));
43
47
 
44
48
  const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
45
- onBlur(id, enumOptionsValueForIndex<S>(target.value, enumOptions, emptyValue));
49
+ onBlur(id, enumOptionValueDecoder<S>(target.value, enumOptions, optionValueFormat, emptyValue));
46
50
 
47
51
  const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
48
- onFocus(id, enumOptionsValueForIndex<S>(target.value, enumOptions, emptyValue));
52
+ onFocus(id, enumOptionValueDecoder<S>(target.value, enumOptions, optionValueFormat, emptyValue));
49
53
 
50
54
  // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
51
55
  // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
@@ -55,7 +59,7 @@ export default function CheckboxesWidget<
55
59
  onFocus: !readonly ? handleFocus : undefined,
56
60
  };
57
61
 
58
- const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, true) as string[];
62
+ const selectValue = enumOptionSelectedValue<S>(value, enumOptions, true, optionValueFormat, []) as string[];
59
63
 
60
64
  return Array.isArray(enumOptions) && enumOptions.length > 0 ? (
61
65
  <>
@@ -63,7 +67,7 @@ export default function CheckboxesWidget<
63
67
  disabled={disabled || (readonlyAsDisabled && readonly)}
64
68
  name={htmlName || id}
65
69
  onChange={!readonly ? handleChange : undefined}
66
- value={selectedIndexes}
70
+ value={selectValue}
67
71
  {...extraProps}
68
72
  aria-describedby={ariaDescribedByIds(id)}
69
73
  >
@@ -75,7 +79,7 @@ export default function CheckboxesWidget<
75
79
  name={htmlName || id}
76
80
  autoFocus={i === 0 ? autofocus : false}
77
81
  disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1}
78
- value={String(i)}
82
+ value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
79
83
  >
80
84
  {option.label}
81
85
  </Checkbox>
@@ -2,8 +2,10 @@ import { FocusEvent } from 'react';
2
2
  import { Radio, RadioChangeEvent } from 'antd';
3
3
  import {
4
4
  ariaDescribedByIds,
5
- enumOptionsIndexForValue,
6
- enumOptionsValueForIndex,
5
+ enumOptionSelectedValue,
6
+ enumOptionValueDecoder,
7
+ enumOptionValueEncoder,
8
+ getOptionValueFormat,
7
9
  optionId,
8
10
  FormContextType,
9
11
  GenericObjectType,
@@ -34,17 +36,18 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
34
36
  const { readonlyAsDisabled = true } = formContext as GenericObjectType;
35
37
 
36
38
  const { enumOptions, enumDisabled, emptyValue } = options;
39
+ const optionValueFormat = getOptionValueFormat(options);
37
40
 
38
41
  const handleChange = ({ target: { value: nextValue } }: RadioChangeEvent) =>
39
- onChange(enumOptionsValueForIndex<S>(nextValue, enumOptions, emptyValue));
42
+ onChange(enumOptionValueDecoder<S>(nextValue, enumOptions, optionValueFormat, emptyValue));
40
43
 
41
44
  const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
42
- onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
45
+ onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
43
46
 
44
47
  const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
45
- onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
48
+ onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
46
49
 
47
- const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions) as string;
50
+ const selectValue = enumOptionSelectedValue<S>(value, enumOptions, false, optionValueFormat, emptyValue);
48
51
 
49
52
  return (
50
53
  <Radio.Group
@@ -54,7 +57,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
54
57
  onChange={!readonly ? handleChange : undefined}
55
58
  onBlur={!readonly ? handleBlur : undefined}
56
59
  onFocus={!readonly ? handleFocus : undefined}
57
- value={selectedIndexes}
60
+ value={selectValue}
58
61
  aria-describedby={ariaDescribedByIds(id)}
59
62
  >
60
63
  {Array.isArray(enumOptions) &&
@@ -65,7 +68,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
65
68
  autoFocus={i === 0 ? autofocus : false}
66
69
  disabled={disabled || (Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1)}
67
70
  key={i}
68
- value={String(i)}
71
+ value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
69
72
  >
70
73
  {option.label}
71
74
  </Radio>
@@ -2,8 +2,10 @@ import { useMemo, useState } from 'react';
2
2
  import { Select, SelectProps } from 'antd';
3
3
  import {
4
4
  ariaDescribedByIds,
5
- enumOptionsIndexForValue,
6
- enumOptionsValueForIndex,
5
+ enumOptionSelectedValue,
6
+ enumOptionValueDecoder,
7
+ enumOptionValueEncoder,
8
+ getOptionValueFormat,
7
9
  FormContextType,
8
10
  GenericObjectType,
9
11
  RJSFSchema,
@@ -47,12 +49,14 @@ export default function SelectWidget<
47
49
  const { readonlyAsDisabled = true } = formContext as GenericObjectType;
48
50
 
49
51
  const { enumOptions, enumDisabled, emptyValue } = options;
52
+ const optionValueFormat = getOptionValueFormat(options);
50
53
 
51
- const handleChange = (nextValue: any) => onChange(enumOptionsValueForIndex<S>(nextValue, enumOptions, emptyValue));
54
+ const handleChange = (nextValue: any) =>
55
+ onChange(enumOptionValueDecoder<S>(nextValue, enumOptions, optionValueFormat, emptyValue));
52
56
 
53
- const handleBlur = () => onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
57
+ const handleBlur = () => onBlur(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
54
58
 
55
- const handleFocus = () => onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
59
+ const handleFocus = () => onFocus(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
56
60
 
57
61
  const filterOption: SelectProps['filterOption'] = (input, option) => {
58
62
  if (option && isString(option.label)) {
@@ -64,7 +68,7 @@ export default function SelectWidget<
64
68
 
65
69
  const getPopupContainer = SelectWidget.getPopupContainerCallback();
66
70
 
67
- const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
71
+ const selectValue = enumOptionSelectedValue<S>(value, enumOptions, !!multiple, optionValueFormat, emptyValue);
68
72
 
69
73
  // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
70
74
  // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
@@ -79,7 +83,7 @@ export default function SelectWidget<
79
83
  const options: DefaultOptionType[] = enumOptions.map(({ value: optionValue, label: optionLabel }, index) => ({
80
84
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
81
85
  key: String(index),
82
- value: String(index),
86
+ value: enumOptionValueEncoder(optionValue, index, optionValueFormat),
83
87
  label: optionLabel,
84
88
  }));
85
89
 
@@ -89,7 +93,7 @@ export default function SelectWidget<
89
93
  return options;
90
94
  }
91
95
  return undefined;
92
- }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
96
+ }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
93
97
 
94
98
  return (
95
99
  <Select
@@ -104,7 +108,7 @@ export default function SelectWidget<
104
108
  onFocus={!readonly ? handleFocus : undefined}
105
109
  placeholder={placeholder}
106
110
  style={SELECT_STYLE}
107
- value={selectedIndexes}
111
+ value={selectValue}
108
112
  {...extraProps}
109
113
  // When the open change is called, set the open state, needed so that the select opens properly in the playground
110
114
  onOpenChange={setOpen}