@rjsf/primereact 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 +133 -118
- package/dist/index.cjs.map +3 -3
- package/dist/primereact.esm.js +147 -179
- package/dist/primereact.esm.js.map +3 -3
- package/dist/primereact.umd.js +130 -116
- package/lib/AddButton/AddButton.d.ts +1 -1
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js +1 -1
- package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js.map +1 -1
- package/lib/AutoCompleteWidget/AutoCompleteWidget.d.ts +1 -1
- package/lib/AutoCompleteWidget/AutoCompleteWidget.js +6 -6
- package/lib/AutoCompleteWidget/AutoCompleteWidget.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +6 -6
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +5 -5
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js +5 -5
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/ColorWidget/ColorWidget.d.ts +1 -1
- package/lib/ColorWidget/ColorWidget.js +5 -5
- package/lib/ColorWidget/ColorWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +1 -1
- package/lib/ErrorList/ErrorList.d.ts +1 -1
- package/lib/ErrorList/ErrorList.js +1 -1
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +2 -3
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.d.ts +1 -1
- package/lib/GridTemplate/GridTemplate.js +1 -1
- package/lib/GridTemplate/GridTemplate.js.map +1 -1
- package/lib/IconButton/IconButton.d.ts +15 -8
- package/lib/IconButton/IconButton.js +14 -6
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/PasswordWidget/PasswordWidget.d.ts +1 -1
- package/lib/PasswordWidget/PasswordWidget.js +5 -5
- package/lib/PasswordWidget/PasswordWidget.js.map +1 -1
- package/lib/PrimeForm/PrimeForm.d.ts +3 -3
- package/lib/PrimeForm/PrimeForm.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/RadioWidget/RadioWidget.js +5 -5
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +1 -1
- package/lib/RangeWidget/RangeWidget.js +5 -5
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +1 -1
- package/lib/SelectWidget/SelectWidget.js +18 -18
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.d.ts +1 -1
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/Templates/Templates.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
- package/lib/Theme/Theme.d.ts +2 -2
- package/lib/TitleField/TitleField.d.ts +1 -1
- package/lib/TitleField/TitleField.js.map +1 -1
- package/lib/UpDownWidget/UpDownWidget.d.ts +1 -1
- package/lib/UpDownWidget/UpDownWidget.js +5 -6
- package/lib/UpDownWidget/UpDownWidget.js.map +1 -1
- package/lib/Widgets/Widgets.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/AddButton/AddButton.tsx +2 -1
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +2 -8
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +2 -10
- package/src/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx +2 -8
- package/src/AutoCompleteWidget/AutoCompleteWidget.tsx +14 -18
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +13 -19
- package/src/CheckboxWidget/CheckboxWidget.tsx +10 -18
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +14 -13
- package/src/ColorWidget/ColorWidget.tsx +10 -16
- package/src/DescriptionField/DescriptionField.tsx +1 -1
- package/src/ErrorList/ErrorList.tsx +4 -3
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +4 -4
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -1
- package/src/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/GridTemplate/GridTemplate.tsx +2 -2
- package/src/IconButton/IconButton.tsx +18 -8
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +2 -12
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
- package/src/PasswordWidget/PasswordWidget.tsx +10 -16
- package/src/PrimeForm/PrimeForm.ts +4 -3
- package/src/RadioWidget/RadioWidget.tsx +11 -13
- package/src/RangeWidget/RangeWidget.tsx +18 -18
- package/src/SelectWidget/SelectWidget.tsx +25 -28
- package/src/SubmitButton/SubmitButton.tsx +2 -1
- package/src/Templates/Templates.ts +1 -1
- package/src/TextareaWidget/TextareaWidget.tsx +2 -2
- package/src/Theme/Theme.ts +2 -2
- package/src/TitleField/TitleField.tsx +2 -1
- package/src/UpDownWidget/UpDownWidget.tsx +13 -18
- package/src/Widgets/Widgets.tsx +1 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +2 -9
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
FormContextType,
|
|
5
|
-
getInputProps,
|
|
6
|
-
RJSFSchema,
|
|
7
|
-
StrictRJSFSchema,
|
|
8
|
-
WidgetProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds, getInputProps } from '@rjsf/utils';
|
|
10
4
|
import { ColorPicker } from 'primereact/colorpicker';
|
|
11
5
|
|
|
12
6
|
/** The `ColorWidget` component renders a color picker.
|
|
@@ -36,10 +30,10 @@ export default function ColorWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
36
30
|
const { inline } = options;
|
|
37
31
|
const primeProps = (options.prime || {}) as object;
|
|
38
32
|
|
|
39
|
-
const
|
|
40
|
-
onChange(
|
|
41
|
-
const
|
|
42
|
-
const
|
|
33
|
+
const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLInputElement>) =>
|
|
34
|
+
onChange(newValue === '' ? options.emptyValue : newValue);
|
|
35
|
+
const handleBlur = () => onBlur && onBlur(id, value);
|
|
36
|
+
const handleFocus = () => onFocus && onFocus(id, value);
|
|
43
37
|
|
|
44
38
|
return (
|
|
45
39
|
<ColorPicker
|
|
@@ -53,9 +47,9 @@ export default function ColorWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
53
47
|
autoFocus={autofocus}
|
|
54
48
|
disabled={disabled || readonly}
|
|
55
49
|
value={value || ''}
|
|
56
|
-
onChange={onChangeOverride ||
|
|
57
|
-
onBlur={
|
|
58
|
-
onFocus={
|
|
50
|
+
onChange={onChangeOverride || handleChange}
|
|
51
|
+
onBlur={handleBlur}
|
|
52
|
+
onFocus={handleFocus}
|
|
59
53
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
60
54
|
/>
|
|
61
55
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RichDescription } from '@rjsf/core';
|
|
2
|
-
import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import type { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
5
5
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema
|
|
1
|
+
import type { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
2
3
|
import { TimesCircleIcon } from 'primereact/icons/timescircle';
|
|
3
4
|
import { Message } from 'primereact/message';
|
|
4
5
|
|
|
@@ -19,8 +20,8 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
19
20
|
<div className='p-message-summary'>{translateString(TranslatableString.ErrorsLabel)}</div>
|
|
20
21
|
</div>
|
|
21
22
|
<ul className='p-message-list'>
|
|
22
|
-
{errors.map((error
|
|
23
|
-
<li key={
|
|
23
|
+
{errors.map((error) => (
|
|
24
|
+
<li key={error.stack}>{error.stack}</li>
|
|
24
25
|
))}
|
|
25
26
|
</ul>
|
|
26
27
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { errorId } from '@rjsf/utils';
|
|
2
3
|
import { Message } from 'primereact/message';
|
|
3
4
|
|
|
4
5
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -12,9 +13,8 @@ export default function FieldErrorTemplate<
|
|
|
12
13
|
>({ errors, fieldPathId }: FieldErrorProps<T, S, F>) {
|
|
13
14
|
if (errors && errors.length > 0) {
|
|
14
15
|
const id = errorId(fieldPathId);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
16
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
17
|
+
const content = errors.map((error, i: number) => <div key={i}>{error}</div>);
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<Message
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RichHelp } from '@rjsf/core';
|
|
2
|
-
import { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema
|
|
2
|
+
import type { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { helpId } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
5
6
|
*
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
FormContextType,
|
|
4
|
-
getTemplate,
|
|
5
|
-
getUiOptions,
|
|
6
|
-
RJSFSchema,
|
|
7
|
-
StrictRJSFSchema,
|
|
8
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate, getUiOptions } from '@rjsf/utils';
|
|
9
3
|
|
|
10
4
|
import { Label } from '../util';
|
|
11
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { GridTemplateProps } from '@rjsf/utils';
|
|
2
|
+
import type { GridTemplateProps } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
const breakpoints = {
|
|
5
5
|
xs: 0,
|
|
@@ -75,7 +75,7 @@ function GridTemplateColumn(props: GridTemplateProps) {
|
|
|
75
75
|
|
|
76
76
|
useEffect(() => {
|
|
77
77
|
if (typeof window === 'undefined') {
|
|
78
|
-
return;
|
|
78
|
+
return () => {};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const handleResize = () => setBreakpoint(getBreakpoint(window.innerWidth));
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
4
|
+
import type { ButtonProps } from 'primereact/button';
|
|
5
|
+
import { Button } from 'primereact/button';
|
|
3
6
|
|
|
4
7
|
export type PrimeIconButtonProps<
|
|
5
8
|
T = any,
|
|
@@ -7,14 +10,16 @@ export type PrimeIconButtonProps<
|
|
|
7
10
|
F extends FormContextType = any,
|
|
8
11
|
> = IconButtonProps<T, S, F> & Omit<ButtonProps, 'onClick'>;
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
function IconButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
11
14
|
props: PrimeIconButtonProps<T, S, F>,
|
|
12
15
|
) {
|
|
13
16
|
const { icon, iconType, uiSchema, registry, ...otherProps } = props;
|
|
14
17
|
return <Button icon={`pi pi-${icon}`} rounded text severity='secondary' {...otherProps} />;
|
|
15
18
|
}
|
|
19
|
+
const IconButton = memo(IconButtonFn) as typeof IconButtonFn;
|
|
20
|
+
export default IconButton;
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
function CopyButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
18
23
|
props: PrimeIconButtonProps<T, S, F>,
|
|
19
24
|
) {
|
|
20
25
|
const {
|
|
@@ -22,8 +27,9 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
22
27
|
} = props;
|
|
23
28
|
return <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon='copy' />;
|
|
24
29
|
}
|
|
30
|
+
export const CopyButton = memo(CopyButtonFn) as typeof CopyButtonFn;
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
function MoveDownButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
27
33
|
props: PrimeIconButtonProps<T, S, F>,
|
|
28
34
|
) {
|
|
29
35
|
const {
|
|
@@ -31,8 +37,9 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
31
37
|
} = props;
|
|
32
38
|
return <IconButton title={translateString(TranslatableString.MoveDownButton)} {...props} icon='angle-down' />;
|
|
33
39
|
}
|
|
40
|
+
export const MoveDownButton = memo(MoveDownButtonFn) as typeof MoveDownButtonFn;
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
function MoveUpButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
36
43
|
props: PrimeIconButtonProps<T, S, F>,
|
|
37
44
|
) {
|
|
38
45
|
const {
|
|
@@ -40,8 +47,9 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
40
47
|
} = props;
|
|
41
48
|
return <IconButton title={translateString(TranslatableString.MoveUpButton)} {...props} icon='angle-up' />;
|
|
42
49
|
}
|
|
50
|
+
export const MoveUpButton = memo(MoveUpButtonFn) as typeof MoveUpButtonFn;
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
function RemoveButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
45
53
|
props: PrimeIconButtonProps<T, S, F>,
|
|
46
54
|
) {
|
|
47
55
|
const {
|
|
@@ -49,8 +57,9 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
49
57
|
} = props;
|
|
50
58
|
return <IconButton title={translateString(TranslatableString.RemoveButton)} {...props} icon='trash' />;
|
|
51
59
|
}
|
|
60
|
+
export const RemoveButton = memo(RemoveButtonFn) as typeof RemoveButtonFn;
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
function ClearButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
54
63
|
props: PrimeIconButtonProps<T, S, F>,
|
|
55
64
|
) {
|
|
56
65
|
const {
|
|
@@ -58,3 +67,4 @@ export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
58
67
|
} = props;
|
|
59
68
|
return <IconButton title={translateString(TranslatableString.ClearButton)} {...props} icon='times' />;
|
|
60
69
|
}
|
|
70
|
+
export const ClearButton = memo(ClearButtonFn) as typeof ClearButtonFn;
|
|
@@ -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
|
import { Fieldset } from 'primereact/fieldset';
|
|
3
3
|
|
|
4
4
|
export default function MultiSchemaFieldTemplate<
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ObjectFieldTemplateProps,
|
|
4
|
-
RJSFSchema,
|
|
5
|
-
StrictRJSFSchema,
|
|
6
|
-
canExpand,
|
|
7
|
-
descriptionId,
|
|
8
|
-
getTemplate,
|
|
9
|
-
getUiOptions,
|
|
10
|
-
titleId,
|
|
11
|
-
buttonId,
|
|
12
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, buttonId } from '@rjsf/utils';
|
|
13
3
|
|
|
14
4
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
15
5
|
* 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 IconButton, { RemoveButton } from '../IconButton';
|
|
4
4
|
|
|
@@ -28,7 +28,8 @@ export default function OptionalDataControlsTemplate<
|
|
|
28
28
|
style={{ height: '1.5rem', width: '1.5rem' }} // Shrink the button
|
|
29
29
|
/>
|
|
30
30
|
);
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
|
+
if (onRemoveClick) {
|
|
32
33
|
return (
|
|
33
34
|
<RemoveButton
|
|
34
35
|
id={id}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
FormContextType,
|
|
5
|
-
getInputProps,
|
|
6
|
-
RJSFSchema,
|
|
7
|
-
StrictRJSFSchema,
|
|
8
|
-
WidgetProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds, getInputProps } from '@rjsf/utils';
|
|
10
4
|
import { Password } from 'primereact/password';
|
|
11
5
|
|
|
12
6
|
/** The `PasswordWidget` renders a `Password` component
|
|
@@ -38,10 +32,10 @@ export default function PasswordWidget<
|
|
|
38
32
|
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
39
33
|
const primeProps = (options.prime || {}) as object;
|
|
40
34
|
|
|
41
|
-
const
|
|
42
|
-
onChange(
|
|
43
|
-
const
|
|
44
|
-
const
|
|
35
|
+
const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLInputElement>) =>
|
|
36
|
+
onChange(newValue === '' ? options.emptyValue : newValue);
|
|
37
|
+
const handleBlur = () => onBlur && onBlur(id, value);
|
|
38
|
+
const handleFocus = () => onFocus && onFocus(id, value);
|
|
45
39
|
|
|
46
40
|
return (
|
|
47
41
|
<Password
|
|
@@ -55,9 +49,9 @@ export default function PasswordWidget<
|
|
|
55
49
|
disabled={disabled || readonly}
|
|
56
50
|
value={value || ''}
|
|
57
51
|
invalid={rawErrors.length > 0}
|
|
58
|
-
onChange={onChangeOverride ||
|
|
59
|
-
onBlur={
|
|
60
|
-
onFocus={
|
|
52
|
+
onChange={onChangeOverride || handleChange}
|
|
53
|
+
onBlur={handleBlur}
|
|
54
|
+
onFocus={handleFocus}
|
|
61
55
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
62
56
|
pt={{ root: { style: { display: 'flex', flexDirection: 'column' } } }}
|
|
63
57
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { FormProps } from '@rjsf/core';
|
|
3
|
+
import { withTheme } from '@rjsf/core';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
5
|
|
|
5
6
|
import { generateTheme } from '../Theme';
|
|
6
7
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
1
2
|
import {
|
|
2
3
|
ariaDescribedByIds,
|
|
3
4
|
enumOptionValueDecoder,
|
|
@@ -5,12 +6,9 @@ import {
|
|
|
5
6
|
enumOptionsIsSelected,
|
|
6
7
|
getOptionValueFormat,
|
|
7
8
|
optionId,
|
|
8
|
-
FormContextType,
|
|
9
|
-
RJSFSchema,
|
|
10
|
-
StrictRJSFSchema,
|
|
11
|
-
WidgetProps,
|
|
12
9
|
} from '@rjsf/utils';
|
|
13
|
-
import {
|
|
10
|
+
import type { RadioButtonChangeEvent } from 'primereact/radiobutton';
|
|
11
|
+
import { RadioButton } from 'primereact/radiobutton';
|
|
14
12
|
|
|
15
13
|
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
16
14
|
* It is typically used with a string property constrained with enum options.
|
|
@@ -25,28 +23,28 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
25
23
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
26
24
|
const optionValueFormat = getOptionValueFormat(options);
|
|
27
25
|
|
|
28
|
-
const
|
|
26
|
+
const handleChange = (e: RadioButtonChangeEvent) => {
|
|
29
27
|
onChange(enumOptionValueDecoder<S>(e.value, enumOptions, optionValueFormat, emptyValue));
|
|
30
28
|
};
|
|
31
29
|
|
|
32
|
-
const
|
|
33
|
-
const
|
|
30
|
+
const handleBlur = () => onBlur(id, value);
|
|
31
|
+
const handleFocus = () => onFocus(id, value);
|
|
34
32
|
|
|
35
33
|
return (
|
|
36
34
|
<div style={{ display: 'flex', flexDirection: 'row', gap: '1rem' }}>
|
|
37
35
|
{Array.isArray(enumOptions) &&
|
|
38
36
|
enumOptions.map((option, index) => {
|
|
39
37
|
const checked = enumOptionsIsSelected<S>(option.value, value);
|
|
40
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
38
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
41
39
|
return (
|
|
42
|
-
<div key={
|
|
40
|
+
<div key={String(option.value)} style={{ display: 'flex', alignItems: 'center' }}>
|
|
43
41
|
<RadioButton
|
|
44
42
|
inputId={optionId(id, index)}
|
|
45
43
|
name={htmlName || id}
|
|
46
44
|
{...primeProps}
|
|
47
|
-
onFocus={
|
|
48
|
-
onBlur={
|
|
49
|
-
onChange={
|
|
45
|
+
onFocus={handleFocus}
|
|
46
|
+
onBlur={handleBlur}
|
|
47
|
+
onChange={handleChange}
|
|
50
48
|
value={enumOptionValueEncoder(option.value, index, optionValueFormat)}
|
|
51
49
|
checked={checked}
|
|
52
50
|
disabled={disabled || itemDisabled || readonly}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { FocusEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds, rangeSpec } from '@rjsf/utils';
|
|
4
|
+
import type { SliderChangeEvent } from 'primereact/slider';
|
|
5
|
+
import { Slider } from 'primereact/slider';
|
|
4
6
|
|
|
5
7
|
/** The `RangeWidget` component uses the `Slider` from PrimeReact, wrapping the result
|
|
6
8
|
* in a div, with the value alongside it.
|
|
@@ -14,24 +16,22 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
14
16
|
const primeProps = (options.prime || {}) as object;
|
|
15
17
|
const sliderProps = { value, id, ...rangeSpec<S>(schema) };
|
|
16
18
|
|
|
17
|
-
const
|
|
19
|
+
const handleChange = (e: SliderChangeEvent) => {
|
|
18
20
|
onChange(e.value ?? options.emptyValue);
|
|
19
21
|
};
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
+
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
|
|
23
|
+
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
22
24
|
|
|
23
25
|
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/>
|
|
35
|
-
</>
|
|
26
|
+
<Slider
|
|
27
|
+
{...primeProps}
|
|
28
|
+
disabled={disabled || readonly}
|
|
29
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
30
|
+
onChange={handleChange}
|
|
31
|
+
onBlur={handleBlur}
|
|
32
|
+
onFocus={handleFocus}
|
|
33
|
+
{...sliderProps}
|
|
34
|
+
aria-describedby={ariaDescribedByIds(id)}
|
|
35
|
+
/>
|
|
36
36
|
);
|
|
37
37
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { FocusEvent } from 'react';
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import type { FormContextType, 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
|
-
RJSFSchema,
|
|
10
|
-
StrictRJSFSchema,
|
|
11
|
-
WidgetProps,
|
|
12
9
|
} from '@rjsf/utils';
|
|
13
10
|
import { Dropdown } from 'primereact/dropdown';
|
|
14
11
|
import { MultiSelect } from 'primereact/multiselect';
|
|
@@ -55,15 +52,15 @@ function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
55
52
|
const optionValueFormat = getOptionValueFormat(options);
|
|
56
53
|
const primeProps = (options.prime || {}) as object;
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
const isMultiple = typeof multiple === 'undefined' ? false : multiple;
|
|
59
56
|
|
|
60
|
-
const emptyValue =
|
|
57
|
+
const emptyValue = isMultiple ? [] : '';
|
|
61
58
|
|
|
62
|
-
const
|
|
59
|
+
const handleChange = (e: { value: any }) =>
|
|
63
60
|
onChange(enumOptionValueDecoder<S>(e.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
64
|
-
const
|
|
61
|
+
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
65
62
|
onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
66
|
-
const
|
|
63
|
+
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
67
64
|
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
68
65
|
const { ...dropdownRemainingProps } = dropdownProps;
|
|
69
66
|
|
|
@@ -72,15 +69,15 @@ function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
72
69
|
id={id}
|
|
73
70
|
name={htmlName || id}
|
|
74
71
|
{...primeProps}
|
|
75
|
-
value={enumOptionSelectedValue<S>(value, enumOptions,
|
|
76
|
-
options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
|
|
77
|
-
label,
|
|
78
|
-
value: enumOptionValueEncoder(
|
|
79
|
-
disabled: Array.isArray(enumDisabled) && enumDisabled.
|
|
72
|
+
value={enumOptionSelectedValue<S>(value, enumOptions, isMultiple, optionValueFormat, emptyValue)}
|
|
73
|
+
options={(enumOptions ?? []).map(({ value: enumValue, label: enumLabel }, i: number) => ({
|
|
74
|
+
label: enumLabel,
|
|
75
|
+
value: enumOptionValueEncoder(enumValue, i, optionValueFormat),
|
|
76
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.includes(enumValue),
|
|
80
77
|
}))}
|
|
81
|
-
onChange={
|
|
82
|
-
onBlur={
|
|
83
|
-
onFocus={
|
|
78
|
+
onChange={handleChange}
|
|
79
|
+
onBlur={handleBlur}
|
|
80
|
+
onFocus={handleFocus}
|
|
84
81
|
placeholder={placeholder}
|
|
85
82
|
disabled={disabled || readonly}
|
|
86
83
|
autoFocus={autofocus}
|
|
@@ -110,11 +107,11 @@ function MultiSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
110
107
|
|
|
111
108
|
const emptyValue = multiple ? [] : '';
|
|
112
109
|
|
|
113
|
-
const
|
|
110
|
+
const handleChange = (e: { value: any }) =>
|
|
114
111
|
onChange(enumOptionValueDecoder<S>(e.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
115
|
-
const
|
|
112
|
+
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
116
113
|
onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
117
|
-
const
|
|
114
|
+
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
118
115
|
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
119
116
|
|
|
120
117
|
return (
|
|
@@ -123,14 +120,14 @@ function MultiSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
123
120
|
name={htmlName || id}
|
|
124
121
|
{...primeProps}
|
|
125
122
|
value={enumOptionSelectedValue<S>(value, enumOptions, multiple, optionValueFormat, emptyValue)}
|
|
126
|
-
options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
|
|
127
|
-
label,
|
|
128
|
-
value: enumOptionValueEncoder(
|
|
129
|
-
disabled: Array.isArray(enumDisabled) && enumDisabled.
|
|
123
|
+
options={(enumOptions ?? []).map(({ value: enumValue, label: enumLabel }, i: number) => ({
|
|
124
|
+
label: enumLabel,
|
|
125
|
+
value: enumOptionValueEncoder(enumValue, i, optionValueFormat),
|
|
126
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.includes(enumValue),
|
|
130
127
|
}))}
|
|
131
|
-
onChange={
|
|
132
|
-
onBlur={
|
|
133
|
-
onFocus={
|
|
128
|
+
onChange={handleChange}
|
|
129
|
+
onBlur={handleBlur}
|
|
130
|
+
onFocus={handleFocus}
|
|
134
131
|
placeholder={placeholder}
|
|
135
132
|
disabled={disabled || readonly}
|
|
136
133
|
autoFocus={autofocus}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
|
|
2
|
+
import { getSubmitButtonOptions } from '@rjsf/utils';
|
|
2
3
|
import { Button } from 'primereact/button';
|
|
3
4
|
|
|
4
5
|
/** The `SubmitButton` renders a button that represents the `Submit` action on a form
|
|
@@ -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 ArrayFieldItemTemplate from '../ArrayFieldItemTemplate';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
2
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
3
|
import { InputTextarea } from 'primereact/inputtextarea';
|
|
4
4
|
|
|
5
5
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea using PrimeReact.
|
package/src/Theme/Theme.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ThemeProps } from '@rjsf/core';
|
|
2
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ThemeProps } from '@rjsf/core';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
import { generateTemplates } from '../Templates';
|
|
5
5
|
import { generateWidgets } from '../Widgets';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FormContextType,
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
|
|
2
|
+
import { getUiOptions, titleId } from '@rjsf/utils';
|
|
2
3
|
import { Divider } from 'primereact/divider';
|
|
3
4
|
|
|
4
5
|
/** The `TitleField` is the template to use to render the title of a field
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
WidgetProps,
|
|
8
|
-
} from '@rjsf/utils';
|
|
9
|
-
import { InputNumber, InputNumberChangeEvent } from 'primereact/inputnumber';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
import { ariaDescribedByIds, getInputProps } from '@rjsf/utils';
|
|
3
|
+
import type { InputNumberChangeEvent } from 'primereact/inputnumber';
|
|
4
|
+
import { InputNumber } from 'primereact/inputnumber';
|
|
10
5
|
|
|
11
6
|
/** The `UpDownWidget` renders an input component for a number.
|
|
12
7
|
*
|
|
@@ -36,9 +31,9 @@ export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
36
31
|
const { showButtons, buttonLayout, useGrouping, minFractionDigits, maxFractionDigits, locale, currency } = options;
|
|
37
32
|
const primeProps = (options.prime || {}) as object;
|
|
38
33
|
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
34
|
+
const handleChange = (event: InputNumberChangeEvent) => onChange(event.value === null ? options.emptyValue : value);
|
|
35
|
+
const handleBlur = () => onBlur && onBlur(id, value);
|
|
36
|
+
const handleFocus = () => onFocus && onFocus(id, value);
|
|
42
37
|
|
|
43
38
|
return (
|
|
44
39
|
<InputNumber
|
|
@@ -46,24 +41,24 @@ export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
46
41
|
name={id}
|
|
47
42
|
{...primeProps}
|
|
48
43
|
placeholder={placeholder}
|
|
49
|
-
step={isNaN(Number(inputProps.step)) ? 1 : Number(inputProps.step)}
|
|
44
|
+
step={Number.isNaN(Number(inputProps.step)) ? 1 : Number(inputProps.step)}
|
|
50
45
|
required={required}
|
|
51
46
|
autoFocus={autofocus}
|
|
52
47
|
disabled={disabled || readonly}
|
|
53
48
|
style={buttonLayout === 'vertical' ? { width: '4em' } : {}}
|
|
54
49
|
showButtons={typeof showButtons === 'undefined' ? true : !!showButtons}
|
|
55
|
-
buttonLayout={
|
|
50
|
+
buttonLayout={buttonLayout ?? 'stacked'}
|
|
56
51
|
useGrouping={!!useGrouping}
|
|
57
52
|
minFractionDigits={minFractionDigits as number}
|
|
58
53
|
maxFractionDigits={maxFractionDigits as number}
|
|
59
54
|
locale={locale as string}
|
|
60
55
|
mode={currency ? 'currency' : 'decimal'}
|
|
61
56
|
currency={currency as string}
|
|
62
|
-
value={isNaN(Number(value)) ? null : Number(value)}
|
|
57
|
+
value={Number.isNaN(Number(value)) ? null : Number(value)}
|
|
63
58
|
invalid={rawErrors.length > 0}
|
|
64
|
-
onChange={
|
|
65
|
-
onBlur={
|
|
66
|
-
onFocus={
|
|
59
|
+
onChange={onChangeOverride || handleChange}
|
|
60
|
+
onBlur={handleBlur}
|
|
61
|
+
onFocus={handleFocus}
|
|
67
62
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
68
63
|
/>
|
|
69
64
|
);
|
package/src/Widgets/Widgets.tsx
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 AutoCompleteWidget from '../AutoCompleteWidget/AutoCompleteWidget';
|
|
4
4
|
import CheckboxesWidget from '../CheckboxesWidget/CheckboxesWidget';
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
buttonId,
|
|
4
|
-
FormContextType,
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
TranslatableString,
|
|
8
|
-
WrapIfAdditionalTemplateProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
|
|
2
|
+
import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString } from '@rjsf/utils';
|
|
10
3
|
import { InputText } from 'primereact/inputtext';
|
|
11
4
|
|
|
12
5
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|