@rjsf/mantine 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/index.cjs +110 -83
- package/dist/index.cjs.map +3 -3
- package/dist/mantine.esm.js +82 -119
- package/dist/mantine.esm.js.map +3 -3
- package/dist/mantine.umd.js +127 -101
- package/lib/Form/index.d.ts +3 -3
- package/lib/Form/index.js.map +1 -1
- package/lib/Theme/index.d.ts +2 -2
- package/lib/templates/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/templates/ArrayFieldItemTemplate.js +1 -1
- package/lib/templates/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/templates/ArrayFieldTemplate.d.ts +1 -1
- package/lib/templates/ArrayFieldTemplate.js +1 -1
- package/lib/templates/ArrayFieldTemplate.js.map +1 -1
- package/lib/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/templates/ArrayFieldTitleTemplate.js +1 -1
- package/lib/templates/ArrayFieldTitleTemplate.js.map +1 -1
- package/lib/templates/BaseInputTemplate.d.ts +1 -1
- package/lib/templates/BaseInputTemplate.js +5 -5
- package/lib/templates/BaseInputTemplate.js.map +1 -1
- package/lib/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/templates/ButtonTemplates/AddButton.js.map +1 -1
- package/lib/templates/ButtonTemplates/IconButton.d.ts +15 -8
- package/lib/templates/ButtonTemplates/IconButton.js +14 -6
- package/lib/templates/ButtonTemplates/IconButton.js.map +1 -1
- package/lib/templates/ButtonTemplates/SubmitButton.d.ts +1 -1
- package/lib/templates/ButtonTemplates/SubmitButton.js.map +1 -1
- package/lib/templates/ButtonTemplates/index.d.ts +1 -1
- package/lib/templates/DescriptionField.d.ts +1 -1
- package/lib/templates/ErrorList.d.ts +1 -1
- package/lib/templates/ErrorList.js.map +1 -1
- package/lib/templates/FieldErrorTemplate.d.ts +1 -1
- package/lib/templates/FieldErrorTemplate.js.map +1 -1
- package/lib/templates/FieldHelpTemplate.d.ts +1 -1
- package/lib/templates/FieldHelpTemplate.js.map +1 -1
- package/lib/templates/FieldTemplate.d.ts +1 -1
- package/lib/templates/FieldTemplate.js +1 -1
- package/lib/templates/FieldTemplate.js.map +1 -1
- package/lib/templates/GridTemplate.d.ts +1 -1
- package/lib/templates/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/templates/ObjectFieldTemplate.d.ts +1 -1
- package/lib/templates/ObjectFieldTemplate.js +1 -1
- package/lib/templates/ObjectFieldTemplate.js.map +1 -1
- package/lib/templates/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/templates/OptionalDataControlsTemplate.js +1 -1
- package/lib/templates/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/templates/TitleField.d.ts +1 -1
- package/lib/templates/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/templates/WrapIfAdditionalTemplate.js +1 -1
- package/lib/templates/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/templates/icons.d.ts +1 -1
- package/lib/templates/index.d.ts +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js.map +1 -1
- package/lib/widgets/CheckboxWidget.d.ts +2 -2
- package/lib/widgets/CheckboxWidget.js +1 -1
- package/lib/widgets/CheckboxWidget.js.map +1 -1
- package/lib/widgets/CheckboxesWidget.d.ts +1 -1
- package/lib/widgets/CheckboxesWidget.js +1 -1
- package/lib/widgets/CheckboxesWidget.js.map +1 -1
- package/lib/widgets/ColorWidget.d.ts +1 -1
- package/lib/widgets/ColorWidget.js +1 -1
- package/lib/widgets/ColorWidget.js.map +1 -1
- package/lib/widgets/DateTime/AltDateTimeWidget.d.ts +1 -1
- package/lib/widgets/DateTime/AltDateWidget.d.ts +1 -1
- package/lib/widgets/DateTime/AltDateWidget.js +1 -1
- package/lib/widgets/DateTime/AltDateWidget.js.map +1 -1
- package/lib/widgets/DateTime/DateTimeInput.d.ts +1 -1
- package/lib/widgets/DateTime/DateTimeInput.js +1 -1
- package/lib/widgets/DateTime/DateTimeInput.js.map +1 -1
- package/lib/widgets/DateTime/DateTimeWidget.d.ts +1 -1
- package/lib/widgets/DateTime/DateWidget.d.ts +1 -1
- package/lib/widgets/DateTime/TimeWidget.d.ts +1 -1
- package/lib/widgets/DateTime/TimeWidget.js +1 -1
- package/lib/widgets/DateTime/TimeWidget.js.map +1 -1
- package/lib/widgets/FileWidget.d.ts +1 -1
- package/lib/widgets/FileWidget.js +2 -1
- package/lib/widgets/FileWidget.js.map +1 -1
- package/lib/widgets/PasswordWidget.d.ts +1 -1
- package/lib/widgets/PasswordWidget.js +2 -2
- package/lib/widgets/PasswordWidget.js.map +1 -1
- package/lib/widgets/RadioWidget.d.ts +1 -1
- package/lib/widgets/RadioWidget.js +1 -1
- package/lib/widgets/RadioWidget.js.map +1 -1
- package/lib/widgets/RangeWidget.d.ts +1 -1
- package/lib/widgets/RangeWidget.js +1 -1
- package/lib/widgets/RangeWidget.js.map +1 -1
- package/lib/widgets/SelectWidget.d.ts +1 -1
- package/lib/widgets/SelectWidget.js +1 -1
- package/lib/widgets/SelectWidget.js.map +1 -1
- package/lib/widgets/TextareaWidget.d.ts +2 -2
- package/lib/widgets/TextareaWidget.js +1 -1
- package/lib/widgets/TextareaWidget.js.map +1 -1
- package/lib/widgets/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/Form/index.ts +4 -3
- package/src/Theme/index.ts +2 -2
- package/src/templates/ArrayFieldItemTemplate.tsx +2 -8
- package/src/templates/ArrayFieldTemplate.tsx +2 -9
- package/src/templates/ArrayFieldTitleTemplate.tsx +2 -8
- package/src/templates/BaseInputTemplate.tsx +8 -15
- package/src/templates/ButtonTemplates/AddButton.tsx +2 -1
- package/src/templates/ButtonTemplates/IconButton.tsx +19 -10
- package/src/templates/ButtonTemplates/SubmitButton.tsx +2 -1
- package/src/templates/ButtonTemplates/index.ts +1 -1
- package/src/templates/DescriptionField.tsx +1 -1
- package/src/templates/ErrorList.tsx +3 -1
- package/src/templates/FieldErrorTemplate.tsx +3 -1
- package/src/templates/FieldHelpTemplate.tsx +2 -1
- package/src/templates/FieldTemplate.tsx +2 -8
- package/src/templates/GridTemplate.tsx +1 -1
- package/src/templates/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/templates/ObjectFieldTemplate.tsx +4 -8
- package/src/templates/OptionalDataControlsTemplate.tsx +3 -2
- package/src/templates/TitleField.tsx +1 -1
- package/src/templates/WrapIfAdditionalTemplate.tsx +2 -10
- package/src/templates/icons.tsx +1 -1
- package/src/templates/index.ts +1 -1
- package/src/utils.ts +2 -2
- package/src/widgets/CheckboxWidget.tsx +4 -11
- package/src/widgets/CheckboxesWidget.tsx +5 -7
- package/src/widgets/ColorWidget.tsx +4 -9
- package/src/widgets/DateTime/AltDateTimeWidget.tsx +1 -1
- package/src/widgets/DateTime/AltDateWidget.tsx +4 -12
- package/src/widgets/DateTime/DateTimeInput.tsx +2 -8
- package/src/widgets/DateTime/DateTimeWidget.tsx +1 -1
- package/src/widgets/DateTime/DateWidget.tsx +1 -1
- package/src/widgets/DateTime/TimeWidget.tsx +4 -9
- package/src/widgets/FileWidget.tsx +4 -9
- package/src/widgets/PasswordWidget.tsx +5 -10
- package/src/widgets/RadioWidget.tsx +5 -7
- package/src/widgets/RangeWidget.tsx +3 -9
- package/src/widgets/SelectWidget.tsx +4 -6
- package/src/widgets/TextareaWidget.tsx +4 -9
- package/src/widgets/index.ts +1 -1
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent, MouseEvent
|
|
1
|
+
import type { ChangeEvent, FocusEvent, MouseEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { TextInput, NumberInput } from '@mantine/core';
|
|
3
4
|
import { SchemaExamples } from '@rjsf/core';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
BaseInputTemplateProps,
|
|
7
|
-
examplesId,
|
|
8
|
-
getInputProps,
|
|
9
|
-
labelValue,
|
|
10
|
-
FormContextType,
|
|
11
|
-
RJSFSchema,
|
|
12
|
-
StrictRJSFSchema,
|
|
13
|
-
} from '@rjsf/utils';
|
|
5
|
+
import type { BaseInputTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
6
|
+
import { ariaDescribedByIds, examplesId, getInputProps, labelValue } from '@rjsf/utils';
|
|
14
7
|
|
|
15
8
|
import { cleanupOptions } from '../utils';
|
|
16
9
|
|
|
@@ -53,13 +46,13 @@ export default function BaseInputTemplate<
|
|
|
53
46
|
const description = hideLabel ? undefined : options.description || schema.description;
|
|
54
47
|
const themeProps = cleanupOptions(options);
|
|
55
48
|
|
|
56
|
-
const handleNumberChange = useCallback((
|
|
49
|
+
const handleNumberChange = useCallback((newValue: number | string) => onChange(newValue), [onChange]);
|
|
57
50
|
|
|
58
51
|
const handleChange = useCallback(
|
|
59
52
|
(e: ChangeEvent<HTMLInputElement>) => {
|
|
60
|
-
const handler = onChangeOverride
|
|
61
|
-
const
|
|
62
|
-
handler(
|
|
53
|
+
const handler = onChangeOverride || onChange;
|
|
54
|
+
const newValue = e.target.value === '' ? options.emptyValue : e.target.value;
|
|
55
|
+
handler(newValue);
|
|
63
56
|
},
|
|
64
57
|
[onChange, onChangeOverride, options],
|
|
65
58
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema
|
|
1
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
import { Plus } from '../icons';
|
|
4
5
|
import IconButton from './IconButton';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { MouseEventHandler } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { MouseEventHandler } from 'react';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import type { ActionIconProps } from '@mantine/core';
|
|
4
|
+
import { ActionIcon } from '@mantine/core';
|
|
5
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
6
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
4
7
|
|
|
5
8
|
import { Copy, ChevronDown, ChevronUp, X } from '../icons';
|
|
6
9
|
|
|
@@ -10,7 +13,7 @@ export type MantineIconButtonProps<
|
|
|
10
13
|
F extends FormContextType = any,
|
|
11
14
|
> = IconButtonProps<T, S, F> & Omit<ActionIconProps, 'onClick'>;
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
function IconButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
14
17
|
props: MantineIconButtonProps<T, S, F>,
|
|
15
18
|
) {
|
|
16
19
|
const { icon, iconType = 'sm', color, onClick, uiSchema, registry, ...otherProps } = props;
|
|
@@ -25,8 +28,10 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
25
28
|
</ActionIcon>
|
|
26
29
|
);
|
|
27
30
|
}
|
|
31
|
+
const IconButton = memo(IconButtonFn) as typeof IconButtonFn;
|
|
32
|
+
export default IconButton;
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
function CopyButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
30
35
|
props: MantineIconButtonProps<T, S, F>,
|
|
31
36
|
) {
|
|
32
37
|
const {
|
|
@@ -36,8 +41,9 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
36
41
|
<IconButton title={translateString(TranslatableString.CopyButton)} variant='subtle' {...props} icon={<Copy />} />
|
|
37
42
|
);
|
|
38
43
|
}
|
|
44
|
+
export const CopyButton = memo(CopyButtonFn) as typeof CopyButtonFn;
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
function MoveDownButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
41
47
|
props: MantineIconButtonProps<T, S, F>,
|
|
42
48
|
) {
|
|
43
49
|
const {
|
|
@@ -52,8 +58,9 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
52
58
|
/>
|
|
53
59
|
);
|
|
54
60
|
}
|
|
61
|
+
export const MoveDownButton = memo(MoveDownButtonFn) as typeof MoveDownButtonFn;
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
function MoveUpButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
57
64
|
props: MantineIconButtonProps<T, S, F>,
|
|
58
65
|
) {
|
|
59
66
|
const {
|
|
@@ -68,8 +75,9 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
68
75
|
/>
|
|
69
76
|
);
|
|
70
77
|
}
|
|
78
|
+
export const MoveUpButton = memo(MoveUpButtonFn) as typeof MoveUpButtonFn;
|
|
71
79
|
|
|
72
|
-
|
|
80
|
+
function RemoveButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
73
81
|
props: MantineIconButtonProps<T, S, F>,
|
|
74
82
|
) {
|
|
75
83
|
const {
|
|
@@ -85,15 +93,16 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
85
93
|
/>
|
|
86
94
|
);
|
|
87
95
|
}
|
|
96
|
+
export const RemoveButton = memo(RemoveButtonFn) as typeof RemoveButtonFn;
|
|
88
97
|
|
|
89
|
-
|
|
98
|
+
function ClearButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
90
99
|
props: MantineIconButtonProps<T, S, F>,
|
|
91
100
|
) {
|
|
92
101
|
const {
|
|
93
102
|
registry: { translateString },
|
|
94
103
|
} = props;
|
|
95
|
-
|
|
96
104
|
return (
|
|
97
105
|
<IconButton title={translateString(TranslatableString.ClearButton)} variant='subtle' {...props} icon={<X />} />
|
|
98
106
|
);
|
|
99
107
|
}
|
|
108
|
+
export const ClearButton = memo(ClearButtonFn) as typeof ClearButtonFn;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Button } from '@mantine/core';
|
|
2
|
-
import {
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
|
|
3
|
+
import { getSubmitButtonOptions } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
5
6
|
*/
|
|
@@ -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 AddButton from './AddButton';
|
|
4
4
|
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from './IconButton';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Text } from '@mantine/core';
|
|
2
2
|
import { RichDescription } from '@rjsf/core';
|
|
3
|
-
import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import type { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
4
|
|
|
5
5
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
6
6
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Alert, Title, List } from '@mantine/core';
|
|
2
|
-
import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema
|
|
2
|
+
import type { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
import { ExclamationCircle } from './icons';
|
|
5
6
|
|
|
@@ -26,6 +27,7 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
26
27
|
>
|
|
27
28
|
<List>
|
|
28
29
|
{errors.map((error, index) => (
|
|
30
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
29
31
|
<List.Item key={`error-${index}`} c='red'>
|
|
30
32
|
{error.stack}
|
|
31
33
|
</List.Item>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Box, List } from '@mantine/core';
|
|
2
|
-
import {
|
|
2
|
+
import type { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { errorId } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
5
6
|
*
|
|
@@ -19,6 +20,7 @@ export default function FieldErrorTemplate<
|
|
|
19
20
|
<Box id={id} c='red' display='none'>
|
|
20
21
|
<List>
|
|
21
22
|
{errors.map((error, index) => (
|
|
23
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
22
24
|
<List.Item key={`field-error-${index}`}>{error}</List.Item>
|
|
23
25
|
))}
|
|
24
26
|
</List>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Text } from '@mantine/core';
|
|
2
2
|
import { RichHelp } from '@rjsf/core';
|
|
3
|
-
import {
|
|
3
|
+
import type { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
|
+
import { helpId } from '@rjsf/utils';
|
|
4
5
|
|
|
5
6
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
6
7
|
*
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Box } from '@mantine/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
FormContextType,
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
getTemplate,
|
|
8
|
-
getUiOptions,
|
|
9
|
-
} from '@rjsf/utils';
|
|
2
|
+
import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { getTemplate, getUiOptions } from '@rjsf/utils';
|
|
10
4
|
|
|
11
5
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
12
6
|
* content, (label, description, children, errors and help) inside a `WrapIfAdditional` component.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Container, Grid } from '@mantine/core';
|
|
2
|
-
import { GridTemplateProps } from '@rjsf/utils';
|
|
2
|
+
import type { GridTemplateProps } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
/** Renders a `GridTemplate` for mantine, which is expecting the column sizing information coming in via the
|
|
5
5
|
* extra props provided by the caller, which are spread directly on the `Grid`/`Grid.Col`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Stack } from '@mantine/core';
|
|
2
|
-
import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import type { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
export default function MultiSchemaFieldTemplate<
|
|
5
5
|
T = any,
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
canExpand,
|
|
5
|
-
descriptionId,
|
|
1
|
+
import type { MantineSpacing } from '@mantine/core';
|
|
2
|
+
import { Box, Container, Group, SimpleGrid } from '@mantine/core';
|
|
3
|
+
import type {
|
|
6
4
|
FormContextType,
|
|
7
|
-
getTemplate,
|
|
8
|
-
getUiOptions,
|
|
9
5
|
ObjectFieldTemplatePropertyType,
|
|
10
6
|
ObjectFieldTemplateProps,
|
|
11
7
|
RJSFSchema,
|
|
12
8
|
StrictRJSFSchema,
|
|
13
|
-
titleId,
|
|
14
9
|
} from '@rjsf/utils';
|
|
10
|
+
import { buttonId, canExpand, descriptionId, getTemplate, getUiOptions, titleId } from '@rjsf/utils';
|
|
15
11
|
|
|
16
12
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
17
13
|
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
@@ -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 from './ButtonTemplates/AddButton';
|
|
4
4
|
import { RemoveButton } from './ButtonTemplates/IconButton';
|
|
@@ -28,7 +28,8 @@ export default function OptionalDataControlsTemplate<
|
|
|
28
28
|
title={label}
|
|
29
29
|
/>
|
|
30
30
|
);
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
|
+
if (onRemoveClick) {
|
|
32
33
|
return (
|
|
33
34
|
<RemoveButton
|
|
34
35
|
id={id}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Grid, Title } from '@mantine/core';
|
|
2
|
-
import { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import type { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
/** The `TitleField` is the template to use to render the title of a field
|
|
5
5
|
*
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { Flex, Grid, TextInput } from '@mantine/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
UI_OPTIONS_KEY,
|
|
5
|
-
buttonId,
|
|
6
|
-
FormContextType,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
TranslatableString,
|
|
10
|
-
WrapIfAdditionalTemplateProps,
|
|
11
|
-
} from '@rjsf/utils';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
|
|
3
|
+
import { ADDITIONAL_PROPERTY_FLAG, UI_OPTIONS_KEY, buttonId, TranslatableString } from '@rjsf/utils';
|
|
12
4
|
|
|
13
5
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
14
6
|
* part of an `additionalProperties` part of a schema.
|
package/src/templates/icons.tsx
CHANGED
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';
|
package/src/utils.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { ReactElement, ChangeEvent, FocusEvent
|
|
1
|
+
import type { ReactElement, ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { Checkbox } from '@mantine/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
getTemplate,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
FormContextType,
|
|
9
|
-
WidgetProps,
|
|
10
|
-
labelValue,
|
|
11
|
-
ariaDescribedByIds,
|
|
12
|
-
} from '@rjsf/utils';
|
|
4
|
+
import type { StrictRJSFSchema, RJSFSchema, FormContextType, WidgetProps } from '@rjsf/utils';
|
|
5
|
+
import { descriptionId, getTemplate, labelValue, ariaDescribedByIds } from '@rjsf/utils';
|
|
13
6
|
|
|
14
7
|
/** The `CheckBoxWidget` is a widget for rendering boolean properties.
|
|
15
8
|
* It is typically used to represent a boolean.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { FocusEvent
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { Checkbox, Flex, Input } from '@mantine/core';
|
|
4
|
+
import type { FormContextType, WidgetProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
5
|
import {
|
|
4
6
|
ariaDescribedByIds,
|
|
5
7
|
enumOptionValueDecoder,
|
|
@@ -8,10 +10,6 @@ import {
|
|
|
8
10
|
getOptionValueFormat,
|
|
9
11
|
optionId,
|
|
10
12
|
titleId,
|
|
11
|
-
FormContextType,
|
|
12
|
-
WidgetProps,
|
|
13
|
-
RJSFSchema,
|
|
14
|
-
StrictRJSFSchema,
|
|
15
13
|
} from '@rjsf/utils';
|
|
16
14
|
|
|
17
15
|
import { cleanupOptions } from '../utils';
|
|
@@ -97,12 +95,12 @@ export default function CheckboxesWidget<
|
|
|
97
95
|
<Flex mt='xs' direction={inline ? 'row' : 'column'} gap='xs' wrap='wrap'>
|
|
98
96
|
{enumOptions.map((option, i) => (
|
|
99
97
|
<Checkbox
|
|
100
|
-
key={
|
|
98
|
+
key={String(option.value)}
|
|
101
99
|
id={optionId(id, i)}
|
|
102
100
|
name={htmlName || id}
|
|
103
101
|
value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
|
|
104
102
|
label={option.label}
|
|
105
|
-
disabled={Array.isArray(enumDisabled) && enumDisabled.
|
|
103
|
+
disabled={Array.isArray(enumDisabled) && enumDisabled.includes(option.value)}
|
|
106
104
|
autoFocus={i === 0 && autofocus}
|
|
107
105
|
onBlur={handleBlur}
|
|
108
106
|
onFocus={handleFocus}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { FocusEvent
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { ColorInput } from '@mantine/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
WidgetProps,
|
|
8
|
-
labelValue,
|
|
9
|
-
ariaDescribedByIds,
|
|
10
|
-
} from '@rjsf/utils';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
5
|
+
import { labelValue, ariaDescribedByIds } from '@rjsf/utils';
|
|
11
6
|
|
|
12
7
|
import { cleanupOptions } from '../utils';
|
|
13
8
|
|
|
@@ -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
|
/** The `AltDateTimeWidget` is an alternative widget for rendering datetime properties.
|
|
4
4
|
* It uses the AltDateWidget for rendering, with the `time` prop set to true by default.
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { Flex, Box, Group, Button, Select, Input } from '@mantine/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
dateRangeOptions,
|
|
5
|
-
titleId,
|
|
6
|
-
DateObject,
|
|
7
|
-
FormContextType,
|
|
8
|
-
RJSFSchema,
|
|
9
|
-
StrictRJSFSchema,
|
|
10
|
-
TranslatableString,
|
|
11
|
-
useAltDateWidgetProps,
|
|
12
|
-
WidgetProps,
|
|
13
|
-
} from '@rjsf/utils';
|
|
2
|
+
import type { DateObject, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds, dateRangeOptions, titleId, TranslatableString, useAltDateWidgetProps } from '@rjsf/utils';
|
|
14
4
|
|
|
15
5
|
/** The `AltDateWidget` is an alternative widget for rendering date properties.
|
|
16
6
|
* @param props - The `WidgetProps` for this component
|
|
@@ -34,6 +24,7 @@ export default function AltDateWidget<
|
|
|
34
24
|
{elements.map((elemProps, i) => {
|
|
35
25
|
const elemId = `${id}_${elemProps.type}`;
|
|
36
26
|
return (
|
|
27
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
37
28
|
<Box key={i}>
|
|
38
29
|
<Select
|
|
39
30
|
id={elemId}
|
|
@@ -67,6 +58,7 @@ export default function AltDateWidget<
|
|
|
67
58
|
{rawErrors &&
|
|
68
59
|
rawErrors?.length > 0 &&
|
|
69
60
|
rawErrors.map((error: string, index: number) => (
|
|
61
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
70
62
|
<Input.Error key={`alt-date-widget-input-errors-${index}`}>{error}</Input.Error>
|
|
71
63
|
))}
|
|
72
64
|
</>
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { DateInput } from '@mantine/dates';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FormContextType,
|
|
6
|
-
labelValue,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
WidgetProps,
|
|
10
|
-
} from '@rjsf/utils';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
4
|
+
import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
|
|
11
5
|
import dayjs from 'dayjs';
|
|
12
6
|
|
|
13
7
|
const dateParser = (input: string, format: string) => {
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { TimeInput } from '@mantine/dates';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
WidgetProps,
|
|
8
|
-
labelValue,
|
|
9
|
-
ariaDescribedByIds,
|
|
10
|
-
} from '@rjsf/utils';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
5
|
+
import { labelValue, ariaDescribedByIds } from '@rjsf/utils';
|
|
11
6
|
|
|
12
7
|
/** The `TimeWidget` component uses the `TimeInput` component from `@mantine/dates` for rendering.
|
|
13
8
|
*
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { FileInput, Pill } from '@mantine/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FormContextType,
|
|
6
|
-
labelValue,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
useFileWidgetProps,
|
|
10
|
-
WidgetProps,
|
|
11
|
-
} from '@rjsf/utils';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
4
|
+
import { ariaDescribedByIds, labelValue, useFileWidgetProps } from '@rjsf/utils';
|
|
12
5
|
|
|
13
6
|
import { cleanupOptions } from '../utils';
|
|
14
7
|
|
|
@@ -43,6 +36,7 @@ export default function FileWidget<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
43
36
|
(files: any) => {
|
|
44
37
|
if (typeof files === 'object') {
|
|
45
38
|
// handleChange is async; DOM event handlers are void-returning, so we intentionally don't await
|
|
39
|
+
// oxlint-disable-next-line no-floating-promises, no-void
|
|
46
40
|
void handleChange(files);
|
|
47
41
|
}
|
|
48
42
|
},
|
|
@@ -54,6 +48,7 @@ export default function FileWidget<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
54
48
|
return (
|
|
55
49
|
<Pill.Group>
|
|
56
50
|
{filesInfo.map((file, index) => (
|
|
51
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
57
52
|
<Pill key={index} withRemoveButton onRemove={() => handleRemove(index)}>
|
|
58
53
|
{file.name}
|
|
59
54
|
</Pill>
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { PasswordInput } from '@mantine/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FormContextType,
|
|
6
|
-
labelValue,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
WidgetProps,
|
|
10
|
-
} from '@rjsf/utils';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
5
|
+
import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
|
|
11
6
|
|
|
12
7
|
import { cleanupOptions } from '../utils';
|
|
13
8
|
|
|
@@ -39,7 +34,7 @@ export default function PasswordWidget<
|
|
|
39
34
|
onFocus,
|
|
40
35
|
} = props;
|
|
41
36
|
|
|
42
|
-
const emptyValue = options
|
|
37
|
+
const { emptyValue } = options;
|
|
43
38
|
const themeProps = cleanupOptions(options);
|
|
44
39
|
|
|
45
40
|
const handleChange = useCallback(
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { FocusEvent
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { Radio, Flex } from '@mantine/core';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
5
|
import {
|
|
4
6
|
ariaDescribedByIds,
|
|
5
7
|
enumOptionValueDecoder,
|
|
@@ -7,10 +9,6 @@ import {
|
|
|
7
9
|
enumOptionsIndexForValue,
|
|
8
10
|
getOptionValueFormat,
|
|
9
11
|
optionId,
|
|
10
|
-
FormContextType,
|
|
11
|
-
RJSFSchema,
|
|
12
|
-
StrictRJSFSchema,
|
|
13
|
-
WidgetProps,
|
|
14
12
|
} from '@rjsf/utils';
|
|
15
13
|
|
|
16
14
|
import { cleanupOptions } from '../utils';
|
|
@@ -90,11 +88,11 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
90
88
|
<Flex mt='xs' direction={inline ? 'row' : 'column'} gap='xs' wrap='wrap'>
|
|
91
89
|
{enumOptions.map((option, i) => (
|
|
92
90
|
<Radio
|
|
93
|
-
key={
|
|
91
|
+
key={String(option.value)}
|
|
94
92
|
id={optionId(id, i)}
|
|
95
93
|
value={enumOptionValueEncoder(option.value, i, optionValueFormat)}
|
|
96
94
|
label={option.label}
|
|
97
|
-
disabled={Array.isArray(enumDisabled) && enumDisabled.
|
|
95
|
+
disabled={Array.isArray(enumDisabled) && enumDisabled.includes(option.value)}
|
|
98
96
|
autoFocus={i === 0 && autofocus}
|
|
99
97
|
onBlur={handleBlur}
|
|
100
98
|
onFocus={handleFocus}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { Slider, Input } from '@mantine/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
rangeSpec,
|
|
6
|
-
FormContextType,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
WidgetProps,
|
|
10
|
-
titleId,
|
|
11
|
-
} from '@rjsf/utils';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
4
|
+
import { ariaDescribedByIds, rangeSpec, titleId } from '@rjsf/utils';
|
|
12
5
|
|
|
13
6
|
import { cleanupOptions } from '../utils';
|
|
14
7
|
|
|
@@ -88,6 +81,7 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
88
81
|
{rawErrors &&
|
|
89
82
|
rawErrors?.length > 0 &&
|
|
90
83
|
rawErrors.map((error: string, index: number) => (
|
|
84
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
91
85
|
<Input.Error key={`range-widget-input-errors-${index}`}>{error}</Input.Error>
|
|
92
86
|
))}
|
|
93
87
|
</>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { FocusEvent
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
2
3
|
import { Select, MultiSelect } from '@mantine/core';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
5
|
import {
|
|
4
6
|
ariaDescribedByIds,
|
|
5
7
|
enumOptionSelectedValue,
|
|
@@ -7,10 +9,6 @@ import {
|
|
|
7
9
|
enumOptionValueEncoder,
|
|
8
10
|
getOptionValueFormat,
|
|
9
11
|
labelValue,
|
|
10
|
-
FormContextType,
|
|
11
|
-
RJSFSchema,
|
|
12
|
-
StrictRJSFSchema,
|
|
13
|
-
WidgetProps,
|
|
14
12
|
} from '@rjsf/utils';
|
|
15
13
|
|
|
16
14
|
import { cleanupOptions } from '../utils';
|
|
@@ -79,7 +77,7 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
79
77
|
key: String(index),
|
|
80
78
|
value: enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
81
79
|
label: option.label,
|
|
82
|
-
disabled: Array.isArray(enumDisabled) && enumDisabled.
|
|
80
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.includes(option.value),
|
|
83
81
|
}));
|
|
84
82
|
}
|
|
85
83
|
return [];
|