@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,2061 @@
1
+ import { LitElement, html, nothing } from 'lit';
2
+ import { hiddenHost } from '../../primitives/hidden.js';
3
+ import { classMap } from 'lit/directives/class-map.js';
4
+ import { html as staticHtml, literal } from 'lit/static-html.js';
5
+ import { AvailabilityController, FollowController, GlyphDrawnController, GlyphMirrorController, LINK_MARK, LinkController, PressController, RovingKeys, SEPARATION_VALUES, SHORTCUT_UPDATE, SystemWatchController, chordsConverter, chordsOf, compChoice, deepActive, hostAria, linkAttributes, layoutSize, naturalHeight, notifyItemUpdate, registerOverlay, report, styleQueries, syncFocusStyle, syncSeparation, } from '../../primitives/index.js';
6
+ // MNU-31: an item draws its shortcut with the keyboard shortcut, which the menu defines wherever it is imported.
7
+ import '../keyboard-shortcut/keyboard-shortcut.js';
8
+ import { groupStyles, itemStyles, menuStyles, submenuStyles } from './menu.styles.js';
9
+ const PLACEMENTS = ['bottom-start', 'bottom-end', 'top-start', 'top-end'];
10
+ /** MNU-38: the design system's choice of mark for each kind of item; the first value is what an unknown name draws. */
11
+ const MARK_CHOICES = {
12
+ checkbox: { property: '--tanrei-comp-menu-checkbox-item-mark', values: ['checkbox', 'check'] },
13
+ radio: { property: '--tanrei-comp-menu-radio-item-mark', values: ['radio', 'check'] },
14
+ };
15
+ /** MNU-22, MNU-39: the icon set's check, by its name. MNU-42: the submenu indicator. */
16
+ const CHECK = 'check';
17
+ const SUBMENU_INDICATOR = 'chevron_right';
18
+ /** MNU-31: `comp.menu.shortcut.variant`, the form an item's shortcut is drawn in. */
19
+ const SHORTCUT_VARIANT = '--tanrei-comp-menu-shortcut-variant';
20
+ /** The keyboard shortcut's default form, which an empty choice falls back to. */
21
+ const DEFAULT_SHORTCUT_VARIANT = 'keycap';
22
+ /**
23
+ * Where the surface goes (MNU-2): `offset` from the anchor on the placement's side, flipped to the other side when this
24
+ * one has less room than the surface needs within `margin` of the viewport's edge and the other has more; aligned by its
25
+ * start or end edge with the anchor's (mirrored in right-to-left), then shifted along the anchor to stay `margin` inside
26
+ * the viewport; its height limited to the room left. Coordinates are the viewport's (`left` is physical).
27
+ */
28
+ export function placeMenu(input) {
29
+ const { anchor, surface, viewport, placement, offset, margin, rtl } = input;
30
+ let side = placement.startsWith('top') ? 'top' : 'bottom';
31
+ const edge = placement.endsWith('end') ? 'end' : 'start';
32
+ const below = viewport.height - margin - (anchor.y + anchor.height + offset);
33
+ const above = anchor.y - offset - margin;
34
+ if (side === 'bottom' && below < surface.height && above > below)
35
+ side = 'top';
36
+ else if (side === 'top' && above < surface.height && below > above)
37
+ side = 'bottom';
38
+ const room = Math.max(0, side === 'bottom' ? below : above);
39
+ const height = Math.min(surface.height, room);
40
+ const top = side === 'bottom' ? anchor.y + anchor.height + offset : anchor.y - offset - height;
41
+ // The start edge is the left one in left-to-right.
42
+ const alignLeft = (edge === 'start') !== rtl;
43
+ const wanted = alignLeft ? anchor.x : anchor.x + anchor.width - surface.width;
44
+ const left = Math.max(margin, Math.min(wanted, viewport.width - margin - surface.width));
45
+ return { top, left, maxHeight: room, side };
46
+ }
47
+ /**
48
+ * Where a submenu's surface goes (MNU-46, MNU-47): beside the surface that holds its item (`parent`), `offset` from that
49
+ * surface's inline-end edge — or from the side `prefer` names, the side its parent surface was itself placed on — and on
50
+ * the other side when this one has less room than the surface needs within `margin` of the viewport's edge and the
51
+ * other has more. Where the side it is on has room for `minWidth` but not for the surface, the surface is narrowed to
52
+ * the room. Where neither side has room for `minWidth` it is laid over `parent`: on the side with more room, as far
53
+ * towards it as the margin allows, as wide as leaves `touch` of the parent uncovered on its other side and never
54
+ * narrower than `minWidth`. Its first row (`lead` below its own block-start edge) is level with the item's `row`, then
55
+ * it is shifted along the block axis to stay `margin` inside the viewport, its height limited to the room.
56
+ * Coordinates are the viewport's (`left` and `side` are physical).
57
+ */
58
+ export function placeSubmenu(input) {
59
+ const { parent, row, surface, lead, viewport, offset, margin, minWidth, touch, rtl, prefer } = input;
60
+ const rooms = { right: viewport.width - margin - (parent.x + parent.width + offset), left: parent.x - offset - margin };
61
+ let side = prefer ?? (rtl ? 'left' : 'right');
62
+ const other = side === 'right' ? 'left' : 'right';
63
+ if (rooms[side] < surface.width && rooms[other] > rooms[side])
64
+ side = other;
65
+ let width = surface.width;
66
+ let left;
67
+ const overlap = rooms[side] < Math.min(minWidth, surface.width);
68
+ if (overlap) {
69
+ // MNU-47: over the parent, from the viewport's margin on that side back towards the parent's far edge.
70
+ const edge = side === 'right' ? viewport.width - margin : margin;
71
+ const kept = side === 'right' ? parent.x + touch : parent.x + parent.width - touch;
72
+ const free = side === 'right' ? edge - kept : kept - edge;
73
+ width = Math.min(Math.max(minWidth, Math.min(surface.width, free)), Math.max(0, viewport.width - 2 * margin));
74
+ left = side === 'right' ? edge - width : edge;
75
+ }
76
+ else {
77
+ width = Math.min(surface.width, rooms[side]);
78
+ left = side === 'right' ? parent.x + parent.width + offset : parent.x - offset - width;
79
+ }
80
+ const room = Math.max(0, viewport.height - 2 * margin);
81
+ const height = Math.min(surface.height, room);
82
+ const top = Math.max(margin, Math.min(row.y - lead, viewport.height - margin - height));
83
+ return { top, left, width, maxHeight: room, side, overlap };
84
+ }
85
+ /** Whether `p` lies in the triangle `a`, `b`, `c` (its edges included). MNU-45: the pointer's path to a submenu. */
86
+ export function inTriangle(p, a, b, c) {
87
+ const cross = (u, v, w) => (u.x - w.x) * (v.y - w.y) - (v.x - w.x) * (u.y - w.y);
88
+ const d1 = cross(p, a, b);
89
+ const d2 = cross(p, b, c);
90
+ const d3 = cross(p, c, a);
91
+ return !((d1 < 0 || d2 < 0 || d3 < 0) && (d1 > 0 || d2 > 0 || d3 > 0));
92
+ }
93
+ // ── The items ─────────────────────────────────────────────────────────────────────────────────────────────────────
94
+ /** The properties of a row that are the element's own business: a change of one is not told to the menu. */
95
+ const INTERNAL = new Set(['context', 'pointerFocused', 'presented', 'blocks']);
96
+ /** 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). */
97
+ function assignBlocks(root, blocks) {
98
+ const slots = root.querySelectorAll('slot');
99
+ blocks.forEach((block, i) => {
100
+ const slot = slots[i];
101
+ if (slot && (slot.assignedNodes().length !== 1 || slot.assignedNodes()[0] !== block))
102
+ slot.assign(block);
103
+ });
104
+ }
105
+ /**
106
+ * What an element forwarded into a menu stands for, where that is not itself: a function, under this key, that returns
107
+ * the rows it draws for the menu in its own shadow root. A menubar's menu that is folded into the overflow item draws
108
+ * itself there as a submenu item (MBR-22). Internal between Tanrei elements.
109
+ * @internal
110
+ */
111
+ export const FORWARDED_ROWS = Symbol.for('tanrei.menu.forwarded-rows');
112
+ /** The elements a block of a surface stands for: a forwarding `<slot>` stands for what is assigned to it. */
113
+ const resolved = (block) => block instanceof HTMLSlotElement ? block.assignedElements({ flatten: true }).flatMap((element) => element[FORWARDED_ROWS]?.() ?? [element]) : [block];
114
+ /**
115
+ * The blocks of a surface (the menu's, a submenu's), each in a slot of its own, and between a group and what is next to
116
+ * it the two forms of the separation: the divider (MNU-23), a separator, and the gap (MNU-36), empty space that is
117
+ * nothing to assistive technology. The surface's styles draw the one its separation names (MNU-35), so a change of the
118
+ * attribute or of the token is followed without a render.
119
+ */
120
+ function blocksTemplate(blocks) {
121
+ // A forwarding slot is drawn as what is assigned to it: a group at its start or end is a group there.
122
+ const group = (element, edge) => {
123
+ const elements = element ? resolved(element) : [];
124
+ return (edge === 'first' ? elements[0] : elements.at(-1)) instanceof TanreiMenuGroup;
125
+ };
126
+ return blocks.map((block, i) => html `${i > 0 && (group(blocks[i - 1], 'last') || group(block, 'first'))
127
+ ? html `<div part="divider" class="divider" role="separator"></div><div class="gap"></div>`
128
+ : nothing}<slot></slot>`);
129
+ }
130
+ /**
131
+ * What every row of a menu is (the spec's `item`, `checkbox-item`, `radio-item` and `submenu` kinds): a label, optional
132
+ * supporting text, a leading icon and trailing text. The host carries the row's semantics and takes focus — except a
133
+ * link item (MNU-53), whose row is the browser's own link: the anchor in its shadow root carries them, and the host is
134
+ * nothing to assistive technology. The menu moves focus among the rows of a surface, tells each its position, the
135
+ * surface's size and which columns the surface reserves, and answers its activation.
136
+ */
137
+ export class TanreiMenuRowBase extends LitElement {
138
+ static { this.styles = [itemStyles, hiddenHost]; }
139
+ static { this.properties = {
140
+ label: { type: String },
141
+ supportingText: { type: String, attribute: 'supporting-text' },
142
+ leadingIcon: { type: String, attribute: 'leading-icon' },
143
+ trailingText: { type: String, attribute: 'trailing-text' },
144
+ disabled: { type: Boolean, reflect: true },
145
+ context: { state: true },
146
+ pointerFocused: { state: true },
147
+ }; }
148
+ /** MNU-18: the condition the item is drawn from. */
149
+ get condition() {
150
+ return 'unselected';
151
+ }
152
+ /** Whether a checkbox or radio item is checked (always false for an action). */
153
+ get isChecked() {
154
+ return false;
155
+ }
156
+ /** MNU-38: which control a checkbox or radio item is marked as, where its mark is a control look; null for a kind that has no mark. */
157
+ get markKind() {
158
+ return null;
159
+ }
160
+ /** MNU-38: the glyph the item itself names for its mark. */
161
+ get ownMarkIcon() {
162
+ return '';
163
+ }
164
+ /** MNU-31: the chords of the item's shortcut; a kind without one has none. */
165
+ get shortcutKeys() {
166
+ return [];
167
+ }
168
+ /** MNU-21: the product's glyph at the end of the row; a kind without one has none. */
169
+ get trailingGlyph() {
170
+ return '';
171
+ }
172
+ /** MNU-42: whether the row ends in the submenu indicator. */
173
+ get opensSubmenu() {
174
+ return false;
175
+ }
176
+ /** MNU-24: what the kind adds to the host's semantics. */
177
+ kindAria() {
178
+ return {};
179
+ }
180
+ /** MNU-53: the link the item is now — its row is then an anchor that carries its semantics and takes its focus. Null for every kind but an item with a destination. */
181
+ get linkForm() {
182
+ return null;
183
+ }
184
+ /** MNU-57: what the kind is, where it takes no destination ("a checkbox item"); null for the kind that takes one. */
185
+ get holds() {
186
+ return null;
187
+ }
188
+ /**
189
+ * @internal Whether the row draws a link's mark in its trailing icon column (MNU-55): a link item that opens a new
190
+ * context and names no trailing icon of its own. The menu reserves the column for its surface then (MNU-19).
191
+ */
192
+ get linkMarked() {
193
+ return !!this.linkForm?.opensNew && !this.trailingGlyph && !this.opensSubmenu;
194
+ }
195
+ /** The element that takes the item's focus and carries its semantics: the anchor of a link item (MNU-53), else the host. */
196
+ get focusTarget() {
197
+ return (this.linkForm && this.rowElement) || this;
198
+ }
199
+ /** @internal Whether the item itself — its host, or the anchor of a link item — is where `event` came from (not something inside it, such as a submenu's surface). */
200
+ isTargetOf(event) {
201
+ const target = event.composedPath()[0];
202
+ return target === this || (!!this.linkForm && target === this.rowElement);
203
+ }
204
+ /** Whether the item has focus: its host, or the anchor of a link item. */
205
+ get focused() {
206
+ return this.matches(':focus') || this.shadowRoot?.activeElement === this.rowElement;
207
+ }
208
+ /** Focus goes to the element that is the item: the host, or the anchor of a link item (MNU-53). */
209
+ focus(options) {
210
+ const target = this.focusTarget;
211
+ if (target === this)
212
+ super.focus(options);
213
+ else
214
+ target.focus(options);
215
+ }
216
+ constructor() {
217
+ super();
218
+ /** The item's text and its accessible name. Required. */
219
+ this.label = '';
220
+ /** A line below the label that says more about the item; it is the item's description. */
221
+ this.supportingText = '';
222
+ /** The name of a glyph of the system's icon set before the label. A glyph the icon set flags as showing a direction (`arrow_forward`, `send`) is drawn mirrored in a right-to-left layout. */
223
+ this.leadingIcon = '';
224
+ /**
225
+ * Text at the end of the row that is not a keyboard shortcut, such as a count or "Beta": it is the item's description,
226
+ * never its keyboard shortcut. An item's shortcut goes in `shortcut`; an item that has both draws the shortcut.
227
+ */
228
+ this.trailingText = '';
229
+ /** Prevents activation. The item stays reachable with the arrow keys. */
230
+ this.disabled = false;
231
+ /** What the menu says about this item. */
232
+ this.context = {
233
+ position: 0,
234
+ size: 0,
235
+ markColumn: false,
236
+ iconColumn: false,
237
+ trailingIconColumn: false,
238
+ radioChecked: false,
239
+ shortcutVariant: DEFAULT_SHORTCUT_VARIANT,
240
+ groupMarkIcon: '',
241
+ };
242
+ /** MNU-8: focus the pointer moved here, which draws no focus ring. */
243
+ this.pointerFocused = false;
244
+ /**
245
+ * MNU-30: a glyph the menu draws — the check of a mark, the check in a checked box, a named mark, the submenu
246
+ * indicator — carries `data-drawn` while the icon set can draw it rather than spell its name in a fallback face. Its
247
+ * ink — the glyph's name at its own width — is watched for any change of size: the icon face loading or failing, the
248
+ * family changing with the system, the menu opening.
249
+ */
250
+ this.glyphs = new GlyphDrawnController(this, () => this.renderRoot?.querySelectorAll('.check, .submenu-indicator, .link-mark') ?? []);
251
+ /**
252
+ * MNU-33: the leading and trailing glyphs, the glyph a `mark-icon` names and the submenu indicator are marked when the
253
+ * icon set mirrors their names in right-to-left (`arrow_right`, `chevron_right`, `undo`), and `iconGlyph()` draws the
254
+ * mark. The check (MNU-22, MNU-39) is not among them: it is never mirrored.
255
+ */
256
+ this.mirror = new GlyphMirrorController(this, { drawn: '.leading-icon, .trailing-icon, .check.named' });
257
+ /** @internal How the activation being dispatched came: a Space keeps a checkbox or radio item's menu open (MNU-6). */
258
+ this.activation = 'pointer';
259
+ /** MNU-15 / MNU-16: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
260
+ this.press = new PressController(this, {
261
+ container: () => this.rowElement,
262
+ holdCarrier: () => this.renderRoot.querySelector('.text'),
263
+ disabled: () => this.disabled,
264
+ });
265
+ this.spaceDown = false;
266
+ /** Whether the item had focus before a render that may replace the element that holds it (a row that becomes a link, or stops being one). */
267
+ this.hadFocus = false;
268
+ /** Enter activates on key-down and Space on key-up, as a native button does. */
269
+ this.onKeyDown = (event) => {
270
+ if (!this.isTargetOf(event))
271
+ return;
272
+ if (event.key === ' ')
273
+ event.preventDefault(); // Space would scroll the surface.
274
+ if (this.disabled)
275
+ return;
276
+ this.press.onKeyDown(event);
277
+ if (event.key === 'Enter') {
278
+ // MNU-54: Enter on a link item is the browser's own — it fires the anchor's click and follows the link, with a
279
+ // modifier key in another tab or window — so nothing is prevented or replaced; a held key activates once.
280
+ if (this.linkForm) {
281
+ if (event.repeat)
282
+ event.preventDefault();
283
+ return;
284
+ }
285
+ event.preventDefault();
286
+ if (!event.repeat)
287
+ this.activate('enter');
288
+ }
289
+ else if (event.key === ' ')
290
+ this.spaceDown = true;
291
+ };
292
+ this.onKeyUp = (event) => {
293
+ if (!this.isTargetOf(event))
294
+ return;
295
+ this.press.onKeyUp(event);
296
+ if (event.key !== ' ' || !this.spaceDown)
297
+ return;
298
+ this.spaceDown = false;
299
+ // MNU-54: Space activates a link item as Enter does — with the anchor's own click — unless a modifier key is down.
300
+ if (this.linkForm && (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey))
301
+ return;
302
+ if (!this.disabled)
303
+ this.activate('space');
304
+ };
305
+ /** MNU-17: where style queries are missing, the focus style is read when focus arrives. */
306
+ this.onFocusIn = (event) => {
307
+ if (this.isTargetOf(event))
308
+ syncFocusStyle(this, this.focusTarget);
309
+ };
310
+ this.onFocusOut = (event) => {
311
+ if (!this.isTargetOf(event))
312
+ return;
313
+ this.pointerFocused = false;
314
+ this.spaceDown = false;
315
+ this.press.onBlur();
316
+ };
317
+ // MNU-9: a disabled item swallows every click that reaches it, from its content or dispatched on it.
318
+ this.addEventListener('click', (event) => {
319
+ if (this.disabled) {
320
+ event.preventDefault();
321
+ event.stopImmediatePropagation();
322
+ }
323
+ }, { capture: true });
324
+ this.addEventListener('keydown', this.onKeyDown);
325
+ this.addEventListener('keyup', this.onKeyUp);
326
+ this.addEventListener('focusin', this.onFocusIn);
327
+ this.addEventListener('focusout', this.onFocusOut);
328
+ }
329
+ connectedCallback() {
330
+ super.connectedCallback();
331
+ // MNU-7: every item takes focus from the menu (arrow keys, the pointer) and none is a Tab stop (Tab closes the menu).
332
+ // A link item's anchor takes it instead (MNU-53).
333
+ if (!this.linkForm && !this.hasAttribute('tabindex'))
334
+ this.setAttribute('tabindex', '-1');
335
+ }
336
+ /** @internal The row in the surface that holds the item. */
337
+ get rowElement() {
338
+ return this.renderRoot?.querySelector('.row') ?? null;
339
+ }
340
+ /** @internal The menu's side: the item's position, its surface's size, the columns and a radio item's checked. */
341
+ setMenuContext(context) {
342
+ const now = this.context;
343
+ if (Object.keys(context).every((key) => context[key] === now[key]))
344
+ return;
345
+ this.context = context;
346
+ }
347
+ /** @internal MNU-8: the pointer moved onto the item — focus follows it, without the focus ring. */
348
+ focusFromPointer() {
349
+ if (this.focused)
350
+ return;
351
+ this.pointerFocused = true;
352
+ this.focus({ preventScroll: true });
353
+ }
354
+ /**
355
+ * @internal MNU-45: the pointer crosses the item on its way to an open submenu — it is not drawn hovered. Written on
356
+ * the row at once, not in a render: the pointer is already over it.
357
+ */
358
+ suppressHover(suppress) {
359
+ this.rowElement?.toggleAttribute('data-nh', suppress);
360
+ }
361
+ /**
362
+ * @internal MNU-38: where a browser has no style container queries, the mark the design system chooses is read from
363
+ * the cascade and written on the mark column; where it has them nothing is written (an attribute could only go stale).
364
+ */
365
+ syncMark() {
366
+ const mark = this.renderRoot?.querySelector('.mark');
367
+ const kind = this.markKind;
368
+ if (!mark || !kind)
369
+ return;
370
+ if (styleQueries())
371
+ delete mark.dataset.mark;
372
+ else
373
+ mark.dataset.mark = compChoice(this, MARK_CHOICES[kind].property, MARK_CHOICES[kind].values);
374
+ }
375
+ /**
376
+ * The click that activates the item: on the host, which the menu answers — or, for a link item, the anchor's own, so
377
+ * that the browser follows the link after it unless it was cancelled (MNU-54).
378
+ */
379
+ send() {
380
+ const target = this.focusTarget;
381
+ if (target === this)
382
+ super.click();
383
+ else
384
+ target.click();
385
+ }
386
+ /** `element.click()` activates the item as a pointer would; a disabled item does nothing (MNU-9). */
387
+ click() {
388
+ if (this.disabled)
389
+ return;
390
+ this.activation = 'pointer';
391
+ this.send();
392
+ }
393
+ /** MNU-6: the activation is a click on the host, which the menu answers; `via` says how it came. */
394
+ activate(via) {
395
+ this.activation = via;
396
+ try {
397
+ this.send();
398
+ }
399
+ finally {
400
+ this.activation = 'pointer';
401
+ }
402
+ }
403
+ /** MNU-31: whether the item draws a keyboard shortcut (in place of its trailing text). */
404
+ get hasShortcut() {
405
+ return this.shortcutKeys.length > 0;
406
+ }
407
+ /** MNU-38: the glyph the mark is, where the item or its group names one; empty where the design system chooses. */
408
+ get markIconName() {
409
+ return this.markKind ? this.ownMarkIcon.trim() || this.context.groupMarkIcon.trim() : '';
410
+ }
411
+ /**
412
+ * MNU-24: named by the label; described by the supporting text and by the trailing text it draws — never read as a
413
+ * shortcut; its shortcut is `aria-keyshortcuts`, in the form the keyboard shortcut it draws gives (KBS-12).
414
+ */
415
+ semantics() {
416
+ const drawn = this.renderRoot.querySelector('tanrei-keyboard-shortcut');
417
+ const shortcut = this.hasShortcut && drawn ? drawn.ariaKeyShortcuts : null;
418
+ // MNU-55: a link item that opens a new context says so last.
419
+ const description = [this.supportingText, this.hasShortcut ? '' : this.trailingText, this.linkForm?.targetLabel ?? ''].filter(Boolean).join(', ');
420
+ return { shortcut, description };
421
+ }
422
+ willUpdate(_changed) {
423
+ this.hadFocus = this.hasUpdated && this.focused;
424
+ }
425
+ firstUpdated() {
426
+ // KBS-12, MNU-24: the shortcut's keys changed without the item (an ancestor's keyboard convention): expose them again.
427
+ this.renderRoot.addEventListener(SHORTCUT_UPDATE, () => this.requestUpdate());
428
+ }
429
+ updated(changed) {
430
+ const { shortcut, description } = this.semantics();
431
+ const semantics = {
432
+ role: this.itemRole,
433
+ 'aria-checked': this.markKind ? String(this.isChecked) : null,
434
+ 'aria-disabled': this.disabled ? 'true' : null,
435
+ 'aria-label': this.label || null,
436
+ 'aria-description': description || null,
437
+ 'aria-keyshortcuts': shortcut,
438
+ 'aria-posinset': this.context.position ? String(this.context.position) : null,
439
+ 'aria-setsize': this.context.size ? String(this.context.size) : null,
440
+ ...this.kindAria(),
441
+ };
442
+ // MNU-53: a link item is exposed once, on its anchor — the menu item role with everything a menu item says; the
443
+ // role and the disabled state there are the link primitive's (`linkAttributes()`). The host is then nothing: no
444
+ // role, no name, and not focusable itself.
445
+ const anchor = this.linkForm ? this.rowElement : null;
446
+ const none = Object.fromEntries(Object.keys(semantics).map((name) => [name, null]));
447
+ if (anchor) {
448
+ const { role: _role, 'aria-disabled': _disabled, ...own } = semantics;
449
+ hostAria(anchor, own);
450
+ }
451
+ hostAria(this, anchor ? none : semantics);
452
+ // MNU-7: every item takes focus from the menu (arrow keys, the pointer) and none is a Tab stop — the host, or the
453
+ // anchor of a link item (its `tabindex` is in the template).
454
+ const wasHost = this.matches(':focus') && !this.shadowRoot?.activeElement;
455
+ if (anchor) {
456
+ if (this.getAttribute('tabindex') === '-1') {
457
+ // Focus the host held moves to the anchor before the host stops taking it.
458
+ if (wasHost)
459
+ anchor.focus({ preventScroll: true });
460
+ this.removeAttribute('tabindex');
461
+ }
462
+ }
463
+ else if (!this.hasAttribute('tabindex'))
464
+ this.setAttribute('tabindex', '-1');
465
+ // The row was replaced under focus (an item that became a link, or stopped being one): focus stays on the item.
466
+ if (this.hadFocus && !this.focused)
467
+ this.focus({ preventScroll: true });
468
+ this.hadFocus = false;
469
+ // MNU-57: a kind that holds a state, or opens another level, takes no destination; one written on it is ignored.
470
+ const held = this.holds;
471
+ if (held && this.getAttribute('href')?.trim()) {
472
+ report(this, 'MNU-57', `${held} cannot be a link: a control that holds a state, or a second action, is not a destination; href, target and targetLabel are ignored`);
473
+ }
474
+ this.syncMark();
475
+ // MNU-26: an item without a label still renders; a debug build says it has no name.
476
+ if (changed.has('label') && !this.label.trim())
477
+ report(this, 'MNU-26', 'label is empty, so the item has no accessible name; give it a label');
478
+ // MNU-31: a shortcut and trailing text both given draw the shortcut, and a debug build says so.
479
+ if (this.hasShortcut && this.trailingText && [...changed.keys()].some((key) => key === 'shortcut' || key === 'trailingText')) {
480
+ report(this, 'MNU-31', `the item "${this.label}" has both a shortcut and trailing text; the shortcut is drawn and the trailing text is not`);
481
+ }
482
+ if (changed.has('disabled') && this.disabled)
483
+ this.spaceDown = false;
484
+ // The menu re-reads its items when a prop it depends on changes (columns, conditions, typeahead, a submenu's open);
485
+ // an internal event, kept out of the item's public API.
486
+ if (this.hasUpdated && [...changed.keys()].some((key) => !INTERNAL.has(key)))
487
+ notifyItemUpdate(this, 'tanrei-menu-item-update');
488
+ }
489
+ /**
490
+ * MNU-22, MNU-38 … MNU-40: the mark column. A glyph the item or its group names is that glyph alone; otherwise the
491
+ * column holds both of the design system's choices — the control look of the kind (a box with the icon set's check on
492
+ * it, or a ring with its fill) and the icon set's check — and the styles draw the one the choice token names.
493
+ */
494
+ renderMark() {
495
+ const kind = this.markKind;
496
+ if (!kind)
497
+ return nothing;
498
+ const named = this.markIconName;
499
+ if (named)
500
+ return html `<span class="check named"><span class="check-ink">${named}</span></span>`;
501
+ return html `${kind === 'checkbox'
502
+ ? html `<span class="control box" data-tanrei-shape><span class="check box-check"><span class="check-ink">${CHECK}</span></span></span>`
503
+ : html `<span class="control ring" data-tanrei-shape><span class="fill"></span></span>`}<span class="check system"><span class="check-ink">${CHECK}</span></span>`;
504
+ }
505
+ renderRow() {
506
+ const condition = this.condition;
507
+ const kind = this.markKind;
508
+ const markColumn = this.context.markColumn || !!kind;
509
+ const iconColumn = this.context.iconColumn || !!this.leadingIcon;
510
+ const trailingGlyph = this.trailingGlyph;
511
+ // MNU-55: a link item that opens a new context ends in the icon set's mark where the product named no glyph there.
512
+ const marked = this.linkMarked;
513
+ const trailingIconColumn = this.context.trailingIconColumn || !!trailingGlyph || this.opensSubmenu || marked;
514
+ // MNU-53: with a destination the same row is an anchor — the same classes, parts and listeners, so every state is
515
+ // drawn from the same tokens — whose address, target, rel, role (the menu item's) and disabled form are the link
516
+ // primitive's. It takes the item's focus (`tabindex`, never a Tab stop) and its semantics (`updated()`).
517
+ const link = this.linkForm;
518
+ const tag = link ? literal `a` : literal `div`;
519
+ return staticHtml `
520
+ <${tag}
521
+ part="container"
522
+ ${linkAttributes(link)}
523
+ tabindex=${link ? '-1' : nothing}
524
+ class=${classMap({
525
+ row: true,
526
+ p: true,
527
+ d: this.disabled,
528
+ pf: this.pointerFocused,
529
+ selected: condition === 'selected',
530
+ destructive: condition === 'destructive',
531
+ expanded: condition === 'expanded',
532
+ checked: this.isChecked,
533
+ })}
534
+ data-tanrei-shape
535
+ @pointerdown=${this.press.onPointerDown}
536
+ @pointerup=${this.press.release}
537
+ @pointercancel=${this.press.release}
538
+ @pointerleave=${this.press.release}
539
+ >
540
+ <span class="content">
541
+ ${markColumn ? html `<span part="mark" class=${classMap({ column: true, mark: true, checkbox: kind === 'checkbox', radio: kind === 'radio' })} aria-hidden="true">${this.renderMark()}</span>` : nothing}
542
+ ${iconColumn
543
+ ? html `<span class="column leading"><span part="leading-icon" class=${classMap({ 'leading-icon': true, empty: !this.leadingIcon })} aria-hidden="true">${this.leadingIcon}</span></span>`
544
+ : nothing}
545
+ <span class="text">
546
+ <span part="label" class="label">${this.label}</span>
547
+ ${this.supportingText ? html `<span part="supporting-text" class="supporting">${this.supportingText}</span>` : nothing}
548
+ </span>
549
+ ${this.hasShortcut
550
+ ? html `<span class="column trailing"
551
+ ><tanrei-keyboard-shortcut
552
+ part="shortcut"
553
+ class="shortcut"
554
+ .keys=${this.shortcutKeys}
555
+ .hosted=${true}
556
+ size="small"
557
+ variant=${this.context.shortcutVariant}
558
+ ?disabled=${this.disabled}
559
+ ></tanrei-keyboard-shortcut
560
+ ></span>`
561
+ : this.trailingText
562
+ ? html `<span class="column trailing"><span part="trailing-text" class="trailing-text">${this.trailingText}</span></span>`
563
+ : nothing}
564
+ ${this.opensSubmenu
565
+ ? html `<span class="column trailing-icon-column"
566
+ ><span part="submenu-indicator" class="trailing-icon submenu-indicator" aria-hidden="true"><span class="ink">${SUBMENU_INDICATOR}</span></span></span
567
+ >`
568
+ : marked
569
+ ? html `<span class="column trailing-icon-column"
570
+ ><span part="trailing-icon link-mark" class="trailing-icon link-mark" aria-hidden="true"><span class="ink">${LINK_MARK}</span></span></span
571
+ >`
572
+ : trailingIconColumn
573
+ ? html `<span class=${classMap({ column: true, 'trailing-icon-column': true, reserved: !trailingGlyph })}
574
+ ><span part="trailing-icon" class=${classMap({ 'trailing-icon': true, empty: !trailingGlyph })} aria-hidden="true">${trailingGlyph}</span></span
575
+ >`
576
+ : nothing}
577
+ </span>
578
+ </${tag}>
579
+ `;
580
+ }
581
+ render() {
582
+ return this.renderRow();
583
+ }
584
+ }
585
+ /**
586
+ * What an item that is not a submenu is (the spec's `item`, `checkbox-item` and `radio-item` kinds): a row that may also
587
+ * end in a keyboard shortcut and a trailing icon; the mark of a checkbox or radio item is in the mark column.
588
+ */
589
+ export class TanreiMenuItemBase extends TanreiMenuRowBase {
590
+ constructor() {
591
+ super(...arguments);
592
+ /** The name of a glyph at the end of the row; one the icon set flags (`arrow_right`) is mirrored in a right-to-left layout. */
593
+ this.trailingIcon = '';
594
+ /**
595
+ * The item's keyboard shortcut, in the keyboard shortcut component's key names: one chord per string, pressed in order
596
+ * (`["mod+c"]`; the attribute holds the chords separated by spaces, `shortcut="mod+c"`). The menu draws it at the end of
597
+ * the row for the keyboard the person uses and exposes it as `aria-keyshortcuts` (MNU-24, MNU-31). It does not make
598
+ * the keys work; the product binds them.
599
+ */
600
+ this.shortcut = [];
601
+ }
602
+ static { this.properties = {
603
+ trailingIcon: { type: String, attribute: 'trailing-icon' },
604
+ shortcut: { converter: chordsConverter },
605
+ }; }
606
+ get shortcutKeys() {
607
+ return chordsOf(this.shortcut);
608
+ }
609
+ get trailingGlyph() {
610
+ return this.trailingIcon;
611
+ }
612
+ }
613
+ /**
614
+ * An action in a menu — the spec's item kind `item`: it does something and closes the menu.
615
+ *
616
+ * With `href` it is a link item (MNU-53): the row is an `<a href role="menuitem" tabindex="-1">` in the shadow
617
+ * root, drawn exactly as an action is and moved to with the same keys, and the browser's own link in everything else —
618
+ * its context menu, a new tab by a modified or a middle click, its address shown on hover. It is exposed as a menu
619
+ * item, not as a link: a menu is read by its items. A plain activation — a click, a touch, Enter, and Space too, which
620
+ * activates every row of a menu — fires the item's `click` (the anchor's own: `preventDefault()` cancels the
621
+ * navigation, as a router does), then the menu's `close`, and then the browser follows the link (MNU-54). A modified
622
+ * or a middle click is the browser's: no `close`, and the menu stays open. `target="new"` opens a new tab, safely
623
+ * (`noopener`), ends the row with the icon set's `open_in_new` in the trailing icon column unless `trailing-icon` names
624
+ * a glyph, and is said through `targetLabel` (MNU-55). A disabled link item is the anchor without `href` (MNU-56).
625
+ *
626
+ * @tag tanrei-menu-item
627
+ * @csspart container - The row: its color, corners, every state, the ripple and the focus ring.
628
+ * @csspart mark - The mark column (reserved while the surface holds a checkbox or radio item).
629
+ * @csspart leading-icon - The leading glyph.
630
+ * @csspart label - The item's text.
631
+ * @csspart supporting-text - The line below the label.
632
+ * @csspart trailing-text - The text at the end of the row that is not a shortcut (a count, "Beta").
633
+ * @csspart shortcut - The `<tanrei-keyboard-shortcut>` that draws the item's shortcut in the trailing column (MNU-31).
634
+ * @csspart trailing-icon - The trailing glyph; for a link item that opens a new context and names none, the `open_in_new` mark.
635
+ * @csspart link-mark - The `open_in_new` glyph of a link item that opens a new context (the same element as `trailing-icon`; hidden from assistive technology).
636
+ * @fires click - The item was activated by pointer, touch, keyboard or assistive technology; the menu then emits `close` with the reason `item`. For a link item it is the anchor's own click, before the menu closes and before the link is followed: `preventDefault()` stops the navigation and not the `close`.
637
+ */
638
+ export class TanreiMenuItem extends TanreiMenuItemBase {
639
+ constructor() {
640
+ super(...arguments);
641
+ /**
642
+ * MBR-43: what a menubar tells the row a folded bar item draws of itself — its link item names the page the person
643
+ * is on, so the row's anchor says so (`aria-current="page"`); the weight is the bar item's to draw. Internal between
644
+ * Tanrei elements and no prop of the item.
645
+ * @internal
646
+ */
647
+ this.barCurrent = false;
648
+ /** Marks an action that deletes or discards something; it is drawn in the destructive condition (the error color). */
649
+ this.destructive = false;
650
+ /** The address the item leads to: a URL, a path or a fragment. Not empty, the item is a link item (MNU-53): the browser's own link, exposed as a menu item; a plain activation fires `click`, closes the menu and follows it (MNU-54). White space is no address; a `javascript:` address or one that cannot be read is refused and reported (MNU-57). */
651
+ this.href = '';
652
+ /** Where a link item opens: `same` (here) or `new` (a new tab or window, with `noopener`), which the row marks with `open_in_new` unless `trailing-icon` names a glyph, and says through `targetLabel` (MNU-55). HTML's `_self` and `_blank` are read as those; anything else is `same` and is reported (MNU-57). Ignored without `href`. */
653
+ this.target = 'same';
654
+ /** What assistive technology reads at the end of the link item's description while `target` is `new` ("opens in a new tab"): your words, in your language. Required then; ignored otherwise. */
655
+ this.targetLabel = '';
656
+ /** Web only: the anchor's `rel`. `noopener` is added while `target` is `new`; `noreferrer` is yours to add. */
657
+ this.rel = null;
658
+ /** Web only: the anchor's `download`. */
659
+ this.download = null;
660
+ /**
661
+ * MNU-53, MNU-55 … MNU-57: the link the item is while it has an address, what its anchor carries — the menu item
662
+ * role in place of the link's, because a menu is read by its items — and what a debug build is told
663
+ * (src/primitives/link.ts). The item keeps a menu's keys: Space presses it as Enter does (MNU-54).
664
+ */
665
+ this.link = new LinkController(this, { ids: { refused: 'MNU-57', newContext: 'MNU-55' }, disabled: () => this.disabled, role: 'menuitem' });
666
+ this.itemRole = 'menuitem';
667
+ }
668
+ static { this.properties = {
669
+ destructive: { type: Boolean, reflect: true },
670
+ href: { type: String },
671
+ target: { type: String },
672
+ targetLabel: { type: String, attribute: 'target-label' },
673
+ rel: { type: String },
674
+ download: { type: String },
675
+ barCurrent: { state: true },
676
+ }; }
677
+ get linkForm() {
678
+ return this.link.form;
679
+ }
680
+ /** @internal Whether the item is a link item now (MNU-53). */
681
+ get isLink() {
682
+ return !!this.link.form;
683
+ }
684
+ /** MBR-43: the current page is said where the link is — on the anchor, which carries a link item's semantics (MNU-53). */
685
+ kindAria() {
686
+ return { 'aria-current': this.barCurrent && this.isLink ? 'page' : null };
687
+ }
688
+ get condition() {
689
+ return this.destructive ? 'destructive' : 'unselected';
690
+ }
691
+ }
692
+ /**
693
+ * An option switched on or off on its own — the spec's item kind `checkbox-item`. Its `checked` is its own: the menu
694
+ * switches it when the item is activated and fires the item's `change`. A checked item's row is filled, and it is
695
+ * marked as the design system chooses (`comp.menu.checkbox-item.mark`: the checkbox look, a box in both conditions, in
696
+ * the default system; the icon set's check in m3-like and cupertino) unless the item or its group names a glyph.
697
+ *
698
+ * @tag tanrei-menu-checkbox-item
699
+ * @csspart container - The row.
700
+ * @csspart mark - The mark column: the box of the checkbox look, or the glyph that marks the item while it is checked. A drawing, never a control.
701
+ * @csspart leading-icon - The leading glyph.
702
+ * @csspart label - The item's text.
703
+ * @csspart supporting-text - The line below the label.
704
+ * @csspart trailing-text - The text at the end of the row that is not a shortcut.
705
+ * @csspart shortcut - The `<tanrei-keyboard-shortcut>` that draws the item's shortcut in the trailing column (MNU-31).
706
+ * @csspart trailing-icon - The trailing glyph.
707
+ * @fires {CustomEvent<TanreiMenuCheckboxItemChangeDetail>} change - The item was activated: `detail.checked` (and the element's `checked`) is the new value.
708
+ */
709
+ export class TanreiMenuCheckboxItem extends TanreiMenuItemBase {
710
+ constructor() {
711
+ super(...arguments);
712
+ /** Whether the option is on. */
713
+ this.checked = false;
714
+ /**
715
+ * The name of a glyph of the system's icon set to mark this item with while it is checked, instead of the mark the
716
+ * design system chooses (`check` draws a plain check). Empty takes its group's `mark-icon`, then the system's choice.
717
+ */
718
+ this.markIcon = '';
719
+ this.itemRole = 'menuitemcheckbox';
720
+ }
721
+ static { this.properties = {
722
+ checked: { type: Boolean, reflect: true },
723
+ markIcon: { type: String, attribute: 'mark-icon' },
724
+ }; }
725
+ get holds() {
726
+ return 'a checkbox item';
727
+ }
728
+ get condition() {
729
+ return this.checked ? 'selected' : 'unselected';
730
+ }
731
+ get isChecked() {
732
+ return this.checked;
733
+ }
734
+ get markKind() {
735
+ return 'checkbox';
736
+ }
737
+ get ownMarkIcon() {
738
+ return this.markIcon ?? '';
739
+ }
740
+ }
741
+ /**
742
+ * One choice of several in its group — the spec's item kind `radio-item`: it is checked while its group's `value` is
743
+ * its own. A checked item's row is filled, and it is marked as the design system chooses (`comp.menu.radio-item.mark`:
744
+ * the radio look, a ring in both conditions, in the default system; the icon set's check in m3-like and cupertino)
745
+ * unless the item or its group names a glyph.
746
+ *
747
+ * @tag tanrei-menu-radio-item
748
+ * @csspart container - The row.
749
+ * @csspart mark - The mark column: the ring of the radio look, or the glyph that marks the item while it is checked. A drawing, never a control.
750
+ * @csspart leading-icon - The leading glyph.
751
+ * @csspart label - The item's text.
752
+ * @csspart supporting-text - The line below the label.
753
+ * @csspart trailing-text - The text at the end of the row that is not a shortcut.
754
+ * @csspart shortcut - The `<tanrei-keyboard-shortcut>` that draws the item's shortcut in the trailing column (MNU-31).
755
+ * @csspart trailing-icon - The trailing glyph.
756
+ */
757
+ export class TanreiMenuRadioItem extends TanreiMenuItemBase {
758
+ constructor() {
759
+ super(...arguments);
760
+ /** Identifies the choice: the item is checked while its group's value equals it. Unique within its group; required. */
761
+ this.value = '';
762
+ /**
763
+ * The name of a glyph of the system's icon set to mark this item with while it is checked, instead of the mark the
764
+ * design system chooses (`check` draws a plain check). Empty takes its group's `mark-icon`, then the system's choice.
765
+ */
766
+ this.markIcon = '';
767
+ this.itemRole = 'menuitemradio';
768
+ }
769
+ static { this.properties = {
770
+ value: { type: String },
771
+ markIcon: { type: String, attribute: 'mark-icon' },
772
+ }; }
773
+ get holds() {
774
+ return 'a radio item';
775
+ }
776
+ get condition() {
777
+ return this.context.radioChecked ? 'selected' : 'unselected';
778
+ }
779
+ get isChecked() {
780
+ return this.context.radioChecked;
781
+ }
782
+ get markKind() {
783
+ return 'radio';
784
+ }
785
+ get ownMarkIcon() {
786
+ return this.markIcon ?? '';
787
+ }
788
+ }
789
+ /** Orders the submenus by when they were opened: of two open in one surface, the later one stays (MNU-48). */
790
+ let opened = 0;
791
+ /**
792
+ * An item that opens another level of the menu beside it — the spec's item kind `submenu`. It holds that level's items
793
+ * as its children, of any kind, further submenus included; it draws its row, ending in the icon set's `chevron_right`,
794
+ * in the surface that holds it, and its own surface as a manual popover in the top layer, placed against the row
795
+ * (MNU-46, MNU-47). It is not an action: activating it opens its submenu and closes nothing. `open` is its own: the menu
796
+ * sets it when the person opens or closes the submenu and fires `toggle`; the product may also set it. The menu it is in
797
+ * does the rest — the keys, the pointer's path, placement, focus and closing.
798
+ *
799
+ * @tag tanrei-submenu
800
+ * @slot - The submenu's items: `<tanrei-menu-item>`, `<tanrei-menu-checkbox-item>`, `<tanrei-menu-radio-item>`, `<tanrei-submenu>` and `<tanrei-menu-group>` children.
801
+ * @csspart container - The row: its color, corners, every state, the ripple and the focus ring; filled from the expanded condition while the submenu is open.
802
+ * @csspart mark - The mark column, empty in a submenu item (reserved while the surface holds a checkbox or radio item).
803
+ * @csspart leading-icon - The leading glyph.
804
+ * @csspart label - The item's text.
805
+ * @csspart supporting-text - The line below the label.
806
+ * @csspart trailing-text - The text at the end of the row, before the indicator: the current value of what the submenu sets, or a count.
807
+ * @csspart submenu-indicator - The icon set's `chevron_right` at the end of the row, mirrored in a right-to-left layout.
808
+ * @csspart surface - The submenu's floating sheet, drawn from the menu's surface tokens.
809
+ * @csspart scroll - The padded box inside the surface that scrolls the items.
810
+ * @csspart divider - A line between a group and what is next to it, while the menu's separation is divider.
811
+ * @fires {CustomEvent<TanreiSubmenuToggleDetail>} toggle - The person opened or closed the submenu: `detail.open` (and the element's `open`) is the new value. It bubbles. A change the product makes, and the whole menu closing, fire none.
812
+ */
813
+ export class TanreiSubmenu extends TanreiMenuRowBase {
814
+ static { this.styles = [itemStyles, submenuStyles, hiddenHost]; }
815
+ // Each child in a slot of its own, so that a divider or a gap can be drawn between two of them (MNU-23, MNU-36).
816
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' }; }
817
+ static { this.properties = {
818
+ open: { type: Boolean, reflect: true },
819
+ blocks: { state: true },
820
+ presented: { state: true },
821
+ }; }
822
+ get holds() {
823
+ return 'a submenu item';
824
+ }
825
+ constructor() {
826
+ super();
827
+ /**
828
+ * Whether the item's submenu is shown. The menu sets it when the person opens or closes the submenu and fires
829
+ * `toggle`; the product may also set it. It shows nothing while the surface that holds the item is not shown, while
830
+ * the item is disabled and while it holds no item.
831
+ */
832
+ this.open = false;
833
+ this.itemRole = 'menuitem';
834
+ /** The submenu's children, each in a slot of its own. */
835
+ this.blocks = [];
836
+ /** Whether its surface is drawn now: the item is then in the expanded condition (MNU-50). */
837
+ this.presented = false;
838
+ this.children$ = new MutationObserver(() => this.readChildren());
839
+ /** @internal How its surface is drawn now. */
840
+ this.presentation = 'hidden';
841
+ /** @internal The side of the surface that holds its item that its own surface is placed on (MNU-46). */
842
+ this.side = 'right';
843
+ /** @internal MNU-47: its surface is laid over the surface that holds its item. */
844
+ this.overlap = false;
845
+ /** @internal What it was last placed for: the menu places it again when this changes. */
846
+ this.lastLayout = '';
847
+ /** @internal When it was opened, among the submenus of the page. */
848
+ this.openedAt = 0;
849
+ // A forwarding <slot> child changed what is assigned to it (a folded menu of a menubar, MBR-22): the blocks' kinds
850
+ // (dividers) and the items.
851
+ this.addEventListener('slotchange', (event) => {
852
+ if (event.target?.parentNode !== this)
853
+ return;
854
+ this.requestUpdate();
855
+ notifyItemUpdate(this, 'tanrei-menu-item-update');
856
+ });
857
+ }
858
+ connectedCallback() {
859
+ super.connectedCallback();
860
+ this.children$.observe(this, { childList: true });
861
+ this.readChildren();
862
+ }
863
+ disconnectedCallback() {
864
+ super.disconnectedCallback();
865
+ this.children$.disconnect();
866
+ }
867
+ readChildren() {
868
+ const now = [...this.children];
869
+ if (now.length !== this.blocks.length || now.some((child, i) => child !== this.blocks[i]))
870
+ this.blocks = now;
871
+ }
872
+ /** @internal The submenu's surface. */
873
+ get surfaceElement() {
874
+ return this.renderRoot?.querySelector('.surface') ?? null;
875
+ }
876
+ /** @internal The box of the surface that scrolls its items. */
877
+ get scrollElement() {
878
+ return this.renderRoot?.querySelector('.scroll') ?? null;
879
+ }
880
+ get condition() {
881
+ return this.presented ? 'expanded' : 'unselected';
882
+ }
883
+ get opensSubmenu() {
884
+ return true;
885
+ }
886
+ /** MNU-24: a menu item that opens a menu, and whether that menu is open. */
887
+ kindAria() {
888
+ return { 'aria-haspopup': 'menu', 'aria-expanded': String(this.presented) };
889
+ }
890
+ /**
891
+ * @internal The menu's side (MNU-43, MNU-48 … MNU-50): draws the surface in place or in the top layer, or removes it —
892
+ * fading out, as the menu's own does (MNU-4). Returns whether the presentation changed.
893
+ */
894
+ present(mode, quick = false) {
895
+ const surface = this.surfaceElement;
896
+ if (!surface || mode === this.presentation)
897
+ return false;
898
+ const was = this.presentation;
899
+ this.presentation = mode;
900
+ this.presented = mode !== 'hidden';
901
+ this.lastLayout = '';
902
+ surface.classList.toggle('inline', mode === 'inline');
903
+ surface.classList.remove('entering');
904
+ if (mode === 'overlay') {
905
+ surface.classList.remove('leaving');
906
+ if (!surface.matches(':popover-open'))
907
+ surface.showPopover();
908
+ }
909
+ else {
910
+ this.overlap = false;
911
+ surface.classList.remove('cascading');
912
+ if (was === 'overlay') {
913
+ // MBR-29: gone at once where a menubar's menu gives its place to another.
914
+ if (!quick)
915
+ this.leave(surface);
916
+ else if (surface.isConnected && surface.matches(':popover-open'))
917
+ surface.hidePopover();
918
+ }
919
+ }
920
+ return true;
921
+ }
922
+ /** @internal MNU-50: the open motion, growing from the edge that faces the item. Called once the surface is placed. */
923
+ enter() {
924
+ const surface = this.surfaceElement;
925
+ if (!surface)
926
+ return;
927
+ surface.classList.remove('entering');
928
+ void surface.offsetWidth; // restart the animation
929
+ surface.classList.add('entering');
930
+ }
931
+ leave(surface) {
932
+ surface.classList.add('leaving');
933
+ const finish = () => {
934
+ if (this.presentation === 'overlay' || !surface.classList.contains('leaving'))
935
+ return;
936
+ surface.classList.remove('leaving');
937
+ if (surface.isConnected && surface.matches(':popover-open'))
938
+ surface.hidePopover();
939
+ };
940
+ const running = surface.getAnimations();
941
+ if (running.length === 0)
942
+ finish();
943
+ else
944
+ void Promise.allSettled(running.map((animation) => animation.finished)).then(finish);
945
+ }
946
+ willUpdate(changed) {
947
+ if (changed.has('open') && this.open && !this.openedAt)
948
+ this.openedAt = ++opened;
949
+ if (changed.has('open') && !this.open)
950
+ this.openedAt = 0;
951
+ }
952
+ firstUpdated() {
953
+ super.firstUpdated();
954
+ // The surface exists now: the menu presents it if it is open.
955
+ notifyItemUpdate(this, 'tanrei-menu-item-update');
956
+ }
957
+ updated(changed) {
958
+ assignBlocks(this.surfaceElement ?? this.renderRoot, this.blocks);
959
+ super.updated(changed);
960
+ }
961
+ render() {
962
+ // MNU-24: the submenu's surface is a menu of its own, named by its item's label.
963
+ return html `${this.renderRow()}
964
+ <div part="surface" class="surface" data-tanrei-shape popover="manual" role="menu" aria-label=${this.label || nothing}>
965
+ <div part="scroll" class="scroll">${blocksTemplate(this.blocks)}</div>
966
+ </div>`;
967
+ }
968
+ }
969
+ /**
970
+ * A run of related items — the spec's item kind `group` — optionally under a title (its `label`, as `<optgroup label>`:
971
+ * a `title` attribute would also draw the browser's tooltip), which names it. The menu separates a group from what is
972
+ * next to it, by a divider or a gap as its `separation` names; a group of radio items is one set of choices, and holds
973
+ * which one is checked in `value`.
974
+ *
975
+ * @tag tanrei-menu-group
976
+ * @slot - The group's items.
977
+ * @csspart title - The heading above the items.
978
+ * @fires {CustomEvent<TanreiMenuGroupChangeDetail>} change - A radio item of the group was chosen: `detail.value` (and the element's `value`) is the new value.
979
+ */
980
+ export class TanreiMenuGroup extends LitElement {
981
+ constructor() {
982
+ super(...arguments);
983
+ /** The group's title, drawn above its items, which names the group; empty draws none. */
984
+ this.label = '';
985
+ /** The value of the group's checked radio item; `null` checks none. The group sets it when a radio item is chosen. */
986
+ this.value = null;
987
+ /**
988
+ * The name of a glyph of the system's icon set that marks the group's checked checkbox and radio items, for those that
989
+ * name none of their own (`check` draws a plain check). Empty takes the design system's choice (MNU-38).
990
+ */
991
+ this.markIcon = '';
992
+ /** Whether this group sits in another (MNU-29). */
993
+ this.nesting = { nested: false };
994
+ }
995
+ static { this.styles = [groupStyles, hiddenHost]; }
996
+ static { this.properties = {
997
+ label: { type: String },
998
+ value: { type: String },
999
+ markIcon: { type: String, attribute: 'mark-icon' },
1000
+ nesting: { state: true },
1001
+ }; }
1002
+ /** @internal The menu's side. */
1003
+ setMenuContext(nesting) {
1004
+ if (this.nesting.nested === nesting.nested)
1005
+ return;
1006
+ this.nesting = nesting;
1007
+ }
1008
+ updated(changed) {
1009
+ const { nested } = this.nesting;
1010
+ // MNU-24: a group named by its title; MNU-29: a group in a group is drawn as its outer group's items.
1011
+ hostAria(this, { role: nested ? 'none' : 'group', 'aria-label': !nested && this.label ? this.label : null });
1012
+ if (this.hasUpdated && (changed.has('label') || changed.has('value') || changed.has('markIcon')))
1013
+ notifyItemUpdate(this, 'tanrei-menu-item-update');
1014
+ }
1015
+ render() {
1016
+ const { nested } = this.nesting;
1017
+ // MNU-28: the title takes no focus and is not read as an item: the group's name is its label.
1018
+ return html `${this.label && !nested ? html `<span part="title" class="title" aria-hidden="true">${this.label}</span>` : nothing}<slot></slot>`;
1019
+ }
1020
+ }
1021
+ // ── The menu ──────────────────────────────────────────────────────────────────────────────────────────────────────
1022
+ const ROWS = 'tanrei-menu-item, tanrei-menu-checkbox-item, tanrei-menu-radio-item, tanrei-submenu';
1023
+ let ids = 0;
1024
+ /**
1025
+ * A node's parent in the flat tree: the slot it is assigned to, else its parent, and a shadow root's host. It is how the
1026
+ * menu tells its own content — slotted into it, or forwarded through a slot of a component that holds the menu in its
1027
+ * shadow root (a split button, SPB-15) — from anything else, and which surface of its tree an item is in.
1028
+ */
1029
+ const flatParent = (node) => {
1030
+ const slot = node.assignedSlot;
1031
+ if (slot)
1032
+ return slot;
1033
+ const parent = node.parentNode;
1034
+ return parent instanceof ShadowRoot ? parent.host : parent;
1035
+ };
1036
+ /**
1037
+ * Offers a short set of actions or choices on a temporary surface that opens from the element that asked for it, with
1038
+ * further levels in submenus where the set needs them.
1039
+ *
1040
+ * Contract: specs/menu.spec.json. The surface is a manual popover in the top layer, placed against the anchor (the
1041
+ * element whose id is `anchor`) by script: below or above it as `placement` says, flipping and shifting to stay inside
1042
+ * the viewport, scrolling when it is taller than the room, following the anchor while it moves. The menu is an operated
1043
+ * overlay that is not modal: it moves focus to its first enabled item when it opens and back to the anchor
1044
+ * when it closes, never traps focus and draws no scrim. It never closes itself: it fires `close` with a reason — Escape,
1045
+ * a press outside the surface and the anchor, Tab, focus leaving it, an item's activation — and you set `open` to false.
1046
+ *
1047
+ * A `<tanrei-submenu>` among the items opens another level beside its row (MNU-42 … MNU-52), by the WAI-ARIA menu
1048
+ * pattern: the arrow key that points to the inline end, Enter, Space, a press or a tap open it and move focus in; the
1049
+ * opposite arrow key and Escape close one level and return focus to its item; a pointer that rests on the item opens it
1050
+ * after `comp.menu.motion.submenu-delay`, and may then cross other items on its way in. Every surface of the tree is
1051
+ * inside the menu: a press in a submenu is not a press outside, and whatever closes the menu closes every level with one
1052
+ * `close`.
1053
+ *
1054
+ * A group is told from what is next to it as `separation` names (MNU-35): a divider, or a gap of
1055
+ * `comp.menu.group.gap`; `auto` takes `comp.menu.separation`, which follows the design system's choice.
1056
+ *
1057
+ * Every visual value comes from `--tanrei-comp-menu-*` tokens, the items' by condition (unselected, selected,
1058
+ * destructive, expanded) and state. The `inline` attribute, for tests and documentation, draws the open surface in place
1059
+ * instead: at its natural size, with its elevation, without an anchor, placement, open motion, focus on opening or light
1060
+ * dismiss, each open submenu beside its item.
1061
+ *
1062
+ * A component that holds a menu in its shadow root may forward its own children into it: a `<slot>` child of the menu
1063
+ * stands for the elements assigned to it, each forwarded child in a slot of its own (the split button, SPB-15).
1064
+ *
1065
+ * @tag tanrei-menu
1066
+ * @slot - The items: `<tanrei-menu-item>`, `<tanrei-menu-checkbox-item>`, `<tanrei-menu-radio-item>`, `<tanrei-submenu>` and `<tanrei-menu-group>` children.
1067
+ * @csspart surface - The floating sheet: its color, corners, elevation and width.
1068
+ * @csspart scroll - The padded box inside the surface that scrolls the items.
1069
+ * @csspart divider - A line between a group and what is next to it, while the separation is divider.
1070
+ * @fires {CustomEvent<TanreiMenuCloseDetail>} close - The menu asks to be closed, every open submenu with it: `detail.reason` is `escape`, `outside`, `tab`, `focus-out` or `item`. Set `open` to false.
1071
+ */
1072
+ export class TanreiMenu extends LitElement {
1073
+ static { this.styles = [menuStyles, hiddenHost]; }
1074
+ // The menu places each child in a slot of its own, so that a divider or a gap can be drawn between two of them (MNU-23, MNU-36).
1075
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' }; }
1076
+ static { this.properties = {
1077
+ open: { type: Boolean, reflect: true },
1078
+ placement: { type: String, reflect: true },
1079
+ separation: { type: String, reflect: true },
1080
+ anchor: { type: String, reflect: true },
1081
+ inline: { type: Boolean, reflect: true },
1082
+ blocks: { state: true },
1083
+ }; }
1084
+ constructor() {
1085
+ super();
1086
+ this.availability = new AvailabilityController(this, 'menu');
1087
+ /** MNU-35, MNU-38: where a browser has no style queries, the choices are read when the menu renders — again when the system is switched. */
1088
+ this.system = new SystemWatchController(this);
1089
+ /** Whether the menu is shown. Open it from its anchor; set it to false when the menu fires `close`. */
1090
+ this.open = false;
1091
+ /** Where the surface goes against the anchor: below or above it, with its start or end edge aligned to the anchor's. */
1092
+ this.placement = 'bottom-start';
1093
+ /**
1094
+ * How a group is told from what is next to it: `divider` draws a line between them, `gap` leaves empty space and no
1095
+ * line. `auto` takes `comp.menu.separation`, the design system's answer (divider in the default system). It applies to
1096
+ * the menu and to every submenu of it.
1097
+ */
1098
+ this.separation = 'auto';
1099
+ /** The id of the anchor element, in the menu's own document or shadow root (as the HTML `anchor` attribute). */
1100
+ this.anchor = '';
1101
+ /** For tests and documentation: draws the open surface in place (MNU-19), each open submenu beside its item, without the overlay's behaviour. */
1102
+ this.inline = false;
1103
+ /**
1104
+ * The element the surface is placed against, when it is not the anchor: a split button places its menu against its
1105
+ * whole row and returns focus to, and names the menu by, its trailing half (the anchor, SPB-15). Internal between
1106
+ * Tanrei elements.
1107
+ * @internal
1108
+ */
1109
+ this.positionAnchor = null;
1110
+ /**
1111
+ * Presents the menu without moving focus into it: no move to the first item when it opens (in place of MNU-1) and none
1112
+ * to an item under the pointer, which still draws it hovered (in place of MNU-8); a press on an item activates it
1113
+ * without focusing it. A split button's menu that is open from hover (SPB-22). Internal between Tanrei elements.
1114
+ * @internal
1115
+ */
1116
+ this.focusless = false;
1117
+ /**
1118
+ * The menubar that shows this menu, and what it tells it (MBR-9, MBR-13, MBR-14, MBR-22, MBR-29). Internal between
1119
+ * Tanrei elements.
1120
+ * @internal
1121
+ */
1122
+ this.bar = null;
1123
+ /** The menu's children, each in a slot of its own. */
1124
+ this.blocks = [];
1125
+ /** MNU-7: the arrow keys and the typeahead of each surface; each remembers what was typed in it. */
1126
+ this.keys = new WeakMap();
1127
+ this.closeRequested = false;
1128
+ this.shown = false;
1129
+ /** The menu has been presented (in the top layer or in place) since it was last closed: closing it closes its submenus (MNU-49). */
1130
+ this.live = false;
1131
+ this.lastLayout = '';
1132
+ /** The rows of each surface, read when first asked after a change. */
1133
+ this.levels = null;
1134
+ this.children$ = new MutationObserver(() => this.readChildren());
1135
+ this.unregister = null;
1136
+ /** MNU-44: where the pointer is now — the item under it. */
1137
+ this.pointerItem = null;
1138
+ /** MNU-44: the submenu item a resting pointer is about to open. */
1139
+ this.resting = null;
1140
+ /** MNU-45: the pointer's last position on the item of an open submenu — the corner of the triangle it may move in. */
1141
+ this.apex = null;
1142
+ /** MNU-45: the items the pointer crossed on its way, which are not drawn hovered, and the pause that ends the way. */
1143
+ this.crossed = new Set();
1144
+ this.pause = null;
1145
+ /** MNU-47: the click of a press that closed a covering submenu activates nothing. */
1146
+ this.swallowClick = false;
1147
+ /** The menu itself is placing focus (MNU-1, MNU-43): that is not the person moving it to another item (MNU-48). */
1148
+ this.placing = false;
1149
+ /**
1150
+ * MNU-5, MNU-7, MNU-43, MNU-48, MNU-51: Escape closes the innermost level — the submenu that holds focus, else the
1151
+ * innermost open one, else the menu — and Tab the whole menu; the arrow keys along the line open a submenu item's
1152
+ * submenu and close the submenu that holds focus, and do nothing else; the vertical arrows, Home, End and typeahead
1153
+ * move focus within the surface that holds it, wrapping.
1154
+ */
1155
+ this.onKeyDown = (event) => {
1156
+ if (!this.open)
1157
+ return;
1158
+ const { item, level } = this.locate(event);
1159
+ if (event.key === 'Escape') {
1160
+ event.preventDefault();
1161
+ event.stopPropagation();
1162
+ const submenu = level instanceof TanreiSubmenu ? level : this.openChain().at(-1);
1163
+ if (submenu)
1164
+ this.closeSubmenu(submenu, true, 'key');
1165
+ else
1166
+ this.requestClose('escape');
1167
+ return;
1168
+ }
1169
+ if (event.key === 'Tab') {
1170
+ // Focus goes to the anchor first, so that the Tab's own move goes on from there, as it would have from the anchor.
1171
+ this.requestClose('tab');
1172
+ if (!this.inline)
1173
+ this.anchorElement?.focus();
1174
+ return;
1175
+ }
1176
+ if (event.altKey || event.ctrlKey || event.metaKey)
1177
+ return;
1178
+ if (!item || !level || !item.isTargetOf(event))
1179
+ return;
1180
+ if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
1181
+ // MNU-51: the key is the menu's whatever it does — it never scrolls or acts on what is behind.
1182
+ event.preventDefault();
1183
+ event.stopPropagation();
1184
+ const towardsEnd = (event.key === 'ArrowRight') !== (getComputedStyle(item).direction === 'rtl');
1185
+ if (towardsEnd) {
1186
+ if (item instanceof TanreiSubmenu)
1187
+ this.openSubmenu(item, 'key');
1188
+ else
1189
+ this.bar?.inlineKey(true);
1190
+ }
1191
+ else if (level instanceof TanreiSubmenu)
1192
+ this.closeSubmenu(level, true, 'key');
1193
+ else
1194
+ this.bar?.inlineKey(false);
1195
+ return;
1196
+ }
1197
+ const rows = this.rowsOf(level);
1198
+ const current = rows.indexOf(item);
1199
+ let keys = this.keys.get(level);
1200
+ if (!keys)
1201
+ this.keys.set(level, (keys = new RovingKeys({ wrap: true })));
1202
+ const target = keys.target(event.key, current, rows.map((each) => ({ focusable: true, label: each.label })));
1203
+ if (target === null)
1204
+ return;
1205
+ event.preventDefault();
1206
+ event.stopPropagation();
1207
+ if (target !== current)
1208
+ rows[target].focus();
1209
+ };
1210
+ /**
1211
+ * MNU-47: while a submenu covers part of the surface it opened from, a press on what is left of that surface closes
1212
+ * the submenu — the way back for a person with no keyboard — and activates nothing.
1213
+ */
1214
+ this.onPointerDown = (event) => {
1215
+ this.swallowClick = false;
1216
+ if (!this.open)
1217
+ return;
1218
+ const { level } = this.locate(event);
1219
+ const covering = level ? this.openIn(level).find((submenu) => submenu.overlap) : undefined;
1220
+ if (!covering)
1221
+ return;
1222
+ event.preventDefault();
1223
+ event.stopPropagation();
1224
+ this.swallowClick = true;
1225
+ // The click of this press follows its pointerup at once; a press that ends elsewhere has none to swallow.
1226
+ const settle = () => setTimeout(() => (this.swallowClick = false));
1227
+ window.addEventListener('pointerup', settle, { once: true, capture: true });
1228
+ window.addEventListener('pointercancel', settle, { once: true, capture: true });
1229
+ this.closeSubmenu(covering, true, 'pointer');
1230
+ };
1231
+ this.onClickCapture = (event) => {
1232
+ if (!this.swallowClick)
1233
+ return;
1234
+ this.swallowClick = false;
1235
+ event.preventDefault();
1236
+ event.stopImmediatePropagation();
1237
+ };
1238
+ /**
1239
+ * MNU-6, MNU-43: an item's activation — its click — does what its kind does, then asks to close (a Space keeps a
1240
+ * checkbox or radio item's menu open); a submenu item's opens its submenu and closes nothing.
1241
+ */
1242
+ this.onClick = (event) => {
1243
+ const item = this.itemOf(event);
1244
+ // A disabled item swallows its clicks before they get here (MNU-9).
1245
+ if (!item || item.disabled)
1246
+ return;
1247
+ const via = item.activation;
1248
+ if (item instanceof TanreiSubmenu) {
1249
+ this.stopResting();
1250
+ this.openSubmenu(item, this.focusless ? 'stay' : via === 'pointer' ? 'pointer' : 'key');
1251
+ return;
1252
+ }
1253
+ if (item instanceof TanreiMenuCheckboxItem) {
1254
+ item.checked = !item.checked;
1255
+ item.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { checked: item.checked } }));
1256
+ }
1257
+ else if (item instanceof TanreiMenuRadioItem) {
1258
+ const group = this.groupOf(item);
1259
+ // A radio item that is already checked emits no change.
1260
+ if (group && group.value !== item.value) {
1261
+ group.value = item.value;
1262
+ this.sync();
1263
+ group.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { value: group.value } }));
1264
+ }
1265
+ }
1266
+ // MNU-54: a link item's click that the browser opens elsewhere — a modifier key, another button — is not an
1267
+ // activation of the menu's: nothing is prevented, no close is asked and the menu stays open, focus where it was.
1268
+ if (item instanceof TanreiMenuItem && item.isLink && (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey))
1269
+ return;
1270
+ if (item instanceof TanreiMenuItem || via !== 'space')
1271
+ this.requestClose('item');
1272
+ };
1273
+ /**
1274
+ * MNU-8, MNU-44, MNU-45: a pointer moving onto an item moves focus there, without the ring, so that the arrow keys
1275
+ * continue from it — except while it is on its way to an open submenu: inside the triangle between its last position
1276
+ * on the submenu's item and the two corners of the submenu's surface that face the item, the items it crosses take
1277
+ * neither hover nor focus, until it leaves the triangle or pauses in it for `submenu-delay`.
1278
+ */
1279
+ this.onPointerMove = (event) => {
1280
+ if (!this.open || event.pointerType === 'touch')
1281
+ return;
1282
+ const { item, level } = this.locate(event);
1283
+ this.pointerItem = item;
1284
+ const aimed = level ? this.openIn(level)[0] : undefined;
1285
+ if (aimed && item === aimed) {
1286
+ // The triangle is taken anew each time the pointer leaves the submenu's item: from where it was last on it.
1287
+ this.endAim();
1288
+ this.apex = { submenu: aimed, x: event.clientX, y: event.clientY };
1289
+ }
1290
+ else if (aimed && this.apex?.submenu === aimed && this.onTheWay(event, aimed)) {
1291
+ if (item) {
1292
+ item.suppressHover(true);
1293
+ this.crossed.add(item);
1294
+ }
1295
+ this.stopResting();
1296
+ if (this.pause !== null)
1297
+ clearTimeout(this.pause);
1298
+ this.pause = setTimeout(() => {
1299
+ this.endAim();
1300
+ if (this.open && this.pointerItem)
1301
+ this.hover(this.pointerItem);
1302
+ }, this.submenuDelay);
1303
+ return;
1304
+ }
1305
+ else if (this.apex)
1306
+ this.endAim();
1307
+ if (item)
1308
+ this.hover(item);
1309
+ else
1310
+ this.stopResting();
1311
+ };
1312
+ /** MNU-44: a pointer that leaves the menu opens nothing; where it was on its way to a submenu its pause still ends the way. */
1313
+ this.onPointerLeave = () => {
1314
+ this.pointerItem = null;
1315
+ this.stopResting();
1316
+ };
1317
+ /** A focusless menu (SPB-22): a press on an item leaves focus where it was; the item's click still activates it. */
1318
+ this.onMouseDown = (event) => {
1319
+ if (this.open && this.focusless && this.itemOf(event))
1320
+ event.preventDefault();
1321
+ };
1322
+ /**
1323
+ * MNU-48: focus moving to another item of a surface (MNU-7, and whatever else moves it there) closes the submenu
1324
+ * that is open in it — not the focus the menu places itself when it opens or opens a submenu.
1325
+ */
1326
+ this.onFocusIn = (event) => {
1327
+ if (!this.open || this.placing)
1328
+ return;
1329
+ const { item, level } = this.locate(event);
1330
+ if (!item || !level || !item.isTargetOf(event))
1331
+ return;
1332
+ for (const other of this.openIn(level))
1333
+ if (other !== item)
1334
+ this.closeSubmenu(other, true, 'stay');
1335
+ };
1336
+ /** MNU-5, MNU-49: focus moving out of the menu and all of its submenus — anywhere but the anchor, whose own press decides — asks to close. */
1337
+ this.onFocusOut = (event) => {
1338
+ if (!this.open || this.inline)
1339
+ return;
1340
+ const to = event.relatedTarget;
1341
+ if (!to || this.owns(to))
1342
+ return;
1343
+ const anchor = this.anchorElement;
1344
+ if (anchor && (anchor === to || anchor.contains(to)))
1345
+ return;
1346
+ // MBR-14: focus that stays in the menubar has not left it.
1347
+ for (let at = this.bar ? to : null; at; at = flatParent(at))
1348
+ if (at === this.bar?.ground)
1349
+ return;
1350
+ this.requestClose('focus-out');
1351
+ };
1352
+ /** MNU-5, MNU-49: a press outside every surface and the anchor asks to close; the press also reaches what is under it. */
1353
+ this.onOutsidePress = (event) => {
1354
+ const path = event.composedPath();
1355
+ if (path.includes(this))
1356
+ return;
1357
+ const anchor = this.anchorElement;
1358
+ if (anchor && path.includes(anchor))
1359
+ return;
1360
+ // MBR-14: a press on the menubar is the bar's to answer.
1361
+ if (this.bar && path.includes(this.bar.ground))
1362
+ return;
1363
+ this.requestClose('outside');
1364
+ };
1365
+ /**
1366
+ * MNU-2, MNU-46: follows the anchor while it moves (scrolling, layout, the viewport) for as long as it is open, and
1367
+ * each open submenu its item; a submenu whose item is scrolled out of the visible part of its surface closes. Asked
1368
+ * by FollowController when something can have moved, frame by frame only while something does.
1369
+ */
1370
+ this.follow = () => {
1371
+ let changed = false;
1372
+ const box = (this.positionAnchor ?? this.anchorElement)?.getBoundingClientRect();
1373
+ const scroll = this.scrollBox;
1374
+ const direction = getComputedStyle(this).direction;
1375
+ const viewport = `${document.documentElement.clientWidth},${document.documentElement.clientHeight}`;
1376
+ // MNU-32: the layout direction is part of where the surface goes — a change of it places the surface again.
1377
+ const layout = `${box?.x},${box?.y},${box?.width},${box?.height},${viewport},${scroll?.scrollHeight},${scroll?.scrollWidth},${direction}`;
1378
+ if (layout !== this.lastLayout) {
1379
+ this.lastLayout = layout;
1380
+ this.place();
1381
+ changed = true;
1382
+ }
1383
+ for (const submenu of this.openChain()) {
1384
+ if (submenu.presentation !== 'overlay')
1385
+ continue;
1386
+ const level = this.levelOf(submenu);
1387
+ const row = submenu.rowElement?.getBoundingClientRect();
1388
+ const held = this.scrollOf(level);
1389
+ const parent = this.surfaceOf(level)?.getBoundingClientRect();
1390
+ const own = submenu.scrollElement;
1391
+ if (!row || !held || !parent)
1392
+ continue;
1393
+ const view = held.getBoundingClientRect();
1394
+ // Only where the surface is drawn at its own size: while it grows in, its boxes are still being scaled.
1395
+ if (view.height >= held.clientHeight - 1 && held.scrollHeight > held.clientHeight && (row.bottom <= view.top || row.top >= view.bottom)) {
1396
+ this.closeSubmenu(submenu, true, 'stay');
1397
+ changed = true;
1398
+ break;
1399
+ }
1400
+ const placed = `${row.x},${row.y},${row.width},${row.height},${parent.x},${parent.y},${parent.width},${parent.height},${viewport},${own?.scrollHeight},${own?.scrollWidth},${direction}`;
1401
+ if (placed === submenu.lastLayout)
1402
+ continue;
1403
+ submenu.lastLayout = placed;
1404
+ this.placeSubmenu(submenu);
1405
+ changed = true;
1406
+ }
1407
+ return changed;
1408
+ };
1409
+ /** What is followed: the anchor, and the item of each submenu open as an overlay; sized: every surface and what scrolls in it. */
1410
+ this.following = new FollowController(this, {
1411
+ followed: () => [this.positionAnchor ?? this.anchorElement, ...this.overlaid().map((submenu) => submenu.rowElement)],
1412
+ sized: () => [this.surface, this.scrollBox, ...this.overlaid().flatMap((submenu) => [submenu.surfaceElement, submenu.scrollElement])],
1413
+ check: this.follow,
1414
+ });
1415
+ this.addEventListener('keydown', this.onKeyDown, { capture: true });
1416
+ this.addEventListener('pointerdown', this.onPointerDown, { capture: true });
1417
+ this.addEventListener('click', this.onClickCapture, { capture: true });
1418
+ this.addEventListener('click', this.onClick);
1419
+ this.addEventListener('pointermove', this.onPointerMove);
1420
+ this.addEventListener('pointerleave', this.onPointerLeave);
1421
+ this.addEventListener('mousedown', this.onMouseDown);
1422
+ this.addEventListener('focusin', this.onFocusIn);
1423
+ this.addEventListener('focusout', this.onFocusOut);
1424
+ this.addEventListener('tanrei-menu-item-update', () => this.sync());
1425
+ // Forwarded content (a <slot> child) changed what is assigned to it: the blocks' kinds (dividers) and the items.
1426
+ this.addEventListener('slotchange', () => {
1427
+ this.requestUpdate();
1428
+ this.sync();
1429
+ });
1430
+ }
1431
+ connectedCallback() {
1432
+ super.connectedCallback();
1433
+ this.children$.observe(this, { childList: true, subtree: true });
1434
+ this.readChildren();
1435
+ // POP-24: what it was opened from, wherever it stands in the document — a press or focus in a menu opened from a
1436
+ // control inside a popover is inside that popover (src/primitives/dismiss.ts). The popover closing takes focus back
1437
+ // to its own opener, which closes the menu by its own rule (MNU-5: focus leaving).
1438
+ this.unregister = registerOverlay(this, { openers: () => [this.positionAnchor, this.anchorElement], open: () => this.open && !this.inline });
1439
+ }
1440
+ disconnectedCallback() {
1441
+ super.disconnectedCallback();
1442
+ this.children$.disconnect();
1443
+ this.unregister?.();
1444
+ this.unregister = null;
1445
+ this.stopFollowing();
1446
+ this.forgetPointer();
1447
+ }
1448
+ readChildren() {
1449
+ const now = [...this.children];
1450
+ if (now.length !== this.blocks.length || now.some((child, i) => child !== this.blocks[i]))
1451
+ this.blocks = now;
1452
+ this.sync();
1453
+ }
1454
+ get surface() {
1455
+ return this.renderRoot?.querySelector('.surface') ?? null;
1456
+ }
1457
+ get scrollBox() {
1458
+ return this.renderRoot?.querySelector('.scroll') ?? null;
1459
+ }
1460
+ /** The menu's content: its children, a forwarding `<slot>` child standing for what is assigned to it. */
1461
+ get content() {
1462
+ return [...this.children].flatMap(resolved);
1463
+ }
1464
+ /** The elements of the content that match `selector`, in document order, that belong to this menu (not a nested one). */
1465
+ find(selector) {
1466
+ // A <slot> child of a submenu stands for what is assigned to it, as one of the menu's does (a folded menu of a
1467
+ // menubar forwards its items into the submenu item it draws, MBR-22).
1468
+ const forwarded = (el) => [...(el instanceof TanreiSubmenu ? [el] : []), ...el.querySelectorAll('tanrei-submenu')].flatMap((submenu) => [...submenu.children].filter((child) => child instanceof HTMLSlotElement).flatMap(resolved).flatMap(under));
1469
+ const under = (el) => [...(el.matches(selector) ? [el] : []), ...el.querySelectorAll(selector), ...forwarded(el)];
1470
+ return this.content.flatMap(under).filter((el) => this.owns(el));
1471
+ }
1472
+ /** Whether `node` is this menu's, in the flat tree: slotted or forwarded into it or into a submenu of it, or in a shadow root of theirs. */
1473
+ owns(node) {
1474
+ for (let at = node; at; at = flatParent(at)) {
1475
+ if (at === this)
1476
+ return true;
1477
+ if (at instanceof TanreiMenu)
1478
+ return false;
1479
+ }
1480
+ return false;
1481
+ }
1482
+ /** The surface `node` is in: the submenu that holds it, through that submenu's groups, or the menu itself (MNU-52). */
1483
+ levelOf(node) {
1484
+ for (let at = flatParent(node); at && at !== this; at = flatParent(at))
1485
+ if (at instanceof TanreiSubmenu)
1486
+ return at;
1487
+ return this;
1488
+ }
1489
+ /** Whether `node` is inside the submenu `submenu`: an item of its surface or of a surface opened from it. */
1490
+ within(node, submenu) {
1491
+ for (let at = node && node !== submenu ? flatParent(node) : null; at && at !== this; at = flatParent(at))
1492
+ if (at === submenu)
1493
+ return true;
1494
+ return false;
1495
+ }
1496
+ /** Every row of the tree by its surface, in focus order (MNU-7: never across levels). */
1497
+ tree() {
1498
+ if (this.levels)
1499
+ return this.levels;
1500
+ const levels = new Map();
1501
+ for (const row of this.find(ROWS)) {
1502
+ if (!(row instanceof TanreiMenuRowBase))
1503
+ continue;
1504
+ const level = this.levelOf(row);
1505
+ levels.set(level, [...(levels.get(level) ?? []), row]);
1506
+ }
1507
+ return (this.levels = levels);
1508
+ }
1509
+ /** The rows of one surface. */
1510
+ rowsOf(level) {
1511
+ return this.tree().get(level) ?? [];
1512
+ }
1513
+ /** The submenus of `level` whose surface is drawn now — at most one (MNU-48). */
1514
+ openIn(level) {
1515
+ return this.rowsOf(level).filter((row) => row instanceof TanreiSubmenu && row.presentation !== 'hidden');
1516
+ }
1517
+ /** The chain of open submenus, from the menu's own surface inward. */
1518
+ openChain(from = this) {
1519
+ const chain = [];
1520
+ for (let next = this.openIn(from)[0]; next; next = this.openIn(next)[0])
1521
+ chain.push(next);
1522
+ return chain;
1523
+ }
1524
+ get groups() {
1525
+ return this.find('tanrei-menu-group').filter((el) => el instanceof TanreiMenuGroup);
1526
+ }
1527
+ /** The element whose id is `anchor`. */
1528
+ get anchorElement() {
1529
+ if (!this.anchor)
1530
+ return null;
1531
+ const root = this.getRootNode();
1532
+ return root.getElementById?.(this.anchor) ?? null;
1533
+ }
1534
+ /** Where the anchor's ARIA states go: the anchor, or the button a custom element anchor draws in its open shadow root. */
1535
+ get anchorTarget() {
1536
+ const anchor = this.anchorElement;
1537
+ return anchor?.shadowRoot?.querySelector('button, [role="button"]') ?? anchor;
1538
+ }
1539
+ /** MNU-14: a placement the menu does not define is drawn as `bottom-start`. */
1540
+ get effectivePlacement() {
1541
+ return PLACEMENTS.includes(this.placement) ? this.placement : 'bottom-start';
1542
+ }
1543
+ /**
1544
+ * The outermost group of the item's own surface that holds `item` (MNU-29: a group in a group is drawn as its outer
1545
+ * group; MNU-52: a group's value reaches only the radio items of its own surface).
1546
+ */
1547
+ groupOf(item) {
1548
+ let group = null;
1549
+ for (let at = flatParent(item); at && at !== this && !(at instanceof TanreiSubmenu); at = flatParent(at))
1550
+ if (at instanceof TanreiMenuGroup)
1551
+ group = at;
1552
+ return group;
1553
+ }
1554
+ /**
1555
+ * Where an event came from: the item it is on, and the surface it is in — a submenu's surface around its items is
1556
+ * that submenu's level, its row an item of the level that holds it.
1557
+ */
1558
+ locate(event) {
1559
+ const path = event.composedPath();
1560
+ for (let i = 0; i < path.length; i += 1) {
1561
+ const node = path[i];
1562
+ if (node === this)
1563
+ return { item: null, level: this };
1564
+ if (!(node instanceof TanreiMenuRowBase) || !this.owns(node))
1565
+ continue;
1566
+ if (node instanceof TanreiSubmenu && node.surfaceElement && path.lastIndexOf(node.surfaceElement, i) >= 0)
1567
+ return { item: null, level: node };
1568
+ return { item: node, level: this.levelOf(node) };
1569
+ }
1570
+ return { item: null, level: null };
1571
+ }
1572
+ /** The item an event came from. */
1573
+ itemOf(event) {
1574
+ return this.locate(event).item;
1575
+ }
1576
+ /**
1577
+ * Tells every item and group what it is now (MNU-18, MNU-19, MNU-24, MNU-28, MNU-29, MNU-52), each surface by itself,
1578
+ * reports what it should, and draws the submenus that are open (MNU-43, MNU-48).
1579
+ */
1580
+ sync() {
1581
+ this.levels = null;
1582
+ const tree = this.tree();
1583
+ for (const group of this.groups) {
1584
+ let nested = false;
1585
+ for (let at = flatParent(group); at && at !== this && !(at instanceof TanreiSubmenu); at = flatParent(at))
1586
+ if (at instanceof TanreiMenuGroup)
1587
+ nested = true;
1588
+ if (nested)
1589
+ report(this, 'MNU-29', `the group "${group.label}" is inside another group; its items are drawn as the outer group's, without its title or a divider`);
1590
+ group.setMenuContext({ nested });
1591
+ }
1592
+ // MNU-31: the form the shortcuts are drawn in, as the cascade gives it now — never cached, so a system switch is seen
1593
+ // the next time the menu opens or changes.
1594
+ // Read for the first row there is: a menu without rows (the overflow menu of a breadcrumb trail that fits, drawn
1595
+ // with every trail of a page) asks the cascade nothing.
1596
+ let variant = null;
1597
+ const shortcut = () => (variant ??= getComputedStyle(this).getPropertyValue(SHORTCUT_VARIANT).trim() || DEFAULT_SHORTCUT_VARIANT);
1598
+ for (const [level, rows] of tree) {
1599
+ // MNU-19: each surface reserves its own columns.
1600
+ const markColumn = rows.some((row) => row instanceof TanreiMenuCheckboxItem || row instanceof TanreiMenuRadioItem);
1601
+ const iconColumn = rows.some((row) => !!row.leadingIcon);
1602
+ // MNU-55: a link item's mark reserves the column as a trailing icon does.
1603
+ const trailingIconColumn = rows.some((row) => row instanceof TanreiSubmenu || (row instanceof TanreiMenuItemBase && !!row.trailingIcon) || row.linkMarked);
1604
+ // MNU-29: which radio items each group checks, and what a debug build reports about them.
1605
+ const radios = new Map();
1606
+ for (const row of rows) {
1607
+ if (!(row instanceof TanreiMenuRadioItem))
1608
+ continue;
1609
+ const group = this.groupOf(row);
1610
+ radios.set(group, [...(radios.get(group) ?? []), row]);
1611
+ }
1612
+ for (const [group, members] of radios) {
1613
+ if (!group) {
1614
+ for (const radio of members)
1615
+ report(this, 'MNU-29', `the radio item "${radio.label}" is not inside a group, so it is never checked`);
1616
+ continue;
1617
+ }
1618
+ const values = members.map((radio) => radio.value);
1619
+ if (group.value !== null && group.value !== undefined && !values.includes(group.value))
1620
+ report(this, 'MNU-29', `the group "${group.label}" has the value "${group.value}", which none of its radio items has`);
1621
+ for (const value of new Set(values))
1622
+ if (values.filter((each) => each === value).length > 1)
1623
+ report(this, 'MNU-29', `two radio items of the group "${group.label}" share the value "${value}"`);
1624
+ }
1625
+ rows.forEach((row, index) => {
1626
+ const group = this.groupOf(row);
1627
+ const radioChecked = row instanceof TanreiMenuRadioItem && !!group && group.value !== null && group.value !== undefined && group.value === row.value;
1628
+ row.setMenuContext({ position: index + 1, size: rows.length, markColumn, iconColumn, trailingIconColumn, radioChecked, shortcutVariant: shortcut(), groupMarkIcon: group?.markIcon ?? '' });
1629
+ row.syncMark();
1630
+ });
1631
+ if (level instanceof TanreiSubmenu)
1632
+ syncSeparation(level, level.scrollElement);
1633
+ }
1634
+ // MNU-52: what a debug build says about the submenus — a third level, and one that holds no item.
1635
+ for (const submenu of this.find('tanrei-submenu')) {
1636
+ if (!(submenu instanceof TanreiSubmenu))
1637
+ continue;
1638
+ let depth = 1;
1639
+ for (let level = this.levelOf(submenu); level instanceof TanreiSubmenu; level = this.levelOf(level))
1640
+ depth += 1;
1641
+ // MBR-22: the level a menubar's overflow item adds is not the product's, and an empty menu of the bar is the bar's to report (MBR-20).
1642
+ const fold = !!this.bar?.fold;
1643
+ if (fold)
1644
+ depth -= 1;
1645
+ if (fold && depth === 0) {
1646
+ if (!tree.get(submenu)?.length)
1647
+ syncSeparation(submenu, submenu.scrollElement);
1648
+ continue;
1649
+ }
1650
+ if (depth > 2)
1651
+ report(this, 'MNU-52', `the submenu "${submenu.label}" is ${depth} levels below the menu; keep to one level of submenus where possible and never more than two — a set that needs more belongs in a dialog, a sheet or a page`);
1652
+ if (!tree.get(submenu)?.length) {
1653
+ report(this, 'MNU-52', `the submenu "${submenu.label}" holds no item, so it opens nothing; give it items or remove it`);
1654
+ syncSeparation(submenu, submenu.scrollElement);
1655
+ }
1656
+ }
1657
+ syncSeparation(this, this.scrollBox);
1658
+ this.presentSubmenus();
1659
+ }
1660
+ // ── Submenus (MNU-42 … MNU-52) ──
1661
+ /** Sets a submenu item's `open`; the person's own opening or closing fires its `toggle`, the product's and the menu's closing none. */
1662
+ setOpen(submenu, open, person) {
1663
+ if (submenu.open === open)
1664
+ return;
1665
+ submenu.open = open;
1666
+ submenu.openedAt = open ? ++opened : 0;
1667
+ if (person)
1668
+ submenu.dispatchEvent(new CustomEvent('toggle', { bubbles: true, detail: { open } }));
1669
+ }
1670
+ /**
1671
+ * Draws what the items' `open` say (MNU-43, MNU-48, MNU-52): in each surface that is shown, the submenu that is open —
1672
+ * the one opened last, where the product opened two — unless it is disabled or holds no item; nothing for a submenu
1673
+ * whose own surface is not shown. A submenu that is drawn is placed and grows in; one that no longer is fades out, and
1674
+ * focus that was inside it moves to its item.
1675
+ */
1676
+ presentSubmenus() {
1677
+ const tree = this.tree();
1678
+ const mode = !this.open ? 'hidden' : this.inline ? 'inline' : this.shown ? 'overlay' : 'hidden';
1679
+ const walk = (level, at) => {
1680
+ const submenus = (tree.get(level) ?? []).filter((row) => row instanceof TanreiSubmenu);
1681
+ let keep = null;
1682
+ if (at !== 'hidden') {
1683
+ for (const submenu of submenus) {
1684
+ if (!submenu.open || !tree.get(submenu)?.length)
1685
+ continue;
1686
+ if (submenu.disabled) {
1687
+ // MNU-51: a disabled submenu item's submenu is closed; one that was open says so.
1688
+ this.setOpen(submenu, false, submenu.presentation !== 'hidden');
1689
+ continue;
1690
+ }
1691
+ if (!keep || submenu.openedAt > keep.openedAt)
1692
+ keep = submenu;
1693
+ }
1694
+ // MNU-48: at most one submenu open in each surface.
1695
+ for (const submenu of submenus)
1696
+ if (submenu !== keep && submenu.open && !!tree.get(submenu)?.length)
1697
+ this.setOpen(submenu, false, false);
1698
+ }
1699
+ for (const submenu of submenus) {
1700
+ const own = submenu === keep ? at : 'hidden';
1701
+ // MNU-48: focus that was inside a submenu that closes alone moves to its item.
1702
+ if (own === 'hidden' && submenu.presentation !== 'hidden' && at !== 'hidden' && this.within(deepActive(), submenu))
1703
+ submenu.focusFromPointer();
1704
+ const changed = submenu.present(own, !!this.bar?.quick);
1705
+ if (own === 'overlay' && changed) {
1706
+ this.placeSubmenu(submenu);
1707
+ if (!this.bar?.quick)
1708
+ submenu.enter();
1709
+ this.following.request();
1710
+ }
1711
+ walk(submenu, own);
1712
+ }
1713
+ // MNU-19's verify: an inline surface lets the submenu drawn beside it show outside its own box.
1714
+ this.surfaceOf(level)?.classList.toggle('cascading', at === 'inline' && !!keep);
1715
+ };
1716
+ walk(this, mode);
1717
+ }
1718
+ surfaceOf(level) {
1719
+ return level === this ? this.surface : level.surfaceElement;
1720
+ }
1721
+ scrollOf(level) {
1722
+ return level === this ? this.scrollBox : level.scrollElement;
1723
+ }
1724
+ /**
1725
+ * MNU-43: opens a submenu item's submenu — any other of its surface closes — and, for a key, a press or a tap, moves
1726
+ * focus to its first enabled item (its first item where none is enabled), with the ring only for a key. One that is
1727
+ * already open only takes focus. A disabled submenu item and one without items open nothing (MNU-51, MNU-52).
1728
+ */
1729
+ openSubmenu(submenu, focus) {
1730
+ const rows = this.rowsOf(submenu);
1731
+ if (submenu.disabled || rows.length === 0)
1732
+ return;
1733
+ for (const other of this.openIn(this.levelOf(submenu)))
1734
+ if (other !== submenu)
1735
+ this.closeSubmenu(other, true, 'stay');
1736
+ this.setOpen(submenu, true, true);
1737
+ this.presentSubmenus();
1738
+ if (focus === 'stay')
1739
+ return;
1740
+ const first = rows.find((row) => !row.disabled) ?? rows[0];
1741
+ this.placeFocus(() => (focus === 'key' ? first.focus() : first.focusFromPointer()));
1742
+ }
1743
+ /** Moves focus as the menu's own doing (MNU-1, MNU-43), which closes no submenu of the surface focus lands in. */
1744
+ placeFocus(move) {
1745
+ this.placing = true;
1746
+ try {
1747
+ move();
1748
+ }
1749
+ finally {
1750
+ this.placing = false;
1751
+ }
1752
+ }
1753
+ /**
1754
+ * MNU-48: closes a submenu and every submenu opened from it, and nothing else; focus returns to its item — always for
1755
+ * a key (with the ring) or a press (without), and otherwise when it was inside.
1756
+ */
1757
+ closeSubmenu(submenu, person, focus) {
1758
+ if (this.apex?.submenu === submenu)
1759
+ this.endAim();
1760
+ if (focus === 'key')
1761
+ submenu.focus();
1762
+ else if (focus === 'pointer' || this.within(deepActive(), submenu)) {
1763
+ // Focus the pointer moved back draws no ring, even where it was a keyboard's before.
1764
+ if (submenu.matches(':focus'))
1765
+ submenu.blur();
1766
+ submenu.focusFromPointer();
1767
+ }
1768
+ for (const each of [...this.openChain(submenu)].reverse())
1769
+ this.setOpen(each, false, person);
1770
+ this.setOpen(submenu, false, person);
1771
+ this.presentSubmenus();
1772
+ }
1773
+ /** MNU-46, MNU-47: places a submenu's surface against its item, in viewport coordinates. */
1774
+ placeSubmenu(submenu) {
1775
+ const own = submenu.surfaceElement;
1776
+ const row = submenu.rowElement;
1777
+ const level = this.levelOf(submenu);
1778
+ const parent = this.surfaceOf(level);
1779
+ if (!own || !row || !parent || submenu.presentation !== 'overlay')
1780
+ return;
1781
+ // The lengths are read through real properties (a custom property holds an expression).
1782
+ const style = getComputedStyle(own);
1783
+ const offset = Number.parseFloat(style.scrollMarginBlockStart) || 0;
1784
+ const margin = Number.parseFloat(style.scrollMarginBlockEnd) || 0;
1785
+ const touch = Number.parseFloat(style.scrollMarginInlineStart) || 0;
1786
+ const minWidth = Number.parseFloat(style.scrollMarginInlineEnd) || 0;
1787
+ // The height is measured as the surface stands, never by lifting the cap (MNU-2's place() says why): uncapped, the
1788
+ // list would not scroll, and a scrolled submenu placed again — its item moving, the window resizing — would be sent
1789
+ // back to its top. Its width is measured free of the narrowing a last placement gave it: wider, its items may take
1790
+ // fewer lines and the list be shorter than its offset for a moment, so the offset is put back once it is placed.
1791
+ const scroll = submenu.scrollElement;
1792
+ const scrolled = scroll?.scrollTop ?? 0;
1793
+ own.style.inlineSize = '';
1794
+ const viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };
1795
+ const rtl = getComputedStyle(submenu).direction === 'rtl';
1796
+ // MNU-46: a submenu opened from a surface placed on the other side tries that side first.
1797
+ const prefer = level instanceof TanreiSubmenu ? level.side : null;
1798
+ const first = this.rowsOf(submenu)[0];
1799
+ const input = { parent: parent.getBoundingClientRect(), row: row.getBoundingClientRect(), viewport, offset, margin, minWidth, touch, rtl, prefer };
1800
+ const lead = () => (first ? first.getBoundingClientRect().top - own.getBoundingClientRect().top + (submenu.scrollElement?.scrollTop ?? 0) : 0);
1801
+ // The surface's size as laid out, fractional (layoutSize): a snapped width would end it up to a pixel off its edge.
1802
+ const free = layoutSize(own).width;
1803
+ let at = placeSubmenu({ ...input, surface: { width: free, height: naturalHeight(own, scroll) }, lead: lead() });
1804
+ if (at.width < free) {
1805
+ // Narrowed, its items wrap: it is placed again at the height that gives.
1806
+ own.style.inlineSize = `${at.width}px`;
1807
+ at = placeSubmenu({ ...input, surface: { width: layoutSize(own).width, height: naturalHeight(own, scroll) }, lead: lead() });
1808
+ }
1809
+ own.style.top = `${at.top}px`;
1810
+ own.style.left = `${at.left}px`;
1811
+ own.style.maxBlockSize = `${at.maxHeight}px`;
1812
+ if (scroll && scroll.scrollTop !== scrolled)
1813
+ scroll.scrollTop = scrolled;
1814
+ own.classList.toggle('side-left', at.side === 'left');
1815
+ submenu.side = at.side;
1816
+ submenu.overlap = at.overlap;
1817
+ }
1818
+ /** MNU-44: `comp.menu.motion.submenu-delay`, read through a real property of the menu's (a duration token is an expression). */
1819
+ get submenuDelay() {
1820
+ const scroll = this.scrollBox;
1821
+ return scroll ? (Number.parseFloat(getComputedStyle(scroll).transitionDelay) || 0) * 1000 : 0;
1822
+ }
1823
+ /** MNU-45: the pointer is no longer on its way to a submenu — the items it crossed answer hover again. */
1824
+ endAim() {
1825
+ if (this.pause !== null)
1826
+ clearTimeout(this.pause);
1827
+ this.pause = null;
1828
+ this.apex = null;
1829
+ for (const item of this.crossed)
1830
+ item.suppressHover(false);
1831
+ this.crossed.clear();
1832
+ }
1833
+ stopResting() {
1834
+ if (this.resting)
1835
+ clearTimeout(this.resting.timer);
1836
+ this.resting = null;
1837
+ }
1838
+ forgetPointer() {
1839
+ this.stopResting();
1840
+ this.endAim();
1841
+ this.pointerItem = null;
1842
+ this.swallowClick = false;
1843
+ }
1844
+ /**
1845
+ * MNU-8, MNU-44, MNU-48: the pointer is on `item` — focus follows it without the ring, another submenu of its surface
1846
+ * closes, and a submenu item it rests on for `submenu-delay` opens, focus staying on the item.
1847
+ */
1848
+ hover(item) {
1849
+ if (!this.focusless)
1850
+ item.focusFromPointer();
1851
+ for (const other of this.openIn(this.levelOf(item)))
1852
+ if (other !== item)
1853
+ this.closeSubmenu(other, true, 'stay');
1854
+ if (!(item instanceof TanreiSubmenu) || item.disabled || item.presentation !== 'hidden') {
1855
+ this.stopResting();
1856
+ return;
1857
+ }
1858
+ if (this.resting?.item === item)
1859
+ return;
1860
+ this.stopResting();
1861
+ const timer = setTimeout(() => {
1862
+ this.resting = null;
1863
+ if (this.open && this.pointerItem === item)
1864
+ this.openSubmenu(item, 'stay');
1865
+ }, this.submenuDelay);
1866
+ this.resting = { item, timer };
1867
+ }
1868
+ /** MNU-5: asks the product to close the menu, once, with the reason. Nothing is asked of a closed menu. */
1869
+ requestClose(reason) {
1870
+ if (!this.open || this.closeRequested)
1871
+ return;
1872
+ this.closeRequested = true;
1873
+ this.dispatchEvent(new CustomEvent('close', { detail: { reason } }));
1874
+ }
1875
+ /** MNU-45: whether the pointer is inside the triangle to `submenu`'s surface, which follows the side it is placed on. */
1876
+ onTheWay(event, submenu) {
1877
+ const surface = submenu.surfaceElement;
1878
+ const row = submenu.rowElement;
1879
+ if (!surface || !row || !this.apex)
1880
+ return false;
1881
+ const box = surface.getBoundingClientRect();
1882
+ // The side that faces the item: the nearer edge of the submenu's surface, wherever it was placed (or drawn in place).
1883
+ const at = row.getBoundingClientRect();
1884
+ const near = Math.abs(box.left - (at.left + at.width / 2)) <= Math.abs(box.right - (at.left + at.width / 2)) ? box.left : box.right;
1885
+ const facing = submenu.presentation === 'overlay' ? (submenu.overlap ? near : submenu.side === 'right' ? box.left : box.right) : near;
1886
+ return inTriangle({ x: event.clientX, y: event.clientY }, this.apex, { x: facing, y: box.top }, { x: facing, y: box.bottom });
1887
+ }
1888
+ /**
1889
+ * MNU-1's move, when a focusless menu becomes an ordinary one while open (SPB-24): focus to the first enabled item.
1890
+ * @internal
1891
+ */
1892
+ focusFirstItem() {
1893
+ const items = this.rowsOf(this);
1894
+ // MBR-9: a menubar's menu opened with Up Arrow takes focus on its last enabled item, and one opened by a pointer without the ring.
1895
+ const { end, quiet } = this.bar?.entry ?? { end: 'first', quiet: false };
1896
+ const item = end === 'last' ? ([...items].reverse().find((each) => !each.disabled) ?? items.at(-1)) : (items.find((each) => !each.disabled) ?? items[0]);
1897
+ this.placeFocus(() => (quiet ? item?.focusFromPointer() : item?.focus()));
1898
+ }
1899
+ /** MNU-2: places the surface against the anchor, in viewport coordinates. */
1900
+ place() {
1901
+ const surface = this.surface;
1902
+ const scroll = this.scrollBox;
1903
+ if (!surface || !scroll || this.inline || !this.shown)
1904
+ return;
1905
+ const style = getComputedStyle(surface);
1906
+ const offset = Number.parseFloat(style.scrollMarginBlockStart) || 0;
1907
+ const margin = Number.parseFloat(style.scrollMarginBlockEnd) || 0;
1908
+ // The surface's size as laid out, fractional and untouched by the enter motion's scale (layoutSize): a snapped
1909
+ // one would put an end-aligned or top-side surface up to a pixel off its anchor.
1910
+ const size = { width: layoutSize(surface).width, height: naturalHeight(surface, scroll) };
1911
+ const box = (this.positionAnchor ?? this.anchorElement)?.getBoundingClientRect() ?? { x: margin, y: margin, width: 0, height: 0 };
1912
+ const viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };
1913
+ const rtl = getComputedStyle(this).direction === 'rtl';
1914
+ const at = placeMenu({ anchor: box, surface: size, viewport, placement: this.effectivePlacement, offset, margin, rtl });
1915
+ surface.style.top = `${at.top}px`;
1916
+ surface.style.left = `${at.left}px`;
1917
+ surface.style.maxBlockSize = `${at.maxHeight}px`;
1918
+ surface.classList.toggle('side-top', at.side === 'top');
1919
+ }
1920
+ overlaid() {
1921
+ return this.openChain().filter((submenu) => submenu.presentation === 'overlay');
1922
+ }
1923
+ stopFollowing() {
1924
+ this.following.stop();
1925
+ this.lastLayout = '';
1926
+ document.removeEventListener('pointerdown', this.onOutsidePress, true);
1927
+ }
1928
+ /** MNU-24: the anchor says it opens a menu, whether it is open, and which. */
1929
+ syncAnchor() {
1930
+ const target = this.anchorTarget;
1931
+ if (!target)
1932
+ return;
1933
+ if (!this.id)
1934
+ this.id = `tanrei-menu-${++ids}`;
1935
+ hostAria(target, {
1936
+ 'aria-haspopup': 'menu',
1937
+ 'aria-expanded': String(this.open),
1938
+ 'aria-controls': target.getRootNode() === this.getRootNode() ? this.id : null,
1939
+ });
1940
+ }
1941
+ /** MNU-1, MNU-4: into the top layer, placed, growing in; focus to the first enabled item. */
1942
+ show() {
1943
+ const surface = this.surface;
1944
+ if (!surface)
1945
+ return;
1946
+ this.live = true;
1947
+ surface.classList.toggle('inline', this.inline);
1948
+ if (this.inline)
1949
+ return;
1950
+ surface.classList.remove('leaving');
1951
+ if (!surface.matches(':popover-open'))
1952
+ surface.showPopover();
1953
+ this.shown = true;
1954
+ this.place();
1955
+ this.following.start();
1956
+ document.addEventListener('pointerdown', this.onOutsidePress, true);
1957
+ surface.classList.remove('entering');
1958
+ // MBR-29: no open motion where it takes the place of another menu of a menubar.
1959
+ if (!this.bar?.quick) {
1960
+ void surface.offsetWidth; // restart the animation
1961
+ surface.classList.add('entering');
1962
+ }
1963
+ if (!this.focusless)
1964
+ this.focusFirstItem();
1965
+ }
1966
+ /** MNU-1, MNU-4, MNU-49: focus back to the anchor if it was inside; every submenu closed with it; fading out, then out of the top layer. */
1967
+ hide() {
1968
+ const surface = this.surface;
1969
+ this.stopFollowing();
1970
+ this.forgetPointer();
1971
+ if (!surface)
1972
+ return;
1973
+ surface.classList.remove('inline', 'entering', 'cascading');
1974
+ if (this.live) {
1975
+ this.live = false;
1976
+ // MNU-49: every open submenu closes with the menu, its `open` set without a `toggle`.
1977
+ for (const rows of this.tree().values())
1978
+ for (const row of rows)
1979
+ if (row instanceof TanreiSubmenu)
1980
+ this.setOpen(row, false, false);
1981
+ }
1982
+ if (!this.shown)
1983
+ return;
1984
+ this.shown = false;
1985
+ // Not :focus-within: it does not match the host while a slotted item has focus inside the top-layer surface. The
1986
+ // focused element, through shadow roots: a forwarded item is not in the menu's own tree. MNU-49: from whatever level.
1987
+ if (this.owns(deepActive()))
1988
+ this.anchorElement?.focus();
1989
+ // MBR-29: no close motion where it gives its place to another menu of a menubar.
1990
+ if (this.bar?.quick) {
1991
+ surface.classList.remove('leaving');
1992
+ if (surface.matches(':popover-open'))
1993
+ surface.hidePopover();
1994
+ return;
1995
+ }
1996
+ surface.classList.add('leaving');
1997
+ const finish = () => {
1998
+ if (this.open || !surface.classList.contains('leaving'))
1999
+ return;
2000
+ surface.classList.remove('leaving');
2001
+ if (surface.matches(':popover-open'))
2002
+ surface.hidePopover();
2003
+ };
2004
+ const running = surface.getAnimations();
2005
+ if (running.length === 0)
2006
+ finish();
2007
+ else
2008
+ void Promise.allSettled(running.map((animation) => animation.finished)).then(finish);
2009
+ }
2010
+ willUpdate(changed) {
2011
+ // MNU-14: a placement the menu does not define is drawn as bottom-start; a debug build says so.
2012
+ if (changed.has('placement') && !PLACEMENTS.includes(this.placement)) {
2013
+ report(this, 'MNU-14', `placement "${this.placement}" is not a value the menu defines; it is drawn as "bottom-start"`);
2014
+ }
2015
+ // MNU-35: a separation the menu does not define is auto (no rule matches the attribute); a debug build says so.
2016
+ if (changed.has('separation') && !SEPARATION_VALUES.includes(this.separation)) {
2017
+ report(this, 'MNU-35', `separation "${this.separation}" is not a value the menu defines; it is drawn as "auto"`);
2018
+ }
2019
+ }
2020
+ updated(changed) {
2021
+ // Each child in its own slot (MNU-23, MNU-36: the divider and the gap are drawn between the slots).
2022
+ assignBlocks(this.renderRoot, this.blocks);
2023
+ const anchor = this.anchorElement;
2024
+ // MNU-24: the menu role while open, named by its anchor.
2025
+ hostAria(this, {
2026
+ role: this.open ? 'menu' : null,
2027
+ 'aria-labelledby': this.open && anchor?.id && anchor.getRootNode() === this.getRootNode() ? anchor.id : null,
2028
+ });
2029
+ this.syncAnchor();
2030
+ if (changed.has('open') || changed.has('inline')) {
2031
+ this.closeRequested = false;
2032
+ if (this.open)
2033
+ this.show();
2034
+ else
2035
+ this.hide();
2036
+ }
2037
+ if (changed.has('placement') && this.open)
2038
+ this.place();
2039
+ this.sync();
2040
+ }
2041
+ render() {
2042
+ return html `
2043
+ <div part="surface" class="surface" data-tanrei-shape popover=${this.inline ? nothing : 'manual'} role="none">
2044
+ <div part="scroll" class="scroll">${blocksTemplate(this.blocks)}</div>
2045
+ </div>
2046
+ `;
2047
+ }
2048
+ }
2049
+ if (!customElements.get('tanrei-menu-item'))
2050
+ customElements.define('tanrei-menu-item', TanreiMenuItem);
2051
+ if (!customElements.get('tanrei-menu-checkbox-item'))
2052
+ customElements.define('tanrei-menu-checkbox-item', TanreiMenuCheckboxItem);
2053
+ if (!customElements.get('tanrei-menu-radio-item'))
2054
+ customElements.define('tanrei-menu-radio-item', TanreiMenuRadioItem);
2055
+ if (!customElements.get('tanrei-submenu'))
2056
+ customElements.define('tanrei-submenu', TanreiSubmenu);
2057
+ if (!customElements.get('tanrei-menu-group'))
2058
+ customElements.define('tanrei-menu-group', TanreiMenuGroup);
2059
+ if (!customElements.get('tanrei-menu'))
2060
+ customElements.define('tanrei-menu', TanreiMenu);
2061
+ //# sourceMappingURL=menu.js.map