@rjsf/antd 6.6.1 → 6.6.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.
Files changed (111) hide show
  1. package/dist/antd.esm.js +79 -136
  2. package/dist/antd.esm.js.map +4 -4
  3. package/dist/antd.umd.js +55 -63
  4. package/dist/index.cjs +80 -91
  5. package/dist/index.cjs.map +4 -4
  6. package/lib/index.d.ts +3 -3
  7. package/lib/index.js.map +1 -1
  8. package/lib/templates/ArrayFieldItemTemplate/index.d.ts +1 -1
  9. package/lib/templates/ArrayFieldItemTemplate/index.js +1 -1
  10. package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -1
  11. package/lib/templates/ArrayFieldTemplate/index.d.ts +1 -1
  12. package/lib/templates/ArrayFieldTemplate/index.js +1 -1
  13. package/lib/templates/ArrayFieldTemplate/index.js.map +1 -1
  14. package/lib/templates/BaseInputTemplate/index.d.ts +1 -1
  15. package/lib/templates/BaseInputTemplate/index.js +3 -4
  16. package/lib/templates/BaseInputTemplate/index.js.map +1 -1
  17. package/lib/templates/ErrorList/index.d.ts +1 -1
  18. package/lib/templates/ErrorList/index.js +2 -2
  19. package/lib/templates/ErrorList/index.js.map +1 -1
  20. package/lib/templates/FieldDescriptionTemplate/index.d.ts +1 -1
  21. package/lib/templates/FieldErrorTemplate/index.d.ts +1 -1
  22. package/lib/templates/FieldErrorTemplate/index.js.map +1 -1
  23. package/lib/templates/FieldHelpTemplate/index.d.ts +1 -1
  24. package/lib/templates/FieldHelpTemplate/index.js.map +1 -1
  25. package/lib/templates/FieldTemplate/index.d.ts +1 -1
  26. package/lib/templates/FieldTemplate/index.js +1 -1
  27. package/lib/templates/FieldTemplate/index.js.map +1 -1
  28. package/lib/templates/GridTemplate/index.d.ts +1 -1
  29. package/lib/templates/IconButton/index.d.ts +2 -2
  30. package/lib/templates/IconButton/index.js +1 -1
  31. package/lib/templates/IconButton/index.js.map +1 -1
  32. package/lib/templates/MultiSchemaFieldTemplate/index.d.ts +1 -1
  33. package/lib/templates/ObjectFieldTemplate/index.d.ts +1 -1
  34. package/lib/templates/ObjectFieldTemplate/index.js +1 -1
  35. package/lib/templates/ObjectFieldTemplate/index.js.map +1 -1
  36. package/lib/templates/OptionalDataControlsTemplate/index.d.ts +1 -1
  37. package/lib/templates/OptionalDataControlsTemplate/index.js +1 -1
  38. package/lib/templates/OptionalDataControlsTemplate/index.js.map +1 -1
  39. package/lib/templates/SubmitButton/index.d.ts +1 -1
  40. package/lib/templates/SubmitButton/index.js.map +1 -1
  41. package/lib/templates/TitleField/index.d.ts +1 -1
  42. package/lib/templates/TitleField/index.js +4 -1
  43. package/lib/templates/TitleField/index.js.map +1 -1
  44. package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +1 -1
  45. package/lib/templates/WrapIfAdditionalTemplate/index.js +1 -1
  46. package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -1
  47. package/lib/templates/index.d.ts +1 -1
  48. package/lib/tsconfig.tsbuildinfo +1 -1
  49. package/lib/widgets/AltDateTimeWidget/index.d.ts +1 -1
  50. package/lib/widgets/AltDateWidget/index.d.ts +1 -1
  51. package/lib/widgets/AltDateWidget/index.js +1 -1
  52. package/lib/widgets/AltDateWidget/index.js.map +1 -1
  53. package/lib/widgets/CheckboxWidget/index.d.ts +1 -1
  54. package/lib/widgets/CheckboxWidget/index.js +1 -1
  55. package/lib/widgets/CheckboxWidget/index.js.map +1 -1
  56. package/lib/widgets/CheckboxesWidget/index.d.ts +1 -1
  57. package/lib/widgets/CheckboxesWidget/index.js +3 -3
  58. package/lib/widgets/CheckboxesWidget/index.js.map +1 -1
  59. package/lib/widgets/DateTimeWidget/index.d.ts +3 -3
  60. package/lib/widgets/DateTimeWidget/index.js +4 -16
  61. package/lib/widgets/DateTimeWidget/index.js.map +1 -1
  62. package/lib/widgets/DateWidget/index.d.ts +9 -2
  63. package/lib/widgets/DateWidget/index.js +10 -6
  64. package/lib/widgets/DateWidget/index.js.map +1 -1
  65. package/lib/widgets/PasswordWidget/index.d.ts +1 -1
  66. package/lib/widgets/PasswordWidget/index.js +1 -1
  67. package/lib/widgets/PasswordWidget/index.js.map +1 -1
  68. package/lib/widgets/RadioWidget/index.d.ts +1 -1
  69. package/lib/widgets/RadioWidget/index.js +1 -1
  70. package/lib/widgets/RadioWidget/index.js.map +1 -1
  71. package/lib/widgets/RangeWidget/index.d.ts +1 -1
  72. package/lib/widgets/RangeWidget/index.js +1 -1
  73. package/lib/widgets/RangeWidget/index.js.map +1 -1
  74. package/lib/widgets/SelectWidget/index.d.ts +1 -1
  75. package/lib/widgets/SelectWidget/index.js +6 -6
  76. package/lib/widgets/SelectWidget/index.js.map +1 -1
  77. package/lib/widgets/TextareaWidget/index.d.ts +1 -1
  78. package/lib/widgets/TextareaWidget/index.js +1 -1
  79. package/lib/widgets/TextareaWidget/index.js.map +1 -1
  80. package/lib/widgets/index.d.ts +1 -1
  81. package/package.json +7 -7
  82. package/src/index.ts +4 -3
  83. package/src/templates/ArrayFieldItemTemplate/index.tsx +2 -8
  84. package/src/templates/ArrayFieldTemplate/index.tsx +2 -4
  85. package/src/templates/BaseInputTemplate/index.tsx +7 -8
  86. package/src/templates/ErrorList/index.tsx +4 -2
  87. package/src/templates/FieldDescriptionTemplate/index.tsx +1 -1
  88. package/src/templates/FieldErrorTemplate/index.tsx +2 -1
  89. package/src/templates/FieldHelpTemplate/index.tsx +2 -1
  90. package/src/templates/FieldTemplate/index.tsx +2 -9
  91. package/src/templates/GridTemplate/index.tsx +1 -1
  92. package/src/templates/IconButton/index.tsx +5 -10
  93. package/src/templates/MultiSchemaFieldTemplate/index.tsx +1 -1
  94. package/src/templates/ObjectFieldTemplate/index.tsx +2 -6
  95. package/src/templates/OptionalDataControlsTemplate/index.tsx +3 -2
  96. package/src/templates/SubmitButton/index.tsx +4 -2
  97. package/src/templates/TitleField/index.tsx +5 -1
  98. package/src/templates/WrapIfAdditionalTemplate/index.tsx +2 -10
  99. package/src/templates/index.ts +1 -1
  100. package/src/widgets/AltDateTimeWidget/index.tsx +1 -1
  101. package/src/widgets/AltDateWidget/index.tsx +2 -10
  102. package/src/widgets/CheckboxWidget/index.tsx +5 -11
  103. package/src/widgets/CheckboxesWidget/index.tsx +27 -32
  104. package/src/widgets/DateTimeWidget/index.tsx +5 -43
  105. package/src/widgets/DateWidget/index.tsx +28 -15
  106. package/src/widgets/PasswordWidget/index.tsx +3 -9
  107. package/src/widgets/RadioWidget/index.tsx +6 -9
  108. package/src/widgets/RangeWidget/index.tsx +2 -9
  109. package/src/widgets/SelectWidget/index.tsx +16 -17
  110. package/src/widgets/TextareaWidget/index.tsx +3 -9
  111. package/src/widgets/index.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
 
3
3
  export default function MultiSchemaFieldTemplate<
4
4
  T = any,
@@ -1,5 +1,5 @@
1
1
  import { useContext } from 'react';
2
- import {
2
+ import type {
3
3
  FormContextType,
4
4
  GenericObjectType,
5
5
  ObjectFieldTemplateProps,
@@ -7,12 +7,8 @@ import {
7
7
  RJSFSchema,
8
8
  StrictRJSFSchema,
9
9
  UiSchema,
10
- canExpand,
11
- getTemplate,
12
- getUiOptions,
13
- titleId,
14
- buttonId,
15
10
  } from '@rjsf/utils';
11
+ import { canExpand, getTemplate, getUiOptions, titleId, buttonId } from '@rjsf/utils';
16
12
  import { Col, Row, ConfigProvider } from 'antd';
17
13
  import classNames from 'classnames';
18
14
  import isNumber from 'lodash/isNumber';
@@ -1,4 +1,4 @@
1
- import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
 
3
3
  import { AddButton, RemoveButton } from '../IconButton';
4
4
 
@@ -29,7 +29,8 @@ export default function OptionalDataControlsTemplate<
29
29
  block={false}
30
30
  />
31
31
  );
32
- } else if (onRemoveClick) {
32
+ }
33
+ if (onRemoveClick) {
33
34
  return (
34
35
  <RemoveButton
35
36
  id={id}
@@ -1,5 +1,7 @@
1
- import { getSubmitButtonOptions, FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
2
- import { Button, ButtonProps } from 'antd';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
2
+ import { getSubmitButtonOptions } from '@rjsf/utils';
3
+ import type { ButtonProps } from 'antd';
4
+ import { Button } from 'antd';
3
5
 
4
6
  type ButtonType = NonNullable<ButtonProps['type']>;
5
7
 
@@ -1,5 +1,5 @@
1
1
  import { useContext } from 'react';
2
- import { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import type { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
3
  import { Col, Divider, Row, ConfigProvider } from 'antd';
4
4
  import classNames from 'classnames';
5
5
 
@@ -39,11 +39,15 @@ export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSch
39
39
  [`${prefixCls}-item-required`]: required,
40
40
  [`${prefixCls}-item-no-colon`]: !colon,
41
41
  });
42
+ // The antd theme, for some reason, made its labels cause the associated field to get the focus when clicked (which
43
+ // kinda breaks a11y), but since it's built that way we will honor it until we decided to break it in a major release
44
+ // oxlint-disable jsx-a11y/no-noninteractive-element-interactions -- <label> is interactive; oxlint incorrectly flags it
42
45
  let heading = title ? (
43
46
  <label
44
47
  className={labelClassName}
45
48
  htmlFor={id}
46
49
  onClick={handleLabelClick}
50
+ onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && handleLabelClick()}
47
51
  title={typeof title === 'string' ? title : ''}
48
52
  >
49
53
  {labelChildren}
@@ -1,13 +1,5 @@
1
- import {
2
- ADDITIONAL_PROPERTY_FLAG,
3
- UI_OPTIONS_KEY,
4
- FormContextType,
5
- RJSFSchema,
6
- StrictRJSFSchema,
7
- TranslatableString,
8
- WrapIfAdditionalTemplateProps,
9
- buttonId,
10
- } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
2
+ import { ADDITIONAL_PROPERTY_FLAG, UI_OPTIONS_KEY, TranslatableString, buttonId } from '@rjsf/utils';
11
3
  import { Col, Row, Form, Input } from 'antd';
12
4
 
13
5
  const VERTICAL_LABEL_COL = { span: 24 };
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
2
2
 
3
3
  import ArrayFieldItemTemplate from './ArrayFieldItemTemplate';
4
4
  import ArrayFieldTemplate from './ArrayFieldTemplate';
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
2
 
3
3
  export default function AltDateTimeWidget<
4
4
  T = any,
@@ -1,13 +1,5 @@
1
- import {
2
- DateElement,
3
- FormContextType,
4
- GenericObjectType,
5
- RJSFSchema,
6
- StrictRJSFSchema,
7
- TranslatableString,
8
- useAltDateWidgetProps,
9
- WidgetProps,
10
- } from '@rjsf/utils';
1
+ import type { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { DateElement, TranslatableString, useAltDateWidgetProps } from '@rjsf/utils';
11
3
  import { Row, Col, Button } from 'antd';
12
4
 
13
5
  export default function AltDateWidget<
@@ -1,14 +1,8 @@
1
- import { FocusEvent } from 'react';
2
- import {
3
- ariaDescribedByIds,
4
- labelValue,
5
- FormContextType,
6
- RJSFSchema,
7
- StrictRJSFSchema,
8
- WidgetProps,
9
- GenericObjectType,
10
- } from '@rjsf/utils';
11
- import { Checkbox, CheckboxProps } from 'antd';
1
+ import type { FocusEvent } from 'react';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType } from '@rjsf/utils';
3
+ import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
4
+ import type { CheckboxProps } from 'antd';
5
+ import { Checkbox } from 'antd';
12
6
 
13
7
  /** The `CheckBoxWidget` is a widget for rendering boolean properties.
14
8
  * It is typically used to represent a boolean.
@@ -1,4 +1,5 @@
1
- import { FocusEvent } from 'react';
1
+ import type { FocusEvent } from 'react';
2
+ import type { FormContextType, WidgetProps, RJSFSchema, StrictRJSFSchema, GenericObjectType } from '@rjsf/utils';
2
3
  import {
3
4
  ariaDescribedByIds,
4
5
  enumOptionSelectedValue,
@@ -6,11 +7,6 @@ import {
6
7
  enumOptionValueEncoder,
7
8
  getOptionValueFormat,
8
9
  optionId,
9
- FormContextType,
10
- WidgetProps,
11
- RJSFSchema,
12
- StrictRJSFSchema,
13
- GenericObjectType,
14
10
  } from '@rjsf/utils';
15
11
  import { Checkbox } from 'antd';
16
12
 
@@ -62,31 +58,30 @@ export default function CheckboxesWidget<
62
58
  const selectValue = enumOptionSelectedValue<S>(value, enumOptions, true, optionValueFormat, []) as string[];
63
59
 
64
60
  return Array.isArray(enumOptions) && enumOptions.length > 0 ? (
65
- <>
66
- <Checkbox.Group
67
- disabled={disabled || (readonlyAsDisabled && readonly)}
68
- name={htmlName || id}
69
- onChange={!readonly ? handleChange : undefined}
70
- value={selectValue}
71
- {...extraProps}
72
- aria-describedby={ariaDescribedByIds(id)}
73
- >
74
- {Array.isArray(enumOptions) &&
75
- enumOptions.map((option, i) => (
76
- <span key={i}>
77
- <Checkbox
78
- id={optionId(id, i)}
79
- name={htmlName || id}
80
- autoFocus={i === 0 ? autofocus : false}
81
- disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1}
82
- value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
83
- >
84
- {option.label}
85
- </Checkbox>
86
- {!inline && <br />}
87
- </span>
88
- ))}
89
- </Checkbox.Group>
90
- </>
61
+ <Checkbox.Group
62
+ disabled={disabled || (readonlyAsDisabled && readonly)}
63
+ name={htmlName || id}
64
+ onChange={!readonly ? handleChange : undefined}
65
+ value={selectValue}
66
+ {...extraProps}
67
+ aria-describedby={ariaDescribedByIds(id)}
68
+ >
69
+ {Array.isArray(enumOptions) &&
70
+ enumOptions.map((option, i) => (
71
+ // oxlint-disable-next-line react/no-array-index-key
72
+ <span key={i}>
73
+ <Checkbox
74
+ id={optionId(id, i)}
75
+ name={htmlName || id}
76
+ autoFocus={i === 0 ? autofocus : false}
77
+ disabled={Array.isArray(enumDisabled) && enumDisabled.includes(option.value)}
78
+ value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
79
+ >
80
+ {option.label}
81
+ </Checkbox>
82
+ {!inline && <br />}
83
+ </span>
84
+ ))}
85
+ </Checkbox.Group>
91
86
  ) : null;
92
87
  }
@@ -1,20 +1,9 @@
1
- import {
2
- ariaDescribedByIds,
3
- FormContextType,
4
- GenericObjectType,
5
- RJSFSchema,
6
- StrictRJSFSchema,
7
- WidgetProps,
8
- } from '@rjsf/utils';
9
- import { DatePicker } from 'antd';
10
- import dayjs from 'dayjs';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
11
2
 
12
- const DATE_PICKER_STYLE = {
13
- width: '100%',
14
- };
3
+ import DateWidget from '../DateWidget';
15
4
 
16
- /** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
17
- * the value to/from utc using the appropriate utility functions.
5
+ /** The `DateTimeWidget` component uses the `DateWidget` with `showTime` enabled, transforming
6
+ * the value to/from ISO string format.
18
7
  *
19
8
  * @param props - The `WidgetProps` for this component
20
9
  */
@@ -23,32 +12,5 @@ export default function DateTimeWidget<
23
12
  S extends StrictRJSFSchema = RJSFSchema,
24
13
  F extends FormContextType = any,
25
14
  >(props: WidgetProps<T, S, F>) {
26
- const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
27
- const { formContext } = registry;
28
- const { readonlyAsDisabled = true } = formContext as GenericObjectType;
29
-
30
- const handleChange = (nextValue: any) => onChange(nextValue && nextValue.toISOString());
31
-
32
- const handleBlur = () => onBlur(id, value);
33
-
34
- const handleFocus = () => onFocus(id, value);
35
-
36
- const getPopupContainer = (node: any) => node.parentNode;
37
-
38
- return (
39
- <DatePicker
40
- disabled={disabled || (readonlyAsDisabled && readonly)}
41
- getPopupContainer={getPopupContainer}
42
- id={id}
43
- name={id}
44
- onBlur={!readonly ? handleBlur : undefined}
45
- onChange={!readonly ? handleChange : undefined}
46
- onFocus={!readonly ? handleFocus : undefined}
47
- placeholder={placeholder}
48
- showTime
49
- style={DATE_PICKER_STYLE}
50
- value={value && dayjs(value)}
51
- aria-describedby={ariaDescribedByIds(id)}
52
- />
53
- );
15
+ return <DateWidget showTime {...props} />;
54
16
  }
@@ -1,11 +1,5 @@
1
- import {
2
- ariaDescribedByIds,
3
- FormContextType,
4
- RJSFSchema,
5
- StrictRJSFSchema,
6
- WidgetProps,
7
- GenericObjectType,
8
- } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType } from '@rjsf/utils';
2
+ import { ariaDescribedByIds } from '@rjsf/utils';
9
3
  import { DatePicker } from 'antd';
10
4
  import dayjs from 'dayjs';
11
5
 
@@ -13,25 +7,38 @@ const DATE_PICKER_STYLE = {
13
7
  width: '100%',
14
8
  };
15
9
 
10
+ type DateWidgetProps<T, S extends StrictRJSFSchema, F extends FormContextType> = WidgetProps<T, S, F> & {
11
+ showTime?: boolean;
12
+ };
13
+
16
14
  /** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
17
15
  * the value to undefined when it is falsy during the `onChange` handling.
18
16
  *
19
17
  * @param props - The `WidgetProps` for this component
20
18
  */
21
- export default function DateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
22
- props: WidgetProps<T, S, F>,
23
- ) {
24
- const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
19
+ export default function DateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
20
+ disabled,
21
+ registry,
22
+ id,
23
+ onBlur,
24
+ onChange,
25
+ onFocus,
26
+ placeholder,
27
+ readonly,
28
+ value,
29
+ showTime = false,
30
+ }: DateWidgetProps<T, S, F>) {
25
31
  const { formContext } = registry;
26
32
  const { readonlyAsDisabled = true } = formContext as GenericObjectType;
27
33
 
28
- const handleChange = (nextValue: any) => onChange(nextValue && nextValue.format('YYYY-MM-DD'));
34
+ const handleChange = (nextValue: any) =>
35
+ onChange(nextValue && (showTime ? nextValue.toISOString() : nextValue.format('YYYY-MM-DD')));
29
36
 
30
37
  const handleBlur = () => onBlur(id, value);
31
38
 
32
39
  const handleFocus = () => onFocus(id, value);
33
40
 
34
- const getPopupContainer = (node: any) => node.parentNode;
41
+ const getPopupContainer = DateWidget.getPopupContainerCallback();
35
42
 
36
43
  return (
37
44
  <DatePicker
@@ -43,10 +50,16 @@ export default function DateWidget<T = any, S extends StrictRJSFSchema = RJSFSch
43
50
  onChange={!readonly ? handleChange : undefined}
44
51
  onFocus={!readonly ? handleFocus : undefined}
45
52
  placeholder={placeholder}
46
- showTime={false}
53
+ showTime={showTime}
47
54
  style={DATE_PICKER_STYLE}
48
55
  value={value && dayjs(value)}
49
56
  aria-describedby={ariaDescribedByIds(id)}
50
57
  />
51
58
  );
52
59
  }
60
+
61
+ /** Give the playground a place to hook into the `getPopupContainer` callback generation function so that it can be
62
+ * disabled while in the playground. Since the callback is a simple function, it can be returned by this static
63
+ * "generator" function.
64
+ */
65
+ DateWidget.getPopupContainerCallback = () => (node: any) => node.parentNode;
@@ -1,12 +1,6 @@
1
- import { ChangeEvent, FocusEvent } from 'react';
2
- import {
3
- ariaDescribedByIds,
4
- FormContextType,
5
- RJSFSchema,
6
- StrictRJSFSchema,
7
- WidgetProps,
8
- GenericObjectType,
9
- } from '@rjsf/utils';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType } from '@rjsf/utils';
3
+ import { ariaDescribedByIds } from '@rjsf/utils';
10
4
  import { Input } from 'antd';
11
5
 
12
6
  /** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
@@ -1,4 +1,5 @@
1
- import { FocusEvent } from 'react';
1
+ import type { FocusEvent } from 'react';
2
+ import type { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
3
  import {
3
4
  ariaDescribedByIds,
4
5
  enumOptionSelectedValue,
@@ -6,13 +7,9 @@ import {
6
7
  enumOptionValueEncoder,
7
8
  getOptionValueFormat,
8
9
  optionId,
9
- FormContextType,
10
- GenericObjectType,
11
- RJSFSchema,
12
- StrictRJSFSchema,
13
- WidgetProps,
14
10
  } from '@rjsf/utils';
15
- import { Radio, RadioChangeEvent } from 'antd';
11
+ import type { RadioChangeEvent } from 'antd';
12
+ import { Radio } from 'antd';
16
13
 
17
14
  /** The `RadioWidget` is a widget for rendering a radio group.
18
15
  * It is typically used with a string property constrained with enum options.
@@ -66,8 +63,8 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
66
63
  id={optionId(id, i)}
67
64
  name={htmlName || id}
68
65
  autoFocus={i === 0 ? autofocus : false}
69
- disabled={disabled || (Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1)}
70
- key={i}
66
+ disabled={disabled || (Array.isArray(enumDisabled) && enumDisabled.includes(option.value))}
67
+ key={String(option.value)}
71
68
  value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
72
69
  >
73
70
  {option.label}
@@ -1,12 +1,5 @@
1
- import {
2
- ariaDescribedByIds,
3
- rangeSpec,
4
- FormContextType,
5
- RJSFSchema,
6
- StrictRJSFSchema,
7
- WidgetProps,
8
- GenericObjectType,
9
- } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType } from '@rjsf/utils';
2
+ import { ariaDescribedByIds, rangeSpec } from '@rjsf/utils';
10
3
  import { Slider } from 'antd';
11
4
 
12
5
  /** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
@@ -1,18 +1,15 @@
1
1
  import { useMemo, useState } from 'react';
2
+ import type { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
3
  import {
3
4
  ariaDescribedByIds,
4
5
  enumOptionSelectedValue,
5
6
  enumOptionValueDecoder,
6
7
  enumOptionValueEncoder,
7
8
  getOptionValueFormat,
8
- FormContextType,
9
- GenericObjectType,
10
- RJSFSchema,
11
- StrictRJSFSchema,
12
- WidgetProps,
13
9
  } from '@rjsf/utils';
14
- import { Select, SelectProps } from 'antd';
15
- import { DefaultOptionType } from 'antd/es/select';
10
+ import type { SelectProps } from 'antd';
11
+ import { Select } from 'antd';
12
+ import type { DefaultOptionType } from 'antd/es/select';
16
13
  import isString from 'lodash/isString';
17
14
 
18
15
  const SELECT_STYLE = {
@@ -61,7 +58,7 @@ export default function SelectWidget<
61
58
  const filterOption: SelectProps['filterOption'] = (input, option) => {
62
59
  if (option && isString(option.label)) {
63
60
  // labels are strings in this context
64
- return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
61
+ return option.label.toLowerCase().includes(input.toLowerCase());
65
62
  }
66
63
  return false;
67
64
  };
@@ -80,17 +77,19 @@ export default function SelectWidget<
80
77
 
81
78
  const selectOptions: DefaultOptionType[] | undefined = useMemo(() => {
82
79
  if (Array.isArray(enumOptions)) {
83
- const options: DefaultOptionType[] = enumOptions.map(({ value: optionValue, label: optionLabel }, index) => ({
84
- disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
85
- key: String(index),
86
- value: enumOptionValueEncoder(optionValue, index, optionValueFormat),
87
- label: optionLabel,
88
- }));
80
+ const enumOptionsList: DefaultOptionType[] = enumOptions.map(
81
+ ({ value: optionValue, label: optionLabel }, index) => ({
82
+ disabled: Array.isArray(enumDisabled) && enumDisabled.includes(optionValue),
83
+ key: String(index),
84
+ value: enumOptionValueEncoder(optionValue, index, optionValueFormat),
85
+ label: optionLabel,
86
+ }),
87
+ );
89
88
 
90
89
  if (showPlaceholderOption) {
91
- options.unshift({ value: '', label: placeholder || '' });
90
+ enumOptionsList.unshift({ value: '', label: placeholder || '' });
92
91
  }
93
- return options;
92
+ return enumOptionsList;
94
93
  }
95
94
  return undefined;
96
95
  }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
@@ -112,7 +111,7 @@ export default function SelectWidget<
112
111
  {...extraProps}
113
112
  // When the open change is called, set the open state, needed so that the select opens properly in the playground
114
113
  onOpenChange={setOpen}
115
- filterOption={filterOption}
114
+ showSearch={{ filterOption }}
116
115
  aria-describedby={ariaDescribedByIds(id)}
117
116
  options={selectOptions}
118
117
  />
@@ -1,12 +1,6 @@
1
- import { ChangeEvent, FocusEvent } from 'react';
2
- import {
3
- ariaDescribedByIds,
4
- FormContextType,
5
- GenericObjectType,
6
- RJSFSchema,
7
- StrictRJSFSchema,
8
- WidgetProps,
9
- } from '@rjsf/utils';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
+ import type { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
+ import { ariaDescribedByIds } from '@rjsf/utils';
10
4
  import { Input } from 'antd';
11
5
 
12
6
  const INPUT_STYLE = {
@@ -1,4 +1,4 @@
1
- import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
 
3
3
  import AltDateTimeWidget from './AltDateTimeWidget';
4
4
  import AltDateWidget from './AltDateWidget';