@seeqdev/qomponents 0.0.132 → 0.0.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +135 -135
  2. package/dist/Accordion/Accordion.js +8 -8
  3. package/dist/Accordion/Accordion.stories.js +114 -114
  4. package/dist/Accordion/Accordion.test.js +54 -54
  5. package/dist/Accordion/Accordion.types.js +1 -1
  6. package/dist/Accordion/index.js +1 -1
  7. package/dist/Alert/Alert.js +33 -33
  8. package/dist/Alert/Alert.stories.js +51 -51
  9. package/dist/Alert/Alert.test.js +50 -50
  10. package/dist/Alert/Alert.types.d.ts +1 -0
  11. package/dist/Alert/Alert.types.js +1 -1
  12. package/dist/Alert/index.js +1 -1
  13. package/dist/Button/Button.js +91 -91
  14. package/dist/Button/Button.stories.js +99 -99
  15. package/dist/Button/Button.test.js +48 -48
  16. package/dist/Button/Button.types.js +4 -4
  17. package/dist/Button/index.js +1 -1
  18. package/dist/ButtonGroup/ButtonGroup.js +32 -32
  19. package/dist/ButtonGroup/ButtonGroup.stories.js +384 -384
  20. package/dist/ButtonGroup/ButtonGroup.test.js +66 -66
  21. package/dist/ButtonGroup/ButtonGroup.types.d.ts +1 -0
  22. package/dist/ButtonGroup/ButtonGroup.types.js +1 -1
  23. package/dist/ButtonGroup/index.js +1 -1
  24. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +59 -59
  25. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +142 -142
  26. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -92
  27. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.d.ts +1 -0
  28. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -1
  29. package/dist/ButtonWithDropdown/index.js +1 -1
  30. package/dist/ButtonWithPopover/ButtonWithPopover.js +61 -61
  31. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +74 -74
  32. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +81 -81
  33. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +1 -1
  34. package/dist/ButtonWithPopover/index.js +1 -1
  35. package/dist/Carousel/Carousel.js +69 -66
  36. package/dist/Carousel/Carousel.js.map +1 -1
  37. package/dist/Carousel/Carousel.stories.js +114 -114
  38. package/dist/Carousel/Carousel.test.js +47 -47
  39. package/dist/Carousel/Carousel.types.d.ts +1 -0
  40. package/dist/Carousel/Carousel.types.js +1 -1
  41. package/dist/Carousel/index.js +1 -1
  42. package/dist/Checkbox/Checkbox.js +25 -25
  43. package/dist/Checkbox/Checkbox.stories.js +33 -33
  44. package/dist/Checkbox/Checkbox.test.js +93 -93
  45. package/dist/Checkbox/Checkbox.types.d.ts +1 -0
  46. package/dist/Checkbox/Checkbox.types.js +1 -1
  47. package/dist/Checkbox/index.js +1 -1
  48. package/dist/Collapse/Collapse.js +14 -17
  49. package/dist/Collapse/Collapse.js.map +1 -1
  50. package/dist/Collapse/Collapse.stories.js +36 -36
  51. package/dist/Collapse/Collapse.test.js +18 -18
  52. package/dist/Collapse/Collapse.types.d.ts +1 -0
  53. package/dist/Collapse/Collapse.types.js +1 -1
  54. package/dist/Collapse/index.js +1 -1
  55. package/dist/Icon/Icon.js +54 -54
  56. package/dist/Icon/Icon.stories.js +46 -46
  57. package/dist/Icon/Icon.test.js +54 -54
  58. package/dist/Icon/Icon.types.d.ts +1 -0
  59. package/dist/Icon/Icon.types.js +15 -15
  60. package/dist/Icon/index.js +1 -1
  61. package/dist/InputGroup/InputGroup.js +31 -31
  62. package/dist/InputGroup/InputGroup.stories.js +167 -167
  63. package/dist/InputGroup/InputGroup.test.js +42 -42
  64. package/dist/InputGroup/InputGroup.types.d.ts +1 -0
  65. package/dist/InputGroup/InputGroup.types.js +1 -1
  66. package/dist/InputGroup/index.js +1 -1
  67. package/dist/Modal/Modal.js +99 -99
  68. package/dist/Modal/Modal.js.map +1 -1
  69. package/dist/Modal/Modal.stories.js +126 -126
  70. package/dist/Modal/Modal.test.js +107 -107
  71. package/dist/Modal/Modal.types.js +1 -1
  72. package/dist/Modal/index.js +1 -1
  73. package/dist/ProgressBar/ProgressBar.js +49 -29
  74. package/dist/ProgressBar/ProgressBar.js.map +1 -1
  75. package/dist/ProgressBar/ProgressBar.stories.js +80 -72
  76. package/dist/ProgressBar/ProgressBar.stories.js.map +1 -1
  77. package/dist/ProgressBar/ProgressBar.test.js +43 -37
  78. package/dist/ProgressBar/ProgressBar.test.js.map +1 -1
  79. package/dist/ProgressBar/ProgressBar.types.d.ts +2 -0
  80. package/dist/ProgressBar/ProgressBar.types.js +1 -1
  81. package/dist/ProgressBar/index.js +1 -1
  82. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +47 -47
  83. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +79 -79
  84. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -72
  85. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.d.ts +1 -0
  86. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -1
  87. package/dist/SeeqActionDropdown/index.js +1 -1
  88. package/dist/SeeqActionDropdown/variants.js +22 -22
  89. package/dist/Select/Select.js +173 -173
  90. package/dist/Select/Select.stories.js +79 -79
  91. package/dist/Select/Select.test.js +181 -181
  92. package/dist/Select/Select.types.js +1 -1
  93. package/dist/Select/index.js +2 -2
  94. package/dist/Slider/Slider.js +12 -12
  95. package/dist/Slider/Slider.stories.js +57 -57
  96. package/dist/Slider/Slider.test.js +32 -32
  97. package/dist/Slider/Slider.types.d.ts +1 -0
  98. package/dist/Slider/Slider.types.js +1 -1
  99. package/dist/Slider/index.js +1 -1
  100. package/dist/Tabs/Tabs.js +21 -21
  101. package/dist/Tabs/Tabs.stories.js +90 -90
  102. package/dist/Tabs/Tabs.test.js +90 -90
  103. package/dist/Tabs/Tabs.types.d.ts +1 -0
  104. package/dist/Tabs/Tabs.types.js +1 -1
  105. package/dist/Tabs/index.js +1 -1
  106. package/dist/TextArea/TextArea.js +24 -24
  107. package/dist/TextArea/TextArea.stories.js +45 -45
  108. package/dist/TextArea/TextArea.test.js +67 -67
  109. package/dist/TextArea/TextArea.types.d.ts +1 -0
  110. package/dist/TextArea/TextArea.types.js +1 -1
  111. package/dist/TextArea/index.js +1 -1
  112. package/dist/TextField/TextField.js +78 -78
  113. package/dist/TextField/TextField.stories.js +69 -69
  114. package/dist/TextField/TextField.test.js +38 -38
  115. package/dist/TextField/TextField.types.d.ts +1 -0
  116. package/dist/TextField/TextField.types.js +1 -1
  117. package/dist/TextField/index.js +1 -1
  118. package/dist/ToolbarButton/ToolbarButton.js +74 -74
  119. package/dist/ToolbarButton/ToolbarButton.stories.js +93 -93
  120. package/dist/ToolbarButton/ToolbarButton.test.js +92 -92
  121. package/dist/ToolbarButton/ToolbarButton.types.js +1 -1
  122. package/dist/ToolbarButton/index.js +1 -1
  123. package/dist/Tooltip/QTip.stories.js +44 -44
  124. package/dist/Tooltip/QTip.types.js +1 -1
  125. package/dist/Tooltip/QTipPerformance.stories.js +29 -29
  126. package/dist/Tooltip/Qtip.js +167 -167
  127. package/dist/Tooltip/Tooltip.js +35 -35
  128. package/dist/Tooltip/Tooltip.stories.js +31 -31
  129. package/dist/Tooltip/Tooltip.types.d.ts +1 -0
  130. package/dist/Tooltip/Tooltip.types.js +2 -2
  131. package/dist/Tooltip/TooltipPerformance.stories.js +29 -29
  132. package/dist/Tooltip/index.js +2 -2
  133. package/dist/Tooltip/qTip.utilities.js +10 -10
  134. package/dist/example/.eslintrc.cjs +14 -14
  135. package/dist/example/README.md +33 -33
  136. package/dist/example/index.html +13 -13
  137. package/dist/example/package.json +30 -30
  138. package/dist/example/src/ComplexSelectExample.tsx +81 -81
  139. package/dist/example/src/Example.tsx +408 -408
  140. package/dist/example/src/index.css +102 -102
  141. package/dist/example/src/main.tsx +10 -10
  142. package/dist/example/src/vite-env.d.ts +1 -1
  143. package/dist/example/tsconfig.json +33 -33
  144. package/dist/example/tsconfig.node.json +12 -12
  145. package/dist/example/vite.config.ts +12 -12
  146. package/dist/index.esm.js +15266 -7869
  147. package/dist/index.esm.js.map +1 -1
  148. package/dist/index.js +15230 -7833
  149. package/dist/index.js.map +1 -1
  150. package/dist/styles.css +3714 -3709
  151. package/dist/types.js +1 -1
  152. package/dist/utils/browserId.js +28 -28
  153. package/dist/utils/svg.js +19 -19
  154. package/dist/utils/validateStyleDimension.js +13 -13
  155. package/dist/utils/validateStyleDimension.test.js +19 -19
  156. package/package.json +89 -86
@@ -1,48 +1,48 @@
1
- import React from 'react';
2
- import '@testing-library/jest-dom';
3
- import { act, render, fireEvent, screen } from '@testing-library/react';
4
- import Carousel from './Carousel';
5
- describe('Carousel Component', () => {
6
- const mockOnSlide = jest.fn();
7
- const carouselItems = [React.createElement("div", { key: "1" }, "Slide 1"), React.createElement("div", { key: "2" }, "Slide 2"), React.createElement("div", { key: "3" }, "Slide 3")];
8
- it('renders correctly', () => {
9
- render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems }));
10
- expect(screen.getByTestId('carousel')).toBeInTheDocument();
11
- });
12
- it('shows the correct initial slide', () => {
13
- render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, activeIndex: 1 }));
14
- expect(screen.getByText('Slide 2')).toBeInTheDocument();
15
- });
16
- it('calls onSlide when next button is clicked', () => {
17
- render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, onSlide: mockOnSlide }));
18
- const nextButton = screen.getByTestId('carousel-next');
19
- fireEvent.click(nextButton);
20
- expect(mockOnSlide).toHaveBeenCalledWith(1, 'right');
21
- });
22
- it('calls onSlide when previous button is clicked', () => {
23
- render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, onSlide: mockOnSlide, activeIndex: 1 }));
24
- const prevButton = screen.getByTestId('carousel-prev');
25
- fireEvent.click(prevButton);
26
- expect(mockOnSlide).toHaveBeenCalledWith(0, 'left');
27
- });
28
- it('does not move past the last slide', () => {
29
- render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, activeIndex: 2, continuous: false }));
30
- const nextButton = screen.queryByTestId('carousel-next');
31
- expect(nextButton).toHaveClass('tw-invisible');
32
- });
33
- it('autoSlides correctly', async () => {
34
- jest.useFakeTimers();
35
- render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, autoSlide: true, interval: 1000 }));
36
- expect(screen.getByText('Slide 1')).toBeInTheDocument();
37
- act(() => {
38
- jest.advanceTimersByTime(1000);
39
- });
40
- expect(screen.getByText('Slide 2')).toBeInTheDocument();
41
- act(() => {
42
- jest.advanceTimersByTime(1000);
43
- });
44
- expect(screen.getByText('Slide 3')).toBeInTheDocument();
45
- jest.useRealTimers();
46
- });
47
- });
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { act, render, fireEvent, screen } from '@testing-library/react';
4
+ import Carousel from './Carousel';
5
+ describe('Carousel Component', () => {
6
+ const mockOnSlide = jest.fn();
7
+ const carouselItems = [React.createElement("div", { key: "1" }, "Slide 1"), React.createElement("div", { key: "2" }, "Slide 2"), React.createElement("div", { key: "3" }, "Slide 3")];
8
+ it('renders correctly', () => {
9
+ render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems }));
10
+ expect(screen.getByTestId('carousel')).toBeInTheDocument();
11
+ });
12
+ it('shows the correct initial slide', () => {
13
+ render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, activeIndex: 1 }));
14
+ expect(screen.getByText('Slide 2')).toBeInTheDocument();
15
+ });
16
+ it('calls onSlide when next button is clicked', () => {
17
+ render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, onSlide: mockOnSlide }));
18
+ const nextButton = screen.getByTestId('carousel-next');
19
+ fireEvent.click(nextButton);
20
+ expect(mockOnSlide).toHaveBeenCalledWith(1, 'right');
21
+ });
22
+ it('calls onSlide when previous button is clicked', () => {
23
+ render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, onSlide: mockOnSlide, activeIndex: 1 }));
24
+ const prevButton = screen.getByTestId('carousel-prev');
25
+ fireEvent.click(prevButton);
26
+ expect(mockOnSlide).toHaveBeenCalledWith(0, 'left');
27
+ });
28
+ it('does not move past the last slide', () => {
29
+ render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, activeIndex: 2, continuous: false }));
30
+ const nextButton = screen.queryByTestId('carousel-next');
31
+ expect(nextButton).toHaveClass('tw-invisible');
32
+ });
33
+ it('autoSlides correctly', async () => {
34
+ jest.useFakeTimers();
35
+ render(React.createElement(Carousel, { testId: "carousel", carouselItems: carouselItems, autoSlide: true, interval: 1000 }));
36
+ expect(screen.getByText('Slide 1')).toBeInTheDocument();
37
+ act(() => {
38
+ jest.advanceTimersByTime(1000);
39
+ });
40
+ expect(screen.getByText('Slide 2')).toBeInTheDocument();
41
+ act(() => {
42
+ jest.advanceTimersByTime(1000);
43
+ });
44
+ expect(screen.getByText('Slide 3')).toBeInTheDocument();
45
+ jest.useRealTimers();
46
+ });
47
+ });
48
48
  //# sourceMappingURL=Carousel.test.js.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * Properties for the Carousel component.
3
4
  */
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=Carousel.types.js.map
@@ -1,2 +1,2 @@
1
- export { default } from './Carousel';
1
+ export { default } from './Carousel';
2
2
  //# sourceMappingURL=index.js.map
@@ -1,26 +1,26 @@
1
- import React from 'react';
2
- import '../styles.css';
3
- import { getQTipData } from '../Tooltip/qTip.utilities';
4
- const alignment = 'tw-flex';
5
- const labelClasses = 'tw-ml-1.5 tw-text-sm tw--mt-0.5';
6
- const baseClasses = 'tw-border-1 tw-h-3.5 tw-w-3.5 focus:tw-ring-0 focus:tw-ring-offset-0 tw-outline-none focus:tw-outline-none' +
7
- ' dark:tw-bg-sq-dark-background dark:tw-border-sq-dark-text dark:hover:tw-bg-sq-dark-background' +
8
- ' checked:tw-text-white checked:tw-border-sq-text-color checked:hover:tw-border-sq-color-dark' +
9
- ' checked:active:tw-border-sq-color-dark checked:focus:tw-border-sq-color-dark disabled:tw-border-sq-disabled-gray' +
10
- ' dark:disabled:tw-border-sq-fairly-dark-gray dark:checked:focus:tw-bg-sq-dark-background';
11
- const checkboxClasses = `tw-form-checkbox tw-rounded ${baseClasses}`;
12
- const radioClasses = `tw-form-radio ${baseClasses}`;
13
- /**
14
- * Checkbox and Radio Box Component.
15
- */
16
- export const Checkbox = (props) => {
17
- const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, ...tooltipProps } = props;
18
- const assignedId = id ?? 'checkbox_' + Math.random();
19
- const tooltipData = getQTipData(tooltipProps);
20
- return (React.createElement("span", { className: `${alignment} ${extraClassNames}` },
21
- React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, readOnly: !onChange, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown, ...tooltipData }),
22
- React.createElement("label", { htmlFor: assignedId, className: `${labelClasses} ${extraLabelClassNames} ${disabled
23
- ? 'tw-cursor-not-allowed dark:tw-text-sq-fairly-dark-gray tw-text-sq-fairly-dark-gray'
24
- : 'tw-cursor-pointer tw-text-sq-text-color dark:tw-text-sq-dark-text'}` }, label)));
25
- };
1
+ import React from 'react';
2
+ import '../styles.css';
3
+ import { getQTipData } from '../Tooltip/qTip.utilities';
4
+ const alignment = 'tw-flex';
5
+ const labelClasses = 'tw-ml-1.5 tw-text-sm tw--mt-0.5';
6
+ const baseClasses = 'tw-border-1 tw-h-3.5 tw-w-3.5 focus:tw-ring-0 focus:tw-ring-offset-0 tw-outline-none focus:tw-outline-none' +
7
+ ' dark:tw-bg-sq-dark-background dark:tw-border-sq-dark-text dark:hover:tw-bg-sq-dark-background' +
8
+ ' checked:tw-text-white checked:tw-border-sq-text-color checked:hover:tw-border-sq-color-dark' +
9
+ ' checked:active:tw-border-sq-color-dark checked:focus:tw-border-sq-color-dark disabled:tw-border-sq-disabled-gray' +
10
+ ' dark:disabled:tw-border-sq-fairly-dark-gray dark:checked:focus:tw-bg-sq-dark-background';
11
+ const checkboxClasses = `tw-form-checkbox tw-rounded ${baseClasses}`;
12
+ const radioClasses = `tw-form-radio ${baseClasses}`;
13
+ /**
14
+ * Checkbox and Radio Box Component.
15
+ */
16
+ export const Checkbox = (props) => {
17
+ const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, ...tooltipProps } = props;
18
+ const assignedId = id ?? 'checkbox_' + Math.random();
19
+ const tooltipData = getQTipData(tooltipProps);
20
+ return (React.createElement("span", { className: `${alignment} ${extraClassNames}` },
21
+ React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, readOnly: !onChange, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown, ...tooltipData }),
22
+ React.createElement("label", { htmlFor: assignedId, className: `${labelClasses} ${extraLabelClassNames} ${disabled
23
+ ? 'tw-cursor-not-allowed dark:tw-text-sq-fairly-dark-gray tw-text-sq-fairly-dark-gray'
24
+ : 'tw-cursor-pointer tw-text-sq-text-color dark:tw-text-sq-dark-text'}` }, label)));
25
+ };
26
26
  //# sourceMappingURL=Checkbox.js.map
@@ -1,34 +1,34 @@
1
- import React from 'react';
2
- import { Checkbox } from './Checkbox';
3
- import { QTip } from '../Tooltip';
4
- export default {
5
- title: 'Checkbox',
6
- };
7
- export const AllCheckboxes = () => {
8
- const getDisplay = (type) => (React.createElement(React.Fragment, null,
9
- React.createElement(QTip, null),
10
- React.createElement("div", { className: "tw-p-4" },
11
- React.createElement(Checkbox, { value: "a", type: type, checked: true, label: 'with Label', tooltip: "Checkbox Tooltip" })),
12
- React.createElement("div", { className: "tw-p-4" },
13
- React.createElement(Checkbox, { value: "d", type: type, checked: false, disabled: true, label: React.createElement("div", null,
14
- "Disabled",
15
- React.createElement("br", null),
16
- "multi-Line"), tooltip: "Checkbox Tooltip" })),
17
- React.createElement("div", { className: "tw-p-4" },
18
- React.createElement(Checkbox, { value: "d", type: type, checked: true, disabled: true, label: "Disabled", tooltip: "Checkbox Tooltip" })),
19
- React.createElement("div", { className: "tw-p-4" },
20
- React.createElement(Checkbox, { value: "b", type: type, checked: true, tooltip: "Checkbox Tooltip" })),
21
- React.createElement("div", { className: "tw-p-4" },
22
- React.createElement(Checkbox, { value: "c", type: type, checked: false, tooltip: "Checkbox Tooltip" }))));
23
- const renderAllVariations = (type) => (React.createElement(React.Fragment, null,
24
- React.createElement("div", { className: "tw-p-4 light" }, getDisplay(type)),
25
- React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, getDisplay(type))));
26
- return (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4" },
27
- React.createElement("div", null,
28
- React.createElement("b", null, "Checkbox"),
29
- renderAllVariations('checkbox')),
30
- React.createElement("div", null,
31
- React.createElement("b", null, "Radios"),
32
- renderAllVariations('radio'))));
33
- };
1
+ import React from 'react';
2
+ import { Checkbox } from './Checkbox';
3
+ import { QTip } from '../Tooltip';
4
+ export default {
5
+ title: 'Checkbox',
6
+ };
7
+ export const AllCheckboxes = () => {
8
+ const getDisplay = (type) => (React.createElement(React.Fragment, null,
9
+ React.createElement(QTip, null),
10
+ React.createElement("div", { className: "tw-p-4" },
11
+ React.createElement(Checkbox, { value: "a", type: type, checked: true, label: 'with Label', tooltip: "Checkbox Tooltip" })),
12
+ React.createElement("div", { className: "tw-p-4" },
13
+ React.createElement(Checkbox, { value: "d", type: type, checked: false, disabled: true, label: React.createElement("div", null,
14
+ "Disabled",
15
+ React.createElement("br", null),
16
+ "multi-Line"), tooltip: "Checkbox Tooltip" })),
17
+ React.createElement("div", { className: "tw-p-4" },
18
+ React.createElement(Checkbox, { value: "d", type: type, checked: true, disabled: true, label: "Disabled", tooltip: "Checkbox Tooltip" })),
19
+ React.createElement("div", { className: "tw-p-4" },
20
+ React.createElement(Checkbox, { value: "b", type: type, checked: true, tooltip: "Checkbox Tooltip" })),
21
+ React.createElement("div", { className: "tw-p-4" },
22
+ React.createElement(Checkbox, { value: "c", type: type, checked: false, tooltip: "Checkbox Tooltip" }))));
23
+ const renderAllVariations = (type) => (React.createElement(React.Fragment, null,
24
+ React.createElement("div", { className: "tw-p-4 light" }, getDisplay(type)),
25
+ React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, getDisplay(type))));
26
+ return (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4" },
27
+ React.createElement("div", null,
28
+ React.createElement("b", null, "Checkbox"),
29
+ renderAllVariations('checkbox')),
30
+ React.createElement("div", null,
31
+ React.createElement("b", null, "Radios"),
32
+ renderAllVariations('radio'))));
33
+ };
34
34
  //# sourceMappingURL=Checkbox.stories.js.map
@@ -1,94 +1,94 @@
1
- import React from 'react';
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(React.createElement(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
- });
1
+ import React from 'react';
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(React.createElement(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
+ });
94
94
  //# sourceMappingURL=Checkbox.test.js.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
2
3
  type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
3
4
  export interface CheckboxProps extends TooltipComponentProps {
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=Checkbox.types.js.map
@@ -1,2 +1,2 @@
1
- export { Checkbox as default } from './Checkbox';
1
+ export { Checkbox as default } from './Checkbox';
2
2
  //# sourceMappingURL=index.js.map
@@ -1,18 +1,15 @@
1
- import React, { useRef, useEffect, useState } from 'react';
2
- import { animated, useSpring } from '@react-spring/web';
3
- const Collapse = ({ isVisible, children }) => {
4
- const contentRef = useRef(null);
5
- const [contentHeight, setContentHeight] = useState(contentRef.current?.scrollHeight);
6
- useEffect(() => {
7
- if (contentRef.current) {
8
- setContentHeight(contentRef.current?.scrollHeight ?? 0);
9
- }
10
- }, [children]);
11
- const styles = useSpring({
12
- opacity: isVisible ? 1 : 0,
13
- height: isVisible ? contentHeight : 0,
14
- });
15
- return React.createElement(animated.div, { style: styles }, isVisible ? React.createElement("div", { ref: contentRef }, children) : undefined);
16
- };
17
- export default Collapse;
1
+ import React, { useRef, useEffect, useState } from 'react';
2
+ import { motion, AnimatePresence } from 'framer-motion';
3
+ const Collapse = ({ isVisible, children }) => {
4
+ const contentRef = useRef(null);
5
+ const [contentHeight, setContentHeight] = useState(0);
6
+ useEffect(() => {
7
+ if (contentRef.current) {
8
+ setContentHeight(contentRef.current.scrollHeight);
9
+ }
10
+ }, [children]);
11
+ return (React.createElement(AnimatePresence, { initial: false }, isVisible && (React.createElement(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: contentHeight, opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { type: 'spring', damping: 20, stiffness: 100 }, style: { overflow: 'hidden' } },
12
+ React.createElement("div", { ref: contentRef }, children)))));
13
+ };
14
+ export default Collapse;
18
15
  //# sourceMappingURL=Collapse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Collapse.js","sourceRoot":"","sources":["../../src/Collapse/Collapse.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGxD,MAAM,QAAQ,GAA2C,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;IACnF,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAErF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC,CAAC;SACzD;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,MAAM,GAAG,SAAS,CAAC;QACvB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;KACtC,CAAC,CAAC;IAEH,OAAO,oBAAC,QAAQ,CAAC,GAAG,IAAC,KAAK,EAAE,MAAM,IAAG,SAAS,CAAC,CAAC,CAAC,6BAAK,GAAG,EAAE,UAAU,IAAG,QAAQ,CAAO,CAAC,CAAC,CAAC,SAAS,CAAgB,CAAC;AACtH,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Collapse.js","sourceRoot":"","sources":["../../src/Collapse/Collapse.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,QAAQ,GAA2C,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;IACnF,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;SACnD;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,oBAAC,eAAe,IAAC,OAAO,EAAE,KAAK,IAC5B,SAAS,IAAI,CACZ,oBAAC,MAAM,CAAC,GAAG,IACT,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAClC,OAAO,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,EAAE,EAC9C,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAC/B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,EAC3D,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAC7B,6BAAK,GAAG,EAAE,UAAU,IAAG,QAAQ,CAAO,CAC3B,CACd,CACe,CACnB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,37 +1,37 @@
1
- import React from 'react';
2
- import Collapse from './Collapse';
3
- import { QTip } from '../Tooltip';
4
- import Button from '../Button';
5
- export default {
6
- title: 'Collapse',
7
- };
8
- export const AllCollapses = () => {
9
- const [isVisible, setIsVisible] = React.useState(true);
10
- const renderChild = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
11
- React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "This is a content to be shown when the collapse is visible. Click the button above to toggle it"),
12
- React.createElement(Button, { variant: "outline", label: "Save data" })));
13
- const renderAllVariations = () => (React.createElement(React.Fragment, null,
14
- React.createElement("div", { className: "tw-p-4 light" },
15
- React.createElement("div", { className: "tw-p-4" },
16
- React.createElement(Button, { variant: "theme", label: "Toggle Collapse", onClick: () => setIsVisible(!isVisible) }),
17
- React.createElement(Collapse, { isVisible: isVisible }, renderChild()))),
18
- React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
19
- React.createElement("div", { className: "tw-p-4" },
20
- React.createElement(Button, { variant: "theme", label: "Toggle Collapse", onClick: () => setIsVisible(!isVisible) }),
21
- React.createElement(Collapse, { isVisible: isVisible }, renderChild())))));
22
- return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
23
- React.createElement(QTip, null),
24
- React.createElement("div", { className: "color_topic" },
25
- React.createElement("b", null, "Topic Colors"),
26
- renderAllVariations()),
27
- React.createElement("div", { className: "color_analysis" },
28
- React.createElement("b", null, "Analysis Colors"),
29
- renderAllVariations()),
30
- React.createElement("div", { className: "color_datalab" },
31
- React.createElement("b", null, "Datalab Colors"),
32
- renderAllVariations()),
33
- React.createElement("div", { className: "color_vantage" },
34
- React.createElement("b", null, "Vantage Colors"),
35
- renderAllVariations())));
36
- };
1
+ import React from 'react';
2
+ import Collapse from './Collapse';
3
+ import { QTip } from '../Tooltip';
4
+ import Button from '../Button';
5
+ export default {
6
+ title: 'Collapse',
7
+ };
8
+ export const AllCollapses = () => {
9
+ const [isVisible, setIsVisible] = React.useState(true);
10
+ const renderChild = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
11
+ React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "This is a content to be shown when the collapse is visible. Click the button above to toggle it"),
12
+ React.createElement(Button, { variant: "outline", label: "Save data" })));
13
+ const renderAllVariations = () => (React.createElement(React.Fragment, null,
14
+ React.createElement("div", { className: "tw-p-4 light" },
15
+ React.createElement("div", { className: "tw-p-4" },
16
+ React.createElement(Button, { variant: "theme", label: "Toggle Collapse", onClick: () => setIsVisible(!isVisible) }),
17
+ React.createElement(Collapse, { isVisible: isVisible }, renderChild()))),
18
+ React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
19
+ React.createElement("div", { className: "tw-p-4" },
20
+ React.createElement(Button, { variant: "theme", label: "Toggle Collapse", onClick: () => setIsVisible(!isVisible) }),
21
+ React.createElement(Collapse, { isVisible: isVisible }, renderChild())))));
22
+ return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
23
+ React.createElement(QTip, null),
24
+ React.createElement("div", { className: "color_topic" },
25
+ React.createElement("b", null, "Topic Colors"),
26
+ renderAllVariations()),
27
+ React.createElement("div", { className: "color_analysis" },
28
+ React.createElement("b", null, "Analysis Colors"),
29
+ renderAllVariations()),
30
+ React.createElement("div", { className: "color_datalab" },
31
+ React.createElement("b", null, "Datalab Colors"),
32
+ renderAllVariations()),
33
+ React.createElement("div", { className: "color_vantage" },
34
+ React.createElement("b", null, "Vantage Colors"),
35
+ renderAllVariations())));
36
+ };
37
37
  //# sourceMappingURL=Collapse.stories.js.map
@@ -1,19 +1,19 @@
1
- import React from 'react';
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(React.createElement(Collapse, { isVisible: true },
8
- React.createElement("div", { "data-testid": "content" }, "Content")));
9
- await waitFor(() => {
10
- expect(screen.getByTestId('content')).toBeVisible();
11
- });
12
- });
13
- test('does not render children when not visible', async () => {
14
- render(React.createElement(Collapse, { isVisible: false },
15
- React.createElement("div", { "data-testid": "content" }, "Content")));
16
- expect(screen.queryByTestId('content')).not.toBeInTheDocument();
17
- });
18
- });
1
+ import React from 'react';
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(React.createElement(Collapse, { isVisible: true },
8
+ React.createElement("div", { "data-testid": "content" }, "Content")));
9
+ await waitFor(() => {
10
+ expect(screen.getByTestId('content')).toBeVisible();
11
+ });
12
+ });
13
+ test('does not render children when not visible', async () => {
14
+ render(React.createElement(Collapse, { isVisible: false },
15
+ React.createElement("div", { "data-testid": "content" }, "Content")));
16
+ expect(screen.queryByTestId('content')).not.toBeInTheDocument();
17
+ });
18
+ });
19
19
  //# sourceMappingURL=Collapse.test.js.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface CollapseProps {
2
3
  isVisible: boolean;
3
4
  children: React.ReactNode;
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=Collapse.types.js.map
@@ -1,2 +1,2 @@
1
- export { default } from './Collapse';
1
+ export { default } from './Collapse';
2
2
  //# sourceMappingURL=index.js.map