@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,1009 @@
1
+ import { LitElement, html, nothing } from 'lit';
2
+ import { classMap } from 'lit/directives/class-map.js';
3
+ import { AvailabilityController, OpenAxesController, report, syncFocusStyle, WordsController } from '../../primitives/index.js';
4
+ import { firstLine, furnish } from './code-block.lines.js';
5
+ import { ownDirection } from '../../styles/product-text.js';
6
+ import '../copy-button/copy-button.js';
7
+ import { CODE_BLOCK_CSS, CODE_BLOCK_DRAWN, SYNTAX_ROLES, roleRule } from './code-block.light.js';
8
+ import { adoptUnlessDrawn } from '../../primitives/sheets.js';
9
+ import { AXES, styles } from './code-block.styles.js';
10
+ const SYNTAXES = ['plain', ...SYNTAX_ROLES];
11
+ /** COD-27: code that has no syntax. Drawn plain, and nothing is said. */
12
+ const NO_SYNTAX = ['', 'text', 'plain', 'plaintext'];
13
+ /** A role a design system may have added: a name a custom property can carry. */
14
+ const ROLE = /^[a-z][a-z0-9-]*$/;
15
+ /** What marks code highlighted where the page was made (COD-29), on the `<code>`. */
16
+ const GIVEN = 'data-syntax-of';
17
+ /** What the element writes into the code's lines: attribute names, so the stylesheet and the element share them. */
18
+ const LINE = 'data-line';
19
+ const LINE_CODE = 'data-line-code';
20
+ const GUTTER = 'data-line-gutter';
21
+ const PROMPT = 'data-line-prompt';
22
+ const LABEL = 'data-line-label';
23
+ /** The light-DOM rules (code-block.light.ts), one constructed sheet per document, adopted by every root that holds a block. */
24
+ let lightSheet;
25
+ /** Unless the root draws the block's lines already — the page loaded `@tanrei/web/code.css`, which sets `CODE_BLOCK_DRAWN` on the block. */
26
+ function adoptLightRules(block) {
27
+ if (lightSheet === undefined) {
28
+ try {
29
+ lightSheet = new CSSStyleSheet();
30
+ lightSheet.replaceSync(CODE_BLOCK_CSS);
31
+ }
32
+ catch {
33
+ // No constructed stylesheets: the block is then drawn by `@tanrei/web/code.css` alone.
34
+ lightSheet = null;
35
+ }
36
+ }
37
+ adoptUnlessDrawn(block, lightSheet, CODE_BLOCK_DRAWN);
38
+ }
39
+ let highlightModule;
40
+ let highlightLoading;
41
+ const loadHighlight = () => (highlightLoading ??= import('../../highlight/index.js').then((module) => (highlightModule = module), (error) => {
42
+ // Asked again, it is tried again.
43
+ highlightLoading = undefined;
44
+ throw error;
45
+ }));
46
+ /** COD-27: an unknown language is reported once for each name. */
47
+ const unknownLanguages = new Set();
48
+ /** The roles a design system added that have their rule in the adopted sheet. */
49
+ const addedRoles = new Set();
50
+ /**
51
+ * COD-28: the first colors of a block are never drawn in the task that draws its code, and the blocks of a page are
52
+ * not all colored in one task: what is owed waits here and is done a few milliseconds at a time, each block whole (its
53
+ * colors arrive in one frame), in tasks of their own — never in a frame callback, so a page at rest asks for none.
54
+ */
55
+ const owed = [];
56
+ let paying = false;
57
+ /** How long one such task may run before it lets the page answer: half of a frame at 60 a second. Not a design value. */
58
+ const SLICE_MS = 8;
59
+ function pay() {
60
+ const until = performance.now() + SLICE_MS;
61
+ while (owed.length && performance.now() < until)
62
+ owed.shift()();
63
+ if (owed.length)
64
+ setTimeout(pay);
65
+ else
66
+ paying = false;
67
+ }
68
+ function later(job) {
69
+ owed.push(job);
70
+ if (paying)
71
+ return;
72
+ paying = true;
73
+ setTimeout(pay);
74
+ }
75
+ const watched = new WeakMap();
76
+ const sizes = typeof ResizeObserver === 'undefined'
77
+ ? null
78
+ : new ResizeObserver((entries) => {
79
+ const blocks = new Set();
80
+ for (const entry of entries) {
81
+ const block = watched.get(entry.target);
82
+ if (block)
83
+ blocks.add(block);
84
+ }
85
+ const read = [...blocks].map((block) => [block, block.read()]);
86
+ for (const [block, can] of read)
87
+ block.tell(can);
88
+ });
89
+ const signature = (pieces) => pieces.map((piece) => `${piece.syntax ?? ''}\u0001${piece.text}`).join('\u0002');
90
+ const endsLine = (node) => node.textContent?.endsWith('\n') ?? false;
91
+ const setAttribute = (element, name, value) => {
92
+ if (value === null) {
93
+ if (element.hasAttribute(name))
94
+ element.removeAttribute(name);
95
+ }
96
+ else if (element.getAttribute(name) !== value)
97
+ element.setAttribute(name, value);
98
+ };
99
+ /**
100
+ * A node as pieces that each hold at most one line break, at their end — a text node split after every break, an
101
+ * element (a run that spans lines) as one shallow copy per line — without adding or removing a character.
102
+ */
103
+ function pieces(node) {
104
+ const text = node.textContent ?? '';
105
+ const first = text.indexOf('\n');
106
+ if (first < 0 || first === text.length - 1)
107
+ return [node];
108
+ if (node.nodeType === Node.TEXT_NODE) {
109
+ const out = [];
110
+ let rest = node;
111
+ for (let at = rest.data.indexOf('\n'); at >= 0 && at < rest.data.length - 1; at = rest.data.indexOf('\n')) {
112
+ const next = rest.splitText(at + 1);
113
+ out.push(rest);
114
+ rest = next;
115
+ }
116
+ out.push(rest);
117
+ return out;
118
+ }
119
+ if (!(node instanceof Element))
120
+ return [node];
121
+ const out = [];
122
+ let current = node.cloneNode(false);
123
+ for (const child of [...node.childNodes]) {
124
+ for (const piece of pieces(child)) {
125
+ current.append(piece);
126
+ if (endsLine(piece)) {
127
+ out.push(current);
128
+ current = node.cloneNode(false);
129
+ }
130
+ }
131
+ }
132
+ if (current.hasChildNodes())
133
+ out.push(current);
134
+ node.remove();
135
+ return out;
136
+ }
137
+ /**
138
+ * Shows lines of code to read, compare and copy: in the code face, on a quiet fill or inside one hairline, scrolling
139
+ * inside itself or wrapping, with an optional header, line numbers, marked lines, a prompt and a copy button; given
140
+ * the code and its language it highlights the code by itself, in the system's syntax colors.
141
+ *
142
+ * Contract: specs/code-block.spec.json. The code stays in the document, as an ordinary `<pre><code>`:
143
+ *
144
+ * <tanrei-code-block title="sizes.js" language="js" copy copy-label="Copy" copied-label="Copied" copy-failed-label="Could not copy">
145
+ * <pre><code>const sizes = ['small', 'medium', 'large'];</code></pre>
146
+ * </tanrei-code-block>
147
+ *
148
+ * so it is there without script — for a reader whose script failed, for crawlers, for find-in-page — and the element
149
+ * draws the frame around it. `@tanrei/web/code.css` draws a block that is not upgraded yet where the element will: its
150
+ * fill, corners, paddings and face, the header's row with the title and the language label, the room of the copy
151
+ * button, and — for lines written where the page was made — what stands beside them; nothing moves when the element
152
+ * is defined. A block built by script sets `code` instead, and the element writes the `<pre><code>`.
153
+ *
154
+ * **It highlights by itself** (COD-19). Three sources of color, in this order: runs the document gives —
155
+ * `<span data-syntax="keyword">` in the `<code>`, or a `<code data-syntax-of="…">` written by `highlightToHtml` where
156
+ * the page was made — are drawn as they are and never read again (COD-29); otherwise, while `highlight` is true and
157
+ * `language` names a language the highlighter knows, the block imports `@tanrei/web/highlight` and colors the code
158
+ * (COD-27); otherwise the code is plain. The code is drawn at once, plain; its colors arrive in one frame and move
159
+ * nothing (COD-28). A role is one of `comment`, `keyword`, `string`, `constant`, `function`, `type`, `tag`, `property`,
160
+ * `punctuation` — or one a design system added — colored from `--tanrei-comp-code-block-syntax-color-*` and weighted
161
+ * from `…-syntax-emphasis-*`. `language` is not drawn: the header's words are `language-label`.
162
+ *
163
+ * **Lines.** The element gives each line a box of its own — `<span data-line>` holding `<span data-line-code>` — by
164
+ * moving the code's nodes and splitting text and runs at line breaks, without adding or removing a character of the
165
+ * code; `[data-line]` children a highlighter already wrote are used as they are, and lines that `highlightToHtml`
166
+ * wrote with the block's props are left untouched. Numbers, signs and the prompt are
167
+ * drawn, not text: never selected, copied or read. A marked line's label (`highlighted-label`, `added-label`,
168
+ * `removed-label`) is the one thing it adds for assistive technology, before the line.
169
+ *
170
+ * The body is one focus stop, with the block's name, only while it can scroll; it is left to right in every layout,
171
+ * and the frame mirrors. The outlined look is read on whatever it is placed on: where that is not the surface color,
172
+ * name it in `--tanrei-code-block-ground`, which the gutter and the copy button's patch stand on while code scrolls
173
+ * under them.
174
+ *
175
+ * @tag tanrei-code-block
176
+ * @slot - The code: one `<pre><code>`. Runs are `<span data-syntax="…">` inside the `<code>`.
177
+ * @csspart container - The block: its fill, its corners, and the edge of the outlined look.
178
+ * @csspart header - The row that holds the title, the language and the copy button.
179
+ * @csspart title - The title.
180
+ * @csspart language - The language label (`language-label`).
181
+ * @csspart copy-button - The copy button (a `<tanrei-copy-button>`).
182
+ * @csspart body - The part that holds the lines and scrolls.
183
+ * @cssprop --tanrei-code-block-ground - The color the outlined look is placed on, where it is not `sys.color.surface`: what the gutter and the copy button's patch are filled with.
184
+ * @fires {CustomEvent<TanreiCodeBlockCopiedDetail>} copied - The code was copied by the block's copy button; `detail.text` is the text that was copied.
185
+ * @fires {CustomEvent<TanreiCodeBlockCopyFailedDetail>} copyfailed - The platform refused the copy asked for by the block's copy button; `detail.reason` is its reason, where it gave one.
186
+ */
187
+ export class TanreiCodeBlock extends LitElement {
188
+ constructor() {
189
+ super(...arguments);
190
+ this.availability = new AvailabilityController(this, 'code-block');
191
+ /** The product's words, read where the instance gives none (src/primitives/words.ts). */
192
+ this.words = new WordsController(this);
193
+ /**
194
+ * The code as plain text, lines separated by line breaks, for a block built by script: the element writes the
195
+ * `<pre><code>` itself. Leave it empty when the `<pre><code>` is in the document. Ignored where the code holds runs.
196
+ */
197
+ this.code = '';
198
+ /** filled: a quiet fill, for code on a page. outlined: no fill inside one hairline, for code inside a container that is already filled. */
199
+ this.variant = 'filled';
200
+ /** medium sets the code in the code role, for a page and a panel; small in the small code role with less padding, for dense interfaces. */
201
+ this.size = 'medium';
202
+ /**
203
+ * A file name or a few words that say what the code is. Drawn in the header and used as the block's accessible name.
204
+ * The attribute is read and removed from the element, so the browser does not also draw its own `title` tooltip over
205
+ * the block.
206
+ */
207
+ this.title = '';
208
+ /**
209
+ * The language the code is written in, as an identifier ("tsx", "css", "swift", "sh"), read without regard to case.
210
+ * It is what the block highlights by (COD-19, COD-27); it is not drawn. Empty, "text", "plain" and "plaintext" mean
211
+ * code that has no syntax; a language the highlighter does not know is drawn plain. The block never guesses one.
212
+ */
213
+ this.language = '';
214
+ /** The language in your words ("TypeScript", "Shell"), drawn in the header. A label only: the block does not highlight by it. */
215
+ this.languageLabel = '';
216
+ /**
217
+ * True: the block highlights the code by itself where it can (COD-19). False — the attribute `highlight="false"` —
218
+ * it never does, whatever `language` says; runs the document gives are still drawn in their colors.
219
+ */
220
+ this.highlight = true;
221
+ /** The block's accessible name where it has no title. Not drawn. A block that can scroll needs a title or a label. */
222
+ this.label = '';
223
+ /** False: a line is never broken, and lines that do not fit scroll sideways inside the block. True: a line that does not fit continues on the next row. */
224
+ this.wrap = false;
225
+ /** Draws each line's number in a gutter at the left of the code. */
226
+ this.lineNumbers = false;
227
+ /** The number of the first line: an excerpt of a file keeps the file's numbers. A whole number of 1 or more. */
228
+ this.startLine = 1;
229
+ /** The lines the text around the block talks about, by number, as numbers and ranges separated by commas ("3, 7-9"), counted from `startLine`. */
230
+ this.highlightedLines = '';
231
+ /** The lines a change adds, written as `highlightedLines` is. */
232
+ this.addedLines = '';
233
+ /** The lines a change takes away, written as `highlightedLines` is. They are drawn, and left out of what the copy button copies. */
234
+ this.removedLines = '';
235
+ /** What assistive technology reads before a highlighted line ("Highlighted"). Required while `highlightedLines` names a line. */
236
+ this.highlightedLabel = '';
237
+ /** What assistive technology reads before an added line ("Added"). Required while `addedLines` names a line. */
238
+ this.addedLabel = '';
239
+ /** What assistive technology reads before a removed line ("Removed"). Required while `removedLines` names a line. */
240
+ this.removedLabel = '';
241
+ /** A prompt ("$", ">") drawn before every line that is not empty. It is not part of the code: not selected, not copied, not read. */
242
+ this.prompt = '';
243
+ /** The most lines shown at once; more than that scroll up and down inside the block. Null shows every line. */
244
+ this.maxLines = null;
245
+ /** Draws a copy button that copies the code. */
246
+ this.copy = false;
247
+ /** The copy button's accessible name ("Copy"). Required while `copy` is true. */
248
+ this.copyLabel = '';
249
+ /** What the copy button announces when the code has been copied ("Copied"). Required while `copy` is true. */
250
+ this.copiedLabel = '';
251
+ /** What the copy button announces when the platform refuses the copy ("Could not copy"). Required while `copy` is true. */
252
+ this.copyFailedLabel = '';
253
+ /** COD-25: there is no code. */
254
+ this.empty = true;
255
+ /** COD-7: the body can scroll, sideways or up and down. */
256
+ this.scrollable = false;
257
+ /** COD-11: what the copy button copies — the lines without the removed ones, joined by line breaks. */
258
+ this.copyText = '';
259
+ /** How many lines the code has (COD-6). */
260
+ this.lineCount = 0;
261
+ /** Whether the lines have a gutter (COD-13): it stays in view at the left, over the room of a corner button there (COD-20). */
262
+ this.gutter = false;
263
+ /** COD-25: sizes and variants a design system adds, and a value the active system does not have (src/primitives/axes.ts). */
264
+ this.axes = new OpenAxesController(this, { component: 'code-block', behavior: 'COD-25', axes: AXES });
265
+ /** COD-25: the custom state the styles read to take a block with no code out of the layout. */
266
+ this.internals = typeof this.attachInternals === 'function' ? this.attachInternals() : null;
267
+ /** The runs this element wrote from the highlighter's answer (as against runs the document gave: COD-29). */
268
+ this.colored = new WeakSet();
269
+ /** What this element last wrote into a line's code, by that line's box: its runs, as one string. */
270
+ this.drawn = new WeakMap();
271
+ /** What the highlighter was last asked — the language and the texts — and the way to cancel that question. */
272
+ this.asked = null;
273
+ this.asking = null;
274
+ /** Whether the highlighter was asked since the block was last put in the document: its first colors wait for a later task (COD-28), later ones do not (COD-30). */
275
+ this.questioned = false;
276
+ /** The lines this element made (as against `[data-line]` children a highlighter wrote). */
277
+ this.made = new WeakSet();
278
+ /** The text `code` last wrote into the document. */
279
+ this.written = null;
280
+ /** COD-22: the code, its runs or its lines changed in the document. */
281
+ this.mutations = typeof MutationObserver === 'undefined' ? null : new MutationObserver(() => this.sync());
282
+ /** COD-7: what the page's size observer watches for this block. */
283
+ this.observedPre = null;
284
+ this.observedBody = null;
285
+ this.removingTitle = false;
286
+ /** COD-7: the body can scroll while its content is larger than it, either way. Read by the page's size observer. */
287
+ this.measured = {
288
+ read: () => {
289
+ const body = this.body;
290
+ return !!body && (body.scrollWidth > body.clientWidth || body.scrollHeight > body.clientHeight);
291
+ },
292
+ tell: (can) => {
293
+ this.scrollable = can;
294
+ },
295
+ };
296
+ /**
297
+ * COD-12: a copied selection holds the selected characters of the code alone, with the code's own line breaks —
298
+ * never a label, and never a break the layout of the lines added. Only for a selection inside this block's code.
299
+ */
300
+ this.onSelectionCopy = (event) => {
301
+ const code = this.codeElement();
302
+ const selection = document.getSelection();
303
+ if (!code || !selection || selection.rangeCount === 0 || selection.isCollapsed || !event.clipboardData)
304
+ return;
305
+ const range = selection.getRangeAt(0);
306
+ if (!code.contains(range.startContainer) || !code.contains(range.endContainer))
307
+ return;
308
+ let text = '';
309
+ const walker = document.createTreeWalker(code, NodeFilter.SHOW_TEXT);
310
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
311
+ if (!range.intersectsNode(node) || node.parentElement?.closest(`[${LABEL}]`))
312
+ continue;
313
+ const from = node === range.startContainer ? range.startOffset : 0;
314
+ const to = node === range.endContainer ? range.endOffset : node.data.length;
315
+ text += node.data.slice(from, to);
316
+ }
317
+ if (!text)
318
+ return;
319
+ event.clipboardData.setData('text/plain', text);
320
+ event.preventDefault();
321
+ };
322
+ }
323
+ static { this.styles = styles; }
324
+ static { this.properties = {
325
+ code: { type: String },
326
+ variant: { type: String, reflect: true },
327
+ size: { type: String, reflect: true },
328
+ title: { type: String },
329
+ language: { type: String },
330
+ languageLabel: { type: String, attribute: 'language-label' },
331
+ // True by default, so its attribute is written to turn it off: highlight="false".
332
+ highlight: { converter: { fromAttribute: (value) => value === null || value.trim().toLowerCase() !== 'false' } },
333
+ label: { type: String },
334
+ wrap: { type: Boolean, reflect: true },
335
+ lineNumbers: { type: Boolean, reflect: true, attribute: 'line-numbers' },
336
+ startLine: { type: Number, attribute: 'start-line' },
337
+ highlightedLines: { type: String, attribute: 'highlighted-lines' },
338
+ addedLines: { type: String, attribute: 'added-lines' },
339
+ removedLines: { type: String, attribute: 'removed-lines' },
340
+ highlightedLabel: { type: String, attribute: 'highlighted-label' },
341
+ addedLabel: { type: String, attribute: 'added-label' },
342
+ removedLabel: { type: String, attribute: 'removed-label' },
343
+ prompt: { type: String },
344
+ maxLines: { type: Number, attribute: 'max-lines' },
345
+ copy: { type: Boolean, reflect: true },
346
+ copyLabel: { type: String, attribute: 'copy-label' },
347
+ copiedLabel: { type: String, attribute: 'copied-label' },
348
+ copyFailedLabel: { type: String, attribute: 'copy-failed-label' },
349
+ empty: { state: true },
350
+ scrollable: { state: true },
351
+ copyText: { state: true },
352
+ lineCount: { state: true },
353
+ gutter: { state: true },
354
+ }; }
355
+ /**
356
+ * The highlighter of every code block, where it is not Tanrei's own (COD-27: "replace the highlighter whole").
357
+ * Undefined — the default: `@tanrei/web/highlight`, imported the first time a block needs it; `setHighlighter` and
358
+ * `registerLanguage` of that module change what it answers. A function: it is asked instead, and that module is never
359
+ * loaded — for a product that has a highlighter it trusts and wants none of Tanrei's. Null: no block highlights by
360
+ * itself. Runs the document gives are drawn whatever this is (COD-29).
361
+ */
362
+ static { this.highlighter = undefined; }
363
+ get body() {
364
+ return this.renderRoot?.querySelector('.body') ?? null;
365
+ }
366
+ get pre() {
367
+ return [...this.children].find((child) => child.localName === 'pre') ?? null;
368
+ }
369
+ /** The `<code>` that holds the code: the `pre`'s own, made around the `pre`'s content where the product wrote none. */
370
+ codeElement(create = false) {
371
+ let pre = this.pre;
372
+ if (!pre) {
373
+ if (!create)
374
+ return null;
375
+ pre = document.createElement('pre');
376
+ this.append(pre);
377
+ }
378
+ const existing = [...pre.children].find((child) => child.localName === 'code');
379
+ if (existing)
380
+ return existing;
381
+ if (!create && !pre.textContent)
382
+ return null;
383
+ const code = document.createElement('code');
384
+ code.append(...pre.childNodes);
385
+ pre.append(code);
386
+ return code;
387
+ }
388
+ attributeChangedCallback(name, old, value) {
389
+ if (name === 'title' && this.removingTitle)
390
+ return;
391
+ super.attributeChangedCallback(name, old, value);
392
+ if (name === 'title' && value !== null) {
393
+ this.removingTitle = true;
394
+ this.removeAttribute('title');
395
+ this.removingTitle = false;
396
+ }
397
+ }
398
+ connectedCallback() {
399
+ super.connectedCallback();
400
+ adoptLightRules(this);
401
+ this.addEventListener('copy', this.onSelectionCopy);
402
+ this.mutations?.observe(this, { childList: true, subtree: true, characterData: true });
403
+ this.sync();
404
+ }
405
+ disconnectedCallback() {
406
+ super.disconnectedCallback();
407
+ this.removeEventListener('copy', this.onSelectionCopy);
408
+ this.mutations?.disconnect();
409
+ this.cancelRuns();
410
+ this.questioned = false;
411
+ for (const element of [this.observedPre, this.observedBody]) {
412
+ if (!element)
413
+ continue;
414
+ sizes?.unobserve(element);
415
+ watched.delete(element);
416
+ }
417
+ this.observedPre = this.observedBody = null;
418
+ }
419
+ cancelRuns() {
420
+ this.asking?.abort();
421
+ this.asking = null;
422
+ this.asked = null;
423
+ }
424
+ /** COD-29: the document gives the runs — the `<code>` says it was highlighted, or holds a run this element did not write. */
425
+ given(code) {
426
+ if (code.hasAttribute(GIVEN))
427
+ return true;
428
+ for (const run of code.querySelectorAll('[data-syntax]'))
429
+ if (!this.colored.has(run))
430
+ return true;
431
+ return false;
432
+ }
433
+ /**
434
+ * COD-19: a role the active design system does not have is drawn plain (no rule matches it) and reported. A role a
435
+ * design system added to the axis has its two tokens in the cascade: it gets its rule, once.
436
+ */
437
+ checkRoles(roles) {
438
+ let style;
439
+ for (const role of new Set(roles)) {
440
+ if (SYNTAXES.includes(role) || addedRoles.has(role))
441
+ continue;
442
+ if (ROLE.test(role) && (style ??= getComputedStyle(this)).getPropertyValue(`--tanrei-comp-code-block-syntax-color-${role}`).trim() !== '') {
443
+ try {
444
+ lightSheet?.insertRule(`@layer tanrei.components { ${roleRule(role)} }`, lightSheet.cssRules.length);
445
+ addedRoles.add(role);
446
+ }
447
+ catch {
448
+ // Without the sheet the role is drawn by the stylesheet of the system that added it, or plain.
449
+ }
450
+ continue;
451
+ }
452
+ report(this, 'COD-19', `the syntax role "${role}" is not one of ${SYNTAXES.join(', ')}, nor one the active design system added; the run is drawn plain`);
453
+ }
454
+ }
455
+ /** COD-31: `comp.code-block.syntax.max-length`, as the cascade gives it to this block; no limit where it is not a number. */
456
+ get maxLength() {
457
+ const value = Number.parseFloat(getComputedStyle(this).getPropertyValue('--tanrei-comp-code-block-syntax-max-length'));
458
+ return Number.isFinite(value) ? value : Number.POSITIVE_INFINITY;
459
+ }
460
+ /** The code of every line this element colored, plain again (the text is the same: COD-19). */
461
+ uncolor(boxes) {
462
+ this.write(boxes.filter((box) => this.drawn.has(box)).map((box) => ({ box, pieces: [{ text: box.textContent ?? '' }] })));
463
+ }
464
+ /**
465
+ * COD-28, COD-30: draws runs — in one pass, replacing the children of each line whose runs are not the ones drawn and
466
+ * touching no other line. Only colors and weights change (COD-18), so nothing moves; a selection in a line that is
467
+ * written again is put back where it was, by its characters.
468
+ */
469
+ write(lines) {
470
+ const changed = lines
471
+ .map((line) => ({ ...line, to: signature(line.pieces) }))
472
+ // A line that was never colored and has no colored run is left as the document has it.
473
+ .filter(({ box, pieces, to }) => (this.drawn.has(box) ? this.drawn.get(box) !== to : pieces.some((piece) => piece.syntax && piece.syntax !== 'plain')));
474
+ if (!changed.length)
475
+ return;
476
+ const selection = document.getSelection();
477
+ const boxes = new Set(changed.map((line) => line.box));
478
+ // Where the selection's two ends are, as characters of a line that is about to be written again.
479
+ const point = (node, offset) => {
480
+ const box = node && [...boxes].find((each) => each.contains(node));
481
+ if (!node || !box)
482
+ return null;
483
+ const before = document.createRange();
484
+ before.selectNodeContents(box);
485
+ before.setEnd(node, offset);
486
+ return { box, at: before.toString().length };
487
+ };
488
+ const ends = selection && selection.rangeCount > 0 ? [point(selection.anchorNode, selection.anchorOffset), point(selection.focusNode, selection.focusOffset)] : null;
489
+ const kept = ends && (ends[0] || ends[1]) ? { anchor: [selection.anchorNode, selection.anchorOffset], focus: [selection.focusNode, selection.focusOffset] } : null;
490
+ for (const { box, pieces, to } of changed) {
491
+ box.replaceChildren(...pieces.map((piece) => {
492
+ if (!piece.syntax || piece.syntax === 'plain')
493
+ return document.createTextNode(piece.text);
494
+ const span = document.createElement('span');
495
+ span.setAttribute('data-syntax', piece.syntax);
496
+ span.textContent = piece.text;
497
+ this.colored.add(span);
498
+ return span;
499
+ }));
500
+ this.drawn.set(box, to);
501
+ }
502
+ if (kept && ends) {
503
+ const place = (mark, was) => {
504
+ if (!mark)
505
+ return was;
506
+ let left = mark.at;
507
+ const walker = document.createTreeWalker(mark.box, NodeFilter.SHOW_TEXT);
508
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
509
+ if (left <= node.data.length)
510
+ return [node, left];
511
+ left -= node.data.length;
512
+ }
513
+ return [mark.box, mark.box.childNodes.length];
514
+ };
515
+ const [anchor, focus] = [place(ends[0], kept.anchor), place(ends[1], kept.focus)];
516
+ if (anchor[0] && focus[0])
517
+ selection.setBaseAndExtent(anchor[0], anchor[1], focus[0], focus[1]);
518
+ }
519
+ // What was written here is not a change of the code.
520
+ this.mutations?.takeRecords();
521
+ }
522
+ /** COD-32: the code stays plain, everything else the block does is untouched, and what failed is said once. */
523
+ failed(boxes, what) {
524
+ this.uncolor(boxes);
525
+ report(this, 'COD-32', `${what}; the code is drawn plain`);
526
+ }
527
+ /**
528
+ * COD-19, COD-27 to COD-33: colors the code by itself where it may. `readings` are the texts the code holds — one,
529
+ * or two where a line is added or removed (COD-33) — each with the boxes of its lines' code. The first colors of a
530
+ * block are owed to a later task (COD-28); a block that has its colors and whose code changes is read again in the
531
+ * task of the change, where its highlighter answers at once, so the new code is drawn with its colors (COD-30).
532
+ */
533
+ color(code, boxes, readings) {
534
+ const language = this.language.trim().toLowerCase();
535
+ const own = TanreiCodeBlock.highlighter;
536
+ // COD-29: the document's runs are drawn as they are. COD-27: code with no syntax is plain, and nothing is said.
537
+ if (!this.highlight || own === null || NO_SYNTAX.includes(language) || !boxes.length || this.given(code)) {
538
+ this.cancelRuns();
539
+ if (!this.given(code))
540
+ this.uncolor(boxes);
541
+ return;
542
+ }
543
+ const question = `${language}\u0000${readings.map((reading) => reading.text).join('\u0000')}`;
544
+ if (question === this.asked)
545
+ return;
546
+ const first = !this.questioned;
547
+ this.questioned = true;
548
+ this.cancelRuns();
549
+ this.asked = question;
550
+ const asking = (this.asking = new AbortController());
551
+ const done = () => {
552
+ if (this.asking === asking)
553
+ this.asking = null;
554
+ };
555
+ const answer = (answers) => {
556
+ if (asking.signal.aborted || !this.isConnected)
557
+ return;
558
+ done();
559
+ if (answers.some((runs) => !runs)) {
560
+ // COD-27: a language the highlighter does not know. Plain, and said once for each name.
561
+ this.uncolor(boxes);
562
+ if (highlightModule && !own && !highlightModule.languages().includes(language) && !unknownLanguages.has(language)) {
563
+ unknownLanguages.add(language);
564
+ report(this, 'COD-27', `the highlighter does not know the language "${language}"; the code is drawn plain (register it with registerLanguage of @tanrei/web/highlight, or write language="text")`);
565
+ }
566
+ return;
567
+ }
568
+ const lines = [];
569
+ const roles = new Set();
570
+ for (const [index, reading] of readings.entries()) {
571
+ const runs = answers[index];
572
+ // COD-32: the runs' texts, joined, are the code — the one check that highlighting cannot alter text.
573
+ if (runs.map((run) => run.text).join('') !== reading.text)
574
+ return this.failed(boxes, 'the highlighter’s runs do not join to the code');
575
+ let at = 0;
576
+ let pieces = [];
577
+ for (const run of runs) {
578
+ if (run.syntax && run.syntax !== 'plain')
579
+ roles.add(run.syntax);
580
+ for (let from = 0; from < run.text.length;) {
581
+ const to = run.text.indexOf('\n', from) + 1 || run.text.length;
582
+ pieces.push({ text: run.text.slice(from, to), syntax: run.syntax });
583
+ from = to;
584
+ if (run.text[to - 1] === '\n') {
585
+ lines.push({ box: reading.boxes[at++], pieces });
586
+ pieces = [];
587
+ }
588
+ }
589
+ }
590
+ if (pieces.length)
591
+ lines.push({ box: reading.boxes[at++], pieces });
592
+ }
593
+ if (lines.some((line) => line.box === undefined))
594
+ return this.failed(boxes, 'the highlighter’s runs do not join to the code');
595
+ this.checkRoles(roles);
596
+ // (A line without a box is one another reading colors: COD-33.)
597
+ this.write(lines.filter((line) => !!line.box));
598
+ };
599
+ const fail = (error) => {
600
+ if (asking.signal.aborted || !this.isConnected)
601
+ return;
602
+ done();
603
+ this.failed(boxes, `the highlighter failed (${error instanceof Error ? error.message : String(error)})`);
604
+ };
605
+ const ask = (highlighter) => {
606
+ if (asking.signal.aborted || !this.isConnected)
607
+ return;
608
+ // COD-31: code that is too long is plain, whole.
609
+ const length = Math.max(...readings.map((reading) => reading.text.length));
610
+ const limit = this.maxLength;
611
+ if (length > limit) {
612
+ done();
613
+ this.uncolor(boxes);
614
+ report(this, 'COD-31', `the code is ${length} characters long, more than comp.code-block.syntax.max-length (${limit}); it is too long to highlight and is drawn plain`);
615
+ return;
616
+ }
617
+ let answers;
618
+ try {
619
+ answers = readings.map((reading) => highlighter(reading.text, language, asking.signal));
620
+ }
621
+ catch (error) {
622
+ return fail(error);
623
+ }
624
+ if (!answers.some((each) => each instanceof Promise))
625
+ answer(answers);
626
+ // Answers that come later are drawn in a task of the queue's, so that the blocks of a page do not all draw in the one their grammar arrives in.
627
+ else
628
+ Promise.all(answers).then((late) => later(() => answer(late)), fail);
629
+ };
630
+ const highlighter = own ?? highlightModule?.highlight;
631
+ // COD-30: a block that is shown and whose code, language or highlight changes is read in the task of the change,
632
+ // so that — where its highlighter answers at once — the new code is drawn with its colors.
633
+ if (!first && highlighter)
634
+ return ask(highlighter);
635
+ // COD-28: the first colors of a block are owed to a later task. COD-30: until runs are ready the lines that did not
636
+ // change keep their colors, and the new ones are plain.
637
+ later(() => {
638
+ if (asking.signal.aborted || !this.isConnected)
639
+ return;
640
+ // (Read again: a product that sets the seam does so after the element is defined, in the task that drew this.)
641
+ const now = TanreiCodeBlock.highlighter;
642
+ if (now === null)
643
+ return void (done(), this.uncolor(boxes));
644
+ if (now ?? highlightModule)
645
+ return ask(now ?? highlightModule.highlight);
646
+ loadHighlight().then((module) => later(() => ask(module.highlight)), (error) => fail(new Error(`@tanrei/web/highlight could not be loaded: ${error instanceof Error ? error.message : String(error)}`)));
647
+ });
648
+ }
649
+ /**
650
+ * Writes `code` as the text of the `<code>`. Where the lines are this element's own, the lines at the start that
651
+ * are the same are left as they are — code that grows at its end keeps the lines it had, and their colors (COD-30).
652
+ */
653
+ writeCode(target, text) {
654
+ const lines = [...target.childNodes];
655
+ if (!lines.length || !lines.every((line) => line instanceof HTMLElement && this.made.has(line))) {
656
+ target.textContent = text;
657
+ return;
658
+ }
659
+ const next = text.match(/[^\n]*\n|[^\n]+/g) ?? [];
660
+ const own = (line) => [...line.children].find((child) => child.hasAttribute(LINE_CODE));
661
+ let same = 0;
662
+ while (same < lines.length && same < next.length && (own(lines[same])?.textContent ?? '') === next[same])
663
+ same++;
664
+ // The last line of code that grows gains its line break, and is otherwise the line it was.
665
+ if (same === lines.length - 1 && same < next.length && `${own(lines[same])?.textContent ?? ''}\n` === next[same])
666
+ own(lines[same++]).append('\n');
667
+ for (const line of lines.slice(same))
668
+ line.remove();
669
+ if (same < next.length)
670
+ target.append(next.slice(same).join(''));
671
+ }
672
+ /** COD-25: a start line below 1 or not whole is 1. */
673
+ get firstLine() {
674
+ return firstLine(this.startLine);
675
+ }
676
+ /** COD-25: a line cap below 1 is none. */
677
+ get cap() {
678
+ return typeof this.maxLines === 'number' && this.maxLines >= 1 ? Math.floor(this.maxLines) : null;
679
+ }
680
+ /**
681
+ * The lines of the code as boxes (the spec's web note): `[data-line]` children of the `<code>`, each holding its code
682
+ * in a `[data-line-code]`. Lines a highlighter wrote are kept; everything else is moved into lines made here, text
683
+ * nodes and runs split at line breaks. No character is added or removed.
684
+ */
685
+ lineBoxes(code) {
686
+ const isLine = (node) => node instanceof HTMLElement && node.hasAttribute(LINE);
687
+ const codeOf = (line) => {
688
+ let own = [...line.children].find((child) => child.hasAttribute(LINE_CODE));
689
+ if (!own) {
690
+ own = document.createElement('span');
691
+ own.setAttribute(LINE_CODE, '');
692
+ own.append(...[...line.childNodes].filter((node) => !(node instanceof Element && (node.hasAttribute(GUTTER) || node.hasAttribute(PROMPT) || node.hasAttribute(LABEL)))));
693
+ line.append(own);
694
+ }
695
+ return own;
696
+ };
697
+ const children = [...code.childNodes];
698
+ // A line that ends where its line does: one line break, at its end (the last line may have none).
699
+ const whole = (node, last) => {
700
+ if (!isLine(node))
701
+ return false;
702
+ const text = codeOf(node).textContent ?? '';
703
+ const at = text.indexOf('\n');
704
+ return last ? at < 0 || at === text.length - 1 : at >= 0 && at === text.length - 1;
705
+ };
706
+ // The lines at the start that are whole are kept as they are — all of them, in the common case after the first
707
+ // pass; where code was added or changed after them, they keep their boxes and so their colors (COD-30).
708
+ let kept = 0;
709
+ while (kept < children.length && whole(children[kept], kept === children.length - 1))
710
+ kept++;
711
+ if (kept === children.length)
712
+ return children;
713
+ const lines = children.slice(0, kept);
714
+ // The code changed under the lines made here: take them apart, and lay the lines out again.
715
+ for (const node of children.slice(kept)) {
716
+ if (isLine(node) && this.made.has(node))
717
+ node.replaceWith(...codeOf(node).childNodes);
718
+ }
719
+ let open = null;
720
+ for (const node of [...code.childNodes].slice(kept)) {
721
+ if (isLine(node)) {
722
+ lines.push(node);
723
+ open = endsLine(codeOf(node)) ? null : node;
724
+ continue;
725
+ }
726
+ // A comment is no part of the code.
727
+ if (node.nodeType !== Node.TEXT_NODE && node.nodeType !== Node.ELEMENT_NODE)
728
+ continue;
729
+ for (const piece of pieces(node)) {
730
+ if (!open) {
731
+ open = document.createElement('span');
732
+ open.setAttribute(LINE, '');
733
+ const own = document.createElement('span');
734
+ own.setAttribute(LINE_CODE, '');
735
+ open.append(own);
736
+ this.made.add(open);
737
+ lines.push(open);
738
+ }
739
+ codeOf(open).append(piece);
740
+ if (endsLine(piece))
741
+ open = null;
742
+ }
743
+ }
744
+ // The lines, in the order of the code.
745
+ for (const line of lines.slice(kept))
746
+ code.append(line);
747
+ return lines;
748
+ }
749
+ /**
750
+ * COD-22: reads the code from the document and draws what the props say on its lines — numbers, signs, the prompt,
751
+ * the marks and their labels — at once, without a motion and without announcing anything.
752
+ */
753
+ sync() {
754
+ if (!this.isConnected)
755
+ return;
756
+ // The `code` prop, for a block built by script: written once per value, unless the document gives runs (COD-29).
757
+ if (this.code !== (this.written ?? '')) {
758
+ const target = this.codeElement(!!this.code);
759
+ if (target && this.given(target)) {
760
+ if (this.code)
761
+ report(this, 'COD-29', 'code is ignored: the <code> in the block holds runs, and their texts are the code');
762
+ }
763
+ else if (target) {
764
+ this.writeCode(target, this.code);
765
+ }
766
+ this.written = this.code;
767
+ }
768
+ const code = this.codeElement();
769
+ const pre = code?.parentElement ?? null;
770
+ if (pre) {
771
+ // COD-2: code is not translated and not spell-checked.
772
+ if (!pre.hasAttribute('translate'))
773
+ pre.setAttribute('translate', 'no');
774
+ if (!pre.hasAttribute('spellcheck'))
775
+ pre.setAttribute('spellcheck', 'false');
776
+ }
777
+ const boxes = code?.textContent ? this.lineBoxes(code) : [];
778
+ const codes = boxes.map((line) => [...line.children].find((child) => child.hasAttribute(LINE_CODE)));
779
+ const whole = codes.map((own) => own?.textContent ?? '');
780
+ const texts = whole.map((text) => text.replace(/\n$/, ''));
781
+ // COD-33: the texts the code holds — one, or two where a line is added or removed.
782
+ let readings = [{ text: whole.join(''), boxes: codes }];
783
+ if (code && boxes.length) {
784
+ // What stands beside each line (COD-13 to COD-17), decided as `highlightToHtml` decides it where a page is made
785
+ // (code-block.lines.ts): lines that were written there are found as they should be, and nothing is written.
786
+ const { lines: beside, first, highlighted, added, removed, problems } = furnish(texts, {
787
+ lineNumbers: this.lineNumbers,
788
+ startLine: this.startLine,
789
+ highlightedLines: this.highlightedLines,
790
+ addedLines: this.addedLines,
791
+ removedLines: this.removedLines,
792
+ // The words of a marked line: the instance's, else the product's.
793
+ highlightedLabel: this.words.get('highlightedLabel', this.highlightedLabel),
794
+ addedLabel: this.words.get('addedLabel', this.addedLabel),
795
+ removedLabel: this.words.get('removedLabel', this.removedLabel),
796
+ prompt: this.prompt,
797
+ });
798
+ for (const problem of problems)
799
+ report(this, 'COD-14', problem);
800
+ // COD-19: an unknown syntax role is plain (no rule matches it), and reported. (The roles of runs this element
801
+ // writes are checked as they are written.)
802
+ if (this.given(code))
803
+ this.checkRoles([...code.querySelectorAll('[data-syntax]')].map((run) => run.getAttribute('data-syntax') ?? ''));
804
+ // COD-33: the lines that are not removed are the code after the change — what is copied — and color those lines;
805
+ // the lines that are not added are the code before it, and color the removed ones.
806
+ if (added.size || removed.size) {
807
+ const after = codes.filter((_, index) => !removed.has(first + index));
808
+ const before = codes.filter((_, index) => !added.has(first + index));
809
+ const text = (of) => of.map((own) => own.textContent ?? '').join('');
810
+ readings = [
811
+ { text: text(after), boxes: after },
812
+ // Read whole, so that a removed line has the state the lines before it leave; only its own runs are drawn.
813
+ { text: text(before), boxes: before.map((own) => (removed.has(first + codes.indexOf(own)) ? own : null)) },
814
+ ];
815
+ }
816
+ const copied = [];
817
+ boxes.forEach((line, index) => {
818
+ const { gutter, number, sign, prompt, label, ...marks } = beside[index];
819
+ for (const [mark, on] of Object.entries(marks))
820
+ setAttribute(line, `data-${mark}`, on ? '' : null);
821
+ if (!marks.removed)
822
+ copied.push(texts[index]);
823
+ // What stands beside the code, in this order: the gutter, the prompt, the label, the code.
824
+ let gutterBox;
825
+ let promptBox;
826
+ let labelBox;
827
+ for (const child of line.children) {
828
+ if (child.hasAttribute(GUTTER))
829
+ gutterBox = child;
830
+ else if (child.hasAttribute(PROMPT))
831
+ promptBox = child;
832
+ else if (child.hasAttribute(LABEL))
833
+ labelBox = child;
834
+ }
835
+ const lineCode = codes[index];
836
+ const part = (found, name, wanted, before) => {
837
+ if (!wanted) {
838
+ found?.remove();
839
+ return undefined;
840
+ }
841
+ if (found)
842
+ return found;
843
+ const element = document.createElement('span');
844
+ element.setAttribute(name, '');
845
+ line.insertBefore(element, before);
846
+ return element;
847
+ };
848
+ // COD-15, COD-16: the mark in words, before the line's text.
849
+ labelBox = part(labelBox, LABEL, label !== null, lineCode);
850
+ if (labelBox && labelBox.textContent !== label)
851
+ labelBox.textContent = label;
852
+ // COD-17: before every line that is not empty.
853
+ promptBox = part(promptBox, PROMPT, prompt !== null, labelBox ?? lineCode);
854
+ if (promptBox) {
855
+ setAttribute(promptBox, 'aria-hidden', 'true');
856
+ setAttribute(promptBox, 'data-prompt', prompt);
857
+ }
858
+ // COD-13, COD-16: drawn, not text — an empty element whose generated content is the number and the sign.
859
+ gutterBox = part(gutterBox, GUTTER, gutter, promptBox ?? labelBox ?? lineCode);
860
+ if (gutterBox) {
861
+ setAttribute(gutterBox, 'aria-hidden', 'true');
862
+ setAttribute(gutterBox, 'data-number', number);
863
+ setAttribute(gutterBox, 'data-sign', sign);
864
+ }
865
+ });
866
+ // COD-25: a marked line whose label is missing still draws.
867
+ if (highlighted.size && this.words.lacks('highlightedLabel', this.highlightedLabel))
868
+ report(this, 'COD-25', 'highlightedLines names a line and highlightedLabel is empty; assistive technology is not told which lines are highlighted');
869
+ if (added.size && this.words.lacks('addedLabel', this.addedLabel))
870
+ report(this, 'COD-25', 'addedLines names a line and addedLabel is empty; assistive technology is not told which lines are added');
871
+ if (removed.size && this.words.lacks('removedLabel', this.removedLabel))
872
+ report(this, 'COD-25', 'removedLines names a line and removedLabel is empty; assistive technology is not told which lines are removed');
873
+ this.copyText = copied.join('\n');
874
+ }
875
+ else {
876
+ this.copyText = '';
877
+ }
878
+ if (code)
879
+ this.color(code, codes, readings);
880
+ this.lineCount = boxes.length;
881
+ this.gutter = boxes.some((line) => [...line.children].some((child) => child.hasAttribute(GUTTER)));
882
+ this.empty = boxes.length === 0;
883
+ // What was written here is not a change of the code.
884
+ this.mutations?.takeRecords();
885
+ this.watchSizes();
886
+ }
887
+ /** The body and the product's `pre` are watched for their sizes (COD-7): the observer answers at once for each. */
888
+ watchSizes() {
889
+ const [body, pre] = [this.body, this.pre];
890
+ const watch = (now, was) => {
891
+ if (now === was)
892
+ return now;
893
+ if (was) {
894
+ sizes?.unobserve(was);
895
+ watched.delete(was);
896
+ }
897
+ if (now) {
898
+ watched.set(now, this.measured);
899
+ sizes?.observe(now);
900
+ }
901
+ return now;
902
+ };
903
+ this.observedBody = watch(body, this.observedBody);
904
+ this.observedPre = watch(pre, this.observedPre);
905
+ }
906
+ /** COD-11: the block's own events, for its copy button's. */
907
+ onCopied(event) {
908
+ event.stopPropagation();
909
+ this.dispatchEvent(new CustomEvent('copied', { bubbles: true, detail: { text: event.detail.text } }));
910
+ }
911
+ onCopyFailed(event) {
912
+ event.stopPropagation();
913
+ this.dispatchEvent(new CustomEvent('copyfailed', { bubbles: true, detail: { reason: event.detail.reason } }));
914
+ }
915
+ /** COD-7: where style queries are missing, the focus style is read when focus arrives. */
916
+ onBodyFocus() {
917
+ syncFocusStyle(this, this.body);
918
+ }
919
+ willUpdate(changed) {
920
+ const drawn = ['code', 'language', 'highlight', 'lineNumbers', 'startLine', 'highlightedLines', 'addedLines', 'removedLines', 'highlightedLabel', 'addedLabel', 'removedLabel', 'prompt'];
921
+ if (this.hasUpdated && drawn.some((name) => changed.has(name)))
922
+ this.sync();
923
+ // COD-25: no code, no block.
924
+ try {
925
+ if (this.empty)
926
+ this.internals?.states.add('empty');
927
+ else
928
+ this.internals?.states.delete('empty');
929
+ }
930
+ catch {
931
+ // A browser without custom states: the empty block is an empty box.
932
+ }
933
+ }
934
+ updated(changed) {
935
+ this.watchSizes();
936
+ // COD-25: what is missing is reported; the block still draws.
937
+ if (this.empty) {
938
+ report(this, 'COD-25', 'the code block has no code, so it draws nothing; give it a <pre><code>, or set code');
939
+ return;
940
+ }
941
+ if (this.copy && (changed.has('copy') || changed.has('copyLabel') || changed.has('copiedLabel') || changed.has('copyFailedLabel'))) {
942
+ const missing = [this.words.lacks('copyLabel', this.copyLabel) && 'copyLabel', this.words.lacks('copiedLabel', this.copiedLabel) && 'copiedLabel', this.words.lacks('copyFailedLabel', this.copyFailedLabel) && 'copyFailedLabel'].filter(Boolean);
943
+ if (missing.length)
944
+ report(this, 'COD-25', `copy is set and ${missing.join(', ')} ${missing.length > 1 ? 'are' : 'is'} empty; the copy button needs its name and its two announcements`);
945
+ }
946
+ if (this.scrollable && !this.title && !this.label)
947
+ report(this, 'COD-25', 'the body can scroll and is a focus stop, and both title and label are empty, so it has no accessible name; give the block one');
948
+ if (changed.has('startLine') && this.firstLine !== this.startLine)
949
+ report(this, 'COD-25', `startLine ${this.startLine} is not a whole number of 1 or more; it is taken as 1`);
950
+ if (changed.has('maxLines') && this.maxLines !== null && this.cap === null)
951
+ report(this, 'COD-25', `maxLines ${this.maxLines} is below 1; every line is shown`);
952
+ }
953
+ render() {
954
+ // COD-25: nothing is drawn and nothing is exposed.
955
+ if (this.empty)
956
+ return nothing;
957
+ // COD-8: the header's words are the title and the language label; `language` itself is not drawn.
958
+ const header = !!this.title || !!this.languageLabel;
959
+ // COD-22: a group named by the title, and by the label where there is none.
960
+ const name = this.title || this.label;
961
+ const cap = this.cap;
962
+ const capped = cap !== null && this.lineCount > cap;
963
+ // COD-9: a Copy button — icon-only, the text variant, the small size — that copies the code (COD-11).
964
+ const button = this.copy
965
+ ? html `<tanrei-copy-button
966
+ part="copy-button"
967
+ variant="text"
968
+ size="small"
969
+ .text=${this.copyText}
970
+ label=${this.words.get('copyLabel', this.copyLabel)}
971
+ copied-label=${this.words.get('copiedLabel', this.copiedLabel)}
972
+ failed-label=${this.words.get('copyFailedLabel', this.copyFailedLabel)}
973
+ @copied=${this.onCopied}
974
+ @copyfailed=${this.onCopyFailed}
975
+ ></tanrei-copy-button>`
976
+ : nothing;
977
+ return html `
978
+ <div part="container" class="container ${classMap({ copy: this.copy, 'has-header': header, gutter: this.gutter })}" data-tanrei-shape>
979
+ ${header
980
+ ? html `<div part="header" class="header">
981
+ ${this.title ? html `<span part="title" class="title" dir=${ownDirection(this.title)}>${this.title}</span>` : nothing}
982
+ <span class="space"></span>
983
+ ${this.languageLabel ? html `<span part="language" class="language">${this.languageLabel}</span>` : nothing}
984
+ ${button}
985
+ </div>`
986
+ : this.copy
987
+ ? html `<div class="corner">${button}</div>`
988
+ : nothing}
989
+ <div
990
+ part="body"
991
+ class="body ${classMap({ capped })}"
992
+ dir="ltr"
993
+ data-tanrei-shape
994
+ role=${name ? 'group' : nothing}
995
+ aria-label=${name || nothing}
996
+ tabindex=${this.scrollable ? '0' : nothing}
997
+ style=${capped ? `--_max-lines: ${cap}` : nothing}
998
+ @focus=${this.onBodyFocus}
999
+ >
1000
+ <slot></slot>
1001
+ </div>
1002
+ <span class="focus" data-tanrei-shape></span>
1003
+ </div>
1004
+ `;
1005
+ }
1006
+ }
1007
+ if (!customElements.get('tanrei-code-block'))
1008
+ customElements.define('tanrei-code-block', TanreiCodeBlock);
1009
+ //# sourceMappingURL=code-block.js.map