@seeqdev/qomponents 0.0.108 → 0.0.109
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/Accordion/Accordion.js +8 -8
- package/dist/Accordion/Accordion.stories.js +114 -114
- package/dist/Accordion/Accordion.test.js +54 -54
- package/dist/Accordion/Accordion.types.js +1 -1
- package/dist/Accordion/index.js +1 -1
- package/dist/Alert/Alert.js +31 -31
- package/dist/Alert/Alert.stories.js +44 -44
- package/dist/Alert/Alert.test.js +50 -50
- package/dist/Alert/Alert.types.js +1 -1
- package/dist/Alert/index.js +1 -1
- package/dist/Button/Button.js +91 -91
- package/dist/Button/Button.stories.js +97 -97
- package/dist/Button/Button.test.js +48 -48
- package/dist/Button/Button.types.js +4 -4
- package/dist/Button/index.js +1 -1
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js +66 -66
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +97 -97
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +84 -84
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -1
- package/dist/ButtonWithDropdown/index.js +1 -1
- package/dist/ButtonWithPopover/ButtonWithPopover.js +50 -50
- package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +74 -74
- package/dist/ButtonWithPopover/ButtonWithPopover.test.js +81 -81
- package/dist/ButtonWithPopover/ButtonWithPopover.types.js +1 -1
- package/dist/ButtonWithPopover/index.js +1 -1
- package/dist/Checkbox/Checkbox.js +25 -25
- package/dist/Checkbox/Checkbox.stories.js +33 -33
- package/dist/Checkbox/Checkbox.test.js +93 -93
- package/dist/Checkbox/Checkbox.types.js +1 -1
- package/dist/Checkbox/index.js +1 -1
- package/dist/Icon/Icon.js +53 -53
- package/dist/Icon/Icon.stories.js +44 -44
- package/dist/Icon/Icon.test.js +54 -54
- package/dist/Icon/Icon.types.js +15 -15
- package/dist/Icon/index.js +1 -1
- package/dist/InputGroup/InputGroup.js +25 -25
- package/dist/InputGroup/InputGroup.stories.js +141 -141
- package/dist/InputGroup/InputGroup.test.js +42 -42
- package/dist/InputGroup/InputGroup.types.js +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/Modal/Modal.js +97 -97
- package/dist/Modal/Modal.stories.js +126 -126
- package/dist/Modal/Modal.test.js +107 -107
- package/dist/Modal/Modal.types.js +1 -1
- package/dist/Modal/index.js +1 -1
- package/dist/SeeqActionDropdown/SeeqActionDropdown.js +47 -47
- package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +79 -79
- package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -72
- package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -1
- package/dist/SeeqActionDropdown/index.js +1 -1
- package/dist/SeeqActionDropdown/variants.js +22 -22
- package/dist/Select/Select.js +173 -173
- package/dist/Select/Select.stories.js +79 -79
- package/dist/Select/Select.test.js +181 -181
- package/dist/Select/Select.types.js +1 -1
- package/dist/Select/index.js +2 -2
- package/dist/Tabs/Tabs.js +21 -21
- package/dist/Tabs/Tabs.stories.js +90 -90
- package/dist/Tabs/Tabs.test.js +90 -90
- package/dist/Tabs/Tabs.types.js +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/TextArea/TextArea.js +24 -24
- package/dist/TextArea/TextArea.stories.js +45 -45
- package/dist/TextArea/TextArea.test.js +67 -67
- package/dist/TextArea/TextArea.types.js +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/TextField/TextField.js +78 -78
- package/dist/TextField/TextField.stories.js +69 -69
- package/dist/TextField/TextField.test.js +38 -38
- package/dist/TextField/TextField.types.js +1 -1
- package/dist/TextField/index.js +1 -1
- package/dist/ToolbarButton/ToolbarButton.js +74 -74
- package/dist/ToolbarButton/ToolbarButton.stories.js +93 -93
- package/dist/ToolbarButton/ToolbarButton.test.js +92 -92
- package/dist/ToolbarButton/ToolbarButton.types.js +1 -1
- package/dist/ToolbarButton/index.js +1 -1
- package/dist/Tooltip/QTip.stories.js +44 -44
- package/dist/Tooltip/QTip.types.js +1 -1
- package/dist/Tooltip/QTipPerformance.stories.js +29 -29
- package/dist/Tooltip/Qtip.js +154 -154
- package/dist/Tooltip/Tooltip.js +30 -30
- package/dist/Tooltip/Tooltip.stories.js +31 -31
- package/dist/Tooltip/Tooltip.types.js +2 -2
- package/dist/Tooltip/TooltipPerformance.stories.js +29 -29
- package/dist/Tooltip/index.js +2 -2
- package/dist/Tooltip/qTip.utilities.js +10 -10
- package/dist/index.esm.js +30 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +30 -17
- package/dist/index.js.map +1 -1
- package/dist/types.js +1 -1
- package/dist/utils/browserId.js +28 -28
- package/dist/utils/svg.js +19 -19
- package/dist/utils/validateStyleDimension.js +13 -13
- package/dist/utils/validateStyleDimension.test.js +19 -19
- package/package.json +1 -1
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import Modal from './Modal';
|
|
3
|
-
import Button from '../Button';
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Modal',
|
|
6
|
-
};
|
|
7
|
-
const modalBody = (React.createElement("div", null, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."));
|
|
8
|
-
const waitUntil = async (timeout) => {
|
|
9
|
-
return new Promise((resolve) => {
|
|
10
|
-
setTimeout(() => resolve('yes'), timeout);
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
const ModalComponent = ({ bodyClass = '', title: originalTitle, titleIcon, isTitleEditable, children, hideCloseIcon, disableSubmitButton, size, buttonLabel = 'Open Modal', customButton, customButtonLabel, submitButtonVariant, onSubmit, }) => {
|
|
14
|
-
const [open, setOpen] = useState(false);
|
|
15
|
-
const [title, setTitle] = useState(originalTitle);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
return () => {
|
|
18
|
-
document.body.className = '';
|
|
19
|
-
};
|
|
20
|
-
}, []);
|
|
21
|
-
const onClose = () => {
|
|
22
|
-
document.body.className = '';
|
|
23
|
-
setOpen(false);
|
|
24
|
-
};
|
|
25
|
-
return (React.createElement("div", { className: "tw-p-4" },
|
|
26
|
-
React.createElement(Button, { onClick: () => {
|
|
27
|
-
document.body.className = bodyClass;
|
|
28
|
-
setOpen(true);
|
|
29
|
-
}, label: buttonLabel }),
|
|
30
|
-
React.createElement(Modal, { open: open, onClose: onClose, title: title, titleIcon: titleIcon, isTitleEditable: isTitleEditable, onTitleChanged: (event) => setTitle(event.target.value), hideCloseIcon: hideCloseIcon, disableSubmitButton: disableSubmitButton, size: size, onSubmit: onSubmit, customButton: customButton, submitButtonVariant: submitButtonVariant, onPointerDownOutside: onClose, customButtonLabel: customButtonLabel }, children)));
|
|
31
|
-
};
|
|
32
|
-
export const AllModalsVariants = () => {
|
|
33
|
-
const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
|
|
34
|
-
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
|
|
35
|
-
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => (React.createElement("div", { key: color },
|
|
36
|
-
React.createElement("b", null,
|
|
37
|
-
color,
|
|
38
|
-
" colors"),
|
|
39
|
-
React.createElement("div", { className: "tw-p-4 light" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}`, bodyClass: `color_${color.toLowerCase()}`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))),
|
|
40
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}_dark`, bodyClass: `color_${color.toLowerCase()} tw-dark color_${color.toLowerCase()}_dark`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))))))));
|
|
41
|
-
};
|
|
42
|
-
export const ModalsWithDisabledSubmit = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
43
|
-
React.createElement("div", null,
|
|
44
|
-
React.createElement("b", null, "Topic Colors"),
|
|
45
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
46
|
-
React.createElement(ModalComponent, { bodyClass: "color_topic", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
47
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
48
|
-
React.createElement(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }))),
|
|
49
|
-
React.createElement("div", null,
|
|
50
|
-
React.createElement("b", null, "Analysis Colors"),
|
|
51
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
52
|
-
React.createElement(ModalComponent, { bodyClass: "color_analysis", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
53
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
54
|
-
React.createElement(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }))),
|
|
55
|
-
React.createElement("div", null,
|
|
56
|
-
React.createElement("b", null, "Datalab Colors"),
|
|
57
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
58
|
-
React.createElement(ModalComponent, { bodyClass: "color_datalab", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
59
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
60
|
-
React.createElement(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }))),
|
|
61
|
-
React.createElement("div", null,
|
|
62
|
-
React.createElement("b", null, "Vantage Colors"),
|
|
63
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
64
|
-
React.createElement(ModalComponent, { bodyClass: "color_vantage", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
65
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
66
|
-
React.createElement(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })))));
|
|
67
|
-
export const ModalsWithEditableTitle = () => {
|
|
68
|
-
const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
|
|
69
|
-
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
|
|
70
|
-
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => (React.createElement("div", { key: color },
|
|
71
|
-
React.createElement("b", null,
|
|
72
|
-
color,
|
|
73
|
-
" colors"),
|
|
74
|
-
React.createElement("div", { className: "tw-p-4 light" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}`, bodyClass: `color_${color.toLowerCase()}`, title: "Editable title example", isTitleEditable: true, titleIcon: "fc-check", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))),
|
|
75
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}_dark`, bodyClass: `color_${color.toLowerCase()} tw-dark color_${color.toLowerCase()}_dark`, title: "Editable title example", isTitleEditable: true, titleIcon: "fc-check", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))))))));
|
|
76
|
-
};
|
|
77
|
-
export const ModalsWithCustomButton = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
78
|
-
React.createElement("div", null,
|
|
79
|
-
React.createElement("b", null, "Topic Colors"),
|
|
80
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
81
|
-
React.createElement(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
82
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
83
|
-
React.createElement(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }))),
|
|
84
|
-
React.createElement("div", null,
|
|
85
|
-
React.createElement("b", null, "Analysis Colors"),
|
|
86
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
87
|
-
React.createElement(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
88
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
89
|
-
React.createElement(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }))),
|
|
90
|
-
React.createElement("div", null,
|
|
91
|
-
React.createElement("b", null, "Datalab Colors"),
|
|
92
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
93
|
-
React.createElement(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
94
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
95
|
-
React.createElement(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }))),
|
|
96
|
-
React.createElement("div", null,
|
|
97
|
-
React.createElement("b", null, "Vantage Colors"),
|
|
98
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
99
|
-
React.createElement(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
100
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
101
|
-
React.createElement(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })))));
|
|
102
|
-
export const ModalsWithVariantButton = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
103
|
-
React.createElement("div", null,
|
|
104
|
-
React.createElement("b", null, "Topic Colors"),
|
|
105
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
106
|
-
React.createElement(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme" })),
|
|
107
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
108
|
-
React.createElement(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme-light" }))),
|
|
109
|
-
React.createElement("div", null,
|
|
110
|
-
React.createElement("b", null, "Analysis Colors"),
|
|
111
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
112
|
-
React.createElement(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "warning" })),
|
|
113
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
114
|
-
React.createElement(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "danger", customButtonLabel: "Back" }))),
|
|
115
|
-
React.createElement("div", null,
|
|
116
|
-
React.createElement("b", null, "Datalab Colors"),
|
|
117
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
118
|
-
React.createElement(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "outline" })),
|
|
119
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
120
|
-
React.createElement(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "no-border", customButtonLabel: "Back" }))),
|
|
121
|
-
React.createElement("div", null,
|
|
122
|
-
React.createElement("b", null, "Vantage Colors"),
|
|
123
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
124
|
-
React.createElement(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "theme", customButtonLabel: "Back" })),
|
|
125
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
126
|
-
React.createElement(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, submitButtonVariant: "outline", customButton: true, customButtonLabel: "Back" })))));
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import Modal from './Modal';
|
|
3
|
+
import Button from '../Button';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Modal',
|
|
6
|
+
};
|
|
7
|
+
const modalBody = (React.createElement("div", null, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."));
|
|
8
|
+
const waitUntil = async (timeout) => {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
setTimeout(() => resolve('yes'), timeout);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const ModalComponent = ({ bodyClass = '', title: originalTitle, titleIcon, isTitleEditable, children, hideCloseIcon, disableSubmitButton, size, buttonLabel = 'Open Modal', customButton, customButtonLabel, submitButtonVariant, onSubmit, }) => {
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
|
+
const [title, setTitle] = useState(originalTitle);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
return () => {
|
|
18
|
+
document.body.className = '';
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
const onClose = () => {
|
|
22
|
+
document.body.className = '';
|
|
23
|
+
setOpen(false);
|
|
24
|
+
};
|
|
25
|
+
return (React.createElement("div", { className: "tw-p-4" },
|
|
26
|
+
React.createElement(Button, { onClick: () => {
|
|
27
|
+
document.body.className = bodyClass;
|
|
28
|
+
setOpen(true);
|
|
29
|
+
}, label: buttonLabel }),
|
|
30
|
+
React.createElement(Modal, { open: open, onClose: onClose, title: title, titleIcon: titleIcon, isTitleEditable: isTitleEditable, onTitleChanged: (event) => setTitle(event.target.value), hideCloseIcon: hideCloseIcon, disableSubmitButton: disableSubmitButton, size: size, onSubmit: onSubmit, customButton: customButton, submitButtonVariant: submitButtonVariant, onPointerDownOutside: onClose, customButtonLabel: customButtonLabel }, children)));
|
|
31
|
+
};
|
|
32
|
+
export const AllModalsVariants = () => {
|
|
33
|
+
const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
|
|
34
|
+
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
|
|
35
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => (React.createElement("div", { key: color },
|
|
36
|
+
React.createElement("b", null,
|
|
37
|
+
color,
|
|
38
|
+
" colors"),
|
|
39
|
+
React.createElement("div", { className: "tw-p-4 light" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}`, bodyClass: `color_${color.toLowerCase()}`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))),
|
|
40
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}_dark`, bodyClass: `color_${color.toLowerCase()} tw-dark color_${color.toLowerCase()}_dark`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))))))));
|
|
41
|
+
};
|
|
42
|
+
export const ModalsWithDisabledSubmit = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
43
|
+
React.createElement("div", null,
|
|
44
|
+
React.createElement("b", null, "Topic Colors"),
|
|
45
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
46
|
+
React.createElement(ModalComponent, { bodyClass: "color_topic", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
47
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
48
|
+
React.createElement(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }))),
|
|
49
|
+
React.createElement("div", null,
|
|
50
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
51
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
52
|
+
React.createElement(ModalComponent, { bodyClass: "color_analysis", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
53
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
54
|
+
React.createElement(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }))),
|
|
55
|
+
React.createElement("div", null,
|
|
56
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
57
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
58
|
+
React.createElement(ModalComponent, { bodyClass: "color_datalab", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
59
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
60
|
+
React.createElement(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }))),
|
|
61
|
+
React.createElement("div", null,
|
|
62
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
63
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
64
|
+
React.createElement(ModalComponent, { bodyClass: "color_vantage", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })),
|
|
65
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
66
|
+
React.createElement(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody })))));
|
|
67
|
+
export const ModalsWithEditableTitle = () => {
|
|
68
|
+
const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
|
|
69
|
+
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
|
|
70
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => (React.createElement("div", { key: color },
|
|
71
|
+
React.createElement("b", null,
|
|
72
|
+
color,
|
|
73
|
+
" colors"),
|
|
74
|
+
React.createElement("div", { className: "tw-p-4 light" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}`, bodyClass: `color_${color.toLowerCase()}`, title: "Editable title example", isTitleEditable: true, titleIcon: "fc-check", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))),
|
|
75
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, sizes.map((size) => (React.createElement(ModalComponent, { key: `${size}_${color}_dark`, bodyClass: `color_${color.toLowerCase()} tw-dark color_${color.toLowerCase()}_dark`, title: "Editable title example", isTitleEditable: true, titleIcon: "fc-check", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` })))))))));
|
|
76
|
+
};
|
|
77
|
+
export const ModalsWithCustomButton = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
78
|
+
React.createElement("div", null,
|
|
79
|
+
React.createElement("b", null, "Topic Colors"),
|
|
80
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
81
|
+
React.createElement(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
82
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
83
|
+
React.createElement(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }))),
|
|
84
|
+
React.createElement("div", null,
|
|
85
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
86
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
87
|
+
React.createElement(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
88
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
89
|
+
React.createElement(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }))),
|
|
90
|
+
React.createElement("div", null,
|
|
91
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
92
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
93
|
+
React.createElement(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
94
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
95
|
+
React.createElement(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }))),
|
|
96
|
+
React.createElement("div", null,
|
|
97
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
98
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
99
|
+
React.createElement(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })),
|
|
100
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
101
|
+
React.createElement(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" })))));
|
|
102
|
+
export const ModalsWithVariantButton = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
103
|
+
React.createElement("div", null,
|
|
104
|
+
React.createElement("b", null, "Topic Colors"),
|
|
105
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
106
|
+
React.createElement(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme" })),
|
|
107
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
108
|
+
React.createElement(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme-light" }))),
|
|
109
|
+
React.createElement("div", null,
|
|
110
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
111
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
112
|
+
React.createElement(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "warning" })),
|
|
113
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
114
|
+
React.createElement(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "danger", customButtonLabel: "Back" }))),
|
|
115
|
+
React.createElement("div", null,
|
|
116
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
117
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
118
|
+
React.createElement(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "outline" })),
|
|
119
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
120
|
+
React.createElement(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "no-border", customButtonLabel: "Back" }))),
|
|
121
|
+
React.createElement("div", null,
|
|
122
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
123
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
124
|
+
React.createElement(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "theme", customButtonLabel: "Back" })),
|
|
125
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
126
|
+
React.createElement(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, submitButtonVariant: "outline", customButton: true, customButtonLabel: "Back" })))));
|
|
127
127
|
//# sourceMappingURL=Modal.stories.js.map
|
package/dist/Modal/Modal.test.js
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import Modal from './Modal';
|
|
6
|
-
describe('Modal', () => {
|
|
7
|
-
class Context {
|
|
8
|
-
props = {
|
|
9
|
-
onTitleChanged: jest.fn(),
|
|
10
|
-
disableSubmitButton: false,
|
|
11
|
-
title: 'Testing Modal Dialog',
|
|
12
|
-
children: React.createElement("div", null, "Modal content"),
|
|
13
|
-
open: true,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
let tc;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
tc = new Context();
|
|
19
|
-
});
|
|
20
|
-
const renderModal = (props) => render(React.createElement(Modal, { ...props }));
|
|
21
|
-
describe('renders Modal', () => {
|
|
22
|
-
it('doesn\'t render the modal if the open state is false', () => {
|
|
23
|
-
const open = false;
|
|
24
|
-
renderModal({ ...tc.props, open });
|
|
25
|
-
expect(screen.queryByTestId('modal')).not.toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
it('renders the modal if the open state is true', () => {
|
|
28
|
-
renderModal(tc.props);
|
|
29
|
-
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
|
30
|
-
expect(screen.getByTestId('modal')).toHaveClass('tw-max-w-xl');
|
|
31
|
-
});
|
|
32
|
-
it('calls onClose modal when close button is clicked', async () => {
|
|
33
|
-
const onClose = jest.fn();
|
|
34
|
-
const { getByTestId } = renderModal({ ...tc.props, onClose });
|
|
35
|
-
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
|
36
|
-
await userEvent.click(getByTestId('closeButton'));
|
|
37
|
-
expect(onClose).toHaveBeenCalled();
|
|
38
|
-
});
|
|
39
|
-
it('hides close button', () => {
|
|
40
|
-
const hideCloseIcon = true;
|
|
41
|
-
const { queryByTestId } = renderModal({ ...tc.props, hideCloseIcon });
|
|
42
|
-
expect(queryByTestId('closeButton')).not.toBeInTheDocument();
|
|
43
|
-
});
|
|
44
|
-
it('renders modal size based on the size prop', () => {
|
|
45
|
-
const size = 'lg';
|
|
46
|
-
renderModal({ ...tc.props, size });
|
|
47
|
-
expect(screen.getByTestId('modal')).toHaveClass('tw-max-w-lg');
|
|
48
|
-
});
|
|
49
|
-
it('renders not editable title', () => {
|
|
50
|
-
renderModal(tc.props);
|
|
51
|
-
expect(screen.getByTestId('modalTitle')).not.toHaveAttribute('value');
|
|
52
|
-
});
|
|
53
|
-
it('renders editable title', () => {
|
|
54
|
-
const isTitleEditable = true;
|
|
55
|
-
const { getByTestId } = renderModal({ ...tc.props, isTitleEditable });
|
|
56
|
-
expect(getByTestId('modalTitle')).toHaveAttribute('value');
|
|
57
|
-
});
|
|
58
|
-
it('calls onChange when title is modified', async () => {
|
|
59
|
-
const isTitleEditable = true;
|
|
60
|
-
const { getByTestId } = renderModal({ ...tc.props, isTitleEditable });
|
|
61
|
-
await userEvent.type(getByTestId('modalTitle'), 'a');
|
|
62
|
-
expect(tc.props.onTitleChanged).toHaveBeenCalled();
|
|
63
|
-
});
|
|
64
|
-
it('displays icon title', () => {
|
|
65
|
-
const titleIcon = 'fc-check';
|
|
66
|
-
const { getByTestId } = renderModal({ ...tc.props, titleIcon });
|
|
67
|
-
expect(getByTestId('modalTitleIcon')).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
it('calls onSubmit when submit button is clicked', async () => {
|
|
70
|
-
const onSubmit = jest.fn();
|
|
71
|
-
const { getByTestId } = renderModal({ ...tc.props, onSubmit });
|
|
72
|
-
expect(getByTestId('submitButton')).not.toBeDisabled();
|
|
73
|
-
await userEvent.click(getByTestId('submitButton'));
|
|
74
|
-
expect(onSubmit).toHaveBeenCalled();
|
|
75
|
-
});
|
|
76
|
-
it('displays the disabled submit button', async () => {
|
|
77
|
-
const onSubmit = jest.fn();
|
|
78
|
-
const disableSubmitButton = true;
|
|
79
|
-
const { getByTestId } = renderModal({ ...tc.props, onSubmit, disableSubmitButton });
|
|
80
|
-
expect(getByTestId('submitButton')).toBeDisabled();
|
|
81
|
-
await userEvent.click(getByTestId('submitButton'));
|
|
82
|
-
expect(onSubmit).not.toHaveBeenCalled();
|
|
83
|
-
});
|
|
84
|
-
it('calls onClose when cancel button is clicked', async () => {
|
|
85
|
-
const onClose = jest.fn();
|
|
86
|
-
const { getByTestId } = renderModal({ ...tc.props, onClose });
|
|
87
|
-
expect(getByTestId('cancelButton')).not.toBeDisabled();
|
|
88
|
-
await userEvent.click(getByTestId('cancelButton'));
|
|
89
|
-
expect(onClose).toHaveBeenCalled();
|
|
90
|
-
});
|
|
91
|
-
it('displays custom button', () => {
|
|
92
|
-
const customButton = true;
|
|
93
|
-
const customButtonLabel = 'Back';
|
|
94
|
-
const { getByTestId } = renderModal({ ...tc.props, customButton, customButtonLabel });
|
|
95
|
-
expect(getByTestId('customButton')).toBeInTheDocument();
|
|
96
|
-
});
|
|
97
|
-
it('calls onClickCustomButton when custom button is clicked', async () => {
|
|
98
|
-
const customButton = true;
|
|
99
|
-
const customButtonLabel = 'Back';
|
|
100
|
-
const onClickCustomButton = jest.fn();
|
|
101
|
-
const { getByTestId } = renderModal({ ...tc.props, customButtonLabel, customButton, onClickCustomButton });
|
|
102
|
-
expect(getByTestId('customButton')).toBeInTheDocument();
|
|
103
|
-
await userEvent.click(getByTestId('customButton'));
|
|
104
|
-
expect(onClickCustomButton).toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import Modal from './Modal';
|
|
6
|
+
describe('Modal', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
props = {
|
|
9
|
+
onTitleChanged: jest.fn(),
|
|
10
|
+
disableSubmitButton: false,
|
|
11
|
+
title: 'Testing Modal Dialog',
|
|
12
|
+
children: React.createElement("div", null, "Modal content"),
|
|
13
|
+
open: true,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
let tc;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
tc = new Context();
|
|
19
|
+
});
|
|
20
|
+
const renderModal = (props) => render(React.createElement(Modal, { ...props }));
|
|
21
|
+
describe('renders Modal', () => {
|
|
22
|
+
it('doesn\'t render the modal if the open state is false', () => {
|
|
23
|
+
const open = false;
|
|
24
|
+
renderModal({ ...tc.props, open });
|
|
25
|
+
expect(screen.queryByTestId('modal')).not.toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
it('renders the modal if the open state is true', () => {
|
|
28
|
+
renderModal(tc.props);
|
|
29
|
+
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByTestId('modal')).toHaveClass('tw-max-w-xl');
|
|
31
|
+
});
|
|
32
|
+
it('calls onClose modal when close button is clicked', async () => {
|
|
33
|
+
const onClose = jest.fn();
|
|
34
|
+
const { getByTestId } = renderModal({ ...tc.props, onClose });
|
|
35
|
+
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
|
36
|
+
await userEvent.click(getByTestId('closeButton'));
|
|
37
|
+
expect(onClose).toHaveBeenCalled();
|
|
38
|
+
});
|
|
39
|
+
it('hides close button', () => {
|
|
40
|
+
const hideCloseIcon = true;
|
|
41
|
+
const { queryByTestId } = renderModal({ ...tc.props, hideCloseIcon });
|
|
42
|
+
expect(queryByTestId('closeButton')).not.toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
it('renders modal size based on the size prop', () => {
|
|
45
|
+
const size = 'lg';
|
|
46
|
+
renderModal({ ...tc.props, size });
|
|
47
|
+
expect(screen.getByTestId('modal')).toHaveClass('tw-max-w-lg');
|
|
48
|
+
});
|
|
49
|
+
it('renders not editable title', () => {
|
|
50
|
+
renderModal(tc.props);
|
|
51
|
+
expect(screen.getByTestId('modalTitle')).not.toHaveAttribute('value');
|
|
52
|
+
});
|
|
53
|
+
it('renders editable title', () => {
|
|
54
|
+
const isTitleEditable = true;
|
|
55
|
+
const { getByTestId } = renderModal({ ...tc.props, isTitleEditable });
|
|
56
|
+
expect(getByTestId('modalTitle')).toHaveAttribute('value');
|
|
57
|
+
});
|
|
58
|
+
it('calls onChange when title is modified', async () => {
|
|
59
|
+
const isTitleEditable = true;
|
|
60
|
+
const { getByTestId } = renderModal({ ...tc.props, isTitleEditable });
|
|
61
|
+
await userEvent.type(getByTestId('modalTitle'), 'a');
|
|
62
|
+
expect(tc.props.onTitleChanged).toHaveBeenCalled();
|
|
63
|
+
});
|
|
64
|
+
it('displays icon title', () => {
|
|
65
|
+
const titleIcon = 'fc-check';
|
|
66
|
+
const { getByTestId } = renderModal({ ...tc.props, titleIcon });
|
|
67
|
+
expect(getByTestId('modalTitleIcon')).toBeInTheDocument();
|
|
68
|
+
});
|
|
69
|
+
it('calls onSubmit when submit button is clicked', async () => {
|
|
70
|
+
const onSubmit = jest.fn();
|
|
71
|
+
const { getByTestId } = renderModal({ ...tc.props, onSubmit });
|
|
72
|
+
expect(getByTestId('submitButton')).not.toBeDisabled();
|
|
73
|
+
await userEvent.click(getByTestId('submitButton'));
|
|
74
|
+
expect(onSubmit).toHaveBeenCalled();
|
|
75
|
+
});
|
|
76
|
+
it('displays the disabled submit button', async () => {
|
|
77
|
+
const onSubmit = jest.fn();
|
|
78
|
+
const disableSubmitButton = true;
|
|
79
|
+
const { getByTestId } = renderModal({ ...tc.props, onSubmit, disableSubmitButton });
|
|
80
|
+
expect(getByTestId('submitButton')).toBeDisabled();
|
|
81
|
+
await userEvent.click(getByTestId('submitButton'));
|
|
82
|
+
expect(onSubmit).not.toHaveBeenCalled();
|
|
83
|
+
});
|
|
84
|
+
it('calls onClose when cancel button is clicked', async () => {
|
|
85
|
+
const onClose = jest.fn();
|
|
86
|
+
const { getByTestId } = renderModal({ ...tc.props, onClose });
|
|
87
|
+
expect(getByTestId('cancelButton')).not.toBeDisabled();
|
|
88
|
+
await userEvent.click(getByTestId('cancelButton'));
|
|
89
|
+
expect(onClose).toHaveBeenCalled();
|
|
90
|
+
});
|
|
91
|
+
it('displays custom button', () => {
|
|
92
|
+
const customButton = true;
|
|
93
|
+
const customButtonLabel = 'Back';
|
|
94
|
+
const { getByTestId } = renderModal({ ...tc.props, customButton, customButtonLabel });
|
|
95
|
+
expect(getByTestId('customButton')).toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
it('calls onClickCustomButton when custom button is clicked', async () => {
|
|
98
|
+
const customButton = true;
|
|
99
|
+
const customButtonLabel = 'Back';
|
|
100
|
+
const onClickCustomButton = jest.fn();
|
|
101
|
+
const { getByTestId } = renderModal({ ...tc.props, customButtonLabel, customButton, onClickCustomButton });
|
|
102
|
+
expect(getByTestId('customButton')).toBeInTheDocument();
|
|
103
|
+
await userEvent.click(getByTestId('customButton'));
|
|
104
|
+
expect(onClickCustomButton).toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
108
|
//# sourceMappingURL=Modal.test.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=Modal.types.js.map
|
package/dist/Modal/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from './Modal';
|
|
1
|
+
export { default } from './Modal';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
|
3
|
-
import { getQTipData } from '../Tooltip/qTip.utilities';
|
|
4
|
-
import { InsertSeeqContent, SeeqActionDropdownItem, ViewWorkbench } from './variants';
|
|
5
|
-
const borderStyles = [
|
|
6
|
-
'tw-border-solid',
|
|
7
|
-
'tw-border',
|
|
8
|
-
'tw-rounded-sm',
|
|
9
|
-
'tw-border-sq-disabled-gray',
|
|
10
|
-
'dark:tw-border-gray-500',
|
|
11
|
-
].join(' ');
|
|
12
|
-
const bgStyles = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
|
|
13
|
-
const disabledClasses = ['tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
|
|
14
|
-
const renderItem = (variant, item) => {
|
|
15
|
-
switch (variant) {
|
|
16
|
-
case 'create-workbench':
|
|
17
|
-
return React.createElement(SeeqActionDropdownItem, { ...item });
|
|
18
|
-
case 'view-workbench':
|
|
19
|
-
return React.createElement(ViewWorkbench, { ...item });
|
|
20
|
-
case 'insert-seeq-content':
|
|
21
|
-
return React.createElement(InsertSeeqContent, { ...item });
|
|
22
|
-
default:
|
|
23
|
-
return React.createElement(SeeqActionDropdownItem, { ...item });
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const SeeqActionDropdown = ({ seeqActionDropdownItems, trigger, id, extraClassNames, containerTestId, disabled = false, align = 'end', placement = 'bottom', placementOffset = 5, alignOffset = -35, hasArrow = false, onOpenChange, isOpen, setFocusOnTriggerOnClose = true, keepFocusInsideDropdown = true, variant, ...tooltipProps }) => {
|
|
27
|
-
const tooltipData = getQTipData(tooltipProps);
|
|
28
|
-
return (React.createElement(DropdownMenu.Root, { defaultOpen: false, open: isOpen, onOpenChange: onOpenChange, modal: keepFocusInsideDropdown },
|
|
29
|
-
React.createElement(DropdownMenu.Trigger, { id: id, "data-testid": id, className: `tw-border-none focus-visible:tw-outline-none focus:tw-outline-none focus-within:tw-outline-none`, asChild: true, disabled: disabled },
|
|
30
|
-
React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-flex tw-flex-col tw-items-center focus-visible:tw-outline-none focus:tw-outline-none focus-within:tw-outline-none ${disabled ? disabledClasses : ''} ${extraClassNames || ''}` }, trigger)),
|
|
31
|
-
React.createElement(DropdownMenu.Content, { sideOffset: placementOffset, side: placement, align: align, alignOffset: alignOffset, asChild: true, onCloseAutoFocus: (e) => !setFocusOnTriggerOnClose && e.preventDefault(), className: "focus-visible:tw-outline-none tw-outline-none" },
|
|
32
|
-
React.createElement("div", { "data-testid": containerTestId, className: bgStyles +
|
|
33
|
-
' tw-relative tw-z-[1200] tw-min-w-6 tw-py-2 focus-visible:tw-outline-none tw-outline-none' +
|
|
34
|
-
' data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out' +
|
|
35
|
-
' forceFont data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade ' +
|
|
36
|
-
borderStyles },
|
|
37
|
-
hasArrow && (React.createElement(DropdownMenu.Arrow, { asChild: true },
|
|
38
|
-
React.createElement("div", { className: " tw-fill-transparent tw-bg-white tw-w-[15px] tw-h-[15px] tw-rotate-45 dark:tw-bg-sq-dark-background tw-border-b tw-border-r tw-border-sq-disabled-gray dark:tw-border-gray-500 tw-mt-[-7px]" }))),
|
|
39
|
-
seeqActionDropdownItems.map((item, index) => {
|
|
40
|
-
return (React.createElement("div", { key: item.display + index },
|
|
41
|
-
React.createElement(DropdownMenu.Item, { onSelect: (e) => {
|
|
42
|
-
item.action(e);
|
|
43
|
-
}, className: `tw-cursor-pointer tw-flex dark:tw-text-sq-white hover:tw-bg-sq-gray-highlight dark:hover:tw-bg-sq-gray-highlight-dark tw-relative tw-select-none tw-outline-none data-[disabled]:tw-text-sq-disabled-gray data-[disabled]:tw-pointer-events-none`, "data-testid": item.testId, disabled: !item.enabled }, renderItem(variant, item)),
|
|
44
|
-
item.divider && (React.createElement(DropdownMenu.Separator, { "data-testid": `dropdown-divider-${index}`, className: "tw-h-[1px] tw-bg-sq-disabled-gray dark:tw-bg-gray-500 tw-my-[8px]" }))));
|
|
45
|
-
})))));
|
|
46
|
-
};
|
|
47
|
-
export default SeeqActionDropdown;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
import { getQTipData } from '../Tooltip/qTip.utilities';
|
|
4
|
+
import { InsertSeeqContent, SeeqActionDropdownItem, ViewWorkbench } from './variants';
|
|
5
|
+
const borderStyles = [
|
|
6
|
+
'tw-border-solid',
|
|
7
|
+
'tw-border',
|
|
8
|
+
'tw-rounded-sm',
|
|
9
|
+
'tw-border-sq-disabled-gray',
|
|
10
|
+
'dark:tw-border-gray-500',
|
|
11
|
+
].join(' ');
|
|
12
|
+
const bgStyles = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
|
|
13
|
+
const disabledClasses = ['tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
|
|
14
|
+
const renderItem = (variant, item) => {
|
|
15
|
+
switch (variant) {
|
|
16
|
+
case 'create-workbench':
|
|
17
|
+
return React.createElement(SeeqActionDropdownItem, { ...item });
|
|
18
|
+
case 'view-workbench':
|
|
19
|
+
return React.createElement(ViewWorkbench, { ...item });
|
|
20
|
+
case 'insert-seeq-content':
|
|
21
|
+
return React.createElement(InsertSeeqContent, { ...item });
|
|
22
|
+
default:
|
|
23
|
+
return React.createElement(SeeqActionDropdownItem, { ...item });
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const SeeqActionDropdown = ({ seeqActionDropdownItems, trigger, id, extraClassNames, containerTestId, disabled = false, align = 'end', placement = 'bottom', placementOffset = 5, alignOffset = -35, hasArrow = false, onOpenChange, isOpen, setFocusOnTriggerOnClose = true, keepFocusInsideDropdown = true, variant, ...tooltipProps }) => {
|
|
27
|
+
const tooltipData = getQTipData(tooltipProps);
|
|
28
|
+
return (React.createElement(DropdownMenu.Root, { defaultOpen: false, open: isOpen, onOpenChange: onOpenChange, modal: keepFocusInsideDropdown },
|
|
29
|
+
React.createElement(DropdownMenu.Trigger, { id: id, "data-testid": id, className: `tw-border-none focus-visible:tw-outline-none focus:tw-outline-none focus-within:tw-outline-none`, asChild: true, disabled: disabled },
|
|
30
|
+
React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-flex tw-flex-col tw-items-center focus-visible:tw-outline-none focus:tw-outline-none focus-within:tw-outline-none ${disabled ? disabledClasses : ''} ${extraClassNames || ''}` }, trigger)),
|
|
31
|
+
React.createElement(DropdownMenu.Content, { sideOffset: placementOffset, side: placement, align: align, alignOffset: alignOffset, asChild: true, onCloseAutoFocus: (e) => !setFocusOnTriggerOnClose && e.preventDefault(), className: "focus-visible:tw-outline-none tw-outline-none" },
|
|
32
|
+
React.createElement("div", { "data-testid": containerTestId, className: bgStyles +
|
|
33
|
+
' tw-relative tw-z-[1200] tw-min-w-6 tw-py-2 focus-visible:tw-outline-none tw-outline-none' +
|
|
34
|
+
' data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out' +
|
|
35
|
+
' forceFont data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade ' +
|
|
36
|
+
borderStyles },
|
|
37
|
+
hasArrow && (React.createElement(DropdownMenu.Arrow, { asChild: true },
|
|
38
|
+
React.createElement("div", { className: " tw-fill-transparent tw-bg-white tw-w-[15px] tw-h-[15px] tw-rotate-45 dark:tw-bg-sq-dark-background tw-border-b tw-border-r tw-border-sq-disabled-gray dark:tw-border-gray-500 tw-mt-[-7px]" }))),
|
|
39
|
+
seeqActionDropdownItems.map((item, index) => {
|
|
40
|
+
return (React.createElement("div", { key: item.display + index },
|
|
41
|
+
React.createElement(DropdownMenu.Item, { onSelect: (e) => {
|
|
42
|
+
item.action(e);
|
|
43
|
+
}, className: `tw-cursor-pointer tw-flex dark:tw-text-sq-white hover:tw-bg-sq-gray-highlight dark:hover:tw-bg-sq-gray-highlight-dark tw-relative tw-select-none tw-outline-none data-[disabled]:tw-text-sq-disabled-gray data-[disabled]:tw-pointer-events-none`, "data-testid": item.testId, disabled: !item.enabled }, renderItem(variant, item)),
|
|
44
|
+
item.divider && (React.createElement(DropdownMenu.Separator, { "data-testid": `dropdown-divider-${index}`, className: "tw-h-[1px] tw-bg-sq-disabled-gray dark:tw-bg-gray-500 tw-my-[8px]" }))));
|
|
45
|
+
})))));
|
|
46
|
+
};
|
|
47
|
+
export default SeeqActionDropdown;
|
|
48
48
|
//# sourceMappingURL=SeeqActionDropdown.js.map
|