@rjsf/antd 6.6.0 → 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.
- package/dist/antd.esm.js +79 -136
- package/dist/antd.esm.js.map +4 -4
- package/dist/antd.umd.js +55 -63
- package/dist/index.cjs +80 -91
- package/dist/index.cjs.map +4 -4
- package/lib/index.d.ts +3 -3
- package/lib/index.js.map +1 -1
- package/lib/templates/ArrayFieldItemTemplate/index.d.ts +1 -1
- package/lib/templates/ArrayFieldItemTemplate/index.js +1 -1
- package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -1
- package/lib/templates/ArrayFieldTemplate/index.d.ts +1 -1
- package/lib/templates/ArrayFieldTemplate/index.js +1 -1
- package/lib/templates/ArrayFieldTemplate/index.js.map +1 -1
- package/lib/templates/BaseInputTemplate/index.d.ts +1 -1
- package/lib/templates/BaseInputTemplate/index.js +3 -4
- package/lib/templates/BaseInputTemplate/index.js.map +1 -1
- package/lib/templates/ErrorList/index.d.ts +1 -1
- package/lib/templates/ErrorList/index.js +2 -2
- package/lib/templates/ErrorList/index.js.map +1 -1
- package/lib/templates/FieldDescriptionTemplate/index.d.ts +1 -1
- package/lib/templates/FieldErrorTemplate/index.d.ts +1 -1
- package/lib/templates/FieldErrorTemplate/index.js.map +1 -1
- package/lib/templates/FieldHelpTemplate/index.d.ts +1 -1
- package/lib/templates/FieldHelpTemplate/index.js.map +1 -1
- package/lib/templates/FieldTemplate/index.d.ts +1 -1
- package/lib/templates/FieldTemplate/index.js +1 -1
- package/lib/templates/FieldTemplate/index.js.map +1 -1
- package/lib/templates/GridTemplate/index.d.ts +1 -1
- package/lib/templates/IconButton/index.d.ts +2 -2
- package/lib/templates/IconButton/index.js +1 -1
- package/lib/templates/IconButton/index.js.map +1 -1
- package/lib/templates/MultiSchemaFieldTemplate/index.d.ts +1 -1
- package/lib/templates/ObjectFieldTemplate/index.d.ts +1 -1
- package/lib/templates/ObjectFieldTemplate/index.js +1 -1
- package/lib/templates/ObjectFieldTemplate/index.js.map +1 -1
- package/lib/templates/OptionalDataControlsTemplate/index.d.ts +1 -1
- package/lib/templates/OptionalDataControlsTemplate/index.js +1 -1
- package/lib/templates/OptionalDataControlsTemplate/index.js.map +1 -1
- package/lib/templates/SubmitButton/index.d.ts +1 -1
- package/lib/templates/SubmitButton/index.js.map +1 -1
- package/lib/templates/TitleField/index.d.ts +1 -1
- package/lib/templates/TitleField/index.js +4 -1
- package/lib/templates/TitleField/index.js.map +1 -1
- package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +1 -1
- package/lib/templates/WrapIfAdditionalTemplate/index.js +1 -1
- package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -1
- package/lib/templates/index.d.ts +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/AltDateTimeWidget/index.d.ts +1 -1
- package/lib/widgets/AltDateWidget/index.d.ts +1 -1
- package/lib/widgets/AltDateWidget/index.js +1 -1
- package/lib/widgets/AltDateWidget/index.js.map +1 -1
- package/lib/widgets/CheckboxWidget/index.d.ts +1 -1
- package/lib/widgets/CheckboxWidget/index.js +1 -1
- package/lib/widgets/CheckboxWidget/index.js.map +1 -1
- package/lib/widgets/CheckboxesWidget/index.d.ts +1 -1
- package/lib/widgets/CheckboxesWidget/index.js +3 -3
- package/lib/widgets/CheckboxesWidget/index.js.map +1 -1
- package/lib/widgets/DateTimeWidget/index.d.ts +3 -3
- package/lib/widgets/DateTimeWidget/index.js +4 -16
- package/lib/widgets/DateTimeWidget/index.js.map +1 -1
- package/lib/widgets/DateWidget/index.d.ts +9 -2
- package/lib/widgets/DateWidget/index.js +10 -6
- package/lib/widgets/DateWidget/index.js.map +1 -1
- package/lib/widgets/PasswordWidget/index.d.ts +1 -1
- package/lib/widgets/PasswordWidget/index.js +1 -1
- package/lib/widgets/PasswordWidget/index.js.map +1 -1
- package/lib/widgets/RadioWidget/index.d.ts +1 -1
- package/lib/widgets/RadioWidget/index.js +1 -1
- package/lib/widgets/RadioWidget/index.js.map +1 -1
- package/lib/widgets/RangeWidget/index.d.ts +1 -1
- package/lib/widgets/RangeWidget/index.js +1 -1
- package/lib/widgets/RangeWidget/index.js.map +1 -1
- package/lib/widgets/SelectWidget/index.d.ts +1 -1
- package/lib/widgets/SelectWidget/index.js +6 -6
- package/lib/widgets/SelectWidget/index.js.map +1 -1
- package/lib/widgets/TextareaWidget/index.d.ts +1 -1
- package/lib/widgets/TextareaWidget/index.js +1 -1
- package/lib/widgets/TextareaWidget/index.js.map +1 -1
- package/lib/widgets/index.d.ts +1 -1
- package/package.json +9 -9
- package/src/index.ts +4 -3
- package/src/templates/ArrayFieldItemTemplate/index.tsx +2 -8
- package/src/templates/ArrayFieldTemplate/index.tsx +2 -4
- package/src/templates/BaseInputTemplate/index.tsx +7 -8
- package/src/templates/ErrorList/index.tsx +4 -2
- package/src/templates/FieldDescriptionTemplate/index.tsx +1 -1
- package/src/templates/FieldErrorTemplate/index.tsx +2 -1
- package/src/templates/FieldHelpTemplate/index.tsx +2 -1
- package/src/templates/FieldTemplate/index.tsx +2 -9
- package/src/templates/GridTemplate/index.tsx +1 -1
- package/src/templates/IconButton/index.tsx +5 -10
- package/src/templates/MultiSchemaFieldTemplate/index.tsx +1 -1
- package/src/templates/ObjectFieldTemplate/index.tsx +2 -6
- package/src/templates/OptionalDataControlsTemplate/index.tsx +3 -2
- package/src/templates/SubmitButton/index.tsx +4 -2
- package/src/templates/TitleField/index.tsx +5 -1
- package/src/templates/WrapIfAdditionalTemplate/index.tsx +2 -10
- package/src/templates/index.ts +1 -1
- package/src/widgets/AltDateTimeWidget/index.tsx +1 -1
- package/src/widgets/AltDateWidget/index.tsx +2 -10
- package/src/widgets/CheckboxWidget/index.tsx +5 -11
- package/src/widgets/CheckboxesWidget/index.tsx +27 -32
- package/src/widgets/DateTimeWidget/index.tsx +5 -43
- package/src/widgets/DateWidget/index.tsx +28 -15
- package/src/widgets/PasswordWidget/index.tsx +3 -9
- package/src/widgets/RadioWidget/index.tsx +6 -9
- package/src/widgets/RangeWidget/index.tsx +2 -9
- package/src/widgets/SelectWidget/index.tsx +16 -17
- package/src/widgets/TextareaWidget/index.tsx +3 -9
- package/src/widgets/index.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MouseEventHandler } from 'react';
|
|
1
|
+
import type { MouseEventHandler } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ArrowDownOutlined,
|
|
4
4
|
ArrowUpOutlined,
|
|
@@ -7,15 +7,10 @@ import {
|
|
|
7
7
|
PlusCircleOutlined,
|
|
8
8
|
CloseOutlined,
|
|
9
9
|
} from '@ant-design/icons';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
RJSFSchema,
|
|
15
|
-
StrictRJSFSchema,
|
|
16
|
-
TranslatableString,
|
|
17
|
-
} from '@rjsf/utils';
|
|
18
|
-
import { Button, ButtonProps } from 'antd';
|
|
10
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
11
|
+
import { getUiOptions, TranslatableString } from '@rjsf/utils';
|
|
12
|
+
import type { ButtonProps } from 'antd';
|
|
13
|
+
import { Button } from 'antd';
|
|
19
14
|
|
|
20
15
|
export type AntdIconButtonProps<
|
|
21
16
|
T = any,
|
|
@@ -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
|
-
}
|
|
32
|
+
}
|
|
33
|
+
if (onRemoveClick) {
|
|
33
34
|
return (
|
|
34
35
|
<RemoveButton
|
|
35
36
|
id={id}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
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 };
|
package/src/templates/index.ts
CHANGED
|
@@ -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,13 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
13
|
-
width: '100%',
|
|
14
|
-
};
|
|
3
|
+
import DateWidget from '../DateWidget';
|
|
15
4
|
|
|
16
|
-
/** The `DateTimeWidget` component uses the `
|
|
17
|
-
* the value to/from
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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) =>
|
|
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 = (
|
|
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={
|
|
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
|
-
|
|
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 {
|
|
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.
|
|
70
|
-
key={
|
|
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
|
-
|
|
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 {
|
|
15
|
-
import {
|
|
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().
|
|
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
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
90
|
+
enumOptionsList.unshift({ value: '', label: placeholder || '' });
|
|
92
91
|
}
|
|
93
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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 = {
|
package/src/widgets/index.ts
CHANGED
|
@@ -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';
|