@boostdev/design-system-components 1.1.0 → 1.1.2

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 (269) hide show
  1. package/AGENTS.md +46 -5
  2. package/dist/client.cjs +206 -113
  3. package/dist/client.css +664 -624
  4. package/dist/client.d.cts +9 -3
  5. package/dist/client.d.ts +9 -3
  6. package/dist/client.js +241 -149
  7. package/dist/index.cjs +206 -113
  8. package/dist/index.css +664 -624
  9. package/dist/index.d.cts +9 -3
  10. package/dist/index.d.ts +9 -3
  11. package/dist/index.js +241 -149
  12. package/dist/web-components/chunk-2QA62WCQ.js +48 -0
  13. package/dist/web-components/chunk-4BX6AWXX.js +146 -0
  14. package/dist/web-components/chunk-57TRNCWQ.js +93 -0
  15. package/dist/web-components/chunk-5IPHEONG.js +139 -0
  16. package/dist/web-components/chunk-5R6IFELV.js +63 -0
  17. package/dist/web-components/chunk-5TFWOPLH.js +49 -0
  18. package/dist/web-components/chunk-6I3CFC26.js +89 -0
  19. package/dist/web-components/chunk-6T3RKUKG.js +65 -0
  20. package/dist/web-components/chunk-7FMR53BW.js +127 -0
  21. package/dist/web-components/chunk-A67LCT7C.js +134 -0
  22. package/dist/web-components/chunk-AGKJTMJI.js +56 -0
  23. package/dist/web-components/chunk-BQLZ7I4G.js +56 -0
  24. package/dist/web-components/chunk-CAPI25CU.js +53 -0
  25. package/dist/web-components/chunk-CJ5ZOO42.js +229 -0
  26. package/dist/web-components/chunk-CR5PGUHV.js +109 -0
  27. package/dist/web-components/chunk-ECW3HHWA.js +185 -0
  28. package/dist/web-components/chunk-HGBNDR22.js +98 -0
  29. package/dist/web-components/chunk-IK3PTFZ4.js +133 -0
  30. package/dist/web-components/chunk-IQGLIQSO.js +188 -0
  31. package/dist/web-components/chunk-ITHLKR7Q.js +105 -0
  32. package/dist/web-components/chunk-K5CE6HSB.js +169 -0
  33. package/dist/web-components/chunk-L3XHOMN6.js +111 -0
  34. package/dist/{web-components.js → web-components/chunk-LGEZYFUU.js} +62 -834
  35. package/dist/web-components/chunk-LSC4N56Q.js +168 -0
  36. package/dist/web-components/chunk-LY62SAVN.js +64 -0
  37. package/dist/web-components/chunk-O4UFI2RX.js +244 -0
  38. package/dist/web-components/chunk-O7I63SQX.js +124 -0
  39. package/dist/web-components/chunk-OHUTLSIQ.js +69 -0
  40. package/dist/web-components/chunk-OQTRTMAB.js +27 -0
  41. package/dist/web-components/chunk-OTX4COSV.js +187 -0
  42. package/dist/web-components/chunk-PY62FTRW.js +179 -0
  43. package/dist/web-components/chunk-Q4T5BJT6.js +94 -0
  44. package/dist/web-components/chunk-QDRH46TF.js +281 -0
  45. package/dist/web-components/chunk-QDST57JC.js +119 -0
  46. package/dist/web-components/chunk-QPOKHLMQ.js +45 -0
  47. package/dist/web-components/chunk-SOQQ7RVJ.js +88 -0
  48. package/dist/web-components/chunk-UFFCKVZE.js +149 -0
  49. package/dist/web-components/chunk-VM3YHGQ2.js +152 -0
  50. package/dist/web-components/chunk-VMMVWLXL.js +53 -0
  51. package/dist/web-components/chunk-VSS5ITNE.js +109 -0
  52. package/dist/web-components/chunk-XIENXR7H.js +118 -0
  53. package/dist/web-components/chunk-Y4MAXTMA.js +80 -0
  54. package/dist/web-components/chunk-YLVTEY23.js +165 -0
  55. package/dist/web-components/globals.d.ts +2 -0
  56. package/dist/web-components/globals.js +1 -0
  57. package/dist/web-components/index.d.ts +41 -0
  58. package/dist/web-components/index.js +165 -0
  59. package/dist/web-components/interaction/bds-accordion-item.d.ts +54 -0
  60. package/dist/web-components/interaction/bds-accordion-item.js +7 -0
  61. package/dist/web-components/interaction/bds-accordion.d.ts +50 -0
  62. package/dist/web-components/interaction/bds-accordion.js +7 -0
  63. package/dist/web-components/interaction/bds-button.d.ts +100 -0
  64. package/dist/web-components/interaction/bds-button.js +7 -0
  65. package/dist/web-components/interaction/bds-collapsible.d.ts +52 -0
  66. package/dist/web-components/interaction/bds-collapsible.js +7 -0
  67. package/dist/web-components/interaction/bds-dialog.d.ts +56 -0
  68. package/dist/web-components/interaction/bds-dialog.js +7 -0
  69. package/dist/web-components/interaction/bds-drawer.d.ts +64 -0
  70. package/dist/web-components/interaction/bds-drawer.js +7 -0
  71. package/dist/web-components/interaction/bds-popover.d.ts +62 -0
  72. package/dist/web-components/interaction/bds-popover.js +7 -0
  73. package/dist/web-components/interaction/bds-skip-link.d.ts +36 -0
  74. package/dist/web-components/interaction/bds-skip-link.js +7 -0
  75. package/dist/web-components/interaction/bds-tab-panel.d.ts +26 -0
  76. package/dist/web-components/interaction/bds-tab-panel.js +7 -0
  77. package/dist/web-components/interaction/bds-tab.d.ts +45 -0
  78. package/dist/web-components/interaction/bds-tab.js +7 -0
  79. package/dist/web-components/interaction/bds-tabs.d.ts +46 -0
  80. package/dist/web-components/interaction/bds-tabs.js +7 -0
  81. package/dist/web-components/interaction/bds-toast-provider.d.ts +57 -0
  82. package/dist/web-components/interaction/bds-toast-provider.js +7 -0
  83. package/dist/web-components/interaction/bds-tooltip.d.ts +50 -0
  84. package/dist/web-components/interaction/bds-tooltip.js +7 -0
  85. package/dist/web-components/interaction/form/bds-checkbox.d.ts +70 -0
  86. package/dist/web-components/interaction/form/bds-checkbox.js +7 -0
  87. package/dist/web-components/interaction/form/bds-combobox.d.ts +84 -0
  88. package/dist/web-components/interaction/form/bds-combobox.js +7 -0
  89. package/dist/web-components/interaction/form/bds-file-input.d.ts +62 -0
  90. package/dist/web-components/interaction/form/bds-file-input.js +7 -0
  91. package/dist/web-components/interaction/form/bds-number-input.d.ts +68 -0
  92. package/dist/web-components/interaction/form/bds-number-input.js +7 -0
  93. package/dist/web-components/interaction/form/bds-radio.d.ts +68 -0
  94. package/dist/web-components/interaction/form/bds-radio.js +7 -0
  95. package/dist/web-components/interaction/form/bds-segmented-control.d.ts +71 -0
  96. package/dist/web-components/interaction/form/bds-segmented-control.js +7 -0
  97. package/dist/web-components/interaction/form/bds-select.d.ts +79 -0
  98. package/dist/web-components/interaction/form/bds-select.js +7 -0
  99. package/dist/web-components/interaction/form/bds-slider.d.ts +70 -0
  100. package/dist/web-components/interaction/form/bds-slider.js +7 -0
  101. package/dist/web-components/interaction/form/bds-switch.d.ts +67 -0
  102. package/dist/web-components/interaction/form/bds-switch.js +7 -0
  103. package/dist/web-components/interaction/form/bds-textarea.d.ts +70 -0
  104. package/dist/web-components/interaction/form/bds-textarea.js +7 -0
  105. package/dist/web-components/ui/bds-alert.d.ts +66 -0
  106. package/dist/web-components/ui/bds-alert.js +7 -0
  107. package/dist/web-components/ui/bds-avatar.d.ts +50 -0
  108. package/dist/web-components/ui/bds-avatar.js +7 -0
  109. package/dist/web-components/ui/bds-badge.d.ts +35 -0
  110. package/dist/web-components/ui/bds-badge.js +7 -0
  111. package/dist/web-components/ui/bds-breadcrumb.d.ts +35 -0
  112. package/dist/web-components/ui/bds-breadcrumb.js +7 -0
  113. package/dist/web-components/ui/bds-card.d.ts +72 -0
  114. package/dist/web-components/ui/bds-card.js +7 -0
  115. package/dist/web-components/ui/bds-description-list.d.ts +42 -0
  116. package/dist/web-components/ui/bds-description-list.js +7 -0
  117. package/dist/web-components/ui/bds-icon-wrapper.d.ts +39 -0
  118. package/dist/web-components/ui/bds-icon-wrapper.js +7 -0
  119. package/dist/web-components/ui/bds-link.d.ts +59 -0
  120. package/dist/web-components/ui/bds-link.js +7 -0
  121. package/dist/web-components/ui/bds-loading.d.ts +32 -0
  122. package/dist/web-components/ui/bds-loading.js +7 -0
  123. package/dist/web-components/ui/bds-notification-banner.d.ts +61 -0
  124. package/dist/web-components/ui/bds-notification-banner.js +7 -0
  125. package/dist/web-components/ui/bds-progress-circle.d.ts +53 -0
  126. package/dist/web-components/ui/bds-progress-circle.js +7 -0
  127. package/dist/web-components/ui/bds-progress.d.ts +54 -0
  128. package/dist/web-components/ui/bds-progress.js +7 -0
  129. package/dist/web-components/ui/bds-rating.d.ts +36 -0
  130. package/dist/web-components/ui/bds-rating.js +7 -0
  131. package/dist/web-components/ui/bds-section-header.d.ts +53 -0
  132. package/dist/web-components/ui/bds-section-header.js +8 -0
  133. package/dist/web-components/ui/bds-separator.d.ts +32 -0
  134. package/dist/web-components/ui/bds-separator.js +7 -0
  135. package/dist/web-components/ui/bds-skeleton.d.ts +22 -0
  136. package/dist/web-components/ui/bds-skeleton.js +7 -0
  137. package/dist/web-components/ui/bds-typography.d.ts +44 -0
  138. package/dist/web-components/ui/bds-typography.js +8 -0
  139. package/package.json +169 -4
  140. package/src/components/interaction/Button/Button.module.css +1 -1
  141. package/src/components/interaction/Button/Button.native.mdx +72 -0
  142. package/src/components/interaction/Command/Command.module.css +7 -7
  143. package/src/components/interaction/Command/Command.spec.tsx +37 -0
  144. package/src/components/interaction/Command/Command.tsx +37 -2
  145. package/src/components/interaction/Dialog/Dialog.module.css +10 -13
  146. package/src/components/interaction/Dialog/Dialog.spec.tsx +53 -1
  147. package/src/components/interaction/Dialog/Dialog.stories.tsx +17 -0
  148. package/src/components/interaction/Dialog/Dialog.tsx +50 -16
  149. package/src/components/interaction/Drawer/Drawer.module.css +11 -11
  150. package/src/components/interaction/Drawer/Drawer.spec.tsx +48 -1
  151. package/src/components/interaction/Drawer/Drawer.tsx +38 -4
  152. package/src/components/interaction/DropdownMenu/DropdownMenu.module.css +6 -6
  153. package/src/components/interaction/Popover/Popover.module.css +74 -15
  154. package/src/components/interaction/Popover/Popover.spec.tsx +94 -59
  155. package/src/components/interaction/Popover/Popover.tsx +44 -60
  156. package/src/components/interaction/Toast/Toast.module.css +7 -7
  157. package/src/components/interaction/form/Checkbox/Checkbox.module.css +6 -6
  158. package/src/components/interaction/form/Checkbox/Checkbox.native.mdx +74 -0
  159. package/src/components/interaction/form/Combobox/Combobox.module.css +7 -8
  160. package/src/components/interaction/form/FileInput/FileInput.module.css +4 -4
  161. package/src/components/interaction/form/NumberInput/NumberInput.module.css +1 -1
  162. package/src/components/interaction/form/Radio/Radio.module.css +6 -6
  163. package/src/components/interaction/form/SegmentedControl/SegmentedControl.module.css +5 -6
  164. package/src/components/interaction/form/Select/Select.module.css +3 -3
  165. package/src/components/interaction/form/Slider/Slider.module.css +6 -6
  166. package/src/components/interaction/form/Switch/Switch.module.css +8 -8
  167. package/src/components/interaction/form/Textarea/Textarea.module.css +1 -1
  168. package/src/components/layout/IconWrapper/IconWrapper.module.css +2 -2
  169. package/src/components/ui/Accordion/Accordion.module.css +5 -5
  170. package/src/components/ui/Alert/Alert.native.mdx +62 -0
  171. package/src/components/ui/Avatar/Avatar.native.mdx +50 -0
  172. package/src/components/ui/Badge/Badge.native.mdx +54 -0
  173. package/src/components/ui/Calendar/Calendar.module.css +7 -7
  174. package/src/components/ui/Carousel/Carousel.module.css +5 -5
  175. package/src/components/ui/Collapsible/Collapsible.module.css +4 -4
  176. package/src/components/ui/Link/Link.module.css +2 -2
  177. package/src/components/ui/Loading/Loading.module.css +7 -7
  178. package/src/components/ui/NotificationBanner/NotificationBanner.module.css +3 -3
  179. package/src/components/ui/Pagination/Pagination.module.css +6 -6
  180. package/src/components/ui/Progress/Progress.module.css +5 -5
  181. package/src/components/ui/Separator/Separator.module.css +3 -3
  182. package/src/components/ui/Skeleton/Skeleton.module.css +1 -1
  183. package/src/components/ui/Table/Table.module.css +9 -9
  184. package/src/components/ui/Tabs/Tabs.module.css +3 -3
  185. package/src/components/ui/Tooltip/Tooltip.module.css +8 -8
  186. package/src/components/ui/Typography/Typography.native.mdx +56 -0
  187. package/src/polyfill-invoker-commands.ts +68 -0
  188. package/src/react-augment.d.ts +19 -0
  189. package/src/stories/ReactNative.mdx +121 -0
  190. package/src/web-components/index.ts +47 -0
  191. package/src/web-components/interaction/BdsButton.mdx +106 -0
  192. package/src/web-components/interaction/BdsPopover.mdx +120 -0
  193. package/src/web-components/interaction/BdsToastProvider.mdx +94 -0
  194. package/src/web-components/interaction/bds-accordion-item.spec.ts +75 -0
  195. package/src/web-components/interaction/bds-accordion-item.ts +181 -0
  196. package/src/web-components/interaction/bds-accordion.spec.ts +73 -0
  197. package/src/web-components/interaction/bds-accordion.ts +99 -0
  198. package/src/web-components/interaction/bds-collapsible.spec.ts +56 -0
  199. package/src/web-components/interaction/bds-collapsible.ts +170 -0
  200. package/src/web-components/interaction/bds-dialog.spec.ts +119 -0
  201. package/src/web-components/interaction/bds-dialog.ts +224 -0
  202. package/src/web-components/interaction/bds-drawer.spec.ts +113 -0
  203. package/src/web-components/interaction/bds-drawer.ts +266 -0
  204. package/src/web-components/interaction/bds-popover.spec.ts +49 -1
  205. package/src/web-components/interaction/bds-popover.ts +12 -0
  206. package/src/web-components/interaction/bds-skip-link.spec.ts +42 -0
  207. package/src/web-components/interaction/bds-skip-link.ts +74 -0
  208. package/src/web-components/interaction/bds-tab-panel.spec.ts +32 -0
  209. package/src/web-components/interaction/bds-tab-panel.ts +38 -0
  210. package/src/web-components/interaction/bds-tab.spec.ts +71 -0
  211. package/src/web-components/interaction/bds-tab.ts +110 -0
  212. package/src/web-components/interaction/bds-tabs.spec.ts +120 -0
  213. package/src/web-components/interaction/bds-tabs.ts +152 -0
  214. package/src/web-components/interaction/bds-tooltip.spec.ts +49 -0
  215. package/src/web-components/interaction/bds-tooltip.ts +127 -0
  216. package/src/web-components/interaction/form/bds-checkbox.spec.ts +63 -0
  217. package/src/web-components/interaction/form/bds-checkbox.ts +168 -0
  218. package/src/web-components/interaction/form/bds-combobox.spec.ts +117 -0
  219. package/src/web-components/interaction/form/bds-combobox.ts +336 -0
  220. package/src/web-components/interaction/form/bds-file-input.spec.ts +58 -0
  221. package/src/web-components/interaction/form/bds-file-input.ts +209 -0
  222. package/src/web-components/interaction/form/bds-number-input.spec.ts +87 -0
  223. package/src/web-components/interaction/form/bds-number-input.ts +221 -0
  224. package/src/web-components/interaction/form/bds-radio.spec.ts +70 -0
  225. package/src/web-components/interaction/form/bds-radio.ts +157 -0
  226. package/src/web-components/interaction/form/bds-segmented-control.spec.ts +74 -0
  227. package/src/web-components/interaction/form/bds-segmented-control.ts +211 -0
  228. package/src/web-components/interaction/form/bds-select.spec.ts +74 -0
  229. package/src/web-components/interaction/form/bds-select.ts +190 -0
  230. package/src/web-components/interaction/form/bds-slider.spec.ts +41 -0
  231. package/src/web-components/interaction/form/bds-slider.ts +162 -0
  232. package/src/web-components/interaction/form/bds-switch.spec.ts +62 -0
  233. package/src/web-components/interaction/form/bds-switch.ts +166 -0
  234. package/src/web-components/interaction/form/bds-textarea.spec.ts +55 -0
  235. package/src/web-components/interaction/form/bds-textarea.ts +143 -0
  236. package/src/web-components/test/helpers.ts +8 -0
  237. package/src/web-components/ui/BdsAlert.mdx +90 -0
  238. package/src/web-components/ui/BdsBadge.mdx +74 -0
  239. package/src/web-components/ui/bds-avatar.spec.ts +75 -0
  240. package/src/web-components/ui/bds-avatar.ts +122 -0
  241. package/src/web-components/ui/bds-breadcrumb.spec.ts +55 -0
  242. package/src/web-components/ui/bds-breadcrumb.ts +114 -0
  243. package/src/web-components/ui/bds-card.spec.ts +70 -0
  244. package/src/web-components/ui/bds-card.ts +156 -0
  245. package/src/web-components/ui/bds-description-list.spec.ts +36 -0
  246. package/src/web-components/ui/bds-description-list.ts +79 -0
  247. package/src/web-components/ui/bds-icon-wrapper.spec.ts +21 -0
  248. package/src/web-components/ui/bds-icon-wrapper.ts +68 -0
  249. package/src/web-components/ui/bds-link.spec.ts +72 -0
  250. package/src/web-components/ui/bds-link.ts +138 -0
  251. package/src/web-components/ui/bds-loading.spec.ts +38 -0
  252. package/src/web-components/ui/bds-loading.ts +76 -0
  253. package/src/web-components/ui/bds-notification-banner.spec.ts +82 -0
  254. package/src/web-components/ui/bds-notification-banner.ts +185 -0
  255. package/src/web-components/ui/bds-progress-circle.spec.ts +58 -0
  256. package/src/web-components/ui/bds-progress-circle.ts +142 -0
  257. package/src/web-components/ui/bds-progress.spec.ts +66 -0
  258. package/src/web-components/ui/bds-progress.ts +127 -0
  259. package/src/web-components/ui/bds-rating.spec.ts +70 -0
  260. package/src/web-components/ui/bds-rating.ts +80 -0
  261. package/src/web-components/ui/bds-section-header.spec.ts +57 -0
  262. package/src/web-components/ui/bds-section-header.ts +96 -0
  263. package/src/web-components/ui/bds-separator.spec.ts +50 -0
  264. package/src/web-components/ui/bds-separator.ts +66 -0
  265. package/src/web-components/ui/bds-skeleton.spec.ts +22 -0
  266. package/src/web-components/ui/bds-skeleton.ts +55 -0
  267. package/src/web-components/ui/bds-typography.spec.ts +76 -0
  268. package/src/web-components/ui/bds-typography.ts +112 -0
  269. package/dist/web-components.d.ts +0 -303
@@ -2,8 +2,7 @@ import { render, screen } from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { Popover } from './Popover';
4
4
 
5
- // jsdom doesn't implement CSS.supports — provide a minimal stub so the
6
- // polyfill guard in Popover.tsx doesn't throw.
5
+ // jsdom doesn't implement CSS.supports — stub so the anchor polyfill guard doesn't throw.
7
6
  beforeAll(() => {
8
7
  Object.defineProperty(globalThis, 'CSS', {
9
8
  value: { supports: () => true },
@@ -11,6 +10,39 @@ beforeAll(() => {
11
10
  });
12
11
  });
13
12
 
13
+ // jsdom doesn't implement the Popover API — mock showPopover/hidePopover/togglePopover
14
+ // and dispatch the `toggle` event so our state-sync listener fires.
15
+ beforeEach(() => {
16
+ HTMLElement.prototype.showPopover = vi.fn(function (this: HTMLElement) {
17
+ const event = new Event('toggle');
18
+ Object.defineProperty(event, 'newState', { value: 'open', configurable: true });
19
+ this.dispatchEvent(event);
20
+ });
21
+ HTMLElement.prototype.hidePopover = vi.fn(function (this: HTMLElement) {
22
+ const event = new Event('toggle');
23
+ Object.defineProperty(event, 'newState', { value: 'closed', configurable: true });
24
+ this.dispatchEvent(event);
25
+ });
26
+ HTMLElement.prototype.togglePopover = vi.fn(function (this: HTMLElement) {
27
+ const isCurrentlyOpen = this.getAttribute('data-popover-open') === 'true';
28
+ if (isCurrentlyOpen) {
29
+ this.setAttribute('data-popover-open', 'false');
30
+ const event = new Event('toggle');
31
+ Object.defineProperty(event, 'newState', { value: 'closed', configurable: true });
32
+ this.dispatchEvent(event);
33
+ } else {
34
+ this.setAttribute('data-popover-open', 'true');
35
+ const event = new Event('toggle');
36
+ Object.defineProperty(event, 'newState', { value: 'open', configurable: true });
37
+ this.dispatchEvent(event);
38
+ }
39
+ });
40
+ });
41
+
42
+ function getPanel() {
43
+ return document.querySelector<HTMLElement>('[popover]')!;
44
+ }
45
+
14
46
  describe('Popover', () => {
15
47
  it('renders the trigger', () => {
16
48
  render(
@@ -21,15 +53,23 @@ describe('Popover', () => {
21
53
  expect(screen.getByRole('button', { name: 'Open' })).toBeInTheDocument();
22
54
  });
23
55
 
24
- it('does not show the panel by default', () => {
56
+ it('renders the panel as a [popover] element', () => {
57
+ render(
58
+ <Popover content={<p>Panel content</p>}>
59
+ <button type="button">Open</button>
60
+ </Popover>
61
+ );
62
+ expect(getPanel()).toBeInTheDocument();
63
+ expect(getPanel()).toHaveAttribute('popover', 'auto');
64
+ });
65
+
66
+ it('panel is not open by default', () => {
25
67
  render(
26
68
  <Popover content={<p>Panel content</p>}>
27
69
  <button type="button">Open</button>
28
70
  </Popover>
29
71
  );
30
- // The dialog element is always in DOM; closed state = no open attribute.
31
- const dialog = document.querySelector('dialog');
32
- expect(dialog).not.toHaveAttribute('open');
72
+ expect(screen.getByRole('button').getAttribute('aria-expanded')).toBe('false');
33
73
  });
34
74
 
35
75
  it('shows the panel when trigger is clicked', async () => {
@@ -40,44 +80,44 @@ describe('Popover', () => {
40
80
  </Popover>
41
81
  );
42
82
  await user.click(screen.getByRole('button', { name: 'Open' }));
43
- expect(document.querySelector('dialog')).toHaveAttribute('open');
83
+ expect(HTMLElement.prototype.togglePopover).toHaveBeenCalled();
44
84
  });
45
85
 
46
- it('closes the panel when trigger is clicked again', async () => {
86
+ it('sets aria-expanded true after opening', async () => {
47
87
  const user = userEvent.setup();
48
88
  render(
49
- <Popover content={<p>Panel content</p>}>
50
- <button type="button">Toggle</button>
89
+ <Popover content={<p>Panel</p>}>
90
+ <button type="button">Open</button>
51
91
  </Popover>
52
92
  );
53
- await user.click(screen.getByRole('button', { name: 'Toggle' }));
54
- await user.click(screen.getByRole('button', { name: 'Toggle' }));
55
- expect(document.querySelector('dialog')).not.toHaveAttribute('open');
93
+ const trigger = screen.getByRole('button');
94
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
95
+ await user.click(trigger);
96
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
56
97
  });
57
98
 
58
- it('closes the panel when Escape is pressed', async () => {
99
+ it('closes the panel when trigger is clicked again', async () => {
59
100
  const user = userEvent.setup();
60
101
  render(
61
102
  <Popover content={<p>Panel content</p>}>
62
- <button type="button">Open</button>
103
+ <button type="button">Toggle</button>
63
104
  </Popover>
64
105
  );
65
- await user.click(screen.getByRole('button', { name: 'Open' }));
66
- await user.keyboard('{Escape}');
67
- expect(document.querySelector('dialog')).not.toHaveAttribute('open');
106
+ await user.click(screen.getByRole('button', { name: 'Toggle' }));
107
+ await user.click(screen.getByRole('button', { name: 'Toggle' }));
108
+ expect(screen.getByRole('button', { name: 'Toggle' })).toHaveAttribute('aria-expanded', 'false');
68
109
  });
69
110
 
70
- it('sets aria-expanded on the trigger when open', async () => {
71
- const user = userEvent.setup();
111
+ it('trigger uses commandfor/command="toggle-popover"', () => {
72
112
  render(
73
113
  <Popover content={<p>Panel</p>}>
74
114
  <button type="button">Open</button>
75
115
  </Popover>
76
116
  );
77
117
  const trigger = screen.getByRole('button');
78
- expect(trigger).toHaveAttribute('aria-expanded', 'false');
79
- await user.click(trigger);
80
- expect(trigger).toHaveAttribute('aria-expanded', 'true');
118
+ expect(trigger).toHaveAttribute('commandfor');
119
+ expect(trigger).toHaveAttribute('command', 'toggle-popover');
120
+ expect(trigger.getAttribute('commandfor')).toBe(getPanel().id);
81
121
  });
82
122
 
83
123
  it('sets anchor-name on the trigger and position-anchor on the panel', () => {
@@ -87,71 +127,66 @@ describe('Popover', () => {
87
127
  </Popover>
88
128
  );
89
129
  const trigger = screen.getByRole('button');
90
- const dialog = document.querySelector('dialog')!;
91
- // Both should reference the same CSS anchor ident.
130
+ const panel = getPanel();
92
131
  const anchorName = trigger.style.getPropertyValue('anchor-name');
93
- const positionAnchor = dialog.style.getPropertyValue('position-anchor');
132
+ const positionAnchor = panel.style.getPropertyValue('position-anchor');
94
133
  expect(anchorName).toMatch(/^--popover-/);
95
134
  expect(positionAnchor).toBe(anchorName);
96
135
  });
97
136
 
98
- it('renders role="region" with aria-label when aria-label prop is provided', async () => {
99
- const user = userEvent.setup();
137
+ it('each instance gets a unique anchor-name', () => {
100
138
  render(
101
- <Popover content={<p>Filters</p>} aria-label="Filter options">
139
+ <>
140
+ <Popover content={<p>A</p>}>
141
+ <button type="button">A</button>
142
+ </Popover>
143
+ <Popover content={<p>B</p>}>
144
+ <button type="button">B</button>
145
+ </Popover>
146
+ </>
147
+ );
148
+ const [btnA, btnB] = screen.getAllByRole('button');
149
+ expect(btnA.style.getPropertyValue('anchor-name')).not.toBe(
150
+ btnB.style.getPropertyValue('anchor-name')
151
+ );
152
+ });
153
+
154
+ it('sets data-placement from the placement prop', () => {
155
+ render(
156
+ <Popover content={<p>Panel</p>} placement="top">
102
157
  <button type="button">Open</button>
103
158
  </Popover>
104
159
  );
105
- await user.click(screen.getByRole('button', { name: 'Open' }));
106
- expect(screen.getByRole('region', { name: 'Filter options' })).toBeInTheDocument();
160
+ expect(getPanel()).toHaveAttribute('data-placement', 'top');
107
161
  });
108
162
 
109
- it('does not render role="region" when no aria-label is provided', async () => {
110
- const user = userEvent.setup();
163
+ it('defaults data-placement to "bottom"', () => {
111
164
  render(
112
165
  <Popover content={<p>Panel</p>}>
113
166
  <button type="button">Open</button>
114
167
  </Popover>
115
168
  );
116
- await user.click(screen.getByRole('button', { name: 'Open' }));
117
- expect(screen.queryByRole('region')).not.toBeInTheDocument();
169
+ expect(getPanel()).toHaveAttribute('data-placement', 'bottom');
118
170
  });
119
171
 
120
- it('constrains maxHeight when trigger is near the bottom of the viewport', async () => {
172
+ it('renders role="region" with aria-label when aria-label prop is provided', async () => {
121
173
  const user = userEvent.setup();
122
- Object.defineProperty(window, 'innerHeight', { value: 600, configurable: true });
123
- Object.defineProperty(window, 'innerWidth', { value: 1024, configurable: true });
124
- vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
125
- top: 530, bottom: 550, left: 100, right: 200, width: 100, height: 20,
126
- x: 100, y: 530, toJSON: () => {},
127
- });
128
174
  render(
129
- <Popover content={<p>Panel</p>} placement="bottom">
175
+ <Popover content={<p>Filters</p>} aria-label="Filter options">
130
176
  <button type="button">Open</button>
131
177
  </Popover>
132
178
  );
133
179
  await user.click(screen.getByRole('button', { name: 'Open' }));
134
- const dialog = document.querySelector('dialog')!;
135
- // max-height = vh - rect.bottom - GAP * 2 = 600 - 550 - 16 = 34
136
- expect(dialog.style.maxHeight).toBe('34px');
180
+ expect(getPanel()).toHaveAttribute('role', 'region');
181
+ expect(getPanel()).toHaveAttribute('aria-label', 'Filter options');
137
182
  });
138
183
 
139
- it('constrains maxWidth when trigger is near the right edge of the viewport', async () => {
140
- const user = userEvent.setup();
141
- Object.defineProperty(window, 'innerHeight', { value: 600, configurable: true });
142
- Object.defineProperty(window, 'innerWidth', { value: 400, configurable: true });
143
- vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
144
- top: 100, bottom: 120, left: 350, right: 390, width: 40, height: 20,
145
- x: 350, y: 100, toJSON: () => {},
146
- });
184
+ it('does not render role="region" when no aria-label is provided', () => {
147
185
  render(
148
- <Popover content={<p>Panel</p>} placement="bottom">
186
+ <Popover content={<p>Panel</p>}>
149
187
  <button type="button">Open</button>
150
188
  </Popover>
151
189
  );
152
- await user.click(screen.getByRole('button', { name: 'Open' }));
153
- const dialog = document.querySelector('dialog')!;
154
- // max-width = vw - rect.left - GAP = 400 - 350 - 8 = 42
155
- expect(dialog.style.maxWidth).toBe('42px');
190
+ expect(getPanel()).not.toHaveAttribute('role');
156
191
  });
157
192
  });
@@ -3,20 +3,21 @@ import {
3
3
  ReactNode,
4
4
  cloneElement,
5
5
  isValidElement,
6
- useCallback,
7
6
  useEffect,
8
7
  useId,
9
8
  useRef,
10
9
  useState,
11
10
  } from 'react';
11
+ import { installInvokerCommandsPolyfill } from '../../../polyfill-invoker-commands';
12
+
13
+ // Install once at module load — no-op if native support is present.
14
+ installInvokerCommandsPolyfill();
15
+
12
16
  import css from './Popover.module.css';
13
17
  import { cn } from '@boostdev/design-system-foundation';
14
18
  import type { WithClassName } from '../../../types';
15
19
 
16
- const GAP = 8; // --bds-space_xs
17
-
18
20
  // Load the CSS Anchor Positioning polyfill once, only in browsers that need it.
19
- // The CSS.supports guard is defensive: older environments may not expose it at all.
20
21
  if (
21
22
  typeof window !== 'undefined' &&
22
23
  !(typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('anchor-name: --a'))
@@ -40,90 +41,73 @@ export function Popover({
40
41
  }: Readonly<PopoverProps>) {
41
42
  const [isOpen, setIsOpen] = useState(false);
42
43
  const containerRef = useRef<HTMLSpanElement>(null);
43
- const dialogRef = useRef<HTMLDialogElement>(null);
44
+ const panelRef = useRef<HTMLDivElement>(null);
44
45
  const rawId = useId();
45
46
  // CSS anchor-name must be a valid custom-ident: strip non-word characters.
46
47
  const anchorName = `--popover-${rawId.replace(/\W/g, '') || 'a'}`;
47
48
  const panelId = rawId;
48
49
 
49
- // Light-dismiss: close on outside click or Escape key.
50
+ // Sync isOpen state via the popover toggle event (fires on both native and
51
+ // polyfilled open/close, including light-dismiss and Escape).
52
+ useEffect(() => {
53
+ const panel = panelRef.current;
54
+ if (!panel) return;
55
+ const handleToggle = (e: Event) => {
56
+ setIsOpen((e as ToggleEvent).newState === 'open');
57
+ };
58
+ panel.addEventListener('toggle', handleToggle);
59
+ return () => panel.removeEventListener('toggle', handleToggle);
60
+ }, []);
61
+
62
+ // Close the popover when the anchor scrolls out of the viewport.
63
+ // Light-dismiss (outside click) and Escape are handled natively by popover="auto".
50
64
  useEffect(() => {
51
65
  if (!isOpen) return;
52
- const handleMouseDown = (e: MouseEvent) => {
53
- if (containerRef.current && !containerRef.current.contains(e.target as Node)) {
54
- setIsOpen(false);
66
+ const handleScroll = () => {
67
+ const rect = containerRef.current?.getBoundingClientRect();
68
+ if (!rect) return;
69
+ const { innerWidth: vw, innerHeight: vh } = window;
70
+ if (rect.bottom < 0 || rect.top > vh || rect.right < 0 || rect.left > vw) {
71
+ panelRef.current?.hidePopover();
55
72
  }
56
73
  };
57
- const handleKeyDown = (e: KeyboardEvent) => {
58
- if (e.key === 'Escape') setIsOpen(false);
59
- };
60
- document.addEventListener('mousedown', handleMouseDown);
61
- document.addEventListener('keydown', handleKeyDown);
74
+ window.addEventListener('scroll', handleScroll, { capture: true, passive: true });
75
+ window.addEventListener('resize', handleScroll, { passive: true });
62
76
  return () => {
63
- document.removeEventListener('mousedown', handleMouseDown);
64
- document.removeEventListener('keydown', handleKeyDown);
77
+ window.removeEventListener('scroll', handleScroll, { capture: true });
78
+ window.removeEventListener('resize', handleScroll);
65
79
  };
66
80
  }, [isOpen]);
67
81
 
68
- // CSS anchor positioning handles placement. JS only constrains max-height/max-width
69
- // so tall content scrolls rather than overflows the viewport.
70
- const constrainPanel = useCallback(() => {
71
- const dialog = dialogRef.current;
72
- const container = containerRef.current;
73
- if (!dialog || !container) return;
74
- const rect = container.getBoundingClientRect();
75
- const vw = window.innerWidth;
76
- const vh = window.innerHeight;
77
- dialog.style.maxHeight = '';
78
- dialog.style.maxWidth = '';
79
- if (placement === 'bottom') {
80
- dialog.style.maxHeight = `${Math.max(0, vh - rect.bottom - GAP * 2)}px`;
81
- dialog.style.maxWidth = `${Math.max(0, vw - rect.left - GAP)}px`;
82
- } else if (placement === 'top') {
83
- dialog.style.maxHeight = `${Math.max(0, rect.top - GAP * 2)}px`;
84
- dialog.style.maxWidth = `${Math.max(0, vw - rect.left - GAP)}px`;
85
- } else if (placement === 'right') {
86
- dialog.style.maxHeight = `${Math.max(0, vh - rect.top - GAP)}px`;
87
- dialog.style.maxWidth = `${Math.max(0, vw - rect.right - GAP * 2)}px`;
88
- } else {
89
- dialog.style.maxHeight = `${Math.max(0, vh - rect.top - GAP)}px`;
90
- dialog.style.maxWidth = `${Math.max(0, rect.left - GAP * 2)}px`;
91
- }
92
- }, [placement]);
93
-
94
- const toggle = useCallback(() => {
95
- if (isOpen) {
96
- setIsOpen(false);
97
- } else {
98
- constrainPanel();
99
- setIsOpen(true);
100
- }
101
- }, [isOpen, constrainPanel]);
102
-
82
+ // Inject invoker command attrs and accessibility props onto the trigger.
83
+ // commandfor/command="toggle-popover" replaces the onClick toggle handler
84
+ // the browser (or polyfill) calls togglePopover() on the panel, which fires
85
+ // the toggle event above to sync state.
103
86
  const trigger = isValidElement(children)
104
87
  ? cloneElement(children as ReactElement<Record<string, unknown>>, {
105
88
  'aria-expanded': isOpen,
106
89
  'aria-controls': panelId,
107
90
  'aria-haspopup': true,
91
+ commandfor: panelId,
92
+ command: 'toggle-popover',
108
93
  style: {
109
94
  ...((children.props as Record<string, unknown>).style as object | undefined),
110
95
  anchorName,
111
96
  },
112
- onClick: (e: MouseEvent) => {
113
- toggle();
114
- const existingOnClick = (children.props as Record<string, unknown>).onClick;
115
- if (typeof existingOnClick === 'function') existingOnClick(e);
116
- },
97
+ // Forward any existing onClick on the child (for custom side-effects).
98
+ // Do NOT add our own toggle here — commandfor/command handles it to
99
+ // avoid a double-toggle when both onClick and invoker fire.
100
+ onClick: (children.props as Record<string, unknown>).onClick as (() => void) | undefined,
117
101
  })
118
102
  : children;
119
103
 
120
104
  return (
121
105
  <span ref={containerRef} className={cn(css.wrapper, className)}>
122
106
  {trigger}
123
- <dialog
124
- ref={dialogRef}
107
+ <div
108
+ ref={panelRef}
125
109
  id={panelId}
126
- open={isOpen}
110
+ popover="auto"
127
111
  data-placement={placement}
128
112
  role={ariaLabel ? 'region' : undefined}
129
113
  aria-label={ariaLabel}
@@ -131,7 +115,7 @@ export function Popover({
131
115
  style={{ positionAnchor: anchorName }}
132
116
  >
133
117
  {content}
134
- </dialog>
118
+ </div>
135
119
  </span>
136
120
  );
137
121
  }
@@ -2,8 +2,8 @@
2
2
  .toastContainer {
3
3
  position: fixed;
4
4
  inset: unset; /* override UA popover default (inset: 0) */
5
- bottom: var(--bds-space_xl);
6
- right: var(--bds-space_xl);
5
+ inset-block-end: var(--bds-space_xl);
6
+ inset-inline-end: var(--bds-space_xl);
7
7
  display: flex;
8
8
  flex-direction: column;
9
9
  gap: var(--bds-space_m);
@@ -23,7 +23,7 @@
23
23
  display: flex;
24
24
  align-items: center;
25
25
  gap: var(--bds-space_m);
26
- min-width: 300px;
26
+ min-inline-size: 300px;
27
27
  animation: slideIn var(--bds-animation_duration--fast) var(--bds-animation_easing);
28
28
  }
29
29
 
@@ -56,8 +56,8 @@
56
56
  align-items: center;
57
57
  justify-content: center;
58
58
  flex-shrink: 0;
59
- width: 1.25rem;
60
- height: 1.25rem;
59
+ inline-size: 1.25rem;
60
+ block-size: 1.25rem;
61
61
  padding: 0;
62
62
  background: none;
63
63
  border: none;
@@ -66,8 +66,8 @@
66
66
  }
67
67
 
68
68
  .closeButton svg {
69
- width: 1rem;
70
- height: 1rem;
69
+ inline-size: 1rem;
70
+ block-size: 1rem;
71
71
  }
72
72
  }
73
73
 
@@ -14,8 +14,8 @@
14
14
 
15
15
  .checkbox {
16
16
  margin-block-start: 0.25em;
17
- width: var(--inputSize);
18
- height: var(--inputSize);
17
+ inline-size: var(--inputSize);
18
+ block-size: var(--inputSize);
19
19
  color: var(--checkbox_color, var(--bds-color_on-bg));
20
20
  border: var(--checkbox_border, none);
21
21
  --bdc_color: currentcolor;
@@ -40,10 +40,10 @@
40
40
  .checkbox:checked::after {
41
41
  content: '';
42
42
  position: absolute;
43
- left: 0.6em;
44
- top: 0.2em;
45
- width: 0.5em;
46
- height: 1em;
43
+ inset-inline-start: 0.6em;
44
+ inset-block-start: 0.2em;
45
+ inline-size: 0.5em;
46
+ block-size: 1em;
47
47
  border: solid var(--checkbox_color-on-active, var(--bdc-color_on-active));
48
48
  border-width: 0 2px 2px 0;
49
49
  transform: rotate(45deg);
@@ -0,0 +1,74 @@
1
+ import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
2
+ import * as Stories from './Checkbox.native.stories';
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # Checkbox (React Native)
7
+
8
+ React Native checkbox component with label, optional hint, and error state. Fully controlled — manage checked state via `checked` + `onChange`.
9
+
10
+ > **Status: alpha** — API may change before stable release.
11
+
12
+ ## Usage
13
+
14
+ ```tsx
15
+ import { Checkbox } from '@boostdev/components';
16
+ import { useState } from 'react';
17
+
18
+ function Example() {
19
+ const [checked, setChecked] = useState(false);
20
+ return (
21
+ <Checkbox
22
+ name="terms"
23
+ label="Accept terms and conditions"
24
+ checked={checked}
25
+ onChange={setChecked}
26
+ />
27
+ );
28
+ }
29
+ ```
30
+
31
+ ## Examples
32
+
33
+ ### Interactive
34
+ <Canvas of={Stories.Interactive} />
35
+
36
+ ### Unchecked
37
+ <Canvas of={Stories.Unchecked} />
38
+
39
+ ### Checked
40
+ <Canvas of={Stories.Checked} />
41
+
42
+ ### With hint
43
+ <Canvas of={Stories.WithHint} />
44
+
45
+ ### With error
46
+ <Canvas of={Stories.WithError} />
47
+
48
+ ### Disabled
49
+ <Canvas of={Stories.Disabled} />
50
+
51
+ ### Disabled + checked
52
+ <Canvas of={Stories.DisabledChecked} />
53
+
54
+ ## Props
55
+
56
+ <ArgTypes of={Stories} />
57
+
58
+ ## Props reference
59
+
60
+ | Prop | Type | Default | Description |
61
+ |------|------|---------|-------------|
62
+ | `name` | string | — | Field name (used for accessibility grouping) |
63
+ | `label` | string | — | Visible label text |
64
+ | `checked` | boolean | `false` | Controlled checked state |
65
+ | `onChange` | `(checked: boolean) => void` | — | Called with the new value on press |
66
+ | `disabled` | boolean | `false` | Prevents interaction, reduces opacity |
67
+ | `hint` | string | — | Helper text below the label |
68
+ | `error` | string | — | Error message; shown instead of hint when set |
69
+
70
+ ## Accessibility
71
+
72
+ - The label, hint, and error are announced together by screen readers
73
+ - `disabled` communicates the disabled state via `accessibilityState`
74
+ - Group related checkboxes using a wrapping `View` with `accessibilityRole="radiogroup"` or a labelled `fieldset` equivalent
@@ -12,7 +12,7 @@
12
12
 
13
13
  .input {
14
14
  appearance: none;
15
- width: 100%;
15
+ inline-size: 100%;
16
16
  font-family: var(--bds-font_family--body);
17
17
  font-size: var(--bds-font_size--body);
18
18
  padding: var(--bds-space_s);
@@ -59,18 +59,17 @@
59
59
  }
60
60
 
61
61
  .chevron svg {
62
- width: 1rem;
63
- height: 1rem;
62
+ inline-size: 1rem;
63
+ block-size: 1rem;
64
64
  }
65
65
 
66
66
  .listbox {
67
67
  position: absolute;
68
- top: calc(100% + var(--bds-space_xxs));
69
- left: 0;
70
- right: 0;
68
+ inset-block-start: calc(100% + var(--bds-space_xxs));
69
+ inset-inline: 0;
71
70
  z-index: var(--bds-z-index_dropdown);
72
- max-height: 15rem;
73
- overflow-y: auto;
71
+ max-block-size: 15rem;
72
+ overflow-block: auto;
74
73
  list-style: none;
75
74
  margin: 0;
76
75
  padding: var(--bds-space_xxs) 0;
@@ -48,8 +48,8 @@
48
48
  }
49
49
 
50
50
  .icon {
51
- width: 2rem;
52
- height: 2rem;
51
+ inline-size: 2rem;
52
+ block-size: 2rem;
53
53
  flex-shrink: 0;
54
54
  }
55
55
 
@@ -70,8 +70,8 @@
70
70
 
71
71
  .hiddenInput {
72
72
  position: absolute;
73
- width: 1px;
74
- height: 1px;
73
+ inline-size: 1px;
74
+ block-size: 1px;
75
75
  overflow: hidden;
76
76
  clip: rect(0, 0, 0, 0);
77
77
  white-space: nowrap;
@@ -38,7 +38,7 @@
38
38
  padding: var(--bds-space_s);
39
39
  background: transparent;
40
40
  color: var(--numberInput_color, var(--bds-color_on-bg));
41
- min-width: 0;
41
+ min-inline-size: 0;
42
42
  appearance: textfield;
43
43
  }
44
44
 
@@ -29,8 +29,8 @@
29
29
  .radio {
30
30
  flex-shrink: 0;
31
31
  margin-block-start: 0.2em;
32
- width: var(--inputSize);
33
- height: var(--inputSize);
32
+ inline-size: var(--inputSize);
33
+ block-size: var(--inputSize);
34
34
  color: var(--radio_color, var(--bds-color_on-bg));
35
35
  border: var(--radio_border, none);
36
36
  --bdc_color: currentcolor;
@@ -55,11 +55,11 @@
55
55
  .radio:checked::after {
56
56
  content: '';
57
57
  position: absolute;
58
- left: 50%;
59
- top: 50%;
58
+ inset-inline-start: 50%;
59
+ inset-block-start: 50%;
60
60
  transform: translate(-50%, -50%);
61
- width: 0.4em;
62
- height: 0.4em;
61
+ inline-size: 0.4em;
62
+ block-size: 0.4em;
63
63
  border-radius: 50%;
64
64
  background-color: var(--radio_color-on-active, var(--bdc-color_on-active));
65
65
  }
@@ -12,10 +12,9 @@
12
12
 
13
13
  .thumb {
14
14
  position: absolute;
15
- top: var(--bds-space_xxxs);
16
- bottom: var(--bds-space_xxxs);
17
- left: var(--bds-space_xxxs);
18
- width: calc((100% - 2 * var(--bds-space_xxxs)) / var(--control_count, 1));
15
+ inset-block: var(--bds-space_xxxs);
16
+ inset-inline-start: var(--bds-space_xxxs);
17
+ inline-size: calc((100% - 2 * var(--bds-space_xxxs)) / var(--control_count, 1));
19
18
  border-radius: var(--bds-border_radius--s);
20
19
  background-color: var(--control_thumb-bg, var(--bds-color_bg));
21
20
  box-shadow: var(--bds-shadow_s);
@@ -43,8 +42,8 @@
43
42
  .radio {
44
43
  position: absolute;
45
44
  opacity: 0;
46
- width: 0;
47
- height: 0;
45
+ inline-size: 0;
46
+ block-size: 0;
48
47
  margin: 0;
49
48
  }
50
49