@taiv/ui 1.10.6 → 1.10.7
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/components/Info/Modals/FormModal/FormModal.d.ts +2 -1
- package/dist/components/Info/Modals/FormModal/FormModal.d.ts.map +1 -1
- package/dist/components/Info/Modals/FormModal/FormModal.js +2 -2
- package/dist/components/Info/Modals/FormModal/FormModal.stories.d.ts +1 -0
- package/dist/components/Info/Modals/FormModal/FormModal.stories.d.ts.map +1 -1
- package/dist/components/Info/Modals/FormModal/FormModal.stories.js +21 -0
- package/package.json +1 -1
|
@@ -8,10 +8,11 @@ export interface FormModalProps {
|
|
|
8
8
|
size?: string | number;
|
|
9
9
|
modalVariant?: keyof typeof modalVariants;
|
|
10
10
|
confirmButtonDisabled?: boolean;
|
|
11
|
+
confirmButtonLoading?: boolean;
|
|
11
12
|
onCancel?: () => void;
|
|
12
13
|
onConfirm?: () => void;
|
|
13
14
|
cancelLabel?: string;
|
|
14
15
|
confirmLabel?: string;
|
|
15
16
|
}
|
|
16
|
-
export declare const FormModal: ({ opened, onClose, icon, children, size, modalVariant, confirmButtonDisabled, onCancel, onConfirm, cancelLabel, confirmLabel, }: FormModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const FormModal: ({ opened, onClose, icon, children, size, modalVariant, confirmButtonDisabled, confirmButtonLoading, onCancel, onConfirm, cancelLabel, confirmLabel, }: FormModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
//# sourceMappingURL=FormModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/Info/Modals/FormModal/FormModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,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,4CAiGhB,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { Center } from "../../../Layout/Center/Center";
|
|
|
7
7
|
import { modalVariants } from "../variants";
|
|
8
8
|
import { Group } from "../../../Layout/Group/Group";
|
|
9
9
|
import { Button } from "../../../Inputs/Buttons/Button/Button";
|
|
10
|
-
export const FormModal = ({ opened, onClose, icon, children, size = "40rem", modalVariant = "info", confirmButtonDisabled = false, onCancel, onConfirm, cancelLabel, confirmLabel, }) => {
|
|
10
|
+
export const FormModal = ({ opened, onClose, icon, children, size = "40rem", modalVariant = "info", confirmButtonDisabled = false, confirmButtonLoading = false, onCancel, onConfirm, cancelLabel, confirmLabel, }) => {
|
|
11
11
|
const selectedVariant = modalVariants[modalVariant];
|
|
12
12
|
const iconContainer = {
|
|
13
13
|
width: "4.2rem",
|
|
@@ -55,5 +55,5 @@ export const FormModal = ({ opened, onClose, icon, children, size = "40rem", mod
|
|
|
55
55
|
body: {
|
|
56
56
|
padding: "0 3.2rem 1.6rem 3.2rem",
|
|
57
57
|
},
|
|
58
|
-
}, children: _jsx(Center, { h: "100%", w: "100%", children: _jsxs(Stack, { gap: "2rem", h: "100%", w: "100%", align: "center", children: [_jsxs(Stack, { gap: "1.5rem", align: "center", children: [_jsx(Center, { style: iconContainer, children: modalIcon }), children && (_jsx(Stack, { gap: "0.25rem", align: "center", children: children }))] }), _jsx(Center, { h: "100%", w: "100%", children: _jsxs(Group, { gap: "1rem", align: "center", children: [_jsx(Button, { onClick: onCancel, variant: "secondary", children: cancelLabel || selectedVariant.cancelLabel }), _jsx(Button, { onClick: onConfirm, variant: selectedVariant.buttonVariant, disabled: confirmButtonDisabled, children: confirmLabel || selectedVariant.confirmLabel })] }) })] }) }) }));
|
|
58
|
+
}, children: _jsx(Center, { h: "100%", w: "100%", children: _jsxs(Stack, { gap: "2rem", h: "100%", w: "100%", align: "center", children: [_jsxs(Stack, { gap: "1.5rem", align: "center", children: [_jsx(Center, { style: iconContainer, children: modalIcon }), children && (_jsx(Stack, { gap: "0.25rem", align: "center", children: children }))] }), _jsx(Center, { h: "100%", w: "100%", children: _jsxs(Group, { gap: "1rem", align: "center", children: [_jsx(Button, { onClick: onCancel, variant: "secondary", children: cancelLabel || selectedVariant.cancelLabel }), _jsx(Button, { onClick: onConfirm, variant: selectedVariant.buttonVariant, disabled: confirmButtonDisabled, loading: confirmButtonLoading, children: confirmLabel || selectedVariant.confirmLabel })] }) })] }) }) }));
|
|
59
59
|
};
|
|
@@ -11,5 +11,6 @@ export declare const Variants: Story;
|
|
|
11
11
|
export declare const Sizes: Story;
|
|
12
12
|
export declare const CustomLabels: Story;
|
|
13
13
|
export declare const ConfirmButtonDisabled: Story;
|
|
14
|
+
export declare const ConfirmButtonLoading: Story;
|
|
14
15
|
export declare const CompleteExample: Story;
|
|
15
16
|
//# sourceMappingURL=FormModal.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormModal.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Info/Modals/FormModal/FormModal.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAYxC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,
|
|
1
|
+
{"version":3,"file":"FormModal.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Info/Modals/FormModal/FormModal.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAYxC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,CA+FhC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AAExC,eAAO,MAAM,OAAO,EAAE,KAyDrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAuB5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAuBjC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAwB3B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAuCtB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAyCnB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAwB1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAgCnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAiClC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAwC7B,CAAC"}
|
|
@@ -69,6 +69,13 @@ const meta = {
|
|
|
69
69
|
type: { summary: "boolean" },
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
|
+
confirmButtonLoading: {
|
|
73
|
+
control: false,
|
|
74
|
+
description: "Whether the modal confirm button shows a loading state.",
|
|
75
|
+
table: {
|
|
76
|
+
type: { summary: "boolean" },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
72
79
|
onCancel: {
|
|
73
80
|
control: false,
|
|
74
81
|
description: "Handler for the cancel button click.",
|
|
@@ -192,6 +199,20 @@ export const ConfirmButtonDisabled = {
|
|
|
192
199
|
return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Open FormModal" }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), confirmButtonDisabled: name.trim().length === 0, children: _jsxs(Stack, { gap: "1rem", align: "center", children: [_jsx(Title, { variant: "cardSubheader", align: "center", children: "Enter your name to enable the confirm button." }), _jsx(TextInput, { label: "Name", placeholder: "Enter your name", value: name, onChange: (e) => setName(e.target.value) })] }) })] }));
|
|
193
200
|
},
|
|
194
201
|
};
|
|
202
|
+
export const ConfirmButtonLoading = {
|
|
203
|
+
render: () => {
|
|
204
|
+
const [opened, setOpened] = useState(false);
|
|
205
|
+
const [loading, setLoading] = useState(false);
|
|
206
|
+
const handleConfirm = () => {
|
|
207
|
+
setLoading(true);
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
setLoading(false);
|
|
210
|
+
setOpened(false);
|
|
211
|
+
}, 2000);
|
|
212
|
+
};
|
|
213
|
+
return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Open FormModal" }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: handleConfirm, confirmButtonLoading: loading, children: _jsx(Title, { variant: "cardSubheader", align: "center", children: "Click OK to see the button loading state." }) })] }));
|
|
214
|
+
},
|
|
215
|
+
};
|
|
195
216
|
export const CompleteExample = {
|
|
196
217
|
render: () => {
|
|
197
218
|
const [opened, setOpened] = useState(false);
|