@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,1917 @@
1
+ import { LitElement, html, nothing } from 'lit';
2
+ import { classMap } from 'lit/directives/class-map.js';
3
+ import { styleMap } from 'lit/directives/style-map.js';
4
+ import { AvailabilityController, DestinationsController, GlyphMirrorController, LINK_MARK, LinkController, OpenAxesController, PressController, badgeDescription, deepActive, findInteractive, holdPageScroll, lineArrow, linkAttributes, markConditionChange, modalLayer, notifyDestinationUpdate, readDestination, report, syncFocusStyle, tabbables, trapFocus, } from '../../primitives/index.js';
5
+ // Not re-exported by the primitives' index: internal to a region and its destinations.
6
+ import { askDestinationContext } from '../../primitives/destination.js';
7
+ import { ownDirection } from '../../styles/product-text.js';
8
+ import { TanreiBadge } from '../badge/badge.js';
9
+ import { TanreiDivider } from '../divider/divider.js';
10
+ import { TanreiTooltip } from '../tooltip/tooltip.js';
11
+ import { AXES, cellStyles, drawerStyles, groupStyles, sectionStyles } from './navigation-drawer.styles.js';
12
+ /** How far a drag toward the start edge must go before the drawer follows it (NVD-20: no platform value on the web). */
13
+ const TOUCH_SLOP = 8;
14
+ /** A release at least this fast toward the start edge is a fling (NVD-20), in px per ms. */
15
+ const FLING_VELOCITY = 0.5;
16
+ /** Groups nested deeper than this are reported (NVD-48). */
17
+ const DEEPEST = 3;
18
+ const ITEM = 'tanrei-navigation-drawer-item';
19
+ const GROUP = 'tanrei-navigation-drawer-group';
20
+ const SECTION = 'tanrei-navigation-drawer-section';
21
+ const DRAWER = 'tanrei-navigation-drawer';
22
+ /** The drawer's cells: its destinations and its groups' rows. */
23
+ const CELLS = `${ITEM}, ${GROUP}`;
24
+ /** A duration as the browser computes it ("0.5s"), in ms. */
25
+ const ms = (value) => (Number.parseFloat(value) || 0) * (value.trim().endsWith('ms') ? 1 : 1000);
26
+ /** Whether an update changed `key` (a private or protected reactive property, which `PropertyValues<this>` does not name). */
27
+ const has = (changed, key) => changed.has(key);
28
+ /** The groups that hold `cell`, outermost first (within its drawer). */
29
+ function groupsOf(cell) {
30
+ const groups = [];
31
+ for (let at = cell.parentElement; at && at.localName !== DRAWER; at = at.parentElement)
32
+ if (at instanceof TanreiNavigationDrawerGroup)
33
+ groups.unshift(at);
34
+ return groups;
35
+ }
36
+ const REST = { selected: false, position: 0, size: 0, labelShown: true, collapsed: false, collapsible: false, shortShown: false, labels: false, level: 0 };
37
+ /**
38
+ * What a destination and a group's row share: the cell — the drawer's full width, the hit area — with its row laid out
39
+ * for the expanded drawer (the icon on the icon column, the label, the trailing content), the item container that is the
40
+ * row while expanded and the row cut after its icon while collapsed, the short label where collapsedLabels draws one, the
41
+ * tooltip that names a collapsed cell without one, and the states, press and focus (NVD-4…10, NVD-31…35, NVD-56).
42
+ */
43
+ class DrawerCell extends LitElement {
44
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true }; }
45
+ static { this.properties = {
46
+ label: { type: String },
47
+ shortLabel: { type: String, attribute: 'short-label' },
48
+ icon: { type: String },
49
+ disabled: { type: Boolean, reflect: true },
50
+ context: { state: true },
51
+ }; }
52
+ constructor() {
53
+ super();
54
+ /** Its name, drawn beside the icon while the drawer is expanded and always its accessible name. Required. */
55
+ this.label = '';
56
+ /** What the collapsed drawer draws under the icon, on one line ("Files" for "My files"), where the drawer's `collapsedLabels` draws labels. Empty draws the label, truncated. */
57
+ this.shortLabel = '';
58
+ /** The name of a glyph of the system's icon set: outlined while unselected, filled while selected. Empty draws none. A glyph the icon set flags as showing a direction (`arrow_forward`, `send`) is drawn mirrored in a right-to-left layout. */
59
+ this.icon = '';
60
+ /** Unavailable: it keeps its place and its disabled look, cannot be activated and leaves the focus order. */
61
+ this.disabled = false;
62
+ this.context = { ...REST };
63
+ /** Whether the drawer has told it anything yet: the first selection is drawn, not animated. */
64
+ this.told = false;
65
+ this.grow = false;
66
+ /**
67
+ * NVD-51: a destination's and a group's glyph, and a glyph the product put in the trailing slot, are marked when the
68
+ * icon set mirrors their names in right-to-left (src/primitives/glyph-mirror.ts); `iconGlyph()` draws the mark. A
69
+ * group's chevron (`expand_more`, NVD-44) is not named here.
70
+ */
71
+ this.mirror = new GlyphMirrorController(this, { drawn: '.icon, .link-mark', slots: 'slot[name="trailing"]' });
72
+ /** NVD-8, NVD-9: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
73
+ this.press = new PressController(this, {
74
+ container: () => this.renderRoot?.querySelector('.container') ?? null,
75
+ holdCarrier: () => this.renderRoot?.querySelector('.hold') ?? null,
76
+ disabled: () => this.disabled,
77
+ keys: () => this.pressKeys,
78
+ // A press outside the item container (elsewhere in the cell) grows the ripple from its centre.
79
+ origin: (at) => {
80
+ const box = this.renderRoot?.querySelector('.container')?.getBoundingClientRect();
81
+ return box && at.x >= box.left && at.x <= box.right && at.y >= box.top && at.y <= box.bottom ? at : null;
82
+ },
83
+ });
84
+ /** NVD-10: where style queries are missing, the focus style is read when focus arrives. NVD-56: keyboard focus names a collapsed cell, without the hover's delay. */
85
+ this.onFocus = () => {
86
+ syncFocusStyle(this, this.cell);
87
+ if (!this.cell?.matches(':focus-visible') || !this.unnamed)
88
+ return;
89
+ // In the next frame: the browser brings a focused cell into view first, and a tooltip whose anchor is outside the
90
+ // window does not open.
91
+ cancelAnimationFrame(this.tipFrame);
92
+ this.tipFrame = requestAnimationFrame(() => {
93
+ if (this.cell?.matches(':focus-visible'))
94
+ this.showName(true);
95
+ });
96
+ };
97
+ this.tipFrame = 0;
98
+ this.hovered = false;
99
+ /** NVD-56: a fine pointer resting on the cell shows its name after the tooltip's show delay; a touch does not. */
100
+ this.onPointerEnter = (event) => {
101
+ if (event.pointerType === 'touch' || !this.unnamed || this.disabled)
102
+ return;
103
+ this.hovered = true;
104
+ clearTimeout(this.tipTimer);
105
+ this.tipTimer = setTimeout(() => {
106
+ if (this.hovered && this.unnamed)
107
+ this.showName(true);
108
+ }, this.tipWaits().show);
109
+ };
110
+ this.onPointerLeave = (event) => {
111
+ this.press.release();
112
+ if (event.pointerType === 'touch')
113
+ return;
114
+ this.hovered = false;
115
+ clearTimeout(this.tipTimer);
116
+ // It stays while the cell has keyboard focus, as a tooltip does.
117
+ if (this.cell?.matches(':focus-visible'))
118
+ return;
119
+ this.tipTimer = setTimeout(() => this.showName(false), this.tipWaits().hide);
120
+ };
121
+ /** An activation closes the tooltip, and so does focus leaving the cell. */
122
+ this.hideName = () => {
123
+ this.hovered = false;
124
+ this.showName(false);
125
+ };
126
+ this.onBlur = () => {
127
+ this.press.onBlur();
128
+ if (!this.hovered)
129
+ this.showName(false);
130
+ };
131
+ // A disabled cell swallows every click that reaches it, from its content or dispatched on it.
132
+ this.addEventListener('click', (event) => {
133
+ if (this.disabled) {
134
+ event.preventDefault();
135
+ event.stopImmediatePropagation();
136
+ }
137
+ }, { capture: true });
138
+ }
139
+ /** The keys that press the cell: Enter and Space (undefined), and Enter alone for a destination that is a link (NVD-1). */
140
+ get pressKeys() {
141
+ return undefined;
142
+ }
143
+ /** @internal The drawer's side. */
144
+ setDrawerContext(context) {
145
+ const now = this.context;
146
+ if (Object.keys(context).every((key) => context[key] === now[key]) && this.told)
147
+ return;
148
+ this.grow = this.told && context.selected && !now.selected && context.collapsed === now.collapsed;
149
+ this.told = true;
150
+ this.context = context;
151
+ }
152
+ /** @internal The native button or link: the cell. */
153
+ get cell() {
154
+ return this.renderRoot?.querySelector('.cell') ?? null;
155
+ }
156
+ /** The group that holds it, if any. */
157
+ get parentGroup() {
158
+ return this.parentElement?.closest(GROUP) ?? null;
159
+ }
160
+ /** NVD-56: whether this cell is one the collapsed drawer draws without a label, so that its name is shown beside it. */
161
+ get unnamed() {
162
+ return this.context.collapsed && !this.context.shortShown && this.context.level === 0 && !!this.label;
163
+ }
164
+ get tip() {
165
+ return this.renderRoot?.querySelector('.tip') ?? null;
166
+ }
167
+ /** NVD-56: shows or hides the cell's name beside it. The tooltip is the tooltip component's plain one, opened by the cell. */
168
+ showName(shown) {
169
+ clearTimeout(this.tipTimer);
170
+ if (!shown)
171
+ cancelAnimationFrame(this.tipFrame);
172
+ const tip = this.tip;
173
+ if (tip && tip.open !== shown)
174
+ tip.open = shown;
175
+ }
176
+ /** The tooltip's waits, as its tokens resolve now, in ms. */
177
+ tipWaits() {
178
+ const clock = this.renderRoot?.querySelector('.tip-clock');
179
+ const style = clock ? getComputedStyle(clock) : null;
180
+ return { show: ms(style?.transitionDelay ?? ''), hide: ms(style?.transitionDuration ?? '') };
181
+ }
182
+ /** Whether `key` is the arrow toward the end of the line (Right in a left-to-right layout), or toward its start. */
183
+ arrow(key) {
184
+ return lineArrow(key, this);
185
+ }
186
+ /** NVD-45: on an item inside an open group, the arrow toward the start moves focus to the group's row. */
187
+ leaveToGroup(event) {
188
+ if (this.context.collapsed || this.arrow(event.key) !== 'start')
189
+ return false;
190
+ const group = this.parentGroup;
191
+ if (!group || group.disabled)
192
+ return false;
193
+ event.preventDefault();
194
+ // The row itself: focusing the group's host would not move focus from an item inside it (it already holds it).
195
+ group.cell?.focus();
196
+ return true;
197
+ }
198
+ disconnectedCallback() {
199
+ super.disconnectedCallback();
200
+ clearTimeout(this.tipTimer);
201
+ cancelAnimationFrame(this.tipFrame);
202
+ this.hovered = false;
203
+ }
204
+ willUpdate(changed) {
205
+ // The first render draws the cell as what it is: the drawer tells it before, whatever order the elements were defined in.
206
+ if (!this.told)
207
+ askDestinationContext(this);
208
+ const before = changed.get('context');
209
+ if (before && before.selected !== this.context.selected && before.collapsed === this.context.collapsed)
210
+ markConditionChange(this.cell);
211
+ // NVD-56: a cell that draws its label again, or leaves the collapsed form, has no tooltip to leave open.
212
+ if (!this.unnamed)
213
+ clearTimeout(this.tipTimer);
214
+ }
215
+ updated(changed) {
216
+ const { position, size } = this.context;
217
+ // NVD-23: a list item of its level's list, its position among the items of its level.
218
+ this.setAttribute('role', 'listitem');
219
+ if (position)
220
+ this.setAttribute('aria-posinset', String(position));
221
+ if (size)
222
+ this.setAttribute('aria-setsize', String(size));
223
+ if (this.grow) {
224
+ this.grow = false;
225
+ this.growIndicator();
226
+ }
227
+ // NVD-34: the short label should be a part of the label, which stays the accessible name.
228
+ if ((changed.has('shortLabel') || changed.has('label')) && this.shortLabel && !this.label.toLowerCase().includes(this.shortLabel.toLowerCase())) {
229
+ report(this, 'NVD-34', `shortLabel "${this.shortLabel}" is not a part of label "${this.label}", so the visible name is not part of the accessible name; make it a part of the label`);
230
+ }
231
+ }
232
+ /**
233
+ * NVD-41: the newly selected cell's icon indicator — which only a system that marks the selection behind the glyph
234
+ * fills — grows in width from its centre, at its full height, over the selection motion. The item container is never
235
+ * resized to show a selection: it changes color in place (the styles).
236
+ */
237
+ growIndicator() {
238
+ const indicator = this.renderRoot.querySelector('.icon-indicator');
239
+ if (!indicator || typeof indicator.animate !== 'function')
240
+ return;
241
+ const style = getComputedStyle(indicator);
242
+ const duration = ms(style.animationDuration);
243
+ for (const running of indicator.getAnimations())
244
+ if (running.id === 'tanrei-drawer-grow')
245
+ running.cancel();
246
+ if (duration <= 0)
247
+ return;
248
+ const animation = indicator.animate([{ inlineSize: '0px' }, { inlineSize: style.inlineSize }], { duration, easing: style.animationTimingFunction || 'ease' });
249
+ animation.id = 'tanrei-drawer-grow';
250
+ }
251
+ /** The cell's classes: its condition, its state and its form. */
252
+ cellClasses(extra = {}) {
253
+ const { selected, collapsed, collapsible, shortShown, labels } = this.context;
254
+ return { cell: true, selected, d: this.disabled, collapsed, collapsible, 'short-shown': shortShown, 'no-labels': !labels, 'no-icon': !this.icon, ...extra };
255
+ }
256
+ /** Its level of nesting, for the item container's, the icon's and the label's indent (NVD-13, NVD-44). */
257
+ cellStyle() {
258
+ return { '--_level': String(this.context.level) };
259
+ }
260
+ /** The glyph (hidden from assistive technology); a destination puts its badge on it. */
261
+ glyph() {
262
+ return html `<span part="icon" class="icon" aria-hidden="true">${this.icon}</span>`;
263
+ }
264
+ /**
265
+ * The row: the item container (the active indicator, the state layer's box), the icon indicator with the icon on the
266
+ * icon column, the label, the trailing content, the short label under the icon — and, for a collapsed cell that draws
267
+ * no label, the plain tooltip that shows its name beside it (NVD-56). Everything but the cell itself is hidden from
268
+ * assistive technology: the cell is named by the label, and the tooltip says nothing a second time.
269
+ */
270
+ row(trailing) {
271
+ return html `
272
+ <span class="row">
273
+ <span part="container" class="container" data-tanrei-shape><span part="active-indicator" class="indicator" aria-hidden="true"></span></span>
274
+ <span class="lead" aria-hidden="true">
275
+ <span part="icon-indicator" class="icon-indicator" data-tanrei-shape></span>
276
+ ${this.icon ? this.glyph() : nothing}
277
+ </span>
278
+ <span part="label" class="label" aria-hidden="true">${this.label}</span>
279
+ ${trailing}
280
+ <span part="short-label" class="short" aria-hidden="true"><span class="short-text" dir=${ownDirection(this.shortLabel || this.label)}>${this.shortLabel || this.label}</span></span>
281
+ ${this.unnamed ? html `<tanrei-tooltip class="tip" no-describe aria-hidden="true" placement="end" .text=${this.label}></tanrei-tooltip>` : nothing}
282
+ </span>
283
+ <span class="hold"></span><span class="tip-clock"></span>
284
+ `;
285
+ }
286
+ }
287
+ /**
288
+ * One destination of a navigation drawer — the spec's item kind `destination`: an icon, a label (a short label
289
+ * while the drawer is collapsed), optional trailing content at the end of its row and an optional badge on its icon. A
290
+ * child of `<tanrei-navigation-drawer>`, of one of its sections or of one of its groups, in order.
291
+ *
292
+ * It is a button, or with `href` a link (NVD-59): an `<a href>` in the shadow root, drawn exactly as the button
293
+ * is, whose context menu, new-tab clicks, drag and address are the browser's own; Enter follows it and Space does not.
294
+ * A link is not selected by a press (NVD-60): a plain activation makes the drawer fire `change` (or `reselect`) —
295
+ * cancelable, with `detail.href`, before the browser follows the link — and the page shown next sets the drawer's
296
+ * `value`; a modified or a middle click, a link whose `target` is `new` and a download fire nothing. Without a `value`
297
+ * a link's `href` is its value. `target="new"` opens a new tab, safely (`noopener`), ends the expanded row with the icon
298
+ * set's `open_in_new` unless the row has trailing content, and says `targetLabel` (NVD-63).
299
+ *
300
+ * Either is named by its label in both forms, the selected one `aria-current="page"`; its badge's description, then its
301
+ * trailing content and then, for a link that opens a new context, `targetLabel` are its description. Its host is a
302
+ * list item, its position counted among the items of its level.
303
+ *
304
+ * @tag tanrei-navigation-drawer-item
305
+ * @slot trailing - Content at the end of the expanded row, in place of `trailing-text`: a glyph of the icon set (drawn at comp.navigation-drawer.item.trailing-icon.size, e.g. `open_in_new`), a badge, a short text. Not interactive.
306
+ * @csspart cell - The whole cell: the native button or link, the hit area.
307
+ * @csspart container - The item container: the row while expanded (starting `item.nest-indent` further in per level of nesting), and while collapsed the row cut after its icon, with the row's height and corners in the default system; the state layer's box, the focus ring's and the ripple's.
308
+ * @csspart active-indicator - The fill of the item container (the active indicator while selected): it changes color in place and is never resized to show a selection.
309
+ * @csspart icon-indicator - The box behind the icon alone (transparent in the default system).
310
+ * @csspart icon - The glyph (hidden from assistive technology).
311
+ * @csspart label - The label beside the icon (hidden from assistive technology: the cell is named by it).
312
+ * @csspart short-label - The short label under the icon while collapsed, where the drawer's `collapsed-labels` draws one (hidden from assistive technology).
313
+ * @csspart trailing-text - The trailing text.
314
+ * @csspart link-mark - The `open_in_new` glyph that ends a link which opens a new context, where the row has no trailing content (hidden from assistive technology).
315
+ */
316
+ export class TanreiNavigationDrawerItem extends DrawerCell {
317
+ constructor() {
318
+ super(...arguments);
319
+ this.given = '';
320
+ /** Short text at the end of the expanded row ("24", "New"), quieter than the label; the trailing slot's content wins. */
321
+ this.trailingText = '';
322
+ /** Draws a Tanrei badge on the icon, in both forms, from `badgeCount` and `badgeLabel`. */
323
+ this.badge = false;
324
+ /** The badge's count: null (no attribute) draws the dot, 0 nothing, above 0 the number (999+ above 999). */
325
+ this.badgeCount = null;
326
+ /** What assistive technology reads after the destination's name and state ("3 unread"). A dot needs one. */
327
+ this.badgeLabel = '';
328
+ /** The address the destination leads to: a URL, a path or a fragment. Not empty, the destination is a link and not a button (NVD-59), and the drawer does not select it by a press (NVD-60). White space is no address; a `javascript:` address or one that cannot be read is refused and reported (NVD-64). */
329
+ this.href = '';
330
+ /** Where a link opens: `same` (here) or `new` (a new tab or window, with `noopener`), which the expanded row marks with `open_in_new` and says through `targetLabel` (NVD-63). HTML's `_self` and `_blank` are read as those; anything else is `same` and is reported (NVD-64). Ignored without `href`. */
331
+ this.target = 'same';
332
+ /** What assistive technology reads at the end of the link's description while `target` is `new` ("opens in a new tab"): your words, in your language. Required then; ignored otherwise. */
333
+ this.targetLabel = '';
334
+ /** Web only: the anchor's `rel`. `noopener` is added while `target` is `new`; `noreferrer` is yours to add. */
335
+ this.rel = null;
336
+ /** Web only: the anchor's `download`. A link that asks for a download is the browser's: the drawer fires nothing for it (NVD-60). */
337
+ this.download = null;
338
+ /**
339
+ * NVD-59, NVD-63, NVD-64: the link the destination is while it has an address, what its anchor carries, and what a
340
+ * debug build is told (src/primitives/link.ts).
341
+ */
342
+ this.link = new LinkController(this, { ids: { refused: 'NVD-64', newContext: 'NVD-63' }, disabled: () => this.disabled });
343
+ /** What the trailing slot holds: whether anything, whether one glyph, and what it says. */
344
+ this.trailing = { filled: false, glyph: false, text: '' };
345
+ this.onKeyDown = (event) => {
346
+ if (this.leaveToGroup(event))
347
+ return;
348
+ this.press.onKeyDown(event);
349
+ };
350
+ }
351
+ static { this.styles = cellStyles; }
352
+ static { this.properties = {
353
+ // Its own accessor (below): a link without a value reads its href. Reflected by hand, as it was given.
354
+ value: { type: String, noAccessor: true },
355
+ trailingText: { type: String, attribute: 'trailing-text' },
356
+ badge: { type: Boolean, reflect: true },
357
+ badgeCount: { type: Number, attribute: 'badge-count' },
358
+ badgeLabel: { type: String, attribute: 'badge-label' },
359
+ href: { type: String },
360
+ target: { type: String },
361
+ targetLabel: { type: String, attribute: 'target-label' },
362
+ rel: { type: String },
363
+ download: { type: String },
364
+ trailing: { state: true },
365
+ }; }
366
+ /**
367
+ * What identifies the destination: the drawer's `value` selects it by this, and `change` / `reselect` carry it. While
368
+ * it is given none, a link's `href` stands for it, as written (NVD-59) — so a page sets the drawer's `value` to its
369
+ * own address and nothing on the items.
370
+ */
371
+ get value() {
372
+ return this.given || (readDestination(this.href).href ?? '');
373
+ }
374
+ set value(value) {
375
+ const before = this.value;
376
+ this.given = value ?? '';
377
+ this.requestUpdate('value', before);
378
+ }
379
+ /** NVD-1, NVD-59: a link is pressed by Enter alone; Space is the browser's, and shows no pressed state. */
380
+ get pressKeys() {
381
+ return this.link.pressKeys;
382
+ }
383
+ /**
384
+ * @internal NVD-60: what the drawer is told of a click on this destination — null while it is a button; for a link
385
+ * its address, and whether the click follows it in place: the primary button, no modifier key, not already
386
+ * cancelled, on a link that opens where the person is and asks for no download.
387
+ */
388
+ linkActivation(event) {
389
+ const form = this.link.form;
390
+ if (!form)
391
+ return null;
392
+ const plain = event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey && !event.defaultPrevented;
393
+ return { href: this.href, counted: plain && !form.disabled && !form.opensNew && this.download === null };
394
+ }
395
+ /** @internal The drawer's side (`DestinationsController`). */
396
+ setDestinationContext(context) {
397
+ this.setDrawerContext({ ...REST, ...context });
398
+ }
399
+ /** Whether the drawer draws this destination as its selected one. */
400
+ get selected() {
401
+ return this.context.selected;
402
+ }
403
+ /** `element.click()` activates the destination as a person would; a disabled one does nothing. */
404
+ click() {
405
+ if (this.disabled)
406
+ return;
407
+ this.cell?.click();
408
+ }
409
+ /** NVD-15, NVD-43: what the trailing slot holds, and what it says as part of the description. */
410
+ onTrailingChange(event) {
411
+ const assigned = event.target.assignedElements({ flatten: true });
412
+ const text = assigned
413
+ .filter((element) => element.getAttribute('aria-hidden') !== 'true')
414
+ .map((element) => element.getAttribute('aria-label') ?? element.textContent?.trim() ?? '')
415
+ .filter(Boolean)
416
+ .join(' ');
417
+ // One plain element holding text only is a glyph of the icon set (a ligature), drawn at trailing-icon.size.
418
+ const glyph = assigned.length === 1 && !assigned[0].localName.includes('-') && !assigned[0].children.length && !!assigned[0].textContent?.trim();
419
+ this.trailing = { filled: assigned.length > 0, glyph, text };
420
+ if (assigned.some((element) => findInteractive(element)))
421
+ report(this, 'NVD-43', 'the trailing slot holds a focusable element; trailing content is not interactive, so it is kept out of the focus order');
422
+ }
423
+ updated(changed) {
424
+ super.updated(changed);
425
+ // NVD-43: the slot's content is drawn; trailingText beside it is not.
426
+ if ((changed.has('trailingText') || has(changed, 'trailing')) && this.trailing.filled && this.trailingText) {
427
+ report(this, 'NVD-43', `the trailing slot has content and trailingText is "${this.trailingText}" as well; the slot's content is drawn`);
428
+ }
429
+ // The value as it was given, for a selector or a product that reads it; a link's href is not written back as one.
430
+ if (changed.has('value')) {
431
+ if (this.given) {
432
+ if (this.getAttribute('value') !== this.given)
433
+ this.setAttribute('value', this.given);
434
+ }
435
+ else if (this.hasAttribute('value'))
436
+ this.removeAttribute('value');
437
+ }
438
+ // Tells the drawer a prop it reads changed; an internal event, kept out of the item's public API.
439
+ notifyDestinationUpdate(this, changed);
440
+ }
441
+ /** NVD-42: the glyph, inside the badge when there is one — the badge is drawn above the icon indicator. */
442
+ glyph() {
443
+ const glyph = super.glyph();
444
+ if (!this.badge)
445
+ return glyph;
446
+ return html `<tanrei-badge .count=${this.badgeCount ?? null} label=${this.badgeLabel}>${glyph}</tanrei-badge>`;
447
+ }
448
+ /**
449
+ * NVD-43: the trailing slot's content, or else the trailing text; inert, and part of the description (NVD-15).
450
+ * NVD-63: a link that opens a new context ends its row with the icon set's `open_in_new` where the product put
451
+ * neither there — drawn as a glyph of the trailing slot is, and mirrored by the icon set's list.
452
+ */
453
+ trailingContent(mark) {
454
+ const { filled, glyph } = this.trailing;
455
+ const text = !filled && !!this.trailingText;
456
+ const marked = mark && !filled && !text;
457
+ return html `<span class=${classMap({ trailing: true, filled: filled || text || marked })} aria-hidden="true" inert>
458
+ <span class=${classMap({ 'trailing-slot': true, filled, glyph })}><slot name="trailing" @slotchange=${this.onTrailingChange}></slot></span>
459
+ ${text ? html `<span part="trailing-text" class="trailing-text">${this.trailingText}</span>` : nothing}
460
+ ${marked ? html `<span part="link-mark" class="link-mark">${LINK_MARK}</span>` : nothing}
461
+ </span>`;
462
+ }
463
+ render() {
464
+ const { selected } = this.context;
465
+ const classes = this.cellClasses();
466
+ // NVD-15, NVD-42: the badge's description, and then the trailing content, after the name and the state.
467
+ const trailing = this.trailing.filled ? this.trailing.text : this.trailingText;
468
+ // NVD-59: with an address it is a link — the anchor's address, target, rel and disabled form are the link
469
+ // primitive's. NVD-63: one that opens a new context says so last, whether its mark is drawn or not.
470
+ const link = this.link.form;
471
+ const description = this.link.describe(badgeDescription(this.badge, this.badgeCount, this.badgeLabel), trailing) ?? nothing;
472
+ const content = this.row(this.trailingContent(!!link?.opensNew));
473
+ if (link) {
474
+ return html `<a
475
+ part="cell"
476
+ class=${classMap(classes)}
477
+ style=${styleMap(this.cellStyle())}
478
+ ${linkAttributes(link)}
479
+ aria-current=${selected ? 'page' : nothing}
480
+ aria-label=${this.label || nothing}
481
+ aria-description=${description}
482
+ @click=${this.hideName}
483
+ @pointerdown=${this.press.onPointerDown}
484
+ @pointerup=${this.press.release}
485
+ @pointercancel=${this.press.release}
486
+ @pointerenter=${this.onPointerEnter}
487
+ @pointerleave=${this.onPointerLeave}
488
+ @keydown=${this.onKeyDown}
489
+ @keyup=${this.press.onKeyUp}
490
+ @blur=${this.onBlur}
491
+ @focus=${this.onFocus}
492
+ >${content}</a
493
+ >`;
494
+ }
495
+ return html `<button
496
+ part="cell"
497
+ class=${classMap(classes)}
498
+ style=${styleMap(this.cellStyle())}
499
+ type="button"
500
+ ?disabled=${this.disabled}
501
+ aria-current=${selected ? 'page' : nothing}
502
+ aria-label=${this.label || nothing}
503
+ aria-description=${description}
504
+ @click=${this.hideName}
505
+ @pointerdown=${this.press.onPointerDown}
506
+ @pointerup=${this.press.release}
507
+ @pointercancel=${this.press.release}
508
+ @pointerenter=${this.onPointerEnter}
509
+ @pointerleave=${this.onPointerLeave}
510
+ @keydown=${this.onKeyDown}
511
+ @keyup=${this.press.onKeyUp}
512
+ @blur=${this.onBlur}
513
+ @focus=${this.onFocus}
514
+ >
515
+ ${content}
516
+ </button>`;
517
+ }
518
+ }
519
+ /**
520
+ * A group of a drawer's destinations — the spec's item kind `group`: a row that opens and closes it (an icon,
521
+ * a label, a short label for the collapsed drawer, and the icon set's `expand_more` turned half a turn while open), and
522
+ * under it, indented one level further, its `<tanrei-navigation-drawer-item>` and `<tanrei-navigation-drawer-group>`
523
+ * children. A collapsed drawer draws it as one cell; activating that cell expands the drawer with the group open.
524
+ *
525
+ * Its row is a `<button aria-expanded aria-controls>` named by its label, and its items a nested list labelled by it.
526
+ * Activating the row sets `open` and then fires `toggle`; with focus on the row, the arrow toward the end of the line
527
+ * opens it and the one toward the start closes it (NVD-45).
528
+ *
529
+ * @tag tanrei-navigation-drawer-group
530
+ * @slot - `<tanrei-navigation-drawer-item>` and `<tanrei-navigation-drawer-group>` children.
531
+ * @csspart cell - The row: the native button, the hit area.
532
+ * @csspart container - The item container (the state layer's box, the focus ring's and the ripple's).
533
+ * @csspart active-indicator - The fill of the item container (drawn selected while the group shows the selection, NVD-47).
534
+ * @csspart icon-indicator - The box behind the icon alone.
535
+ * @csspart icon - The glyph (hidden from assistive technology).
536
+ * @csspart label - The label (hidden from assistive technology: the row is named by it).
537
+ * @csspart short-label - The short label under the icon while collapsed.
538
+ * @csspart chevron - The expand_more glyph (hidden from assistive technology).
539
+ * @csspart items - The list of its items.
540
+ * @fires {CustomEvent<TanreiNavigationDrawerToggleDetail>} toggle - The user opened or closed the group from its row, or from its cell in the collapsed drawer, or the drawer opened it to show the selected destination (`reveal-selected`, NVD-58): `detail.open` (and `open`) is its new state. Bubbles.
541
+ */
542
+ export class TanreiNavigationDrawerGroup extends DrawerCell {
543
+ constructor() {
544
+ super(...arguments);
545
+ /** Whether its items are shown under its row while the drawer is expanded. Reflected; the drawer sets it on activation. */
546
+ this.open = false;
547
+ /** NVD-58: the drawer opened this group to show the selection while building its first frame. */
548
+ this.shownInFirstFrame = false;
549
+ this.onClick = () => {
550
+ this.hideName();
551
+ if (this.disabled)
552
+ return;
553
+ // NVD-47: a group's cell in the collapsed drawer expands the drawer with the group open.
554
+ if (this.context.collapsed) {
555
+ this.drawer?.expandToGroup(this);
556
+ return;
557
+ }
558
+ this.setOpenByUser(!this.open);
559
+ };
560
+ this.onKeyDown = (event) => {
561
+ const arrow = this.arrow(event.key);
562
+ if (arrow && !this.context.collapsed) {
563
+ // NVD-45: toward the end opens a closed group; toward the start closes an open one, or leaves for the group above.
564
+ if (arrow === 'end' && !this.open) {
565
+ event.preventDefault();
566
+ this.setOpenByUser(true);
567
+ return;
568
+ }
569
+ if (arrow === 'start' && this.open) {
570
+ event.preventDefault();
571
+ this.setOpenByUser(false);
572
+ return;
573
+ }
574
+ if (this.leaveToGroup(event))
575
+ return;
576
+ }
577
+ this.press.onKeyDown(event);
578
+ };
579
+ }
580
+ static { this.styles = [cellStyles, groupStyles]; }
581
+ static { this.properties = {
582
+ open: { type: Boolean, reflect: true },
583
+ }; }
584
+ /** @internal Opens or closes the group as its user did, and fires `toggle` (NVD-45, NVD-47). */
585
+ setOpenByUser(open) {
586
+ if (this.disabled || this.open === open)
587
+ return;
588
+ this.open = open;
589
+ this.dispatchEvent(new CustomEvent('toggle', { bubbles: true, detail: { open } }));
590
+ }
591
+ /**
592
+ * @internal NVD-58: the drawer opens the group to show the selected destination inside it — a disabled group too —
593
+ * and the group fires `toggle`. In the drawer's first frame it is drawn open without the motion of NVD-44 (the
594
+ * drawer's `data-arriving`); afterwards with it.
595
+ */
596
+ openForSelection(firstFrame = false) {
597
+ if (firstFrame)
598
+ this.shownInFirstFrame = true;
599
+ if (this.open)
600
+ return;
601
+ this.open = true;
602
+ this.dispatchEvent(new CustomEvent('toggle', { bubbles: true, detail: { open: true } }));
603
+ }
604
+ willUpdate(changed) {
605
+ // NVD-58, NVD-62: until the drawer's first frame is drawn, a group it opened for the selection is open whatever
606
+ // its `open` is told — a state the product gave back loses to `reveal-selected`. A property set on the element
607
+ // before it was upgraded is given to it only at its first update, after the drawer has looked at it and opened
608
+ // it; and a page's script may run after the upgrade and still before the frame. The drawer has said that the
609
+ // group is open (its one `toggle`): nothing is said again.
610
+ if (this.shownInFirstFrame && !this.open && this.drawer?.arriving)
611
+ this.open = true;
612
+ super.willUpdate(changed);
613
+ }
614
+ /** @internal Resolves once the motion that opens or closes the group has ended (at once where there is none). */
615
+ async settled() {
616
+ await this.updateComplete;
617
+ const fold = this.renderRoot?.querySelector('.items');
618
+ const running = typeof fold?.getAnimations === 'function' ? fold.getAnimations() : [];
619
+ await Promise.all(running.map((animation) => animation.finished.catch(() => undefined)));
620
+ }
621
+ get drawer() {
622
+ return this.closest(DRAWER) ?? null;
623
+ }
624
+ updated(changed) {
625
+ super.updated(changed);
626
+ // NVD-46: a group without a label is a button and a list without a name.
627
+ if (changed.has('label') && !this.label.trim())
628
+ report(this, 'NVD-46', 'label is empty, so the group has no accessible name; give it a label');
629
+ notifyDestinationUpdate(this, changed);
630
+ }
631
+ render() {
632
+ const shown = this.open && !this.context.collapsed;
633
+ return html `<button
634
+ part="cell"
635
+ id="row"
636
+ class=${classMap(this.cellClasses({ open: shown }))}
637
+ style=${styleMap(this.cellStyle())}
638
+ type="button"
639
+ ?disabled=${this.disabled}
640
+ aria-label=${this.label || nothing}
641
+ aria-expanded=${String(shown)}
642
+ aria-controls="items"
643
+ @click=${this.onClick}
644
+ @pointerdown=${this.press.onPointerDown}
645
+ @pointerup=${this.press.release}
646
+ @pointercancel=${this.press.release}
647
+ @pointerenter=${this.onPointerEnter}
648
+ @pointerleave=${this.onPointerLeave}
649
+ @keydown=${this.onKeyDown}
650
+ @keyup=${this.press.onKeyUp}
651
+ @blur=${this.onBlur}
652
+ @focus=${this.onFocus}
653
+ >
654
+ ${this.row(html `<span class="trailing filled" aria-hidden="true"><span part="chevron" class="chevron">expand_more</span></span>`)}
655
+ </button>
656
+ <div class=${classMap({ items: true, shown })} ?inert=${!shown}>
657
+ <div class="fold"><div part="items" id="items" class="list" role="list" aria-labelledby="row"><slot></slot></div></div>
658
+ </div>`;
659
+ }
660
+ }
661
+ /**
662
+ * A group of a drawer's destinations and groups under an optional heading — the spec's item kind `section`:
663
+ * the divider component before it while `divider` is set, its heading (a heading, level 2 unless `heading-level` says
664
+ * otherwise) and its children. Sections do not nest and do not go inside a group: such a section draws only its items,
665
+ * in its place, and a debug build says so (NVD-17). Collapsed, its heading keeps its row and draws no text (NVD-16).
666
+ *
667
+ * @tag tanrei-navigation-drawer-section
668
+ * @slot - `<tanrei-navigation-drawer-item>` and `<tanrei-navigation-drawer-group>` children.
669
+ * @csspart heading - The heading row.
670
+ */
671
+ export class TanreiNavigationDrawerSection extends LitElement {
672
+ constructor() {
673
+ super(...arguments);
674
+ /** The text that names the items under it, exposed as a heading. Empty draws no heading row. */
675
+ this.heading = '';
676
+ /** Draws a divider (the divider component) before the section. */
677
+ this.divider = false;
678
+ /** Web only: the heading's level, 1 to 6. */
679
+ this.headingLevel = 2;
680
+ this.nested = false;
681
+ this.collapsed = false;
682
+ }
683
+ static { this.styles = sectionStyles; }
684
+ static { this.properties = {
685
+ heading: { type: String },
686
+ divider: { type: Boolean, reflect: true },
687
+ headingLevel: { type: Number, attribute: 'heading-level' },
688
+ nested: { state: true },
689
+ collapsed: { state: true },
690
+ }; }
691
+ connectedCallback() {
692
+ super.connectedCallback();
693
+ const outer = this.parentElement?.closest(`${SECTION}, ${GROUP}`);
694
+ this.nested = !!outer;
695
+ if (outer?.localName === SECTION)
696
+ report(this, 'NVD-17', 'a section holds a section; sections do not nest, so the inner one draws only its items, in its place');
697
+ else if (outer)
698
+ report(this, 'NVD-17', 'a group holds a section; sections do not go inside a group, so it draws only its items, in its place');
699
+ }
700
+ /** @internal The drawer's side: the drawer's form. */
701
+ setDrawerContext({ collapsed }) {
702
+ this.collapsed = collapsed;
703
+ }
704
+ updated() {
705
+ // NVD-23: a list item of the drawer's list (a nested one is nothing: its items are its parent's).
706
+ this.setAttribute('role', this.nested ? 'none' : 'listitem');
707
+ this.toggleAttribute('data-nested', this.nested);
708
+ }
709
+ render() {
710
+ if (this.nested)
711
+ return html `<slot></slot>`;
712
+ const level = Math.min(6, Math.max(1, Math.round(Number(this.headingLevel) || 2)));
713
+ return html `<div class=${classMap({ section: true, collapsed: this.collapsed })}>
714
+ ${this.divider ? html `<tanrei-divider></tanrei-divider>` : nothing}
715
+ ${this.heading
716
+ ? html `<div part="heading" class="heading" role="heading" aria-level=${level} aria-hidden=${this.collapsed ? 'true' : nothing}><span class="heading-text">${this.heading}</span></div>`
717
+ : nothing}
718
+ <div class="items" role="list"><slot></slot></div>
719
+ </div>`;
720
+ }
721
+ }
722
+ /**
723
+ * A panel of destinations at the start edge, in two variants — `standard`, a layout region beside the content,
724
+ * and `modal`, a modal overlay over a scrim that closes itself after a destination is chosen — and, while `collapsible`,
725
+ * in two forms: expanded, and collapsed to a column of icons, which is the expanded drawer with its labels gone: every
726
+ * row is the same row cut after its icon, at the same height and with the same corners, and every icon exactly in place
727
+ * while the drawer moves between the two. A collapsed cell shows its name in a plain tooltip on hover and keyboard focus;
728
+ * `collapsed-labels` draws short labels under the icons instead, for a product or a system whose column is labelled.
729
+ *
730
+ * Contract: specs/navigation-drawer.spec.json. `<tanrei-navigation-drawer-item>`, `<tanrei-navigation-drawer-group>` and
731
+ * `<tanrei-navigation-drawer-section>` children, in order; header buttons (icon-only `<tanrei-button>`s) with
732
+ * `slot="header-button"`, the main action (`<tanrei-main-action-button>`) with `slot="main-action"`, and the `header`
733
+ * slot. The drawer's `value` is the selected destination's value; the drawer sets it when a button destination is
734
+ * activated and fires `change`, or `reselect` for the selected one.
735
+ *
736
+ * A site's sidebar (NVD-57…64): a destination with `href` is a link, and the selected destination is the current page
737
+ * (`aria-current="page"`) — one state, which in a site of separate pages the page says, through `value` (a link without
738
+ * a `value` takes its `href`). The drawer never writes `value` for a link: a plain activation fires `change` or
739
+ * `reselect` with `detail.href`, cancelable, before the browser follows the link (a router cancels it and goes to
740
+ * `detail.href` itself), and then closes a modal drawer; a modified or a middle click, a link whose `target` is `new`
741
+ * and a download fire nothing and close nothing. The row that shows the selection is brought into view when the drawer
742
+ * first appears and whenever `value` changes — centred if it was not wholly in view, untouched if it was, without motion
743
+ * and without moving focus — and `reveal-selected` opens the groups that hold it (each fires `toggle`). `scrollOffset`
744
+ * reads and writes how far the items are scrolled; the scroll does not chain to the page. Nothing is stored: a site keeps
745
+ * each group's `open` (from `toggle`) and `scrollOffset` (read on `pagehide`) itself and gives them back as attributes.
746
+ *
747
+ * Forms (NVD-30): not collapsible, always expanded. Collapsible and standard: `expanded` chooses. Collapsible and modal:
748
+ * collapsed — its column in the layout, drawn as a standard drawer's — while closed, and expanded over the content while
749
+ * open. The first header button is then the menu button: the drawer sets `aria-expanded` and `aria-controls` on its
750
+ * native button (`ariaExpanded`, `ariaControlsElements`), and its activation asks for the other form: the drawer sets
751
+ * `expanded` (or `open`) and fires `expandedchange`. The main action's `extended` follows the form. The read-only
752
+ * `collapsed` attribute reflects the form.
753
+ *
754
+ * Standard: a `<nav>` named by `label`, taking its form's width in the layout while `open` and none while closed (sliding
755
+ * while the content beside it resizes). Opening it moves focus in; closing it with focus inside returns focus to where it
756
+ * was; Tab leaves it without closing it.
757
+ *
758
+ * Modal: a native `<dialog>` in the shadow root, opened with `showModal()` while `open` — in the top layer over its
759
+ * `::backdrop` (the scrim), everything else inert, the page held from scrolling, focus kept inside. Escape, the platform's
760
+ * back, a press on the scrim, a drag toward the start edge past half its width (or a fling), the menu button and a
761
+ * destination's activation close it: the drawer sets `open` to false itself and fires `close`. Focus returns to where it
762
+ * was.
763
+ *
764
+ * Responsive (NVD-53…55): with `responsive`, the window's width chooses what the drawer is, and `variant` is ignored —
765
+ * a standard drawer, shown whatever `open` says, from `comp.navigation-drawer.breakpoint.expanded` (1024 px at the
766
+ * default text size); its column, widening over the content while `open`, from `breakpoint.collapsed` (600 px) while
767
+ * `collapsible`; a modal drawer below that. The read-only `presentation` says which (and the `presentation` attribute, for
768
+ * styling); `presentationchange` fires when it is first decided and whenever the width changes it. A change of
769
+ * presentation is drawn at once, is entered closed (an open overlay closes: `open` is false and `close` fires once), and
770
+ * keeps `expanded`, `value` and every group's `open`. The presentation is derived from the width alone: it is never
771
+ * written to `variant`, `open` or `expanded`, and the element stores nothing — a product that wants the user's choice of
772
+ * form remembered keeps what `expandedchange` carries and sets `expanded` from it.
773
+ *
774
+ * Every visual value comes from `--tanrei-comp-navigation-drawer-*` tokens. The color reaches under
775
+ * `env(safe-area-inset-*)` at the start, top and bottom.
776
+ *
777
+ * @tag tanrei-navigation-drawer
778
+ * @slot - `<tanrei-navigation-drawer-item>`, `<tanrei-navigation-drawer-group>` and `<tanrei-navigation-drawer-section>` children.
779
+ * @slot header-button - Icon-only `<tanrei-button>`s stacked in the icon column; the first is the menu button while the drawer is collapsible.
780
+ * @slot main-action - A `<tanrei-main-action-button>` below the header buttons, collapsed to its icon with the drawer. Only the first is drawn.
781
+ * @slot header - Content beside the first header button while the drawer is expanded (a title, an account switcher); not restyled.
782
+ * @csspart container - The panel: the `<nav>` of a standard drawer (or a collapsible modal drawer's column), the `<dialog>` of a modal one.
783
+ * @csspart outline - The end edge.
784
+ * @csspart header - The header, which stays in place.
785
+ * @csspart content - The list of items, which scrolls.
786
+ * @fires {CustomEvent<TanreiNavigationChangeDetail>} change - The user activated another destination: `detail.value` (and, for a button destination, the drawer's `value`) is its value. For a link it is fired before the link is followed, only for a plain activation of a link that opens in place, carries `detail.href`, leaves `value` to the page, and is cancelable: `preventDefault()` stops the browser's navigation.
787
+ * @fires {CustomEvent<TanreiNavigationChangeDetail>} reselect - The user activated the selected destination again; for a link, as `change`.
788
+ * @fires close - A modal drawer closed: the scrim, Escape, back, a drag, the menu button, or after a destination was activated. `open` is already false.
789
+ * @fires {CustomEvent<TanreiNavigationDrawerExpandedChangeDetail>} expandedchange - The user asked a collapsible drawer for its other form (its menu button, or a group's cell while collapsed): `detail.expanded`. `expanded` (or, for a modal drawer, `open`) already holds it.
790
+ * @fires {CustomEvent<TanreiNavigationDrawerPresentationChangeDetail>} presentationchange - A responsive drawer decided its presentation for the first time, or the window's width changed it: `detail.presentation` (and `presentation`) is `standard`, `column` or `modal`. A product shows its own menu button while it is `modal`.
791
+ */
792
+ export class TanreiNavigationDrawer extends LitElement {
793
+ static { this.styles = drawerStyles; }
794
+ static { this.properties = {
795
+ variant: { type: String, reflect: true },
796
+ open: { type: Boolean, reflect: true },
797
+ collapsible: { type: Boolean, reflect: true },
798
+ expanded: {
799
+ type: Boolean,
800
+ reflect: true,
801
+ // True unless the attribute says "false": a boolean that defaults to true cannot be turned off by absence.
802
+ converter: { fromAttribute: (value) => value !== 'false', toAttribute: (value) => (value ? '' : 'false') },
803
+ },
804
+ collapsedLabels: { type: String, attribute: 'collapsed-labels', reflect: true },
805
+ responsive: { type: Boolean, reflect: true },
806
+ decided: { state: true },
807
+ value: { type: String },
808
+ revealSelected: { type: Boolean, attribute: 'reveal-selected' },
809
+ // Its own accessor (below): the scroller's present offset. The attribute is read once, for the first frame.
810
+ scrollOffset: { type: Number, attribute: 'scroll-offset', noAccessor: true },
811
+ label: { type: String },
812
+ hasButtons: { state: true },
813
+ hasTitle: { state: true },
814
+ hasMain: { state: true },
815
+ presented: { state: true },
816
+ measured: { state: true },
817
+ }; }
818
+ /**
819
+ * How far the items are scrolled from their start, in CSS pixels (NVD-61). Reading it gives the present distance;
820
+ * setting it scrolls there at once, without motion, held inside the scroll range — before the drawer first appears
821
+ * included, when it is where the first frame is drawn (the `scroll-offset` attribute is read once, for that frame).
822
+ * No event is fired while the user scrolls, and nothing is stored (NVD-62): a site reads it when the page is left and
823
+ * gives it back on the next page.
824
+ */
825
+ get scrollOffset() {
826
+ if (this.unwritten && this.givenOffset !== null)
827
+ return this.givenOffset;
828
+ return this.scroller?.scrollTop ?? 0;
829
+ }
830
+ set scrollOffset(offset) {
831
+ const to = Number(offset);
832
+ this.givenOffset = Number.isFinite(to) ? Math.max(0, to) : 0;
833
+ this.unwritten = true;
834
+ // Written now where the items are laid out; before that, in the first frame's order (NVD-62).
835
+ this.applyOffset();
836
+ }
837
+ /** @internal NVD-62: the drawer's first frame is not drawn yet: its groups read it (a group opened for the selection stays open until then, NVD-58). */
838
+ get arriving() {
839
+ return !this.painted;
840
+ }
841
+ constructor() {
842
+ super();
843
+ this.availability = new AvailabilityController(this, 'navigation-drawer');
844
+ /** Standard sits beside the content; modal lays itself over it with a scrim and holds focus until it closes. Ignored while `responsive`. Reflected. */
845
+ this.variant = 'standard';
846
+ /** Whether the drawer is shown: a standard one takes its place in the layout, a modal one is presented. While `responsive` it only opens the presentations that lie over the content, and every change of presentation sets it back to false. Reflected. */
847
+ this.open = false;
848
+ /** Gives the drawer its collapsed form, the icon column. Reflected. */
849
+ this.collapsible = false;
850
+ /** The form of a collapsible standard drawer: true for the full drawer, false for the icon column (`expanded="false"`). The user's choice: a change of the window's width never writes it. Reflected. */
851
+ this.expanded = true;
852
+ /** Which cells draw their short label under the icon while collapsed: `never` (the default: a collapsed drawer is the expanded one with its labels gone), `selected` or `always` (anything else is `never`). */
853
+ this.collapsedLabels = 'never';
854
+ /** Lets the window's width choose the drawer's presentation (NVD-53): standard where it is wide, its column where it is narrower (while `collapsible`), modal where it is narrow. Reflected. */
855
+ this.responsive = false;
856
+ /** What the window's width has decided for a responsive drawer; null while it is not responsive, or the width is not known. */
857
+ this.decided = null;
858
+ /**
859
+ * The value of the selected destination, wherever it stands; empty selects none. The selected destination is the place
860
+ * being shown, exposed as the current page. The drawer sets it when a button destination is activated; it never sets
861
+ * it for a link (NVD-60) — in a site of separate pages each page sets it to its own destination (a link's `href`
862
+ * stands as its value while it has none).
863
+ */
864
+ this.value = '';
865
+ /**
866
+ * Opens the groups that hold the selected destination when the drawer first appears (in its first frame, without
867
+ * motion) and whenever `value` changes, whatever their `open` said; each fires `toggle` (NVD-58). The user may close
868
+ * such a group again: it then stays closed until `value` changes. While false a closed group stays closed and its row
869
+ * shows the selection (NVD-47).
870
+ */
871
+ this.revealSelected = false;
872
+ /**
873
+ * The offset the product gave, while it still has work to do: until it has been written (`unwritten` — nothing is
874
+ * laid out yet), and until the first frame is drawn, because the first frame's order may run more than once while the
875
+ * drawer's children are still arriving (NVD-62).
876
+ */
877
+ this.givenOffset = null;
878
+ this.unwritten = false;
879
+ /** NVD-61: where the items were scrolled when the drawer last looked — before the browser answered a focus by scrolling. */
880
+ this.lastScroll = null;
881
+ /** Names the navigation landmark and, while modal and open, the dialog ("Mail"). */
882
+ this.label = '';
883
+ this.hasButtons = false;
884
+ this.hasTitle = false;
885
+ this.hasMain = false;
886
+ /** A collapsible modal drawer's dialog is drawn (open, or narrowing back to its column). */
887
+ this.presented = false;
888
+ /** Measured from the product's own elements: the first header button's width, the main action's height. */
889
+ this.measured = {};
890
+ /** Where a collapsible modal drawer's column is, for its dialog to widen from. */
891
+ this.place = {};
892
+ /** NVD-26: variants a design system adds, and a value the active system does not have (src/primitives/axes.ts). */
893
+ this.axes = new OpenAxesController(this, { component: 'navigation-drawer', behavior: 'NVD-26', axes: AXES });
894
+ this.snapshot = { shower: null, top: [], places: new Map() };
895
+ /** NVD-1…3, NVD-24, NVD-29: selection, activation and the debug reports (src/primitives/destination.ts). */
896
+ this.destinations = new DestinationsController(this, {
897
+ items: () => [...this.querySelectorAll(ITEM)].filter((item) => item instanceof TanreiNavigationDrawerItem),
898
+ ids: { unknownValue: 'NVD-3', emptyLabel: 'NVD-24', duplicate: 'NVD-29' },
899
+ context: (item, base) => {
900
+ if (base.position === 1) {
901
+ // NVD-62: what is revealed comes before any cell is told what it is, so the first frame draws it settled.
902
+ this.revealSelection();
903
+ this.snapshot = this.takeSnapshot();
904
+ }
905
+ return this.cellContext(item, base.selected);
906
+ },
907
+ synced: (_, items) => {
908
+ this.syncStructure(items);
909
+ this.viewSelection();
910
+ },
911
+ // NVD-60: a link is followed, not selected.
912
+ link: (item, event) => item.linkActivation(event),
913
+ });
914
+ /** Where focus was when the drawer opened (NVD-22, NVD-28). */
915
+ this.opener = null;
916
+ this.shown = false;
917
+ this.pressedScrim = false;
918
+ this.dragged = false;
919
+ this.drag = null;
920
+ /** The form at the last update; undefined before the first. */
921
+ this.wasCollapsed = undefined;
922
+ /** Focus was on what the collapsed form does not draw when the drawer collapsed (NVD-36). */
923
+ this.focusLost = false;
924
+ /** Whether focus was inside a standard drawer that is closing (read before the render makes it inert). */
925
+ this.closingWithFocus = false;
926
+ /** Where focus was before a collapsible modal drawer's dialog took its column's place (NVD-22). */
927
+ this.pendingOpener = null;
928
+ /** The menu button whose press is opening the drawer, until that update is drawn (NVD-22). */
929
+ this.pressedMenu = null;
930
+ /** The first header button, as last told it was the menu button. */
931
+ this.menuButton = null;
932
+ /** NVD-53: the two widths a responsive drawer listens to, widest first, and what stops listening. */
933
+ this.widths = null;
934
+ /** NVD-54: a `presentationchange` owed once the presentation it names is drawn. */
935
+ this.announce = false;
936
+ /** NVD-54: the element that had focus when the width changed the presentation, if it was in the drawer. */
937
+ this.focusBefore = null;
938
+ this.instantFrame = 0;
939
+ this.sizes = new ResizeObserver(() => this.measure());
940
+ /** NVD-57, NVD-58: the value whose selection was last shown (null: none was selected); undefined before the first. */
941
+ this.shownFor = undefined;
942
+ /** NVD-58: the groups just opened to show the selection, until the selection has been brought into view. */
943
+ this.revealed = [];
944
+ /** NVD-57: the selection is owed a look: its row is brought into view once the cells are drawn. */
945
+ this.viewOwed = false;
946
+ this.viewing = false;
947
+ /** The drawer's first frame has been drawn: what it opens afterwards takes its motion (NVD-58), and the first frame's order (NVD-62) is over. */
948
+ this.painted = false;
949
+ this.paintFrame = 0;
950
+ /** NVD-61: the user scrolled, or the range changed under the items. No event is fired for it. */
951
+ this.onScroll = (event) => {
952
+ const scroller = event.currentTarget;
953
+ this.lastScroll = { scroller, top: scroller.scrollTop };
954
+ };
955
+ /**
956
+ * NVD-61: keyboard focus that moves to a cell which is not wholly in view scrolls it into view by the least distance
957
+ * that shows it whole. The browsers answer a focus each in its own way — one centres a cell that was out of view,
958
+ * another leaves one that is partly in view where it is — and some before this event, some after it: so the items
959
+ * are put back where they were before the focus, and then moved by the least distance; a browser that answers
960
+ * afterwards finds the cell in view and does nothing. A pointer's focus scrolls nothing.
961
+ */
962
+ this.onFocusIn = (event) => {
963
+ const cell = event.composedPath().find((node) => node instanceof DrawerCell);
964
+ if (!cell?.cell?.matches(':focus-visible'))
965
+ return;
966
+ const scroller = this.scroller;
967
+ const before = this.lastScroll;
968
+ if (scroller && before?.scroller === scroller && scroller.scrollTop !== before.top)
969
+ scroller.scrollTop = before.top;
970
+ this.showWhole(cell);
971
+ };
972
+ this.onWidth = () => this.decide();
973
+ // ---- activation, the menu button and the groups (NVD-21, NVD-37, NVD-47) ----
974
+ this.afterActivation = (event) => {
975
+ if (event.target !== this || !this.modal || !this.open)
976
+ return;
977
+ this.dismiss();
978
+ };
979
+ /** NVD-37: the first header button of a collapsible drawer changes its form (or closes an open modal one). */
980
+ this.onMenuClick = (event) => {
981
+ if (!this.collapsible)
982
+ return;
983
+ const menu = this.headerButtons[0];
984
+ if (!menu || !event.composedPath().includes(menu))
985
+ return;
986
+ if (this.modal && this.open) {
987
+ this.dismiss();
988
+ return;
989
+ }
990
+ // NVD-53: in the modal presentation the drawer has no other form to ask for.
991
+ if (!this.collapses)
992
+ return;
993
+ // NVD-22: the button whose press opens the drawer is where focus goes back to when the press itself gave focus to
994
+ // nothing (Safari on macOS does not focus a button that is clicked).
995
+ this.pressedMenu = menu;
996
+ this.askForm(this.collapsed);
997
+ void this.updateComplete.then(() => (this.pressedMenu = null));
998
+ };
999
+ this.onKeyDown = (event) => {
1000
+ if (event.key === 'Escape') {
1001
+ if (event.defaultPrevented)
1002
+ return;
1003
+ event.preventDefault();
1004
+ event.stopPropagation();
1005
+ this.dismiss();
1006
+ return;
1007
+ }
1008
+ if (event.key === 'Tab' && this.dialog)
1009
+ trapFocus(event, this.dialog);
1010
+ };
1011
+ /** The platform's back (a close request without a key) arrives as the native cancel. */
1012
+ this.onNativeCancel = (event) => {
1013
+ event.preventDefault();
1014
+ this.dismiss();
1015
+ };
1016
+ this.onPointerDown = (event) => {
1017
+ this.pressedScrim = this.onScrim(event);
1018
+ if (this.pressedScrim || !this.open)
1019
+ return;
1020
+ this.drag = { id: event.pointerId, x: event.clientX, time: event.timeStamp, following: false, lastX: event.clientX, lastTime: event.timeStamp, velocity: 0 };
1021
+ };
1022
+ this.onPointerMove = (event) => {
1023
+ const drag = this.drag;
1024
+ const dialog = this.dialog;
1025
+ if (!drag || !dialog || event.pointerId !== drag.id)
1026
+ return;
1027
+ const distance = this.towardStart(event.clientX - drag.x);
1028
+ if (!drag.following) {
1029
+ if (distance <= TOUCH_SLOP)
1030
+ return;
1031
+ drag.following = true;
1032
+ dialog.classList.add('dragging');
1033
+ try {
1034
+ dialog.setPointerCapture?.(event.pointerId);
1035
+ }
1036
+ catch {
1037
+ // A pointer the browser no longer counts as active cannot be captured; the dialog still follows its events.
1038
+ }
1039
+ }
1040
+ const dt = event.timeStamp - drag.lastTime;
1041
+ if (dt > 0)
1042
+ drag.velocity = this.towardStart(event.clientX - drag.lastX) / dt;
1043
+ drag.lastX = event.clientX;
1044
+ drag.lastTime = event.timeStamp;
1045
+ const offset = Math.max(0, distance);
1046
+ const rtl = getComputedStyle(this).direction === 'rtl';
1047
+ dialog.style.setProperty('--_drag', `${rtl ? offset : -offset}px`);
1048
+ };
1049
+ this.onPointerUp = (event) => {
1050
+ const drag = this.drag;
1051
+ const dialog = this.dialog;
1052
+ this.drag = null;
1053
+ if (!drag || !dialog || event.pointerId !== drag.id || !drag.following)
1054
+ return;
1055
+ const distance = this.towardStart(event.clientX - drag.x);
1056
+ dialog.classList.remove('dragging');
1057
+ dialog.style.removeProperty('--_drag');
1058
+ // The click that ends a drag is not an activation.
1059
+ this.dragged = true;
1060
+ setTimeout(() => (this.dragged = false), 0);
1061
+ if (distance > dialog.getBoundingClientRect().width / 2 || drag.velocity >= FLING_VELOCITY)
1062
+ this.dismiss();
1063
+ };
1064
+ /** Swallows the click that ends a drag, before it reaches a destination. */
1065
+ this.onClickCapture = {
1066
+ capture: true,
1067
+ handleEvent: (event) => {
1068
+ if (!this.dragged)
1069
+ return;
1070
+ event.stopPropagation();
1071
+ event.preventDefault();
1072
+ },
1073
+ };
1074
+ this.onClick = (event) => {
1075
+ const scrim = this.pressedScrim && this.onScrim(event);
1076
+ this.pressedScrim = false;
1077
+ if (scrim)
1078
+ this.dismiss();
1079
+ };
1080
+ // NVD-21: a destination's activation closes a modal drawer, after change or reselect.
1081
+ this.addEventListener('change', this.afterActivation);
1082
+ this.addEventListener('reselect', this.afterActivation);
1083
+ // NVD-37: the menu button, after its own click.
1084
+ this.addEventListener('click', this.onMenuClick);
1085
+ // NVD-61: keyboard focus on a cell that is not wholly in view. One listener for every cell.
1086
+ this.addEventListener('focusin', this.onFocusIn);
1087
+ }
1088
+ /** The drawer's destinations, in reading order, in sections and groups or not. */
1089
+ get items() {
1090
+ return this.destinations.items;
1091
+ }
1092
+ /** The drawer's groups, in reading order. */
1093
+ get groups() {
1094
+ return [...this.querySelectorAll(GROUP)].filter((group) => group instanceof TanreiNavigationDrawerGroup);
1095
+ }
1096
+ /** The form the drawer is in (NVD-30): collapsed to the icon column, or not. Read-only; reflected as the `collapsed` attribute. */
1097
+ get collapsed() {
1098
+ if (!this.collapses)
1099
+ return false;
1100
+ return this.modal ? !this.open : !this.expanded;
1101
+ }
1102
+ /**
1103
+ * NVD-53, NVD-55: what a responsive drawer is at the window's current width — `standard`, `column` or `modal` — or
1104
+ * null while it is not responsive. Read-only, derived from the width alone and never stored in a prop; reflected as
1105
+ * the `presentation` attribute, for styling.
1106
+ */
1107
+ get presentation() {
1108
+ return this.responsive ? this.decided : null;
1109
+ }
1110
+ /** Whether the drawer is drawn as a modal one: its variant, or what a responsive drawer's presentation stands for (NVD-53). */
1111
+ get modal() {
1112
+ if (this.responsive)
1113
+ return this.decided === 'column' || this.decided === 'modal';
1114
+ return this.variant === 'modal';
1115
+ }
1116
+ /** Whether the drawer is drawn with a collapsed form: `collapsible`, unless a responsive drawer's presentation is the modal one (NVD-53). */
1117
+ get collapses() {
1118
+ if (this.responsive && this.decided === 'modal')
1119
+ return false;
1120
+ return this.collapsible;
1121
+ }
1122
+ /** Whether the drawer is shown: `open`, and always while a responsive drawer is beside the content (NVD-53). */
1123
+ get isOpen() {
1124
+ // NVD-55: before the width is known nothing is made inert and nothing is opened on a guess.
1125
+ if (this.responsive && this.decided !== 'column' && this.decided !== 'modal')
1126
+ return true;
1127
+ return this.open;
1128
+ }
1129
+ get labelsMode() {
1130
+ return this.collapsedLabels === 'selected' || this.collapsedLabels === 'always' ? this.collapsedLabels : 'never';
1131
+ }
1132
+ get panel() {
1133
+ return this.renderRoot?.querySelector('.drawer') ?? null;
1134
+ }
1135
+ get dialog() {
1136
+ return this.renderRoot?.querySelector('dialog') ?? null;
1137
+ }
1138
+ /** The list of items, which scrolls under the header (NVD-12). */
1139
+ get scroller() {
1140
+ return this.renderRoot?.querySelector('.items') ?? null;
1141
+ }
1142
+ /** NVD-61: the `scroll-offset` attribute is read once, for the first frame; afterwards the property is the handle. */
1143
+ attributeChangedCallback(name, before, value) {
1144
+ if (name === 'scroll-offset' && this.hasUpdated)
1145
+ return;
1146
+ super.attributeChangedCallback(name, before, value);
1147
+ }
1148
+ // ---- the selection shown, and the scroll (NVD-57, NVD-58, NVD-61, NVD-62) ----
1149
+ /**
1150
+ * NVD-58: while `revealSelected`, the closed groups that hold the selected destination are opened — when the drawer
1151
+ * first appears, and when `value` changes to a destination (or `revealSelected` is turned on). A group the user
1152
+ * closes afterwards stays closed: nothing here runs again until the value does change. Whether or not anything is
1153
+ * opened, the selection is then owed a look (NVD-57).
1154
+ */
1155
+ revealSelection() {
1156
+ const selected = this.destinations.selected;
1157
+ const key = selected ? this.value : null;
1158
+ if (this.shownFor !== undefined && key === this.shownFor)
1159
+ return;
1160
+ this.shownFor = key;
1161
+ this.viewOwed = true;
1162
+ if (!selected || !this.revealSelected)
1163
+ return;
1164
+ const closed = groupsOf(selected).filter((group) => !group.open);
1165
+ for (const group of closed)
1166
+ group.openForSelection(!this.painted);
1167
+ this.revealed.push(...closed);
1168
+ }
1169
+ /**
1170
+ * NVD-57, NVD-62: the selection is owed a look — its value changed, or the drawer has not drawn its first frame yet.
1171
+ * Until that frame the order is run again whenever the drawer's children change: a drawer upgraded before its
1172
+ * children were parsed has nothing to scroll yet, and one whose later cells are still to come has a shorter range
1173
+ * than it will have.
1174
+ */
1175
+ viewSelection() {
1176
+ if (this.shownFor === undefined) {
1177
+ // No destination yet (the drawer's children are still to come): the first frame's order still runs, for the offset.
1178
+ this.shownFor = null;
1179
+ this.viewOwed = true;
1180
+ }
1181
+ if (!this.painted)
1182
+ this.viewOwed = true;
1183
+ if (this.viewOwed && !this.viewing)
1184
+ void this.showSelection();
1185
+ }
1186
+ /** Resolves once the drawer and every cell have nothing left to draw: one wait for a whole burst of updates. */
1187
+ async cellsDrawn() {
1188
+ // Bounded: a product that keeps its cells updating forever is looked at as it is.
1189
+ for (let turn = 0; turn < 16; turn++) {
1190
+ const cells = [...this.querySelectorAll(CELLS)];
1191
+ await Promise.all(cells.map((cell) => cell.updateComplete));
1192
+ await this.updateComplete;
1193
+ if (!this.isUpdatePending && !cells.some((cell) => cell.isUpdatePending))
1194
+ return;
1195
+ }
1196
+ }
1197
+ /**
1198
+ * NVD-57, NVD-62: once every cell is drawn — and, after the first frame, the groups just opened have finished
1199
+ * opening — the items go to the offset the product gave (in the first frame's order) and the row that shows the
1200
+ * selection is brought into view. Before the first frame all of it happens in microtasks, so no frame shows the
1201
+ * items anywhere else; and it reads the layout once for a whole burst of updates, however many cells there are.
1202
+ */
1203
+ async showSelection() {
1204
+ this.viewing = true;
1205
+ try {
1206
+ while (this.viewOwed) {
1207
+ this.viewOwed = false;
1208
+ const first = !this.painted;
1209
+ const opened = this.revealed;
1210
+ this.revealed = [];
1211
+ await this.cellsDrawn();
1212
+ if (!first)
1213
+ await Promise.all(opened.map((group) => group.settled()));
1214
+ // Asked again meanwhile (more cells arrived, or the value changed once more): that look replaces this one.
1215
+ if (this.viewOwed || !this.isConnected)
1216
+ continue;
1217
+ // Each run of the first frame's order starts where the product put the items — at their start, if it said
1218
+ // nothing — so that a run made while cells were still arriving leaves no trace in the next.
1219
+ if (first)
1220
+ this.applyOffset(true);
1221
+ this.bringSelectionIntoView();
1222
+ }
1223
+ }
1224
+ finally {
1225
+ this.viewing = false;
1226
+ }
1227
+ }
1228
+ /** Writes how far the items are scrolled: at once (the scroller's `scroll-behavior` is auto), held inside the range by the browser. */
1229
+ scrollItemsTo(scroller, top) {
1230
+ scroller.scrollTop = top;
1231
+ this.lastScroll = { scroller, top: scroller.scrollTop };
1232
+ }
1233
+ /** Scrolls the items by the least distance that puts `cell`'s row wholly inside the space they scroll in; by nothing if it is. */
1234
+ showWhole(cell) {
1235
+ const scroller = this.scroller;
1236
+ const row = cell.renderRoot?.querySelector('.container');
1237
+ if (!scroller || !row || !scroller.clientHeight)
1238
+ return;
1239
+ const box = row.getBoundingClientRect();
1240
+ if (!box.height)
1241
+ return;
1242
+ const top = scroller.getBoundingClientRect().top + scroller.clientTop;
1243
+ const bottom = top + scroller.clientHeight;
1244
+ // A row taller than the space shows its start.
1245
+ if (box.top < top - 0.5 || box.height > scroller.clientHeight)
1246
+ this.scrollItemsTo(scroller, scroller.scrollTop + box.top - top);
1247
+ else if (box.bottom > bottom + 0.5)
1248
+ this.scrollItemsTo(scroller, scroller.scrollTop + box.bottom - bottom);
1249
+ else
1250
+ this.lastScroll = { scroller, top: scroller.scrollTop };
1251
+ }
1252
+ /** NVD-61: the items go to the offset the product gave; `orStart`: to their start, the default, where it gave none. */
1253
+ applyOffset(orStart = false) {
1254
+ const scroller = this.scroller;
1255
+ const offset = this.givenOffset ?? (orStart ? 0 : null);
1256
+ // Not laid out (not rendered yet, or a closed drawer): kept until it is.
1257
+ if (offset === null || !scroller || !scroller.clientHeight)
1258
+ return;
1259
+ this.scrollItemsTo(scroller, offset);
1260
+ this.unwritten = false;
1261
+ if (this.painted)
1262
+ this.givenOffset = null;
1263
+ }
1264
+ /**
1265
+ * NVD-57: the row that shows the selection — the selected destination, or the group's row NVD-47 names — is centred
1266
+ * in the space the items scroll in if it is not wholly inside it, as far as the range allows, and left alone if it
1267
+ * is. A write to `scrollTop`: never `scrollIntoView()`, which would scroll the page as well; no focus moves.
1268
+ */
1269
+ bringSelectionIntoView() {
1270
+ const scroller = this.scroller;
1271
+ const { shower } = this.takeSnapshot();
1272
+ const row = shower?.renderRoot?.querySelector('.container');
1273
+ if (!scroller || !row || !scroller.clientHeight)
1274
+ return;
1275
+ const space = scroller.getBoundingClientRect();
1276
+ const box = row.getBoundingClientRect();
1277
+ if (!box.height)
1278
+ return;
1279
+ const top = space.top + scroller.clientTop;
1280
+ // Half a pixel of slack: a row that a fractional layout puts a hair past the edge is in view.
1281
+ if (box.top >= top - 0.5 && box.bottom <= top + scroller.clientHeight + 0.5)
1282
+ return;
1283
+ this.scrollItemsTo(scroller, scroller.scrollTop + box.top + box.height / 2 - (top + scroller.clientHeight / 2));
1284
+ }
1285
+ get headerButtons() {
1286
+ return [...this.children].filter((child) => child.getAttribute('slot') === 'header-button');
1287
+ }
1288
+ get mainActions() {
1289
+ return [...this.children].filter((child) => child.getAttribute('slot') === 'main-action');
1290
+ }
1291
+ connectedCallback() {
1292
+ // The form is drawn from the first style the host is given (a controller reads the cascade as it connects): a drawer
1293
+ // that starts collapsed does not narrow into place, and its main action does not collapse into place.
1294
+ // NVD-55: so is a responsive drawer's presentation — decided from the window's width before the first frame.
1295
+ this.watchWidths();
1296
+ this.reflectState();
1297
+ this.syncMainAction();
1298
+ super.connectedCallback();
1299
+ // What the drawer opens after its first frame takes its motion (NVD-58).
1300
+ // NVD-62: until then it is drawn as it is given, without motion (the styles' `data-arriving`).
1301
+ if (!this.painted) {
1302
+ this.setAttribute('data-arriving', '');
1303
+ this.paintFrame = requestAnimationFrame(() => {
1304
+ this.painted = true;
1305
+ // The first frame is about to be drawn: an offset that was written into it has done its work, and what was
1306
+ // given so far is settled in the styles before the motions are given back.
1307
+ if (!this.unwritten)
1308
+ this.givenOffset = null;
1309
+ void this.offsetHeight;
1310
+ this.removeAttribute('data-arriving');
1311
+ });
1312
+ }
1313
+ if (this.hasUpdated && this.open && this.modal)
1314
+ this.present();
1315
+ }
1316
+ // ---- what the drawer is drawn as (NVD-30, NVD-53…55) ----
1317
+ /** The state attributes the styles read: what the drawer is drawn as, whatever its props say (see the styles' header). */
1318
+ reflectState() {
1319
+ this.toggleAttribute('collapsed', this.collapsed);
1320
+ this.setAttribute('data-as', this.modal ? 'modal' : 'standard');
1321
+ this.toggleAttribute('data-collapsible', this.collapses);
1322
+ this.toggleAttribute('data-open', this.isOpen);
1323
+ const presentation = this.presentation;
1324
+ if (presentation)
1325
+ this.setAttribute('presentation', presentation);
1326
+ else
1327
+ this.removeAttribute('presentation');
1328
+ }
1329
+ /**
1330
+ * NVD-53: a responsive drawer listens to its system's two widths — `breakpoint.expanded` and `breakpoint.collapsed`,
1331
+ * read from its computed style (the generated CSS carries them in rem, so they follow the reader's text size) — with
1332
+ * `matchMedia`. While it is not responsive it reads no width and listens to nothing.
1333
+ */
1334
+ watchWidths() {
1335
+ if (!this.responsive || !this.isConnected || typeof matchMedia !== 'function') {
1336
+ this.unwatchWidths();
1337
+ if (this.decided !== null)
1338
+ this.decided = null;
1339
+ return;
1340
+ }
1341
+ const style = getComputedStyle(this);
1342
+ const [expanded, collapsed] = ['expanded', 'collapsed'].map((name) => style.getPropertyValue(`--tanrei-comp-navigation-drawer-breakpoint-${name}`).trim());
1343
+ const text = `${expanded} ${collapsed}`;
1344
+ // Before its stylesheet has arrived the system names no widths: nothing is decided on a guess (NVD-55).
1345
+ if (!expanded || !collapsed) {
1346
+ this.unwatchWidths();
1347
+ return;
1348
+ }
1349
+ if (this.widths?.text !== text) {
1350
+ this.unwatchWidths();
1351
+ this.widths = { expanded: matchMedia(`(min-width: ${expanded})`), collapsed: matchMedia(`(min-width: ${collapsed})`), text };
1352
+ this.widths.expanded.addEventListener('change', this.onWidth);
1353
+ this.widths.collapsed.addEventListener('change', this.onWidth);
1354
+ }
1355
+ this.decide();
1356
+ }
1357
+ unwatchWidths() {
1358
+ this.widths?.expanded.removeEventListener('change', this.onWidth);
1359
+ this.widths?.collapsed.removeEventListener('change', this.onWidth);
1360
+ this.widths = null;
1361
+ }
1362
+ /**
1363
+ * NVD-53, NVD-54: the presentation of the window's current width. The first decision is only drawn. A change is drawn
1364
+ * at once, without the motions of opening, closing or changing form, and is entered closed: an open overlay is taken
1365
+ * down, `open` is false again and `close` fires once. `expanded`, `value` and every group's `open` are not touched.
1366
+ */
1367
+ decide() {
1368
+ const widths = this.widths;
1369
+ if (!widths)
1370
+ return;
1371
+ const next = widths.expanded.matches ? 'standard' : widths.collapsed.matches && this.collapsible ? 'column' : 'modal';
1372
+ const before = this.decided;
1373
+ if (next === before)
1374
+ return;
1375
+ const first = before === null;
1376
+ if (!first) {
1377
+ // Read before anything changes: where focus is, and whether the drawer has it.
1378
+ const active = deepActive();
1379
+ this.focusBefore = active instanceof HTMLElement && this.hasFocus() ? active : null;
1380
+ this.drawAtOnce();
1381
+ const wasOpen = this.open;
1382
+ // The overlay comes down without its motion and without a second `close`.
1383
+ if (this.shown)
1384
+ this.withdraw(false, false);
1385
+ clearTimeout(this.presentTimer);
1386
+ this.presented = false;
1387
+ this.opener = null;
1388
+ this.removeAttribute('data-sliding');
1389
+ if (wasOpen) {
1390
+ this.open = false;
1391
+ this.dispatchEvent(new Event('close'));
1392
+ }
1393
+ }
1394
+ this.decided = next;
1395
+ this.announce = true;
1396
+ // The first frame is the presentation's (NVD-55): the attributes are written before the first style is read.
1397
+ if (!this.hasUpdated)
1398
+ this.reflectState();
1399
+ }
1400
+ /** NVD-54: until the new presentation is drawn, nothing of the drawer's takes time (the styles' `data-instant`). */
1401
+ drawAtOnce() {
1402
+ this.setAttribute('data-instant', '');
1403
+ this.removeAttribute('data-form-change');
1404
+ clearTimeout(this.formTimer);
1405
+ cancelAnimationFrame(this.instantFrame);
1406
+ void this.updateComplete.then(() => {
1407
+ this.instantFrame = requestAnimationFrame(() => {
1408
+ this.instantFrame = requestAnimationFrame(() => this.removeAttribute('data-instant'));
1409
+ });
1410
+ });
1411
+ }
1412
+ disconnectedCallback() {
1413
+ super.disconnectedCallback();
1414
+ this.sizes.disconnect();
1415
+ this.unwatchWidths();
1416
+ cancelAnimationFrame(this.paintFrame);
1417
+ cancelAnimationFrame(this.instantFrame);
1418
+ this.removeAttribute('data-instant');
1419
+ clearTimeout(this.formTimer);
1420
+ clearTimeout(this.presentTimer);
1421
+ if (this.shown)
1422
+ this.withdraw(false, false);
1423
+ }
1424
+ // ---- the cells: what each is told (NVD-3, NVD-23, NVD-31, NVD-33, NVD-47) ----
1425
+ takeSnapshot() {
1426
+ const selected = this.destinations.selected;
1427
+ let shower = selected;
1428
+ if (selected) {
1429
+ const groups = groupsOf(selected);
1430
+ if (this.collapsed && groups.length)
1431
+ shower = groups[0];
1432
+ else
1433
+ shower = groups.find((group) => !group.open) ?? selected;
1434
+ }
1435
+ // The cells of each level, in reading order: a group's are those it holds directly or through anything that is not
1436
+ // a group (a section inside it draws only its items, NVD-17); the top level's are those no group holds.
1437
+ const places = new Map();
1438
+ const top = [];
1439
+ const walk = (parent, level, cells) => {
1440
+ for (const child of parent.children) {
1441
+ if (child instanceof DrawerCell)
1442
+ cells.push(child);
1443
+ if (child instanceof TanreiNavigationDrawerGroup) {
1444
+ const inner = [];
1445
+ walk(child, level + 1, inner);
1446
+ inner.forEach((cell, index) => places.set(cell, { level: level + 1, position: index + 1, size: inner.length }));
1447
+ }
1448
+ else if (child.firstElementChild)
1449
+ walk(child, level, cells);
1450
+ }
1451
+ };
1452
+ walk(this, 0, top);
1453
+ top.forEach((cell, index) => places.set(cell, { level: 0, position: index + 1, size: top.length }));
1454
+ return { shower, top, places };
1455
+ }
1456
+ cellContext(cell, selected) {
1457
+ const { shower, places } = this.snapshot;
1458
+ const { level, position, size } = places.get(cell) ?? { level: groupsOf(cell).length, position: 0, size: 0 };
1459
+ const mode = this.labelsMode;
1460
+ return {
1461
+ selected,
1462
+ position,
1463
+ size,
1464
+ labelShown: true,
1465
+ collapsed: this.collapsed,
1466
+ collapsible: this.collapses,
1467
+ shortShown: mode === 'always' || (mode === 'selected' && cell === shower),
1468
+ labels: mode !== 'never',
1469
+ level,
1470
+ };
1471
+ }
1472
+ /** The groups and sections are told the form and the selection too; and what a debug build reports about the structure. */
1473
+ syncStructure(items) {
1474
+ if (!items.length)
1475
+ this.snapshot = this.takeSnapshot();
1476
+ const { shower, top } = this.snapshot;
1477
+ for (const group of this.groups) {
1478
+ const context = this.cellContext(group, group === shower);
1479
+ group.setDrawerContext(context);
1480
+ // NVD-48: deeper than three levels is still drawn, and reported.
1481
+ if (context.level + 1 > DEEPEST)
1482
+ report(this, 'NVD-48', `groups nest ${context.level + 1} levels deep; a drawer is made for at most ${DEEPEST}`);
1483
+ }
1484
+ for (const section of this.querySelectorAll(SECTION))
1485
+ if (section instanceof TanreiNavigationDrawerSection)
1486
+ section.setDrawerContext({ collapsed: this.collapsed });
1487
+ // NVD-49: a collapsed drawer needs an icon on every top-level destination and group.
1488
+ if (this.collapsed && top.some((cell) => !cell.icon))
1489
+ report(this, 'NVD-49', 'a top-level destination or group has no icon; a collapsible drawer needs an icon on every top-level destination and group');
1490
+ }
1491
+ /** Applies the form asked for (expanded for a standard drawer, open for a modal one), then fires `expandedchange`. */
1492
+ askForm(expand) {
1493
+ if (this.modal)
1494
+ this.open = expand;
1495
+ else
1496
+ this.expanded = expand;
1497
+ this.dispatchEvent(new CustomEvent('expandedchange', { bubbles: true, detail: { expanded: expand } }));
1498
+ }
1499
+ /** @internal NVD-47: a group's cell in the collapsed drawer expands it with the group open, and takes focus to its row. */
1500
+ expandToGroup(group) {
1501
+ if (!this.collapsed)
1502
+ return;
1503
+ this.askForm(true);
1504
+ group.setOpenByUser(true);
1505
+ void this.updateComplete.then(() => group.updateComplete).then(() => group.cell?.focus());
1506
+ }
1507
+ /** NVD-20, NVD-21: a modal drawer closes itself and fires `close` once. */
1508
+ dismiss() {
1509
+ if (!this.modal || !this.open)
1510
+ return;
1511
+ this.open = false;
1512
+ }
1513
+ // ---- focus (NVD-19, NVD-22, NVD-28, NVD-36) ----
1514
+ /** NVD-19, NVD-28: focus to the selected destination (or the group row that shows it), or else the first focusable element. */
1515
+ focusInside() {
1516
+ const { shower } = this.takeSnapshot();
1517
+ if (shower && !shower.disabled) {
1518
+ shower.cell?.focus();
1519
+ if (this.hasFocus()) {
1520
+ // NVD-57, NVD-61: the focus the drawer gives shows its cell whole, whatever the browser does with a focus() call.
1521
+ this.showWhole(shower);
1522
+ return;
1523
+ }
1524
+ }
1525
+ const panel = this.panel;
1526
+ const first = panel ? tabbables(panel)[0] : undefined;
1527
+ if (first)
1528
+ first.focus();
1529
+ else
1530
+ panel?.focus();
1531
+ }
1532
+ /** NVD-22, NVD-28: focus back where it was when the drawer opened — or dropped, where that element is gone. */
1533
+ restoreFocus() {
1534
+ const opener = this.opener;
1535
+ this.opener = null;
1536
+ if (opener && opener.isConnected && typeof opener.focus === 'function' && !opener.closest('[inert]'))
1537
+ opener.focus();
1538
+ else if (this.hasFocus())
1539
+ deepActive()?.blur();
1540
+ }
1541
+ /** Whether focus is inside the drawer (its light DOM or its shadow root). */
1542
+ hasFocus() {
1543
+ const active = deepActive();
1544
+ if (!active)
1545
+ return false;
1546
+ return this.contains(active) || this.renderRoot.contains(active) || (active.getRootNode() instanceof ShadowRoot && this.contains(active.getRootNode().host));
1547
+ }
1548
+ /** NVD-36: whether focus is on what the collapsed form does not draw — the header slot's content, an item inside a group. */
1549
+ focusOnExpandedOnly() {
1550
+ let at = deepActive();
1551
+ while (at && !this.contains(at)) {
1552
+ const root = at.getRootNode();
1553
+ at = root instanceof ShadowRoot ? root.host : null;
1554
+ }
1555
+ if (!at || at === this)
1556
+ return false;
1557
+ if (at.closest('[slot="header"]'))
1558
+ return true;
1559
+ const cell = at.closest(CELLS);
1560
+ return !!cell && groupsOf(cell).length > 0;
1561
+ }
1562
+ // ---- the modal drawer (NVD-19, NVD-20, NVD-22, NVD-40) ----
1563
+ /** NVD-19: the modal drawer in the top layer; the page held; focus inside. */
1564
+ present() {
1565
+ const dialog = this.dialog;
1566
+ if (!dialog || this.shown || !this.isConnected)
1567
+ return;
1568
+ // A collapsible drawer's column was just replaced by its dialog: where focus was is read before that (willUpdate).
1569
+ this.opener = this.pendingOpener ?? deepActive();
1570
+ this.pendingOpener = null;
1571
+ if (!dialog.open)
1572
+ dialog.showModal();
1573
+ this.shown = true;
1574
+ modalLayer.add(this);
1575
+ holdPageScroll(this, true);
1576
+ // NVD-61: an offset given while it was closed is where it opens; NVD-57: focus then brings the selection into view.
1577
+ this.applyOffset();
1578
+ this.focusInside();
1579
+ }
1580
+ /** NVD-20, NVD-22: out of the top layer (sliding, or narrowing to its column), focus back where it was, the page given back, `close`. */
1581
+ withdraw(restore = true, notify = true) {
1582
+ if (!this.shown)
1583
+ return;
1584
+ this.shown = false;
1585
+ modalLayer.delete(this);
1586
+ holdPageScroll(this, false);
1587
+ const dialog = this.dialog;
1588
+ if (dialog?.open)
1589
+ dialog.close();
1590
+ // NVD-40: a collapsible drawer's dialog narrows back to its column, which then takes its place. Focus goes back once
1591
+ // it has: the element that had it (its menu button, usually) is drawn in the closing dialog until then, and an
1592
+ // element in a closed dialog cannot take focus.
1593
+ const narrowing = this.collapses && this.presented;
1594
+ if (!narrowing) {
1595
+ if (restore)
1596
+ this.restoreFocus();
1597
+ else
1598
+ this.opener = null;
1599
+ }
1600
+ else {
1601
+ clearTimeout(this.presentTimer);
1602
+ this.presentTimer = setTimeout(() => {
1603
+ if (this.open)
1604
+ return;
1605
+ this.presented = false;
1606
+ void this.updateComplete.then(() => {
1607
+ if (restore)
1608
+ this.restoreFocus();
1609
+ else
1610
+ this.opener = null;
1611
+ });
1612
+ }, this.expandDuration());
1613
+ }
1614
+ if (notify)
1615
+ this.dispatchEvent(new Event('close'));
1616
+ }
1617
+ /** The change of form's duration, read through a real property (0 where motion is reduced). */
1618
+ expandDuration() {
1619
+ const clock = this.renderRoot?.querySelector('.clock');
1620
+ return clock ? ms(getComputedStyle(clock).transitionDelay) : 0;
1621
+ }
1622
+ onScrim(event) {
1623
+ const dialog = this.dialog;
1624
+ if (!dialog || event.composedPath()[0] !== dialog)
1625
+ return false;
1626
+ const box = dialog.getBoundingClientRect();
1627
+ return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
1628
+ }
1629
+ /** The distance dragged toward the start edge (positive), whatever the direction of the text. */
1630
+ towardStart(dx) {
1631
+ return getComputedStyle(this).direction === 'rtl' ? dx : -dx;
1632
+ }
1633
+ // ---- the header (NVD-37…39) ----
1634
+ onHeaderButtons() {
1635
+ this.hasButtons = this.headerButtons.length > 0;
1636
+ this.observeSizes();
1637
+ this.syncMenuButton();
1638
+ }
1639
+ onHeaderChange(event) {
1640
+ this.hasTitle = event.target.assignedNodes({ flatten: true }).some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? '').trim() !== '');
1641
+ }
1642
+ onMainAction() {
1643
+ const actions = this.mainActions;
1644
+ this.hasMain = actions.length > 0;
1645
+ // NVD-39: the first is drawn; the rest are reported.
1646
+ actions.forEach((action, index) => action.toggleAttribute('data-tanrei-drawer-extra', index > 0));
1647
+ if (actions.length > 1)
1648
+ report(this, 'NVD-39', `it holds ${actions.length} main actions; the first is drawn`);
1649
+ this.observeSizes();
1650
+ this.syncMainAction();
1651
+ }
1652
+ observeSizes() {
1653
+ this.sizes.disconnect();
1654
+ const [button] = this.headerButtons;
1655
+ const [main] = this.mainActions;
1656
+ if (button)
1657
+ this.sizes.observe(button);
1658
+ if (main)
1659
+ this.sizes.observe(main);
1660
+ this.measure();
1661
+ }
1662
+ /** The first header button's width (the header slot starts item.gap after it) and the main action's height (NVD-38, NVD-39). */
1663
+ measure() {
1664
+ const [button] = this.headerButtons;
1665
+ const [main] = this.mainActions;
1666
+ const next = {};
1667
+ if (button?.offsetWidth)
1668
+ next['--_lead'] = `calc(var(--tanrei-comp-navigation-drawer-collapsed-container-width) / 2 + ${button.offsetWidth / 2}px)`;
1669
+ if (main?.offsetHeight)
1670
+ next['--_main-size'] = `${main.offsetHeight}px`;
1671
+ const now = this.measured;
1672
+ if (Object.keys(next).length !== Object.keys(now).length || Object.entries(next).some(([key, value]) => now[key] !== value))
1673
+ this.measured = next;
1674
+ }
1675
+ /** NVD-37: the menu button says whether the drawer is expanded, and that it controls it, on its native button. */
1676
+ syncMenuButton() {
1677
+ const first = this.headerButtons[0] ?? null;
1678
+ const inner = (button) => button?.shadowRoot?.querySelector('button') ?? null;
1679
+ if (this.menuButton && this.menuButton !== first) {
1680
+ const old = inner(this.menuButton);
1681
+ if (old) {
1682
+ old.ariaExpanded = null;
1683
+ if ('ariaControlsElements' in old)
1684
+ old.ariaControlsElements = null;
1685
+ }
1686
+ }
1687
+ this.menuButton = first;
1688
+ if (!first)
1689
+ return;
1690
+ const button = inner(first);
1691
+ if (!button) {
1692
+ // Not rendered yet: once it is.
1693
+ void first.updateComplete?.then(() => {
1694
+ if (inner(first))
1695
+ this.syncMenuButton();
1696
+ });
1697
+ return;
1698
+ }
1699
+ if (this.collapses) {
1700
+ button.ariaExpanded = String(!this.collapsed);
1701
+ if ('ariaControlsElements' in button)
1702
+ button.ariaControlsElements = [this];
1703
+ }
1704
+ else {
1705
+ button.ariaExpanded = null;
1706
+ if ('ariaControlsElements' in button)
1707
+ button.ariaControlsElements = null;
1708
+ }
1709
+ }
1710
+ /** NVD-39: the main action is collapsed to its icon while the drawer is, and extended while it is expanded. */
1711
+ syncMainAction() {
1712
+ const [main] = this.mainActions;
1713
+ // Set before the button is defined too: a Lit element takes a property set before its upgrade as its own.
1714
+ if (main && ('extended' in main || !customElements.get(main.localName)))
1715
+ main.extended = !this.collapsed;
1716
+ }
1717
+ // ---- updates ----
1718
+ willUpdate(changed) {
1719
+ // NVD-53: `responsive` turned on or off, or `collapsible` changed under it: the widths are listened to, or no longer.
1720
+ if ((changed.has('responsive') || changed.has('collapsible')) && this.hasUpdated) {
1721
+ if (changed.has('responsive'))
1722
+ this.watchWidths();
1723
+ else
1724
+ this.decide();
1725
+ }
1726
+ else if (this.responsive && !this.widths)
1727
+ this.watchWidths(); // its system's widths had not arrived yet
1728
+ const instant = this.hasAttribute('data-instant');
1729
+ const collapsed = this.collapsed;
1730
+ // NVD-35: a change of form takes the change's motion, for as long as it lasts; the collapsed attribute reflects it.
1731
+ // NVD-54: not when the window's width changed the presentation, which is drawn at once.
1732
+ if (this.wasCollapsed !== undefined && collapsed !== this.wasCollapsed && !instant) {
1733
+ this.focusLost = collapsed && !this.modal && this.focusOnExpandedOnly();
1734
+ this.removeAttribute('data-sliding');
1735
+ this.setAttribute('data-form-change', '');
1736
+ clearTimeout(this.formTimer);
1737
+ this.formTimer = setTimeout(() => this.removeAttribute('data-form-change'), this.expandDuration());
1738
+ }
1739
+ this.wasCollapsed = collapsed;
1740
+ this.reflectState();
1741
+ // NVD-18: a standard drawer that opens slides in over the enter motion.
1742
+ if (changed.has('open') && changed.get('open') !== undefined && this.open && !this.modal && !instant && !this.responsive)
1743
+ this.setAttribute('data-sliding', '');
1744
+ if (changed.has('open') && changed.get('open') === true && !this.open && !this.modal)
1745
+ this.closingWithFocus = this.hasFocus();
1746
+ // NVD-40: a collapsible modal drawer's dialog widens from its column, placed over it.
1747
+ if (this.modal && this.collapses && this.open) {
1748
+ clearTimeout(this.presentTimer);
1749
+ if (!this.presented) {
1750
+ const active = deepActive();
1751
+ this.pendingOpener = (!active || active === document.body) && this.pressedMenu?.isConnected ? this.pressedMenu : active;
1752
+ const box = this.getBoundingClientRect();
1753
+ const rtl = getComputedStyle(this).direction === 'rtl';
1754
+ this.place = { '--_top': `${box.top}px`, '--_start': `${rtl ? document.documentElement.clientWidth - box.right : box.left}px`, '--_height': `${box.height}px` };
1755
+ this.presented = true;
1756
+ }
1757
+ }
1758
+ }
1759
+ updated(changed) {
1760
+ // NVD-58: turned on, it shows the selection it has.
1761
+ if (changed.has('revealSelected') && changed.get('revealSelected') === false && this.revealSelected) {
1762
+ this.shownFor = undefined;
1763
+ this.destinations.sync();
1764
+ }
1765
+ // NVD-57, NVD-61: a drawer that takes its place only now is scrolled where it was asked to be, its selection in view.
1766
+ if (changed.has('open') && changed.get('open') === false && this.open && !this.modal) {
1767
+ this.applyOffset();
1768
+ this.bringSelectionIntoView();
1769
+ }
1770
+ // NVD-24: a modal drawer without a label is a dialog without a name.
1771
+ if ((changed.has('label') || changed.has('variant')) && this.modal && !this.label.trim())
1772
+ report(this, 'NVD-24', 'label is empty, so the modal drawer is a dialog without a name; give it a label');
1773
+ // NVD-37: a collapsible drawer whose user cannot change its form.
1774
+ if ((changed.has('collapsible') || has(changed, 'hasButtons')) && this.collapsible && !this.headerButtons.length) {
1775
+ report(this, 'NVD-37', 'it is collapsible but has no header button, so its user cannot change its form; give it a menu button (slot="header-button")', { once: false });
1776
+ }
1777
+ const presentationChanged = has(changed, 'decided') || (changed.has('responsive') && changed.get('responsive') !== undefined);
1778
+ const variantChanged = (changed.has('variant') && changed.get('variant') !== undefined) || (changed.has('collapsible') && changed.get('collapsible') !== undefined) || presentationChanged;
1779
+ if (variantChanged && this.shown)
1780
+ this.withdraw(false, false);
1781
+ if (changed.has('open') || variantChanged || has(changed, 'presented')) {
1782
+ const was = changed.has('open') ? changed.get('open') === true : this.open;
1783
+ if (this.modal) {
1784
+ if (this.open)
1785
+ this.present();
1786
+ else if (this.shown)
1787
+ this.withdraw();
1788
+ }
1789
+ else if (changed.has('open') && this.hasUpdated && changed.get('open') !== undefined && !this.responsive) {
1790
+ // NVD-28: a standard drawer opened moves focus in; closed with focus inside, it gives it back.
1791
+ if (this.open && !was) {
1792
+ this.opener = deepActive();
1793
+ this.focusInside();
1794
+ }
1795
+ else if (!this.open && was && this.closingWithFocus) {
1796
+ this.closingWithFocus = false;
1797
+ this.restoreFocus();
1798
+ }
1799
+ }
1800
+ }
1801
+ const form = changed.has('collapsible') || changed.has('open') || changed.has('expanded') || changed.has('variant') || presentationChanged;
1802
+ if (form || has(changed, 'hasButtons'))
1803
+ this.syncMenuButton();
1804
+ if (form)
1805
+ this.syncMainAction();
1806
+ // NVD-36: focus on what the collapsed form does not draw goes to the menu button, or else the first focusable element.
1807
+ if (this.focusLost) {
1808
+ this.focusLost = false;
1809
+ const [menu] = this.headerButtons;
1810
+ const panel = this.panel;
1811
+ const first = menu ?? (panel ? tabbables(panel)[0] : undefined);
1812
+ first?.focus();
1813
+ }
1814
+ // NVD-54: focus that was in the drawer stays where it is while the new presentation still shows it; on something it
1815
+ // does not show, it goes to the menu button, or else the first focusable element still shown; and where the drawer
1816
+ // shows nothing it is left to the platform.
1817
+ const focused = this.focusBefore;
1818
+ if (focused && presentationChanged) {
1819
+ this.focusBefore = null;
1820
+ this.keepFocus(focused);
1821
+ }
1822
+ // NVD-54, NVD-55: once the presentation it names is drawn — the first decision included.
1823
+ if (this.announce && this.presentation) {
1824
+ this.announce = false;
1825
+ this.dispatchEvent(new CustomEvent('presentationchange', { bubbles: true, detail: { presentation: this.presentation } }));
1826
+ }
1827
+ }
1828
+ /** NVD-54: puts focus back on `element` if the drawer still shows it, or else on what it does show. */
1829
+ keepFocus(element) {
1830
+ const panel = this.panel;
1831
+ // Nothing of the drawer is shown (the modal presentation, closed): focus is the platform's.
1832
+ if (!panel || panel.matches('[inert]') || (panel instanceof HTMLDialogElement && !panel.open))
1833
+ return;
1834
+ // Inert is inherited through slots and shadow roots: every ancestor in the flat tree is asked.
1835
+ const inert = (candidate) => {
1836
+ for (let at = candidate; at && at !== this; at = at.assignedSlot ?? at.parentNode ?? at.host ?? null) {
1837
+ if (at instanceof Element && at.hasAttribute('inert'))
1838
+ return true;
1839
+ }
1840
+ return false;
1841
+ };
1842
+ const shown = (candidate) => candidate.isConnected && !inert(candidate) && candidate.getClientRects().length > 0 && getComputedStyle(candidate).visibility !== 'hidden';
1843
+ void Promise.all([...this.querySelectorAll(`${CELLS}, ${SECTION}`)].map((cell) => cell.updateComplete)).then(() => {
1844
+ if (shown(element)) {
1845
+ if (deepActive() !== element)
1846
+ element.focus();
1847
+ if (deepActive() === element)
1848
+ return;
1849
+ }
1850
+ const [menu] = this.headerButtons;
1851
+ const first = menu ?? tabbables(panel)[0];
1852
+ first?.focus();
1853
+ });
1854
+ }
1855
+ body() {
1856
+ const collapsed = this.collapsed;
1857
+ const filled = this.hasButtons || this.hasTitle || this.hasMain;
1858
+ return html `
1859
+ <div part="outline" class="edge" aria-hidden="true"></div>
1860
+ <div part="header" class=${classMap({ header: true, filled, 'no-buttons': !this.hasButtons })} style=${styleMap(this.measured)}>
1861
+ <slot name="header-button" @slotchange=${this.onHeaderButtons}></slot>
1862
+ <div class=${classMap({ title: true, filled: this.hasTitle })} ?inert=${collapsed} aria-hidden=${collapsed ? 'true' : nothing}>
1863
+ <slot name="header" @slotchange=${this.onHeaderChange}></slot>
1864
+ </div>
1865
+ <slot name="main-action" @slotchange=${this.onMainAction}></slot>
1866
+ </div>
1867
+ <div part="content" class="items" role="list" @scroll=${this.onScroll}><slot></slot></div>
1868
+ <span class="clock"></span>
1869
+ `;
1870
+ }
1871
+ render() {
1872
+ const label = this.label || nothing;
1873
+ if (this.modal && (!this.collapses || this.presented)) {
1874
+ // NVD-23: a modal dialog named by the label, holding the navigation landmark.
1875
+ return html `<dialog
1876
+ part="container"
1877
+ class=${classMap({ drawer: true, widening: this.collapses })}
1878
+ style=${styleMap(this.collapses ? this.place : {})}
1879
+ aria-label=${label}
1880
+ tabindex="-1"
1881
+ data-tanrei-shape
1882
+ @keydown=${this.onKeyDown}
1883
+ @cancel=${this.onNativeCancel}
1884
+ @pointerdown=${this.onPointerDown}
1885
+ @pointermove=${this.onPointerMove}
1886
+ @pointerup=${this.onPointerUp}
1887
+ @pointercancel=${this.onPointerUp}
1888
+ @click=${this.onClick}
1889
+ >
1890
+ <nav class="landmark" aria-label=${label} @click=${this.onClickCapture}>${this.body()}</nav>
1891
+ </dialog>`;
1892
+ }
1893
+ // NVD-40: a collapsible modal drawer's column, while it is closed: a layout region, drawn as a standard drawer's.
1894
+ if (this.modal)
1895
+ return html `<nav part="container" class="drawer column" aria-label=${label} data-tanrei-shape>${this.body()}</nav>`;
1896
+ // NVD-18: closed, it is out of the focus order and the accessibility tree at once (inert), and hidden once it has slid out.
1897
+ return html `<nav part="container" class="drawer standard" aria-label=${label} ?inert=${!this.isOpen} data-tanrei-shape>${this.body()}</nav>`;
1898
+ }
1899
+ }
1900
+ // A section's divider and a destination's badge are the divider and badge components (NVD-17, NVD-42): they are defined
1901
+ // wherever a drawer is.
1902
+ if (!customElements.get('tanrei-divider'))
1903
+ customElements.define('tanrei-divider', TanreiDivider);
1904
+ if (!customElements.get('tanrei-badge'))
1905
+ customElements.define('tanrei-badge', TanreiBadge);
1906
+ // NVD-56: a collapsed cell's name is shown by the tooltip component.
1907
+ if (!customElements.get('tanrei-tooltip'))
1908
+ customElements.define('tanrei-tooltip', TanreiTooltip);
1909
+ if (!customElements.get(ITEM))
1910
+ customElements.define(ITEM, TanreiNavigationDrawerItem);
1911
+ if (!customElements.get(GROUP))
1912
+ customElements.define(GROUP, TanreiNavigationDrawerGroup);
1913
+ if (!customElements.get(SECTION))
1914
+ customElements.define(SECTION, TanreiNavigationDrawerSection);
1915
+ if (!customElements.get(DRAWER))
1916
+ customElements.define(DRAWER, TanreiNavigationDrawer);
1917
+ //# sourceMappingURL=navigation-drawer.js.map