@seeqdev/qomponents 0.0.184 → 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/dist/src/Accordion/Accordion.d.ts +4 -0
- package/dist/src/Accordion/Accordion.js +8 -0
- package/dist/src/Accordion/Accordion.stories.d.ts +5 -0
- package/dist/src/Accordion/Accordion.stories.js +96 -0
- package/dist/src/Accordion/Accordion.test.d.ts +1 -0
- package/dist/src/Accordion/Accordion.test.js +54 -0
- package/dist/src/Accordion/Accordion.types.d.ts +86 -0
- package/dist/src/Accordion/Accordion.types.js +1 -0
- package/dist/src/Accordion/index.d.ts +1 -0
- package/dist/src/Accordion/index.js +1 -0
- package/dist/src/Alert/Alert.d.ts +7 -0
- package/dist/src/Alert/Alert.js +33 -0
- package/dist/src/Alert/Alert.stories.d.ts +14 -0
- package/dist/src/Alert/Alert.stories.js +72 -0
- package/dist/src/Alert/Alert.test.d.ts +1 -0
- package/dist/src/Alert/Alert.test.js +49 -0
- package/dist/src/Alert/Alert.types.d.ts +62 -0
- package/dist/src/Alert/Alert.types.js +1 -0
- package/dist/src/Alert/index.d.ts +1 -0
- package/dist/src/Alert/index.js +1 -0
- package/dist/src/Button/Button.d.ts +10 -0
- package/dist/src/Button/Button.js +107 -0
- package/dist/src/Button/Button.stories.d.ts +9 -0
- package/dist/src/Button/Button.stories.js +74 -0
- package/dist/src/Button/Button.test.d.ts +1 -0
- package/dist/src/Button/Button.test.js +65 -0
- package/dist/src/Button/Button.types.d.ts +148 -0
- package/dist/src/Button/Button.types.js +4 -0
- package/dist/src/Button/index.d.ts +1 -0
- package/dist/src/Button/index.js +1 -0
- package/dist/src/ButtonGroup/ButtonGroup.d.ts +7 -0
- package/dist/src/ButtonGroup/ButtonGroup.js +34 -0
- package/dist/src/ButtonGroup/ButtonGroup.stories.d.ts +5 -0
- package/dist/src/ButtonGroup/ButtonGroup.stories.js +328 -0
- package/dist/src/ButtonGroup/ButtonGroup.test.d.ts +1 -0
- package/dist/src/ButtonGroup/ButtonGroup.test.js +65 -0
- package/dist/src/ButtonGroup/ButtonGroup.types.d.ts +80 -0
- package/dist/src/ButtonGroup/ButtonGroup.types.js +1 -0
- package/dist/src/ButtonGroup/index.d.ts +1 -0
- package/dist/src/ButtonGroup/index.js +1 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.d.ts +4 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.js +46 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.stories.d.ts +5 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.stories.js +119 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.test.d.ts +1 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.types.d.ts +232 -0
- package/dist/src/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -0
- package/dist/src/ButtonWithDropdown/index.d.ts +1 -0
- package/dist/src/ButtonWithDropdown/index.js +1 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.d.ts +4 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.js +54 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.stories.d.ts +5 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.stories.js +51 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.test.d.ts +1 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.test.js +80 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.types.d.ts +134 -0
- package/dist/src/ButtonWithPopover/ButtonWithPopover.types.js +1 -0
- package/dist/src/ButtonWithPopover/index.d.ts +1 -0
- package/dist/src/ButtonWithPopover/index.js +1 -0
- package/dist/src/Carousel/Carousel.d.ts +9 -0
- package/dist/src/Carousel/Carousel.js +80 -0
- package/dist/src/Carousel/Carousel.stories.d.ts +5 -0
- package/dist/src/Carousel/Carousel.stories.js +100 -0
- package/dist/src/Carousel/Carousel.test.d.ts +1 -0
- package/dist/src/Carousel/Carousel.test.js +47 -0
- package/dist/src/Carousel/Carousel.types.d.ts +85 -0
- package/dist/src/Carousel/Carousel.types.js +1 -0
- package/dist/src/Carousel/index.d.ts +1 -0
- package/dist/src/Carousel/index.js +1 -0
- package/dist/src/Checkbox/Checkbox.d.ts +7 -0
- package/dist/src/Checkbox/Checkbox.js +24 -0
- package/dist/src/Checkbox/Checkbox.stories.d.ts +5 -0
- package/dist/src/Checkbox/Checkbox.stories.js +21 -0
- package/dist/src/Checkbox/Checkbox.test.d.ts +1 -0
- package/dist/src/Checkbox/Checkbox.test.js +93 -0
- package/dist/src/Checkbox/Checkbox.types.d.ts +91 -0
- package/dist/src/Checkbox/Checkbox.types.js +1 -0
- package/dist/src/Checkbox/index.d.ts +1 -0
- package/dist/src/Checkbox/index.js +1 -0
- package/dist/src/Collapse/Collapse.d.ts +4 -0
- package/dist/src/Collapse/Collapse.js +16 -0
- package/dist/src/Collapse/Collapse.stories.d.ts +5 -0
- package/dist/src/Collapse/Collapse.stories.js +28 -0
- package/dist/src/Collapse/Collapse.test.d.ts +1 -0
- package/dist/src/Collapse/Collapse.test.js +16 -0
- package/dist/src/Collapse/Collapse.types.d.ts +18 -0
- package/dist/src/Collapse/Collapse.types.js +1 -0
- package/dist/src/Collapse/index.d.ts +1 -0
- package/dist/src/Collapse/index.js +1 -0
- package/dist/src/Icon/Icon.d.ts +10 -0
- package/dist/src/Icon/Icon.js +55 -0
- package/dist/src/Icon/Icon.stories.d.ts +5 -0
- package/dist/src/Icon/Icon.stories.js +31 -0
- package/dist/src/Icon/Icon.test.d.ts +1 -0
- package/dist/src/Icon/Icon.test.js +54 -0
- package/dist/src/Icon/Icon.types.d.ts +90 -0
- package/dist/src/Icon/Icon.types.js +15 -0
- package/dist/src/Icon/index.d.ts +1 -0
- package/dist/src/Icon/index.js +1 -0
- package/dist/src/InputGroup/InputGroup.d.ts +7 -0
- package/dist/src/InputGroup/InputGroup.js +33 -0
- package/dist/src/InputGroup/InputGroup.stories.d.ts +5 -0
- package/dist/src/InputGroup/InputGroup.stories.js +144 -0
- package/dist/src/InputGroup/InputGroup.test.d.ts +1 -0
- package/dist/src/InputGroup/InputGroup.test.js +41 -0
- package/dist/src/InputGroup/InputGroup.types.d.ts +61 -0
- package/dist/src/InputGroup/InputGroup.types.js +1 -0
- package/dist/src/InputGroup/index.d.ts +2 -0
- package/dist/src/InputGroup/index.js +1 -0
- package/dist/src/Modal/Modal.d.ts +5 -0
- package/dist/src/Modal/Modal.js +86 -0
- package/dist/src/Modal/Modal.stories.d.ts +10 -0
- package/dist/src/Modal/Modal.stories.js +79 -0
- package/dist/src/Modal/Modal.test.d.ts +1 -0
- package/dist/src/Modal/Modal.test.js +107 -0
- package/dist/src/Modal/Modal.types.d.ts +244 -0
- package/dist/src/Modal/Modal.types.js +1 -0
- package/dist/src/Modal/index.d.ts +1 -0
- package/dist/src/Modal/index.js +1 -0
- package/dist/src/ProgressBar/ProgressBar.d.ts +4 -0
- package/dist/src/ProgressBar/ProgressBar.js +71 -0
- package/dist/src/ProgressBar/ProgressBar.stories.d.ts +5 -0
- package/dist/src/ProgressBar/ProgressBar.stories.js +46 -0
- package/dist/src/ProgressBar/ProgressBar.test.d.ts +1 -0
- package/dist/src/ProgressBar/ProgressBar.test.js +42 -0
- package/dist/src/ProgressBar/ProgressBar.types.d.ts +77 -0
- package/dist/src/ProgressBar/ProgressBar.types.js +1 -0
- package/dist/src/ProgressBar/index.d.ts +1 -0
- package/dist/src/ProgressBar/index.js +1 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.d.ts +4 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.js +41 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.stories.d.ts +5 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.stories.js +73 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.test.d.ts +1 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.types.d.ts +159 -0
- package/dist/src/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -0
- package/dist/src/SeeqActionDropdown/index.d.ts +1 -0
- package/dist/src/SeeqActionDropdown/index.js +1 -0
- package/dist/src/SeeqActionDropdown/variants.d.ts +5 -0
- package/dist/src/SeeqActionDropdown/variants.js +34 -0
- package/dist/src/Select/Select.d.ts +15 -0
- package/dist/src/Select/Select.js +171 -0
- package/dist/src/Select/Select.stories.d.ts +5 -0
- package/dist/src/Select/Select.stories.js +50 -0
- package/dist/src/Select/Select.test.d.ts +1 -0
- package/dist/src/Select/Select.test.js +176 -0
- package/dist/src/Select/Select.types.d.ts +220 -0
- package/dist/src/Select/Select.types.js +1 -0
- package/dist/src/Select/index.d.ts +2 -0
- package/dist/src/Select/index.js +2 -0
- package/dist/src/Slider/Slider.d.ts +6 -0
- package/dist/src/Slider/Slider.js +11 -0
- package/dist/src/Slider/Slider.stories.d.ts +5 -0
- package/dist/src/Slider/Slider.stories.js +37 -0
- package/dist/src/Slider/Slider.test.d.ts +1 -0
- package/dist/src/Slider/Slider.test.js +31 -0
- package/dist/src/Slider/Slider.types.d.ts +84 -0
- package/dist/src/Slider/Slider.types.js +1 -0
- package/dist/src/Slider/index.d.ts +1 -0
- package/dist/src/Slider/index.js +1 -0
- package/dist/src/SvgIcon/SvgIcon.d.ts +20 -0
- package/dist/src/SvgIcon/SvgIcon.js +27 -0
- package/dist/src/SvgIcon/SvgIcon.stories.d.ts +5 -0
- package/dist/src/SvgIcon/SvgIcon.stories.js +26 -0
- package/dist/src/SvgIcon/SvgIcon.test.d.ts +1 -0
- package/dist/src/SvgIcon/SvgIcon.test.js +40 -0
- package/dist/src/SvgIcon/SvgIcon.types.d.ts +75 -0
- package/dist/src/SvgIcon/SvgIcon.types.js +2 -0
- package/dist/src/SvgIcon/index.d.ts +1 -0
- package/dist/src/SvgIcon/index.js +1 -0
- package/dist/src/Tabs/Tabs.d.ts +4 -0
- package/dist/src/Tabs/Tabs.js +18 -0
- package/dist/src/Tabs/Tabs.stories.d.ts +5 -0
- package/dist/src/Tabs/Tabs.stories.js +83 -0
- package/dist/src/Tabs/Tabs.test.d.ts +1 -0
- package/dist/src/Tabs/Tabs.test.js +91 -0
- package/dist/src/Tabs/Tabs.types.d.ts +100 -0
- package/dist/src/Tabs/Tabs.types.js +1 -0
- package/dist/src/Tabs/index.d.ts +1 -0
- package/dist/src/Tabs/index.js +1 -0
- package/dist/src/TextArea/TextArea.d.ts +7 -0
- package/dist/src/TextArea/TextArea.js +54 -0
- package/dist/src/TextArea/TextArea.stories.d.ts +5 -0
- package/dist/src/TextArea/TextArea.stories.js +21 -0
- package/dist/src/TextArea/TextArea.test.d.ts +1 -0
- package/dist/src/TextArea/TextArea.test.js +129 -0
- package/dist/src/TextArea/TextArea.types.d.ts +115 -0
- package/dist/src/TextArea/TextArea.types.js +1 -0
- package/dist/src/TextArea/index.d.ts +1 -0
- package/dist/src/TextArea/index.js +1 -0
- package/dist/src/TextField/TextField.d.ts +7 -0
- package/dist/src/TextField/TextField.js +85 -0
- package/dist/src/TextField/TextField.stories.d.ts +5 -0
- package/dist/src/TextField/TextField.stories.js +30 -0
- package/dist/src/TextField/TextField.test.d.ts +1 -0
- package/dist/src/TextField/TextField.test.js +40 -0
- package/dist/src/TextField/TextField.types.d.ts +198 -0
- package/dist/src/TextField/TextField.types.js +1 -0
- package/dist/src/TextField/index.d.ts +1 -0
- package/dist/src/TextField/index.js +1 -0
- package/dist/src/ToolbarButton/ToolbarButton.d.ts +3 -0
- package/dist/src/ToolbarButton/ToolbarButton.js +58 -0
- package/dist/src/ToolbarButton/ToolbarButton.stories.d.ts +5 -0
- package/dist/src/ToolbarButton/ToolbarButton.stories.js +63 -0
- package/dist/src/ToolbarButton/ToolbarButton.test.d.ts +1 -0
- package/dist/src/ToolbarButton/ToolbarButton.test.js +89 -0
- package/dist/src/ToolbarButton/ToolbarButton.types.d.ts +122 -0
- package/dist/src/ToolbarButton/ToolbarButton.types.js +1 -0
- package/dist/src/ToolbarButton/index.d.ts +1 -0
- package/dist/src/ToolbarButton/index.js +1 -0
- package/dist/src/Tooltip/QTip.stories.d.ts +5 -0
- package/dist/src/Tooltip/QTip.stories.js +22 -0
- package/dist/src/Tooltip/QTip.types.d.ts +13 -0
- package/dist/src/Tooltip/QTip.types.js +1 -0
- package/dist/src/Tooltip/QTipPerformance.stories.d.ts +5 -0
- package/dist/src/Tooltip/QTipPerformance.stories.js +27 -0
- package/dist/src/Tooltip/Qtip.d.ts +26 -0
- package/dist/src/Tooltip/Qtip.js +168 -0
- package/dist/src/Tooltip/Tooltip.d.ts +13 -0
- package/dist/src/Tooltip/Tooltip.js +34 -0
- package/dist/src/Tooltip/Tooltip.stories.d.ts +5 -0
- package/dist/src/Tooltip/Tooltip.stories.js +20 -0
- package/dist/src/Tooltip/Tooltip.types.d.ts +22 -0
- package/dist/src/Tooltip/Tooltip.types.js +2 -0
- package/dist/src/Tooltip/TooltipPerformance.stories.d.ts +5 -0
- package/dist/src/Tooltip/TooltipPerformance.stories.js +25 -0
- package/dist/src/Tooltip/index.d.ts +2 -0
- package/dist/src/Tooltip/index.js +2 -0
- package/dist/src/Tooltip/qTip.utilities.d.ts +3 -0
- package/dist/src/Tooltip/qTip.utilities.js +10 -0
- package/dist/src/index.d.ts +46 -0
- package/dist/src/index.js +47 -0
- package/dist/src/setupTests.d.ts +1 -0
- package/dist/src/setupTests.js +5 -0
- package/dist/src/types.d.ts +27 -0
- package/dist/src/types.js +25 -0
- package/dist/src/utils/browserId.d.ts +9 -0
- package/dist/src/utils/browserId.js +28 -0
- package/dist/src/utils/svg.d.ts +15 -0
- package/dist/src/utils/svg.js +19 -0
- package/dist/src/utils/validateStyleDimension.d.ts +2 -0
- package/dist/src/utils/validateStyleDimension.js +13 -0
- package/dist/src/utils/validateStyleDimension.test.d.ts +1 -0
- package/dist/src/utils/validateStyleDimension.test.js +19 -0
- package/package.json +11 -5
|
@@ -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,91 @@
|
|
|
1
|
+
import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
|
|
2
|
+
type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
3
|
+
export interface CheckboxProps extends TooltipComponentProps {
|
|
4
|
+
/**
|
|
5
|
+
* Additional CSS classes to apply to the checkbox container.
|
|
6
|
+
* These classes are combined with the component's built-in styling.
|
|
7
|
+
* Use this to customize the overall appearance of the checkbox wrapper.
|
|
8
|
+
*/
|
|
9
|
+
extraClassNames?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Additional CSS classes to apply specifically to the label element.
|
|
12
|
+
* Use this to customize the styling of the text label that appears next to the checkbox.
|
|
13
|
+
* Does not affect the input element itself.
|
|
14
|
+
*/
|
|
15
|
+
extraLabelClassNames?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Determines the type of input control to render:
|
|
18
|
+
* - `checkbox`: Standard checkbox that can be checked/unchecked independently
|
|
19
|
+
* - `radio`: Radio button that is typically part of a group where only one can be selected
|
|
20
|
+
* @default 'checkbox'
|
|
21
|
+
*/
|
|
22
|
+
type?: 'radio' | 'checkbox';
|
|
23
|
+
/**
|
|
24
|
+
* HTML ID attribute for the input element.
|
|
25
|
+
* Should be unique across the entire page for proper HTML semantics and accessibility.
|
|
26
|
+
* If not provided, a random ID will be generated automatically.
|
|
27
|
+
* Used for associating the label with the input for accessibility.
|
|
28
|
+
*/
|
|
29
|
+
id?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Name attribute for the input element, used for form submission and grouping.
|
|
32
|
+
* For radio buttons, all options in the same group should share the same name.
|
|
33
|
+
* For checkboxes, this identifies the field when the form is submitted.
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Controls whether the checkbox/radio button is currently checked.
|
|
38
|
+
* Use this for controlled components where you manage the state externally.
|
|
39
|
+
* When provided, the component becomes controlled and you must handle state changes via `onChange`.
|
|
40
|
+
*/
|
|
41
|
+
checked?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Sets the initial checked state for uncontrolled components.
|
|
44
|
+
* Only used when `checked` is not provided (uncontrolled mode).
|
|
45
|
+
* The component will manage its own state after the initial render.
|
|
46
|
+
*/
|
|
47
|
+
defaultChecked?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The value associated with this checkbox/radio button.
|
|
50
|
+
* This is the value that will be submitted with the form when the input is checked.
|
|
51
|
+
* For radio buttons, each option in a group should have a unique value.
|
|
52
|
+
*/
|
|
53
|
+
value?: string | number;
|
|
54
|
+
/**
|
|
55
|
+
* The text or content to display as the label next to the checkbox/radio button.
|
|
56
|
+
* Can be a simple string or any React element for more complex label content.
|
|
57
|
+
* Clicking on this label will toggle the input due to proper accessibility association.
|
|
58
|
+
*/
|
|
59
|
+
label?: string | React.ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Callback function triggered when the checkbox/radio button state changes.
|
|
62
|
+
* Receives the change event which contains the new checked state and value.
|
|
63
|
+
* Use this to update your component state when in controlled mode.
|
|
64
|
+
*/
|
|
65
|
+
onChange?: React.ChangeEventHandler<FormControlElement>;
|
|
66
|
+
/**
|
|
67
|
+
* Callback function triggered when a key is pressed while the input has focus.
|
|
68
|
+
* Useful for implementing custom keyboard navigation or shortcuts.
|
|
69
|
+
* Receives the keyboard event with details about the pressed key.
|
|
70
|
+
*/
|
|
71
|
+
onKeyDown?: React.KeyboardEventHandler<FormControlElement>;
|
|
72
|
+
/**
|
|
73
|
+
* Callback function triggered when the input element is clicked.
|
|
74
|
+
* This fires before the onChange event and can be used for additional click handling.
|
|
75
|
+
* Note that clicking the associated label will also trigger this event.
|
|
76
|
+
*/
|
|
77
|
+
onClick?: React.MouseEventHandler<FormControlElement>;
|
|
78
|
+
/**
|
|
79
|
+
* When true, disables the checkbox/radio button preventing user interaction.
|
|
80
|
+
* Disabled inputs appear visually dimmed and do not respond to user actions.
|
|
81
|
+
* The input will not be included in form submissions when disabled.
|
|
82
|
+
*/
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Test ID attribute for the input element used in automated testing.
|
|
86
|
+
* Applied to the `data-testid` attribute for element selection in test suites.
|
|
87
|
+
* Helps identify this specific checkbox/radio button in tests.
|
|
88
|
+
*/
|
|
89
|
+
testId?: string;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox as default } from './Checkbox';
|
|
@@ -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 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the Collapse component that creates smooth expand/collapse animations.
|
|
3
|
+
*/
|
|
4
|
+
export interface CollapseProps {
|
|
5
|
+
/**
|
|
6
|
+
* Controls whether the collapse content is visible and expanded.
|
|
7
|
+
* When true, the content smoothly expands to full height.
|
|
8
|
+
* When false, the content smoothly collapses to zero height.
|
|
9
|
+
* Use this to control the collapse state from parent components.
|
|
10
|
+
*/
|
|
11
|
+
isVisible: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Content to display inside the collapsible area.
|
|
14
|
+
* Can be any React elements that you want to show/hide with animation.
|
|
15
|
+
* The content will be measured and animated when expanding or collapsing.
|
|
16
|
+
*/
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Collapse';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Collapse';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { IconProps } from './Icon.types';
|
|
4
|
+
/**
|
|
5
|
+
* Icon:
|
|
6
|
+
* - access to Seeq custom icons by providing the desired icon
|
|
7
|
+
* - leverage "type" to style your icon
|
|
8
|
+
*/
|
|
9
|
+
declare const Icon: React.FunctionComponent<IconProps>;
|
|
10
|
+
export default Icon;
|
|
@@ -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 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
|
|
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 = typeof iconTypes[number];
|
|
4
|
+
export type IconSize = '2xs' | 'xs' | 'sm' | 'lg' | 'xl' | '2xl' | '1x' | '2x' | '3x' | '4x' | '5x' | '6x' | '7x' | '8x' | '9x' | '10x';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the Icon component that renders customizable icons with various styling options.
|
|
7
|
+
* Extends TooltipComponentProps to support tooltip functionality on the icon.
|
|
8
|
+
*/
|
|
9
|
+
export interface IconProps extends TooltipComponentProps {
|
|
10
|
+
/**
|
|
11
|
+
* Icon class name to display, typically from FontAwesome.
|
|
12
|
+
* Examples: 'fc-zoom', 'fc-delete', 'fc-save'. This determines which icon is rendered.
|
|
13
|
+
*/
|
|
14
|
+
icon: string;
|
|
15
|
+
/**
|
|
16
|
+
* Custom prefix for the icon class when not using standard FontAwesome icons.
|
|
17
|
+
* By default, icons are prefixed with 'fa-sharp fa-regular', but some icons
|
|
18
|
+
* from different icon sets require specific prefixes. Use this to override the default.
|
|
19
|
+
*/
|
|
20
|
+
iconPrefix?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Visual style type that determines the icon's color and appearance:
|
|
23
|
+
* - `theme`: Uses primary theme colors (default)
|
|
24
|
+
* - `white`: Pure white color
|
|
25
|
+
* - `text`: Uses standard text color
|
|
26
|
+
* - `dark-gray`: Dark gray color
|
|
27
|
+
* - `darkish-gray`: Medium-dark gray color
|
|
28
|
+
* - `gray`: Standard gray color
|
|
29
|
+
* - `color`: Uses custom color specified in `color` prop
|
|
30
|
+
* - `info`: Blue informational color
|
|
31
|
+
* - `warning`: Yellow/orange warning color
|
|
32
|
+
* - `danger`: Red error/danger color
|
|
33
|
+
* - `success`: Green success color
|
|
34
|
+
* - `theme-light`: Lighter version of theme color
|
|
35
|
+
* - `inherit`: Inherits color from parent element
|
|
36
|
+
* @default 'theme'
|
|
37
|
+
*/
|
|
38
|
+
type?: IconType;
|
|
39
|
+
/**
|
|
40
|
+
* Icon size, mapped to FontAwesome sizing classes so it works for both FA and FontCustom icons.
|
|
41
|
+
* Examples: 'sm', 'lg', 'xl', '2xl', '1x'...'10x', 'xs', '2xs'.
|
|
42
|
+
*/
|
|
43
|
+
size?: IconSize;
|
|
44
|
+
/**
|
|
45
|
+
* Custom color value for the icon when `type` is set to 'color'.
|
|
46
|
+
* Can be any valid CSS color (hex, rgb, color names, etc.).
|
|
47
|
+
* This property is required when type is 'color'.
|
|
48
|
+
*/
|
|
49
|
+
color?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Callback function triggered when the icon is clicked.
|
|
52
|
+
* Receives the mouse event as a parameter. Use this to make icons interactive
|
|
53
|
+
* for actions like opening menus, triggering functions, or navigation.
|
|
54
|
+
*/
|
|
55
|
+
onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => any;
|
|
56
|
+
/**
|
|
57
|
+
* Additional CSS classes to apply to the icon element.
|
|
58
|
+
* Use this to customize the icon's appearance, spacing, or behavior beyond built-in options.
|
|
59
|
+
*/
|
|
60
|
+
extraClassNames?: string;
|
|
61
|
+
/**
|
|
62
|
+
* HTML ID attribute for the icon element.
|
|
63
|
+
* Should be unique across the page for proper HTML semantics and accessibility.
|
|
64
|
+
*/
|
|
65
|
+
id?: string;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Use `size="lg"` instead.
|
|
68
|
+
*/
|
|
69
|
+
large?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated Use `size="sm"` instead.
|
|
72
|
+
*/
|
|
73
|
+
small?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Test ID attribute for the icon element used in automated testing.
|
|
76
|
+
* Applied to the `data-testid` attribute for element selection in test suites.
|
|
77
|
+
*/
|
|
78
|
+
testId?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Custom identifier placed in the `data-customid` attribute on the icon element.
|
|
81
|
+
* Useful for identifying the specific icon in event handlers when multiple icons
|
|
82
|
+
* share the same click handler. Helps distinguish which icon was clicked.
|
|
83
|
+
*/
|
|
84
|
+
customId?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Numeric value associated with the icon, purpose depends on specific use case.
|
|
87
|
+
* Can be used for ordering, counting, or any numeric data related to the icon.
|
|
88
|
+
*/
|
|
89
|
+
number?: number;
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Icon';
|
|
@@ -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
|
+
});
|