fastapi-rtk 0.2.11 → 0.2.13
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/core/cjs/ActionIcons/Modals/CommonModal.cjs +8 -5
- package/dist/core/esm/ActionIcons/Modals/CommonModal.mjs +9 -6
- package/dist/core/lib/ActionIcons/Add/AddDialog.d.ts +122 -4
- package/dist/core/lib/ActionIcons/Edit/EditDialog.d.ts +124 -4
- package/dist/core/lib/ActionIcons/Modals/CommonModal.d.ts +102 -18
- package/package.json +1 -1
|
@@ -25,6 +25,7 @@ function CommonModal({
|
|
|
25
25
|
buttonText,
|
|
26
26
|
buttonLoading,
|
|
27
27
|
withTitleOptions = true,
|
|
28
|
+
titleOptions,
|
|
28
29
|
...props
|
|
29
30
|
}) {
|
|
30
31
|
var _a;
|
|
@@ -59,8 +60,9 @@ function CommonModal({
|
|
|
59
60
|
title: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
60
61
|
props.title,
|
|
61
62
|
!fab && withTitleOptions && //* Backward compatibility to fab-react-toolkit
|
|
62
|
-
/* @__PURE__ */ jsxRuntime.
|
|
63
|
-
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core.Group, { gap: "xs", pr: "xs", children: [
|
|
64
|
+
utils.parseFromValuesOrFunc(titleOptions == null ? void 0 : titleOptions.left, { view, setView }),
|
|
65
|
+
!(titleOptions == null ? void 0 : titleOptions.hideOverlay) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
64
66
|
core.CloseButton,
|
|
65
67
|
{
|
|
66
68
|
onClick: () => setView(view !== constants.VIEW_MODE.OVERLAY ? constants.VIEW_MODE.OVERLAY : constants.VIEW_MODE.NORMAL),
|
|
@@ -74,7 +76,7 @@ function CommonModal({
|
|
|
74
76
|
)
|
|
75
77
|
}
|
|
76
78
|
),
|
|
77
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
79
|
+
!(titleOptions == null ? void 0 : titleOptions.hideFullScreen) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
80
|
core.CloseButton,
|
|
79
81
|
{
|
|
80
82
|
onClick: () => setView(view !== constants.VIEW_MODE.FULL_SCREEN ? constants.VIEW_MODE.FULL_SCREEN : constants.VIEW_MODE.NORMAL),
|
|
@@ -87,8 +89,9 @@ function CommonModal({
|
|
|
87
89
|
}
|
|
88
90
|
)
|
|
89
91
|
}
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
+
),
|
|
93
|
+
utils.parseFromValuesOrFunc(titleOptions == null ? void 0 : titleOptions.right, { view, setView })
|
|
94
|
+
] })
|
|
92
95
|
] }),
|
|
93
96
|
classNames: { content: "mrt-table-container" },
|
|
94
97
|
styles: utils.deepMerge(props.styles, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { JsonFormsWithCustomizer } from "fastapi-rtk/.bundled-jsonforms";
|
|
3
3
|
import { VIEW_MODE } from "fastapi-rtk/constants";
|
|
4
|
-
import { deepMerge } from "fastapi-rtk/utils";
|
|
4
|
+
import { deepMerge, parseFromValuesOrFunc } from "fastapi-rtk/utils";
|
|
5
5
|
import { Icon } from "../../../../.external/esm/@iconify_react@6.0.0_react@18.3.1/@iconify/react/dist/iconify.mjs";
|
|
6
6
|
import { Modal, Box, Stack, Group, Button, CloseButton } from "@mantine/core";
|
|
7
7
|
import { useForm, yupResolver } from "@mantine/form";
|
|
@@ -23,6 +23,7 @@ function CommonModal({
|
|
|
23
23
|
buttonText,
|
|
24
24
|
buttonLoading,
|
|
25
25
|
withTitleOptions = true,
|
|
26
|
+
titleOptions,
|
|
26
27
|
...props
|
|
27
28
|
}) {
|
|
28
29
|
var _a;
|
|
@@ -57,8 +58,9 @@ function CommonModal({
|
|
|
57
58
|
title: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
58
59
|
props.title,
|
|
59
60
|
!fab && withTitleOptions && //* Backward compatibility to fab-react-toolkit
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
61
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", pr: "xs", children: [
|
|
62
|
+
parseFromValuesOrFunc(titleOptions == null ? void 0 : titleOptions.left, { view, setView }),
|
|
63
|
+
!(titleOptions == null ? void 0 : titleOptions.hideOverlay) && /* @__PURE__ */ jsx(
|
|
62
64
|
CloseButton,
|
|
63
65
|
{
|
|
64
66
|
onClick: () => setView(view !== VIEW_MODE.OVERLAY ? VIEW_MODE.OVERLAY : VIEW_MODE.NORMAL),
|
|
@@ -72,7 +74,7 @@ function CommonModal({
|
|
|
72
74
|
)
|
|
73
75
|
}
|
|
74
76
|
),
|
|
75
|
-
/* @__PURE__ */ jsx(
|
|
77
|
+
!(titleOptions == null ? void 0 : titleOptions.hideFullScreen) && /* @__PURE__ */ jsx(
|
|
76
78
|
CloseButton,
|
|
77
79
|
{
|
|
78
80
|
onClick: () => setView(view !== VIEW_MODE.FULL_SCREEN ? VIEW_MODE.FULL_SCREEN : VIEW_MODE.NORMAL),
|
|
@@ -85,8 +87,9 @@ function CommonModal({
|
|
|
85
87
|
}
|
|
86
88
|
)
|
|
87
89
|
}
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
+
),
|
|
91
|
+
parseFromValuesOrFunc(titleOptions == null ? void 0 : titleOptions.right, { view, setView })
|
|
92
|
+
] })
|
|
90
93
|
] }),
|
|
91
94
|
classNames: { content: "mrt-table-container" },
|
|
92
95
|
styles: deepMerge(props.styles, {
|
|
@@ -1,4 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} CommonModalTitleOptionsProps
|
|
3
|
+
* @property {React.ReactNode | ((props: { view: string; setView: (view: string) => void }) => React.ReactNode)} left - Content or function to render on the left side of the title.
|
|
4
|
+
* @property {React.ReactNode | ((props: { view: string; setView: (view: string) => void }) => React.ReactNode)} right - Content or function to render on the right side of the title.
|
|
5
|
+
* @property {boolean} [hideOverlay=false] - If true, hides the overlay toggle button.
|
|
6
|
+
* @property {boolean} [hideFullScreen=false] - If true, hides the full screen toggle button.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} CommonModalProps
|
|
10
|
+
* @property {Record<string, any>} fabSchema - Schema for backward compatibility with fab-react-toolkit that includes defaultValues and validation schema.
|
|
11
|
+
* @property {Record<string, any>} schema - JSON Schema used by JsonFormsWithCustomizer.
|
|
12
|
+
* @property {Record<string, any>} uischema - UI schema for customizing the form layout.
|
|
13
|
+
* @property {Record<string, any>} state - State object containing the form data.
|
|
14
|
+
* @property {Function} setState - Function to update the state containing form data.
|
|
15
|
+
* @property {string} view - Current view mode (e.g., VIEW_MODE.NORMAL, VIEW_MODE.FULL_SCREEN, VIEW_MODE.OVERLAY).
|
|
16
|
+
* @property {Function} setView - Function to update the view mode.
|
|
17
|
+
* @property {Record<string, any>} jsonForms - Customizer configuration or additional properties for JsonFormsWithCustomizer.
|
|
18
|
+
* @property {Function} onSubmit - Callback function triggered on form submission.
|
|
19
|
+
* @property {Record<string, any>} boxProps - Additional properties to be passed to the Box component wrapping the form.
|
|
20
|
+
* @property {string} buttonText - Text displayed on the submit button.
|
|
21
|
+
* @property {boolean} buttonLoading - Indicates whether the submit button should display a loading state.
|
|
22
|
+
* @property {boolean} [withTitleOptions=true] - Flag to determine if title options (e.g., full screen, overlay toggles) should be displayed.
|
|
23
|
+
* @property {CommonModalTitleOptionsProps} [titleOptions] - Options for customizing the title area, such as toggles for full screen and overlay modes.
|
|
24
|
+
* @property {Record<string, any>} rest - Additional props to be passed to the Modal component.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* AddDialog is a component that renders a modal dialog for adding a new entry.
|
|
28
|
+
*
|
|
29
|
+
* It integrates with the application's API to add entries and manages form state,
|
|
30
|
+
* view modes, and loading state via custom hooks. The component also manages the merge
|
|
31
|
+
* of default JSON Forms settings with any additional props provided.
|
|
32
|
+
*
|
|
33
|
+
* @param {CommonModalProps} props - The properties passed to the AddDialog component.
|
|
34
|
+
* @returns {JSX.Element} The rendered modal dialog component for adding an entry.
|
|
35
|
+
*/
|
|
36
|
+
export function AddDialog({ jsonForms: __jsonForms, ...props }: CommonModalProps): JSX.Element;
|
|
37
|
+
export type CommonModalTitleOptionsProps = {
|
|
38
|
+
/**
|
|
39
|
+
* - Content or function to render on the left side of the title.
|
|
40
|
+
*/
|
|
41
|
+
left: React.ReactNode | ((props: {
|
|
42
|
+
view: string;
|
|
43
|
+
setView: (view: string) => void;
|
|
44
|
+
}) => React.ReactNode);
|
|
45
|
+
/**
|
|
46
|
+
* - Content or function to render on the right side of the title.
|
|
47
|
+
*/
|
|
48
|
+
right: React.ReactNode | ((props: {
|
|
49
|
+
view: string;
|
|
50
|
+
setView: (view: string) => void;
|
|
51
|
+
}) => React.ReactNode);
|
|
52
|
+
/**
|
|
53
|
+
* - If true, hides the overlay toggle button.
|
|
54
|
+
*/
|
|
55
|
+
hideOverlay?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* - If true, hides the full screen toggle button.
|
|
58
|
+
*/
|
|
59
|
+
hideFullScreen?: boolean;
|
|
60
|
+
};
|
|
61
|
+
export type CommonModalProps = {
|
|
62
|
+
/**
|
|
63
|
+
* - Schema for backward compatibility with fab-react-toolkit that includes defaultValues and validation schema.
|
|
64
|
+
*/
|
|
65
|
+
fabSchema: Record<string, any>;
|
|
66
|
+
/**
|
|
67
|
+
* - JSON Schema used by JsonFormsWithCustomizer.
|
|
68
|
+
*/
|
|
69
|
+
schema: Record<string, any>;
|
|
70
|
+
/**
|
|
71
|
+
* - UI schema for customizing the form layout.
|
|
72
|
+
*/
|
|
73
|
+
uischema: Record<string, any>;
|
|
74
|
+
/**
|
|
75
|
+
* - State object containing the form data.
|
|
76
|
+
*/
|
|
77
|
+
state: Record<string, any>;
|
|
78
|
+
/**
|
|
79
|
+
* - Function to update the state containing form data.
|
|
80
|
+
*/
|
|
81
|
+
setState: Function;
|
|
82
|
+
/**
|
|
83
|
+
* - Current view mode (e.g., VIEW_MODE.NORMAL, VIEW_MODE.FULL_SCREEN, VIEW_MODE.OVERLAY).
|
|
84
|
+
*/
|
|
85
|
+
view: string;
|
|
86
|
+
/**
|
|
87
|
+
* - Function to update the view mode.
|
|
88
|
+
*/
|
|
89
|
+
setView: Function;
|
|
90
|
+
/**
|
|
91
|
+
* - Customizer configuration or additional properties for JsonFormsWithCustomizer.
|
|
92
|
+
*/
|
|
93
|
+
jsonForms: Record<string, any>;
|
|
94
|
+
/**
|
|
95
|
+
* - Callback function triggered on form submission.
|
|
96
|
+
*/
|
|
97
|
+
onSubmit: Function;
|
|
98
|
+
/**
|
|
99
|
+
* - Additional properties to be passed to the Box component wrapping the form.
|
|
100
|
+
*/
|
|
101
|
+
boxProps: Record<string, any>;
|
|
102
|
+
/**
|
|
103
|
+
* - Text displayed on the submit button.
|
|
104
|
+
*/
|
|
105
|
+
buttonText: string;
|
|
106
|
+
/**
|
|
107
|
+
* - Indicates whether the submit button should display a loading state.
|
|
108
|
+
*/
|
|
109
|
+
buttonLoading: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* - Flag to determine if title options (e.g., full screen, overlay toggles) should be displayed.
|
|
112
|
+
*/
|
|
113
|
+
withTitleOptions?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* - Options for customizing the title area, such as toggles for full screen and overlay modes.
|
|
116
|
+
*/
|
|
117
|
+
titleOptions?: CommonModalTitleOptionsProps;
|
|
118
|
+
/**
|
|
119
|
+
* - Additional props to be passed to the Modal component.
|
|
120
|
+
*/
|
|
121
|
+
rest: Record<string, any>;
|
|
122
|
+
};
|
|
@@ -1,4 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} CommonModalTitleOptionsProps
|
|
3
|
+
* @property {React.ReactNode | ((props: { view: string; setView: (view: string) => void }) => React.ReactNode)} left - Content or function to render on the left side of the title.
|
|
4
|
+
* @property {React.ReactNode | ((props: { view: string; setView: (view: string) => void }) => React.ReactNode)} right - Content or function to render on the right side of the title.
|
|
5
|
+
* @property {boolean} [hideOverlay=false] - If true, hides the overlay toggle button.
|
|
6
|
+
* @property {boolean} [hideFullScreen=false] - If true, hides the full screen toggle button.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} CommonModalProps
|
|
10
|
+
* @property {Record<string, any>} fabSchema - Schema for backward compatibility with fab-react-toolkit that includes defaultValues and validation schema.
|
|
11
|
+
* @property {Record<string, any>} schema - JSON Schema used by JsonFormsWithCustomizer.
|
|
12
|
+
* @property {Record<string, any>} uischema - UI schema for customizing the form layout.
|
|
13
|
+
* @property {Record<string, any>} state - State object containing the form data.
|
|
14
|
+
* @property {Function} setState - Function to update the state containing form data.
|
|
15
|
+
* @property {string} view - Current view mode (e.g., VIEW_MODE.NORMAL, VIEW_MODE.FULL_SCREEN, VIEW_MODE.OVERLAY).
|
|
16
|
+
* @property {Function} setView - Function to update the view mode.
|
|
17
|
+
* @property {Record<string, any>} jsonForms - Customizer configuration or additional properties for JsonFormsWithCustomizer.
|
|
18
|
+
* @property {Function} onSubmit - Callback function triggered on form submission.
|
|
19
|
+
* @property {Record<string, any>} boxProps - Additional properties to be passed to the Box component wrapping the form.
|
|
20
|
+
* @property {string} buttonText - Text displayed on the submit button.
|
|
21
|
+
* @property {boolean} buttonLoading - Indicates whether the submit button should display a loading state.
|
|
22
|
+
* @property {boolean} [withTitleOptions=true] - Flag to determine if title options (e.g., full screen, overlay toggles) should be displayed.
|
|
23
|
+
* @property {CommonModalTitleOptionsProps} [titleOptions] - Options for customizing the title area, such as toggles for full screen and overlay modes.
|
|
24
|
+
* @property {Record<string, any>} rest - Additional props to be passed to the Modal component.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* EditDialog component renders a modal dialog for editing an entry.
|
|
28
|
+
*
|
|
29
|
+
* This component leverages various hooks to manage form state, API interactions, and UI transitions.
|
|
30
|
+
* It initializes the form state based on the provided item's result and handles form submission by
|
|
31
|
+
* sending only changed data to update the corresponding entry. Upon a successful update, it triggers
|
|
32
|
+
* a refetch of data and related information.
|
|
33
|
+
*
|
|
34
|
+
* @component
|
|
35
|
+
* @param {CommonModalProps} props - The component props.
|
|
36
|
+
* @returns {JSX.Element} The rendered EditDialog component.
|
|
37
|
+
*/
|
|
38
|
+
export function EditDialog({ jsonForms: __jsonForms, ...props }: CommonModalProps): JSX.Element;
|
|
39
|
+
export type CommonModalTitleOptionsProps = {
|
|
40
|
+
/**
|
|
41
|
+
* - Content or function to render on the left side of the title.
|
|
42
|
+
*/
|
|
43
|
+
left: React.ReactNode | ((props: {
|
|
44
|
+
view: string;
|
|
45
|
+
setView: (view: string) => void;
|
|
46
|
+
}) => React.ReactNode);
|
|
47
|
+
/**
|
|
48
|
+
* - Content or function to render on the right side of the title.
|
|
49
|
+
*/
|
|
50
|
+
right: React.ReactNode | ((props: {
|
|
51
|
+
view: string;
|
|
52
|
+
setView: (view: string) => void;
|
|
53
|
+
}) => React.ReactNode);
|
|
54
|
+
/**
|
|
55
|
+
* - If true, hides the overlay toggle button.
|
|
56
|
+
*/
|
|
57
|
+
hideOverlay?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* - If true, hides the full screen toggle button.
|
|
60
|
+
*/
|
|
61
|
+
hideFullScreen?: boolean;
|
|
62
|
+
};
|
|
63
|
+
export type CommonModalProps = {
|
|
64
|
+
/**
|
|
65
|
+
* - Schema for backward compatibility with fab-react-toolkit that includes defaultValues and validation schema.
|
|
66
|
+
*/
|
|
67
|
+
fabSchema: Record<string, any>;
|
|
68
|
+
/**
|
|
69
|
+
* - JSON Schema used by JsonFormsWithCustomizer.
|
|
70
|
+
*/
|
|
71
|
+
schema: Record<string, any>;
|
|
72
|
+
/**
|
|
73
|
+
* - UI schema for customizing the form layout.
|
|
74
|
+
*/
|
|
75
|
+
uischema: Record<string, any>;
|
|
76
|
+
/**
|
|
77
|
+
* - State object containing the form data.
|
|
78
|
+
*/
|
|
79
|
+
state: Record<string, any>;
|
|
80
|
+
/**
|
|
81
|
+
* - Function to update the state containing form data.
|
|
82
|
+
*/
|
|
83
|
+
setState: Function;
|
|
84
|
+
/**
|
|
85
|
+
* - Current view mode (e.g., VIEW_MODE.NORMAL, VIEW_MODE.FULL_SCREEN, VIEW_MODE.OVERLAY).
|
|
86
|
+
*/
|
|
87
|
+
view: string;
|
|
88
|
+
/**
|
|
89
|
+
* - Function to update the view mode.
|
|
90
|
+
*/
|
|
91
|
+
setView: Function;
|
|
92
|
+
/**
|
|
93
|
+
* - Customizer configuration or additional properties for JsonFormsWithCustomizer.
|
|
94
|
+
*/
|
|
95
|
+
jsonForms: Record<string, any>;
|
|
96
|
+
/**
|
|
97
|
+
* - Callback function triggered on form submission.
|
|
98
|
+
*/
|
|
99
|
+
onSubmit: Function;
|
|
100
|
+
/**
|
|
101
|
+
* - Additional properties to be passed to the Box component wrapping the form.
|
|
102
|
+
*/
|
|
103
|
+
boxProps: Record<string, any>;
|
|
104
|
+
/**
|
|
105
|
+
* - Text displayed on the submit button.
|
|
106
|
+
*/
|
|
107
|
+
buttonText: string;
|
|
108
|
+
/**
|
|
109
|
+
* - Indicates whether the submit button should display a loading state.
|
|
110
|
+
*/
|
|
111
|
+
buttonLoading: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* - Flag to determine if title options (e.g., full screen, overlay toggles) should be displayed.
|
|
114
|
+
*/
|
|
115
|
+
withTitleOptions?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* - Options for customizing the title area, such as toggles for full screen and overlay modes.
|
|
118
|
+
*/
|
|
119
|
+
titleOptions?: CommonModalTitleOptionsProps;
|
|
120
|
+
/**
|
|
121
|
+
* - Additional props to be passed to the Modal component.
|
|
122
|
+
*/
|
|
123
|
+
rest: Record<string, any>;
|
|
124
|
+
};
|
|
@@ -1,38 +1,122 @@
|
|
|
1
|
+
import { Modal } from '@mantine/core';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} CommonModalTitleOptionsProps
|
|
4
|
+
* @property {React.ReactNode | ((props: { view: string; setView: (view: string) => void }) => React.ReactNode)} left - Content or function to render on the left side of the title.
|
|
5
|
+
* @property {React.ReactNode | ((props: { view: string; setView: (view: string) => void }) => React.ReactNode)} right - Content or function to render on the right side of the title.
|
|
6
|
+
* @property {boolean} [hideOverlay=false] - If true, hides the overlay toggle button.
|
|
7
|
+
* @property {boolean} [hideFullScreen=false] - If true, hides the full screen toggle button.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} CommonModalProps
|
|
11
|
+
* @property {Record<string, any>} fabSchema - Schema for backward compatibility with fab-react-toolkit that includes defaultValues and validation schema.
|
|
12
|
+
* @property {Record<string, any>} schema - JSON Schema used by JsonFormsWithCustomizer.
|
|
13
|
+
* @property {Record<string, any>} uischema - UI schema for customizing the form layout.
|
|
14
|
+
* @property {Record<string, any>} state - State object containing the form data.
|
|
15
|
+
* @property {Function} setState - Function to update the state containing form data.
|
|
16
|
+
* @property {string} view - Current view mode (e.g., VIEW_MODE.NORMAL, VIEW_MODE.FULL_SCREEN, VIEW_MODE.OVERLAY).
|
|
17
|
+
* @property {Function} setView - Function to update the view mode.
|
|
18
|
+
* @property {Record<string, any>} jsonForms - Customizer configuration or additional properties for JsonFormsWithCustomizer.
|
|
19
|
+
* @property {Function} onSubmit - Callback function triggered on form submission.
|
|
20
|
+
* @property {Record<string, any>} boxProps - Additional properties to be passed to the Box component wrapping the form.
|
|
21
|
+
* @property {string} buttonText - Text displayed on the submit button.
|
|
22
|
+
* @property {boolean} buttonLoading - Indicates whether the submit button should display a loading state.
|
|
23
|
+
* @property {boolean} [withTitleOptions=true] - Flag to determine if title options (e.g., full screen, overlay toggles) should be displayed.
|
|
24
|
+
* @property {CommonModalTitleOptionsProps} [titleOptions] - Options for customizing the title area, such as toggles for full screen and overlay modes.
|
|
25
|
+
* @property {Record<string, any>} rest - Additional props to be passed to the Modal component.
|
|
26
|
+
* @typedef {CommonModalProps & React.ComponentProps<typeof Modal>} CommonModalComponentProps
|
|
27
|
+
*/
|
|
1
28
|
/**
|
|
2
29
|
* CommonModal component renders a modal with a form.
|
|
3
30
|
*
|
|
4
31
|
* @component
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {Record<string, any>} props.fabSchema - Schema for backward compatibility with fab-react-toolkit that includes defaultValues and validation schema.
|
|
7
|
-
* @param {Record<string, any>} props.schema - JSON Schema used by JsonFormsWithCustomizer.
|
|
8
|
-
* @param {Record<string, any>} props.uischema - UI schema for customizing the form layout.
|
|
9
|
-
* @param {Record<string, any>} props.state - State object containing the form data.
|
|
10
|
-
* @param {Function} props.setState - Function to update the state containing form data.
|
|
11
|
-
* @param {string} props.view - Current view mode (e.g., VIEW_MODE.NORMAL, VIEW_MODE.FULL_SCREEN, VIEW_MODE.OVERLAY).
|
|
12
|
-
* @param {Function} props.setView - Function to update the view mode.
|
|
13
|
-
* @param {Record<string, any>} props.jsonForms - Customizer configuration or additional properties for JsonFormsWithCustomizer.
|
|
14
|
-
* @param {Function} props.onSubmit - Callback function triggered on form submission.
|
|
15
|
-
* @param {Record<string, any>} props.boxProps - Additional properties to be passed to the Box component wrapping the form.
|
|
16
|
-
* @param {string} props.buttonText - Text displayed on the submit button.
|
|
17
|
-
* @param {boolean} props.buttonLoading - Indicates whether the submit button should display a loading state.
|
|
18
|
-
* @param {boolean} [props.withTitleOptions=true] - Flag to determine if title options (e.g., full screen, overlay toggles) should be displayed.
|
|
19
|
-
* @param {Record<string, any>} props.rest - Additional props to be passed to the Modal component.
|
|
20
|
-
*
|
|
32
|
+
* @param {CommonModalComponentProps} props - The properties for the CommonModal component.
|
|
21
33
|
* @returns - A rendered Modal component with an embedded form and optional title controls.
|
|
22
34
|
*/
|
|
23
|
-
export function CommonModal({ fabSchema, schema, uischema, state, setState, view, setView, jsonForms, onSubmit, boxProps, buttonText, buttonLoading, withTitleOptions, ...props }:
|
|
35
|
+
export function CommonModal({ fabSchema, schema, uischema, state, setState, view, setView, jsonForms, onSubmit, boxProps, buttonText, buttonLoading, withTitleOptions, titleOptions, ...props }: CommonModalComponentProps): import("react").JSX.Element;
|
|
36
|
+
export type CommonModalTitleOptionsProps = {
|
|
37
|
+
/**
|
|
38
|
+
* - Content or function to render on the left side of the title.
|
|
39
|
+
*/
|
|
40
|
+
left: React.ReactNode | ((props: {
|
|
41
|
+
view: string;
|
|
42
|
+
setView: (view: string) => void;
|
|
43
|
+
}) => React.ReactNode);
|
|
44
|
+
/**
|
|
45
|
+
* - Content or function to render on the right side of the title.
|
|
46
|
+
*/
|
|
47
|
+
right: React.ReactNode | ((props: {
|
|
48
|
+
view: string;
|
|
49
|
+
setView: (view: string) => void;
|
|
50
|
+
}) => React.ReactNode);
|
|
51
|
+
/**
|
|
52
|
+
* - If true, hides the overlay toggle button.
|
|
53
|
+
*/
|
|
54
|
+
hideOverlay?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* - If true, hides the full screen toggle button.
|
|
57
|
+
*/
|
|
58
|
+
hideFullScreen?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export type CommonModalProps = {
|
|
61
|
+
/**
|
|
62
|
+
* - Schema for backward compatibility with fab-react-toolkit that includes defaultValues and validation schema.
|
|
63
|
+
*/
|
|
24
64
|
fabSchema: Record<string, any>;
|
|
65
|
+
/**
|
|
66
|
+
* - JSON Schema used by JsonFormsWithCustomizer.
|
|
67
|
+
*/
|
|
25
68
|
schema: Record<string, any>;
|
|
69
|
+
/**
|
|
70
|
+
* - UI schema for customizing the form layout.
|
|
71
|
+
*/
|
|
26
72
|
uischema: Record<string, any>;
|
|
73
|
+
/**
|
|
74
|
+
* - State object containing the form data.
|
|
75
|
+
*/
|
|
27
76
|
state: Record<string, any>;
|
|
77
|
+
/**
|
|
78
|
+
* - Function to update the state containing form data.
|
|
79
|
+
*/
|
|
28
80
|
setState: Function;
|
|
81
|
+
/**
|
|
82
|
+
* - Current view mode (e.g., VIEW_MODE.NORMAL, VIEW_MODE.FULL_SCREEN, VIEW_MODE.OVERLAY).
|
|
83
|
+
*/
|
|
29
84
|
view: string;
|
|
85
|
+
/**
|
|
86
|
+
* - Function to update the view mode.
|
|
87
|
+
*/
|
|
30
88
|
setView: Function;
|
|
89
|
+
/**
|
|
90
|
+
* - Customizer configuration or additional properties for JsonFormsWithCustomizer.
|
|
91
|
+
*/
|
|
31
92
|
jsonForms: Record<string, any>;
|
|
93
|
+
/**
|
|
94
|
+
* - Callback function triggered on form submission.
|
|
95
|
+
*/
|
|
32
96
|
onSubmit: Function;
|
|
97
|
+
/**
|
|
98
|
+
* - Additional properties to be passed to the Box component wrapping the form.
|
|
99
|
+
*/
|
|
33
100
|
boxProps: Record<string, any>;
|
|
101
|
+
/**
|
|
102
|
+
* - Text displayed on the submit button.
|
|
103
|
+
*/
|
|
34
104
|
buttonText: string;
|
|
105
|
+
/**
|
|
106
|
+
* - Indicates whether the submit button should display a loading state.
|
|
107
|
+
*/
|
|
35
108
|
buttonLoading: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* - Flag to determine if title options (e.g., full screen, overlay toggles) should be displayed.
|
|
111
|
+
*/
|
|
36
112
|
withTitleOptions?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* - Options for customizing the title area, such as toggles for full screen and overlay modes.
|
|
115
|
+
*/
|
|
116
|
+
titleOptions?: CommonModalTitleOptionsProps;
|
|
117
|
+
/**
|
|
118
|
+
* - Additional props to be passed to the Modal component.
|
|
119
|
+
*/
|
|
37
120
|
rest: Record<string, any>;
|
|
38
|
-
}
|
|
121
|
+
};
|
|
122
|
+
export type CommonModalComponentProps = CommonModalProps & React.ComponentProps<typeof Modal>;
|
package/package.json
CHANGED