@ndlib/component-library 1.0.20 → 1.0.22

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 (259) hide show
  1. package/README.md +26 -8
  2. package/dist/assets/index-3cfb730f.js +1 -0
  3. package/dist/components/composites/Card/Card.stories.js +2 -0
  4. package/dist/components/composites/Card/index.js +4 -3
  5. package/dist/components/composites/CardV2/CardV2.module.css +74 -0
  6. package/dist/components/composites/CardV2/CardV2.stories.d.ts +19 -0
  7. package/dist/components/composites/CardV2/CardV2.stories.js +187 -0
  8. package/dist/components/composites/CardV2/CardV2.test.js +67 -0
  9. package/dist/components/composites/CardV2/index.d.ts +42 -0
  10. package/dist/components/composites/CardV2/index.js +97 -0
  11. package/dist/components/composites/DragDropList/DragDropList.stories.js +3 -1
  12. package/dist/components/composites/DropdownLinks/DropdownLinks.stories.js +2 -0
  13. package/dist/components/composites/DropdownLinks/index.d.ts +1 -1
  14. package/dist/components/composites/EmptyState/EmptyState.stories.js +2 -0
  15. package/dist/components/composites/EmptyState/index.js +1 -1
  16. package/dist/components/composites/Modal/Modal.stories.js +5 -2
  17. package/dist/components/composites/Modal/index.js +3 -2
  18. package/dist/components/composites/ModalV2/ModalV2.stories.d.ts +6 -0
  19. package/dist/components/composites/ModalV2/ModalV2.stories.js +41 -0
  20. package/dist/components/composites/ModalV2/ModalV2.test.js +37 -0
  21. package/dist/components/composites/ModalV2/index.d.ts +20 -0
  22. package/dist/components/composites/ModalV2/index.js +65 -0
  23. package/dist/components/composites/NavMenu/NavMenu.stories.js +2 -0
  24. package/dist/components/composites/NavMenu/index.js +1 -1
  25. package/dist/components/composites/Seo/seo.stories.js +2 -0
  26. package/dist/components/composites/SnackBar/SnackBar.stories.js +2 -0
  27. package/dist/components/composites/StructuredData/StructuredData.stories.js +2 -0
  28. package/dist/components/elements/Alerts/Alert.stories.js +2 -0
  29. package/dist/components/elements/Alerts/Alerts.stories.js +2 -0
  30. package/dist/components/elements/Alerts/index.js +2 -1
  31. package/dist/components/elements/ArrowLink/ArrowLink.stories.js +2 -0
  32. package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.stories.js +6 -4
  33. package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.test.js +1 -1
  34. package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/index.js +3 -3
  35. package/dist/components/elements/BrandingBar/BrandingBar.stories.js +2 -0
  36. package/dist/components/elements/Button/Button.stories.js +4 -2
  37. package/dist/components/elements/ButtonV2/ButtonV2.module.css +25 -0
  38. package/dist/components/elements/ButtonV2/ButtonV2.stories.d.ts +15 -0
  39. package/dist/components/elements/ButtonV2/ButtonV2.stories.js +90 -0
  40. package/dist/components/elements/ButtonV2/ButtonV2.test.js +45 -0
  41. package/dist/components/elements/ButtonV2/index.d.ts +49 -0
  42. package/dist/components/elements/ButtonV2/index.js +136 -0
  43. package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.stories.js +3 -1
  44. package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.test.js +1 -1
  45. package/dist/components/elements/{Fields/Checkbox → Checkbox}/index.d.ts +1 -1
  46. package/dist/components/elements/{Fields/Checkbox → Checkbox}/index.js +2 -2
  47. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.stories.js +3 -1
  48. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.test.js +1 -1
  49. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/index.d.ts +1 -1
  50. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/index.js +7 -7
  51. package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.stories.d.ts +8 -0
  52. package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.stories.js +31 -0
  53. package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.test.js +34 -0
  54. package/dist/components/elements/CheckboxGroupV2/index.d.ts +17 -0
  55. package/dist/components/elements/CheckboxGroupV2/index.js +50 -0
  56. package/dist/components/elements/CheckboxV2/CheckboxV2.module.css +5 -0
  57. package/dist/components/elements/CheckboxV2/CheckboxV2.stories.d.ts +6 -0
  58. package/dist/components/elements/CheckboxV2/CheckboxV2.stories.js +19 -0
  59. package/dist/components/elements/CheckboxV2/CheckboxV2.test.js +35 -0
  60. package/dist/components/elements/CheckboxV2/index.d.ts +9 -0
  61. package/dist/components/elements/CheckboxV2/index.js +22 -0
  62. package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.stories.js +3 -1
  63. package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.test.js +1 -1
  64. package/dist/components/elements/{Fields/DatePicker → DatePicker}/index.d.ts +1 -1
  65. package/dist/components/elements/{Fields/DatePicker → DatePicker}/index.js +2 -2
  66. package/dist/components/elements/Dropdown/Dropdown.stories.js +3 -1
  67. package/dist/components/elements/Dropdown/index.js +1 -1
  68. package/dist/components/elements/GroupV2/index.d.ts +22 -0
  69. package/dist/components/elements/GroupV2/index.js +71 -0
  70. package/dist/components/elements/{text/Heading → Heading}/Heading.stories.js +5 -3
  71. package/dist/components/elements/{text/Heading → Heading}/Heading.test.js +3 -3
  72. package/dist/components/elements/{text/Heading → Heading}/index.d.ts +3 -3
  73. package/dist/components/elements/{text/Heading → Heading}/index.js +10 -9
  74. package/dist/components/elements/HeadingV2/HeadingV2.module.css +8 -0
  75. package/dist/components/elements/HeadingV2/HeadingV2.stories.d.ts +8 -0
  76. package/dist/components/elements/HeadingV2/HeadingV2.stories.js +37 -0
  77. package/dist/components/elements/HeadingV2/HeadingV2.test.js +51 -0
  78. package/dist/components/elements/HeadingV2/index.d.ts +22 -0
  79. package/dist/components/elements/HeadingV2/index.js +100 -0
  80. package/dist/components/elements/Icon/Icon.stories.js +3 -1
  81. package/dist/components/elements/IconV2/IconV2.module.css +10 -0
  82. package/dist/components/elements/IconV2/IconV2.stories.d.ts +7 -0
  83. package/dist/components/elements/IconV2/IconV2.stories.js +31 -0
  84. package/dist/components/elements/IconV2/IconV2.test.js +62 -0
  85. package/dist/components/elements/IconV2/index.d.ts +10 -0
  86. package/dist/components/elements/IconV2/index.js +33 -0
  87. package/dist/components/elements/{text/Inline → Inline}/Inline.stories.js +2 -0
  88. package/dist/components/elements/{text/Inline → Inline}/index.d.ts +1 -1
  89. package/dist/components/elements/{text/Inline → Inline}/index.js +1 -1
  90. package/dist/components/elements/{text/Label → Label}/Label.stories.js +4 -2
  91. package/dist/components/elements/Label/Label.test.d.ts +1 -0
  92. package/dist/components/elements/{text/Label → Label}/Label.test.js +3 -3
  93. package/dist/components/elements/{text/Label → Label}/index.d.ts +2 -2
  94. package/dist/components/elements/{text/Label → Label}/index.js +3 -3
  95. package/dist/components/elements/LabelV2/LabelV2.stories.d.ts +6 -0
  96. package/dist/components/elements/LabelV2/LabelV2.stories.js +22 -0
  97. package/dist/components/elements/LabelV2/LabelV2.test.d.ts +1 -0
  98. package/dist/components/elements/LabelV2/LabelV2.test.js +56 -0
  99. package/dist/components/elements/LabelV2/index.d.ts +20 -0
  100. package/dist/components/elements/LabelV2/index.js +41 -0
  101. package/dist/components/elements/Link/Link.stories.js +3 -1
  102. package/dist/components/elements/List/List.stories.js +3 -1
  103. package/dist/components/elements/List/index.js +1 -1
  104. package/dist/components/elements/ListBox/Listbox.stories.js +2 -0
  105. package/dist/components/elements/ListBox/index.d.ts +1 -1
  106. package/dist/components/elements/ListBox/index.js +1 -1
  107. package/dist/components/elements/ListBoxV2/ListBoxV2.module.css +33 -0
  108. package/dist/components/elements/ListBoxV2/ListBoxV2.stories.d.ts +6 -0
  109. package/dist/components/elements/ListBoxV2/ListBoxV2.stories.js +19 -0
  110. package/dist/components/elements/ListBoxV2/index.d.ts +33 -0
  111. package/dist/components/elements/ListBoxV2/index.js +35 -0
  112. package/dist/components/elements/Markdown/Markdown.stories.js +2 -0
  113. package/dist/components/elements/Markdown/index.js +4 -4
  114. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.stories.js +3 -1
  115. package/dist/components/elements/MonthPicker/MonthPicker.test.d.ts +1 -0
  116. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.test.js +1 -1
  117. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/index.d.ts +1 -1
  118. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/index.js +2 -2
  119. package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.stories.js +5 -3
  120. package/dist/components/elements/Paragraph/Paragraph.test.d.ts +1 -0
  121. package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.test.js +1 -1
  122. package/dist/components/elements/{text/Paragraph → Paragraph}/index.d.ts +2 -2
  123. package/dist/components/elements/{text/Paragraph → Paragraph}/index.js +6 -5
  124. package/dist/components/elements/ParagraphV2/ParagraphV2.stories.d.ts +7 -0
  125. package/dist/components/elements/ParagraphV2/ParagraphV2.stories.js +33 -0
  126. package/dist/components/elements/ParagraphV2/ParagraphV2.test.d.ts +1 -0
  127. package/dist/components/elements/ParagraphV2/ParagraphV2.test.js +9 -0
  128. package/dist/components/elements/ParagraphV2/index.d.ts +15 -0
  129. package/dist/components/elements/ParagraphV2/index.js +39 -0
  130. package/dist/components/elements/Pill/Pill.stories.js +3 -1
  131. package/dist/components/elements/Pill/index.js +2 -1
  132. package/dist/components/elements/{Fields/Radio → Radio}/Radio.stories.js +3 -1
  133. package/dist/components/elements/Radio/Radio.test.d.ts +1 -0
  134. package/dist/components/elements/{Fields/Radio → Radio}/Radio.test.js +3 -3
  135. package/dist/components/elements/{Fields/Radio → Radio}/index.d.ts +1 -1
  136. package/dist/components/elements/{Fields/Radio → Radio}/index.js +1 -1
  137. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.stories.js +3 -1
  138. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.test.js +1 -1
  139. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/index.d.ts +1 -1
  140. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/index.js +6 -6
  141. package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.stories.js +5 -3
  142. package/dist/components/elements/ReadMore/ReadMore.test.d.ts +1 -0
  143. package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.test.js +4 -9
  144. package/dist/components/elements/{text/ReadMore → ReadMore}/index.d.ts +2 -2
  145. package/dist/components/elements/{text/ReadMore → ReadMore}/index.js +10 -9
  146. package/dist/components/elements/ReadMoreV2/ReadMoreV2.module.css +19 -0
  147. package/dist/components/elements/ReadMoreV2/ReadMoreV2.stories.d.ts +8 -0
  148. package/dist/components/elements/ReadMoreV2/ReadMoreV2.stories.js +28 -0
  149. package/dist/components/elements/ReadMoreV2/ReadMoreV2.test.d.ts +1 -0
  150. package/dist/components/elements/ReadMoreV2/ReadMoreV2.test.js +30 -0
  151. package/dist/components/elements/ReadMoreV2/index.d.ts +12 -0
  152. package/dist/components/elements/ReadMoreV2/index.js +81 -0
  153. package/dist/components/elements/{Fields/Select → Select}/Select.stories.js +6 -4
  154. package/dist/components/elements/Select/Select.test.d.ts +1 -0
  155. package/dist/components/elements/{Fields/Select → Select}/Select.test.js +1 -1
  156. package/dist/components/elements/{Fields/Select → Select}/index.d.ts +1 -1
  157. package/dist/components/elements/{Fields/Select → Select}/index.js +9 -9
  158. package/dist/components/elements/SelectV2/SelectV2.module.css +27 -0
  159. package/dist/components/elements/SelectV2/SelectV2.stories.d.ts +8 -0
  160. package/dist/components/elements/SelectV2/SelectV2.stories.js +41 -0
  161. package/dist/components/elements/SelectV2/SelectV2.test.d.ts +1 -0
  162. package/dist/components/elements/SelectV2/SelectV2.test.js +52 -0
  163. package/dist/components/elements/SelectV2/index.d.ts +18 -0
  164. package/dist/components/elements/SelectV2/index.js +164 -0
  165. package/dist/components/elements/Spinner/Spinner.stories.js +2 -0
  166. package/dist/components/elements/Spinner/index.js +1 -1
  167. package/dist/components/elements/SpinnerV2/SpinnerV2.module.css +12 -0
  168. package/dist/components/elements/SpinnerV2/SpinnerV2.stories.d.ts +7 -0
  169. package/dist/components/elements/SpinnerV2/SpinnerV2.stories.js +29 -0
  170. package/dist/components/elements/SpinnerV2/SpinnerV2.test.d.ts +1 -0
  171. package/dist/components/elements/SpinnerV2/SpinnerV2.test.js +9 -0
  172. package/dist/components/elements/SpinnerV2/index.d.ts +14 -0
  173. package/dist/components/elements/SpinnerV2/index.js +35 -0
  174. package/dist/components/elements/TabList/TabList.stories.js +2 -0
  175. package/dist/components/elements/Table/Table.stories.js +2 -0
  176. package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.stories.js +6 -4
  177. package/dist/components/elements/TextInput/TextInput.test.d.ts +1 -0
  178. package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.test.js +2 -2
  179. package/dist/components/elements/{Fields/TextInput → TextInput}/index.d.ts +3 -3
  180. package/dist/components/elements/{Fields/TextInput → TextInput}/index.js +9 -8
  181. package/dist/components/elements/TextInputV2/TextInputV2.module.css +71 -0
  182. package/dist/components/elements/TextInputV2/TextInputV2.stories.d.ts +9 -0
  183. package/dist/components/elements/TextInputV2/TextInputV2.stories.js +37 -0
  184. package/dist/components/elements/TextInputV2/TextInputV2.test.d.ts +1 -0
  185. package/dist/components/elements/TextInputV2/TextInputV2.test.js +59 -0
  186. package/dist/components/elements/TextInputV2/index.d.ts +45 -0
  187. package/dist/components/elements/TextInputV2/index.js +97 -0
  188. package/dist/components/elements/layout/Box.stories.js +2 -0
  189. package/dist/components/elements/layout/Flex.stories.js +3 -1
  190. package/dist/components/elements/layoutV2/BoxV2.d.ts +9 -0
  191. package/dist/components/elements/layoutV2/BoxV2.js +19 -0
  192. package/dist/components/elements/layoutV2/BoxV2.stories.d.ts +6 -0
  193. package/dist/components/elements/layoutV2/BoxV2.stories.js +14 -0
  194. package/dist/components/elements/layoutV2/ColumnV2.d.ts +8 -0
  195. package/dist/components/elements/layoutV2/ColumnV2.js +21 -0
  196. package/dist/components/elements/layoutV2/RowV2.d.ts +19 -0
  197. package/dist/components/elements/layoutV2/RowV2.js +54 -0
  198. package/dist/components/providers/alerts.js +5 -4
  199. package/dist/components/providers/alerts.test.d.ts +1 -0
  200. package/dist/components/providers/alerts.test.js +115 -0
  201. package/dist/components/providers/componentConfigV2.d.ts +25 -0
  202. package/dist/components/providers/componentConfigV2.js +37 -0
  203. package/dist/components/providers/media.js +1 -1
  204. package/dist/components/providers/mediaV2.d.ts +11 -0
  205. package/dist/components/providers/mediaV2.js +48 -0
  206. package/dist/components/providers/uiV2.d.ts +20 -0
  207. package/dist/components/providers/uiV2.js +16 -0
  208. package/dist/index.d.ts +34 -14
  209. package/dist/index.html +14 -0
  210. package/dist/index.js +33 -13
  211. package/dist/theme/Color.stories.js +3 -1
  212. package/dist/theme/GlobalStylesV2.d.ts +2 -0
  213. package/dist/theme/GlobalStylesV2.js +212 -0
  214. package/dist/theme/Typography.stories.js +3 -1
  215. package/dist/theme/css-variables.css +57 -0
  216. package/dist/theme/index.d.ts +127 -1
  217. package/dist/theme/index.js +14 -0
  218. package/dist/theme/typography.js +2 -2
  219. package/dist/utils/decorators/UIVersion1.d.ts +2 -0
  220. package/dist/utils/decorators/UIVersion1.js +7 -0
  221. package/dist/utils/decorators/UIVersion2.d.ts +2 -0
  222. package/dist/utils/decorators/UIVersion2.js +7 -0
  223. package/dist/utils/hooks/useFocus.d.ts +7 -0
  224. package/dist/utils/hooks/useFocus.js +12 -0
  225. package/dist/utils/processSx.d.ts +3 -0
  226. package/dist/utils/processSx.js +135 -0
  227. package/package.json +7 -4
  228. /package/dist/components/{elements/Fields/Checkbox/Checkbox.test.d.ts → composites/CardV2/CardV2.test.d.ts} +0 -0
  229. /package/dist/components/{elements/Fields/CheckboxGroup/CheckboxGroup.test.d.ts → composites/ModalV2/ModalV2.test.d.ts} +0 -0
  230. /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.stories.d.ts +0 -0
  231. /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.test.d.ts +0 -0
  232. /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/index.d.ts +0 -0
  233. /package/dist/components/elements/{Fields/DatePicker/DatePicker.test.d.ts → ButtonV2/ButtonV2.test.d.ts} +0 -0
  234. /package/dist/components/elements/{text/Caption → Caption}/index.d.ts +0 -0
  235. /package/dist/components/elements/{text/Caption → Caption}/index.js +0 -0
  236. /package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.stories.d.ts +0 -0
  237. /package/dist/components/elements/{Fields/MonthPicker/MonthPicker.test.d.ts → Checkbox/Checkbox.test.d.ts} +0 -0
  238. /package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.stories.d.ts +0 -0
  239. /package/dist/components/elements/{Fields/Radio/Radio.test.d.ts → CheckboxGroup/CheckboxGroup.test.d.ts} +0 -0
  240. /package/dist/components/elements/{Fields/Select/Select.test.d.ts → CheckboxGroupV2/CheckboxGroupV2.test.d.ts} +0 -0
  241. /package/dist/components/elements/{text/Heading/Heading.test.d.ts → CheckboxV2/CheckboxV2.test.d.ts} +0 -0
  242. /package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.stories.d.ts +0 -0
  243. /package/dist/components/elements/{text/Label/Label.test.d.ts → DatePicker/DatePicker.test.d.ts} +0 -0
  244. /package/dist/components/elements/{text/Heading → Heading}/Heading.stories.d.ts +0 -0
  245. /package/dist/components/elements/{text/Paragraph/Paragraph.test.d.ts → Heading/Heading.test.d.ts} +0 -0
  246. /package/dist/components/elements/{text/ReadMore/ReadMore.test.d.ts → HeadingV2/HeadingV2.test.d.ts} +0 -0
  247. /package/dist/components/elements/{Fields/RadioGroup/RadioGroup.test.d.ts → IconV2/IconV2.test.d.ts} +0 -0
  248. /package/dist/components/elements/{text/Inline → Inline}/Inline.stories.d.ts +0 -0
  249. /package/dist/components/elements/{text/Label → Label}/Label.stories.d.ts +0 -0
  250. /package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.stories.d.ts +0 -0
  251. /package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.stories.d.ts +0 -0
  252. /package/dist/components/elements/{Fields/Radio → Radio}/Radio.stories.d.ts +0 -0
  253. /package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.stories.d.ts +0 -0
  254. /package/dist/components/elements/{Fields/TextInput/TextInput.test.d.ts → RadioGroup/RadioGroup.test.d.ts} +0 -0
  255. /package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.stories.d.ts +0 -0
  256. /package/dist/components/elements/{Fields/Select → Select}/Select.stories.d.ts +0 -0
  257. /package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.stories.d.ts +0 -0
  258. /package/dist/components/elements/{Fields/option.d.ts → option.d.ts} +0 -0
  259. /package/dist/components/elements/{Fields/option.js → option.js} +0 -0
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { fireEvent } from '@testing-library/react';
3
+ import { vi } from 'vitest';
4
+ import { render } from '../../../utils/test';
5
+ import { ButtonV2 } from '.';
6
+ const MockPrimaryIcon = () => _jsx("div", { children: "Mock Primary Icon" });
7
+ const MockLeftIcon = () => _jsx("div", { children: "Mock Left Icon" });
8
+ const MockRightIcon = () => _jsx("div", { children: "Mock Right Icon" });
9
+ describe('Button', () => {
10
+ const mockClickHandler = vi.fn();
11
+ afterEach(() => {
12
+ vi.resetAllMocks();
13
+ });
14
+ it('renders without throwing an error', () => {
15
+ const { getByText } = render(_jsx(ButtonV2, { children: "Foo" }));
16
+ expect(getByText('Foo')).toBeInTheDocument();
17
+ });
18
+ it('renders icon component passed to it', () => {
19
+ const { getByText } = render(_jsxs(_Fragment, { children: [_jsx(ButtonV2, Object.assign({ leftIcon: MockLeftIcon }, { children: "Click Me" })), _jsx(ButtonV2, Object.assign({ primaryIcon: MockPrimaryIcon }, { children: "Click Me" })), _jsx(ButtonV2, Object.assign({ rightIcon: MockRightIcon }, { children: "Click Me" }))] }));
20
+ expect(getByText('Mock Primary Icon')).toBeDefined();
21
+ expect(getByText('Mock Left Icon')).toBeDefined();
22
+ expect(getByText('Mock Right Icon')).toBeDefined();
23
+ });
24
+ it('renders without icons if not passed', () => {
25
+ const { queryByText } = render(_jsx(ButtonV2, { children: "Click Me" }));
26
+ expect(queryByText('Mock Primary Icon')).toBeNull();
27
+ expect(queryByText('Mock Left Icon')).toBeNull();
28
+ expect(queryByText('Mock Right Icon')).toBeNull();
29
+ });
30
+ it('responds to click handlers', () => {
31
+ const { getByRole } = render(_jsx(ButtonV2, { onClick: mockClickHandler }));
32
+ fireEvent.click(getByRole('button'));
33
+ expect(mockClickHandler).toHaveBeenCalledTimes(1);
34
+ });
35
+ it('does not respond to click handler when disabled', () => {
36
+ const { getByRole } = render(_jsx(ButtonV2, { onClick: mockClickHandler, disabled: true }));
37
+ fireEvent.click(getByRole('button'));
38
+ expect(mockClickHandler).not.toHaveBeenCalled();
39
+ });
40
+ it('does not respond to click handler when loading', () => {
41
+ const { getByRole } = render(_jsx(ButtonV2, { onClick: mockClickHandler, loading: true }));
42
+ fireEvent.click(getByRole('button'));
43
+ expect(mockClickHandler).not.toHaveBeenCalled();
44
+ });
45
+ });
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { StyledElementPropsV2 } from '../../../theme';
3
+ import { COLOR } from '../../../theme/colors';
4
+ export declare enum BUTTONV2_SIZE {
5
+ SM = "sm",
6
+ MD = "md",
7
+ LG = "lg"
8
+ }
9
+ export declare enum BUTTONV2_TYPE {
10
+ DEFAULT = "default",
11
+ TEXT = "text",
12
+ OUTLINE = "outline"
13
+ }
14
+ export type ButtonV2Props = StyledElementPropsV2<HTMLButtonElement, {
15
+ size?: BUTTONV2_SIZE;
16
+ type?: BUTTONV2_TYPE;
17
+ color?: COLOR;
18
+ textColor?: COLOR;
19
+ customColor?: string;
20
+ primaryIcon?: React.FC<any>;
21
+ leftIcon?: React.FC<any>;
22
+ rightIcon?: React.FC<any>;
23
+ accessibleLabel?: string;
24
+ loading?: boolean;
25
+ disabled?: boolean;
26
+ disableFocusStyles?: boolean;
27
+ }>;
28
+ export declare const ButtonV2: React.ForwardRefExoticComponent<{
29
+ sx?: import("../../../theme").StylesPropV2 | undefined;
30
+ children?: React.ReactNode;
31
+ } & Omit<React.HTMLAttributes<HTMLButtonElement>, "children" | "onChange"> & {
32
+ size?: BUTTONV2_SIZE | undefined;
33
+ type?: BUTTONV2_TYPE | undefined;
34
+ color?: COLOR | undefined;
35
+ textColor?: COLOR | undefined;
36
+ customColor?: string | undefined;
37
+ primaryIcon?: React.FC<any> | undefined;
38
+ leftIcon?: React.FC<any> | undefined;
39
+ rightIcon?: React.FC<any> | undefined;
40
+ accessibleLabel?: string | undefined;
41
+ loading?: boolean | undefined;
42
+ disabled?: boolean | undefined;
43
+ disableFocusStyles?: boolean | undefined;
44
+ } & {
45
+ htmlFor?: string | undefined;
46
+ } & React.RefAttributes<HTMLButtonElement>>;
47
+ type LinkButtonV2Props = Omit<ButtonV2Props, 'type' | 'color' | 'textColor'>;
48
+ export declare const LinkButtonV2: React.FC<LinkButtonV2Props>;
49
+ export {};
@@ -0,0 +1,136 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import React from 'react';
14
+ import { COLOR } from '../../../theme/colors';
15
+ import { TYPOGRAPHY_TYPE, getIconSize, getTypographyStyles, } from '../../../theme/typography';
16
+ import { IconV2 } from '../IconV2';
17
+ import { useEnvironment } from '../../providers/env';
18
+ import { SPINNERV2_SIZE, SpinnerV2 } from '../SpinnerV2';
19
+ import { BOX_SHADOW } from '../../../theme/custom';
20
+ import { processSx } from '../../../utils/processSx';
21
+ import { useHover } from '../../../utils/hooks/useHover';
22
+ import { useFocus } from '../../../utils/hooks/useFocus';
23
+ import * as styles from './ButtonV2.module.css';
24
+ export var BUTTONV2_SIZE;
25
+ (function (BUTTONV2_SIZE) {
26
+ BUTTONV2_SIZE["SM"] = "sm";
27
+ BUTTONV2_SIZE["MD"] = "md";
28
+ BUTTONV2_SIZE["LG"] = "lg";
29
+ })(BUTTONV2_SIZE || (BUTTONV2_SIZE = {}));
30
+ const typographyMap = {
31
+ [BUTTONV2_SIZE.SM]: TYPOGRAPHY_TYPE.CONTROL_SMALL,
32
+ [BUTTONV2_SIZE.MD]: TYPOGRAPHY_TYPE.CONTROL_MEDIUM,
33
+ [BUTTONV2_SIZE.LG]: TYPOGRAPHY_TYPE.CONTROL_LARGE,
34
+ };
35
+ const defaultPaddingX = {
36
+ [BUTTONV2_SIZE.SM]: '0.5rem',
37
+ [BUTTONV2_SIZE.MD]: '0.75rem',
38
+ [BUTTONV2_SIZE.LG]: '1rem',
39
+ };
40
+ const defaultHeight = {
41
+ [BUTTONV2_SIZE.SM]: '2rem',
42
+ [BUTTONV2_SIZE.MD]: '2.5rem',
43
+ [BUTTONV2_SIZE.LG]: '3rem',
44
+ };
45
+ const iconMargin = {
46
+ [BUTTONV2_SIZE.SM]: '0.25rem',
47
+ [BUTTONV2_SIZE.MD]: '0.5rem',
48
+ [BUTTONV2_SIZE.LG]: '0.5rem',
49
+ };
50
+ export var BUTTONV2_TYPE;
51
+ (function (BUTTONV2_TYPE) {
52
+ BUTTONV2_TYPE["DEFAULT"] = "default";
53
+ BUTTONV2_TYPE["TEXT"] = "text";
54
+ BUTTONV2_TYPE["OUTLINE"] = "outline";
55
+ })(BUTTONV2_TYPE || (BUTTONV2_TYPE = {}));
56
+ const typeSafeStyles = styles;
57
+ export const ButtonV2 = React.forwardRef((_a, ref) => {
58
+ var { size: sizeParam, type: typeParam, color, customColor, textColor: textColorParam, primaryIcon, leftIcon, rightIcon, disabled: disabledParam, children, sx, loading, disableFocusStyles } = _a, rest = __rest(_a, ["size", "type", "color", "customColor", "textColor", "primaryIcon", "leftIcon", "rightIcon", "disabled", "children", "sx", "loading", "disableFocusStyles"]);
59
+ const disabled = disabledParam || loading;
60
+ const { flagInDevelopment } = useEnvironment();
61
+ const { isHovered, anchorElementProps } = useHover();
62
+ const { isFocused } = useFocus();
63
+ let bg = COLOR.PRIMARY;
64
+ let borderColor = COLOR.TRANSPARENT;
65
+ let cursor = 'pointer';
66
+ let textColor = COLOR.BACKGROUND;
67
+ let hoverShadow = BOX_SHADOW.NORMAL;
68
+ let hoverDecoration = undefined;
69
+ let hoverTransform = 'scale(1.03)';
70
+ const isTextButton = typeParam === BUTTONV2_TYPE.TEXT;
71
+ const isIconButton = primaryIcon;
72
+ const type = typeParam || BUTTONV2_TYPE.DEFAULT;
73
+ const size = sizeParam || BUTTONV2_SIZE.MD;
74
+ const paddingX = isIconButton || isTextButton ? 0 : defaultPaddingX[size];
75
+ const height = isTextButton ? undefined : defaultHeight[size];
76
+ const width = primaryIcon ? height : undefined;
77
+ if (isIconButton && !rest['aria-label']) {
78
+ flagInDevelopment('Icon buttons should include aria-label prop for accessibility');
79
+ }
80
+ if (isIconButton) {
81
+ hoverTransform = 'scale(1.05)';
82
+ }
83
+ if (type === BUTTONV2_TYPE.DEFAULT) {
84
+ bg = color || COLOR.SECONDARY;
85
+ textColor = COLOR.BLACK;
86
+ }
87
+ if (type === BUTTONV2_TYPE.TEXT) {
88
+ bg = COLOR.TRANSPARENT;
89
+ textColor = color || COLOR.PRIMARY;
90
+ hoverShadow = undefined;
91
+ hoverDecoration = 'underline';
92
+ }
93
+ if (type === BUTTONV2_TYPE.OUTLINE) {
94
+ bg = COLOR.BACKGROUND;
95
+ textColor = color || COLOR.TEXT;
96
+ borderColor = textColor;
97
+ }
98
+ if (textColorParam) {
99
+ textColor = textColorParam;
100
+ }
101
+ if (disabled) {
102
+ cursor = 'not-allowed';
103
+ if (bg === COLOR.BACKGROUND || bg === COLOR.TRANSPARENT) {
104
+ textColor = COLOR.GRAY;
105
+ }
106
+ else {
107
+ bg = COLOR.GRAY;
108
+ }
109
+ }
110
+ const typography = typographyMap[size];
111
+ const typographyStyles = getTypographyStyles(typography);
112
+ let body = children;
113
+ if (primaryIcon) {
114
+ body = (_jsx(IconV2, { icon: primaryIcon, size: getIconSize(typographyStyles.fontSize), color: textColor }));
115
+ }
116
+ if (loading) {
117
+ body = (_jsxs("div", Object.assign({ className: typeSafeStyles.spinnerWrapper }, { children: [_jsx(SpinnerV2, { size: SPINNERV2_SIZE.SM, color: textColor, sx: { position: 'absolute' } }), _jsx("div", Object.assign({ style: { visibility: 'hidden' } }, { children: body }))] })));
118
+ }
119
+ const processedStyles = processSx(Object.assign(Object.assign({ bg: customColor ? customColor : bg }, typographyStyles), sx));
120
+ const hoverStyles = !disabled
121
+ ? {
122
+ boxShadow: hoverShadow,
123
+ transform: hoverTransform,
124
+ textDecoration: hoverDecoration,
125
+ }
126
+ : undefined;
127
+ const appliedHoverStyles = !disableFocusStyles && isHovered ? hoverStyles : {};
128
+ const appliedFocusStyles = !disableFocusStyles && isFocused ? hoverStyles : {};
129
+ return (_jsxs("button", Object.assign({}, anchorElementProps, { ref: ref, tabIndex: disabled ? -1 : 0, disabled: disabled, className: typeSafeStyles.button, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ cursor }, processSx({
130
+ color: textColor,
131
+ borderColor,
132
+ })), { paddingLeft: paddingX, paddingRight: paddingX, width: width, height: height }), appliedHoverStyles), appliedFocusStyles), processedStyles) }, rest, { children: [leftIcon && (_jsx(IconV2, { icon: leftIcon, size: typographyStyles.fontSize, sx: { mr: iconMargin[size] }, color: textColor })), _jsx("div", Object.assign({ className: typeSafeStyles.bodyWrapper }, { children: body })), rightIcon && (_jsx(IconV2, { icon: rightIcon, size: typographyStyles.fontSize, sx: { ml: iconMargin[size] }, color: textColor }))] })));
133
+ });
134
+ export const LinkButtonV2 = (props) => {
135
+ return (_jsx(ButtonV2, Object.assign({}, props, { color: COLOR.ND_BLUE_BRIGHT, textColor: COLOR.WHITE })));
136
+ };
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Checkbox } from './index';
3
3
  import { useState } from 'react';
4
- import { Row } from '../../layout/Row';
4
+ import { Row } from '../layout/Row';
5
+ import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
5
6
  const meta = {
6
7
  title: 'Elements/Fields/Checkbox',
7
8
  component: Checkbox,
8
9
  tags: ['autodocs'],
10
+ decorators: [UIVersion1],
9
11
  };
10
12
  export default meta;
11
13
  const StatefulCheckbox = (props) => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render, fireEvent } from '@testing-library/react';
3
- import { Checkbox } from './';
3
+ import { Checkbox } from '.';
4
4
  import { vi } from 'vitest';
5
5
  describe('Checkbox', () => {
6
6
  it('renders unchecked checkbox', () => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { StyledElementProps } from '../../../../theme';
2
+ import { StyledElementProps } from '../../../theme';
3
3
  type CheckboxProps = StyledElementProps<HTMLInputElement, {
4
4
  checked: boolean;
5
5
  onChange: (value: boolean) => void;
@@ -10,13 +10,13 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
- import { useTheme } from '../../../../theme';
13
+ import { useTheme } from '../../../theme';
14
14
  export const Checkbox = (_a) => {
15
15
  var { checked, onChange, disabled, sx } = _a, rest = __rest(_a, ["checked", "onChange", "disabled", "sx"]);
16
16
  const theme = useTheme();
17
17
  return (_jsx("input", Object.assign({ type: "checkbox", onChange: (e) => {
18
18
  onChange(e.target.checked);
19
19
  }, checked: checked, sx: Object.assign({ margin: '0px', height: '1rem', width: '1rem', cursor: disabled ? 'not-allowed' : 'pointer', ':hover': {
20
- boxShadow: theme.boxShadow,
20
+ boxShadow: theme === null || theme === void 0 ? void 0 : theme.boxShadow,
21
21
  } }, sx), disabled: disabled }, rest)));
22
22
  };
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { CheckboxGroup } from './index';
3
3
  import { useState } from 'react';
4
- import { Row } from '../../layout/Row';
4
+ import { Row } from '../layout/Row';
5
+ import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
5
6
  const meta = {
6
7
  title: 'Elements/Fields/CheckboxGroup',
7
8
  component: CheckboxGroup,
8
9
  tags: ['autodocs'],
10
+ decorators: [UIVersion1],
9
11
  };
10
12
  export default meta;
11
13
  const options = [
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render, fireEvent } from '@testing-library/react';
3
- import { CheckboxGroup } from './';
3
+ import { CheckboxGroup } from '.';
4
4
  import { vi } from 'vitest';
5
5
  const mockOptions = [
6
6
  { value: 'option1', label: 'Option 1' },
@@ -1,4 +1,4 @@
1
- import { StyledElementProps, StylesProp } from '../../../../theme';
1
+ import { StyledElementProps, StylesProp } from '../../../theme';
2
2
  import { Key } from '../option';
3
3
  export type Option<K extends Key = string> = {
4
4
  value: K;
@@ -11,14 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useMemo } from 'react';
14
- import { Row } from '../../layout/Row';
14
+ import { Row } from '../layout/Row';
15
15
  import { Checkbox } from '../Checkbox';
16
- import { Label } from '../../text/Label';
17
- import { Group } from '../../Group';
18
- import { GROUP_TYPE } from '../../Group';
19
- import { Column } from '../../layout/Column';
20
- import { TYPOGRAPHY_TYPE, getTypographyStyles, } from '../../../../theme/typography';
21
- import { COLOR } from '../../../../theme/colors';
16
+ import { Label } from '../Label';
17
+ import { Group } from '../Group';
18
+ import { GROUP_TYPE } from '../Group';
19
+ import { Column } from '../layout/Column';
20
+ import { TYPOGRAPHY_TYPE, getTypographyStyles } from '../../../theme/typography';
21
+ import { COLOR } from '../../../theme/colors';
22
22
  export function CheckboxGroup(_a) {
23
23
  var { options, checkedOptions, columns: columnsProp, columnStyles, rowStyles, onChange } = _a, rest = __rest(_a, ["options", "checkedOptions", "columns", "columnStyles", "rowStyles", "onChange"]);
24
24
  const columns = columnsProp || 1;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { CheckboxGroupV2 } from './index';
3
+ declare const meta: Meta<typeof CheckboxGroupV2>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof CheckboxGroupV2>;
6
+ export declare const Default: Story;
7
+ export declare const Columns: Story;
8
+ export declare const Disabled: Story;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CheckboxGroupV2 } from './index';
3
+ import { useState } from 'react';
4
+ import { RowV2 } from '../layoutV2/RowV2';
5
+ import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
6
+ const meta = {
7
+ title: 'Elements/Fields/CheckboxGroupV2',
8
+ component: CheckboxGroupV2,
9
+ tags: ['autodocs'],
10
+ decorators: [UIVersion2],
11
+ };
12
+ export default meta;
13
+ const options = [
14
+ { value: 'orange', label: 'Orange', disabled: true },
15
+ { value: 'apple', label: 'Apple' },
16
+ { value: 'strawberry', label: 'Strawberry' },
17
+ { value: 'pineapple', label: 'Pineapple' },
18
+ ];
19
+ const StatefulCheckboxGroup = (props) => {
20
+ const [checked, setChecked] = useState(new Set(['orange']));
21
+ return (_jsx(CheckboxGroupV2, Object.assign({}, props, { checkedOptions: checked, options: props.options || options, onChange: setChecked })));
22
+ };
23
+ export const Default = {
24
+ render: () => (_jsx(RowV2, { children: _jsx(StatefulCheckboxGroup, {}) })),
25
+ };
26
+ export const Columns = {
27
+ render: () => (_jsx(RowV2, { children: _jsx(StatefulCheckboxGroup, { columns: 2 }) })),
28
+ };
29
+ export const Disabled = {
30
+ render: () => (_jsx(RowV2, { children: _jsx(StatefulCheckboxGroup, { options: options.map((option, i) => (Object.assign(Object.assign({}, option), { disabled: i === 1 ? true : false }))) }) })),
31
+ };
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import { CheckboxGroupV2 } from '.';
4
+ import { vi } from 'vitest';
5
+ const mockOptions = [
6
+ { value: 'option1', label: 'Option 1' },
7
+ { value: 'option2', label: 'Option 2', disabled: true },
8
+ { value: 'option3', label: 'Option 3' },
9
+ ];
10
+ describe('CheckboxGroupV2', () => {
11
+ it('renders checkboxes with options correctly', () => {
12
+ const { getByText } = render(_jsx(CheckboxGroupV2, { options: mockOptions, onChange: () => { } }));
13
+ mockOptions.forEach((option) => {
14
+ const label = getByText(option.label);
15
+ expect(label).toBeInTheDocument();
16
+ });
17
+ });
18
+ it('calls onChange handler with correct value when checkbox is clicked', () => {
19
+ const onChangeMock = vi.fn();
20
+ const { getByLabelText } = render(_jsx(CheckboxGroupV2, { options: mockOptions, onChange: onChangeMock }));
21
+ const option1Checkbox = getByLabelText('Option 1');
22
+ fireEvent.click(option1Checkbox);
23
+ expect(onChangeMock).toHaveBeenCalledWith(new Set(['option1']));
24
+ });
25
+ it('disables checkboxes correctly', () => {
26
+ const { getByLabelText } = render(_jsx(CheckboxGroupV2, { options: mockOptions, onChange: () => { } }));
27
+ const option1Checkbox = getByLabelText('Option 1');
28
+ expect(option1Checkbox).not.toBeDisabled();
29
+ const option2Checkbox = getByLabelText('Option 2');
30
+ expect(option2Checkbox).toBeDisabled();
31
+ const option3Checkbox = getByLabelText('Option 3');
32
+ expect(option3Checkbox).not.toBeDisabled();
33
+ });
34
+ });
@@ -0,0 +1,17 @@
1
+ import { StyledElementPropsV2, StylesPropV2 } from '../../../theme';
2
+ import { Key } from '../option';
3
+ export type Option<K extends Key = string> = {
4
+ value: K;
5
+ label: string;
6
+ disabled?: boolean;
7
+ };
8
+ type CheckboxGroupV2Props<K extends Key = string> = StyledElementPropsV2<HTMLDivElement, {
9
+ onChange: (value: Set<K>) => void;
10
+ options: Option<K>[];
11
+ checkedOptions?: Set<K>;
12
+ columnStyles?: StylesPropV2;
13
+ rowStyles?: StylesPropV2;
14
+ columns?: number;
15
+ }, string>;
16
+ export declare function CheckboxGroupV2<K extends Key>({ options, checkedOptions, columns: columnsProp, columnStyles, rowStyles, onChange, ...rest }: CheckboxGroupV2Props<K>): import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,50 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useMemo } from 'react';
14
+ import { RowV2 } from '../layoutV2/RowV2';
15
+ import { CheckboxV2 } from '../CheckboxV2';
16
+ import { LabelV2 } from '../LabelV2';
17
+ import { GroupV2 } from '../GroupV2';
18
+ import { GROUPV2_TYPE } from '../GroupV2';
19
+ import { ColumnV2 } from '../layoutV2/ColumnV2';
20
+ import { TYPOGRAPHY_TYPE, getTypographyStyles } from '../../../theme/typography';
21
+ import { COLOR } from '../../../theme/colors';
22
+ export function CheckboxGroupV2(_a) {
23
+ var { options, checkedOptions, columns: columnsProp, columnStyles, rowStyles, onChange } = _a, rest = __rest(_a, ["options", "checkedOptions", "columns", "columnStyles", "rowStyles", "onChange"]);
24
+ const columns = columnsProp || 1;
25
+ const optionsByColumn = useMemo(() => {
26
+ const optionsByColumn = [];
27
+ for (let i = 0; i < options.length; i++) {
28
+ const maxPerColumn = Math.ceil(options.length / columns);
29
+ const columnIndex = Math.floor(i / maxPerColumn);
30
+ if (optionsByColumn[columnIndex] === undefined) {
31
+ optionsByColumn[columnIndex] = [];
32
+ }
33
+ optionsByColumn[columnIndex].push(options[i]);
34
+ }
35
+ return optionsByColumn;
36
+ }, [options, columns]);
37
+ return (_jsx(RowV2, Object.assign({}, rest, { children: optionsByColumn.map((options, index) => (_jsx(ColumnV2, Object.assign({ grow: 1, sx: Object.assign({ mr: 4 }, columnStyles) }, { children: options.map((option) => (_jsx(GroupV2, Object.assign({ type: GROUPV2_TYPE.RAW }, { children: ({ labelTargetId }) => (_jsxs(RowV2, Object.assign({ sx: Object.assign({ mb: 2, alignItems: 'center' }, rowStyles) }, { children: [_jsx(CheckboxV2, { onChange: (checked) => {
38
+ const updatedSet = new Set(checkedOptions || []);
39
+ if (checked) {
40
+ updatedSet.add(option.value);
41
+ }
42
+ else {
43
+ updatedSet.delete(option.value);
44
+ }
45
+ onChange(updatedSet);
46
+ }, checked: !!(checkedOptions === null || checkedOptions === void 0 ? void 0 : checkedOptions.has(option.value)), id: labelTargetId, disabled: option.disabled, sx: {
47
+ mr: 2,
48
+ flexShrink: 0,
49
+ } }), _jsx(LabelV2, Object.assign({ sx: Object.assign(Object.assign({ cursor: option.disabled ? 'not-allowed' : 'pointer' }, getTypographyStyles(TYPOGRAPHY_TYPE.CONDENSED_TEXT_MEDIUM)), { color: option.disabled ? COLOR.GRAY : undefined }) }, { children: option.label }))] }))) }), option.value))) }), index))) })));
50
+ }
@@ -0,0 +1,5 @@
1
+ .checkbox {
2
+ margin: 0;
3
+ height: 1rem;
4
+ width: 1rem;
5
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { CheckboxV2 } from '.';
3
+ declare const meta: Meta<typeof CheckboxV2>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof CheckboxV2>;
6
+ export declare const Default: Story;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CheckboxV2 } from '.';
3
+ import { useState } from 'react';
4
+ import { RowV2 } from '../layoutV2/RowV2';
5
+ import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
6
+ const meta = {
7
+ title: 'Elements/Fields/CheckboxV2',
8
+ component: CheckboxV2,
9
+ tags: ['autodocs'],
10
+ decorators: [UIVersion2],
11
+ };
12
+ export default meta;
13
+ const StatefulCheckbox = (props) => {
14
+ const [checked, setChecked] = useState(false);
15
+ return _jsx(CheckboxV2, Object.assign({}, props, { checked: checked, onChange: setChecked }));
16
+ };
17
+ export const Default = {
18
+ render: () => (_jsx(RowV2, { children: _jsx(StatefulCheckbox, {}) })),
19
+ };
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import { CheckboxV2 } from '.';
4
+ import { vi } from 'vitest';
5
+ describe('CheckboxV2', () => {
6
+ it('renders unchecked checkbox', () => {
7
+ const { getByRole } = render(_jsx(CheckboxV2, { checked: false, onChange: () => { } }));
8
+ const checkbox = getByRole('checkbox');
9
+ expect(checkbox).toBeInTheDocument();
10
+ expect(checkbox).not.toBeChecked();
11
+ });
12
+ it('renders checked checkbox', () => {
13
+ const { getByRole } = render(_jsx(CheckboxV2, { checked: true, onChange: () => { } }));
14
+ const checkbox = getByRole('checkbox');
15
+ expect(checkbox).toBeInTheDocument();
16
+ expect(checkbox).toBeChecked();
17
+ });
18
+ it('calls onChange handler when checkbox is clicked', () => {
19
+ const onChangeMock = vi.fn();
20
+ const { getByRole } = render(_jsx(CheckboxV2, { checked: false, onChange: onChangeMock }));
21
+ const checkbox = getByRole('checkbox');
22
+ fireEvent.click(checkbox);
23
+ expect(onChangeMock).toHaveBeenCalledWith(true);
24
+ });
25
+ it('applies disabled styles when disabled', () => {
26
+ const { getByRole } = render(_jsx(CheckboxV2, { checked: false, onChange: () => { }, disabled: true }));
27
+ const checkbox = getByRole('checkbox');
28
+ expect(checkbox).toHaveStyle('cursor: not-allowed;');
29
+ });
30
+ it('applies pointer cursor style when not disabled', () => {
31
+ const { getByRole } = render(_jsx(CheckboxV2, { checked: false, onChange: () => { } }));
32
+ const checkbox = getByRole('checkbox');
33
+ expect(checkbox).toHaveStyle('cursor: pointer;');
34
+ });
35
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { StyledElementPropsV2 } from '../../../theme';
3
+ type CheckboxV2Props = StyledElementPropsV2<HTMLInputElement, {
4
+ checked: boolean;
5
+ onChange: (value: boolean) => void;
6
+ disabled?: boolean;
7
+ }, string>;
8
+ export declare const CheckboxV2: React.FC<CheckboxV2Props>;
9
+ export {};
@@ -0,0 +1,22 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { processSx } from '../../../utils/processSx';
14
+ import * as styles from './CheckboxV2.module.css';
15
+ const typeSafeStyles = styles;
16
+ export const CheckboxV2 = (_a) => {
17
+ var { checked, onChange, disabled, sx } = _a, rest = __rest(_a, ["checked", "onChange", "disabled", "sx"]);
18
+ const processedStyles = processSx(sx);
19
+ return (_jsx("input", Object.assign({ type: "checkbox", onChange: (e) => {
20
+ onChange(e.target.checked);
21
+ }, checked: checked, className: typeSafeStyles.checkbox, style: Object.assign({ cursor: disabled ? 'not-allowed' : 'pointer' }, processedStyles), disabled: disabled }, rest)));
22
+ };
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { DatePicker } from '.';
4
- import { Box } from '../../layout/Box';
4
+ import { Box } from '../layout/Box';
5
+ import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
5
6
  const meta = {
6
7
  title: 'Elements/Fields/DatePicker',
7
8
  component: DatePicker,
8
9
  tags: ['autodocs'],
10
+ decorators: [UIVersion1],
9
11
  };
10
12
  export default meta;
11
13
  const StatefulDatePicker = (props) => {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render, fireEvent, screen } from '@testing-library/react';
3
3
  import { describe, it, expect, vi } from 'vitest';
4
- import { DatePicker, areDatesEqual } from './';
4
+ import { DatePicker, areDatesEqual } from '.';
5
5
  describe('DatePicker Component', () => {
6
6
  it('renders correctly', () => {
7
7
  const mockDate = new Date(2023, 4, 23);
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import 'react-datepicker/dist/react-datepicker.css';
3
3
  import { TextInputProps } from '../TextInput';
4
- import { BoxProps } from '../../layout/Box';
4
+ import { BoxProps } from '../layout/Box';
5
5
  export declare const InputWrapper: React.ForwardRefExoticComponent<{
6
6
  onChange?: ((e: React.ChangeEvent) => void) | undefined;
7
7
  onClick?: ((e: React.MouseEvent) => void) | undefined;
@@ -15,8 +15,8 @@ import _ReactDatePicker from 'react-datepicker';
15
15
  import 'react-datepicker/dist/react-datepicker.css';
16
16
  import { TextInput } from '../TextInput';
17
17
  import _CalendarIcon from '@mui/icons-material/CalendarMonth';
18
- import { Box } from '../../layout/Box';
19
- import { importedDefaultComponentShim } from '../../../../utils/misc';
18
+ import { Box } from '../layout/Box';
19
+ import { importedDefaultComponentShim } from '../../../utils/misc';
20
20
  const CalendarIcon = importedDefaultComponentShim(_CalendarIcon);
21
21
  const ReactDatePicker = importedDefaultComponentShim(_ReactDatePicker);
22
22
  export const InputWrapper = React.forwardRef(({ onChange, value, children, onClick }, ref) => {