@seeqdev/qomponents 0.0.108 → 0.0.109

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 (96) hide show
  1. package/dist/Accordion/Accordion.js +8 -8
  2. package/dist/Accordion/Accordion.stories.js +114 -114
  3. package/dist/Accordion/Accordion.test.js +54 -54
  4. package/dist/Accordion/Accordion.types.js +1 -1
  5. package/dist/Accordion/index.js +1 -1
  6. package/dist/Alert/Alert.js +31 -31
  7. package/dist/Alert/Alert.stories.js +44 -44
  8. package/dist/Alert/Alert.test.js +50 -50
  9. package/dist/Alert/Alert.types.js +1 -1
  10. package/dist/Alert/index.js +1 -1
  11. package/dist/Button/Button.js +91 -91
  12. package/dist/Button/Button.stories.js +97 -97
  13. package/dist/Button/Button.test.js +48 -48
  14. package/dist/Button/Button.types.js +4 -4
  15. package/dist/Button/index.js +1 -1
  16. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +66 -66
  17. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +97 -97
  18. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +84 -84
  19. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -1
  20. package/dist/ButtonWithDropdown/index.js +1 -1
  21. package/dist/ButtonWithPopover/ButtonWithPopover.js +50 -50
  22. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +74 -74
  23. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +81 -81
  24. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +1 -1
  25. package/dist/ButtonWithPopover/index.js +1 -1
  26. package/dist/Checkbox/Checkbox.js +25 -25
  27. package/dist/Checkbox/Checkbox.stories.js +33 -33
  28. package/dist/Checkbox/Checkbox.test.js +93 -93
  29. package/dist/Checkbox/Checkbox.types.js +1 -1
  30. package/dist/Checkbox/index.js +1 -1
  31. package/dist/Icon/Icon.js +53 -53
  32. package/dist/Icon/Icon.stories.js +44 -44
  33. package/dist/Icon/Icon.test.js +54 -54
  34. package/dist/Icon/Icon.types.js +15 -15
  35. package/dist/Icon/index.js +1 -1
  36. package/dist/InputGroup/InputGroup.js +25 -25
  37. package/dist/InputGroup/InputGroup.stories.js +141 -141
  38. package/dist/InputGroup/InputGroup.test.js +42 -42
  39. package/dist/InputGroup/InputGroup.types.js +1 -1
  40. package/dist/InputGroup/index.js +1 -1
  41. package/dist/Modal/Modal.js +97 -97
  42. package/dist/Modal/Modal.stories.js +126 -126
  43. package/dist/Modal/Modal.test.js +107 -107
  44. package/dist/Modal/Modal.types.js +1 -1
  45. package/dist/Modal/index.js +1 -1
  46. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +47 -47
  47. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +79 -79
  48. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -72
  49. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -1
  50. package/dist/SeeqActionDropdown/index.js +1 -1
  51. package/dist/SeeqActionDropdown/variants.js +22 -22
  52. package/dist/Select/Select.js +173 -173
  53. package/dist/Select/Select.stories.js +79 -79
  54. package/dist/Select/Select.test.js +181 -181
  55. package/dist/Select/Select.types.js +1 -1
  56. package/dist/Select/index.js +2 -2
  57. package/dist/Tabs/Tabs.js +21 -21
  58. package/dist/Tabs/Tabs.stories.js +90 -90
  59. package/dist/Tabs/Tabs.test.js +90 -90
  60. package/dist/Tabs/Tabs.types.js +1 -1
  61. package/dist/Tabs/index.js +1 -1
  62. package/dist/TextArea/TextArea.js +24 -24
  63. package/dist/TextArea/TextArea.stories.js +45 -45
  64. package/dist/TextArea/TextArea.test.js +67 -67
  65. package/dist/TextArea/TextArea.types.js +1 -1
  66. package/dist/TextArea/index.js +1 -1
  67. package/dist/TextField/TextField.js +78 -78
  68. package/dist/TextField/TextField.stories.js +69 -69
  69. package/dist/TextField/TextField.test.js +38 -38
  70. package/dist/TextField/TextField.types.js +1 -1
  71. package/dist/TextField/index.js +1 -1
  72. package/dist/ToolbarButton/ToolbarButton.js +74 -74
  73. package/dist/ToolbarButton/ToolbarButton.stories.js +93 -93
  74. package/dist/ToolbarButton/ToolbarButton.test.js +92 -92
  75. package/dist/ToolbarButton/ToolbarButton.types.js +1 -1
  76. package/dist/ToolbarButton/index.js +1 -1
  77. package/dist/Tooltip/QTip.stories.js +44 -44
  78. package/dist/Tooltip/QTip.types.js +1 -1
  79. package/dist/Tooltip/QTipPerformance.stories.js +29 -29
  80. package/dist/Tooltip/Qtip.js +154 -154
  81. package/dist/Tooltip/Tooltip.js +30 -30
  82. package/dist/Tooltip/Tooltip.stories.js +31 -31
  83. package/dist/Tooltip/Tooltip.types.js +2 -2
  84. package/dist/Tooltip/TooltipPerformance.stories.js +29 -29
  85. package/dist/Tooltip/index.js +2 -2
  86. package/dist/Tooltip/qTip.utilities.js +10 -10
  87. package/dist/index.esm.js +30 -17
  88. package/dist/index.esm.js.map +1 -1
  89. package/dist/index.js +30 -17
  90. package/dist/index.js.map +1 -1
  91. package/dist/types.js +1 -1
  92. package/dist/utils/browserId.js +28 -28
  93. package/dist/utils/svg.js +19 -19
  94. package/dist/utils/validateStyleDimension.js +13 -13
  95. package/dist/utils/validateStyleDimension.test.js +19 -19
  96. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import { Root, Item, Trigger, Content } from '@radix-ui/react-accordion';
3
- const Accordion = ({ accordionItems, defaultValue, value, onItemSelect, disabled, extraClassNames, testId, }) => {
4
- return (React.createElement(Root, { className: `tw-rounded-md tw-w-full focus-visible:tw-outline-none ${extraClassNames || ''}`, type: "single", defaultValue: defaultValue, value: value, collapsible: true, "data-testid": testId, onValueChange: (_value) => onItemSelect(_value) }, accordionItems.map((item) => (React.createElement(Item, { className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-w-full`, key: item.value, disabled: disabled, value: item.value },
5
- React.createElement(Trigger, { disabled: disabled, className: `tw-w-full tw-cursor-default focus-visible:tw-outline-none` }, item.trigger),
6
- React.createElement(Content, { className: `data-[state=open]:tw-animate-slideDown data-[state=closed]:tw-animate-slideUp tw-overflow-hidden focus-visible:tw-outline-none ${item.contentClassNames || ''}` }, item.content))))));
7
- };
8
- export default Accordion;
1
+ import React from 'react';
2
+ import { Root, Item, Trigger, Content } from '@radix-ui/react-accordion';
3
+ const Accordion = ({ accordionItems, defaultValue, value, onItemSelect, disabled, extraClassNames, testId, }) => {
4
+ return (React.createElement(Root, { className: `tw-rounded-md tw-w-full focus-visible:tw-outline-none ${extraClassNames || ''}`, type: "single", defaultValue: defaultValue, value: value, collapsible: true, "data-testid": testId, onValueChange: (_value) => onItemSelect(_value) }, accordionItems.map((item) => (React.createElement(Item, { className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-w-full`, key: item.value, disabled: disabled, value: item.value },
5
+ React.createElement(Trigger, { disabled: disabled, className: `tw-w-full tw-cursor-default focus-visible:tw-outline-none` }, item.trigger),
6
+ React.createElement(Content, { className: `data-[state=open]:tw-animate-slideDown data-[state=closed]:tw-animate-slideUp tw-overflow-hidden focus-visible:tw-outline-none ${item.contentClassNames || ''}` }, item.content))))));
7
+ };
8
+ export default Accordion;
9
9
  //# sourceMappingURL=Accordion.js.map
@@ -1,115 +1,115 @@
1
- import React from 'react';
2
- import Accordion from './Accordion';
3
- import { QTip } from '../Tooltip/Qtip';
4
- import Icon from '../Icon';
5
- import Tabs from '../Tabs';
6
- import Button from '../Button';
7
- export default {
8
- title: 'Accordion',
9
- };
10
- const Trigger = ({ label }) => (React.createElement("div", { className: "tw-flex tw-justify-start tw-items-center tw-border-b tw-px-2 tw-text-sq-color-dark" },
11
- React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-color-dark tw-mr-[0.5rem] tw-text-[12px]", type: "text" }),
12
- label));
13
- const TriggerSecond = ({ label }) => (React.createElement("div", { className: "tw-flex tw-justify-between tw-items-center tw-border-b tw-px-2 tw-text-sq-color-dark tw-py-2" },
14
- label,
15
- React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-color-dark tw-mr-[0.5rem] tw-text-[12px]", type: "text" })));
16
- const renderData = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
17
- React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "This is a data tab to show details about your data. You can make changes to your account"),
18
- React.createElement(Button, { variant: "outline", label: "Save data" })));
19
- const renderTools = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
20
- React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "Make changes to your account here. Click save when you're done."),
21
- React.createElement(Button, { variant: "outline", label: "Save tools" })));
22
- const renderJournal = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
23
- React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "Make changes to your account here. Click save when you're done."),
24
- React.createElement(Button, { variant: "outline", label: "Save journal" })));
25
- const tabsList = [
26
- {
27
- id: 'data',
28
- label: 'Data',
29
- icon: 'fc-data',
30
- content: renderData(),
31
- },
32
- {
33
- id: 'tools',
34
- label: 'Tools',
35
- icon: 'fc-gears-2',
36
- content: renderTools(),
37
- },
38
- {
39
- id: 'journal',
40
- label: 'Journal',
41
- icon: 'fc-workbook-lock',
42
- content: renderJournal(),
43
- },
44
- ];
45
- export const AllAccordionVariants = () => {
46
- const [activeTab, setActiveTab] = React.useState('data');
47
- const [value, setValue] = React.useState('oranges');
48
- const accordionItems = [
49
- {
50
- value: 'oranges',
51
- id: 'oranges',
52
- itemTestId: 'oranges',
53
- trigger: React.createElement(Trigger, { label: "Oranges" }),
54
- content: (React.createElement("div", { className: "tw-p-2 tw-text-[13px] dark:tw-text-sq-white" }, "Oranges are the fruit of the citrus species Citrus \u00D7 sinensis in the family Rutaceae. They are also called sweet oranges to distinguish them from the related Citrus \u00D7 aurantium, referred to as bitter oranges. They are round and orange, and usually have a sour or bitter taste. Oranges are a good source of vitamin C.")),
55
- },
56
- {
57
- value: 'apples',
58
- id: 'apples',
59
- itemTestId: 'apples',
60
- trigger: React.createElement(Trigger, { label: "Apples" }),
61
- content: (React.createElement("div", null,
62
- React.createElement("div", { className: "tw-p-4" },
63
- React.createElement(Tabs, { stretchTabs: true, activeTab: activeTab, onTabSelect: setActiveTab, defaultActiveTab: "data", tabs: tabsList })))),
64
- },
65
- {
66
- value: 'bananas',
67
- id: 'bananas',
68
- trigger: React.createElement(Trigger, { label: "Bananas" }),
69
- itemTestId: 'bananas',
70
- content: (React.createElement("div", null, "A banana is an elongated, edible fruit \u2013 botanically a berry \u2013 produced by several kinds of large herbaceous flowering plants in the genus Musa. In some countries, bananas used for cooking may be called \"plantains\", distinguishing them from dessert bananas. The fruit is variable in size, color, and firmness, but is usually elongated and curved, with soft flesh rich in starch covered with a rind, which may be green, yellow, red, purple, or brown when ripe.")),
71
- },
72
- {
73
- value: 'pineapples',
74
- id: 'pineapples',
75
- trigger: React.createElement(Trigger, { label: "Pineapples" }),
76
- itemTestId: 'pineapples',
77
- content: (React.createElement("div", null, "The pineapple is a tropical plant with an edible fruit and the most economically significant plant in the family Bromeliaceae. The pineapple is indigenous to South America, where it has been cultivated for many centuries. The introduction of the pineapple to Europe in the 17th century made it a significant cultural icon of luxury. Since the 1820s, pineapple has been commercially grown in greenhouses and many tropical plantations.")),
78
- },
79
- ];
80
- const allAccordions = (isDark) => (React.createElement("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '' },
81
- React.createElement("div", { className: "tw-p-5 " },
82
- React.createElement(Accordion, { accordionItems: isDark
83
- ? accordionItems
84
- : accordionItems.map((item) => ({ ...item, trigger: React.createElement(TriggerSecond, { label: item.value.toUpperCase() }) })), value: value, testId: "basic-accordion1", onItemSelect: (value) => setValue(value) }))));
85
- const renderAllVariations = (isDark) => React.createElement("div", { className: "tw-p-4" }, allAccordions(isDark));
86
- return (React.createElement(React.Fragment, null,
87
- React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
88
- React.createElement(QTip, null),
89
- React.createElement("div", { className: "color_topic" },
90
- React.createElement("b", null, "Topic Colors"),
91
- renderAllVariations()),
92
- React.createElement("div", { className: "color_analysis" },
93
- React.createElement("b", null, "Analysis Colors"),
94
- renderAllVariations()),
95
- React.createElement("div", { className: "color_datalab" },
96
- React.createElement("b", null, "Datalab Colors"),
97
- renderAllVariations()),
98
- React.createElement("div", { className: "color_vantage" },
99
- React.createElement("b", null, "Vantage Colors"),
100
- renderAllVariations())),
101
- React.createElement("div", { className: "tw-dark tw-bg-sq-dark-background tw-grid tw-grid-cols-4 tw-gap-4 tw-py-4" },
102
- React.createElement("div", { className: "color_topic dark:tw-text-sq-white tw-text-center" },
103
- React.createElement("b", null, "Topic Colors"),
104
- renderAllVariations(true)),
105
- React.createElement("div", { className: "color_analysis dark:tw-text-sq-white tw-text-center" },
106
- React.createElement("b", null, "Analysis Colors"),
107
- renderAllVariations(true)),
108
- React.createElement("div", { className: "color_datalab dark:tw-text-sq-white tw-text-center" },
109
- React.createElement("b", null, "Datalab Colors"),
110
- renderAllVariations(true)),
111
- React.createElement("div", { className: "color_vantage dark:tw-text-sq-white tw-text-center" },
112
- React.createElement("b", null, "Vantage Colors"),
113
- renderAllVariations(true)))));
114
- };
1
+ import React from 'react';
2
+ import Accordion from './Accordion';
3
+ import { QTip } from '../Tooltip/Qtip';
4
+ import Icon from '../Icon';
5
+ import Tabs from '../Tabs';
6
+ import Button from '../Button';
7
+ export default {
8
+ title: 'Accordion',
9
+ };
10
+ const Trigger = ({ label }) => (React.createElement("div", { className: "tw-flex tw-justify-start tw-items-center tw-border-b tw-px-2 tw-text-sq-color-dark" },
11
+ React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-color-dark tw-mr-[0.5rem] tw-text-[12px]", type: "text" }),
12
+ label));
13
+ const TriggerSecond = ({ label }) => (React.createElement("div", { className: "tw-flex tw-justify-between tw-items-center tw-border-b tw-px-2 tw-text-sq-color-dark tw-py-2" },
14
+ label,
15
+ React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-color-dark tw-mr-[0.5rem] tw-text-[12px]", type: "text" })));
16
+ const renderData = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
17
+ React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "This is a data tab to show details about your data. You can make changes to your account"),
18
+ React.createElement(Button, { variant: "outline", label: "Save data" })));
19
+ const renderTools = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
20
+ React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "Make changes to your account here. Click save when you're done."),
21
+ React.createElement(Button, { variant: "outline", label: "Save tools" })));
22
+ const renderJournal = () => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
23
+ React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }, "Make changes to your account here. Click save when you're done."),
24
+ React.createElement(Button, { variant: "outline", label: "Save journal" })));
25
+ const tabsList = [
26
+ {
27
+ id: 'data',
28
+ label: 'Data',
29
+ icon: 'fc-data',
30
+ content: renderData(),
31
+ },
32
+ {
33
+ id: 'tools',
34
+ label: 'Tools',
35
+ icon: 'fc-gears-2',
36
+ content: renderTools(),
37
+ },
38
+ {
39
+ id: 'journal',
40
+ label: 'Journal',
41
+ icon: 'fc-workbook-lock',
42
+ content: renderJournal(),
43
+ },
44
+ ];
45
+ export const AllAccordionVariants = () => {
46
+ const [activeTab, setActiveTab] = React.useState('data');
47
+ const [value, setValue] = React.useState('oranges');
48
+ const accordionItems = [
49
+ {
50
+ value: 'oranges',
51
+ id: 'oranges',
52
+ itemTestId: 'oranges',
53
+ trigger: React.createElement(Trigger, { label: "Oranges" }),
54
+ content: (React.createElement("div", { className: "tw-p-2 tw-text-[13px] dark:tw-text-sq-white" }, "Oranges are the fruit of the citrus species Citrus \u00D7 sinensis in the family Rutaceae. They are also called sweet oranges to distinguish them from the related Citrus \u00D7 aurantium, referred to as bitter oranges. They are round and orange, and usually have a sour or bitter taste. Oranges are a good source of vitamin C.")),
55
+ },
56
+ {
57
+ value: 'apples',
58
+ id: 'apples',
59
+ itemTestId: 'apples',
60
+ trigger: React.createElement(Trigger, { label: "Apples" }),
61
+ content: (React.createElement("div", null,
62
+ React.createElement("div", { className: "tw-p-4" },
63
+ React.createElement(Tabs, { stretchTabs: true, activeTab: activeTab, onTabSelect: setActiveTab, defaultActiveTab: "data", tabs: tabsList })))),
64
+ },
65
+ {
66
+ value: 'bananas',
67
+ id: 'bananas',
68
+ trigger: React.createElement(Trigger, { label: "Bananas" }),
69
+ itemTestId: 'bananas',
70
+ content: (React.createElement("div", null, "A banana is an elongated, edible fruit \u2013 botanically a berry \u2013 produced by several kinds of large herbaceous flowering plants in the genus Musa. In some countries, bananas used for cooking may be called \"plantains\", distinguishing them from dessert bananas. The fruit is variable in size, color, and firmness, but is usually elongated and curved, with soft flesh rich in starch covered with a rind, which may be green, yellow, red, purple, or brown when ripe.")),
71
+ },
72
+ {
73
+ value: 'pineapples',
74
+ id: 'pineapples',
75
+ trigger: React.createElement(Trigger, { label: "Pineapples" }),
76
+ itemTestId: 'pineapples',
77
+ content: (React.createElement("div", null, "The pineapple is a tropical plant with an edible fruit and the most economically significant plant in the family Bromeliaceae. The pineapple is indigenous to South America, where it has been cultivated for many centuries. The introduction of the pineapple to Europe in the 17th century made it a significant cultural icon of luxury. Since the 1820s, pineapple has been commercially grown in greenhouses and many tropical plantations.")),
78
+ },
79
+ ];
80
+ const allAccordions = (isDark) => (React.createElement("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '' },
81
+ React.createElement("div", { className: "tw-p-5 " },
82
+ React.createElement(Accordion, { accordionItems: isDark
83
+ ? accordionItems
84
+ : accordionItems.map((item) => ({ ...item, trigger: React.createElement(TriggerSecond, { label: item.value.toUpperCase() }) })), value: value, testId: "basic-accordion1", onItemSelect: (value) => setValue(value) }))));
85
+ const renderAllVariations = (isDark) => React.createElement("div", { className: "tw-p-4" }, allAccordions(isDark));
86
+ return (React.createElement(React.Fragment, null,
87
+ React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
88
+ React.createElement(QTip, null),
89
+ React.createElement("div", { className: "color_topic" },
90
+ React.createElement("b", null, "Topic Colors"),
91
+ renderAllVariations()),
92
+ React.createElement("div", { className: "color_analysis" },
93
+ React.createElement("b", null, "Analysis Colors"),
94
+ renderAllVariations()),
95
+ React.createElement("div", { className: "color_datalab" },
96
+ React.createElement("b", null, "Datalab Colors"),
97
+ renderAllVariations()),
98
+ React.createElement("div", { className: "color_vantage" },
99
+ React.createElement("b", null, "Vantage Colors"),
100
+ renderAllVariations())),
101
+ React.createElement("div", { className: "tw-dark tw-bg-sq-dark-background tw-grid tw-grid-cols-4 tw-gap-4 tw-py-4" },
102
+ React.createElement("div", { className: "color_topic dark:tw-text-sq-white tw-text-center" },
103
+ React.createElement("b", null, "Topic Colors"),
104
+ renderAllVariations(true)),
105
+ React.createElement("div", { className: "color_analysis dark:tw-text-sq-white tw-text-center" },
106
+ React.createElement("b", null, "Analysis Colors"),
107
+ renderAllVariations(true)),
108
+ React.createElement("div", { className: "color_datalab dark:tw-text-sq-white tw-text-center" },
109
+ React.createElement("b", null, "Datalab Colors"),
110
+ renderAllVariations(true)),
111
+ React.createElement("div", { className: "color_vantage dark:tw-text-sq-white tw-text-center" },
112
+ React.createElement("b", null, "Vantage Colors"),
113
+ renderAllVariations(true)))));
114
+ };
115
115
  //# sourceMappingURL=Accordion.stories.js.map
@@ -1,55 +1,55 @@
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 Accordion from './Accordion';
6
- describe('Accordion', () => {
7
- const mockOnItemSelect = jest.fn();
8
- class Context {
9
- testId = 'buttonTestId';
10
- label = 'button label';
11
- props = {
12
- accordionItems: [
13
- {
14
- id: 'item1',
15
- value: 'item1',
16
- trigger: 'Item 1',
17
- content: 'Content 1',
18
- },
19
- {
20
- id: 'item2',
21
- value: 'item2',
22
- trigger: 'Item 2',
23
- content: 'Content 2',
24
- },
25
- ],
26
- defaultValue: 'item1',
27
- value: 'item1',
28
- onItemSelect: (key) => mockOnItemSelect(key),
29
- disabled: false,
30
- extraClassNames: 'extra-class',
31
- testId: this.testId,
32
- };
33
- }
34
- let tc;
35
- beforeEach(() => {
36
- tc = new Context();
37
- });
38
- const renderAccordion = (props) => render(React.createElement(Accordion, { ...props }));
39
- it('renders accordion items', () => {
40
- renderAccordion(tc.props);
41
- expect(screen.getByText('Item 1')).toBeInTheDocument();
42
- expect(screen.getByText('Item 2')).toBeInTheDocument();
43
- });
44
- it('renders accordion content', () => {
45
- renderAccordion(tc.props);
46
- expect(screen.getByText('Content 1')).toBeInTheDocument();
47
- expect(screen.queryByText('Content 2')).not.toBeInTheDocument();
48
- });
49
- it('calls onItemSelect when an item is selected', async () => {
50
- renderAccordion(tc.props);
51
- await userEvent.click(screen.getByText('Item 2'));
52
- expect(mockOnItemSelect).toHaveBeenCalledWith('item2');
53
- });
54
- });
1
+ 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 Accordion from './Accordion';
6
+ describe('Accordion', () => {
7
+ const mockOnItemSelect = jest.fn();
8
+ class Context {
9
+ testId = 'buttonTestId';
10
+ label = 'button label';
11
+ props = {
12
+ accordionItems: [
13
+ {
14
+ id: 'item1',
15
+ value: 'item1',
16
+ trigger: 'Item 1',
17
+ content: 'Content 1',
18
+ },
19
+ {
20
+ id: 'item2',
21
+ value: 'item2',
22
+ trigger: 'Item 2',
23
+ content: 'Content 2',
24
+ },
25
+ ],
26
+ defaultValue: 'item1',
27
+ value: 'item1',
28
+ onItemSelect: (key) => mockOnItemSelect(key),
29
+ disabled: false,
30
+ extraClassNames: 'extra-class',
31
+ testId: this.testId,
32
+ };
33
+ }
34
+ let tc;
35
+ beforeEach(() => {
36
+ tc = new Context();
37
+ });
38
+ const renderAccordion = (props) => render(React.createElement(Accordion, { ...props }));
39
+ it('renders accordion items', () => {
40
+ renderAccordion(tc.props);
41
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
42
+ expect(screen.getByText('Item 2')).toBeInTheDocument();
43
+ });
44
+ it('renders accordion content', () => {
45
+ renderAccordion(tc.props);
46
+ expect(screen.getByText('Content 1')).toBeInTheDocument();
47
+ expect(screen.queryByText('Content 2')).not.toBeInTheDocument();
48
+ });
49
+ it('calls onItemSelect when an item is selected', async () => {
50
+ renderAccordion(tc.props);
51
+ await userEvent.click(screen.getByText('Item 2'));
52
+ expect(mockOnItemSelect).toHaveBeenCalledWith('item2');
53
+ });
54
+ });
55
55
  //# sourceMappingURL=Accordion.test.js.map
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=Accordion.types.js.map
@@ -1,2 +1,2 @@
1
- export { default } from './Accordion';
1
+ export { default } from './Accordion';
2
2
  //# sourceMappingURL=index.js.map
@@ -1,32 +1,32 @@
1
- import React from 'react';
2
- import '../styles.css';
3
- import Icon from '../Icon';
4
- const baseClasses = 'tw-mx-auto tw-p-4 tw-leading-normal tw-outline-none tw-py-2 tw-px-3 tw-rounded-sm tw-w-full' +
5
- ' tw-border-solid tw-border tw-text-sm tw-flex tw-flex-col tw-justify-center tw-items-center';
6
- const darkTheme = 'dark:tw-bg-sq-colored-hover-dark dark:tw-text-sq-dark-text';
7
- const lightTheme = 'tw-text-sq-text-color tw-bg-sq-colored-hover';
8
- const errorClasses = 'tw-border-sq-danger-color';
9
- const borderColorClasses = 'tw-border-sq-color-dark';
10
- /**
11
- * Alert.
12
- */
13
- export const Alert = ({ children, dismissible = true, onClose, show = true, variant, testId, id, extraClassNames, }) => {
14
- const appliedTheme = {
15
- theme: `${lightTheme} ${darkTheme}`,
16
- danger: 'tw-text-sq-text-color tw-bg-sq-danger-color',
17
- warning: 'tw-bg-sq-bg-warning-color tw-text-sq-text-color',
18
- };
19
- const appliedBorderTheme = {
20
- theme: borderColorClasses,
21
- danger: errorClasses,
22
- warning: 'tw-border-none',
23
- };
24
- const appliedClasses = `${baseClasses} ${appliedTheme[variant]} ${extraClassNames} ${appliedBorderTheme[variant]}`;
25
- if (!show) {
26
- return React.createElement("div", null);
27
- }
28
- return (React.createElement("div", { "data-testid": testId, id: id, className: appliedClasses },
29
- dismissible && (React.createElement(Icon, { icon: "fc-delete", type: variant.match(/danger|warning/) ? 'color' : 'theme', color: variant.match(/danger|warning/) ? 'inherit' : undefined, extraClassNames: `tw-self-end tw-text-[11px] tw-cursor-pointer ${variant.match(/danger|warning/) ? 'tw-text-sq-text-color dark:tw-text-sq-text-color' : ''}`, testId: `${testId}-close-btn`, onClick: onClose })),
30
- children));
31
- };
1
+ import React from 'react';
2
+ import '../styles.css';
3
+ import Icon from '../Icon';
4
+ const baseClasses = 'tw-mx-auto tw-p-4 tw-leading-normal tw-outline-none tw-py-2 tw-px-3 tw-rounded-sm tw-w-full' +
5
+ ' tw-border-solid tw-border tw-text-sm tw-flex tw-flex-col tw-justify-center tw-items-center';
6
+ const darkTheme = 'dark:tw-bg-sq-colored-hover-dark dark:tw-text-sq-dark-text';
7
+ const lightTheme = 'tw-text-sq-text-color tw-bg-sq-colored-hover';
8
+ const errorClasses = 'tw-border-sq-danger-color';
9
+ const borderColorClasses = 'tw-border-sq-color-dark';
10
+ /**
11
+ * Alert.
12
+ */
13
+ export const Alert = ({ children, dismissible = true, onClose, show = true, variant, testId, id, extraClassNames, }) => {
14
+ const appliedTheme = {
15
+ theme: `${lightTheme} ${darkTheme}`,
16
+ danger: 'tw-text-sq-text-color tw-bg-sq-danger-color',
17
+ warning: 'tw-bg-sq-bg-warning-color tw-text-sq-text-color',
18
+ };
19
+ const appliedBorderTheme = {
20
+ theme: borderColorClasses,
21
+ danger: errorClasses,
22
+ warning: 'tw-border-none',
23
+ };
24
+ const appliedClasses = `${baseClasses} ${appliedTheme[variant]} ${extraClassNames} ${appliedBorderTheme[variant]}`;
25
+ if (!show) {
26
+ return React.createElement("div", null);
27
+ }
28
+ return (React.createElement("div", { "data-testid": testId, id: id, className: appliedClasses },
29
+ dismissible && (React.createElement(Icon, { icon: "fc-delete", type: variant.match(/danger|warning/) ? 'color' : 'theme', color: variant.match(/danger|warning/) ? 'inherit' : undefined, extraClassNames: `tw-self-end tw-text-[11px] tw-cursor-pointer ${variant.match(/danger|warning/) ? 'tw-text-sq-text-color dark:tw-text-sq-text-color' : ''}`, testId: `${testId}-close-btn`, onClick: onClose })),
30
+ children));
31
+ };
32
32
  //# sourceMappingURL=Alert.js.map
@@ -1,45 +1,45 @@
1
- import React from 'react';
2
- import { Alert } from './Alert';
3
- export default {
4
- title: 'Alert',
5
- };
6
- const colors = ['topic', 'analysis', 'datalab', 'vantage'];
7
- const renderAlert = ({ text, dismissable, variant, }) => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
8
- React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }),
9
- React.createElement(Alert, { variant: variant, dismissible: dismissable, show: true }, text)));
10
- export const AllAlertsVariants = () => {
11
- const renderAllVariations = (color) => (React.createElement("div", { key: color + '_wrapper' },
12
- React.createElement("div", { className: "tw-p-4" }, renderAlert({
13
- text: 'This is a dismissible alert, it looks very pleasing and is very useful for showing alerts to the user',
14
- dismissable: true,
15
- variant: 'theme',
16
- })),
17
- React.createElement("div", { className: "tw-p-4" }, renderAlert({
18
- text: 'This is a non dismissable alert, it looks very pleasing and is very useful for showing alerts to the user',
19
- dismissable: false,
20
- variant: 'theme',
21
- })),
22
- React.createElement("div", { className: "tw-p-4" }, renderAlert({
23
- text: 'This is a warning alert, it is used to display a warning',
24
- dismissable: false,
25
- variant: 'warning',
26
- })),
27
- React.createElement("div", { className: "tw-p-4" }, renderAlert({
28
- text: 'This is an error alert, it is used to display an error',
29
- dismissable: false,
30
- variant: 'danger',
31
- })),
32
- React.createElement("div", { className: "tw-p-4" }, renderAlert({
33
- text: 'This is an error alert that is dismissible, it is used to display an error',
34
- dismissable: true,
35
- variant: 'danger',
36
- }))));
37
- return (React.createElement("div", null,
38
- React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => {
39
- return React.createElement("div", { className: `color_${color}` }, renderAllVariations(color));
40
- })),
41
- React.createElement("div", { className: "tw-dark tw-bg-sq-dark-background tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => {
42
- return React.createElement("div", { className: `color_${color}` }, renderAllVariations(color));
43
- }))));
44
- };
1
+ import React from 'react';
2
+ import { Alert } from './Alert';
3
+ export default {
4
+ title: 'Alert',
5
+ };
6
+ const colors = ['topic', 'analysis', 'datalab', 'vantage'];
7
+ const renderAlert = ({ text, dismissable, variant, }) => (React.createElement("div", { className: "tw-text-sq-color-gray dark:tw-text-sq-white" },
8
+ React.createElement("p", { className: "tw-mb-5 tw-text-[15px] tw-leading-normal" }),
9
+ React.createElement(Alert, { variant: variant, dismissible: dismissable, show: true }, text)));
10
+ export const AllAlertsVariants = () => {
11
+ const renderAllVariations = (color) => (React.createElement("div", { key: color + '_wrapper' },
12
+ React.createElement("div", { className: "tw-p-4" }, renderAlert({
13
+ text: 'This is a dismissible alert, it looks very pleasing and is very useful for showing alerts to the user',
14
+ dismissable: true,
15
+ variant: 'theme',
16
+ })),
17
+ React.createElement("div", { className: "tw-p-4" }, renderAlert({
18
+ text: 'This is a non dismissable alert, it looks very pleasing and is very useful for showing alerts to the user',
19
+ dismissable: false,
20
+ variant: 'theme',
21
+ })),
22
+ React.createElement("div", { className: "tw-p-4" }, renderAlert({
23
+ text: 'This is a warning alert, it is used to display a warning',
24
+ dismissable: false,
25
+ variant: 'warning',
26
+ })),
27
+ React.createElement("div", { className: "tw-p-4" }, renderAlert({
28
+ text: 'This is an error alert, it is used to display an error',
29
+ dismissable: false,
30
+ variant: 'danger',
31
+ })),
32
+ React.createElement("div", { className: "tw-p-4" }, renderAlert({
33
+ text: 'This is an error alert that is dismissible, it is used to display an error',
34
+ dismissable: true,
35
+ variant: 'danger',
36
+ }))));
37
+ return (React.createElement("div", null,
38
+ React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => {
39
+ return React.createElement("div", { className: `color_${color}` }, renderAllVariations(color));
40
+ })),
41
+ React.createElement("div", { className: "tw-dark tw-bg-sq-dark-background tw-grid tw-grid-cols-4 tw-gap-4" }, colors.map((color) => {
42
+ return React.createElement("div", { className: `color_${color}` }, renderAllVariations(color));
43
+ }))));
44
+ };
45
45
  //# sourceMappingURL=Alert.stories.js.map