@nldd/design-system 0.21.0 → 0.22.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 (452) hide show
  1. package/custom-elements.json +864 -232
  2. package/dist/cdn/autoloader.js +136 -136
  3. package/dist/cdn/chunks/{activity-indicator-JglZJ8dh.js → activity-indicator-BTnpfsIt.js} +22 -22
  4. package/dist/cdn/chunks/{avatar-ASqePVhU.js → avatar--5c37XVW.js} +44 -43
  5. package/dist/cdn/chunks/{avatar-group-rknt4FBO.js → avatar-group-BNfmY5CU.js} +41 -41
  6. package/dist/cdn/chunks/{badge-Cc2Nufoc.js → badge-YAvIVoRy.js} +28 -28
  7. package/dist/cdn/chunks/{banner-BLVKM07M.js → banner-BpCK57yd.js} +41 -37
  8. package/dist/cdn/chunks/{bar-split-view-Clbg-p9H.js → bar-split-view-BgYo4YJw.js} +27 -27
  9. package/dist/cdn/chunks/blockquote-BOu-31f3.js +240 -0
  10. package/dist/cdn/chunks/{box-WkhyjQVy.js → box-YipFNjJh.js} +7 -7
  11. package/dist/cdn/chunks/{breadcrumbs-D9YxZzRj.js → breadcrumbs-DSVAVozW.js} +33 -33
  12. package/dist/cdn/chunks/{button-DO90Lo6q.js → button-XtEOeBEq.js} +101 -100
  13. package/dist/cdn/chunks/{button-bar-Bxgdbyh3.js → button-bar-D1i71rRQ.js} +13 -13
  14. package/dist/cdn/chunks/{button-group-BYGPPLmZ.js → button-group-un5QDbqK.js} +10 -10
  15. package/dist/cdn/chunks/{card-BP0jfOkS.js → card-D5yTAdts.js} +22 -22
  16. package/dist/cdn/chunks/{cell-BRD2ilQh.js → cell-BbtB9C2Z.js} +24 -23
  17. package/dist/cdn/chunks/{checkbox-field-DDZ-B6vH.js → checkbox-field-Cmc6Aagc.js} +33 -30
  18. package/dist/cdn/chunks/{checkbox-Cazx8CQn.js → checkbox-oYX8b8iy.js} +28 -27
  19. package/dist/cdn/chunks/{class-map-CXSdNjt8.js → class-map-DKd4N9Wz.js} +1 -1
  20. package/dist/cdn/chunks/{code-editor-D6Q55oaY.js → code-editor-BZwpTu4O.js} +55 -57
  21. package/dist/cdn/chunks/{code-viewer-DspLH2T1.js → code-viewer-C4XDF03i.js} +75 -75
  22. package/dist/cdn/chunks/{codemirror-input-Db65x22n.js → codemirror-input-Sen5OmAF.js} +5 -5
  23. package/dist/cdn/chunks/{collection-NVtkvDls.js → collection-BnZstW7U.js} +36 -36
  24. package/dist/cdn/chunks/{combo-box-DyBQSaQl.js → combo-box-BpaGeypm.js} +68 -68
  25. package/dist/cdn/chunks/{container-rrbwk0z4.js → container-DuV5d7Eb.js} +51 -51
  26. package/dist/cdn/chunks/{custom-element-q6NzoL5b.js → custom-element-DsfOrnOD.js} +1 -1
  27. package/dist/cdn/chunks/{date-field-Clti_wKN.js → date-field-FactdbhC.js} +125 -117
  28. package/dist/cdn/chunks/{date-picker-2TCQLd5D.js → date-picker-BtlBTKvh.js} +78 -78
  29. package/dist/cdn/chunks/{decorate-TduJMFD_.js → decorate-CJCfz_g6.js} +2 -2
  30. package/dist/cdn/chunks/{described-by-mixin-daRE7orX.js → described-by-mixin-CPultP0p.js} +2 -2
  31. package/dist/cdn/chunks/{description-cell-CQwOj_rN.js → description-cell-DFc0_dWI.js} +24 -23
  32. package/dist/cdn/chunks/{dev-checks-zW_W-hnh.js → dev-checks-DGwOQoR3.js} +76 -26
  33. package/dist/cdn/chunks/{dist-EgIBI-FG.js → dist-6xUfJUfa.js} +26 -26
  34. package/dist/cdn/chunks/{dist-A7_1pHX0.js → dist-AQ1Gehx3.js} +25 -25
  35. package/dist/cdn/chunks/{dist-DPUBF0MZ.js → dist-BUqkX3a-.js} +362 -371
  36. package/dist/cdn/chunks/{dist-Rm6FvrSR.js → dist-BWSiWu4t.js} +55 -55
  37. package/dist/cdn/chunks/{dist-CP3G1pSK.js → dist-Bmb_H8Sp.js} +1 -1
  38. package/dist/cdn/chunks/{dist-DrTzvgE7.js → dist-BuquxOFD.js} +178 -188
  39. package/dist/cdn/chunks/{dist-EM4MWLQq.js → dist-CM5DHMaz.js} +120 -125
  40. package/dist/cdn/chunks/{dist-C_dGY6zR.js → dist-ClsiJytN.js} +43 -43
  41. package/dist/cdn/chunks/{dist-D2qap2OY.js → dist-CtdONv3x.js} +13 -13
  42. package/dist/cdn/chunks/{dist-ChmCRv39.js → dist-CxdoWiwX.js} +50 -50
  43. package/dist/cdn/chunks/{dist-BEfLdOvy.js → dist-D-9cbJjq.js} +190 -196
  44. package/dist/cdn/chunks/{divider-CCNbnplA.js → divider-CZ8Hn1om.js} +6 -6
  45. package/dist/cdn/chunks/{document-tab-bar-CUc4WWY3.js → document-tab-bar-BBnyyiEA.js} +56 -56
  46. package/dist/cdn/chunks/{dropdown-DZTZtkm5.js → dropdown-Bbbgy8mT.js} +31 -31
  47. package/dist/cdn/chunks/{file-field-Bff6_1pp.js → file-field-CddG_e0F.js} +116 -116
  48. package/dist/cdn/chunks/{form-hXLgy_tY.js → form-DIIMIq0q.js} +23 -9
  49. package/dist/cdn/chunks/{form-actions-C_7hINq-.js → form-actions-BICy0Sgp.js} +7 -7
  50. package/dist/cdn/chunks/{form-associated-mixin--GIbl98p.js → form-associated-mixin-BtStDDYA.js} +14 -3
  51. package/dist/cdn/chunks/{form-field--4nWJ_DK.js → form-field-Bnei2EQO.js} +36 -36
  52. package/dist/cdn/chunks/{form-section-By-D4un0.js → form-section-Cv0tr0pm.js} +1 -1
  53. package/dist/cdn/chunks/{full-bleed-section-Dg4sIJG1.js → full-bleed-section-LOfo_1Aj.js} +10 -10
  54. package/dist/cdn/chunks/{hero-CQQMNCT_.js → hero-BABWpYs5.js} +48 -48
  55. package/dist/cdn/chunks/{icon-BORlalt0.js → icon-D5dJm51v.js} +41 -47
  56. package/dist/cdn/chunks/{icon-button-rKiIHs7A.js → icon-button-DtxIRaQy.js} +80 -79
  57. package/dist/cdn/chunks/{icon-cell-rk4NQid2.js → icon-cell-Be5awZV7.js} +26 -24
  58. package/dist/cdn/chunks/{identity-Cg1l0HhB.js → identity-B4KtbT8h.js} +26 -26
  59. package/dist/cdn/chunks/{if-defined-CaKKERku.js → if-defined-BirFs11D.js} +1 -1
  60. package/dist/cdn/chunks/{image-DZMW6JgL.js → image-BpVEir6U.js} +66 -61
  61. package/dist/cdn/chunks/{inline-dialog-WlqtPBPJ.js → inline-dialog-B627fZmT.js} +29 -28
  62. package/dist/cdn/chunks/{just-in-time-education-DRcb5g7x.js → just-in-time-education-Nw5ido3N.js} +44 -48
  63. package/dist/cdn/chunks/{kanban-Ca_mfqsA.js → kanban-9HGexCJx.js} +24 -24
  64. package/dist/cdn/chunks/{kanban-column-fgIMc7pw.js → kanban-column-v5rfv8fN.js} +13 -13
  65. package/dist/cdn/chunks/{keyboard-shortcut-EknnW7Ub.js → keyboard-shortcut-CVNilmgr.js} +20 -20
  66. package/dist/cdn/chunks/{languages-yKikVFv_.js → languages-Ce4h7R1-.js} +12 -12
  67. package/dist/cdn/chunks/{link-FBSAJ3UC.js → link-BQQwp17j.js} +36 -36
  68. package/dist/cdn/chunks/{link-group-90qVfKa0.js → link-group-CQhEcQIV.js} +11 -11
  69. package/dist/cdn/chunks/{list-CaWl3q0Z.js → list-DDxjOe38.js} +41 -39
  70. package/dist/cdn/chunks/{list-item-Cagnf6eG.js → list-item-Da6-fFDs.js} +131 -77
  71. package/dist/cdn/chunks/{list-item-segment-BRzBF1y_.js → list-item-segment-CnGHU6G-.js} +44 -44
  72. package/dist/cdn/chunks/{menu-bar-0NFXvq-v.js → menu-bar-MPNB2ovW.js} +21 -21
  73. package/dist/cdn/chunks/{menu-bar-item-DGSC_ETi.js → menu-bar-item-BuZ-VvnR.js} +34 -34
  74. package/dist/cdn/chunks/{menu-divider-CLLRgMll.js → menu-divider-CcOTQxx5.js} +6 -6
  75. package/dist/cdn/chunks/{menu-group-BL24ChpR.js → menu-group-DGgbYejF.js} +8 -8
  76. package/dist/cdn/chunks/{menu-item-CooKfrFa.js → menu-item-DgM4RmyD.js} +28 -28
  77. package/dist/cdn/chunks/{menu-BOu_pD1Q.js → menu-uOExHS1i.js} +58 -57
  78. package/dist/cdn/chunks/{menu.template-C6rbfI-u.js → menu.template-DkbfQRQ6.js} +3 -3
  79. package/dist/cdn/chunks/{modal-dialog-BrUMP4Jm.js → modal-dialog-BRYfJ7Vf.js} +26 -26
  80. package/dist/cdn/chunks/{multi-line-text-field-D7hXhyOn.js → multi-line-text-field-CWOPY6sF.js} +47 -47
  81. package/dist/cdn/chunks/{navigation-split-view-B2ZQhxEb.js → navigation-split-view-BRiplUXM.js} +37 -37
  82. package/dist/cdn/chunks/nl.generated-fkFCex7n.js +112 -0
  83. package/dist/cdn/chunks/{notification-DSGP14d1.js → notification-DhnzrUQp.js} +25 -25
  84. package/dist/cdn/chunks/{number-field-B8op14Y_.js → number-field-DgRrXCiv.js} +39 -39
  85. package/dist/cdn/chunks/{one-half-one-half-section-ZYmHYf4Q.js → one-half-one-half-section-D7tzDw-p.js} +11 -11
  86. package/dist/cdn/chunks/{one-third-two-thirds-section-Ds10K6AS.js → one-third-two-thirds-section-E8xOdcsf.js} +11 -11
  87. package/dist/cdn/chunks/{one-time-code-field-Cgy_tTS4.js → one-time-code-field-BoJdVvNN.js} +54 -54
  88. package/dist/cdn/chunks/{page-CBf_Decp.js → page-DDm193hL.js} +27 -27
  89. package/dist/cdn/chunks/{page-footer-CSv1dU7M.js → page-footer-32oZSwvG.js} +46 -61
  90. package/dist/cdn/chunks/{page-section-mixin-Dp6X8GKd.js → page-section-mixin-CmsW9L1S.js} +2 -2
  91. package/dist/cdn/chunks/{pagination-CMUcFB53.js → pagination-Co1BlFTP.js} +45 -45
  92. package/dist/cdn/chunks/{password-field-C76Vm3rm.js → password-field-BxKQRE4K.js} +54 -54
  93. package/dist/cdn/chunks/{popover-C-CVVtfl.js → popover-DpCE_XjR.js} +92 -58
  94. package/dist/cdn/chunks/{progress-bar-BLiHaRUS.js → progress-bar-5WAVf0HV.js} +53 -53
  95. package/dist/cdn/chunks/{progress-circle-CjkovRbL.js → progress-circle-D7Mn6WZv.js} +55 -55
  96. package/dist/cdn/chunks/{radio-button-field-C-Z6Lnd4.js → radio-button-field-Dxnahic-.js} +25 -25
  97. package/dist/cdn/chunks/{radio-button-group-ChTqBCnQ.js → radio-button-group-D_4lI2U-.js} +18 -18
  98. package/dist/cdn/chunks/{radio-button-GHyO-GQB.js → radio-button-pd8lwtEO.js} +29 -29
  99. package/dist/cdn/chunks/{render-marked-DX_5ISZE.js → render-marked-CAskRZMx.js} +1 -1
  100. package/dist/cdn/chunks/{drag-handle-cell-CbzDYebG.js → reorder-handle-cell-BL8ECfi5.js} +38 -37
  101. package/dist/cdn/chunks/reorder-handle-cell.i18n-DlH2aVwd.js +3 -0
  102. package/dist/cdn/chunks/reorder-handle-mixin-BDRPLv58.js +16 -0
  103. package/dist/cdn/chunks/{repeat-Ch_5OsXE.js → repeat-D5W3dDCY.js} +1 -1
  104. package/dist/cdn/chunks/{return-focus-Xmagtk6r.js → return-focus-BzZWhXhc.js} +21 -16
  105. package/dist/cdn/chunks/rich-text-diNxNddp.js +61 -0
  106. package/dist/cdn/chunks/rolldown-runtime-CGnMp29N.js +10 -0
  107. package/dist/cdn/chunks/{row-header-mixin-CgqvREoV.js → row-header-mixin-Dj6t4nYI.js} +2 -2
  108. package/dist/cdn/chunks/{search-field-BGNfERhn.js → search-field-CLuQnvBU.js} +67 -67
  109. package/dist/cdn/chunks/{segmented-control-BYAG4VRp.js → segmented-control-B0z5J7r9.js} +86 -82
  110. package/dist/cdn/chunks/{shadow-resets-6SToDsPu.js → shadow-resets-BeVmf7ky.js} +2 -2
  111. package/dist/cdn/chunks/{sheet-BdVCqm2H.js → sheet-CKfFzUCu.js} +22 -22
  112. package/dist/cdn/chunks/{shell-C9rds_D9.js → shell-CglPjEWB.js} +7 -7
  113. package/dist/cdn/chunks/{side-by-side-split-view-C5oX4c6Z.js → side-by-side-split-view-DU4ODEBX.js} +21 -21
  114. package/dist/cdn/chunks/{sidebar-section-DP4jnS7g.js → sidebar-section-DzJw-MHs.js} +29 -29
  115. package/dist/cdn/chunks/{simple-section-qrCqXeBa.js → simple-section-BfhBYqMa.js} +12 -12
  116. package/dist/cdn/chunks/{skip-link-DWh4W6-J.js → skip-link-DwVvD9XL.js} +19 -19
  117. package/dist/cdn/chunks/{slider--hODfOwh.js → slider-BBxKxr-H.js} +86 -82
  118. package/dist/cdn/chunks/{spacer-CFzq_JCh.js → spacer-CqK1xVh2.js} +11 -11
  119. package/dist/cdn/chunks/{spacer-cell-DuVOgIj8.js → spacer-cell-DS7Tphdm.js} +13 -12
  120. package/dist/cdn/chunks/{split-button-BeXnOUTt.js → split-button-Brh7EmIA.js} +32 -32
  121. package/dist/cdn/chunks/{split-view-divider-jzcPmnMh.js → split-view-divider-Bh3XLobi.js} +10 -10
  122. package/dist/cdn/chunks/{split-view-pane-BLsZz263.js → split-view-pane-BPKlAR4d.js} +13 -13
  123. package/dist/cdn/chunks/{stacked-split-view-CcOR8LrJ.js → stacked-split-view-SrIHWkKW.js} +20 -20
  124. package/dist/cdn/chunks/{static-html-Cf4ccUIg.js → static-html-OvWm15yg.js} +1 -1
  125. package/dist/cdn/chunks/{status-bar-CINbOihq.js → status-bar-IqyLnoMx.js} +24 -24
  126. package/dist/cdn/chunks/{step-bar-6FvZL1Ti.js → step-bar-DltkU-AG.js} +56 -56
  127. package/dist/cdn/chunks/{step-cell-CejRisgS.js → step-cell-BHW3t6nn.js} +40 -39
  128. package/dist/cdn/chunks/{stepper-CY2rJWOJ.js → stepper-DMlk7A-Y.js} +30 -30
  129. package/dist/cdn/chunks/{style-map-DsIw6lkq.js → style-map-CNYX1L3t.js} +1 -1
  130. package/dist/cdn/chunks/{swatch-picker-BY3DBIl6.js → swatch-picker-BAKkJFgt.js} +47 -47
  131. package/dist/cdn/chunks/{switch-DDSsZFwK.js → switch-B3d_1Leh.js} +27 -26
  132. package/dist/cdn/chunks/{switch-field-CMoM9I38.js → switch-field-BXJj1PHC.js} +47 -28
  133. package/dist/cdn/chunks/{tab-bar-DmslEoPD.js → tab-bar-C7T0XL0u.js} +70 -70
  134. package/dist/cdn/chunks/{table-DwXjCSD5.js → table-CVyPmXfX.js} +31 -31
  135. package/dist/cdn/chunks/{tag-DM3APy3B.js → tag-KdbJbRcK.js} +25 -25
  136. package/dist/cdn/chunks/{text-cell-BkEsGI3g.js → text-cell-CUH5Tf5F.js} +43 -42
  137. package/dist/cdn/chunks/{text-editor-BvTiMeNV.js → text-editor-Bsfygq28.js} +71 -71
  138. package/dist/cdn/chunks/{text-field-CUyh1-V8.js → text-field-BQxQe0ch.js} +56 -56
  139. package/dist/cdn/chunks/{text-B1CatNR1.js → text-lQLJJw1m.js} +45 -45
  140. package/dist/cdn/chunks/{time-field-Cj5WojfO.js → time-field-kdMQ7qaa.js} +123 -113
  141. package/dist/cdn/chunks/{time-picker-W0xYXLy8.js → time-picker-T1bZ4zxP.js} +86 -79
  142. package/dist/cdn/chunks/{title-cell-8d8psUBX.js → title-cell-CyJr9OiV.js} +61 -63
  143. package/dist/cdn/chunks/{title-BuT7tWqN.js → title-yXmufzsm.js} +110 -74
  144. package/dist/cdn/chunks/{toggle-button-DNXWXZpE.js → toggle-button-DiZaFEAk.js} +74 -74
  145. package/dist/cdn/chunks/{toggle-button-group-ByowJYgs.js → toggle-button-group-DRai7q0C.js} +20 -20
  146. package/dist/cdn/chunks/{token-CnkEB3hB.js → token-C6EudIjw.js} +30 -30
  147. package/dist/cdn/chunks/{token-field-hvDB3l6O.js → token-field-OCw3wLIW.js} +69 -69
  148. package/dist/cdn/chunks/{toolbar-iNd1VmuG.js → toolbar-K5UY_y15.js} +26 -26
  149. package/dist/cdn/chunks/{toolbar-item-DpPfPxCi.js → toolbar-item-CI3OVQuq.js} +13 -13
  150. package/dist/cdn/chunks/{toolbar-title-KBMpfL9d.js → toolbar-title-xvfrEhvQ.js} +31 -31
  151. package/dist/cdn/chunks/{toolbar.styles-BQkG4gVc.js → toolbar.styles-BBj5j7Iq.js} +3 -3
  152. package/dist/cdn/chunks/{tooltip-BsAHJjci.js → tooltip-B6XDYQNn.js} +42 -45
  153. package/dist/cdn/chunks/{top-navigation-bar-D1hjWIF3.js → top-navigation-bar-D7JkgCQi.js} +86 -86
  154. package/dist/cdn/chunks/{top-title-bar-iNFB2zQL.js → top-title-bar-BMSTl1Z7.js} +50 -44
  155. package/dist/cdn/chunks/{two-thirds-one-third-section-D-UANbHC.js → two-thirds-one-third-section-Cc1Mh9TT.js} +11 -11
  156. package/dist/cdn/chunks/{validation-list-C5BhHZIG.js → validation-list-xF6yTpz8.js} +19 -19
  157. package/dist/cdn/chunks/{visibility-mixin-COAZ9pON.js → visibility-mixin-LkgEnUqn.js} +2 -2
  158. package/dist/cdn/chunks/{visually-hidden-BPgATaH0.js → visually-hidden-CMo9yGtA.js} +6 -6
  159. package/dist/cdn/chunks/{window-t5iFkMLY.js → window-CclQ8SHn.js} +37 -37
  160. package/dist/cdn/chunks/with-translations-DdCPcavT.js +16 -0
  161. package/dist/components/actions/toolbar/toolbar.story-sync.js +1 -1
  162. package/dist/components/actions/toolbar/toolbar.story-sync.js.map +1 -1
  163. package/dist/components/content/blockquote/blockquote.d.ts +10 -1
  164. package/dist/components/content/blockquote/blockquote.d.ts.map +1 -1
  165. package/dist/components/content/blockquote/blockquote.js +24 -7
  166. package/dist/components/content/blockquote/blockquote.js.map +1 -1
  167. package/dist/components/content/blockquote/blockquote.styles.d.ts.map +1 -1
  168. package/dist/components/content/blockquote/blockquote.styles.js +51 -10
  169. package/dist/components/content/blockquote/blockquote.styles.js.map +1 -1
  170. package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
  171. package/dist/components/content/code-viewer/code-viewer.js +4 -0
  172. package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
  173. package/dist/components/content/code-viewer/code-viewer.template.js +1 -1
  174. package/dist/components/content/code-viewer/code-viewer.template.js.map +1 -1
  175. package/dist/components/content/identity/identity.d.ts +1 -0
  176. package/dist/components/content/identity/identity.d.ts.map +1 -1
  177. package/dist/components/content/identity/identity.js +1 -0
  178. package/dist/components/content/identity/identity.js.map +1 -1
  179. package/dist/components/content/image/image.d.ts +7 -2
  180. package/dist/components/content/image/image.d.ts.map +1 -1
  181. package/dist/components/content/image/image.js +29 -15
  182. package/dist/components/content/image/image.js.map +1 -1
  183. package/dist/components/content/image/image.styles.d.ts.map +1 -1
  184. package/dist/components/content/image/image.styles.js +1 -2
  185. package/dist/components/content/image/image.styles.js.map +1 -1
  186. package/dist/components/content/rich-text/rich-text.d.ts +10 -0
  187. package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
  188. package/dist/components/content/rich-text/rich-text.js +41 -2
  189. package/dist/components/content/rich-text/rich-text.js.map +1 -1
  190. package/dist/components/content/text/text.d.ts +1 -0
  191. package/dist/components/content/text/text.d.ts.map +1 -1
  192. package/dist/components/content/text/text.js +1 -0
  193. package/dist/components/content/text/text.js.map +1 -1
  194. package/dist/components/content/title/title.d.ts +26 -10
  195. package/dist/components/content/title/title.d.ts.map +1 -1
  196. package/dist/components/content/title/title.js +38 -11
  197. package/dist/components/content/title/title.js.map +1 -1
  198. package/dist/components/content/title/title.styles.d.ts.map +1 -1
  199. package/dist/components/content/title/title.styles.js +74 -43
  200. package/dist/components/content/title/title.styles.js.map +1 -1
  201. package/dist/components/content/tooltip/tooltip.d.ts +1 -1
  202. package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
  203. package/dist/components/content/tooltip/tooltip.js +5 -3
  204. package/dist/components/content/tooltip/tooltip.js.map +1 -1
  205. package/dist/components/forms/form/form.d.ts +11 -0
  206. package/dist/components/forms/form/form.d.ts.map +1 -1
  207. package/dist/components/forms/form/form.js +57 -4
  208. package/dist/components/forms/form/form.js.map +1 -1
  209. package/dist/components/forms/form-field/form-field.d.ts +1 -0
  210. package/dist/components/forms/form-field/form-field.d.ts.map +1 -1
  211. package/dist/components/forms/form-field/form-field.js +1 -0
  212. package/dist/components/forms/form-field/form-field.js.map +1 -1
  213. package/dist/components/index.d.ts +1 -1
  214. package/dist/components/index.d.ts.map +1 -1
  215. package/dist/components/index.js +1 -1
  216. package/dist/components/index.js.map +1 -1
  217. package/dist/components/inputs/checkbox-field/checkbox-field.d.ts +4 -1
  218. package/dist/components/inputs/checkbox-field/checkbox-field.d.ts.map +1 -1
  219. package/dist/components/inputs/checkbox-field/checkbox-field.js +6 -1
  220. package/dist/components/inputs/checkbox-field/checkbox-field.js.map +1 -1
  221. package/dist/components/inputs/code-editor/code-editor.d.ts +9 -11
  222. package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
  223. package/dist/components/inputs/code-editor/code-editor.js +3 -3
  224. package/dist/components/inputs/code-editor/code-editor.js.map +1 -1
  225. package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
  226. package/dist/components/inputs/code-editor/code-editor.styles.js +23 -25
  227. package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
  228. package/dist/components/inputs/date-field/date-field.d.ts +9 -4
  229. package/dist/components/inputs/date-field/date-field.d.ts.map +1 -1
  230. package/dist/components/inputs/date-field/date-field.js +20 -7
  231. package/dist/components/inputs/date-field/date-field.js.map +1 -1
  232. package/dist/components/inputs/date-field/date-field.template.d.ts.map +1 -1
  233. package/dist/components/inputs/date-field/date-field.template.js +1 -0
  234. package/dist/components/inputs/date-field/date-field.template.js.map +1 -1
  235. package/dist/components/inputs/dropdown/dropdown.d.ts +1 -0
  236. package/dist/components/inputs/dropdown/dropdown.d.ts.map +1 -1
  237. package/dist/components/inputs/dropdown/dropdown.js +1 -0
  238. package/dist/components/inputs/dropdown/dropdown.js.map +1 -1
  239. package/dist/components/inputs/one-time-code-field/one-time-code-field.d.ts +3 -3
  240. package/dist/components/inputs/one-time-code-field/one-time-code-field.d.ts.map +1 -1
  241. package/dist/components/inputs/one-time-code-field/one-time-code-field.js +4 -4
  242. package/dist/components/inputs/one-time-code-field/one-time-code-field.js.map +1 -1
  243. package/dist/components/inputs/segmented-control/segmented-control.styles.d.ts.map +1 -1
  244. package/dist/components/inputs/segmented-control/segmented-control.styles.js +4 -0
  245. package/dist/components/inputs/segmented-control/segmented-control.styles.js.map +1 -1
  246. package/dist/components/inputs/slider/slider.styles.d.ts.map +1 -1
  247. package/dist/components/inputs/slider/slider.styles.js +4 -0
  248. package/dist/components/inputs/slider/slider.styles.js.map +1 -1
  249. package/dist/components/inputs/swatch-picker/swatch-picker.d.ts +1 -1
  250. package/dist/components/inputs/swatch-picker/swatch-picker.js +1 -1
  251. package/dist/components/inputs/switch-field/switch-field.d.ts +12 -1
  252. package/dist/components/inputs/switch-field/switch-field.d.ts.map +1 -1
  253. package/dist/components/inputs/switch-field/switch-field.js +24 -2
  254. package/dist/components/inputs/switch-field/switch-field.js.map +1 -1
  255. package/dist/components/inputs/text-editor/text-editor.d.ts +2 -3
  256. package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
  257. package/dist/components/inputs/text-editor/text-editor.js +18 -17
  258. package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
  259. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +1 -1
  260. package/dist/components/inputs/text-editor/text-editor.styles.js +19 -19
  261. package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
  262. package/dist/components/inputs/time-field/time-field.d.ts +4 -0
  263. package/dist/components/inputs/time-field/time-field.d.ts.map +1 -1
  264. package/dist/components/inputs/time-field/time-field.js +17 -2
  265. package/dist/components/inputs/time-field/time-field.js.map +1 -1
  266. package/dist/components/inputs/time-field/time-field.template.d.ts.map +1 -1
  267. package/dist/components/inputs/time-field/time-field.template.js +1 -0
  268. package/dist/components/inputs/time-field/time-field.template.js.map +1 -1
  269. package/dist/components/inputs/time-picker/time-picker.d.ts +28 -19
  270. package/dist/components/inputs/time-picker/time-picker.d.ts.map +1 -1
  271. package/dist/components/inputs/time-picker/time-picker.js +78 -51
  272. package/dist/components/inputs/time-picker/time-picker.js.map +1 -1
  273. package/dist/components/inputs/time-picker/time-picker.styles.d.ts.map +1 -1
  274. package/dist/components/inputs/time-picker/time-picker.styles.js +2 -1
  275. package/dist/components/inputs/time-picker/time-picker.styles.js.map +1 -1
  276. package/dist/components/inputs/time-picker/time-picker.template.d.ts.map +1 -1
  277. package/dist/components/inputs/time-picker/time-picker.template.js +1 -0
  278. package/dist/components/inputs/time-picker/time-picker.template.js.map +1 -1
  279. package/dist/components/layout/kanban/kanban-column.d.ts +1 -1
  280. package/dist/components/layout/kanban/kanban-column.js +1 -1
  281. package/dist/components/layout/kanban/kanban.d.ts +7 -7
  282. package/dist/components/layout/kanban/kanban.js +9 -9
  283. package/dist/components/layout/kanban/kanban.js.map +1 -1
  284. package/dist/components/layout/page-footer/page-footer.d.ts +4 -0
  285. package/dist/components/layout/page-footer/page-footer.d.ts.map +1 -1
  286. package/dist/components/layout/page-footer/page-footer.js +7 -12
  287. package/dist/components/layout/page-footer/page-footer.js.map +1 -1
  288. package/dist/components/layout/page-footer/page-footer.styles.d.ts.map +1 -1
  289. package/dist/components/layout/page-footer/page-footer.styles.js +4 -19
  290. package/dist/components/layout/page-footer/page-footer.styles.js.map +1 -1
  291. package/dist/components/layout/page-footer/page-footer.template.d.ts.map +1 -1
  292. package/dist/components/layout/page-footer/page-footer.template.js +1 -4
  293. package/dist/components/layout/page-footer/page-footer.template.js.map +1 -1
  294. package/dist/components/layout/page-sections/hero/hero.d.ts +1 -0
  295. package/dist/components/layout/page-sections/hero/hero.d.ts.map +1 -1
  296. package/dist/components/layout/page-sections/hero/hero.js +1 -0
  297. package/dist/components/layout/page-sections/hero/hero.js.map +1 -1
  298. package/dist/components/layout/popover/popover.d.ts +24 -2
  299. package/dist/components/layout/popover/popover.d.ts.map +1 -1
  300. package/dist/components/layout/popover/popover.js +110 -13
  301. package/dist/components/layout/popover/popover.js.map +1 -1
  302. package/dist/components/layout/popover/popover.styles.d.ts.map +1 -1
  303. package/dist/components/layout/popover/popover.styles.js +6 -0
  304. package/dist/components/layout/popover/popover.styles.js.map +1 -1
  305. package/dist/components/lists-and-tables/cells/cell/cell.d.ts +2 -0
  306. package/dist/components/lists-and-tables/cells/cell/cell.d.ts.map +1 -1
  307. package/dist/components/lists-and-tables/cells/cell/cell.js +2 -1
  308. package/dist/components/lists-and-tables/cells/cell/cell.js.map +1 -1
  309. package/dist/components/lists-and-tables/cells/description-cell/description-cell.d.ts +2 -0
  310. package/dist/components/lists-and-tables/cells/description-cell/description-cell.d.ts.map +1 -1
  311. package/dist/components/lists-and-tables/cells/description-cell/description-cell.js +2 -1
  312. package/dist/components/lists-and-tables/cells/description-cell/description-cell.js.map +1 -1
  313. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts +2 -0
  314. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts.map +1 -1
  315. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js +2 -1
  316. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js.map +1 -1
  317. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.d.ts +46 -0
  318. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.d.ts.map +1 -0
  319. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.i18n.d.ts +5 -0
  320. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.i18n.d.ts.map +1 -0
  321. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.i18n.js +4 -0
  322. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.i18n.js.map +1 -0
  323. package/dist/components/lists-and-tables/cells/{drag-handle-cell/drag-handle-cell.js → reorder-handle-cell/reorder-handle-cell.js} +24 -24
  324. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.js.map +1 -0
  325. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.styles.d.ts +2 -0
  326. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.styles.d.ts.map +1 -0
  327. package/dist/components/lists-and-tables/cells/{drag-handle-cell/drag-handle-cell.styles.js → reorder-handle-cell/reorder-handle-cell.styles.js} +14 -14
  328. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.styles.js.map +1 -0
  329. package/dist/components/lists-and-tables/cells/{drag-handle-cell/drag-handle-cell.template.d.ts → reorder-handle-cell/reorder-handle-cell.template.d.ts} +1 -1
  330. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.template.d.ts.map +1 -0
  331. package/dist/components/lists-and-tables/cells/{drag-handle-cell/drag-handle-cell.template.js → reorder-handle-cell/reorder-handle-cell.template.js} +4 -4
  332. package/dist/components/lists-and-tables/cells/reorder-handle-cell/reorder-handle-cell.template.js.map +1 -0
  333. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.d.ts +2 -0
  334. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.d.ts.map +1 -1
  335. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js +2 -1
  336. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js.map +1 -1
  337. package/dist/components/lists-and-tables/cells/step-cell/step-cell.d.ts +2 -0
  338. package/dist/components/lists-and-tables/cells/step-cell/step-cell.d.ts.map +1 -1
  339. package/dist/components/lists-and-tables/cells/step-cell/step-cell.js +2 -1
  340. package/dist/components/lists-and-tables/cells/step-cell/step-cell.js.map +1 -1
  341. package/dist/components/lists-and-tables/cells/text-cell/text-cell.d.ts +2 -0
  342. package/dist/components/lists-and-tables/cells/text-cell/text-cell.d.ts.map +1 -1
  343. package/dist/components/lists-and-tables/cells/text-cell/text-cell.js +2 -1
  344. package/dist/components/lists-and-tables/cells/text-cell/text-cell.js.map +1 -1
  345. package/dist/components/lists-and-tables/cells/title-cell/title-cell.d.ts +7 -5
  346. package/dist/components/lists-and-tables/cells/title-cell/title-cell.d.ts.map +1 -1
  347. package/dist/components/lists-and-tables/cells/title-cell/title-cell.js +4 -3
  348. package/dist/components/lists-and-tables/cells/title-cell/title-cell.js.map +1 -1
  349. package/dist/components/lists-and-tables/cells/title-cell/title-cell.styles.js +5 -5
  350. package/dist/components/lists-and-tables/list/list.d.ts +3 -2
  351. package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
  352. package/dist/components/lists-and-tables/list/list.js +15 -21
  353. package/dist/components/lists-and-tables/list/list.js.map +1 -1
  354. package/dist/components/lists-and-tables/list-item/list-item.d.ts +30 -14
  355. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  356. package/dist/components/lists-and-tables/list-item/list-item.js +107 -154
  357. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  358. package/dist/components/lists-and-tables/list-item/list-item.styles.js +3 -3
  359. package/dist/components/lists-and-tables/table/table.d.ts +4 -4
  360. package/dist/components/lists-and-tables/table/table.js +5 -5
  361. package/dist/components/lists-and-tables/table/table.js.map +1 -1
  362. package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts +6 -6
  363. package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts.map +1 -1
  364. package/dist/components/navigation/document-tab-bar/document-tab-bar.js +16 -24
  365. package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
  366. package/dist/components/navigation/tab-bar/tab-bar.d.ts +2 -2
  367. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  368. package/dist/components/navigation/tab-bar/tab-bar.js +4 -4
  369. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  370. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js +1 -1
  371. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js.map +1 -1
  372. package/dist/components/navigation/top-title-bar/top-title-bar.d.ts +1 -0
  373. package/dist/components/navigation/top-title-bar/top-title-bar.d.ts.map +1 -1
  374. package/dist/components/navigation/top-title-bar/top-title-bar.js +12 -0
  375. package/dist/components/navigation/top-title-bar/top-title-bar.js.map +1 -1
  376. package/dist/components/status-and-feedback/banner/banner.d.ts +1 -1
  377. package/dist/components/status-and-feedback/banner/banner.js +1 -1
  378. package/dist/components/status-and-feedback/banner/banner.styles.d.ts.map +1 -1
  379. package/dist/components/status-and-feedback/banner/banner.styles.js +6 -2
  380. package/dist/components/status-and-feedback/banner/banner.styles.js.map +1 -1
  381. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.d.ts +1 -1
  382. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js +1 -1
  383. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.d.ts +2 -2
  384. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.d.ts.map +1 -1
  385. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js +5 -7
  386. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js.map +1 -1
  387. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts +1 -1
  388. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js +1 -1
  389. package/dist/css/global-open-font.css +1 -0
  390. package/dist/css/global.css +1 -0
  391. package/dist/css/title.css +88 -0
  392. package/dist/css/variables.css +2 -3
  393. package/dist/nldd.min.js +942 -866
  394. package/dist/translations/en-US.js +1 -1
  395. package/dist/translations/en-US.js.map +1 -1
  396. package/dist/translations/fy.js +1 -1
  397. package/dist/translations/fy.js.map +1 -1
  398. package/dist/translations/nl.generated.d.ts +1 -1
  399. package/dist/translations/nl.generated.js +2 -2
  400. package/dist/translations/nl.generated.js.map +1 -1
  401. package/dist/translations/pap-AW.js +1 -1
  402. package/dist/translations/pap-AW.js.map +1 -1
  403. package/dist/translations/pap-CW.js +1 -1
  404. package/dist/translations/pap-CW.js.map +1 -1
  405. package/dist/types/react.d.ts +45 -37
  406. package/dist/types/vue.d.ts +74 -59
  407. package/dist/utilities/autoloader.generated.js +1 -1
  408. package/dist/utilities/autoloader.generated.js.map +1 -1
  409. package/dist/utilities/dev-rules.generated.d.ts.map +1 -1
  410. package/dist/utilities/dev-rules.generated.js +75 -25
  411. package/dist/utilities/dev-rules.generated.js.map +1 -1
  412. package/dist/utilities/form-associated-mixin.d.ts +10 -0
  413. package/dist/utilities/form-associated-mixin.d.ts.map +1 -1
  414. package/dist/utilities/form-associated-mixin.js +17 -0
  415. package/dist/utilities/form-associated-mixin.js.map +1 -1
  416. package/dist/utilities/reorder-handle-mixin.d.ts +21 -0
  417. package/dist/utilities/reorder-handle-mixin.d.ts.map +1 -0
  418. package/dist/utilities/reorder-handle-mixin.js +34 -0
  419. package/dist/utilities/reorder-handle-mixin.js.map +1 -0
  420. package/dist/utilities/return-focus.d.ts +14 -0
  421. package/dist/utilities/return-focus.d.ts.map +1 -1
  422. package/dist/utilities/return-focus.js +26 -8
  423. package/dist/utilities/return-focus.js.map +1 -1
  424. package/lint/data.generated.json +1 -1
  425. package/lint/engine.js +53 -1
  426. package/lint/fix.js +11 -0
  427. package/lint/format.js +6 -5
  428. package/lint/frontends.js +224 -16
  429. package/lint/linter.js +10 -4
  430. package/lint/main.js +36 -9
  431. package/lint/project.js +73 -4
  432. package/lint/rule-data.js +17 -2
  433. package/lint/rule.schema.json +1 -0
  434. package/lint/tree.js +3 -0
  435. package/package.json +6 -6
  436. package/dist/cdn/chunks/blockquote-BoOqbGdm.js +0 -189
  437. package/dist/cdn/chunks/drag-handle-cell.i18n-CKUrbm2q.js +0 -3
  438. package/dist/cdn/chunks/nl.generated-D6T41jG3.js +0 -112
  439. package/dist/cdn/chunks/rich-text-CQ2uwMSp.js +0 -47
  440. package/dist/cdn/chunks/with-translations-XX14GKFh.js +0 -16
  441. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.d.ts +0 -44
  442. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.d.ts.map +0 -1
  443. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.i18n.d.ts +0 -5
  444. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.i18n.d.ts.map +0 -1
  445. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.i18n.js +0 -4
  446. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.i18n.js.map +0 -1
  447. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js.map +0 -1
  448. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.styles.d.ts +0 -2
  449. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.styles.d.ts.map +0 -1
  450. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.styles.js.map +0 -1
  451. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.template.d.ts.map +0 -1
  452. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.template.js.map +0 -1
package/lint/engine.js CHANGED
@@ -65,6 +65,45 @@ function createFieldLabelCheck(isInput, allowMaybe) {
65
65
  };
66
66
  }
67
67
 
68
+ /**
69
+ * Whether the nearest component around a plain element styles it, as nldd-dropdown
70
+ * does its <select> and nldd-rich-text everything in it. Each component says so
71
+ * with `@accepts` in its JSDoc.
72
+ *
73
+ * What a file renders is judged in that file: that a parent elsewhere might put it
74
+ * inside an nldd-rich-text does not make plain HTML written here the system's. A
75
+ * tree the file builds under a name (a helper component, a variable) is judged where
76
+ * the file uses that name. Used nowhere here, or under a component of the app, it is
77
+ * unknown.
78
+ */
79
+ function createAcceptedCheck(tags, allowUnknown) {
80
+ // `chain` holds the plain elements between the node and the component: the
81
+ // component styles its own children (::slotted) or descendants of what it styles,
82
+ // so each of them has to be accepted too. `seen` keeps a component that places
83
+ // itself from going round in circles.
84
+ const accepted = (node, from, chain, seen) => {
85
+ for (let parent = from; parent; parent = parent.parent) {
86
+ if (parent.name === '#root') {
87
+ if (!parent.detached) return false;
88
+ if (!parent.placements) return allowUnknown;
89
+ if (seen.has(parent)) return false;
90
+ const next = new Set(seen).add(parent);
91
+ // Accepted in any of the places the file uses it is enough.
92
+ return parent.placements.some((place) => accepted(node, place.parent, chain, next));
93
+ }
94
+ if (parent.opaque) return allowUnknown;
95
+ if (!parent.name.startsWith('nldd-')) {
96
+ chain.push(parent.name);
97
+ continue;
98
+ }
99
+ const accepts = tags[parent.name]?.accepts ?? [];
100
+ return accepts.includes('*') || [node.name, ...chain].every((name) => accepts.includes(name));
101
+ }
102
+ return false;
103
+ };
104
+ return (node) => accepted(node, node.parent, [], new Set());
105
+ }
106
+
68
107
  function classPseudos(classes) {
69
108
  return Object.fromEntries(
70
109
  Object.entries(classes).map(([name, tags]) => {
@@ -88,6 +127,7 @@ function forWorld(tokens, classes, widen) {
88
127
  }
89
128
  if (!widen) return token;
90
129
  if (token.type === 'pseudo' && token.name === 'named-by-field') return { ...token, name: 'may-be-named-by-field' };
130
+ if (token.type === 'pseudo' && token.name === 'accepted') return { ...token, name: 'may-be-accepted' };
91
131
  if (token.type === 'tag' || (token.type === 'pseudo' && token.name in classes)) {
92
132
  return { type: 'pseudo', name: 'is', data: [[token], [unknown]] };
93
133
  }
@@ -101,15 +141,27 @@ function forWorld(tokens, classes, widen) {
101
141
  });
102
142
  }
103
143
 
104
- export function createEngine({ classes = {} } = {}) {
144
+ export function createEngine({ classes = {}, tags = {} } = {}) {
105
145
  const shared = classPseudos(classes);
106
146
  const pseudos = {
107
147
  ...shared,
108
148
  'named-by-field': createFieldLabelCheck(shared['form-input'] ?? (() => false), false),
109
149
  'may-be-named-by-field': createFieldLabelCheck(shared['form-input'] ?? (() => false), true),
150
+ accepted: createAcceptedCheck(tags, false),
151
+ 'may-be-accepted': createAcceptedCheck(tags, true),
152
+ // Inside an element of this name in this file. A drawing's own classes and styles are its business.
153
+ within: (node, name) => {
154
+ for (let parent = node.parent; parent; parent = parent.parent) if (parent.name === name) return true;
155
+ return false;
156
+ },
157
+ // No element and no text: an empty mount point such as <div id="app"></div>.
158
+ blank: (node) => node.children.length === 0 && !node.text,
110
159
  // Only exists on a running page, so in source it is never true.
111
160
  state: () => false,
112
161
  unknown: (node) => node.opaque,
162
+ // The attribute is in the markup, with a value or bound to one. `[class]` asks for a
163
+ // value we can read, so a bound class would only ever be cantTell.
164
+ written: (node, name) => node.attrs.has(name),
113
165
  bound: (node, name) => node.opaque || node.spread || node.attrs.get(name) === BOUND,
114
166
  };
115
167
  const cache = new Map();
package/lint/fix.js CHANGED
@@ -129,6 +129,16 @@ function removeEdits(source, offset, name) {
129
129
  return [{ from, to: end, text: '' }];
130
130
  }
131
131
 
132
+ /** A value written out in the markup that became a boolean: the whole attribute
133
+ * turns into the new name. The rule's context says which value that is. */
134
+ function flagEdits(source, offset, from, to) {
135
+ const found = findAttribute(source, offset, from);
136
+ if (!found || found.prefix || findAttribute(source, offset, to)) return [];
137
+ const end = endOfValue(source, found.end);
138
+ if (end === undefined) return [];
139
+ return [{ from: found.start, to: end, text: to }];
140
+ }
141
+
132
142
  /**
133
143
  * The parser says where an element ends: a comment or a string that looks like its
134
144
  * closing tag does not count. Without a closing tag of its own it stays as it is.
@@ -150,6 +160,7 @@ function editsOf(source, { fix, offset, endOffset, tag }) {
150
160
  ...Object.entries(fix.rename ?? {}).flatMap(([from, to]) => renameEdits(source, offset, from, to)),
151
161
  ...Object.entries(fix.value ?? {}).flatMap(([name, values]) => valueEdits(source, offset, name, values)),
152
162
  ...(fix.remove ?? []).flatMap((name) => removeEdits(source, offset, name)),
163
+ ...Object.entries(fix.flag ?? {}).flatMap(([from, to]) => flagEdits(source, offset, from, to)),
153
164
  ...(fix.tag ? tagEdits(source, offset, endOffset, tag, fix.tag) : []),
154
165
  ];
155
166
  }
package/lint/format.js CHANGED
@@ -45,7 +45,7 @@ function hintSummary(results, root, explainRule) {
45
45
  return lines;
46
46
  }
47
47
 
48
- export function formatText(results, { root, files, ms, skipped, explainRule }) {
48
+ export function formatText(results, { root, files, ms, skipped, loose, explainRule }) {
49
49
  const lines = [];
50
50
  for (const { filename, source, findings } of results) {
51
51
  const sourceLines = source.split('\n');
@@ -65,7 +65,7 @@ export function formatText(results, { root, files, ms, skipped, explainRule }) {
65
65
  const errors = count('error');
66
66
  const warnings = count('warn');
67
67
  const hints = count('hint') ? `, ${plural(count('hint'), 'hint')}` : '';
68
- const known = skipped ? dim(` (${skipped} in baseline)`) : '';
68
+ const known = (skipped ? dim(` (${skipped} in baseline)`) : '') + (loose ? dim(` (${loose} accepted no longer found: run --tighten-baseline)`) : '');
69
69
  const summary = `${plural(errors, 'error')}, ${plural(warnings, 'warning')}${hints} in ${plural(files, 'file')} (${ms} ms)`;
70
70
  const fixable = all.filter(({ fix }) => fix).length;
71
71
  const canFix = fixable ? `, ${fixable} fixable with --fix` : '';
@@ -93,7 +93,7 @@ export function formatStatistics(results, { files, ms, skipped }) {
93
93
  }
94
94
 
95
95
  /** Everything an agent needs to fix a finding without opening the docs. */
96
- export function formatJson(results, { root, explainRule }) {
96
+ export function formatJson(results, { root, explainRule, skipped = 0, loose = 0 }) {
97
97
  const findings = results.flatMap(({ filename, findings: list }) =>
98
98
  list.map((finding) => {
99
99
  const detail = explainRule(finding.rule);
@@ -111,7 +111,7 @@ export function formatJson(results, { root, explainRule }) {
111
111
  };
112
112
  }),
113
113
  );
114
- return JSON.stringify({ findings }, null, 2);
114
+ return JSON.stringify({ findings, baseline: { accepted: skipped, noLongerFound: loose } }, null, 2);
115
115
  }
116
116
 
117
117
  function escapeGithub(text) {
@@ -120,8 +120,9 @@ function escapeGithub(text) {
120
120
 
121
121
  const escapeProperty = (text) => escapeGithub(text).replace(/:/g, '%3A').replace(/,/g, '%2C');
122
122
 
123
- export function formatGithub(results, { root }) {
123
+ export function formatGithub(results, { root, loose = 0 }) {
124
124
  const lines = [];
125
+ if (loose) lines.push(`::notice title=baseline::${loose} accepted findings are no longer found: run nldd lint --tighten-baseline.`);
125
126
  for (const { filename, findings } of results) {
126
127
  for (const { severity, line, column, rule, message } of findings) {
127
128
  const level = { error: 'error', warn: 'warning', hint: 'notice' }[severity];
package/lint/frontends.js CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  createNode,
16
16
  createRoot,
17
17
  isOpaqueTag,
18
+ walk,
18
19
  } from './tree.js';
19
20
 
20
21
  const TRANSPARENT = new Set([
@@ -56,8 +57,13 @@ function readAttribute(element, name, value) {
56
57
  else if (/^(:|v-bind:|x-bind:|\.|\?)/.test(name)) {
57
58
  const bare = name.replace(/^(v-bind|x-bind)?[:.?]/, '').replace(/\.(prop|attr|camel)$/, '');
58
59
  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.
60
+ } else if (/^\[(class\.|style\.)/.test(name) || /^\[(ngClass|ngStyle|className)\]$/.test(name)) {
61
+ // Angular's way to set one class or style, or a set of them. Not an attribute of
62
+ // its own, but the element ends up with a class or a style, which the group pure asks.
63
+ const attribute = /^\[(class\.|ngClass|className)/.test(name) ? 'class' : 'style';
64
+ if (!element.attrs.has(attribute)) element.attrs.set(attribute, BOUND);
65
+ } else if (/^\[@/.test(name)) {
66
+ // An Angular animation: no attribute.
61
67
  } else if (/^\[.+\]$/.test(name)) {
62
68
  element.attrs.set(name.replace(/^\[\(?|\)?\]$/g, '').replace(/^attr\./, ''), BOUND);
63
69
  } else if (/^(@|#|v-|\(|\*)/.test(name)) {
@@ -81,6 +87,12 @@ function readHtmlChildren(children, parent, given) {
81
87
  const hole = given.lit && children.find((node) => node.type === 'text' && node.data.includes('${'));
82
88
  if (hole) appendUnknown(parent, hole.startIndex ?? 0);
83
89
  for (const node of children) {
90
+ if (node.type === 'text' && node.data.trim()) parent.text = true;
91
+ // htmlparser2 gives <style> a type of its own. The group pure reads every block in it.
92
+ if (node.type === 'style') {
93
+ for (const offset of styleBlockOffsets(node)) appendChild(parent, createNode('style', offset));
94
+ continue;
95
+ }
84
96
  if (node.type !== 'tag') continue;
85
97
  const { name, attribs } = node;
86
98
  // In a document, a template is inert until something stamps it out, here or elsewhere.
@@ -200,10 +212,77 @@ export function parseVue(source) {
200
212
  const template = documentNode.children.find(
201
213
  (node) => node.type === 'tag' && node.name === 'template',
202
214
  );
203
- if (!template) return [];
215
+ const roots = [];
216
+ if (template) {
217
+ const root = createRoot();
218
+ readHtmlChildren(template.children, root, {});
219
+ roots.push(root);
220
+ }
221
+ // A style block is the component's own stylesheet, so it stands as the element it is.
222
+ const blocks = documentNode.children.filter((each) => each.name === 'style').flatMap(styleBlockOffsets);
223
+ if (blocks.length > 0) roots.push(stylesheetRoot(blocks));
224
+ return roots;
225
+ }
226
+
227
+ /** Where each block of a <style> element starts in the file. */
228
+ function styleBlockOffsets(node) {
229
+ const text = node.children?.find((child) => child.type === 'text');
230
+ return text ? cssBlockOffsets(text.data).map((offset) => (text.startIndex ?? 0) + offset) : [];
231
+ }
232
+
233
+ /** One <style> element per block, so a suppression or a baseline count covers one block and not the whole sheet. */
234
+ function stylesheetRoot(offsets) {
204
235
  const root = createRoot();
205
- readHtmlChildren(template.children, root, {});
206
- return [root];
236
+ for (const offset of offsets) appendChild(root, createNode('style', offset));
237
+ return root;
238
+ }
239
+
240
+ /**
241
+ * The stylesheet with comments and imports of the design system blanked out, so
242
+ * what is left is the app's own and every offset still points at the source.
243
+ */
244
+ const ownCss = (source) =>
245
+ source
246
+ .replace(/\/\*[\s\S]*?\*\//g, (comment) => comment.replace(/[^\n]/g, ' '))
247
+ .replace(/^\s*\/\/.*$/gm, (comment) => ' '.repeat(comment.length))
248
+ .replace(/@(import|use|forward)\s+(url\()?['"]?[^'";)]*(@nldd\/design-system|\/nldd\/css\/)[^;]*;/g, (line) => ' '.repeat(line.length));
249
+
250
+ /**
251
+ * Where each top-level block of the app's own CSS starts: a rule with its braces,
252
+ * or a statement up to its semicolon.
253
+ */
254
+ function cssBlockOffsets(source, indented = false) {
255
+ // Strings and url() can hold a brace or a semicolon, so their contents are blanked first.
256
+ const own = ownCss(source).replace(/(["'])(?:\\.|(?!\1).)*\1|url\([^)]*\)/g, (text) => text[0] + ' '.repeat(text.length - 1));
257
+ // Sass without braces: a block is a line that starts at the margin.
258
+ if (indented) return [...own.matchAll(/^\S/gm)].map((match) => match.index);
259
+ const offsets = [];
260
+ let depth = 0;
261
+ let inBlock = false;
262
+ for (let at = 0; at < own.length; at++) {
263
+ const char = own[at];
264
+ if (!inBlock && depth === 0 && /\S/.test(char)) {
265
+ offsets.push(at);
266
+ inBlock = true;
267
+ }
268
+ if (char === '{') depth += 1;
269
+ else if (char === '}') {
270
+ depth = Math.max(0, depth - 1);
271
+ if (depth === 0) inBlock = false;
272
+ } else if (char === ';' && depth === 0) inBlock = false;
273
+ }
274
+ return offsets;
275
+ }
276
+
277
+ /**
278
+ * A stylesheet file is a <style> element in a file of its own, so the rule about
279
+ * one reads both. A file that only imports the design system's own CSS is not one.
280
+ * Each block is an element of its own, starting where it does, so a comment above
281
+ * a block suppresses that block.
282
+ */
283
+ export function parseStylesheet(source, filename = '') {
284
+ const offsets = cssBlockOffsets(source, filename.endsWith('.sass'));
285
+ return offsets.length === 0 ? [] : [stylesheetRoot(offsets)];
207
286
  }
208
287
 
209
288
  /** Every code block and inline tag in a Markdown file is a tree of its own. */
@@ -302,15 +381,103 @@ function jsxName(node) {
302
381
  return `${node.namespace.name}:${node.name.name}`;
303
382
  }
304
383
 
305
- function collectJsx(node, found) {
384
+ /** Expressions a value passes through unchanged: `a ? <x /> : <y />`, `(<x />)`, `<x /> as JSX.Element`. */
385
+ const PASSES_ON_VALUE = new Set([
386
+ 'ConditionalExpression', 'LogicalExpression', 'ParenthesizedExpression', 'SequenceExpression',
387
+ 'TSAsExpression', 'TSSatisfiesExpression', 'TSNonNullExpression', 'TSTypeAssertion',
388
+ ]);
389
+
390
+ /** Between `export` and the component it exports: `export const A = memo(() => ...)`, a class and its render. */
391
+ const PASSES_ON_EXPORT = new Set([
392
+ ...PASSES_ON_VALUE, 'VariableDeclaration', 'VariableDeclarator', 'CallExpression',
393
+ 'ClassDeclaration', 'ClassExpression', 'ClassBody', 'MethodDefinition', 'PropertyDefinition',
394
+ ]);
395
+
396
+ const FUNCTIONS = new Set(['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression']);
397
+
398
+ /**
399
+ * Finds every JSX tree. What an exported component returns is what this file
400
+ * renders. Any other tree is built to be placed somewhere, maybe inside a component
401
+ * of this same file, and is marked detached. A tree that a function bound to a name
402
+ * returns, or that a name is bound to directly, gets that name as its owner, so its
403
+ * place can be looked up: `<Row />`, `{items}`. JSX assigned later or pushed into an
404
+ * array has no owner and stays unknown.
405
+ */
406
+ function collectJsx(node, found, state = {}, exportedNames = new Set()) {
306
407
  if (!node || typeof node !== 'object') return;
408
+ const { exported = false, renders = false, returned = false, fnOwner, valueOwner } = state;
307
409
  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);
410
+ for (const item of node) collectJsx(item, found, state, exportedNames);
411
+ return;
412
+ }
413
+ if (node.type === 'JSXElement' || node.type === 'JSXFragment') {
414
+ found.push({ node, detached: !(renders && returned), owner: returned ? fnOwner : valueOwner });
415
+ return;
416
+ }
417
+ const isFunction = FUNCTIONS.has(node.type);
418
+ // `function A() {}` with `export default A` further down, or `export { A }`.
419
+ const named = (node.type === 'FunctionDeclaration' || node.type === 'VariableDeclarator' || node.type === 'ClassDeclaration') && exportedNames.has(node.id?.name);
420
+ const isExported = exported || named;
421
+ // The name a function returns its JSX under: its own, or the one it is bound to.
422
+ const ownName = node.type === 'FunctionDeclaration' ? node.id?.name : isFunction ? valueOwner : fnOwner;
423
+ for (const key of Object.keys(node)) {
424
+ if (key === 'parent') continue;
425
+ let nextValueOwner;
426
+ if (node.type === 'VariableDeclarator' && key === 'init' && node.id?.type === 'Identifier') nextValueOwner = node.id.name;
427
+ else if (PASSES_ON_VALUE.has(node.type)) nextValueOwner = valueOwner;
428
+ // `memo(() => ...)`, `useMemo(() => ...)`, `xs.map((x) => ...)`: the callback is what the name holds.
429
+ else if (node.type === 'CallExpression' && key === 'arguments') nextValueOwner = valueOwner;
430
+ collectJsx(node[key], found, {
431
+ exported: node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration' || (isExported && (named || PASSES_ON_EXPORT.has(node.type))),
432
+ // A function renders when it is the exported one; a function inside it does not.
433
+ renders: isFunction ? isExported : renders,
434
+ returned: (node.type === 'ReturnStatement' && key === 'argument')
435
+ || (node.type === 'ArrowFunctionExpression' && key === 'body')
436
+ || (returned && PASSES_ON_VALUE.has(node.type)),
437
+ fnOwner: isFunction ? ownName : fnOwner,
438
+ valueOwner: nextValueOwner,
439
+ }, exportedNames);
440
+ }
441
+ }
442
+
443
+ /** Every name the file binds, with how often: a name bound twice cannot be looked up by name alone. */
444
+ function bindingCounts(program) {
445
+ const counts = new Map();
446
+ const add = (name) => name && counts.set(name, (counts.get(name) ?? 0) + 1);
447
+ const pattern = (node) => {
448
+ if (!node) return;
449
+ if (node.type === 'Identifier') add(node.name);
450
+ else if (node.type === 'ObjectPattern') node.properties.forEach((property) => pattern(property.value ?? property.argument));
451
+ else if (node.type === 'ArrayPattern') node.elements.forEach(pattern);
452
+ else if (node.type === 'AssignmentPattern') pattern(node.left);
453
+ else if (node.type === 'RestElement') pattern(node.argument);
454
+ else if (node.type === 'TSParameterProperty') pattern(node.parameter);
455
+ };
456
+ const visit = (node) => {
457
+ if (!node || typeof node !== 'object') return;
458
+ if (Array.isArray(node)) return node.forEach(visit);
459
+ if (node.type === 'VariableDeclarator') pattern(node.id);
460
+ if ((node.type === 'FunctionDeclaration' || node.type === 'ClassDeclaration') && node.id) add(node.id.name);
461
+ if (FUNCTIONS.has(node.type)) node.params?.forEach(pattern);
462
+ for (const key of Object.keys(node)) if (key !== 'parent') visit(node[key]);
463
+ };
464
+ visit(program);
465
+ return counts;
466
+ }
467
+
468
+ /** The names a module exports by reference rather than in place. */
469
+ function exportedNamesOf(program) {
470
+ const names = new Set();
471
+ for (const statement of program.body ?? []) {
472
+ if (statement.type === 'ExportDefaultDeclaration' && statement.declaration?.type === 'Identifier') names.add(statement.declaration.name);
473
+ // `export default withRouter(Page)`: the component inside the wrapper is what is exported.
474
+ const wrapped = (call) => call?.type === 'CallExpression' && call.arguments.forEach((arg) => (arg.type === 'Identifier' ? names.add(arg.name) : wrapped(arg)));
475
+ if (statement.type === 'ExportDefaultDeclaration') wrapped(statement.declaration);
476
+ if (statement.type === 'ExportNamedDeclaration' && !statement.source) {
477
+ for (const specifier of statement.specifiers ?? []) names.add(specifier.local?.name);
478
+ }
313
479
  }
480
+ return names;
314
481
  }
315
482
 
316
483
  /** `undefined` means the attribute is not there: `x={false}` and `x={null}` switch it off. */
@@ -345,7 +512,7 @@ function readJsxAttributes(element, attributes, roots) {
345
512
  // An element passed as a prop renders elsewhere, so it is a tree of its own.
346
513
  const nested = [];
347
514
  collectJsx(attribute.value, nested);
348
- for (const node of nested) roots.push(jsxTree(node, roots));
515
+ for (const { node } of nested) roots.push(jsxTree(node, roots, true));
349
516
  }
350
517
  }
351
518
 
@@ -357,8 +524,10 @@ function readJsxExpression(expression, parent, flags, roots) {
357
524
  readJsxNode(expression, parent, flags, roots);
358
525
  break;
359
526
  case 'JSXEmptyExpression':
527
+ break;
360
528
  case 'Literal':
361
529
  case 'TemplateLiteral':
530
+ if (expression.value !== '' && expression.value !== null) parent.text = true;
362
531
  break;
363
532
  case 'LogicalExpression':
364
533
  // The left of `a && <x />` renders nothing worth counting.
@@ -376,11 +545,15 @@ function readJsxExpression(expression, parent, flags, roots) {
376
545
  const found = [];
377
546
  collectJsx(expression, found);
378
547
  if (found.length === 0) appendUnknown(parent, expression.start);
379
- for (const node of found) {
548
+ for (const { node } of found) {
380
549
  readJsxNode(node, parent, { ...flags, repeated: true }, roots);
381
550
  }
382
551
  break;
383
552
  }
553
+ case 'Identifier':
554
+ // `{items}`: whatever the file bound to that name renders here.
555
+ appendUnknown(parent, expression.start).ref = expression.name;
556
+ break;
384
557
  default:
385
558
  appendUnknown(parent, expression.start);
386
559
  }
@@ -388,6 +561,7 @@ function readJsxExpression(expression, parent, flags, roots) {
388
561
 
389
562
  function readJsxChildren(children, parent, flags, roots) {
390
563
  for (const child of children) {
564
+ if (child.type === 'JSXText' && child.value.trim()) parent.text = true;
391
565
  if (child.type === 'JSXElement' || child.type === 'JSXFragment') {
392
566
  readJsxNode(child, parent, flags, roots);
393
567
  } else if (child.type === 'JSXExpressionContainer') {
@@ -418,8 +592,9 @@ function readJsxNode(node, parent, flags, roots) {
418
592
  readJsxChildren(node.children, element, {}, roots);
419
593
  }
420
594
 
421
- function jsxTree(node, roots) {
595
+ function jsxTree(node, roots, detached = true) {
422
596
  const root = createRoot();
597
+ if (detached) root.detached = true;
423
598
  readJsxNode(node, root, {}, roots);
424
599
  return root;
425
600
  }
@@ -432,15 +607,44 @@ export async function parseJsx(source, filename) {
432
607
  });
433
608
  const { program, errors } = oxcParser.parseSync(filename, source);
434
609
  const found = [];
435
- collectJsx(program, found);
610
+ collectJsx(program, found, {}, exportedNamesOf(program));
611
+ const bindings = bindingCounts(program);
436
612
  const roots = [];
437
- for (const node of found) roots.push(jsxTree(node, roots));
613
+ const owners = new Map();
614
+ for (const { node, detached, owner } of found) {
615
+ const root = jsxTree(node, roots, detached);
616
+ roots.push(root);
617
+ // A name bound more than once (a parameter that shadows it, two components with
618
+ // the same local) might be the other one where it is used: then it stays unknown.
619
+ if (detached && owner && bindings.get(owner) === 1) owners.set(root, owner);
620
+ }
621
+ placeDetachedRoots(roots, owners);
438
622
  if (errors?.length) {
439
623
  roots.syntaxError = { message: errors[0].message, offset: errors[0].labels?.[0]?.start ?? 0 };
440
624
  }
441
625
  return roots;
442
626
  }
443
627
 
628
+ /**
629
+ * A tree bound to a name lands where this file uses that name: `<Row />` for a
630
+ * component, `{items}` for a value. Those places tell what is around it, so a
631
+ * rule can judge its plain HTML. Used nowhere in the file, it stays unknown.
632
+ */
633
+ function placeDetachedRoots(roots, owners) {
634
+ if (owners.size === 0) return;
635
+ const uses = new Map();
636
+ for (const root of roots) {
637
+ walk(root, (node) => {
638
+ const name = node.ref ?? (node.opaque ? node.name : undefined);
639
+ if (name) uses.set(name, [...(uses.get(name) ?? []), node]);
640
+ });
641
+ }
642
+ for (const [root, owner] of owners) {
643
+ const places = uses.get(owner);
644
+ if (places?.length) root.placements = places;
645
+ }
646
+ }
647
+
444
648
  /** Names a framework wrapper by the tag it renders, with kebab-case props. */
445
649
  export function applyWrappers(roots, wrappers) {
446
650
  const visit = (node) => {
@@ -473,6 +677,10 @@ const PARSERS = {
473
677
  '.jsx': parseJsx,
474
678
  '.tsx': parseJsx,
475
679
  '.ts': parseLit,
680
+ '.css': parseStylesheet,
681
+ '.scss': parseStylesheet,
682
+ '.sass': parseStylesheet,
683
+ '.less': parseStylesheet,
476
684
  };
477
685
 
478
686
  /** @returns {Promise<import('./tree.js').TreeNode[]>} */
package/lint/linter.js CHANGED
@@ -6,7 +6,7 @@
6
6
  import { createEngine } from './engine.js';
7
7
  import { canFix, stuckTags } from './fix.js';
8
8
  import { applyWrappers, parseSource } from './frontends.js';
9
- import { BUILT_IN_RULES, createCanonical, loadData } from './rule-data.js';
9
+ import { BUILT_IN_RULES, createCanonical, loadData, OPT_IN_GROUPS } from './rule-data.js';
10
10
  import { BOUND, walk } from './tree.js';
11
11
 
12
12
  export { BUILT_IN_RULES, createCanonical, loadData };
@@ -152,8 +152,10 @@ export function createLinter(data = loadData(), { wrappers = {}, severities: con
152
152
  icons: new Set(data.icons),
153
153
  anyChildAttrs: Object.assign({}, ...Object.values(data.tags).map((tag) => tag.childAttrs)),
154
154
  };
155
- const engine = createEngine({ classes: data.classes });
156
- const rules = data.rules.filter((rule) => !rule.runtime && severities[rule.id] !== 'off');
155
+ const engine = createEngine({ classes: data.classes, tags: data.tags });
156
+ // An opt-in group runs only where a level was given for it, never by default.
157
+ const isOn = (rule) => (OPT_IN_GROUPS.includes(rule.group) ? Boolean(severities[rule.id]) : true) && severities[rule.id] !== 'off';
158
+ const rules = data.rules.filter((rule) => !rule.runtime && isOn(rule));
157
159
  const ranInSource = (id) => severities[id] !== 'off' && (rules.some((rule) => rule.id === id) || id in BUILT_IN_RULES);
158
160
  const isRule = (id) => id in BUILT_IN_RULES || data.rules.some((rule) => rule.id === id);
159
161
 
@@ -171,6 +173,10 @@ export function createLinter(data = loadData(), { wrappers = {}, severities: con
171
173
  return !node.wrapped && !maybeInput;
172
174
  }
173
175
 
176
+ /** A rule whose context picks a value of a name that is gone: its fix is only right for that value. */
177
+ const testsRemovedValue = (rule) =>
178
+ rule.removed?.some((name) => new RegExp(`\\[${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*[~|^$*]?=`).test(rule.context));
179
+
174
180
  function lintRoots(roots, isPlainHtml) {
175
181
  const findings = [];
176
182
  const counts = { failed: 0, passed: 0, cantTell: 0 };
@@ -188,7 +194,7 @@ export function createLinter(data = loadData(), { wrappers = {}, severities: con
188
194
  message: rule.message,
189
195
  node,
190
196
  covers: [...(rule.removed ?? []), ...Object.keys(rule.fix?.value ?? {})],
191
- fix: isOurs(node, rule, isPlainHtml) ? rule.fix : undefined,
197
+ fix: isOurs(node, rule, isPlainHtml) && !(outcome === 'cantTell' && testsRemovedValue(rule)) ? rule.fix : undefined,
192
198
  });
193
199
  }
194
200
  }
package/lint/main.js CHANGED
@@ -5,15 +5,19 @@ import { dirname, extname, join, relative, resolve, sep } from 'node:path';
5
5
  import { parseArgs } from 'node:util';
6
6
  import { applyFixes, linesNaming, renameReferences } from './fix.js';
7
7
  import { formatGithub, formatJson, formatStatistics, formatText } from './format.js';
8
- import { BUILT_IN_RULES, createCanonical, loadData, GROUPS, resolveSeverities } from './rule-data.js';
8
+ import { BUILT_IN_RULES, createCanonical, loadData, GROUPS, OPT_IN_GROUPS, resolveSeverities } from './rule-data.js';
9
9
  import { rulesAboutTag } from './rule-index.js';
10
- import { applyBaseline, findFiles, IGNORED_DIRECTORIES, readBaseline, readConfig, REFERENCE_EXTENSIONS, writeBaseline } from './project.js';
10
+ import { applyBaseline, DEFAULT_EXTENSIONS, looseInBaseline, tightenBaseline, findFiles, IGNORED_DIRECTORIES, readBaseline, readConfig, REFERENCE_EXTENSIONS, STYLESHEET_EXTENSIONS, writeBaseline } from './project.js';
11
11
 
12
12
  const USAGE = `Usage:
13
13
  nldd lint [paths...] check files; without paths, the whole project
14
14
  --format text|json|github default: text
15
15
  --fix apply the fixes that are certain: what only got another name
16
+ --pure also check that everything comes from the system: no class,
17
+ style, plain HTML or stylesheet of your own (the group pure).
18
+ Reads every file, stylesheets included, so it takes longer
16
19
  --update-baseline accept what is there now, report only new findings
20
+ --tighten-baseline lower the baseline to what is still there; never raises it
17
21
  --max-warnings <n> exit 1 above this number of warnings
18
22
  --select <groups or rules> only these, comma separated
19
23
  --ignore <groups or rules> all but these
@@ -22,7 +26,7 @@ const USAGE = `Usage:
22
26
  nldd explain <rule> what a rule checks, and why
23
27
  nldd rules [--for <tag>] [--group <group>] [--json]
24
28
  list the rules, or those about one component or group
25
- groups: api, a11y, copy, structure, pattern
29
+ groups: api, a11y, copy, structure, pattern, pure (opt-in)
26
30
  `;
27
31
 
28
32
  const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
@@ -135,9 +139,13 @@ async function runLint(data, paths, options) {
135
139
  const chosen = { text: formatText, json: formatJson, github: formatGithub }[formatName];
136
140
  if (!chosen) throw new Error(`Unknown format: ${formatName}`);
137
141
  if (options.statistics && formatName !== 'text') throw new Error('--statistics is plain text, so it takes no --format.');
138
- if (options['update-baseline'] && (options.select || options.ignore)) {
139
- throw new Error('--update-baseline takes no --select or --ignore: it would forget every finding outside them.');
142
+ for (const flag of ['update-baseline', 'tighten-baseline']) {
143
+ if (options[flag] && (options.select || options.ignore)) {
144
+ throw new Error(`--${flag} takes no --select or --ignore: it would forget every finding outside them.`);
145
+ }
140
146
  }
147
+ if (options['update-baseline'] && options['tighten-baseline']) throw new Error('Choose --update-baseline or --tighten-baseline.');
148
+ if (options['tighten-baseline'] && options.stdin) throw new Error('--tighten-baseline reads the project, so it takes no --stdin.');
141
149
  const root = process.cwd();
142
150
  const started = performance.now();
143
151
  if (options.fix && (options.stdin || options['update-baseline'])) {
@@ -154,22 +162,30 @@ async function runLint(data, paths, options) {
154
162
  noteOtherVersion(root);
155
163
  const canonical = createCanonical(data);
156
164
 
165
+ const severities = resolveSeverities(data, config.rules, { select, ignore, optIn: options.pure ? OPT_IN_GROUPS : [] });
166
+ // An app that is to be pure has to be read in full: a file without a single component
167
+ // is the least pure of all, and a stylesheet is one too.
168
+ const pure = data.rules.some((rule) => OPT_IN_GROUPS.includes(rule.group) && severities[rule.id] !== 'off');
169
+ const extensions = pure ? [...DEFAULT_EXTENSIONS, ...STYLESHEET_EXTENSIONS] : DEFAULT_EXTENSIONS;
170
+
157
171
  const inputs = options.stdin
158
172
  ? [{ filename: resolve(root, options.filename ?? 'stdin.html'), source: readFileSync(0, 'utf8') }]
159
- : findFiles(paths, root, config.exclude).map((filename) => ({
173
+ : findFiles(paths, root, config.exclude, extensions).map((filename) => ({
160
174
  filename,
161
175
  source: readFileSync(filename, 'utf8'),
162
176
  }));
163
177
 
164
178
  // Most files in an app use no component at all, and those need no parser either.
165
- const relevant = inputs.filter(({ source }) => /nldd-|Nldd/.test(source) || config.wrappers);
179
+ // Tightening has to see every file the baseline names, also one without a component left.
180
+ const inBaseline = options['tighten-baseline'] ? new Set(Object.keys(readBaseline(root, canonical))) : new Set();
181
+ const relevant = pure ? inputs : inputs.filter(({ filename, source }) => /nldd-|Nldd/.test(source) || config.wrappers || inBaseline.has(relative(root, filename)));
166
182
  const results = [];
167
183
  let fixed = 0;
168
184
  let fixedFiles = 0;
169
185
  const renamedTags = new Map();
170
186
  if (relevant.length > 0) {
171
187
  const { createLinter } = await import('./linter.js');
172
- const linter = createLinter(data, { wrappers: config.wrappers, severities: resolveSeverities(data, config.rules, { select, ignore }) });
188
+ const linter = createLinter(data, { wrappers: config.wrappers, severities });
173
189
  for (const { filename, source } of relevant) {
174
190
  const canWrite = options.fix && isUtf8(filename);
175
191
  if (options.fix && !canWrite) console.error(`Skipped ${relative(root, filename)}: it is not UTF-8.`);
@@ -197,8 +213,16 @@ async function runLint(data, paths, options) {
197
213
  }
198
214
  }
199
215
 
216
+ // What a rule that did not run accepted stays accepted: one that is off, or the
217
+ // group pure in a run without it.
218
+ const ran = (id) => severities[id] !== 'off' && (!OPT_IN_GROUPS.includes(findRule(data, id)?.group) || Boolean(severities[id]));
219
+ if (options['tighten-baseline']) {
220
+ const dropped = tightenBaseline(results, root, canonical, ran);
221
+ console.log(dropped === undefined ? 'No baseline to tighten.' : `Baseline tightened: ${dropped} fewer findings accepted.`);
222
+ return 0;
223
+ }
200
224
  if (options['update-baseline']) {
201
- writeBaseline(results, root, canonical);
225
+ writeBaseline(results, root, canonical, ran);
202
226
  const accepted = results.flatMap(({ findings }) => findings).filter(({ severity }) => severity !== 'hint').length;
203
227
  console.log(`Baseline updated: ${accepted} findings accepted.`);
204
228
  return 0;
@@ -217,6 +241,7 @@ async function runLint(data, paths, options) {
217
241
  files: inputs.length,
218
242
  ms: Math.round(performance.now() - started),
219
243
  skipped,
244
+ loose: looseInBaseline(results, baseline, root, ran),
220
245
  explainRule: (id) => findRule(data, id),
221
246
  };
222
247
  const format = options.statistics ? formatStatistics : chosen;
@@ -237,6 +262,7 @@ async function main() {
237
262
  options: {
238
263
  format: { type: 'string' },
239
264
  'update-baseline': { type: 'boolean' },
265
+ 'tighten-baseline': { type: 'boolean' },
240
266
  'max-warnings': { type: 'string' },
241
267
  stdin: { type: 'boolean' },
242
268
  filename: { type: 'string' },
@@ -246,6 +272,7 @@ async function main() {
246
272
  ignore: { type: 'string' },
247
273
  statistics: { type: 'boolean' },
248
274
  fix: { type: 'boolean' },
275
+ pure: { type: 'boolean' },
249
276
  json: { type: 'boolean' },
250
277
  version: { type: 'boolean', short: 'v' },
251
278
  help: { type: 'boolean', short: 'h' },