@seeqdev/qomponents 0.0.185 → 0.0.186
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/package.json +2 -2
- package/dist/src/Accordion/Accordion.js +0 -8
- package/dist/src/Accordion/Accordion.stories.js +0 -96
- package/dist/src/Accordion/Accordion.test.js +0 -54
- package/dist/src/Accordion/Accordion.types.js +0 -1
- package/dist/src/Accordion/index.js +0 -1
- package/dist/src/Alert/Alert.js +0 -33
- package/dist/src/Alert/Alert.stories.js +0 -72
- package/dist/src/Alert/Alert.test.js +0 -49
- package/dist/src/Alert/Alert.types.js +0 -1
- package/dist/src/Alert/index.js +0 -1
- package/dist/src/Button/Button.js +0 -107
- package/dist/src/Button/Button.stories.js +0 -74
- package/dist/src/Button/Button.test.js +0 -65
- package/dist/src/Button/Button.types.js +0 -4
- package/dist/src/Button/index.js +0 -1
- package/dist/src/ButtonGroup/ButtonGroup.js +0 -34
- package/dist/src/ButtonGroup/ButtonGroup.stories.js +0 -328
- package/dist/src/ButtonGroup/ButtonGroup.test.js +0 -65
- package/dist/src/ButtonGroup/ButtonGroup.types.js +0 -1
- package/dist/src/ButtonGroup/index.js +0 -1
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.js +0 -46
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.stories.js +0 -119
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.test.js +0 -92
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.types.js +0 -1
- package/dist/src/ButtonWithDropdown/index.js +0 -1
- package/dist/src/ButtonWithPopover/ButtonWithPopover.js +0 -54
- package/dist/src/ButtonWithPopover/ButtonWithPopover.stories.js +0 -51
- package/dist/src/ButtonWithPopover/ButtonWithPopover.test.js +0 -80
- package/dist/src/ButtonWithPopover/ButtonWithPopover.types.js +0 -1
- package/dist/src/ButtonWithPopover/index.js +0 -1
- package/dist/src/Carousel/Carousel.js +0 -80
- package/dist/src/Carousel/Carousel.stories.js +0 -100
- package/dist/src/Carousel/Carousel.test.js +0 -47
- package/dist/src/Carousel/Carousel.types.js +0 -1
- package/dist/src/Carousel/index.js +0 -1
- package/dist/src/Checkbox/Checkbox.js +0 -24
- package/dist/src/Checkbox/Checkbox.stories.js +0 -21
- package/dist/src/Checkbox/Checkbox.test.js +0 -93
- package/dist/src/Checkbox/Checkbox.types.js +0 -1
- package/dist/src/Checkbox/index.js +0 -1
- package/dist/src/Collapse/Collapse.js +0 -16
- package/dist/src/Collapse/Collapse.stories.js +0 -28
- package/dist/src/Collapse/Collapse.test.js +0 -16
- package/dist/src/Collapse/Collapse.types.js +0 -1
- package/dist/src/Collapse/index.js +0 -1
- package/dist/src/Icon/Icon.js +0 -55
- package/dist/src/Icon/Icon.stories.js +0 -31
- package/dist/src/Icon/Icon.test.js +0 -54
- package/dist/src/Icon/Icon.types.js +0 -15
- package/dist/src/Icon/index.js +0 -1
- package/dist/src/InputGroup/InputGroup.js +0 -33
- package/dist/src/InputGroup/InputGroup.stories.js +0 -144
- package/dist/src/InputGroup/InputGroup.test.js +0 -41
- package/dist/src/InputGroup/InputGroup.types.js +0 -1
- package/dist/src/InputGroup/index.js +0 -1
- package/dist/src/Modal/Modal.js +0 -86
- package/dist/src/Modal/Modal.stories.js +0 -79
- package/dist/src/Modal/Modal.test.js +0 -107
- package/dist/src/Modal/Modal.types.js +0 -1
- package/dist/src/Modal/index.js +0 -1
- package/dist/src/ProgressBar/ProgressBar.js +0 -71
- package/dist/src/ProgressBar/ProgressBar.stories.js +0 -46
- package/dist/src/ProgressBar/ProgressBar.test.js +0 -42
- package/dist/src/ProgressBar/ProgressBar.types.js +0 -1
- package/dist/src/ProgressBar/index.js +0 -1
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.js +0 -41
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.stories.js +0 -73
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.test.js +0 -72
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.types.js +0 -1
- package/dist/src/SeeqActionDropdown/index.js +0 -1
- package/dist/src/SeeqActionDropdown/variants.js +0 -34
- package/dist/src/Select/Select.js +0 -171
- package/dist/src/Select/Select.stories.js +0 -50
- package/dist/src/Select/Select.test.js +0 -176
- package/dist/src/Select/Select.types.js +0 -1
- package/dist/src/Select/index.js +0 -2
- package/dist/src/Slider/Slider.js +0 -11
- package/dist/src/Slider/Slider.stories.js +0 -37
- package/dist/src/Slider/Slider.test.js +0 -31
- package/dist/src/Slider/Slider.types.js +0 -1
- package/dist/src/Slider/index.js +0 -1
- package/dist/src/SvgIcon/SvgIcon.js +0 -27
- package/dist/src/SvgIcon/SvgIcon.stories.js +0 -26
- package/dist/src/SvgIcon/SvgIcon.test.js +0 -40
- package/dist/src/SvgIcon/SvgIcon.types.js +0 -2
- package/dist/src/SvgIcon/index.js +0 -1
- package/dist/src/Tabs/Tabs.js +0 -18
- package/dist/src/Tabs/Tabs.stories.js +0 -83
- package/dist/src/Tabs/Tabs.test.js +0 -91
- package/dist/src/Tabs/Tabs.types.js +0 -1
- package/dist/src/Tabs/index.js +0 -1
- package/dist/src/TextArea/TextArea.js +0 -54
- package/dist/src/TextArea/TextArea.stories.js +0 -21
- package/dist/src/TextArea/TextArea.test.js +0 -129
- package/dist/src/TextArea/TextArea.types.js +0 -1
- package/dist/src/TextArea/index.js +0 -1
- package/dist/src/TextField/TextField.js +0 -85
- package/dist/src/TextField/TextField.stories.js +0 -30
- package/dist/src/TextField/TextField.test.js +0 -40
- package/dist/src/TextField/TextField.types.js +0 -1
- package/dist/src/TextField/index.js +0 -1
- package/dist/src/ToolbarButton/ToolbarButton.js +0 -58
- package/dist/src/ToolbarButton/ToolbarButton.stories.js +0 -63
- package/dist/src/ToolbarButton/ToolbarButton.test.js +0 -89
- package/dist/src/ToolbarButton/ToolbarButton.types.js +0 -1
- package/dist/src/ToolbarButton/index.js +0 -1
- package/dist/src/Tooltip/QTip.stories.js +0 -22
- package/dist/src/Tooltip/QTip.types.js +0 -1
- package/dist/src/Tooltip/QTipPerformance.stories.js +0 -27
- package/dist/src/Tooltip/Qtip.js +0 -168
- package/dist/src/Tooltip/Tooltip.js +0 -34
- package/dist/src/Tooltip/Tooltip.stories.js +0 -20
- package/dist/src/Tooltip/Tooltip.types.js +0 -2
- package/dist/src/Tooltip/TooltipPerformance.stories.js +0 -25
- package/dist/src/Tooltip/index.js +0 -2
- package/dist/src/Tooltip/qTip.utilities.js +0 -10
- package/dist/src/index.js +0 -47
- package/dist/src/setupTests.js +0 -5
- package/dist/src/types.js +0 -25
- package/dist/src/utils/browserId.js +0 -28
- package/dist/src/utils/svg.js +0 -19
- package/dist/src/utils/validateStyleDimension.js +0 -13
- package/dist/src/utils/validateStyleDimension.test.js +0 -19
package/dist/src/Modal/Modal.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import '../styles.css';
|
|
6
|
-
import Button from '../Button';
|
|
7
|
-
import Icon from '../Icon';
|
|
8
|
-
import TextField from '../TextField';
|
|
9
|
-
const Dialog = DialogPrimitive.Root;
|
|
10
|
-
const DialogPortal = DialogPrimitive.Portal;
|
|
11
|
-
const DialogClose = DialogPrimitive.Close;
|
|
12
|
-
const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(DialogPortal, { children: [
|
|
13
|
-
_jsx("div", { className: "tw-select-none tw-fixed tw-w-full tw-h-full tw-opacity-50 tw-inset-0 tw-z-[1009] tw-bg-sq-dark-background\n data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0\n data-[state=open]:fade-in-0 " }), _jsxs(DialogPrimitive.Content, { ref: ref, className: `tw-fixed tw-left-[50%] tw-top-0 tw-my-6 tw-translate-x-[-50%] tw-z-[1010] tw-grid
|
|
14
|
-
tw-gap-4 tw-border tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-6 tw-shadow-lg tw-duration-200
|
|
15
|
-
tw-rounded-lg ${className}`, ...props, children: [
|
|
16
|
-
_jsx(DialogPrimitive.DialogTitle, { className: "tw-hidden" }), children] })
|
|
17
|
-
] })));
|
|
18
|
-
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
19
|
-
const DialogHeader = (props) => (_jsx("div", { className: "tw-w-full tw-justify-between", children: _jsx("div", { ...props }) }));
|
|
20
|
-
DialogHeader.displayName = 'DialogHeader';
|
|
21
|
-
const DialogFooter = (props) => _jsx("div", { ...props });
|
|
22
|
-
DialogFooter.displayName = 'DialogFooter';
|
|
23
|
-
const DialogTitle = React.forwardRef((props, ref) => _jsx(DialogPrimitive.Title, { ref: ref, ...props }));
|
|
24
|
-
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
25
|
-
const DialogDescription = React.forwardRef((props, ref) => _jsx(DialogPrimitive.Description, { ref: ref, ...props }));
|
|
26
|
-
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
27
|
-
const Modal = ({ titleIcon, title = 'Modal title example', titleSuffixLabel, subtitle, children, open = false, onClose, customButton = false, customButtonLabel = 'Back', onClickCustomButton, submitButtonLabel = 'Submit', cancelButtonLabel = 'Cancel', disableSubmitButton = false, stopPropagationSubmitButton = false, onSubmit, isTitleEditable = false, onTitleChanged, inputExtraClassNames, hideCloseIcon = false, size = 'xl', titleIconPosition = 'left', hideFooterButtons = false, hideSubmitButton = false, hideCancelButton = false, testId = 'modal', modalFooter, dialogClassName, titlePlaceholder, titleRequired, titleError, submitButtonTooltip, cancelButtonTooltip, disableCustomButton, customHeader, middleFooterSection = _jsx(_Fragment, {}), customButtonVariant = 'outline', submitButtonVariant = 'theme', keepFocusInsideModal = true, onPointerDownOutside, onInteractOutside, }) => {
|
|
28
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
29
|
-
// the Dialog is adding pointerEvents: none to body and the dropdowns from the modal does not work anymore
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (open) {
|
|
32
|
-
// Pushing the change to the end of the call stack
|
|
33
|
-
const timer = setTimeout(() => {
|
|
34
|
-
document.body.style.pointerEvents = '';
|
|
35
|
-
}, 0);
|
|
36
|
-
return () => clearTimeout(timer);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
document.body.style.pointerEvents = 'auto';
|
|
40
|
-
}
|
|
41
|
-
}, [open]);
|
|
42
|
-
const handleSubmit = async (e) => {
|
|
43
|
-
if (!onSubmit)
|
|
44
|
-
return;
|
|
45
|
-
try {
|
|
46
|
-
setIsLoading(true);
|
|
47
|
-
await onSubmit(e);
|
|
48
|
-
}
|
|
49
|
-
finally {
|
|
50
|
-
setIsLoading(false);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const renderTitle = () => {
|
|
54
|
-
let titleIconElement = _jsx(_Fragment, {});
|
|
55
|
-
if (titleIcon) {
|
|
56
|
-
if (typeof titleIcon === 'string') {
|
|
57
|
-
titleIconElement = (_jsx(Icon, { icon: titleIcon, testId: "modalTitleIcon", extraClassNames: "tw-flex tw-text-xl tw-mt-1" }));
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
titleIconElement = _jsx("div", { className: "tw-mt-1.5", children: titleIcon });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return (_jsxs(_Fragment, { children: [titleIcon && titleIconPosition === 'left' ? _jsx("div", { className: "tw-flex tw-mr-2", children: titleIconElement }) : _jsx(_Fragment, {}), _jsx(DialogTitle, { asChild: true, children: isTitleEditable ? (_jsxs("div", { className: "tw-flex tw-w-full tw-items-center", children: [
|
|
64
|
-
_jsx(TextField, { extraClassNames: inputExtraClassNames, value: title, type: "text", testId: "modalTitle", onChange: onTitleChanged, placeholder: titlePlaceholder, required: titleRequired, showError: !!titleError }), titleError && _jsx("p", { className: "tw-text-sq-danger-color tw-min-w-fit tw-pl-2 tw-mb-0", children: titleError })] })) : (customHeader ?? (_jsxs("div", { "data-testid": "modalTitle", className: "modal-title", children: [
|
|
65
|
-
_jsxs("div", { className: "tw-flex tw-items-center", children: [
|
|
66
|
-
_jsx("h3", { children: title }), titleSuffixLabel && _jsx("span", { className: "tw-text-xl tw-pl-0.5", children: titleSuffixLabel })] }), subtitle && (_jsx("div", { className: "tw-italic tw-text-sm tw-text-left tw-mt-1", "data-testid": "modal-subtitle", children: subtitle }))] }))) }), titleIcon && titleIconPosition === 'right' ? _jsx("div", { className: "tw-flex tw-ml-4", children: titleIconElement }) : _jsx(_Fragment, {})] }));
|
|
67
|
-
};
|
|
68
|
-
return open ? (_jsx(Dialog, { open: true, onOpenChange: onClose, modal: keepFocusInsideModal, children: _jsxs(DialogContent, { onPointerDownOutside: (e) => (onPointerDownOutside ? onPointerDownOutside(e) : e.preventDefault()), onInteractOutside: (e) => (onInteractOutside ? onInteractOutside(e) : e.preventDefault()), "data-testid": testId, className: classNames(`modalContent tw-w-full !tw-p-0 tw-border-none tw-shadow-none dark:tw-text-sq-dark-text !tw-gap-0`, {
|
|
69
|
-
'tw-max-w-xs': size === 'xs',
|
|
70
|
-
'tw-max-w-sm': size === 'sm',
|
|
71
|
-
'tw-max-w-md': size === 'md',
|
|
72
|
-
'tw-max-w-lg': size === 'lg',
|
|
73
|
-
'tw-max-w-xl': size === 'xl',
|
|
74
|
-
'tw-max-w-2xl': size === '2xl',
|
|
75
|
-
'tw-max-w-3xl': size === '3xl',
|
|
76
|
-
'tw-max-w-4xl': size === '4xl',
|
|
77
|
-
'tw-max-w-5xl': size === '5xl',
|
|
78
|
-
'tw-max-w-6xl': size === '6xl',
|
|
79
|
-
}, dialogClassName), children: [
|
|
80
|
-
_jsxs(DialogHeader, { className: "modal-header tw-flex tw-w-full tw-justify-between tw-border-sq-disabled-gray\n dark:tw-border-sq-dark-disabled-gray tw-border-0 tw-border-b tw-px-6 tw-py-4", children: [
|
|
81
|
-
_jsx("div", { className: "tw-flex tw-w-full", children: renderTitle() }), !hideCloseIcon && (_jsx(DialogClose, { autoFocus: false, className: "[&:has(:focus-visible)]:none tw-opacity-70 tw-bg-transparent hover:tw-opacity-100 close tw-text-base tw-cursor-pointer tw-ml-4", "data-testid": "closeButton", children: _jsx("span", { className: "tw-cursor-pointer", children: "\u00D7" }) }))] }), _jsx(DialogDescription, { className: "modal-body tw-px-6 tw-py-4 tw-overflow-y-auto", asChild: true, children: children }), !hideFooterButtons && (_jsx(DialogFooter, { className: "modal-footer tw-px-6 tw-py-4", children: modalFooter ?? (_jsxs("div", { className: "tw-flex tw-w-full tw-justify-between", "data-testid": "modalFooter", children: [
|
|
82
|
-
_jsx("div", { className: "tw-flex tw-justify-start", children: customButton && (_jsx(Button, { label: customButtonLabel, onClick: onClickCustomButton, disabled: disableCustomButton, extraClassNames: "tw-justify-start tw-min-w-[100px]", testId: "customButton", variant: customButtonVariant })) }), _jsxs("div", { className: "tw-flex tw-justify-end", children: [
|
|
83
|
-
_jsx("div", { className: "tw-flex tw-items-center", children: middleFooterSection }), !hideCancelButton && (_jsx(DialogClose, { asChild: true, children: _jsx(Button, { label: cancelButtonLabel, extraClassNames: "tw-mr-5 tw-min-w-[100px]", tooltip: cancelButtonTooltip, variant: "outline", stopPropagation: false, testId: "cancelButton" }) })), !hideSubmitButton && (_jsx(Button, { label: submitButtonLabel, onClick: handleSubmit, disabled: disableSubmitButton || isLoading, variant: submitButtonVariant, stopPropagation: stopPropagationSubmitButton, tooltip: submitButtonTooltip, icon: isLoading ? 'fc-loading-notch tw-animate-spin' : undefined, iconPosition: "left", testId: "submitButton", extraClassNames: "tw-min-w-[100px]" }))] })
|
|
84
|
-
] })) }))] }) })) : (_jsx(_Fragment, {}));
|
|
85
|
-
};
|
|
86
|
-
export default Modal;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import Modal from './Modal';
|
|
4
|
-
import Button from '../Button';
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Modal',
|
|
7
|
-
};
|
|
8
|
-
const modalBody = (_jsx("div", { children: "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." }));
|
|
9
|
-
const waitUntil = async (timeout) => {
|
|
10
|
-
return new Promise((resolve) => {
|
|
11
|
-
setTimeout(() => resolve('yes'), timeout);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
const ModalComponent = ({ bodyClass = '', title: originalTitle, titleIcon, isTitleEditable, children, hideCloseIcon, disableSubmitButton, size, buttonLabel = 'Open Modal', customButton, customButtonLabel, submitButtonVariant, onSubmit, }) => {
|
|
15
|
-
const [open, setOpen] = useState(false);
|
|
16
|
-
const [title, setTitle] = useState(originalTitle);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
return () => {
|
|
19
|
-
document.body.className = '';
|
|
20
|
-
};
|
|
21
|
-
}, []);
|
|
22
|
-
const onClose = () => {
|
|
23
|
-
document.body.className = '';
|
|
24
|
-
setOpen(false);
|
|
25
|
-
};
|
|
26
|
-
return (_jsxs("div", { className: "tw-p-4", children: [
|
|
27
|
-
_jsx(Button, { onClick: () => {
|
|
28
|
-
document.body.className = bodyClass;
|
|
29
|
-
setOpen(true);
|
|
30
|
-
}, label: buttonLabel }), _jsx(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: children })
|
|
31
|
-
] }));
|
|
32
|
-
};
|
|
33
|
-
export const AllModalsVariants = () => {
|
|
34
|
-
const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
|
|
35
|
-
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
|
|
36
|
-
return (_jsx("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: colors.map((color) => (_jsxs("div", { children: [
|
|
37
|
-
_jsxs("b", { children: [color, " colors"] }), _jsx("div", { className: "tw-p-4 light", children: sizes.map((size) => (_jsx(ModalComponent, { bodyClass: `color_${color.toLowerCase()}`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` }, `${size}_${color}`))) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: sizes.map((size) => (_jsx(ModalComponent, { bodyClass: `color_${color.toLowerCase()} tw-dark color_${color.toLowerCase()}_dark`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` }, `${size}_${color}_dark`))) })
|
|
38
|
-
] }, color))) }));
|
|
39
|
-
};
|
|
40
|
-
export const ModalsWithDisabledSubmit = () => (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
41
|
-
_jsxs("div", { children: [
|
|
42
|
-
_jsx("b", { children: "Topic Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_topic", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
|
|
43
|
-
] }), _jsxs("div", { children: [
|
|
44
|
-
_jsx("b", { children: "Analysis Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_analysis", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
|
|
45
|
-
] }), _jsxs("div", { children: [
|
|
46
|
-
_jsx("b", { children: "Datalab Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_datalab", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
|
|
47
|
-
] }), _jsxs("div", { children: [
|
|
48
|
-
_jsx("b", { children: "Vantage Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_vantage", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
|
|
49
|
-
] })
|
|
50
|
-
] }));
|
|
51
|
-
export const ModalsWithEditableTitle = () => {
|
|
52
|
-
const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
|
|
53
|
-
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
|
|
54
|
-
return (_jsx("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: colors.map((color) => (_jsxs("div", { children: [
|
|
55
|
-
_jsxs("b", { children: [color, " colors"] }), _jsx("div", { className: "tw-p-4 light", children: sizes.map((size) => (_jsx(ModalComponent, { bodyClass: `color_${color.toLowerCase()}`, title: "Editable title example", isTitleEditable: true, titleIcon: "fc-check", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` }, `${size}_${color}`))) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: sizes.map((size) => (_jsx(ModalComponent, { 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` }, `${size}_${color}_dark`))) })
|
|
56
|
-
] }, color))) }));
|
|
57
|
-
};
|
|
58
|
-
export const ModalsWithCustomButton = () => (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
59
|
-
_jsxs("div", { children: [
|
|
60
|
-
_jsx("b", { children: "Topic Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
|
|
61
|
-
] }), _jsxs("div", { children: [
|
|
62
|
-
_jsx("b", { children: "Analysis Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
|
|
63
|
-
] }), _jsxs("div", { children: [
|
|
64
|
-
_jsx("b", { children: "Datalab Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
|
|
65
|
-
] }), _jsxs("div", { children: [
|
|
66
|
-
_jsx("b", { children: "Vantage Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
|
|
67
|
-
] })
|
|
68
|
-
] }));
|
|
69
|
-
export const ModalsWithVariantButton = () => (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
70
|
-
_jsxs("div", { children: [
|
|
71
|
-
_jsx("b", { children: "Topic Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme-light" }) })
|
|
72
|
-
] }), _jsxs("div", { children: [
|
|
73
|
-
_jsx("b", { children: "Analysis Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "warning" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "danger", customButtonLabel: "Back" }) })
|
|
74
|
-
] }), _jsxs("div", { children: [
|
|
75
|
-
_jsx("b", { children: "Datalab Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "outline" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "no-border", customButtonLabel: "Back" }) })
|
|
76
|
-
] }), _jsxs("div", { children: [
|
|
77
|
-
_jsx("b", { children: "Vantage Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "theme", customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, submitButtonVariant: "outline", customButton: true, customButtonLabel: "Back" }) })
|
|
78
|
-
] })
|
|
79
|
-
] }));
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
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: _jsx("div", { children: "Modal content" }),
|
|
13
|
-
open: true,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
let tc;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
tc = new Context();
|
|
19
|
-
});
|
|
20
|
-
const renderModal = (props) => render(_jsx(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 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/Modal/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Modal';
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createElement as _createElement } from "react";
|
|
3
|
-
import React, { useEffect, useRef } from 'react';
|
|
4
|
-
import * as Progress from '@radix-ui/react-progress';
|
|
5
|
-
import { getQTipData } from '../Tooltip/qTip.utilities';
|
|
6
|
-
import tinycolor from 'tinycolor2';
|
|
7
|
-
const baseLabelClasses = 'tw-left-1 tw-text-xs tw-text-sq-text-color dark:tw-text-sq-dark-text tw-items-center tw-h-[18px]';
|
|
8
|
-
const ProgressIndicator = (props) => {
|
|
9
|
-
const { value, color = undefined, testId, label, extraClasses = '', labelClasses = '', valuesLength, max, index, totalValue, ...tooltipProps } = props;
|
|
10
|
-
const tooltipData = getQTipData(tooltipProps);
|
|
11
|
-
const previousWidth = useRef(0);
|
|
12
|
-
const indicatorElementRef = useRef(null);
|
|
13
|
-
const [textColorClass, setTextColorClass] = React.useState('');
|
|
14
|
-
const [animatedWidth, setAnimatedWidth] = React.useState(previousWidth.current);
|
|
15
|
-
// Determine which corners to round based on position and total value
|
|
16
|
-
let roundedCorners = '';
|
|
17
|
-
if (totalValue >= max) {
|
|
18
|
-
// If progress is 100%, round both ends
|
|
19
|
-
if (index === 0 && valuesLength === 1) {
|
|
20
|
-
roundedCorners = 'tw-rounded-[15px]';
|
|
21
|
-
}
|
|
22
|
-
else if (index === 0) {
|
|
23
|
-
roundedCorners = 'tw-rounded-l-[15px]';
|
|
24
|
-
}
|
|
25
|
-
else if (index === valuesLength - 1) {
|
|
26
|
-
roundedCorners = 'tw-rounded-r-[15px]';
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
// Otherwise, only round the leftmost indicator
|
|
31
|
-
if (index === 0) {
|
|
32
|
-
roundedCorners = 'tw-rounded-l-[15px]';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const timeout = setTimeout(() => {
|
|
37
|
-
const newWidth = (Number(value) / Number(max)) * 100;
|
|
38
|
-
setAnimatedWidth(newWidth);
|
|
39
|
-
previousWidth.current = newWidth;
|
|
40
|
-
}, 100);
|
|
41
|
-
return () => clearTimeout(timeout);
|
|
42
|
-
}, [value]);
|
|
43
|
-
const bgColor = color || undefined;
|
|
44
|
-
const bgClass = color ? '' : 'tw-bg-sq-color-dark';
|
|
45
|
-
const computeTextClass = (elem) => {
|
|
46
|
-
const computedStyle = getComputedStyle(elem);
|
|
47
|
-
const backgroundColor = computedStyle.backgroundColor;
|
|
48
|
-
const textColorClass = tinycolor(backgroundColor).isDark()
|
|
49
|
-
? 'tw-text-sq-white dark:tw-text-sq-white'
|
|
50
|
-
: 'tw-text-sq-text-color dark:tw-text-sq-text-color';
|
|
51
|
-
setTextColorClass(textColorClass);
|
|
52
|
-
};
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (indicatorElementRef.current) {
|
|
55
|
-
computeTextClass(indicatorElementRef.current);
|
|
56
|
-
}
|
|
57
|
-
}, [!!indicatorElementRef.current]);
|
|
58
|
-
return (_createElement(Progress.Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-w-full tw-h-[18px] tw-duration-[660ms] tw-flex tw-justify-center tw-items-center ${valuesLength === 1 ? '' : 'tw-overflow-hidden'} ${roundedCorners} ${bgClass} ${extraClasses}`, ...tooltipData, "data-qtip-text": tooltipProps.tooltip ? tooltipProps.tooltip : `${value}%`, "data-testid": `progress-bar-indicator-${testId ? testId : value}`, key: `${index}-${value}`, ref: indicatorElementRef, style: {
|
|
59
|
-
// Background color will default to the theme color if undefined
|
|
60
|
-
backgroundColor: bgColor,
|
|
61
|
-
animation: 'width 660ms forwards',
|
|
62
|
-
width: `${animatedWidth}%`,
|
|
63
|
-
} }, label ? (_jsx("span", { className: `${baseLabelClasses} ${labelClasses} ${textColorClass} ${valuesLength === 1 ? 'tw-absolute tw-z-50' : ''}`, children: label })) : undefined));
|
|
64
|
-
};
|
|
65
|
-
const ProgressBar = ({ values = [], max = 100, containerExtraClasses = '', zeroValueLabel = 'No progress yet', }) => {
|
|
66
|
-
const totalValue = values.reduce((acc, { value }) => acc + value, 0);
|
|
67
|
-
return (_jsx(Progress.Root, { className: `tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[15px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray tw-flex tw-flex-1 ${containerExtraClasses}`, max: max, value: totalValue, children: totalValue > 0 ? (values.map((props, i) => {
|
|
68
|
-
return (_createElement(ProgressIndicator, { ...props, max: max, valuesLength: values.length, index: i, totalValue: totalValue, key: i }));
|
|
69
|
-
})) : (_jsx("div", { className: `${baseLabelClasses} tw-mx-auto tw-overflow-hidden`, children: zeroValueLabel })) }));
|
|
70
|
-
};
|
|
71
|
-
export default ProgressBar;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
import ProgressBar from './ProgressBar';
|
|
4
|
-
import { QTip } from '../Tooltip';
|
|
5
|
-
export default {
|
|
6
|
-
title: 'ProgressBar',
|
|
7
|
-
};
|
|
8
|
-
export const AllProgressBars = () => {
|
|
9
|
-
const [values, setValues] = React.useState([
|
|
10
|
-
{ value: 20, label: 'RGB' },
|
|
11
|
-
{ value: 15, color: 'brown', label: 'Brown' },
|
|
12
|
-
{ value: 40, color: '#435abc', label: 'Hex' },
|
|
13
|
-
]);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const timeout = setTimeout(() => {
|
|
16
|
-
setValues([
|
|
17
|
-
{ value: 40, label: 'RGB' },
|
|
18
|
-
{ value: 5, color: 'brown', label: 'Brown' },
|
|
19
|
-
{ value: 50, color: '#435abc', label: 'Hex' },
|
|
20
|
-
]);
|
|
21
|
-
}, 2000);
|
|
22
|
-
return () => clearTimeout(timeout);
|
|
23
|
-
});
|
|
24
|
-
const renderAllVariations = () => (_jsxs(_Fragment, { children: [
|
|
25
|
-
_jsxs("div", { className: "tw-p-4 light", children: [
|
|
26
|
-
_jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { max: 100, values: [{ value: 40 }] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { max: 100, values: [{ value: 10 }] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 0 }], max: 100 }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 70, tooltip: 'this is an indicator tooltip' }], max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [
|
|
27
|
-
{ value: 20, label: 'RGB' },
|
|
28
|
-
{ value: 15, color: 'brown', label: 'Brown' },
|
|
29
|
-
{ value: 40, color: '#435abc', label: 'Hex' },
|
|
30
|
-
], max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 5, label: 'A very long text' }], max: 100 }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: values, max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 0, label: 'zero label' }], max: 100 }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 0 }], zeroValueLabel: "default zero level label deliberately long to test overflow", max: 100 }) })
|
|
31
|
-
] }), _jsxs("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: [
|
|
32
|
-
_jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { max: 100, values: [{ value: 40 }] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { max: 100, values: [{ value: 10 }] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 0 }], max: 100 }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 70, tooltip: 'this is an indicator tooltip' }], max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [
|
|
33
|
-
{ value: 20, color: 'rgb(44,200,190)', label: 'RGB' },
|
|
34
|
-
{ value: 15, color: 'brown', label: 'Brown' },
|
|
35
|
-
{ value: 40, color: '#435abc', label: 'Hex' },
|
|
36
|
-
], max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: values, max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 0, label: 'zero label' }], max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(ProgressBar, { values: [{ value: 0 }], zeroValueLabel: "default zero level label is made deliberately long to test overflow", max: 100, containerExtraClasses: "tw-bg-sq-text-color" }) })
|
|
37
|
-
] })
|
|
38
|
-
] }));
|
|
39
|
-
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
40
|
-
_jsx(QTip, {}), _jsxs("div", { className: "color_topic", children: [
|
|
41
|
-
_jsx("b", { children: "Topic Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
42
|
-
_jsx("b", { children: "Analysis Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
43
|
-
_jsx("b", { children: "Datalab Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
44
|
-
_jsx("b", { children: "Vantage Colors" }), renderAllVariations()] })
|
|
45
|
-
] }));
|
|
46
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import ProgressBar from './ProgressBar';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
describe('ProgressBar', () => {
|
|
6
|
-
it('renders without crashing', () => {
|
|
7
|
-
render(_jsx(ProgressBar, { values: [{ value: 50 }] }));
|
|
8
|
-
const progressBar = screen.getByRole('progressbar');
|
|
9
|
-
expect(progressBar).toBeInTheDocument();
|
|
10
|
-
});
|
|
11
|
-
it('displays the correct progress value', () => {
|
|
12
|
-
render(_jsx(ProgressBar, { values: [{ value: 75 }] }));
|
|
13
|
-
const progressBarIndicator = screen.getByRole('progressbar').firstChild;
|
|
14
|
-
waitFor(() => {
|
|
15
|
-
expect(progressBarIndicator).toHaveStyle('transform: translateX(-25%)');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
it('applies the correct max value', () => {
|
|
19
|
-
render(_jsx(ProgressBar, { values: [{ value: 50 }], max: 200 }));
|
|
20
|
-
const progressBar = screen.getByRole('progressbar');
|
|
21
|
-
expect(progressBar).toHaveAttribute('data-max', '200');
|
|
22
|
-
});
|
|
23
|
-
it('displays the tooltip with the correct label', () => {
|
|
24
|
-
render(_jsx(ProgressBar, { values: [{ value: 50, tooltip: 'Progress' }] }));
|
|
25
|
-
userEvent.hover(screen.getByTestId('progress-bar-indicator-50'));
|
|
26
|
-
waitFor(() => {
|
|
27
|
-
expect(screen.getByText('Progress')).toBeInTheDocument();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it('displays the no progress level for zero value', () => {
|
|
31
|
-
render(_jsx(ProgressBar, { values: [{ value: 0, tooltip: '0%' }], zeroValueLabel: "No progress" }));
|
|
32
|
-
waitFor(() => {
|
|
33
|
-
expect(screen.getByText('No progress')).toBeInTheDocument();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
it('applies the multiple values of the Progress bar', () => {
|
|
37
|
-
render(_jsx(ProgressBar, { values: [{ value: 20 }, { value: 15 }, { value: 40 }], max: 200 }));
|
|
38
|
-
for (const val of [20, 15, 40]) {
|
|
39
|
-
expect(screen.getByTestId(`progress-bar-indicator-${val}`)).toBeInTheDocument();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './ProgressBar';
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
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-md',
|
|
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 _jsx(SeeqActionDropdownItem, { ...item });
|
|
18
|
-
case 'view-workbench':
|
|
19
|
-
return _jsx(ViewWorkbench, { ...item });
|
|
20
|
-
case 'insert-seeq-content':
|
|
21
|
-
return _jsx(InsertSeeqContent, { ...item });
|
|
22
|
-
default:
|
|
23
|
-
return _jsx(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 (_jsxs(DropdownMenu.Root, { defaultOpen: false, open: isOpen, onOpenChange: onOpenChange, modal: keepFocusInsideDropdown, children: [
|
|
29
|
-
_jsx(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, children: _jsx("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 || ''}`, children: trigger }) }), _jsx(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", children: _jsxs("div", { "data-testid": containerTestId, className: bgStyles +
|
|
30
|
-
' tw-relative tw-z-[1200] tw-min-w-6 tw-py-2 focus-visible:tw-outline-none tw-outline-none' +
|
|
31
|
-
' data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out' +
|
|
32
|
-
' 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 ' +
|
|
33
|
-
borderStyles, children: [hasArrow && (_jsx(DropdownMenu.Arrow, { asChild: true, children: _jsx("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]" }) })), seeqActionDropdownItems.map((item, index) => {
|
|
34
|
-
return (_jsxs("div", { children: [
|
|
35
|
-
_jsx(DropdownMenu.Item, { onSelect: (e) => {
|
|
36
|
-
item.action(e);
|
|
37
|
-
}, 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, children: renderItem(variant, item) }), item.divider && (_jsx(DropdownMenu.Separator, { "data-testid": `dropdown-divider-${index}`, className: "tw-h-[1px] tw-bg-sq-disabled-gray dark:tw-bg-gray-500 tw-my-[8px]" }))] }, item.display + index));
|
|
38
|
-
})] }) })
|
|
39
|
-
] }));
|
|
40
|
-
};
|
|
41
|
-
export default SeeqActionDropdown;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { QTip } from '../Tooltip/Qtip';
|
|
4
|
-
import Button from '../Button/Button';
|
|
5
|
-
import SeeqActionDropdown from './SeeqActionDropdown';
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Seeq Action Dropdown',
|
|
8
|
-
};
|
|
9
|
-
const options = [
|
|
10
|
-
{
|
|
11
|
-
display: 'New Workbook',
|
|
12
|
-
text: 'This is a workbook to show details about your data. You can make changes to your account',
|
|
13
|
-
icon: 'fc-analysis',
|
|
14
|
-
id: 'newWorkbook',
|
|
15
|
-
enabled: true,
|
|
16
|
-
iconExtraClassNames: 'workbenchDisplay',
|
|
17
|
-
action: () => { },
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
display: 'New Report Binder',
|
|
21
|
-
text: 'This is a data tab to show details about your data. You can make changes to your account',
|
|
22
|
-
icon: 'fc-report',
|
|
23
|
-
enabled: true,
|
|
24
|
-
action: () => { },
|
|
25
|
-
id: 'newReportBinder',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
display: 'New Datalab',
|
|
29
|
-
text: 'This is a data tab to show details about your data. You can make changes to your account',
|
|
30
|
-
icon: 'fc-seeq-datalab',
|
|
31
|
-
id: 'newDataLab',
|
|
32
|
-
enabled: false,
|
|
33
|
-
action: () => { },
|
|
34
|
-
divider: true,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
display: 'Folder',
|
|
38
|
-
icon: 'fc-folder',
|
|
39
|
-
action: () => { },
|
|
40
|
-
id: 'newFolder',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
display: 'SvgIcon',
|
|
44
|
-
icon: 'svgpath:M0 8.8153a8.8153 8.8153 90 1117.6306 0A8.8153 8.8153 90 110 8.8153zM9.9172 3.3057a1.1019 1.1019' +
|
|
45
|
-
' 90 10-2.2038 0 1.1019 1.1019 90 102.2038 0zM8.8153 14.3249c1.2155 0 2.2038-.9883 2.2038-2.2038 0-.5992-.2376-1.1398-.6233-1.5358L12.6031 5.5681c.1825-.4167-.0069-.9056-.4235-1.0881s-.9056.0069-1.0881.4235L8.8807 9.9172c-.0207 0-.0448 0-.0654 0-1.2155 0-2.2038.9883-2.2038 2.2038s.9883 2.2038 2.2038 2.2038zM6.0605 4.9586a1.1019 1.1019 90 10-2.2038 0 1.1019 1.1019 90 102.2038 0zM3.3057 9.9172a1.1019 1.1019 90 100-2.2038 1.1019 1.1019 90 100 2.2038zm12.121-1.1019a1.1019 1.1019 90 10-2.2038 0 1.1019 1.1019 90 102.2038 0z',
|
|
46
|
-
action: () => { },
|
|
47
|
-
id: 'svgIcon',
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
export const AllSeeqActionDropdownVariants = () => {
|
|
51
|
-
const [openDropdown, setOpenDropdown] = React.useState('');
|
|
52
|
-
const allSeeqActionDropdowns = (color, isDark) => (_jsxs("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '', children: [
|
|
53
|
-
_jsx("div", { className: "tw-p-5 ", children: _jsx(SeeqActionDropdown, { trigger: _jsx(Button, { label: "New", icon: "fa-plus", variant: "theme" }), "data-testid": "homeScreenNewButton", id: "seeqActionDropdownItem", align: "start", alignOffset: 0, placementOffset: 0, variant: "create-workbench", seeqActionDropdownItems: options }, "seeqActionDropdownItem") }), _jsxs("div", { className: "tw-p-5 ", children: [
|
|
54
|
-
_jsx("div", { className: "dark:tw-text-white tw-text-xs", children: "New workbench with arrow" }), _jsx(SeeqActionDropdown, { trigger: _jsx(Button, { label: "New", icon: "fa-plus", variant: "theme" }), "data-testid": "homeScreenNewButton", id: "seeqActionDropdownItem", align: "start", alignOffset: 0, hasArrow: true, variant: "create-workbench", placementOffset: 0, seeqActionDropdownItems: options }, "seeqActionDropdownItem")
|
|
55
|
-
] }), _jsxs("div", { className: "tw-p-5 ", children: [
|
|
56
|
-
_jsx("div", { className: "dark:tw-text-white tw-text-xs", children: "New workbench with center align" }), _jsx(SeeqActionDropdown, { trigger: _jsx(Button, { label: "New", icon: "fa-plus", variant: "theme" }), "data-testid": "homeScreenNewButton", id: "seeqActionDropdownItem", align: "center", alignOffset: 0, hasArrow: true, variant: "create-workbench", placementOffset: 0, seeqActionDropdownItems: options }, "seeqActionDropdownItem")
|
|
57
|
-
] }), _jsxs("div", { className: "tw-p-5 ", children: [
|
|
58
|
-
_jsx("div", { className: "dark:tw-text-white tw-text-xs", children: "New workbench with disabled button" }), _jsx(SeeqActionDropdown, { trigger: _jsx(Button, { label: "New", icon: "fa-plus", variant: "theme" }), "data-testid": "homeScreenNewButton", id: "seeqActionDropdownItem", align: "center", disabled: true, variant: "create-workbench", alignOffset: 0, hasArrow: true, placementOffset: 0, seeqActionDropdownItems: options }, "seeqActionDropdownItem")
|
|
59
|
-
] }), _jsxs("div", { className: "tw-p-5 ", children: [
|
|
60
|
-
_jsx("div", { className: "dark:tw-text-white tw-text-xs", children: "View workbench" }), _jsx(SeeqActionDropdown, { trigger: _jsx(Button, { label: "View", icon: "fa-plus", variant: "theme" }), "data-testid": "homeScreenNewButton", id: "seeqActionDropdownItem", align: "center", variant: "view-workbench", alignOffset: 0, placementOffset: 0, seeqActionDropdownItems: options }, "seeqActionDropdownItem")
|
|
61
|
-
] }), _jsxs("div", { className: "tw-p-5 ", children: [
|
|
62
|
-
_jsx("div", { className: "dark:tw-text-white tw-text-xs", children: "Insert seeq content" }), _jsx(SeeqActionDropdown, { trigger: _jsx(Button, { label: "Insert", icon: "fc-plus", variant: "theme" }), "data-testid": "homeScreenNewButton", id: "seeqActionDropdownItem", align: "center", variant: "insert-seeq-content", alignOffset: 0, placementOffset: 0, seeqActionDropdownItems: options }, "seeqActionDropdownItem")
|
|
63
|
-
] })
|
|
64
|
-
] }));
|
|
65
|
-
const renderAllVariations = (color) => (_jsxs("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4 tw-p-4", children: [allSeeqActionDropdowns(color), allSeeqActionDropdowns(color, true)] }));
|
|
66
|
-
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
67
|
-
_jsx(QTip, {}), _jsxs("div", { className: "color_topic", children: [
|
|
68
|
-
_jsx("b", { children: "Topic Colors" }), renderAllVariations('topic')] }), _jsxs("div", { className: "color_analysis", children: [
|
|
69
|
-
_jsx("b", { children: "Analysis Colors" }), renderAllVariations('analysis')] }), _jsxs("div", { className: "color_datalab", children: [
|
|
70
|
-
_jsx("b", { children: "Datalab Colors" }), renderAllVariations('datalab')] }), _jsxs("div", { className: "color_vantage", children: [
|
|
71
|
-
_jsx("b", { children: "Vantage Colors" }), renderAllVariations('vantage')] })
|
|
72
|
-
] }));
|
|
73
|
-
};
|