@tanrei/web 0.0.0-stage → 0.1.0-next.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 (781) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +58 -0
  3. package/README.md +9743 -2
  4. package/custom-elements.json +86072 -0
  5. package/dist/THIRD_PARTY_LICENSES.md +136 -0
  6. package/dist/accordion.css +812 -0
  7. package/dist/app-shell.css +493 -0
  8. package/dist/avatar.css +80 -0
  9. package/dist/breadcrumbs.css +511 -0
  10. package/dist/callout.css +65 -0
  11. package/dist/code.css +595 -0
  12. package/dist/components/accordion/accordion.d.ts +197 -0
  13. package/dist/components/accordion/accordion.js +763 -0
  14. package/dist/components/accordion/accordion.js.map +1 -0
  15. package/dist/components/app-bar/app-bar.d.ts +107 -0
  16. package/dist/components/app-bar/app-bar.js +295 -0
  17. package/dist/components/app-bar/app-bar.js.map +1 -0
  18. package/dist/components/app-bar/app-bar.styles.d.ts +12 -0
  19. package/dist/components/app-bar/app-bar.styles.js +223 -0
  20. package/dist/components/app-bar/app-bar.styles.js.map +1 -0
  21. package/dist/components/app-shell/app-shell.d.ts +220 -0
  22. package/dist/components/app-shell/app-shell.js +677 -0
  23. package/dist/components/app-shell/app-shell.js.map +1 -0
  24. package/dist/components/avatar/avatar.d.ts +162 -0
  25. package/dist/components/avatar/avatar.js +390 -0
  26. package/dist/components/avatar/avatar.js.map +1 -0
  27. package/dist/components/avatar/avatar.styles.d.ts +9 -0
  28. package/dist/components/avatar/avatar.styles.js +258 -0
  29. package/dist/components/avatar/avatar.styles.js.map +1 -0
  30. package/dist/components/badge/badge.d.ts +59 -0
  31. package/dist/components/badge/badge.js +176 -0
  32. package/dist/components/badge/badge.js.map +1 -0
  33. package/dist/components/badge/badge.styles.d.ts +1 -0
  34. package/dist/components/badge/badge.styles.js +106 -0
  35. package/dist/components/badge/badge.styles.js.map +1 -0
  36. package/dist/components/bottom-sheet/bottom-sheet.d.ts +207 -0
  37. package/dist/components/bottom-sheet/bottom-sheet.js +724 -0
  38. package/dist/components/bottom-sheet/bottom-sheet.js.map +1 -0
  39. package/dist/components/bottom-sheet/bottom-sheet.styles.d.ts +1 -0
  40. package/dist/components/bottom-sheet/bottom-sheet.styles.js +393 -0
  41. package/dist/components/bottom-sheet/bottom-sheet.styles.js.map +1 -0
  42. package/dist/components/breadcrumbs/breadcrumbs.d.ts +176 -0
  43. package/dist/components/breadcrumbs/breadcrumbs.js +638 -0
  44. package/dist/components/breadcrumbs/breadcrumbs.js.map +1 -0
  45. package/dist/components/breadcrumbs/breadcrumbs.styles.d.ts +1 -0
  46. package/dist/components/breadcrumbs/breadcrumbs.styles.js +225 -0
  47. package/dist/components/breadcrumbs/breadcrumbs.styles.js.map +1 -0
  48. package/dist/components/button/button.d.ts +280 -0
  49. package/dist/components/button/button.js +530 -0
  50. package/dist/components/button/button.js.map +1 -0
  51. package/dist/components/button/button.styles.d.ts +20 -0
  52. package/dist/components/button/button.styles.js +328 -0
  53. package/dist/components/button/button.styles.js.map +1 -0
  54. package/dist/components/button-group/button-group.d.ts +124 -0
  55. package/dist/components/button-group/button-group.js +287 -0
  56. package/dist/components/button-group/button-group.js.map +1 -0
  57. package/dist/components/button-group/button-group.styles.d.ts +1 -0
  58. package/dist/components/button-group/button-group.styles.js +220 -0
  59. package/dist/components/button-group/button-group.styles.js.map +1 -0
  60. package/dist/components/button-with-menu/button-with-menu.d.ts +224 -0
  61. package/dist/components/button-with-menu/button-with-menu.js +635 -0
  62. package/dist/components/button-with-menu/button-with-menu.js.map +1 -0
  63. package/dist/components/button-with-menu/button-with-menu.styles.d.ts +15 -0
  64. package/dist/components/button-with-menu/button-with-menu.styles.js +418 -0
  65. package/dist/components/button-with-menu/button-with-menu.styles.js.map +1 -0
  66. package/dist/components/calendar/calendar.d.ts +380 -0
  67. package/dist/components/calendar/calendar.js +1619 -0
  68. package/dist/components/calendar/calendar.js.map +1 -0
  69. package/dist/components/calendar/calendar.styles.d.ts +11 -0
  70. package/dist/components/calendar/calendar.styles.js +412 -0
  71. package/dist/components/calendar/calendar.styles.js.map +1 -0
  72. package/dist/components/callout/callout.d.ts +157 -0
  73. package/dist/components/callout/callout.js +436 -0
  74. package/dist/components/callout/callout.js.map +1 -0
  75. package/dist/components/callout/callout.styles.d.ts +13 -0
  76. package/dist/components/callout/callout.styles.js +383 -0
  77. package/dist/components/callout/callout.styles.js.map +1 -0
  78. package/dist/components/card/card.d.ts +108 -0
  79. package/dist/components/card/card.js +235 -0
  80. package/dist/components/card/card.js.map +1 -0
  81. package/dist/components/card/card.styles.d.ts +9 -0
  82. package/dist/components/card/card.styles.js +170 -0
  83. package/dist/components/card/card.styles.js.map +1 -0
  84. package/dist/components/carousel/carousel-geometry.d.ts +178 -0
  85. package/dist/components/carousel/carousel-geometry.js +356 -0
  86. package/dist/components/carousel/carousel-geometry.js.map +1 -0
  87. package/dist/components/carousel/carousel.d.ts +401 -0
  88. package/dist/components/carousel/carousel.js +1352 -0
  89. package/dist/components/carousel/carousel.js.map +1 -0
  90. package/dist/components/carousel/carousel.styles.d.ts +4 -0
  91. package/dist/components/carousel/carousel.styles.js +475 -0
  92. package/dist/components/carousel/carousel.styles.js.map +1 -0
  93. package/dist/components/chat-composer/chat-composer.d.ts +482 -0
  94. package/dist/components/chat-composer/chat-composer.js +1374 -0
  95. package/dist/components/chat-composer/chat-composer.js.map +1 -0
  96. package/dist/components/chat-composer/chat-composer.styles.d.ts +9 -0
  97. package/dist/components/chat-composer/chat-composer.styles.js +308 -0
  98. package/dist/components/chat-composer/chat-composer.styles.js.map +1 -0
  99. package/dist/components/checkbox/checkbox.d.ts +135 -0
  100. package/dist/components/checkbox/checkbox.js +296 -0
  101. package/dist/components/checkbox/checkbox.js.map +1 -0
  102. package/dist/components/checkbox/checkbox.styles.d.ts +13 -0
  103. package/dist/components/checkbox/checkbox.styles.js +226 -0
  104. package/dist/components/checkbox/checkbox.styles.js.map +1 -0
  105. package/dist/components/checkbox-group/checkbox-group.d.ts +199 -0
  106. package/dist/components/checkbox-group/checkbox-group.js +500 -0
  107. package/dist/components/checkbox-group/checkbox-group.js.map +1 -0
  108. package/dist/components/chip/chip.d.ts +176 -0
  109. package/dist/components/chip/chip.js +376 -0
  110. package/dist/components/chip/chip.js.map +1 -0
  111. package/dist/components/chip/chip.styles.d.ts +10 -0
  112. package/dist/components/chip/chip.styles.js +465 -0
  113. package/dist/components/chip/chip.styles.js.map +1 -0
  114. package/dist/components/chip-field/chip-field.d.ts +315 -0
  115. package/dist/components/chip-field/chip-field.js +887 -0
  116. package/dist/components/chip-field/chip-field.js.map +1 -0
  117. package/dist/components/code-block/code-block.before.d.ts +2 -0
  118. package/dist/components/code-block/code-block.before.js +193 -0
  119. package/dist/components/code-block/code-block.before.js.map +1 -0
  120. package/dist/components/code-block/code-block.d.ts +268 -0
  121. package/dist/components/code-block/code-block.js +1009 -0
  122. package/dist/components/code-block/code-block.js.map +1 -0
  123. package/dist/components/code-block/code-block.light.d.ts +50 -0
  124. package/dist/components/code-block/code-block.light.js +287 -0
  125. package/dist/components/code-block/code-block.light.js.map +1 -0
  126. package/dist/components/code-block/code-block.lines.d.ts +49 -0
  127. package/dist/components/code-block/code-block.lines.js +75 -0
  128. package/dist/components/code-block/code-block.lines.js.map +1 -0
  129. package/dist/components/code-block/code-block.styles.d.ts +8 -0
  130. package/dist/components/code-block/code-block.styles.js +212 -0
  131. package/dist/components/code-block/code-block.styles.js.map +1 -0
  132. package/dist/components/color-field/color-field.d.ts +120 -0
  133. package/dist/components/color-field/color-field.js +182 -0
  134. package/dist/components/color-field/color-field.js.map +1 -0
  135. package/dist/components/color-input/color-input.d.ts +302 -0
  136. package/dist/components/color-input/color-input.js +748 -0
  137. package/dist/components/color-input/color-input.js.map +1 -0
  138. package/dist/components/color-input/color-input.styles.d.ts +22 -0
  139. package/dist/components/color-input/color-input.styles.js +373 -0
  140. package/dist/components/color-input/color-input.styles.js.map +1 -0
  141. package/dist/components/color-input/color-text.d.ts +48 -0
  142. package/dist/components/color-input/color-text.js +77 -0
  143. package/dist/components/color-input/color-text.js.map +1 -0
  144. package/dist/components/combobox/combobox.d.ts +387 -0
  145. package/dist/components/combobox/combobox.js +1108 -0
  146. package/dist/components/combobox/combobox.js.map +1 -0
  147. package/dist/components/combobox/combobox.styles.d.ts +26 -0
  148. package/dist/components/combobox/combobox.styles.js +497 -0
  149. package/dist/components/combobox/combobox.styles.js.map +1 -0
  150. package/dist/components/combobox-field/combobox-field.d.ts +159 -0
  151. package/dist/components/combobox-field/combobox-field.js +280 -0
  152. package/dist/components/combobox-field/combobox-field.js.map +1 -0
  153. package/dist/components/copy-button/copy-button.d.ts +112 -0
  154. package/dist/components/copy-button/copy-button.js +237 -0
  155. package/dist/components/copy-button/copy-button.js.map +1 -0
  156. package/dist/components/copy-button/copy-button.styles.d.ts +1 -0
  157. package/dist/components/copy-button/copy-button.styles.js +62 -0
  158. package/dist/components/copy-button/copy-button.styles.js.map +1 -0
  159. package/dist/components/date-time-picker/date-time-picker.d.ts +603 -0
  160. package/dist/components/date-time-picker/date-time-picker.js +2537 -0
  161. package/dist/components/date-time-picker/date-time-picker.js.map +1 -0
  162. package/dist/components/date-time-picker/date-time-picker.styles.d.ts +1 -0
  163. package/dist/components/date-time-picker/date-time-picker.styles.js +842 -0
  164. package/dist/components/date-time-picker/date-time-picker.styles.js.map +1 -0
  165. package/dist/components/description-list/description-list.d.ts +133 -0
  166. package/dist/components/description-list/description-list.js +395 -0
  167. package/dist/components/description-list/description-list.js.map +1 -0
  168. package/dist/components/dialog/dialog.d.ts +140 -0
  169. package/dist/components/dialog/dialog.js +440 -0
  170. package/dist/components/dialog/dialog.js.map +1 -0
  171. package/dist/components/dialog/dialog.styles.d.ts +1 -0
  172. package/dist/components/dialog/dialog.styles.js +306 -0
  173. package/dist/components/dialog/dialog.styles.js.map +1 -0
  174. package/dist/components/divider/divider.d.ts +112 -0
  175. package/dist/components/divider/divider.js +331 -0
  176. package/dist/components/divider/divider.js.map +1 -0
  177. package/dist/components/divider/divider.styles.d.ts +6 -0
  178. package/dist/components/divider/divider.styles.js +183 -0
  179. package/dist/components/divider/divider.styles.js.map +1 -0
  180. package/dist/components/embedded-text-input/embedded-text-input.d.ts +246 -0
  181. package/dist/components/embedded-text-input/embedded-text-input.js +673 -0
  182. package/dist/components/embedded-text-input/embedded-text-input.js.map +1 -0
  183. package/dist/components/embedded-text-input/embedded-text-input.styles.d.ts +1 -0
  184. package/dist/components/embedded-text-input/embedded-text-input.styles.js +204 -0
  185. package/dist/components/embedded-text-input/embedded-text-input.styles.js.map +1 -0
  186. package/dist/components/empty-state/empty-state.d.ts +132 -0
  187. package/dist/components/empty-state/empty-state.js +333 -0
  188. package/dist/components/empty-state/empty-state.js.map +1 -0
  189. package/dist/components/empty-state/empty-state.styles.d.ts +11 -0
  190. package/dist/components/empty-state/empty-state.styles.js +218 -0
  191. package/dist/components/empty-state/empty-state.styles.js.map +1 -0
  192. package/dist/components/fab-menu/fab-menu.d.ts +240 -0
  193. package/dist/components/fab-menu/fab-menu.js +605 -0
  194. package/dist/components/fab-menu/fab-menu.js.map +1 -0
  195. package/dist/components/fab-menu/fab-menu.styles.d.ts +21 -0
  196. package/dist/components/fab-menu/fab-menu.styles.js +427 -0
  197. package/dist/components/fab-menu/fab-menu.styles.js.map +1 -0
  198. package/dist/components/field/field.d.ts +165 -0
  199. package/dist/components/field/field.js +399 -0
  200. package/dist/components/field/field.js.map +1 -0
  201. package/dist/components/field/field.styles.d.ts +2 -0
  202. package/dist/components/field/field.styles.js +177 -0
  203. package/dist/components/field/field.styles.js.map +1 -0
  204. package/dist/components/field-group/field-group.d.ts +122 -0
  205. package/dist/components/field-group/field-group.js +246 -0
  206. package/dist/components/field-group/field-group.js.map +1 -0
  207. package/dist/components/field-group/field-group.styles.d.ts +7 -0
  208. package/dist/components/field-group/field-group.styles.js +28 -0
  209. package/dist/components/field-group/field-group.styles.js.map +1 -0
  210. package/dist/components/figure/figure.d.ts +152 -0
  211. package/dist/components/figure/figure.js +435 -0
  212. package/dist/components/figure/figure.js.map +1 -0
  213. package/dist/components/file-item/file-item.d.ts +232 -0
  214. package/dist/components/file-item/file-item.js +665 -0
  215. package/dist/components/file-item/file-item.js.map +1 -0
  216. package/dist/components/file-item/file-item.styles.d.ts +2 -0
  217. package/dist/components/file-item/file-item.styles.js +582 -0
  218. package/dist/components/file-item/file-item.styles.js.map +1 -0
  219. package/dist/components/file-picker/file-picker.d.ts +221 -0
  220. package/dist/components/file-picker/file-picker.js +588 -0
  221. package/dist/components/file-picker/file-picker.js.map +1 -0
  222. package/dist/components/file-picker/file-picker.styles.d.ts +2 -0
  223. package/dist/components/file-picker/file-picker.styles.js +303 -0
  224. package/dist/components/file-picker/file-picker.styles.js.map +1 -0
  225. package/dist/components/file-upload/file-upload.d.ts +353 -0
  226. package/dist/components/file-upload/file-upload.js +939 -0
  227. package/dist/components/file-upload/file-upload.js.map +1 -0
  228. package/dist/components/file-upload/file-upload.styles.d.ts +1 -0
  229. package/dist/components/file-upload/file-upload.styles.js +91 -0
  230. package/dist/components/file-upload/file-upload.styles.js.map +1 -0
  231. package/dist/components/image-preview/image-preview.d.ts +336 -0
  232. package/dist/components/image-preview/image-preview.js +1510 -0
  233. package/dist/components/image-preview/image-preview.js.map +1 -0
  234. package/dist/components/image-preview/image-preview.styles.d.ts +1 -0
  235. package/dist/components/image-preview/image-preview.styles.js +418 -0
  236. package/dist/components/image-preview/image-preview.styles.js.map +1 -0
  237. package/dist/components/keyboard-shortcut/keyboard-shortcut.d.ts +94 -0
  238. package/dist/components/keyboard-shortcut/keyboard-shortcut.js +285 -0
  239. package/dist/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -0
  240. package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.d.ts +11 -0
  241. package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.js +155 -0
  242. package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.js.map +1 -0
  243. package/dist/components/link-card/link-card.d.ts +156 -0
  244. package/dist/components/link-card/link-card.js +713 -0
  245. package/dist/components/link-card/link-card.js.map +1 -0
  246. package/dist/components/list/list.d.ts +430 -0
  247. package/dist/components/list/list.js +1230 -0
  248. package/dist/components/list/list.js.map +1 -0
  249. package/dist/components/list/list.styles.d.ts +3 -0
  250. package/dist/components/list/list.styles.js +334 -0
  251. package/dist/components/list/list.styles.js.map +1 -0
  252. package/dist/components/loading-indicator/loading-indicator.d.ts +83 -0
  253. package/dist/components/loading-indicator/loading-indicator.js +195 -0
  254. package/dist/components/loading-indicator/loading-indicator.js.map +1 -0
  255. package/dist/components/loading-indicator/loading-indicator.styles.d.ts +6 -0
  256. package/dist/components/loading-indicator/loading-indicator.styles.js +124 -0
  257. package/dist/components/loading-indicator/loading-indicator.styles.js.map +1 -0
  258. package/dist/components/main-action-button/main-action-button.d.ts +95 -0
  259. package/dist/components/main-action-button/main-action-button.js +202 -0
  260. package/dist/components/main-action-button/main-action-button.js.map +1 -0
  261. package/dist/components/main-action-button/main-action-button.styles.d.ts +10 -0
  262. package/dist/components/main-action-button/main-action-button.styles.js +285 -0
  263. package/dist/components/main-action-button/main-action-button.styles.js.map +1 -0
  264. package/dist/components/menu/menu.d.ts +813 -0
  265. package/dist/components/menu/menu.js +2061 -0
  266. package/dist/components/menu/menu.js.map +1 -0
  267. package/dist/components/menu/menu.styles.d.ts +18 -0
  268. package/dist/components/menu/menu.styles.js +587 -0
  269. package/dist/components/menu/menu.styles.js.map +1 -0
  270. package/dist/components/menubar/menubar.d.ts +477 -0
  271. package/dist/components/menubar/menubar.js +1677 -0
  272. package/dist/components/menubar/menubar.js.map +1 -0
  273. package/dist/components/menubar/menubar.styles.d.ts +43 -0
  274. package/dist/components/menubar/menubar.styles.js +379 -0
  275. package/dist/components/menubar/menubar.styles.js.map +1 -0
  276. package/dist/components/navigation-bar/navigation-bar.d.ts +239 -0
  277. package/dist/components/navigation-bar/navigation-bar.js +544 -0
  278. package/dist/components/navigation-bar/navigation-bar.js.map +1 -0
  279. package/dist/components/navigation-bar/navigation-bar.styles.d.ts +21 -0
  280. package/dist/components/navigation-bar/navigation-bar.styles.js +320 -0
  281. package/dist/components/navigation-bar/navigation-bar.styles.js.map +1 -0
  282. package/dist/components/navigation-drawer/navigation-drawer.d.ts +627 -0
  283. package/dist/components/navigation-drawer/navigation-drawer.js +1917 -0
  284. package/dist/components/navigation-drawer/navigation-drawer.js.map +1 -0
  285. package/dist/components/navigation-drawer/navigation-drawer.styles.d.ts +40 -0
  286. package/dist/components/navigation-drawer/navigation-drawer.styles.js +934 -0
  287. package/dist/components/navigation-drawer/navigation-drawer.styles.js.map +1 -0
  288. package/dist/components/number-field/number-field.d.ts +147 -0
  289. package/dist/components/number-field/number-field.js +252 -0
  290. package/dist/components/number-field/number-field.js.map +1 -0
  291. package/dist/components/number-input/number-input.d.ts +347 -0
  292. package/dist/components/number-input/number-input.js +929 -0
  293. package/dist/components/number-input/number-input.js.map +1 -0
  294. package/dist/components/number-input/number-input.styles.d.ts +22 -0
  295. package/dist/components/number-input/number-input.styles.js +395 -0
  296. package/dist/components/number-input/number-input.styles.js.map +1 -0
  297. package/dist/components/number-input/number-text.d.ts +74 -0
  298. package/dist/components/number-input/number-text.js +230 -0
  299. package/dist/components/number-input/number-text.js.map +1 -0
  300. package/dist/components/one-time-code-field/one-time-code-field.d.ts +94 -0
  301. package/dist/components/one-time-code-field/one-time-code-field.js +135 -0
  302. package/dist/components/one-time-code-field/one-time-code-field.js.map +1 -0
  303. package/dist/components/one-time-code-input/code-text.d.ts +51 -0
  304. package/dist/components/one-time-code-input/code-text.js +145 -0
  305. package/dist/components/one-time-code-input/code-text.js.map +1 -0
  306. package/dist/components/one-time-code-input/one-time-code-input.d.ts +219 -0
  307. package/dist/components/one-time-code-input/one-time-code-input.js +710 -0
  308. package/dist/components/one-time-code-input/one-time-code-input.js.map +1 -0
  309. package/dist/components/one-time-code-input/one-time-code-input.styles.d.ts +8 -0
  310. package/dist/components/one-time-code-input/one-time-code-input.styles.js +323 -0
  311. package/dist/components/one-time-code-input/one-time-code-input.styles.js.map +1 -0
  312. package/dist/components/option/option.d.ts +51 -0
  313. package/dist/components/option/option.js +75 -0
  314. package/dist/components/option/option.js.map +1 -0
  315. package/dist/components/page-header/page-header.d.ts +97 -0
  316. package/dist/components/page-header/page-header.js +258 -0
  317. package/dist/components/page-header/page-header.js.map +1 -0
  318. package/dist/components/popover/popover.d.ts +217 -0
  319. package/dist/components/popover/popover.js +616 -0
  320. package/dist/components/popover/popover.js.map +1 -0
  321. package/dist/components/popover/popover.styles.d.ts +8 -0
  322. package/dist/components/popover/popover.styles.js +299 -0
  323. package/dist/components/popover/popover.styles.js.map +1 -0
  324. package/dist/components/progress-indicator/progress-indicator.d.ts +76 -0
  325. package/dist/components/progress-indicator/progress-indicator.js +165 -0
  326. package/dist/components/progress-indicator/progress-indicator.js.map +1 -0
  327. package/dist/components/progress-indicator/progress-indicator.styles.d.ts +7 -0
  328. package/dist/components/progress-indicator/progress-indicator.styles.js +271 -0
  329. package/dist/components/progress-indicator/progress-indicator.styles.js.map +1 -0
  330. package/dist/components/radio-button/radio-button.d.ts +149 -0
  331. package/dist/components/radio-button/radio-button.js +370 -0
  332. package/dist/components/radio-button/radio-button.js.map +1 -0
  333. package/dist/components/radio-button/radio-button.styles.d.ts +8 -0
  334. package/dist/components/radio-button/radio-button.styles.js +190 -0
  335. package/dist/components/radio-button/radio-button.styles.js.map +1 -0
  336. package/dist/components/radio-group/radio-group.d.ts +188 -0
  337. package/dist/components/radio-group/radio-group.js +380 -0
  338. package/dist/components/radio-group/radio-group.js.map +1 -0
  339. package/dist/components/search/search.d.ts +569 -0
  340. package/dist/components/search/search.js +1801 -0
  341. package/dist/components/search/search.js.map +1 -0
  342. package/dist/components/search/search.styles.d.ts +15 -0
  343. package/dist/components/search/search.styles.js +967 -0
  344. package/dist/components/search/search.styles.js.map +1 -0
  345. package/dist/components/segmented-button/segmented-button.d.ts +183 -0
  346. package/dist/components/segmented-button/segmented-button.js +483 -0
  347. package/dist/components/segmented-button/segmented-button.js.map +1 -0
  348. package/dist/components/segmented-button/segmented-button.styles.d.ts +19 -0
  349. package/dist/components/segmented-button/segmented-button.styles.js +400 -0
  350. package/dist/components/segmented-button/segmented-button.styles.js.map +1 -0
  351. package/dist/components/select/select.d.ts +259 -0
  352. package/dist/components/select/select.js +702 -0
  353. package/dist/components/select/select.js.map +1 -0
  354. package/dist/components/select/select.styles.d.ts +27 -0
  355. package/dist/components/select/select.styles.js +359 -0
  356. package/dist/components/select/select.styles.js.map +1 -0
  357. package/dist/components/select-field/select-field.d.ts +141 -0
  358. package/dist/components/select-field/select-field.js +234 -0
  359. package/dist/components/select-field/select-field.js.map +1 -0
  360. package/dist/components/side-sheet/side-sheet.d.ts +190 -0
  361. package/dist/components/side-sheet/side-sheet.js +592 -0
  362. package/dist/components/side-sheet/side-sheet.js.map +1 -0
  363. package/dist/components/side-sheet/side-sheet.styles.d.ts +9 -0
  364. package/dist/components/side-sheet/side-sheet.styles.js +352 -0
  365. package/dist/components/side-sheet/side-sheet.styles.js.map +1 -0
  366. package/dist/components/skeleton/skeleton.d.ts +157 -0
  367. package/dist/components/skeleton/skeleton.js +550 -0
  368. package/dist/components/skeleton/skeleton.js.map +1 -0
  369. package/dist/components/slider/slider.d.ts +235 -0
  370. package/dist/components/slider/slider.js +792 -0
  371. package/dist/components/slider/slider.js.map +1 -0
  372. package/dist/components/slider/slider.styles.d.ts +6 -0
  373. package/dist/components/slider/slider.styles.js +492 -0
  374. package/dist/components/slider/slider.styles.js.map +1 -0
  375. package/dist/components/slider-field/slider-field.d.ts +150 -0
  376. package/dist/components/slider-field/slider-field.js +269 -0
  377. package/dist/components/slider-field/slider-field.js.map +1 -0
  378. package/dist/components/snackbar/snackbar.d.ts +237 -0
  379. package/dist/components/snackbar/snackbar.js +607 -0
  380. package/dist/components/snackbar/snackbar.js.map +1 -0
  381. package/dist/components/snackbar/snackbar.styles.d.ts +10 -0
  382. package/dist/components/snackbar/snackbar.styles.js +510 -0
  383. package/dist/components/snackbar/snackbar.styles.js.map +1 -0
  384. package/dist/components/switch/switch.d.ts +161 -0
  385. package/dist/components/switch/switch.js +470 -0
  386. package/dist/components/switch/switch.js.map +1 -0
  387. package/dist/components/switch/switch.styles.d.ts +3 -0
  388. package/dist/components/switch/switch.styles.js +440 -0
  389. package/dist/components/switch/switch.styles.js.map +1 -0
  390. package/dist/components/tab-view/tab-view.d.ts +303 -0
  391. package/dist/components/tab-view/tab-view.js +917 -0
  392. package/dist/components/tab-view/tab-view.js.map +1 -0
  393. package/dist/components/tab-view/tab-view.styles.d.ts +19 -0
  394. package/dist/components/tab-view/tab-view.styles.js +85 -0
  395. package/dist/components/tab-view/tab-view.styles.js.map +1 -0
  396. package/dist/components/table/table.d.ts +386 -0
  397. package/dist/components/table/table.js +1320 -0
  398. package/dist/components/table/table.js.map +1 -0
  399. package/dist/components/table-of-contents/table-of-contents.d.ts +227 -0
  400. package/dist/components/table-of-contents/table-of-contents.js +963 -0
  401. package/dist/components/table-of-contents/table-of-contents.js.map +1 -0
  402. package/dist/components/table-of-contents/table-of-contents.styles.d.ts +1 -0
  403. package/dist/components/table-of-contents/table-of-contents.styles.js +243 -0
  404. package/dist/components/table-of-contents/table-of-contents.styles.js.map +1 -0
  405. package/dist/components/tabs/tabs.d.ts +800 -0
  406. package/dist/components/tabs/tabs.js +2183 -0
  407. package/dist/components/tabs/tabs.js.map +1 -0
  408. package/dist/components/tabs/tabs.styles.d.ts +47 -0
  409. package/dist/components/tabs/tabs.styles.js +595 -0
  410. package/dist/components/tabs/tabs.styles.js.map +1 -0
  411. package/dist/components/tag/tag.d.ts +77 -0
  412. package/dist/components/tag/tag.js +143 -0
  413. package/dist/components/tag/tag.js.map +1 -0
  414. package/dist/components/tag/tag.styles.d.ts +13 -0
  415. package/dist/components/tag/tag.styles.js +215 -0
  416. package/dist/components/tag/tag.styles.js.map +1 -0
  417. package/dist/components/tag-group/tag-group.d.ts +110 -0
  418. package/dist/components/tag-group/tag-group.js +298 -0
  419. package/dist/components/tag-group/tag-group.js.map +1 -0
  420. package/dist/components/tag-group/tag-group.styles.d.ts +8 -0
  421. package/dist/components/tag-group/tag-group.styles.js +66 -0
  422. package/dist/components/tag-group/tag-group.styles.js.map +1 -0
  423. package/dist/components/text-field/text-field.d.ts +159 -0
  424. package/dist/components/text-field/text-field.js +272 -0
  425. package/dist/components/text-field/text-field.js.map +1 -0
  426. package/dist/components/text-input/text-input-segments.d.ts +93 -0
  427. package/dist/components/text-input/text-input-segments.js +233 -0
  428. package/dist/components/text-input/text-input-segments.js.map +1 -0
  429. package/dist/components/text-input/text-input.d.ts +683 -0
  430. package/dist/components/text-input/text-input.js +2120 -0
  431. package/dist/components/text-input/text-input.js.map +1 -0
  432. package/dist/components/text-input/text-input.styles.d.ts +27 -0
  433. package/dist/components/text-input/text-input.styles.js +1071 -0
  434. package/dist/components/text-input/text-input.styles.js.map +1 -0
  435. package/dist/components/toolbar/toolbar.d.ts +123 -0
  436. package/dist/components/toolbar/toolbar.js +336 -0
  437. package/dist/components/toolbar/toolbar.js.map +1 -0
  438. package/dist/components/toolbar/toolbar.styles.d.ts +10 -0
  439. package/dist/components/toolbar/toolbar.styles.js +156 -0
  440. package/dist/components/toolbar/toolbar.styles.js.map +1 -0
  441. package/dist/components/tooltip/tooltip-placement.d.ts +22 -0
  442. package/dist/components/tooltip/tooltip-placement.js +15 -0
  443. package/dist/components/tooltip/tooltip-placement.js.map +1 -0
  444. package/dist/components/tooltip/tooltip.d.ts +267 -0
  445. package/dist/components/tooltip/tooltip.js +902 -0
  446. package/dist/components/tooltip/tooltip.js.map +1 -0
  447. package/dist/components/tooltip/tooltip.styles.d.ts +7 -0
  448. package/dist/components/tooltip/tooltip.styles.js +240 -0
  449. package/dist/components/tooltip/tooltip.styles.js.map +1 -0
  450. package/dist/components/tree-view/tree-view.d.ts +264 -0
  451. package/dist/components/tree-view/tree-view.js +1228 -0
  452. package/dist/components/tree-view/tree-view.js.map +1 -0
  453. package/dist/description-list.css +337 -0
  454. package/dist/empty-state.css +70 -0
  455. package/dist/figure.css +381 -0
  456. package/dist/generated/icon-sets.d.ts +9 -0
  457. package/dist/generated/icon-sets.js +18 -0
  458. package/dist/generated/icon-sets.js.map +1 -0
  459. package/dist/generated/words.d.ts +161 -0
  460. package/dist/generated/words.js +91 -0
  461. package/dist/generated/words.js.map +1 -0
  462. package/dist/highlight/grammars/css.d.ts +3 -0
  463. package/dist/highlight/grammars/css.js +56 -0
  464. package/dist/highlight/grammars/css.js.map +1 -0
  465. package/dist/highlight/grammars/dart.d.ts +3 -0
  466. package/dist/highlight/grammars/dart.js +53 -0
  467. package/dist/highlight/grammars/dart.js.map +1 -0
  468. package/dist/highlight/grammars/javascript.d.ts +4 -0
  469. package/dist/highlight/grammars/javascript.js +119 -0
  470. package/dist/highlight/grammars/javascript.js.map +1 -0
  471. package/dist/highlight/grammars/json.d.ts +3 -0
  472. package/dist/highlight/grammars/json.js +19 -0
  473. package/dist/highlight/grammars/json.js.map +1 -0
  474. package/dist/highlight/grammars/kotlin.d.ts +3 -0
  475. package/dist/highlight/grammars/kotlin.js +46 -0
  476. package/dist/highlight/grammars/kotlin.js.map +1 -0
  477. package/dist/highlight/grammars/markup.d.ts +3 -0
  478. package/dist/highlight/grammars/markup.js +45 -0
  479. package/dist/highlight/grammars/markup.js.map +1 -0
  480. package/dist/highlight/grammars/shared.d.ts +25 -0
  481. package/dist/highlight/grammars/shared.js +37 -0
  482. package/dist/highlight/grammars/shared.js.map +1 -0
  483. package/dist/highlight/grammars/shell.d.ts +3 -0
  484. package/dist/highlight/grammars/shell.js +48 -0
  485. package/dist/highlight/grammars/shell.js.map +1 -0
  486. package/dist/highlight/grammars/swift.d.ts +3 -0
  487. package/dist/highlight/grammars/swift.js +46 -0
  488. package/dist/highlight/grammars/swift.js.map +1 -0
  489. package/dist/highlight/grammars/typescript.d.ts +2 -0
  490. package/dist/highlight/grammars/typescript.js +5 -0
  491. package/dist/highlight/grammars/typescript.js.map +1 -0
  492. package/dist/highlight/index.d.ts +104 -0
  493. package/dist/highlight/index.js +331 -0
  494. package/dist/highlight/index.js.map +1 -0
  495. package/dist/icons.css +107 -0
  496. package/dist/icons.d.ts +2 -0
  497. package/dist/icons.js +10 -0
  498. package/dist/icons.js.map +1 -0
  499. package/dist/index.d.ts +85 -0
  500. package/dist/index.js +100 -0
  501. package/dist/index.js.map +1 -0
  502. package/dist/link-card.css +678 -0
  503. package/dist/link.css +728 -0
  504. package/dist/link.d.ts +21 -0
  505. package/dist/link.js +594 -0
  506. package/dist/link.js.map +1 -0
  507. package/dist/links/index.d.ts +136 -0
  508. package/dist/links/index.js +404 -0
  509. package/dist/links/index.js.map +1 -0
  510. package/dist/links/node/address.js +154 -0
  511. package/dist/links/node/cli.js +102 -0
  512. package/dist/links/node/fetcher.js +267 -0
  513. package/dist/links/node/head.js +278 -0
  514. package/dist/links/node/index.d.ts +164 -0
  515. package/dist/links/node/index.js +26 -0
  516. package/dist/links/node/links.js +275 -0
  517. package/dist/links/node/lock.js +86 -0
  518. package/dist/links/node/mark.js +71 -0
  519. package/dist/links/node/options.js +120 -0
  520. package/dist/links/node/pictures.js +265 -0
  521. package/dist/links/node/refresh.js +28 -0
  522. package/dist/menu.css +97 -0
  523. package/dist/menubar.css +69 -0
  524. package/dist/page-header.css +324 -0
  525. package/dist/pagination.css +410 -0
  526. package/dist/pagination.d.ts +6 -0
  527. package/dist/pagination.js +256 -0
  528. package/dist/pagination.js.map +1 -0
  529. package/dist/primitives/actions.d.ts +75 -0
  530. package/dist/primitives/actions.js +142 -0
  531. package/dist/primitives/actions.js.map +1 -0
  532. package/dist/primitives/after-click.d.ts +8 -0
  533. package/dist/primitives/after-click.js +21 -0
  534. package/dist/primitives/after-click.js.map +1 -0
  535. package/dist/primitives/anchored.d.ts +134 -0
  536. package/dist/primitives/anchored.js +425 -0
  537. package/dist/primitives/anchored.js.map +1 -0
  538. package/dist/primitives/arc.d.ts +13 -0
  539. package/dist/primitives/arc.js +49 -0
  540. package/dist/primitives/arc.js.map +1 -0
  541. package/dist/primitives/arrow.d.ts +47 -0
  542. package/dist/primitives/arrow.js +159 -0
  543. package/dist/primitives/arrow.js.map +1 -0
  544. package/dist/primitives/auto-height.d.ts +56 -0
  545. package/dist/primitives/auto-height.js +150 -0
  546. package/dist/primitives/auto-height.js.map +1 -0
  547. package/dist/primitives/autofocus.d.ts +11 -0
  548. package/dist/primitives/autofocus.js +26 -0
  549. package/dist/primitives/autofocus.js.map +1 -0
  550. package/dist/primitives/availability.d.ts +32 -0
  551. package/dist/primitives/availability.js +122 -0
  552. package/dist/primitives/availability.js.map +1 -0
  553. package/dist/primitives/axes.d.ts +45 -0
  554. package/dist/primitives/axes.js +72 -0
  555. package/dist/primitives/axes.js.map +1 -0
  556. package/dist/primitives/behavior.d.ts +14 -0
  557. package/dist/primitives/behavior.js +19 -0
  558. package/dist/primitives/behavior.js.map +1 -0
  559. package/dist/primitives/calendar-date.d.ts +79 -0
  560. package/dist/primitives/calendar-date.js +135 -0
  561. package/dist/primitives/calendar-date.js.map +1 -0
  562. package/dist/primitives/composed.d.ts +144 -0
  563. package/dist/primitives/composed.js +303 -0
  564. package/dist/primitives/composed.js.map +1 -0
  565. package/dist/primitives/default-button.d.ts +49 -0
  566. package/dist/primitives/default-button.js +270 -0
  567. package/dist/primitives/default-button.js.map +1 -0
  568. package/dist/primitives/description.d.ts +18 -0
  569. package/dist/primitives/description.js +18 -0
  570. package/dist/primitives/description.js.map +1 -0
  571. package/dist/primitives/destination.d.ts +259 -0
  572. package/dist/primitives/destination.js +651 -0
  573. package/dist/primitives/destination.js.map +1 -0
  574. package/dist/primitives/direction.d.ts +23 -0
  575. package/dist/primitives/direction.js +90 -0
  576. package/dist/primitives/direction.js.map +1 -0
  577. package/dist/primitives/disabled-while-focused.d.ts +46 -0
  578. package/dist/primitives/disabled-while-focused.js +126 -0
  579. package/dist/primitives/disabled-while-focused.js.map +1 -0
  580. package/dist/primitives/disclosure.d.ts +9 -0
  581. package/dist/primitives/disclosure.js +15 -0
  582. package/dist/primitives/disclosure.js.map +1 -0
  583. package/dist/primitives/dismiss.d.ts +88 -0
  584. package/dist/primitives/dismiss.js +232 -0
  585. package/dist/primitives/dismiss.js.map +1 -0
  586. package/dist/primitives/field-frame.d.ts +166 -0
  587. package/dist/primitives/field-frame.js +358 -0
  588. package/dist/primitives/field-frame.js.map +1 -0
  589. package/dist/primitives/field-group-frame.d.ts +59 -0
  590. package/dist/primitives/field-group-frame.js +174 -0
  591. package/dist/primitives/field-group-frame.js.map +1 -0
  592. package/dist/primitives/field-trigger.d.ts +117 -0
  593. package/dist/primitives/field-trigger.js +387 -0
  594. package/dist/primitives/field-trigger.js.map +1 -0
  595. package/dist/primitives/field.d.ts +186 -0
  596. package/dist/primitives/field.js +349 -0
  597. package/dist/primitives/field.js.map +1 -0
  598. package/dist/primitives/file-format.d.ts +23 -0
  599. package/dist/primitives/file-format.js +185 -0
  600. package/dist/primitives/file-format.js.map +1 -0
  601. package/dist/primitives/file-item-holder.d.ts +45 -0
  602. package/dist/primitives/file-item-holder.js +39 -0
  603. package/dist/primitives/file-item-holder.js.map +1 -0
  604. package/dist/primitives/focus-order.d.ts +11 -0
  605. package/dist/primitives/focus-order.js +11 -0
  606. package/dist/primitives/focus-order.js.map +1 -0
  607. package/dist/primitives/focus-ring.d.ts +76 -0
  608. package/dist/primitives/focus-ring.js +230 -0
  609. package/dist/primitives/focus-ring.js.map +1 -0
  610. package/dist/primitives/follow.d.ts +65 -0
  611. package/dist/primitives/follow.js +283 -0
  612. package/dist/primitives/follow.js.map +1 -0
  613. package/dist/primitives/form-disabled.d.ts +20 -0
  614. package/dist/primitives/form-disabled.js +46 -0
  615. package/dist/primitives/form-disabled.js.map +1 -0
  616. package/dist/primitives/form-says.d.ts +33 -0
  617. package/dist/primitives/form-says.js +45 -0
  618. package/dist/primitives/form-says.js.map +1 -0
  619. package/dist/primitives/forward.d.ts +13 -0
  620. package/dist/primitives/forward.js +28 -0
  621. package/dist/primitives/forward.js.map +1 -0
  622. package/dist/primitives/glyph-mirror.d.ts +77 -0
  623. package/dist/primitives/glyph-mirror.js +211 -0
  624. package/dist/primitives/glyph-mirror.js.map +1 -0
  625. package/dist/primitives/glyph-pending.d.ts +17 -0
  626. package/dist/primitives/glyph-pending.js +91 -0
  627. package/dist/primitives/glyph-pending.js.map +1 -0
  628. package/dist/primitives/glyph.d.ts +53 -0
  629. package/dist/primitives/glyph.js +161 -0
  630. package/dist/primitives/glyph.js.map +1 -0
  631. package/dist/primitives/group-item.d.ts +128 -0
  632. package/dist/primitives/group-item.js +334 -0
  633. package/dist/primitives/group-item.js.map +1 -0
  634. package/dist/primitives/hidden.d.ts +2 -0
  635. package/dist/primitives/hidden.js +23 -0
  636. package/dist/primitives/hidden.js.map +1 -0
  637. package/dist/primitives/host-aria.d.ts +8 -0
  638. package/dist/primitives/host-aria.js +18 -0
  639. package/dist/primitives/host-aria.js.map +1 -0
  640. package/dist/primitives/index.d.ts +59 -0
  641. package/dist/primitives/index.js +189 -0
  642. package/dist/primitives/index.js.map +1 -0
  643. package/dist/primitives/indicator-drag.d.ts +90 -0
  644. package/dist/primitives/indicator-drag.js +207 -0
  645. package/dist/primitives/indicator-drag.js.map +1 -0
  646. package/dist/primitives/interactive.d.ts +13 -0
  647. package/dist/primitives/interactive.js +67 -0
  648. package/dist/primitives/interactive.js.map +1 -0
  649. package/dist/primitives/item-row.d.ts +34 -0
  650. package/dist/primitives/item-row.js +76 -0
  651. package/dist/primitives/item-row.js.map +1 -0
  652. package/dist/primitives/item-update.d.ts +2 -0
  653. package/dist/primitives/item-update.js +12 -0
  654. package/dist/primitives/item-update.js.map +1 -0
  655. package/dist/primitives/kept-length.d.ts +34 -0
  656. package/dist/primitives/kept-length.js +154 -0
  657. package/dist/primitives/kept-length.js.map +1 -0
  658. package/dist/primitives/keyboard-convention.d.ts +30 -0
  659. package/dist/primitives/keyboard-convention.js +88 -0
  660. package/dist/primitives/keyboard-convention.js.map +1 -0
  661. package/dist/primitives/label-lines.d.ts +12 -0
  662. package/dist/primitives/label-lines.js +34 -0
  663. package/dist/primitives/label-lines.js.map +1 -0
  664. package/dist/primitives/layout-scale.d.ts +18 -0
  665. package/dist/primitives/layout-scale.js +35 -0
  666. package/dist/primitives/layout-scale.js.map +1 -0
  667. package/dist/primitives/link.d.ts +147 -0
  668. package/dist/primitives/link.js +204 -0
  669. package/dist/primitives/link.js.map +1 -0
  670. package/dist/primitives/locale-date.d.ts +132 -0
  671. package/dist/primitives/locale-date.js +508 -0
  672. package/dist/primitives/locale-date.js.map +1 -0
  673. package/dist/primitives/missing-value.d.ts +16 -0
  674. package/dist/primitives/missing-value.js +31 -0
  675. package/dist/primitives/missing-value.js.map +1 -0
  676. package/dist/primitives/modal.d.ts +38 -0
  677. package/dist/primitives/modal.js +175 -0
  678. package/dist/primitives/modal.js.map +1 -0
  679. package/dist/primitives/native-text.d.ts +51 -0
  680. package/dist/primitives/native-text.js +77 -0
  681. package/dist/primitives/native-text.js.map +1 -0
  682. package/dist/primitives/natural-height.d.ts +21 -0
  683. package/dist/primitives/natural-height.js +36 -0
  684. package/dist/primitives/natural-height.js.map +1 -0
  685. package/dist/primitives/option-list.d.ts +314 -0
  686. package/dist/primitives/option-list.js +1098 -0
  687. package/dist/primitives/option-list.js.map +1 -0
  688. package/dist/primitives/overlay-focus.d.ts +48 -0
  689. package/dist/primitives/overlay-focus.js +152 -0
  690. package/dist/primitives/overlay-focus.js.map +1 -0
  691. package/dist/primitives/placement.d.ts +131 -0
  692. package/dist/primitives/placement.js +144 -0
  693. package/dist/primitives/placement.js.map +1 -0
  694. package/dist/primitives/places.d.ts +44 -0
  695. package/dist/primitives/places.js +98 -0
  696. package/dist/primitives/places.js.map +1 -0
  697. package/dist/primitives/press.d.ts +90 -0
  698. package/dist/primitives/press.js +153 -0
  699. package/dist/primitives/press.js.map +1 -0
  700. package/dist/primitives/report.d.ts +17 -0
  701. package/dist/primitives/report.js +34 -0
  702. package/dist/primitives/report.js.map +1 -0
  703. package/dist/primitives/ripple.d.ts +40 -0
  704. package/dist/primitives/ripple.js +70 -0
  705. package/dist/primitives/ripple.js.map +1 -0
  706. package/dist/primitives/roving.d.ts +41 -0
  707. package/dist/primitives/roving.js +71 -0
  708. package/dist/primitives/roving.js.map +1 -0
  709. package/dist/primitives/selection.d.ts +134 -0
  710. package/dist/primitives/selection.js +287 -0
  711. package/dist/primitives/selection.js.map +1 -0
  712. package/dist/primitives/separation.d.ts +28 -0
  713. package/dist/primitives/separation.js +96 -0
  714. package/dist/primitives/separation.js.map +1 -0
  715. package/dist/primitives/shared-choice.d.ts +33 -0
  716. package/dist/primitives/shared-choice.js +110 -0
  717. package/dist/primitives/shared-choice.js.map +1 -0
  718. package/dist/primitives/sheet.d.ts +63 -0
  719. package/dist/primitives/sheet.js +139 -0
  720. package/dist/primitives/sheet.js.map +1 -0
  721. package/dist/primitives/sheets.d.ts +8 -0
  722. package/dist/primitives/sheets.js +96 -0
  723. package/dist/primitives/sheets.js.map +1 -0
  724. package/dist/primitives/states.d.ts +33 -0
  725. package/dist/primitives/states.js +30 -0
  726. package/dist/primitives/states.js.map +1 -0
  727. package/dist/primitives/system-watch.d.ts +9 -0
  728. package/dist/primitives/system-watch.js +29 -0
  729. package/dist/primitives/system-watch.js.map +1 -0
  730. package/dist/primitives/target.d.ts +21 -0
  731. package/dist/primitives/target.js +79 -0
  732. package/dist/primitives/target.js.map +1 -0
  733. package/dist/primitives/values.d.ts +6 -0
  734. package/dist/primitives/values.js +22 -0
  735. package/dist/primitives/values.js.map +1 -0
  736. package/dist/primitives/visibility.d.ts +12 -0
  737. package/dist/primitives/visibility.js +50 -0
  738. package/dist/primitives/visibility.js.map +1 -0
  739. package/dist/primitives/words.d.ts +81 -0
  740. package/dist/primitives/words.js +236 -0
  741. package/dist/primitives/words.js.map +1 -0
  742. package/dist/prose.css +1917 -0
  743. package/dist/registry.d.ts +182 -0
  744. package/dist/registry.js +2 -0
  745. package/dist/registry.js.map +1 -0
  746. package/dist/shape.css +21 -0
  747. package/dist/skeleton.css +428 -0
  748. package/dist/steps.css +231 -0
  749. package/dist/steps.d.ts +6 -0
  750. package/dist/steps.js +156 -0
  751. package/dist/steps.js.map +1 -0
  752. package/dist/styles/icons.d.ts +62 -0
  753. package/dist/styles/icons.js +237 -0
  754. package/dist/styles/icons.js.map +1 -0
  755. package/dist/styles/product-text.d.ts +66 -0
  756. package/dist/styles/product-text.js +114 -0
  757. package/dist/styles/product-text.js.map +1 -0
  758. package/dist/styles/registered-properties.d.ts +6 -0
  759. package/dist/styles/registered-properties.js +68 -0
  760. package/dist/styles/registered-properties.js.map +1 -0
  761. package/dist/styles/shape.d.ts +59 -0
  762. package/dist/styles/shape.js +95 -0
  763. package/dist/styles/shape.js.map +1 -0
  764. package/dist/systems/cupertino.css +8793 -0
  765. package/dist/systems/m3-expressive-like.css +8786 -0
  766. package/dist/systems/m3-like.css +8748 -0
  767. package/dist/table-of-contents.css +482 -0
  768. package/dist/table.css +902 -0
  769. package/dist/tanrei.bundle.js +26644 -0
  770. package/dist/tanrei.bundle.js.map +7 -0
  771. package/dist/text.css +104 -0
  772. package/dist/timeline.css +410 -0
  773. package/dist/timeline.d.ts +6 -0
  774. package/dist/timeline.js +176 -0
  775. package/dist/timeline.js.map +1 -0
  776. package/dist/tokens.css +8801 -0
  777. package/dist/tree-view.css +797 -0
  778. package/dist/words.d.ts +2 -0
  779. package/dist/words.js +6 -0
  780. package/dist/words.js.map +1 -0
  781. package/package.json +132 -3
@@ -0,0 +1,1677 @@
1
+ import { LitElement, html, nothing } from 'lit';
2
+ import { classMap } from 'lit/directives/class-map.js';
3
+ import { AvailabilityController, GlyphDrawnController, GlyphMirrorController, LINK_MARK, LinkController, PressController, RovingKeys, WordsController, afterClick, deepActive, hostAria, linkRel, readTarget, report, syncFocusStyle } from '../../primitives/index.js';
4
+ import { hiddenHost } from '../../primitives/hidden.js';
5
+ import { FORWARDED_ROWS } from '../menu/menu.js';
6
+ import { barStyles, itemStyles, menuStyles } from './menubar.styles.js';
7
+ /** MBR-21: the glyph of the overflow item, by its name in the system's icon set. */
8
+ const OVERFLOW_GLYPH = 'more_horiz';
9
+ /** The menu's item kinds that are rows, as the menu spec defines them: what makes a bar's menu not empty (MBR-20). */
10
+ const ROWS = 'tanrei-menu-item, tanrei-menu-checkbox-item, tanrei-menu-radio-item, tanrei-submenu';
11
+ /** The overflow item among the bar's titles (MBR-22): the one title that is not an entry of the product's. */
12
+ const OVERFLOW = 'overflow';
13
+ /** MBR-36: an activation the bar answers — the primary button and no modifier key. Any other click on a link is the browser's. */
14
+ const plain = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
15
+ /** The attributes of the product's anchor a link item is read from: when one changes the bar item is drawn again and the row laid out again (MBR-30). */
16
+ const ANCHOR_ATTRIBUTES = ['href', 'target', 'aria-current', 'rel', 'download', 'aria-description'];
17
+ const NOWHERE = { folded: false, position: 0, size: 0, stop: false, inline: false };
18
+ /** Each child in a slot of its own; only a changed assignment is written (assigning again re-slots the child, which blurs a focused item). */
19
+ function assignEach(slots, nodes) {
20
+ let i = 0;
21
+ for (const slot of slots) {
22
+ const node = nodes[i++];
23
+ const now = slot.assignedNodes();
24
+ if (node ? now.length !== 1 || now[0] !== node : now.length > 0)
25
+ slot.assign(...(node ? [node] : []));
26
+ }
27
+ }
28
+ /** A node's parent in the flat tree: the slot it is assigned to, else its parent, and a shadow root's host. */
29
+ const flatParent = (node) => {
30
+ const slot = node.assignedSlot;
31
+ if (slot)
32
+ return slot;
33
+ const parent = node.parentNode;
34
+ return parent instanceof ShadowRoot ? parent.host : parent;
35
+ };
36
+ /**
37
+ * One menu of a menubar — the spec's item kind `menu`: its title in the bar's row, and the items that open below it.
38
+ *
39
+ * It holds the menu's own item elements as its children, exactly as `<tanrei-menu>` holds them, and forwards them — each
40
+ * in a slot of its own, none of them moved — into a Tanrei Menu in its shadow root, a manual popover in the top layer
41
+ * placed below its title. The host is the title: `role="menuitem"` with `aria-haspopup="menu"`, `aria-expanded`,
42
+ * `aria-disabled`, its position among the bar's titles, and the bar's roving `tabindex`; it draws its label in its shadow
43
+ * root from the `--tanrei-comp-menubar-*` tokens of its condition (unselected, or expanded while its menu is open) and
44
+ * state. The bar it is in does the rest: the keys, the pointer, which menu is open, and folding it into the overflow
45
+ * item when the row has no room — it is then drawn as a submenu item of the overflow item's menu, with the same label
46
+ * and the same items, and `open` and `toggle` mean the same there.
47
+ *
48
+ * `open` is its own: the bar sets it when the person opens or closes the menu and fires `toggle`; the product may set it
49
+ * to open or close the menu itself, which fires none. The items' own `click`, `change` and `toggle` bubble through it.
50
+ *
51
+ * @tag tanrei-menubar-menu
52
+ * @slot - The menu's items: `<tanrei-menu-item>`, `<tanrei-menu-checkbox-item>`, `<tanrei-menu-radio-item>`, `<tanrei-submenu>` and `<tanrei-menu-group>` children.
53
+ * @csspart container - The title's container: its fill, corners, every state, the ripple and the focus ring.
54
+ * @csspart label - The title's text.
55
+ * @fires {CustomEvent<TanreiMenubarMenuToggleDetail>} toggle - The person opened or closed the menu: `detail.open` (and the element's `open`) is the new value. It bubbles. A change the product makes to `open` fires none. A submenu item's `toggle` bubbles through the element too: tell them apart by the event's target.
56
+ */
57
+ export class TanreiMenubarMenu extends LitElement {
58
+ static { this.styles = menuStyles; }
59
+ // Each child in a slot of its own, forwarded into the menu, which draws its dividers between them (MNU-23).
60
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' }; }
61
+ static { this.properties = {
62
+ label: { type: String },
63
+ open: { type: Boolean, reflect: true },
64
+ disabled: { type: Boolean, reflect: true },
65
+ blocks: { state: true },
66
+ place: { state: true },
67
+ pointerFocused: { state: true },
68
+ }; }
69
+ constructor() {
70
+ super();
71
+ /** The title's text, and the name of the title and of the menu it opens ("File"). Required. One or two words. */
72
+ this.label = '';
73
+ /**
74
+ * Whether this menu is shown. The bar sets it when the person opens or closes the menu and fires `toggle`; the
75
+ * product may set it to open or close the menu itself. At most one menu of a bar is open.
76
+ */
77
+ this.open = false;
78
+ /** Prevents the menu from opening. The title stays in the row and reachable with the arrow keys. */
79
+ this.disabled = false;
80
+ /** The menu's children, each in a slot of its own. */
81
+ this.blocks = [];
82
+ /** What the bar says about this menu. */
83
+ this.place = NOWHERE;
84
+ /** MBR-4, MBR-5: focus a pointer's act gave the title, which is not the focused state and draws no ring. */
85
+ this.pointerFocused = false;
86
+ this.children$ = new MutationObserver(() => this.readChildren());
87
+ /**
88
+ * What the bar tells the menu this element shows (src/components/menu/menu.ts): the bar itself, the inline arrow keys
89
+ * the menu hands back (MBR-13), where focus goes on opening (MBR-9), and whether the surface comes and goes without
90
+ * its motion (MBR-29).
91
+ * @internal
92
+ */
93
+ this.channel = {
94
+ ground: this,
95
+ inlineKey: (towardsEnd) => this.bar?.travel(this, towardsEnd),
96
+ entry: { end: 'first', quiet: false },
97
+ quick: false,
98
+ fold: false,
99
+ };
100
+ /** MBR-6, MBR-7: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
101
+ this.press = new PressController(this, {
102
+ container: () => this.containerElement,
103
+ holdCarrier: () => this.renderRoot?.querySelector('.content') ?? null,
104
+ disabled: () => this.disabled,
105
+ });
106
+ /** MBR-20: a menu with no item still opens its surface, empty; a debug build says so each time it becomes empty. */
107
+ this.empty = false;
108
+ /** MBR-11: while a menu of the bar is open, a pointer that can hover moves the open menu along with it. */
109
+ this.onPointerEnter = (event) => {
110
+ if (event.pointerType === 'mouse' || event.pointerType === 'pen')
111
+ this.bar?.hovered(this);
112
+ };
113
+ /** MBR-14, MBR-15: the menu asks to be closed; the bar answers. */
114
+ this.onMenuClose = (event) => {
115
+ this.bar?.closeRequested(this, event.detail.reason);
116
+ };
117
+ /** MBR-22: folded, the menu's submenu item was opened or closed by the person — the same `open`, the same `toggle`. */
118
+ this.onSubmenuToggle = (event) => {
119
+ // A submenu among the items fires its own, which is the product's to hear.
120
+ if (event.target !== event.currentTarget)
121
+ return;
122
+ event.stopPropagation();
123
+ this.bar?.foldedToggled(this, event.detail.open);
124
+ };
125
+ this.addEventListener('focus', () => syncFocusStyle(this, this));
126
+ this.addEventListener('blur', () => {
127
+ this.pointerFocused = false;
128
+ this.press.onBlur();
129
+ });
130
+ // MBR-6: Enter and Space press the title; what they do is the bar's (MBR-9).
131
+ this.addEventListener('keydown', (event) => {
132
+ if (event.composedPath()[0] === this)
133
+ this.press.onKeyDown(event);
134
+ });
135
+ this.addEventListener('keyup', (event) => {
136
+ if (event.composedPath()[0] === this)
137
+ this.press.onKeyUp(event);
138
+ });
139
+ // MBR-9, MBR-10: a press or a tap on the title — or an activation by assistive technology, a click on the host
140
+ // itself — opens its menu, and closes it when it is open. A click inside its menu is an item's.
141
+ this.addEventListener('click', (event) => {
142
+ if (this.place.folded)
143
+ return;
144
+ const first = event.composedPath()[0];
145
+ const title = this.renderRoot?.querySelector('.title');
146
+ if (first === this || (title && (first === title || title.contains(first))))
147
+ this.bar?.pressed(this);
148
+ });
149
+ }
150
+ /** The bar this menu is one of. */
151
+ get bar() {
152
+ const parent = this.parentElement;
153
+ return parent instanceof TanreiMenubar ? parent : null;
154
+ }
155
+ /** @internal The title's container, which the menu is placed against. */
156
+ get containerElement() {
157
+ return this.renderRoot?.querySelector('.container') ?? null;
158
+ }
159
+ /** @internal Whether the menu holds an item (MBR-20). */
160
+ get hasItems() {
161
+ return !!this.querySelector(ROWS);
162
+ }
163
+ /** @internal MBR-22: folded, the element stands in the overflow item's menu for the submenu item it draws. */
164
+ [FORWARDED_ROWS]() {
165
+ const submenu = this.place.folded ? this.renderRoot?.querySelector('tanrei-submenu') : null;
166
+ return submenu ? [submenu] : [];
167
+ }
168
+ /** @internal The bar's side: where the menu is drawn, and its title's place among the bar's titles. */
169
+ setBarContext(place) {
170
+ const now = this.place;
171
+ if (Object.keys(place).every((key) => place[key] === now[key]))
172
+ return;
173
+ this.place = place;
174
+ }
175
+ /** @internal Focus to the title; `quiet` where a pointer's act moved it, which draws no ring (MBR-5). */
176
+ focusTitle(quiet) {
177
+ if (this.matches(':focus')) {
178
+ if (!quiet)
179
+ this.pointerFocused = false;
180
+ return;
181
+ }
182
+ // The class is drawn in the next render; nothing is painted in between.
183
+ this.pointerFocused = quiet;
184
+ this.renderRoot?.querySelector('.title')?.classList.toggle('pf', quiet);
185
+ this.focus({ preventScroll: true });
186
+ }
187
+ /** @internal MBR-9: focus into the open menu from its title, to its first or its last enabled item. */
188
+ focusMenu(end) {
189
+ this.channel.entry = { end, quiet: false };
190
+ this.renderRoot?.querySelector('tanrei-menu')?.focusFirstItem();
191
+ }
192
+ connectedCallback() {
193
+ super.connectedCallback();
194
+ this.children$.observe(this, { childList: true, subtree: true });
195
+ this.readChildren();
196
+ }
197
+ disconnectedCallback() {
198
+ super.disconnectedCallback();
199
+ this.children$.disconnect();
200
+ }
201
+ readChildren() {
202
+ const now = [...this.children];
203
+ if (now.length !== this.blocks.length || now.some((child, i) => child !== this.blocks[i]))
204
+ this.blocks = now;
205
+ this.checkItems();
206
+ }
207
+ checkItems() {
208
+ const empty = !this.hasItems;
209
+ if (empty === this.empty)
210
+ return;
211
+ this.empty = empty;
212
+ if (empty && this.hasUpdated)
213
+ this.reportEmpty();
214
+ }
215
+ reportEmpty() {
216
+ report(this, 'MBR-20', `the menu "${this.label}" holds no item, so its title opens an empty surface; give it tanrei-menu-item children`, { once: false });
217
+ }
218
+ willUpdate(changed) {
219
+ // MBR-10, MBR-18: whoever changed open or disabled, the bar shows at most one menu and never a disabled one.
220
+ if (changed.has('open') || changed.has('disabled'))
221
+ this.bar?.reconcile();
222
+ }
223
+ firstUpdated() {
224
+ // The children may arrive after the element connects: an empty menu is judged once they had a frame to.
225
+ requestAnimationFrame(() => {
226
+ if (this.isConnected && this.empty)
227
+ this.reportEmpty();
228
+ });
229
+ // Folded, what the submenu item says about itself (its items, its surface) is the overflow item's menu's to hear.
230
+ this.renderRoot.addEventListener('tanrei-menu-item-update', () => this.bar?.foldedUpdated());
231
+ }
232
+ updated(changed) {
233
+ assignEach(this.renderRoot.querySelectorAll('slot'), this.blocks);
234
+ const { folded, position, size, stop } = this.place;
235
+ const shown = this.open && !this.disabled;
236
+ // MBR-19: the host is the title — a menu item that opens a menu, named by the label, with whether its menu is open,
237
+ // its disabled state and its place among the bar's titles; the bar's Tab stop is its tabindex (MBR-12). Folded, the
238
+ // host is nothing: the submenu item it draws in the overflow item's menu says all of it.
239
+ hostAria(this, folded
240
+ ? { role: 'none', 'aria-haspopup': null, 'aria-expanded': null, 'aria-disabled': null, 'aria-label': null, 'aria-posinset': null, 'aria-setsize': null, tabindex: null, 'data-tanrei-folded': '' }
241
+ : {
242
+ role: 'menuitem',
243
+ 'aria-haspopup': 'menu',
244
+ 'aria-expanded': String(shown),
245
+ 'aria-disabled': this.disabled ? 'true' : null,
246
+ 'aria-label': this.label || null,
247
+ 'aria-posinset': position ? String(position) : null,
248
+ 'aria-setsize': size ? String(size) : null,
249
+ tabindex: stop ? '0' : '-1',
250
+ 'data-tanrei-folded': null,
251
+ });
252
+ // MBR-9: the menu is placed against the title's container, below it with their start edges together.
253
+ const menu = this.renderRoot.querySelector('tanrei-menu');
254
+ if (menu)
255
+ menu.positionAnchor = this.containerElement;
256
+ // MBR-20: a title without a label still renders and works; a debug build says it has no name.
257
+ if (changed.has('label') && !this.label.trim())
258
+ report(this, 'MBR-20', 'label is empty, so the title and the menu it opens have no accessible name; give the menu a label ("File")');
259
+ // MBR-44: a destination is a bar item's alone; one written on a menu is ignored, and the menu stays what it is.
260
+ if (this.hasAttribute('href'))
261
+ report(this, 'MBR-44', 'href is written on a menu, which opens and goes nowhere; it is ignored — a destination is a bar item\'s: <tanrei-menubar-item><a href="…">…</a></tanrei-menubar-item>');
262
+ // MBR-21, MBR-30: the bar measures the title again, and lays its row out for what changed.
263
+ if (changed.has('label') || changed.has('disabled') || changed.has('place'))
264
+ this.bar?.entryUpdated();
265
+ }
266
+ render() {
267
+ const slots = this.blocks.map(() => html `<slot></slot>`);
268
+ const shown = this.open && !this.disabled;
269
+ // In place (the bar's inline) only while it is shown: a closed menu's surface is a popover, which draws nothing.
270
+ // MBR-22: folded, a submenu item of the overflow item's menu — the same label, the same items, a disabled menu a
271
+ // disabled submenu item — which that menu operates as it does any submenu (MNU-42 … MNU-52).
272
+ if (this.place.folded) {
273
+ return html `<tanrei-submenu label=${this.label} ?disabled=${this.disabled} .open=${shown} @toggle=${this.onSubmenuToggle}>${slots}</tanrei-submenu>`;
274
+ }
275
+ return html `<span
276
+ class=${classMap({ title: true, p: true, d: this.disabled, expanded: shown, pf: this.pointerFocused })}
277
+ @pointerdown=${this.press.onPointerDown}
278
+ @pointerup=${this.press.release}
279
+ @pointercancel=${this.press.release}
280
+ @pointerleave=${this.press.release}
281
+ @pointerenter=${this.onPointerEnter}
282
+ ><span part="container" class="container" data-tanrei-shape
283
+ ><span class="content"><span part="label" class="label">${this.label}</span></span></span
284
+ ></span
285
+ ><tanrei-menu class="menu" aria-label=${this.label || nothing} .bar=${this.channel} .open=${shown} ?inline=${this.place.inline && shown} @close=${this.onMenuClose}>${slots}</tanrei-menu>`;
286
+ }
287
+ }
288
+ /**
289
+ * A bar item of a menubar — the spec's item kind `item`: an entry of the row that acts by itself instead of opening a
290
+ * menu. It is drawn exactly as a menu's title is and reached by the same keys; nothing at rest tells them apart but
291
+ * their words, so name an action with a verb ("Run") and a link with its place ("Documentation").
292
+ *
293
+ * **An action** is written with a `label`: `<tanrei-menubar-item label="Run"></tanrei-menubar-item>`. The host is the
294
+ * entry — `role="menuitem"` with neither `aria-haspopup` nor `aria-expanded`, `aria-disabled`, its position among the
295
+ * bar's entries and the bar's roving `tabindex` — and `click` is the host's own: a press, Enter, Space (on key up, as a
296
+ * button) and assistive technology produce it, once, after the menu of the bar that was open has closed.
297
+ *
298
+ * **A link item** is the same element around the product's own anchor, which stays in the document:
299
+ * `<tanrei-menubar-item><a href="/docs/">Documentation</a></tanrei-menubar-item>`. The anchor is the entry: the element
300
+ * writes `role="menuitem"`, the roving `tabindex` and the position on it and `role="none"` on the host, and draws the
301
+ * title around it. Everything a link is, is the anchor's — its text is the label, `href`, `target` (`_blank` opens a new
302
+ * context: the element adds `noopener` to `rel` and draws the icon set's `open_in_new` after the label),
303
+ * `aria-current="page"` (drawn at the emphasized weight, with no fill), `rel`, `download` — and the properties `label`,
304
+ * `href`, `target` and `current` of the host read the anchor and write it. `click` is the anchor's own click:
305
+ * `preventDefault()` cancels the navigation, a click with a modifier key or the middle button is the browser's, and so
306
+ * is Enter with a modifier key; Space follows the link as Enter does. The link works before the element is defined and
307
+ * where script does not run (`@tanrei/web/menubar.css` lays it out there).
308
+ *
309
+ * `disabled` on the host is the one statement that the entry is disabled; a disabled link item's anchor is written
310
+ * without `href`. Folded into the overflow item, a bar item is an item of that menu, which it draws of itself; its
311
+ * `click` is the same event of the same element.
312
+ *
313
+ * @tag tanrei-menubar-item
314
+ * @slot - A link item's anchor: one `<a href>` child of the product's own. An action has no child.
315
+ * @csspart container - The entry's container: its fill, corners, every state, the ripple and the focus ring.
316
+ * @csspart label - The entry's text: an action's label, or the box a link item's anchor stands in.
317
+ * @csspart mark - The `open_in_new` glyph of a link item that opens a new context (hidden from assistive technology).
318
+ * @fires click - The bar item was activated by pointer, touch, Enter, Space or assistive technology — in the row, after the open menu of the bar has closed, or folded, in the overflow item's menu, before that menu closes. An action's is the host's own click; a link item's is its anchor's, before the link is followed: `preventDefault()` stops the navigation.
319
+ */
320
+ export class TanreiMenubarItem extends LitElement {
321
+ static { this.styles = [itemStyles, hiddenHost]; }
322
+ // The anchor alone is drawn, in the label's place: nothing else the element holds is.
323
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' }; }
324
+ static { this.properties = {
325
+ label: { type: String, noAccessor: true },
326
+ disabled: { type: Boolean, reflect: true },
327
+ href: { attribute: false, noAccessor: true },
328
+ target: { attribute: false, noAccessor: true },
329
+ targetLabel: { type: String, attribute: 'target-label' },
330
+ current: { attribute: false, noAccessor: true },
331
+ place: { state: true },
332
+ pointerFocused: { state: true },
333
+ }; }
334
+ /**
335
+ * The bar item's text and its accessible name ("Run", "Documentation"). Required. An action's is this attribute; a
336
+ * link item's is its anchor's text, which the property reads and writes — a `label` attribute on an element that
337
+ * holds an anchor is ignored.
338
+ */
339
+ get label() {
340
+ const anchor = this.anchor;
341
+ return anchor ? (anchor.textContent ?? '').trim() : this.ownLabel;
342
+ }
343
+ set label(value) {
344
+ const text = value ?? '';
345
+ const anchor = this.anchor;
346
+ if (!anchor)
347
+ this.ownLabel = text;
348
+ else if ((anchor.textContent ?? '').trim() !== text)
349
+ anchor.textContent = text;
350
+ this.requestUpdate();
351
+ }
352
+ /**
353
+ * A link item's destination: its anchor's `href`, read from it and written to it. Empty for an action. Setting it on
354
+ * an element that holds no anchor does nothing: the destination is the anchor's, so that the link exists before the
355
+ * element is defined.
356
+ */
357
+ get href() {
358
+ return this.anchor?.getAttribute('href') ?? '';
359
+ }
360
+ set href(value) {
361
+ const anchor = this.anchor;
362
+ if (!anchor)
363
+ return;
364
+ hostAria(anchor, { href: value ? value : null });
365
+ this.requestUpdate();
366
+ }
367
+ /** Where a link item opens: `same`, or `new` — its anchor's `target="_blank"`, read from it and written to it. Anything else the anchor names is `same`. */
368
+ get target() {
369
+ return readTarget(this.anchor?.getAttribute('target')).target;
370
+ }
371
+ set target(value) {
372
+ const anchor = this.anchor;
373
+ if (!anchor)
374
+ return;
375
+ hostAria(anchor, { target: readTarget(value).target === 'new' ? '_blank' : null });
376
+ this.requestUpdate();
377
+ }
378
+ /** The link item names the page the person is on: its anchor's `aria-current="page"`, read from it and written to it. The bar never sets it. */
379
+ get current() {
380
+ const value = this.anchor?.getAttribute('aria-current');
381
+ return value != null && value !== 'false';
382
+ }
383
+ set current(value) {
384
+ const anchor = this.anchor;
385
+ if (!anchor)
386
+ return;
387
+ hostAria(anchor, { 'aria-current': value ? 'page' : null });
388
+ this.requestUpdate();
389
+ }
390
+ /** @internal The anchor's own `rel`, for the link primitive. */
391
+ get rel() {
392
+ return this.anchor?.getAttribute('rel') ?? null;
393
+ }
394
+ /** @internal The anchor's own `download`, for the link primitive. */
395
+ get download() {
396
+ return this.anchor?.getAttribute('download') ?? null;
397
+ }
398
+ constructor() {
399
+ super();
400
+ /** An action's label, as its attribute or the product gave it; a link item's is its anchor's text. */
401
+ this.ownLabel = '';
402
+ /** Prevents activation. The bar item stays in the row and reachable with the arrow keys. A disabled link item's anchor is written without `href`. */
403
+ this.disabled = false;
404
+ /** What assistive technology reads after a link item's name while it opens a new context ("opens in a new tab"): your words. Empty takes the product's words (`targetLabel`). Written as the anchor's `aria-description` unless the product wrote one there. */
405
+ this.targetLabel = '';
406
+ /** What the bar says about this entry. */
407
+ this.place = NOWHERE;
408
+ /** MBR-4, MBR-5: focus a pointer's act gave the entry, which is not the focused state and draws no ring. */
409
+ this.pointerFocused = false;
410
+ /** MBR-36: Space is down on the entry; it activates when the key comes up, as on a button. */
411
+ this.spaceDown = false;
412
+ /** The description the element last wrote on the anchor: one the product wrote there is left as it is (MBR-37). */
413
+ this.described = null;
414
+ /** What the bar measures of this entry, as it was last drawn (MBR-21, MBR-30, MBR-38). */
415
+ this.drawn = '';
416
+ this.children$ = new MutationObserver(() => this.requestUpdate());
417
+ this.settled = false;
418
+ /**
419
+ * MBR-35, MBR-37, MBR-44: whether the anchor names a destination, whether it opens a new context and what is said of
420
+ * that, and what a debug build is told of an address that is none (src/primitives/link.ts). The anchor is
421
+ * the product's: the element writes no address on it.
422
+ */
423
+ this.link = new LinkController(this, { ids: { refused: 'MBR-44', newContext: 'MBR-37' }, disabled: () => this.disabled, role: 'menuitem' });
424
+ /** MBR-6, MBR-7, MBR-36: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
425
+ this.press = new PressController(this, {
426
+ container: () => this.renderRoot?.querySelector('.container') ?? null,
427
+ holdCarrier: () => this.renderRoot?.querySelector('.content') ?? null,
428
+ disabled: () => this.disabled,
429
+ });
430
+ /** MBR-37: nothing is drawn in the mark's place until the icon set can draw it — never its name. */
431
+ this.glyphs = new GlyphDrawnController(this, () => this.renderRoot?.querySelectorAll('.icon') ?? []);
432
+ /** MBR-37: the mark is mirrored exactly when the icon set marks its name, by the icon helper. */
433
+ this.mirror = new GlyphMirrorController(this, { drawn: '.icon' });
434
+ /**
435
+ * MBR-33, MBR-36: Enter activates on key down and Space on key up, as a button's keys do — a handler that moves focus
436
+ * on Space would otherwise hand the key's release to what it focused. Enter on a link item is the browser's own: it
437
+ * fires the anchor's click and follows the link, with a modifier key in another tab or window, so nothing is
438
+ * prevented or replaced there; a held key activates once. Space scrolls nothing.
439
+ */
440
+ this.onKeyDown = (event) => {
441
+ if (!this.isEntry(event))
442
+ return;
443
+ this.press.onKeyDown(event);
444
+ if (event.key === ' ') {
445
+ event.preventDefault();
446
+ event.stopPropagation();
447
+ if (!event.repeat && !this.disabled)
448
+ this.spaceDown = true;
449
+ return;
450
+ }
451
+ if (event.key !== 'Enter')
452
+ return;
453
+ if (this.anchor?.hasAttribute('href')) {
454
+ if (event.repeat)
455
+ event.preventDefault();
456
+ return;
457
+ }
458
+ if (event.altKey || event.ctrlKey || event.metaKey)
459
+ return;
460
+ event.preventDefault();
461
+ event.stopPropagation();
462
+ if (!event.repeat)
463
+ this.click();
464
+ };
465
+ this.onKeyUp = (event) => {
466
+ if (!this.isEntry(event))
467
+ return;
468
+ this.press.onKeyUp(event);
469
+ if (event.key !== ' ' || !this.spaceDown)
470
+ return;
471
+ this.spaceDown = false;
472
+ // MBR-36: Space activates a link item as Enter does — with the anchor's own click — unless a modifier key is down.
473
+ if (event.altKey || event.ctrlKey || event.metaKey || (this.link.form && event.shiftKey))
474
+ return;
475
+ this.click();
476
+ };
477
+ /**
478
+ * Every click that reaches the element, before anything inside it or the product hears it. A disabled bar item
479
+ * swallows it (MBR-39). In the row: a click on the title that is not on the anchor is handed to the anchor, so that
480
+ * the product hears one click on its own element; a click the browser opens elsewhere — a modifier key, another
481
+ * button — is left to it and closes nothing (MBR-36); any other is an activation, for which the bar closes its open
482
+ * menu first (MBR-33).
483
+ */
484
+ this.onClickCapture = (event) => {
485
+ if (this.disabled) {
486
+ event.stopImmediatePropagation();
487
+ if (plain(event))
488
+ event.preventDefault();
489
+ return;
490
+ }
491
+ if (this.place.folded)
492
+ return;
493
+ const anchor = this.anchor;
494
+ if (anchor) {
495
+ const first = event.composedPath()[0];
496
+ if (first !== anchor && !anchor.contains(first)) {
497
+ event.stopImmediatePropagation();
498
+ event.preventDefault();
499
+ anchor.click();
500
+ return;
501
+ }
502
+ if (this.link.form && !plain(event))
503
+ return;
504
+ }
505
+ this.bar?.activating(this);
506
+ };
507
+ /** MBR-44: an anchor whose address is no destination — white space, a script — is an action: nothing is followed or run. */
508
+ this.onClick = (event) => {
509
+ if (this.anchor?.hasAttribute('href') && !this.link.form)
510
+ event.preventDefault();
511
+ };
512
+ /**
513
+ * MBR-43: a plain activation of the row a folded link item draws is one click on the product's own anchor. The row's
514
+ * own click goes no further and follows nothing; the anchor's `click()` is what the product hears — and may cancel —
515
+ * and what navigates, while the overflow item's menu is still shown; the bar closes it after. A click the browser
516
+ * opens elsewhere is left to the row's own anchor, which has the same address (MNU-54). An action's row needs none
517
+ * of this: its click leaves the shadow root as the host's own.
518
+ */
519
+ this.onFoldedClick = (event) => {
520
+ const anchor = this.anchor;
521
+ if (!this.place.folded || !anchor || this.disabled)
522
+ return;
523
+ // The anchor's own click — the one sent below — passes here too, on its way out.
524
+ const row = this.renderRoot.querySelector('tanrei-menu-item');
525
+ if (!row || !event.composedPath().includes(row))
526
+ return;
527
+ if (this.link.form && !plain(event))
528
+ return;
529
+ event.preventDefault();
530
+ event.stopImmediatePropagation();
531
+ this.bar?.foldedActivated();
532
+ anchor.click();
533
+ };
534
+ /**
535
+ * MBR-5, MBR-33: focus a press gives the entry is the pointer's, and draws no ring — said here, as the press begins,
536
+ * because an engine may call focus that a mouse gave an element visible when a key moved focus just before. A press
537
+ * that leaves the entry without focus (it ended elsewhere; an engine that does not focus a link on a press) says
538
+ * nothing: the bar gives it focus, quietly, once its click has gone through the page.
539
+ */
540
+ this.onPointerDown = (event) => {
541
+ this.press.onPointerDown(event);
542
+ if (this.disabled || (event.button !== 0 && event.pointerType === 'mouse'))
543
+ return;
544
+ this.pointerFocused = true;
545
+ this.renderRoot.querySelector('.title')?.classList.add('pf');
546
+ };
547
+ this.onPointerEnd = () => {
548
+ this.press.release();
549
+ if (this.pointerFocused && !this.entryElement.matches(':focus'))
550
+ this.pointerFocused = false;
551
+ };
552
+ /** MBR-35: a link item's address is the browser's to drag, and the press ends there; an action is never the start of a drag. */
553
+ this.onDragStart = (event) => {
554
+ if (this.link.form)
555
+ this.press.release();
556
+ else
557
+ event.preventDefault();
558
+ };
559
+ this.addEventListener('focusin', (event) => {
560
+ if (!this.isEntry(event))
561
+ return;
562
+ syncFocusStyle(this, this);
563
+ // MBR-5, MBR-8: a link item's keyboard focus is its anchor's; the ring is the container's, so the host says it.
564
+ const anchor = this.anchor;
565
+ this.toggleAttribute('data-tanrei-focus', !!anchor && anchor.matches(':focus-visible'));
566
+ });
567
+ this.addEventListener('focusout', (event) => {
568
+ if (!this.isEntry(event))
569
+ return;
570
+ this.pointerFocused = false;
571
+ this.spaceDown = false;
572
+ this.removeAttribute('data-tanrei-focus');
573
+ this.press.onBlur();
574
+ });
575
+ this.addEventListener('keydown', this.onKeyDown);
576
+ this.addEventListener('keyup', this.onKeyUp);
577
+ this.addEventListener('click', this.onClickCapture, { capture: true });
578
+ this.addEventListener('click', this.onClick);
579
+ }
580
+ /** The bar this entry is one of. */
581
+ get bar() {
582
+ const parent = this.parentElement;
583
+ return parent instanceof TanreiMenubar ? parent : null;
584
+ }
585
+ /** The product's own anchor: the first `<a>` child. With one, the entry is the anchor (MBR-35, MBR-45). */
586
+ get anchor() {
587
+ for (const child of this.children)
588
+ if (child instanceof HTMLAnchorElement)
589
+ return child;
590
+ return null;
591
+ }
592
+ /** @internal The element that is the entry: the anchor of a link item, else the host. It takes the bar's focus and carries the entry's semantics. */
593
+ get entryElement() {
594
+ return this.anchor ?? this;
595
+ }
596
+ /** @internal MBR-38: the link item names the current page (ignored without a destination). */
597
+ get isCurrent() {
598
+ return !!this.link.form && this.current;
599
+ }
600
+ /** @internal MBR-37: the link item opens a new context, so it ends in the mark. */
601
+ get marked() {
602
+ return !!this.link.form?.opensNew;
603
+ }
604
+ isEntry(event) {
605
+ return !this.place.folded && event.composedPath()[0] === this.entryElement;
606
+ }
607
+ /** @internal MBR-43: folded, the element stands in the overflow item's menu for the item it draws. */
608
+ [FORWARDED_ROWS]() {
609
+ const row = this.place.folded ? this.renderRoot?.querySelector('tanrei-menu-item') : null;
610
+ return row ? [row] : [];
611
+ }
612
+ /** @internal The bar's side: where the entry is drawn, and its place among the bar's titles. */
613
+ setBarContext(place) {
614
+ const now = this.place;
615
+ if (Object.keys(place).every((key) => place[key] === now[key]))
616
+ return;
617
+ this.place = place;
618
+ }
619
+ /** @internal Focus to the entry; `quiet` where a pointer's act moved it, which draws no ring (MBR-5). */
620
+ focusTitle(quiet) {
621
+ const entry = this.entryElement;
622
+ if (entry.matches(':focus')) {
623
+ if (!quiet)
624
+ this.pointerFocused = false;
625
+ return;
626
+ }
627
+ // The class is drawn in the next render; nothing is painted in between.
628
+ this.pointerFocused = quiet;
629
+ this.renderRoot?.querySelector('.title')?.classList.toggle('pf', quiet);
630
+ entry.focus({ preventScroll: true });
631
+ }
632
+ /** Focus goes to the element that is the entry: the host, or the anchor of a link item (MBR-35). */
633
+ focus(options) {
634
+ const entry = this.entryElement;
635
+ if (entry === this)
636
+ super.focus(options);
637
+ else
638
+ entry.focus(options);
639
+ }
640
+ /** `element.click()` activates the bar item as a pointer would — a link item through its anchor; a disabled one does nothing (MBR-39). */
641
+ click() {
642
+ if (this.disabled)
643
+ return;
644
+ const anchor = this.anchor;
645
+ if (anchor)
646
+ anchor.click();
647
+ else
648
+ super.click();
649
+ }
650
+ // A `label` attribute is an action's: on an element that holds an anchor it is kept and not written to the anchor.
651
+ attributeChangedCallback(name, old, value) {
652
+ if (name !== 'label') {
653
+ super.attributeChangedCallback(name, old, value);
654
+ return;
655
+ }
656
+ this.ownLabel = value ?? '';
657
+ this.requestUpdate();
658
+ }
659
+ connectedCallback() {
660
+ super.connectedCallback();
661
+ // MBR-30: the anchor arriving, leaving, or changing its text or what it says of itself is drawn at once.
662
+ this.children$.observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ANCHOR_ATTRIBUTES });
663
+ }
664
+ disconnectedCallback() {
665
+ super.disconnectedCallback();
666
+ this.children$.disconnect();
667
+ }
668
+ firstUpdated() {
669
+ this.renderRoot.addEventListener('click', this.onFoldedClick, { capture: true });
670
+ // The anchor may arrive after the element connects: what a bar item lacks is judged once its children had a frame to.
671
+ requestAnimationFrame(() => {
672
+ this.settled = true;
673
+ if (this.isConnected)
674
+ this.check(this.anchor);
675
+ });
676
+ // Folded, what the row says about itself is the overflow item's menu's to hear.
677
+ this.renderRoot.addEventListener('tanrei-menu-item-update', () => this.bar?.foldedUpdated());
678
+ }
679
+ updated(changed) {
680
+ const anchor = this.anchor;
681
+ const slot = this.renderRoot.querySelector('slot');
682
+ if (slot) {
683
+ const now = slot.assignedNodes();
684
+ if (anchor ? now.length !== 1 || now[0] !== anchor : now.length > 0)
685
+ slot.assign(...(anchor ? [anchor] : []));
686
+ }
687
+ const { folded, position, size, stop } = this.place;
688
+ const form = this.link.form;
689
+ // MBR-42: the entry is a menu item that opens nothing — no aria-haspopup and no aria-expanded, in any value — with
690
+ // its disabled state and its place among the bar's entries; the bar's Tab stop is its tabindex (MBR-12). MBR-35:
691
+ // of a link item all of it is said on the anchor, and the host is nothing. Folded, the row it draws in the overflow
692
+ // item's menu says it, and the anchor, which nothing displays, takes no focus.
693
+ const said = {
694
+ role: 'menuitem',
695
+ 'aria-disabled': this.disabled ? 'true' : null,
696
+ 'aria-posinset': position ? String(position) : null,
697
+ 'aria-setsize': size ? String(size) : null,
698
+ tabindex: stop ? '0' : '-1',
699
+ };
700
+ const nothingSaid = { role: 'none', 'aria-disabled': null, 'aria-label': null, 'aria-posinset': null, 'aria-setsize': null, tabindex: null };
701
+ if (folded) {
702
+ hostAria(this, { ...nothingSaid, 'data-tanrei-folded': '', 'data-tanrei-focus': null });
703
+ if (anchor)
704
+ hostAria(anchor, { ...said, 'aria-posinset': null, 'aria-setsize': null, tabindex: '-1' });
705
+ }
706
+ else if (anchor) {
707
+ hostAria(this, { ...nothingSaid, 'data-tanrei-folded': null });
708
+ hostAria(anchor, said);
709
+ }
710
+ else
711
+ hostAria(this, { ...said, 'aria-label': this.label || null, 'data-tanrei-folded': null, 'data-tanrei-focus': null });
712
+ if (anchor) {
713
+ // MBR-37: what a new context is said with — the description, unless the product wrote its own on the anchor — and
714
+ // no handle for the page it opens to the one that opened it.
715
+ const want = form?.targetLabel ?? null;
716
+ const have = anchor.getAttribute('aria-description');
717
+ if (have === null || have === this.described) {
718
+ hostAria(anchor, { 'aria-description': want });
719
+ this.described = want;
720
+ }
721
+ if (form?.opensNew)
722
+ hostAria(anchor, { rel: linkRel(anchor.getAttribute('rel'), 'new') });
723
+ }
724
+ if (this.settled)
725
+ this.check(anchor);
726
+ // MBR-21, MBR-30, MBR-38: the bar measures the entry again, and lays its row out for what changed.
727
+ const drawn = [this.label, this.disabled, !!form, this.marked, this.isCurrent].join('\u0000');
728
+ if (drawn !== this.drawn || changed.has('place')) {
729
+ this.drawn = drawn;
730
+ this.bar?.entryUpdated();
731
+ }
732
+ }
733
+ /** What a debug build is told of a bar item the element survives (MBR-38, MBR-39, MBR-44, MBR-45); the link primitive says the rest. */
734
+ check(anchor) {
735
+ if (!this.label.trim())
736
+ report(this, 'MBR-44', 'label is empty, so the bar item has no accessible name; give an action a label ("Run"), a link item\'s anchor its text');
737
+ if (!anchor) {
738
+ if (this.hasAttribute('href'))
739
+ report(this, 'MBR-45', 'href is written on the element, which holds no anchor; it is ignored and the bar item is an action — a link item is the product\'s own anchor inside the element, <tanrei-menubar-item><a href="…">…</a></tanrei-menubar-item>, so that the link exists before the element is defined');
740
+ return;
741
+ }
742
+ const address = anchor.hasAttribute('href');
743
+ if (this.disabled && address)
744
+ report(this, 'MBR-39', 'it is disabled and its anchor still has an href: it is drawn and exposed disabled, emits no click and has its plain activation prevented, but the browser still gives the address a new tab, a context menu and a drag; write the anchor without href while the bar item is disabled');
745
+ if (!this.disabled && !address)
746
+ report(this, 'MBR-44', 'its anchor has no href, so it is an action whose entry is the anchor; write an action with label instead, <tanrei-menubar-item label="…">');
747
+ const target = anchor.getAttribute('target');
748
+ if (!readTarget(target).known)
749
+ report(this, 'MBR-44', `its anchor's target "${target}" is not one a bar item defines ("_blank" for a new context); it is drawn and described as one that opens where the person is`);
750
+ if (this.current && !this.link.form)
751
+ report(this, 'MBR-38', 'its anchor says aria-current and names no destination; current is ignored');
752
+ }
753
+ render() {
754
+ const form = this.link.form;
755
+ const current = this.isCurrent;
756
+ // MBR-43: folded, an item of the overflow item's menu — the same label, a disabled bar item a disabled row, a link
757
+ // item the menu's own link item with the same address, target and words, and the current page said and drawn.
758
+ if (this.place.folded) {
759
+ // The product's anchor keeps its place in the tree that is drawn — in a slot nothing displays — so that its click
760
+ // goes through the page as any click does (an engine sends the event of a child that is in no slot to nobody else).
761
+ return html `<tanrei-menu-item
762
+ class=${classMap({ current })}
763
+ label=${this.label}
764
+ ?disabled=${this.disabled}
765
+ href=${form ? this.href : nothing}
766
+ target=${form?.opensNew ? 'new' : nothing}
767
+ target-label=${form?.opensNew && this.targetLabel ? this.targetLabel : nothing}
768
+ .rel=${form ? this.rel : null}
769
+ .download=${form ? this.download : null}
770
+ .barCurrent=${current}
771
+ ></tanrei-menu-item
772
+ ><span class="kept"><slot></slot></span>`;
773
+ }
774
+ // MBR-32: a title in every respect — the same boxes, by the same rules, always unselected. MBR-35: the anchor of a
775
+ // link item is slotted into the label, and is given the whole title by the styles.
776
+ return html `<span
777
+ class=${classMap({ title: true, p: true, d: this.disabled, pf: this.pointerFocused, link: !!form, current })}
778
+ @pointerdown=${this.onPointerDown}
779
+ @pointerup=${this.onPointerEnd}
780
+ @pointercancel=${this.onPointerEnd}
781
+ @pointerleave=${this.onPointerEnd}
782
+ @dragstart=${this.onDragStart}
783
+ ><span part="container" class="container" data-tanrei-shape
784
+ ><span class="content"
785
+ ><span part="label" class="label">${this.anchor ? html `<slot></slot>` : this.label}</span>${this.marked
786
+ ? html `<span part="mark" class="icon" aria-hidden="true"><span class="ink">${LINK_MARK}</span></span>`
787
+ : nothing}</span
788
+ ></span
789
+ ></span
790
+ >`;
791
+ }
792
+ }
793
+ /**
794
+ * Keeps an application's commands within reach in one persistent row of named menus (File, Edit, View…), each opening
795
+ * a menu below its title, with the arrow keys moving along the row and into each menu.
796
+ *
797
+ * Contract: specs/menubar.spec.json. The host is `role="menubar"`, named by `label`; its children are
798
+ * `<tanrei-menubar-menu>` elements, each of which is its title and holds its menu's items, and — for the one or two
799
+ * entries that act by themselves — `<tanrei-menubar-item>` elements, an action or the product's own anchor as a link
800
+ * item, drawn and reached as the titles are (a press, Enter or Space runs or follows one; the block arrow keys do
801
+ * nothing on it; from a menu the inline arrow keys land on it and open nothing). The bar is one Tab stop: the
802
+ * inline arrow keys, Home, End and a typed character move along the titles; Enter, Space and the block arrow keys open
803
+ * a title's menu; from inside a menu the inline arrow keys go on to the neighbouring menu; Escape returns to the title
804
+ * and Tab leaves the bar. While one menu is open a pointer that moves onto another title opens that one at once. It
805
+ * shows one menu at a time, sets each menu's `open` and fires its `toggle`.
806
+ *
807
+ * Titles that the row has no room for are folded whole, from the end, into one overflow item — the icon set's
808
+ * `more_horiz`, named by `overflow-label` — whose menu holds each folded menu as a submenu. The bar measures what fits
809
+ * and decides again when its size, its menus, a label, the text size or the direction changes. It draws no position,
810
+ * edge or elevation of its own: you place it. Every visual value comes from `--tanrei-comp-menubar-*` tokens; the
811
+ * surfaces the titles open are Menus, drawn from `--tanrei-comp-menu-*`.
812
+ *
813
+ * The `inline` attribute, for tests and documentation, draws an open menu in place below its title instead of in the
814
+ * top layer, as the menu's own does: without placement, open motion, focus on opening or light dismiss.
815
+ *
816
+ * @tag tanrei-menubar
817
+ * @slot - The entries, in the order given: `<tanrei-menubar-menu>` and `<tanrei-menubar-item>` elements. Anything else gets no title, no key and no place in the row, and is reported in debug builds (MBR-20).
818
+ * @csspart bar - The row: its fill, paddings and the gap between titles.
819
+ * @csspart overflow-item - The overflow item, the last title of a row that cannot hold every title.
820
+ * @csspart container - The overflow item's container: its fill, corners, every state, the ripple and the focus ring.
821
+ * @csspart icon - The overflow item's glyph (hidden from assistive technology).
822
+ */
823
+ export class TanreiMenubar extends LitElement {
824
+ static { this.styles = barStyles; }
825
+ // The titles in the row and the folded menus in the overflow item's menu are assigned by hand: a menu is in the one
826
+ // or the other, where the product wrote it either way (MBR-22).
827
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' }; }
828
+ static { this.properties = {
829
+ label: { type: String },
830
+ overflowLabel: { type: String, attribute: 'overflow-label' },
831
+ inline: { type: Boolean, reflect: true },
832
+ items: { state: true },
833
+ folds: { state: true },
834
+ overflowOpen: { state: true },
835
+ stop: { state: true },
836
+ overflowQuiet: { state: true },
837
+ }; }
838
+ constructor() {
839
+ super();
840
+ this.availability = new AvailabilityController(this, 'menubar');
841
+ /** Names the bar for assistive technology ("Application menu"), in the product's language. Never drawn. Required. It is this bar's own name and is not read from the product's words. */
842
+ this.label = '';
843
+ /**
844
+ * The accessible name of the overflow item ("More menus"), in the product's language. Never drawn. Empty takes the
845
+ * product's words (`menubarOverflowLabel`); needed whenever the bar may be narrower than its titles.
846
+ */
847
+ this.overflowLabel = '';
848
+ /** For tests and documentation: draws an open menu in place below its title, without the overlay's behaviour. */
849
+ this.inline = false;
850
+ /** MBR-23: the overflow item's name is the instance's, else the product's word; Tanrei has none of its own. */
851
+ this.words = new WordsController(this);
852
+ /** The bar's entries — its menus and its bar items (MBR-32) — in the order given. */
853
+ this.items = [];
854
+ /** MBR-21: how many entries are folded out of the row, from its end. */
855
+ this.folds = 0;
856
+ /** MBR-22: whether the overflow item's menu is shown. */
857
+ this.overflowOpen = false;
858
+ /** MBR-10: the menu the bar shows now — in the row, or as a submenu of the overflow item's menu. */
859
+ this.current = null;
860
+ /** MBR-12: the title the Tab stop stands on: the one focused last or whose menu was opened last, whichever came later. */
861
+ this.stop = null;
862
+ /** The title that holds focus now, as far as the bar was told (MBR-30: a removed element tells nobody). */
863
+ this.focused = null;
864
+ /** MBR-4: focus a pointer's act gave the overflow item. */
865
+ this.overflowQuiet = false;
866
+ /** What the person last acted with on the bar: a menu opened by a pointer takes focus without the ring (MBR-9). */
867
+ this.input = 'key';
868
+ /** MBR-12: the next and the previous title, wrapping, and the first and the last (the typeahead is the bar's own: one character). */
869
+ this.keys = new RovingKeys({ wrap: true });
870
+ /** MBR-21: the inline sizes the fold is decided from, as the observer last reported them. */
871
+ this.sizes = new Map();
872
+ this.resize = null;
873
+ this.children$ = new MutationObserver(() => this.readChildren());
874
+ this.settled = false;
875
+ /** What the bar tells the overflow item's menu (src/components/menu/menu.ts): as each menu's own channel, and that its own level is the fold's (MBR-22). */
876
+ this.overflowChannel = {
877
+ ground: this,
878
+ inlineKey: (towardsEnd) => this.travel(OVERFLOW, towardsEnd),
879
+ entry: { end: 'first', quiet: false },
880
+ quick: false,
881
+ fold: true,
882
+ };
883
+ /** MBR-6, MBR-7, MBR-22: the overflow item is pressed as any title is. */
884
+ this.press = new PressController(this, {
885
+ container: () => this.overflowElement?.querySelector('.container') ?? null,
886
+ holdCarrier: () => this.overflowElement?.querySelector('.content') ?? null,
887
+ disabled: () => false,
888
+ });
889
+ /** MBR-21: nothing is drawn in the glyph's place until the icon set can draw it — never its name. */
890
+ this.glyphs = new GlyphDrawnController(this, () => this.renderRoot?.querySelectorAll('.overflow .icon') ?? []);
891
+ /** MBR-25: the glyph is mirrored exactly when the icon set marks its name, by the icon helper. */
892
+ this.mirror = new GlyphMirrorController(this, { drawn: '.icon' });
893
+ this.onOverflowClose = (event) => this.closeRequested(OVERFLOW, event.detail.reason);
894
+ /** MBR-12: focus on a title makes it the Tab stop; where style queries are missing the focus style is read as focus arrives (MBR-8). */
895
+ this.onFocusIn = (event) => {
896
+ const title = this.titleOf(event);
897
+ if (!title)
898
+ return;
899
+ this.focused = title;
900
+ if (title === OVERFLOW)
901
+ syncFocusStyle(this, this.overflowElement);
902
+ if (this.stop === title)
903
+ return;
904
+ this.stop = title;
905
+ this.place();
906
+ };
907
+ /** MBR-14: focus leaving the bar and its open menu closes the menu, and the bar takes no focus back. */
908
+ this.onFocusOut = (event) => {
909
+ const title = this.titleOf(event);
910
+ const to = event.relatedTarget;
911
+ if (title) {
912
+ if (title === OVERFLOW) {
913
+ this.overflowQuiet = false;
914
+ this.press.onBlur();
915
+ }
916
+ // A title that was removed is not blurred by the person: the bar still knows focus was there when it reads its
917
+ // children again (MBR-30). Whether this blur is a removal's is known once the script that caused it has ended:
918
+ // the title is then no longer the bar's.
919
+ if (to) {
920
+ if (this.focused === title)
921
+ this.focused = null;
922
+ }
923
+ else {
924
+ queueMicrotask(() => {
925
+ const here = title === OVERFLOW ? this.folds > 0 : title.parentElement === this;
926
+ if (this.focused === title && here && this.titleAt(deepActive()) !== title)
927
+ this.focused = null;
928
+ });
929
+ }
930
+ }
931
+ if (!to || this.holds(to) || this.inline)
932
+ return;
933
+ if (this.openTitle() || this.current)
934
+ this.present(null);
935
+ };
936
+ /**
937
+ * MBR-9, MBR-12, MBR-14, MBR-20: the keys on a title. With no menu open: the inline arrow keys, Home, End and one
938
+ * typed character move focus along the bar and open nothing; Enter, Space and Down Arrow open the title's menu with
939
+ * focus on its first enabled item, Up Arrow on its last; nothing else is handled — not Escape. On a title while a
940
+ * menu is open (a menu that holds no item keeps focus on its title): the inline arrow keys travel as MBR-13 says,
941
+ * Escape closes it, Tab closes it and moves on, and the keys that open a menu act on the focused title.
942
+ */
943
+ this.onKeyDown = (event) => {
944
+ const title = this.titleOf(event);
945
+ if (!title || event.defaultPrevented)
946
+ return;
947
+ const open = this.openTitle();
948
+ const { key } = event;
949
+ if (key === 'Tab') {
950
+ // The focused title is the Tab stop, so the key's own move leaves the bar (MBR-12, MBR-14).
951
+ if (open)
952
+ this.present(null);
953
+ return;
954
+ }
955
+ if (event.altKey || event.ctrlKey || event.metaKey)
956
+ return;
957
+ const handled = () => {
958
+ event.preventDefault();
959
+ event.stopPropagation();
960
+ };
961
+ if (key === 'Escape') {
962
+ // MBR-14: with no menu open the key is not the bar's.
963
+ if (!open)
964
+ return;
965
+ handled();
966
+ this.present(null);
967
+ return;
968
+ }
969
+ const titles = this.titles();
970
+ const at = titles.indexOf(title);
971
+ if (key === 'ArrowRight' || key === 'ArrowLeft') {
972
+ handled();
973
+ const towardsEnd = (key === 'ArrowRight') !== (getComputedStyle(this).direction === 'rtl');
974
+ if (open)
975
+ this.travel(open, towardsEnd);
976
+ else
977
+ this.move(titles, this.keys.target(towardsEnd ? 'ArrowDown' : 'ArrowUp', at, titles.map(() => ({ focusable: true, label: '' }))));
978
+ return;
979
+ }
980
+ if (title instanceof TanreiMenubarItem) {
981
+ // MBR-34: a bar item has no menu to open: the block arrow keys are taken and do nothing, so that the same keys
982
+ // never open a menu on one entry and move the page on the next. Enter and Space are the bar item's own
983
+ // (MBR-33, MBR-36) — on a link item Enter is the browser's.
984
+ if (key === 'ArrowDown' || key === 'ArrowUp')
985
+ handled();
986
+ if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Enter' || key === ' ')
987
+ return;
988
+ }
989
+ else if (key === 'Enter' || key === ' ' || key === 'ArrowDown' || key === 'ArrowUp') {
990
+ handled();
991
+ if (event.repeat || this.disabledTitle(title))
992
+ return;
993
+ const end = key === 'ArrowUp' ? 'last' : 'first';
994
+ if (open !== title)
995
+ this.present(title, { entry: { end, quiet: false } });
996
+ else if (key === 'Enter' || key === ' ')
997
+ this.present(null);
998
+ else if (title !== OVERFLOW)
999
+ title.focusMenu(end);
1000
+ else {
1001
+ this.overflowChannel.entry = { end, quiet: false };
1002
+ this.overflowMenu?.focusFirstItem();
1003
+ }
1004
+ return;
1005
+ }
1006
+ if (open)
1007
+ return;
1008
+ if (key === 'Home' || key === 'End') {
1009
+ handled();
1010
+ this.move(titles, this.keys.target(key, at, titles.map(() => ({ focusable: true, label: '' }))));
1011
+ return;
1012
+ }
1013
+ // MBR-12: one printable character, with no modifier but Shift: the next title after the focused one, wrapping,
1014
+ // whose label begins with it, whatever its letter case; nowhere when none does.
1015
+ if ([...key].length !== 1)
1016
+ return;
1017
+ handled();
1018
+ const typed = key.toLocaleLowerCase();
1019
+ for (let step = 1; step <= titles.length; step += 1) {
1020
+ const index = (at + step) % titles.length;
1021
+ if (this.labelOf(titles[index]).trim().toLocaleLowerCase().startsWith(typed)) {
1022
+ this.move(titles, index);
1023
+ return;
1024
+ }
1025
+ }
1026
+ };
1027
+ // ── The overflow item (MBR-22) ──
1028
+ this.onOverflowKeyDown = (event) => {
1029
+ if (event.composedPath()[0] === this.overflowElement)
1030
+ this.press.onKeyDown(event);
1031
+ };
1032
+ this.onOverflowKeyUp = (event) => {
1033
+ if (event.composedPath()[0] === this.overflowElement)
1034
+ this.press.onKeyUp(event);
1035
+ };
1036
+ this.onOverflowClick = (event) => {
1037
+ // A click inside its menu is an item's.
1038
+ const first = event.composedPath()[0];
1039
+ const title = this.overflowElement?.querySelector('.title');
1040
+ if (first === this.overflowElement || (title && (first === title || title.contains(first))))
1041
+ this.pressed(OVERFLOW);
1042
+ };
1043
+ this.onOverflowEnter = (event) => {
1044
+ if (event.pointerType === 'mouse' || event.pointerType === 'pen')
1045
+ this.hovered(OVERFLOW);
1046
+ };
1047
+ this.addEventListener('keydown', () => (this.input = 'key'), { capture: true });
1048
+ this.addEventListener('pointerdown', () => (this.input = 'pointer'), { capture: true });
1049
+ this.addEventListener('keydown', this.onKeyDown);
1050
+ this.addEventListener('focusin', this.onFocusIn);
1051
+ this.addEventListener('focusout', this.onFocusOut);
1052
+ }
1053
+ connectedCallback() {
1054
+ super.connectedCallback();
1055
+ this.resize ??= new ResizeObserver((entries) => this.measured(entries));
1056
+ this.children$.observe(this, { childList: true });
1057
+ this.readChildren();
1058
+ if (this.hasUpdated)
1059
+ this.observe();
1060
+ }
1061
+ disconnectedCallback() {
1062
+ super.disconnectedCallback();
1063
+ this.children$.disconnect();
1064
+ this.resize?.disconnect();
1065
+ this.sizes.clear();
1066
+ }
1067
+ // ── The titles ──
1068
+ get overflowElement() {
1069
+ return this.renderRoot?.querySelector('.overflow') ?? null;
1070
+ }
1071
+ get overflowMenu() {
1072
+ return this.renderRoot?.querySelector('.overflow > tanrei-menu') ?? null;
1073
+ }
1074
+ /** MBR-21: the entries in the row. */
1075
+ get visible() {
1076
+ return this.items.slice(0, this.items.length - this.folds);
1077
+ }
1078
+ /** MBR-21, MBR-43: the entries folded into the overflow item, in the order given. */
1079
+ get folded() {
1080
+ return this.items.slice(this.items.length - this.folds);
1081
+ }
1082
+ /** The bar's menus, in the order given: the entries that open. */
1083
+ get menus() {
1084
+ return this.items.filter((row) => row instanceof TanreiMenubarMenu);
1085
+ }
1086
+ /** The bar's titles, in order: the entries in the row, then the overflow item while something is folded (MBR-22). */
1087
+ titles() {
1088
+ return [...this.visible, ...(this.folds > 0 ? [OVERFLOW] : [])];
1089
+ }
1090
+ /** The title an entry is reached from: its own, or the overflow item where it is folded. */
1091
+ titleFor(row) {
1092
+ return this.folded.includes(row) ? OVERFLOW : row;
1093
+ }
1094
+ /** The title whose menu is open now. */
1095
+ openTitle() {
1096
+ if (this.overflowOpen)
1097
+ return OVERFLOW;
1098
+ return this.current && !this.folded.includes(this.current) ? this.current : null;
1099
+ }
1100
+ disabledTitle(title) {
1101
+ return title !== OVERFLOW && title.disabled;
1102
+ }
1103
+ labelOf(title) {
1104
+ return title === OVERFLOW ? this.words.get('menubarOverflowLabel', this.overflowLabel) : title.label;
1105
+ }
1106
+ /** Whether `node` is in the bar: its menus and their items, wherever they are drawn, or its own shadow root. */
1107
+ holds(node) {
1108
+ for (let at = node; at; at = flatParent(at))
1109
+ if (at === this)
1110
+ return true;
1111
+ return false;
1112
+ }
1113
+ /** The title a key or focus event is on: the host of a menu in the row, or the overflow item — not something inside a menu. */
1114
+ titleOf(event) {
1115
+ return this.titleAt(event.composedPath()[0]);
1116
+ }
1117
+ titleAt(node) {
1118
+ if (!node)
1119
+ return null;
1120
+ if (node === this.overflowElement)
1121
+ return OVERFLOW;
1122
+ if (node instanceof TanreiMenubarMenu)
1123
+ return this.visible.includes(node) ? node : null;
1124
+ // MBR-35: a bar item's entry is its host, or the product's anchor inside it.
1125
+ const item = node instanceof TanreiMenubarItem ? node : node.parentNode instanceof TanreiMenubarItem ? node.parentNode : null;
1126
+ return item && item.entryElement === node && this.visible.includes(item) ? item : null;
1127
+ }
1128
+ focusTitle(title, quiet) {
1129
+ if (title === OVERFLOW) {
1130
+ const element = this.overflowElement;
1131
+ if (!element)
1132
+ return;
1133
+ this.overflowQuiet = element.matches(':focus') ? quiet && this.overflowQuiet : quiet;
1134
+ element.querySelector('.title')?.classList.toggle('pf', this.overflowQuiet);
1135
+ element.focus({ preventScroll: true });
1136
+ }
1137
+ else
1138
+ title.focusTitle(quiet);
1139
+ }
1140
+ /** MBR-12: the Tab stop is one of the titles there are — a folded menu's is the overflow item, and with none it is the first title. */
1141
+ stopNow() {
1142
+ const titles = this.titles();
1143
+ if (this.stop && titles.includes(this.stop))
1144
+ return this.stop;
1145
+ if (this.stop && this.stop !== OVERFLOW && this.folded.includes(this.stop))
1146
+ return OVERFLOW;
1147
+ return titles[0] ?? null;
1148
+ }
1149
+ /** Tells each entry where it is drawn and what its title is among the bar's titles (MBR-12, MBR-19, MBR-21, MBR-42). */
1150
+ place() {
1151
+ const titles = this.titles();
1152
+ const stop = this.stopNow();
1153
+ for (const row of this.items) {
1154
+ const folded = this.folded.includes(row);
1155
+ if (row instanceof TanreiMenubarMenu)
1156
+ row.channel.ground = this;
1157
+ row.setBarContext({ folded, position: folded ? 0 : titles.indexOf(row) + 1, size: folded ? 0 : titles.length, stop: row === stop, inline: this.inline });
1158
+ }
1159
+ }
1160
+ // ── The menus the bar holds (MBR-20, MBR-30) ──
1161
+ readChildren() {
1162
+ const before = this.items;
1163
+ const now = [...this.children].filter(isRow);
1164
+ if (this.settled)
1165
+ this.checkContent();
1166
+ if (now.length === before.length && now.every((menu, i) => menu === before[i]))
1167
+ return;
1168
+ const removed = before.filter((menu) => !now.includes(menu));
1169
+ // MBR-30: where focus was — on a removed title, or inside a removed menu that was open — it must not fall out of
1170
+ // the bar; a removed element is no longer focused, so the bar remembers where focus was.
1171
+ const nowhere = !deepActive() || deepActive() === document.body;
1172
+ const lost = nowhere ? (removed.find((menu) => this.focused === menu || this.current === menu) ?? null) : null;
1173
+ const follower = (menu) => now[Math.min(before.indexOf(menu) - removed.filter((each) => before.indexOf(each) < before.indexOf(menu)).length, now.length - 1)] ?? null;
1174
+ for (const menu of removed) {
1175
+ // MBR-30: a menu removed while open is closed without its toggle.
1176
+ if (menu instanceof TanreiMenubarMenu && this.current === menu) {
1177
+ this.current = null;
1178
+ menu.channel.quick = false;
1179
+ if (menu.open)
1180
+ menu.open = false;
1181
+ }
1182
+ if (this.stop === menu)
1183
+ this.stop = follower(menu);
1184
+ if (this.focused === menu)
1185
+ this.focused = null;
1186
+ menu.setBarContext(NOWHERE);
1187
+ }
1188
+ this.items = now;
1189
+ // The fold is decided again from the copies of the titles there are now; until then no more are folded than there are.
1190
+ this.folds = Math.min(this.folds, now.length);
1191
+ if (this.folds === 0 && this.overflowOpen)
1192
+ this.overflowOpen = false;
1193
+ this.place();
1194
+ this.reconcile();
1195
+ if (lost) {
1196
+ const next = follower(lost);
1197
+ if (next)
1198
+ void this.updateComplete.then(() => this.focusTitle(this.titleFor(next), this.input === 'pointer'));
1199
+ }
1200
+ }
1201
+ /**
1202
+ * MBR-20: a bar with no entry, and anything in it that is neither a menu nor a bar item, are reported; such a thing
1203
+ * gets no place in the row. MBR-44: a bar of bar items alone is drawn and works, and is reported.
1204
+ */
1205
+ checkContent() {
1206
+ const children = [...this.children];
1207
+ const rows = children.filter(isRow);
1208
+ if (rows.length === 0)
1209
+ report(this, 'MBR-20', 'it holds neither a menu nor a bar item, so the bar is drawn with nothing on it and takes no focus; a menubar holds <tanrei-menubar-menu> elements, and <tanrei-menubar-item> elements beside them', { once: false });
1210
+ else if (!rows.some((row) => row instanceof TanreiMenubarMenu))
1211
+ report(this, 'MBR-44', 'it holds bar items and no menu: a row of actions alone is a toolbar, and a row of links alone is navigation; it is still drawn and works');
1212
+ for (const child of children) {
1213
+ if (isRow(child))
1214
+ continue;
1215
+ report(this, 'MBR-20', `it holds <${child.localName}>, which is neither a <tanrei-menubar-menu> nor a <tanrei-menubar-item>; it gets no title, no key and no place in the row — a field, a control of the product's own or an entry that holds a state would take the keys the bar moves focus with and would not be a menu item`);
1216
+ }
1217
+ }
1218
+ // ── Which menu is shown (MBR-9, MBR-10, MBR-18, MBR-22, MBR-29) ──
1219
+ fire(menu, open) {
1220
+ menu.dispatchEvent(new CustomEvent('toggle', { bubbles: true, detail: { open } }));
1221
+ }
1222
+ /**
1223
+ * Shows `next` — a menu, the overflow item's menu alone, or nothing — in place of what is shown (MBR-10: at most one):
1224
+ * the menu that was open closes first, its `open` set and its `toggle` fired (`closes`), then the new one opens, its
1225
+ * `open` set and its `toggle` fired (`opens`). Where one title's menu takes the place of another's neither moves
1226
+ * (MBR-29). Focus goes into the new menu as `entry` says (MBR-9) — the menu's own doing — or to its title where it
1227
+ * holds no item (MBR-20).
1228
+ */
1229
+ present(next, { entry = { end: 'first', quiet: false }, closes = true, opens = true } = {}) {
1230
+ const was = this.openTitle();
1231
+ const menu = next === OVERFLOW ? null : next;
1232
+ const title = next === null ? null : next === OVERFLOW ? OVERFLOW : this.titleFor(next);
1233
+ // MBR-29: one title's menu in place of another's — both at once, with neither motion.
1234
+ const quick = !!was && !!title && was !== title;
1235
+ const before = this.current;
1236
+ if (before && before !== menu) {
1237
+ before.channel.quick = quick;
1238
+ this.current = null;
1239
+ if (before.open)
1240
+ before.open = false;
1241
+ if (closes)
1242
+ this.fire(before, false);
1243
+ }
1244
+ if (this.overflowOpen && title !== OVERFLOW) {
1245
+ this.overflowChannel.quick = quick;
1246
+ this.overflowOpen = false;
1247
+ }
1248
+ if (title === OVERFLOW) {
1249
+ if (!this.overflowOpen) {
1250
+ this.overflowChannel.quick = quick;
1251
+ this.overflowChannel.entry = entry;
1252
+ this.overflowOpen = true;
1253
+ }
1254
+ }
1255
+ if (menu && this.current !== menu) {
1256
+ menu.channel.quick = quick;
1257
+ menu.channel.entry = entry;
1258
+ this.current = menu;
1259
+ if (!menu.open)
1260
+ menu.open = true;
1261
+ if (opens)
1262
+ this.fire(menu, true);
1263
+ }
1264
+ // MBR-12: the Tab stop follows the menu opened last, by any input.
1265
+ if (title) {
1266
+ this.stop = title;
1267
+ this.place();
1268
+ // MBR-20: a menu with no item takes no focus; its title keeps it, or takes it from the menu that closed.
1269
+ if (title !== OVERFLOW && menu && !menu.hasItems && !this.inline && (was !== null || this.holds(deepActive())))
1270
+ this.focusTitle(title, entry.quiet);
1271
+ }
1272
+ }
1273
+ /**
1274
+ * MBR-10, MBR-18: a menu's `open` or `disabled` changed — the person's doing through the bar, which is already in
1275
+ * step, or the product's: a disabled menu is closed; a menu the product closed is closed, without its toggle; a menu
1276
+ * the product opened is opened as an activation would, without its toggle, and the menu that was open closes with
1277
+ * its own; of several the product opened the first is shown.
1278
+ * @internal
1279
+ */
1280
+ reconcile() {
1281
+ for (const menu of this.menus) {
1282
+ if (!menu.open || !menu.disabled)
1283
+ continue;
1284
+ // MBR-18: a disabled menu is closed; one that was shown says so.
1285
+ const shown = this.current === menu;
1286
+ if (shown)
1287
+ this.current = null;
1288
+ menu.channel.quick = false;
1289
+ menu.open = false;
1290
+ if (shown)
1291
+ this.fire(menu, false);
1292
+ }
1293
+ if (this.current && !this.current.open) {
1294
+ // The product closed it: as an activation would, so focus that was inside returns to the title it is reached from.
1295
+ const closed = this.current;
1296
+ const title = this.titleFor(closed);
1297
+ closed.channel.quick = false;
1298
+ this.current = null;
1299
+ const active = deepActive();
1300
+ if (title !== OVERFLOW && closed.isConnected && this.holds(active) && !this.titleAt(active) && active !== this)
1301
+ this.focusTitle(title, this.input === 'pointer');
1302
+ }
1303
+ const fresh = this.menus.filter((menu) => menu.open && menu !== this.current);
1304
+ if (fresh.length === 0)
1305
+ return;
1306
+ if (fresh.length > 1)
1307
+ report(this, 'MBR-10', `open is set on ${fresh.length} menus; a bar shows one menu at a time, so the first of them is shown`, { once: false });
1308
+ for (const menu of fresh.slice(1))
1309
+ menu.open = false;
1310
+ this.present(fresh[0], { opens: false });
1311
+ }
1312
+ /** @internal MBR-22: a folded menu's submenu item was opened or closed by the person, as a submenu of the overflow item's menu. */
1313
+ foldedToggled(menu, open) {
1314
+ if (open) {
1315
+ if (this.current && this.current !== menu) {
1316
+ const before = this.current;
1317
+ this.current = null;
1318
+ if (before.open) {
1319
+ before.open = false;
1320
+ this.fire(before, false);
1321
+ }
1322
+ }
1323
+ this.current = menu;
1324
+ this.stop = OVERFLOW;
1325
+ if (!menu.open)
1326
+ menu.open = true;
1327
+ this.fire(menu, true);
1328
+ }
1329
+ else {
1330
+ if (this.current === menu)
1331
+ this.current = null;
1332
+ if (menu.open) {
1333
+ menu.open = false;
1334
+ this.fire(menu, false);
1335
+ }
1336
+ }
1337
+ }
1338
+ /** @internal What a folded menu draws in the overflow item's menu changed: that menu reads its items again. */
1339
+ foldedUpdated() {
1340
+ const menu = this.overflowMenu;
1341
+ if (!menu)
1342
+ return;
1343
+ menu.requestUpdate();
1344
+ menu.dispatchEvent(new Event('tanrei-menu-item-update'));
1345
+ }
1346
+ /** @internal MBR-21, MBR-30, MBR-38: an entry's label, disabled value, mark, weight or place changed: its copy is measured again by the observer; a folded one is read again. */
1347
+ entryUpdated() {
1348
+ this.requestUpdate();
1349
+ if (this.folds > 0)
1350
+ this.foldedUpdated();
1351
+ // What changed may be drawn nowhere but in the copy the fold is measured from — a folded entry's label or weight
1352
+ // (MBR-38: the current page that is no longer current, MBR-30) — and the copy is never painted. An engine that
1353
+ // draws a frame only when something painted changed (WebKit on Linux) then reports the copy's new size to the
1354
+ // observer with the next frame the page happens to draw, and until then the row stays folded as it was. One frame
1355
+ // is asked for, so that what fits is decided again now; it does nothing itself.
1356
+ requestAnimationFrame(() => { });
1357
+ // MBR-38: each is drawn and exposed as given; at most one bar item of a bar names the current page.
1358
+ const current = this.items.filter((row) => row instanceof TanreiMenubarItem && row.isCurrent).length;
1359
+ if (current > 1)
1360
+ report(this, 'MBR-38', `${current} bar items say they are the current page; each is drawn and exposed as given — at most one names the page the person is on`);
1361
+ }
1362
+ // ── A bar item's activation (MBR-33, MBR-36, MBR-43) ──
1363
+ /**
1364
+ * @internal MBR-33, MBR-36: a bar item in the row is being activated — the click is on its way to the product. The
1365
+ * menu of the bar that is open, another entry's, closes first, with its toggle, as it does when another title is
1366
+ * pressed (MBR-10); the Tab stop is the bar item (MBR-12); and once the click has gone through the page focus rests
1367
+ * on the bar item — without the ring where the input was a pointer — unless the product moved it elsewhere.
1368
+ */
1369
+ activating(item) {
1370
+ if (this.inline)
1371
+ return;
1372
+ if (this.openTitle() || this.current)
1373
+ this.present(null);
1374
+ this.stop = item;
1375
+ this.place();
1376
+ const quiet = this.input === 'pointer';
1377
+ afterClick(() => {
1378
+ const active = deepActive();
1379
+ const moved = !!active && active !== document.body && !this.holds(active);
1380
+ if (!moved && this.visible.includes(item) && this.titleAt(active) !== item)
1381
+ this.focusTitle(item, quiet);
1382
+ });
1383
+ }
1384
+ /** @internal MBR-43: a folded link item's row was activated: its click is heard while the overflow item's menu is still shown, which closes after it (MBR-15). */
1385
+ foldedActivated() {
1386
+ this.closeRequested(OVERFLOW, 'item');
1387
+ }
1388
+ // ── The pointer (MBR-9, MBR-10, MBR-11) ──
1389
+ /** @internal MBR-9, MBR-10: a press or a tap on a title opens its menu, and closes it where it is open, focus staying on the title. */
1390
+ pressed(title) {
1391
+ if (this.disabledTitle(title))
1392
+ return;
1393
+ const quiet = this.input === 'pointer';
1394
+ if (this.openTitle() === title) {
1395
+ this.present(null);
1396
+ this.focusTitle(title, quiet);
1397
+ }
1398
+ else
1399
+ this.present(title, { entry: { end: 'first', quiet } });
1400
+ }
1401
+ /** @internal MBR-11: while a menu is open, a pointer that can hover on another enabled title opens that one at once. */
1402
+ hovered(title) {
1403
+ const open = this.openTitle();
1404
+ if (!open || open === title || this.disabledTitle(title) || this.inline)
1405
+ return;
1406
+ this.present(title, { entry: { end: 'first', quiet: true } });
1407
+ // The overflow item's menu always holds rows; a menu's own takes focus itself, or its title does (present()).
1408
+ }
1409
+ // ── The keys (MBR-9, MBR-12, MBR-13, MBR-14) ──
1410
+ /**
1411
+ * MBR-13: from inside an open menu — or on the title of an open menu that holds no item (MBR-20) — the inline arrow
1412
+ * key closes it and opens the next or the previous enabled title's menu, wrapping, passing over disabled titles,
1413
+ * with focus on its first enabled item and the ring shown. With one enabled title it does nothing.
1414
+ * @internal
1415
+ */
1416
+ travel(from, towardsEnd) {
1417
+ const enabled = this.titles().filter((title) => !this.disabledTitle(title));
1418
+ // A folded menu's own channel is never asked: its items are rows of the overflow item's menu.
1419
+ const at = enabled.indexOf(from === OVERFLOW ? OVERFLOW : this.titleFor(from));
1420
+ if (at < 0 || enabled.length < 2)
1421
+ return;
1422
+ const next = enabled[(at + (towardsEnd ? 1 : -1) + enabled.length) % enabled.length];
1423
+ if (next instanceof TanreiMenubarItem) {
1424
+ // MBR-40: a bar item has no menu to show: it takes focus, with the ring, the open menu closes with its toggle,
1425
+ // and nothing opens or runs. No menu is then open, so the bar's keys go on along the row (MBR-12) and open none.
1426
+ this.stop = next;
1427
+ this.place();
1428
+ this.focusTitle(next, false);
1429
+ this.present(null);
1430
+ return;
1431
+ }
1432
+ this.present(next, { entry: { end: 'first', quiet: false } });
1433
+ }
1434
+ /**
1435
+ * MBR-14, MBR-15: the open menu asks to be closed. Escape returns focus to its title; Tab closes it and lets focus go
1436
+ * on out of the bar, from its title; a press outside the bar and focus leaving it close it and take no focus back; an
1437
+ * item's activation closes it after the item's own event has gone through the page, and returns focus to the title
1438
+ * unless the product moved it meanwhile.
1439
+ * @internal
1440
+ */
1441
+ closeRequested(from, reason) {
1442
+ if (this.inline)
1443
+ return;
1444
+ const title = from === OVERFLOW ? OVERFLOW : this.titleFor(from);
1445
+ if (this.openTitle() !== title)
1446
+ return;
1447
+ if (reason === 'escape' || reason === 'back') {
1448
+ this.present(null);
1449
+ this.focusTitle(title, false);
1450
+ }
1451
+ else if (reason === 'tab') {
1452
+ // Focus goes to the title first — the bar's one Tab stop — so that the key's own move goes on from there, out of
1453
+ // the bar in either direction and never to another title.
1454
+ this.stop = title;
1455
+ this.place();
1456
+ this.focusTitle(title, false);
1457
+ this.present(null);
1458
+ }
1459
+ else if (reason === 'item') {
1460
+ const quiet = this.input === 'pointer';
1461
+ afterClick(() => {
1462
+ if (this.openTitle() !== title)
1463
+ return;
1464
+ const active = deepActive();
1465
+ // MBR-15: focus the product moved elsewhere while handling the item's event stays where it put it.
1466
+ const moved = !!active && active !== document.body && !this.holds(active);
1467
+ this.present(null);
1468
+ if (!moved && this.isConnected)
1469
+ this.focusTitle(title, quiet);
1470
+ });
1471
+ }
1472
+ else
1473
+ this.present(null);
1474
+ }
1475
+ /** MBR-12: focus to the title at `index`, which becomes the Tab stop; nothing opens. */
1476
+ move(titles, index) {
1477
+ const title = index === null ? undefined : titles[index];
1478
+ if (!title)
1479
+ return;
1480
+ this.stop = title;
1481
+ this.place();
1482
+ this.focusTitle(title, false);
1483
+ }
1484
+ // ── The fold (MBR-21, MBR-22, MBR-27) ──
1485
+ /** The row, the copy of every title and of the overflow item, and the gap are observed: any of them may change what fits. */
1486
+ observe() {
1487
+ const resize = this.resize;
1488
+ if (!resize)
1489
+ return;
1490
+ const wanted = new Set(this.renderRoot.querySelectorAll('.bar, .ruler > *'));
1491
+ let fewer = false;
1492
+ for (const element of [...this.sizes.keys()]) {
1493
+ if (wanted.has(element))
1494
+ continue;
1495
+ resize.unobserve(element);
1496
+ this.sizes.delete(element);
1497
+ fewer = true;
1498
+ }
1499
+ // A title that left changes no size the observer watches: what fits is decided from the sizes there are (MBR-30).
1500
+ if (fewer)
1501
+ this.decide();
1502
+ for (const element of wanted) {
1503
+ if (this.sizes.has(element))
1504
+ continue;
1505
+ // Not measured yet: nothing is decided from it until the observer has reported it.
1506
+ this.sizes.set(element, Number.NaN);
1507
+ resize.observe(element);
1508
+ }
1509
+ }
1510
+ /**
1511
+ * MBR-21: what fits, from the sizes the observer reports after a layout — the row's inner inline size, each title's
1512
+ * copy, the overflow item's and the gap — so that deciding it asks the page for no layout of its own. Every title
1513
+ * keeps its size; menus fold from the end, as few as make the rest fit beside the overflow item; where the first
1514
+ * title does not fit beside it, every menu folds.
1515
+ */
1516
+ measured(entries) {
1517
+ for (const entry of entries) {
1518
+ if (!this.sizes.has(entry.target))
1519
+ continue;
1520
+ const bar = entry.target.classList.contains('bar');
1521
+ const box = bar ? entry.contentBoxSize?.[0] : entry.borderBoxSize?.[0];
1522
+ this.sizes.set(entry.target, box ? box.inlineSize : entry.contentRect.width);
1523
+ }
1524
+ this.decide();
1525
+ }
1526
+ /** MBR-21: decides the fold from the sizes reported so far; nothing is decided while one of them is still awaited. */
1527
+ decide() {
1528
+ const size = (selector) => this.sizes.get(this.renderRoot.querySelector(selector)) ?? Number.NaN;
1529
+ const room = size('.bar');
1530
+ const gap = size('.ruler > .gap');
1531
+ const overflow = size('.ruler > .overflow-copy');
1532
+ const titles = [...this.renderRoot.querySelectorAll('.ruler > .menu-copy')].map((copy) => this.sizes.get(copy) ?? Number.NaN);
1533
+ if ([room, gap, overflow, ...titles].some((value) => Number.isNaN(value)) || titles.length !== this.items.length)
1534
+ return;
1535
+ // Half a pixel of slack: a row that fits exactly is laid out from rounded sizes.
1536
+ const fits = (length) => length <= room + 0.5;
1537
+ const all = titles.reduce((sum, width) => sum + width, 0) + gap * Math.max(0, titles.length - 1);
1538
+ let kept = titles.length;
1539
+ if (!fits(all)) {
1540
+ let length = 0;
1541
+ kept = 0;
1542
+ for (let n = 0; n < titles.length - 1; n += 1) {
1543
+ length += titles[n] + gap;
1544
+ if (!fits(length + overflow))
1545
+ break;
1546
+ kept = n + 1;
1547
+ }
1548
+ }
1549
+ this.fold(titles.length - kept);
1550
+ }
1551
+ /**
1552
+ * MBR-21, MBR-22: folds `count` menus from the end, at once. Where that folds or unfolds the menu that is open, or
1553
+ * changes the overflow item's menu while it is shown, it is closed first; focus that was inside it, or on a title
1554
+ * that is no longer drawn, moves to the title the menu is now reached from.
1555
+ */
1556
+ fold(count) {
1557
+ if (count === this.folds)
1558
+ return;
1559
+ const willFold = (menu) => this.items.indexOf(menu) >= this.items.length - count;
1560
+ const open = this.current;
1561
+ const active = deepActive();
1562
+ const onTitle = this.titleAt(active);
1563
+ const inside = !onTitle && this.holds(active) && active !== this;
1564
+ const closing = this.overflowOpen || (!!open && this.folded.includes(open) !== willFold(open));
1565
+ if (closing)
1566
+ this.present(null);
1567
+ // Where focus goes once the row is drawn again: the title its menu is now reached from.
1568
+ let refocus = null;
1569
+ if (closing && inside)
1570
+ refocus = open ? (willFold(open) ? OVERFLOW : open) : count > 0 ? OVERFLOW : (this.items.at(-1) ?? null);
1571
+ else if (onTitle === OVERFLOW && count === 0)
1572
+ refocus = this.items.at(-1) ?? null;
1573
+ else if (onTitle && onTitle !== OVERFLOW && willFold(onTitle))
1574
+ refocus = OVERFLOW;
1575
+ this.folds = count;
1576
+ this.place();
1577
+ if (refocus) {
1578
+ const quiet = this.input === 'pointer';
1579
+ const title = refocus;
1580
+ this.stop = title;
1581
+ void this.updateComplete.then(() => this.focusTitle(title, quiet));
1582
+ }
1583
+ }
1584
+ willUpdate(changed) {
1585
+ if (changed.has('inline'))
1586
+ this.place();
1587
+ }
1588
+ firstUpdated() {
1589
+ this.observe();
1590
+ // An empty bar fires no slotchange: the content is checked once the children had a frame to arrive.
1591
+ requestAnimationFrame(() => {
1592
+ this.settled = true;
1593
+ if (this.isConnected)
1594
+ this.checkContent();
1595
+ });
1596
+ }
1597
+ updated(changed) {
1598
+ // MBR-19: a menubar named by its label, horizontal; each title says the rest about itself.
1599
+ hostAria(this, { role: 'menubar', 'aria-label': this.label || null, 'aria-orientation': 'horizontal' });
1600
+ // MBR-20: a bar without a label still renders and works; a debug build says it has no name.
1601
+ if (changed.has('label') && !this.label.trim())
1602
+ report(this, 'MBR-20', 'label is empty, so the menubar has no accessible name; give it a label ("Application menu")');
1603
+ // MBR-21, MBR-22: the menus in the row and the folded ones, each where it is drawn now, none of them moved.
1604
+ const row = this.renderRoot.querySelector('slot.row');
1605
+ const visible = this.visible;
1606
+ if (row) {
1607
+ const now = row.assignedNodes();
1608
+ if (now.length !== visible.length || now.some((node, i) => node !== visible[i]))
1609
+ row.assign(...visible);
1610
+ }
1611
+ assignEach(this.renderRoot.querySelectorAll('.overflow > tanrei-menu > slot'), this.folded);
1612
+ const menu = this.overflowMenu;
1613
+ if (menu)
1614
+ menu.positionAnchor = this.overflowElement?.querySelector('.container') ?? null;
1615
+ this.observe();
1616
+ // MBR-22: without a name the overflow item is drawn and works, is exposed unnamed, and the missing word is reported once.
1617
+ if (this.folds > 0 && !this.words.get('menubarOverflowLabel', this.overflowLabel)) {
1618
+ this.words.missing('menubarOverflowLabel', { prop: 'overflowLabel', id: 'MBR-22', effect: 'the overflow item is drawn and works, and has no accessible name' });
1619
+ }
1620
+ }
1621
+ /** The copy of a title the fold is measured from: the same boxes, drawn by the same rules, never shown. */
1622
+ copy(content, kind, glyph = false) {
1623
+ return html `<span class="title ${kind}"><span class=${classMap({ container: true, glyph })}><span class="content">${content}</span></span></span>`;
1624
+ }
1625
+ render() {
1626
+ const titles = this.titles();
1627
+ const name = this.words.get('menubarOverflowLabel', this.overflowLabel);
1628
+ const glyph = html `<span part="icon" class="icon" aria-hidden="true"><span class="ink">${OVERFLOW_GLYPH}</span></span>`;
1629
+ // MBR-21, MBR-22: the overflow item is drawn only while something is folded — a title in every respect, its menu
1630
+ // the folded menus, each the submenu item it draws of itself.
1631
+ const overflow = this.folds > 0
1632
+ ? html `<div
1633
+ part="overflow-item"
1634
+ class="overflow"
1635
+ role="menuitem"
1636
+ aria-haspopup="menu"
1637
+ aria-expanded=${String(this.overflowOpen)}
1638
+ aria-label=${name || nothing}
1639
+ aria-posinset=${titles.length}
1640
+ aria-setsize=${titles.length}
1641
+ tabindex=${this.stopNow() === OVERFLOW ? '0' : '-1'}
1642
+ @keydown=${this.onOverflowKeyDown}
1643
+ @keyup=${this.onOverflowKeyUp}
1644
+ @click=${this.onOverflowClick}
1645
+ >
1646
+ <span
1647
+ class=${classMap({ title: true, p: true, expanded: this.overflowOpen, pf: this.overflowQuiet })}
1648
+ @pointerdown=${this.press.onPointerDown}
1649
+ @pointerup=${this.press.release}
1650
+ @pointercancel=${this.press.release}
1651
+ @pointerleave=${this.press.release}
1652
+ @pointerenter=${this.onOverflowEnter}
1653
+ ><span part="container" class="container glyph" data-tanrei-shape><span class="content">${glyph}</span></span></span
1654
+ ><tanrei-menu class="menu" aria-label=${name || nothing} .bar=${this.overflowChannel} .open=${this.overflowOpen} ?inline=${this.inline && this.overflowOpen} @close=${this.onOverflowClose}
1655
+ >${this.folded.map(() => html `<slot></slot>`)}</tanrei-menu
1656
+ >
1657
+ </div>`
1658
+ : nothing;
1659
+ return html `<div part="bar" class="bar"><slot class="row"></slot>${overflow}</div>
1660
+ <div class="ruler" aria-hidden="true">
1661
+ ${this.items.map((row) => row instanceof TanreiMenubarItem
1662
+ ? this.copy(html `<span class="label">${row.label}</span>${row.marked ? html `<span class="icon"><span class="ink">${LINK_MARK}</span></span>` : nothing}`, row.isCurrent ? 'menu-copy current' : 'menu-copy')
1663
+ : this.copy(html `<span class="label">${row.label}</span>`, 'menu-copy'))}${this.copy(html `<span class="icon"><span class="ink">${OVERFLOW_GLYPH}</span></span>`, 'overflow-copy apart', true)}<span class="gap apart"></span>
1664
+ </div>`;
1665
+ }
1666
+ }
1667
+ /** MBR-32: whether a child of the bar is one of its entries. */
1668
+ function isRow(child) {
1669
+ return child instanceof TanreiMenubarMenu || child instanceof TanreiMenubarItem;
1670
+ }
1671
+ if (!customElements.get('tanrei-menubar-menu'))
1672
+ customElements.define('tanrei-menubar-menu', TanreiMenubarMenu);
1673
+ if (!customElements.get('tanrei-menubar-item'))
1674
+ customElements.define('tanrei-menubar-item', TanreiMenubarItem);
1675
+ if (!customElements.get('tanrei-menubar'))
1676
+ customElements.define('tanrei-menubar', TanreiMenubar);
1677
+ //# sourceMappingURL=menubar.js.map