@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,499 @@
1
+ import { FormAssociatedElement, boeFormFieldErrorStyles, formDataFromNamedValues, formErrorMessageMarkup, stringValuesFromFormValue, } from "../../core/index.js";
2
+ import { boeRadius } from "../../foundations/geometry/index.js";
3
+ const DEFAULT_TAG_NAME = "box-pill-selector-dropdown";
4
+ const escapeHtml = (value) => value
5
+ .replaceAll("&", "&")
6
+ .replaceAll("<", "&lt;")
7
+ .replaceAll(">", "&gt;")
8
+ .replaceAll('"', "&quot;")
9
+ .replaceAll("'", "&#39;");
10
+ const pillSelectorStyles = `
11
+ :host {
12
+ display: block;
13
+ color: inherit;
14
+ font: inherit;
15
+ }
16
+
17
+ [part="field"] {
18
+ display: flex;
19
+ flex-wrap: wrap;
20
+ align-items: center;
21
+ gap: 0.4rem;
22
+ padding: 0.4rem;
23
+ border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
24
+ border-radius: ${boeRadius.control};
25
+ background: var(--boe-token-surface-surface, #ffffff);
26
+ }
27
+
28
+ [part="pill"] {
29
+ display: inline-flex;
30
+ align-items: center;
31
+ gap: 0.3rem;
32
+ padding: 0.2rem 0.3rem 0.2rem 0.6rem;
33
+ border-radius: 999px;
34
+ background: color-mix(in srgb, var(--boe-token-surface-surface-secondary, #fbfbfb) 70%, var(--boe-token-surface-surface, #ffffff) 30%);
35
+ border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
36
+ font-size: 0.82rem;
37
+ font-weight: 600;
38
+ }
39
+
40
+ [part="pill-remove"] {
41
+ appearance: none;
42
+ display: inline-flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ inline-size: 1.1rem;
46
+ block-size: 1.1rem;
47
+ padding: 0;
48
+ border: 0;
49
+ border-radius: 999px;
50
+ background: transparent;
51
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
52
+ cursor: pointer;
53
+ }
54
+
55
+ [part="pill-remove"] svg {
56
+ inline-size: 0.65rem;
57
+ block-size: 0.65rem;
58
+ }
59
+
60
+ [part="pill-remove"]:hover {
61
+ background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 16%, transparent);
62
+ color: var(--boe-token-text-text, #222222);
63
+ }
64
+
65
+ [part="dropdown"] {
66
+ position: relative;
67
+ display: inline-block;
68
+ }
69
+
70
+ [part="trigger"] {
71
+ appearance: none;
72
+ display: inline-flex;
73
+ align-items: center;
74
+ gap: 0.3rem;
75
+ padding: 0.3rem 0.6rem;
76
+ border: 1px dashed color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
77
+ border-radius: 999px;
78
+ background: transparent;
79
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
80
+ font: inherit;
81
+ font-size: 0.82rem;
82
+ font-weight: 600;
83
+ cursor: pointer;
84
+ }
85
+
86
+ [part="trigger"]:hover {
87
+ border-color: var(--boe-token-stroke-stroke-hover, #bcbcbc);
88
+ color: var(--boe-token-text-text, #222222);
89
+ }
90
+
91
+ [part="trigger"]:focus-visible,
92
+ [part="option"]:focus-visible {
93
+ outline: none;
94
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 22%, transparent);
95
+ }
96
+
97
+ [part="menu"] {
98
+ position: absolute;
99
+ z-index: 10;
100
+ inset-block-start: calc(100% + 0.25rem);
101
+ inset-inline-start: 0;
102
+ min-inline-size: 11rem;
103
+ margin: 0;
104
+ padding: 0.3rem;
105
+ list-style: none;
106
+ border: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 82%, transparent);
107
+ border-radius: ${boeRadius.large};
108
+ background: var(--boe-token-surface-surface, #ffffff);
109
+ box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
110
+ }
111
+
112
+ [part="option"] {
113
+ appearance: none;
114
+ display: block;
115
+ inline-size: 100%;
116
+ text-align: start;
117
+ padding: 0.4rem 0.55rem;
118
+ border: 0;
119
+ border-radius: ${boeRadius.med};
120
+ background: transparent;
121
+ color: var(--boe-token-text-text, #222222);
122
+ font: inherit;
123
+ font-size: 0.85rem;
124
+ cursor: pointer;
125
+ }
126
+
127
+ [part="option"]:hover {
128
+ background: var(--boe-token-surface-surface-hover, #f4f4f4);
129
+ }
130
+
131
+ [part="option-empty"] {
132
+ padding: 0.4rem 0.55rem;
133
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
134
+ font-size: 0.82rem;
135
+ }
136
+
137
+ ${boeFormFieldErrorStyles}
138
+ `;
139
+ /**
140
+ * A multi-select pill field: the current selection shows as removable pills, and
141
+ * an "Add" dropdown offers the remaining options. Data arrives via `options`;
142
+ * the selection is exposed as `value` (a string[]) and every add/remove emits
143
+ * `value-changed`. The popup is a `role="menu"` of `role="menuitem"` buttons —
144
+ * opening focuses the first item; ArrowUp/Down/Home/End move focus, Escape (or
145
+ * moving focus outside) closes and returns focus to the trigger.
146
+ */
147
+ export class BoxPillSelectorDropdownElement extends FormAssociatedElement {
148
+ static get observedAttributes() {
149
+ return [
150
+ ...FormAssociatedElement.formObservedAttributes,
151
+ "label",
152
+ "options",
153
+ "placeholder",
154
+ "value",
155
+ ];
156
+ }
157
+ valueInternal = [];
158
+ open = false;
159
+ menuFocusValue = null;
160
+ pendingFocus = null;
161
+ fieldEl;
162
+ pillsEl;
163
+ dropdownEl;
164
+ triggerEl;
165
+ menuEl = null;
166
+ errorEl;
167
+ // Close the open menu when a pointer press lands outside this element. Bound
168
+ // once so it can be added/removed cleanly; a focusout listener can't be used
169
+ // because every interaction re-renders and transiently drops focus to body.
170
+ onOutsidePointer = (event) => {
171
+ if (!this.open) {
172
+ return;
173
+ }
174
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
175
+ if (!path.some(node => node === this)) {
176
+ this.closeMenu(false);
177
+ }
178
+ };
179
+ get label() {
180
+ return this.getAttribute("label") ?? "Selection";
181
+ }
182
+ set label(value) {
183
+ this.setAttribute("label", value);
184
+ }
185
+ get placeholder() {
186
+ return this.getAttribute("placeholder") ?? "Add";
187
+ }
188
+ set placeholder(value) {
189
+ this.setAttribute("placeholder", value);
190
+ }
191
+ get options() {
192
+ const raw = this.getAttribute("options");
193
+ if (!raw) {
194
+ return [];
195
+ }
196
+ try {
197
+ const parsed = JSON.parse(raw);
198
+ return Array.isArray(parsed) ? parsed : [];
199
+ }
200
+ catch {
201
+ return [];
202
+ }
203
+ }
204
+ set options(value) {
205
+ this.setAttribute("options", JSON.stringify(value));
206
+ }
207
+ get value() {
208
+ return [...this.valueInternal];
209
+ }
210
+ set value(nextValue) {
211
+ this.valueInternal = [...nextValue];
212
+ this.setAttribute("value", JSON.stringify(nextValue));
213
+ this.syncFormAssociation();
214
+ if (this.isRendered) {
215
+ this.update();
216
+ }
217
+ }
218
+ disconnectedCallback() {
219
+ document.removeEventListener("pointerdown", this.onOutsidePointer);
220
+ }
221
+ attributeChangedCallback(name, oldValue, newValue) {
222
+ if (name === "value") {
223
+ const raw = this.getAttribute("value");
224
+ if (!raw) {
225
+ this.valueInternal = [];
226
+ }
227
+ else {
228
+ try {
229
+ const parsed = JSON.parse(raw);
230
+ this.valueInternal = Array.isArray(parsed) ? parsed : [];
231
+ }
232
+ catch {
233
+ this.valueInternal = [];
234
+ }
235
+ }
236
+ }
237
+ super.attributeChangedCallback(name, oldValue, newValue);
238
+ }
239
+ getFormValue() {
240
+ return formDataFromNamedValues(this.name, this.valueInternal);
241
+ }
242
+ restoreFormValue(value) {
243
+ const next = stringValuesFromFormValue(value, this.name);
244
+ this.valueInternal = next;
245
+ this.setAttribute("value", JSON.stringify(next));
246
+ this.syncFormAssociation();
247
+ if (this.isRendered) {
248
+ this.update();
249
+ }
250
+ }
251
+ availableOptions() {
252
+ return this.options.filter(option => !this.valueInternal.includes(option.value));
253
+ }
254
+ labelFor(value) {
255
+ return this.options.find(option => option.value === value)?.label ?? value;
256
+ }
257
+ commit(next) {
258
+ this.valueInternal = next;
259
+ const serialized = JSON.stringify(next);
260
+ // Render exactly once: setAttribute already triggers attributeChangedCallback
261
+ // (which updates), so only update manually when the attribute is unchanged.
262
+ if (this.getAttribute("value") === serialized) {
263
+ if (this.isRendered) {
264
+ this.update();
265
+ }
266
+ }
267
+ else {
268
+ this.setAttribute("value", serialized);
269
+ }
270
+ this.syncFormAssociation();
271
+ this.dispatchEvent(new CustomEvent("value-changed", {
272
+ bubbles: true,
273
+ composed: true,
274
+ detail: { value: [...next] },
275
+ }));
276
+ }
277
+ addValue(value) {
278
+ if (!value || this.valueInternal.includes(value)) {
279
+ return;
280
+ }
281
+ const next = [...this.valueInternal, value];
282
+ const remaining = this.options.filter(option => !next.includes(option.value));
283
+ this.menuFocusValue = remaining[0]?.value ?? null;
284
+ this.pendingFocus = remaining.length ? "menu" : "trigger";
285
+ this.commit(next);
286
+ }
287
+ removeValue(value) {
288
+ if (!this.valueInternal.includes(value)) {
289
+ return;
290
+ }
291
+ this.pendingFocus = "trigger";
292
+ this.commit(this.valueInternal.filter(item => item !== value));
293
+ }
294
+ openMenu() {
295
+ if (this.open) {
296
+ return;
297
+ }
298
+ this.open = true;
299
+ this.menuFocusValue = this.availableOptions()[0]?.value ?? null;
300
+ this.pendingFocus = this.menuFocusValue ? "menu" : null;
301
+ document.addEventListener("pointerdown", this.onOutsidePointer);
302
+ this.update();
303
+ }
304
+ closeMenu(focusTrigger) {
305
+ if (!this.open) {
306
+ return;
307
+ }
308
+ this.open = false;
309
+ this.menuFocusValue = null;
310
+ this.pendingFocus = focusTrigger ? "trigger" : null;
311
+ document.removeEventListener("pointerdown", this.onOutsidePointer);
312
+ this.update();
313
+ }
314
+ moveMenuFocus(delta) {
315
+ const available = this.availableOptions();
316
+ if (!available.length) {
317
+ return;
318
+ }
319
+ const currentIndex = available.findIndex(option => option.value === this.menuFocusValue);
320
+ const nextIndex = Math.max(0, Math.min(available.length - 1, currentIndex + delta));
321
+ this.menuFocusValue = available[nextIndex]?.value ?? null;
322
+ this.pendingFocus = "menu";
323
+ this.update();
324
+ }
325
+ moveMenuFocusTo(edge) {
326
+ const available = this.availableOptions();
327
+ if (!available.length) {
328
+ return;
329
+ }
330
+ this.menuFocusValue = (edge === "first" ? available[0] : available[available.length - 1])?.value ?? null;
331
+ this.pendingFocus = "menu";
332
+ this.update();
333
+ }
334
+ applyPendingFocus() {
335
+ if (!this.pendingFocus) {
336
+ return;
337
+ }
338
+ const pending = this.pendingFocus;
339
+ this.pendingFocus = null;
340
+ if (pending === "trigger") {
341
+ this.triggerEl.focus();
342
+ return;
343
+ }
344
+ if (pending === "menu" && this.menuFocusValue && this.menuEl) {
345
+ const target = Array.from(this.menuEl.querySelectorAll('[part="option"]')).find(node => node.dataset.value === this.menuFocusValue);
346
+ target?.focus();
347
+ }
348
+ }
349
+ renderTemplate() {
350
+ if (!this.shadowRoot) {
351
+ return;
352
+ }
353
+ this.shadowRoot.innerHTML = `
354
+ <style>${pillSelectorStyles}</style>
355
+ <div part="field" role="group">
356
+ <span part="pills"></span>
357
+ <div part="dropdown">
358
+ <button type="button" part="trigger" aria-haspopup="menu"></button>
359
+ </div>
360
+ ${formErrorMessageMarkup()}
361
+ </div>
362
+ `;
363
+ this.fieldEl = this.shadowRoot.querySelector('[part="field"]');
364
+ this.pillsEl = this.shadowRoot.querySelector('[part="pills"]');
365
+ this.dropdownEl = this.shadowRoot.querySelector('[part="dropdown"]');
366
+ this.triggerEl = this.shadowRoot.querySelector('[part="trigger"]');
367
+ this.errorEl = this.shadowRoot.querySelector('[part="error-message"]');
368
+ }
369
+ setupListeners() {
370
+ this.triggerEl.addEventListener("click", () => {
371
+ if (this.open) {
372
+ this.closeMenu(true);
373
+ }
374
+ else {
375
+ this.openMenu();
376
+ }
377
+ });
378
+ this.triggerEl.addEventListener("keydown", event => {
379
+ const key = event.key;
380
+ if ((key === "ArrowDown" || key === "Enter" || key === " ") && !this.open) {
381
+ event.preventDefault();
382
+ this.openMenu();
383
+ }
384
+ else if (key === "Escape" && this.open) {
385
+ event.preventDefault();
386
+ this.closeMenu(true);
387
+ }
388
+ });
389
+ this.pillsEl.addEventListener("click", event => {
390
+ const remove = event.target.closest('[part="pill-remove"]');
391
+ if (!remove || !this.pillsEl.contains(remove)) {
392
+ return;
393
+ }
394
+ this.removeValue(remove.dataset.value ?? "");
395
+ });
396
+ this.dropdownEl.addEventListener("click", event => {
397
+ const option = event.target.closest('[part="option"]');
398
+ if (!option || !this.dropdownEl.contains(option)) {
399
+ return;
400
+ }
401
+ this.addValue(option.dataset.value ?? "");
402
+ });
403
+ this.dropdownEl.addEventListener("keydown", event => {
404
+ const option = event.target.closest('[part="option"]');
405
+ if (!option || !this.dropdownEl.contains(option)) {
406
+ return;
407
+ }
408
+ const keyboardEvent = event;
409
+ switch (keyboardEvent.key) {
410
+ case "ArrowDown":
411
+ keyboardEvent.preventDefault();
412
+ this.moveMenuFocus(1);
413
+ break;
414
+ case "ArrowUp":
415
+ keyboardEvent.preventDefault();
416
+ this.moveMenuFocus(-1);
417
+ break;
418
+ case "Home":
419
+ keyboardEvent.preventDefault();
420
+ this.moveMenuFocusTo("first");
421
+ break;
422
+ case "End":
423
+ keyboardEvent.preventDefault();
424
+ this.moveMenuFocusTo("last");
425
+ break;
426
+ case "Escape":
427
+ keyboardEvent.preventDefault();
428
+ this.closeMenu(true);
429
+ break;
430
+ default:
431
+ break;
432
+ }
433
+ });
434
+ }
435
+ update() {
436
+ if (!this.fieldEl || !this.pillsEl || !this.triggerEl || !this.errorEl) {
437
+ return;
438
+ }
439
+ this.fieldEl.setAttribute("aria-label", this.label);
440
+ this.triggerEl.textContent = `+ ${this.placeholder}`;
441
+ this.triggerEl.setAttribute("aria-expanded", String(this.open));
442
+ this.pillsEl.innerHTML = this.valueInternal
443
+ .map(value => `
444
+ <span part="pill" data-value="${escapeHtml(value)}">
445
+ <span part="pill-label">${escapeHtml(this.labelFor(value))}</span>
446
+ <button type="button" part="pill-remove" data-value="${escapeHtml(value)}" aria-label="Remove ${escapeHtml(this.labelFor(value))}">
447
+ <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>
448
+ </button>
449
+ </span>
450
+ `)
451
+ .join("");
452
+ const available = this.availableOptions();
453
+ if (this.open) {
454
+ if (!this.menuEl) {
455
+ this.menuEl = document.createElement("ul");
456
+ this.menuEl.setAttribute("part", "menu");
457
+ this.menuEl.setAttribute("role", "menu");
458
+ this.dropdownEl.append(this.menuEl);
459
+ }
460
+ this.menuEl.setAttribute("aria-label", `${this.label} options`);
461
+ this.menuEl.innerHTML = available.length
462
+ ? available
463
+ .map(option => `
464
+ <li part="option-row" role="none">
465
+ <button
466
+ type="button"
467
+ part="option"
468
+ role="menuitem"
469
+ data-value="${escapeHtml(option.value)}"
470
+ tabindex="${option.value === this.menuFocusValue ? "0" : "-1"}"
471
+ >${escapeHtml(option.label)}</button>
472
+ </li>
473
+ `)
474
+ .join("")
475
+ : `<li part="option-empty" role="none">No more options</li>`;
476
+ }
477
+ else if (this.menuEl) {
478
+ this.menuEl.remove();
479
+ this.menuEl = null;
480
+ }
481
+ const focusableControls = [
482
+ this.triggerEl,
483
+ ...Array.from(this.pillsEl.querySelectorAll('[part="pill-remove"]')),
484
+ ];
485
+ if (this.menuEl) {
486
+ focusableControls.push(...Array.from(this.menuEl.querySelectorAll('[part="option"]')));
487
+ }
488
+ this.applyInvalidStateToControls(focusableControls, this.errorEl);
489
+ this.applyPendingFocus();
490
+ }
491
+ }
492
+ export const defineBoxPillSelectorDropdownElement = (tagName = DEFAULT_TAG_NAME) => {
493
+ const existingElement = customElements.get(tagName);
494
+ if (existingElement) {
495
+ return existingElement;
496
+ }
497
+ customElements.define(tagName, BoxPillSelectorDropdownElement);
498
+ return BoxPillSelectorDropdownElement;
499
+ };
@@ -0,0 +1,32 @@
1
+ import { FormAssociatedElement } from "../../core/index.js";
2
+ import type { FormValue } from "../../core/index.js";
3
+ export declare class BoxRadioGroupElement extends FormAssociatedElement {
4
+ static get observedAttributes(): string[];
5
+ private valueInternal;
6
+ private groupName;
7
+ private lastOptionsJson;
8
+ private legendEl;
9
+ private optionsContainerEl;
10
+ private errorEl;
11
+ get value(): string;
12
+ set value(nextValue: string);
13
+ get disabled(): boolean;
14
+ set disabled(value: boolean);
15
+ get label(): string;
16
+ set label(value: string);
17
+ get options(): Array<{
18
+ label: string;
19
+ value: string;
20
+ }>;
21
+ set options(value: Array<{
22
+ label: string;
23
+ value: string;
24
+ }>);
25
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
26
+ protected getFormValue(): FormValue;
27
+ protected restoreFormValue(value: FormValue): void;
28
+ private getRadioGroupName;
29
+ protected renderTemplate(): void;
30
+ protected update(): void;
31
+ }
32
+ export declare const defineBoxRadioGroupElement: (tagName?: string) => typeof BoxRadioGroupElement;