@seeqdev/qomponents 0.0.184 → 0.0.185

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/src/Accordion/Accordion.d.ts +4 -0
  2. package/dist/src/Accordion/Accordion.js +8 -0
  3. package/dist/src/Accordion/Accordion.stories.d.ts +5 -0
  4. package/dist/src/Accordion/Accordion.stories.js +96 -0
  5. package/dist/src/Accordion/Accordion.test.d.ts +1 -0
  6. package/dist/src/Accordion/Accordion.test.js +54 -0
  7. package/dist/src/Accordion/Accordion.types.d.ts +86 -0
  8. package/dist/src/Accordion/Accordion.types.js +1 -0
  9. package/dist/src/Accordion/index.d.ts +1 -0
  10. package/dist/src/Accordion/index.js +1 -0
  11. package/dist/src/Alert/Alert.d.ts +7 -0
  12. package/dist/src/Alert/Alert.js +33 -0
  13. package/dist/src/Alert/Alert.stories.d.ts +14 -0
  14. package/dist/src/Alert/Alert.stories.js +72 -0
  15. package/dist/src/Alert/Alert.test.d.ts +1 -0
  16. package/dist/src/Alert/Alert.test.js +49 -0
  17. package/dist/src/Alert/Alert.types.d.ts +62 -0
  18. package/dist/src/Alert/Alert.types.js +1 -0
  19. package/dist/src/Alert/index.d.ts +1 -0
  20. package/dist/src/Alert/index.js +1 -0
  21. package/dist/src/Button/Button.d.ts +10 -0
  22. package/dist/src/Button/Button.js +107 -0
  23. package/dist/src/Button/Button.stories.d.ts +9 -0
  24. package/dist/src/Button/Button.stories.js +74 -0
  25. package/dist/src/Button/Button.test.d.ts +1 -0
  26. package/dist/src/Button/Button.test.js +65 -0
  27. package/dist/src/Button/Button.types.d.ts +148 -0
  28. package/dist/src/Button/Button.types.js +4 -0
  29. package/dist/src/Button/index.d.ts +1 -0
  30. package/dist/src/Button/index.js +1 -0
  31. package/dist/src/ButtonGroup/ButtonGroup.d.ts +7 -0
  32. package/dist/src/ButtonGroup/ButtonGroup.js +34 -0
  33. package/dist/src/ButtonGroup/ButtonGroup.stories.d.ts +5 -0
  34. package/dist/src/ButtonGroup/ButtonGroup.stories.js +328 -0
  35. package/dist/src/ButtonGroup/ButtonGroup.test.d.ts +1 -0
  36. package/dist/src/ButtonGroup/ButtonGroup.test.js +65 -0
  37. package/dist/src/ButtonGroup/ButtonGroup.types.d.ts +80 -0
  38. package/dist/src/ButtonGroup/ButtonGroup.types.js +1 -0
  39. package/dist/src/ButtonGroup/index.d.ts +1 -0
  40. package/dist/src/ButtonGroup/index.js +1 -0
  41. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.d.ts +4 -0
  42. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.js +46 -0
  43. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.stories.d.ts +5 -0
  44. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.stories.js +119 -0
  45. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.test.d.ts +1 -0
  46. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -0
  47. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.types.d.ts +232 -0
  48. package/dist/src/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -0
  49. package/dist/src/ButtonWithDropdown/index.d.ts +1 -0
  50. package/dist/src/ButtonWithDropdown/index.js +1 -0
  51. package/dist/src/ButtonWithPopover/ButtonWithPopover.d.ts +4 -0
  52. package/dist/src/ButtonWithPopover/ButtonWithPopover.js +54 -0
  53. package/dist/src/ButtonWithPopover/ButtonWithPopover.stories.d.ts +5 -0
  54. package/dist/src/ButtonWithPopover/ButtonWithPopover.stories.js +51 -0
  55. package/dist/src/ButtonWithPopover/ButtonWithPopover.test.d.ts +1 -0
  56. package/dist/src/ButtonWithPopover/ButtonWithPopover.test.js +80 -0
  57. package/dist/src/ButtonWithPopover/ButtonWithPopover.types.d.ts +134 -0
  58. package/dist/src/ButtonWithPopover/ButtonWithPopover.types.js +1 -0
  59. package/dist/src/ButtonWithPopover/index.d.ts +1 -0
  60. package/dist/src/ButtonWithPopover/index.js +1 -0
  61. package/dist/src/Carousel/Carousel.d.ts +9 -0
  62. package/dist/src/Carousel/Carousel.js +80 -0
  63. package/dist/src/Carousel/Carousel.stories.d.ts +5 -0
  64. package/dist/src/Carousel/Carousel.stories.js +100 -0
  65. package/dist/src/Carousel/Carousel.test.d.ts +1 -0
  66. package/dist/src/Carousel/Carousel.test.js +47 -0
  67. package/dist/src/Carousel/Carousel.types.d.ts +85 -0
  68. package/dist/src/Carousel/Carousel.types.js +1 -0
  69. package/dist/src/Carousel/index.d.ts +1 -0
  70. package/dist/src/Carousel/index.js +1 -0
  71. package/dist/src/Checkbox/Checkbox.d.ts +7 -0
  72. package/dist/src/Checkbox/Checkbox.js +24 -0
  73. package/dist/src/Checkbox/Checkbox.stories.d.ts +5 -0
  74. package/dist/src/Checkbox/Checkbox.stories.js +21 -0
  75. package/dist/src/Checkbox/Checkbox.test.d.ts +1 -0
  76. package/dist/src/Checkbox/Checkbox.test.js +93 -0
  77. package/dist/src/Checkbox/Checkbox.types.d.ts +91 -0
  78. package/dist/src/Checkbox/Checkbox.types.js +1 -0
  79. package/dist/src/Checkbox/index.d.ts +1 -0
  80. package/dist/src/Checkbox/index.js +1 -0
  81. package/dist/src/Collapse/Collapse.d.ts +4 -0
  82. package/dist/src/Collapse/Collapse.js +16 -0
  83. package/dist/src/Collapse/Collapse.stories.d.ts +5 -0
  84. package/dist/src/Collapse/Collapse.stories.js +28 -0
  85. package/dist/src/Collapse/Collapse.test.d.ts +1 -0
  86. package/dist/src/Collapse/Collapse.test.js +16 -0
  87. package/dist/src/Collapse/Collapse.types.d.ts +18 -0
  88. package/dist/src/Collapse/Collapse.types.js +1 -0
  89. package/dist/src/Collapse/index.d.ts +1 -0
  90. package/dist/src/Collapse/index.js +1 -0
  91. package/dist/src/Icon/Icon.d.ts +10 -0
  92. package/dist/src/Icon/Icon.js +55 -0
  93. package/dist/src/Icon/Icon.stories.d.ts +5 -0
  94. package/dist/src/Icon/Icon.stories.js +31 -0
  95. package/dist/src/Icon/Icon.test.d.ts +1 -0
  96. package/dist/src/Icon/Icon.test.js +54 -0
  97. package/dist/src/Icon/Icon.types.d.ts +90 -0
  98. package/dist/src/Icon/Icon.types.js +15 -0
  99. package/dist/src/Icon/index.d.ts +1 -0
  100. package/dist/src/Icon/index.js +1 -0
  101. package/dist/src/InputGroup/InputGroup.d.ts +7 -0
  102. package/dist/src/InputGroup/InputGroup.js +33 -0
  103. package/dist/src/InputGroup/InputGroup.stories.d.ts +5 -0
  104. package/dist/src/InputGroup/InputGroup.stories.js +144 -0
  105. package/dist/src/InputGroup/InputGroup.test.d.ts +1 -0
  106. package/dist/src/InputGroup/InputGroup.test.js +41 -0
  107. package/dist/src/InputGroup/InputGroup.types.d.ts +61 -0
  108. package/dist/src/InputGroup/InputGroup.types.js +1 -0
  109. package/dist/src/InputGroup/index.d.ts +2 -0
  110. package/dist/src/InputGroup/index.js +1 -0
  111. package/dist/src/Modal/Modal.d.ts +5 -0
  112. package/dist/src/Modal/Modal.js +86 -0
  113. package/dist/src/Modal/Modal.stories.d.ts +10 -0
  114. package/dist/src/Modal/Modal.stories.js +79 -0
  115. package/dist/src/Modal/Modal.test.d.ts +1 -0
  116. package/dist/src/Modal/Modal.test.js +107 -0
  117. package/dist/src/Modal/Modal.types.d.ts +244 -0
  118. package/dist/src/Modal/Modal.types.js +1 -0
  119. package/dist/src/Modal/index.d.ts +1 -0
  120. package/dist/src/Modal/index.js +1 -0
  121. package/dist/src/ProgressBar/ProgressBar.d.ts +4 -0
  122. package/dist/src/ProgressBar/ProgressBar.js +71 -0
  123. package/dist/src/ProgressBar/ProgressBar.stories.d.ts +5 -0
  124. package/dist/src/ProgressBar/ProgressBar.stories.js +46 -0
  125. package/dist/src/ProgressBar/ProgressBar.test.d.ts +1 -0
  126. package/dist/src/ProgressBar/ProgressBar.test.js +42 -0
  127. package/dist/src/ProgressBar/ProgressBar.types.d.ts +77 -0
  128. package/dist/src/ProgressBar/ProgressBar.types.js +1 -0
  129. package/dist/src/ProgressBar/index.d.ts +1 -0
  130. package/dist/src/ProgressBar/index.js +1 -0
  131. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.d.ts +4 -0
  132. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.js +41 -0
  133. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.stories.d.ts +5 -0
  134. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.stories.js +73 -0
  135. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.test.d.ts +1 -0
  136. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -0
  137. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.types.d.ts +159 -0
  138. package/dist/src/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -0
  139. package/dist/src/SeeqActionDropdown/index.d.ts +1 -0
  140. package/dist/src/SeeqActionDropdown/index.js +1 -0
  141. package/dist/src/SeeqActionDropdown/variants.d.ts +5 -0
  142. package/dist/src/SeeqActionDropdown/variants.js +34 -0
  143. package/dist/src/Select/Select.d.ts +15 -0
  144. package/dist/src/Select/Select.js +171 -0
  145. package/dist/src/Select/Select.stories.d.ts +5 -0
  146. package/dist/src/Select/Select.stories.js +50 -0
  147. package/dist/src/Select/Select.test.d.ts +1 -0
  148. package/dist/src/Select/Select.test.js +176 -0
  149. package/dist/src/Select/Select.types.d.ts +220 -0
  150. package/dist/src/Select/Select.types.js +1 -0
  151. package/dist/src/Select/index.d.ts +2 -0
  152. package/dist/src/Select/index.js +2 -0
  153. package/dist/src/Slider/Slider.d.ts +6 -0
  154. package/dist/src/Slider/Slider.js +11 -0
  155. package/dist/src/Slider/Slider.stories.d.ts +5 -0
  156. package/dist/src/Slider/Slider.stories.js +37 -0
  157. package/dist/src/Slider/Slider.test.d.ts +1 -0
  158. package/dist/src/Slider/Slider.test.js +31 -0
  159. package/dist/src/Slider/Slider.types.d.ts +84 -0
  160. package/dist/src/Slider/Slider.types.js +1 -0
  161. package/dist/src/Slider/index.d.ts +1 -0
  162. package/dist/src/Slider/index.js +1 -0
  163. package/dist/src/SvgIcon/SvgIcon.d.ts +20 -0
  164. package/dist/src/SvgIcon/SvgIcon.js +27 -0
  165. package/dist/src/SvgIcon/SvgIcon.stories.d.ts +5 -0
  166. package/dist/src/SvgIcon/SvgIcon.stories.js +26 -0
  167. package/dist/src/SvgIcon/SvgIcon.test.d.ts +1 -0
  168. package/dist/src/SvgIcon/SvgIcon.test.js +40 -0
  169. package/dist/src/SvgIcon/SvgIcon.types.d.ts +75 -0
  170. package/dist/src/SvgIcon/SvgIcon.types.js +2 -0
  171. package/dist/src/SvgIcon/index.d.ts +1 -0
  172. package/dist/src/SvgIcon/index.js +1 -0
  173. package/dist/src/Tabs/Tabs.d.ts +4 -0
  174. package/dist/src/Tabs/Tabs.js +18 -0
  175. package/dist/src/Tabs/Tabs.stories.d.ts +5 -0
  176. package/dist/src/Tabs/Tabs.stories.js +83 -0
  177. package/dist/src/Tabs/Tabs.test.d.ts +1 -0
  178. package/dist/src/Tabs/Tabs.test.js +91 -0
  179. package/dist/src/Tabs/Tabs.types.d.ts +100 -0
  180. package/dist/src/Tabs/Tabs.types.js +1 -0
  181. package/dist/src/Tabs/index.d.ts +1 -0
  182. package/dist/src/Tabs/index.js +1 -0
  183. package/dist/src/TextArea/TextArea.d.ts +7 -0
  184. package/dist/src/TextArea/TextArea.js +54 -0
  185. package/dist/src/TextArea/TextArea.stories.d.ts +5 -0
  186. package/dist/src/TextArea/TextArea.stories.js +21 -0
  187. package/dist/src/TextArea/TextArea.test.d.ts +1 -0
  188. package/dist/src/TextArea/TextArea.test.js +129 -0
  189. package/dist/src/TextArea/TextArea.types.d.ts +115 -0
  190. package/dist/src/TextArea/TextArea.types.js +1 -0
  191. package/dist/src/TextArea/index.d.ts +1 -0
  192. package/dist/src/TextArea/index.js +1 -0
  193. package/dist/src/TextField/TextField.d.ts +7 -0
  194. package/dist/src/TextField/TextField.js +85 -0
  195. package/dist/src/TextField/TextField.stories.d.ts +5 -0
  196. package/dist/src/TextField/TextField.stories.js +30 -0
  197. package/dist/src/TextField/TextField.test.d.ts +1 -0
  198. package/dist/src/TextField/TextField.test.js +40 -0
  199. package/dist/src/TextField/TextField.types.d.ts +198 -0
  200. package/dist/src/TextField/TextField.types.js +1 -0
  201. package/dist/src/TextField/index.d.ts +1 -0
  202. package/dist/src/TextField/index.js +1 -0
  203. package/dist/src/ToolbarButton/ToolbarButton.d.ts +3 -0
  204. package/dist/src/ToolbarButton/ToolbarButton.js +58 -0
  205. package/dist/src/ToolbarButton/ToolbarButton.stories.d.ts +5 -0
  206. package/dist/src/ToolbarButton/ToolbarButton.stories.js +63 -0
  207. package/dist/src/ToolbarButton/ToolbarButton.test.d.ts +1 -0
  208. package/dist/src/ToolbarButton/ToolbarButton.test.js +89 -0
  209. package/dist/src/ToolbarButton/ToolbarButton.types.d.ts +122 -0
  210. package/dist/src/ToolbarButton/ToolbarButton.types.js +1 -0
  211. package/dist/src/ToolbarButton/index.d.ts +1 -0
  212. package/dist/src/ToolbarButton/index.js +1 -0
  213. package/dist/src/Tooltip/QTip.stories.d.ts +5 -0
  214. package/dist/src/Tooltip/QTip.stories.js +22 -0
  215. package/dist/src/Tooltip/QTip.types.d.ts +13 -0
  216. package/dist/src/Tooltip/QTip.types.js +1 -0
  217. package/dist/src/Tooltip/QTipPerformance.stories.d.ts +5 -0
  218. package/dist/src/Tooltip/QTipPerformance.stories.js +27 -0
  219. package/dist/src/Tooltip/Qtip.d.ts +26 -0
  220. package/dist/src/Tooltip/Qtip.js +168 -0
  221. package/dist/src/Tooltip/Tooltip.d.ts +13 -0
  222. package/dist/src/Tooltip/Tooltip.js +34 -0
  223. package/dist/src/Tooltip/Tooltip.stories.d.ts +5 -0
  224. package/dist/src/Tooltip/Tooltip.stories.js +20 -0
  225. package/dist/src/Tooltip/Tooltip.types.d.ts +22 -0
  226. package/dist/src/Tooltip/Tooltip.types.js +2 -0
  227. package/dist/src/Tooltip/TooltipPerformance.stories.d.ts +5 -0
  228. package/dist/src/Tooltip/TooltipPerformance.stories.js +25 -0
  229. package/dist/src/Tooltip/index.d.ts +2 -0
  230. package/dist/src/Tooltip/index.js +2 -0
  231. package/dist/src/Tooltip/qTip.utilities.d.ts +3 -0
  232. package/dist/src/Tooltip/qTip.utilities.js +10 -0
  233. package/dist/src/index.d.ts +46 -0
  234. package/dist/src/index.js +47 -0
  235. package/dist/src/setupTests.d.ts +1 -0
  236. package/dist/src/setupTests.js +5 -0
  237. package/dist/src/types.d.ts +27 -0
  238. package/dist/src/types.js +25 -0
  239. package/dist/src/utils/browserId.d.ts +9 -0
  240. package/dist/src/utils/browserId.js +28 -0
  241. package/dist/src/utils/svg.d.ts +15 -0
  242. package/dist/src/utils/svg.js +19 -0
  243. package/dist/src/utils/validateStyleDimension.d.ts +2 -0
  244. package/dist/src/utils/validateStyleDimension.js +13 -0
  245. package/dist/src/utils/validateStyleDimension.test.d.ts +1 -0
  246. package/dist/src/utils/validateStyleDimension.test.js +19 -0
  247. package/package.json +11 -5
@@ -0,0 +1,144 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { InputGroup } from './InputGroup';
3
+ import { QTip } from '../Tooltip/Qtip';
4
+ export default {
5
+ title: 'InputGroup',
6
+ };
7
+ export const AllTextFields = () => {
8
+ const renderAllVariations = () => (_jsxs(_Fragment, { children: [
9
+ _jsxs("div", { className: "light", children: [
10
+ _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { value: "value provided", append: [
11
+ {
12
+ variant: 'button',
13
+ buttonProps: {
14
+ icon: 'fc-annotate',
15
+ iconStyle: 'theme',
16
+ },
17
+ },
18
+ {
19
+ variant: 'button',
20
+ buttonProps: {
21
+ icon: 'fc-trash',
22
+ iconStyle: 'theme',
23
+ },
24
+ },
25
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
26
+ {
27
+ variant: 'button',
28
+ buttonProps: {
29
+ icon: 'fc-annotate',
30
+ iconStyle: 'theme',
31
+ },
32
+ },
33
+ {
34
+ variant: 'button',
35
+ buttonProps: {
36
+ icon: 'fc-trash',
37
+ iconStyle: 'theme',
38
+ },
39
+ },
40
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
41
+ {
42
+ variant: 'button',
43
+ buttonProps: {
44
+ icon: 'fc-annotate',
45
+ iconStyle: 'theme',
46
+ },
47
+ },
48
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with custom element", append: [
49
+ {
50
+ variant: 'element',
51
+ element: _jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", children: "Custom" }),
52
+ },
53
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "button input group", field: _jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", onClick: () => console.log('clicked'), children: "custom grouped element" }), append: [
54
+ {
55
+ variant: 'element',
56
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Custom" })),
57
+ },
58
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, field: _jsxs("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", children: [
59
+ _jsx("div", { className: "tw-rounded-sm tw-bg-green-400 ", children: "Custom element 1" }), _jsx("div", { className: "tw-rounded-sm tw-bg-red-400 tw-mt-1", onClick: () => console.log('clicked'), children: "Custom element 2" })
60
+ ] }), append: [
61
+ {
62
+ variant: 'element',
63
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Edit" })),
64
+ },
65
+ {
66
+ variant: 'element',
67
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Edit 2" })),
68
+ },
69
+ {
70
+ variant: 'element',
71
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Delete" })),
72
+ },
73
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, placeholder: "inputgroup without any appended element", tooltipPlacement: "top", isHtmlTooltip: false, append: [] }) })
74
+ ] }), _jsxs("div", { className: "tw-dark tw-bg-sq-dark-background", children: [
75
+ _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { value: "value provided", append: [
76
+ {
77
+ variant: 'button',
78
+ buttonProps: {
79
+ icon: 'fc-annotate',
80
+ iconStyle: 'theme',
81
+ },
82
+ },
83
+ {
84
+ variant: 'button',
85
+ buttonProps: {
86
+ icon: 'fc-trash',
87
+ iconStyle: 'theme',
88
+ },
89
+ },
90
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
91
+ {
92
+ variant: 'button',
93
+ buttonProps: {
94
+ icon: 'fc-annotate',
95
+ iconStyle: 'theme',
96
+ },
97
+ },
98
+ {
99
+ variant: 'button',
100
+ buttonProps: {
101
+ icon: 'fc-trash',
102
+ iconStyle: 'theme',
103
+ },
104
+ },
105
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with tooltip", append: [
106
+ {
107
+ variant: 'button',
108
+ buttonProps: {
109
+ icon: 'fc-annotate',
110
+ iconStyle: 'theme',
111
+ },
112
+ },
113
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "with custom element", append: [
114
+ {
115
+ variant: 'element',
116
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Custom" })),
117
+ },
118
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, value: "button input group", field: _jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", onClick: () => console.log('clicked'), children: "custom grouped element" }), append: [
119
+ {
120
+ variant: 'element',
121
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Custom" })),
122
+ },
123
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, field: _jsxs("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background", children: [
124
+ _jsx("div", { className: "tw-rounded-sm tw-bg-green-400 dark:tw-text-sq-dark-text", children: "Custom element 1" }), _jsx("div", { className: "tw-rounded-sm tw-bg-red-400 dark:tw-text-sq-dark-text tw-mt-1", onClick: () => console.log('clicked'), children: "Custom element 2" })
125
+ ] }), append: [
126
+ {
127
+ variant: 'element',
128
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Edit" })),
129
+ },
130
+ {
131
+ variant: 'element',
132
+ element: (_jsx("div", { className: "tw-text-sm tw-p-1 tw-bg-sq-light-background dark:tw-text-sq-dark-text", children: "Delete" })),
133
+ },
134
+ ] }) }), _jsx("div", { className: "tw-p-4", children: _jsx(InputGroup, { tooltip: "This is a small input group.", tooltipDelay: 0, placeholder: "inputgroup without any appended element", tooltipPlacement: "top", isHtmlTooltip: false, append: [] }) })
135
+ ] })
136
+ ] }));
137
+ return (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
138
+ _jsx(QTip, {}), _jsxs("div", { className: "color_topic", children: [
139
+ _jsx("b", { children: "Topic Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_analysis", children: [
140
+ _jsx("b", { children: "Analysis Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_datalab", children: [
141
+ _jsx("b", { children: "Datalab Colors" }), renderAllVariations()] }), _jsxs("div", { className: "color_vantage", children: [
142
+ _jsx("b", { children: "Vantage Colors" }), renderAllVariations()] })
143
+ ] }));
144
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render } from '@testing-library/react';
3
+ import { InputGroup } from './InputGroup';
4
+ describe('InputGroup', () => {
5
+ const defaultProps = {
6
+ value: 'with tooltip',
7
+ append: [
8
+ {
9
+ variant: 'button',
10
+ buttonProps: {
11
+ icon: 'fc-annotate',
12
+ iconStyle: 'theme',
13
+ },
14
+ },
15
+ ],
16
+ extraClassNames: 'extra-class',
17
+ tooltip: 'Tooltip title',
18
+ tooltipDelay: 0,
19
+ id: 'input-group-id',
20
+ testId: 'input-group-test-id',
21
+ };
22
+ it('renders without crashing', () => {
23
+ const { getByTestId } = render(_jsx(InputGroup, { ...defaultProps }));
24
+ expect(getByTestId('input-group-test-id')).toBeInTheDocument();
25
+ });
26
+ it('applies the correct classes', () => {
27
+ const { getByTestId } = render(_jsx(InputGroup, { ...defaultProps }));
28
+ const inputGroup = getByTestId('input-group-test-id');
29
+ expect(inputGroup).toHaveClass('tw-flex');
30
+ expect(inputGroup).toHaveClass('tw-outline-none');
31
+ expect(inputGroup).toHaveClass('extra-class');
32
+ });
33
+ it('renders append items', () => {
34
+ const { getByRole } = render(_jsx(InputGroup, { ...defaultProps }));
35
+ expect(getByRole('button')).toBeInTheDocument();
36
+ });
37
+ it('renders input element', () => {
38
+ const { container } = render(_jsx(InputGroup, { ...defaultProps }));
39
+ expect(container.querySelector('input[type="text"]')).toBeInTheDocument();
40
+ });
41
+ });
@@ -0,0 +1,61 @@
1
+ import { ButtonProps } from '../Button/Button.types';
2
+ import { InputLengthStyleProps, TextFieldProps } from '../TextField/TextField.types';
3
+ import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
4
+ /**
5
+ * Interface for button elements that can be appended to an InputGroup.
6
+ * Used when you want to add interactive buttons alongside the input field.
7
+ */
8
+ interface AppendedButtonProps {
9
+ /**
10
+ * Specifies that this appended item is an interactive button.
11
+ * Button items can trigger actions and provide additional functionality to the input.
12
+ */
13
+ variant: 'button';
14
+ /**
15
+ * Configuration properties for the button component.
16
+ * Uses all standard Button props including click handlers, styling, icons, and tooltips.
17
+ */
18
+ buttonProps: ButtonProps;
19
+ }
20
+ /**
21
+ * Interface for custom React elements that can be appended to an InputGroup.
22
+ * Used when you need to add non-button content like icons, labels, or decorative elements.
23
+ */
24
+ interface ElementProps {
25
+ /**
26
+ * Specifies that this appended item is a custom React element.
27
+ * Element items are typically decorative or informational and don't have built-in interactivity.
28
+ */
29
+ variant: 'element';
30
+ /**
31
+ * The React content to render alongside the input field.
32
+ * Can be any valid React node including text, icons, indicators, or complex components.
33
+ */
34
+ element: React.ReactNode;
35
+ }
36
+ export type AppendedProps = AppendedButtonProps | ElementProps | undefined;
37
+ /**
38
+ * Base interface for InputGroup component properties.
39
+ * Extends TextFieldProps to inherit all text input functionality while adding group-specific features.
40
+ */
41
+ interface BaseInputGroupProps extends TextFieldProps {
42
+ /**
43
+ * Array of elements to append to the right side of the input field.
44
+ * Each item can be either a button (for interactive functionality) or an element (for decoration).
45
+ * Items are displayed in the order they appear in the array, creating a cohesive input group.
46
+ */
47
+ append: AppendedProps[];
48
+ /**
49
+ * Custom input field component to render instead of the default TextField.
50
+ * Use this when you need specialized input behavior while maintaining the group styling.
51
+ * The field will be integrated seamlessly with the appended elements.
52
+ */
53
+ field?: React.ReactNode;
54
+ }
55
+ /**
56
+ * Complete props interface for the InputGroup component.
57
+ * Combines base input group functionality with tooltip support and text length constraints.
58
+ * Creates a cohesive input control with attached buttons or decorative elements.
59
+ */
60
+ export type InputGroupProps = BaseInputGroupProps & TooltipComponentProps & InputLengthStyleProps;
61
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { InputGroup as default } from './InputGroup';
2
+ export type { AppendedProps } from './InputGroup.types';
@@ -0,0 +1 @@
1
+ export { InputGroup as default } from './InputGroup';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import '../styles.css';
3
+ import { ModalProps } from './Modal.types';
4
+ declare const Modal: React.FunctionComponent<ModalProps>;
5
+ export default Modal;
@@ -0,0 +1,86 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useEffect, useState } from 'react';
3
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
4
+ import classNames from 'classnames';
5
+ import '../styles.css';
6
+ import Button from '../Button';
7
+ import Icon from '../Icon';
8
+ import TextField from '../TextField';
9
+ const Dialog = DialogPrimitive.Root;
10
+ const DialogPortal = DialogPrimitive.Portal;
11
+ const DialogClose = DialogPrimitive.Close;
12
+ const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(DialogPortal, { children: [
13
+ _jsx("div", { className: "tw-select-none tw-fixed tw-w-full tw-h-full tw-opacity-50 tw-inset-0 tw-z-[1009] tw-bg-sq-dark-background\n data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0\n data-[state=open]:fade-in-0 " }), _jsxs(DialogPrimitive.Content, { ref: ref, className: `tw-fixed tw-left-[50%] tw-top-0 tw-my-6 tw-translate-x-[-50%] tw-z-[1010] tw-grid
14
+ tw-gap-4 tw-border tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-6 tw-shadow-lg tw-duration-200
15
+ tw-rounded-lg ${className}`, ...props, children: [
16
+ _jsx(DialogPrimitive.DialogTitle, { className: "tw-hidden" }), children] })
17
+ ] })));
18
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
19
+ const DialogHeader = (props) => (_jsx("div", { className: "tw-w-full tw-justify-between", children: _jsx("div", { ...props }) }));
20
+ DialogHeader.displayName = 'DialogHeader';
21
+ const DialogFooter = (props) => _jsx("div", { ...props });
22
+ DialogFooter.displayName = 'DialogFooter';
23
+ const DialogTitle = React.forwardRef((props, ref) => _jsx(DialogPrimitive.Title, { ref: ref, ...props }));
24
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
25
+ const DialogDescription = React.forwardRef((props, ref) => _jsx(DialogPrimitive.Description, { ref: ref, ...props }));
26
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
27
+ const Modal = ({ titleIcon, title = 'Modal title example', titleSuffixLabel, subtitle, children, open = false, onClose, customButton = false, customButtonLabel = 'Back', onClickCustomButton, submitButtonLabel = 'Submit', cancelButtonLabel = 'Cancel', disableSubmitButton = false, stopPropagationSubmitButton = false, onSubmit, isTitleEditable = false, onTitleChanged, inputExtraClassNames, hideCloseIcon = false, size = 'xl', titleIconPosition = 'left', hideFooterButtons = false, hideSubmitButton = false, hideCancelButton = false, testId = 'modal', modalFooter, dialogClassName, titlePlaceholder, titleRequired, titleError, submitButtonTooltip, cancelButtonTooltip, disableCustomButton, customHeader, middleFooterSection = _jsx(_Fragment, {}), customButtonVariant = 'outline', submitButtonVariant = 'theme', keepFocusInsideModal = true, onPointerDownOutside, onInteractOutside, }) => {
28
+ const [isLoading, setIsLoading] = useState(false);
29
+ // the Dialog is adding pointerEvents: none to body and the dropdowns from the modal does not work anymore
30
+ useEffect(() => {
31
+ if (open) {
32
+ // Pushing the change to the end of the call stack
33
+ const timer = setTimeout(() => {
34
+ document.body.style.pointerEvents = '';
35
+ }, 0);
36
+ return () => clearTimeout(timer);
37
+ }
38
+ else {
39
+ document.body.style.pointerEvents = 'auto';
40
+ }
41
+ }, [open]);
42
+ const handleSubmit = async (e) => {
43
+ if (!onSubmit)
44
+ return;
45
+ try {
46
+ setIsLoading(true);
47
+ await onSubmit(e);
48
+ }
49
+ finally {
50
+ setIsLoading(false);
51
+ }
52
+ };
53
+ const renderTitle = () => {
54
+ let titleIconElement = _jsx(_Fragment, {});
55
+ if (titleIcon) {
56
+ if (typeof titleIcon === 'string') {
57
+ titleIconElement = (_jsx(Icon, { icon: titleIcon, testId: "modalTitleIcon", extraClassNames: "tw-flex tw-text-xl tw-mt-1" }));
58
+ }
59
+ else {
60
+ titleIconElement = _jsx("div", { className: "tw-mt-1.5", children: titleIcon });
61
+ }
62
+ }
63
+ return (_jsxs(_Fragment, { children: [titleIcon && titleIconPosition === 'left' ? _jsx("div", { className: "tw-flex tw-mr-2", children: titleIconElement }) : _jsx(_Fragment, {}), _jsx(DialogTitle, { asChild: true, children: isTitleEditable ? (_jsxs("div", { className: "tw-flex tw-w-full tw-items-center", children: [
64
+ _jsx(TextField, { extraClassNames: inputExtraClassNames, value: title, type: "text", testId: "modalTitle", onChange: onTitleChanged, placeholder: titlePlaceholder, required: titleRequired, showError: !!titleError }), titleError && _jsx("p", { className: "tw-text-sq-danger-color tw-min-w-fit tw-pl-2 tw-mb-0", children: titleError })] })) : (customHeader ?? (_jsxs("div", { "data-testid": "modalTitle", className: "modal-title", children: [
65
+ _jsxs("div", { className: "tw-flex tw-items-center", children: [
66
+ _jsx("h3", { children: title }), titleSuffixLabel && _jsx("span", { className: "tw-text-xl tw-pl-0.5", children: titleSuffixLabel })] }), subtitle && (_jsx("div", { className: "tw-italic tw-text-sm tw-text-left tw-mt-1", "data-testid": "modal-subtitle", children: subtitle }))] }))) }), titleIcon && titleIconPosition === 'right' ? _jsx("div", { className: "tw-flex tw-ml-4", children: titleIconElement }) : _jsx(_Fragment, {})] }));
67
+ };
68
+ return open ? (_jsx(Dialog, { open: true, onOpenChange: onClose, modal: keepFocusInsideModal, children: _jsxs(DialogContent, { onPointerDownOutside: (e) => (onPointerDownOutside ? onPointerDownOutside(e) : e.preventDefault()), onInteractOutside: (e) => (onInteractOutside ? onInteractOutside(e) : e.preventDefault()), "data-testid": testId, className: classNames(`modalContent tw-w-full !tw-p-0 tw-border-none tw-shadow-none dark:tw-text-sq-dark-text !tw-gap-0`, {
69
+ 'tw-max-w-xs': size === 'xs',
70
+ 'tw-max-w-sm': size === 'sm',
71
+ 'tw-max-w-md': size === 'md',
72
+ 'tw-max-w-lg': size === 'lg',
73
+ 'tw-max-w-xl': size === 'xl',
74
+ 'tw-max-w-2xl': size === '2xl',
75
+ 'tw-max-w-3xl': size === '3xl',
76
+ 'tw-max-w-4xl': size === '4xl',
77
+ 'tw-max-w-5xl': size === '5xl',
78
+ 'tw-max-w-6xl': size === '6xl',
79
+ }, dialogClassName), children: [
80
+ _jsxs(DialogHeader, { className: "modal-header tw-flex tw-w-full tw-justify-between tw-border-sq-disabled-gray\n dark:tw-border-sq-dark-disabled-gray tw-border-0 tw-border-b tw-px-6 tw-py-4", children: [
81
+ _jsx("div", { className: "tw-flex tw-w-full", children: renderTitle() }), !hideCloseIcon && (_jsx(DialogClose, { autoFocus: false, className: "[&:has(:focus-visible)]:none tw-opacity-70 tw-bg-transparent hover:tw-opacity-100 close tw-text-base tw-cursor-pointer tw-ml-4", "data-testid": "closeButton", children: _jsx("span", { className: "tw-cursor-pointer", children: "\u00D7" }) }))] }), _jsx(DialogDescription, { className: "modal-body tw-px-6 tw-py-4 tw-overflow-y-auto", asChild: true, children: children }), !hideFooterButtons && (_jsx(DialogFooter, { className: "modal-footer tw-px-6 tw-py-4", children: modalFooter ?? (_jsxs("div", { className: "tw-flex tw-w-full tw-justify-between", "data-testid": "modalFooter", children: [
82
+ _jsx("div", { className: "tw-flex tw-justify-start", children: customButton && (_jsx(Button, { label: customButtonLabel, onClick: onClickCustomButton, disabled: disableCustomButton, extraClassNames: "tw-justify-start tw-min-w-[100px]", testId: "customButton", variant: customButtonVariant })) }), _jsxs("div", { className: "tw-flex tw-justify-end", children: [
83
+ _jsx("div", { className: "tw-flex tw-items-center", children: middleFooterSection }), !hideCancelButton && (_jsx(DialogClose, { asChild: true, children: _jsx(Button, { label: cancelButtonLabel, extraClassNames: "tw-mr-5 tw-min-w-[100px]", tooltip: cancelButtonTooltip, variant: "outline", stopPropagation: false, testId: "cancelButton" }) })), !hideSubmitButton && (_jsx(Button, { label: submitButtonLabel, onClick: handleSubmit, disabled: disableSubmitButton || isLoading, variant: submitButtonVariant, stopPropagation: stopPropagationSubmitButton, tooltip: submitButtonTooltip, icon: isLoading ? 'fc-loading-notch tw-animate-spin' : undefined, iconPosition: "left", testId: "submitButton", extraClassNames: "tw-min-w-[100px]" }))] })
84
+ ] })) }))] }) })) : (_jsx(_Fragment, {}));
85
+ };
86
+ export default Modal;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const AllModalsVariants: React.FunctionComponent;
7
+ export declare const ModalsWithDisabledSubmit: React.FunctionComponent;
8
+ export declare const ModalsWithEditableTitle: React.FunctionComponent;
9
+ export declare const ModalsWithCustomButton: React.FunctionComponent;
10
+ export declare const ModalsWithVariantButton: React.FunctionComponent;
@@ -0,0 +1,79 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import Modal from './Modal';
4
+ import Button from '../Button';
5
+ export default {
6
+ title: 'Modal',
7
+ };
8
+ const modalBody = (_jsx("div", { children: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." }));
9
+ const waitUntil = async (timeout) => {
10
+ return new Promise((resolve) => {
11
+ setTimeout(() => resolve('yes'), timeout);
12
+ });
13
+ };
14
+ const ModalComponent = ({ bodyClass = '', title: originalTitle, titleIcon, isTitleEditable, children, hideCloseIcon, disableSubmitButton, size, buttonLabel = 'Open Modal', customButton, customButtonLabel, submitButtonVariant, onSubmit, }) => {
15
+ const [open, setOpen] = useState(false);
16
+ const [title, setTitle] = useState(originalTitle);
17
+ useEffect(() => {
18
+ return () => {
19
+ document.body.className = '';
20
+ };
21
+ }, []);
22
+ const onClose = () => {
23
+ document.body.className = '';
24
+ setOpen(false);
25
+ };
26
+ return (_jsxs("div", { className: "tw-p-4", children: [
27
+ _jsx(Button, { onClick: () => {
28
+ document.body.className = bodyClass;
29
+ setOpen(true);
30
+ }, label: buttonLabel }), _jsx(Modal, { open: open, onClose: onClose, title: title, titleIcon: titleIcon, isTitleEditable: isTitleEditable, onTitleChanged: (event) => setTitle(event.target.value), hideCloseIcon: hideCloseIcon, disableSubmitButton: disableSubmitButton, size: size, onSubmit: onSubmit, customButton: customButton, submitButtonVariant: submitButtonVariant, onPointerDownOutside: onClose, customButtonLabel: customButtonLabel, children: children })
31
+ ] }));
32
+ };
33
+ export const AllModalsVariants = () => {
34
+ const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
35
+ const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
36
+ return (_jsx("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: colors.map((color) => (_jsxs("div", { children: [
37
+ _jsxs("b", { children: [color, " colors"] }), _jsx("div", { className: "tw-p-4 light", children: sizes.map((size) => (_jsx(ModalComponent, { bodyClass: `color_${color.toLowerCase()}`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` }, `${size}_${color}`))) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: sizes.map((size) => (_jsx(ModalComponent, { bodyClass: `color_${color.toLowerCase()} tw-dark color_${color.toLowerCase()}_dark`, title: "Modal example", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` }, `${size}_${color}_dark`))) })
38
+ ] }, color))) }));
39
+ };
40
+ export const ModalsWithDisabledSubmit = () => (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
41
+ _jsxs("div", { children: [
42
+ _jsx("b", { children: "Topic Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_topic", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
43
+ ] }), _jsxs("div", { children: [
44
+ _jsx("b", { children: "Analysis Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_analysis", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
45
+ ] }), _jsxs("div", { children: [
46
+ _jsx("b", { children: "Datalab Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_datalab", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
47
+ ] }), _jsxs("div", { children: [
48
+ _jsx("b", { children: "Vantage Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_vantage", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Disabled submit button example", disableSubmitButton: true, children: modalBody }) })
49
+ ] })
50
+ ] }));
51
+ export const ModalsWithEditableTitle = () => {
52
+ const colors = ['Topic', 'Analysis', 'Datalab', 'Vantage'];
53
+ const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
54
+ return (_jsx("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: colors.map((color) => (_jsxs("div", { children: [
55
+ _jsxs("b", { children: [color, " colors"] }), _jsx("div", { className: "tw-p-4 light", children: sizes.map((size) => (_jsx(ModalComponent, { bodyClass: `color_${color.toLowerCase()}`, title: "Editable title example", isTitleEditable: true, titleIcon: "fc-check", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` }, `${size}_${color}`))) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: sizes.map((size) => (_jsx(ModalComponent, { bodyClass: `color_${color.toLowerCase()} tw-dark color_${color.toLowerCase()}_dark`, title: "Editable title example", isTitleEditable: true, titleIcon: "fc-check", children: modalBody, size: size, buttonLabel: `Open ${size} size modal` }, `${size}_${color}_dark`))) })
56
+ ] }, color))) }));
57
+ };
58
+ export const ModalsWithCustomButton = () => (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
59
+ _jsxs("div", { children: [
60
+ _jsx("b", { children: "Topic Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
61
+ ] }), _jsxs("div", { children: [
62
+ _jsx("b", { children: "Analysis Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
63
+ ] }), _jsxs("div", { children: [
64
+ _jsx("b", { children: "Datalab Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
65
+ ] }), _jsxs("div", { children: [
66
+ _jsx("b", { children: "Vantage Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back" }) })
67
+ ] })
68
+ ] }));
69
+ export const ModalsWithVariantButton = () => (_jsxs("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4", children: [
70
+ _jsxs("div", { children: [
71
+ _jsx("b", { children: "Topic Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_topic", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_topic tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "theme-light" }) })
72
+ ] }), _jsxs("div", { children: [
73
+ _jsx("b", { children: "Analysis Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_analysis", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "warning" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_analysis tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "danger", customButtonLabel: "Back" }) })
74
+ ] }), _jsxs("div", { children: [
75
+ _jsx("b", { children: "Datalab Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_datalab", title: "Modal with custom button", children: modalBody, customButton: true, customButtonLabel: "Back", submitButtonVariant: "outline" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_datalab tw-dark color_analysis_dark", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "no-border", customButtonLabel: "Back" }) })
76
+ ] }), _jsxs("div", { children: [
77
+ _jsx("b", { children: "Vantage Colors" }), _jsx("div", { className: "tw-p-4 light", children: _jsx(ModalComponent, { bodyClass: "color_vantage", title: "Modal with custom button", children: modalBody, customButton: true, submitButtonVariant: "theme", customButtonLabel: "Back" }) }), _jsx("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background", children: _jsx(ModalComponent, { bodyClass: "color_vantage tw-dark color_vantage_dark", title: "Modal with custom button", children: modalBody, submitButtonVariant: "outline", customButton: true, customButtonLabel: "Back" }) })
78
+ ] })
79
+ ] }));
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+ import Modal from './Modal';
6
+ describe('Modal', () => {
7
+ class Context {
8
+ props = {
9
+ onTitleChanged: jest.fn(),
10
+ disableSubmitButton: false,
11
+ title: 'Testing Modal Dialog',
12
+ children: _jsx("div", { children: "Modal content" }),
13
+ open: true,
14
+ };
15
+ }
16
+ let tc;
17
+ beforeEach(() => {
18
+ tc = new Context();
19
+ });
20
+ const renderModal = (props) => render(_jsx(Modal, { ...props }));
21
+ describe('renders Modal', () => {
22
+ it("doesn't render the modal if the open state is false", () => {
23
+ const open = false;
24
+ renderModal({ ...tc.props, open });
25
+ expect(screen.queryByTestId('modal')).not.toBeInTheDocument();
26
+ });
27
+ it('renders the modal if the open state is true', () => {
28
+ renderModal(tc.props);
29
+ expect(screen.getByTestId('modal')).toBeInTheDocument();
30
+ expect(screen.getByTestId('modal')).toHaveClass('tw-max-w-xl');
31
+ });
32
+ it('calls onClose modal when close button is clicked', async () => {
33
+ const onClose = jest.fn();
34
+ const { getByTestId } = renderModal({ ...tc.props, onClose });
35
+ expect(screen.getByTestId('modal')).toBeInTheDocument();
36
+ await userEvent.click(getByTestId('closeButton'));
37
+ expect(onClose).toHaveBeenCalled();
38
+ });
39
+ it('hides close button', () => {
40
+ const hideCloseIcon = true;
41
+ const { queryByTestId } = renderModal({ ...tc.props, hideCloseIcon });
42
+ expect(queryByTestId('closeButton')).not.toBeInTheDocument();
43
+ });
44
+ it('renders modal size based on the size prop', () => {
45
+ const size = 'lg';
46
+ renderModal({ ...tc.props, size });
47
+ expect(screen.getByTestId('modal')).toHaveClass('tw-max-w-lg');
48
+ });
49
+ it('renders not editable title', () => {
50
+ renderModal(tc.props);
51
+ expect(screen.getByTestId('modalTitle')).not.toHaveAttribute('value');
52
+ });
53
+ it('renders editable title', () => {
54
+ const isTitleEditable = true;
55
+ const { getByTestId } = renderModal({ ...tc.props, isTitleEditable });
56
+ expect(getByTestId('modalTitle')).toHaveAttribute('value');
57
+ });
58
+ it('calls onChange when title is modified', async () => {
59
+ const isTitleEditable = true;
60
+ const { getByTestId } = renderModal({ ...tc.props, isTitleEditable });
61
+ await userEvent.type(getByTestId('modalTitle'), 'a');
62
+ expect(tc.props.onTitleChanged).toHaveBeenCalled();
63
+ });
64
+ it('displays icon title', () => {
65
+ const titleIcon = 'fc-check';
66
+ const { getByTestId } = renderModal({ ...tc.props, titleIcon });
67
+ expect(getByTestId('modalTitleIcon')).toBeInTheDocument();
68
+ });
69
+ it('calls onSubmit when submit button is clicked', async () => {
70
+ const onSubmit = jest.fn();
71
+ const { getByTestId } = renderModal({ ...tc.props, onSubmit });
72
+ expect(getByTestId('submitButton')).not.toBeDisabled();
73
+ await userEvent.click(getByTestId('submitButton'));
74
+ expect(onSubmit).toHaveBeenCalled();
75
+ });
76
+ it('displays the disabled submit button', async () => {
77
+ const onSubmit = jest.fn();
78
+ const disableSubmitButton = true;
79
+ const { getByTestId } = renderModal({ ...tc.props, onSubmit, disableSubmitButton });
80
+ expect(getByTestId('submitButton')).toBeDisabled();
81
+ await userEvent.click(getByTestId('submitButton'));
82
+ expect(onSubmit).not.toHaveBeenCalled();
83
+ });
84
+ it('calls onClose when cancel button is clicked', async () => {
85
+ const onClose = jest.fn();
86
+ const { getByTestId } = renderModal({ ...tc.props, onClose });
87
+ expect(getByTestId('cancelButton')).not.toBeDisabled();
88
+ await userEvent.click(getByTestId('cancelButton'));
89
+ expect(onClose).toHaveBeenCalled();
90
+ });
91
+ it('displays custom button', () => {
92
+ const customButton = true;
93
+ const customButtonLabel = 'Back';
94
+ const { getByTestId } = renderModal({ ...tc.props, customButton, customButtonLabel });
95
+ expect(getByTestId('customButton')).toBeInTheDocument();
96
+ });
97
+ it('calls onClickCustomButton when custom button is clicked', async () => {
98
+ const customButton = true;
99
+ const customButtonLabel = 'Back';
100
+ const onClickCustomButton = jest.fn();
101
+ const { getByTestId } = renderModal({ ...tc.props, customButtonLabel, customButton, onClickCustomButton });
102
+ expect(getByTestId('customButton')).toBeInTheDocument();
103
+ await userEvent.click(getByTestId('customButton'));
104
+ expect(onClickCustomButton).toHaveBeenCalled();
105
+ });
106
+ });
107
+ });