@seeqdev/qomponents 0.0.132 → 0.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -135
- package/dist/Accordion/Accordion.js +8 -8
- package/dist/Accordion/Accordion.stories.js +114 -114
- package/dist/Accordion/Accordion.test.js +54 -54
- package/dist/Accordion/Accordion.types.js +1 -1
- package/dist/Accordion/index.js +1 -1
- package/dist/Alert/Alert.js +33 -33
- package/dist/Alert/Alert.stories.js +51 -51
- package/dist/Alert/Alert.test.js +50 -50
- package/dist/Alert/Alert.types.js +1 -1
- package/dist/Alert/index.js +1 -1
- package/dist/Button/Button.js +91 -91
- package/dist/Button/Button.stories.js +99 -99
- package/dist/Button/Button.test.js +48 -48
- package/dist/Button/Button.types.js +4 -4
- package/dist/Button/index.js +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +32 -32
- package/dist/ButtonGroup/ButtonGroup.stories.js +384 -384
- package/dist/ButtonGroup/ButtonGroup.test.js +66 -66
- package/dist/ButtonGroup/ButtonGroup.types.js +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js +59 -59
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +142 -142
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -92
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -1
- package/dist/ButtonWithDropdown/index.js +1 -1
- package/dist/ButtonWithPopover/ButtonWithPopover.js +61 -61
- package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +74 -74
- package/dist/ButtonWithPopover/ButtonWithPopover.test.js +81 -81
- package/dist/ButtonWithPopover/ButtonWithPopover.types.js +1 -1
- package/dist/ButtonWithPopover/index.js +1 -1
- package/dist/Carousel/Carousel.js +66 -66
- package/dist/Carousel/Carousel.stories.js +114 -114
- package/dist/Carousel/Carousel.test.js +47 -47
- package/dist/Carousel/Carousel.types.js +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/Checkbox/Checkbox.js +25 -25
- package/dist/Checkbox/Checkbox.stories.js +33 -33
- package/dist/Checkbox/Checkbox.test.js +93 -93
- package/dist/Checkbox/Checkbox.types.js +1 -1
- package/dist/Checkbox/index.js +1 -1
- package/dist/Collapse/Collapse.js +17 -17
- package/dist/Collapse/Collapse.stories.js +36 -36
- package/dist/Collapse/Collapse.test.js +18 -18
- package/dist/Collapse/Collapse.types.js +1 -1
- package/dist/Collapse/index.js +1 -1
- package/dist/Icon/Icon.js +54 -54
- package/dist/Icon/Icon.stories.js +46 -46
- package/dist/Icon/Icon.test.js +54 -54
- package/dist/Icon/Icon.types.js +15 -15
- package/dist/Icon/index.js +1 -1
- package/dist/InputGroup/InputGroup.js +31 -31
- package/dist/InputGroup/InputGroup.stories.js +167 -167
- package/dist/InputGroup/InputGroup.test.js +42 -42
- package/dist/InputGroup/InputGroup.types.js +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/Modal/Modal.js +99 -99
- package/dist/Modal/Modal.js.map +1 -1
- package/dist/Modal/Modal.stories.js +126 -126
- package/dist/Modal/Modal.test.js +107 -107
- package/dist/Modal/Modal.types.js +1 -1
- package/dist/Modal/index.js +1 -1
- package/dist/ProgressBar/ProgressBar.js +49 -29
- package/dist/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.stories.js +80 -72
- package/dist/ProgressBar/ProgressBar.stories.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.test.js +43 -37
- package/dist/ProgressBar/ProgressBar.test.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.types.d.ts +2 -0
- package/dist/ProgressBar/ProgressBar.types.js +1 -1
- package/dist/ProgressBar/index.js +1 -1
- package/dist/SeeqActionDropdown/SeeqActionDropdown.js +47 -47
- package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +79 -79
- package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -72
- package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -1
- package/dist/SeeqActionDropdown/index.js +1 -1
- package/dist/SeeqActionDropdown/variants.js +22 -22
- package/dist/Select/Select.js +173 -173
- package/dist/Select/Select.stories.js +79 -79
- package/dist/Select/Select.test.js +181 -181
- package/dist/Select/Select.types.js +1 -1
- package/dist/Select/index.js +2 -2
- package/dist/Slider/Slider.js +12 -12
- package/dist/Slider/Slider.stories.js +57 -57
- package/dist/Slider/Slider.test.js +32 -32
- package/dist/Slider/Slider.types.js +1 -1
- package/dist/Slider/index.js +1 -1
- package/dist/Tabs/Tabs.js +21 -21
- package/dist/Tabs/Tabs.stories.js +90 -90
- package/dist/Tabs/Tabs.test.js +90 -90
- package/dist/Tabs/Tabs.types.js +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/TextArea/TextArea.js +24 -24
- package/dist/TextArea/TextArea.stories.js +45 -45
- package/dist/TextArea/TextArea.test.js +67 -67
- package/dist/TextArea/TextArea.types.js +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/TextField/TextField.js +78 -78
- package/dist/TextField/TextField.stories.js +69 -69
- package/dist/TextField/TextField.test.js +38 -38
- package/dist/TextField/TextField.types.js +1 -1
- package/dist/TextField/index.js +1 -1
- package/dist/ToolbarButton/ToolbarButton.js +74 -74
- package/dist/ToolbarButton/ToolbarButton.stories.js +93 -93
- package/dist/ToolbarButton/ToolbarButton.test.js +92 -92
- package/dist/ToolbarButton/ToolbarButton.types.js +1 -1
- package/dist/ToolbarButton/index.js +1 -1
- package/dist/Tooltip/QTip.stories.js +44 -44
- package/dist/Tooltip/QTip.types.js +1 -1
- package/dist/Tooltip/QTipPerformance.stories.js +29 -29
- package/dist/Tooltip/Qtip.js +167 -167
- package/dist/Tooltip/Tooltip.js +35 -35
- package/dist/Tooltip/Tooltip.stories.js +31 -31
- package/dist/Tooltip/Tooltip.types.js +2 -2
- package/dist/Tooltip/TooltipPerformance.stories.js +29 -29
- package/dist/Tooltip/index.js +2 -2
- package/dist/Tooltip/qTip.utilities.js +10 -10
- package/dist/example/.eslintrc.cjs +14 -14
- package/dist/example/README.md +33 -33
- package/dist/example/index.html +13 -13
- package/dist/example/package.json +30 -30
- package/dist/example/src/ComplexSelectExample.tsx +81 -81
- package/dist/example/src/Example.tsx +408 -408
- package/dist/example/src/index.css +102 -102
- package/dist/example/src/main.tsx +10 -10
- package/dist/example/src/vite-env.d.ts +1 -1
- package/dist/example/tsconfig.json +33 -33
- package/dist/example/tsconfig.node.json +12 -12
- package/dist/example/vite.config.ts +12 -12
- package/dist/index.esm.js +1229 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1229 -31
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3714 -3709
- package/dist/types.js +1 -1
- package/dist/utils/browserId.js +28 -28
- package/dist/utils/svg.js +19 -19
- package/dist/utils/validateStyleDimension.js +13 -13
- package/dist/utils/validateStyleDimension.test.js +19 -19
- package/package.json +88 -86
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import Select from './Select';
|
|
6
|
-
describe('Select', () => {
|
|
7
|
-
class Context {
|
|
8
|
-
testId = 'selectTestId';
|
|
9
|
-
label = 'button label';
|
|
10
|
-
options = [
|
|
11
|
-
{ label: 'vanilla', value: 'a' },
|
|
12
|
-
{ label: 'chocolate', value: 'b' },
|
|
13
|
-
{ label: 'strawberry', value: 'c' },
|
|
14
|
-
];
|
|
15
|
-
otherOptions = [
|
|
16
|
-
{ label: 'red', value: 'd' },
|
|
17
|
-
{ label: 'green', value: 'e' },
|
|
18
|
-
];
|
|
19
|
-
groupedOptions = [
|
|
20
|
-
{
|
|
21
|
-
label: 'Ice Cream Flavors',
|
|
22
|
-
options: this.options,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: 'Colors',
|
|
26
|
-
options: this.otherOptions,
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
props = {
|
|
30
|
-
onChange: jest.fn(),
|
|
31
|
-
options: this.options,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
let tc;
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
tc = new Context();
|
|
37
|
-
});
|
|
38
|
-
const openSelect = async () => {
|
|
39
|
-
const select = document.querySelector(`.specOpenSelect`);
|
|
40
|
-
await userEvent.click(select);
|
|
41
|
-
};
|
|
42
|
-
const renderSelect = (props) => render(React.createElement("div", { id: "wrapper" },
|
|
43
|
-
React.createElement(Select, { ...props })));
|
|
44
|
-
it('renders the select', () => {
|
|
45
|
-
renderSelect(tc.props);
|
|
46
|
-
expect(document.querySelector('.specSelectControl')).toBeInTheDocument();
|
|
47
|
-
});
|
|
48
|
-
it('displays options', async () => {
|
|
49
|
-
renderSelect(tc.props);
|
|
50
|
-
await openSelect();
|
|
51
|
-
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(3);
|
|
52
|
-
});
|
|
53
|
-
it('displays grouped options', async () => {
|
|
54
|
-
renderSelect({ ...tc.props, options: tc.groupedOptions });
|
|
55
|
-
await openSelect();
|
|
56
|
-
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(5);
|
|
57
|
-
expect(document.querySelectorAll('.specSelectGroupHeading')).toHaveLength(2);
|
|
58
|
-
expect(document.querySelectorAll('.specSelectGroup')).toHaveLength(2);
|
|
59
|
-
});
|
|
60
|
-
it('reflects error state', () => {
|
|
61
|
-
renderSelect({ ...tc.props, showError: true });
|
|
62
|
-
expect(document.querySelector('.specSelectControl')).toHaveClass('tw-border-sq-danger-color');
|
|
63
|
-
});
|
|
64
|
-
it('reflects custom render function for option', async () => {
|
|
65
|
-
const getOptionLabel = (option) => (React.createElement("div", null,
|
|
66
|
-
option.label,
|
|
67
|
-
React.createElement("br", null),
|
|
68
|
-
"custom formatting applied"));
|
|
69
|
-
renderSelect({ ...tc.props, getOptionLabel });
|
|
70
|
-
await openSelect();
|
|
71
|
-
expect(document.querySelectorAll('.specSelectOption')[0]).toHaveTextContent('custom formatting applied');
|
|
72
|
-
});
|
|
73
|
-
it('reflects custom render for selected option', async () => {
|
|
74
|
-
const getSelectedValueLabel = (option) => (React.createElement("div", null,
|
|
75
|
-
option.label,
|
|
76
|
-
React.createElement("br", null),
|
|
77
|
-
"the chosen one"));
|
|
78
|
-
renderSelect({ ...tc.props, getSelectedValueLabel });
|
|
79
|
-
await openSelect();
|
|
80
|
-
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
81
|
-
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent('the chosen one');
|
|
82
|
-
});
|
|
83
|
-
it('renders the provided value as selected', () => {
|
|
84
|
-
const value = tc.options[1];
|
|
85
|
-
renderSelect({ ...tc.props, value });
|
|
86
|
-
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(value.label);
|
|
87
|
-
});
|
|
88
|
-
it('renders the provided placeholder', () => {
|
|
89
|
-
const placeholder = 'choose your favorite flavor';
|
|
90
|
-
renderSelect({ ...tc.props, placeholder });
|
|
91
|
-
expect(screen.getByText(placeholder)).toBeInTheDocument();
|
|
92
|
-
});
|
|
93
|
-
it('renders the provided noOptionsMessage', async () => {
|
|
94
|
-
const noOptionsMessage = 'Nothing to see here.';
|
|
95
|
-
renderSelect({ ...tc.props, noOptionsMessage, options: [] });
|
|
96
|
-
await openSelect();
|
|
97
|
-
expect(screen.getByText(noOptionsMessage)).toBeInTheDocument();
|
|
98
|
-
});
|
|
99
|
-
it('supports multi selection', async () => {
|
|
100
|
-
const isMulti = true;
|
|
101
|
-
renderSelect({ ...tc.props, isMulti });
|
|
102
|
-
await openSelect();
|
|
103
|
-
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
104
|
-
await openSelect();
|
|
105
|
-
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
106
|
-
expect(document.querySelectorAll('.specOpenSelect')).toHaveLength(2);
|
|
107
|
-
});
|
|
108
|
-
it('renders isClearable', async () => {
|
|
109
|
-
const isClearable = true;
|
|
110
|
-
const placeholder = 'no worries - you can clear this.';
|
|
111
|
-
renderSelect({ ...tc.props, isClearable, placeholder });
|
|
112
|
-
await openSelect();
|
|
113
|
-
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
114
|
-
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(tc.options[0].label);
|
|
115
|
-
expect(document.querySelector('.specClearSelect')).toBeInTheDocument();
|
|
116
|
-
await userEvent.click(document.querySelector('.specClearSelect'));
|
|
117
|
-
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(placeholder);
|
|
118
|
-
});
|
|
119
|
-
it('supports menuIsOpen', async () => {
|
|
120
|
-
const menuIsOpen = true;
|
|
121
|
-
renderSelect({ ...tc.props, menuIsOpen, menuPortalTarget: document.querySelector('#wrapper') });
|
|
122
|
-
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(tc.options.length);
|
|
123
|
-
});
|
|
124
|
-
it('supports closeMenuOnSelect', async () => {
|
|
125
|
-
const closeMenuOnSelect = false;
|
|
126
|
-
renderSelect({ ...tc.props, closeMenuOnSelect });
|
|
127
|
-
await openSelect();
|
|
128
|
-
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
129
|
-
await userEvent.click(screen.getByText(tc.options[2].label));
|
|
130
|
-
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(tc.options[2].label);
|
|
131
|
-
});
|
|
132
|
-
it('removes selected option from multi-select options list', async () => {
|
|
133
|
-
const closeMenuOnSelect = false;
|
|
134
|
-
renderSelect({ ...tc.props, isMulti: true, closeMenuOnSelect });
|
|
135
|
-
await openSelect();
|
|
136
|
-
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
137
|
-
await userEvent.click(screen.getByText(tc.options[2].label));
|
|
138
|
-
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(tc.options.length - 2);
|
|
139
|
-
});
|
|
140
|
-
it('calls onChange handler', async () => {
|
|
141
|
-
const onChange = jest.fn();
|
|
142
|
-
renderSelect({ ...tc.props, onChange });
|
|
143
|
-
await openSelect();
|
|
144
|
-
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
145
|
-
expect(onChange).toHaveBeenCalledWith(tc.options[1]);
|
|
146
|
-
});
|
|
147
|
-
it('includes inputId', async () => {
|
|
148
|
-
const inputId = 'idMe';
|
|
149
|
-
renderSelect({ ...tc.props, inputId });
|
|
150
|
-
expect(document.querySelector(`#${inputId}`)).toBeInTheDocument();
|
|
151
|
-
});
|
|
152
|
-
it('supports creating options', async () => {
|
|
153
|
-
const inputId = 'idMe';
|
|
154
|
-
const favorite = 'Almond Joy';
|
|
155
|
-
renderSelect({ ...tc.props, creatable: true, inputId });
|
|
156
|
-
await openSelect();
|
|
157
|
-
await userEvent.type(document.querySelector(`#${inputId}`), favorite);
|
|
158
|
-
expect(screen.getByText(`Create "${favorite}"`)).toBeInTheDocument();
|
|
159
|
-
});
|
|
160
|
-
it('supports onMenuOpen', async () => {
|
|
161
|
-
const onMenuOpen = jest.fn();
|
|
162
|
-
renderSelect({ ...tc.props, onMenuOpen });
|
|
163
|
-
await openSelect();
|
|
164
|
-
expect(onMenuOpen).toHaveBeenCalled();
|
|
165
|
-
});
|
|
166
|
-
it('supports onMenuClose', async () => {
|
|
167
|
-
const onMenuClose = jest.fn();
|
|
168
|
-
renderSelect({ ...tc.props, onMenuClose });
|
|
169
|
-
await openSelect();
|
|
170
|
-
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
171
|
-
expect(onMenuClose).toHaveBeenCalled();
|
|
172
|
-
});
|
|
173
|
-
it('supports custom components', async () => {
|
|
174
|
-
const components = {
|
|
175
|
-
DropdownIndicator: () => React.createElement("div", { className: "custom" }, "Custom Dropdown"),
|
|
176
|
-
};
|
|
177
|
-
renderSelect({ ...tc.props, components });
|
|
178
|
-
await openSelect();
|
|
179
|
-
expect(document.querySelector('.custom')).toBeInTheDocument();
|
|
180
|
-
});
|
|
181
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import Select from './Select';
|
|
6
|
+
describe('Select', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
testId = 'selectTestId';
|
|
9
|
+
label = 'button label';
|
|
10
|
+
options = [
|
|
11
|
+
{ label: 'vanilla', value: 'a' },
|
|
12
|
+
{ label: 'chocolate', value: 'b' },
|
|
13
|
+
{ label: 'strawberry', value: 'c' },
|
|
14
|
+
];
|
|
15
|
+
otherOptions = [
|
|
16
|
+
{ label: 'red', value: 'd' },
|
|
17
|
+
{ label: 'green', value: 'e' },
|
|
18
|
+
];
|
|
19
|
+
groupedOptions = [
|
|
20
|
+
{
|
|
21
|
+
label: 'Ice Cream Flavors',
|
|
22
|
+
options: this.options,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: 'Colors',
|
|
26
|
+
options: this.otherOptions,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
props = {
|
|
30
|
+
onChange: jest.fn(),
|
|
31
|
+
options: this.options,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
let tc;
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
tc = new Context();
|
|
37
|
+
});
|
|
38
|
+
const openSelect = async () => {
|
|
39
|
+
const select = document.querySelector(`.specOpenSelect`);
|
|
40
|
+
await userEvent.click(select);
|
|
41
|
+
};
|
|
42
|
+
const renderSelect = (props) => render(React.createElement("div", { id: "wrapper" },
|
|
43
|
+
React.createElement(Select, { ...props })));
|
|
44
|
+
it('renders the select', () => {
|
|
45
|
+
renderSelect(tc.props);
|
|
46
|
+
expect(document.querySelector('.specSelectControl')).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
it('displays options', async () => {
|
|
49
|
+
renderSelect(tc.props);
|
|
50
|
+
await openSelect();
|
|
51
|
+
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(3);
|
|
52
|
+
});
|
|
53
|
+
it('displays grouped options', async () => {
|
|
54
|
+
renderSelect({ ...tc.props, options: tc.groupedOptions });
|
|
55
|
+
await openSelect();
|
|
56
|
+
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(5);
|
|
57
|
+
expect(document.querySelectorAll('.specSelectGroupHeading')).toHaveLength(2);
|
|
58
|
+
expect(document.querySelectorAll('.specSelectGroup')).toHaveLength(2);
|
|
59
|
+
});
|
|
60
|
+
it('reflects error state', () => {
|
|
61
|
+
renderSelect({ ...tc.props, showError: true });
|
|
62
|
+
expect(document.querySelector('.specSelectControl')).toHaveClass('tw-border-sq-danger-color');
|
|
63
|
+
});
|
|
64
|
+
it('reflects custom render function for option', async () => {
|
|
65
|
+
const getOptionLabel = (option) => (React.createElement("div", null,
|
|
66
|
+
option.label,
|
|
67
|
+
React.createElement("br", null),
|
|
68
|
+
"custom formatting applied"));
|
|
69
|
+
renderSelect({ ...tc.props, getOptionLabel });
|
|
70
|
+
await openSelect();
|
|
71
|
+
expect(document.querySelectorAll('.specSelectOption')[0]).toHaveTextContent('custom formatting applied');
|
|
72
|
+
});
|
|
73
|
+
it('reflects custom render for selected option', async () => {
|
|
74
|
+
const getSelectedValueLabel = (option) => (React.createElement("div", null,
|
|
75
|
+
option.label,
|
|
76
|
+
React.createElement("br", null),
|
|
77
|
+
"the chosen one"));
|
|
78
|
+
renderSelect({ ...tc.props, getSelectedValueLabel });
|
|
79
|
+
await openSelect();
|
|
80
|
+
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
81
|
+
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent('the chosen one');
|
|
82
|
+
});
|
|
83
|
+
it('renders the provided value as selected', () => {
|
|
84
|
+
const value = tc.options[1];
|
|
85
|
+
renderSelect({ ...tc.props, value });
|
|
86
|
+
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(value.label);
|
|
87
|
+
});
|
|
88
|
+
it('renders the provided placeholder', () => {
|
|
89
|
+
const placeholder = 'choose your favorite flavor';
|
|
90
|
+
renderSelect({ ...tc.props, placeholder });
|
|
91
|
+
expect(screen.getByText(placeholder)).toBeInTheDocument();
|
|
92
|
+
});
|
|
93
|
+
it('renders the provided noOptionsMessage', async () => {
|
|
94
|
+
const noOptionsMessage = 'Nothing to see here.';
|
|
95
|
+
renderSelect({ ...tc.props, noOptionsMessage, options: [] });
|
|
96
|
+
await openSelect();
|
|
97
|
+
expect(screen.getByText(noOptionsMessage)).toBeInTheDocument();
|
|
98
|
+
});
|
|
99
|
+
it('supports multi selection', async () => {
|
|
100
|
+
const isMulti = true;
|
|
101
|
+
renderSelect({ ...tc.props, isMulti });
|
|
102
|
+
await openSelect();
|
|
103
|
+
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
104
|
+
await openSelect();
|
|
105
|
+
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
106
|
+
expect(document.querySelectorAll('.specOpenSelect')).toHaveLength(2);
|
|
107
|
+
});
|
|
108
|
+
it('renders isClearable', async () => {
|
|
109
|
+
const isClearable = true;
|
|
110
|
+
const placeholder = 'no worries - you can clear this.';
|
|
111
|
+
renderSelect({ ...tc.props, isClearable, placeholder });
|
|
112
|
+
await openSelect();
|
|
113
|
+
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
114
|
+
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(tc.options[0].label);
|
|
115
|
+
expect(document.querySelector('.specClearSelect')).toBeInTheDocument();
|
|
116
|
+
await userEvent.click(document.querySelector('.specClearSelect'));
|
|
117
|
+
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(placeholder);
|
|
118
|
+
});
|
|
119
|
+
it('supports menuIsOpen', async () => {
|
|
120
|
+
const menuIsOpen = true;
|
|
121
|
+
renderSelect({ ...tc.props, menuIsOpen, menuPortalTarget: document.querySelector('#wrapper') });
|
|
122
|
+
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(tc.options.length);
|
|
123
|
+
});
|
|
124
|
+
it('supports closeMenuOnSelect', async () => {
|
|
125
|
+
const closeMenuOnSelect = false;
|
|
126
|
+
renderSelect({ ...tc.props, closeMenuOnSelect });
|
|
127
|
+
await openSelect();
|
|
128
|
+
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
129
|
+
await userEvent.click(screen.getByText(tc.options[2].label));
|
|
130
|
+
expect(document.querySelectorAll('.specOpenSelect')[0]).toHaveTextContent(tc.options[2].label);
|
|
131
|
+
});
|
|
132
|
+
it('removes selected option from multi-select options list', async () => {
|
|
133
|
+
const closeMenuOnSelect = false;
|
|
134
|
+
renderSelect({ ...tc.props, isMulti: true, closeMenuOnSelect });
|
|
135
|
+
await openSelect();
|
|
136
|
+
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
137
|
+
await userEvent.click(screen.getByText(tc.options[2].label));
|
|
138
|
+
expect(document.querySelectorAll('.specSelectOption')).toHaveLength(tc.options.length - 2);
|
|
139
|
+
});
|
|
140
|
+
it('calls onChange handler', async () => {
|
|
141
|
+
const onChange = jest.fn();
|
|
142
|
+
renderSelect({ ...tc.props, onChange });
|
|
143
|
+
await openSelect();
|
|
144
|
+
await userEvent.click(screen.getByText(tc.options[1].label));
|
|
145
|
+
expect(onChange).toHaveBeenCalledWith(tc.options[1]);
|
|
146
|
+
});
|
|
147
|
+
it('includes inputId', async () => {
|
|
148
|
+
const inputId = 'idMe';
|
|
149
|
+
renderSelect({ ...tc.props, inputId });
|
|
150
|
+
expect(document.querySelector(`#${inputId}`)).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
it('supports creating options', async () => {
|
|
153
|
+
const inputId = 'idMe';
|
|
154
|
+
const favorite = 'Almond Joy';
|
|
155
|
+
renderSelect({ ...tc.props, creatable: true, inputId });
|
|
156
|
+
await openSelect();
|
|
157
|
+
await userEvent.type(document.querySelector(`#${inputId}`), favorite);
|
|
158
|
+
expect(screen.getByText(`Create "${favorite}"`)).toBeInTheDocument();
|
|
159
|
+
});
|
|
160
|
+
it('supports onMenuOpen', async () => {
|
|
161
|
+
const onMenuOpen = jest.fn();
|
|
162
|
+
renderSelect({ ...tc.props, onMenuOpen });
|
|
163
|
+
await openSelect();
|
|
164
|
+
expect(onMenuOpen).toHaveBeenCalled();
|
|
165
|
+
});
|
|
166
|
+
it('supports onMenuClose', async () => {
|
|
167
|
+
const onMenuClose = jest.fn();
|
|
168
|
+
renderSelect({ ...tc.props, onMenuClose });
|
|
169
|
+
await openSelect();
|
|
170
|
+
await userEvent.click(screen.getByText(tc.options[0].label));
|
|
171
|
+
expect(onMenuClose).toHaveBeenCalled();
|
|
172
|
+
});
|
|
173
|
+
it('supports custom components', async () => {
|
|
174
|
+
const components = {
|
|
175
|
+
DropdownIndicator: () => React.createElement("div", { className: "custom" }, "Custom Dropdown"),
|
|
176
|
+
};
|
|
177
|
+
renderSelect({ ...tc.props, components });
|
|
178
|
+
await openSelect();
|
|
179
|
+
expect(document.querySelector('.custom')).toBeInTheDocument();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
182
|
//# sourceMappingURL=Select.test.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=Select.types.js.map
|
package/dist/Select/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from './Select';
|
|
2
|
-
export { components as SelectCompoents } from 'react-select';
|
|
1
|
+
export { default } from './Select';
|
|
2
|
+
export { components as SelectCompoents } from 'react-select';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/Slider/Slider.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import * as RadixSlider from '@radix-ui/react-slider';
|
|
3
|
-
/**
|
|
4
|
-
* Slider .
|
|
5
|
-
*/
|
|
6
|
-
export const Slider = (props) => {
|
|
7
|
-
const { onValueChange, onPointerUp, id, value, name, disabled = false, rootExtraClassNames = '', trackExtraClassNames = '', rangeExtraClassNames = '', thumbExtraClassNames = '', step, min, max, } = props;
|
|
8
|
-
return (React.createElement(RadixSlider.Root, { className: `tw-relative tw-flex tw-h-5 tw-w-full tw-touch-none tw-select-none tw-items-center ${rootExtraClassNames}`, defaultValue: [value], value: [value], onValueChange: (value) => onValueChange && onValueChange(value), onPointerUp: (e) => onPointerUp && onPointerUp(e), name: name, id: id, max: max, min: min, disabled: disabled, step: step },
|
|
9
|
-
React.createElement(RadixSlider.Track, { className: `tw-relative tw-h-[5px] tw-grow tw-rounded-[4px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray ${trackExtraClassNames}` },
|
|
10
|
-
React.createElement(RadixSlider.Range, { className: `tw-absolute tw-h-full tw-rounded-full ${rangeExtraClassNames}` })),
|
|
11
|
-
React.createElement(RadixSlider.Thumb, { className: `tw-block tw-h-[15px] tw-w-[15px] tw-rounded-full tw-bg-sq-color-dark active:tw-bg-sq-color-dark-dark focus:outline-none focus-visible:tw-outline-none aria-disabled:tw-bg-sq-dark-gray dark:aria-disabled:tw-bg-sq-dark-disabled-gray tw-transition tw-ease-in-out ${thumbExtraClassNames}`, "aria-disabled": disabled })));
|
|
12
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as RadixSlider from '@radix-ui/react-slider';
|
|
3
|
+
/**
|
|
4
|
+
* Slider .
|
|
5
|
+
*/
|
|
6
|
+
export const Slider = (props) => {
|
|
7
|
+
const { onValueChange, onPointerUp, id, value, name, disabled = false, rootExtraClassNames = '', trackExtraClassNames = '', rangeExtraClassNames = '', thumbExtraClassNames = '', step, min, max, } = props;
|
|
8
|
+
return (React.createElement(RadixSlider.Root, { className: `tw-relative tw-flex tw-h-5 tw-w-full tw-touch-none tw-select-none tw-items-center ${rootExtraClassNames}`, defaultValue: [value], value: [value], onValueChange: (value) => onValueChange && onValueChange(value), onPointerUp: (e) => onPointerUp && onPointerUp(e), name: name, id: id, max: max, min: min, disabled: disabled, step: step },
|
|
9
|
+
React.createElement(RadixSlider.Track, { className: `tw-relative tw-h-[5px] tw-grow tw-rounded-[4px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray ${trackExtraClassNames}` },
|
|
10
|
+
React.createElement(RadixSlider.Range, { className: `tw-absolute tw-h-full tw-rounded-full ${rangeExtraClassNames}` })),
|
|
11
|
+
React.createElement(RadixSlider.Thumb, { className: `tw-block tw-h-[15px] tw-w-[15px] tw-rounded-full tw-bg-sq-color-dark active:tw-bg-sq-color-dark-dark focus:outline-none focus-visible:tw-outline-none aria-disabled:tw-bg-sq-dark-gray dark:aria-disabled:tw-bg-sq-dark-disabled-gray tw-transition tw-ease-in-out ${thumbExtraClassNames}`, "aria-disabled": disabled })));
|
|
12
|
+
};
|
|
13
13
|
//# sourceMappingURL=Slider.js.map
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Slider } from './Slider';
|
|
3
|
-
import { QTip } from '../Tooltip';
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Slider',
|
|
6
|
-
};
|
|
7
|
-
export const AllSliders = () => {
|
|
8
|
-
const [value1, setValue1] = React.useState(0);
|
|
9
|
-
const [value2, setValue2] = React.useState(0);
|
|
10
|
-
const renderAllVariations = () => (React.createElement(React.Fragment, null,
|
|
11
|
-
React.createElement("div", { className: "tw-p-4 light" },
|
|
12
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
13
|
-
React.createElement(Slider, { min: 0, max: 10, value: 4 })),
|
|
14
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
15
|
-
React.createElement(Slider, { min: 0, max: 10, value: 10 })),
|
|
16
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
17
|
-
React.createElement(Slider, { value: 0, min: 0, max: 10 })),
|
|
18
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
19
|
-
React.createElement("div", null, "1 Step"),
|
|
20
|
-
React.createElement(Slider, { value: value1, min: 0, max: 20, step: 4, onValueChange: (v) => setValue1(v[0]) })),
|
|
21
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
22
|
-
React.createElement("div", null, "10 Steps"),
|
|
23
|
-
React.createElement(Slider, { value: value2, min: 0, max: 20, step: 10, onValueChange: (v) => setValue2(v[0]) })),
|
|
24
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
25
|
-
React.createElement("div", { className: "tw-sq-text-color" }, "Disabled"),
|
|
26
|
-
React.createElement(Slider, { value: 10, min: 0, max: 20, step: 10, disabled: true }))),
|
|
27
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
28
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
29
|
-
React.createElement(Slider, { min: 0, max: 10, value: 4 })),
|
|
30
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
31
|
-
React.createElement(Slider, { min: 0, max: 10, value: 10 })),
|
|
32
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
33
|
-
React.createElement(Slider, { value: 0, min: 0, max: 10 })),
|
|
34
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
35
|
-
React.createElement("div", { className: "dark:tw-text-white" }, "1 Step"),
|
|
36
|
-
React.createElement(Slider, { value: value1, min: 0, max: 20, step: 4, onValueChange: (v) => setValue1(v[0]) })),
|
|
37
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
38
|
-
React.createElement("div", { className: "dark:tw-text-white" }, "10 Steps"),
|
|
39
|
-
React.createElement(Slider, { value: value2, min: 0, max: 20, step: 10, onValueChange: (v) => setValue2(v[0]) })),
|
|
40
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
41
|
-
React.createElement("div", { className: "dark:tw-text-white" }, "Disabled"),
|
|
42
|
-
React.createElement(Slider, { value: 10, min: 0, max: 20, step: 10, disabled: true })))));
|
|
43
|
-
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
44
|
-
React.createElement(QTip, null),
|
|
45
|
-
React.createElement("div", { className: "color_topic" },
|
|
46
|
-
React.createElement("b", null, "Topic Colors"),
|
|
47
|
-
renderAllVariations()),
|
|
48
|
-
React.createElement("div", { className: "color_analysis" },
|
|
49
|
-
React.createElement("b", null, "Analysis Colors"),
|
|
50
|
-
renderAllVariations()),
|
|
51
|
-
React.createElement("div", { className: "color_datalab" },
|
|
52
|
-
React.createElement("b", null, "Datalab Colors"),
|
|
53
|
-
renderAllVariations()),
|
|
54
|
-
React.createElement("div", { className: "color_vantage" },
|
|
55
|
-
React.createElement("b", null, "Vantage Colors"),
|
|
56
|
-
renderAllVariations())));
|
|
57
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Slider } from './Slider';
|
|
3
|
+
import { QTip } from '../Tooltip';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Slider',
|
|
6
|
+
};
|
|
7
|
+
export const AllSliders = () => {
|
|
8
|
+
const [value1, setValue1] = React.useState(0);
|
|
9
|
+
const [value2, setValue2] = React.useState(0);
|
|
10
|
+
const renderAllVariations = () => (React.createElement(React.Fragment, null,
|
|
11
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
12
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
13
|
+
React.createElement(Slider, { min: 0, max: 10, value: 4 })),
|
|
14
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
15
|
+
React.createElement(Slider, { min: 0, max: 10, value: 10 })),
|
|
16
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
17
|
+
React.createElement(Slider, { value: 0, min: 0, max: 10 })),
|
|
18
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
19
|
+
React.createElement("div", null, "1 Step"),
|
|
20
|
+
React.createElement(Slider, { value: value1, min: 0, max: 20, step: 4, onValueChange: (v) => setValue1(v[0]) })),
|
|
21
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
22
|
+
React.createElement("div", null, "10 Steps"),
|
|
23
|
+
React.createElement(Slider, { value: value2, min: 0, max: 20, step: 10, onValueChange: (v) => setValue2(v[0]) })),
|
|
24
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
25
|
+
React.createElement("div", { className: "tw-sq-text-color" }, "Disabled"),
|
|
26
|
+
React.createElement(Slider, { value: 10, min: 0, max: 20, step: 10, disabled: true }))),
|
|
27
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
28
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
29
|
+
React.createElement(Slider, { min: 0, max: 10, value: 4 })),
|
|
30
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
31
|
+
React.createElement(Slider, { min: 0, max: 10, value: 10 })),
|
|
32
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
33
|
+
React.createElement(Slider, { value: 0, min: 0, max: 10 })),
|
|
34
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
35
|
+
React.createElement("div", { className: "dark:tw-text-white" }, "1 Step"),
|
|
36
|
+
React.createElement(Slider, { value: value1, min: 0, max: 20, step: 4, onValueChange: (v) => setValue1(v[0]) })),
|
|
37
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
38
|
+
React.createElement("div", { className: "dark:tw-text-white" }, "10 Steps"),
|
|
39
|
+
React.createElement(Slider, { value: value2, min: 0, max: 20, step: 10, onValueChange: (v) => setValue2(v[0]) })),
|
|
40
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
41
|
+
React.createElement("div", { className: "dark:tw-text-white" }, "Disabled"),
|
|
42
|
+
React.createElement(Slider, { value: 10, min: 0, max: 20, step: 10, disabled: true })))));
|
|
43
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
44
|
+
React.createElement(QTip, null),
|
|
45
|
+
React.createElement("div", { className: "color_topic" },
|
|
46
|
+
React.createElement("b", null, "Topic Colors"),
|
|
47
|
+
renderAllVariations()),
|
|
48
|
+
React.createElement("div", { className: "color_analysis" },
|
|
49
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
50
|
+
renderAllVariations()),
|
|
51
|
+
React.createElement("div", { className: "color_datalab" },
|
|
52
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
53
|
+
renderAllVariations()),
|
|
54
|
+
React.createElement("div", { className: "color_vantage" },
|
|
55
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
56
|
+
renderAllVariations())));
|
|
57
|
+
};
|
|
58
58
|
//# sourceMappingURL=Slider.stories.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
-
import { Slider } from './Slider';
|
|
5
|
-
describe('Slider Component', () => {
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
onValueChange: jest.fn(),
|
|
8
|
-
onPointerUp: jest.fn(),
|
|
9
|
-
id: 'test-slider',
|
|
10
|
-
value: 50,
|
|
11
|
-
name: 'slider',
|
|
12
|
-
disabled: false,
|
|
13
|
-
testId: 'slider',
|
|
14
|
-
step: 1,
|
|
15
|
-
min: 0,
|
|
16
|
-
max: 100,
|
|
17
|
-
};
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
global.ResizeObserver = jest.fn().mockImplementation(() => {
|
|
20
|
-
return { observe: jest.fn(), disconnect: jest.fn(), unobserve: jest.fn() };
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
it('renders without crashing', () => {
|
|
24
|
-
const { getByRole } = render(React.createElement(Slider, { ...defaultProps }));
|
|
25
|
-
expect(getByRole('slider')).toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
it('is disabled when disabled prop is true', () => {
|
|
28
|
-
const { getByRole } = render(React.createElement(Slider, { ...defaultProps, disabled: true }));
|
|
29
|
-
const thumb = getByRole('slider');
|
|
30
|
-
expect(thumb).toHaveAttribute('data-disabled', '');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import { Slider } from './Slider';
|
|
5
|
+
describe('Slider Component', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
onValueChange: jest.fn(),
|
|
8
|
+
onPointerUp: jest.fn(),
|
|
9
|
+
id: 'test-slider',
|
|
10
|
+
value: 50,
|
|
11
|
+
name: 'slider',
|
|
12
|
+
disabled: false,
|
|
13
|
+
testId: 'slider',
|
|
14
|
+
step: 1,
|
|
15
|
+
min: 0,
|
|
16
|
+
max: 100,
|
|
17
|
+
};
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
global.ResizeObserver = jest.fn().mockImplementation(() => {
|
|
20
|
+
return { observe: jest.fn(), disconnect: jest.fn(), unobserve: jest.fn() };
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it('renders without crashing', () => {
|
|
24
|
+
const { getByRole } = render(React.createElement(Slider, { ...defaultProps }));
|
|
25
|
+
expect(getByRole('slider')).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
it('is disabled when disabled prop is true', () => {
|
|
28
|
+
const { getByRole } = render(React.createElement(Slider, { ...defaultProps, disabled: true }));
|
|
29
|
+
const thumb = getByRole('slider');
|
|
30
|
+
expect(thumb).toHaveAttribute('data-disabled', '');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
33
|
//# sourceMappingURL=Slider.test.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=Slider.types.js.map
|
package/dist/Slider/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Slider as default } from './Slider';
|
|
1
|
+
export { Slider as default } from './Slider';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|