@unofficialbox/box-open-elements 0.1.0

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 (351) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -0
  3. package/dist/components/actions/button-group.d.ts +22 -0
  4. package/dist/components/actions/button-group.js +255 -0
  5. package/dist/components/actions/button.d.ts +16 -0
  6. package/dist/components/actions/button.js +190 -0
  7. package/dist/components/actions/icon-button.d.ts +20 -0
  8. package/dist/components/actions/icon-button.js +187 -0
  9. package/dist/components/actions/link-button.d.ts +14 -0
  10. package/dist/components/actions/link-button.js +137 -0
  11. package/dist/components/actions/menu-item.d.ts +17 -0
  12. package/dist/components/actions/menu-item.js +137 -0
  13. package/dist/components/actions/menu.d.ts +22 -0
  14. package/dist/components/actions/menu.js +178 -0
  15. package/dist/components/actions/segmented-control.d.ts +27 -0
  16. package/dist/components/actions/segmented-control.js +273 -0
  17. package/dist/components/collections/card.d.ts +13 -0
  18. package/dist/components/collections/card.js +110 -0
  19. package/dist/components/collections/carousel.d.ts +40 -0
  20. package/dist/components/collections/carousel.js +406 -0
  21. package/dist/components/collections/datalist-item.d.ts +32 -0
  22. package/dist/components/collections/datalist-item.js +196 -0
  23. package/dist/components/collections/draggable-list.d.ts +33 -0
  24. package/dist/components/collections/draggable-list.js +306 -0
  25. package/dist/components/collections/grid-view.d.ts +38 -0
  26. package/dist/components/collections/grid-view.js +321 -0
  27. package/dist/components/collections/pagination.d.ts +19 -0
  28. package/dist/components/collections/pagination.js +147 -0
  29. package/dist/components/collections/tree-grid.d.ts +47 -0
  30. package/dist/components/collections/tree-grid.js +593 -0
  31. package/dist/components/collections/tree.d.ts +37 -0
  32. package/dist/components/collections/tree.js +526 -0
  33. package/dist/components/feedback/alert.d.ts +27 -0
  34. package/dist/components/feedback/alert.js +263 -0
  35. package/dist/components/feedback/badge.d.ts +12 -0
  36. package/dist/components/feedback/badge.js +99 -0
  37. package/dist/components/feedback/chip.d.ts +33 -0
  38. package/dist/components/feedback/chip.js +261 -0
  39. package/dist/components/feedback/empty-state.d.ts +19 -0
  40. package/dist/components/feedback/empty-state.js +137 -0
  41. package/dist/components/feedback/error-mask.d.ts +25 -0
  42. package/dist/components/feedback/error-mask.js +199 -0
  43. package/dist/components/feedback/help-text.d.ts +22 -0
  44. package/dist/components/feedback/help-text.js +176 -0
  45. package/dist/components/feedback/nudge.d.ts +32 -0
  46. package/dist/components/feedback/nudge.js +299 -0
  47. package/dist/components/feedback/progress-bar.d.ts +18 -0
  48. package/dist/components/feedback/progress-bar.js +128 -0
  49. package/dist/components/feedback/progress-ring.d.ts +21 -0
  50. package/dist/components/feedback/progress-ring.js +155 -0
  51. package/dist/components/feedback/progress-steps.d.ts +25 -0
  52. package/dist/components/feedback/progress-steps.js +276 -0
  53. package/dist/components/feedback/skeleton.d.ts +14 -0
  54. package/dist/components/feedback/skeleton.js +95 -0
  55. package/dist/components/feedback/spinner.d.ts +10 -0
  56. package/dist/components/feedback/spinner.js +80 -0
  57. package/dist/components/feedback/toast.d.ts +26 -0
  58. package/dist/components/feedback/toast.js +205 -0
  59. package/dist/components/files/drop-zone.d.ts +19 -0
  60. package/dist/components/files/drop-zone.js +169 -0
  61. package/dist/components/forms/calendar.d.ts +47 -0
  62. package/dist/components/forms/calendar.js +499 -0
  63. package/dist/components/forms/category-selector.d.ts +35 -0
  64. package/dist/components/forms/category-selector.js +269 -0
  65. package/dist/components/forms/checkbox-group.d.ts +31 -0
  66. package/dist/components/forms/checkbox-group.js +267 -0
  67. package/dist/components/forms/checkbox.d.ts +28 -0
  68. package/dist/components/forms/checkbox.js +250 -0
  69. package/dist/components/forms/color-picker.d.ts +34 -0
  70. package/dist/components/forms/color-picker.js +314 -0
  71. package/dist/components/forms/combobox.d.ts +37 -0
  72. package/dist/components/forms/combobox.js +234 -0
  73. package/dist/components/forms/date-field.d.ts +27 -0
  74. package/dist/components/forms/date-field.js +187 -0
  75. package/dist/components/forms/dropdown.d.ts +38 -0
  76. package/dist/components/forms/dropdown.js +405 -0
  77. package/dist/components/forms/dual-listbox.d.ts +44 -0
  78. package/dist/components/forms/dual-listbox.js +484 -0
  79. package/dist/components/forms/fieldset.d.ts +32 -0
  80. package/dist/components/forms/fieldset.js +168 -0
  81. package/dist/components/forms/multi-select.d.ts +30 -0
  82. package/dist/components/forms/multi-select.js +264 -0
  83. package/dist/components/forms/number-input.d.ts +32 -0
  84. package/dist/components/forms/number-input.js +245 -0
  85. package/dist/components/forms/pill-cloud.d.ts +35 -0
  86. package/dist/components/forms/pill-cloud.js +230 -0
  87. package/dist/components/forms/pill-selector-dropdown.d.ts +55 -0
  88. package/dist/components/forms/pill-selector-dropdown.js +499 -0
  89. package/dist/components/forms/radio-group.d.ts +32 -0
  90. package/dist/components/forms/radio-group.js +285 -0
  91. package/dist/components/forms/range-slider.d.ts +36 -0
  92. package/dist/components/forms/range-slider.js +294 -0
  93. package/dist/components/forms/rating.d.ts +31 -0
  94. package/dist/components/forms/rating.js +302 -0
  95. package/dist/components/forms/rich-text-input.d.ts +32 -0
  96. package/dist/components/forms/rich-text-input.js +403 -0
  97. package/dist/components/forms/search-field.d.ts +27 -0
  98. package/dist/components/forms/search-field.js +293 -0
  99. package/dist/components/forms/select.d.ts +30 -0
  100. package/dist/components/forms/select.js +198 -0
  101. package/dist/components/forms/slider.d.ts +31 -0
  102. package/dist/components/forms/slider.js +221 -0
  103. package/dist/components/forms/spin-button.d.ts +33 -0
  104. package/dist/components/forms/spin-button.js +352 -0
  105. package/dist/components/forms/switch.d.ts +32 -0
  106. package/dist/components/forms/switch.js +302 -0
  107. package/dist/components/forms/tag-input.d.ts +46 -0
  108. package/dist/components/forms/tag-input.js +420 -0
  109. package/dist/components/forms/text-area.d.ts +26 -0
  110. package/dist/components/forms/text-area.js +188 -0
  111. package/dist/components/forms/text-field.d.ts +24 -0
  112. package/dist/components/forms/text-field.js +151 -0
  113. package/dist/components/forms/time-field.d.ts +29 -0
  114. package/dist/components/forms/time-field.js +203 -0
  115. package/dist/components/identity/avatar.d.ts +21 -0
  116. package/dist/components/identity/avatar.js +191 -0
  117. package/dist/components/identity/contact-datalist-item.d.ts +31 -0
  118. package/dist/components/identity/contact-datalist-item.js +235 -0
  119. package/dist/components/identity/persona.d.ts +28 -0
  120. package/dist/components/identity/persona.js +272 -0
  121. package/dist/components/layout/app-shell.d.ts +26 -0
  122. package/dist/components/layout/app-shell.js +258 -0
  123. package/dist/components/layout/divider.d.ts +12 -0
  124. package/dist/components/layout/divider.js +119 -0
  125. package/dist/components/layout/nav-sidebar.d.ts +23 -0
  126. package/dist/components/layout/nav-sidebar.js +167 -0
  127. package/dist/components/layout/section.d.ts +20 -0
  128. package/dist/components/layout/section.js +143 -0
  129. package/dist/components/layout/sidebar-toggle-button.d.ts +26 -0
  130. package/dist/components/layout/sidebar-toggle-button.js +137 -0
  131. package/dist/components/layout/split-view.d.ts +19 -0
  132. package/dist/components/layout/split-view.js +157 -0
  133. package/dist/components/navigation/accordion.d.ts +25 -0
  134. package/dist/components/navigation/accordion.js +253 -0
  135. package/dist/components/navigation/tabs.d.ts +27 -0
  136. package/dist/components/navigation/tabs.js +289 -0
  137. package/dist/components/overlays/dialog.d.ts +26 -0
  138. package/dist/components/overlays/dialog.js +267 -0
  139. package/dist/components/overlays/drawer.d.ts +32 -0
  140. package/dist/components/overlays/drawer.js +323 -0
  141. package/dist/components/overlays/popover.d.ts +35 -0
  142. package/dist/components/overlays/popover.js +317 -0
  143. package/dist/components/overlays/tooltip.d.ts +26 -0
  144. package/dist/components/overlays/tooltip.js +204 -0
  145. package/dist/components/visuals/illustration.d.ts +26 -0
  146. package/dist/components/visuals/illustration.js +319 -0
  147. package/dist/core/controller.d.ts +11 -0
  148. package/dist/core/controller.js +23 -0
  149. package/dist/core/element.d.ts +22 -0
  150. package/dist/core/element.js +28 -0
  151. package/dist/core/event-emitter.d.ts +9 -0
  152. package/dist/core/event-emitter.js +33 -0
  153. package/dist/core/form-associated.d.ts +63 -0
  154. package/dist/core/form-associated.js +218 -0
  155. package/dist/core/index.d.ts +6 -0
  156. package/dist/core/index.js +4 -0
  157. package/dist/core/json-schema.d.ts +1 -0
  158. package/dist/core/json-schema.js +1 -0
  159. package/dist/foundations/a11y/focus.d.ts +17 -0
  160. package/dist/foundations/a11y/focus.js +94 -0
  161. package/dist/foundations/a11y/heading.d.ts +26 -0
  162. package/dist/foundations/a11y/heading.js +40 -0
  163. package/dist/foundations/a11y/index.d.ts +5 -0
  164. package/dist/foundations/a11y/index.js +3 -0
  165. package/dist/foundations/a11y/keyboard.d.ts +28 -0
  166. package/dist/foundations/a11y/keyboard.js +77 -0
  167. package/dist/foundations/geometry/index.d.ts +1 -0
  168. package/dist/foundations/geometry/index.js +1 -0
  169. package/dist/foundations/geometry/tokens.d.ts +123 -0
  170. package/dist/foundations/geometry/tokens.js +154 -0
  171. package/dist/foundations/icons/box-iconography.d.ts +479 -0
  172. package/dist/foundations/icons/box-iconography.generated.d.ts +2370 -0
  173. package/dist/foundations/icons/box-iconography.generated.js +4010 -0
  174. package/dist/foundations/icons/box-iconography.js +39 -0
  175. package/dist/foundations/icons/index.d.ts +1 -0
  176. package/dist/foundations/icons/index.js +1 -0
  177. package/dist/foundations/motion/index.d.ts +2 -0
  178. package/dist/foundations/motion/index.js +1 -0
  179. package/dist/foundations/motion/tokens.d.ts +39 -0
  180. package/dist/foundations/motion/tokens.js +43 -0
  181. package/dist/foundations/tokens/box-dark.d.ts +11 -0
  182. package/dist/foundations/tokens/box-dark.js +46 -0
  183. package/dist/foundations/tokens/box-defaults.d.ts +5 -0
  184. package/dist/foundations/tokens/box-defaults.js +52 -0
  185. package/dist/foundations/tokens/index.d.ts +5 -0
  186. package/dist/foundations/tokens/index.js +4 -0
  187. package/dist/foundations/tokens/interaction.d.ts +28 -0
  188. package/dist/foundations/tokens/interaction.js +72 -0
  189. package/dist/foundations/tokens/registry.d.ts +14 -0
  190. package/dist/foundations/tokens/registry.js +92 -0
  191. package/dist/foundations/tokens/types.d.ts +16 -0
  192. package/dist/foundations/tokens/types.js +1 -0
  193. package/dist/foundations/typography/index.d.ts +2 -0
  194. package/dist/foundations/typography/index.js +1 -0
  195. package/dist/foundations/typography/tokens.d.ts +76 -0
  196. package/dist/foundations/typography/tokens.js +27 -0
  197. package/dist/index.d.ts +87 -0
  198. package/dist/index.js +98 -0
  199. package/dist/patterns/content-explorer/actions/controller.d.ts +12 -0
  200. package/dist/patterns/content-explorer/actions/controller.js +36 -0
  201. package/dist/patterns/content-explorer/actions/index.d.ts +2 -0
  202. package/dist/patterns/content-explorer/actions/index.js +1 -0
  203. package/dist/patterns/content-explorer/actions/types.d.ts +13 -0
  204. package/dist/patterns/content-explorer/actions/types.js +1 -0
  205. package/dist/patterns/content-explorer/adapters/action-menu.d.ts +24 -0
  206. package/dist/patterns/content-explorer/adapters/action-menu.js +312 -0
  207. package/dist/patterns/content-explorer/adapters/breadcrumbs.d.ts +15 -0
  208. package/dist/patterns/content-explorer/adapters/breadcrumbs.js +161 -0
  209. package/dist/patterns/content-explorer/adapters/item-summary.d.ts +11 -0
  210. package/dist/patterns/content-explorer/adapters/item-summary.js +72 -0
  211. package/dist/patterns/content-explorer/adapters/items.d.ts +4 -0
  212. package/dist/patterns/content-explorer/adapters/items.js +12 -0
  213. package/dist/patterns/content-explorer/adapters/list.d.ts +28 -0
  214. package/dist/patterns/content-explorer/adapters/list.js +527 -0
  215. package/dist/patterns/content-explorer/adapters/table.d.ts +23 -0
  216. package/dist/patterns/content-explorer/adapters/table.js +467 -0
  217. package/dist/patterns/content-explorer/adapters/toolbar.d.ts +19 -0
  218. package/dist/patterns/content-explorer/adapters/toolbar.js +234 -0
  219. package/dist/patterns/content-explorer/box-transport.d.ts +44 -0
  220. package/dist/patterns/content-explorer/box-transport.js +229 -0
  221. package/dist/patterns/content-explorer/collection/controller.d.ts +17 -0
  222. package/dist/patterns/content-explorer/collection/controller.js +67 -0
  223. package/dist/patterns/content-explorer/collection/index.d.ts +2 -0
  224. package/dist/patterns/content-explorer/collection/index.js +1 -0
  225. package/dist/patterns/content-explorer/collection/types.d.ts +20 -0
  226. package/dist/patterns/content-explorer/collection/types.js +1 -0
  227. package/dist/patterns/content-explorer/content-explorer.d.ts +85 -0
  228. package/dist/patterns/content-explorer/content-explorer.js +745 -0
  229. package/dist/patterns/content-explorer/contracts.d.ts +32 -0
  230. package/dist/patterns/content-explorer/contracts.js +114 -0
  231. package/dist/patterns/content-explorer/controller.d.ts +34 -0
  232. package/dist/patterns/content-explorer/controller.js +399 -0
  233. package/dist/patterns/content-explorer/host-bindings.d.ts +50 -0
  234. package/dist/patterns/content-explorer/host-bindings.js +76 -0
  235. package/dist/patterns/content-explorer/index.d.ts +18 -0
  236. package/dist/patterns/content-explorer/index.js +24 -0
  237. package/dist/patterns/content-explorer/navigation/controller.d.ts +10 -0
  238. package/dist/patterns/content-explorer/navigation/controller.js +48 -0
  239. package/dist/patterns/content-explorer/navigation/index.d.ts +2 -0
  240. package/dist/patterns/content-explorer/navigation/index.js +1 -0
  241. package/dist/patterns/content-explorer/navigation/types.d.ts +20 -0
  242. package/dist/patterns/content-explorer/navigation/types.js +1 -0
  243. package/dist/patterns/content-explorer/schemas.d.ts +6 -0
  244. package/dist/patterns/content-explorer/schemas.js +120 -0
  245. package/dist/patterns/content-explorer/selection/controller.d.ts +12 -0
  246. package/dist/patterns/content-explorer/selection/controller.js +54 -0
  247. package/dist/patterns/content-explorer/selection/index.d.ts +2 -0
  248. package/dist/patterns/content-explorer/selection/index.js +1 -0
  249. package/dist/patterns/content-explorer/selection/types.d.ts +14 -0
  250. package/dist/patterns/content-explorer/selection/types.js +1 -0
  251. package/dist/patterns/content-explorer/types.d.ts +209 -0
  252. package/dist/patterns/content-explorer/types.js +10 -0
  253. package/dist/patterns/file-request/file-request-builder.d.ts +36 -0
  254. package/dist/patterns/file-request/file-request-builder.js +344 -0
  255. package/dist/patterns/file-request/index.d.ts +1 -0
  256. package/dist/patterns/file-request/index.js +1 -0
  257. package/dist/patterns/governance/governance-panel.d.ts +40 -0
  258. package/dist/patterns/governance/governance-panel.js +351 -0
  259. package/dist/patterns/governance/index.d.ts +1 -0
  260. package/dist/patterns/governance/index.js +1 -0
  261. package/dist/patterns/insights/bar-chart.d.ts +43 -0
  262. package/dist/patterns/insights/bar-chart.js +462 -0
  263. package/dist/patterns/insights/chart-panel.d.ts +43 -0
  264. package/dist/patterns/insights/chart-panel.js +436 -0
  265. package/dist/patterns/insights/donut-chart.d.ts +43 -0
  266. package/dist/patterns/insights/donut-chart.js +535 -0
  267. package/dist/patterns/insights/index.d.ts +5 -0
  268. package/dist/patterns/insights/index.js +5 -0
  269. package/dist/patterns/insights/line-chart.d.ts +46 -0
  270. package/dist/patterns/insights/line-chart.js +511 -0
  271. package/dist/patterns/insights/metric-card.d.ts +36 -0
  272. package/dist/patterns/insights/metric-card.js +278 -0
  273. package/dist/patterns/item/bulk-action-bar.d.ts +35 -0
  274. package/dist/patterns/item/bulk-action-bar.js +325 -0
  275. package/dist/patterns/item/index.d.ts +4 -0
  276. package/dist/patterns/item/index.js +4 -0
  277. package/dist/patterns/item/item-details-panel.d.ts +61 -0
  278. package/dist/patterns/item/item-details-panel.js +429 -0
  279. package/dist/patterns/item/item-form.d.ts +54 -0
  280. package/dist/patterns/item/item-form.js +485 -0
  281. package/dist/patterns/item/preview-header.d.ts +46 -0
  282. package/dist/patterns/item/preview-header.js +323 -0
  283. package/dist/patterns/metadata/contracts.d.ts +75 -0
  284. package/dist/patterns/metadata/contracts.js +91 -0
  285. package/dist/patterns/metadata/index.d.ts +4 -0
  286. package/dist/patterns/metadata/index.js +4 -0
  287. package/dist/patterns/metadata/metadata-filter-builder.d.ts +43 -0
  288. package/dist/patterns/metadata/metadata-filter-builder.js +362 -0
  289. package/dist/patterns/metadata/metadata-inspector.d.ts +31 -0
  290. package/dist/patterns/metadata/metadata-inspector.js +245 -0
  291. package/dist/patterns/metadata/schemas.d.ts +5 -0
  292. package/dist/patterns/metadata/schemas.js +66 -0
  293. package/dist/patterns/preview/annotation-inspector.d.ts +44 -0
  294. package/dist/patterns/preview/annotation-inspector.js +380 -0
  295. package/dist/patterns/preview/annotation-thread.d.ts +37 -0
  296. package/dist/patterns/preview/annotation-thread.js +338 -0
  297. package/dist/patterns/preview/annotation-toolbar.d.ts +42 -0
  298. package/dist/patterns/preview/annotation-toolbar.js +393 -0
  299. package/dist/patterns/preview/content-preview-adapter.d.ts +13 -0
  300. package/dist/patterns/preview/content-preview-adapter.js +30 -0
  301. package/dist/patterns/preview/index.d.ts +6 -0
  302. package/dist/patterns/preview/index.js +6 -0
  303. package/dist/patterns/preview/preview-element.d.ts +41 -0
  304. package/dist/patterns/preview/preview-element.js +429 -0
  305. package/dist/patterns/preview/provider-adapter.d.ts +36 -0
  306. package/dist/patterns/preview/provider-adapter.js +29 -0
  307. package/dist/patterns/search/filter-bar.d.ts +50 -0
  308. package/dist/patterns/search/filter-bar.js +379 -0
  309. package/dist/patterns/search/index.d.ts +3 -0
  310. package/dist/patterns/search/index.js +3 -0
  311. package/dist/patterns/search/saved-view-picker.d.ts +25 -0
  312. package/dist/patterns/search/saved-view-picker.js +239 -0
  313. package/dist/patterns/search/search-results-header.d.ts +34 -0
  314. package/dist/patterns/search/search-results-header.js +288 -0
  315. package/dist/patterns/share/access-stats.d.ts +19 -0
  316. package/dist/patterns/share/access-stats.js +204 -0
  317. package/dist/patterns/share/collaborator-avatars.d.ts +22 -0
  318. package/dist/patterns/share/collaborator-avatars.js +214 -0
  319. package/dist/patterns/share/contracts.d.ts +65 -0
  320. package/dist/patterns/share/contracts.js +75 -0
  321. package/dist/patterns/share/index.d.ts +14 -0
  322. package/dist/patterns/share/index.js +14 -0
  323. package/dist/patterns/share/invite-collaborators-contracts.d.ts +38 -0
  324. package/dist/patterns/share/invite-collaborators-contracts.js +1 -0
  325. package/dist/patterns/share/invite-collaborators-controller.d.ts +40 -0
  326. package/dist/patterns/share/invite-collaborators-controller.js +86 -0
  327. package/dist/patterns/share/invite-collaborators-modal.d.ts +46 -0
  328. package/dist/patterns/share/invite-collaborators-modal.js +465 -0
  329. package/dist/patterns/share/permission-matrix.d.ts +37 -0
  330. package/dist/patterns/share/permission-matrix.js +360 -0
  331. package/dist/patterns/share/presence-contracts.d.ts +26 -0
  332. package/dist/patterns/share/presence-contracts.js +1 -0
  333. package/dist/patterns/share/presence-controller.d.ts +31 -0
  334. package/dist/patterns/share/presence-controller.js +47 -0
  335. package/dist/patterns/share/presence.d.ts +32 -0
  336. package/dist/patterns/share/presence.js +255 -0
  337. package/dist/patterns/share/schemas.d.ts +4 -0
  338. package/dist/patterns/share/schemas.js +41 -0
  339. package/dist/patterns/share/share-panel.d.ts +75 -0
  340. package/dist/patterns/share/share-panel.js +565 -0
  341. package/dist/patterns/share/unified-share-controller.d.ts +52 -0
  342. package/dist/patterns/share/unified-share-controller.js +97 -0
  343. package/dist/patterns/share/unified-share-modal.d.ts +50 -0
  344. package/dist/patterns/share/unified-share-modal.js +646 -0
  345. package/dist/patterns/task/index.d.ts +2 -0
  346. package/dist/patterns/task/index.js +2 -0
  347. package/dist/patterns/task/review-queue-item.d.ts +45 -0
  348. package/dist/patterns/task/review-queue-item.js +403 -0
  349. package/dist/patterns/task/task-assignment-panel.d.ts +50 -0
  350. package/dist/patterns/task/task-assignment-panel.js +450 -0
  351. package/package.json +151 -0
@@ -0,0 +1,187 @@
1
+ import { DESIGN_SYSTEM_CHANGE_EVENT, resolveDesignIcon, } from "../../foundations/tokens/registry.js";
2
+ import { BaseElement } from "../../core/index.js";
3
+ import { boeRadius } from "../../foundations/geometry/index.js";
4
+ import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
5
+ const DEFAULT_TAG_NAME = "box-icon-button";
6
+ const escapeHtml = (value) => value
7
+ .replaceAll("&", "&")
8
+ .replaceAll("<", "&lt;")
9
+ .replaceAll(">", "&gt;")
10
+ .replaceAll('"', "&quot;")
11
+ .replaceAll("'", "&#39;");
12
+ const iconButtonStyles = `
13
+ :host {
14
+ display: inline-block;
15
+ color: inherit;
16
+ font: inherit;
17
+ }
18
+
19
+ [part="button"] {
20
+ appearance: none;
21
+ width: 2rem;
22
+ height: 2rem;
23
+ display: inline-grid;
24
+ place-items: center;
25
+ padding: 0;
26
+ font: inherit;
27
+ border: 1px solid var(--boe-token-stroke-stroke, #e8e8e8);
28
+ border-radius: ${boeRadius.control};
29
+ background: var(--boe-token-surface-surface, #ffffff);
30
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
31
+ cursor: pointer;
32
+ box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
33
+ transition:
34
+ background-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
35
+ border-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
36
+ color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
37
+ box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
38
+ }
39
+
40
+ [part="button"]:hover:not(:disabled) {
41
+ border-color: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 28%, var(--boe-token-stroke-stroke, #e8e8e8) 72%);
42
+ background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 8%, var(--boe-token-surface-surface, #ffffff) 92%);
43
+ color: var(--boe-token-surface-surface-brand, #0061d5);
44
+ }
45
+
46
+ [part="button"]:active:not(:disabled) {
47
+ background: color-mix(in srgb, var(--boe-token-surface-item-surface-selected, #f2f7fd) 70%, var(--boe-token-surface-surface, #ffffff) 30%);
48
+ }
49
+
50
+ [part="button"][data-tone="primary"] {
51
+ border-color: transparent;
52
+ background: var(--boe-token-surface-surface-brand, #0061d5);
53
+ color: var(--boe-token-text-text-on-brand, #ffffff);
54
+ }
55
+
56
+ [part="button"][data-tone="primary"]:hover:not(:disabled) {
57
+ background: var(--boe-token-surface-surface-brand-hover, #006ae9);
58
+ color: var(--boe-token-text-text-on-brand, #ffffff);
59
+ }
60
+
61
+ [part="button"][data-tone="primary"]:active:not(:disabled) {
62
+ background: var(--boe-token-surface-surface-brand-pressed, #004eac);
63
+ }
64
+
65
+ [part="button"][data-tone="danger"] {
66
+ border-color: transparent;
67
+ background: var(--boe-token-surface-status-surface-error, #ed3757);
68
+ color: var(--boe-token-text-text-on-brand, #ffffff);
69
+ }
70
+
71
+ [part="button"][data-tone="danger"]:hover:not(:disabled) {
72
+ background: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 90%, var(--boe-token-surface-surface, #ffffff) 10%);
73
+ color: var(--boe-token-text-text-on-brand, #ffffff);
74
+ }
75
+
76
+ [part="button"]:focus-visible {
77
+ outline: none;
78
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
79
+ }
80
+
81
+ [part="button"]:disabled {
82
+ cursor: not-allowed;
83
+ opacity: 0.55;
84
+ box-shadow: none;
85
+ }
86
+
87
+ [part="icon"] {
88
+ display: inline-grid;
89
+ place-items: center;
90
+ font-size: 1rem;
91
+ line-height: 1;
92
+ }
93
+
94
+ [part="icon"] svg {
95
+ width: 1.1em;
96
+ height: 1.1em;
97
+ display: block;
98
+ fill: currentColor;
99
+ }
100
+ `;
101
+ export class BoxIconButtonElement extends BaseElement {
102
+ handleDesignSystemChange = () => {
103
+ if (this.isRendered) {
104
+ this.update();
105
+ }
106
+ };
107
+ static get observedAttributes() {
108
+ return ["disabled", "icon", "label", "tone"];
109
+ }
110
+ buttonEl;
111
+ iconEl;
112
+ get disabled() {
113
+ return this.hasAttribute("disabled");
114
+ }
115
+ set disabled(value) {
116
+ if (value) {
117
+ this.setAttribute("disabled", "");
118
+ }
119
+ else {
120
+ this.removeAttribute("disabled");
121
+ }
122
+ }
123
+ get icon() {
124
+ return this.getAttribute("icon") ?? "•";
125
+ }
126
+ set icon(value) {
127
+ this.setAttribute("icon", value);
128
+ }
129
+ get label() {
130
+ return this.getAttribute("label") ?? "Icon button";
131
+ }
132
+ set label(value) {
133
+ this.setAttribute("label", value);
134
+ }
135
+ get tone() {
136
+ return this.getAttribute("tone") ?? "secondary";
137
+ }
138
+ set tone(value) {
139
+ this.setAttribute("tone", value);
140
+ }
141
+ connectedCallback() {
142
+ globalThis.addEventListener?.(DESIGN_SYSTEM_CHANGE_EVENT, this.handleDesignSystemChange);
143
+ super.connectedCallback();
144
+ }
145
+ disconnectedCallback() {
146
+ globalThis.removeEventListener?.(DESIGN_SYSTEM_CHANGE_EVENT, this.handleDesignSystemChange);
147
+ }
148
+ renderTemplate() {
149
+ if (!this.shadowRoot) {
150
+ return;
151
+ }
152
+ this.shadowRoot.innerHTML = `
153
+ <style>${iconButtonStyles}</style>
154
+ <button type="button" part="button">
155
+ <span part="icon" aria-hidden="true"></span>
156
+ </button>
157
+ `;
158
+ this.buttonEl = this.shadowRoot.querySelector('[part="button"]');
159
+ this.iconEl = this.shadowRoot.querySelector('[part="icon"]');
160
+ }
161
+ update() {
162
+ if (!this.buttonEl || !this.iconEl) {
163
+ return;
164
+ }
165
+ const resolvedIcon = resolveDesignIcon(this.icon);
166
+ const iconMarkup = resolvedIcon ?? escapeHtml(this.icon);
167
+ this.buttonEl.setAttribute("aria-label", this.label);
168
+ this.buttonEl.setAttribute("title", this.label);
169
+ this.buttonEl.dataset.tone = this.tone;
170
+ if (this.disabled) {
171
+ this.buttonEl.setAttribute("disabled", "");
172
+ }
173
+ else {
174
+ this.buttonEl.removeAttribute("disabled");
175
+ }
176
+ this.iconEl.dataset.iconSource = resolvedIcon ? "design-system" : "text";
177
+ this.iconEl.innerHTML = iconMarkup;
178
+ }
179
+ }
180
+ export const defineBoxIconButtonElement = (tagName = DEFAULT_TAG_NAME) => {
181
+ const existingElement = customElements.get(tagName);
182
+ if (existingElement) {
183
+ return existingElement;
184
+ }
185
+ customElements.define(tagName, BoxIconButtonElement);
186
+ return BoxIconButtonElement;
187
+ };
@@ -0,0 +1,14 @@
1
+ import { BaseElement } from "../../core/index.js";
2
+ export declare class BoxLinkButtonElement extends BaseElement {
3
+ static get observedAttributes(): string[];
4
+ private linkEl;
5
+ get href(): string;
6
+ set href(value: string);
7
+ get label(): string;
8
+ set label(value: string);
9
+ get tone(): string;
10
+ set tone(value: string);
11
+ protected renderTemplate(): void;
12
+ protected update(): void;
13
+ }
14
+ export declare const defineBoxLinkButtonElement: (tagName?: string) => typeof BoxLinkButtonElement;
@@ -0,0 +1,137 @@
1
+ import { BaseElement } from "../../core/index.js";
2
+ import { boeRadius } from "../../foundations/geometry/index.js";
3
+ import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
4
+ const DEFAULT_TAG_NAME = "box-link-button";
5
+ const escapeHtml = (value) => value
6
+ .replaceAll("&", "&amp;")
7
+ .replaceAll("<", "&lt;")
8
+ .replaceAll(">", "&gt;")
9
+ .replaceAll('"', "&quot;")
10
+ .replaceAll("'", "&#39;");
11
+ /**
12
+ * Reject dangerous URL schemes (javascript:, data:, vbscript:) before the href
13
+ * reaches the DOM. `escapeHtml` prevents attribute breakout but does NOT stop a
14
+ * scheme from executing on click, so navigable URLs must be scheme-validated.
15
+ * Relative URLs, fragments, and query strings have no scheme and are allowed.
16
+ */
17
+ const safeHref = (value) => {
18
+ // Strip tab/newline/CR first: browsers ignore them in URLs, so "java\nscript:"
19
+ // normalizes back to the javascript: scheme on navigation and must not slip past.
20
+ const trimmed = value.replace(/[\t\n\r]/g, "").trim();
21
+ const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(trimmed);
22
+ if (!scheme)
23
+ return trimmed; // relative / fragment / query — no scheme to abuse
24
+ return ["http", "https", "mailto", "tel"].includes(scheme[1].toLowerCase()) ? trimmed : "#";
25
+ };
26
+ const linkButtonStyles = `
27
+ :host {
28
+ display: inline-block;
29
+ color: inherit;
30
+ font: inherit;
31
+ }
32
+
33
+ [part="link"] {
34
+ display: inline-flex;
35
+ align-items: center;
36
+ gap: 0.35em;
37
+ font: inherit;
38
+ font-weight: 600;
39
+ line-height: 1.2;
40
+ padding: 0.35em 0.6em;
41
+ margin: -0.35em -0.6em;
42
+ border-radius: ${boeRadius.control};
43
+ color: var(--boe-token-surface-surface-brand, #0061d5);
44
+ text-decoration: none;
45
+ text-underline-offset: 0.2em;
46
+ cursor: pointer;
47
+ transition:
48
+ background-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
49
+ color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
50
+ box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
51
+ }
52
+
53
+ [part="link"]:hover {
54
+ text-decoration: underline;
55
+ background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 8%, transparent);
56
+ color: var(--boe-token-surface-surface-brand-hover, #006ae9);
57
+ }
58
+
59
+ [part="link"]:active {
60
+ color: var(--boe-token-surface-surface-brand-pressed, #004eac);
61
+ background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 12%, transparent);
62
+ }
63
+
64
+ [part="link"]:focus-visible {
65
+ outline: none;
66
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
67
+ }
68
+
69
+ [part="link"][data-tone="neutral"] {
70
+ color: var(--boe-token-text-text, #222222);
71
+ }
72
+
73
+ [part="link"][data-tone="neutral"]:hover {
74
+ background: var(--boe-token-surface-surface-hover, #f4f4f4);
75
+ color: var(--boe-token-text-text, #222222);
76
+ }
77
+
78
+ [part="link"][data-tone="danger"] {
79
+ color: var(--boe-token-surface-status-surface-error, #ed3757);
80
+ }
81
+
82
+ [part="link"][data-tone="danger"]:hover {
83
+ background: color-mix(in srgb, var(--boe-token-surface-status-surface-error, #ed3757) 8%, transparent);
84
+ color: var(--boe-token-surface-status-surface-error, #ed3757);
85
+ }
86
+ `;
87
+ export class BoxLinkButtonElement extends BaseElement {
88
+ static get observedAttributes() {
89
+ return ["href", "label", "tone"];
90
+ }
91
+ linkEl;
92
+ get href() {
93
+ return this.getAttribute("href") ?? "#";
94
+ }
95
+ set href(value) {
96
+ this.setAttribute("href", value);
97
+ }
98
+ get label() {
99
+ return this.getAttribute("label") ?? "Learn more";
100
+ }
101
+ set label(value) {
102
+ this.setAttribute("label", value);
103
+ }
104
+ get tone() {
105
+ return this.getAttribute("tone") ?? "primary";
106
+ }
107
+ set tone(value) {
108
+ this.setAttribute("tone", value);
109
+ }
110
+ renderTemplate() {
111
+ if (!this.shadowRoot) {
112
+ return;
113
+ }
114
+ this.shadowRoot.innerHTML = `
115
+ <style>${linkButtonStyles}</style>
116
+ <a part="link"></a>
117
+ `;
118
+ this.linkEl = this.shadowRoot.querySelector('[part="link"]');
119
+ }
120
+ update() {
121
+ if (!this.linkEl) {
122
+ return;
123
+ }
124
+ this.linkEl.dataset.tone = this.tone;
125
+ this.linkEl.setAttribute("href", escapeHtml(safeHref(this.href)));
126
+ this.linkEl.setAttribute("aria-label", this.label);
127
+ this.linkEl.textContent = this.label;
128
+ }
129
+ }
130
+ export const defineBoxLinkButtonElement = (tagName = DEFAULT_TAG_NAME) => {
131
+ const existingElement = customElements.get(tagName);
132
+ if (existingElement) {
133
+ return existingElement;
134
+ }
135
+ customElements.define(tagName, BoxLinkButtonElement);
136
+ return BoxLinkButtonElement;
137
+ };
@@ -0,0 +1,17 @@
1
+ import { BaseElement } from "../../core/index.js";
2
+ export declare class BoxMenuItemElement extends BaseElement {
3
+ static get observedAttributes(): string[];
4
+ private itemEl;
5
+ get disabled(): boolean;
6
+ set disabled(value: boolean);
7
+ get label(): string;
8
+ set label(value: string);
9
+ get value(): string;
10
+ set value(value: string);
11
+ get selected(): boolean;
12
+ set selected(value: boolean);
13
+ protected renderTemplate(): void;
14
+ protected setupListeners(): void;
15
+ protected update(): void;
16
+ }
17
+ export declare const defineBoxMenuItemElement: (tagName?: string) => typeof BoxMenuItemElement;
@@ -0,0 +1,137 @@
1
+ import { BaseElement } from "../../core/index.js";
2
+ import { boeControl, boeOverlay } from "../../foundations/geometry/index.js";
3
+ import { boeNeutralInteractiveStyles } from "../../foundations/tokens/index.js";
4
+ import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
5
+ const DEFAULT_TAG_NAME = "box-menu-item";
6
+ const menuItemStyles = `
7
+ :host {
8
+ display: block;
9
+ color: inherit;
10
+ font: inherit;
11
+ }
12
+
13
+ [part="item"] {
14
+ width: 100%;
15
+ appearance: none;
16
+ box-sizing: border-box;
17
+ display: flex;
18
+ align-items: center;
19
+ min-height: ${boeOverlay.itemMinHeight};
20
+ text-align: left;
21
+ border: 0;
22
+ border-radius: ${boeOverlay.itemRadius};
23
+ background: transparent;
24
+ color: var(--boe-token-text-text, #222222);
25
+ font: inherit;
26
+ font-size: ${boeControl.fontSize};
27
+ padding: ${boeOverlay.itemPadding};
28
+ cursor: pointer;
29
+ transition:
30
+ background-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
31
+ color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
32
+ box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
33
+ }
34
+
35
+ [part="item"][data-selected="true"] {
36
+ background: var(--boe-token-surface-item-surface-selected, #f2f7fd);
37
+ color: var(--boe-token-text-text, #222222);
38
+ font-weight: 600;
39
+ }
40
+
41
+ ${boeNeutralInteractiveStyles('[part="item"]')}
42
+
43
+ [part="item"][data-selected="true"]:hover:not(:disabled),
44
+ [part="item"][data-selected="true"]:active:not(:disabled) {
45
+ background: var(--boe-token-surface-item-surface-selected, #f2f7fd);
46
+ }
47
+
48
+ [part="item"]:hover:not(:disabled),
49
+ [part="item"]:focus-visible:not(:disabled) {
50
+ background: var(--boe-token-surface-surface-hover, #f4f4f4);
51
+ color: var(--boe-token-text-text, #222222);
52
+ }
53
+
54
+ [part="item"]:disabled {
55
+ opacity: ${boeControl.disabledOpacity};
56
+ }
57
+ `;
58
+ export class BoxMenuItemElement extends BaseElement {
59
+ static get observedAttributes() {
60
+ return ["disabled", "label", "selected", "value"];
61
+ }
62
+ itemEl;
63
+ get disabled() {
64
+ return this.hasAttribute("disabled");
65
+ }
66
+ set disabled(value) {
67
+ if (value) {
68
+ this.setAttribute("disabled", "");
69
+ }
70
+ else {
71
+ this.removeAttribute("disabled");
72
+ }
73
+ }
74
+ get label() {
75
+ return this.getAttribute("label") ?? "Menu Item";
76
+ }
77
+ set label(value) {
78
+ this.setAttribute("label", value);
79
+ }
80
+ get value() {
81
+ return this.getAttribute("value") ?? "";
82
+ }
83
+ set value(value) {
84
+ this.setAttribute("value", value);
85
+ }
86
+ get selected() {
87
+ return this.hasAttribute("selected");
88
+ }
89
+ set selected(value) {
90
+ if (value) {
91
+ this.setAttribute("selected", "");
92
+ }
93
+ else {
94
+ this.removeAttribute("selected");
95
+ }
96
+ }
97
+ renderTemplate() {
98
+ if (!this.shadowRoot) {
99
+ return;
100
+ }
101
+ this.shadowRoot.innerHTML = `
102
+ <style>${menuItemStyles}</style>
103
+ <button type="button" part="item" role="menuitemradio"></button>
104
+ `;
105
+ this.itemEl = this.shadowRoot.querySelector('[part="item"]');
106
+ }
107
+ setupListeners() {
108
+ this.itemEl.addEventListener("click", () => {
109
+ if (this.disabled) {
110
+ return;
111
+ }
112
+ this.dispatchEvent(new CustomEvent("selected", {
113
+ bubbles: true,
114
+ composed: true,
115
+ detail: { value: this.value, label: this.label },
116
+ }));
117
+ });
118
+ }
119
+ update() {
120
+ if (!this.itemEl) {
121
+ return;
122
+ }
123
+ this.itemEl.dataset.selected = String(this.selected);
124
+ this.itemEl.setAttribute("aria-checked", String(this.selected));
125
+ this.itemEl.setAttribute("aria-disabled", String(this.disabled));
126
+ this.itemEl.disabled = this.disabled;
127
+ this.itemEl.textContent = this.label;
128
+ }
129
+ }
130
+ export const defineBoxMenuItemElement = (tagName = DEFAULT_TAG_NAME) => {
131
+ const existingElement = customElements.get(tagName);
132
+ if (existingElement) {
133
+ return existingElement;
134
+ }
135
+ customElements.define(tagName, BoxMenuItemElement);
136
+ return BoxMenuItemElement;
137
+ };
@@ -0,0 +1,22 @@
1
+ import { BaseElement } from "../../core/index.js";
2
+ type BoxMenuItem = {
3
+ disabled?: boolean;
4
+ id: string;
5
+ label: string;
6
+ };
7
+ export declare class BoxMenuElement extends BaseElement {
8
+ static get observedAttributes(): string[];
9
+ private menuEl;
10
+ get disabled(): boolean;
11
+ set disabled(value: boolean);
12
+ get label(): string;
13
+ set label(value: string);
14
+ get items(): BoxMenuItem[];
15
+ set items(value: BoxMenuItem[]);
16
+ protected renderTemplate(): void;
17
+ protected setupListeners(): void;
18
+ private enabledMenuItems;
19
+ protected update(): void;
20
+ }
21
+ export declare const defineBoxMenuElement: (tagName?: string) => typeof BoxMenuElement;
22
+ export {};
@@ -0,0 +1,178 @@
1
+ import { BaseElement } from "../../core/index.js";
2
+ import { applyRovingTabindex, focusRovingItem, nextRovingIndex, } from "../../foundations/a11y/index.js";
3
+ import { boeControl, boeOverlay } from "../../foundations/geometry/index.js";
4
+ import { boeNeutralInteractiveStyles } from "../../foundations/tokens/index.js";
5
+ import { boeMotionDuration, boeMotionEasing } from "../../foundations/motion/index.js";
6
+ const DEFAULT_TAG_NAME = "box-menu";
7
+ const escapeHtml = (value) => value
8
+ .replaceAll("&", "&amp;")
9
+ .replaceAll("<", "&lt;")
10
+ .replaceAll(">", "&gt;")
11
+ .replaceAll('"', "&quot;")
12
+ .replaceAll("'", "&#39;");
13
+ const menuStyles = `
14
+ :host {
15
+ display: inline-block;
16
+ color: inherit;
17
+ font: inherit;
18
+ }
19
+
20
+ [part="menu"] {
21
+ min-width: 11rem;
22
+ margin: 0;
23
+ padding: ${boeOverlay.padding};
24
+ display: grid;
25
+ gap: 0;
26
+ border: ${boeOverlay.border};
27
+ border-radius: ${boeOverlay.radius};
28
+ background: var(--boe-token-surface-surface, #ffffff);
29
+ box-shadow: ${boeOverlay.shadow};
30
+ }
31
+
32
+ [part="menu-item"] {
33
+ width: 100%;
34
+ appearance: none;
35
+ box-sizing: border-box;
36
+ display: flex;
37
+ align-items: center;
38
+ min-height: ${boeOverlay.itemMinHeight};
39
+ text-align: left;
40
+ border: 0;
41
+ border-radius: ${boeOverlay.itemRadius};
42
+ background: transparent;
43
+ color: var(--boe-token-text-text, #222222);
44
+ font: inherit;
45
+ font-size: ${boeControl.fontSize};
46
+ padding: ${boeOverlay.itemPadding};
47
+ cursor: pointer;
48
+ transition:
49
+ background-color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
50
+ color ${boeMotionDuration.interactive} ${boeMotionEasing.standard},
51
+ box-shadow ${boeMotionDuration.interactive} ${boeMotionEasing.standard};
52
+ }
53
+
54
+ ${boeNeutralInteractiveStyles('[part="menu-item"]')}
55
+
56
+ [part="menu-item"]:hover:not(:disabled),
57
+ [part="menu-item"]:focus-visible:not(:disabled) {
58
+ background: var(--boe-token-surface-surface-hover, #f4f4f4);
59
+ color: var(--boe-token-text-text, #222222);
60
+ }
61
+
62
+ [part="menu-item"]:disabled {
63
+ opacity: ${boeControl.disabledOpacity};
64
+ }
65
+ `;
66
+ export class BoxMenuElement extends BaseElement {
67
+ static get observedAttributes() {
68
+ return ["disabled", "items", "label"];
69
+ }
70
+ menuEl;
71
+ get disabled() {
72
+ return this.hasAttribute("disabled");
73
+ }
74
+ set disabled(value) {
75
+ if (value) {
76
+ this.setAttribute("disabled", "");
77
+ }
78
+ else {
79
+ this.removeAttribute("disabled");
80
+ }
81
+ }
82
+ get label() {
83
+ return this.getAttribute("label") ?? "Menu";
84
+ }
85
+ set label(value) {
86
+ this.setAttribute("label", value);
87
+ }
88
+ get items() {
89
+ const raw = this.getAttribute("items");
90
+ if (!raw) {
91
+ return [];
92
+ }
93
+ try {
94
+ const parsed = JSON.parse(raw);
95
+ return Array.isArray(parsed) ? parsed : [];
96
+ }
97
+ catch {
98
+ return [];
99
+ }
100
+ }
101
+ set items(value) {
102
+ this.setAttribute("items", JSON.stringify(value));
103
+ }
104
+ renderTemplate() {
105
+ if (!this.shadowRoot) {
106
+ return;
107
+ }
108
+ this.shadowRoot.innerHTML = `
109
+ <style>${menuStyles}</style>
110
+ <div part="menu" role="menu"></div>
111
+ `;
112
+ this.menuEl = this.shadowRoot.querySelector('[part="menu"]');
113
+ }
114
+ setupListeners() {
115
+ this.menuEl.addEventListener("click", event => {
116
+ const button = event.target?.closest('[part="menu-item"]');
117
+ if (!button || !this.menuEl.contains(button) || button.disabled) {
118
+ return;
119
+ }
120
+ const itemId = button.getAttribute("data-item-id");
121
+ const item = this.items.find(entry => entry.id === itemId);
122
+ if (!item || this.disabled || item.disabled) {
123
+ return;
124
+ }
125
+ this.dispatchEvent(new CustomEvent("item-selected", {
126
+ bubbles: true,
127
+ composed: true,
128
+ detail: item,
129
+ }));
130
+ });
131
+ this.menuEl.addEventListener("keydown", event => {
132
+ const keyboardEvent = event;
133
+ const buttons = this.enabledMenuItems();
134
+ if (buttons.length === 0) {
135
+ return;
136
+ }
137
+ const active = keyboardEvent.target;
138
+ const currentIndex = buttons.indexOf(active);
139
+ if (currentIndex < 0) {
140
+ return;
141
+ }
142
+ const nextIndex = nextRovingIndex(keyboardEvent.key, currentIndex, buttons.length, {
143
+ orientation: "vertical",
144
+ });
145
+ if (nextIndex == null) {
146
+ return;
147
+ }
148
+ keyboardEvent.preventDefault();
149
+ focusRovingItem(buttons, nextIndex);
150
+ });
151
+ }
152
+ enabledMenuItems() {
153
+ return Array.from(this.menuEl.querySelectorAll('[part="menu-item"]')).filter(button => !button.disabled);
154
+ }
155
+ update() {
156
+ if (!this.menuEl) {
157
+ return;
158
+ }
159
+ this.menuEl.setAttribute("aria-label", this.label);
160
+ this.menuEl.innerHTML = this.items
161
+ .map(item => `
162
+ <button type="button" part="menu-item" role="menuitem" data-item-id="${escapeHtml(item.id)}" ${this.disabled || item.disabled ? "disabled" : ""}>
163
+ ${escapeHtml(item.label)}
164
+ </button>
165
+ `)
166
+ .join("");
167
+ const buttons = this.enabledMenuItems();
168
+ applyRovingTabindex(buttons, 0);
169
+ }
170
+ }
171
+ export const defineBoxMenuElement = (tagName = DEFAULT_TAG_NAME) => {
172
+ const existingElement = customElements.get(tagName);
173
+ if (existingElement) {
174
+ return existingElement;
175
+ }
176
+ customElements.define(tagName, BoxMenuElement);
177
+ return BoxMenuElement;
178
+ };