ngwr 16.5.0 β†’ 16.6.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 (287) hide show
  1. package/back-top/styles/_index.scss +6 -0
  2. package/breadcrumbs/styles/_rules.scss +34 -0
  3. package/cascader/styles/_rules.scss +7 -0
  4. package/charts/chart-legend/styles/_index.scss +1 -9
  5. package/counter/styles/_index.scss +1 -8
  6. package/date-picker/styles/_index.scss +15 -9
  7. package/dialog/styles/_index.scss +37 -0
  8. package/editor/styles/_index.scss +1 -8
  9. package/event-calendar/styles/_index.scss +2 -6
  10. package/fesm2022/ngwr-affix.mjs +1 -1
  11. package/fesm2022/ngwr-affix.mjs.map +1 -1
  12. package/fesm2022/ngwr-anchor.mjs +9 -2
  13. package/fesm2022/ngwr-anchor.mjs.map +1 -1
  14. package/fesm2022/ngwr-animations-aurora.mjs.map +1 -1
  15. package/fesm2022/ngwr-animations-blur-reveal.mjs.map +1 -1
  16. package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
  17. package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
  18. package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
  19. package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
  20. package/fesm2022/ngwr-animations-dot-grid.mjs.map +1 -1
  21. package/fesm2022/ngwr-animations-falling-letters.mjs.map +1 -1
  22. package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
  23. package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
  24. package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
  25. package/fesm2022/ngwr-animations-glow-border.mjs.map +1 -1
  26. package/fesm2022/ngwr-animations-gradient-flow.mjs.map +1 -1
  27. package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
  28. package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
  29. package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
  30. package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
  31. package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
  32. package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
  33. package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
  34. package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
  35. package/fesm2022/ngwr-animations-tilt.mjs +20 -13
  36. package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
  37. package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
  38. package/fesm2022/ngwr-breadcrumbs.mjs +40 -7
  39. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  40. package/fesm2022/ngwr-button.mjs +12 -3
  41. package/fesm2022/ngwr-button.mjs.map +1 -1
  42. package/fesm2022/ngwr-carousel.mjs +8 -2
  43. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  44. package/fesm2022/ngwr-cascader.mjs +24 -4
  45. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  46. package/fesm2022/ngwr-charts-core.mjs +12 -5
  47. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  48. package/fesm2022/ngwr-charts-meter-group.mjs +4 -2
  49. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  50. package/fesm2022/ngwr-checkbox.mjs +3 -2
  51. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  52. package/fesm2022/ngwr-color-picker.mjs +21 -1
  53. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  54. package/fesm2022/ngwr-context-menu.mjs +4 -5
  55. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  56. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  57. package/fesm2022/ngwr-date-picker.mjs +49 -1
  58. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  59. package/fesm2022/ngwr-dialog.mjs +16 -6
  60. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  61. package/fesm2022/ngwr-directives.mjs +9 -6
  62. package/fesm2022/ngwr-directives.mjs.map +1 -1
  63. package/fesm2022/ngwr-event-calendar.mjs +20 -9
  64. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  65. package/fesm2022/ngwr-form.mjs +170 -3
  66. package/fesm2022/ngwr-form.mjs.map +1 -1
  67. package/fesm2022/ngwr-i18n-ar.mjs +15 -0
  68. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  69. package/fesm2022/ngwr-i18n-cs.mjs +15 -0
  70. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  71. package/fesm2022/ngwr-i18n-de.mjs +15 -0
  72. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  73. package/fesm2022/ngwr-i18n-en.mjs +15 -0
  74. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  75. package/fesm2022/ngwr-i18n-es.mjs +15 -0
  76. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  77. package/fesm2022/ngwr-i18n-fr.mjs +15 -0
  78. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  79. package/fesm2022/ngwr-i18n-he.mjs +15 -0
  80. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  81. package/fesm2022/ngwr-i18n-hi.mjs +15 -0
  82. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  83. package/fesm2022/ngwr-i18n-id.mjs +15 -0
  84. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  85. package/fesm2022/ngwr-i18n-it.mjs +15 -0
  86. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  87. package/fesm2022/ngwr-i18n-ja.mjs +15 -0
  88. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  89. package/fesm2022/ngwr-i18n-ko.mjs +15 -0
  90. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  91. package/fesm2022/ngwr-i18n-nl.mjs +15 -0
  92. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  93. package/fesm2022/ngwr-i18n-pl.mjs +15 -0
  94. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  95. package/fesm2022/ngwr-i18n-pt.mjs +15 -0
  96. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  97. package/fesm2022/ngwr-i18n-ru.mjs +15 -0
  98. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  99. package/fesm2022/ngwr-i18n-sv.mjs +15 -0
  100. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  101. package/fesm2022/ngwr-i18n-tr.mjs +15 -0
  102. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  103. package/fesm2022/ngwr-i18n-uk.mjs +15 -0
  104. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  105. package/fesm2022/ngwr-i18n-vi.mjs +15 -0
  106. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  107. package/fesm2022/ngwr-i18n-zh-tw.mjs +15 -0
  108. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  109. package/fesm2022/ngwr-i18n-zh.mjs +15 -0
  110. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  111. package/fesm2022/ngwr-i18n.mjs +82 -11
  112. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  113. package/fesm2022/ngwr-input-number.mjs +24 -1
  114. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  115. package/fesm2022/ngwr-input-otp.mjs +2 -2
  116. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  117. package/fesm2022/ngwr-input.mjs +10 -2
  118. package/fesm2022/ngwr-input.mjs.map +1 -1
  119. package/fesm2022/ngwr-layout.mjs.map +1 -1
  120. package/fesm2022/ngwr-list.mjs +1 -1
  121. package/fesm2022/ngwr-list.mjs.map +1 -1
  122. package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -1
  123. package/fesm2022/ngwr-loading-bar.mjs +2 -2
  124. package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
  125. package/fesm2022/ngwr-mention.mjs +8 -0
  126. package/fesm2022/ngwr-mention.mjs.map +1 -1
  127. package/fesm2022/ngwr-meta.mjs +9 -6
  128. package/fesm2022/ngwr-meta.mjs.map +1 -1
  129. package/fesm2022/ngwr-page-header.mjs +21 -0
  130. package/fesm2022/ngwr-page-header.mjs.map +1 -1
  131. package/fesm2022/ngwr-pagination.mjs +2 -0
  132. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  133. package/fesm2022/ngwr-pipes.mjs +8 -1
  134. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  135. package/fesm2022/ngwr-popconfirm.mjs +2 -1
  136. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  137. package/fesm2022/ngwr-popover.mjs +47 -3
  138. package/fesm2022/ngwr-popover.mjs.map +1 -1
  139. package/fesm2022/ngwr-qr.mjs +6 -2
  140. package/fesm2022/ngwr-qr.mjs.map +1 -1
  141. package/fesm2022/ngwr-radio.mjs +71 -5
  142. package/fesm2022/ngwr-radio.mjs.map +1 -1
  143. package/fesm2022/ngwr-schema-form.mjs +10 -1
  144. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  145. package/fesm2022/ngwr-scroll.mjs +1 -3
  146. package/fesm2022/ngwr-scroll.mjs.map +1 -1
  147. package/fesm2022/ngwr-segmented.mjs +20 -0
  148. package/fesm2022/ngwr-segmented.mjs.map +1 -1
  149. package/fesm2022/ngwr-select.mjs +80 -9
  150. package/fesm2022/ngwr-select.mjs.map +1 -1
  151. package/fesm2022/ngwr-sortable-list.mjs +16 -4
  152. package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
  153. package/fesm2022/ngwr-storage.mjs +1 -1
  154. package/fesm2022/ngwr-storage.mjs.map +1 -1
  155. package/fesm2022/ngwr-switch.mjs +2 -2
  156. package/fesm2022/ngwr-switch.mjs.map +1 -1
  157. package/fesm2022/ngwr-table.mjs +41 -7
  158. package/fesm2022/ngwr-table.mjs.map +1 -1
  159. package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
  160. package/fesm2022/ngwr-textarea.mjs +2 -2
  161. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  162. package/fesm2022/ngwr-toast.mjs +28 -0
  163. package/fesm2022/ngwr-toast.mjs.map +1 -1
  164. package/fesm2022/ngwr-tour.mjs +2 -2
  165. package/fesm2022/ngwr-tour.mjs.map +1 -1
  166. package/fesm2022/ngwr-typography.mjs +20 -0
  167. package/fesm2022/ngwr-typography.mjs.map +1 -1
  168. package/fesm2022/ngwr-utils-router.mjs.map +1 -1
  169. package/fesm2022/ngwr-utils.mjs +46 -4
  170. package/fesm2022/ngwr-utils.mjs.map +1 -1
  171. package/fesm2022/ngwr-validators.mjs +33 -1
  172. package/fesm2022/ngwr-validators.mjs.map +1 -1
  173. package/fesm2022/ngwr-version.mjs +1 -1
  174. package/fesm2022/ngwr-version.mjs.map +1 -1
  175. package/form/styles/_index.scss +37 -0
  176. package/graph/styles/_index.scss +1 -9
  177. package/i18n/ar.json +15 -0
  178. package/i18n/cs.json +15 -0
  179. package/i18n/de.json +15 -0
  180. package/i18n/en.json +15 -0
  181. package/i18n/es.json +15 -0
  182. package/i18n/fr.json +15 -0
  183. package/i18n/he.json +15 -0
  184. package/i18n/hi.json +15 -0
  185. package/i18n/id.json +15 -0
  186. package/i18n/it.json +15 -0
  187. package/i18n/ja.json +15 -0
  188. package/i18n/ko.json +15 -0
  189. package/i18n/nl.json +15 -0
  190. package/i18n/pl.json +15 -0
  191. package/i18n/pt.json +15 -0
  192. package/i18n/ru.json +15 -0
  193. package/i18n/sv.json +15 -0
  194. package/i18n/tr.json +15 -0
  195. package/i18n/uk.json +15 -0
  196. package/i18n/vi.json +15 -0
  197. package/i18n/zh-TW.json +15 -0
  198. package/i18n/zh.json +15 -0
  199. package/image-cropper/styles/_index.scss +1 -9
  200. package/input-number/styles/_index.scss +7 -0
  201. package/layout/styles/_index.scss +13 -1
  202. package/llms-full.txt +10 -10
  203. package/loading-bar/styles/_rules.scss +6 -0
  204. package/package.json +2 -2
  205. package/page-header/styles/_index.scss +18 -0
  206. package/popover/styles/_index.scss +7 -0
  207. package/schematics/use/symbol-map.json +2 -0
  208. package/segmented/styles/_index.scss +7 -0
  209. package/select/styles/_index.scss +7 -0
  210. package/sidebar/styles/_index.scss +6 -0
  211. package/skills/ngwr/references/catalog.md +1 -1
  212. package/sortable-list/styles/_rules.scss +1 -9
  213. package/speed-dial/styles/_index.scss +6 -0
  214. package/stepper/styles/_index.scss +1 -9
  215. package/table/styles/_index.scss +49 -0
  216. package/theme/_index.scss +12 -1
  217. package/theme/styles/_colors.scss +11 -0
  218. package/theme/styles/_contrast.scss +6 -0
  219. package/theme/styles/_index.scss +1 -0
  220. package/theme/styles/_mixins.scss +45 -0
  221. package/theme/styles/_print.scss +17 -0
  222. package/toast/styles/_index.scss +7 -0
  223. package/tour/styles/_index.scss +8 -0
  224. package/tree/styles/_index.scss +1 -9
  225. package/types/ngwr-anchor.d.ts +3 -0
  226. package/types/ngwr-animations-aurora.d.ts +6 -0
  227. package/types/ngwr-animations-blur-reveal.d.ts +6 -0
  228. package/types/ngwr-animations-click-sparks.d.ts +6 -0
  229. package/types/ngwr-animations-confetti.d.ts +6 -0
  230. package/types/ngwr-animations-decode.d.ts +6 -0
  231. package/types/ngwr-animations-destruct.d.ts +6 -0
  232. package/types/ngwr-animations-dot-grid.d.ts +6 -0
  233. package/types/ngwr-animations-falling-letters.d.ts +6 -0
  234. package/types/ngwr-animations-flow-lines.d.ts +6 -0
  235. package/types/ngwr-animations-fluid-cursor.d.ts +6 -0
  236. package/types/ngwr-animations-glitch.d.ts +6 -0
  237. package/types/ngwr-animations-glow-border.d.ts +6 -0
  238. package/types/ngwr-animations-gradient-flow.d.ts +6 -0
  239. package/types/ngwr-animations-marquee.d.ts +6 -0
  240. package/types/ngwr-animations-orbit.d.ts +6 -0
  241. package/types/ngwr-animations-reveal.d.ts +6 -0
  242. package/types/ngwr-animations-ripple-grid.d.ts +6 -0
  243. package/types/ngwr-animations-rotate-reveal.d.ts +6 -0
  244. package/types/ngwr-animations-shimmer.d.ts +6 -0
  245. package/types/ngwr-animations-spotlight.d.ts +6 -0
  246. package/types/ngwr-animations-thread-lines.d.ts +6 -0
  247. package/types/ngwr-animations-tilt.d.ts +10 -0
  248. package/types/ngwr-animations-typewriter.d.ts +6 -0
  249. package/types/ngwr-breadcrumbs.d.ts +25 -0
  250. package/types/ngwr-button.d.ts +23 -3
  251. package/types/ngwr-carousel.d.ts +2 -0
  252. package/types/ngwr-cascader.d.ts +7 -0
  253. package/types/ngwr-charts-core.d.ts +16 -0
  254. package/types/ngwr-charts-meter-group.d.ts +2 -0
  255. package/types/ngwr-checkbox.d.ts +1 -0
  256. package/types/ngwr-color-picker.d.ts +1 -0
  257. package/types/ngwr-context-menu.d.ts +1 -1
  258. package/types/ngwr-date-picker.d.ts +19 -0
  259. package/types/ngwr-dialog.d.ts +39 -8
  260. package/types/ngwr-directives.d.ts +12 -4
  261. package/types/ngwr-drawer.d.ts +1 -1
  262. package/types/ngwr-dropdown.d.ts +1 -1
  263. package/types/ngwr-event-calendar.d.ts +4 -0
  264. package/types/ngwr-form.d.ts +85 -1
  265. package/types/ngwr-i18n.d.ts +65 -5
  266. package/types/ngwr-input-number.d.ts +8 -0
  267. package/types/ngwr-input.d.ts +7 -0
  268. package/types/ngwr-layout.d.ts +1 -1
  269. package/types/ngwr-loading-bar-router.d.ts +6 -0
  270. package/types/ngwr-page-header.d.ts +23 -1
  271. package/types/ngwr-popconfirm.d.ts +1 -1
  272. package/types/ngwr-popover.d.ts +28 -4
  273. package/types/ngwr-radio.d.ts +47 -5
  274. package/types/ngwr-segmented.d.ts +7 -0
  275. package/types/ngwr-select.d.ts +57 -13
  276. package/types/ngwr-sortable-list.d.ts +20 -7
  277. package/types/ngwr-table.d.ts +58 -5
  278. package/types/ngwr-tabs-router.d.ts +6 -0
  279. package/types/ngwr-toast.d.ts +11 -0
  280. package/types/ngwr-tour.d.ts +0 -1
  281. package/types/ngwr-typography.d.ts +7 -0
  282. package/types/ngwr-utils-router.d.ts +6 -0
  283. package/types/ngwr-utils.d.ts +56 -2
  284. package/types/ngwr-validators.d.ts +49 -1
  285. package/types/ngwr-version.d.ts +1 -1
  286. package/typography/styles/_index.scss +4 -0
  287. package/window/styles/_index.scss +1 -9
@@ -48,3 +48,9 @@
48
48
  }
49
49
  }
50
50
  }
51
+
52
+ @media print {
53
+ .wr-back-top {
54
+ display: none;
55
+ }
56
+ }
@@ -23,6 +23,9 @@
23
23
  --wr-breadcrumbs-link-radius: var(--wr-border-radius-sm);
24
24
  --wr-breadcrumbs-current-gap: var(--wr-space-sm);
25
25
  --wr-breadcrumbs-current-font-weight: var(--wr-font-weight-semibold);
26
+ // Read only under `truncate`.
27
+ --wr-breadcrumbs-item-max-width: 16rem;
28
+ --wr-breadcrumbs-current-max-width: none;
26
29
 
27
30
  display: block;
28
31
  font-family: var(--wr-breadcrumbs-font-family);
@@ -90,4 +93,35 @@
90
93
  --wr-icon-size: 1rem;
91
94
  flex: 0 0 auto;
92
95
  }
96
+
97
+ // No box until `truncate`: what is projected stays a flex item of the anchor.
98
+ &__label {
99
+ display: contents;
100
+ }
101
+
102
+ // Opt-in (`truncate`): one line per item, cut inside the anchor so the
103
+ // separator and the focus ring stay whole.
104
+ &--truncate {
105
+ .wr-breadcrumbs__item,
106
+ .wr-breadcrumbs__link,
107
+ .wr-breadcrumbs__current {
108
+ min-inline-size: 0;
109
+ }
110
+
111
+ .wr-breadcrumbs__link {
112
+ max-inline-size: var(--wr-breadcrumbs-item-max-width);
113
+ }
114
+
115
+ .wr-breadcrumbs__current {
116
+ max-inline-size: var(--wr-breadcrumbs-current-max-width);
117
+ }
118
+
119
+ .wr-breadcrumbs__label {
120
+ display: block;
121
+ min-inline-size: 0;
122
+ overflow: hidden;
123
+ text-overflow: ellipsis;
124
+ white-space: nowrap;
125
+ }
126
+ }
93
127
  }
@@ -67,6 +67,13 @@
67
67
  height: 0;
68
68
  }
69
69
 
70
+ // Layout
71
+ &--block,
72
+ &:where([block]:not([block='false'])) {
73
+ display: grid;
74
+ width: 100%;
75
+ }
76
+
70
77
  &--disabled {
71
78
  --wr-cascader-color: var(--wr-color-on-surface-muted);
72
79
  --wr-cascader-bg: var(--wr-color-fill);
@@ -153,15 +153,7 @@
153
153
 
154
154
  // The word a hidden row of a legend that does not toggle carries for a screen reader.
155
155
  .wr-chart-legend__sr-only {
156
- position: absolute;
157
- width: 1px;
158
- height: 1px;
159
- padding: 0;
160
- margin: -1px;
161
- overflow: hidden;
162
- clip: rect(0, 0, 0, 0);
163
- white-space: nowrap;
164
- border: 0;
156
+ @include theme.visually-hidden;
165
157
  }
166
158
 
167
159
  .wr-chart-legend__item--hidden {
@@ -9,14 +9,7 @@
9
9
  color: var(--wr-color-on-surface);
10
10
 
11
11
  &__sr-only {
12
- position: absolute;
13
- width: 1px;
14
- height: 1px;
15
- margin: -1px;
16
- padding: 0;
17
- overflow: hidden;
18
- clip: rect(0, 0, 0, 0);
19
- border: 0;
12
+ @include theme.visually-hidden;
20
13
  }
21
14
 
22
15
  &__odo {
@@ -20,15 +20,7 @@
20
20
  // element per block, since a BEM class is public API: the range picker's is its own.
21
21
  .wr-date-picker__sr-only,
22
22
  .wr-date-range-picker__sr-only {
23
- position: absolute;
24
- width: 1px;
25
- height: 1px;
26
- padding: 0;
27
- margin: -1px;
28
- overflow: hidden;
29
- clip: rect(0, 0, 0, 0);
30
- white-space: nowrap;
31
- border: 0;
23
+ @include theme.visually-hidden;
32
24
  }
33
25
 
34
26
  .wr-date-picker {
@@ -40,6 +32,13 @@
40
32
  width: 100%;
41
33
  }
42
34
 
35
+ // Layout
36
+ &--block,
37
+ &:where([block]:not([block='false'])) {
38
+ display: block;
39
+ width: 100%;
40
+ }
41
+
43
42
  // Inner button β€” same affix sizing rules as wr-input-group's toggle.
44
43
  &__trigger {
45
44
  // Box of the calendar / clock glyph. It follows the control's font size, the
@@ -184,6 +183,13 @@
184
183
  width: 100%;
185
184
  }
186
185
 
186
+ // Layout
187
+ &--block,
188
+ &:where([block]:not([block='false'])) {
189
+ display: block;
190
+ width: 100%;
191
+ }
192
+
187
193
  // Each end shares the group's width so the pair reads as one control.
188
194
  &__input {
189
195
  flex: 1 1 0;
@@ -75,6 +75,9 @@
75
75
  --wr-dialog-radius: var(--wr-border-radius-lg);
76
76
  --wr-dialog-shadow: var(--wr-shadow-modal);
77
77
  --wr-dialog-min-width: 18rem;
78
+ --wr-dialog-width-sm: 28rem;
79
+ --wr-dialog-width-md: 40rem;
80
+ --wr-dialog-width-lg: 56rem;
78
81
  --wr-dialog-padding-y: var(--wr-space-lg);
79
82
  // One step down from `--wr-space-xl`. The conversion rounded the old 20px up
80
83
  // to 24 and the panel read too roomy; 16 is the nearest step the other way
@@ -138,6 +141,38 @@
138
141
  max-height: calc(100dvh - 2rem);
139
142
  }
140
143
 
144
+ // Written out, not looped: `gen:css-vars` reads the hooks from the source.
145
+ &--sm {
146
+ width: var(--wr-dialog-width-sm);
147
+
148
+ --wr-dialog-padding-y: var(--wr-space-md);
149
+ --wr-dialog-padding-x: var(--wr-space-md);
150
+ --wr-dialog-title-font-size: var(--wr-text-base);
151
+ --wr-dialog-content-font-size: var(--wr-text-sm);
152
+ --wr-dialog-content-line-height: var(--wr-text-sm-leading);
153
+ // The glyph steps down and the padding takes up the slack: the box stays
154
+ // 24px, the smallest target WCAG 2.5.8 allows.
155
+ --wr-dialog-close-font-size: var(--wr-text-sm);
156
+ --wr-dialog-close-padding: calc((1.5rem - var(--wr-text-sm)) / 2);
157
+ --wr-dialog-footer-gap: var(--wr-space-xs);
158
+ --wr-dialog-intent-size: 1rem;
159
+ }
160
+ &--md {
161
+ width: var(--wr-dialog-width-md);
162
+ }
163
+ &--lg {
164
+ width: var(--wr-dialog-width-lg);
165
+
166
+ --wr-dialog-padding-y: var(--wr-space-xl);
167
+ --wr-dialog-padding-x: var(--wr-space-xl);
168
+ --wr-dialog-title-font-size: var(--wr-text-xl);
169
+ --wr-dialog-content-font-size: var(--wr-text-lg);
170
+ --wr-dialog-content-line-height: var(--wr-text-lg-leading);
171
+ --wr-dialog-close-font-size: var(--wr-text-lg);
172
+ --wr-dialog-footer-gap: var(--wr-space-md);
173
+ --wr-dialog-intent-size: 1.5rem;
174
+ }
175
+
141
176
  // The component the service mounts sits BETWEEN this panel and the dialog's
142
177
  // own parts, and it is the panel's only flex item. Left a plain block it keeps
143
178
  // `min-height: auto` β€” whose automatic minimum size under flexbox is its
@@ -234,6 +269,8 @@
234
269
  }
235
270
 
236
271
  &__content {
272
+ // Takes the room a `height` leaves, so the footer sits on the panel's edge.
273
+ flex: 1 1 auto;
237
274
  padding: var(--wr-dialog-padding-y) var(--wr-dialog-padding-x);
238
275
  overflow: auto;
239
276
  color: var(--wr-color-on-surface);
@@ -419,14 +419,7 @@
419
419
  }
420
420
 
421
421
  &__sr-only {
422
- position: absolute;
423
- width: 1px;
424
- height: 1px;
425
- margin: -1px;
426
- padding: 0;
427
- overflow: hidden;
428
- clip: rect(0, 0, 0, 0);
429
- border: 0;
422
+ @include theme.visually-hidden;
430
423
  }
431
424
 
432
425
  // ProseMirror's own state classes, which it names and this stylesheet can only
@@ -362,13 +362,9 @@
362
362
  // name: the event titles and the "+N more" a sighted user reads would be missing
363
363
  // from it (WCAG 2.5.3, Label in Name).
364
364
  &__sr-only {
365
- position: absolute;
366
- width: 1px;
367
- height: 1px;
368
- overflow: hidden;
369
- clip: rect(0 0 0 0);
365
+ @include styles.visually-hidden;
366
+
370
367
  clip-path: inset(50%);
371
- white-space: nowrap;
372
368
  }
373
369
 
374
370
  &__daynum {
@@ -13,7 +13,7 @@ function scrollParent(el) {
13
13
  for (let node = el.parentElement; node !== null; node = node.parentElement) {
14
14
  if (node === document.body || node === document.documentElement) break;
15
15
  const style = getComputedStyle(node);
16
- if (/auto|scroll|overlay|hidden/.test(`${style.overflowY} ${style.overflowX}`) && node.scrollHeight > node.clientHeight) return node;
16
+ if (/auto|scroll|overlay|hidden/.test(`${style.overflowY} ${style.overflowX}`)) return node;
17
17
  }
18
18
  return null;
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-affix.mjs","names":[],"sources":["../../../projects/lib/affix/affix.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n Injector,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n output,\n} from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * The element a `position: sticky` host actually pins against.\n *\n * Walks up looking for an ancestor that scrolls β€” `overflow` anything but\n * `visible` on an axis, and a box that can actually be scrolled. `null` means\n * the document scroller, which is both what the browser uses and what\n * `IntersectionObserver` takes for \"the viewport\".\n *\n * A `getComputedStyle` read per ancestor, once per observer construction β€”\n * cheap, and the only way to answer the question: CSS resolves it internally\n * and exposes nothing.\n */\nfunction scrollParent(el: HTMLElement): HTMLElement | null {\n for (let node = el.parentElement; node !== null; node = node.parentElement) {\n if (node === document.body || node === document.documentElement) break;\n const style = getComputedStyle(node);\n const scrolls = /auto|scroll|overlay|hidden/.test(`${style.overflowY} ${style.overflowX}`);\n if (scrolls && node.scrollHeight > node.clientHeight) return node;\n }\n return null;\n}\n\n/**\n * Whether a parent lays its children out as flex or grid items, where a flow\n * sentinel is not inert: a flex container puts a `gap` on each side of it, and\n * a grid container gives it a cell of its own, shifting every item after it. A\n * computed value, so `inline-flex` and `inline-grid` answer the same.\n */\nfunction laysOutItems(parent: HTMLElement): boolean {\n return /\\b(?:inline-)?(?:flex|grid)\\b/.test(getComputedStyle(parent).display);\n}\n\n/**\n * Every out-of-flow affix in one parent shares that parent's containing-block\n * claim, so only the last one to leave gives it back β€” sticky group headers in\n * one filtered list come and go in any order. `inline` is the parent's own\n * inline `position`, kept only when the fallback in `claimContainer` wrote one.\n */\nconst containers = new WeakMap<HTMLElement, { count: number; inline: string | null }>();\n\n/**\n * Makes `parent` the containing block of the absolutely positioned sentinels\n * inside it, and returns the release.\n *\n * An absolute box scrolls with a scroller's content only when its containing\n * block sits inside that scroller, and the nearest positioned ancestor may well\n * be outside it β€” so inside a nested scroller the sentinel would hold still while\n * the host scrolled away, and the state would never flip.\n *\n * The parent is TAGGED rather than styled: `ngwr/affix` gives\n * `.wr-affix__container` its `position: relative` under `:where()`, at zero\n * specificity, so any position the author gives the parent still wins, a media\n * query included. An inline `position` would beat all of them for the\n * directive's whole lifetime. Only when nothing positions the parent once it is\n * tagged β€” the stylesheet is not loaded β€” is `relative` written inline, and the\n * last release puts the inline value back.\n */\nfunction claimContainer(parent: HTMLElement): () => void {\n let claim = containers.get(parent);\n if (!claim) {\n parent.classList.add('wr-affix__container');\n const positioned = /relative|absolute|fixed|sticky/.test(getComputedStyle(parent).position);\n claim = { count: 0, inline: positioned ? null : parent.style.position };\n if (!positioned) parent.style.position = 'relative';\n containers.set(parent, claim);\n }\n claim.count++;\n\n const held = claim;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n if (--held.count > 0) return;\n containers.delete(parent);\n parent.classList.remove('wr-affix__container');\n if (held.inline !== null && parent.style.position === 'relative') parent.style.position = held.inline;\n };\n}\n\n/**\n * Takes the sentinel out of a flex or grid parent's layout and keeps it on the\n * host's natural top edge. Returns the teardown.\n *\n * Absolutely positioned and zero-sized, so neither a gap nor a track is made\n * for it β€” which leaves its place to be measured. Two choices follow:\n *\n * - **The parent becomes the containing block** β€” see `claimContainer`.\n * - **The host is measured with sticky switched off.** A stuck element's\n * `offsetTop` already includes the sticky shift, and the sentinel marks the\n * line the host leaves its natural place at. Static and sticky lay out\n * identically in flow, so nothing else moves, and both writes land before\n * the next paint.\n *\n * Re-measured whenever the parent, the host or anything laid out before the host\n * changes size β€” those are what move the host's top β€” and whenever the parent's\n * children change: an element inserted above the host moves it without resizing\n * a fixed-height scroll panel, and becomes one more thing to watch.\n */\nfunction pinOutOfFlow(host: HTMLElement, parent: HTMLElement, sentinel: HTMLElement): () => void {\n const release = claimContainer(parent);\n\n const measure = (): void => {\n const position = host.style.position;\n host.style.position = 'static';\n const top = host.offsetTop;\n const left = host.offsetLeft;\n host.style.position = position;\n sentinel.style.top = `${top}px`;\n // Physical on purpose: `offsetLeft` is physical too, so the pair lines up in either direction.\n sentinel.style.left = `${left}px`;\n };\n measure();\n\n const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => measure());\n const watchLayout = (): void => {\n if (!resize) return;\n resize.disconnect();\n resize.observe(parent);\n for (let node: Element | null = host; node; node = node.previousElementSibling) {\n if (node !== sentinel) resize.observe(node);\n }\n };\n watchLayout();\n\n const children =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver(() => {\n watchLayout();\n measure();\n });\n children?.observe(parent, { childList: true });\n\n return () => {\n resize?.disconnect();\n children?.disconnect();\n release();\n };\n}\n\n/**\n * Stick-on-scroll directive. Combines native CSS `position: sticky` with\n * an `IntersectionObserver`-driven `wr-affix--active` state class, so consumers\n * can style the element differently while it's pinned (e.g. add a\n * shadow, change the background, shrink the height).\n *\n * The host gets `position: sticky; top: ${offsetTop}px;` inline. A tiny\n * sentinel `<div>` is inserted just before the host β€” when the sentinel\n * scrolls out of view, the host is \"stuck\" and gets `wr-affix--active`\n * + an `(wrAffixChange)` emission.\n *\n * In block layout the sentinel is a zero-height flow element. In a flex or grid\n * parent (read once, after the first render) it is absolutely positioned and\n * zero-sized instead, so it adds no gap and takes no grid cell. It is placed on\n * the host's natural top edge and re-placed when the parent, the host or an\n * element before the host resizes, or when the parent's children change. That\n * needs the parent as its containing block: the parent is tagged\n * `wr-affix__container`, which `ngwr/affix` makes `position: relative` at zero\n * specificity, so a position the author gives it still wins. The tag comes off\n * when the last affix in that parent is destroyed.\n *\n * Works inside any scroll container without configuration: CSS sticky picks\n * the nearest scrollable ancestor, and the observer watching for the pinned\n * state is given that same element as its root β€” see `scrollParent`. Without\n * that second half the two measured different lines, and the state never\n * flipped inside a nested scroller.\n *\n * @example\n * ```html\n * <header wrAffix [wrAffixOffsetTop]=\"0\">\n * <!-- adds a shadow once stuck -->\n * </header>\n * ```\n *\n * ```scss\n * header.wr-affix.wr-affix--active {\n * box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);\n * }\n * ```\n */\n@Directive({\n selector: '[wrAffix]',\n host: {\n class: 'wr-affix',\n '[style.position]': '\"sticky\"',\n '[style.top.px]': 'offsetTop()',\n },\n})\nexport class WrAffix {\n /** Pixels from the top of the scroll container when stuck. @default 0 */\n readonly offsetTop = input(0, {\n alias: 'wrAffixOffsetTop',\n transform: (v: unknown): number => coerceNumberProperty(v, 0),\n });\n\n /**\n * Fires when the element pins or unpins β€” `true` once it has stuck, `false`\n * when it returns to the flow. Use it to swap a shadow or a compact layout.\n */\n // eslint-disable-next-line @angular-eslint/no-output-rename -- keep wr-prefixed binding to match `[wrAffix]`\n readonly affixChange = output<boolean>({ alias: 'wrAffixChange' });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n /**\n * `afterNextRender`'s callback is not an injection context, and the observer\n * cannot exist before the sentinel it watches β€” so the effect that rebuilds it\n * is handed the injector explicitly.\n */\n private readonly injector = inject(Injector);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('affix');\n if (!this.isBrowser) return;\n\n afterNextRender(() => {\n const el = this.host.nativeElement;\n const parent = el.parentElement;\n if (!parent) return;\n\n // Sentinel: an empty zero-height block placed immediately before\n // the host. When the sentinel scrolls out of view, the host is\n // necessarily \"stuck\" at the configured offset.\n const sentinel = el.ownerDocument.createElement('div');\n sentinel.className = 'wr-affix__sentinel';\n sentinel.setAttribute('aria-hidden', 'true');\n // In a flex or grid parent a flow element is an item with a gap or a cell\n // of its own, so there it leaves the flow β€” see `pinOutOfFlow`.\n const outOfFlow = laysOutItems(parent);\n sentinel.style.cssText = outOfFlow\n ? 'position:absolute;width:0;height:0;margin:0;padding:0;pointer-events:none;'\n : 'height:0;width:100%;margin:0;padding:0;pointer-events:none;';\n parent.insertBefore(sentinel, el);\n const unpin = outOfFlow ? pinOutOfFlow(el, parent, sentinel) : null;\n\n // The observer reports STATE, not transitions: it delivers an entry for the\n // sentinel as soon as it starts watching it β€” before anything has scrolled β€”\n // and can repeat a state the host is already in (a resize, another crossing of\n // the same threshold). `affixChange` is documented as the transition, so it\n // only fires on one. The starting state is \"not affixed\", which is what the\n // element already renders as, so that first entry is silent.\n let affixed = false;\n\n let observer: IntersectionObserver | null = null;\n\n // `rootMargin` is fixed for an observer's lifetime, so a changed offset means\n // a NEW observer. Without this the two halves of the offset drifted apart:\n // `[style.top.px]` is a live binding, so a header that animates its offset\n // pinned at the new line while still flipping state at the old one.\n // Re-observing re-delivers the current state, which the transition guard\n // above absorbs when nothing has actually changed.\n effect(\n onCleanup => {\n const offset = this.offsetTop();\n\n // The observer's ROOT has to be the element the host sticks to, not\n // the viewport. `position: sticky` pins against the nearest\n // SCROLLING ancestor, and an observer with no root measures against\n // the viewport β€” so inside any nested scroller whose top sits below\n // the viewport's, `rootBounds.top` was 0 while the host pinned at\n // the container's own top. The direction guard below then computed\n // `false` at the one crossing it was ever handed, and because\n // `isIntersecting` stays false afterwards no further callback came:\n // `wr-affix--active` was never added and `(wrAffixChange)` never\n // emitted, for the whole scroll. The JSDoc promised the opposite β€”\n // \"works inside any scroll container without configuration\" β€” and\n // the docs page's own demo is exactly that shape.\n const root = scrollParent(el);\n\n observer = new IntersectionObserver(\n ([entry]) => {\n // NOT `!entry.isIntersecting` on its own. A sentinel is outside\n // the root in TWO directions, and only one of them means the\n // header has stuck: above the line because the page scrolled past\n // it, or below it because the host simply starts further down the\n // page than the first screen. The bare negation called both\n // \"affixed\", so any sticky element below the fold reported\n // `affixed = true` and painted `.wr-affix--active` on its very\n // first observer callback β€” before a pixel had scrolled β€” and\n // emitted a transition that never happened.\n //\n // `rootBounds.top` is the offset line (the negative `rootMargin`\n // above moves it), so a sentinel above it has genuinely gone by.\n const rootTop = entry.rootBounds?.top ?? offset;\n const next = !entry.isIntersecting && entry.boundingClientRect.top < rootTop;\n if (next === affixed) return;\n\n affixed = next;\n el.classList.toggle('wr-affix--active', next);\n this.affixChange.emit(next);\n },\n {\n // `null` is the document scroller, which is what the browser\n // uses for a host with no scrolling ancestor.\n root,\n // Trigger when the sentinel's top crosses the offset line. NEGATED\n // rather than prefixed with a minus: a negative offset is valid sticky\n // CSS (the host pins partly above the edge), and the prefix turned\n // `-10` into `--10px`, which the constructor refuses with a\n // SyntaxError β€” so the state never flipped at all. Negated, a\n // negative offset GROWS the root above its edge, which is where the\n // host pins.\n rootMargin: `${-offset}px 0px 0px 0px`,\n threshold: [0],\n }\n );\n observer.observe(sentinel);\n\n onCleanup(() => observer?.disconnect());\n },\n { injector: this.injector }\n );\n\n this.destroyRef.onDestroy(() => {\n observer?.disconnect();\n unpin?.();\n sentinel.remove();\n el.classList.remove('wr-affix--active');\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAoCA,SAAS,aAAa,IAAe;CACnC,KAAK,IAAI,OAAO,GAAG,eAAe,SAAS,MAAM,OAAO,KAAK,eAAe;EAC1E,IAAI,SAAS,SAAS,QAAQ,SAAS,SAAS,iBAAiB;EACjE,MAAM,QAAQ,iBAAiB,IAAI;EAEnC,IADgB,6BAA6B,KAAK,GAAG,MAAM,UAAS,GAAI,MAAM,WAC1E,KAAW,KAAK,eAAe,KAAK,cAAc,OAAO;CAC/D;CACA,OAAO;AACT;AAQA,SAAS,aAAa,QAAmB;CACvC,OAAO,gCAAgC,KAAK,iBAAiB,MAAM,CAAC,CAAC,OAAO;AAC9E;AAQA,MAAM,6BAAa,IAAI,QAAO;AAmB9B,SAAS,eAAe,QAAmB;CACzC,IAAI,QAAQ,WAAW,IAAI,MAAM;CACjC,IAAI,CAAC,OAAO;EACV,OAAO,UAAU,IAAI,qBA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CAAC,CAAC;IACd,CAAA;IAEH,SAAS,QAAQ,QAAQ;IAEzB,gBAAgB,UAAU,WAAU,CAAE;GACxC,GACA,EAAE,UAAU,KAAK,SAAQ,CAAE;GAG7B,KAAK,WAAW,gBAAe;IAC7B,UAAU,WAAU;IACpB,QAAO;IACP,SAAS,OAAM;IACf,GAAG,UAAU,OAAO,kBAAkB;GACxC,CAAC;EACH,CAAC;CACH;CArIW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAO,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAP,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAO,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,WAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,SAAA,EAAA,aAAA,gBAAA;EAAA,MAAA;GAAA,YAAA;IAAA,kBAAA;IAAA,gBAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;CAAA,CAAA;;AAAP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAO,YAAA,CAAA;EARnB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM;IACJ,OAAO;IACP,oBAAoB;IACpB,kBAAkB;GACnB;EACF,CAAA"}
1
+ {"version":3,"file":"ngwr-affix.mjs","names":[],"sources":["../../../projects/lib/affix/affix.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n Injector,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n output,\n} from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * The element a `position: sticky` host actually pins against.\n *\n * Walks up looking for an ancestor that scrolls β€” `overflow` anything but\n * `visible` on an axis. Not its current size: a list that loads later makes an\n * empty box scrollable after the observer is built. `null` means\n * the document scroller, which is both what the browser uses and what\n * `IntersectionObserver` takes for \"the viewport\".\n *\n * A `getComputedStyle` read per ancestor, once per observer construction β€”\n * cheap, and the only way to answer the question: CSS resolves it internally\n * and exposes nothing.\n */\nfunction scrollParent(el: HTMLElement): HTMLElement | null {\n for (let node = el.parentElement; node !== null; node = node.parentElement) {\n if (node === document.body || node === document.documentElement) break;\n const style = getComputedStyle(node);\n const scrolls = /auto|scroll|overlay|hidden/.test(`${style.overflowY} ${style.overflowX}`);\n if (scrolls) return node;\n }\n return null;\n}\n\n/**\n * Whether a parent lays its children out as flex or grid items, where a flow\n * sentinel is not inert: a flex container puts a `gap` on each side of it, and\n * a grid container gives it a cell of its own, shifting every item after it. A\n * computed value, so `inline-flex` and `inline-grid` answer the same.\n */\nfunction laysOutItems(parent: HTMLElement): boolean {\n return /\\b(?:inline-)?(?:flex|grid)\\b/.test(getComputedStyle(parent).display);\n}\n\n/**\n * Every out-of-flow affix in one parent shares that parent's containing-block\n * claim, so only the last one to leave gives it back β€” sticky group headers in\n * one filtered list come and go in any order. `inline` is the parent's own\n * inline `position`, kept only when the fallback in `claimContainer` wrote one.\n */\nconst containers = new WeakMap<HTMLElement, { count: number; inline: string | null }>();\n\n/**\n * Makes `parent` the containing block of the absolutely positioned sentinels\n * inside it, and returns the release.\n *\n * An absolute box scrolls with a scroller's content only when its containing\n * block sits inside that scroller, and the nearest positioned ancestor may well\n * be outside it β€” so inside a nested scroller the sentinel would hold still while\n * the host scrolled away, and the state would never flip.\n *\n * The parent is TAGGED rather than styled: `ngwr/affix` gives\n * `.wr-affix__container` its `position: relative` under `:where()`, at zero\n * specificity, so any position the author gives the parent still wins, a media\n * query included. An inline `position` would beat all of them for the\n * directive's whole lifetime. Only when nothing positions the parent once it is\n * tagged β€” the stylesheet is not loaded β€” is `relative` written inline, and the\n * last release puts the inline value back.\n */\nfunction claimContainer(parent: HTMLElement): () => void {\n let claim = containers.get(parent);\n if (!claim) {\n parent.classList.add('wr-affix__container');\n const positioned = /relative|absolute|fixed|sticky/.test(getComputedStyle(parent).position);\n claim = { count: 0, inline: positioned ? null : parent.style.position };\n if (!positioned) parent.style.position = 'relative';\n containers.set(parent, claim);\n }\n claim.count++;\n\n const held = claim;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n if (--held.count > 0) return;\n containers.delete(parent);\n parent.classList.remove('wr-affix__container');\n if (held.inline !== null && parent.style.position === 'relative') parent.style.position = held.inline;\n };\n}\n\n/**\n * Takes the sentinel out of a flex or grid parent's layout and keeps it on the\n * host's natural top edge. Returns the teardown.\n *\n * Absolutely positioned and zero-sized, so neither a gap nor a track is made\n * for it β€” which leaves its place to be measured. Two choices follow:\n *\n * - **The parent becomes the containing block** β€” see `claimContainer`.\n * - **The host is measured with sticky switched off.** A stuck element's\n * `offsetTop` already includes the sticky shift, and the sentinel marks the\n * line the host leaves its natural place at. Static and sticky lay out\n * identically in flow, so nothing else moves, and both writes land before\n * the next paint.\n *\n * Re-measured whenever the parent, the host or anything laid out before the host\n * changes size β€” those are what move the host's top β€” and whenever the parent's\n * children change: an element inserted above the host moves it without resizing\n * a fixed-height scroll panel, and becomes one more thing to watch.\n */\nfunction pinOutOfFlow(host: HTMLElement, parent: HTMLElement, sentinel: HTMLElement): () => void {\n const release = claimContainer(parent);\n\n const measure = (): void => {\n const position = host.style.position;\n host.style.position = 'static';\n const top = host.offsetTop;\n const left = host.offsetLeft;\n host.style.position = position;\n sentinel.style.top = `${top}px`;\n // Physical on purpose: `offsetLeft` is physical too, so the pair lines up in either direction.\n sentinel.style.left = `${left}px`;\n };\n measure();\n\n const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => measure());\n const watchLayout = (): void => {\n if (!resize) return;\n resize.disconnect();\n resize.observe(parent);\n for (let node: Element | null = host; node; node = node.previousElementSibling) {\n if (node !== sentinel) resize.observe(node);\n }\n };\n watchLayout();\n\n const children =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver(() => {\n watchLayout();\n measure();\n });\n children?.observe(parent, { childList: true });\n\n return () => {\n resize?.disconnect();\n children?.disconnect();\n release();\n };\n}\n\n/**\n * Stick-on-scroll directive. Combines native CSS `position: sticky` with\n * an `IntersectionObserver`-driven `wr-affix--active` state class, so consumers\n * can style the element differently while it's pinned (e.g. add a\n * shadow, change the background, shrink the height).\n *\n * The host gets `position: sticky; top: ${offsetTop}px;` inline. A tiny\n * sentinel `<div>` is inserted just before the host β€” when the sentinel\n * scrolls out of view, the host is \"stuck\" and gets `wr-affix--active`\n * + an `(wrAffixChange)` emission.\n *\n * In block layout the sentinel is a zero-height flow element. In a flex or grid\n * parent (read once, after the first render) it is absolutely positioned and\n * zero-sized instead, so it adds no gap and takes no grid cell. It is placed on\n * the host's natural top edge and re-placed when the parent, the host or an\n * element before the host resizes, or when the parent's children change. That\n * needs the parent as its containing block: the parent is tagged\n * `wr-affix__container`, which `ngwr/affix` makes `position: relative` at zero\n * specificity, so a position the author gives it still wins. The tag comes off\n * when the last affix in that parent is destroyed.\n *\n * Works inside any scroll container without configuration: CSS sticky picks\n * the nearest scrollable ancestor, and the observer watching for the pinned\n * state is given that same element as its root β€” see `scrollParent`. Without\n * that second half the two measured different lines, and the state never\n * flipped inside a nested scroller.\n *\n * @example\n * ```html\n * <header wrAffix [wrAffixOffsetTop]=\"0\">\n * <!-- adds a shadow once stuck -->\n * </header>\n * ```\n *\n * ```scss\n * header.wr-affix.wr-affix--active {\n * box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);\n * }\n * ```\n */\n@Directive({\n selector: '[wrAffix]',\n host: {\n class: 'wr-affix',\n '[style.position]': '\"sticky\"',\n '[style.top.px]': 'offsetTop()',\n },\n})\nexport class WrAffix {\n /** Pixels from the top of the scroll container when stuck. @default 0 */\n readonly offsetTop = input(0, {\n alias: 'wrAffixOffsetTop',\n transform: (v: unknown): number => coerceNumberProperty(v, 0),\n });\n\n /**\n * Fires when the element pins or unpins β€” `true` once it has stuck, `false`\n * when it returns to the flow. Use it to swap a shadow or a compact layout.\n */\n // eslint-disable-next-line @angular-eslint/no-output-rename -- keep wr-prefixed binding to match `[wrAffix]`\n readonly affixChange = output<boolean>({ alias: 'wrAffixChange' });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n /**\n * `afterNextRender`'s callback is not an injection context, and the observer\n * cannot exist before the sentinel it watches β€” so the effect that rebuilds it\n * is handed the injector explicitly.\n */\n private readonly injector = inject(Injector);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('affix');\n if (!this.isBrowser) return;\n\n afterNextRender(() => {\n const el = this.host.nativeElement;\n const parent = el.parentElement;\n if (!parent) return;\n\n // Sentinel: an empty zero-height block placed immediately before\n // the host. When the sentinel scrolls out of view, the host is\n // necessarily \"stuck\" at the configured offset.\n const sentinel = el.ownerDocument.createElement('div');\n sentinel.className = 'wr-affix__sentinel';\n sentinel.setAttribute('aria-hidden', 'true');\n // In a flex or grid parent a flow element is an item with a gap or a cell\n // of its own, so there it leaves the flow β€” see `pinOutOfFlow`.\n const outOfFlow = laysOutItems(parent);\n sentinel.style.cssText = outOfFlow\n ? 'position:absolute;width:0;height:0;margin:0;padding:0;pointer-events:none;'\n : 'height:0;width:100%;margin:0;padding:0;pointer-events:none;';\n parent.insertBefore(sentinel, el);\n const unpin = outOfFlow ? pinOutOfFlow(el, parent, sentinel) : null;\n\n // The observer reports STATE, not transitions: it delivers an entry for the\n // sentinel as soon as it starts watching it β€” before anything has scrolled β€”\n // and can repeat a state the host is already in (a resize, another crossing of\n // the same threshold). `affixChange` is documented as the transition, so it\n // only fires on one. The starting state is \"not affixed\", which is what the\n // element already renders as, so that first entry is silent.\n let affixed = false;\n\n let observer: IntersectionObserver | null = null;\n\n // `rootMargin` is fixed for an observer's lifetime, so a changed offset means\n // a NEW observer. Without this the two halves of the offset drifted apart:\n // `[style.top.px]` is a live binding, so a header that animates its offset\n // pinned at the new line while still flipping state at the old one.\n // Re-observing re-delivers the current state, which the transition guard\n // above absorbs when nothing has actually changed.\n effect(\n onCleanup => {\n const offset = this.offsetTop();\n\n // The observer's ROOT has to be the element the host sticks to, not\n // the viewport. `position: sticky` pins against the nearest\n // SCROLLING ancestor, and an observer with no root measures against\n // the viewport β€” so inside any nested scroller whose top sits below\n // the viewport's, `rootBounds.top` was 0 while the host pinned at\n // the container's own top. The direction guard below then computed\n // `false` at the one crossing it was ever handed, and because\n // `isIntersecting` stays false afterwards no further callback came:\n // `wr-affix--active` was never added and `(wrAffixChange)` never\n // emitted, for the whole scroll. The JSDoc promised the opposite β€”\n // \"works inside any scroll container without configuration\" β€” and\n // the docs page's own demo is exactly that shape.\n const root = scrollParent(el);\n\n observer = new IntersectionObserver(\n ([entry]) => {\n // NOT `!entry.isIntersecting` on its own. A sentinel is outside\n // the root in TWO directions, and only one of them means the\n // header has stuck: above the line because the page scrolled past\n // it, or below it because the host simply starts further down the\n // page than the first screen. The bare negation called both\n // \"affixed\", so any sticky element below the fold reported\n // `affixed = true` and painted `.wr-affix--active` on its very\n // first observer callback β€” before a pixel had scrolled β€” and\n // emitted a transition that never happened.\n //\n // `rootBounds.top` is the offset line (the negative `rootMargin`\n // above moves it), so a sentinel above it has genuinely gone by.\n const rootTop = entry.rootBounds?.top ?? offset;\n const next = !entry.isIntersecting && entry.boundingClientRect.top < rootTop;\n if (next === affixed) return;\n\n affixed = next;\n el.classList.toggle('wr-affix--active', next);\n this.affixChange.emit(next);\n },\n {\n // `null` is the document scroller, which is what the browser\n // uses for a host with no scrolling ancestor.\n root,\n // Trigger when the sentinel's top crosses the offset line. NEGATED\n // rather than prefixed with a minus: a negative offset is valid sticky\n // CSS (the host pins partly above the edge), and the prefix turned\n // `-10` into `--10px`, which the constructor refuses with a\n // SyntaxError β€” so the state never flipped at all. Negated, a\n // negative offset GROWS the root above its edge, which is where the\n // host pins.\n rootMargin: `${-offset}px 0px 0px 0px`,\n threshold: [0],\n }\n );\n observer.observe(sentinel);\n\n onCleanup(() => observer?.disconnect());\n },\n { injector: this.injector }\n );\n\n this.destroyRef.onDestroy(() => {\n observer?.disconnect();\n unpin?.();\n sentinel.remove();\n el.classList.remove('wr-affix--active');\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAqCA,SAAS,aAAa,IAAe;CACnC,KAAK,IAAI,OAAO,GAAG,eAAe,SAAS,MAAM,OAAO,KAAK,eAAe;EAC1E,IAAI,SAAS,SAAS,QAAQ,SAAS,SAAS,iBAAiB;EACjE,MAAM,QAAQ,iBAAiB,IAAI;EAEnC,IADgB,6BAA6B,KAAK,GAAG,MAAM,UAAS,GAAI,MAAM,WAC1E,GAAS,OAAO;CACtB;CACA,OAAO;AACT;AAQA,SAAS,aAAa,QAAmB;CACvC,OAAO,gCAAgC,KAAK,iBAAiB,MAAM,CAAC,CAAC,OAAO;AAC9E;AAQA,MAAM,6BAAa,IAAI,QAAO;AAmB9B,SAAS,eAAe,QAAmB;CACzC,IAAI,QAAQ,WAAW,IAAI,MAAM;CACjC,IAAI,CAAC,OAAO;EACV,OAAO,UAAU,IAAI,qBAAqB;EAC1C,MAAM,aAAa,iCAAiC,KAAK,iBAAiB,MAAM,CAAC,CAAC,QAAQ;EAC1F,QAAQ;GAAE,OAAO;GAAG,QAAQ,aAAa,OAAO,OAAO,MAAM;EAAQ;EACrE,IAAI,CAAC,YAAY,OAAO,MAAM,WAAW;EACzC,WAAW,IAAI,QAAQ,KAAK;CAC9B;CACA,MAAM;CAEN,MAAM,OAAO;CACb,IAAI,WAAW;CACf,aAAY;EACV,IAAI,UAAU;EACd,WAAW;EACX,IAAI,EAAE,KAAK,QAAQ,GAAG;EACtB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,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAP,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAO,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,WAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,SAAA,EAAA,aAAA,gBAAA;EAAA,MAAA;GAAA,YAAA;IAAA,kBAAA;IAAA,gBAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;CAAA,CAAA;;AAAP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAO,YAAA,CAAA;EARnB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM;IACJ,OAAO;IACP,oBAAoB;IACpB,kBAAkB;GACnB;EACF,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { Component, DestroyRef, NgZone, ViewEncapsulation, afterNextRender, computed, inject, input, signal } from "@angular/core";
3
3
  import { coerceNumberProperty } from "@angular/cdk/coercion";
4
+ import { DOCUMENT as DOCUMENT$1 } from "@angular/common";
4
5
  import { wrCheckStyles } from "ngwr/utils";
5
6
  import { useI18nText } from "ngwr/i18n";
6
7
  import { WrPlatform } from "ngwr/platform";
@@ -34,6 +35,7 @@ var WrAnchor = class WrAnchor {
34
35
  }, ...ngDevMode ? [{ debugName: "flatIds" }] : /* istanbul ignore next */ []);
35
36
  scroll = inject(WrScroll);
36
37
  platform = inject(WrPlatform);
38
+ doc = inject(DOCUMENT$1);
37
39
  zone = inject(NgZone);
38
40
  destroyRef = inject(DestroyRef);
39
41
  pinned = null;
@@ -79,7 +81,12 @@ var WrAnchor = class WrAnchor {
79
81
  });
80
82
  afterNextRender(() => measure());
81
83
  }
84
+ hrefFor(id) {
85
+ const location = this.doc.location;
86
+ return `${location?.pathname ?? ""}${location?.search ?? ""}#${id}`;
87
+ }
82
88
  onClick(id, event) {
89
+ if (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;
83
90
  event.preventDefault();
84
91
  const target = document.getElementById(id);
85
92
  if (target) {
@@ -145,7 +152,7 @@ var WrAnchor = class WrAnchor {
145
152
  classAttribute: "wr-anchor"
146
153
  },
147
154
  ngImport: i0,
148
- template: "<ul class=\"wr-anchor__list\">\n @for (link of links(); track link.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === link.id\"\n [attr.aria-current]=\"activeId() === link.id ? 'location' : null\"\n [href]=\"`#${link.id}`\"\n (click)=\"onClick(link.id, $event)\"\n >\n {{ link.label }}\n </a>\n @if (link.children?.length) {\n <ul class=\"wr-anchor__list wr-anchor__list--nested\">\n @for (child of link.children; track child.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === child.id\"\n [attr.aria-current]=\"activeId() === child.id ? 'location' : null\"\n [href]=\"`#${child.id}`\"\n (click)=\"onClick(child.id, $event)\"\n >\n {{ child.label }}\n </a>\n </li>\n }\n </ul>\n }\n </li>\n }\n</ul>\n",
155
+ template: "<ul class=\"wr-anchor__list\">\n @for (link of links(); track link.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === link.id\"\n [attr.aria-current]=\"activeId() === link.id ? 'location' : null\"\n [href]=\"hrefFor(link.id)\"\n (click)=\"onClick(link.id, $event)\"\n >\n {{ link.label }}\n </a>\n @if (link.children?.length) {\n <ul class=\"wr-anchor__list wr-anchor__list--nested\">\n @for (child of link.children; track child.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === child.id\"\n [attr.aria-current]=\"activeId() === child.id ? 'location' : null\"\n [href]=\"hrefFor(child.id)\"\n (click)=\"onClick(child.id, $event)\"\n >\n {{ child.label }}\n </a>\n </li>\n }\n </ul>\n }\n </li>\n }\n</ul>\n",
149
156
  encapsulation: i0.ViewEncapsulation.None
150
157
  });
151
158
  };
@@ -164,7 +171,7 @@ i0.Ι΅Ι΅ngDeclareClassMetadata({
164
171
  role: "navigation",
165
172
  "[attr.aria-label]": "resolvedAriaLabel()"
166
173
  },
167
- template: "<ul class=\"wr-anchor__list\">\n @for (link of links(); track link.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === link.id\"\n [attr.aria-current]=\"activeId() === link.id ? 'location' : null\"\n [href]=\"`#${link.id}`\"\n (click)=\"onClick(link.id, $event)\"\n >\n {{ link.label }}\n </a>\n @if (link.children?.length) {\n <ul class=\"wr-anchor__list wr-anchor__list--nested\">\n @for (child of link.children; track child.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === child.id\"\n [attr.aria-current]=\"activeId() === child.id ? 'location' : null\"\n [href]=\"`#${child.id}`\"\n (click)=\"onClick(child.id, $event)\"\n >\n {{ child.label }}\n </a>\n </li>\n }\n </ul>\n }\n </li>\n }\n</ul>\n"
174
+ template: "<ul class=\"wr-anchor__list\">\n @for (link of links(); track link.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === link.id\"\n [attr.aria-current]=\"activeId() === link.id ? 'location' : null\"\n [href]=\"hrefFor(link.id)\"\n (click)=\"onClick(link.id, $event)\"\n >\n {{ link.label }}\n </a>\n @if (link.children?.length) {\n <ul class=\"wr-anchor__list wr-anchor__list--nested\">\n @for (child of link.children; track child.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === child.id\"\n [attr.aria-current]=\"activeId() === child.id ? 'location' : null\"\n [href]=\"hrefFor(child.id)\"\n (click)=\"onClick(child.id, $event)\"\n >\n {{ child.label }}\n </a>\n </li>\n }\n </ul>\n }\n </li>\n }\n</ul>\n"
168
175
  }]
169
176
  }],
170
177
  ctorParameters: () => [],
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-anchor.mjs","names":[],"sources":["../../../projects/lib/anchor/anchor.ts","../../../projects/lib/anchor/anchor.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n NgZone,\n ViewEncapsulation,\n afterNextRender,\n computed,\n inject,\n input,\n signal,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrPlatform } from 'ngwr/platform';\nimport { WrScroll } from 'ngwr/scroll';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrAnchorLink } from './types';\n\n/**\n * Scroll-spy in-page navigation. Renders a list of links to elements on\n * the page; clicking a link smooth-scrolls (via {@link WrScroll}),\n * and the closest visible heading auto-highlights as the user scrolls.\n *\n * @example\n * ```html\n * <wr-anchor\n * [links]=\"[\n * { id: 'intro', label: 'Introduction' },\n * { id: 'usage', label: 'Usage', children: [\n * { id: 'basic', label: 'Basic' },\n * { id: 'advanced', label: 'Advanced' },\n * ]}\n * ]\"\n * [offset]=\"80\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/anchor\n */\n@Component({\n selector: 'wr-anchor',\n templateUrl: './anchor.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-anchor', role: 'navigation', '[attr.aria-label]': 'resolvedAriaLabel()' },\n})\nexport class WrAnchor {\n /**\n * The entries, in DOCUMENT ORDER β€” the scroll spy walks them top to bottom\n * and stops at the first target below the cursor line, so a list in any other\n * order highlights the wrong entry.\n */\n readonly links = input<readonly WrAnchorLink[]>([]);\n\n /**\n * Accessible name for the navigation landmark. Falls back to `anchor.label`,\n * then `'Table of contents'` β€” it used to be that English string, hard-coded\n * on the host, in a landmark a screen reader reads out on every page.\n */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'anchor.label', 'Table of contents');\n\n /** Pixel offset subtracted on scroll β€” for sticky headers. @default 0 */\n readonly offset = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /** Highlight an item when its target's top is within this many px of the offset line. @default 80 */\n readonly hitArea = input(80, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 80)) });\n\n protected readonly activeId = signal<string | null>(null);\n\n /**\n * Flat list of the ids the template RENDERS β€” top level plus one level of\n * children, which is the nesting `WrAnchorLink` documents. It used to recurse\n * all the way down, so a third level was spied on and drawn nowhere: scrolling\n * through a grandchild made it active, no rendered link matched the id, and\n * the highlight vanished for that whole region rather than resting on its\n * parent.\n */\n protected readonly flatIds = computed<readonly string[]>(() => {\n const out: string[] = [];\n for (const item of this.links()) {\n out.push(item.id);\n for (const child of item.children ?? []) out.push(child.id);\n }\n return out;\n });\n\n private readonly scroll = inject(WrScroll);\n private readonly platform = inject(WrPlatform);\n private readonly zone = inject(NgZone);\n private readonly destroyRef = inject(DestroyRef);\n\n /**\n * The entry a click asked for, and the scroll position that click sends the\n * page to. A target near the end of the page can never reach the cursor line β€”\n * the page runs out of scroll first β€” so the spy took the highlight straight\n * back from the entry just clicked and handed it to the one above. While the\n * page is still travelling toward that position, or parked on it, the clicked\n * entry stays lit; the first scroll AWAY from it is the reader's own, and the\n * spy takes over again.\n */\n private pinned: { readonly id: string; readonly y: number } | null = null;\n private lastY = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('anchor');\n if (!this.platform.isBrowser) return;\n const measure = (): void => {\n const y = window.scrollY;\n const pin = this.pinned;\n if (pin) {\n const distance = Math.abs(pin.y - y);\n if (distance <= 1 || distance < Math.abs(pin.y - this.lastY)) {\n this.lastY = y;\n if (pin.id !== this.activeId()) this.zone.run(() => this.activeId.set(pin.id));\n return;\n }\n this.pinned = null;\n }\n this.lastY = y;\n const cursor = this.offset() + this.hitArea();\n let active: string | null = null;\n for (const id of this.flatIds()) {\n const el = document.getElementById(id);\n if (!el) continue;\n const top = el.getBoundingClientRect().top;\n if (top <= cursor) active = id;\n else break;\n }\n if (active !== this.activeId()) this.zone.run(() => this.activeId.set(active));\n };\n let frame = 0;\n const handler = (): void => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n measure();\n });\n };\n this.zone.runOutsideAngular(() => window.addEventListener('scroll', handler, { passive: true }));\n this.destroyRef.onDestroy(() => {\n window.removeEventListener('scroll', handler);\n if (frame) cancelAnimationFrame(frame);\n });\n // The first pass has to wait for a render: the targets are elsewhere on the\n // page and are usually rendered AFTER this list, so a constructor-time pass\n // found nothing by `getElementById` and left the page with no highlight at\n // all until the reader happened to scroll.\n afterNextRender(() => measure());\n }\n\n protected onClick(id: string, event: MouseEvent): void {\n event.preventDefault();\n const target = document.getElementById(id);\n if (target) {\n // Where `WrScroll` sends the page, clamped the way the browser clamps it.\n const root = document.documentElement;\n const max = Math.max(0, root.scrollHeight - root.clientHeight);\n const y = target.getBoundingClientRect().top + window.scrollY - this.offset();\n this.pinned = { id, y: Math.min(max, Math.max(0, y)) };\n this.lastY = window.scrollY;\n }\n this.scroll.to(`#${id}`, { offset: this.offset() });\n this.activeId.set(id);\n }\n}\n\nexport type { WrAnchorLink } from './types';\n","<ul class=\"wr-anchor__list\">\n @for (link of links(); track link.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === link.id\"\n [attr.aria-current]=\"activeId() === link.id ? 'location' : null\"\n [href]=\"`#${link.id}`\"\n (click)=\"onClick(link.id, $event)\"\n >\n {{ link.label }}\n </a>\n @if (link.children?.length) {\n <ul class=\"wr-anchor__list wr-anchor__list--nested\">\n @for (child of link.children; track child.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === child.id\"\n [attr.aria-current]=\"activeId() === child.id ? 'location' : null\"\n [href]=\"`#${child.id}`\"\n (click)=\"onClick(child.id, $event)\"\n >\n {{ child.label }}\n </a>\n </li>\n }\n </ul>\n }\n </li>\n }\n</ul>\n"],"mappings":";;;;;;;;;;;;;AAsDA,IAAa,WAAb,MAAa,SAAQ;CAMV,QAAQ,MAA+B,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAO1C,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,gBAAgB,mBAAmB;CAG7F,SAAS,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,SAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,GAAG,qBAAqB,GAAG,CAAC,CAAC;CAAC,CAAA;CAG9F,UAAU,MAAM,IAAE;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,GAAG,qBAAqB,GAAG,EAAE,CAAC;CAAC,CAAA;CAEvF,WAAW,OAAsB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAUtC,UAAU,eAAiC;EAC5D,MAAM,MAAgB,CAAA;EACtB,KAAK,MAAM,QAAQ,KAAK,MAAK,GAAI;GAC/B,IAAI,KAAK,KAAK,EAAE;GAChB,KAAK,MAAM,SAAS,KAAK,YAAY,CAAA,GAAI,IAAI,KAAK,MAAM,EAAE;EAC5D;EACA,OAAO;CACT,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAEe,SAAS,OAAO,QAAQ;CACxB,WAAW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AAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EANpB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAW,eAEN,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAa,MAAM;IAAc,qBAAqB;GAAqB;GAAE,UAAA;EAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-anchor.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/anchor/anchor.ts","../../../projects/lib/anchor/anchor.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { DOCUMENT } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n NgZone,\n ViewEncapsulation,\n afterNextRender,\n computed,\n inject,\n input,\n signal,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrPlatform } from 'ngwr/platform';\nimport { WrScroll } from 'ngwr/scroll';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrAnchorLink } from './types';\n\n/**\n * Scroll-spy in-page navigation. Renders a list of links to elements on\n * the page; clicking a link smooth-scrolls (via {@link WrScroll}),\n * and the closest visible heading auto-highlights as the user scrolls.\n *\n * @example\n * ```html\n * <wr-anchor\n * [links]=\"[\n * { id: 'intro', label: 'Introduction' },\n * { id: 'usage', label: 'Usage', children: [\n * { id: 'basic', label: 'Basic' },\n * { id: 'advanced', label: 'Advanced' },\n * ]}\n * ]\"\n * [offset]=\"80\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/anchor\n */\n@Component({\n selector: 'wr-anchor',\n templateUrl: './anchor.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-anchor', role: 'navigation', '[attr.aria-label]': 'resolvedAriaLabel()' },\n})\nexport class WrAnchor {\n /**\n * The entries, in DOCUMENT ORDER β€” the scroll spy walks them top to bottom\n * and stops at the first target below the cursor line, so a list in any other\n * order highlights the wrong entry.\n */\n readonly links = input<readonly WrAnchorLink[]>([]);\n\n /**\n * Accessible name for the navigation landmark. Falls back to `anchor.label`,\n * then `'Table of contents'` β€” it used to be that English string, hard-coded\n * on the host, in a landmark a screen reader reads out on every page.\n */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'anchor.label', 'Table of contents');\n\n /** Pixel offset subtracted on scroll β€” for sticky headers. @default 0 */\n readonly offset = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /** Highlight an item when its target's top is within this many px of the offset line. @default 80 */\n readonly hitArea = input(80, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 80)) });\n\n protected readonly activeId = signal<string | null>(null);\n\n /**\n * Flat list of the ids the template RENDERS β€” top level plus one level of\n * children, which is the nesting `WrAnchorLink` documents. It used to recurse\n * all the way down, so a third level was spied on and drawn nowhere: scrolling\n * through a grandchild made it active, no rendered link matched the id, and\n * the highlight vanished for that whole region rather than resting on its\n * parent.\n */\n protected readonly flatIds = computed<readonly string[]>(() => {\n const out: string[] = [];\n for (const item of this.links()) {\n out.push(item.id);\n for (const child of item.children ?? []) out.push(child.id);\n }\n return out;\n });\n\n private readonly scroll = inject(WrScroll);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private readonly zone = inject(NgZone);\n private readonly destroyRef = inject(DestroyRef);\n\n /**\n * The entry a click asked for, and the scroll position that click sends the\n * page to. A target near the end of the page can never reach the cursor line β€”\n * the page runs out of scroll first β€” so the spy took the highlight straight\n * back from the entry just clicked and handed it to the one above. While the\n * page is still travelling toward that position, or parked on it, the clicked\n * entry stays lit; the first scroll AWAY from it is the reader's own, and the\n * spy takes over again.\n */\n private pinned: { readonly id: string; readonly y: number } | null = null;\n private lastY = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('anchor');\n if (!this.platform.isBrowser) return;\n const measure = (): void => {\n const y = window.scrollY;\n const pin = this.pinned;\n if (pin) {\n const distance = Math.abs(pin.y - y);\n if (distance <= 1 || distance < Math.abs(pin.y - this.lastY)) {\n this.lastY = y;\n if (pin.id !== this.activeId()) this.zone.run(() => this.activeId.set(pin.id));\n return;\n }\n this.pinned = null;\n }\n this.lastY = y;\n const cursor = this.offset() + this.hitArea();\n let active: string | null = null;\n for (const id of this.flatIds()) {\n const el = document.getElementById(id);\n if (!el) continue;\n const top = el.getBoundingClientRect().top;\n if (top <= cursor) active = id;\n else break;\n }\n if (active !== this.activeId()) this.zone.run(() => this.activeId.set(active));\n };\n let frame = 0;\n const handler = (): void => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n measure();\n });\n };\n this.zone.runOutsideAngular(() => window.addEventListener('scroll', handler, { passive: true }));\n this.destroyRef.onDestroy(() => {\n window.removeEventListener('scroll', handler);\n if (frame) cancelAnimationFrame(frame);\n });\n // The first pass has to wait for a render: the targets are elsewhere on the\n // page and are usually rendered AFTER this list, so a constructor-time pass\n // found nothing by `getElementById` and left the page with no highlight at\n // all until the reader happened to scroll.\n afterNextRender(() => measure());\n }\n\n /** Carries the current path, so a `<base href>` cannot send copy link or a new tab to the site root. */\n protected hrefFor(id: string): string {\n const location = this.doc.location;\n return `${location?.pathname ?? ''}${location?.search ?? ''}#${id}`;\n }\n\n protected onClick(id: string, event: MouseEvent): void {\n if (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n const target = document.getElementById(id);\n if (target) {\n // Where `WrScroll` sends the page, clamped the way the browser clamps it.\n const root = document.documentElement;\n const max = Math.max(0, root.scrollHeight - root.clientHeight);\n const y = target.getBoundingClientRect().top + window.scrollY - this.offset();\n this.pinned = { id, y: Math.min(max, Math.max(0, y)) };\n this.lastY = window.scrollY;\n }\n this.scroll.to(`#${id}`, { offset: this.offset() });\n this.activeId.set(id);\n }\n}\n\nexport type { WrAnchorLink } from './types';\n","<ul class=\"wr-anchor__list\">\n @for (link of links(); track link.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === link.id\"\n [attr.aria-current]=\"activeId() === link.id ? 'location' : null\"\n [href]=\"hrefFor(link.id)\"\n (click)=\"onClick(link.id, $event)\"\n >\n {{ link.label }}\n </a>\n @if (link.children?.length) {\n <ul class=\"wr-anchor__list wr-anchor__list--nested\">\n @for (child of link.children; track child.id) {\n <li class=\"wr-anchor__item\">\n <a\n class=\"wr-anchor__link\"\n [class.wr-anchor__link--active]=\"activeId() === child.id\"\n [attr.aria-current]=\"activeId() === child.id ? 'location' : null\"\n [href]=\"hrefFor(child.id)\"\n (click)=\"onClick(child.id, $event)\"\n >\n {{ child.label }}\n </a>\n </li>\n }\n </ul>\n }\n </li>\n }\n</ul>\n"],"mappings":";;;;;;;;;;;;;;AAuDA,IAAa,WAAb,MAAa,SAAQ;CAMV,QAAQ,MAA+B,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAO1C,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,gBAAgB,mBAAmB;CAG7F,SAAS,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,SAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,GAAG,qBAAqB,GAAG,CAAC,CAAC;CAAC,CAAA;CAG9F,UAAU,MAAM,IAAE;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,GAAG,qBAAqB,GAAG,EAAE,CAAC;CAAC,CAAA;CAEvF,WAAW,OAAsB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAA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