@seeqdev/qomponents 0.0.132 → 0.0.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -135
- 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 +33 -33
- package/dist/Alert/Alert.stories.js +51 -51
- package/dist/Alert/Alert.test.js +50 -50
- package/dist/Alert/Alert.types.d.ts +1 -0
- 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 +99 -99
- 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/ButtonGroup/ButtonGroup.js +32 -32
- package/dist/ButtonGroup/ButtonGroup.stories.js +384 -384
- package/dist/ButtonGroup/ButtonGroup.test.js +66 -66
- package/dist/ButtonGroup/ButtonGroup.types.d.ts +1 -0
- package/dist/ButtonGroup/ButtonGroup.types.js +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js +59 -59
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +142 -142
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -92
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.d.ts +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -1
- package/dist/ButtonWithDropdown/index.js +1 -1
- package/dist/ButtonWithPopover/ButtonWithPopover.js +61 -61
- 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/Carousel/Carousel.js +69 -66
- package/dist/Carousel/Carousel.js.map +1 -1
- package/dist/Carousel/Carousel.stories.js +114 -114
- package/dist/Carousel/Carousel.test.js +47 -47
- package/dist/Carousel/Carousel.types.d.ts +1 -0
- package/dist/Carousel/Carousel.types.js +1 -1
- package/dist/Carousel/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.d.ts +1 -0
- package/dist/Checkbox/Checkbox.types.js +1 -1
- package/dist/Checkbox/index.js +1 -1
- package/dist/Collapse/Collapse.js +14 -17
- package/dist/Collapse/Collapse.js.map +1 -1
- package/dist/Collapse/Collapse.stories.js +36 -36
- package/dist/Collapse/Collapse.test.js +18 -18
- package/dist/Collapse/Collapse.types.d.ts +1 -0
- package/dist/Collapse/Collapse.types.js +1 -1
- package/dist/Collapse/index.js +1 -1
- package/dist/Icon/Icon.js +54 -54
- package/dist/Icon/Icon.stories.js +46 -46
- package/dist/Icon/Icon.test.js +54 -54
- package/dist/Icon/Icon.types.d.ts +1 -0
- package/dist/Icon/Icon.types.js +15 -15
- package/dist/Icon/index.js +1 -1
- package/dist/InputGroup/InputGroup.js +31 -31
- package/dist/InputGroup/InputGroup.stories.js +167 -167
- package/dist/InputGroup/InputGroup.test.js +42 -42
- package/dist/InputGroup/InputGroup.types.d.ts +1 -0
- package/dist/InputGroup/InputGroup.types.js +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/Modal/Modal.js +99 -99
- package/dist/Modal/Modal.js.map +1 -1
- 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/ProgressBar/ProgressBar.js +49 -29
- package/dist/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.stories.js +80 -72
- package/dist/ProgressBar/ProgressBar.stories.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.test.js +43 -37
- package/dist/ProgressBar/ProgressBar.test.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.types.d.ts +2 -0
- package/dist/ProgressBar/ProgressBar.types.js +1 -1
- package/dist/ProgressBar/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.d.ts +1 -0
- 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/Slider/Slider.js +12 -12
- package/dist/Slider/Slider.stories.js +57 -57
- package/dist/Slider/Slider.test.js +32 -32
- package/dist/Slider/Slider.types.d.ts +1 -0
- package/dist/Slider/Slider.types.js +1 -1
- package/dist/Slider/index.js +1 -1
- 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.d.ts +1 -0
- 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.d.ts +1 -0
- 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.d.ts +1 -0
- 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 +167 -167
- package/dist/Tooltip/Tooltip.js +35 -35
- package/dist/Tooltip/Tooltip.stories.js +31 -31
- package/dist/Tooltip/Tooltip.types.d.ts +1 -0
- 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/example/.eslintrc.cjs +14 -14
- package/dist/example/README.md +33 -33
- package/dist/example/index.html +13 -13
- package/dist/example/package.json +30 -30
- package/dist/example/src/ComplexSelectExample.tsx +81 -81
- package/dist/example/src/Example.tsx +408 -408
- package/dist/example/src/index.css +102 -102
- package/dist/example/src/main.tsx +10 -10
- package/dist/example/src/vite-env.d.ts +1 -1
- package/dist/example/tsconfig.json +33 -33
- package/dist/example/tsconfig.node.json +12 -12
- package/dist/example/vite.config.ts +12 -12
- package/dist/index.esm.js +15266 -7869
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15230 -7833
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3714 -3709
- 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 +89 -86
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
|
-
import Icon from '../Icon';
|
|
4
|
-
import { DEFAULT_TOOL_TIP_DELAY } from '../Tooltip/Tooltip.types';
|
|
5
|
-
import { getSvgIconPath } from '../utils/svg';
|
|
6
|
-
const borderStyles = [
|
|
7
|
-
'tw-border-solid',
|
|
8
|
-
'tw-border',
|
|
9
|
-
'tw-rounded-sm',
|
|
10
|
-
'tw-border-sq-disabled-gray',
|
|
11
|
-
'dark:tw-border-gray-500',
|
|
12
|
-
].join(' ');
|
|
13
|
-
const triggerBorderStyles = [
|
|
14
|
-
'tw-border-solid',
|
|
15
|
-
'tw-border',
|
|
16
|
-
'tw-rounded-sm',
|
|
17
|
-
'tw-border-transparent',
|
|
18
|
-
'hover:tw-border-solid',
|
|
19
|
-
'hover:tw-border',
|
|
20
|
-
'hover:tw-rounded-sm',
|
|
21
|
-
'hover:tw-border-sq-darkish-gray',
|
|
22
|
-
'active:tw-border-sq-color-dark',
|
|
23
|
-
'dark:hover:tw-border-sq-color-dark-dark',
|
|
24
|
-
'dark:focus:tw-border-sq-color-dark-dark',
|
|
25
|
-
'dark:active:tw-border-sq-color-dark-dark',
|
|
26
|
-
].join(' ');
|
|
27
|
-
const activeBorderStyles = [
|
|
28
|
-
'active',
|
|
29
|
-
'tw-border-solid',
|
|
30
|
-
'tw-border',
|
|
31
|
-
'tw-rounded-sm',
|
|
32
|
-
'tw-border-sq-color-dark',
|
|
33
|
-
'active:tw-border-sq-color-dark',
|
|
34
|
-
'dark:hover:tw-border-sq-color-dark-dark',
|
|
35
|
-
].join(' ');
|
|
36
|
-
const bgStyles = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
|
|
37
|
-
const disabledClasses = ['tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
|
|
38
|
-
const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (React.createElement(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, ...props, asChild: true })));
|
|
39
|
-
export const ToolbarButton = ({ isSmall = false, label, icon, secondIcon, forceSmallIcon = false, tooltipText, id, popoverContent, extraClassNames, testId, tooltipTestId, tooltipOptions, isActive = false, isHtmlTooltip = false, hasArrow = false, disabled = false, isPrimaryAnSvg = false, primaryIconExtraClassNames = false, iconHeight = 24, iconWidth = 24, primaryIconViewbox = '0 0 24 24', onClick, onHide, }) => {
|
|
40
|
-
let tooltipData = undefined;
|
|
41
|
-
if (tooltipText) {
|
|
42
|
-
tooltipData = {
|
|
43
|
-
'data-qtip-text': tooltipText,
|
|
44
|
-
'data-qtip-placement': tooltipOptions?.position,
|
|
45
|
-
'data-qtip-is-html': isHtmlTooltip,
|
|
46
|
-
'data-qtip-testid': tooltipTestId,
|
|
47
|
-
'data-qtip-delay': tooltipOptions?.delay ?? DEFAULT_TOOL_TIP_DELAY,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const onOpenChange = (open) => {
|
|
51
|
-
if (!open) {
|
|
52
|
-
onHide && onHide();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return (React.createElement(PopoverPrimitive.Root, { defaultOpen: false, onOpenChange: onOpenChange },
|
|
56
|
-
React.createElement(PopoverPrimitive.Trigger, { id: id, className: `tw-border-none ${isActive ? 'active' : ''}`, disabled: disabled, "data-testid": testId, onClick: (e) => {
|
|
57
|
-
onClick && onClick(e);
|
|
58
|
-
} },
|
|
59
|
-
React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-items-center ${isSmall ? 'tw-py-[1px] tw-px-[5px]' : 'tw-px-2 tw-py-[5px]'} ${disabled ? disabledClasses : isActive ? activeBorderStyles : triggerBorderStyles} ${extraClassNames || ''}` },
|
|
60
|
-
React.createElement("span", { className: "tw-nowrap" },
|
|
61
|
-
isPrimaryAnSvg ? (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", className: `tw-text-sq-text-color dark:tw-text-sq-dark-text ${primaryIconExtraClassNames || ''}`, viewBox: primaryIconViewbox, height: `${iconHeight}px`, width: `${iconWidth}px`, fill: "currentColor", "data-testid": testId },
|
|
62
|
-
React.createElement("path", { d: getSvgIconPath(icon) }))) : (React.createElement(Icon, { icon: icon, testId: "firstIcon", type: "text", large: !isSmall && !label && !secondIcon && !forceSmallIcon, extraClassNames: `tw-text-sq-text-color dark:tw-text-sq-dark-text` })),
|
|
63
|
-
secondIcon && React.createElement(Icon, { icon: secondIcon, type: "text", testId: "secondIcon" }),
|
|
64
|
-
popoverContent ? (React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-ml-[3px] tw-text-[8px]", type: "text" })) : undefined),
|
|
65
|
-
!isSmall && (React.createElement("small", { className: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-text-[10px]" }, label)))),
|
|
66
|
-
!!popoverContent ? (React.createElement(PopoverContent, { sideOffset: 2, align: "start" },
|
|
67
|
-
React.createElement("div", { className: bgStyles +
|
|
68
|
-
' tw-relative tw-z-[1000] tw-min-w-6 tw-p-[0.5rem] focus-visible:tw-outline-none tw-outline-none data-[state=open]:animate-in data-[state=closed]:animate-out' +
|
|
69
|
-
' data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2' +
|
|
70
|
-
borderStyles },
|
|
71
|
-
hasArrow && (React.createElement(PopoverPrimitive.Arrow, { asChild: true },
|
|
72
|
-
React.createElement("div", { className: " tw-fill-transparent tw-bg-white tw-w-[15px] tw-h-[15px] tw-mt-[-7px] 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" }))),
|
|
73
|
-
popoverContent))) : undefined));
|
|
74
|
-
};
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import { DEFAULT_TOOL_TIP_DELAY } from '../Tooltip/Tooltip.types';
|
|
5
|
+
import { getSvgIconPath } from '../utils/svg';
|
|
6
|
+
const borderStyles = [
|
|
7
|
+
'tw-border-solid',
|
|
8
|
+
'tw-border',
|
|
9
|
+
'tw-rounded-sm',
|
|
10
|
+
'tw-border-sq-disabled-gray',
|
|
11
|
+
'dark:tw-border-gray-500',
|
|
12
|
+
].join(' ');
|
|
13
|
+
const triggerBorderStyles = [
|
|
14
|
+
'tw-border-solid',
|
|
15
|
+
'tw-border',
|
|
16
|
+
'tw-rounded-sm',
|
|
17
|
+
'tw-border-transparent',
|
|
18
|
+
'hover:tw-border-solid',
|
|
19
|
+
'hover:tw-border',
|
|
20
|
+
'hover:tw-rounded-sm',
|
|
21
|
+
'hover:tw-border-sq-darkish-gray',
|
|
22
|
+
'active:tw-border-sq-color-dark',
|
|
23
|
+
'dark:hover:tw-border-sq-color-dark-dark',
|
|
24
|
+
'dark:focus:tw-border-sq-color-dark-dark',
|
|
25
|
+
'dark:active:tw-border-sq-color-dark-dark',
|
|
26
|
+
].join(' ');
|
|
27
|
+
const activeBorderStyles = [
|
|
28
|
+
'active',
|
|
29
|
+
'tw-border-solid',
|
|
30
|
+
'tw-border',
|
|
31
|
+
'tw-rounded-sm',
|
|
32
|
+
'tw-border-sq-color-dark',
|
|
33
|
+
'active:tw-border-sq-color-dark',
|
|
34
|
+
'dark:hover:tw-border-sq-color-dark-dark',
|
|
35
|
+
].join(' ');
|
|
36
|
+
const bgStyles = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
|
|
37
|
+
const disabledClasses = ['tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
|
|
38
|
+
const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (React.createElement(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, ...props, asChild: true })));
|
|
39
|
+
export const ToolbarButton = ({ isSmall = false, label, icon, secondIcon, forceSmallIcon = false, tooltipText, id, popoverContent, extraClassNames, testId, tooltipTestId, tooltipOptions, isActive = false, isHtmlTooltip = false, hasArrow = false, disabled = false, isPrimaryAnSvg = false, primaryIconExtraClassNames = false, iconHeight = 24, iconWidth = 24, primaryIconViewbox = '0 0 24 24', onClick, onHide, }) => {
|
|
40
|
+
let tooltipData = undefined;
|
|
41
|
+
if (tooltipText) {
|
|
42
|
+
tooltipData = {
|
|
43
|
+
'data-qtip-text': tooltipText,
|
|
44
|
+
'data-qtip-placement': tooltipOptions?.position,
|
|
45
|
+
'data-qtip-is-html': isHtmlTooltip,
|
|
46
|
+
'data-qtip-testid': tooltipTestId,
|
|
47
|
+
'data-qtip-delay': tooltipOptions?.delay ?? DEFAULT_TOOL_TIP_DELAY,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const onOpenChange = (open) => {
|
|
51
|
+
if (!open) {
|
|
52
|
+
onHide && onHide();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return (React.createElement(PopoverPrimitive.Root, { defaultOpen: false, onOpenChange: onOpenChange },
|
|
56
|
+
React.createElement(PopoverPrimitive.Trigger, { id: id, className: `tw-border-none ${isActive ? 'active' : ''}`, disabled: disabled, "data-testid": testId, onClick: (e) => {
|
|
57
|
+
onClick && onClick(e);
|
|
58
|
+
} },
|
|
59
|
+
React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-items-center ${isSmall ? 'tw-py-[1px] tw-px-[5px]' : 'tw-px-2 tw-py-[5px]'} ${disabled ? disabledClasses : isActive ? activeBorderStyles : triggerBorderStyles} ${extraClassNames || ''}` },
|
|
60
|
+
React.createElement("span", { className: "tw-nowrap" },
|
|
61
|
+
isPrimaryAnSvg ? (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", className: `tw-text-sq-text-color dark:tw-text-sq-dark-text ${primaryIconExtraClassNames || ''}`, viewBox: primaryIconViewbox, height: `${iconHeight}px`, width: `${iconWidth}px`, fill: "currentColor", "data-testid": testId },
|
|
62
|
+
React.createElement("path", { d: getSvgIconPath(icon) }))) : (React.createElement(Icon, { icon: icon, testId: "firstIcon", type: "text", large: !isSmall && !label && !secondIcon && !forceSmallIcon, extraClassNames: `tw-text-sq-text-color dark:tw-text-sq-dark-text` })),
|
|
63
|
+
secondIcon && React.createElement(Icon, { icon: secondIcon, type: "text", testId: "secondIcon" }),
|
|
64
|
+
popoverContent ? (React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-ml-[3px] tw-text-[8px]", type: "text" })) : undefined),
|
|
65
|
+
!isSmall && (React.createElement("small", { className: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-text-[10px]" }, label)))),
|
|
66
|
+
!!popoverContent ? (React.createElement(PopoverContent, { sideOffset: 2, align: "start" },
|
|
67
|
+
React.createElement("div", { className: bgStyles +
|
|
68
|
+
' tw-relative tw-z-[1000] tw-min-w-6 tw-p-[0.5rem] focus-visible:tw-outline-none tw-outline-none data-[state=open]:animate-in data-[state=closed]:animate-out' +
|
|
69
|
+
' data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2' +
|
|
70
|
+
borderStyles },
|
|
71
|
+
hasArrow && (React.createElement(PopoverPrimitive.Arrow, { asChild: true },
|
|
72
|
+
React.createElement("div", { className: " tw-fill-transparent tw-bg-white tw-w-[15px] tw-h-[15px] tw-mt-[-7px] 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" }))),
|
|
73
|
+
popoverContent))) : undefined));
|
|
74
|
+
};
|
|
75
75
|
//# sourceMappingURL=ToolbarButton.js.map
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ToolbarButton } from './ToolbarButton';
|
|
3
|
-
import Icon from '../Icon';
|
|
4
|
-
import { QTip } from '../Tooltip/Qtip';
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Toolbar Button',
|
|
7
|
-
};
|
|
8
|
-
export const AllToolbarButtonVariants = () => {
|
|
9
|
-
const options = [
|
|
10
|
-
{ value: 'a', label: 'Chocolate' },
|
|
11
|
-
{ value: 'b', label: 'Strawberry' },
|
|
12
|
-
{ value: 'c', label: 'Vanilla' },
|
|
13
|
-
{ value: 'd', label: 'Rocky Road' },
|
|
14
|
-
{ value: 'e', label: 'Crazy Cow' },
|
|
15
|
-
{ value: 'f', label: 'Almond Joy' },
|
|
16
|
-
{ value: 'g', label: 'All of the above' },
|
|
17
|
-
];
|
|
18
|
-
const colorOptions = [
|
|
19
|
-
{ value: 'h', label: 'pink' },
|
|
20
|
-
{ value: 'i', label: 'purple' },
|
|
21
|
-
{ value: 'j', label: 'green' },
|
|
22
|
-
{ value: 'k', label: 'red' },
|
|
23
|
-
];
|
|
24
|
-
const allToolbarButtons = (isDark) => (React.createElement("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '' },
|
|
25
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
26
|
-
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Popover", testId: "basic-popover1", tooltipText: "This is a small popover.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isSmall: true, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
27
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
28
|
-
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
29
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
30
|
-
React.createElement("span", null, option.label)))),
|
|
31
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
32
|
-
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
33
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
34
|
-
React.createElement("span", null, option.label))))) })),
|
|
35
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
36
|
-
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Normal", testId: "basic-popover1", tooltipText: "This is a normal popover.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
37
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
38
|
-
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
39
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
40
|
-
React.createElement("span", null, option.label)))),
|
|
41
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
42
|
-
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
43
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
44
|
-
React.createElement("span", null, option.label))))) })),
|
|
45
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
46
|
-
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "With arrow", testId: "basic-popover1", tooltipText: "This is a normal popover.", tooltipOptions: { position: 'top', delay: 0 }, hasArrow: true, isHtmlTooltip: false, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
47
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
48
|
-
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
49
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
50
|
-
React.createElement("span", null, option.label)))),
|
|
51
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
52
|
-
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
53
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
54
|
-
React.createElement("span", null, option.label))))) })),
|
|
55
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
56
|
-
React.createElement("p", { className: "tw-text-sq-color-dark tw-text-[10px]" }, "Without popup"),
|
|
57
|
-
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Button", testId: "basic-popover3", isHtmlTooltip: false })),
|
|
58
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
59
|
-
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Disabled", testId: "basic-popover2", tooltipText: "This is a popover.", tooltipOptions: { position: 'top' }, isHtmlTooltip: false, disabled: true, popoverContent: React.createElement("div", { className: "tw-border tw-border-gray-100 tw-p-2 tw-rounded-sm tw-text-sm dark:tw-bg-sq-dark-background" },
|
|
60
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
61
|
-
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
62
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
63
|
-
React.createElement("span", null, option.label)))),
|
|
64
|
-
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
65
|
-
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
66
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
67
|
-
React.createElement("span", null, option.label))))) })),
|
|
68
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
69
|
-
React.createElement(ToolbarButton, { id: "scatterPlotFlipXY", isActive: false, disabled: true, testId: "scatterPlotFlipXY", label: "", icon: "fc-grab-window", tooltipText: "This is a large disabled popover.", tooltipOptions: { position: 'top' }, extraClassNames: "no-border ml5" })),
|
|
70
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
71
|
-
React.createElement(ToolbarButton, { icon: "fc-y-axis", tooltipText: "This is a large popover icon", tooltipOptions: { position: 'top', delay: 0 }, testId: "basic-popover4", isHtmlTooltip: false })),
|
|
72
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
73
|
-
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Active", testId: "basic-popover5", tooltipText: "This is a button.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isActive: true })),
|
|
74
|
-
React.createElement("div", { className: "tw-p-5 " },
|
|
75
|
-
React.createElement(ToolbarButton, { isPrimaryAnSvg: true, iconHeight: 13, iconWidth: 13, icon: "svgpath:M 19 2.76 L 18.016 4.066 L 7.678 17.765 L 6.745 19 L 5.812 17.765 L 0.984 11.373 L 0 10.067 L 1.867 7.307 L 2.851 8.613 L 6.745 13.771 L 16.149 1.306 L 17.133 0 L 19 2.76 Z", label: "Active", testId: "basic-popover5", tooltipText: "This is a button.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isActive: true }))));
|
|
76
|
-
const renderAllVariations = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4 tw-p-4" },
|
|
77
|
-
allToolbarButtons(),
|
|
78
|
-
allToolbarButtons(true)));
|
|
79
|
-
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
80
|
-
React.createElement(QTip, null),
|
|
81
|
-
React.createElement("div", { className: "color_topic" },
|
|
82
|
-
React.createElement("b", null, "Topic Colors"),
|
|
83
|
-
renderAllVariations()),
|
|
84
|
-
React.createElement("div", { className: "color_analysis" },
|
|
85
|
-
React.createElement("b", null, "Analysis Colors"),
|
|
86
|
-
renderAllVariations()),
|
|
87
|
-
React.createElement("div", { className: "color_datalab" },
|
|
88
|
-
React.createElement("b", null, "Datalab Colors"),
|
|
89
|
-
renderAllVariations()),
|
|
90
|
-
React.createElement("div", { className: "color_vantage" },
|
|
91
|
-
React.createElement("b", null, "Vantage Colors"),
|
|
92
|
-
renderAllVariations())));
|
|
93
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarButton } from './ToolbarButton';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import { QTip } from '../Tooltip/Qtip';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Toolbar Button',
|
|
7
|
+
};
|
|
8
|
+
export const AllToolbarButtonVariants = () => {
|
|
9
|
+
const options = [
|
|
10
|
+
{ value: 'a', label: 'Chocolate' },
|
|
11
|
+
{ value: 'b', label: 'Strawberry' },
|
|
12
|
+
{ value: 'c', label: 'Vanilla' },
|
|
13
|
+
{ value: 'd', label: 'Rocky Road' },
|
|
14
|
+
{ value: 'e', label: 'Crazy Cow' },
|
|
15
|
+
{ value: 'f', label: 'Almond Joy' },
|
|
16
|
+
{ value: 'g', label: 'All of the above' },
|
|
17
|
+
];
|
|
18
|
+
const colorOptions = [
|
|
19
|
+
{ value: 'h', label: 'pink' },
|
|
20
|
+
{ value: 'i', label: 'purple' },
|
|
21
|
+
{ value: 'j', label: 'green' },
|
|
22
|
+
{ value: 'k', label: 'red' },
|
|
23
|
+
];
|
|
24
|
+
const allToolbarButtons = (isDark) => (React.createElement("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '' },
|
|
25
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
26
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Popover", testId: "basic-popover1", tooltipText: "This is a small popover.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isSmall: true, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
27
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
28
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
29
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
30
|
+
React.createElement("span", null, option.label)))),
|
|
31
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
32
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
33
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
34
|
+
React.createElement("span", null, option.label))))) })),
|
|
35
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
36
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Normal", testId: "basic-popover1", tooltipText: "This is a normal popover.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
37
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
38
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
39
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
40
|
+
React.createElement("span", null, option.label)))),
|
|
41
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
42
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
43
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
44
|
+
React.createElement("span", null, option.label))))) })),
|
|
45
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
46
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "With arrow", testId: "basic-popover1", tooltipText: "This is a normal popover.", tooltipOptions: { position: 'top', delay: 0 }, hasArrow: true, isHtmlTooltip: false, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
47
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
48
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
49
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
50
|
+
React.createElement("span", null, option.label)))),
|
|
51
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
52
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
53
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
54
|
+
React.createElement("span", null, option.label))))) })),
|
|
55
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
56
|
+
React.createElement("p", { className: "tw-text-sq-color-dark tw-text-[10px]" }, "Without popup"),
|
|
57
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Button", testId: "basic-popover3", isHtmlTooltip: false })),
|
|
58
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
59
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Disabled", testId: "basic-popover2", tooltipText: "This is a popover.", tooltipOptions: { position: 'top' }, isHtmlTooltip: false, disabled: true, popoverContent: React.createElement("div", { className: "tw-border tw-border-gray-100 tw-p-2 tw-rounded-sm tw-text-sm dark:tw-bg-sq-dark-background" },
|
|
60
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
|
|
61
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
62
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
63
|
+
React.createElement("span", null, option.label)))),
|
|
64
|
+
React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Colors"),
|
|
65
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
66
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
67
|
+
React.createElement("span", null, option.label))))) })),
|
|
68
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
69
|
+
React.createElement(ToolbarButton, { id: "scatterPlotFlipXY", isActive: false, disabled: true, testId: "scatterPlotFlipXY", label: "", icon: "fc-grab-window", tooltipText: "This is a large disabled popover.", tooltipOptions: { position: 'top' }, extraClassNames: "no-border ml5" })),
|
|
70
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
71
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", tooltipText: "This is a large popover icon", tooltipOptions: { position: 'top', delay: 0 }, testId: "basic-popover4", isHtmlTooltip: false })),
|
|
72
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
73
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Active", testId: "basic-popover5", tooltipText: "This is a button.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isActive: true })),
|
|
74
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
75
|
+
React.createElement(ToolbarButton, { isPrimaryAnSvg: true, iconHeight: 13, iconWidth: 13, icon: "svgpath:M 19 2.76 L 18.016 4.066 L 7.678 17.765 L 6.745 19 L 5.812 17.765 L 0.984 11.373 L 0 10.067 L 1.867 7.307 L 2.851 8.613 L 6.745 13.771 L 16.149 1.306 L 17.133 0 L 19 2.76 Z", label: "Active", testId: "basic-popover5", tooltipText: "This is a button.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isActive: true }))));
|
|
76
|
+
const renderAllVariations = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4 tw-p-4" },
|
|
77
|
+
allToolbarButtons(),
|
|
78
|
+
allToolbarButtons(true)));
|
|
79
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
80
|
+
React.createElement(QTip, null),
|
|
81
|
+
React.createElement("div", { className: "color_topic" },
|
|
82
|
+
React.createElement("b", null, "Topic Colors"),
|
|
83
|
+
renderAllVariations()),
|
|
84
|
+
React.createElement("div", { className: "color_analysis" },
|
|
85
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
86
|
+
renderAllVariations()),
|
|
87
|
+
React.createElement("div", { className: "color_datalab" },
|
|
88
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
89
|
+
renderAllVariations()),
|
|
90
|
+
React.createElement("div", { className: "color_vantage" },
|
|
91
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
92
|
+
renderAllVariations())));
|
|
93
|
+
};
|
|
94
94
|
//# sourceMappingURL=ToolbarButton.stories.js.map
|
|
@@ -1,93 +1,93 @@
|
|
|
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 { ToolbarButton } from './ToolbarButton';
|
|
6
|
-
import Icon from '../Icon';
|
|
7
|
-
describe('ToolbarButton', () => {
|
|
8
|
-
const options = [
|
|
9
|
-
{ value: 'a', label: 'Chocolate' },
|
|
10
|
-
{ value: 'b', label: 'Strawberry' },
|
|
11
|
-
{ value: 'c', label: 'Vanilla' },
|
|
12
|
-
{ value: 'd', label: 'Rocky Road' },
|
|
13
|
-
{ value: 'e', label: 'Crazy Cow' },
|
|
14
|
-
{ value: 'f', label: 'Almond Joy' },
|
|
15
|
-
{ value: 'g', label: 'All of the above' },
|
|
16
|
-
];
|
|
17
|
-
const colorOptions = [
|
|
18
|
-
{ value: 'h', label: 'pink' },
|
|
19
|
-
{ value: 'i', label: 'purple' },
|
|
20
|
-
{ value: 'j', label: 'green' },
|
|
21
|
-
{ value: 'k', label: 'red' },
|
|
22
|
-
];
|
|
23
|
-
const popoverContent = (React.createElement("div", { className: "tw-text-sm" },
|
|
24
|
-
React.createElement("p", { className: "tw-bg-gray-200 tw-p-2" }, "Flavors"),
|
|
25
|
-
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
26
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
27
|
-
React.createElement("span", null, option.label)))),
|
|
28
|
-
React.createElement("p", null, "Colors"),
|
|
29
|
-
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
30
|
-
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
31
|
-
React.createElement("span", null, option.label))))));
|
|
32
|
-
const mockOnClick = jest.fn();
|
|
33
|
-
class Context {
|
|
34
|
-
testId = 'popoverTestId';
|
|
35
|
-
label = 'popover label';
|
|
36
|
-
props = {
|
|
37
|
-
label: this.label,
|
|
38
|
-
onClick: mockOnClick,
|
|
39
|
-
testId: this.testId,
|
|
40
|
-
icon: 'fc-y-axis',
|
|
41
|
-
tooltipText: 'This is a popover.',
|
|
42
|
-
tooltipOptions: { position: 'top', delay: 0 },
|
|
43
|
-
isHtmlTooltip: false,
|
|
44
|
-
isSmall: false,
|
|
45
|
-
popoverContent,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
let tc;
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
tc = new Context();
|
|
51
|
-
jest.clearAllMocks();
|
|
52
|
-
});
|
|
53
|
-
const renderToolbarButton = (props) => render(React.createElement(ToolbarButton, { ...props }));
|
|
54
|
-
const openPopover = async () => {
|
|
55
|
-
const popover = screen.getByTestId(tc.testId);
|
|
56
|
-
await userEvent.click(popover);
|
|
57
|
-
};
|
|
58
|
-
it('renders popover icon without label when small', () => {
|
|
59
|
-
tc.props.isSmall = true;
|
|
60
|
-
renderToolbarButton(tc.props);
|
|
61
|
-
const popoverLabel = screen.queryByText(tc.label);
|
|
62
|
-
expect(popoverLabel).not.toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
it('renders popover trigger button', () => {
|
|
65
|
-
renderToolbarButton(tc.props);
|
|
66
|
-
expect(screen.getByText(tc.label)).toBeInTheDocument();
|
|
67
|
-
});
|
|
68
|
-
it('opens popover on click', async () => {
|
|
69
|
-
renderToolbarButton(tc.props);
|
|
70
|
-
await openPopover();
|
|
71
|
-
expect(screen.getByText(options[2].label)).toBeVisible();
|
|
72
|
-
});
|
|
73
|
-
it('renders disabled popover trigger', async () => {
|
|
74
|
-
renderToolbarButton({ ...tc.props, disabled: true });
|
|
75
|
-
await openPopover();
|
|
76
|
-
expect(mockOnClick).not.toHaveBeenCalled();
|
|
77
|
-
});
|
|
78
|
-
it('handles click events', async () => {
|
|
79
|
-
const handleClick = jest.fn();
|
|
80
|
-
tc.props.onClick = handleClick;
|
|
81
|
-
const { getByTestId } = renderToolbarButton(tc.props);
|
|
82
|
-
await userEvent.click(getByTestId(tc.testId));
|
|
83
|
-
expect(handleClick).toHaveBeenCalled();
|
|
84
|
-
});
|
|
85
|
-
it('handles click events within popover and does not close the popover', async () => {
|
|
86
|
-
renderToolbarButton(tc.props);
|
|
87
|
-
expect(screen.queryByText(options[4].label)).not.toBeInTheDocument();
|
|
88
|
-
await openPopover();
|
|
89
|
-
await userEvent.click(screen.getByText(options[3].label));
|
|
90
|
-
expect(screen.getByText(options[4].label)).toBeInTheDocument();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
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 { ToolbarButton } from './ToolbarButton';
|
|
6
|
+
import Icon from '../Icon';
|
|
7
|
+
describe('ToolbarButton', () => {
|
|
8
|
+
const options = [
|
|
9
|
+
{ value: 'a', label: 'Chocolate' },
|
|
10
|
+
{ value: 'b', label: 'Strawberry' },
|
|
11
|
+
{ value: 'c', label: 'Vanilla' },
|
|
12
|
+
{ value: 'd', label: 'Rocky Road' },
|
|
13
|
+
{ value: 'e', label: 'Crazy Cow' },
|
|
14
|
+
{ value: 'f', label: 'Almond Joy' },
|
|
15
|
+
{ value: 'g', label: 'All of the above' },
|
|
16
|
+
];
|
|
17
|
+
const colorOptions = [
|
|
18
|
+
{ value: 'h', label: 'pink' },
|
|
19
|
+
{ value: 'i', label: 'purple' },
|
|
20
|
+
{ value: 'j', label: 'green' },
|
|
21
|
+
{ value: 'k', label: 'red' },
|
|
22
|
+
];
|
|
23
|
+
const popoverContent = (React.createElement("div", { className: "tw-text-sm" },
|
|
24
|
+
React.createElement("p", { className: "tw-bg-gray-200 tw-p-2" }, "Flavors"),
|
|
25
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
26
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
27
|
+
React.createElement("span", null, option.label)))),
|
|
28
|
+
React.createElement("p", null, "Colors"),
|
|
29
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
30
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
31
|
+
React.createElement("span", null, option.label))))));
|
|
32
|
+
const mockOnClick = jest.fn();
|
|
33
|
+
class Context {
|
|
34
|
+
testId = 'popoverTestId';
|
|
35
|
+
label = 'popover label';
|
|
36
|
+
props = {
|
|
37
|
+
label: this.label,
|
|
38
|
+
onClick: mockOnClick,
|
|
39
|
+
testId: this.testId,
|
|
40
|
+
icon: 'fc-y-axis',
|
|
41
|
+
tooltipText: 'This is a popover.',
|
|
42
|
+
tooltipOptions: { position: 'top', delay: 0 },
|
|
43
|
+
isHtmlTooltip: false,
|
|
44
|
+
isSmall: false,
|
|
45
|
+
popoverContent,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
let tc;
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
tc = new Context();
|
|
51
|
+
jest.clearAllMocks();
|
|
52
|
+
});
|
|
53
|
+
const renderToolbarButton = (props) => render(React.createElement(ToolbarButton, { ...props }));
|
|
54
|
+
const openPopover = async () => {
|
|
55
|
+
const popover = screen.getByTestId(tc.testId);
|
|
56
|
+
await userEvent.click(popover);
|
|
57
|
+
};
|
|
58
|
+
it('renders popover icon without label when small', () => {
|
|
59
|
+
tc.props.isSmall = true;
|
|
60
|
+
renderToolbarButton(tc.props);
|
|
61
|
+
const popoverLabel = screen.queryByText(tc.label);
|
|
62
|
+
expect(popoverLabel).not.toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
it('renders popover trigger button', () => {
|
|
65
|
+
renderToolbarButton(tc.props);
|
|
66
|
+
expect(screen.getByText(tc.label)).toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
it('opens popover on click', async () => {
|
|
69
|
+
renderToolbarButton(tc.props);
|
|
70
|
+
await openPopover();
|
|
71
|
+
expect(screen.getByText(options[2].label)).toBeVisible();
|
|
72
|
+
});
|
|
73
|
+
it('renders disabled popover trigger', async () => {
|
|
74
|
+
renderToolbarButton({ ...tc.props, disabled: true });
|
|
75
|
+
await openPopover();
|
|
76
|
+
expect(mockOnClick).not.toHaveBeenCalled();
|
|
77
|
+
});
|
|
78
|
+
it('handles click events', async () => {
|
|
79
|
+
const handleClick = jest.fn();
|
|
80
|
+
tc.props.onClick = handleClick;
|
|
81
|
+
const { getByTestId } = renderToolbarButton(tc.props);
|
|
82
|
+
await userEvent.click(getByTestId(tc.testId));
|
|
83
|
+
expect(handleClick).toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
it('handles click events within popover and does not close the popover', async () => {
|
|
86
|
+
renderToolbarButton(tc.props);
|
|
87
|
+
expect(screen.queryByText(options[4].label)).not.toBeInTheDocument();
|
|
88
|
+
await openPopover();
|
|
89
|
+
await userEvent.click(screen.getByText(options[3].label));
|
|
90
|
+
expect(screen.getByText(options[4].label)).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
93
|
//# sourceMappingURL=ToolbarButton.test.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const toolbarButtonVariants = ['outline', 'theme', 'theme-light', 'warning', 'danger', 'no-border'];
|
|
1
|
+
export const toolbarButtonVariants = ['outline', 'theme', 'theme-light', 'warning', 'danger', 'no-border'];
|
|
2
2
|
//# sourceMappingURL=ToolbarButton.types.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ToolbarButton as default } from './ToolbarButton';
|
|
1
|
+
export { ToolbarButton as default } from './ToolbarButton';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|