@rjsf/antd 5.11.2 → 5.12.1

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 (124) hide show
  1. package/dist/antd.esm.js +891 -1117
  2. package/dist/antd.esm.js.map +7 -1
  3. package/dist/antd.umd.js +1184 -0
  4. package/dist/index.js +1347 -5
  5. package/dist/index.js.map +7 -0
  6. package/lib/components/DatePicker/index.d.ts +48 -0
  7. package/lib/components/DatePicker/index.js +5 -0
  8. package/lib/components/DatePicker/index.js.map +1 -0
  9. package/lib/index.d.ts +11 -0
  10. package/lib/index.js +17 -0
  11. package/lib/index.js.map +1 -0
  12. package/lib/templates/ArrayFieldItemTemplate/index.d.ts +7 -0
  13. package/lib/templates/ArrayFieldItemTemplate/index.js +21 -0
  14. package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -0
  15. package/lib/templates/ArrayFieldTemplate/index.d.ts +7 -0
  16. package/lib/templates/ArrayFieldTemplate/index.js +38 -0
  17. package/lib/templates/ArrayFieldTemplate/index.js.map +1 -0
  18. package/lib/templates/BaseInputTemplate/index.d.ts +9 -0
  19. package/lib/templates/BaseInputTemplate/index.js +31 -0
  20. package/lib/templates/BaseInputTemplate/index.js.map +1 -0
  21. package/lib/templates/DescriptionField/index.d.ts +7 -0
  22. package/lib/templates/DescriptionField/index.js +13 -0
  23. package/lib/templates/DescriptionField/index.js.map +1 -0
  24. package/lib/templates/ErrorList/index.d.ts +7 -0
  25. package/lib/templates/ErrorList/index.js +16 -0
  26. package/lib/templates/ErrorList/index.js.map +1 -0
  27. package/lib/templates/FieldErrorTemplate/index.d.ts +7 -0
  28. package/lib/templates/FieldErrorTemplate/index.js +15 -0
  29. package/lib/templates/FieldErrorTemplate/index.js.map +1 -0
  30. package/lib/templates/FieldTemplate/index.d.ts +8 -0
  31. package/lib/templates/FieldTemplate/index.js +34 -0
  32. package/lib/templates/FieldTemplate/index.js.map +1 -0
  33. package/lib/templates/IconButton/index.d.ts +10 -0
  34. package/lib/templates/IconButton/index.js +36 -0
  35. package/lib/templates/IconButton/index.js.map +1 -0
  36. package/lib/templates/ObjectFieldTemplate/index.d.ts +9 -0
  37. package/lib/templates/ObjectFieldTemplate/index.js +71 -0
  38. package/lib/templates/ObjectFieldTemplate/index.js.map +1 -0
  39. package/lib/templates/SubmitButton/index.d.ts +5 -0
  40. package/lib/templates/SubmitButton/index.js +13 -0
  41. package/lib/templates/SubmitButton/index.js.map +1 -0
  42. package/lib/templates/TitleField/index.d.ts +7 -0
  43. package/lib/templates/TitleField/index.js +34 -0
  44. package/lib/templates/TitleField/index.js.map +1 -0
  45. package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +8 -0
  46. package/lib/templates/WrapIfAdditionalTemplate/index.js +34 -0
  47. package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -0
  48. package/lib/templates/index.d.ts +4 -0
  49. package/lib/templates/index.js +36 -0
  50. package/lib/templates/index.js.map +1 -0
  51. package/lib/widgets/AltDateTimeWidget/index.d.ts +15 -0
  52. package/lib/widgets/AltDateTimeWidget/index.js +8 -0
  53. package/lib/widgets/AltDateTimeWidget/index.js.map +1 -0
  54. package/lib/widgets/AltDateWidget/index.d.ts +15 -0
  55. package/lib/widgets/AltDateWidget/index.js +89 -0
  56. package/lib/widgets/AltDateWidget/index.js.map +1 -0
  57. package/lib/widgets/CheckboxWidget/index.d.ts +8 -0
  58. package/lib/widgets/CheckboxWidget/index.js +23 -0
  59. package/lib/widgets/CheckboxWidget/index.js.map +1 -0
  60. package/lib/widgets/CheckboxesWidget/index.d.ts +8 -0
  61. package/lib/widgets/CheckboxesWidget/index.js +26 -0
  62. package/lib/widgets/CheckboxesWidget/index.js.map +1 -0
  63. package/lib/widgets/DateTimeWidget/index.d.ts +8 -0
  64. package/lib/widgets/DateTimeWidget/index.js +22 -0
  65. package/lib/widgets/DateTimeWidget/index.js.map +1 -0
  66. package/lib/widgets/DateWidget/index.d.ts +8 -0
  67. package/lib/widgets/DateWidget/index.js +22 -0
  68. package/lib/widgets/DateWidget/index.js.map +1 -0
  69. package/lib/widgets/PasswordWidget/index.d.ts +7 -0
  70. package/lib/widgets/PasswordWidget/index.js +17 -0
  71. package/lib/widgets/PasswordWidget/index.js.map +1 -0
  72. package/lib/widgets/RadioWidget/index.d.ts +8 -0
  73. package/lib/widgets/RadioWidget/index.js +19 -0
  74. package/lib/widgets/RadioWidget/index.js.map +1 -0
  75. package/lib/widgets/RangeWidget/index.d.ts +8 -0
  76. package/lib/widgets/RangeWidget/index.js +26 -0
  77. package/lib/widgets/RangeWidget/index.js.map +1 -0
  78. package/lib/widgets/SelectWidget/index.d.ts +8 -0
  79. package/lib/widgets/SelectWidget/index.js +36 -0
  80. package/lib/widgets/SelectWidget/index.js.map +1 -0
  81. package/lib/widgets/TextareaWidget/index.d.ts +7 -0
  82. package/lib/widgets/TextareaWidget/index.js +23 -0
  83. package/lib/widgets/TextareaWidget/index.js.map +1 -0
  84. package/lib/widgets/index.d.ts +4 -0
  85. package/lib/widgets/index.js +28 -0
  86. package/lib/widgets/index.js.map +1 -0
  87. package/package.json +24 -16
  88. package/src/components/DatePicker/index.ts +6 -0
  89. package/src/index.less +38 -0
  90. package/src/index.ts +33 -0
  91. package/src/templates/ArrayFieldItemTemplate/index.tsx +90 -0
  92. package/src/templates/ArrayFieldTemplate/index.tsx +132 -0
  93. package/src/templates/BaseInputTemplate/index.tsx +105 -0
  94. package/src/templates/DescriptionField/index.tsx +17 -0
  95. package/src/templates/ErrorList/index.tsx +37 -0
  96. package/src/templates/FieldErrorTemplate/index.tsx +25 -0
  97. package/src/templates/FieldTemplate/index.tsx +114 -0
  98. package/src/templates/IconButton/index.tsx +94 -0
  99. package/src/templates/ObjectFieldTemplate/index.tsx +175 -0
  100. package/src/templates/SubmitButton/index.tsx +20 -0
  101. package/src/templates/TitleField/index.tsx +57 -0
  102. package/src/templates/WrapIfAdditionalTemplate/index.tsx +124 -0
  103. package/src/templates/index.ts +43 -0
  104. package/src/widgets/AltDateTimeWidget/index.tsx +17 -0
  105. package/src/widgets/AltDateWidget/index.tsx +197 -0
  106. package/src/widgets/CheckboxWidget/index.tsx +52 -0
  107. package/src/widgets/CheckboxesWidget/index.tsx +75 -0
  108. package/src/widgets/DateTimeWidget/index.tsx +54 -0
  109. package/src/widgets/DateWidget/index.tsx +52 -0
  110. package/src/widgets/PasswordWidget/index.tsx +46 -0
  111. package/src/widgets/RadioWidget/index.tsx +73 -0
  112. package/src/widgets/RangeWidget/index.tsx +69 -0
  113. package/src/widgets/SelectWidget/index.tsx +97 -0
  114. package/src/widgets/TextareaWidget/index.tsx +67 -0
  115. package/src/widgets/index.ts +35 -0
  116. package/dist/antd.cjs.development.js +0 -1643
  117. package/dist/antd.cjs.development.js.map +0 -1
  118. package/dist/antd.cjs.production.min.js +0 -2
  119. package/dist/antd.cjs.production.min.js.map +0 -1
  120. package/dist/antd.umd.development.js +0 -1617
  121. package/dist/antd.umd.development.js.map +0 -1
  122. package/dist/antd.umd.production.min.js +0 -2
  123. package/dist/antd.umd.production.min.js.map +0 -1
  124. package/dist/index.d.ts +0 -16
@@ -0,0 +1,46 @@
1
+ import { ChangeEvent, FocusEvent } from 'react';
2
+ import Input from 'antd/lib/input';
3
+ import {
4
+ ariaDescribedByIds,
5
+ FormContextType,
6
+ RJSFSchema,
7
+ StrictRJSFSchema,
8
+ WidgetProps,
9
+ GenericObjectType,
10
+ } from '@rjsf/utils';
11
+
12
+ /** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
13
+ *
14
+ * @param props - The `WidgetProps` for this component
15
+ */
16
+ export default function PasswordWidget<
17
+ T = any,
18
+ S extends StrictRJSFSchema = RJSFSchema,
19
+ F extends FormContextType = any
20
+ >(props: WidgetProps<T, S, F>) {
21
+ const { disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
22
+ const { readonlyAsDisabled = true } = formContext as GenericObjectType;
23
+
24
+ const emptyValue = options.emptyValue || '';
25
+
26
+ const handleChange = ({ target }: ChangeEvent<HTMLInputElement>) =>
27
+ onChange(target.value === '' ? emptyValue : target.value);
28
+
29
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target.value);
30
+
31
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target.value);
32
+
33
+ return (
34
+ <Input.Password
35
+ disabled={disabled || (readonlyAsDisabled && readonly)}
36
+ id={id}
37
+ name={id}
38
+ onBlur={!readonly ? handleBlur : undefined}
39
+ onChange={!readonly ? handleChange : undefined}
40
+ onFocus={!readonly ? handleFocus : undefined}
41
+ placeholder={placeholder}
42
+ value={value || ''}
43
+ aria-describedby={ariaDescribedByIds<T>(id)}
44
+ />
45
+ );
46
+ }
@@ -0,0 +1,73 @@
1
+ import { FocusEvent } from 'react';
2
+ import Radio, { RadioChangeEvent } from 'antd/lib/radio';
3
+ import {
4
+ ariaDescribedByIds,
5
+ enumOptionsIndexForValue,
6
+ enumOptionsValueForIndex,
7
+ optionId,
8
+ FormContextType,
9
+ GenericObjectType,
10
+ RJSFSchema,
11
+ StrictRJSFSchema,
12
+ WidgetProps,
13
+ } from '@rjsf/utils';
14
+
15
+ /** The `RadioWidget` is a widget for rendering a radio group.
16
+ * It is typically used with a string property constrained with enum options.
17
+ *
18
+ * @param props - The `WidgetProps` for this component
19
+ */
20
+ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
21
+ autofocus,
22
+ disabled,
23
+ formContext,
24
+ id,
25
+ onBlur,
26
+ onChange,
27
+ onFocus,
28
+ options,
29
+ readonly,
30
+ value,
31
+ }: WidgetProps<T, S, F>) {
32
+ const { readonlyAsDisabled = true } = formContext as GenericObjectType;
33
+
34
+ const { enumOptions, enumDisabled, emptyValue } = options;
35
+
36
+ const handleChange = ({ target: { value: nextValue } }: RadioChangeEvent) =>
37
+ onChange(enumOptionsValueForIndex<S>(nextValue, enumOptions, emptyValue));
38
+
39
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
40
+ onBlur(id, enumOptionsValueForIndex<S>(target.value, enumOptions, emptyValue));
41
+
42
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
43
+ onFocus(id, enumOptionsValueForIndex<S>(target.value, enumOptions, emptyValue));
44
+
45
+ const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions) as string;
46
+
47
+ return (
48
+ <Radio.Group
49
+ disabled={disabled || (readonlyAsDisabled && readonly)}
50
+ id={id}
51
+ name={id}
52
+ onChange={!readonly ? handleChange : undefined}
53
+ onBlur={!readonly ? handleBlur : undefined}
54
+ onFocus={!readonly ? handleFocus : undefined}
55
+ value={selectedIndexes}
56
+ aria-describedby={ariaDescribedByIds<T>(id)}
57
+ >
58
+ {Array.isArray(enumOptions) &&
59
+ enumOptions.map((option, i) => (
60
+ <Radio
61
+ id={optionId(id, i)}
62
+ name={id}
63
+ autoFocus={i === 0 ? autofocus : false}
64
+ disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1}
65
+ key={i}
66
+ value={String(i)}
67
+ >
68
+ {option.label}
69
+ </Radio>
70
+ ))}
71
+ </Radio.Group>
72
+ );
73
+ }
@@ -0,0 +1,69 @@
1
+ import Slider from 'antd/lib/slider';
2
+ import {
3
+ ariaDescribedByIds,
4
+ rangeSpec,
5
+ FormContextType,
6
+ RJSFSchema,
7
+ StrictRJSFSchema,
8
+ WidgetProps,
9
+ GenericObjectType,
10
+ } from '@rjsf/utils';
11
+
12
+ /** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
13
+ * in a div, with the value along side it.
14
+ *
15
+ * @param props - The `WidgetProps` for this component
16
+ */
17
+ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
18
+ props: WidgetProps<T, S, F>
19
+ ) {
20
+ const {
21
+ autofocus,
22
+ disabled,
23
+ formContext,
24
+ id,
25
+ onBlur,
26
+ onChange,
27
+ onFocus,
28
+ options,
29
+ placeholder,
30
+ readonly,
31
+ schema,
32
+ value,
33
+ } = props;
34
+ const { readonlyAsDisabled = true } = formContext as GenericObjectType;
35
+
36
+ const { min, max, step } = rangeSpec(schema);
37
+
38
+ const emptyValue = options.emptyValue || '';
39
+
40
+ const handleChange = (nextValue: any) => onChange(nextValue === '' ? emptyValue : nextValue);
41
+
42
+ const handleBlur = () => onBlur(id, value);
43
+
44
+ const handleFocus = () => onFocus(id, value);
45
+
46
+ // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
47
+ // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
48
+ const extraProps = {
49
+ placeholder,
50
+ onBlur: !readonly ? handleBlur : undefined,
51
+ onFocus: !readonly ? handleFocus : undefined,
52
+ };
53
+
54
+ return (
55
+ <Slider
56
+ autoFocus={autofocus}
57
+ disabled={disabled || (readonlyAsDisabled && readonly)}
58
+ id={id}
59
+ max={max}
60
+ min={min}
61
+ onChange={!readonly ? handleChange : undefined}
62
+ range={false}
63
+ step={step}
64
+ value={value}
65
+ {...extraProps}
66
+ aria-describedby={ariaDescribedByIds<T>(id)}
67
+ />
68
+ );
69
+ }
@@ -0,0 +1,97 @@
1
+ import Select, { DefaultOptionType } from 'antd/lib/select';
2
+ import {
3
+ ariaDescribedByIds,
4
+ enumOptionsIndexForValue,
5
+ enumOptionsValueForIndex,
6
+ FormContextType,
7
+ GenericObjectType,
8
+ RJSFSchema,
9
+ StrictRJSFSchema,
10
+ WidgetProps,
11
+ } from '@rjsf/utils';
12
+ import isString from 'lodash/isString';
13
+
14
+ const SELECT_STYLE = {
15
+ width: '100%',
16
+ };
17
+
18
+ /** The `SelectWidget` is a widget for rendering dropdowns.
19
+ * It is typically used with string properties constrained with enum options.
20
+ *
21
+ * @param props - The `WidgetProps` for this component
22
+ */
23
+ export default function SelectWidget<
24
+ T = any,
25
+ S extends StrictRJSFSchema = RJSFSchema,
26
+ F extends FormContextType = any
27
+ >({
28
+ autofocus,
29
+ disabled,
30
+ formContext = {} as F,
31
+ id,
32
+ multiple,
33
+ onBlur,
34
+ onChange,
35
+ onFocus,
36
+ options,
37
+ placeholder,
38
+ readonly,
39
+ value,
40
+ }: WidgetProps<T, S, F>) {
41
+ const { readonlyAsDisabled = true } = formContext as GenericObjectType;
42
+
43
+ const { enumOptions, enumDisabled, emptyValue } = options;
44
+
45
+ const handleChange = (nextValue: any) => onChange(enumOptionsValueForIndex<S>(nextValue, enumOptions, emptyValue));
46
+
47
+ const handleBlur = () => onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
48
+
49
+ const handleFocus = () => onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
50
+
51
+ const filterOption = (input: string, option?: DefaultOptionType) => {
52
+ if (option && isString(option.label)) {
53
+ // labels are strings in this context
54
+ return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
55
+ }
56
+ return false;
57
+ };
58
+
59
+ const getPopupContainer = (node: any) => node.parentNode;
60
+
61
+ const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
62
+
63
+ // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
64
+ // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
65
+ const extraProps = {
66
+ name: id,
67
+ };
68
+ return (
69
+ <Select
70
+ autoFocus={autofocus}
71
+ disabled={disabled || (readonlyAsDisabled && readonly)}
72
+ getPopupContainer={getPopupContainer}
73
+ id={id}
74
+ mode={multiple ? 'multiple' : undefined}
75
+ onBlur={!readonly ? handleBlur : undefined}
76
+ onChange={!readonly ? handleChange : undefined}
77
+ onFocus={!readonly ? handleFocus : undefined}
78
+ placeholder={placeholder}
79
+ style={SELECT_STYLE}
80
+ value={selectedIndexes}
81
+ {...extraProps}
82
+ filterOption={filterOption}
83
+ aria-describedby={ariaDescribedByIds<T>(id)}
84
+ >
85
+ {Array.isArray(enumOptions) &&
86
+ enumOptions.map(({ value: optionValue, label: optionLabel }, index) => (
87
+ <Select.Option
88
+ disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1}
89
+ key={String(index)}
90
+ value={String(index)}
91
+ >
92
+ {optionLabel}
93
+ </Select.Option>
94
+ ))}
95
+ </Select>
96
+ );
97
+ }
@@ -0,0 +1,67 @@
1
+ import { ChangeEvent, FocusEvent } from 'react';
2
+ import Input from 'antd/lib/input';
3
+ import {
4
+ ariaDescribedByIds,
5
+ FormContextType,
6
+ GenericObjectType,
7
+ RJSFSchema,
8
+ StrictRJSFSchema,
9
+ WidgetProps,
10
+ } from '@rjsf/utils';
11
+
12
+ const INPUT_STYLE = {
13
+ width: '100%',
14
+ };
15
+
16
+ /** The `TextareaWidget` is a widget for rendering input fields as textarea.
17
+ *
18
+ * @param props - The `WidgetProps` for this component
19
+ */
20
+ export default function TextareaWidget<
21
+ T = any,
22
+ S extends StrictRJSFSchema = RJSFSchema,
23
+ F extends FormContextType = any
24
+ >({
25
+ disabled,
26
+ formContext,
27
+ id,
28
+ onBlur,
29
+ onChange,
30
+ onFocus,
31
+ options,
32
+ placeholder,
33
+ readonly,
34
+ value,
35
+ }: WidgetProps<T, S, F>) {
36
+ const { readonlyAsDisabled = true } = formContext as GenericObjectType;
37
+
38
+ const handleChange = ({ target }: ChangeEvent<HTMLTextAreaElement>) =>
39
+ onChange(target.value === '' ? options.emptyValue : target.value);
40
+
41
+ const handleBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target.value);
42
+
43
+ const handleFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target.value);
44
+
45
+ // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
46
+ // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
47
+ const extraProps = {
48
+ type: 'textarea',
49
+ };
50
+
51
+ return (
52
+ <Input.TextArea
53
+ disabled={disabled || (readonlyAsDisabled && readonly)}
54
+ id={id}
55
+ name={id}
56
+ onBlur={!readonly ? handleBlur : undefined}
57
+ onChange={!readonly ? handleChange : undefined}
58
+ onFocus={!readonly ? handleFocus : undefined}
59
+ placeholder={placeholder}
60
+ rows={options.rows || 4}
61
+ style={INPUT_STYLE}
62
+ value={value}
63
+ {...extraProps}
64
+ aria-describedby={ariaDescribedByIds<T>(id)}
65
+ />
66
+ );
67
+ }
@@ -0,0 +1,35 @@
1
+ import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+
3
+ import AltDateTimeWidget from './AltDateTimeWidget';
4
+ import AltDateWidget from './AltDateWidget';
5
+ import CheckboxesWidget from './CheckboxesWidget';
6
+ import CheckboxWidget from './CheckboxWidget';
7
+ import DateTimeWidget from './DateTimeWidget';
8
+ import DateWidget from './DateWidget';
9
+ import PasswordWidget from './PasswordWidget';
10
+ import RadioWidget from './RadioWidget';
11
+ import RangeWidget from './RangeWidget';
12
+ import SelectWidget from './SelectWidget';
13
+ import TextareaWidget from './TextareaWidget';
14
+
15
+ export function generateWidgets<
16
+ T = any,
17
+ S extends StrictRJSFSchema = RJSFSchema,
18
+ F extends FormContextType = any
19
+ >(): RegistryWidgetsType<T, S, F> {
20
+ return {
21
+ AltDateTimeWidget,
22
+ AltDateWidget,
23
+ CheckboxesWidget,
24
+ CheckboxWidget,
25
+ DateTimeWidget,
26
+ DateWidget,
27
+ PasswordWidget,
28
+ RadioWidget,
29
+ RangeWidget,
30
+ SelectWidget,
31
+ TextareaWidget,
32
+ };
33
+ }
34
+
35
+ export default generateWidgets();