@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seeqdev/qomponents",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.186",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -92,6 +92,6 @@
|
|
|
92
92
|
"lint:fix": "echo 'ESLint not configured yet'",
|
|
93
93
|
"format:check": "prettier --check \"**/*.{ts,tsx,js,json,css}\"",
|
|
94
94
|
"format:write": "prettier --write \"**/*.{ts,tsx,js,json,css}\"",
|
|
95
|
-
"type:check": "
|
|
95
|
+
"type:check": "tsgo --noEmit"
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Root, Item, Trigger, Content } from '@radix-ui/react-accordion';
|
|
3
|
-
const Accordion = ({ accordionItems, defaultValue, value, onItemSelect, disabled, extraClassNames, testId, }) => {
|
|
4
|
-
return (_jsx(Root, { className: `tw-rounded-md tw-w-full focus-visible:tw-outline-none ${extraClassNames || ''}`, type: "single", defaultValue: defaultValue, value: value, collapsible: true, "data-testid": testId, onValueChange: (_value) => onItemSelect(_value), children: accordionItems.map((item) => (_jsxs(Item, { className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-w-full`, disabled: disabled, value: item.value, children: [
|
|
5
|
-
_jsx(Trigger, { disabled: disabled, className: `tw-w-full tw-cursor-default focus-visible:tw-outline-none`, children: item.trigger }), _jsx(Content, { className: `data-[state=open]:tw-animate-slideDown data-[state=closed]:tw-animate-slideUp tw-overflow-hidden focus-visible:tw-outline-none ${item.contentClassNames || ''}`, children: item.content })
|
|
6
|
-
] }, item.value))) }));
|
|
7
|
-
};
|
|
8
|
-
export default Accordion;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Accordion from './Accordion';
|
|
4
|
-
import { QTip } from '../Tooltip/Qtip';
|
|
5
|
-
import Icon from '../Icon';
|
|
6
|
-
import Tabs from '../Tabs';
|
|
7
|
-
import Button from '../Button';
|
|
8
|
-
export default {
|
|
9
|
-
title: 'Accordion',
|
|
10
|
-
};
|
|
11
|
-
const Trigger = ({ label }) => (_jsxs("div", { className: "tw-flex tw-justify-start tw-items-center tw-border-b tw-px-2 tw-text-sq-color-dark", children: [
|
|
12
|
-
_jsx(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-color-dark tw-mr-[0.5rem] tw-text-[0.75rem]", type: "text" }), label] }));
|
|
13
|
-
const TriggerSecond = ({ label }) => (_jsxs("div", { className: "tw-flex tw-justify-between tw-items-center tw-border-b tw-px-2 tw-text-sq-color-dark tw-py-2", children: [label, _jsx(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-color-dark tw-mr-[0.5rem] tw-text-[0.75rem]", type: "text" })
|
|
14
|
-
] }));
|
|
15
|
-
const renderData = () => (_jsxs("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white", children: [
|
|
16
|
-
_jsx("p", { className: "tw-mb-5 tw-text-[0.9375rem] tw-leading-normal", children: "This is a data tab to show details about your data. You can make changes to your account" }), _jsx(Button, { variant: "outline", label: "Save data" })
|
|
17
|
-
] }));
|
|
18
|
-
const renderTools = () => (_jsxs("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white", children: [
|
|
19
|
-
_jsx("p", { className: "tw-mb-5 tw-text-[0.9375rem] tw-leading-normal", children: "Make changes to your account here. Click save when you're done." }), _jsx(Button, { variant: "outline", label: "Save tools" })
|
|
20
|
-
] }));
|
|
21
|
-
const renderJournal = () => (_jsxs("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white", children: [
|
|
22
|
-
_jsx("p", { className: "tw-mb-5 tw-text-[0.9375rem] tw-leading-normal", children: "Make changes to your account here. Click save when you're done." }), _jsx(Button, { variant: "outline", label: "Save journal" })
|
|
23
|
-
] }));
|
|
24
|
-
const tabsList = [
|
|
25
|
-
{
|
|
26
|
-
id: 'data',
|
|
27
|
-
label: 'Data',
|
|
28
|
-
icon: 'fc-data',
|
|
29
|
-
content: renderData(),
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 'tools',
|
|
33
|
-
label: 'Tools',
|
|
34
|
-
icon: 'fc-gears-2',
|
|
35
|
-
content: renderTools(),
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 'journal',
|
|
39
|
-
label: 'Journal',
|
|
40
|
-
icon: 'fc-workbook-lock',
|
|
41
|
-
content: renderJournal(),
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
export const AllAccordionVariants = () => {
|
|
45
|
-
const [activeTab, setActiveTab] = React.useState('data');
|
|
46
|
-
const [value, setValue] = React.useState('oranges');
|
|
47
|
-
const accordionItems = [
|
|
48
|
-
{
|
|
49
|
-
value: 'oranges',
|
|
50
|
-
id: 'oranges',
|
|
51
|
-
itemTestId: 'oranges',
|
|
52
|
-
trigger: _jsx(Trigger, { label: "Oranges" }),
|
|
53
|
-
content: (_jsx("div", { className: "tw-p-2 tw-text-[0.8125rem] dark:tw-text-sq-white", children: "Oranges are the fruit of the citrus species Citrus \u00D7 sinensis in the family Rutaceae. They are also called sweet oranges to distinguish them from the related Citrus \u00D7 aurantium, referred to as bitter oranges. They are round and orange, and usually have a sour or bitter taste. Oranges are a good source of vitamin C." })),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
value: 'apples',
|
|
57
|
-
id: 'apples',
|
|
58
|
-
itemTestId: 'apples',
|
|
59
|
-
trigger: _jsx(Trigger, { label: "Apples" }),
|
|
60
|
-
content: (_jsx("div", { children: _jsx("div", { className: "tw-p-4", children: _jsx(Tabs, { stretchTabs: true, activeTab: activeTab, onTabSelect: setActiveTab, defaultActiveTab: "data", tabs: tabsList }) }) })),
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
value: 'bananas',
|
|
64
|
-
id: 'bananas',
|
|
65
|
-
trigger: _jsx(Trigger, { label: "Bananas" }),
|
|
66
|
-
itemTestId: 'bananas',
|
|
67
|
-
content: (_jsx("div", { children: "A banana is an elongated, edible fruit \u2013 botanically a berry \u2013 produced by several kinds of large herbaceous flowering plants in the genus Musa. In some countries, bananas used for cooking may be called \"plantains\", distinguishing them from dessert bananas. The fruit is variable in size, color, and firmness, but is usually elongated and curved, with soft flesh rich in starch covered with a rind, which may be green, yellow, red, purple, or brown when ripe." })),
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
value: 'pineapples',
|
|
71
|
-
id: 'pineapples',
|
|
72
|
-
trigger: _jsx(Trigger, { label: "Pineapples" }),
|
|
73
|
-
itemTestId: 'pineapples',
|
|
74
|
-
content: (_jsx("div", { children: "The pineapple is a tropical plant with an edible fruit and the most economically significant plant in the family Bromeliaceae. The pineapple is indigenous to South America, where it has been cultivated for many centuries. The introduction of the pineapple to Europe in the 17th century made it a significant cultural icon of luxury. Since the 1820s, pineapple has been commercially grown in greenhouses and many tropical plantations." })),
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
const allAccordions = (isDark) => (_jsx("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '', children: _jsx("div", { className: "tw-p-5 ", children: _jsx(Accordion, { accordionItems: isDark
|
|
78
|
-
? accordionItems
|
|
79
|
-
: accordionItems.map((item) => ({ ...item, trigger: _jsx(TriggerSecond, { label: item.value.toUpperCase() }) })), value: value, testId: "basic-accordion1", onItemSelect: (value) => setValue(value) }) }) }));
|
|
80
|
-
const renderAllVariations = (isDark) => _jsx("div", { className: "tw-p-4", children: allAccordions(isDark) });
|
|
81
|
-
return (_jsxs(_Fragment, { children: [
|
|
82
|
-
_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
83
|
-
_jsx(QTip, {}), _jsxs("div", { className: "color_topic", children: [
|
|
84
|
-
_jsx("b", { children: "Topic Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
85
|
-
_jsx("b", { children: "Analysis Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
86
|
-
_jsx("b", { children: "Datalab Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
87
|
-
_jsx("b", { children: "Vantage Colors" }), renderAllVariations()] })
|
|
88
|
-
] }), _jsxs("div", { className: "tw-dark tw-bg-sq-dark-background tw-grid tw-grid-cols-4 tw-gap-4 tw-py-4", children: [
|
|
89
|
-
_jsxs("div", { className: "color_topic dark:tw-text-sq-white tw-text-center", children: [
|
|
90
|
-
_jsx("b", { children: "Topic Colors" }), renderAllVariations(true)] }), _jsxs("div", { className: "color_analysis dark:tw-text-sq-white tw-text-center", children: [
|
|
91
|
-
_jsx("b", { children: "Analysis Colors" }), renderAllVariations(true)] }), _jsxs("div", { className: "color_datalab dark:tw-text-sq-white tw-text-center", children: [
|
|
92
|
-
_jsx("b", { children: "Datalab Colors" }), renderAllVariations(true)] }), _jsxs("div", { className: "color_vantage dark:tw-text-sq-white tw-text-center", children: [
|
|
93
|
-
_jsx("b", { children: "Vantage Colors" }), renderAllVariations(true)] })
|
|
94
|
-
] })
|
|
95
|
-
] }));
|
|
96
|
-
};
|
|
@@ -1,54 +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 Accordion from './Accordion';
|
|
6
|
-
describe('Accordion', () => {
|
|
7
|
-
const mockOnItemSelect = jest.fn();
|
|
8
|
-
class Context {
|
|
9
|
-
testId = 'buttonTestId';
|
|
10
|
-
label = 'button label';
|
|
11
|
-
props = {
|
|
12
|
-
accordionItems: [
|
|
13
|
-
{
|
|
14
|
-
id: 'item1',
|
|
15
|
-
value: 'item1',
|
|
16
|
-
trigger: 'Item 1',
|
|
17
|
-
content: 'Content 1',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
id: 'item2',
|
|
21
|
-
value: 'item2',
|
|
22
|
-
trigger: 'Item 2',
|
|
23
|
-
content: 'Content 2',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
defaultValue: 'item1',
|
|
27
|
-
value: 'item1',
|
|
28
|
-
onItemSelect: (key) => mockOnItemSelect(key),
|
|
29
|
-
disabled: false,
|
|
30
|
-
extraClassNames: 'extra-class',
|
|
31
|
-
testId: this.testId,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
let tc;
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
tc = new Context();
|
|
37
|
-
});
|
|
38
|
-
const renderAccordion = (props) => render(_jsx(Accordion, { ...props }));
|
|
39
|
-
it('renders accordion items', () => {
|
|
40
|
-
renderAccordion(tc.props);
|
|
41
|
-
expect(screen.getByText('Item 1')).toBeInTheDocument();
|
|
42
|
-
expect(screen.getByText('Item 2')).toBeInTheDocument();
|
|
43
|
-
});
|
|
44
|
-
it('renders accordion content', () => {
|
|
45
|
-
renderAccordion(tc.props);
|
|
46
|
-
expect(screen.getByText('Content 1')).toBeInTheDocument();
|
|
47
|
-
expect(screen.queryByText('Content 2')).not.toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
it('calls onItemSelect when an item is selected', async () => {
|
|
50
|
-
renderAccordion(tc.props);
|
|
51
|
-
await userEvent.click(screen.getByText('Item 2'));
|
|
52
|
-
expect(mockOnItemSelect).toHaveBeenCalledWith('item2');
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Accordion';
|
package/dist/src/Alert/Alert.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import '../styles.css';
|
|
3
|
-
import Icon from '../Icon';
|
|
4
|
-
const baseClasses = 'tw-mx-auto tw-p-4 tw-leading-normal tw-outline-none tw-py-2 tw-px-3 tw-rounded-[10px] tw-w-full tw-relative' +
|
|
5
|
-
' tw-border-solid tw-border tw-text-sm tw-flex tw-flex-col tw-justify-center tw-items-center';
|
|
6
|
-
const darkTheme = 'dark:tw-bg-sq-colored-hover-dark dark:tw-text-sq-dark-text';
|
|
7
|
-
const lightTheme = 'tw-text-sq-text-color tw-bg-sq-colored-hover';
|
|
8
|
-
const errorClasses = 'tw-border-sq-danger-color';
|
|
9
|
-
const borderColorClasses = 'tw-border-sq-color-dark';
|
|
10
|
-
/**
|
|
11
|
-
* Alert.
|
|
12
|
-
*/
|
|
13
|
-
export const Alert = ({ children, dismissible = true, onClose, show = true, variant, testId = 'alert-id', id, extraClassNames, ...tooltipProps }) => {
|
|
14
|
-
const appliedTheme = {
|
|
15
|
-
theme: `${lightTheme} ${darkTheme}`,
|
|
16
|
-
formulaError: 'tw-text-red-800 tw-bg-red-200 !tw-rounded-[4px]',
|
|
17
|
-
danger: 'tw-text-sq-text-color tw-bg-sq-danger-color',
|
|
18
|
-
warning: 'tw-bg-sq-bg-warning-color tw-text-sq-text-color',
|
|
19
|
-
gray: 'tw-bg-sq-light-gray tw-text-sq-text-color dark:tw-bg-sq-worksheetspanel-gray-dark dark:tw-text-sq-dark-text',
|
|
20
|
-
};
|
|
21
|
-
const appliedBorderTheme = {
|
|
22
|
-
theme: borderColorClasses,
|
|
23
|
-
danger: errorClasses,
|
|
24
|
-
warning: 'tw-border-none',
|
|
25
|
-
gray: 'tw-border-sq-darkish-gray',
|
|
26
|
-
formulaError: 'tw-border-red-100',
|
|
27
|
-
};
|
|
28
|
-
const appliedClasses = `${baseClasses} ${appliedTheme[variant]} ${extraClassNames} ${appliedBorderTheme[variant]}`;
|
|
29
|
-
if (!show) {
|
|
30
|
-
return _jsx("div", {});
|
|
31
|
-
}
|
|
32
|
-
return (_jsxs("div", { "data-testid": testId, id: id, className: appliedClasses, children: [children, dismissible && (_jsx(Icon, { icon: "fc-delete", type: variant.match(/danger|warning|formulaError/) ? 'color' : 'theme', color: variant.match(/danger|warning|formulaError/) ? 'inherit' : undefined, extraClassNames: `tw-self-end tw-text-[0.6875rem] tw-cursor-pointer tw-absolute tw-right-[10px] tw-top-[10px] ${variant.match(/danger|warning|gray|formulaError/) ? 'tw-text-sq-text-color dark:tw-text-sq-dark-text' : ''}`, testId: `${testId}-close-btn`, onClick: onClose, ...tooltipProps }))] }));
|
|
33
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Alert } from './Alert';
|
|
3
|
-
import { QTip } from '../Tooltip';
|
|
4
|
-
const Template = ({ variant }) => {
|
|
5
|
-
return (_jsxs("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white", children: [
|
|
6
|
-
_jsxs("h3", { className: "tw-mb-5 tw-text-[0.9375rem] tw-leading-normal", children: ["This is a ", variant, " alert, it looks very pleasing and is very useful for showing alerts to the user"] }), _jsx(Alert, { variant: variant, dismissible: true, show: true, extraClassNames: "tw-h-[200px]", tooltip: "This is a small close alert icon", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, children: "This is a dismissible alert, it looks very pleasing and is very useful for showing alerts to the user" }), _jsx(QTip, {})
|
|
7
|
-
] }));
|
|
8
|
-
};
|
|
9
|
-
export const ThemedAlert = Template.bind({});
|
|
10
|
-
ThemedAlert.args = {
|
|
11
|
-
variant: 'theme',
|
|
12
|
-
};
|
|
13
|
-
export const WarningAlert = Template.bind({});
|
|
14
|
-
WarningAlert.args = {
|
|
15
|
-
variant: 'warning',
|
|
16
|
-
};
|
|
17
|
-
export const DangerAlert = Template.bind({});
|
|
18
|
-
DangerAlert.args = {
|
|
19
|
-
variant: 'danger',
|
|
20
|
-
};
|
|
21
|
-
export const FormulaErrorAlert = Template.bind({});
|
|
22
|
-
FormulaErrorAlert.args = {
|
|
23
|
-
variant: 'formulaError',
|
|
24
|
-
};
|
|
25
|
-
export const GrayAlert = Template.bind({});
|
|
26
|
-
GrayAlert.args = {
|
|
27
|
-
variant: 'gray',
|
|
28
|
-
};
|
|
29
|
-
const colors = ['topic', 'analysis', 'datalab', 'vantage'];
|
|
30
|
-
const renderAlert = ({ text, dismissable, variant, }) => (_jsxs("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white", children: [
|
|
31
|
-
_jsx("p", { className: "tw-mb-5 tw-text-[0.9375rem] tw-leading-normal" }), _jsx(Alert, { variant: variant, dismissible: dismissable, show: true, extraClassNames: "tw-h-[200px]", tooltip: "This is a small close alert icon", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, children: text })
|
|
32
|
-
] }));
|
|
33
|
-
export const AllAlertsVariants = () => {
|
|
34
|
-
const renderAllVariations = (color) => (_jsxs("div", { children: [
|
|
35
|
-
_jsx("div", { className: "tw-p-4", children: renderAlert({
|
|
36
|
-
text: 'This is a dismissible alert, it looks very pleasing and is very useful for showing alerts to the user',
|
|
37
|
-
dismissable: true,
|
|
38
|
-
variant: 'theme',
|
|
39
|
-
}) }), _jsx("div", { className: "tw-p-4", children: renderAlert({
|
|
40
|
-
text: 'This is a non dismissable alert, it looks very pleasing and is very useful for showing alerts to the user',
|
|
41
|
-
dismissable: false,
|
|
42
|
-
variant: 'theme',
|
|
43
|
-
}) }), _jsx("div", { className: "tw-p-4", children: renderAlert({
|
|
44
|
-
text: 'This is a warning alert, it is used to display a warning',
|
|
45
|
-
dismissable: false,
|
|
46
|
-
variant: 'warning',
|
|
47
|
-
}) }), _jsx("div", { className: "tw-p-4", children: renderAlert({
|
|
48
|
-
text: 'This is an error alert, it is used to display an error',
|
|
49
|
-
dismissable: false,
|
|
50
|
-
variant: 'danger',
|
|
51
|
-
}) }), _jsx("div", { className: "tw-p-4", children: renderAlert({
|
|
52
|
-
text: 'This is a gray alert, it is used to display a neutral alert',
|
|
53
|
-
dismissable: true,
|
|
54
|
-
variant: 'gray',
|
|
55
|
-
}) }), _jsx("div", { className: "tw-p-4", children: renderAlert({
|
|
56
|
-
text: 'This is an error alert that is dismissible, it is used to display an error',
|
|
57
|
-
dismissable: true,
|
|
58
|
-
variant: 'danger',
|
|
59
|
-
}) }), _jsx("div", { className: "tw-p-4", children: renderAlert({
|
|
60
|
-
text: 'This is a formula error alert that is dismissible, it is used to display an error',
|
|
61
|
-
dismissable: true,
|
|
62
|
-
variant: 'formulaError',
|
|
63
|
-
}) })
|
|
64
|
-
] }, color + '_wrapper'));
|
|
65
|
-
return (_jsxs("div", { children: [
|
|
66
|
-
_jsx(QTip, {}), _jsx("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: colors.map((color) => {
|
|
67
|
-
return _jsx("div", { className: `color_${color}`, children: renderAllVariations(color) });
|
|
68
|
-
}) }), _jsx("div", { className: "tw-dark tw-bg-sq-dark-background tw-grid tw-grid-cols-4 tw-gap-4", children: colors.map((color) => {
|
|
69
|
-
return _jsx("div", { className: `color_${color}`, children: renderAllVariations(color) });
|
|
70
|
-
}) })
|
|
71
|
-
] }));
|
|
72
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { Alert } from './Alert';
|
|
4
|
-
describe('Alert Component', () => {
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
children: 'Test Alert',
|
|
7
|
-
dismissible: true,
|
|
8
|
-
onClose: jest.fn(),
|
|
9
|
-
show: true,
|
|
10
|
-
variant: 'theme',
|
|
11
|
-
testId: 'alert-test-id',
|
|
12
|
-
id: 'alert-id',
|
|
13
|
-
extraClassNames: '',
|
|
14
|
-
};
|
|
15
|
-
it('should render the Alert component', () => {
|
|
16
|
-
render(_jsx(Alert, { ...defaultProps }));
|
|
17
|
-
const alertElement = screen.getByTestId('alert-test-id');
|
|
18
|
-
expect(alertElement).toBeInTheDocument();
|
|
19
|
-
});
|
|
20
|
-
it('should render children correctly', () => {
|
|
21
|
-
render(_jsx(Alert, { ...defaultProps }));
|
|
22
|
-
const alertElement = screen.getByTestId('alert-test-id');
|
|
23
|
-
expect(alertElement).toHaveTextContent('Test Alert');
|
|
24
|
-
});
|
|
25
|
-
it('should apply the correct classes based on variant', () => {
|
|
26
|
-
const { rerender } = render(_jsx(Alert, { ...defaultProps, variant: "danger" }));
|
|
27
|
-
let alertElement = screen.getByTestId('alert-test-id');
|
|
28
|
-
expect(alertElement).toHaveClass('tw-text-sq-text-color tw-bg-sq-danger-color');
|
|
29
|
-
rerender(_jsx(Alert, { ...defaultProps, variant: "warning" }));
|
|
30
|
-
alertElement = screen.getByTestId('alert-test-id');
|
|
31
|
-
expect(alertElement).toHaveClass('tw-bg-sq-bg-warning-color tw-text-sq-text-color');
|
|
32
|
-
});
|
|
33
|
-
it('should call onClose when dismissible icon is clicked', () => {
|
|
34
|
-
render(_jsx(Alert, { ...defaultProps }));
|
|
35
|
-
const closeButton = screen.getByTestId('alert-test-id-close-btn');
|
|
36
|
-
fireEvent.click(closeButton);
|
|
37
|
-
expect(defaultProps.onClose).toHaveBeenCalled();
|
|
38
|
-
});
|
|
39
|
-
it('should not render when show is false', () => {
|
|
40
|
-
render(_jsx(Alert, { ...defaultProps, show: false }));
|
|
41
|
-
const alertElement = screen.queryByTestId('alert-test-id');
|
|
42
|
-
expect(alertElement).not.toBeInTheDocument();
|
|
43
|
-
});
|
|
44
|
-
it('should apply extra class names', () => {
|
|
45
|
-
render(_jsx(Alert, { ...defaultProps, extraClassNames: "extra-class" }));
|
|
46
|
-
const alertElement = screen.getByTestId('alert-test-id');
|
|
47
|
-
expect(alertElement).toHaveClass('extra-class');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/Alert/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Alert as default } from './Alert';
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import '../styles.css';
|
|
3
|
-
import { browserIsFirefox } from '../utils/browserId';
|
|
4
|
-
import Icon from '../Icon';
|
|
5
|
-
import { DEFAULT_TOOL_TIP_DELAY } from '../Tooltip/Tooltip.types';
|
|
6
|
-
/**
|
|
7
|
-
* All-in-one Button:
|
|
8
|
-
* - use "variant" to achieve the desired style
|
|
9
|
-
* - include tooltips and/or icons
|
|
10
|
-
*/
|
|
11
|
-
const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, iconPosition = 'left', iconPrefix = undefined, preventBlur = false, isHtmlTooltip = false, tooltipTestId, }) => {
|
|
12
|
-
const baseClasses = 'tw-px-2.5 tw-rounded-md focus:tw-ring-0 focus-visible:tw-outline-none aria-disabled:tw-cursor-not-allowed disabled:tw-pointer-events-none';
|
|
13
|
-
const baseClassesByVariant = {
|
|
14
|
-
'outline': 'disabled:tw-opacity-50 aria-disabled:tw-opacity-50 tw-border-solid tw-border',
|
|
15
|
-
'theme': 'disabled:tw-opacity-50 aria-disabled:tw-opacity-50 tw-border-solid tw-border',
|
|
16
|
-
'danger': 'tw-bg-sq-danger-color disabled:tw-opacity-50 aria-disabled:tw-opacity-50 ' +
|
|
17
|
-
'tw-border-solid tw-border tw-border-sq-danger-color',
|
|
18
|
-
'theme-light': 'disabled:tw-opacity-50 aria-disabled:tw-opacity-50 tw-border-solid tw-border',
|
|
19
|
-
'no-border': 'disabled:tw-opacity-50 aria-disabled:tw-opacity-50',
|
|
20
|
-
'warning': 'tw-bg-sq-warning-color tw-border-solid tw-border tw-border-sq-warning-color ' +
|
|
21
|
-
'disabled:tw-opacity-50 aria-disabled:tw-opacity-50',
|
|
22
|
-
};
|
|
23
|
-
const textClassesByVariantLightTheme = {
|
|
24
|
-
'outline': 'tw-text-sq-text-color',
|
|
25
|
-
'theme': 'tw-text-white',
|
|
26
|
-
'theme-light': 'tw-text-white',
|
|
27
|
-
'danger': 'tw-text-white',
|
|
28
|
-
'no-border': 'tw-text-sq-text-color',
|
|
29
|
-
'warning': 'tw-text-white',
|
|
30
|
-
};
|
|
31
|
-
const textClassesByVariantDarkTheme = {
|
|
32
|
-
'outline': 'dark:tw-text-sq-dark-text',
|
|
33
|
-
'theme': 'dark:tw-text-white',
|
|
34
|
-
'theme-light': 'dark:tw-text-white',
|
|
35
|
-
'danger': 'dark:tw-text-white',
|
|
36
|
-
'no-border': 'dark:tw-text-sq-dark-text',
|
|
37
|
-
'warning': 'dark:tw-text-white',
|
|
38
|
-
};
|
|
39
|
-
const classesByVariantLightTheme = {
|
|
40
|
-
'outline': 'tw-bg-white tw-border-sq-disabled-gray',
|
|
41
|
-
'theme': 'tw-bg-sq-color-dark tw-border-sq-color-dark',
|
|
42
|
-
'danger': '',
|
|
43
|
-
'theme-light': 'tw-bg-sq-icon',
|
|
44
|
-
'no-border': '',
|
|
45
|
-
'warning': '',
|
|
46
|
-
};
|
|
47
|
-
const classesByVariantDarkTheme = {
|
|
48
|
-
'outline': 'dark:tw-bg-sq-dark-background dark:tw-border-sq-dark-disabled-gray',
|
|
49
|
-
'theme': 'dark:tw-bg-sq-color-dark dark:tw-border-sq-color-dark',
|
|
50
|
-
'danger': '',
|
|
51
|
-
'theme-light': 'dark:tw-bg-sq-icon-dark dark:tw-border-sq-icon-dark',
|
|
52
|
-
'no-border': '',
|
|
53
|
-
'warning': '',
|
|
54
|
-
};
|
|
55
|
-
const activeClassesByVariantLightTheme = {
|
|
56
|
-
'outline': 'hover:tw-bg-sq-light-gray focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark' +
|
|
57
|
-
' active:tw-border-sq-color-dark',
|
|
58
|
-
'theme': 'hover:tw-bg-sq-color-highlight hover:tw-border-sq-color-highlight',
|
|
59
|
-
'danger': 'hover:tw-bg-sq-danger-color-hover hover:tw-border-sq-danger-color-hover',
|
|
60
|
-
'theme-light': 'hover:tw-bg-sq-link hover:tw-border-sq-link',
|
|
61
|
-
'no-border': '',
|
|
62
|
-
'warning': '',
|
|
63
|
-
};
|
|
64
|
-
const activeClassesByVariantDarkTheme = {
|
|
65
|
-
'outline': 'dark:hover:tw-bg-sq-highlight-color-dark dark:focus:tw-bg-sq-multi-gray-dark' +
|
|
66
|
-
' dark:active:tw-bg-sq-multi-gray-dark dark:focus:tw-border-sq-color-dark dark:active:tw-border-sq-color-dark',
|
|
67
|
-
'theme': 'dark:hover:tw-bg-sq-color-highlight dark:hover:tw-border-sq-color-highlight',
|
|
68
|
-
'danger': 'dark:hover:tw-bg-sq-danger-color-hover dark:hover:tw-border-sq-danger-color-hover',
|
|
69
|
-
'theme-light': 'dark:hover:tw-bg-sq-link-dark dark:hover:tw-border-sq-link-dark',
|
|
70
|
-
'no-border': '',
|
|
71
|
-
'warning': '',
|
|
72
|
-
};
|
|
73
|
-
const sizeClasses = {
|
|
74
|
-
xs: 'tw-text-xs tw-py-0.5',
|
|
75
|
-
sm: 'tw-text-sm tw-py-1',
|
|
76
|
-
lg: 'tw-text-xl tw-py-1',
|
|
77
|
-
};
|
|
78
|
-
let tooltipData = undefined;
|
|
79
|
-
let appliedClasses = `${baseClasses} ${baseClassesByVariant[variant]} ${sizeClasses[size]} ${classesByVariantLightTheme[variant]} ${classesByVariantDarkTheme[variant]} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]} ${extraClassNames}`;
|
|
80
|
-
if (!disabled) {
|
|
81
|
-
appliedClasses += ` ${activeClassesByVariantLightTheme[variant]} ${activeClassesByVariantDarkTheme[variant]}`;
|
|
82
|
-
}
|
|
83
|
-
if (tooltip) {
|
|
84
|
-
tooltipData = {
|
|
85
|
-
'data-qtip-text': tooltip,
|
|
86
|
-
'data-qtip-placement': tooltipOptions?.position,
|
|
87
|
-
'data-qtip-is-html': isHtmlTooltip,
|
|
88
|
-
'data-qtip-testid': tooltipTestId,
|
|
89
|
-
'data-qtip-delay': tooltipOptions?.delay ?? DEFAULT_TOOL_TIP_DELAY,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
const iconClass = iconPosition === 'left' ? 'tw-mr-1' : 'tw-ml-1';
|
|
93
|
-
const iconElement = icon && (_jsx(Icon, { icon: icon, iconPrefix: iconPrefix, type: iconStyle, color: iconColor, extraClassNames: label
|
|
94
|
-
? `${iconClass} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}`
|
|
95
|
-
: '', testId: `${id}_spinner` }));
|
|
96
|
-
return (_jsxs("button", { id: id, ...tooltipData, disabled: disabled && !tooltip, "aria-disabled": disabled, "data-testid": testId, tabIndex: disabled ? -1 : undefined, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
|
|
97
|
-
stopPropagation && e.stopPropagation();
|
|
98
|
-
if (!disabled) {
|
|
99
|
-
onClick?.(e);
|
|
100
|
-
}
|
|
101
|
-
}, onMouseDown: (e) => {
|
|
102
|
-
if (preventBlur) {
|
|
103
|
-
e.preventDefault();
|
|
104
|
-
}
|
|
105
|
-
}, className: appliedClasses, children: [iconPosition === 'left' && iconElement, label, iconPosition === 'right' && iconElement] }));
|
|
106
|
-
};
|
|
107
|
-
export default Button;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Button from './Button';
|
|
3
|
-
import { buttonVariants, buttonSizes } from './Button.types';
|
|
4
|
-
import { QTip } from '../Tooltip';
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Button',
|
|
7
|
-
};
|
|
8
|
-
export const AllButtonVariants = () => {
|
|
9
|
-
const renderAllVariations = () => (_jsx(_Fragment, { children: buttonVariants.map((variant) => (_jsxs("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4", children: [
|
|
10
|
-
_jsx("div", { className: "tw-p-4", children: _jsx(Button, { label: `Variant: ${variant}`, onClick: () => { }, variant: variant }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(Button, { label: `Variant: ${variant}`, onClick: () => { }, variant: variant }) })
|
|
11
|
-
] }, `{variant_${variant}`))) }));
|
|
12
|
-
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
13
|
-
_jsxs("div", { className: "color_topic", children: [
|
|
14
|
-
_jsx("b", { children: "Topic Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
15
|
-
_jsx("b", { children: "Analysis Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
16
|
-
_jsx("b", { children: "Datalab Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
17
|
-
_jsx("b", { children: "Vantage Colors" }), renderAllVariations()] })
|
|
18
|
-
] }));
|
|
19
|
-
};
|
|
20
|
-
export const ButtonWithTooltip = () => {
|
|
21
|
-
const renderButtonWithTooltip = () => (_jsxs(_Fragment, { children: [
|
|
22
|
-
_jsx("div", { className: "tw-p-4", children: _jsx(Button, { tooltip: "Helpful tooltip", variant: "theme", label: "Hover me" }) }), _jsx("div", { className: "tw-p-4", children: _jsx(Button, { tooltip: "Helpful tooltip shown even when button is disabled", disabled: true, variant: "theme", label: "Hover me (disabled)" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(Button, { tooltip: "Helpful tooltip", variant: "theme", label: "Hover me" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(Button, { tooltip: "Helpful tooltip shown even when button is disabled", disabled: true, variant: "theme", label: "Hover me (disabled)" }) })
|
|
23
|
-
] }));
|
|
24
|
-
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
25
|
-
_jsx(QTip, {}), _jsxs("div", { className: "color_topic", children: [
|
|
26
|
-
_jsx("b", { children: "Topic Colors" }), renderButtonWithTooltip()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
27
|
-
_jsx("b", { children: "Analysis Colors" }), renderButtonWithTooltip()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
28
|
-
_jsx("b", { children: "Datalab Colors" }), renderButtonWithTooltip()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
29
|
-
_jsx("b", { children: "Vantage Colors" }), renderButtonWithTooltip()] })
|
|
30
|
-
] }));
|
|
31
|
-
};
|
|
32
|
-
export const ButtonWithIcon = () => {
|
|
33
|
-
const renderButtonWithIcon = () => (_jsxs(_Fragment, { children: [
|
|
34
|
-
_jsx("div", { className: "tw-p-4", children: _jsx(Button, { icon: "fc-search-power", variant: "theme", label: "With Icon" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(Button, { icon: "fc-search-power", variant: "theme", label: "With Icon" }) })
|
|
35
|
-
] }));
|
|
36
|
-
const renderButtonWithIconOnRight = () => (_jsxs(_Fragment, { children: [
|
|
37
|
-
_jsx("div", { className: "tw-p-4", children: _jsx(Button, { icon: "fc-search-power", iconPosition: "right", variant: "theme", label: "With Icon On Right" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(Button, { icon: "fc-search-power", iconPosition: "right", variant: "theme", label: "With Icon On Right" }) })
|
|
38
|
-
] }));
|
|
39
|
-
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
40
|
-
_jsxs("div", { className: "color_topic", children: [
|
|
41
|
-
_jsx("b", { children: "Topic Colors" }), renderButtonWithIcon()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
42
|
-
_jsx("b", { children: "Analysis Colors" }), renderButtonWithIcon()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
43
|
-
_jsx("b", { children: "Datalab Colors" }), renderButtonWithIcon()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
44
|
-
_jsx("b", { children: "Vantage Colors" }), renderButtonWithIcon()] }), _jsx("div", { className: "color_topic", children: renderButtonWithIconOnRight() }), _jsx("div", { className: "color_analysis", children: renderButtonWithIconOnRight() }), _jsx("div", { className: "color_datalab", children: renderButtonWithIconOnRight() }), _jsx("div", { className: "color_vantage", children: renderButtonWithIconOnRight() })
|
|
45
|
-
] }));
|
|
46
|
-
};
|
|
47
|
-
export const DisabledButton = () => {
|
|
48
|
-
const renderDisabledButton = () => (_jsxs(_Fragment, { children: [
|
|
49
|
-
_jsxs("div", { className: "tw-p-4", children: [
|
|
50
|
-
_jsx(Button, { disabled: true, variant: "theme", label: "Disabled Button" }), _jsx(Button, { extraClassNames: "tw-m-5", disabled: true, label: "Disabled Button" })
|
|
51
|
-
] }), _jsxs("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: [
|
|
52
|
-
_jsx(Button, { disabled: true, variant: "theme", label: "Disabled Button" }), _jsx(Button, { extraClassNames: "tw-m-5", disabled: true, label: "Disabled Button" })
|
|
53
|
-
] })
|
|
54
|
-
] }));
|
|
55
|
-
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
56
|
-
_jsxs("div", { className: "color_topic", children: [
|
|
57
|
-
_jsx("b", { children: "Topic Colors" }), renderDisabledButton()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
58
|
-
_jsx("b", { children: "Analysis Colors" }), renderDisabledButton()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
59
|
-
_jsx("b", { children: "Datalab Colors" }), renderDisabledButton()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
60
|
-
_jsx("b", { children: "Vantage Colors" }), renderDisabledButton()] })
|
|
61
|
-
] }));
|
|
62
|
-
};
|
|
63
|
-
export const ButtonSizes = () => {
|
|
64
|
-
const renderButtonSizes = () => (_jsxs(_Fragment, { children: [
|
|
65
|
-
_jsx("div", { className: "tw-p-4", children: buttonSizes.map((size) => (_jsx("div", { className: "tw-mb-2", children: _jsx(Button, { size: size, variant: "theme", label: `Size: ${size}` }) }, `size_light_${size}`))) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: buttonSizes.map((size) => (_jsx("div", { className: "tw-mb-2", children: _jsx(Button, { size: size, variant: "theme", label: `Size: ${size}` }) }, `size_dark_${size}`))) })
|
|
66
|
-
] }));
|
|
67
|
-
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
68
|
-
_jsxs("div", { className: "color_topic", children: [
|
|
69
|
-
_jsx("b", { children: "Topic Colors" }), renderButtonSizes()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
70
|
-
_jsx("b", { children: "Analysis Colors" }), renderButtonSizes()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
71
|
-
_jsx("b", { children: "Datalab Colors" }), renderButtonSizes()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
72
|
-
_jsx("b", { children: "Vantage Colors" }), renderButtonSizes()] })
|
|
73
|
-
] }));
|
|
74
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } 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 Button from './Button';
|
|
6
|
-
import { QTip } from '../Tooltip';
|
|
7
|
-
describe('Button', () => {
|
|
8
|
-
class Context {
|
|
9
|
-
testId = 'buttonTestId';
|
|
10
|
-
label = 'button label';
|
|
11
|
-
props = {
|
|
12
|
-
label: this.label,
|
|
13
|
-
onClick: jest.fn(),
|
|
14
|
-
testId: this.testId,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
let tc;
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
tc = new Context();
|
|
20
|
-
});
|
|
21
|
-
const renderButton = ({ withQTip = false, ...rest }) => render(_jsxs(_Fragment, { children: [withQTip && _jsx(QTip, {}), _jsx(Button, { ...rest })
|
|
22
|
-
] }));
|
|
23
|
-
it('renders button label', () => {
|
|
24
|
-
renderButton(tc.props);
|
|
25
|
-
expect(screen.getByText(tc.label)).toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
it('calls on click', async () => {
|
|
28
|
-
renderButton(tc.props);
|
|
29
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
30
|
-
expect(tc.props.onClick).toHaveBeenCalled();
|
|
31
|
-
});
|
|
32
|
-
describe('stopPropagation', () => {
|
|
33
|
-
it('stops propagation of click event by default', async () => {
|
|
34
|
-
const callOnPropagation = jest.fn();
|
|
35
|
-
render(_jsx("div", { onClick: callOnPropagation, children: _jsx(Button, { ...tc.props }) }));
|
|
36
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
37
|
-
expect(callOnPropagation).not.toHaveBeenCalled();
|
|
38
|
-
});
|
|
39
|
-
it('does not stop propagation of click event when stopPropagation is false', async () => {
|
|
40
|
-
const callOnPropagation = jest.fn();
|
|
41
|
-
render(_jsx("div", { onClick: callOnPropagation, children: _jsx(Button, { ...tc.props, stopPropagation: false }) }));
|
|
42
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
43
|
-
expect(callOnPropagation).toHaveBeenCalled();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe('disabled', () => {
|
|
47
|
-
it('renders disabled button', () => {
|
|
48
|
-
renderButton({ ...tc.props, disabled: true });
|
|
49
|
-
expect(screen.getByText(tc.label)).toBeDisabled();
|
|
50
|
-
});
|
|
51
|
-
it('does not call onClick when disabled', async () => {
|
|
52
|
-
renderButton({ ...tc.props, disabled: true });
|
|
53
|
-
await userEvent.click(screen.getByRole('button', { name: tc.label }));
|
|
54
|
-
expect(tc.props.onClick).not.toHaveBeenCalled();
|
|
55
|
-
});
|
|
56
|
-
it('shows a tooltip even when disabled', async () => {
|
|
57
|
-
renderButton({ ...tc.props, disabled: true, tooltip: 'Testing tooltip', withQTip: true });
|
|
58
|
-
// A <Button> with a tooltip does not set the disabled attribute on the button element
|
|
59
|
-
expect(screen.getByRole('button', { name: tc.label })).not.toBeDisabled();
|
|
60
|
-
expect(screen.getByRole('button', { name: tc.label })).toHaveAttribute('aria-disabled', 'true');
|
|
61
|
-
await userEvent.hover(screen.getByRole('button', { name: tc.label }));
|
|
62
|
-
expect(await screen.findByText('Testing tooltip')).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
package/dist/src/Button/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Button';
|