@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,2183 @@
1
+ import { LitElement, html, nothing } from 'lit';
2
+ import { hiddenHost } from '../../primitives/hidden.js';
3
+ import { classMap } from 'lit/directives/class-map.js';
4
+ import { AvailabilityController, GlyphMirrorController, OpenAxesController, PressController, RovingKeys, SHEET_FLING_VELOCITY, SheetDrag, answersPress, choiceAttribute, compChoice, findInteractive, hostAria, keepInPlace, layoutScale, notifyItemUpdate, remember, remembered, report, sharedChoice, styleQueries, syncFocusStyle, } from '../../primitives/index.js';
5
+ import { ownDirection } from '../../styles/product-text.js';
6
+ import { TanreiTooltip } from '../tooltip/tooltip.js';
7
+ import { AXES, INLINE_VARIANTS, TRACK_CHOICE, TRACK_PROPERTY, TRANSITION_CHOICE, TRANSITION_PROPERTY, TRANSITION_VALUES, panelStyles, tabStyles, tabsStyles } from './tabs.styles.js';
8
+ const UNSCALED = { x: 1, y: 1 };
9
+ /**
10
+ * TAB-28: how fast the tabs scroll to keep a dragged indicator in view, in px per ms. The spec names no speed; this is
11
+ * the gesture's own constant, as the slop and the fling velocity are.
12
+ */
13
+ const DRAG_SCROLL_SPEED = 0.6;
14
+ /** How many frames a row drawn at a scale that does not change is looked at before it is taken to rest at it (TAB-16). */
15
+ const SCALE_STILL_FRAMES = 30;
16
+ /** TAB-14, TAB-16: how much wider than tall a content may measure and still be as wide as it is tall, in px at rest. */
17
+ const CIRCLE_SLACK = 0.05;
18
+ /** Twice what a written length is rounded to (`px()`), in px: less than this is no overlap at all. */
19
+ const HAIR = 0.02;
20
+ const lerp = (a, b, p) => a + (b - a) * p;
21
+ /** Whether two places of the indicator are one, to what a length is written to. */
22
+ const sameMark = (a, b) => ['x', 'y', 'w', 'h'].every((k) => Math.abs(a.pill[k] - b.pill[k]) < 0.01) && Math.abs(a.line.x - b.line.x) < 0.01 && Math.abs(a.line.w - b.line.w) < 0.01;
23
+ const between = (a, b, p) => ({
24
+ pill: { x: lerp(a.pill.x, b.pill.x, p), y: lerp(a.pill.y, b.pill.y, p), w: lerp(a.pill.w, b.pill.w, p), h: lerp(a.pill.h, b.pill.h, p) },
25
+ line: { x: lerp(a.line.x, b.line.x, p), w: lerp(a.line.w, b.line.w, p) },
26
+ });
27
+ let ids = 0;
28
+ /** Whether `node` is inside `ancestor`, through shadow roots. */
29
+ function composedContains(ancestor, node) {
30
+ for (let each = node; each; each = each instanceof ShadowRoot ? each.host : each.parentNode)
31
+ if (each === ancestor)
32
+ return true;
33
+ return false;
34
+ }
35
+ const px = (n) => `${Math.round(n * 100) / 100}px`;
36
+ const num = (n) => Math.round(n * 100) / 100;
37
+ /**
38
+ * TAB-16, TAB-24: what one tab draws of the indicator at `pill` and of the underline at `line`, both in the tab's own
39
+ * coordinates (they may reach beyond it: the rest is drawn by its neighbours): the covered layer's clip, the same shape
40
+ * cut out of the plain content, and the underline's clip — and whether the indicator reaches the tab at all, and its
41
+ * content. Every number of the three is linear in the indicator's place while its corner stays (`radius` in px, taken
42
+ * as the browser clamps it: at most half of either side), so a browser that interpolates two of these draws what this
43
+ * function gives for the place in between: a slide's frames (TAB-17) are a drag's (TAB-28).
44
+ */
45
+ function pieces(pill, line, { size, content }, radius) {
46
+ // Reaching it by less than what a length is written to (a hundredth of a pixel: two boxes that meet, measured apart)
47
+ // is not reaching it — it would be a hairline of the indicator's color drawn beside the indicator, on its neighbour.
48
+ const reaches = pill.w > HAIR && pill.h > HAIR && pill.x < size.w - HAIR && pill.x + pill.w > HAIR && pill.y < size.h - HAIR && pill.y + pill.h > HAIR;
49
+ const r = Math.max(0, Math.min(radius, pill.w / 2, pill.h / 2));
50
+ const [x, y, w, h] = [pill.x - content.x, pill.y - content.y, pill.w, pill.h];
51
+ return {
52
+ reaches,
53
+ meets: reaches && x < content.w - HAIR && x + w > HAIR && y < content.h - HAIR && y + h > HAIR,
54
+ cover: `inset(${px(pill.y)} ${px(size.w - pill.x - pill.w)} ${px(size.h - pill.y - pill.h)} ${px(pill.x)} round ${px(r)})`,
55
+ plain: `path(evenodd, "M-99999 -99999H99999V99999H-99999Z M${num(x + r)} ${num(y)}H${num(x + w - r)}A${num(r)} ${num(r)} 0 0 1 ${num(x + w)} ${num(y + r)}V${num(y + h - r)}A${num(r)} ${num(r)} 0 0 1 ${num(x + w - r)} ${num(y + h)}H${num(x + r)}A${num(r)} ${num(r)} 0 0 1 ${num(x)} ${num(y + h - r)}V${num(y + r)}A${num(r)} ${num(r)} 0 0 1 ${num(x + r)} ${num(y)}Z")`,
56
+ underline: `inset(0 ${px(size.w - line.x - line.w)} 0 ${px(line.x)} round var(--_us) var(--_us) 0 0)`,
57
+ };
58
+ }
59
+ /** The slide's own name on every animation of it: the row's clock on the strip, and each tab's pieces (TAB-17). */
60
+ const SLIDE = 'tanrei-tabs-slide';
61
+ /**
62
+ * One tab of a row — the spec's item kind `tab`: a label, an optional icon, and the value that selects it.
63
+ * Placed as a child of `<tanrei-tabs>`, as `<option>` in a `<select>`; the row decides whether it is selected, which tab
64
+ * is the Tab stop, and answers its activation.
65
+ *
66
+ * The host carries the tab's semantics — the tab role, its selected state, its position, the number of tabs and its
67
+ * name, its label whether or not the label is drawn — and takes focus itself.
68
+ *
69
+ * A label that does not fit its tab (a row that fills) is truncated with an ellipsis and shown whole in a plain tooltip on
70
+ * hover and keyboard focus; it stays the tab's whole accessible name, and the tooltip is not exposed a second time.
71
+ *
72
+ * @tag tanrei-tab
73
+ * @csspart container - The tab's state layer: hover, focus and press and the ripple, drawn in the box the active indicator has on this tab (a capsule, a circle, or the tab's share in a row that fills), never on the tab's rectangle. The whole tab answers the pointer.
74
+ * @csspart icon - The glyph (hidden from assistive technology).
75
+ * @csspart label - The tab's text.
76
+ * @csspart active-indicator - The indicator's piece on this tab, carrying the covered copy of the icon and label, clipped to where the indicator is (hidden from assistive technology).
77
+ * @csspart underline - The underline's piece on the tab's bottom edge, clipped to where the underline is (hidden from assistive technology).
78
+ */
79
+ export class TanreiTab extends LitElement {
80
+ static { this.styles = [tabStyles, hiddenHost]; }
81
+ static { this.properties = {
82
+ value: { type: String, reflect: true },
83
+ label: { type: String },
84
+ icon: { type: String },
85
+ labelHidden: { type: Boolean, attribute: 'label-hidden', reflect: true },
86
+ disabled: { type: Boolean, reflect: true },
87
+ context: { state: true },
88
+ truncated: { state: true },
89
+ }; }
90
+ constructor() {
91
+ super();
92
+ /** Identifies the tab: the row's `value` names the selected tab by it, and `change` carries it. Unique within the row; required. */
93
+ this.value = '';
94
+ /** The tab's text and its accessible name. Required, even when `labelHidden` is true. */
95
+ this.label = '';
96
+ /** The name of a glyph of the system's icon set. Give every tab of a row an icon, or none. A glyph the icon set flags as showing a direction (`arrow_forward`, `send`) is drawn mirrored in a right-to-left layout. */
97
+ this.icon = '';
98
+ /** Draws the icon alone and keeps `label` as the accessible name (an icon-only tab). */
99
+ this.labelHidden = false;
100
+ /** Prevents selecting the tab; the arrow keys skip it and it is never the Tab stop. */
101
+ this.disabled = false;
102
+ /** What the row says about this tab. */
103
+ this.context = { selected: false, tabStop: false, position: 0, size: 0, secondary: false, small: false, fill: false, pillDisabled: false };
104
+ /** TAB-25: the drawn label does not fit its tab, so it is truncated and the tooltip shows it whole. */
105
+ this.truncated = false;
106
+ /** TAB-25: the label's box changes with the row's width and the text's (a font arriving, the text size). */
107
+ this.labelSize$ = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.measureTruncation());
108
+ this.observedLabel = null;
109
+ /**
110
+ * TAB-32: the tab's glyph, in both of its copies (TAB-24), is marked when the icon set mirrors its name in
111
+ * right-to-left (src/primitives/glyph-mirror.ts); `iconGlyph()` draws the mark.
112
+ */
113
+ this.mirror = new GlyphMirrorController(this, { drawn: '.icon' });
114
+ /** TAB-8 / TAB-9: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
115
+ this.press = new PressController(this, {
116
+ container: () => this.renderRoot?.querySelector('.tab') ?? null,
117
+ // TAB-9, TAB-18: the ripple is drawn in the container (the indicator's box) and clipped to it, wherever the press lands.
118
+ rippleHost: () => this.renderRoot?.querySelector('.box') ?? null,
119
+ holdCarrier: () => this.renderRoot.querySelector('.content'),
120
+ disabled: () => this.disabled,
121
+ });
122
+ this.spaceDown = false;
123
+ /** TAB-34: how much narrower than its own width the tab is laid out now, in px: what its ends of the row took back. */
124
+ this.trimmed = 0;
125
+ /** TAB-41: the row measures this tab's label with every other row's (`measureLabel()`), so its next draw does not. */
126
+ this.labelDeferred = false;
127
+ /** TAB-1: Enter activates on key-down and Space on key-up, as a native button does; the activation is a click. */
128
+ this.onKeyDown = (event) => {
129
+ if (event.composedPath()[0] !== this)
130
+ return;
131
+ if (event.key === ' ')
132
+ event.preventDefault(); // Space would scroll the page.
133
+ if (this.disabled)
134
+ return;
135
+ this.press.onKeyDown(event);
136
+ if (event.key === 'Enter') {
137
+ event.preventDefault();
138
+ if (!event.repeat)
139
+ super.click();
140
+ }
141
+ else if (event.key === ' ')
142
+ this.spaceDown = true;
143
+ };
144
+ this.onKeyUp = (event) => {
145
+ if (event.composedPath()[0] !== this)
146
+ return;
147
+ this.press.onKeyUp(event);
148
+ if (event.key !== ' ' || !this.spaceDown)
149
+ return;
150
+ this.spaceDown = false;
151
+ if (!this.disabled)
152
+ super.click();
153
+ };
154
+ /**
155
+ * TAB-10: where style queries are missing, the focus style is read when focus arrives. TAB-25: keyboard focus on a
156
+ * truncated tab shows its whole label (the tooltip opens by itself on hover; focus is on this host, outside it).
157
+ */
158
+ this.onFocus = () => {
159
+ syncFocusStyle(this, this);
160
+ if (!this.matches(':focus-visible') || !this.measureTruncation())
161
+ return;
162
+ void this.updateComplete.then(() => {
163
+ const tip = this.tooltip;
164
+ if (tip && this.matches(':focus-visible'))
165
+ tip.open = true;
166
+ });
167
+ };
168
+ this.onBlur = () => {
169
+ this.spaceDown = false;
170
+ this.press.onBlur();
171
+ const tip = this.tooltip;
172
+ if (tip)
173
+ tip.open = false;
174
+ };
175
+ // TAB-2: a disabled tab swallows every click that reaches it, from its content or dispatched on it.
176
+ this.addEventListener('click', (event) => {
177
+ if (this.disabled) {
178
+ event.preventDefault();
179
+ event.stopImmediatePropagation();
180
+ }
181
+ }, { capture: true });
182
+ this.addEventListener('keydown', this.onKeyDown);
183
+ this.addEventListener('keyup', this.onKeyUp);
184
+ this.addEventListener('focus', this.onFocus);
185
+ this.addEventListener('blur', this.onBlur);
186
+ }
187
+ connectedCallback() {
188
+ super.connectedCallback();
189
+ if (!this.id)
190
+ this.id = `tanrei-tab-${++ids}`;
191
+ if (this.observedLabel)
192
+ this.labelSize$?.observe(this.observedLabel);
193
+ }
194
+ disconnectedCallback() {
195
+ super.disconnectedCallback();
196
+ this.labelSize$?.disconnect();
197
+ }
198
+ /** @internal The row's side. */
199
+ setTabsContext(context) {
200
+ const now = this.context;
201
+ if (Object.keys(context).every((key) => context[key] === now[key]))
202
+ return;
203
+ this.context = context;
204
+ }
205
+ /** @internal Whether the row draws this tab as its selected one. */
206
+ get isSelected() {
207
+ return this.context.selected;
208
+ }
209
+ /** `element.click()` selects the tab as a pointer would; a disabled tab does nothing (TAB-2). */
210
+ click() {
211
+ if (this.disabled)
212
+ return;
213
+ super.click();
214
+ }
215
+ /** @internal What the row measures to place the indicator (TAB-16, TAB-17). */
216
+ get indicatorParts() {
217
+ const root = this.renderRoot;
218
+ const tab = root?.querySelector('.tab');
219
+ const box = root?.querySelector('.box');
220
+ const content = root?.querySelector('.tab > .content');
221
+ const plate = root?.querySelector('.plate');
222
+ return tab && box && content && plate ? { tab, box, content, plate } : null;
223
+ }
224
+ /**
225
+ * @internal TAB-23, TAB-38: while `on`, the tab's colors change at once — the row follows its group's choice, or one
226
+ * restored from storage, and a follower shows no motion. The row takes it off again once the change is drawn.
227
+ */
228
+ still(on) {
229
+ this.renderRoot?.querySelector('.tab')?.toggleAttribute('data-still', on);
230
+ }
231
+ /** @internal TAB-28: the drag was taken, so the press on this tab ends as any press does (TAB-8). */
232
+ releasePress() {
233
+ this.press.release();
234
+ }
235
+ /**
236
+ * @internal TAB-16, TAB-18: reads what sizes the container, which is the indicator's box on this tab. Its height is the
237
+ * tab's (the row's) less track.padding above and below — the box's own, by its insets. In a row that hugs its width
238
+ * is the content plus active-indicator.padding-inline on each side (the probe), never wider than the tab and never
239
+ * narrower than its height — and exactly its height where the content is not wider than it is tall: a circle.
240
+ * Everything is in the tab's own pixels: what is read on the page is divided by the row's `scale`, so a row first
241
+ * drawn while its surface scales in sizes its tabs as it does at rest (the padding and what is written are never
242
+ * scaled).
243
+ */
244
+ readBox(scale = UNSCALED) {
245
+ const parts = this.indicatorParts;
246
+ if (!parts)
247
+ return null;
248
+ const height = parts.box.getBoundingClientRect().height / scale.y;
249
+ // The tab's own width is what it has before an end of the row takes some of it back (TAB-34): what is drawn, and
250
+ // what was taken.
251
+ const tab = Math.max(parts.tab.getBoundingClientRect().width / scale.x + this.trimmed, height);
252
+ const drawn = parts.content.getBoundingClientRect();
253
+ const content = { width: drawn.width / scale.x, height: drawn.height / scale.y };
254
+ const padding = getComputedStyle(parts.content);
255
+ const tall = content.height - (Number.parseFloat(padding.paddingTop) || 0) - (Number.parseFloat(padding.paddingBottom) || 0);
256
+ // What the page rounds a box to, read through the scale, is the measurement's and not the content's: a glyph as
257
+ // wide as it is tall is a circle at any scale.
258
+ const circle = content.width <= tall + CIRCLE_SLACK / Math.min(1, scale.x, scale.y);
259
+ // In a row that fills the box is the tab's whole share (the stylesheet's), whatever the tab holds.
260
+ const fill = this.context.fill;
261
+ const width = fill ? tab : circle ? height : Math.min(tab, Math.max(height, parts.plate.getBoundingClientRect().width / scale.x));
262
+ const round = circle && !fill;
263
+ // The track's inset is the box's own, above and below (the stylesheet's).
264
+ const over = round ? (tab - width) / 2 - (Number.parseFloat(getComputedStyle(parts.box).top) || 0) : 0;
265
+ return { height, width, tab, round, over: over > 0.01 ? over : 0 };
266
+ }
267
+ /**
268
+ * @internal TAB-14, TAB-16, TAB-34: writes what `readBox()` read — the container's width, the tab's least width,
269
+ * whether the tab is its circle (no inline padding), and how much wider than its indicator the tab is at each side
270
+ * (`--_wider`: what is left of the track's inset beside an end tab is that tab's hit area). Returns whether what it
271
+ * wrote changes the tab's own width, so that the row reads the tabs again.
272
+ */
273
+ writeBox(size) {
274
+ const tab = this.renderRoot?.querySelector('.tab');
275
+ if (!tab || !size)
276
+ return false;
277
+ const least = px(size.height);
278
+ if (this.style.getPropertyValue('--_th') !== least)
279
+ this.style.setProperty('--_th', least);
280
+ const resized = tab.hasAttribute('data-round') !== size.round;
281
+ if (resized)
282
+ tab.toggleAttribute('data-round', size.round);
283
+ const wider = px(Math.max(0, (size.tab - size.width) / 2));
284
+ if (this.style.getPropertyValue('--_wider') !== wider)
285
+ this.style.setProperty('--_wider', wider);
286
+ // TAB-34: at an end of the row a circle's tab that is wider than the circle by more than the track's inset ends at
287
+ // the track's edge: it is laid out that much narrower on that side, and its content, its container and its ring
288
+ // lean the same way, so that the circle lies the inset from the track's end and one tab's width from its
289
+ // neighbour's. (The track clips what would reach beyond it; the row answers a press there, `tabBeside()`.)
290
+ const { position, size: count } = this.context;
291
+ const [start, end] = [position === 1 ? size.over : 0, position > 0 && position === count ? size.over : 0];
292
+ const trim = start + end;
293
+ const both = Math.min(start, end);
294
+ const set = (name, value) => {
295
+ const text = value > 0 ? px(value) : '';
296
+ if (this.style.getPropertyValue(name) === text)
297
+ return false;
298
+ if (text)
299
+ this.style.setProperty(name, text);
300
+ else
301
+ this.style.removeProperty(name);
302
+ return true;
303
+ };
304
+ const trimmedNow = set('--_trim', trim);
305
+ set('--_lean-start', end - both);
306
+ set('--_lean-end', start - both);
307
+ this.trimmed = trim > 0 ? Math.round(trim * 100) / 100 : 0;
308
+ // A box as wide as the tab is the tab's own width (the stylesheet's 100%), not a number that could lag behind it.
309
+ const width = size.width >= size.tab - 0.01 ? '' : px(size.width);
310
+ if (tab.style.getPropertyValue('--_bw') !== width) {
311
+ if (width)
312
+ tab.style.setProperty('--_bw', width);
313
+ else
314
+ tab.style.removeProperty('--_bw');
315
+ }
316
+ return resized || trimmedNow;
317
+ }
318
+ /**
319
+ * @internal TAB-16, TAB-24: draws the indicator's and the underline's pieces on this tab. `pill` and `line` are in the
320
+ * tab's own coordinates (they may reach beyond it: the rest is drawn by its neighbours), `size` is the tab's box and
321
+ * `content` its plain content's box, `radius` the indicator's corner in px. The covered layer — the indicator's color
322
+ * and the covered copy — is clipped to the indicator; the plain content has the same shape cut out, so nothing is
323
+ * drawn twice under a translucent indicator. `null` draws neither.
324
+ */
325
+ paintIndicator(pill, line, size, content, radius) {
326
+ const root = this.renderRoot;
327
+ const cover = root?.querySelector('.cover');
328
+ const underline = root?.querySelector('.underline');
329
+ const plain = root?.querySelector('.tab > .content');
330
+ if (!cover || !underline || !plain)
331
+ return;
332
+ const piece = pill && line ? pieces(pill, line, { size, content }, radius) : null;
333
+ // A tab the indicator does not reach draws no copy at all: hidden, not only clipped away, so that nothing reads it as
334
+ // text on the indicator's color (an accessibility checker does not see a clip).
335
+ cover.style.visibility = piece?.reaches ? '' : 'hidden';
336
+ cover.style.clipPath = piece?.cover ?? '';
337
+ plain.style.clipPath = piece?.meets ? piece.plain : '';
338
+ underline.style.clipPath = piece?.underline ?? '';
339
+ }
340
+ /**
341
+ * @internal TAB-17, TAB-24: this tab's pieces of a slide — the covered layer's clip, the cut in the plain content and
342
+ * the underline's clip, each moved by the browser through what `pieces()` gives at every one of `stops` (the
343
+ * indicator's places along the slide, at equal parts of it, in the tab's own coordinates), over `timing` from `start`
344
+ * on the document's timeline. What the tab is given to draw at rest (`paintIndicator`, the slide's end) is under them
345
+ * and shows when they are over; while they run the covered layer is drawn on every tab the indicator passes.
346
+ * Returns the animations: the row holds them.
347
+ */
348
+ slideIndicator(stops, frame, radius, timing, start) {
349
+ const root = this.renderRoot;
350
+ const cover = root?.querySelector('.cover');
351
+ const underline = root?.querySelector('.underline');
352
+ const plain = root?.querySelector('.tab > .content');
353
+ if (!cover || !underline || !plain)
354
+ return [];
355
+ const drawn = stops.map((stop) => pieces(stop.pill, stop.line, frame, radius));
356
+ // Everything the indicator passes between its stops: the box around them all.
357
+ const [left, right] = [Math.min(...stops.map((stop) => stop.pill.x)), Math.max(...stops.map((stop) => stop.pill.x + stop.pill.w))];
358
+ const [top, bottom] = [Math.min(...stops.map((stop) => stop.pill.y)), Math.max(...stops.map((stop) => stop.pill.y + stop.pill.h))];
359
+ const passed = pieces({ x: left, y: top, w: right - left, h: bottom - top }, stops[0].line, frame, 0);
360
+ // Every tab is given the indicator's and the underline's clip — each draws its piece of one box, wherever the box
361
+ // is — and the tabs the indicator passes draw their covered layer while it slides, with its shape cut out of their
362
+ // plain content.
363
+ const moved = [
364
+ [cover, passed.reaches ? { clipPath: drawn.map((piece) => piece.cover), visibility: drawn.map(() => 'visible') } : { clipPath: drawn.map((piece) => piece.cover) }],
365
+ [underline, { clipPath: drawn.map((piece) => piece.underline) }],
366
+ ];
367
+ if (passed.meets)
368
+ moved.push([plain, { clipPath: drawn.map((piece) => piece.plain) }]);
369
+ return moved.map(([element, keyframes]) => {
370
+ const animation = new Animation(new KeyframeEffect(element, keyframes, timing));
371
+ animation.id = SLIDE;
372
+ if (start === null)
373
+ animation.play();
374
+ else
375
+ animation.startTime = start;
376
+ return animation;
377
+ });
378
+ }
379
+ /** @internal The indicator's corner as drawn on this tab, in px (TAB-16). */
380
+ get indicatorRadius() {
381
+ const plate = this.renderRoot?.querySelector('.plate');
382
+ return plate ? Number.parseFloat(getComputedStyle(plate).borderTopLeftRadius) || 0 : 0;
383
+ }
384
+ /** @internal TAB-41: the tab's next draw leaves its label unmeasured; the row has it measured with the others. */
385
+ deferLabel() {
386
+ this.labelDeferred = true;
387
+ }
388
+ /** @internal TAB-25, TAB-41: measures the label now, for the row. */
389
+ measureLabel() {
390
+ this.labelDeferred = false;
391
+ this.measureTruncation();
392
+ }
393
+ /** TAB-25: whether the drawn label is cut short by its tab. */
394
+ measureTruncation() {
395
+ const label = this.renderRoot?.querySelector('.tab > .content > .label');
396
+ this.truncated = !!label && label.scrollWidth > label.clientWidth;
397
+ return this.truncated;
398
+ }
399
+ get tooltip() {
400
+ return this.renderRoot?.querySelector('.tip') ?? null;
401
+ }
402
+ /** TAB-19: the label is drawn unless it is hidden and there is an icon to draw instead. */
403
+ get drawsLabel() {
404
+ return !this.labelHidden || !this.icon;
405
+ }
406
+ updated(changed) {
407
+ // TAB-25: watch the drawn label (a new element when it is drawn again), and measure it after a change of text.
408
+ const label = this.renderRoot.querySelector('.tab > .content > .label');
409
+ // A label that is watched from this update on is measured when the observer first reports it — after the layout
410
+ // of the frame it is first drawn in, with every other tab's — and not here, in this tab's own turn, where the read
411
+ // would have the page laid out once for each tab.
412
+ let reported = false;
413
+ if (label !== this.observedLabel) {
414
+ if (this.observedLabel)
415
+ this.labelSize$?.unobserve(this.observedLabel);
416
+ if (label)
417
+ this.labelSize$?.observe(label);
418
+ this.observedLabel = label;
419
+ reported = !!label && !!this.labelSize$;
420
+ }
421
+ if (!label)
422
+ this.truncated = false;
423
+ else if (reported) {
424
+ // Measured in the coming frame.
425
+ }
426
+ else if (['label', 'icon', 'labelHidden'].some((key) => changed.has(key)) || (changed.has('context') && !this.labelDeferred))
427
+ this.measureTruncation();
428
+ const { selected, tabStop, position, size } = this.context;
429
+ // TAB-2, TAB-12, TAB-13: the tab role, its selection, position and name; one Tab stop per row; a disabled tab takes
430
+ // no focus at all, so a pointer cannot focus it either.
431
+ hostAria(this, {
432
+ role: 'tab',
433
+ 'aria-selected': String(selected),
434
+ 'aria-disabled': this.disabled ? 'true' : null,
435
+ 'aria-label': this.label || null,
436
+ 'aria-posinset': position ? String(position) : null,
437
+ 'aria-setsize': size ? String(size) : null,
438
+ tabindex: this.disabled ? null : tabStop ? '0' : '-1',
439
+ });
440
+ // TAB-22: a tab without a label still renders; a debug build says it has no name.
441
+ if (changed.has('label') && !this.label.trim())
442
+ report(this, 'TAB-22', 'label is empty, so the tab has no accessible name; give it a label');
443
+ // TAB-19: an icon-only tab needs an icon; without one the label is drawn anyway.
444
+ if ((changed.has('labelHidden') || changed.has('icon')) && this.labelHidden && !this.icon) {
445
+ report(this, 'TAB-19', 'label-hidden is set but the tab has no icon, so its label is drawn anyway; give it an icon');
446
+ }
447
+ if (changed.has('disabled') && this.disabled)
448
+ this.spaceDown = false;
449
+ // The row re-reads its tabs when a prop it depends on changes (values, disabled, labels); an internal event, kept out
450
+ // of the tab's public API.
451
+ if (this.hasUpdated && [...changed.keys()].some((key) => key !== 'context' && key !== 'truncated')) {
452
+ notifyItemUpdate(this, 'tanrei-tab-update');
453
+ }
454
+ }
455
+ render() {
456
+ const { selected, secondary, small, fill, pillDisabled, position, size } = this.context;
457
+ const label = this.drawsLabel;
458
+ const icon = !!this.icon;
459
+ const glyph = (named) => (icon ? html `<span part=${named ? 'icon' : nothing} class="icon" aria-hidden="true">${this.icon}</span>` : nothing);
460
+ // TAB-33, TAB-21: the box that cuts the label has the label's own direction, so it is cut at its own end in every engine.
461
+ const text = (named) => (label ? html `<span part=${named ? 'label' : nothing} class="label" dir=${ownDirection(this.label)}>${this.label}</span>` : nothing);
462
+ // TAB-13, TAB-24, TAB-25: the tab is named by its host's aria-label; the covered copy and the tooltip are hidden from
463
+ // assistive technology, so each label is exposed once.
464
+ return html `
465
+ <div
466
+ class=${classMap({ tab: true, p: true, d: this.disabled, selected, wide: secondary, fill, first: position === 1, last: position > 0 && position === size, 'pill-disabled': pillDisabled, stacked: !secondary && !small && icon && label })}
467
+ @pointerdown=${this.press.onPointerDown}
468
+ @pointerup=${this.press.release}
469
+ @pointercancel=${this.press.release}
470
+ @pointerleave=${this.press.release}
471
+ >
472
+ <span part="container" class="box" data-tanrei-shape aria-hidden="true"></span>
473
+ <span class="content"><span class="plate"></span>${glyph(true)}${text(true)}</span>
474
+ <span part="active-indicator" class="cover" aria-hidden="true"><span class="content">${glyph(false)}${text(false)}</span></span>
475
+ <span class="ring" data-tanrei-shape aria-hidden="true"></span>
476
+ <span part="underline" class="underline" aria-hidden="true"></span>
477
+ ${label && this.truncated ? html `<tanrei-tooltip class="tip" no-describe aria-hidden="true" .text=${this.label}></tanrei-tooltip>` : nothing}
478
+ </div>
479
+ `;
480
+ }
481
+ }
482
+ /**
483
+ * The view a tab shows. Placed as a child of `<tanrei-tabs>` after its tabs, or of a `<tanrei-tab-view>`, and matched to
484
+ * the tab whose `value` is its own. The row (or the view) gives it the tab panel role, names it by its tab, hides it while
485
+ * its tab is not selected, and makes it a Tab stop itself while it holds nothing focusable.
486
+ *
487
+ * In a `<tanrei-tab-view>` that draws its own row (TBV-16), the panel also says what its tab shows: `label`, `icon`,
488
+ * `label-hidden` and `disabled`, as `<tanrei-tab>` has them. A panel of a `<tanrei-tabs>`, or of a view linked to a row
489
+ * placed elsewhere, ignores them.
490
+ *
491
+ * @tag tanrei-tab-panel
492
+ * @slot - The view.
493
+ */
494
+ export class TanreiTabPanel extends LitElement {
495
+ static { this.styles = panelStyles; }
496
+ static { this.properties = {
497
+ value: { type: String, reflect: true },
498
+ label: { type: String },
499
+ icon: { type: String },
500
+ labelHidden: { type: Boolean, attribute: 'label-hidden', reflect: true },
501
+ disabled: { type: Boolean, reflect: true },
502
+ inView: { state: true },
503
+ }; }
504
+ constructor() {
505
+ super();
506
+ /** The value of the tab that shows this panel. */
507
+ this.value = '';
508
+ /**
509
+ * The text of this panel's tab in the row a `<tanrei-tab-view>` draws itself, and the accessible name of the tab and of
510
+ * the panel. Required there, even when `labelHidden` is true.
511
+ */
512
+ this.label = '';
513
+ /** The name of a glyph of the system's icon set for this panel's tab in the view's own row. Give every panel one, or none. */
514
+ this.icon = '';
515
+ /** Draws this panel's tab in the view's own row as its icon alone, keeping `label` as its accessible name. */
516
+ this.labelHidden = false;
517
+ /** Makes this panel's tab in the view's own row disabled: it cannot be selected, and a swipe skips its panel. */
518
+ this.disabled = false;
519
+ /** TBV-10: a panel of a `<tanrei-tab-view>` draws its focus ring inside the view's edge, following its corners. */
520
+ this.inView = false;
521
+ // TAB-13, TBV-10: where style queries are missing, the focus style is read when focus arrives.
522
+ this.addEventListener('focus', () => syncFocusStyle(this, this));
523
+ }
524
+ connectedCallback() {
525
+ super.connectedCallback();
526
+ if (!this.id)
527
+ this.id = `tanrei-tab-panel-${++ids}`;
528
+ this.inView = this.parentElement?.localName === 'tanrei-tab-view';
529
+ }
530
+ updated(changed) {
531
+ // TBV-6, TBV-16: the row (or the view) re-reads its panels when their value — or, for a view's own row, a tab prop —
532
+ // changes; an internal event, kept out of the panel's public API.
533
+ if (this.hasUpdated && ['value', 'label', 'icon', 'labelHidden', 'disabled'].some((key) => changed.has(key)))
534
+ notifyItemUpdate(this, 'tanrei-tab-update');
535
+ }
536
+ render() {
537
+ return html `<div class=${classMap({ panel: true, inside: this.inView })} data-tanrei-shape><slot></slot></div>`;
538
+ }
539
+ }
540
+ /**
541
+ * Switches between views of the same subject with a row of labelled tabs, one of them selected, above the view it shows.
542
+ *
543
+ * Contract: specs/tabs.spec.json. `<tanrei-tab>` children are the tabs, in order; `<tanrei-tab-panel>` children after
544
+ * them are the panels, matched to tabs by `value` — or, where a `<tanrei-tab-view tabs="<this row's id>">` is linked to
545
+ * the row, the view's panels take their place (TAB-13), and the view draws the indicator between two tabs while it is
546
+ * swiped (`indicatorOffset`, TAB-26). The row's selected tab is its `value`, as a `<select>`'s: `null`
547
+ * selects the first enabled tab. The row sets it when a tab is activated — by pointer, touch, Enter, Space, or the arrow
548
+ * keys, which select the tab they reach (automatic activation) — and then fires `change`.
549
+ *
550
+ * Three variants say how much the selection weighs — `primary`, `secondary`, and `tonal`, the quiet row whose indicator
551
+ * is a soft layer under a darker label — and are one control in everything else. `size` is the row's height (`medium`,
552
+ * the default, and `small`, which stands in a header beside small controls: it stays as low as it is, and a press just
553
+ * above or below it, on nothing that would answer the press itself, still selects the tab in line with it).
554
+ *
555
+ * The row sits on a track: one constant color per variant, the same whichever tab is selected (a capsule in the
556
+ * default system); `track="false"` fills none and changes nothing else, `track` draws it whatever the design system
557
+ * says, and without the attribute the system decides (`--tanrei-comp-tabs-track-visible`). The tabs hug their content and scroll sideways inside the track (the default), or share the row's
558
+ * width (`full-width`), truncating a label that does not fit. The selected tab's active indicator — the thumb on the
559
+ * track: as tall as the row less the track's padding on every tab, a capsule as wide as the tab's content plus its
560
+ * padding or a circle where that content is not wider than it is tall, and the tab's whole share in a row that fills —
561
+ * slides to a newly selected tab with the underline, and each label and icon it passes over takes its covered colors
562
+ * where it is covered.
563
+ *
564
+ * A drag across the row — by touch, a pen or a mouse, past 8 px and further sideways than up or down — carries the
565
+ * indicator with the pointer, its place, its width and the covered colors changing continuously. Nothing is selected
566
+ * before the release, which chooses the nearer of the two tabs the indicator lies between (or the one a fling is
567
+ * toward), sets `value` and fires `change` once; Escape, a cancelled pointer, or `value` set meanwhile returns it.
568
+ *
569
+ * `transition` says how a new selection is drawn: `slide` as above, `none` whole in one frame — nothing travels and no
570
+ * color fades between selected and not, a tab out of view is brought in at once, and a drag still carries the indicator
571
+ * and lands at once on release — and `auto`, the default, as the design system says
572
+ * (`--tanrei-comp-tabs-motion-transition`). Hover, focus and press are answered the same under each.
573
+ *
574
+ * Every visual value comes from `--tanrei-comp-tabs-*` tokens, per variant, look (selected or not) and state. How a
575
+ * press is answered and how keyboard focus is drawn are the system's choices of kind (`--tanrei-sys-behavior-*`),
576
+ * read from the cascade.
577
+ *
578
+ * @tag tanrei-tabs
579
+ * @slot - `<tanrei-tab>` children (the tabs) and `<tanrei-tab-panel>` children (the panels).
580
+ * @csspart tablist - The row that holds the tabs: the tab list.
581
+ * @csspart scroller - The box that lays the tabs out and scrolls them sideways when they do not fit; it is also the track.
582
+ * @csspart track - The constant background of the whole row (the same element as `scroller`): its color and its corners.
583
+ * @csspart divider - The line along the bottom of the whole row.
584
+ * @fires {CustomEvent<TanreiTabsChangeDetail>} change - The user selected another tab: `detail.value` (and the row's `value`) is its value.
585
+ */
586
+ export class TanreiTabs extends LitElement {
587
+ static { this.styles = [tabsStyles, hiddenHost]; }
588
+ // The tabs go into the tab list and the panels after it: the row assigns each child to its slot.
589
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' }; }
590
+ static { this.properties = {
591
+ variant: { type: String, reflect: true },
592
+ size: { type: String, reflect: true },
593
+ track: { reflect: true, converter: choiceAttribute },
594
+ fullWidth: { type: Boolean, attribute: 'full-width', reflect: true },
595
+ value: { type: String },
596
+ transition: { type: String, reflect: true },
597
+ label: { type: String },
598
+ group: { type: String },
599
+ rememberAs: { type: String, attribute: 'remember-as' },
600
+ }; }
601
+ /**
602
+ * Where the active indicator and the underline are drawn while a linked Tab view is swiped, relative to the selected
603
+ * tab: 0 on it, 1 on the next enabled tab and −1 on the previous one in reading order, and in between for values
604
+ * between (TAB-26). They follow it in the frame it is set, without a motion of their own; beyond 1 they stay on the
605
+ * neighbour, and where there is no enabled tab in its direction they stay on the selected tab. The Tab view sets it;
606
+ * a product leaves it at 0 unless it drives the indicator itself. A property only, with no attribute.
607
+ */
608
+ get indicatorOffset() {
609
+ return this.offset;
610
+ }
611
+ set indicatorOffset(value) {
612
+ const next = Number(value);
613
+ const offset = Number.isFinite(next) ? next : 0;
614
+ if (offset === this.offset)
615
+ return;
616
+ this.offset = offset;
617
+ if (!this.hasUpdated)
618
+ return;
619
+ // TAB-26: while the offset is not 0 the swipe that sets it has the indicator, and the row follows no drag of its own.
620
+ if (offset)
621
+ this.cancelDrag(false);
622
+ // TAB-26: no motion of their own — a running slide (TAB-17) ends where the offset puts them.
623
+ this.stopSliding();
624
+ this.draw(this.at(this.selectedTab));
625
+ }
626
+ /**
627
+ * TAB-15, TAB-17: a change of size or place (a font arriving, the text size, the row resizing) puts things back at
628
+ * once. One observer for every row (TAB-41): the rows that changed in a frame are told together, so that they are
629
+ * all measured and then all written.
630
+ */
631
+ static { this.watched = new WeakMap(); }
632
+ static { this.resize$ = typeof ResizeObserver === 'undefined'
633
+ ? null
634
+ : new ResizeObserver((entries) => {
635
+ const rows = new Set();
636
+ for (const entry of entries) {
637
+ const row = TanreiTabs.watched.get(entry.target);
638
+ if (row?.isConnected)
639
+ rows.add(row);
640
+ }
641
+ TanreiTabs.placeTogether([...rows]);
642
+ }); }
643
+ /**
644
+ * Where the indicator and the underline are drawn now, in the track's coordinates (null: nowhere): where they rest,
645
+ * or the place a running slide has reached — worked out from its clock when it is asked for, never frame by frame.
646
+ */
647
+ get mark() {
648
+ const sliding = this.sliding;
649
+ if (!sliding)
650
+ return this.rest;
651
+ const { clock, stops } = sliding;
652
+ const progress = clock.playState === 'finished' || clock.playState === 'idle' ? null : (clock.effect?.getComputedTiming().progress ?? null);
653
+ if (progress === null)
654
+ return stops[stops.length - 1];
655
+ // As the browser reads keyframes at equal parts: an easing that overshoots goes on along the first or the last part.
656
+ const at = progress * (stops.length - 1);
657
+ const index = Math.min(stops.length - 2, Math.max(0, Math.floor(at)));
658
+ return between(stops[index], stops[index + 1], at - index);
659
+ }
660
+ constructor() {
661
+ super();
662
+ this.availability = new AvailabilityController(this, 'tabs');
663
+ /**
664
+ * How much the selection weighs. Primary tabs switch the main views of a screen, at the top of its content; secondary
665
+ * tabs switch within one of them; tonal tabs are the quiet row, for a choice that should not compete with what it
666
+ * changes — the language of a code sample, a contrast, a unit, a period. The three are the same control otherwise.
667
+ */
668
+ this.variant = 'primary';
669
+ /**
670
+ * The row's height (small 32 / medium 48) and what shrinks with it: a tab's padding, the active indicator's margins
671
+ * and the icon. A small row puts a tab's icon before its label in every variant, and its tabs still answer a press
672
+ * within the minimum target.
673
+ */
674
+ this.size = 'medium';
675
+ /**
676
+ * Whether the row draws its track, the background behind all its tabs. False draws none and changes nothing else.
677
+ * Null, the default, takes the system's choice (`track.visible`, on in the default system). The attribute: absent is
678
+ * null, `track` is true, `track="false"` is false.
679
+ */
680
+ this.track = null;
681
+ /**
682
+ * False (hug, the default) sizes each tab to its content, never truncating its label, and scrolls the row sideways when
683
+ * the tabs do not fit; true (fill) divides the row's width equally among the tabs and truncates a label that does not
684
+ * fit its share, showing it whole in a tooltip (for two to five short labels).
685
+ */
686
+ this.fullWidth = false;
687
+ /**
688
+ * The value of the selected tab; `null` selects the first enabled tab. The row sets it when a tab is activated. While
689
+ * the row is a member of a group (`group`), the group's choice selects the tab of that value wherever the row has one.
690
+ */
691
+ this.value = null;
692
+ /**
693
+ * How the row draws a new selection. `slide`: the active indicator and the underline slide and resize to the newly
694
+ * selected tab, the labels' colors changing under them. `none`: the new selection is drawn whole in one frame.
695
+ * `auto` (the default, and what any other value is taken as) takes the design system's answer
696
+ * (`motion.transition`, slide in the default system). A drag across the row carries the indicator under each, and
697
+ * hover, focus and press are answered the same; where motion is reduced a selection is drawn as `none` does.
698
+ */
699
+ this.transition = 'auto';
700
+ /**
701
+ * The accessible name of the row: what the views are views of — or, for a row without panels, what is chosen
702
+ * ("Contrast", "Units"). Needed when a screen has more than one row of tabs, and for every row without panels.
703
+ */
704
+ this.label = '';
705
+ /**
706
+ * Names a choice this row shares with the other rows of tabs in the document — placed by the product or drawn by a
707
+ * `<tanrei-tab-view>` — that name the same group, compared exactly. Selecting a tab in one selects the tab of the same
708
+ * value in every other row that has an enabled one, at once and without moving focus or the page; a row that has no
709
+ * such tab keeps its own. Only the row the person used fires `change`. Empty (the default): the row's choice is its own.
710
+ */
711
+ this.group = '';
712
+ /**
713
+ * The key of the origin's `localStorage` under which a person's choice on this row is kept across pages and visits,
714
+ * and from which it is restored before the row is first drawn. The key is the product's own and is used exactly as
715
+ * given; only the chosen tab's value is stored. Empty (the default): the row neither reads nor writes any storage. It
716
+ * needs no group, and a group needs no key.
717
+ */
718
+ this.rememberAs = '';
719
+ /** TAB-36: the group the row is a member of now (null: none, or the row is out of the document). */
720
+ this.joined = null;
721
+ /** TAB-37: the `value` the row last saw as its own; another one, once the row is drawn, is one the product set. */
722
+ this.known = null;
723
+ /** TAB-39: whether the row has looked for a remembered choice, which it does once, before it is first drawn. */
724
+ this.restored = false;
725
+ /** TAB-39: the remembered value a row without a group selects as soon as it has an enabled tab of it. */
726
+ this.restoring = null;
727
+ /** TAB-38: the selection changed because the row follows (its group, or the storage): the next sync draws it at once. */
728
+ this.atOnce = false;
729
+ /** TAB-41: the rows that follow one choice together; the row adds itself instead of measuring alone. */
730
+ this.following = null;
731
+ /** TAB-41: the `value` the row has already drawn as a follower, so that the update its change asks for draws nothing again. */
732
+ this.followed = null;
733
+ /** TAB-26: the offset the indicator is drawn at now (0: on the selected tab). */
734
+ this.offset = 0;
735
+ /** TAB-13, TBV-9: the Tab view linked to this row, whose panels take the place of the row's own. */
736
+ this.linked = null;
737
+ /** TBV-16, TBV-18: the Tab view that draws this row as its own, which announces the row's selections itself. */
738
+ this.owner = null;
739
+ /** TAB-7: a variant or a size a design system adds, and a value the active system does not have (src/primitives/axes.ts). */
740
+ this.axes = new OpenAxesController(this, { component: 'tabs', behavior: 'TAB-7', axes: AXES });
741
+ this.keys = new RovingKeys({ wrap: true });
742
+ this.children$ = new MutationObserver(() => this.sync());
743
+ /**
744
+ * What the observer watches for this row now, each with the tab it is a part of (null: the row's own). Emptied when
745
+ * the row leaves the document, and of a tab's parts when the tab leaves the row.
746
+ */
747
+ this.observed = new Map();
748
+ /** The row's first placement is the observer's, and has not been reported yet (`sync`). */
749
+ this.awaitsObserver = false;
750
+ /** The tab drawn selected at the last sync (TAB-17 slides the indicator from it). */
751
+ this.shownTab = null;
752
+ this.scrolling = null;
753
+ this.scrollFrame = 0;
754
+ /** Where the indicator and the underline are written to rest, in the track's coordinates (null: nowhere). */
755
+ this.rest = null;
756
+ /**
757
+ * TAB-17: the slide running now. `clock` is the row's own animation on the strip (it draws nothing; its progress is
758
+ * the slide's), `parts` every tab's pieces, which the browser moves; `stops` are the indicator's places along the
759
+ * slide, at equal parts of it — where it was, the enabled tabs it passes, where it goes — and `tabs` the tab each
760
+ * stop is measured on (null: a place between tabs, where a slide, an offset or a drag had left it).
761
+ */
762
+ this.sliding = null;
763
+ /** TAB-28…30: the drag across the row, from its press to its release. */
764
+ this.drag = null;
765
+ this.dragFrame = 0;
766
+ /** TAB-28, TAB-29: the click that follows a drag the row took is not a tap. */
767
+ this.swallowClick = false;
768
+ /** TAB-1: a tab's activation — its click, from a pointer, Enter, Space or `element.click()` — selects it. */
769
+ this.onClick = (event) => {
770
+ const tab = this.tabOf(event);
771
+ if (tab)
772
+ this.select(tab);
773
+ };
774
+ /**
775
+ * TAB-12: Right and Left Arrow move to the next and previous enabled tab, wrapping (mirrored in right-to-left), Home and
776
+ * End to the first and last; each move selects the tab it reaches. Disabled tabs are skipped (TAB-2).
777
+ */
778
+ this.onKeyDown = (event) => {
779
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
780
+ return;
781
+ const tab = this.tabOf(event);
782
+ if (!tab || event.composedPath()[0] !== tab)
783
+ return;
784
+ const rtl = getComputedStyle(this).direction === 'rtl';
785
+ const keys = { ArrowRight: rtl ? 'ArrowUp' : 'ArrowDown', ArrowLeft: rtl ? 'ArrowDown' : 'ArrowUp', Home: 'Home', End: 'End' };
786
+ const key = keys[event.key];
787
+ if (!key)
788
+ return;
789
+ const tabs = this.tabs;
790
+ const target = this.keys.target(key, tabs.indexOf(tab), tabs.map((each) => ({ focusable: !each.disabled, label: each.label })));
791
+ if (target === null)
792
+ return;
793
+ event.preventDefault();
794
+ const next = tabs[target];
795
+ // The focus moves without the browser's own jump; the row brings the tab into view over its motion (TAB-15).
796
+ next.focus({ preventScroll: true });
797
+ this.select(next);
798
+ };
799
+ /** TAB-15: a tab that receives keyboard focus is brought into view. */
800
+ this.onFocusIn = (event) => {
801
+ const tab = this.tabOf(event);
802
+ if (tab && tab.matches(':focus-visible'))
803
+ this.reveal(tab, true);
804
+ };
805
+ /** The scale the row was last measured at, the frame that looks at it again, and for how many frames it has not changed. */
806
+ this.scaleSeen = UNSCALED;
807
+ this.scaleFrame = 0;
808
+ this.scaleStill = 0;
809
+ /** The tab the indicator was last put on at rest (no offset, no slide, no drag), or null. */
810
+ this.markTab = null;
811
+ /**
812
+ * TAB-28: a press on the row with touch, a pen or a mouse may become a drag. Not while indicatorOffset is not 0 (the
813
+ * swipe that sets it has the indicator, TAB-26), not without a selected tab to carry the indicator from, and, while the
814
+ * tabs scroll inside the track, only from the selected tab: every other sideways drag scrolls them.
815
+ */
816
+ this.onPointerDown = (event) => {
817
+ this.swallowClick = false;
818
+ // A press whose release never came here (a mouse released outside the window) is over.
819
+ if (this.drag && this.drag.state !== 'taken')
820
+ this.unwatch(this.drag);
821
+ if (this.drag || !event.isPrimary || event.button !== 0 || this.offset !== 0)
822
+ return;
823
+ if (!['touch', 'pen', 'mouse'].includes(event.pointerType))
824
+ return;
825
+ const scroller = this.scroller;
826
+ if (!scroller || !event.composedPath().includes(scroller))
827
+ return;
828
+ const selected = this.selectedTab;
829
+ if (!selected || !this.tabs.some((tab) => !tab.disabled))
830
+ return;
831
+ const pressed = this.tabOf(event);
832
+ if (this.scrolls && pressed !== selected)
833
+ return;
834
+ this.drag = { gesture: new SheetDrag(event, 'x'), pressed, state: 'pending', x: event.clientX, catchUp: null, place: null, frameTime: 0 };
835
+ this.watchPointer(true);
836
+ };
837
+ /**
838
+ * TAB-28: past the touch slop, further sideways than up or down, the row takes the drag: the pointer is captured, the
839
+ * pressed tab leaves its pressed state, and the indicator comes to the pointer over the state motion and then follows
840
+ * it in every move. A drag that went up or down first is the page's, for its whole length.
841
+ */
842
+ this.onPointerMove = (event) => {
843
+ const drag = this.drag;
844
+ if (!drag || event.pointerId !== drag.gesture.id || drag.state === 'cancelled')
845
+ return;
846
+ // A mouse that comes back with no button down was released where nothing heard it.
847
+ if (drag.state === 'pending' && event.pointerType === 'mouse' && event.buttons === 0) {
848
+ this.endDrag(drag);
849
+ return;
850
+ }
851
+ const step = drag.gesture.move(event);
852
+ // Up or down first: the page's. A swipe of the linked view began meanwhile (TAB-26): the view's.
853
+ if (drag.gesture.rejected || (step === 'start' && this.offset !== 0)) {
854
+ this.endDrag(drag);
855
+ return;
856
+ }
857
+ drag.x = event.clientX;
858
+ if (step === 'start')
859
+ this.takeDrag(drag, event);
860
+ if (drag.state !== 'taken')
861
+ return;
862
+ event.preventDefault();
863
+ this.follow(drag);
864
+ };
865
+ /**
866
+ * TAB-29: a release chooses one enabled tab — the one the indicator is nearer to of the two it lies between (the one
867
+ * after it from halfway on), or the one of the two a fling is toward — and selects it (one `change`, the indicator
868
+ * settling from where the release left it), or returns the indicator when it is the selected tab. It becomes the Tab
869
+ * stop; the click that follows is not a tap.
870
+ */
871
+ this.onPointerUp = (event) => {
872
+ const drag = this.drag;
873
+ if (!drag || event.pointerId !== drag.gesture.id)
874
+ return;
875
+ const taken = drag.state === 'taken';
876
+ if (taken)
877
+ drag.x = event.clientX;
878
+ const place = taken ? (this.placeAt(drag.x) ?? drag.place) : null;
879
+ const velocity = taken ? drag.gesture.velocity(event) : 0;
880
+ this.endDrag(drag);
881
+ if (!taken || !place)
882
+ return;
883
+ const fling = Math.abs(velocity) >= SHEET_FLING_VELOCITY;
884
+ // `from` is the tab toward the left and `to` the one toward the right, as they are drawn.
885
+ const chosen = fling ? (velocity > 0 ? place.to : place.from) : place.p >= 0.5 ? place.to : place.from;
886
+ this.settle(chosen);
887
+ };
888
+ /** TAB-30: the platform took the pointer back. */
889
+ this.onPointerCancel = (event) => {
890
+ const drag = this.drag;
891
+ if (!drag || event.pointerId !== drag.gesture.id)
892
+ return;
893
+ const taken = drag.state === 'taken';
894
+ this.endDrag(drag);
895
+ if (taken)
896
+ this.settle(null);
897
+ };
898
+ /** TAB-30: a capture lost while the drag lasts (not by its own release) cancels it. */
899
+ this.onLostCapture = (event) => {
900
+ const drag = this.drag;
901
+ if (!drag || event.pointerId !== drag.gesture.id || drag.state !== 'taken')
902
+ return;
903
+ this.endDrag(drag);
904
+ this.settle(null);
905
+ };
906
+ /** TAB-30: Escape while a drag lasts cancels it, and nothing else hears that key. */
907
+ this.onDragKey = (event) => {
908
+ if (event.key !== 'Escape' || this.drag?.state !== 'taken')
909
+ return;
910
+ event.preventDefault();
911
+ event.stopPropagation();
912
+ this.cancelDrag(true);
913
+ };
914
+ /** TAB-28, TAB-29: the click a taken drag ends with is not a tap — it activates nothing. */
915
+ this.onClickCapture = (event) => {
916
+ if (!this.swallowClick)
917
+ return;
918
+ this.swallowClick = false;
919
+ event.preventDefault();
920
+ event.stopImmediatePropagation();
921
+ };
922
+ this.addEventListener('keydown', this.onKeyDown);
923
+ this.addEventListener('click', this.onClickCapture, { capture: true });
924
+ this.addEventListener('click', this.onClick);
925
+ this.addEventListener('pointerdown', this.onPointerDown);
926
+ this.addEventListener('lostpointercapture', this.onLostCapture);
927
+ this.addEventListener('focusin', this.onFocusIn);
928
+ this.addEventListener('tanrei-tab-update', () => this.sync());
929
+ }
930
+ connectedCallback() {
931
+ super.connectedCallback();
932
+ this.children$.observe(this, { childList: true, subtree: true });
933
+ TanreiTabs.listenBeside(this, true);
934
+ // A row that comes back (moved in the document, or put into a surface that opens later) is watched again: it left
935
+ // with nothing observed, and what it measured while it was away — or not displayed — is not where it is now.
936
+ if (this.hasUpdated)
937
+ this.observe(null, this.strip, this.scroller);
938
+ // TAB-36, TAB-39: a row that enters the document joins its group and takes its choice before it is drawn.
939
+ this.followGroup();
940
+ this.sync();
941
+ }
942
+ disconnectedCallback() {
943
+ super.disconnectedCallback();
944
+ this.children$.disconnect();
945
+ TanreiTabs.listenBeside(this, false);
946
+ this.unobserve(() => true);
947
+ this.awaitsObserver = false;
948
+ // TAB-41: a row that leaves the document leaves its group, which keeps its choice.
949
+ this.enroll();
950
+ cancelAnimationFrame(this.scaleFrame);
951
+ this.scaleFrame = 0;
952
+ this.dropDrag();
953
+ this.stopScrolling();
954
+ this.stopSliding();
955
+ // TBV-14: a linked view that loses its tabs shows its panels without them.
956
+ this.linked?.followTabs();
957
+ }
958
+ /** @internal A `<tanrei-tab-view>` links itself to the row (TAB-13): its panels take the place of the row's own. */
959
+ linkView(view) {
960
+ if (this.linked === view)
961
+ return;
962
+ this.linked = view;
963
+ this.sync();
964
+ }
965
+ /** @internal TBV-16: the Tab view that draws this row as its own (null: none); it announces the row's selections (TBV-18). */
966
+ setOwnerView(view) {
967
+ this.owner = view;
968
+ }
969
+ /** @internal The view is no longer linked to the row: the row's own panels are its panels again. */
970
+ unlinkView(view) {
971
+ if (this.linked !== view)
972
+ return;
973
+ this.linked = null;
974
+ this.sync();
975
+ }
976
+ /** @internal The linked Tab view, if it is connected. */
977
+ get linkedView() {
978
+ return this.linked?.isConnected ? this.linked : null;
979
+ }
980
+ /** @internal The panels the row holds itself (TBV-15: a linked view reports them). */
981
+ get ownPanels() {
982
+ return this.panels;
983
+ }
984
+ /** @internal The panels changed in the linked view: the tabs control them anew (TAB-13). */
985
+ relink() {
986
+ this.sync();
987
+ }
988
+ /** The row's tabs, in order. */
989
+ get tabs() {
990
+ return [...this.children].filter((child) => child instanceof TanreiTab);
991
+ }
992
+ get panels() {
993
+ return [...this.children].filter((child) => child instanceof TanreiTabPanel);
994
+ }
995
+ get scroller() {
996
+ return this.renderRoot?.querySelector('.scroller') ?? null;
997
+ }
998
+ /** @internal TBV-3, TBV-8: whether the row follows a drag of its own now (a Tab view then takes none). */
999
+ get dragging() {
1000
+ return this.drag?.state === 'taken';
1001
+ }
1002
+ /** The box the tabs are laid out in: it scrolls with them, so positions in it do not change while the row scrolls. */
1003
+ get strip() {
1004
+ return this.renderRoot?.querySelector('.tabs') ?? null;
1005
+ }
1006
+ /**
1007
+ * TAB-11: the tab `value` selects — the first tab with that value — or, while `value` is null, the first enabled tab;
1008
+ * `null` when `value` names no tab.
1009
+ */
1010
+ get selectedTab() {
1011
+ const tabs = this.tabs;
1012
+ if (this.value === null || this.value === undefined)
1013
+ return tabs.find((tab) => !tab.disabled) ?? null;
1014
+ return tabs.find((tab) => tab.value === this.value) ?? null;
1015
+ }
1016
+ /** The tab an event came from. */
1017
+ tabOf(event) {
1018
+ for (const node of event.composedPath()) {
1019
+ if (node === this)
1020
+ return null;
1021
+ if (node instanceof TanreiTab && node.parentElement === this)
1022
+ return node;
1023
+ }
1024
+ return null;
1025
+ }
1026
+ /**
1027
+ * TAB-1, TAB-12: selects `tab`, and fires `change` once, when it is enabled and not already selected — or, on the row a
1028
+ * Tab view draws itself, has the view announce it instead (TBV-18), so that the row's `change` never reaches the product.
1029
+ */
1030
+ select(tab) {
1031
+ if (tab.disabled || tab === this.selectedTab)
1032
+ return;
1033
+ const owner = this.owner?.isConnected && this.owner === this.linkedView ? this.owner : null;
1034
+ owner?.rowWillSelect();
1035
+ this.choose(tab.value, this, true);
1036
+ if (owner)
1037
+ owner.rowSelected(tab.value);
1038
+ else
1039
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { value: tab.value } }));
1040
+ }
1041
+ /**
1042
+ * TAB-37 to TAB-41: a person chose the tab of `value` on this row. The row takes it (`now`: and draws it in this
1043
+ * task); it becomes the group's choice, so every other member that has an enabled tab of it follows at once, in the
1044
+ * same frame, and fires nothing; it is stored once under each key that this row or a member whose tab changed names;
1045
+ * and `hold` — the row, or a Tab view's container for a swipe — stays where it is in the window while the members
1046
+ * before it change height (TAB-40, TBV-21), measured once before anything is written and once after.
1047
+ */
1048
+ choose(value, hold, now) {
1049
+ const group = value ? this.joined : null;
1050
+ const followers = group ? [...group.members].filter((member) => member !== this && member.wouldFollow(value)) : [];
1051
+ const top = followers.length ? hold.getBoundingClientRect().top : null;
1052
+ this.restoring = null;
1053
+ if (group)
1054
+ group.choice = value;
1055
+ this.value = value;
1056
+ this.known = value;
1057
+ if (now)
1058
+ this.sync();
1059
+ // TAB-40: the followers' panels have changed in this task; where `hold` is now is read with everything else the
1060
+ // followers read, once, before the frame is drawn. (The row acted on is drawn first: a Tab view that starts its
1061
+ // switch measures itself, and does so before anything else is written.)
1062
+ TanreiTabs.followTogether(followers, top === null ? null : () => keepInPlace(hold, top));
1063
+ const keys = new Set([this, ...followers].map((member) => member.rememberAs).filter(Boolean));
1064
+ for (const key of keys)
1065
+ remember(this.ownerDocument, key, value);
1066
+ }
1067
+ /**
1068
+ * @internal TBV-4, TBV-21: a person committed a swipe to the tab of `value` on the Tab view linked to this row. The
1069
+ * row takes it as a selection made on itself — the group follows, the choice is remembered — and keeps `hold`, the
1070
+ * view's container, in place; the view announces it.
1071
+ */
1072
+ personSelected(value, hold) {
1073
+ this.choose(value, hold, false);
1074
+ }
1075
+ /** TAB-36: whether the group's choice `value` would give this row another selected tab: it has an enabled tab of it. */
1076
+ wouldFollow(value) {
1077
+ const tab = this.tabs.find((each) => each.value === value);
1078
+ return !!tab && !tab.disabled && tab !== this.selectedTab;
1079
+ }
1080
+ /**
1081
+ * TAB-36, TAB-39, TAB-41: brings the row's membership in line with `group` and the document — out of the group it
1082
+ * was in, into the one it names — and, once, before the row is first drawn, looks for the choice remembered under
1083
+ * its key: a group that holds no choice takes it (whether or not this row has a tab of it), and a row without a
1084
+ * group selects its tab of it.
1085
+ */
1086
+ enroll() {
1087
+ const document = this.ownerDocument;
1088
+ const group = this.isConnected && this.group ? sharedChoice(document, this.group) : null;
1089
+ if (group !== this.joined) {
1090
+ this.joined?.members.delete(this);
1091
+ this.joined = group;
1092
+ group?.members.add(this);
1093
+ }
1094
+ if (this.restored || !this.isConnected || !this.rememberAs)
1095
+ return;
1096
+ this.restored = true;
1097
+ const stored = remembered(document, this.rememberAs);
1098
+ if (!stored)
1099
+ return;
1100
+ if (!group)
1101
+ this.restoring = stored;
1102
+ else if (group.choice === null) {
1103
+ group.choice = stored;
1104
+ // The members drawn already follow at once, and store nothing (TAB-38, TAB-39).
1105
+ TanreiTabs.followTogether([...group.members].filter((member) => member !== this && member.wouldFollow(stored)));
1106
+ }
1107
+ }
1108
+ /**
1109
+ * TAB-36, TAB-39: takes the group's choice — or, without a group, the remembered value — while the row has an
1110
+ * enabled tab of it: `value` is set, nothing is fired, and the next sync draws it at once (TAB-38). Says whether
1111
+ * `value` changed. A row that has no such tab keeps its own, and follows again as soon as it has one.
1112
+ */
1113
+ adopt() {
1114
+ const group = this.joined;
1115
+ const want = group ? group.choice : this.restoring;
1116
+ if (want === null)
1117
+ return false;
1118
+ const tabs = this.tabs;
1119
+ // A remembered value is for the row as it is first drawn — until then whatever gives the row a selected (a Tab view
1120
+ // its own) is before the first frame, and its tabs may still be arriving while the document loads.
1121
+ if (!group && this.hasUpdated && tabs.length && this.ownerDocument.readyState !== 'loading')
1122
+ this.restoring = null;
1123
+ if (this.value === want)
1124
+ return false;
1125
+ const tab = tabs.find((each) => each.value === want);
1126
+ if (!tab || tab.disabled)
1127
+ return false;
1128
+ this.value = want;
1129
+ this.known = want;
1130
+ this.atOnce = true;
1131
+ return true;
1132
+ }
1133
+ /**
1134
+ * @internal TAB-36, TBV-16: joins the group the row names and takes its choice now, before the row is drawn — a Tab
1135
+ * view asks this of the row it draws once it has given it its own selected, so that the view's first frame is the
1136
+ * choice's.
1137
+ */
1138
+ followGroup() {
1139
+ this.enroll();
1140
+ this.adopt();
1141
+ }
1142
+ /** TAB-38: this member follows the choice now, to be measured and drawn with the others that do (`together`). */
1143
+ followNow(together) {
1144
+ if (!this.adopt() || !this.hasUpdated)
1145
+ return;
1146
+ this.following = together;
1147
+ this.sync();
1148
+ this.following = null;
1149
+ this.followed = this.value;
1150
+ }
1151
+ /**
1152
+ * TAB-38, TAB-41: every row of `rows` takes the choice in this task — its selection, its tabs' exposure and its panels —
1153
+ * and, once their tabs have drawn what they are now, all of them are measured and then all of them written, so that
1154
+ * sixty rows that follow cost one layout and not sixty. `keep` (TAB-40) is run where everything is read, after the
1155
+ * rows' own sizes are written and before their indicators are.
1156
+ */
1157
+ static followTogether(rows, keep = null) {
1158
+ const together = [];
1159
+ for (const row of rows)
1160
+ row.followNow(together);
1161
+ if (!together.length) {
1162
+ keep?.();
1163
+ return;
1164
+ }
1165
+ void Promise.all(together.flatMap((each) => each.tabs.map((tab) => tab.updateComplete))).then(() => {
1166
+ const live = together.filter((each) => each.row.isConnected && each.row.selectedTab === each.selected && each.row.drag?.state !== 'taken');
1167
+ for (const { row, tabs, from, selected } of live) {
1168
+ for (const tab of tabs)
1169
+ row.observeTab(tab);
1170
+ row.stopSliding();
1171
+ row.stopScrolling();
1172
+ // TAB-25: what the two tabs that changed did not measure of their labels when they were drawn is read here,
1173
+ // with everything else.
1174
+ for (const tab of [from, selected])
1175
+ tab?.measureLabel();
1176
+ }
1177
+ // A tab that changes size with its selection (a system whose selected label is heavier) is seen by the observer
1178
+ // in this frame, which sizes the tabs then; the followers read their sizes only if that happens.
1179
+ TanreiTabs.settleTogether(live, keep, false);
1180
+ });
1181
+ }
1182
+ /** TAB-23, TAB-38: the tabs whose colors change at once now, and the frame that lets them move again. */
1183
+ static { this.stilled = new Set(); }
1184
+ static { this.stillFrame = 0; }
1185
+ /**
1186
+ * TAB-23, TAB-38: `tabs` change their colors without the state motion — for the frame that draws the change; two
1187
+ * frames on, when it has been drawn, they answer a pointer with their motion again. One frame for every row.
1188
+ */
1189
+ static still(tabs) {
1190
+ for (const tab of tabs) {
1191
+ if (!tab)
1192
+ continue;
1193
+ tab.still(true);
1194
+ TanreiTabs.stilled.add(tab);
1195
+ }
1196
+ if (TanreiTabs.stillFrame)
1197
+ return;
1198
+ TanreiTabs.stillFrame = requestAnimationFrame(() => {
1199
+ TanreiTabs.stillFrame = requestAnimationFrame(() => {
1200
+ TanreiTabs.stillFrame = 0;
1201
+ for (const tab of TanreiTabs.stilled)
1202
+ tab.still(false);
1203
+ TanreiTabs.stilled.clear();
1204
+ });
1205
+ });
1206
+ }
1207
+ /**
1208
+ * TAB-38: what `place()` and `reveal()` do for a row that follows, in two halves — everything is read now, and the
1209
+ * function returned writes it — so that many rows are read together and then written together. The indicator and the
1210
+ * underline go on `selected` at once (at the current offset), and the tab is brought into view inside the track at
1211
+ * once.
1212
+ */
1213
+ placing(selected, measured) {
1214
+ const scroller = this.scroller;
1215
+ const scrolls = measured && this.scrolls;
1216
+ const draw = this.drawing(this.at(selected));
1217
+ const to = this.revealing(selected);
1218
+ return () => {
1219
+ if (measured)
1220
+ scroller?.classList.toggle('scrolls', scrolls);
1221
+ draw();
1222
+ if (to === null || !scroller)
1223
+ return;
1224
+ this.stopScrolling();
1225
+ scroller.scrollLeft = to;
1226
+ };
1227
+ }
1228
+ /**
1229
+ * Tells every tab what it is now and every panel whether it shows (TAB-2, TAB-11, TAB-13), assigns the slots, slides
1230
+ * the indicator when the selected tab changed (TAB-17), and reports what it should.
1231
+ */
1232
+ sync() {
1233
+ if (!this.hasUpdated)
1234
+ return;
1235
+ this.syncChoices();
1236
+ // TAB-36: a row that gained a tab of its group's choice, or had one enabled, has it selected in this frame.
1237
+ this.adopt();
1238
+ const tabs = this.tabs;
1239
+ this.unobserve((tab) => !!tab && tab.parentElement !== this);
1240
+ const panels = this.panels;
1241
+ const [tabSlot, panelSlot] = this.renderRoot.querySelectorAll('slot');
1242
+ // Only a changed assignment is written: assigning again re-slots the child, which blurs a focused tab.
1243
+ const assign = (slot, nodes) => {
1244
+ if (!slot)
1245
+ return;
1246
+ const now = slot.assignedNodes();
1247
+ if (now.length !== nodes.length || now.some((node, i) => node !== nodes[i]))
1248
+ slot.assign(...nodes);
1249
+ };
1250
+ assign(tabSlot, tabs);
1251
+ assign(panelSlot, panels);
1252
+ const selected = this.selectedTab;
1253
+ if (this.value !== null && this.value !== undefined && !selected && tabs.length)
1254
+ report(this, 'TAB-11', `value "${this.value}" names no tab; none is drawn selected`);
1255
+ const values = tabs.map((tab) => tab.value);
1256
+ for (const tab of tabs)
1257
+ if (!tab.value)
1258
+ report(this, 'TAB-11', `the tab "${tab.label}" has an empty value; it cannot be selected by value`);
1259
+ for (const value of new Set(values.filter(Boolean))) {
1260
+ if (values.filter((each) => each === value).length > 1)
1261
+ report(this, 'TAB-11', `the value "${value}" is given to more than one tab; the first of them is the one it selects`);
1262
+ }
1263
+ // TAB-2, TAB-12: one Tab stop — the selected tab, or the first enabled tab when that is disabled or there is none.
1264
+ const stop = selected && !selected.disabled ? selected : (tabs.find((tab) => !tab.disabled) ?? null);
1265
+ const secondary = INLINE_VARIANTS.includes(this.variant);
1266
+ const small = this.size === 'small';
1267
+ const fill = this.fullWidth;
1268
+ // TAB-30: the product set the selection, or removed or disabled a tab the indicator lies between: the drag is over
1269
+ // and the indicator goes to the selected tab — the one just set — from where it is.
1270
+ const drag = this.drag;
1271
+ let returns = false;
1272
+ if (drag?.state === 'taken') {
1273
+ const gone = (tab) => !!tab && (tab.disabled || tab.parentElement !== this);
1274
+ if (selected !== this.shownTab || gone(drag.place?.from) || gone(drag.place?.to)) {
1275
+ this.cancelDrag(false);
1276
+ returns = true;
1277
+ }
1278
+ }
1279
+ const pillDisabled = !!selected?.disabled;
1280
+ // TAB-13: where a Tab view is linked, each tab controls the view's panel of its value, and the row's own panels are
1281
+ // all hidden (TBV-15: the view reports them).
1282
+ const view = this.linkedView;
1283
+ const ownPanelOf = (tab) => (tab.value ? panels.find((panel) => panel.value === tab.value) : undefined);
1284
+ const panelOf = (tab) => (view ? (tab.value ? (view.panelFor(tab.value) ?? undefined) : undefined) : ownPanelOf(tab));
1285
+ tabs.forEach((tab, index) => {
1286
+ tab.setTabsContext({ selected: tab === selected, tabStop: tab === stop, position: index + 1, size: tabs.length, secondary, small, fill, pillDisabled });
1287
+ hostAria(tab, { 'aria-controls': panelOf(tab)?.id ?? null });
1288
+ });
1289
+ // TAB-13: the selected tab's panel, named by its tab; the others hidden; a panel with nothing focusable is a Tab stop.
1290
+ const shown = selected && !view ? ownPanelOf(selected) : undefined;
1291
+ for (const panel of panels) {
1292
+ const tab = tabs.find((each) => each.value && each.value === panel.value);
1293
+ const focusable = [...panel.children].some((child) => findInteractive(child));
1294
+ hostAria(panel, {
1295
+ role: 'tabpanel',
1296
+ 'aria-labelledby': tab?.id ?? null,
1297
+ tabindex: focusable ? null : '0',
1298
+ hidden: panel === shown ? null : '',
1299
+ });
1300
+ }
1301
+ const changed = selected !== this.shownTab;
1302
+ const from = this.shownTab;
1303
+ this.shownTab = selected;
1304
+ // TAB-38: the row follows its group's choice, or one restored from storage: no slide, no color motion, and the
1305
+ // tab in view at once. (A drag of its own that the choice ends returns as TAB-30 says.)
1306
+ const follows = this.atOnce && changed && !returns;
1307
+ this.atOnce = false;
1308
+ // TAB-23, TAB-43: so does a new selection of a row whose transition is none, whatever made it — the two tabs take
1309
+ // the colors of their new look in the frame that draws it. (The indicator's motion and the scroll read no time
1310
+ // then, as where motion is reduced: `motion()`.) A change between states keeps its motion.
1311
+ if (follows || (changed && !!from && this.hasNoTransition))
1312
+ TanreiTabs.still([from, selected]);
1313
+ // TAB-41: rows that follow one choice are measured together and then written together.
1314
+ if (follows && selected && this.following) {
1315
+ for (const tab of [from, selected])
1316
+ tab?.deferLabel();
1317
+ this.following.push({ row: this, tabs, from, selected });
1318
+ }
1319
+ // TAB-16, TAB-17: once the tabs have drawn what they are now, the indicator slides to a newly selected tab, or is put
1320
+ // on the selected one at once (the row appearing, a tab or the variant changing).
1321
+ else {
1322
+ void Promise.all(tabs.map((tab) => tab.updateComplete)).then(() => {
1323
+ const watched = this.observed.size;
1324
+ for (const tab of tabs)
1325
+ this.observeTab(tab);
1326
+ if (follows) {
1327
+ this.stopSliding();
1328
+ this.stopScrolling();
1329
+ }
1330
+ // The first placement of a row is the observer's: it reports the tabs it was just given after the layout of
1331
+ // the frame they are first drawn in, and every row of the page is then measured and written together
1332
+ // (`placeTogether`) — before that frame is painted, at once and without motion. Placed here, in the row's own
1333
+ // turn, each row had the page styled and laid out for itself, five times over.
1334
+ // Until it has, the row leaves every placement to it (a tab's own first update tells the row to look again).
1335
+ if (TanreiTabs.resize$ && !this.mark && !this.sliding && (this.awaitsObserver || (!from && this.observed.size > watched))) {
1336
+ this.awaitsObserver = true;
1337
+ return;
1338
+ }
1339
+ this.boxes();
1340
+ // TAB-26: a selection made while the indicator is drawn at an offset is placed at once, without a slide.
1341
+ if (!follows && changed && from && selected && from.isConnected && this.mark && this.offset === 0)
1342
+ this.slide(from, selected);
1343
+ else if (returns && selected && this.mark && this.offset === 0)
1344
+ this.slide(null, selected);
1345
+ else
1346
+ this.place();
1347
+ if (changed && selected)
1348
+ this.reveal(selected, !!from && !follows);
1349
+ });
1350
+ }
1351
+ // TBV-1, TBV-2: a linked view follows the row's selection — at once where the row itself follows (TBV-20).
1352
+ view?.followTabs(follows);
1353
+ }
1354
+ /** Watches what moves the indicator when its size or place changes (TAB-17). */
1355
+ observe(tab, ...elements) {
1356
+ for (const element of elements) {
1357
+ if (!element || this.observed.has(element))
1358
+ continue;
1359
+ this.observed.set(element, tab);
1360
+ TanreiTabs.watched.set(element, this);
1361
+ TanreiTabs.resize$?.observe(element);
1362
+ }
1363
+ }
1364
+ /** Watches a tab's parts: what the indicator is measured from. */
1365
+ observeTab(tab) {
1366
+ const parts = tab.indicatorParts;
1367
+ this.observe(tab, tab, parts?.content, parts?.box, parts?.plate);
1368
+ }
1369
+ /** Stops watching what `gone` says is no longer the row's: everything when it leaves, a tab's parts when the tab does. */
1370
+ unobserve(gone) {
1371
+ for (const [element, tab] of this.observed) {
1372
+ if (!gone(tab))
1373
+ continue;
1374
+ this.observed.delete(element);
1375
+ TanreiTabs.watched.delete(element);
1376
+ TanreiTabs.resize$?.unobserve(element);
1377
+ }
1378
+ }
1379
+ /**
1380
+ * TAB-15, TAB-17, TAB-41: `rows` changed size or place in one frame. Each puts its indicator back on its selected tab
1381
+ * and that tab in view, at once — one row as `place()` and `reveal()` do, several as they do but all read first and
1382
+ * then all written, so that a page of rows costs one layout and not one for each row. A row that slides or follows a
1383
+ * drag keeps its own way.
1384
+ */
1385
+ static placeTogether(rows) {
1386
+ for (const row of rows)
1387
+ row.awaitsObserver = false;
1388
+ const own = (row) => rows.length === 1 || !!row.sliding || row.drag?.state === 'taken';
1389
+ for (const row of rows) {
1390
+ if (!own(row))
1391
+ continue;
1392
+ row.place();
1393
+ row.reveal(row.selectedTab, false);
1394
+ }
1395
+ TanreiTabs.settleTogether(rows.filter((row) => !own(row)).map((row) => ({ row, selected: row.selectedTab })));
1396
+ }
1397
+ /**
1398
+ * TAB-41: puts the indicator of every row of `rows` on its `selected` tab, and that tab in view, at once: every row's
1399
+ * tabs are read, then written (`sized`); then every row's place is read — and `keep` run — then written.
1400
+ */
1401
+ static settleTogether(rows, keep = null, sized = true) {
1402
+ const sizes = sized ? rows.map(({ row }) => row.readBoxes()) : [];
1403
+ const resized = rows.filter(({ row }, index) => row.writeBoxes(sizes[index] ?? null));
1404
+ // What is written from the tabs' widths is read once more — every row first, then every row written.
1405
+ const again = resized.map(({ row }) => row.readBoxes());
1406
+ resized.forEach(({ row }, index) => row.writeBoxes(again[index]));
1407
+ const writes = rows.map(({ row, selected }, index) => row.placing(selected, !!sizes[index]));
1408
+ keep?.();
1409
+ for (const write of writes)
1410
+ write();
1411
+ }
1412
+ /** The indicator's timing (TAB-15, TAB-17): the tokens, read through real properties — 0 where motion is reduced. */
1413
+ motion() {
1414
+ const style = getComputedStyle(this.scroller ?? this);
1415
+ return { duration: (Number.parseFloat(style.animationDuration) || 0) * 1000, easing: style.animationTimingFunction || 'ease' };
1416
+ }
1417
+ /**
1418
+ * TAB-14, TAB-16, TAB-18: every tab sizes its container — the indicator's box on it — from the row's height and its own
1419
+ * content: all read first, then all written. Also says whether the tabs scroll inside the track (TAB-28).
1420
+ */
1421
+ boxes() {
1422
+ // A tab that became its circle (or stopped being it) changed its own width: what is written from the tabs' widths
1423
+ // is read once more, in the same frame.
1424
+ const sizes = this.readBoxes();
1425
+ if (!sizes)
1426
+ return;
1427
+ if (this.writeBoxes(sizes))
1428
+ this.writeBoxes(this.readBoxes());
1429
+ const scroller = this.scroller;
1430
+ scroller?.classList.toggle('scrolls', this.scrolls);
1431
+ }
1432
+ /** The reading half of `boxes()`: what every tab says of its container now, or null while the row is drawn flat. */
1433
+ readBoxes() {
1434
+ if (this.flat())
1435
+ return null;
1436
+ const scale = this.scale();
1437
+ return this.tabs.map((tab) => tab.readBox(scale));
1438
+ }
1439
+ /**
1440
+ * The writing half of `boxes()`: every tab's container as `sizes` say, and how far the end tabs reach into the track's
1441
+ * inset. Says whether a tab changed its own width by it, so that the tabs are read once more.
1442
+ */
1443
+ writeBoxes(sizes) {
1444
+ if (!sizes)
1445
+ return false;
1446
+ const resized = this.tabs.map((tab, index) => tab.writeBox(sizes[index] ?? null)).some(Boolean);
1447
+ // TAB-34: the first and the last tab reach into the track's inset by half of what they are wider than their
1448
+ // indicator, so that the indicator — not the tab's box — lies track.padding from the track's end.
1449
+ const strip = this.strip;
1450
+ const reach = (size) => (size ? px(Math.max(0, (size.tab - size.width) / 2)) : '0px');
1451
+ for (const [name, value] of [['--_reach-start', reach(sizes[0])], ['--_reach-end', reach(sizes[sizes.length - 1])]]) {
1452
+ if (strip && strip.style.getPropertyValue(name) !== value)
1453
+ strip.style.setProperty(name, value);
1454
+ }
1455
+ return resized;
1456
+ }
1457
+ /**
1458
+ * TAB-16, TAB-24: how much larger the row is drawn than laid out now — not 1 while an ancestor scales it (a picker's
1459
+ * or a dialog's surface growing in over its open motion, which is when a row inside it is first measured). Nothing
1460
+ * reports the end of a transform, so the row never keeps a box measured in the page's pixels.
1461
+ */
1462
+ scale() {
1463
+ const strip = this.strip;
1464
+ const scale = strip ? layoutScale(strip) : UNSCALED;
1465
+ this.watchScale(scale);
1466
+ return scale.x && scale.y ? scale : UNSCALED;
1467
+ }
1468
+ /**
1469
+ * TAB-16: a row measured at a scale is measured through it — to the page's precision divided by the scale, so the
1470
+ * smaller it is drawn the less exact its boxes are — and nothing reports a transform changing or ending. So while the
1471
+ * row is drawn at a scale that changes, it measures again in every frame the scale changed, and what it has drawn when
1472
+ * the motion ends was measured at the motion's end. It stops looking once the scale is 1, or has not changed for
1473
+ * `SCALE_STILL_FRAMES` frames (a row kept at a scale); a row drawn flat is looked at until it is not, since nothing of
1474
+ * it has been measured yet.
1475
+ */
1476
+ watchScale(scale) {
1477
+ this.scaleSeen = scale;
1478
+ const flat = !scale.x || !scale.y;
1479
+ if (this.scaleFrame || (!flat && scale.x === 1 && scale.y === 1))
1480
+ return;
1481
+ this.scaleFrame = requestAnimationFrame(() => {
1482
+ this.scaleFrame = 0;
1483
+ const strip = this.strip;
1484
+ if (!this.isConnected || !strip)
1485
+ return;
1486
+ const [seen, now] = [this.scaleSeen, layoutScale(strip)];
1487
+ if (now.x === seen.x && now.y === seen.y) {
1488
+ // Unchanged: flat still, or resting at a scale — which is looked at a little longer (an easing may start slowly).
1489
+ if ((now.x && now.y && ++this.scaleStill >= SCALE_STILL_FRAMES) || (now.x === 1 && now.y === 1))
1490
+ return;
1491
+ this.watchScale(now);
1492
+ return;
1493
+ }
1494
+ this.scaleStill = 0;
1495
+ // Measures at the new scale, and watches on from it.
1496
+ this.place();
1497
+ this.reveal(this.selectedTab, false);
1498
+ this.watchScale(layoutScale(strip));
1499
+ });
1500
+ }
1501
+ /**
1502
+ * TAB-16: whether the row is drawn flat now — scaled to nothing on an axis, as on the first frame of a surface that
1503
+ * grows from its anchor's edge. Nothing of it can be measured then (every box on the page is empty) and nothing of it
1504
+ * is seen, so nothing is written; `watchScale()` places the indicator once it is not flat.
1505
+ */
1506
+ flat() {
1507
+ const strip = this.strip;
1508
+ const scale = strip ? layoutScale(strip) : UNSCALED;
1509
+ if (scale.x && scale.y)
1510
+ return false;
1511
+ this.watchScale(scale);
1512
+ return true;
1513
+ }
1514
+ /** TAB-14, TAB-28: whether the tabs do not fit and scroll inside the track. */
1515
+ get scrolls() {
1516
+ const scroller = this.scroller;
1517
+ return !!scroller && scroller.scrollWidth - scroller.clientWidth > 0.5;
1518
+ }
1519
+ /**
1520
+ * TAB-16: where the indicator and the underline go on `tab`, in the strip's coordinates. The indicator is the tab's
1521
+ * container (its box): as tall as the row less track.padding above and below and, in a row that hugs, as wide as the
1522
+ * content plus active-indicator.padding-inline on each side — a circle where the content is not wider than it is tall
1523
+ * — or, in a row that fills, as wide as the tab. The underline spans the content (primary) or the tab (secondary).
1524
+ */
1525
+ measure(tab) {
1526
+ const strip = this.strip;
1527
+ const parts = tab.indicatorParts;
1528
+ if (!strip || !parts || !tab.isConnected || this.flat())
1529
+ return null;
1530
+ const origin = strip.getBoundingClientRect();
1531
+ const scale = this.scale();
1532
+ const [whole, box, content] = [parts.tab.getBoundingClientRect(), parts.box.getBoundingClientRect(), parts.content.getBoundingClientRect()];
1533
+ const wide = parts.tab.classList.contains('wide');
1534
+ return {
1535
+ pill: { x: (box.left - origin.left) / scale.x, y: (box.top - origin.top) / scale.y, w: box.width / scale.x, h: box.height / scale.y },
1536
+ line: wide ? { x: (whole.left - origin.left) / scale.x, w: whole.width / scale.x } : { x: (content.left - origin.left) / scale.x, w: content.width / scale.x },
1537
+ };
1538
+ }
1539
+ /**
1540
+ * TAB-16, TAB-24: draws the indicator and the underline at `mark` on every tab at once — each tab its piece, clipped to
1541
+ * it, and the covered copy of its content within it — so the indicator and every inversion move in the same frame.
1542
+ * Everything is read first, then written.
1543
+ */
1544
+ draw(mark) {
1545
+ this.drawing(mark)();
1546
+ }
1547
+ /** `draw()` in two halves: every tab's box is read now, and the function returned writes every tab's piece. */
1548
+ drawing(mark) {
1549
+ this.rest = mark;
1550
+ const { read, radius } = this.frames();
1551
+ return () => {
1552
+ for (const each of read) {
1553
+ const pill = mark ? { ...mark.pill, x: mark.pill.x - each.x, y: mark.pill.y - each.y } : null;
1554
+ const line = mark ? { x: mark.line.x - each.x, w: mark.line.w } : null;
1555
+ each.tab.paintIndicator(pill, line, each.size, each.content, radius);
1556
+ }
1557
+ };
1558
+ }
1559
+ /** Every tab's box and its content's box, in the strip's coordinates and the row's own pixels, and the indicator's corner. */
1560
+ frames() {
1561
+ const strip = this.strip;
1562
+ if (!strip)
1563
+ return { read: [], radius: 0 };
1564
+ const origin = strip.getBoundingClientRect();
1565
+ const scale = this.scale();
1566
+ const radius = this.selectedTab?.indicatorRadius ?? 0;
1567
+ const read = this.tabs.flatMap((tab) => {
1568
+ const parts = tab.indicatorParts;
1569
+ if (!parts)
1570
+ return [];
1571
+ const [box, content] = [parts.tab.getBoundingClientRect(), parts.content.getBoundingClientRect()];
1572
+ return [
1573
+ {
1574
+ tab,
1575
+ x: (box.left - origin.left) / scale.x,
1576
+ y: (box.top - origin.top) / scale.y,
1577
+ size: { w: box.width / scale.x, h: box.height / scale.y },
1578
+ content: { x: (content.left - box.left) / scale.x, y: (content.top - box.top) / scale.y, w: content.width / scale.x, h: content.height / scale.y },
1579
+ },
1580
+ ];
1581
+ });
1582
+ return { read, radius };
1583
+ }
1584
+ /**
1585
+ * TAB-16, TAB-26: where the indicator and the underline go for `selected` at the current offset — on it at 0, and
1586
+ * otherwise each edge interpolated toward the next (above 0) or previous (below 0) enabled tab in reading order by the
1587
+ * offset's magnitude, clamped to 1; on `selected` where there is no enabled tab in that direction.
1588
+ */
1589
+ at(selected) {
1590
+ const here = selected ? this.measure(selected) : null;
1591
+ this.markTab = here ? selected : null;
1592
+ const offset = this.offset;
1593
+ if (!here || !selected || !offset)
1594
+ return here;
1595
+ const tabs = this.tabs;
1596
+ const step = offset > 0 ? 1 : -1;
1597
+ let index = tabs.indexOf(selected) + step;
1598
+ while (index >= 0 && index < tabs.length && tabs[index].disabled)
1599
+ index += step;
1600
+ const there = index >= 0 && index < tabs.length ? this.measure(tabs[index]) : null;
1601
+ if (!there)
1602
+ return here;
1603
+ this.markTab = null;
1604
+ return between(here, there, Math.min(1, Math.abs(offset)));
1605
+ }
1606
+ /**
1607
+ * TAB-17, TAB-26: puts the indicator on the selected tab (at the current offset) at once — or, while it slides, sends
1608
+ * the slide there; while a drag carries it (TAB-28), it stays where the pointer is.
1609
+ */
1610
+ place() {
1611
+ this.boxes();
1612
+ if (this.drag?.state === 'taken') {
1613
+ this.follow(this.drag);
1614
+ return;
1615
+ }
1616
+ const selected = this.selectedTab;
1617
+ const sliding = this.sliding;
1618
+ const to = this.at(selected);
1619
+ if (sliding && to) {
1620
+ // The row changed size or place under a slide: the slide goes on, by its own clock, to where the tab is now —
1621
+ // every stop that is a tab measured afresh, and the pieces given their new places. Nothing is written where
1622
+ // nothing moved (a tab's first measuring after a choice reports the sizes the slide was already made from).
1623
+ const stops = sliding.stops.map((stop, index) => (index === sliding.stops.length - 1 ? to : ((sliding.tabs[index] ? this.measure(sliding.tabs[index]) : null) ?? stop)));
1624
+ if (stops.every((stop, index) => sameMark(stop, sliding.stops[index])))
1625
+ return;
1626
+ this.slideThrough(stops, sliding.tabs, sliding.clock);
1627
+ return;
1628
+ }
1629
+ this.stopSliding();
1630
+ this.draw(to);
1631
+ }
1632
+ /** Ends a slide where it is: its pieces leave, and what is written under them shows until the caller draws. */
1633
+ stopSliding() {
1634
+ const sliding = this.sliding;
1635
+ if (!sliding)
1636
+ return;
1637
+ this.sliding = null;
1638
+ sliding.clock.cancel();
1639
+ for (const part of sliding.parts)
1640
+ part.cancel();
1641
+ }
1642
+ /** The enabled tabs in the order they are drawn along the row, left to right, with each one's box on the page. */
1643
+ stops() {
1644
+ return this.tabs
1645
+ .filter((tab) => !tab.disabled)
1646
+ .map((tab) => {
1647
+ const box = tab.getBoundingClientRect();
1648
+ return { tab, left: box.left, right: box.right };
1649
+ })
1650
+ .sort((a, b) => a.left - b.left);
1651
+ }
1652
+ /**
1653
+ * TAB-28: where the indicator is drawn while the pointer is at `x` (clientX): on an enabled tab at that tab's centre,
1654
+ * halfway between two neighbouring enabled tabs where they meet (the middle of any disabled tabs between them), each
1655
+ * edge at the linear interpolation in between, and on the first or last enabled tab before or beyond its centre.
1656
+ * Nothing changes at the place where two tabs meet: it is only where `p` passes one half.
1657
+ */
1658
+ placeAt(x) {
1659
+ const stops = this.stops();
1660
+ if (!stops.length)
1661
+ return null;
1662
+ const centre = (stop) => (stop.left + stop.right) / 2;
1663
+ let index = 0;
1664
+ while (index < stops.length - 1 && x >= centre(stops[index + 1]))
1665
+ index++;
1666
+ const [a, b] = [stops[index], stops[Math.min(index + 1, stops.length - 1)]];
1667
+ const [from, to] = [this.measure(a.tab), this.measure(b.tab)];
1668
+ if (!from || !to)
1669
+ return null;
1670
+ let p = 0;
1671
+ if (a !== b && x > centre(a)) {
1672
+ const meet = (a.right + b.left) / 2;
1673
+ p = x <= meet ? (0.5 * (x - centre(a))) / Math.max(meet - centre(a), 0.001) : 0.5 + (0.5 * (x - meet)) / Math.max(centre(b) - meet, 0.001);
1674
+ p = Math.min(1, Math.max(0, p));
1675
+ }
1676
+ return { from: a.tab, to: b.tab, p, mark: between(from, to, p) };
1677
+ }
1678
+ /**
1679
+ * TAB-17, TAB-21, TAB-24: the indicator and the underline slide and resize from where they are drawn — on `old`, or
1680
+ * wherever a running slide, an offset or a released drag has left them — to `tab` over the indicator's motion, as one
1681
+ * box measured on the page, so the slide mirrors in right-to-left. The old tab is measured afresh: it may have moved
1682
+ * without changing size (the layout direction flipping), which nothing reports. At once where motion is reduced.
1683
+ *
1684
+ * The browser runs it. The row writes once — the end of the slide, where everything rests — and gives every tab the
1685
+ * indicator passes its pieces as animations between the slide's stops (`slideIndicator`), all on the document's
1686
+ * timeline from the same moment as the row's own animation `tanrei-tabs-slide` on the strip, an effect without
1687
+ * keyframes that draws nothing and is the slide's clock. No script runs while it slides; where the indicator has got
1688
+ * to is worked out from the clock when something asks (`mark`): a choice made meanwhile, a drag, an offset.
1689
+ *
1690
+ * Every frame is a look a drag draws (TAB-28): from a tab at rest the indicator passes over the enabled tabs between
1691
+ * the two as a drag does, taking each one's box on the way, so its width is always between two neighbouring tabs'.
1692
+ * From anywhere else it goes straight to the tab, each edge interpolated.
1693
+ */
1694
+ slide(old, tab) {
1695
+ const to = this.measure(tab);
1696
+ const resting = !!old && !this.sliding && this.markTab === old;
1697
+ const from = resting ? (this.measure(old) ?? this.mark) : this.mark;
1698
+ this.stopSliding();
1699
+ this.markTab = tab;
1700
+ const { duration } = this.motion();
1701
+ if (!from || !to || !this.strip || sameMark(from, to) || duration <= 0 || typeof KeyframeEffect === 'undefined') {
1702
+ this.draw(to);
1703
+ return;
1704
+ }
1705
+ const enabled = this.tabs.filter((each) => !each.disabled);
1706
+ const [start, end] = [resting && old ? enabled.indexOf(old) : -1, enabled.indexOf(tab)];
1707
+ const step = end > start ? 1 : -1;
1708
+ const passed = start >= 0 && end >= 0 && Math.abs(end - start) > 1 ? Array.from({ length: Math.abs(end - start) - 1 }, (_, index) => enabled[start + step * (index + 1)]) : [];
1709
+ const marks = passed.map((each) => this.measure(each));
1710
+ if (marks.every((mark) => mark))
1711
+ this.slideThrough([from, ...marks, to], [resting ? old : null, ...passed, tab], null);
1712
+ else
1713
+ this.slideThrough([from, to], [resting ? old : null, tab], null);
1714
+ }
1715
+ /**
1716
+ * TAB-17: writes the slide's end and has the browser move every tab's pieces through `stops` — a new slide, or
1717
+ * (`clock`) the one that is running, which goes on from the moment it began.
1718
+ */
1719
+ slideThrough(stops, tabs, clock) {
1720
+ const strip = this.strip;
1721
+ if (!strip)
1722
+ return;
1723
+ const timing = this.motion();
1724
+ const before = this.sliding;
1725
+ this.sliding = null;
1726
+ for (const part of before?.parts ?? [])
1727
+ part.cancel();
1728
+ // Everything is read, then the end is written, then the pieces are handed to the browser.
1729
+ const { read, radius } = this.frames();
1730
+ const to = stops[stops.length - 1];
1731
+ this.rest = to;
1732
+ for (const each of read)
1733
+ each.tab.paintIndicator({ ...to.pill, x: to.pill.x - each.x, y: to.pill.y - each.y }, { x: to.line.x - each.x, w: to.line.w }, each.size, each.content, radius);
1734
+ // No fill: once finished they leave their elements' animations, and the clock's progress (null) reads as the end.
1735
+ const running = clock ?? new Animation(new KeyframeEffect(strip, [], timing));
1736
+ const now = strip.ownerDocument.timeline.currentTime;
1737
+ if (!clock) {
1738
+ running.id = SLIDE;
1739
+ if (now === null)
1740
+ running.play();
1741
+ else
1742
+ running.startTime = now;
1743
+ }
1744
+ const started = clock ? clock.startTime : now;
1745
+ const parts = read.flatMap((each) => each.tab.slideIndicator(stops.map((stop) => ({ pill: { ...stop.pill, x: stop.pill.x - each.x, y: stop.pill.y - each.y }, line: { x: stop.line.x - each.x, w: stop.line.w } })), each, radius, clock ? (clock.effect?.getTiming() ?? timing) : timing, typeof started === 'number' ? started : null));
1746
+ // A clock that is held (paused, as a test or a tool holds it) holds its pieces at the same place.
1747
+ if (clock && clock.playState === 'paused') {
1748
+ for (const part of parts) {
1749
+ part.pause();
1750
+ part.currentTime = clock.currentTime;
1751
+ }
1752
+ }
1753
+ const sliding = { clock: running, parts, stops, tabs };
1754
+ this.sliding = sliding;
1755
+ if (!clock) {
1756
+ // Over, or cancelled: nothing slides (what was written for the end is what shows).
1757
+ const over = () => {
1758
+ if (this.sliding?.clock === running)
1759
+ this.stopSliding();
1760
+ };
1761
+ running.finished.then(over, over);
1762
+ }
1763
+ }
1764
+ /** The state motion (TAB-28's catch-up), read through real properties of the strip — 0 where motion is reduced. */
1765
+ stateMotion() {
1766
+ const strip = this.strip;
1767
+ const style = strip ? getComputedStyle(strip) : null;
1768
+ return { duration: (Number.parseFloat(style?.transitionDuration ?? '') || 0) * 1000, easing: style?.transitionTimingFunction || 'ease' };
1769
+ }
1770
+ /**
1771
+ * From the press to the release the pointer is followed on the window: before the drag is taken nothing captures it,
1772
+ * and it may leave the row (a mouse) and be released anywhere.
1773
+ */
1774
+ watchPointer(on) {
1775
+ const listen = on ? window.addEventListener.bind(window) : window.removeEventListener.bind(window);
1776
+ listen('pointermove', this.onPointerMove, { capture: true });
1777
+ listen('pointerup', this.onPointerUp, { capture: true });
1778
+ listen('pointercancel', this.onPointerCancel, { capture: true });
1779
+ }
1780
+ takeDrag(drag, event) {
1781
+ drag.state = 'taken';
1782
+ try {
1783
+ this.setPointerCapture(event.pointerId);
1784
+ }
1785
+ catch {
1786
+ // A pointer the browser does not know (a synthetic one) cannot be captured; its events still come here.
1787
+ }
1788
+ // The press activates no tab when it ends, and the tab under it leaves its pressed state as when a press ends.
1789
+ this.swallowClick = true;
1790
+ drag.pressed?.releasePress();
1791
+ // From where the indicator is drawn — a running slide stops there — to the pointer, over the state motion.
1792
+ const from = this.mark;
1793
+ this.stopSliding();
1794
+ this.stopScrolling();
1795
+ this.markTab = null;
1796
+ const strip = this.strip;
1797
+ const { duration, easing } = this.stateMotion();
1798
+ if (from && strip && duration > 0 && typeof KeyframeEffect !== 'undefined') {
1799
+ const animation = new Animation(new KeyframeEffect(strip, [], { duration, easing }));
1800
+ animation.id = 'tanrei-tabs-catch-up';
1801
+ animation.play();
1802
+ drag.catchUp = { animation, from };
1803
+ }
1804
+ window.addEventListener('keydown', this.onDragKey, { capture: true });
1805
+ drag.frameTime = performance.now();
1806
+ const frame = () => {
1807
+ if (this.drag !== drag || drag.state !== 'taken')
1808
+ return;
1809
+ this.follow(drag);
1810
+ this.dragFrame = requestAnimationFrame(frame);
1811
+ };
1812
+ this.dragFrame = requestAnimationFrame(frame);
1813
+ }
1814
+ /**
1815
+ * TAB-28: draws the indicator and the underline where the pointer is — in the frame it moves, without a motion of their
1816
+ * own, except the catch-up that brings them from where they rested — and scrolls the tabs to keep the indicator in view
1817
+ * while the drag carries it toward an end of the track.
1818
+ */
1819
+ follow(drag) {
1820
+ const place = this.placeAt(drag.x);
1821
+ if (!place)
1822
+ return;
1823
+ drag.place = place;
1824
+ let mark = place.mark;
1825
+ const catchUp = drag.catchUp;
1826
+ if (catchUp) {
1827
+ const over = catchUp.animation.playState === 'finished' || catchUp.animation.playState === 'idle';
1828
+ if (over)
1829
+ drag.catchUp = null;
1830
+ else
1831
+ mark = between(catchUp.from, mark, catchUp.animation.effect?.getComputedTiming().progress ?? 1);
1832
+ }
1833
+ this.draw(mark);
1834
+ const now = performance.now();
1835
+ const elapsed = Math.max(0, now - drag.frameTime);
1836
+ drag.frameTime = now;
1837
+ const scroller = this.scroller;
1838
+ const strip = this.strip;
1839
+ if (!scroller || !strip || !this.scrolls)
1840
+ return;
1841
+ const view = scroller.getBoundingClientRect();
1842
+ // The mark is in the row's own pixels and the view on the page; the scroll is the row's own again.
1843
+ const scale = this.scale();
1844
+ const left = strip.getBoundingClientRect().left + place.mark.pill.x * scale.x;
1845
+ const right = left + place.mark.pill.w * scale.x;
1846
+ const beyond = (right > view.right ? right - view.right : left < view.left ? left - view.left : 0) / scale.x;
1847
+ if (beyond)
1848
+ scroller.scrollLeft += Math.sign(beyond) * Math.min(Math.abs(beyond), DRAG_SCROLL_SPEED * elapsed);
1849
+ }
1850
+ /**
1851
+ * TAB-30: ends a drag the row has taken without a selection — the indicator returns to the selected tab over the
1852
+ * indicator's motion (`settle`), or is left to the caller's own placing — and the pointer, still down, is ignored until
1853
+ * it is released.
1854
+ */
1855
+ cancelDrag(settle) {
1856
+ const drag = this.drag;
1857
+ if (!drag)
1858
+ return;
1859
+ if (drag.state !== 'taken') {
1860
+ if (drag.state === 'pending')
1861
+ this.endDrag(drag);
1862
+ return;
1863
+ }
1864
+ drag.state = 'cancelled';
1865
+ this.stopFollowing(drag);
1866
+ if (settle)
1867
+ this.settle(null);
1868
+ }
1869
+ stopFollowing(drag) {
1870
+ cancelAnimationFrame(this.dragFrame);
1871
+ drag.catchUp?.animation.cancel();
1872
+ drag.catchUp = null;
1873
+ window.removeEventListener('keydown', this.onDragKey, { capture: true });
1874
+ }
1875
+ /** Nothing of the drag is watched any longer. */
1876
+ unwatch(drag) {
1877
+ this.stopFollowing(drag);
1878
+ this.watchPointer(false);
1879
+ if (this.drag === drag)
1880
+ this.drag = null;
1881
+ }
1882
+ /** The pointer is up (or gone): the drag is over, and the click that may follow it is let through no longer than this task. */
1883
+ endDrag(drag) {
1884
+ const pending = drag.state === 'pending';
1885
+ this.unwatch(drag);
1886
+ if (pending)
1887
+ return;
1888
+ setTimeout(() => {
1889
+ this.swallowClick = false;
1890
+ });
1891
+ }
1892
+ /** The row is leaving: nothing of a drag is kept. */
1893
+ dropDrag() {
1894
+ const drag = this.drag;
1895
+ if (!drag)
1896
+ return;
1897
+ this.unwatch(drag);
1898
+ this.swallowClick = false;
1899
+ }
1900
+ /**
1901
+ * TAB-29, TAB-30: after a drag, the indicator and the underline go from where they are to `chosen` — selecting it, with
1902
+ * one `change`, when it is not the selected tab — or back to the selected tab (`null`), over the indicator's motion and
1903
+ * at once where motion is reduced.
1904
+ */
1905
+ settle(chosen) {
1906
+ const selected = this.selectedTab;
1907
+ if (chosen && chosen !== selected && !chosen.disabled) {
1908
+ // The chosen tab is the Tab stop; where the focus was on another tab of the row it follows the selection.
1909
+ const within = this.tabs.find((tab) => tab.matches(':focus'));
1910
+ this.select(chosen);
1911
+ if (within && within !== chosen)
1912
+ chosen.focus({ preventScroll: true });
1913
+ return;
1914
+ }
1915
+ if (selected && this.mark)
1916
+ this.slide(null, selected);
1917
+ else
1918
+ this.place();
1919
+ }
1920
+ stopScrolling() {
1921
+ cancelAnimationFrame(this.scrollFrame);
1922
+ this.scrolling?.cancel();
1923
+ this.scrolling = null;
1924
+ }
1925
+ /**
1926
+ * TAB-15: scrolls the tabs inside the track until the whole of `tab` is visible — over the indicator's motion when `animate`, at
1927
+ * once when the row first appears (or is resized) and where motion is reduced. The progress of the motion's easing is
1928
+ * read from an effect without keyframes on the scroller (it draws nothing), so the scroll follows the token's curve and
1929
+ * the motion is the scroller's own animation, `tanrei-tabs-reveal`, on the document's timeline: read, paused or finished
1930
+ * like the indicator's slide.
1931
+ */
1932
+ reveal(tab, animate) {
1933
+ const scroller = this.scroller;
1934
+ const to = this.revealing(tab);
1935
+ if (to === null || !scroller)
1936
+ return;
1937
+ this.stopScrolling();
1938
+ const from = scroller.scrollLeft;
1939
+ const { duration, easing } = this.motion();
1940
+ if (!animate || duration <= 0 || typeof KeyframeEffect === 'undefined') {
1941
+ scroller.scrollLeft = to;
1942
+ return;
1943
+ }
1944
+ // No fill: once finished it leaves the scroller's animations, and its progress (null) reads as the end.
1945
+ const timing = new Animation(new KeyframeEffect(scroller, [], { duration, easing }));
1946
+ timing.id = 'tanrei-tabs-reveal';
1947
+ this.scrolling = timing;
1948
+ timing.play();
1949
+ const step = () => {
1950
+ const progress = timing.effect?.getComputedTiming().progress ?? 1;
1951
+ scroller.scrollLeft = from + (to - from) * progress;
1952
+ if (timing.playState === 'finished' || timing.playState === 'idle' || this.scrolling !== timing)
1953
+ return;
1954
+ this.scrollFrame = requestAnimationFrame(step);
1955
+ };
1956
+ this.scrollFrame = requestAnimationFrame(step);
1957
+ }
1958
+ /** The reading half of `reveal()`: where the tabs must scroll to for the whole of `tab` to be visible, or null where it is. */
1959
+ revealing(tab) {
1960
+ const scroller = this.scroller;
1961
+ if (!tab || !scroller || !tab.isConnected)
1962
+ return null;
1963
+ // The whole tab, with the track's padding beside it: the space its focus ring is drawn in (TAB-4), and what brings
1964
+ // the first and the last tab to the track's very ends.
1965
+ // (What an end tab reaches into the inset is not padding any more, TAB-34: each side has its own.)
1966
+ const strip = this.strip;
1967
+ const inset = strip ? getComputedStyle(strip) : null;
1968
+ // The boxes are read on the page, where the row may be drawn scaled; the padding and the scroll are its own pixels.
1969
+ const scale = this.scale();
1970
+ const [padLeft, padRight] = [inset ? (Number.parseFloat(inset.paddingLeft) || 0) * scale.x : 0, inset ? (Number.parseFloat(inset.paddingRight) || 0) * scale.x : 0];
1971
+ const bounds = scroller.getBoundingClientRect();
1972
+ const view = { left: bounds.left + padLeft, right: bounds.right - padRight, width: bounds.width - padLeft - padRight };
1973
+ const box = tab.getBoundingClientRect();
1974
+ const rtl = getComputedStyle(this).direction === 'rtl';
1975
+ let delta = 0;
1976
+ if (box.width >= view.width)
1977
+ delta = rtl ? box.right - view.right : box.left - view.left;
1978
+ else if (box.left < view.left)
1979
+ delta = box.left - view.left;
1980
+ else if (box.right > view.right)
1981
+ delta = box.right - view.right;
1982
+ delta /= scale.x;
1983
+ return Math.abs(delta) < 0.5 ? null : scroller.scrollLeft + delta;
1984
+ }
1985
+ /**
1986
+ * TAB-43: whether the row draws a new selection at once right now: its `transition` when it names one, else the
1987
+ * system's choice as the cascade gives it at this moment — never cached, and an unknown name is the first value (slide).
1988
+ */
1989
+ get hasNoTransition() {
1990
+ return compChoice(this, TRANSITION_PROPERTY, TRANSITION_CHOICE) === 'none';
1991
+ }
1992
+ /**
1993
+ * TAB-49, TAB-43: where the browser answers no style query, the two choices' names are read from the cascade and
1994
+ * written on the row for the same rules (`whenChosen()`); where it does, nothing is written — an attribute could
1995
+ * only go stale.
1996
+ */
1997
+ syncChoices() {
1998
+ const row = this.renderRoot?.querySelector('.row');
1999
+ if (!row)
2000
+ return;
2001
+ if (styleQueries()) {
2002
+ delete row.dataset.track;
2003
+ delete row.dataset.transition;
2004
+ return;
2005
+ }
2006
+ row.dataset.track = compChoice(this, TRACK_PROPERTY, TRACK_CHOICE);
2007
+ row.dataset.transition = compChoice(this, TRANSITION_PROPERTY, TRANSITION_CHOICE);
2008
+ }
2009
+ /** TAB-5: every row in the page, for the one listener that hears a press beside them. */
2010
+ static { this.rows = new Set(); }
2011
+ /** TAB-5: `row` enters or leaves the document; the window is listened to while there is a row. */
2012
+ static listenBeside(row, on) {
2013
+ const rows = TanreiTabs.rows;
2014
+ const before = rows.size;
2015
+ if (on)
2016
+ rows.add(row);
2017
+ else
2018
+ rows.delete(row);
2019
+ if (typeof window === 'undefined' || !before === !rows.size)
2020
+ return;
2021
+ if (rows.size)
2022
+ window.addEventListener('click', TanreiTabs.onPressBeside);
2023
+ else
2024
+ window.removeEventListener('click', TanreiTabs.onPressBeside);
2025
+ }
2026
+ /**
2027
+ * TAB-5: a press that no tab took, and that nothing has answered by the time it reaches the window. Where it lies just
2028
+ * above or below a row that is lower than the minimum target, in line with one of its tabs, it is that tab's: the
2029
+ * row's hit area reaches as far beyond its top and bottom edges as it takes to make the target, without the row
2030
+ * being any taller. It yields to whatever would answer the press itself — a control, a link, a field, a Tab stop,
2031
+ * anything that shows the pointer of a link — to a press that ends a selection of text, and to a surface in the top
2032
+ * layer that the row is not inside. No element is laid over the page for it: the tabs scroll inside a box that clips
2033
+ * them, so nothing of a tab can reach beyond the row, and an element laid beside the row would lie over the controls
2034
+ * next to it.
2035
+ */
2036
+ static { this.onPressBeside = (event) => {
2037
+ if (event.defaultPrevented || event.button !== 0)
2038
+ return;
2039
+ const path = event.composedPath();
2040
+ const pressed = path[0];
2041
+ if (!(pressed instanceof Element) || path.some((node) => node instanceof TanreiTab))
2042
+ return;
2043
+ let asked = false;
2044
+ for (const row of TanreiTabs.rows) {
2045
+ const tab = row.tabBeside(event);
2046
+ if (!tab)
2047
+ continue;
2048
+ // Only now is the page asked what the press landed on: nearly every press is beside no row.
2049
+ if (!asked) {
2050
+ if (answersPress(path) || pressed.ownerDocument.getSelection()?.isCollapsed === false)
2051
+ return;
2052
+ asked = true;
2053
+ }
2054
+ const layer = path.find((node) => node instanceof Element && ((node.localName === 'dialog' && node.matches(':modal')) || (node.hasAttribute('popover') && node.matches(':popover-open'))));
2055
+ if (layer && !composedContains(layer, row))
2056
+ continue;
2057
+ row.select(tab);
2058
+ return;
2059
+ }
2060
+ }; }
2061
+ /**
2062
+ * TAB-5, TAB-34: the enabled tab of this row that a press at the event's point belongs to though it missed the row: the
2063
+ * point is in line with the tab — or beyond the track's end beside an end tab that ends there, by no more than that
2064
+ * tab lacks to the target's width — and no further above the row's top edge or below its bottom edge than half of
2065
+ * what the row lacks to the minimum target (sys.target.touch for touch and a pen, and where the input cannot be told on a
2066
+ * device whose pointer is coarse; sys.target.pointer for a mouse), and the tab is not covered where the point is
2067
+ * nearest to it. Null for a row as tall as the target.
2068
+ */
2069
+ tabBeside(event) {
2070
+ const scroller = this.scroller;
2071
+ const targets = this.renderRoot?.querySelector('.divider');
2072
+ if (!scroller || !targets || this.ownerDocument !== event.target?.ownerDocument)
2073
+ return null;
2074
+ const box = scroller.getBoundingClientRect();
2075
+ const { clientX: x, clientY: y } = event;
2076
+ const [inX, inY] = [x >= box.left && x < box.right, y >= box.top && y < box.bottom];
2077
+ // On the row itself the press is a tab's own (or the track's inset's, which is the end tabs').
2078
+ if (!box.height || (inX && inY))
2079
+ return null;
2080
+ const type = event.pointerType;
2081
+ const coarse = type ? type !== 'mouse' : typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
2082
+ const style = getComputedStyle(targets);
2083
+ const scale = layoutScale(scroller);
2084
+ const target = Number.parseFloat(coarse ? style.scrollMarginBlockEnd : style.scrollMarginBlockStart) || 0;
2085
+ const reach = Math.max(0, (target * scale.y - box.height) / 2);
2086
+ if (y < box.top - reach || y >= box.bottom + reach || (!inY && !reach))
2087
+ return null;
2088
+ const tabs = this.tabs;
2089
+ let tab;
2090
+ if (inX) {
2091
+ tab = tabs.find((each) => {
2092
+ const own = each.getBoundingClientRect();
2093
+ return x >= own.left && x < own.right;
2094
+ });
2095
+ }
2096
+ else {
2097
+ // TAB-34: beyond an end of the track, as far as the end tab lacks to the target's width.
2098
+ const ends = tabs.length ? [tabs[0], tabs[tabs.length - 1]] : [];
2099
+ tab = ends.find((each) => {
2100
+ const own = each.getBoundingClientRect();
2101
+ const lacks = target * scale.x - own.width;
2102
+ if (lacks <= 0 || own.right <= box.left || own.left >= box.right)
2103
+ return false;
2104
+ return x < box.left ? own.left <= box.left + 0.5 && x >= own.left - lacks : own.right >= box.right - 0.5 && x < own.right + lacks;
2105
+ });
2106
+ }
2107
+ if (!tab || tab.disabled)
2108
+ return null;
2109
+ // The tab itself must be what a press at the nearest point inside the row would land on: a row under something
2110
+ // else has no hit area beyond it either.
2111
+ const root = this.getRootNode();
2112
+ // (Asked at the row's middle height, in line with the press or, beyond an end, at the tab's own middle: the track's
2113
+ // rounded corners are not the tab's.)
2114
+ const own = tab.getBoundingClientRect();
2115
+ const across = inX ? x : Math.min(Math.max((own.left + own.right) / 2, box.left), box.right);
2116
+ return root.elementFromPoint?.(across, (box.top + box.bottom) / 2) === tab ? tab : null;
2117
+ }
2118
+ firstUpdated() {
2119
+ this.observe(null, this.strip, this.scroller);
2120
+ }
2121
+ willUpdate(changed) {
2122
+ // TAB-36, TAB-39: the row is in its group, and has looked for its remembered choice, before it is first drawn.
2123
+ // A key given later remembers from then on; it restores nothing, since the row has been drawn.
2124
+ if (!this.hasUpdated || changed.has('group') || changed.has('rememberAs'))
2125
+ this.enroll();
2126
+ this.restored = true;
2127
+ // TAB-37: a selected set by the product once the row is drawn, to one of its enabled tabs, is its group's choice —
2128
+ // every other member follows at once, nothing is fired and nothing is stored. The selected a row is first drawn
2129
+ // with is its own.
2130
+ if (this.hasUpdated && changed.has('value') && this.value !== this.known) {
2131
+ const value = this.value;
2132
+ const tab = value ? this.selectedTab : null;
2133
+ this.restoring = null;
2134
+ if (value && this.joined && tab && !tab.disabled && this.joined.choice !== value) {
2135
+ this.joined.choice = value;
2136
+ TanreiTabs.followTogether([...this.joined.members].filter((member) => member !== this && member.wouldFollow(value)));
2137
+ }
2138
+ }
2139
+ this.known = this.value;
2140
+ this.adopt();
2141
+ }
2142
+ updated(changed) {
2143
+ // TAB-41: a row that followed its group has drawn this `value` already, in the task the choice was made in.
2144
+ const followed = this.followed;
2145
+ this.followed = null;
2146
+ if (followed !== null && followed === this.value && changed.size === 1 && changed.has('value'))
2147
+ return;
2148
+ if (changed.has('transition')) {
2149
+ // TAB-43: a value the tabs do not define is auto.
2150
+ if (this.transition && !TRANSITION_VALUES.includes(this.transition))
2151
+ report(this, 'TAB-43', `transition "${this.transition}" is not a transition of the tabs; it is taken as "auto"`);
2152
+ // TAB-43: a slide that is running when the row's transition becomes none ends on its tab at once.
2153
+ if (this.sliding && this.hasNoTransition) {
2154
+ this.stopSliding();
2155
+ this.stopScrolling();
2156
+ this.place();
2157
+ this.reveal(this.selectedTab, false);
2158
+ }
2159
+ }
2160
+ // TAB-13: the tab list, named by the row's label.
2161
+ this.sync();
2162
+ if (changed.has('fullWidth') && changed.get('fullWidth') !== undefined)
2163
+ void this.selectedTab?.updateComplete.then(() => this.reveal(this.selectedTab, false));
2164
+ }
2165
+ render() {
2166
+ return html `
2167
+ <div part="tablist" class="row" role="tablist" aria-label=${this.label || nothing}>
2168
+ <div part="divider" class="divider" aria-hidden="true"></div>
2169
+ <div part="scroller track" class="scroller" data-tanrei-shape><div class="tabs"><slot></slot></div></div>
2170
+ </div>
2171
+ <slot></slot>
2172
+ `;
2173
+ }
2174
+ }
2175
+ if (!customElements.get('tanrei-tooltip'))
2176
+ customElements.define('tanrei-tooltip', TanreiTooltip);
2177
+ if (!customElements.get('tanrei-tab'))
2178
+ customElements.define('tanrei-tab', TanreiTab);
2179
+ if (!customElements.get('tanrei-tab-panel'))
2180
+ customElements.define('tanrei-tab-panel', TanreiTabPanel);
2181
+ if (!customElements.get('tanrei-tabs'))
2182
+ customElements.define('tanrei-tabs', TanreiTabs);
2183
+ //# sourceMappingURL=tabs.js.map