@rjsf/primereact 6.0.0-beta.11
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/README.md +120 -0
- package/dist/index.js +1285 -0
- package/dist/index.js.map +7 -0
- package/dist/primereact.esm.js +1327 -0
- package/dist/primereact.esm.js.map +7 -0
- package/dist/primereact.umd.js +1135 -0
- package/lib/AddButton/AddButton.d.ts +4 -0
- package/lib/AddButton/AddButton.js +10 -0
- package/lib/AddButton/AddButton.js.map +1 -0
- package/lib/AddButton/index.d.ts +2 -0
- package/lib/AddButton/index.js +3 -0
- package/lib/AddButton/index.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +6 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +13 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldItemTemplate/index.js +3 -0
- package/lib/ArrayFieldItemTemplate/index.js.map +1 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +6 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +30 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
- package/lib/ArrayFieldTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldTemplate/index.js +3 -0
- package/lib/ArrayFieldTemplate/index.js.map +1 -0
- package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.d.ts +6 -0
- package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js +11 -0
- package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js.map +1 -0
- package/lib/ArrayFieldTitleTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldTitleTemplate/index.js +3 -0
- package/lib/ArrayFieldTitleTemplate/index.js.map +1 -0
- package/lib/AutoCompleteWidget/AutoCompleteWidget.d.ts +7 -0
- package/lib/AutoCompleteWidget/AutoCompleteWidget.js +42 -0
- package/lib/AutoCompleteWidget/AutoCompleteWidget.js.map +1 -0
- package/lib/AutoCompleteWidget/index.d.ts +2 -0
- package/lib/AutoCompleteWidget/index.js +3 -0
- package/lib/AutoCompleteWidget/index.js.map +1 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +4 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js +19 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
- package/lib/BaseInputTemplate/index.d.ts +2 -0
- package/lib/BaseInputTemplate/index.js +3 -0
- package/lib/BaseInputTemplate/index.js.map +1 -0
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +7 -0
- package/lib/CheckboxWidget/CheckboxWidget.js +23 -0
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -0
- package/lib/CheckboxWidget/index.d.ts +2 -0
- package/lib/CheckboxWidget/index.js +3 -0
- package/lib/CheckboxWidget/index.js.map +1 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +7 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js +35 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
- package/lib/CheckboxesWidget/index.d.ts +2 -0
- package/lib/CheckboxesWidget/index.js +3 -0
- package/lib/CheckboxesWidget/index.js.map +1 -0
- package/lib/ColorWidget/ColorWidget.d.ts +6 -0
- package/lib/ColorWidget/ColorWidget.js +18 -0
- package/lib/ColorWidget/ColorWidget.js.map +1 -0
- package/lib/ColorWidget/index.d.ts +2 -0
- package/lib/ColorWidget/index.js +3 -0
- package/lib/ColorWidget/index.js.map +1 -0
- package/lib/DescriptionField/DescriptionField.d.ts +6 -0
- package/lib/DescriptionField/DescriptionField.js +14 -0
- package/lib/DescriptionField/DescriptionField.js.map +1 -0
- package/lib/DescriptionField/index.d.ts +2 -0
- package/lib/DescriptionField/index.js +3 -0
- package/lib/DescriptionField/index.js.map +1 -0
- package/lib/ErrorList/ErrorList.d.ts +6 -0
- package/lib/ErrorList/ErrorList.js +21 -0
- package/lib/ErrorList/ErrorList.js.map +1 -0
- package/lib/ErrorList/index.d.ts +2 -0
- package/lib/ErrorList/index.js +3 -0
- package/lib/ErrorList/index.js.map +1 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +6 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +18 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
- package/lib/FieldErrorTemplate/index.d.ts +2 -0
- package/lib/FieldErrorTemplate/index.js +3 -0
- package/lib/FieldErrorTemplate/index.js.map +1 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +6 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +15 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
- package/lib/FieldHelpTemplate/index.d.ts +2 -0
- package/lib/FieldHelpTemplate/index.js +3 -0
- package/lib/FieldHelpTemplate/index.js.map +1 -0
- package/lib/FieldTemplate/FieldTemplate.d.ts +2 -0
- package/lib/FieldTemplate/FieldTemplate.js +13 -0
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/FieldTemplate/index.d.ts +2 -0
- package/lib/FieldTemplate/index.js +3 -0
- package/lib/FieldTemplate/index.js.map +1 -0
- package/lib/GridTemplate/GridTemplate.d.ts +8 -0
- package/lib/GridTemplate/GridTemplate.js +69 -0
- package/lib/GridTemplate/GridTemplate.js.map +1 -0
- package/lib/GridTemplate/index.d.ts +2 -0
- package/lib/GridTemplate/index.js +3 -0
- package/lib/GridTemplate/index.js.map +1 -0
- package/lib/IconButton/IconButton.d.ts +7 -0
- package/lib/IconButton/IconButton.js +25 -0
- package/lib/IconButton/IconButton.js.map +1 -0
- package/lib/IconButton/index.d.ts +2 -0
- package/lib/IconButton/index.js +3 -0
- package/lib/IconButton/index.js.map +1 -0
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -0
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +7 -0
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -0
- package/lib/MultiSchemaFieldTemplate/index.d.ts +2 -0
- package/lib/MultiSchemaFieldTemplate/index.js +3 -0
- package/lib/MultiSchemaFieldTemplate/index.js.map +1 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +8 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +18 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
- package/lib/ObjectFieldTemplate/index.d.ts +2 -0
- package/lib/ObjectFieldTemplate/index.js +3 -0
- package/lib/ObjectFieldTemplate/index.js.map +1 -0
- package/lib/PasswordWidget/PasswordWidget.d.ts +6 -0
- package/lib/PasswordWidget/PasswordWidget.js +17 -0
- package/lib/PasswordWidget/PasswordWidget.js.map +1 -0
- package/lib/PasswordWidget/index.d.ts +2 -0
- package/lib/PasswordWidget/index.js +3 -0
- package/lib/PasswordWidget/index.js.map +1 -0
- package/lib/PrimeForm/PrimeForm.d.ts +6 -0
- package/lib/PrimeForm/PrimeForm.js +7 -0
- package/lib/PrimeForm/PrimeForm.js.map +1 -0
- package/lib/PrimeForm/index.d.ts +2 -0
- package/lib/PrimeForm/index.js +3 -0
- package/lib/PrimeForm/index.js.map +1 -0
- package/lib/RadioWidget/RadioWidget.d.ts +7 -0
- package/lib/RadioWidget/RadioWidget.js +25 -0
- package/lib/RadioWidget/RadioWidget.js.map +1 -0
- package/lib/RadioWidget/index.d.ts +2 -0
- package/lib/RadioWidget/index.js +3 -0
- package/lib/RadioWidget/index.js.map +1 -0
- package/lib/RangeWidget/RangeWidget.d.ts +7 -0
- package/lib/RangeWidget/RangeWidget.js +21 -0
- package/lib/RangeWidget/RangeWidget.js.map +1 -0
- package/lib/RangeWidget/index.d.ts +2 -0
- package/lib/RangeWidget/index.js +3 -0
- package/lib/RangeWidget/index.js.map +1 -0
- package/lib/SelectWidget/SelectWidget.d.ts +7 -0
- package/lib/SelectWidget/SelectWidget.js +47 -0
- package/lib/SelectWidget/SelectWidget.js.map +1 -0
- package/lib/SelectWidget/index.d.ts +2 -0
- package/lib/SelectWidget/index.js +3 -0
- package/lib/SelectWidget/index.js.map +1 -0
- package/lib/SubmitButton/SubmitButton.d.ts +4 -0
- package/lib/SubmitButton/SubmitButton.js +13 -0
- package/lib/SubmitButton/SubmitButton.js.map +1 -0
- package/lib/SubmitButton/index.d.ts +2 -0
- package/lib/SubmitButton/index.js +3 -0
- package/lib/SubmitButton/index.js.map +1 -0
- package/lib/Templates/Templates.d.ts +4 -0
- package/lib/Templates/Templates.js +45 -0
- package/lib/Templates/Templates.js.map +1 -0
- package/lib/Templates/index.d.ts +2 -0
- package/lib/Templates/index.js +3 -0
- package/lib/Templates/index.js.map +1 -0
- package/lib/TextareaWidget/TextareaWidget.d.ts +6 -0
- package/lib/TextareaWidget/TextareaWidget.js +20 -0
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -0
- package/lib/TextareaWidget/index.d.ts +2 -0
- package/lib/TextareaWidget/index.js +3 -0
- package/lib/TextareaWidget/index.js.map +1 -0
- package/lib/Theme/Theme.d.ts +5 -0
- package/lib/Theme/Theme.js +10 -0
- package/lib/Theme/Theme.js.map +1 -0
- package/lib/Theme/index.d.ts +2 -0
- package/lib/Theme/index.js +3 -0
- package/lib/Theme/index.js.map +1 -0
- package/lib/TitleField/TitleField.d.ts +6 -0
- package/lib/TitleField/TitleField.js +12 -0
- package/lib/TitleField/TitleField.js.map +1 -0
- package/lib/TitleField/index.d.ts +2 -0
- package/lib/TitleField/index.js +3 -0
- package/lib/TitleField/index.js.map +1 -0
- package/lib/UpDownWidget/UpDownWidget.d.ts +6 -0
- package/lib/UpDownWidget/UpDownWidget.js +19 -0
- package/lib/UpDownWidget/UpDownWidget.js.map +1 -0
- package/lib/UpDownWidget/index.d.ts +2 -0
- package/lib/UpDownWidget/index.js +3 -0
- package/lib/UpDownWidget/index.js.map +1 -0
- package/lib/Widgets/Widgets.d.ts +4 -0
- package/lib/Widgets/Widgets.js +26 -0
- package/lib/Widgets/Widgets.js.map +1 -0
- package/lib/Widgets/index.d.ts +2 -0
- package/lib/Widgets/index.js +3 -0
- package/lib/Widgets/index.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +7 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +20 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/index.d.ts +2 -0
- package/lib/WrapIfAdditionalTemplate/index.js +3 -0
- package/lib/WrapIfAdditionalTemplate/index.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/util.d.ts +5 -0
- package/lib/util.js +8 -0
- package/lib/util.js.map +1 -0
- package/package.json +104 -0
- package/src/AddButton/AddButton.tsx +23 -0
- package/src/AddButton/index.ts +2 -0
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +40 -0
- package/src/ArrayFieldItemTemplate/index.ts +2 -0
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +111 -0
- package/src/ArrayFieldTemplate/index.ts +2 -0
- package/src/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx +25 -0
- package/src/ArrayFieldTitleTemplate/index.ts +2 -0
- package/src/AutoCompleteWidget/AutoCompleteWidget.tsx +96 -0
- package/src/AutoCompleteWidget/index.ts +2 -0
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +71 -0
- package/src/BaseInputTemplate/index.ts +2 -0
- package/src/CheckboxWidget/CheckboxWidget.tsx +86 -0
- package/src/CheckboxWidget/index.ts +2 -0
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +105 -0
- package/src/CheckboxesWidget/index.ts +2 -0
- package/src/ColorWidget/ColorWidget.tsx +62 -0
- package/src/ColorWidget/index.ts +2 -0
- package/src/DescriptionField/DescriptionField.tsx +22 -0
- package/src/DescriptionField/index.ts +2 -0
- package/src/ErrorList/ErrorList.tsx +44 -0
- package/src/ErrorList/index.ts +2 -0
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +30 -0
- package/src/FieldErrorTemplate/index.ts +2 -0
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +18 -0
- package/src/FieldHelpTemplate/index.ts +2 -0
- package/src/FieldTemplate/FieldTemplate.tsx +40 -0
- package/src/FieldTemplate/index.ts +2 -0
- package/src/GridTemplate/GridTemplate.tsx +93 -0
- package/src/GridTemplate/index.ts +2 -0
- package/src/IconButton/IconButton.tsx +47 -0
- package/src/IconButton/index.ts +2 -0
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +17 -0
- package/src/MultiSchemaFieldTemplate/index.ts +2 -0
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +88 -0
- package/src/ObjectFieldTemplate/index.ts +2 -0
- package/src/PasswordWidget/PasswordWidget.tsx +65 -0
- package/src/PasswordWidget/index.ts +2 -0
- package/src/PrimeForm/PrimeForm.ts +15 -0
- package/src/PrimeForm/index.ts +2 -0
- package/src/RadioWidget/RadioWidget.tsx +60 -0
- package/src/RadioWidget/index.ts +2 -0
- package/src/RangeWidget/RangeWidget.tsx +37 -0
- package/src/RangeWidget/index.ts +2 -0
- package/src/SelectWidget/SelectWidget.tsx +139 -0
- package/src/SelectWidget/index.ts +2 -0
- package/src/SubmitButton/SubmitButton.tsx +16 -0
- package/src/SubmitButton/index.ts +2 -0
- package/src/Templates/Templates.ts +52 -0
- package/src/Templates/index.ts +2 -0
- package/src/TextareaWidget/TextareaWidget.tsx +41 -0
- package/src/TextareaWidget/index.ts +2 -0
- package/src/Theme/Theme.ts +18 -0
- package/src/Theme/index.ts +2 -0
- package/src/TitleField/TitleField.tsx +23 -0
- package/src/TitleField/index.ts +2 -0
- package/src/UpDownWidget/UpDownWidget.tsx +70 -0
- package/src/UpDownWidget/index.ts +2 -0
- package/src/Widgets/Widgets.tsx +33 -0
- package/src/Widgets/index.ts +2 -0
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +83 -0
- package/src/WrapIfAdditionalTemplate/index.ts +2 -0
- package/src/index.ts +8 -0
- package/src/tsconfig.json +24 -0
- package/src/util.tsx +11 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { GridTemplateProps } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
const breakpoints = {
|
|
5
|
+
xs: 0,
|
|
6
|
+
sm: 576,
|
|
7
|
+
md: 768,
|
|
8
|
+
lg: 992,
|
|
9
|
+
xl: 1200,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Breakpoint = keyof typeof breakpoints;
|
|
13
|
+
type ResponsiveSpan = Partial<Record<Breakpoint, number>>;
|
|
14
|
+
|
|
15
|
+
function getBreakpoint(width: number): Breakpoint {
|
|
16
|
+
if (width >= breakpoints.xl) {
|
|
17
|
+
return 'xl';
|
|
18
|
+
}
|
|
19
|
+
if (width >= breakpoints.lg) {
|
|
20
|
+
return 'lg';
|
|
21
|
+
}
|
|
22
|
+
if (width >= breakpoints.md) {
|
|
23
|
+
return 'md';
|
|
24
|
+
}
|
|
25
|
+
if (width >= breakpoints.sm) {
|
|
26
|
+
return 'sm';
|
|
27
|
+
}
|
|
28
|
+
return 'xs';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getResponsiveSpan(spanDef: ResponsiveSpan, breakpoint: Breakpoint): number {
|
|
32
|
+
return spanDef[breakpoint] ?? spanDef.xl ?? spanDef.lg ?? spanDef.md ?? spanDef.sm ?? spanDef.xs ?? 12;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getInitialWidth(): number {
|
|
36
|
+
return typeof window !== 'undefined' ? window.innerWidth : breakpoints.xs;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Renders a `GridTemplate`, which is expecting the column size for each viewport breakpoint (xs, sm, md, lg, xl)
|
|
40
|
+
* coming in via the extra props provided by the caller.
|
|
41
|
+
* Uses a 12 column grid by default. This can be overridden by passing `layoutGrid` in `uiSchema`.
|
|
42
|
+
*
|
|
43
|
+
* @param props - The GridTemplateProps, including the extra props containing the grid sizing details
|
|
44
|
+
*/
|
|
45
|
+
export default function GridTemplate(props: GridTemplateProps) {
|
|
46
|
+
return props.column ? GridTemplateColumn(props) : GridTemplateRow(props);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function GridTemplateRow(props: GridTemplateProps) {
|
|
50
|
+
const { children, column, uiSchema, style, ...rest } = props;
|
|
51
|
+
const layoutGrid = uiSchema?.['ui:layoutGrid'] ?? {};
|
|
52
|
+
const totalColumns = layoutGrid.columns ?? 12;
|
|
53
|
+
const gap = layoutGrid.gap ?? '16px';
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
style={{
|
|
58
|
+
display: 'grid',
|
|
59
|
+
gridTemplateColumns: `repeat(${totalColumns}, 1fr)`,
|
|
60
|
+
alignItems: 'start',
|
|
61
|
+
gap,
|
|
62
|
+
...(style ?? {}),
|
|
63
|
+
}}
|
|
64
|
+
{...rest}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function GridTemplateColumn(props: GridTemplateProps) {
|
|
72
|
+
const { children, column, uiSchema, xs, sm, md, lg, xl, style, ...rest } = props;
|
|
73
|
+
|
|
74
|
+
const [breakpoint, setBreakpoint] = useState<Breakpoint>(() => getBreakpoint(getInitialWidth()));
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (typeof window === 'undefined') {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handleResize = () => setBreakpoint(getBreakpoint(window.innerWidth));
|
|
82
|
+
window.addEventListener('resize', handleResize);
|
|
83
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
86
|
+
const span = getResponsiveSpan(props as ResponsiveSpan, breakpoint);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div style={{ gridColumn: `span ${span} / span ${span}`, ...(style ?? {}) }} {...rest}>
|
|
90
|
+
{children}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Button } from 'primereact/button';
|
|
2
|
+
import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
5
|
+
props: IconButtonProps<T, S, F>,
|
|
6
|
+
) {
|
|
7
|
+
const { icon, iconType, uiSchema, registry, ...otherProps } = props;
|
|
8
|
+
return <Button icon={`pi pi-${icon}`} rounded text severity='secondary' {...otherProps} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default IconButton;
|
|
12
|
+
|
|
13
|
+
export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
14
|
+
props: IconButtonProps<T, S, F>,
|
|
15
|
+
) {
|
|
16
|
+
const {
|
|
17
|
+
registry: { translateString },
|
|
18
|
+
} = props;
|
|
19
|
+
return <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon='copy' />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
23
|
+
props: IconButtonProps<T, S, F>,
|
|
24
|
+
) {
|
|
25
|
+
const {
|
|
26
|
+
registry: { translateString },
|
|
27
|
+
} = props;
|
|
28
|
+
return <IconButton title={translateString(TranslatableString.MoveDownButton)} {...props} icon='angle-down' />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
32
|
+
props: IconButtonProps<T, S, F>,
|
|
33
|
+
) {
|
|
34
|
+
const {
|
|
35
|
+
registry: { translateString },
|
|
36
|
+
} = props;
|
|
37
|
+
return <IconButton title={translateString(TranslatableString.MoveUpButton)} {...props} icon='angle-up' />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
41
|
+
props: IconButtonProps<T, S, F>,
|
|
42
|
+
) {
|
|
43
|
+
const {
|
|
44
|
+
registry: { translateString },
|
|
45
|
+
} = props;
|
|
46
|
+
return <IconButton title={translateString(TranslatableString.RemoveButton)} {...props} icon='trash' />;
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { Fieldset } from 'primereact/fieldset';
|
|
3
|
+
|
|
4
|
+
export default function MultiSchemaFieldTemplate<
|
|
5
|
+
T = any,
|
|
6
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
7
|
+
F extends FormContextType = any,
|
|
8
|
+
>(props: MultiSchemaFieldTemplateProps<T, S, F>) {
|
|
9
|
+
const { selector, optionSchemaField } = props;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Fieldset>
|
|
13
|
+
<div style={{ marginBottom: '1rem' }}>{selector}</div>
|
|
14
|
+
{optionSchemaField}
|
|
15
|
+
</Fieldset>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormContextType,
|
|
3
|
+
ObjectFieldTemplateProps,
|
|
4
|
+
RJSFSchema,
|
|
5
|
+
StrictRJSFSchema,
|
|
6
|
+
canExpand,
|
|
7
|
+
descriptionId,
|
|
8
|
+
getTemplate,
|
|
9
|
+
getUiOptions,
|
|
10
|
+
titleId,
|
|
11
|
+
buttonId,
|
|
12
|
+
} from '@rjsf/utils';
|
|
13
|
+
|
|
14
|
+
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
15
|
+
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
16
|
+
* the properties.
|
|
17
|
+
*
|
|
18
|
+
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
19
|
+
*/
|
|
20
|
+
export default function ObjectFieldTemplate<
|
|
21
|
+
T = any,
|
|
22
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
23
|
+
F extends FormContextType = any,
|
|
24
|
+
>(props: ObjectFieldTemplateProps<T, S, F>) {
|
|
25
|
+
const {
|
|
26
|
+
description,
|
|
27
|
+
onAddClick,
|
|
28
|
+
title,
|
|
29
|
+
properties,
|
|
30
|
+
disabled,
|
|
31
|
+
readonly,
|
|
32
|
+
required,
|
|
33
|
+
uiSchema,
|
|
34
|
+
schema,
|
|
35
|
+
formData,
|
|
36
|
+
idSchema,
|
|
37
|
+
registry,
|
|
38
|
+
} = props;
|
|
39
|
+
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
40
|
+
const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, uiOptions);
|
|
41
|
+
const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
|
|
42
|
+
'DescriptionFieldTemplate',
|
|
43
|
+
registry,
|
|
44
|
+
uiOptions,
|
|
45
|
+
);
|
|
46
|
+
// Button templates are not overridden in the uiSchema
|
|
47
|
+
const {
|
|
48
|
+
ButtonTemplates: { AddButton },
|
|
49
|
+
} = registry.templates;
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
{title && (
|
|
53
|
+
<TitleFieldTemplate
|
|
54
|
+
id={titleId<T>(idSchema)}
|
|
55
|
+
title={title}
|
|
56
|
+
required={required}
|
|
57
|
+
schema={schema}
|
|
58
|
+
uiSchema={uiSchema}
|
|
59
|
+
registry={registry}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
{description && (
|
|
63
|
+
<div style={{ marginBottom: '1rem' }}>
|
|
64
|
+
<DescriptionFieldTemplate
|
|
65
|
+
id={descriptionId<T>(idSchema)}
|
|
66
|
+
description={description}
|
|
67
|
+
schema={schema}
|
|
68
|
+
uiSchema={uiSchema}
|
|
69
|
+
registry={registry}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
{properties.map((prop) => prop.content)}
|
|
74
|
+
{canExpand<T, S, F>(schema, uiSchema, formData) && (
|
|
75
|
+
<div style={{ marginTop: '1rem', textAlign: 'right' }}>
|
|
76
|
+
<AddButton
|
|
77
|
+
id={buttonId<T>(idSchema, 'add')}
|
|
78
|
+
className='rjsf-object-property-expand'
|
|
79
|
+
icon='pi pi-plus'
|
|
80
|
+
onClick={onAddClick(schema)}
|
|
81
|
+
disabled={disabled || readonly}
|
|
82
|
+
registry={registry}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
)}
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ariaDescribedByIds,
|
|
4
|
+
FormContextType,
|
|
5
|
+
getInputProps,
|
|
6
|
+
RJSFSchema,
|
|
7
|
+
StrictRJSFSchema,
|
|
8
|
+
WidgetProps,
|
|
9
|
+
} from '@rjsf/utils';
|
|
10
|
+
import { Password } from 'primereact/password';
|
|
11
|
+
|
|
12
|
+
/** The `PasswordWidget` renders a `Password` component
|
|
13
|
+
*
|
|
14
|
+
* @param props - The `WidgetProps` for this component
|
|
15
|
+
*/
|
|
16
|
+
export default function PasswordWidget<
|
|
17
|
+
T = any,
|
|
18
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
19
|
+
F extends FormContextType = any,
|
|
20
|
+
>(props: WidgetProps<T, S, F>) {
|
|
21
|
+
const {
|
|
22
|
+
id,
|
|
23
|
+
placeholder,
|
|
24
|
+
value,
|
|
25
|
+
required,
|
|
26
|
+
readonly,
|
|
27
|
+
disabled,
|
|
28
|
+
onChange,
|
|
29
|
+
onChangeOverride,
|
|
30
|
+
onBlur,
|
|
31
|
+
onFocus,
|
|
32
|
+
autofocus,
|
|
33
|
+
options,
|
|
34
|
+
schema,
|
|
35
|
+
type,
|
|
36
|
+
rawErrors = [],
|
|
37
|
+
} = props;
|
|
38
|
+
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
39
|
+
const primeProps = (options.prime || {}) as object;
|
|
40
|
+
|
|
41
|
+
const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
|
|
42
|
+
onChange(value === '' ? options.emptyValue : value);
|
|
43
|
+
const _onBlur = () => onBlur && onBlur(id, value);
|
|
44
|
+
const _onFocus = () => onFocus && onFocus(id, value);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Password
|
|
48
|
+
id={id}
|
|
49
|
+
name={id}
|
|
50
|
+
placeholder={placeholder}
|
|
51
|
+
{...primeProps}
|
|
52
|
+
{...inputProps}
|
|
53
|
+
required={required}
|
|
54
|
+
autoFocus={autofocus}
|
|
55
|
+
disabled={disabled || readonly}
|
|
56
|
+
value={value || ''}
|
|
57
|
+
invalid={rawErrors.length > 0}
|
|
58
|
+
onChange={onChangeOverride || _onChange}
|
|
59
|
+
onBlur={_onBlur}
|
|
60
|
+
onFocus={_onFocus}
|
|
61
|
+
aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
|
|
62
|
+
pt={{ root: { style: { display: 'flex', flexDirection: 'column' } } }}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { withTheme, FormProps } from '@rjsf/core';
|
|
3
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
|
+
|
|
5
|
+
import { generateTheme } from '../Theme';
|
|
6
|
+
|
|
7
|
+
export function generateForm<
|
|
8
|
+
T = any,
|
|
9
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
10
|
+
F extends FormContextType = any,
|
|
11
|
+
>(): ComponentType<FormProps<T, S, F>> {
|
|
12
|
+
return withTheme<T, S, F>(generateTheme<T, S, F>());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default generateForm();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ariaDescribedByIds,
|
|
3
|
+
enumOptionsIsSelected,
|
|
4
|
+
enumOptionsValueForIndex,
|
|
5
|
+
optionId,
|
|
6
|
+
FormContextType,
|
|
7
|
+
RJSFSchema,
|
|
8
|
+
StrictRJSFSchema,
|
|
9
|
+
WidgetProps,
|
|
10
|
+
} from '@rjsf/utils';
|
|
11
|
+
import { RadioButton, RadioButtonChangeEvent } from 'primereact/radiobutton';
|
|
12
|
+
|
|
13
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
14
|
+
* It is typically used with a string property constrained with enum options.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The `WidgetProps` for this component
|
|
17
|
+
*/
|
|
18
|
+
export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
19
|
+
props: WidgetProps<T, S, F>,
|
|
20
|
+
) {
|
|
21
|
+
const { id, value, disabled, readonly, onChange, onBlur, onFocus, options } = props;
|
|
22
|
+
const primeProps = (options.prime || {}) as object;
|
|
23
|
+
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
24
|
+
|
|
25
|
+
const _onChange = (e: RadioButtonChangeEvent) => {
|
|
26
|
+
onChange(enumOptionsValueForIndex<S>(e.value, enumOptions, emptyValue));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const _onBlur = () => onBlur(id, value);
|
|
30
|
+
const _onFocus = () => onFocus(id, value);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div style={{ display: 'flex', flexDirection: 'row', gap: '1rem' }}>
|
|
34
|
+
{Array.isArray(enumOptions) &&
|
|
35
|
+
enumOptions.map((option, index) => {
|
|
36
|
+
const checked = enumOptionsIsSelected<S>(option.value, value);
|
|
37
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
38
|
+
return (
|
|
39
|
+
<div key={index} style={{ display: 'flex', alignItems: 'center' }}>
|
|
40
|
+
<RadioButton
|
|
41
|
+
inputId={optionId(id, index)}
|
|
42
|
+
name={id}
|
|
43
|
+
{...primeProps}
|
|
44
|
+
onFocus={_onFocus}
|
|
45
|
+
onBlur={_onBlur}
|
|
46
|
+
onChange={_onChange}
|
|
47
|
+
value={String(index)}
|
|
48
|
+
checked={checked}
|
|
49
|
+
disabled={disabled || itemDisabled || readonly}
|
|
50
|
+
aria-describedby={ariaDescribedByIds<T>(id)}
|
|
51
|
+
/>
|
|
52
|
+
<label htmlFor={optionId(id, index)} style={{ marginLeft: '8px' }}>
|
|
53
|
+
{option.label}
|
|
54
|
+
</label>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
})}
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FocusEvent } from 'react';
|
|
2
|
+
import { Slider, SliderChangeEvent } from 'primereact/slider';
|
|
3
|
+
import { ariaDescribedByIds, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, rangeSpec } from '@rjsf/utils';
|
|
4
|
+
|
|
5
|
+
/** The `RangeWidget` component uses the `Slider` from PrimeReact, wrapping the result
|
|
6
|
+
* in a div, with the value alongside it.
|
|
7
|
+
*
|
|
8
|
+
* @param props - The `WidgetProps` for this component
|
|
9
|
+
*/
|
|
10
|
+
export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
11
|
+
props: WidgetProps<T, S, F>,
|
|
12
|
+
) {
|
|
13
|
+
const { value, readonly, disabled, onBlur, onFocus, options, schema, onChange, id } = props;
|
|
14
|
+
const primeProps = (options.prime || {}) as object;
|
|
15
|
+
const sliderProps = { value, id, ...rangeSpec<S>(schema) };
|
|
16
|
+
|
|
17
|
+
const _onChange = (e: SliderChangeEvent) => {
|
|
18
|
+
onChange(e.value ?? options.emptyValue);
|
|
19
|
+
};
|
|
20
|
+
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
|
|
21
|
+
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<Slider
|
|
26
|
+
{...primeProps}
|
|
27
|
+
disabled={disabled || readonly}
|
|
28
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
29
|
+
onChange={_onChange}
|
|
30
|
+
onBlur={_onBlur}
|
|
31
|
+
onFocus={_onFocus}
|
|
32
|
+
{...sliderProps}
|
|
33
|
+
aria-describedby={ariaDescribedByIds<T>(id)}
|
|
34
|
+
/>
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { FocusEvent } from 'react';
|
|
2
|
+
import { Dropdown } from 'primereact/dropdown';
|
|
3
|
+
import {
|
|
4
|
+
ariaDescribedByIds,
|
|
5
|
+
enumOptionsIndexForValue,
|
|
6
|
+
enumOptionsValueForIndex,
|
|
7
|
+
FormContextType,
|
|
8
|
+
RJSFSchema,
|
|
9
|
+
StrictRJSFSchema,
|
|
10
|
+
WidgetProps,
|
|
11
|
+
} from '@rjsf/utils';
|
|
12
|
+
import { MultiSelect } from 'primereact/multiselect';
|
|
13
|
+
|
|
14
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
15
|
+
* It is typically used with string properties constrained with enum options.
|
|
16
|
+
*
|
|
17
|
+
* @param props - The `WidgetProps` for this component
|
|
18
|
+
*/
|
|
19
|
+
export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
20
|
+
props: WidgetProps<T, S, F>,
|
|
21
|
+
) {
|
|
22
|
+
const { multiple = false } = props;
|
|
23
|
+
|
|
24
|
+
return multiple ? <MultiSelectWidget {...props} /> : <SingleSelectWidget {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
28
|
+
schema,
|
|
29
|
+
id,
|
|
30
|
+
name, // remove this from dropdownProps
|
|
31
|
+
options,
|
|
32
|
+
label,
|
|
33
|
+
hideLabel,
|
|
34
|
+
required,
|
|
35
|
+
disabled,
|
|
36
|
+
placeholder,
|
|
37
|
+
readonly,
|
|
38
|
+
value,
|
|
39
|
+
multiple,
|
|
40
|
+
autofocus,
|
|
41
|
+
onChange,
|
|
42
|
+
onBlur,
|
|
43
|
+
onFocus,
|
|
44
|
+
errorSchema,
|
|
45
|
+
rawErrors = [],
|
|
46
|
+
registry,
|
|
47
|
+
uiSchema,
|
|
48
|
+
hideError,
|
|
49
|
+
formContext,
|
|
50
|
+
...dropdownProps
|
|
51
|
+
}: WidgetProps<T, S, F>) {
|
|
52
|
+
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
53
|
+
const primeProps = (options.prime || {}) as object;
|
|
54
|
+
|
|
55
|
+
multiple = typeof multiple === 'undefined' ? false : multiple;
|
|
56
|
+
|
|
57
|
+
const emptyValue = multiple ? [] : '';
|
|
58
|
+
const isEmpty = typeof value === 'undefined' || (multiple && value.length < 1) || (!multiple && value === emptyValue);
|
|
59
|
+
|
|
60
|
+
const _onChange = (e: { value: any }) => onChange(enumOptionsValueForIndex<S>(e.value, enumOptions, optEmptyVal));
|
|
61
|
+
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
62
|
+
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
|
|
63
|
+
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
64
|
+
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
|
|
65
|
+
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
|
|
66
|
+
const { ...dropdownRemainingProps } = dropdownProps;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Dropdown
|
|
70
|
+
id={id}
|
|
71
|
+
name={id}
|
|
72
|
+
{...primeProps}
|
|
73
|
+
value={!isEmpty && typeof selectedIndexes !== 'undefined' ? selectedIndexes : emptyValue}
|
|
74
|
+
options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
|
|
75
|
+
label,
|
|
76
|
+
value: String(i),
|
|
77
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
78
|
+
}))}
|
|
79
|
+
onChange={_onChange}
|
|
80
|
+
onBlur={_onBlur}
|
|
81
|
+
onFocus={_onFocus}
|
|
82
|
+
placeholder={placeholder}
|
|
83
|
+
disabled={disabled || readonly}
|
|
84
|
+
autoFocus={autofocus}
|
|
85
|
+
aria-describedby={ariaDescribedByIds<T>(id)}
|
|
86
|
+
{...dropdownRemainingProps}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function MultiSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
92
|
+
id,
|
|
93
|
+
options,
|
|
94
|
+
disabled,
|
|
95
|
+
placeholder,
|
|
96
|
+
readonly,
|
|
97
|
+
value,
|
|
98
|
+
multiple = false,
|
|
99
|
+
autofocus,
|
|
100
|
+
onChange,
|
|
101
|
+
onBlur,
|
|
102
|
+
onFocus,
|
|
103
|
+
}: WidgetProps<T, S, F>) {
|
|
104
|
+
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
105
|
+
const primeProps = (options.prime || {}) as object;
|
|
106
|
+
|
|
107
|
+
const emptyValue = multiple ? [] : '';
|
|
108
|
+
const isEmpty = typeof value === 'undefined' || (multiple && value.length < 1) || (!multiple && value === emptyValue);
|
|
109
|
+
|
|
110
|
+
const _onChange = (e: { value: any }) => onChange(enumOptionsValueForIndex<S>(e.value, enumOptions, optEmptyVal));
|
|
111
|
+
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
112
|
+
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
|
|
113
|
+
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
114
|
+
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, optEmptyVal));
|
|
115
|
+
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<MultiSelect
|
|
119
|
+
id={id}
|
|
120
|
+
name={id}
|
|
121
|
+
{...primeProps}
|
|
122
|
+
value={!isEmpty && typeof selectedIndexes !== 'undefined' ? selectedIndexes : emptyValue}
|
|
123
|
+
options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
|
|
124
|
+
label,
|
|
125
|
+
value: String(i),
|
|
126
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
127
|
+
}))}
|
|
128
|
+
onChange={_onChange}
|
|
129
|
+
onBlur={_onBlur}
|
|
130
|
+
onFocus={_onFocus}
|
|
131
|
+
placeholder={placeholder}
|
|
132
|
+
disabled={disabled || readonly}
|
|
133
|
+
autoFocus={autofocus}
|
|
134
|
+
display={options.display === 'chip' ? 'chip' : 'comma'}
|
|
135
|
+
aria-describedby={ariaDescribedByIds<T>(id)}
|
|
136
|
+
pt={{ root: { style: { position: 'relative' } } }}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Button } from 'primereact/button';
|
|
2
|
+
import { getSubmitButtonOptions, FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
/** The `SubmitButton` renders a button that represents the `Submit` action on a form
|
|
5
|
+
*/
|
|
6
|
+
export default function SubmitButton<
|
|
7
|
+
T = any,
|
|
8
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
9
|
+
F extends FormContextType = any,
|
|
10
|
+
>({ uiSchema }: SubmitButtonProps<T, S, F>) {
|
|
11
|
+
const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions<T, S, F>(uiSchema);
|
|
12
|
+
if (norender) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return <Button type='submit' label={submitText} {...submitButtonProps} />;
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
2
|
+
|
|
3
|
+
import AddButton from '../AddButton';
|
|
4
|
+
import ArrayFieldItemTemplate from '../ArrayFieldItemTemplate';
|
|
5
|
+
import ArrayFieldTemplate from '../ArrayFieldTemplate';
|
|
6
|
+
import BaseInputTemplate from '../BaseInputTemplate';
|
|
7
|
+
import DescriptionField from '../DescriptionField';
|
|
8
|
+
import ErrorList from '../ErrorList';
|
|
9
|
+
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from '../IconButton';
|
|
10
|
+
import FieldErrorTemplate from '../FieldErrorTemplate';
|
|
11
|
+
import FieldHelpTemplate from '../FieldHelpTemplate';
|
|
12
|
+
import FieldTemplate from '../FieldTemplate';
|
|
13
|
+
import MultiSchemaFieldTemplate from '../MultiSchemaFieldTemplate';
|
|
14
|
+
import ObjectFieldTemplate from '../ObjectFieldTemplate';
|
|
15
|
+
import SubmitButton from '../SubmitButton';
|
|
16
|
+
import TitleField from '../TitleField';
|
|
17
|
+
import WrapIfAdditionalTemplate from '../WrapIfAdditionalTemplate';
|
|
18
|
+
import ArrayFieldTitleTemplate from '../ArrayFieldTitleTemplate';
|
|
19
|
+
import GridTemplate from '../GridTemplate';
|
|
20
|
+
|
|
21
|
+
export function generateTemplates<
|
|
22
|
+
T = any,
|
|
23
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
24
|
+
F extends FormContextType = any,
|
|
25
|
+
>(): Partial<TemplatesType<T, S, F>> {
|
|
26
|
+
return {
|
|
27
|
+
ArrayFieldItemTemplate,
|
|
28
|
+
ArrayFieldTemplate,
|
|
29
|
+
ArrayFieldTitleTemplate,
|
|
30
|
+
BaseInputTemplate,
|
|
31
|
+
ButtonTemplates: {
|
|
32
|
+
AddButton,
|
|
33
|
+
CopyButton,
|
|
34
|
+
MoveDownButton,
|
|
35
|
+
MoveUpButton,
|
|
36
|
+
RemoveButton,
|
|
37
|
+
SubmitButton,
|
|
38
|
+
},
|
|
39
|
+
DescriptionFieldTemplate: DescriptionField,
|
|
40
|
+
ErrorListTemplate: ErrorList,
|
|
41
|
+
FieldErrorTemplate,
|
|
42
|
+
FieldHelpTemplate,
|
|
43
|
+
FieldTemplate,
|
|
44
|
+
MultiSchemaFieldTemplate,
|
|
45
|
+
ObjectFieldTemplate,
|
|
46
|
+
TitleFieldTemplate: TitleField,
|
|
47
|
+
WrapIfAdditionalTemplate,
|
|
48
|
+
GridTemplate,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default generateTemplates();
|