@seeqdev/qomponents 0.0.183 → 0.0.185
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 +5 -19
- package/dist/example/.eslintrc.cjs +2 -6
- package/dist/example/README.md +0 -3
- package/dist/example/src/Example.tsx +7 -7
- package/dist/example/tsconfig.json +2 -8
- package/dist/example/tsconfig.node.json +1 -3
- package/dist/example/vite.config.ts +1 -1
- package/dist/index.esm.js +784 -523
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +781 -520
- package/dist/index.js.map +1 -1
- package/dist/src/Accordion/Accordion.js +8 -0
- package/dist/src/Accordion/Accordion.stories.js +96 -0
- package/dist/src/Accordion/Accordion.test.js +54 -0
- package/dist/src/Accordion/Accordion.types.js +1 -0
- package/dist/src/Accordion/index.js +1 -0
- package/dist/src/Alert/Alert.js +33 -0
- package/dist/src/Alert/Alert.stories.d.ts +13 -5
- package/dist/src/Alert/Alert.stories.js +72 -0
- package/dist/src/Alert/Alert.test.js +49 -0
- package/dist/src/Alert/Alert.types.js +1 -0
- package/dist/src/Alert/index.js +1 -0
- package/dist/src/Button/Button.js +107 -0
- package/dist/src/Button/Button.stories.js +74 -0
- package/dist/src/Button/Button.test.js +65 -0
- package/dist/src/Button/Button.types.d.ts +4 -4
- package/dist/src/Button/Button.types.js +4 -0
- package/dist/src/Button/index.d.ts +1 -1
- package/dist/src/Button/index.js +1 -0
- package/dist/src/ButtonGroup/ButtonGroup.js +34 -0
- package/dist/src/ButtonGroup/ButtonGroup.stories.js +328 -0
- package/dist/src/ButtonGroup/ButtonGroup.test.js +65 -0
- package/dist/src/ButtonGroup/ButtonGroup.types.js +1 -0
- package/dist/src/ButtonGroup/index.js +1 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.js +46 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.stories.js +119 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -0
- package/dist/src/ButtonWithDropdown/index.js +1 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.js +54 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.stories.js +51 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.test.js +80 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.types.js +1 -0
- package/dist/src/ButtonWithPopover/index.js +1 -0
- package/dist/src/Carousel/Carousel.js +80 -0
- package/dist/src/Carousel/Carousel.stories.js +100 -0
- package/dist/src/Carousel/Carousel.test.js +47 -0
- package/dist/src/Carousel/Carousel.types.js +1 -0
- package/dist/src/Carousel/index.js +1 -0
- package/dist/src/Checkbox/Checkbox.js +24 -0
- package/dist/src/Checkbox/Checkbox.stories.js +21 -0
- package/dist/src/Checkbox/Checkbox.test.js +93 -0
- package/dist/src/Checkbox/Checkbox.types.js +1 -0
- package/dist/src/Checkbox/index.js +1 -0
- package/dist/src/Collapse/Collapse.js +16 -0
- package/dist/src/Collapse/Collapse.stories.js +28 -0
- package/dist/src/Collapse/Collapse.test.js +16 -0
- package/dist/src/Collapse/Collapse.types.js +1 -0
- package/dist/src/Collapse/index.js +1 -0
- package/dist/src/Icon/Icon.js +55 -0
- package/dist/src/Icon/Icon.stories.js +31 -0
- package/dist/src/Icon/Icon.test.js +54 -0
- package/dist/src/Icon/Icon.types.d.ts +1 -1
- package/dist/src/Icon/Icon.types.js +15 -0
- package/dist/src/Icon/index.js +1 -0
- package/dist/src/InputGroup/InputGroup.js +33 -0
- package/dist/src/InputGroup/InputGroup.stories.js +144 -0
- package/dist/src/InputGroup/InputGroup.test.js +41 -0
- package/dist/src/InputGroup/InputGroup.types.js +1 -0
- package/dist/src/InputGroup/index.js +1 -0
- package/dist/src/Modal/Modal.js +86 -0
- package/dist/src/Modal/Modal.stories.js +79 -0
- package/dist/src/Modal/Modal.test.js +107 -0
- package/dist/src/Modal/Modal.types.js +1 -0
- package/dist/src/Modal/index.js +1 -0
- package/dist/src/ProgressBar/ProgressBar.js +71 -0
- package/dist/src/ProgressBar/ProgressBar.stories.js +46 -0
- package/dist/src/ProgressBar/ProgressBar.test.js +42 -0
- package/dist/src/ProgressBar/ProgressBar.types.js +1 -0
- package/dist/src/ProgressBar/index.js +1 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.js +41 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.stories.js +73 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.types.d.ts +0 -5
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -0
- package/dist/src/SeeqActionDropdown/index.js +1 -0
- package/dist/src/SeeqActionDropdown/variants.js +34 -0
- package/dist/src/Select/Select.js +171 -0
- package/dist/src/Select/Select.stories.js +50 -0
- package/dist/src/Select/Select.test.js +176 -0
- package/dist/src/Select/Select.types.js +1 -0
- package/dist/src/Select/index.js +2 -0
- package/dist/src/Slider/Slider.js +11 -0
- package/dist/src/Slider/Slider.stories.js +37 -0
- package/dist/src/Slider/Slider.test.js +31 -0
- package/dist/src/Slider/Slider.types.js +1 -0
- package/dist/src/Slider/index.js +1 -0
- package/dist/src/SvgIcon/SvgIcon.js +27 -0
- package/dist/src/SvgIcon/SvgIcon.stories.js +26 -0
- package/dist/src/SvgIcon/SvgIcon.test.js +40 -0
- package/dist/src/SvgIcon/SvgIcon.types.d.ts +1 -1
- package/dist/src/SvgIcon/SvgIcon.types.js +2 -0
- package/dist/src/SvgIcon/index.js +1 -0
- package/dist/src/Tabs/Tabs.js +18 -0
- package/dist/src/Tabs/Tabs.stories.js +83 -0
- package/dist/src/Tabs/Tabs.test.js +91 -0
- package/dist/src/Tabs/Tabs.types.js +1 -0
- package/dist/src/Tabs/index.js +1 -0
- package/dist/src/TextArea/TextArea.js +54 -0
- package/dist/src/TextArea/TextArea.stories.js +21 -0
- package/dist/src/TextArea/TextArea.test.js +129 -0
- package/dist/src/TextArea/TextArea.types.js +1 -0
- package/dist/src/TextArea/index.js +1 -0
- package/dist/src/TextField/TextField.js +85 -0
- package/dist/src/TextField/TextField.stories.js +30 -0
- package/dist/src/TextField/TextField.test.js +40 -0
- package/dist/src/TextField/TextField.types.js +1 -0
- package/dist/src/TextField/index.js +1 -0
- package/dist/src/ToolbarButton/ToolbarButton.js +58 -0
- package/dist/src/ToolbarButton/ToolbarButton.stories.js +63 -0
- package/dist/src/ToolbarButton/ToolbarButton.test.js +89 -0
- package/dist/src/ToolbarButton/ToolbarButton.types.d.ts +1 -1
- package/dist/src/ToolbarButton/ToolbarButton.types.js +1 -0
- package/dist/src/ToolbarButton/index.js +1 -0
- package/dist/src/Tooltip/QTip.stories.js +22 -0
- package/dist/src/Tooltip/QTip.types.js +1 -0
- package/dist/src/Tooltip/QTipPerformance.stories.js +27 -0
- package/dist/src/Tooltip/Qtip.js +168 -0
- package/dist/src/Tooltip/Tooltip.js +34 -0
- package/dist/src/Tooltip/Tooltip.stories.js +20 -0
- package/dist/src/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/src/Tooltip/Tooltip.types.js +2 -0
- package/dist/src/Tooltip/TooltipPerformance.stories.js +25 -0
- package/dist/src/Tooltip/index.js +2 -0
- package/dist/src/Tooltip/qTip.utilities.js +10 -0
- package/dist/src/index.js +47 -0
- package/dist/src/setupTests.js +5 -0
- package/dist/src/types.js +25 -0
- package/dist/src/utils/browserId.d.ts +3 -3
- package/dist/src/utils/browserId.js +28 -0
- package/dist/src/utils/svg.js +19 -0
- package/dist/src/utils/validateStyleDimension.js +13 -0
- package/dist/src/utils/validateStyleDimension.test.js +19 -0
- package/dist/styles.css +3410 -2791
- package/package.json +22 -17
|
@@ -0,0 +1,93 @@
|
|
|
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 { Checkbox } from './Checkbox';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
describe('Checkbox', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
testId = 'checkboxTestId';
|
|
9
|
+
props = {
|
|
10
|
+
onChange: jest.fn(),
|
|
11
|
+
checked: false,
|
|
12
|
+
testId: this.testId,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let tc;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
tc = new Context();
|
|
18
|
+
});
|
|
19
|
+
const renderCheckbox = (props) => render(_jsx(Checkbox, { ...props }));
|
|
20
|
+
it('renders checkbox', () => {
|
|
21
|
+
renderCheckbox(tc.props);
|
|
22
|
+
expect(screen.getByTestId(tc.testId)).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
it('renders radio', () => {
|
|
25
|
+
renderCheckbox({ ...tc.props, type: 'radio' });
|
|
26
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('type', 'radio');
|
|
27
|
+
});
|
|
28
|
+
it('renders label', () => {
|
|
29
|
+
const label = 'look at this checkbox!';
|
|
30
|
+
renderCheckbox({ ...tc.props, label });
|
|
31
|
+
expect(screen.getByText(label)).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
it('respects checked', () => {
|
|
34
|
+
renderCheckbox({ ...tc.props, checked: true });
|
|
35
|
+
expect(screen.getByTestId(tc.testId)).toBeChecked();
|
|
36
|
+
});
|
|
37
|
+
it('calls onChange handler', async () => {
|
|
38
|
+
const onChange = jest.fn();
|
|
39
|
+
renderCheckbox({ ...tc.props, onChange });
|
|
40
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
41
|
+
expect(onChange).toHaveBeenCalled();
|
|
42
|
+
});
|
|
43
|
+
it('calls onKeyDown handler', async () => {
|
|
44
|
+
const onKeyDown = jest.fn();
|
|
45
|
+
renderCheckbox({ ...tc.props, onKeyDown });
|
|
46
|
+
await userEvent.type(screen.getByTestId(tc.testId), 'a');
|
|
47
|
+
expect(onKeyDown).toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
it('calls onClickHandler handler', async () => {
|
|
50
|
+
const onClick = jest.fn();
|
|
51
|
+
renderCheckbox({ ...tc.props, onClick });
|
|
52
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
53
|
+
expect(onClick).toHaveBeenCalled();
|
|
54
|
+
});
|
|
55
|
+
it('respects disabled', () => {
|
|
56
|
+
renderCheckbox({ ...tc.props, disabled: true });
|
|
57
|
+
expect(screen.getByTestId(tc.testId)).not.toBeEnabled();
|
|
58
|
+
});
|
|
59
|
+
it('renders label clickable', async () => {
|
|
60
|
+
const label = 'amazing checkbox';
|
|
61
|
+
const onClick = jest.fn();
|
|
62
|
+
renderCheckbox({ ...tc.props, label, onClick });
|
|
63
|
+
expect(screen.getByTestId(tc.testId)).not.toBeChecked();
|
|
64
|
+
await userEvent.click(screen.getByText(label));
|
|
65
|
+
expect(onClick).toHaveBeenCalled();
|
|
66
|
+
});
|
|
67
|
+
it('respects id', () => {
|
|
68
|
+
const id = 'checkboxId';
|
|
69
|
+
renderCheckbox({ ...tc.props, id });
|
|
70
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('id', id);
|
|
71
|
+
});
|
|
72
|
+
it('respects name', () => {
|
|
73
|
+
const name = 'checkboxName';
|
|
74
|
+
renderCheckbox({ ...tc.props, name });
|
|
75
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('name', name);
|
|
76
|
+
});
|
|
77
|
+
it('respects name', () => {
|
|
78
|
+
const value = 'priceless';
|
|
79
|
+
renderCheckbox({ ...tc.props, value });
|
|
80
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('value', value);
|
|
81
|
+
});
|
|
82
|
+
it('applies extraClassNames', () => {
|
|
83
|
+
const extraClassNames = 'extra styling so fancy';
|
|
84
|
+
renderCheckbox({ ...tc.props, extraClassNames });
|
|
85
|
+
expect(screen.getByTestId(tc.testId).parentNode).toHaveClass(extraClassNames);
|
|
86
|
+
});
|
|
87
|
+
it('applies extraLabelClassNames', () => {
|
|
88
|
+
const extraLabelClassNames = 'special label';
|
|
89
|
+
const label = 'amazing checkbox';
|
|
90
|
+
renderCheckbox({ ...tc.props, extraLabelClassNames, label });
|
|
91
|
+
expect(screen.getByText(label)).toHaveClass(extraLabelClassNames);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox as default } from './Checkbox';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
4
|
+
const Collapse = ({ isVisible, children }) => {
|
|
5
|
+
const contentRef = useRef(null);
|
|
6
|
+
const [contentHeight, setContentHeight] = useState(0);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (contentRef.current) {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
setContentHeight((contentRef.current?.scrollHeight ?? 0) + 5);
|
|
11
|
+
}, 0);
|
|
12
|
+
}
|
|
13
|
+
}, [children]);
|
|
14
|
+
return (_jsx(AnimatePresence, { initial: false, children: isVisible && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: contentHeight, opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { type: 'spring', damping: 20, stiffness: 100 }, children: _jsx("div", { ref: contentRef, children: children }) })) }));
|
|
15
|
+
};
|
|
16
|
+
export default Collapse;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Collapse from './Collapse';
|
|
4
|
+
import { QTip } from '../Tooltip';
|
|
5
|
+
import Button from '../Button';
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Collapse',
|
|
8
|
+
};
|
|
9
|
+
export const AllCollapses = () => {
|
|
10
|
+
const [isVisible, setIsVisible] = React.useState(true);
|
|
11
|
+
const renderChild = () => (_jsxs("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white", children: [
|
|
12
|
+
_jsx("p", { className: "tw-mb-5 tw-text-[0.9375rem] tw-leading-normal", children: "This is a content to be shown when the collapse is visible. Click the button above to toggle it" }), _jsx(Button, { variant: "outline", label: "Save data" })
|
|
13
|
+
] }));
|
|
14
|
+
const renderAllVariations = () => (_jsxs(_Fragment, { children: [
|
|
15
|
+
_jsx("div", { className: "tw-p-4 light", children: _jsxs("div", { className: "tw-p-4", children: [
|
|
16
|
+
_jsx(Button, { variant: "theme", label: "Toggle Collapse", onClick: () => setIsVisible(!isVisible) }), _jsx(Collapse, { isVisible: isVisible, children: renderChild() })
|
|
17
|
+
] }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsxs("div", { className: "tw-p-4", children: [
|
|
18
|
+
_jsx(Button, { variant: "theme", label: "Toggle Collapse", onClick: () => setIsVisible(!isVisible) }), _jsx(Collapse, { isVisible: isVisible, children: renderChild() })
|
|
19
|
+
] }) })
|
|
20
|
+
] }));
|
|
21
|
+
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
22
|
+
_jsx(QTip, {}), _jsxs("div", { className: "color_topic", children: [
|
|
23
|
+
_jsx("b", { children: "Topic Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
24
|
+
_jsx("b", { children: "Analysis Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
25
|
+
_jsx("b", { children: "Datalab Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
26
|
+
_jsx("b", { children: "Vantage Colors" }), renderAllVariations()] })
|
|
27
|
+
] }));
|
|
28
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import Collapse from './Collapse';
|
|
5
|
+
describe('Collapse component', () => {
|
|
6
|
+
test('renders children when visible', async () => {
|
|
7
|
+
render(_jsx(Collapse, { isVisible: true, children: _jsx("div", { "data-testid": "content", children: "Content" }) }));
|
|
8
|
+
await waitFor(() => {
|
|
9
|
+
expect(screen.getByTestId('content')).toBeVisible();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
test('does not render children when not visible', async () => {
|
|
13
|
+
render(_jsx(Collapse, { isVisible: false, children: _jsx("div", { "data-testid": "content", children: "Content" }) }));
|
|
14
|
+
expect(screen.queryByTestId('content')).not.toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Collapse';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { getQTipData } from '../Tooltip/qTip.utilities';
|
|
4
|
+
const colorClassesThemeLight = {
|
|
5
|
+
'theme': 'tw-text-sq-color-dark',
|
|
6
|
+
'white': 'tw-text-white',
|
|
7
|
+
'dark-gray': 'tw-text-sq-fairly-dark-gray',
|
|
8
|
+
'warning': 'tw-text-sq-warning-color',
|
|
9
|
+
'darkish-gray': 'tw-text-sq-darkish-gray',
|
|
10
|
+
'gray': 'tw-text-sq-disabled-gray',
|
|
11
|
+
'color': '',
|
|
12
|
+
'info': 'tw-text-sq-link',
|
|
13
|
+
'text': 'tw-text-sq-text-color',
|
|
14
|
+
'inherit': '',
|
|
15
|
+
'danger': 'tw-text-sq-danger-color',
|
|
16
|
+
'theme-light': 'tw-text-sq-color-light',
|
|
17
|
+
'success': 'tw-text-sq-success-color',
|
|
18
|
+
};
|
|
19
|
+
const colorClassesThemeDark = {
|
|
20
|
+
'theme': 'dark:tw-text-sq-color-dark-dark',
|
|
21
|
+
'white': '',
|
|
22
|
+
'dark-gray': 'tw-text-sq-fairly-dark-gray',
|
|
23
|
+
'warning': '',
|
|
24
|
+
'darkish-gray': 'tw-text-sq-darkish-gray',
|
|
25
|
+
'gray': 'dark:tw-text-sq-dark-disabled-gray',
|
|
26
|
+
'color': '',
|
|
27
|
+
'info': 'dark:tw-text-sq-link-dark',
|
|
28
|
+
'text': 'dark:tw-text-sq-dark-text',
|
|
29
|
+
'inherit': '',
|
|
30
|
+
'danger': 'tw-text-sq-danger-color',
|
|
31
|
+
'theme-light': 'tw-text-sq-color-light',
|
|
32
|
+
'success': 'tw-text-sq-success-color',
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Icon:
|
|
36
|
+
* - access to Seeq custom icons by providing the desired icon
|
|
37
|
+
* - leverage "type" to style your icon
|
|
38
|
+
*/
|
|
39
|
+
const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClassNames, id, large, small, size, color, testId, customId, number, ...tooltipProps }) => {
|
|
40
|
+
if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
|
|
41
|
+
const errorMessage = color === undefined || color === ''
|
|
42
|
+
? 'Icon with type="color" must have prop color specified.'
|
|
43
|
+
: 'Icon with prop color must have type="color".';
|
|
44
|
+
return _jsx("div", { className: "tw-text-sq-danger-color", children: errorMessage });
|
|
45
|
+
}
|
|
46
|
+
const fontAwesomePrefix = iconPrefix ? iconPrefix : 'fa-sharp fa-regular';
|
|
47
|
+
const iconPrefixString = icon.startsWith('fc') ? 'fc' : fontAwesomePrefix;
|
|
48
|
+
const style = type === 'color' && color ? { color } : {};
|
|
49
|
+
const sizeClass = size ? `fa-${size}` : small ? 'fa-sm' : large ? 'fa-lg' : '';
|
|
50
|
+
const appliedClassNames = `${iconPrefixString} ${icon} ${sizeClass}
|
|
51
|
+
${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'tw-cursor-pointer' : ''} ${extraClassNames} focus:tw-outline-none focus-visible:tw-outline-none tw-outline-none`;
|
|
52
|
+
const tooltipData = getQTipData(tooltipProps);
|
|
53
|
+
return (_jsx("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number, ...tooltipData }));
|
|
54
|
+
};
|
|
55
|
+
export default Icon;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Icon from './Icon';
|
|
3
|
+
import { iconTypes } from './Icon.types';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Icons',
|
|
6
|
+
};
|
|
7
|
+
export const AllIcons = () => {
|
|
8
|
+
const renderAllVariations = () => {
|
|
9
|
+
return (_jsxs(_Fragment, { children: [
|
|
10
|
+
_jsx("br", {}), _jsx("br", {}), iconTypes.map((iconType) => {
|
|
11
|
+
return (_jsxs("div", { children: [
|
|
12
|
+
_jsxs("b", { children: ["type=", iconType] }), _jsx("br", {}), _jsxs("div", { children: [
|
|
13
|
+
_jsx(Icon, { icon: "fc-genai-chat", small: true, extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'purple' : undefined }), _jsx(Icon, { icon: "fc-formula-ai", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? '#928378' : undefined }), _jsx(Icon, { icon: "fc-datalab-ai", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined }), _jsx(Icon, { icon: "fc-genai-agent-q", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined }), _jsx(Icon, { icon: "fc-workbook-ai", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined }), _jsx(Icon, { icon: "fc-vantage", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined })
|
|
14
|
+
] }), _jsxs("div", { children: [
|
|
15
|
+
_jsx(Icon, { icon: "fc-statistics-menu", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined }), _jsx(Icon, { icon: "fc-statistic-summary", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined }), _jsx(Icon, { icon: "fc-create-summary", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? '#928378' : undefined }), _jsx(Icon, { icon: "fc-view-summaries", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined })
|
|
16
|
+
] }), _jsx("b", { children: "Sizes" }), _jsx("br", {}), _jsxs("div", { className: "tw-flex tw-flex-row tw-flex-wrap tw-gap-1 tw-py-6", children: [
|
|
17
|
+
_jsx(Icon, { icon: "fc-pca", size: "2xs", type: iconType, color: iconType === 'color' ? 'purple' : undefined }), _jsx(Icon, { icon: "fc-pca", size: "xs", type: iconType, color: iconType === 'color' ? 'purple' : undefined }), _jsx(Icon, { icon: "fc-pca", size: "sm", type: iconType, color: iconType === 'color' ? 'purple' : undefined }), _jsx(Icon, { icon: "fc-pca", size: "lg", type: iconType, color: iconType === 'color' ? 'purple' : undefined }), _jsx(Icon, { icon: "fc-pca", size: "xl", type: iconType, color: iconType === 'color' ? 'purple' : undefined }), _jsx(Icon, { icon: "fc-pca", size: "2xl", type: iconType, color: iconType === 'color' ? 'purple' : undefined })
|
|
18
|
+
] }), _jsxs("div", { className: "tw-dark tw-bg-sq-dark-background", children: [
|
|
19
|
+
_jsx(Icon, { icon: "fc-announcements", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'purple' : undefined }), _jsx(Icon, { icon: "fc-announcements", extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? '#928378' : undefined }), _jsx(Icon, { icon: "fc-announcements", large: true, extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined })
|
|
20
|
+
] }), _jsx("br", {})
|
|
21
|
+
] }, `${iconType}`));
|
|
22
|
+
})] }));
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
25
|
+
_jsxs("div", { className: "color_topic", children: [
|
|
26
|
+
_jsx("b", { children: "Topic Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
27
|
+
_jsx("b", { children: "Analysis Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
28
|
+
_jsx("b", { children: "Datalab Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
29
|
+
_jsx("b", { children: "Vantage Colors" }), renderAllVariations()] })
|
|
30
|
+
] }));
|
|
31
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
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 Icon from './Icon';
|
|
5
|
+
describe('Icon', () => {
|
|
6
|
+
class Context {
|
|
7
|
+
testId = 'iconTestId';
|
|
8
|
+
icon = 'testIcon';
|
|
9
|
+
props = {
|
|
10
|
+
icon: this.icon,
|
|
11
|
+
onClick: jest.fn(),
|
|
12
|
+
testId: this.testId,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let tc;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
tc = new Context();
|
|
18
|
+
});
|
|
19
|
+
const renderIcon = (props) => render(_jsx(Icon, { ...props }));
|
|
20
|
+
it('renders icon', () => {
|
|
21
|
+
renderIcon(tc.props);
|
|
22
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass(tc.icon);
|
|
23
|
+
});
|
|
24
|
+
it('renders large icon', () => {
|
|
25
|
+
renderIcon({ ...tc.props, large: true });
|
|
26
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('fa-lg');
|
|
27
|
+
});
|
|
28
|
+
it('renders small icon', () => {
|
|
29
|
+
renderIcon({ ...tc.props, small: true });
|
|
30
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('fa-sm');
|
|
31
|
+
});
|
|
32
|
+
describe('icon types', () => {
|
|
33
|
+
it('renders the theme type by default', () => {
|
|
34
|
+
renderIcon(tc.props);
|
|
35
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('tw-text-sq-color-dark');
|
|
36
|
+
});
|
|
37
|
+
it('renders the white icon', () => {
|
|
38
|
+
renderIcon({ ...tc.props, type: 'white' });
|
|
39
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('tw-text-white');
|
|
40
|
+
});
|
|
41
|
+
it('renders the text-type icon', () => {
|
|
42
|
+
renderIcon({ ...tc.props, type: 'text' });
|
|
43
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('tw-text-sq-text-color');
|
|
44
|
+
});
|
|
45
|
+
it('renders the color-type icon', () => {
|
|
46
|
+
renderIcon({ ...tc.props, type: 'color', color: '#AABBFF' });
|
|
47
|
+
expect(screen.getByTestId(tc.testId)).toHaveStyle('color: #AABBFF');
|
|
48
|
+
});
|
|
49
|
+
it('renders a warning if type=color and no color is provided', () => {
|
|
50
|
+
renderIcon({ ...tc.props, type: 'color' });
|
|
51
|
+
expect(screen.getByText('Icon with type="color" must have prop color specified.')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
|
|
2
2
|
export declare const iconTypes: readonly ["theme", "white", "dark-gray", "darkish-gray", "gray", "color", "info", "text", "warning", "inherit", "danger", "theme-light", "success"];
|
|
3
|
-
export type IconType =
|
|
3
|
+
export type IconType = typeof iconTypes[number];
|
|
4
4
|
export type IconSize = '2xs' | 'xs' | 'sm' | 'lg' | 'xl' | '2xl' | '1x' | '2x' | '3x' | '4x' | '5x' | '6x' | '7x' | '8x' | '9x' | '10x';
|
|
5
5
|
/**
|
|
6
6
|
* Props for the Icon component that renders customizable icons with various styling options.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Icon';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import '../styles.css';
|
|
4
|
+
import { getQTipData } from '../Tooltip/qTip.utilities';
|
|
5
|
+
import TextField from '../TextField';
|
|
6
|
+
import Button from '../Button';
|
|
7
|
+
const baseClasses = 'tw-flex tw-outline-none tw-rounded-md tw-w-full tw-relative tw-flex-wrap';
|
|
8
|
+
const errorClasses = 'tw-border-sq-danger-color';
|
|
9
|
+
const borderColorClasses = [
|
|
10
|
+
'tw-border-sq-disabled-gray',
|
|
11
|
+
'dark:tw-border-sq-dark-disabled-gray',
|
|
12
|
+
'dark:focus:tw-border-sq-color-dark-dark',
|
|
13
|
+
'dark:active:tw-border-sq-color-dark-dark',
|
|
14
|
+
'focus:tw-border-sq-color-dark',
|
|
15
|
+
'active:tw-border-sq-color-dark',
|
|
16
|
+
].join(' ');
|
|
17
|
+
const fieldBorderRadius = 'tw-rounded-l-md tw-rounded-r-none';
|
|
18
|
+
const fieldClasses = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3' + 'tw-p-1 tw-border-solid tw-border';
|
|
19
|
+
const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
|
|
20
|
+
const lightTheme = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
|
|
21
|
+
/**
|
|
22
|
+
* InputGroup.
|
|
23
|
+
*/
|
|
24
|
+
export const InputGroup = React.forwardRef((props, ref) => {
|
|
25
|
+
const { readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, name, value, placeholder, append = [], extraClassNames = '', id, testId, showError, required, autoComplete, autoFocus, disabled, type, step, min, max, field, maxLength, minLength, ...tooltipProps } = props;
|
|
26
|
+
const tooltipData = getQTipData(tooltipProps);
|
|
27
|
+
const appliedClasses = `${baseClasses} ${extraClassNames}`;
|
|
28
|
+
const fieldAppliedClasses = `${fieldClasses} ${extraClassNames} ${lightTheme} ${darkTheme} ${fieldBorderRadius} ${showError ? errorClasses : borderColorClasses} `;
|
|
29
|
+
const elementsToAppend = append.filter(Boolean);
|
|
30
|
+
return (_jsxs("div", { id: `input-group-${id}`, className: appliedClasses, children: [field ? (_jsx("div", { "data-testid": testId, className: `tw-flex tw-flex-1 tw-cursor-pointer active:tw-z-50 ${fieldAppliedClasses}`, children: field })) : (_jsx(TextField, { testId: testId, readonly: readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, ref: ref, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, maxLength: maxLength, minLength: minLength, extraClassNames: `tw-flex tw-flex-1 tw-w-full focus:tw-z-30 tw-rounded-r-none last:tw-rounded-r-md ${extraClassNames}`, ...tooltipData })), elementsToAppend.map((item, index) => {
|
|
31
|
+
return item?.variant === 'button' ? (_jsx(Button, { extraClassNames: `${index ? 'tw-ml-[-1px]' : 'tw-ml-0'} focus:tw-z-40 focus:tw-border tw-rounded-none last:tw-rounded-r-md`, ...item.buttonProps }, index)) : (_jsx("div", { className: `${borderColorClasses} ${index ? 'tw-ml-[-1px]' : 'tw-ml-0'} tw-flex tw-items-center tw-justify-center tw-rounded-none last:tw-rounded-r-md active:tw-z-30 active:tw-border tw-border`, children: item?.element }, index));
|
|
32
|
+
})] }));
|
|
33
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { InputGroup } from './InputGroup';
|
|
3
|
+
import { QTip } from '../Tooltip/Qtip';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'InputGroup',
|
|
6
|
+
};
|
|
7
|
+
export const AllTextFields = () => {
|
|
8
|
+
const renderAllVariations = () => (_jsxs(_Fragment, { children: [
|
|
9
|
+
_jsxs("div", { className: "light", children: [
|
|
10
|
+
_jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { value: "value provided", append: [
|
|
11
|
+
{
|
|
12
|
+
variant: 'button',
|
|
13
|
+
buttonProps: {
|
|
14
|
+
icon: 'fc-annotate',
|
|
15
|
+
iconStyle: 'theme',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
variant: 'button',
|
|
20
|
+
buttonProps: {
|
|
21
|
+
icon: 'fc-trash',
|
|
22
|
+
iconStyle: 'theme',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
|
|
26
|
+
{
|
|
27
|
+
variant: 'button',
|
|
28
|
+
buttonProps: {
|
|
29
|
+
icon: 'fc-annotate',
|
|
30
|
+
iconStyle: 'theme',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
variant: 'button',
|
|
35
|
+
buttonProps: {
|
|
36
|
+
icon: 'fc-trash',
|
|
37
|
+
iconStyle: 'theme',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
|
|
41
|
+
{
|
|
42
|
+
variant: 'button',
|
|
43
|
+
buttonProps: {
|
|
44
|
+
icon: 'fc-annotate',
|
|
45
|
+
iconStyle: 'theme',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with custom element", append: [
|
|
49
|
+
{
|
|
50
|
+
variant: 'element',
|
|
51
|
+
element: _jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", children: "Custom" }),
|
|
52
|
+
},
|
|
53
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "button input group", field: _jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", onClick: () => console.log('clicked'), children: "custom grouped element" }), append: [
|
|
54
|
+
{
|
|
55
|
+
variant: 'element',
|
|
56
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Custom" })),
|
|
57
|
+
},
|
|
58
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, field: _jsxs("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", children: [
|
|
59
|
+
_jsx("div", { className: "tw-rounded-sm tw-bg-green-400 ", children: "Custom element 1" }), _jsx("div", { className: "tw-rounded-sm tw-bg-red-400 tw-mt-1", onClick: () => console.log('clicked'), children: "Custom element 2" })
|
|
60
|
+
] }), append: [
|
|
61
|
+
{
|
|
62
|
+
variant: 'element',
|
|
63
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Edit" })),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
variant: 'element',
|
|
67
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Edit 2" })),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
variant: 'element',
|
|
71
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Delete" })),
|
|
72
|
+
},
|
|
73
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, placeholder: "inputgroup without any appended element", tooltipPlacement: "top", isHtmlTooltip: false, append: [] }) })
|
|
74
|
+
] }), _jsxs("div", { className: "tw-dark tw-bg-sq-dark-background", children: [
|
|
75
|
+
_jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { value: "value provided", append: [
|
|
76
|
+
{
|
|
77
|
+
variant: 'button',
|
|
78
|
+
buttonProps: {
|
|
79
|
+
icon: 'fc-annotate',
|
|
80
|
+
iconStyle: 'theme',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
variant: 'button',
|
|
85
|
+
buttonProps: {
|
|
86
|
+
icon: 'fc-trash',
|
|
87
|
+
iconStyle: 'theme',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
|
|
91
|
+
{
|
|
92
|
+
variant: 'button',
|
|
93
|
+
buttonProps: {
|
|
94
|
+
icon: 'fc-annotate',
|
|
95
|
+
iconStyle: 'theme',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
variant: 'button',
|
|
100
|
+
buttonProps: {
|
|
101
|
+
icon: 'fc-trash',
|
|
102
|
+
iconStyle: 'theme',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
|
|
106
|
+
{
|
|
107
|
+
variant: 'button',
|
|
108
|
+
buttonProps: {
|
|
109
|
+
icon: 'fc-annotate',
|
|
110
|
+
iconStyle: 'theme',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with custom element", append: [
|
|
114
|
+
{
|
|
115
|
+
variant: 'element',
|
|
116
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Custom" })),
|
|
117
|
+
},
|
|
118
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "button input group", field: _jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", onClick: () => console.log('clicked'), children: "custom grouped element" }), append: [
|
|
119
|
+
{
|
|
120
|
+
variant: 'element',
|
|
121
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Custom" })),
|
|
122
|
+
},
|
|
123
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, field: _jsxs("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", children: [
|
|
124
|
+
_jsx("div", { className: "tw-rounded-sm tw-bg-green-400 dark:tw-text-sq-dark-text", children: "Custom element 1" }), _jsx("div", { className: "tw-rounded-sm tw-bg-red-400 dark:tw-text-sq-dark-text tw-mt-1", onClick: () => console.log('clicked'), children: "Custom element 2" })
|
|
125
|
+
] }), append: [
|
|
126
|
+
{
|
|
127
|
+
variant: 'element',
|
|
128
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Edit" })),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
variant: 'element',
|
|
132
|
+
element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Delete" })),
|
|
133
|
+
},
|
|
134
|
+
] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, placeholder: "inputgroup without any appended element", tooltipPlacement: "top", isHtmlTooltip: false, append: [] }) })
|
|
135
|
+
] })
|
|
136
|
+
] }));
|
|
137
|
+
return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
|
|
138
|
+
_jsx(QTip, {}), _jsxs("div", { className: "color_topic", children: [
|
|
139
|
+
_jsx("b", { children: "Topic Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_analysis", children: [
|
|
140
|
+
_jsx("b", { children: "Analysis Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_datalab", children: [
|
|
141
|
+
_jsx("b", { children: "Datalab Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_vantage", children: [
|
|
142
|
+
_jsx("b", { children: "Vantage Colors" }), renderAllVariations()] })
|
|
143
|
+
] }));
|
|
144
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { InputGroup } from './InputGroup';
|
|
4
|
+
describe('InputGroup', () => {
|
|
5
|
+
const defaultProps = {
|
|
6
|
+
value: 'with tooltip',
|
|
7
|
+
append: [
|
|
8
|
+
{
|
|
9
|
+
variant: 'button',
|
|
10
|
+
buttonProps: {
|
|
11
|
+
icon: 'fc-annotate',
|
|
12
|
+
iconStyle: 'theme',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
extraClassNames: 'extra-class',
|
|
17
|
+
tooltip: 'Tooltip title',
|
|
18
|
+
tooltipDelay: 0,
|
|
19
|
+
id: 'input-group-id',
|
|
20
|
+
testId: 'input-group-test-id',
|
|
21
|
+
};
|
|
22
|
+
it('renders without crashing', () => {
|
|
23
|
+
const { getByTestId } = render(_jsx(InputGroup, { ...defaultProps }));
|
|
24
|
+
expect(getByTestId('input-group-test-id')).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
it('applies the correct classes', () => {
|
|
27
|
+
const { getByTestId } = render(_jsx(InputGroup, { ...defaultProps }));
|
|
28
|
+
const inputGroup = getByTestId('input-group-test-id');
|
|
29
|
+
expect(inputGroup).toHaveClass('tw-flex');
|
|
30
|
+
expect(inputGroup).toHaveClass('tw-outline-none');
|
|
31
|
+
expect(inputGroup).toHaveClass('extra-class');
|
|
32
|
+
});
|
|
33
|
+
it('renders append items', () => {
|
|
34
|
+
const { getByRole } = render(_jsx(InputGroup, { ...defaultProps }));
|
|
35
|
+
expect(getByRole('button')).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
it('renders input element', () => {
|
|
38
|
+
const { container } = render(_jsx(InputGroup, { ...defaultProps }));
|
|
39
|
+
expect(container.querySelector('input[type="text"]')).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InputGroup as default } from './InputGroup';
|