@nldd/design-system 0.13.2 → 0.14.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 (491) hide show
  1. package/README.md +4 -2
  2. package/custom-elements.json +1425 -136
  3. package/dist/components/actions/button/button.d.ts +0 -2
  4. package/dist/components/actions/button/button.d.ts.map +1 -1
  5. package/dist/components/actions/button/button.js +17 -33
  6. package/dist/components/actions/button/button.js.map +1 -1
  7. package/dist/components/actions/button/button.template.js +2 -2
  8. package/dist/components/actions/button-bar/button-bar.d.ts +0 -2
  9. package/dist/components/actions/button-bar/button-bar.d.ts.map +1 -1
  10. package/dist/components/actions/button-bar/button-bar.js +2 -12
  11. package/dist/components/actions/button-bar/button-bar.js.map +1 -1
  12. package/dist/components/actions/button-group/button-group.d.ts.map +1 -1
  13. package/dist/components/actions/button-group/button-group.js +9 -10
  14. package/dist/components/actions/button-group/button-group.js.map +1 -1
  15. package/dist/components/actions/icon-button/icon-button.d.ts +0 -1
  16. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  17. package/dist/components/actions/icon-button/icon-button.js +4 -11
  18. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  19. package/dist/components/actions/icon-button/icon-button.template.js +2 -2
  20. package/dist/components/actions/menu/menu-divider.d.ts +1 -0
  21. package/dist/components/actions/menu/menu-divider.d.ts.map +1 -1
  22. package/dist/components/actions/menu/menu-divider.js +1 -0
  23. package/dist/components/actions/menu/menu-divider.js.map +1 -1
  24. package/dist/components/actions/menu/menu-group.d.ts +1 -0
  25. package/dist/components/actions/menu/menu-group.d.ts.map +1 -1
  26. package/dist/components/actions/menu/menu-group.js +1 -0
  27. package/dist/components/actions/menu/menu-group.js.map +1 -1
  28. package/dist/components/actions/menu/menu-item.d.ts +1 -0
  29. package/dist/components/actions/menu/menu-item.d.ts.map +1 -1
  30. package/dist/components/actions/menu/menu-item.js +4 -7
  31. package/dist/components/actions/menu/menu-item.js.map +1 -1
  32. package/dist/components/actions/menu/menu.d.ts +1 -4
  33. package/dist/components/actions/menu/menu.d.ts.map +1 -1
  34. package/dist/components/actions/menu/menu.js +3 -17
  35. package/dist/components/actions/menu/menu.js.map +1 -1
  36. package/dist/components/actions/split-button/split-button.d.ts.map +1 -1
  37. package/dist/components/actions/split-button/split-button.js +2 -1
  38. package/dist/components/actions/split-button/split-button.js.map +1 -1
  39. package/dist/components/actions/toolbar/toolbar-item.d.ts +0 -2
  40. package/dist/components/actions/toolbar/toolbar-item.d.ts.map +1 -1
  41. package/dist/components/actions/toolbar/toolbar-item.js +2 -20
  42. package/dist/components/actions/toolbar/toolbar-item.js.map +1 -1
  43. package/dist/components/actions/toolbar/toolbar-title.d.ts.map +1 -1
  44. package/dist/components/actions/toolbar/toolbar-title.js +2 -1
  45. package/dist/components/actions/toolbar/toolbar-title.js.map +1 -1
  46. package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
  47. package/dist/components/actions/toolbar/toolbar.js +2 -1
  48. package/dist/components/actions/toolbar/toolbar.js.map +1 -1
  49. package/dist/components/button.i18n-DiDGynnq.js +8 -0
  50. package/dist/components/components.js +352 -706
  51. package/dist/components/content/avatar/avatar.d.ts +0 -2
  52. package/dist/components/content/avatar/avatar.d.ts.map +1 -1
  53. package/dist/components/content/avatar/avatar.js +2 -27
  54. package/dist/components/content/avatar/avatar.js.map +1 -1
  55. package/dist/components/content/avatar-group/avatar-group.d.ts +0 -1
  56. package/dist/components/content/avatar-group/avatar-group.d.ts.map +1 -1
  57. package/dist/components/content/avatar-group/avatar-group.js +2 -24
  58. package/dist/components/content/avatar-group/avatar-group.js.map +1 -1
  59. package/dist/components/content/blockquote/blockquote.d.ts.map +1 -1
  60. package/dist/components/content/blockquote/blockquote.js +2 -1
  61. package/dist/components/content/blockquote/blockquote.js.map +1 -1
  62. package/dist/components/content/code-viewer/code-viewer.d.ts +1 -0
  63. package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
  64. package/dist/components/content/code-viewer/code-viewer.diff.d.ts +2 -0
  65. package/dist/components/content/code-viewer/code-viewer.diff.d.ts.map +1 -1
  66. package/dist/components/content/code-viewer/code-viewer.diff.js +1 -4
  67. package/dist/components/content/code-viewer/code-viewer.diff.js.map +1 -1
  68. package/dist/components/content/code-viewer/code-viewer.js +13 -11
  69. package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
  70. package/dist/components/content/icon/icon.d.ts +3 -0
  71. package/dist/components/content/icon/icon.d.ts.map +1 -1
  72. package/dist/components/content/icon/icon.js +19 -15
  73. package/dist/components/content/icon/icon.js.map +1 -1
  74. package/dist/components/content/identity/identity.d.ts.map +1 -1
  75. package/dist/components/content/identity/identity.js +2 -1
  76. package/dist/components/content/identity/identity.js.map +1 -1
  77. package/dist/components/content/image/image.d.ts +5 -11
  78. package/dist/components/content/image/image.d.ts.map +1 -1
  79. package/dist/components/content/image/image.js +14 -31
  80. package/dist/components/content/image/image.js.map +1 -1
  81. package/dist/components/content/image/lqip-encoder-element.d.ts.map +1 -1
  82. package/dist/components/content/image/lqip-encoder-element.js +2 -1
  83. package/dist/components/content/image/lqip-encoder-element.js.map +1 -1
  84. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts.map +1 -1
  85. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js +2 -1
  86. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  87. package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
  88. package/dist/components/content/rich-text/rich-text.js +2 -1
  89. package/dist/components/content/rich-text/rich-text.js.map +1 -1
  90. package/dist/components/content/tag/tag.d.ts.map +1 -1
  91. package/dist/components/content/tag/tag.js +5 -5
  92. package/dist/components/content/tag/tag.js.map +1 -1
  93. package/dist/components/content/text/text.d.ts.map +1 -1
  94. package/dist/components/content/text/text.js +2 -1
  95. package/dist/components/content/text/text.js.map +1 -1
  96. package/dist/components/content/title/title.d.ts +1 -5
  97. package/dist/components/content/title/title.d.ts.map +1 -1
  98. package/dist/components/content/title/title.js +15 -27
  99. package/dist/components/content/title/title.js.map +1 -1
  100. package/dist/components/content/token/token.d.ts.map +1 -1
  101. package/dist/components/content/token/token.js +2 -1
  102. package/dist/components/content/token/token.js.map +1 -1
  103. package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
  104. package/dist/components/content/tooltip/tooltip.js +2 -1
  105. package/dist/components/content/tooltip/tooltip.js.map +1 -1
  106. package/dist/components/content/visually-hidden/visually-hidden.js +1 -1
  107. package/dist/components/content/visually-hidden/visually-hidden.js.map +1 -1
  108. package/dist/components/{decorate-Cz9-peTN.js → decorate-x12uDAK4.js} +9 -1
  109. package/dist/components/dev-checks-BgrW077W.js +2503 -0
  110. package/dist/components/element-state-BnarBv0M.js +42 -0
  111. package/dist/components/forms/form/form.d.ts +1 -96
  112. package/dist/components/forms/form/form.d.ts.map +1 -1
  113. package/dist/components/forms/form/form.js +1 -0
  114. package/dist/components/forms/form/form.js.map +1 -1
  115. package/dist/components/forms/form-actions/form-actions.d.ts.map +1 -1
  116. package/dist/components/forms/form-actions/form-actions.js +2 -1
  117. package/dist/components/forms/form-actions/form-actions.js.map +1 -1
  118. package/dist/components/forms/form-field/form-field.d.ts +1 -2
  119. package/dist/components/forms/form-field/form-field.d.ts.map +1 -1
  120. package/dist/components/forms/form-field/form-field.js +10 -26
  121. package/dist/components/forms/form-field/form-field.js.map +1 -1
  122. package/dist/components/forms/form-section/form-section.d.ts +1 -67
  123. package/dist/components/forms/form-section/form-section.d.ts.map +1 -1
  124. package/dist/components/forms/form-section/form-section.js +2 -16
  125. package/dist/components/forms/form-section/form-section.js.map +1 -1
  126. package/dist/components/forms/validation-list/validation-list.d.ts.map +1 -1
  127. package/dist/components/forms/validation-list/validation-list.js +7 -6
  128. package/dist/components/forms/validation-list/validation-list.js.map +1 -1
  129. package/dist/components/{icon-DRpTWSIg.js → icon-IgCyk9ui.js} +17 -4
  130. package/dist/components/{icon-button-DUEmWlBD.js → icon-button-B5tH4b3c.js} +8 -17
  131. package/dist/components/icon-button.i18n-1_N-wN6x.js +10 -0
  132. package/dist/components/inputs/checkbox/checkbox.d.ts.map +1 -1
  133. package/dist/components/inputs/checkbox/checkbox.js +2 -1
  134. package/dist/components/inputs/checkbox/checkbox.js.map +1 -1
  135. package/dist/components/inputs/checkbox-field/checkbox-field.d.ts.map +1 -1
  136. package/dist/components/inputs/checkbox-field/checkbox-field.js +2 -1
  137. package/dist/components/inputs/checkbox-field/checkbox-field.js.map +1 -1
  138. package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
  139. package/dist/components/inputs/code-editor/code-editor.js +2 -1
  140. package/dist/components/inputs/code-editor/code-editor.js.map +1 -1
  141. package/dist/components/inputs/combo-box/combo-box.d.ts.map +1 -1
  142. package/dist/components/inputs/combo-box/combo-box.js +4 -5
  143. package/dist/components/inputs/combo-box/combo-box.js.map +1 -1
  144. package/dist/components/inputs/date-field/date-field.d.ts.map +1 -1
  145. package/dist/components/inputs/date-field/date-field.js +2 -1
  146. package/dist/components/inputs/date-field/date-field.js.map +1 -1
  147. package/dist/components/inputs/date-picker/date-picker.d.ts.map +1 -1
  148. package/dist/components/inputs/date-picker/date-picker.js +2 -1
  149. package/dist/components/inputs/date-picker/date-picker.js.map +1 -1
  150. package/dist/components/inputs/dropdown/dropdown.d.ts.map +1 -1
  151. package/dist/components/inputs/dropdown/dropdown.js +5 -4
  152. package/dist/components/inputs/dropdown/dropdown.js.map +1 -1
  153. package/dist/components/inputs/file-field/file-field.d.ts.map +1 -1
  154. package/dist/components/inputs/file-field/file-field.js +2 -1
  155. package/dist/components/inputs/file-field/file-field.js.map +1 -1
  156. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts.map +1 -1
  157. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js +2 -4
  158. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js.map +1 -1
  159. package/dist/components/inputs/number-field/number-field.d.ts.map +1 -1
  160. package/dist/components/inputs/number-field/number-field.js +2 -4
  161. package/dist/components/inputs/number-field/number-field.js.map +1 -1
  162. package/dist/components/inputs/password-field/password-field.d.ts.map +1 -1
  163. package/dist/components/inputs/password-field/password-field.js +2 -1
  164. package/dist/components/inputs/password-field/password-field.js.map +1 -1
  165. package/dist/components/inputs/radio-button/radio-button.d.ts.map +1 -1
  166. package/dist/components/inputs/radio-button/radio-button.js +2 -1
  167. package/dist/components/inputs/radio-button/radio-button.js.map +1 -1
  168. package/dist/components/inputs/radio-button-field/radio-button-field.d.ts.map +1 -1
  169. package/dist/components/inputs/radio-button-field/radio-button-field.js +2 -1
  170. package/dist/components/inputs/radio-button-field/radio-button-field.js.map +1 -1
  171. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts +0 -1
  172. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts.map +1 -1
  173. package/dist/components/inputs/radio-button-group/radio-button-group.js +2 -6
  174. package/dist/components/inputs/radio-button-group/radio-button-group.js.map +1 -1
  175. package/dist/components/inputs/search-field/search-field.d.ts.map +1 -1
  176. package/dist/components/inputs/search-field/search-field.js +2 -1
  177. package/dist/components/inputs/search-field/search-field.js.map +1 -1
  178. package/dist/components/inputs/segmented-control/segmented-control.d.ts +0 -1
  179. package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
  180. package/dist/components/inputs/segmented-control/segmented-control.js +2 -11
  181. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  182. package/dist/components/inputs/slider/slider.d.ts.map +1 -1
  183. package/dist/components/inputs/slider/slider.js +2 -1
  184. package/dist/components/inputs/slider/slider.js.map +1 -1
  185. package/dist/components/inputs/stepper/stepper.d.ts.map +1 -1
  186. package/dist/components/inputs/stepper/stepper.js +2 -1
  187. package/dist/components/inputs/stepper/stepper.js.map +1 -1
  188. package/dist/components/inputs/switch/switch.d.ts.map +1 -1
  189. package/dist/components/inputs/switch/switch.js +2 -4
  190. package/dist/components/inputs/switch/switch.js.map +1 -1
  191. package/dist/components/inputs/switch-field/switch-field.d.ts.map +1 -1
  192. package/dist/components/inputs/switch-field/switch-field.js +2 -1
  193. package/dist/components/inputs/switch-field/switch-field.js.map +1 -1
  194. package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
  195. package/dist/components/inputs/text-editor/text-editor.js +7 -3
  196. package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
  197. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +2 -0
  198. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts.map +1 -1
  199. package/dist/components/inputs/text-editor/text-editor.mentions.js +14 -2
  200. package/dist/components/inputs/text-editor/text-editor.mentions.js.map +1 -1
  201. package/dist/components/inputs/text-field/text-field.d.ts +1 -5
  202. package/dist/components/inputs/text-field/text-field.d.ts.map +1 -1
  203. package/dist/components/inputs/text-field/text-field.js +6 -23
  204. package/dist/components/inputs/text-field/text-field.js.map +1 -1
  205. package/dist/components/inputs/time-field/time-field.d.ts.map +1 -1
  206. package/dist/components/inputs/time-field/time-field.js +2 -1
  207. package/dist/components/inputs/time-field/time-field.js.map +1 -1
  208. package/dist/components/inputs/time-picker/time-picker.d.ts.map +1 -1
  209. package/dist/components/inputs/time-picker/time-picker.js +2 -1
  210. package/dist/components/inputs/time-picker/time-picker.js.map +1 -1
  211. package/dist/components/inputs/toggle-button/toggle-button.d.ts +0 -2
  212. package/dist/components/inputs/toggle-button/toggle-button.d.ts.map +1 -1
  213. package/dist/components/inputs/toggle-button/toggle-button.js +2 -23
  214. package/dist/components/inputs/toggle-button/toggle-button.js.map +1 -1
  215. package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts +0 -2
  216. package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts.map +1 -1
  217. package/dist/components/inputs/toggle-button-group/toggle-button-group.js +2 -12
  218. package/dist/components/inputs/toggle-button-group/toggle-button-group.js.map +1 -1
  219. package/dist/components/inputs/token-field/token-field.d.ts.map +1 -1
  220. package/dist/components/inputs/token-field/token-field.js +2 -1
  221. package/dist/components/inputs/token-field/token-field.js.map +1 -1
  222. package/dist/components/just-in-time-education.i18n-BJ5ovWVB.js +370 -0
  223. package/dist/components/layout/box/box.d.ts.map +1 -1
  224. package/dist/components/layout/box/box.js +2 -1
  225. package/dist/components/layout/box/box.js.map +1 -1
  226. package/dist/components/layout/card/card.d.ts +0 -1
  227. package/dist/components/layout/card/card.d.ts.map +1 -1
  228. package/dist/components/layout/card/card.js +2 -15
  229. package/dist/components/layout/card/card.js.map +1 -1
  230. package/dist/components/layout/card/card.template.js +2 -2
  231. package/dist/components/layout/collection/collection.d.ts +0 -2
  232. package/dist/components/layout/collection/collection.d.ts.map +1 -1
  233. package/dist/components/layout/collection/collection.js +8 -24
  234. package/dist/components/layout/collection/collection.js.map +1 -1
  235. package/dist/components/layout/container/container.d.ts +6 -3
  236. package/dist/components/layout/container/container.d.ts.map +1 -1
  237. package/dist/components/layout/container/container.js +17 -23
  238. package/dist/components/layout/container/container.js.map +1 -1
  239. package/dist/components/layout/divider/divider.js +1 -1
  240. package/dist/components/layout/divider/divider.js.map +1 -1
  241. package/dist/components/layout/page/page.d.ts +2 -3
  242. package/dist/components/layout/page/page.d.ts.map +1 -1
  243. package/dist/components/layout/page/page.js +9 -12
  244. package/dist/components/layout/page/page.js.map +1 -1
  245. package/dist/components/layout/page-footer/page-footer.d.ts.map +1 -1
  246. package/dist/components/layout/page-footer/page-footer.js +6 -7
  247. package/dist/components/layout/page-footer/page-footer.js.map +1 -1
  248. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.d.ts.map +1 -1
  249. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.js +2 -1
  250. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.js.map +1 -1
  251. package/dist/components/layout/page-sections/hero/hero-corner.d.ts +0 -1
  252. package/dist/components/layout/page-sections/hero/hero-corner.d.ts.map +1 -1
  253. package/dist/components/layout/page-sections/hero/hero-corner.js +9 -28
  254. package/dist/components/layout/page-sections/hero/hero-corner.js.map +1 -1
  255. package/dist/components/layout/page-sections/hero/hero.d.ts +1 -4
  256. package/dist/components/layout/page-sections/hero/hero.d.ts.map +1 -1
  257. package/dist/components/layout/page-sections/hero/hero.js +7 -29
  258. package/dist/components/layout/page-sections/hero/hero.js.map +1 -1
  259. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.d.ts.map +1 -1
  260. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.js +2 -1
  261. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.js.map +1 -1
  262. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.d.ts.map +1 -1
  263. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.js +2 -1
  264. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.js.map +1 -1
  265. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.d.ts.map +1 -1
  266. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.js +2 -1
  267. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.js.map +1 -1
  268. package/dist/components/layout/page-sections/simple-section/simple-section.d.ts.map +1 -1
  269. package/dist/components/layout/page-sections/simple-section/simple-section.js +2 -1
  270. package/dist/components/layout/page-sections/simple-section/simple-section.js.map +1 -1
  271. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.d.ts.map +1 -1
  272. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.js +2 -1
  273. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.js.map +1 -1
  274. package/dist/components/layout/popover/popover.d.ts +0 -2
  275. package/dist/components/layout/popover/popover.d.ts.map +1 -1
  276. package/dist/components/layout/popover/popover.js +6 -25
  277. package/dist/components/layout/popover/popover.js.map +1 -1
  278. package/dist/components/layout/sheet/sheet.d.ts +0 -2
  279. package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
  280. package/dist/components/layout/sheet/sheet.js +9 -20
  281. package/dist/components/layout/sheet/sheet.js.map +1 -1
  282. package/dist/components/layout/shell/shell.d.ts.map +1 -1
  283. package/dist/components/layout/shell/shell.js +2 -1
  284. package/dist/components/layout/shell/shell.js.map +1 -1
  285. package/dist/components/layout/spacer/spacer.d.ts.map +1 -1
  286. package/dist/components/layout/spacer/spacer.js +2 -1
  287. package/dist/components/layout/spacer/spacer.js.map +1 -1
  288. package/dist/components/layout/split-views/bar-split-view/bar-split-view.d.ts +6 -6
  289. package/dist/components/layout/split-views/bar-split-view/bar-split-view.d.ts.map +1 -1
  290. package/dist/components/layout/split-views/bar-split-view/bar-split-view.js +9 -12
  291. package/dist/components/layout/split-views/bar-split-view/bar-split-view.js.map +1 -1
  292. package/dist/components/layout/split-views/navigation-split-view/navigation-split-view.d.ts.map +1 -1
  293. package/dist/components/layout/split-views/navigation-split-view/navigation-split-view.js +2 -1
  294. package/dist/components/layout/split-views/navigation-split-view/navigation-split-view.js.map +1 -1
  295. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.d.ts.map +1 -1
  296. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js +2 -1
  297. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js.map +1 -1
  298. package/dist/components/layout/split-views/split-view-divider/split-view-divider.d.ts.map +1 -1
  299. package/dist/components/layout/split-views/split-view-divider/split-view-divider.js +2 -1
  300. package/dist/components/layout/split-views/split-view-divider/split-view-divider.js.map +1 -1
  301. package/dist/components/layout/split-views/split-view-pane/split-view-pane.d.ts.map +1 -1
  302. package/dist/components/layout/split-views/split-view-pane/split-view-pane.js +2 -1
  303. package/dist/components/layout/split-views/split-view-pane/split-view-pane.js.map +1 -1
  304. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.d.ts.map +1 -1
  305. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js +2 -1
  306. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js.map +1 -1
  307. package/dist/components/layout/task-board/task-board-column.d.ts.map +1 -1
  308. package/dist/components/layout/task-board/task-board-column.js +2 -4
  309. package/dist/components/layout/task-board/task-board-column.js.map +1 -1
  310. package/dist/components/layout/task-board/task-board.d.ts.map +1 -1
  311. package/dist/components/layout/task-board/task-board.js +4 -3
  312. package/dist/components/layout/task-board/task-board.js.map +1 -1
  313. package/dist/components/layout/window/window.d.ts +0 -1
  314. package/dist/components/layout/window/window.d.ts.map +1 -1
  315. package/dist/components/layout/window/window.js +4 -6
  316. package/dist/components/layout/window/window.js.map +1 -1
  317. package/dist/components/list-item.i18n-89uqlBMK.js +8 -0
  318. package/dist/components/list.i18n-nFB6dZpc.js +13 -0
  319. package/dist/components/lists-and-tables/cells/cell/cell.d.ts.map +1 -1
  320. package/dist/components/lists-and-tables/cells/cell/cell.js +2 -1
  321. package/dist/components/lists-and-tables/cells/cell/cell.js.map +1 -1
  322. package/dist/components/lists-and-tables/cells/description-cell/description-cell.d.ts.map +1 -1
  323. package/dist/components/lists-and-tables/cells/description-cell/description-cell.js +2 -1
  324. package/dist/components/lists-and-tables/cells/description-cell/description-cell.js.map +1 -1
  325. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.d.ts.map +1 -1
  326. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js +2 -1
  327. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js.map +1 -1
  328. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts +1 -0
  329. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts.map +1 -1
  330. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js +3 -1
  331. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js.map +1 -1
  332. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.d.ts.map +1 -1
  333. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js +2 -1
  334. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js.map +1 -1
  335. package/dist/components/lists-and-tables/cells/step-cell/step-cell.d.ts +0 -1
  336. package/dist/components/lists-and-tables/cells/step-cell/step-cell.d.ts.map +1 -1
  337. package/dist/components/lists-and-tables/cells/step-cell/step-cell.js +5 -15
  338. package/dist/components/lists-and-tables/cells/step-cell/step-cell.js.map +1 -1
  339. package/dist/components/lists-and-tables/cells/text-cell/text-cell.d.ts.map +1 -1
  340. package/dist/components/lists-and-tables/cells/text-cell/text-cell.js +2 -1
  341. package/dist/components/lists-and-tables/cells/text-cell/text-cell.js.map +1 -1
  342. package/dist/components/lists-and-tables/cells/title-cell/title-cell.d.ts.map +1 -1
  343. package/dist/components/lists-and-tables/cells/title-cell/title-cell.js +2 -1
  344. package/dist/components/lists-and-tables/cells/title-cell/title-cell.js.map +1 -1
  345. package/dist/components/lists-and-tables/list/list.d.ts +5 -23
  346. package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
  347. package/dist/components/lists-and-tables/list/list.js +53 -98
  348. package/dist/components/lists-and-tables/list/list.js.map +1 -1
  349. package/dist/components/lists-and-tables/list-item/list-item.d.ts +10 -15
  350. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  351. package/dist/components/lists-and-tables/list-item/list-item.js +40 -87
  352. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  353. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts +2 -2
  354. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts.map +1 -1
  355. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js +6 -11
  356. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js.map +1 -1
  357. package/dist/components/lists-and-tables/table/table.d.ts +0 -13
  358. package/dist/components/lists-and-tables/table/table.d.ts.map +1 -1
  359. package/dist/components/lists-and-tables/table/table.js +6 -41
  360. package/dist/components/lists-and-tables/table/table.js.map +1 -1
  361. package/dist/components/navigation/breadcrumbs/breadcrumbs.d.ts.map +1 -1
  362. package/dist/components/navigation/breadcrumbs/breadcrumbs.js +2 -1
  363. package/dist/components/navigation/breadcrumbs/breadcrumbs.js.map +1 -1
  364. package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts.map +1 -1
  365. package/dist/components/navigation/document-tab-bar/document-tab-bar.js +2 -4
  366. package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
  367. package/dist/components/navigation/link/link.d.ts.map +1 -1
  368. package/dist/components/navigation/link/link.js +2 -1
  369. package/dist/components/navigation/link/link.js.map +1 -1
  370. package/dist/components/navigation/link/link.template.js +2 -2
  371. package/dist/components/navigation/menu-bar/menu-bar.d.ts +4 -0
  372. package/dist/components/navigation/menu-bar/menu-bar.d.ts.map +1 -1
  373. package/dist/components/navigation/menu-bar/menu-bar.js +13 -10
  374. package/dist/components/navigation/menu-bar/menu-bar.js.map +1 -1
  375. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts.map +1 -1
  376. package/dist/components/navigation/menu-bar-item/menu-bar-item.js +2 -1
  377. package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
  378. package/dist/components/navigation/pagination/pagination.d.ts.map +1 -1
  379. package/dist/components/navigation/pagination/pagination.js +2 -1
  380. package/dist/components/navigation/pagination/pagination.js.map +1 -1
  381. package/dist/components/navigation/skip-link/skip-link.d.ts.map +1 -1
  382. package/dist/components/navigation/skip-link/skip-link.js +6 -8
  383. package/dist/components/navigation/skip-link/skip-link.js.map +1 -1
  384. package/dist/components/navigation/tab-bar/tab-bar.d.ts +1 -1
  385. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  386. package/dist/components/navigation/tab-bar/tab-bar.js +5 -15
  387. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  388. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts +0 -1
  389. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
  390. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +6 -6
  391. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
  392. package/dist/components/navigation/top-title-bar/top-title-bar.d.ts.map +1 -1
  393. package/dist/components/navigation/top-title-bar/top-title-bar.js +7 -6
  394. package/dist/components/navigation/top-title-bar/top-title-bar.js.map +1 -1
  395. package/dist/components/nl.generated-Ny3Kwppu.js +61 -0
  396. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.d.ts.map +1 -1
  397. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js +2 -1
  398. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js.map +1 -1
  399. package/dist/components/status-and-feedback/badge/badge.d.ts.map +1 -1
  400. package/dist/components/status-and-feedback/badge/badge.js +3 -6
  401. package/dist/components/status-and-feedback/badge/badge.js.map +1 -1
  402. package/dist/components/status-and-feedback/banner/banner.d.ts.map +1 -1
  403. package/dist/components/status-and-feedback/banner/banner.js +2 -1
  404. package/dist/components/status-and-feedback/banner/banner.js.map +1 -1
  405. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.d.ts.map +1 -1
  406. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js +2 -1
  407. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js.map +1 -1
  408. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.d.ts.map +1 -1
  409. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js +2 -1
  410. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js.map +1 -1
  411. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts +0 -3
  412. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts.map +1 -1
  413. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js +2 -14
  414. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js.map +1 -1
  415. package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
  416. package/dist/components/status-and-feedback/notification/notification.js +3 -7
  417. package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
  418. package/dist/components/status-and-feedback/progress-bar/progress-bar.d.ts.map +1 -1
  419. package/dist/components/status-and-feedback/progress-bar/progress-bar.js +4 -5
  420. package/dist/components/status-and-feedback/progress-bar/progress-bar.js.map +1 -1
  421. package/dist/components/status-and-feedback/progress-circle/progress-circle.d.ts.map +1 -1
  422. package/dist/components/status-and-feedback/progress-circle/progress-circle.js +2 -1
  423. package/dist/components/status-and-feedback/progress-circle/progress-circle.js.map +1 -1
  424. package/dist/components/status-and-feedback/status-bar/status-bar.d.ts +1 -1
  425. package/dist/components/status-and-feedback/status-bar/status-bar.d.ts.map +1 -1
  426. package/dist/components/status-and-feedback/status-bar/status-bar.js +8 -7
  427. package/dist/components/status-and-feedback/status-bar/status-bar.js.map +1 -1
  428. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts +0 -7
  429. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts.map +1 -1
  430. package/dist/components/status-and-feedback/step-bar/step-bar.js +2 -24
  431. package/dist/components/status-and-feedback/step-bar/step-bar.js.map +1 -1
  432. package/dist/components/{visibility-mixin-C-K7ho5Q.js → visibility-mixin-DcwzF0_a.js} +1 -7
  433. package/dist/components/{with-translations-DRuOq3QK.js → with-translations-DLzmBSkU.js} +26 -5
  434. package/dist/nldd.min.js +775 -775
  435. package/dist/types/vue.d.ts +76 -6
  436. package/dist/utilities/codemirror/codemirror-input.d.ts +0 -2
  437. package/dist/utilities/codemirror/codemirror-input.d.ts.map +1 -1
  438. package/dist/utilities/codemirror/codemirror-input.js +0 -14
  439. package/dist/utilities/codemirror/codemirror-input.js.map +1 -1
  440. package/dist/utilities/custom-element.d.ts +7 -0
  441. package/dist/utilities/custom-element.d.ts.map +1 -0
  442. package/dist/utilities/custom-element.js +7 -0
  443. package/dist/utilities/custom-element.js.map +1 -0
  444. package/dist/utilities/dev-checks-trigger.d.ts +2 -0
  445. package/dist/utilities/dev-checks-trigger.d.ts.map +1 -0
  446. package/dist/utilities/dev-checks-trigger.js +10 -0
  447. package/dist/utilities/dev-checks-trigger.js.map +1 -0
  448. package/dist/utilities/dev-checks.d.ts +40 -0
  449. package/dist/utilities/dev-checks.d.ts.map +1 -0
  450. package/dist/utilities/dev-checks.js +115 -0
  451. package/dist/utilities/dev-checks.js.map +1 -0
  452. package/dist/utilities/dev-rules.generated.d.ts +3 -0
  453. package/dist/utilities/dev-rules.generated.d.ts.map +1 -0
  454. package/dist/utilities/dev-rules.generated.js +2472 -0
  455. package/dist/utilities/dev-rules.generated.js.map +1 -0
  456. package/dist/utilities/element-state.d.ts +19 -0
  457. package/dist/utilities/element-state.d.ts.map +1 -0
  458. package/dist/utilities/element-state.js +49 -0
  459. package/dist/utilities/element-state.js.map +1 -0
  460. package/dist/utilities/form-associated-mixin.d.ts.map +1 -1
  461. package/dist/utilities/form-associated-mixin.js +2 -1
  462. package/dist/utilities/form-associated-mixin.js.map +1 -1
  463. package/dist/utilities/link-hint.d.ts +2 -21
  464. package/dist/utilities/link-hint.d.ts.map +1 -1
  465. package/dist/utilities/link-hint.js +22 -8
  466. package/dist/utilities/link-hint.js.map +1 -1
  467. package/dist/utilities/spacing-scale.d.ts +4 -5
  468. package/dist/utilities/spacing-scale.d.ts.map +1 -1
  469. package/dist/utilities/spacing-scale.js +4 -23
  470. package/dist/utilities/spacing-scale.js.map +1 -1
  471. package/dist/utilities/translations.d.ts.map +1 -1
  472. package/dist/utilities/translations.js +3 -15
  473. package/dist/utilities/translations.js.map +1 -1
  474. package/dist/utilities/visibility-mixin.d.ts +7 -0
  475. package/dist/utilities/visibility-mixin.d.ts.map +1 -1
  476. package/dist/utilities/visibility-mixin.js +0 -10
  477. package/dist/utilities/visibility-mixin.js.map +1 -1
  478. package/lint/cli.js +18 -0
  479. package/lint/data.generated.json +1 -0
  480. package/lint/engine.js +191 -0
  481. package/lint/fix.js +293 -0
  482. package/lint/format.js +133 -0
  483. package/lint/frontends.js +483 -0
  484. package/lint/linter.js +262 -0
  485. package/lint/main.js +279 -0
  486. package/lint/project.js +143 -0
  487. package/lint/rule-data.js +83 -0
  488. package/lint/rule-index.js +20 -0
  489. package/lint/rule.schema.json +65 -0
  490. package/lint/tree.js +131 -0
  491. package/package.json +21 -4
@@ -0,0 +1,483 @@
1
+ /**
2
+ * Turns source files into normalized trees. One function per template language;
3
+ * rules never see the difference.
4
+ *
5
+ * Bound attributes keep their name and lose their value, so `:selected` on a tab
6
+ * is still seen as `selected`. Wrappers that add nothing to the DOM disappear, or
7
+ * `nldd-list > template[v-for] > nldd-list-item` would break every child selector.
8
+ */
9
+
10
+ import { parseDocument } from 'htmlparser2';
11
+ import {
12
+ BOUND,
13
+ appendChild,
14
+ appendUnknown,
15
+ createNode,
16
+ createRoot,
17
+ isOpaqueTag,
18
+ } from './tree.js';
19
+
20
+ const TRANSPARENT = new Set([
21
+ 'Transition',
22
+ 'TransitionGroup',
23
+ 'KeepAlive',
24
+ 'Suspense',
25
+ 'transition',
26
+ 'transition-group',
27
+ 'keep-alive',
28
+ 'suspense',
29
+ 'Fragment',
30
+ 'React.Fragment',
31
+ 'ng-container',
32
+ ]);
33
+
34
+ const CONDITIONAL = new Set(['v-if', 'v-else', 'v-else-if', '*ngIf']);
35
+ const REPEATED = new Set(['v-for', '*ngFor']);
36
+
37
+ /** A value a template language fills in: `{{ x }}`, `{% x %}`, `${x}`, `<%= x %>` or `{x}`. */
38
+ const TEMPLATE_VALUE = /\{\{|\{%|\$\{|<%|^\{.*\}$/;
39
+
40
+ /** Jinja, Django, Handlebars and Angular control flow, written between the tags. */
41
+ const TEMPLATE_TEXT = /\{%|\{\{|@(if|else|for|switch|defer)\b/;
42
+
43
+ /** Angular markup in an .html file, where `<nldd-x />` does close the element. */
44
+ const ANGULAR = /\*ng[A-Z]|\[\(|\s\[[a-zA-Z.-]+\]=|\s\([a-zA-Z.-]+\)=["']|@(if|for|switch)\s*\(/;
45
+
46
+ /** Anything else cannot be an attribute, so a template language is writing into the tag. */
47
+ const PLAIN_ATTRIBUTE = /^[a-zA-Z_][\w:.-]*$/;
48
+
49
+ function readAttribute(element, name, value) {
50
+ if (CONDITIONAL.has(name)) element.conditional = true;
51
+ else if (REPEATED.has(name)) element.repeated = true;
52
+ else if (name === 'v-show') element.toggled = true;
53
+ else if (name === 'v-bind' || /^(v-bind)?:\[/.test(name)) element.spread = true;
54
+ else if (name === 'v-model') element.attrs.set('value', BOUND);
55
+ else if (name.startsWith('v-model:')) element.attrs.set(name.slice(8), BOUND);
56
+ else if (/^(:|v-bind:|x-bind:|\.|\?)/.test(name)) {
57
+ const bare = name.replace(/^(v-bind|x-bind)?[:.?]/, '').replace(/\.(prop|attr|camel)$/, '');
58
+ element.attrs.set(bare, BOUND);
59
+ } else if (/^\[(class\.|style\.|@)/.test(name)) {
60
+ // Angular's way to set one class, one style or an animation: no attribute.
61
+ } else if (/^\[.+\]$/.test(name)) {
62
+ element.attrs.set(name.replace(/^\[\(?|\)?\]$/g, '').replace(/^attr\./, ''), BOUND);
63
+ } else if (/^(@|#|v-|\(|\*)/.test(name)) {
64
+ // Listeners, directives and template references add no attribute.
65
+ } else if (!PLAIN_ATTRIBUTE.test(name)) {
66
+ element.spread = true;
67
+ element.templated = true;
68
+ } else element.attrs.set(name, TEMPLATE_VALUE.test(value) ? BOUND : value);
69
+ }
70
+
71
+ function hasSlotName(attribs) {
72
+ return Object.keys(attribs).some((name) => name.startsWith('#') || name.startsWith('v-slot'));
73
+ }
74
+
75
+ function readHtmlChildren(children, parent, given) {
76
+ // Control flow and includes are text in .html, so what is around them is uncertain.
77
+ const templated = given.inert && children.some((node) => node.type === 'text' && TEMPLATE_TEXT.test(node.data));
78
+ const inherited = templated ? { ...given, conditional: true } : given;
79
+ if (templated) appendUnknown(parent, children[0].startIndex ?? 0);
80
+ // A Lit hole between the tags can render anything, or nothing.
81
+ const hole = given.lit && children.find((node) => node.type === 'text' && node.data.includes('${'));
82
+ if (hole) appendUnknown(parent, hole.startIndex ?? 0);
83
+ for (const node of children) {
84
+ if (node.type !== 'tag') continue;
85
+ const { name, attribs } = node;
86
+ // In a document, a template is inert until something stamps it out, here or elsewhere.
87
+ if (name === 'template' && inherited.inert) {
88
+ appendUnknown(parent, node.startIndex ?? 0);
89
+ continue;
90
+ }
91
+ // This one stamps out a template from somewhere else.
92
+ if (name === 'ng-container' && Object.keys(attribs).some((key) => /ngTemplateOutlet\]?$/.test(key))) {
93
+ appendUnknown(parent, node.startIndex ?? 0);
94
+ continue;
95
+ }
96
+ const isWrapper = (name === 'template' && !hasSlotName(attribs)) || TRANSPARENT.has(name);
97
+ if (isWrapper) {
98
+ readHtmlChildren(node.children, parent, {
99
+ conditional:
100
+ inherited.conditional || Object.keys(attribs).some((key) => CONDITIONAL.has(key)),
101
+ repeated: inherited.repeated || Object.keys(attribs).some((key) => REPEATED.has(key)),
102
+ inert: inherited.inert,
103
+ lit: inherited.lit,
104
+ });
105
+ continue;
106
+ }
107
+ const element = createNode(name, node.startIndex ?? 0);
108
+ element.endOffset = node.endIndex ?? undefined;
109
+ for (const [key, value] of Object.entries(attribs)) readAttribute(element, key, value);
110
+ element.conditional ||= inherited.conditional;
111
+ element.repeated ||= inherited.repeated;
112
+ element.opaque = isOpaqueTag(name) || name === 'template';
113
+ appendChild(parent, element);
114
+ readHtmlChildren(node.children, element, { inert: inherited.inert, lit: inherited.lit });
115
+ }
116
+ }
117
+
118
+ function parseMarkup(source, { selfClosing }) {
119
+ return parseDocument(source, {
120
+ lowerCaseTags: false,
121
+ lowerCaseAttributeNames: false,
122
+ recognizeSelfClosing: selfClosing,
123
+ withStartIndices: true,
124
+ withEndIndices: true,
125
+ });
126
+ }
127
+
128
+ const OPENS_BLOCK = /^\{%-?\s*(if|for|with|block|macro|call|filter|autoescape|trans|blocktrans)\b/;
129
+ const CLOSES_BLOCK = /^\{%-?\s*end/;
130
+
131
+ /** Same length, so positions stay right. */
132
+ const blank = (text) => text.replace(/[^\n]/g, ' ');
133
+
134
+ /**
135
+ * Jinja and Django write into a tag, where an HTML parser reads them as markup:
136
+ * `<nldd-field{% if x %} hidden{% endif %}>` would be a tag called `nldd-field{%`.
137
+ * Between the quotes of a value this leaves something that reads as bound. Loose
138
+ * in a tag it leaves a name that cannot be an attribute, so the element counts as
139
+ * spread, and a whole `{% if %}` block goes: what is in it may not be there.
140
+ */
141
+ function quietTemplateTags(source) {
142
+ const text = source
143
+ .replace(/\{#[\s\S]*?#\}|\{%-?\s*comment\b[\s\S]*?\{%-?\s*endcomment\s*-?%\}/g, blank)
144
+ // A name the template fills in is a tag nobody can check.
145
+ .replace(/(<\/?)([a-zA-Z][\w-]*\{\{.*?\}\}[\w-]*)/g, (_, open, name) => `${open}x-${'x'.repeat(name.length - 2)}`);
146
+ let out = '';
147
+ let at = 0;
148
+ let inTag = false;
149
+ let quote = '';
150
+ let depth = 0;
151
+ while (at < text.length) {
152
+ const close = text.startsWith('{%', at) ? '%}' : text.startsWith('{{', at) ? '}}' : '';
153
+ const end = close ? text.indexOf(close, at) : -1;
154
+ if (end !== -1) {
155
+ const piece = text.slice(at, end + 2);
156
+ if (!inTag) out += piece.replace(/[<>]/g, ' ');
157
+ else if (quote) out += `{{${'x'.repeat(piece.length - 4)}}}`;
158
+ else {
159
+ if (close === '%}' && OPENS_BLOCK.test(piece)) depth += 1;
160
+ if (close === '%}' && CLOSES_BLOCK.test(piece)) depth = Math.max(0, depth - 1);
161
+ out += ' {%%}'.slice(0, piece.length).padEnd(piece.length);
162
+ }
163
+ at = end + 2;
164
+ continue;
165
+ }
166
+ const char = text[at];
167
+ if (!inTag) {
168
+ const raw = char === '<' && /^<(script|style)[\s>]/i.exec(text.slice(at, at + 8));
169
+ const skip = raw ? text.toLowerCase().indexOf(`</${raw[1].toLowerCase()}`, at) : text.startsWith('<!--', at) ? text.indexOf('-->', at) : -1;
170
+ if (skip !== -1) {
171
+ out += text.slice(at, skip);
172
+ at = skip;
173
+ continue;
174
+ }
175
+ inTag = char === '<' && /[a-zA-Z]/.test(text[at + 1] ?? '');
176
+ } else if (quote) {
177
+ if (char === quote) quote = '';
178
+ } else if (char === '"' || char === "'") {
179
+ quote = char;
180
+ } else if (char === '>') {
181
+ inTag = false;
182
+ depth = 0;
183
+ }
184
+ out += depth > 0 && inTag && char !== '\n' ? ' ' : char;
185
+ at += 1;
186
+ }
187
+ return out;
188
+ }
189
+
190
+ const quietIfTemplated = (source) => (/\{[%{#]/.test(source) ? quietTemplateTags(source) : source);
191
+
192
+ export function parseHtml(source) {
193
+ const root = createRoot({ closed: /<html[\s>]/i.test(source) });
194
+ readHtmlChildren(parseMarkup(quietIfTemplated(source), { selfClosing: ANGULAR.test(source) }).children, root, { inert: true });
195
+ return [root];
196
+ }
197
+
198
+ export function parseVue(source) {
199
+ const documentNode = parseMarkup(source, { selfClosing: true });
200
+ const template = documentNode.children.find(
201
+ (node) => node.type === 'tag' && node.name === 'template',
202
+ );
203
+ if (!template) return [];
204
+ const root = createRoot();
205
+ readHtmlChildren(template.children, root, {});
206
+ return [root];
207
+ }
208
+
209
+ /** Every code block and inline tag in a Markdown file is a tree of its own. */
210
+ export function parseMarkdown(source) {
211
+ const roots = [];
212
+ const read = (text, offset) => {
213
+ const root = createRoot();
214
+ const padded = ' '.repeat(offset) + quietIfTemplated(text);
215
+ readHtmlChildren(parseMarkup(padded, { selfClosing: true }).children, root, {});
216
+ roots.push(root);
217
+ };
218
+ const fences = /^( *)```[^\n]*\n([\s\S]*?)^ *```/gm;
219
+ for (const match of source.matchAll(fences)) {
220
+ if (match[2].includes('<nldd-')) read(match[2], match.index + match[0].indexOf('\n') + 1);
221
+ }
222
+ const prose = source.replace(fences, (block) => ' '.repeat(block.length));
223
+ // A bare `<nldd-button>` in a sentence names the tag and says nothing about its attributes.
224
+ for (const match of prose.matchAll(/`(<nldd-[^`\n]*)`/g)) {
225
+ read(match[1].replace(/^<([a-z-]+)\s*\/?>$/, '<$1 v-bind="x"><Mention /></$1>'), match.index + 1);
226
+ }
227
+ return roots;
228
+ }
229
+
230
+ /**
231
+ * Finds every html`` template, also inside the holes of another. A small scanner,
232
+ * so that a story needs no TypeScript parser: it only tells strings, comments and
233
+ * templates apart.
234
+ */
235
+ function litTemplates(source) {
236
+ const templates = [];
237
+ const skipString = (start) => {
238
+ let at = start + 1;
239
+ while (at < source.length && source[at] !== source[start] && source[at] !== '\n') {
240
+ at += source[at] === '\\' ? 2 : 1;
241
+ }
242
+ return at;
243
+ };
244
+ const readTemplate = (start, isHtml) => {
245
+ const holes = [];
246
+ let at = start;
247
+ while (at < source.length && source[at] !== '`') {
248
+ if (source[at] === '\\') at += 2;
249
+ else if (source.startsWith('${', at)) {
250
+ const end = readCode(at + 2, true);
251
+ holes.push([at, end + 1]);
252
+ at = end + 1;
253
+ } else at += 1;
254
+ }
255
+ if (isHtml) templates.push({ start, end: at, holes });
256
+ return at;
257
+ };
258
+ function readCode(start, inHole) {
259
+ let depth = 0;
260
+ let at = start;
261
+ while (at < source.length) {
262
+ const char = source[at];
263
+ if (char === "'" || char === '"') at = skipString(at);
264
+ else if (source.startsWith('//', at)) at = source.indexOf('\n', at) >>> 0;
265
+ else if (source.startsWith('/*', at)) at = source.indexOf('*/', at) >>> 0;
266
+ else if (char === '`') at = readTemplate(at + 1, source.slice(at - 4, at) === 'html');
267
+ else if (char === '{') depth += 1;
268
+ else if (char === '}') {
269
+ if (inHole && depth === 0) return at;
270
+ depth -= 1;
271
+ }
272
+ at += 1;
273
+ }
274
+ return at;
275
+ }
276
+ readCode(0, false);
277
+ return templates;
278
+ }
279
+
280
+ /**
281
+ * Lit in a .ts file. A hole gets a filler of the same length without spaces, so
282
+ * positions stay right, an unquoted value stays one value, and it reads as bound.
283
+ */
284
+ export function parseLit(source) {
285
+ return litTemplates(source).flatMap(({ start, end, holes }) => {
286
+ let text = source.slice(start, end);
287
+ if (!text.includes('<nldd-')) return [];
288
+ for (const [from, to] of holes) {
289
+ const filler = `\${${'x'.repeat(to - from - 3)}}`;
290
+ text = text.slice(0, from - start) + filler + text.slice(to - start);
291
+ }
292
+ const root = createRoot();
293
+ const padded = ' '.repeat(start) + text;
294
+ readHtmlChildren(parseMarkup(padded, { selfClosing: false }).children, root, { lit: true });
295
+ return [root];
296
+ });
297
+ }
298
+
299
+ function jsxName(node) {
300
+ if (node.type === 'JSXIdentifier') return node.name;
301
+ if (node.type === 'JSXMemberExpression') return `${jsxName(node.object)}.${node.property.name}`;
302
+ return `${node.namespace.name}:${node.name.name}`;
303
+ }
304
+
305
+ function collectJsx(node, found) {
306
+ if (!node || typeof node !== 'object') return;
307
+ if (Array.isArray(node)) {
308
+ for (const item of node) collectJsx(item, found);
309
+ } else if (node.type === 'JSXElement' || node.type === 'JSXFragment') {
310
+ found.push(node);
311
+ } else {
312
+ for (const key of Object.keys(node)) collectJsx(node[key], found);
313
+ }
314
+ }
315
+
316
+ /** `undefined` means the attribute is not there: `x={false}` and `x={null}` switch it off. */
317
+ function staticJsxValue(value) {
318
+ if (value === null) return '';
319
+ if (value.type === 'Literal') return String(value.value);
320
+ if (value.type !== 'JSXExpressionContainer') return BOUND;
321
+ const { expression } = value;
322
+ if (expression.type === 'Literal') {
323
+ if (expression.value === false || expression.value === null) return undefined;
324
+ return expression.value === true ? '' : String(expression.value);
325
+ }
326
+ if (expression.type === 'TemplateLiteral' && expression.expressions.length === 0) {
327
+ return expression.quasis[0].value.cooked;
328
+ }
329
+ return BOUND;
330
+ }
331
+
332
+ /** Props React keeps to itself: they never reach the element. */
333
+ const REACT_ONLY = new Set(['key', 'ref', 'dangerouslySetInnerHTML', 'suppressHydrationWarning', 'suppressContentEditableWarning']);
334
+
335
+ function readJsxAttributes(element, attributes, roots) {
336
+ for (const attribute of attributes) {
337
+ if (attribute.type === 'JSXSpreadAttribute') {
338
+ element.spread = true;
339
+ continue;
340
+ }
341
+ const name = jsxName(attribute.name);
342
+ const isHandler = /^on[A-Z]/.test(name) || REACT_ONLY.has(name);
343
+ const value = staticJsxValue(attribute.value);
344
+ if (!isHandler && value !== undefined) element.attrs.set(name === 'className' ? 'class' : name, value);
345
+ // An element passed as a prop renders elsewhere, so it is a tree of its own.
346
+ const nested = [];
347
+ collectJsx(attribute.value, nested);
348
+ for (const node of nested) roots.push(jsxTree(node, roots));
349
+ }
350
+ }
351
+
352
+ function readJsxExpression(expression, parent, flags, roots) {
353
+ const conditional = { ...flags, conditional: true };
354
+ switch (expression.type) {
355
+ case 'JSXElement':
356
+ case 'JSXFragment':
357
+ readJsxNode(expression, parent, flags, roots);
358
+ break;
359
+ case 'JSXEmptyExpression':
360
+ case 'Literal':
361
+ case 'TemplateLiteral':
362
+ break;
363
+ case 'LogicalExpression':
364
+ // The left of `a && <x />` renders nothing worth counting.
365
+ if (expression.operator !== '&&') readJsxExpression(expression.left, parent, conditional, roots);
366
+ readJsxExpression(expression.right, parent, conditional, roots);
367
+ break;
368
+ case 'ConditionalExpression':
369
+ readJsxExpression(expression.consequent, parent, conditional, roots);
370
+ readJsxExpression(expression.alternate, parent, conditional, roots);
371
+ break;
372
+ case 'ParenthesizedExpression':
373
+ readJsxExpression(expression.expression, parent, flags, roots);
374
+ break;
375
+ case 'CallExpression': {
376
+ const found = [];
377
+ collectJsx(expression, found);
378
+ if (found.length === 0) appendUnknown(parent, expression.start);
379
+ for (const node of found) {
380
+ readJsxNode(node, parent, { ...flags, repeated: true }, roots);
381
+ }
382
+ break;
383
+ }
384
+ default:
385
+ appendUnknown(parent, expression.start);
386
+ }
387
+ }
388
+
389
+ function readJsxChildren(children, parent, flags, roots) {
390
+ for (const child of children) {
391
+ if (child.type === 'JSXElement' || child.type === 'JSXFragment') {
392
+ readJsxNode(child, parent, flags, roots);
393
+ } else if (child.type === 'JSXExpressionContainer') {
394
+ readJsxExpression(child.expression, parent, flags, roots);
395
+ } else if (child.type === 'JSXSpreadChild') {
396
+ appendUnknown(parent, child.start);
397
+ }
398
+ }
399
+ }
400
+
401
+ function readJsxNode(node, parent, flags, roots) {
402
+ if (node.type === 'JSXFragment') {
403
+ readJsxChildren(node.children, parent, flags, roots);
404
+ return;
405
+ }
406
+ const name = jsxName(node.openingElement.name);
407
+ if (TRANSPARENT.has(name)) {
408
+ readJsxChildren(node.children, parent, flags, roots);
409
+ return;
410
+ }
411
+ const element = createNode(name, node.start);
412
+ element.endOffset = node.end - 1;
413
+ element.conditional = Boolean(flags.conditional);
414
+ element.repeated = Boolean(flags.repeated);
415
+ element.opaque = isOpaqueTag(name);
416
+ readJsxAttributes(element, node.openingElement.attributes, roots);
417
+ appendChild(parent, element);
418
+ readJsxChildren(node.children, element, {}, roots);
419
+ }
420
+
421
+ function jsxTree(node, roots) {
422
+ const root = createRoot();
423
+ readJsxNode(node, root, {}, roots);
424
+ return root;
425
+ }
426
+
427
+ let oxcParser;
428
+
429
+ export async function parseJsx(source, filename) {
430
+ oxcParser ??= await import('oxc-parser').catch(() => {
431
+ throw new Error(`Reading ${filename} needs the optional dependency oxc-parser, which needs Node 20.19 or newer.`);
432
+ });
433
+ const { program, errors } = oxcParser.parseSync(filename, source);
434
+ const found = [];
435
+ collectJsx(program, found);
436
+ const roots = [];
437
+ for (const node of found) roots.push(jsxTree(node, roots));
438
+ if (errors?.length) {
439
+ roots.syntaxError = { message: errors[0].message, offset: errors[0].labels?.[0]?.start ?? 0 };
440
+ }
441
+ return roots;
442
+ }
443
+
444
+ /** Names a framework wrapper by the tag it renders, with kebab-case props. */
445
+ export function applyWrappers(roots, wrappers) {
446
+ const visit = (node) => {
447
+ const tag = wrappers[node.name];
448
+ if (tag) {
449
+ node.name = tag;
450
+ node.opaque = false;
451
+ node.wrapped = true;
452
+ node.attrs = new Map(
453
+ [...node.attrs].map(([name, value]) => [
454
+ name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`),
455
+ value,
456
+ ]),
457
+ );
458
+ }
459
+ node.children.forEach(visit);
460
+ };
461
+ roots.forEach(visit);
462
+ return roots;
463
+ }
464
+
465
+ const PARSERS = {
466
+ '.html': parseHtml,
467
+ '.htm': parseHtml,
468
+ '.j2': parseHtml,
469
+ '.jinja': parseHtml,
470
+ '.jinja2': parseHtml,
471
+ '.vue': parseVue,
472
+ '.md': parseMarkdown,
473
+ '.jsx': parseJsx,
474
+ '.tsx': parseJsx,
475
+ '.ts': parseLit,
476
+ };
477
+
478
+ /** @returns {Promise<import('./tree.js').TreeNode[]>} */
479
+ export async function parseSource(source, filename) {
480
+ const extension = filename.slice(filename.lastIndexOf('.'));
481
+ const parser = PARSERS[extension];
482
+ return parser ? parser(source, filename) : [];
483
+ }