ngwr 16.5.0 → 16.7.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 (450) hide show
  1. package/avatar/styles/_index.scss +39 -0
  2. package/back-top/styles/_index.scss +6 -0
  3. package/breadcrumbs/styles/_rules.scss +34 -0
  4. package/button/styles/_index.scss +45 -2
  5. package/cascader/styles/_rules.scss +7 -0
  6. package/charts/chart-legend/styles/_index.scss +1 -9
  7. package/copy-value/styles/_index.scss +4 -0
  8. package/counter/styles/_index.scss +1 -8
  9. package/date-picker/styles/_index.scss +15 -9
  10. package/dialog/styles/_index.scss +37 -0
  11. package/dropdown/styles/_index.scss +17 -0
  12. package/editor/styles/_index.scss +1 -8
  13. package/event-calendar/styles/_index.scss +2 -6
  14. package/fesm2022/ngwr-affix.mjs +4 -4
  15. package/fesm2022/ngwr-affix.mjs.map +1 -1
  16. package/fesm2022/ngwr-alert.mjs +3 -3
  17. package/fesm2022/ngwr-anchor.mjs +12 -5
  18. package/fesm2022/ngwr-anchor.mjs.map +1 -1
  19. package/fesm2022/ngwr-animations-aurora.mjs +3 -3
  20. package/fesm2022/ngwr-animations-aurora.mjs.map +1 -1
  21. package/fesm2022/ngwr-animations-blur-reveal.mjs +3 -3
  22. package/fesm2022/ngwr-animations-blur-reveal.mjs.map +1 -1
  23. package/fesm2022/ngwr-animations-click-sparks.mjs +3 -3
  24. package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
  25. package/fesm2022/ngwr-animations-confetti.mjs +3 -3
  26. package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
  27. package/fesm2022/ngwr-animations-decode.mjs +3 -3
  28. package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
  29. package/fesm2022/ngwr-animations-destruct.mjs +3 -3
  30. package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
  31. package/fesm2022/ngwr-animations-dot-grid.mjs +3 -3
  32. package/fesm2022/ngwr-animations-dot-grid.mjs.map +1 -1
  33. package/fesm2022/ngwr-animations-falling-letters.mjs +3 -3
  34. package/fesm2022/ngwr-animations-falling-letters.mjs.map +1 -1
  35. package/fesm2022/ngwr-animations-flow-lines.mjs +3 -3
  36. package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
  37. package/fesm2022/ngwr-animations-fluid-cursor.mjs +3 -3
  38. package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
  39. package/fesm2022/ngwr-animations-glitch.mjs +3 -3
  40. package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
  41. package/fesm2022/ngwr-animations-glow-border.mjs +3 -3
  42. package/fesm2022/ngwr-animations-glow-border.mjs.map +1 -1
  43. package/fesm2022/ngwr-animations-gradient-flow.mjs +3 -3
  44. package/fesm2022/ngwr-animations-gradient-flow.mjs.map +1 -1
  45. package/fesm2022/ngwr-animations-marquee.mjs +4 -3
  46. package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
  47. package/fesm2022/ngwr-animations-orbit.mjs +3 -3
  48. package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
  49. package/fesm2022/ngwr-animations-reveal.mjs +3 -3
  50. package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
  51. package/fesm2022/ngwr-animations-ripple-grid.mjs +3 -3
  52. package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
  53. package/fesm2022/ngwr-animations-rotate-reveal.mjs +3 -3
  54. package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
  55. package/fesm2022/ngwr-animations-shimmer.mjs +3 -3
  56. package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
  57. package/fesm2022/ngwr-animations-spotlight.mjs +3 -3
  58. package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
  59. package/fesm2022/ngwr-animations-thread-lines.mjs +3 -3
  60. package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
  61. package/fesm2022/ngwr-animations-tilt.mjs +23 -16
  62. package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
  63. package/fesm2022/ngwr-animations-typewriter.mjs +3 -3
  64. package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
  65. package/fesm2022/ngwr-avatar.mjs +171 -6
  66. package/fesm2022/ngwr-avatar.mjs.map +1 -1
  67. package/fesm2022/ngwr-back-top.mjs +3 -3
  68. package/fesm2022/ngwr-badge.mjs +6 -6
  69. package/fesm2022/ngwr-breadcrumbs.mjs +47 -13
  70. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  71. package/fesm2022/ngwr-burger.mjs +3 -3
  72. package/fesm2022/ngwr-button.mjs +38 -9
  73. package/fesm2022/ngwr-button.mjs.map +1 -1
  74. package/fesm2022/ngwr-calendar.mjs +3 -3
  75. package/fesm2022/ngwr-card.mjs +9 -9
  76. package/fesm2022/ngwr-carousel.mjs +14 -8
  77. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  78. package/fesm2022/ngwr-cascader.mjs +27 -7
  79. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  80. package/fesm2022/ngwr-charts-bar-chart.mjs +3 -3
  81. package/fesm2022/ngwr-charts-boxplot-chart.mjs +3 -3
  82. package/fesm2022/ngwr-charts-bullet-chart.mjs +3 -3
  83. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -3
  84. package/fesm2022/ngwr-charts-candlestick-chart.mjs +3 -3
  85. package/fesm2022/ngwr-charts-chart-legend.mjs +9 -9
  86. package/fesm2022/ngwr-charts-core.mjs +18 -11
  87. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  88. package/fesm2022/ngwr-charts-donut-chart.mjs +3 -3
  89. package/fesm2022/ngwr-charts-funnel-chart.mjs +3 -3
  90. package/fesm2022/ngwr-charts-gauge.mjs +3 -3
  91. package/fesm2022/ngwr-charts-heatmap-chart.mjs +3 -3
  92. package/fesm2022/ngwr-charts-line-chart.mjs +3 -3
  93. package/fesm2022/ngwr-charts-meter-group.mjs +7 -5
  94. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  95. package/fesm2022/ngwr-charts-radar-chart.mjs +3 -3
  96. package/fesm2022/ngwr-charts-scatter-chart.mjs +3 -3
  97. package/fesm2022/ngwr-charts-sparkline.mjs +3 -3
  98. package/fesm2022/ngwr-charts-treemap-chart.mjs +3 -3
  99. package/fesm2022/ngwr-charts-waterfall-chart.mjs +3 -3
  100. package/fesm2022/ngwr-checkbox.mjs +9 -8
  101. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  102. package/fesm2022/ngwr-clipboard.mjs +3 -3
  103. package/fesm2022/ngwr-collapse.mjs +9 -9
  104. package/fesm2022/ngwr-color-picker.mjs +27 -7
  105. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  106. package/fesm2022/ngwr-command-palette.mjs +3 -3
  107. package/fesm2022/ngwr-comment.mjs +7 -6
  108. package/fesm2022/ngwr-comment.mjs.map +1 -1
  109. package/fesm2022/ngwr-compare.mjs +3 -3
  110. package/fesm2022/ngwr-context-menu.mjs +16 -17
  111. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  112. package/fesm2022/ngwr-cookie.mjs +3 -3
  113. package/fesm2022/ngwr-copy-value.mjs +3 -3
  114. package/fesm2022/ngwr-counter.mjs +6 -6
  115. package/fesm2022/ngwr-date-picker-testing.mjs +35 -0
  116. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  117. package/fesm2022/ngwr-date-picker.mjs +151 -54
  118. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  119. package/fesm2022/ngwr-date-stamp.mjs +3 -3
  120. package/fesm2022/ngwr-date.mjs +40 -16
  121. package/fesm2022/ngwr-date.mjs.map +1 -1
  122. package/fesm2022/ngwr-density.mjs +6 -6
  123. package/fesm2022/ngwr-descriptions.mjs +6 -6
  124. package/fesm2022/ngwr-dialog.mjs +35 -24
  125. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  126. package/fesm2022/ngwr-directives.mjs +189 -23
  127. package/fesm2022/ngwr-directives.mjs.map +1 -1
  128. package/fesm2022/ngwr-divider.mjs +3 -3
  129. package/fesm2022/ngwr-drawer.mjs +18 -18
  130. package/fesm2022/ngwr-dropdown-testing.mjs +5 -1
  131. package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
  132. package/fesm2022/ngwr-dropdown.mjs +59 -16
  133. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  134. package/fesm2022/ngwr-editor.mjs +6 -5
  135. package/fesm2022/ngwr-editor.mjs.map +1 -1
  136. package/fesm2022/ngwr-empty.mjs +3 -3
  137. package/fesm2022/ngwr-event-calendar.mjs +27 -15
  138. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  139. package/fesm2022/ngwr-file-upload-testing.mjs +5 -0
  140. package/fesm2022/ngwr-file-upload-testing.mjs.map +1 -1
  141. package/fesm2022/ngwr-file-upload.mjs +68 -13
  142. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  143. package/fesm2022/ngwr-form.mjs +181 -12
  144. package/fesm2022/ngwr-form.mjs.map +1 -1
  145. package/fesm2022/ngwr-graph-testing.mjs +30 -0
  146. package/fesm2022/ngwr-graph-testing.mjs.map +1 -1
  147. package/fesm2022/ngwr-graph.mjs +100 -11
  148. package/fesm2022/ngwr-graph.mjs.map +1 -1
  149. package/fesm2022/ngwr-hotkey.mjs +6 -6
  150. package/fesm2022/ngwr-i18n-ar.mjs +21 -2
  151. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  152. package/fesm2022/ngwr-i18n-cs.mjs +21 -2
  153. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  154. package/fesm2022/ngwr-i18n-de.mjs +21 -2
  155. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  156. package/fesm2022/ngwr-i18n-en.mjs +21 -2
  157. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  158. package/fesm2022/ngwr-i18n-es.mjs +21 -2
  159. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  160. package/fesm2022/ngwr-i18n-fr.mjs +21 -2
  161. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  162. package/fesm2022/ngwr-i18n-he.mjs +21 -2
  163. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  164. package/fesm2022/ngwr-i18n-hi.mjs +21 -2
  165. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  166. package/fesm2022/ngwr-i18n-id.mjs +21 -2
  167. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  168. package/fesm2022/ngwr-i18n-it.mjs +21 -2
  169. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  170. package/fesm2022/ngwr-i18n-ja.mjs +21 -2
  171. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  172. package/fesm2022/ngwr-i18n-kk.mjs +520 -0
  173. package/fesm2022/ngwr-i18n-kk.mjs.map +1 -0
  174. package/fesm2022/ngwr-i18n-ko.mjs +21 -2
  175. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  176. package/fesm2022/ngwr-i18n-nl.mjs +21 -2
  177. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  178. package/fesm2022/ngwr-i18n-pl.mjs +21 -2
  179. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  180. package/fesm2022/ngwr-i18n-pt.mjs +21 -2
  181. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  182. package/fesm2022/ngwr-i18n-ru.mjs +21 -2
  183. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  184. package/fesm2022/ngwr-i18n-sv.mjs +21 -2
  185. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  186. package/fesm2022/ngwr-i18n-tr.mjs +21 -2
  187. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  188. package/fesm2022/ngwr-i18n-uk.mjs +21 -2
  189. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  190. package/fesm2022/ngwr-i18n-vi.mjs +21 -2
  191. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  192. package/fesm2022/ngwr-i18n-zh-tw.mjs +21 -2
  193. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  194. package/fesm2022/ngwr-i18n-zh.mjs +21 -2
  195. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  196. package/fesm2022/ngwr-i18n.mjs +91 -20
  197. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  198. package/fesm2022/ngwr-icon.mjs +6 -6
  199. package/fesm2022/ngwr-image-cropper.mjs +8 -4
  200. package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
  201. package/fesm2022/ngwr-input-number.mjs +27 -4
  202. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  203. package/fesm2022/ngwr-input-otp.mjs +5 -5
  204. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  205. package/fesm2022/ngwr-input.mjs +25 -17
  206. package/fesm2022/ngwr-input.mjs.map +1 -1
  207. package/fesm2022/ngwr-keyboard.mjs +3 -3
  208. package/fesm2022/ngwr-knob.mjs +3 -3
  209. package/fesm2022/ngwr-layout.mjs +15 -15
  210. package/fesm2022/ngwr-layout.mjs.map +1 -1
  211. package/fesm2022/ngwr-lightbox.mjs +8 -8
  212. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  213. package/fesm2022/ngwr-list.mjs +9 -9
  214. package/fesm2022/ngwr-list.mjs.map +1 -1
  215. package/fesm2022/ngwr-load-state.mjs +16 -15
  216. package/fesm2022/ngwr-load-state.mjs.map +1 -1
  217. package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -1
  218. package/fesm2022/ngwr-loading-bar.mjs +8 -8
  219. package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
  220. package/fesm2022/ngwr-mention.mjs +14 -6
  221. package/fesm2022/ngwr-mention.mjs.map +1 -1
  222. package/fesm2022/ngwr-meta.mjs +15 -12
  223. package/fesm2022/ngwr-meta.mjs.map +1 -1
  224. package/fesm2022/ngwr-overlay.mjs +9 -9
  225. package/fesm2022/ngwr-page-header.mjs +24 -3
  226. package/fesm2022/ngwr-page-header.mjs.map +1 -1
  227. package/fesm2022/ngwr-pagination-testing.mjs +3 -0
  228. package/fesm2022/ngwr-pagination-testing.mjs.map +1 -1
  229. package/fesm2022/ngwr-pagination.mjs +34 -5
  230. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  231. package/fesm2022/ngwr-pipes.mjs +35 -28
  232. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  233. package/fesm2022/ngwr-platform.mjs +9 -9
  234. package/fesm2022/ngwr-popconfirm.mjs +9 -7
  235. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  236. package/fesm2022/ngwr-popover.mjs +162 -18
  237. package/fesm2022/ngwr-popover.mjs.map +1 -1
  238. package/fesm2022/ngwr-progress.mjs +75 -10
  239. package/fesm2022/ngwr-progress.mjs.map +1 -1
  240. package/fesm2022/ngwr-pull-to-refresh.mjs +3 -3
  241. package/fesm2022/ngwr-qr.mjs +9 -5
  242. package/fesm2022/ngwr-qr.mjs.map +1 -1
  243. package/fesm2022/ngwr-radio.mjs +77 -11
  244. package/fesm2022/ngwr-radio.mjs.map +1 -1
  245. package/fesm2022/ngwr-rating.mjs +3 -3
  246. package/fesm2022/ngwr-resizable.mjs +3 -3
  247. package/fesm2022/ngwr-result.mjs +12 -12
  248. package/fesm2022/ngwr-schema-form.mjs +20 -7
  249. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  250. package/fesm2022/ngwr-scroll.mjs +233 -10
  251. package/fesm2022/ngwr-scroll.mjs.map +1 -1
  252. package/fesm2022/ngwr-segmented.mjs +23 -3
  253. package/fesm2022/ngwr-segmented.mjs.map +1 -1
  254. package/fesm2022/ngwr-select.mjs +106 -26
  255. package/fesm2022/ngwr-select.mjs.map +1 -1
  256. package/fesm2022/ngwr-sidebar-testing.mjs +17 -1
  257. package/fesm2022/ngwr-sidebar-testing.mjs.map +1 -1
  258. package/fesm2022/ngwr-sidebar.mjs +66 -11
  259. package/fesm2022/ngwr-sidebar.mjs.map +1 -1
  260. package/fesm2022/ngwr-skeleton.mjs +3 -3
  261. package/fesm2022/ngwr-slider.mjs +3 -3
  262. package/fesm2022/ngwr-sortable-list.mjs +27 -15
  263. package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
  264. package/fesm2022/ngwr-speed-dial.mjs +3 -3
  265. package/fesm2022/ngwr-spinner.mjs +3 -3
  266. package/fesm2022/ngwr-splitter.mjs +3 -3
  267. package/fesm2022/ngwr-statistic.mjs +9 -9
  268. package/fesm2022/ngwr-stepper.mjs +6 -6
  269. package/fesm2022/ngwr-storage.mjs +4 -4
  270. package/fesm2022/ngwr-storage.mjs.map +1 -1
  271. package/fesm2022/ngwr-switch.mjs +5 -5
  272. package/fesm2022/ngwr-switch.mjs.map +1 -1
  273. package/fesm2022/ngwr-table-router.mjs +89 -0
  274. package/fesm2022/ngwr-table-router.mjs.map +1 -0
  275. package/fesm2022/ngwr-table-testing.mjs +5 -0
  276. package/fesm2022/ngwr-table-testing.mjs.map +1 -1
  277. package/fesm2022/ngwr-table.mjs +307 -47
  278. package/fesm2022/ngwr-table.mjs.map +1 -1
  279. package/fesm2022/ngwr-tabs-router.mjs +9 -5
  280. package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
  281. package/fesm2022/ngwr-tabs-testing.mjs +8 -1
  282. package/fesm2022/ngwr-tabs-testing.mjs.map +1 -1
  283. package/fesm2022/ngwr-tabs.mjs +60 -10
  284. package/fesm2022/ngwr-tabs.mjs.map +1 -1
  285. package/fesm2022/ngwr-textarea.mjs +5 -5
  286. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  287. package/fesm2022/ngwr-theme.mjs +3 -3
  288. package/fesm2022/ngwr-timeline.mjs +6 -6
  289. package/fesm2022/ngwr-toast.mjs +43 -15
  290. package/fesm2022/ngwr-toast.mjs.map +1 -1
  291. package/fesm2022/ngwr-toolbar.mjs +3 -3
  292. package/fesm2022/ngwr-tour.mjs +9 -8
  293. package/fesm2022/ngwr-tour.mjs.map +1 -1
  294. package/fesm2022/ngwr-transfer.mjs +4 -3
  295. package/fesm2022/ngwr-transfer.mjs.map +1 -1
  296. package/fesm2022/ngwr-tree.mjs +3 -3
  297. package/fesm2022/ngwr-typography.mjs +23 -3
  298. package/fesm2022/ngwr-typography.mjs.map +1 -1
  299. package/fesm2022/ngwr-utils-router.mjs +3 -3
  300. package/fesm2022/ngwr-utils-router.mjs.map +1 -1
  301. package/fesm2022/ngwr-utils.mjs +74 -4
  302. package/fesm2022/ngwr-utils.mjs.map +1 -1
  303. package/fesm2022/ngwr-validators.mjs +33 -1
  304. package/fesm2022/ngwr-validators.mjs.map +1 -1
  305. package/fesm2022/ngwr-version.mjs +1 -1
  306. package/fesm2022/ngwr-version.mjs.map +1 -1
  307. package/fesm2022/ngwr-virtual-scroll.mjs +3 -3
  308. package/fesm2022/ngwr-window.mjs +18 -13
  309. package/fesm2022/ngwr-window.mjs.map +1 -1
  310. package/file-upload/styles/_index.scss +16 -0
  311. package/form/styles/_index.scss +37 -0
  312. package/graph/styles/_index.scss +49 -9
  313. package/i18n/ar.json +19 -2
  314. package/i18n/cs.json +19 -2
  315. package/i18n/de.json +19 -2
  316. package/i18n/en.json +19 -2
  317. package/i18n/es.json +19 -2
  318. package/i18n/fr.json +19 -2
  319. package/i18n/he.json +19 -2
  320. package/i18n/hi.json +19 -2
  321. package/i18n/id.json +19 -2
  322. package/i18n/it.json +19 -2
  323. package/i18n/ja.json +19 -2
  324. package/i18n/kk.json +567 -0
  325. package/i18n/ko.json +19 -2
  326. package/i18n/nl.json +19 -2
  327. package/i18n/pl.json +19 -2
  328. package/i18n/pt.json +19 -2
  329. package/i18n/ru.json +19 -2
  330. package/i18n/sv.json +19 -2
  331. package/i18n/tr.json +19 -2
  332. package/i18n/uk.json +19 -2
  333. package/i18n/vi.json +19 -2
  334. package/i18n/zh-TW.json +19 -2
  335. package/i18n/zh.json +19 -2
  336. package/image-cropper/styles/_index.scss +1 -9
  337. package/input-number/styles/_index.scss +7 -0
  338. package/layout/styles/_index.scss +13 -1
  339. package/llms-full.txt +37 -26
  340. package/llms.txt +4 -1
  341. package/loading-bar/styles/_rules.scss +6 -0
  342. package/package.json +16 -8
  343. package/page-header/styles/_index.scss +18 -0
  344. package/pagination/styles/_index.scss +6 -0
  345. package/popover/styles/_index.scss +9 -0
  346. package/progress/styles/_index.scss +64 -0
  347. package/schematics/use/symbol-map.json +7 -0
  348. package/segmented/styles/_index.scss +7 -0
  349. package/select/styles/_index.scss +7 -0
  350. package/sidebar/styles/_index.scss +64 -6
  351. package/skills/ngwr/SKILL.md +7 -6
  352. package/skills/ngwr/references/catalog.md +7 -5
  353. package/sortable-list/styles/_rules.scss +1 -9
  354. package/speed-dial/styles/_index.scss +6 -0
  355. package/stepper/styles/_index.scss +1 -9
  356. package/table/styles/_index.scss +168 -30
  357. package/tabs/styles/_index.scss +9 -0
  358. package/theme/_index.scss +12 -1
  359. package/theme/styles/_colors.scss +11 -0
  360. package/theme/styles/_contrast.scss +6 -0
  361. package/theme/styles/_focus.scss +3 -1
  362. package/theme/styles/_index.scss +1 -0
  363. package/theme/styles/_mixins.scss +45 -0
  364. package/theme/styles/_print.scss +17 -0
  365. package/toast/styles/_index.scss +7 -0
  366. package/tour/styles/_index.scss +9 -0
  367. package/tree/styles/_index.scss +1 -9
  368. package/types/ngwr-anchor.d.ts +3 -0
  369. package/types/ngwr-animations-aurora.d.ts +6 -0
  370. package/types/ngwr-animations-blur-reveal.d.ts +6 -0
  371. package/types/ngwr-animations-click-sparks.d.ts +6 -0
  372. package/types/ngwr-animations-confetti.d.ts +6 -0
  373. package/types/ngwr-animations-decode.d.ts +6 -0
  374. package/types/ngwr-animations-destruct.d.ts +6 -0
  375. package/types/ngwr-animations-dot-grid.d.ts +6 -0
  376. package/types/ngwr-animations-falling-letters.d.ts +6 -0
  377. package/types/ngwr-animations-flow-lines.d.ts +6 -0
  378. package/types/ngwr-animations-fluid-cursor.d.ts +6 -0
  379. package/types/ngwr-animations-glitch.d.ts +6 -0
  380. package/types/ngwr-animations-glow-border.d.ts +6 -0
  381. package/types/ngwr-animations-gradient-flow.d.ts +6 -0
  382. package/types/ngwr-animations-marquee.d.ts +6 -0
  383. package/types/ngwr-animations-orbit.d.ts +6 -0
  384. package/types/ngwr-animations-reveal.d.ts +6 -0
  385. package/types/ngwr-animations-ripple-grid.d.ts +6 -0
  386. package/types/ngwr-animations-rotate-reveal.d.ts +6 -0
  387. package/types/ngwr-animations-shimmer.d.ts +6 -0
  388. package/types/ngwr-animations-spotlight.d.ts +6 -0
  389. package/types/ngwr-animations-thread-lines.d.ts +6 -0
  390. package/types/ngwr-animations-tilt.d.ts +10 -0
  391. package/types/ngwr-animations-typewriter.d.ts +6 -0
  392. package/types/ngwr-avatar.d.ts +39 -0
  393. package/types/ngwr-breadcrumbs.d.ts +25 -0
  394. package/types/ngwr-button.d.ts +35 -3
  395. package/types/ngwr-carousel.d.ts +2 -0
  396. package/types/ngwr-cascader.d.ts +7 -0
  397. package/types/ngwr-charts-core.d.ts +16 -0
  398. package/types/ngwr-charts-meter-group.d.ts +2 -0
  399. package/types/ngwr-checkbox.d.ts +1 -0
  400. package/types/ngwr-color-picker.d.ts +1 -0
  401. package/types/ngwr-context-menu.d.ts +1 -1
  402. package/types/ngwr-date-picker-testing.d.ts +22 -0
  403. package/types/ngwr-date-picker.d.ts +97 -17
  404. package/types/ngwr-date.d.ts +51 -0
  405. package/types/ngwr-dialog.d.ts +39 -8
  406. package/types/ngwr-directives.d.ts +57 -4
  407. package/types/ngwr-drawer.d.ts +1 -1
  408. package/types/ngwr-dropdown-testing.d.ts +8 -1
  409. package/types/ngwr-dropdown.d.ts +30 -1
  410. package/types/ngwr-event-calendar.d.ts +4 -0
  411. package/types/ngwr-file-upload-testing.d.ts +10 -0
  412. package/types/ngwr-file-upload.d.ts +55 -1
  413. package/types/ngwr-form.d.ts +87 -1
  414. package/types/ngwr-graph-testing.d.ts +28 -1
  415. package/types/ngwr-graph.d.ts +53 -3
  416. package/types/ngwr-i18n-kk.d.ts +3 -0
  417. package/types/ngwr-i18n.d.ts +65 -5
  418. package/types/ngwr-image-cropper.d.ts +6 -0
  419. package/types/ngwr-input-number.d.ts +8 -0
  420. package/types/ngwr-input.d.ts +7 -0
  421. package/types/ngwr-layout.d.ts +1 -1
  422. package/types/ngwr-loading-bar-router.d.ts +6 -0
  423. package/types/ngwr-page-header.d.ts +23 -1
  424. package/types/ngwr-pagination-testing.d.ts +8 -0
  425. package/types/ngwr-pagination.d.ts +16 -0
  426. package/types/ngwr-popconfirm.d.ts +1 -1
  427. package/types/ngwr-popover.d.ts +67 -4
  428. package/types/ngwr-progress.d.ts +63 -1
  429. package/types/ngwr-radio.d.ts +47 -5
  430. package/types/ngwr-scroll.d.ts +86 -0
  431. package/types/ngwr-segmented.d.ts +7 -0
  432. package/types/ngwr-select.d.ts +88 -25
  433. package/types/ngwr-sidebar-testing.d.ts +21 -7
  434. package/types/ngwr-sidebar.d.ts +66 -4
  435. package/types/ngwr-sortable-list.d.ts +20 -7
  436. package/types/ngwr-table-router.d.ts +49 -0
  437. package/types/ngwr-table-testing.d.ts +7 -0
  438. package/types/ngwr-table.d.ts +241 -10
  439. package/types/ngwr-tabs-router.d.ts +7 -1
  440. package/types/ngwr-tabs-testing.d.ts +5 -1
  441. package/types/ngwr-tabs.d.ts +34 -1
  442. package/types/ngwr-toast.d.ts +11 -0
  443. package/types/ngwr-tour.d.ts +0 -1
  444. package/types/ngwr-typography.d.ts +7 -0
  445. package/types/ngwr-utils-router.d.ts +6 -0
  446. package/types/ngwr-utils.d.ts +69 -2
  447. package/types/ngwr-validators.d.ts +49 -1
  448. package/types/ngwr-version.d.ts +1 -1
  449. package/typography/styles/_index.scss +4 -0
  450. package/window/styles/_index.scss +1 -9
@@ -201,7 +201,7 @@ var WrConfetti = class WrConfetti {
201
201
  }
202
202
  static ɵfac = i0.ɵɵngDeclareFactory({
203
203
  minVersion: "12.0.0",
204
- version: "22.2.6",
204
+ version: "22.3.0",
205
205
  ngImport: i0,
206
206
  type: WrConfetti,
207
207
  deps: [],
@@ -209,14 +209,14 @@ var WrConfetti = class WrConfetti {
209
209
  });
210
210
  static ɵprov = i0.ɵɵngDeclareService({
211
211
  minVersion: "22.0.0",
212
- version: "22.2.6",
212
+ version: "22.3.0",
213
213
  ngImport: i0,
214
214
  type: WrConfetti
215
215
  });
216
216
  };
217
217
  i0.ɵɵngDeclareClassMetadata({
218
218
  minVersion: "12.0.0",
219
- version: "22.2.6",
219
+ version: "22.3.0",
220
220
  ngImport: i0,
221
221
  type: WrConfetti,
222
222
  decorators: [{ type: Service }],
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-confetti.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/confetti/confetti.ts","../../../projects/lib/animations/confetti/public-api.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 { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, PLATFORM_ID, Service, effect, inject } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrClamp, wrResolveCssColor } from 'ngwr/utils';\n\nimport { MAX_FRAME_MS, canvasBackdropRatio } from '../internal';\n\nimport type { WrConfettiOptions, WrConfettiRect } from './types';\n\n/** Pieces in one burst. */\nconst CONFETTI_COUNT = 84;\n\n/** How wide the fan of launch directions is, in degrees, centred straight up. */\nconst CONFETTI_CONE = 80;\n\n/** Launch speed, px/s: the slowest and the fastest piece. */\nconst CONFETTI_SPEED_MIN = 520;\nconst CONFETTI_SPEED_MAX = 980;\n\n/** Gravity, px/s²: light, as paper falls, not a stone. */\nconst CONFETTI_GRAVITY = 560;\n\n/**\n * Air drag, per second: velocity decays by `e^-drag` every second, so a piece\n * launched at 900px/s is at a third of that after two thirds of a second and\n * falls no faster than `gravity / drag` (350px/s) however long it drops.\n */\nconst CONFETTI_DRAG = 1.6;\n\n/** How far the flutter pushes a piece sideways, px/s at the peak of a flip. */\nconst CONFETTI_SWAY = 60;\n\n/** How long a piece lives, ms: at least this, plus up to the spread. */\nconst CONFETTI_LIFE_MS = 1900;\nconst CONFETTI_LIFE_SPREAD_MS = 500;\n\n/** A piece fades over its last ms. */\nconst CONFETTI_FADE_MS = 600;\n\n/** Every fifth piece is a thin strip rather than a rectangle. */\nconst CONFETTI_STRIP_EVERY = 5;\n\n/**\n * The colour hooks on the canvas, each a bare intent: confetti is a graphic,\n * not text, so it keeps the intent itself rather than the `-ink` text role\n * (see `docs/internals/theme.md`). The literal is the fallback when a hook\n * cannot be resolved, as in a document with no stylesheet.\n */\nconst CONFETTI_COLORS: readonly (readonly [hook: string, fallback: string])[] = [\n ['var(--wr-confetti-color-1)', '#3969e2'],\n ['var(--wr-confetti-color-2)', '#008800'],\n ['var(--wr-confetti-color-3)', '#ffba00'],\n ['var(--wr-confetti-color-4)', '#dc3137'],\n ['var(--wr-confetti-color-5)', '#3472d9'],\n];\n\n/** One piece of paper in the air. Positions in CSS px, velocities in px/s, angles in rad. */\nexport interface WrConfettiPiece {\n x: number;\n y: number;\n vx: number;\n vy: number;\n readonly width: number;\n readonly height: number;\n /** Its turn on the screen plane. */\n angle: number;\n readonly spin: number;\n /** Its flip round its own long axis: the drawn height is `height * cos(phase)`. */\n phase: number;\n readonly flutter: number;\n readonly color: string;\n /** ms left. */\n life: number;\n}\n\n/* eslint-disable no-bitwise -- xorshift is defined in 32-bit integer arithmetic */\n/**\n * A deterministic 0–1 sequence from `seed` (xorshift32): the same seed gives\n * the same burst, which a spec can pin. A zero seed would stay zero for ever,\n * so it is replaced by a constant.\n */\nexport function confettiRandom(seed: number): () => number {\n let state = seed >>> 0 || 0x9e3779b9;\n return () => {\n state ^= state << 13;\n state >>>= 0;\n state ^= state >>> 17;\n state ^= state << 5;\n state >>>= 0;\n return state / 0x1_0000_0000;\n };\n}\n/* eslint-enable no-bitwise */\n\n/**\n * The pieces of one burst at launch: `count` of them, spread over `from`,\n * each thrown upward inside the cone at its own speed with its own spin,\n * flutter and life, coloured from `palette` in turn so every colour is\n * equally represented.\n */\nexport function confettiLaunch(\n from: WrConfettiRect,\n seed: number,\n count: number,\n palette: readonly string[]\n): WrConfettiPiece[] {\n const random = confettiRandom(seed);\n const half = (CONFETTI_CONE / 2) * (Math.PI / 180);\n const pieces: WrConfettiPiece[] = [];\n for (let i = 0; i < Math.max(0, Math.round(count)); i++) {\n const strip = i % CONFETTI_STRIP_EVERY === CONFETTI_STRIP_EVERY - 1;\n const direction = -Math.PI / 2 + (random() * 2 - 1) * half;\n const speed = CONFETTI_SPEED_MIN + random() * (CONFETTI_SPEED_MAX - CONFETTI_SPEED_MIN);\n pieces.push({\n x: from.left + random() * from.width,\n y: from.top + random() * from.height,\n vx: Math.cos(direction) * speed,\n vy: Math.sin(direction) * speed,\n width: strip ? 2 + random() * 1.5 : 6 + random() * 4,\n height: strip ? 10 + random() * 6 : 3 + random() * 2.5,\n angle: random() * Math.PI * 2,\n spin: (random() * 2 - 1) * 8,\n phase: random() * Math.PI * 2,\n flutter: 5 + random() * 7,\n color: palette[i % palette.length] ?? '',\n life: CONFETTI_LIFE_MS + random() * CONFETTI_LIFE_SPREAD_MS,\n });\n }\n return pieces;\n}\n\n/**\n * Moves one piece `dt` ms on. Gravity pulls, drag slows both axes towards the\n * terminal speed, the flutter sways it sideways as it flips, and the spin and\n * the flip advance; the life runs down.\n */\nexport function confettiStep(piece: WrConfettiPiece, dt: number): void {\n const s = dt / 1000;\n const keep = Math.exp(-CONFETTI_DRAG * s);\n const terminal = CONFETTI_GRAVITY / CONFETTI_DRAG;\n piece.vx *= keep;\n piece.vy = terminal + (piece.vy - terminal) * keep;\n piece.x += (piece.vx + Math.sin(piece.phase) * CONFETTI_SWAY) * s;\n piece.y += piece.vy * s;\n piece.angle += piece.spin * s;\n piece.phase += piece.flutter * s;\n piece.life -= dt;\n}\n\n/** Whether a piece is still worth drawing: alive and not below the bottom edge of a `height` tall viewport. */\nexport function confettiAlive(piece: WrConfettiPiece, height: number): boolean {\n return piece.life > 0 && piece.y - Math.max(piece.width, piece.height) < height;\n}\n\n/** A piece's opacity: solid, then fading over its last {@link CONFETTI_FADE_MS}. */\nexport function confettiAlpha(piece: WrConfettiPiece): number {\n return wrClamp(piece.life / CONFETTI_FADE_MS, 0, 1);\n}\n\n/**\n * A one-shot celebration: small paper pieces burst up and out from an\n * element, flutter, tumble and fall under gravity, and are gone inside two\n * and a half seconds. A service, not a component: call {@link burst} from\n * wherever the moment is.\n *\n * The first burst makes one fixed, full-viewport canvas in `document.body`\n * (`aria-hidden`, under no pointer, at the device ratio capped as the\n * backdrops cap it) and starts one frame loop; a burst that comes while\n * pieces are in the air joins the same canvas and loop, and the canvas goes\n * when the last piece has faded or dropped off the bottom. The layout of a\n * burst is deterministic for a seed; the physics is in {@link confettiLaunch},\n * {@link confettiStep} and {@link confettiAlive}, pure functions a spec can\n * run on their own. Each piece is a rectangle, every fifth a thin strip,\n * turning on the screen plane while its drawn height follows a cosine, so it\n * flips like paper; the back of a piece paints a shade darker.\n *\n * Colours are the `--wr-confetti-color-*` hooks on the canvas, bare theme\n * intents by default, resolved through the cascade when a burst starts, so\n * the scheme the reader is in is the one that paints. Nothing happens under\n * `prefers-reduced-motion: reduce` (a preference that flips mid-burst clears\n * the canvas at once), under `forced-colors: active` or on the server; a\n * hidden document pauses the loop and a visible one resumes it where it\n * stopped. Styles: `@use 'ngwr/animations/confetti'`, which places the canvas and\n * lists the `--wr-confetti-color-*` hooks; a service has no host to check them\n * from, so the first burst warns in dev mode when the sheet is missing.\n */\n@Service()\nexport class WrConfetti {\n private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private canvas: HTMLCanvasElement | null = null;\n private ctx: CanvasRenderingContext2D | null = null;\n private pieces: WrConfettiPiece[] = [];\n private rafId: number | null = null;\n private lastFrame = 0;\n private dpr = 1;\n private width = 0;\n private height = 0;\n private listeners: AbortController | null = null;\n /** The stylesheet was looked for once in this document. */\n private checked = false;\n\n constructor() {\n if (!this.browser) return;\n\n effect(() => {\n const reduced = this.platform.prefersReducedMotion();\n this.platform.pageVisible();\n if (reduced) this.clear();\n else this.sync();\n });\n\n inject(DestroyRef).onDestroy(() => this.clear());\n }\n\n /** Whether pieces are in the air. */\n get active(): boolean {\n return this.pieces.length > 0;\n }\n\n /**\n * Throws a burst of confetti up from `from`: an element, whose client rect\n * is read now, or a rect in client coordinates. Pieces start anywhere\n * inside the rect, so a wide block showers along its width and a button\n * bursts from a point.\n */\n burst(from: Element | WrConfettiRect, options: WrConfettiOptions = {}): void {\n if (!this.browser || this.platform.prefersReducedMotion()) return;\n const view = this.doc.defaultView;\n if (!view || view.matchMedia?.('(forced-colors: active)').matches) return;\n\n const canvas = this.canvas ?? this.mount(view);\n if (!canvas) return;\n const rect = 'getBoundingClientRect' in from ? from.getBoundingClientRect() : from;\n const seed = options.seed ?? Math.floor(Math.random() * 0x1_0000_0000);\n const palette = CONFETTI_COLORS.map(([hook, fallback]) => wrResolveCssColor(canvas, hook, fallback));\n this.pieces.push(...confettiLaunch(rect, seed, options.count ?? CONFETTI_COUNT, palette));\n this.sync();\n }\n\n /** Stops the loop and takes the canvas and every piece out. Idempotent. */\n clear(): void {\n this.stopLoop();\n this.pieces = [];\n this.listeners?.abort();\n this.listeners = null;\n this.canvas?.remove();\n this.canvas = null;\n this.ctx = null;\n }\n\n /** Makes the canvas, or returns `null` when the browser gives it no context. */\n private mount(view: Window): HTMLCanvasElement | null {\n const canvas = this.doc.createElement('canvas');\n canvas.className = 'wr-confetti';\n canvas.setAttribute('aria-hidden', 'true');\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n this.canvas = canvas;\n this.ctx = ctx;\n this.listeners = new AbortController();\n view.addEventListener('resize', () => this.resize(view), { signal: this.listeners.signal, passive: true });\n this.doc.body.append(canvas);\n this.resize(view);\n if (typeof ngDevMode === 'undefined' || ngDevMode) this.checkStyles(view);\n return canvas;\n }\n\n /**\n * The service's own `wrCheckStyles`, which a root service cannot call: that\n * helper reads the host element it is injected beside, and a service has\n * none. The same marker, the same words, once per document.\n */\n private checkStyles(view: Window): void {\n if (this.checked || /jsdom|happydom/i.test(view.navigator.userAgent)) return;\n this.checked = true;\n const loaded = view.getComputedStyle(this.doc.documentElement).getPropertyValue('--wr-loaded-animations-confetti');\n if (loaded.trim() !== '') return;\n // eslint-disable-next-line no-console -- a dev-mode diagnostic, reported and never thrown\n console.warn(\n \"[NGWR] WrConfetti paints without its styles. Add @use 'ngwr/animations/confetti'; to your global stylesheet, \" +\n 'or run ng g ngwr:component-style animations/confetti.'\n );\n }\n\n private resize(view: Window): void {\n if (!this.canvas || !this.ctx) return;\n this.width = view.innerWidth;\n this.height = view.innerHeight;\n this.dpr = canvasBackdropRatio(Math.max(1, this.width), Math.max(1, this.height), view.devicePixelRatio ?? 1);\n this.canvas.width = Math.round(this.width * this.dpr);\n this.canvas.height = Math.round(this.height * this.dpr);\n }\n\n /** Starts or stops the loop: it runs while pieces are in the air and the document is visible. */\n private sync(): void {\n const run = this.ctx !== null && this.pieces.length > 0 && this.platform.pageVisible();\n if (run === (this.rafId !== null)) return;\n if (run) {\n this.lastFrame = performance.now();\n this.rafId = requestAnimationFrame(this.frame);\n return;\n }\n this.stopLoop();\n }\n\n private stopLoop(): void {\n if (this.rafId !== null) cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n\n private readonly frame = (now: number): void => {\n this.rafId = null;\n // A tab that was throttled comes back with one huge frame; the pieces move at most this far at once.\n const dt = wrClamp(now - this.lastFrame, 0, MAX_FRAME_MS);\n this.lastFrame = now;\n for (const piece of this.pieces) confettiStep(piece, dt);\n this.pieces = this.pieces.filter(piece => confettiAlive(piece, this.height));\n if (this.pieces.length === 0) {\n this.clear();\n return;\n }\n this.draw();\n this.rafId = requestAnimationFrame(this.frame);\n };\n\n private draw(): void {\n const ctx = this.ctx;\n if (!ctx) return;\n const { dpr } = this;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, this.width * dpr, this.height * dpr);\n for (const piece of this.pieces) {\n const flip = Math.cos(piece.phase);\n // Never flat: a sheet seen edge-on still shows its edge.\n const thickness = Math.sign(flip || 1) * Math.max(0.12, Math.abs(flip));\n ctx.setTransform(dpr, 0, 0, dpr, piece.x * dpr, piece.y * dpr);\n ctx.rotate(piece.angle);\n ctx.scale(1, thickness);\n // The back of the paper is in shadow.\n ctx.globalAlpha = confettiAlpha(piece) * (flip < 0 ? 0.75 : 1);\n ctx.fillStyle = piece.color;\n ctx.fillRect(-piece.width / 2, -piece.height / 2, piece.width, piece.height);\n }\n ctx.globalAlpha = 1;\n }\n}\n\nexport {\n CONFETTI_CONE,\n CONFETTI_COUNT,\n CONFETTI_DRAG,\n CONFETTI_FADE_MS,\n CONFETTI_GRAVITY,\n CONFETTI_LIFE_MS,\n CONFETTI_LIFE_SPREAD_MS,\n CONFETTI_SPEED_MAX,\n CONFETTI_SPEED_MIN,\n CONFETTI_STRIP_EVERY,\n};\n","/**\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\nexport { WrConfetti } from './confetti';\nexport type { WrConfettiOptions, WrConfettiRect } from './types';\n"],"mappings":";;;;;;;;;;;;AAmCA,MAAM,gBAAgB;AAGtB,MAAM,gBAAgB;AAGtB,MAAM,mBAAmB;AAezB,MAAM,kBAA0E;CAC9E,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;AACzC;AA2BD,SAAgB,eAAe,MAAY;CACzC,IAAI,QAAQ,SAAS,KAAK;CAC1B,aAAY;EACV,SAAS,SAAS;EAClB,WAAW;EACX,SAAS,UAAU;EACnB,SAAS,SAAS;EAClB,WA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KAAK,IAAI,KAAM,KAAK,IAAI,IAAI,CAAC;GACtE,IAAI,aAAa,KAAK,GAAG,GAAG,KAAK,MAAM,IAAI,KAAK,MAAM,IAAI,GAAG;GAC7D,IAAI,OAAO,MAAM,KAAK;GACtB,IAAI,MAAM,GAAG,SAAS;GAEtB,IAAI,cAAc,cAAc,KAAK,KAAK,OAAO,IAAI,MAAO;GAC5D,IAAI,YAAY,MAAM;GACtB,IAAI,SAAS,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,SAAS,GAAG,MAAM,OAAO,MAAM,MAAM;EAC7E;EACA,IAAI,cAAc;CACpB;CA/JW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAU,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAV,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAU,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA,EADtB,MAAA,Q"}
1
+ {"version":3,"file":"ngwr-animations-confetti.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/confetti/confetti.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 { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, PLATFORM_ID, Service, effect, inject } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrClamp, wrResolveCssColor } from 'ngwr/utils';\n\nimport { MAX_FRAME_MS, canvasBackdropRatio } from '../internal';\n\nimport type { WrConfettiOptions, WrConfettiRect } from './types';\n\n/** Pieces in one burst. */\nconst CONFETTI_COUNT = 84;\n\n/** How wide the fan of launch directions is, in degrees, centred straight up. */\nconst CONFETTI_CONE = 80;\n\n/** Launch speed, px/s: the slowest and the fastest piece. */\nconst CONFETTI_SPEED_MIN = 520;\nconst CONFETTI_SPEED_MAX = 980;\n\n/** Gravity, px/s²: light, as paper falls, not a stone. */\nconst CONFETTI_GRAVITY = 560;\n\n/**\n * Air drag, per second: velocity decays by `e^-drag` every second, so a piece\n * launched at 900px/s is at a third of that after two thirds of a second and\n * falls no faster than `gravity / drag` (350px/s) however long it drops.\n */\nconst CONFETTI_DRAG = 1.6;\n\n/** How far the flutter pushes a piece sideways, px/s at the peak of a flip. */\nconst CONFETTI_SWAY = 60;\n\n/** How long a piece lives, ms: at least this, plus up to the spread. */\nconst CONFETTI_LIFE_MS = 1900;\nconst CONFETTI_LIFE_SPREAD_MS = 500;\n\n/** A piece fades over its last ms. */\nconst CONFETTI_FADE_MS = 600;\n\n/** Every fifth piece is a thin strip rather than a rectangle. */\nconst CONFETTI_STRIP_EVERY = 5;\n\n/**\n * The colour hooks on the canvas, each a bare intent: confetti is a graphic,\n * not text, so it keeps the intent itself rather than the `-ink` text role\n * (see `docs/internals/theme.md`). The literal is the fallback when a hook\n * cannot be resolved, as in a document with no stylesheet.\n */\nconst CONFETTI_COLORS: readonly (readonly [hook: string, fallback: string])[] = [\n ['var(--wr-confetti-color-1)', '#3969e2'],\n ['var(--wr-confetti-color-2)', '#008800'],\n ['var(--wr-confetti-color-3)', '#ffba00'],\n ['var(--wr-confetti-color-4)', '#dc3137'],\n ['var(--wr-confetti-color-5)', '#3472d9'],\n];\n\n/** One piece of paper in the air. Positions in CSS px, velocities in px/s, angles in rad. */\nexport interface WrConfettiPiece {\n x: number;\n y: number;\n vx: number;\n vy: number;\n readonly width: number;\n readonly height: number;\n /** Its turn on the screen plane. */\n angle: number;\n readonly spin: number;\n /** Its flip round its own long axis: the drawn height is `height * cos(phase)`. */\n phase: number;\n readonly flutter: number;\n readonly color: string;\n /** ms left. */\n life: number;\n}\n\n/* eslint-disable no-bitwise -- xorshift is defined in 32-bit integer arithmetic */\n/**\n * A deterministic 0–1 sequence from `seed` (xorshift32): the same seed gives\n * the same burst, which a spec can pin. A zero seed would stay zero for ever,\n * so it is replaced by a constant.\n */\nexport function confettiRandom(seed: number): () => number {\n let state = seed >>> 0 || 0x9e3779b9;\n return () => {\n state ^= state << 13;\n state >>>= 0;\n state ^= state >>> 17;\n state ^= state << 5;\n state >>>= 0;\n return state / 0x1_0000_0000;\n };\n}\n/* eslint-enable no-bitwise */\n\n/**\n * The pieces of one burst at launch: `count` of them, spread over `from`,\n * each thrown upward inside the cone at its own speed with its own spin,\n * flutter and life, coloured from `palette` in turn so every colour is\n * equally represented.\n */\nexport function confettiLaunch(\n from: WrConfettiRect,\n seed: number,\n count: number,\n palette: readonly string[]\n): WrConfettiPiece[] {\n const random = confettiRandom(seed);\n const half = (CONFETTI_CONE / 2) * (Math.PI / 180);\n const pieces: WrConfettiPiece[] = [];\n for (let i = 0; i < Math.max(0, Math.round(count)); i++) {\n const strip = i % CONFETTI_STRIP_EVERY === CONFETTI_STRIP_EVERY - 1;\n const direction = -Math.PI / 2 + (random() * 2 - 1) * half;\n const speed = CONFETTI_SPEED_MIN + random() * (CONFETTI_SPEED_MAX - CONFETTI_SPEED_MIN);\n pieces.push({\n x: from.left + random() * from.width,\n y: from.top + random() * from.height,\n vx: Math.cos(direction) * speed,\n vy: Math.sin(direction) * speed,\n width: strip ? 2 + random() * 1.5 : 6 + random() * 4,\n height: strip ? 10 + random() * 6 : 3 + random() * 2.5,\n angle: random() * Math.PI * 2,\n spin: (random() * 2 - 1) * 8,\n phase: random() * Math.PI * 2,\n flutter: 5 + random() * 7,\n color: palette[i % palette.length] ?? '',\n life: CONFETTI_LIFE_MS + random() * CONFETTI_LIFE_SPREAD_MS,\n });\n }\n return pieces;\n}\n\n/**\n * Moves one piece `dt` ms on. Gravity pulls, drag slows both axes towards the\n * terminal speed, the flutter sways it sideways as it flips, and the spin and\n * the flip advance; the life runs down.\n */\nexport function confettiStep(piece: WrConfettiPiece, dt: number): void {\n const s = dt / 1000;\n const keep = Math.exp(-CONFETTI_DRAG * s);\n const terminal = CONFETTI_GRAVITY / CONFETTI_DRAG;\n piece.vx *= keep;\n piece.vy = terminal + (piece.vy - terminal) * keep;\n piece.x += (piece.vx + Math.sin(piece.phase) * CONFETTI_SWAY) * s;\n piece.y += piece.vy * s;\n piece.angle += piece.spin * s;\n piece.phase += piece.flutter * s;\n piece.life -= dt;\n}\n\n/** Whether a piece is still worth drawing: alive and not below the bottom edge of a `height` tall viewport. */\nexport function confettiAlive(piece: WrConfettiPiece, height: number): boolean {\n return piece.life > 0 && piece.y - Math.max(piece.width, piece.height) < height;\n}\n\n/** A piece's opacity: solid, then fading over its last {@link CONFETTI_FADE_MS}. */\nexport function confettiAlpha(piece: WrConfettiPiece): number {\n return wrClamp(piece.life / CONFETTI_FADE_MS, 0, 1);\n}\n\n/**\n * A one-shot celebration: small paper pieces burst up and out from an\n * element, flutter, tumble and fall under gravity, and are gone inside two\n * and a half seconds. A service, not a component: call {@link burst} from\n * wherever the moment is.\n *\n * The first burst makes one fixed, full-viewport canvas in `document.body`\n * (`aria-hidden`, under no pointer, at the device ratio capped as the\n * backdrops cap it) and starts one frame loop; a burst that comes while\n * pieces are in the air joins the same canvas and loop, and the canvas goes\n * when the last piece has faded or dropped off the bottom. The layout of a\n * burst is deterministic for a seed; the physics is in {@link confettiLaunch},\n * {@link confettiStep} and {@link confettiAlive}, pure functions a spec can\n * run on their own. Each piece is a rectangle, every fifth a thin strip,\n * turning on the screen plane while its drawn height follows a cosine, so it\n * flips like paper; the back of a piece paints a shade darker.\n *\n * Colours are the `--wr-confetti-color-*` hooks on the canvas, bare theme\n * intents by default, resolved through the cascade when a burst starts, so\n * the scheme the reader is in is the one that paints. Nothing happens under\n * `prefers-reduced-motion: reduce` (a preference that flips mid-burst clears\n * the canvas at once), under `forced-colors: active` or on the server; a\n * hidden document pauses the loop and a visible one resumes it where it\n * stopped. Styles: `@use 'ngwr/animations/confetti'`, which places the canvas and\n * lists the `--wr-confetti-color-*` hooks; a service has no host to check them\n * from, so the first burst warns in dev mode when the sheet is missing.\n */\n@Service()\nexport class WrConfetti {\n private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private canvas: HTMLCanvasElement | null = null;\n private ctx: CanvasRenderingContext2D | null = null;\n private pieces: WrConfettiPiece[] = [];\n private rafId: number | null = null;\n private lastFrame = 0;\n private dpr = 1;\n private width = 0;\n private height = 0;\n private listeners: AbortController | null = null;\n /** The stylesheet was looked for once in this document. */\n private checked = false;\n\n constructor() {\n if (!this.browser) return;\n\n effect(() => {\n const reduced = this.platform.prefersReducedMotion();\n this.platform.pageVisible();\n if (reduced) this.clear();\n else this.sync();\n });\n\n inject(DestroyRef).onDestroy(() => this.clear());\n }\n\n /** Whether pieces are in the air. */\n get active(): boolean {\n return this.pieces.length > 0;\n }\n\n /**\n * Throws a burst of confetti up from `from`: an element, whose client rect\n * is read now, or a rect in client coordinates. Pieces start anywhere\n * inside the rect, so a wide block showers along its width and a button\n * bursts from a point.\n */\n burst(from: Element | WrConfettiRect, options: WrConfettiOptions = {}): void {\n if (!this.browser || this.platform.prefersReducedMotion()) return;\n const view = this.doc.defaultView;\n if (!view || view.matchMedia?.('(forced-colors: active)').matches) return;\n\n const canvas = this.canvas ?? this.mount(view);\n if (!canvas) return;\n const rect = 'getBoundingClientRect' in from ? from.getBoundingClientRect() : from;\n const seed = options.seed ?? Math.floor(Math.random() * 0x1_0000_0000);\n const palette = CONFETTI_COLORS.map(([hook, fallback]) => wrResolveCssColor(canvas, hook, fallback));\n this.pieces.push(...confettiLaunch(rect, seed, options.count ?? CONFETTI_COUNT, palette));\n this.sync();\n }\n\n /** Stops the loop and takes the canvas and every piece out. Idempotent. */\n clear(): void {\n this.stopLoop();\n this.pieces = [];\n this.listeners?.abort();\n this.listeners = null;\n this.canvas?.remove();\n this.canvas = null;\n this.ctx = null;\n }\n\n /** Makes the canvas, or returns `null` when the browser gives it no context. */\n private mount(view: Window): HTMLCanvasElement | null {\n const canvas = this.doc.createElement('canvas');\n canvas.className = 'wr-confetti';\n canvas.setAttribute('aria-hidden', 'true');\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n this.canvas = canvas;\n this.ctx = ctx;\n this.listeners = new AbortController();\n view.addEventListener('resize', () => this.resize(view), { signal: this.listeners.signal, passive: true });\n this.doc.body.append(canvas);\n this.resize(view);\n if (typeof ngDevMode === 'undefined' || ngDevMode) this.checkStyles(view);\n return canvas;\n }\n\n /**\n * The service's own `wrCheckStyles`, which a root service cannot call: that\n * helper reads the host element it is injected beside, and a service has\n * none. The same marker, the same words, once per document.\n */\n private checkStyles(view: Window): void {\n if (this.checked || /jsdom|happydom/i.test(view.navigator.userAgent)) return;\n this.checked = true;\n const loaded = view.getComputedStyle(this.doc.documentElement).getPropertyValue('--wr-loaded-animations-confetti');\n if (loaded.trim() !== '') return;\n // eslint-disable-next-line no-console -- a dev-mode diagnostic, reported and never thrown\n console.warn(\n \"[NGWR] WrConfetti paints without its styles. Add @use 'ngwr/animations/confetti'; to your global stylesheet, \" +\n 'or run ng g ngwr:component-style animations/confetti.'\n );\n }\n\n private resize(view: Window): void {\n if (!this.canvas || !this.ctx) return;\n this.width = view.innerWidth;\n this.height = view.innerHeight;\n this.dpr = canvasBackdropRatio(Math.max(1, this.width), Math.max(1, this.height), view.devicePixelRatio ?? 1);\n this.canvas.width = Math.round(this.width * this.dpr);\n this.canvas.height = Math.round(this.height * this.dpr);\n }\n\n /** Starts or stops the loop: it runs while pieces are in the air and the document is visible. */\n private sync(): void {\n const run = this.ctx !== null && this.pieces.length > 0 && this.platform.pageVisible();\n if (run === (this.rafId !== null)) return;\n if (run) {\n this.lastFrame = performance.now();\n this.rafId = requestAnimationFrame(this.frame);\n return;\n }\n this.stopLoop();\n }\n\n private stopLoop(): void {\n if (this.rafId !== null) cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n\n private readonly frame = (now: number): void => {\n this.rafId = null;\n // A tab that was throttled comes back with one huge frame; the pieces move at most this far at once.\n const dt = wrClamp(now - this.lastFrame, 0, MAX_FRAME_MS);\n this.lastFrame = now;\n for (const piece of this.pieces) confettiStep(piece, dt);\n this.pieces = this.pieces.filter(piece => confettiAlive(piece, this.height));\n if (this.pieces.length === 0) {\n this.clear();\n return;\n }\n this.draw();\n this.rafId = requestAnimationFrame(this.frame);\n };\n\n private draw(): void {\n const ctx = this.ctx;\n if (!ctx) return;\n const { dpr } = this;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, this.width * dpr, this.height * dpr);\n for (const piece of this.pieces) {\n const flip = Math.cos(piece.phase);\n // Never flat: a sheet seen edge-on still shows its edge.\n const thickness = Math.sign(flip || 1) * Math.max(0.12, Math.abs(flip));\n ctx.setTransform(dpr, 0, 0, dpr, piece.x * dpr, piece.y * dpr);\n ctx.rotate(piece.angle);\n ctx.scale(1, thickness);\n // The back of the paper is in shadow.\n ctx.globalAlpha = confettiAlpha(piece) * (flip < 0 ? 0.75 : 1);\n ctx.fillStyle = piece.color;\n ctx.fillRect(-piece.width / 2, -piece.height / 2, piece.width, piece.height);\n }\n ctx.globalAlpha = 1;\n }\n}\n\nexport {\n CONFETTI_CONE,\n CONFETTI_COUNT,\n CONFETTI_DRAG,\n CONFETTI_FADE_MS,\n CONFETTI_GRAVITY,\n CONFETTI_LIFE_MS,\n CONFETTI_LIFE_SPREAD_MS,\n CONFETTI_SPEED_MAX,\n CONFETTI_SPEED_MIN,\n CONFETTI_STRIP_EVERY,\n};\n"],"mappings":";;;;;;;;;;;;AAmCA,MAAM,gBAAgB;AAGtB,MAAM,gBAAgB;AAGtB,MAAM,mBAAmB;AAezB,MAAM,kBAA0E;CAC9E,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;CACxC,CAAC,8BAA8B,SAAS;AACzC;AA2B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,GAAG;EACvD,KAAK,MAAM,SAAS,KAAK,QAAQ;GAC/B,MAAM,OAAO,KAAK,IAAI,MAAM,KAAK;GAEjC,MAAM,YAAY,KAAK,KAAK,QAAQ,CAAC,IAAI,KAAK,IAAI,KAAM,KAAK,IAAI,IAAI,CAAC;GACtE,IAAI,aAAa,KAAK,GAAG,GAAG,KAAK,MAAM,IAAI,KAAK,MAAM,IAAI,GAAG;GAC7D,IAAI,OAAO,MAAM,KAAK;GACtB,IAAI,MAAM,GAAG,SAAS;GAEtB,IAAI,cAAc,cAAc,KAAK,KAAK,OAAO,IAAI,MAAO;GAC5D,IAAI,YAAY,MAAM;GACtB,IAAI,SAAS,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,SAAS,GAAG,MAAM,OAAO,MAAM,MAAM;EAC7E;EACA,IAAI,cAAc;CACpB;CA/JW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAU,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAV,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAU,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA,EADtB,MAAA,Q"}
@@ -196,7 +196,7 @@ var WrDecode = class WrDecode {
196
196
  }
197
197
  static ɵfac = i0.ɵɵngDeclareFactory({
198
198
  minVersion: "12.0.0",
199
- version: "22.2.6",
199
+ version: "22.3.0",
200
200
  ngImport: i0,
201
201
  type: WrDecode,
202
202
  deps: [],
@@ -204,7 +204,7 @@ var WrDecode = class WrDecode {
204
204
  });
205
205
  static ɵdir = i0.ɵɵngDeclareDirective({
206
206
  minVersion: "17.1.0",
207
- version: "22.2.6",
207
+ version: "22.3.0",
208
208
  type: WrDecode,
209
209
  isStandalone: true,
210
210
  selector: "[wrDecode]",
@@ -244,7 +244,7 @@ var WrDecode = class WrDecode {
244
244
  };
245
245
  i0.ɵɵngDeclareClassMetadata({
246
246
  minVersion: "12.0.0",
247
- version: "22.2.6",
247
+ version: "22.3.0",
248
248
  ngImport: i0,
249
249
  type: WrDecode,
250
250
  decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-decode.mjs","names":[],"sources":["../../../projects/lib/animations/decode/decode.ts","../../../projects/lib/animations/decode/public-api.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 { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { BREAKING_SPACES, FOCUSABLE, VIEW_THRESHOLD, graphemes, optionalMs, staggerGap } from '../internal';\n\nimport type { WrDecodeShape, WrDecodeTrigger } from './types';\n\n/** How long a glyph stays before the next one, in ms: fast enough to read as noise, slow enough to read as glyphs. */\nconst DECODE_GLYPH_MS = 55;\n\n/** How long the whole text scrambles before the first slot locks, in ms. */\nconst DECODE_HOLD = 360;\n\n/** The gap between one slot locking and the next when `stagger` is not set, in ms. */\nconst DECODE_GAP = 36;\n\n/** How long a locked slot takes to ease from the tint to the text colour, in ms. */\nconst DECODE_SETTLE = 240;\n\nconst GLYPHS: Readonly<Record<WrDecodeShape, string>> = {\n upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',\n lower: 'abcdefghijklmnopqrstuvwxyz',\n digit: '0123456789',\n symbol: '#%&*+-=<>?!/\\\\~',\n};\n\n/** The shape of one grapheme: what its random stand-ins are drawn from. */\nfunction decodeShape(grapheme: string): WrDecodeShape {\n if (/^\\d$/.test(grapheme)) return 'digit';\n const upper = grapheme.toUpperCase();\n const lower = grapheme.toLowerCase();\n if (upper === lower) return 'symbol';\n return grapheme === upper ? 'upper' : 'lower';\n}\n\n/** A random glyph from `glyphs`, another than `current` when there is a choice, so every reroll is a visible change. */\nfunction pick(glyphs: readonly string[], current?: string): string {\n if (glyphs.length < 2) return glyphs[0] ?? '';\n let glyph: string;\n do {\n glyph = glyphs[Math.floor(Math.random() * glyphs.length)];\n } while (glyph === current);\n return glyph;\n}\n\ninterface DecodeSlot {\n readonly el: HTMLElement;\n readonly glyphs: readonly string[];\n /** When the slot locks, in ms from the first glyph. */\n readonly at: number;\n locked: boolean;\n}\n\n/**\n * A readout locking on: when it plays, every character of the host's text\n * shows random glyphs that change quickly, then settles on its real character,\n * one after another in reading order. The line never moves while it plays:\n * the real character stays in its slot, hidden, and the glyph is painted over\n * it, centred, out of flow, so a wide stand-in may overlap its neighbour but\n * never pushes it. A glyph keeps the shape of the character it stands in for\n * (upper, lower, digit, or a symbol for punctuation) so the word shape stays\n * readable; spaces never scramble. The host keeps its own tag and its authored\n * children: they are moved out while the slots play and the same nodes are\n * moved back when the last slot has settled, so selection, find-in-page and\n * Angular bindings inside work as before. While split, the slots are\n * `aria-hidden` and a visually-hidden copy of the text stands beside them, so\n * a screen reader hears the text once and never the noise. Nothing plays\n * under `prefers-reduced-motion: reduce`, on the server or, in `view` mode,\n * without `IntersectionObserver`.\n */\n@Directive({\n selector: '[wrDecode]',\n host: { class: 'wr-decode' },\n})\nexport class WrDecode {\n /**\n * `view` plays once, the first time most of the host is in the viewport.\n * `hover` plays on every pointer enter and focus of the host or its closest\n * focusable ancestor, but never restarts while already playing. @default 'view'\n */\n readonly trigger = input<WrDecodeTrigger>('view');\n\n /**\n * The characters random glyphs are drawn from, for every slot. Unset, each\n * slot draws from the shape of its own character: uppercase letters and\n * digits for an uppercase letter, lowercase for lowercase, digits for a digit,\n * a few symbols for anything else.\n */\n readonly glyphs = input<string | null>(null);\n\n /**\n * Gap between one slot locking and the next, in ms. Unset, 36. Either way\n * the locks spread over 1.2 s at most, so for a long text the gap shrinks\n * until the last slot locks by then.\n */\n readonly stagger = input<number | null, unknown>(null, { transform: optionalMs });\n\n /** Pause between the trigger and the first glyph, in ms. The text stands as authored meanwhile. @default 0 */\n readonly delay = input(0, { transform: wrNumAttr(0) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private observer: IntersectionObserver | null = null;\n private listeners: AbortController | null = null;\n private frame = 0;\n /** The host's authored children while they are out of the DOM, else `null`. */\n private original: ChildNode[] | null = null;\n private slots: DecodeSlot[] = [];\n private started: number | null = null;\n private lastGlyph = -Infinity;\n private playing = false;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/decode');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n if (this.trigger() === 'hover') {\n this.listen();\n return;\n }\n if (typeof IntersectionObserver === 'undefined') return;\n this.observer = new IntersectionObserver(\n entries => {\n if (!entries.some(entry => entry.isIntersecting)) return;\n this.observer?.disconnect();\n this.observer = null;\n this.start();\n },\n { threshold: VIEW_THRESHOLD }\n );\n this.observer.observe(this.host.nativeElement);\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.observer?.disconnect();\n this.observer = null;\n this.listeners?.abort();\n this.listeners = null;\n this.restore();\n });\n }\n\n /** `hover` mode: the closest focusable ancestor is what a keyboard reaches, so it is what both events are read on. */\n private listen(): void {\n const host = this.host.nativeElement;\n const target = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n target.addEventListener('pointerenter', () => this.start(), options);\n target.addEventListener('focusin', () => this.start(), options);\n }\n\n /** Begin a play, unless one is running or motion is reduced now. The DOM is touched only once the delay has passed. */\n private start(): void {\n if (this.playing || this.platform.prefersReducedMotion()) return;\n this.playing = true;\n this.started = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n private tick(now: number): void {\n this.started ??= now;\n const elapsed = now - this.started - Math.max(0, this.delay());\n if (elapsed < 0) {\n this.frame = requestAnimationFrame(t => this.tick(t));\n return;\n }\n if (!this.original) {\n this.arm();\n if (!this.original) return;\n }\n\n const reroll = now - this.lastGlyph >= DECODE_GLYPH_MS;\n if (reroll) this.lastGlyph = now;\n let busy = false;\n for (const slot of this.slots) {\n if (slot.locked) continue;\n if (elapsed >= slot.at) {\n slot.locked = true;\n slot.el.classList.remove('wr-decode__slot--scramble');\n continue;\n }\n busy = true;\n if (reroll) slot.el.dataset['glyph'] = pick(slot.glyphs, slot.el.dataset['glyph']);\n }\n if (!busy && elapsed >= this.slots[this.slots.length - 1].at + DECODE_SETTLE) {\n this.restore();\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Split the authored children into slots and scramble them in one task, so\n * the first frame the slots can be seen in already shows glyphs. A slot holds\n * its real character as its only text; the glyph lives in `data-glyph` and is\n * painted by the stylesheet, so the slot's width is the character's.\n */\n private arm(): void {\n const host = this.host.nativeElement;\n const original = Array.from(host.childNodes);\n const text = host.textContent ?? '';\n const custom = this.glyphs();\n const wrapper = document.createElement('span');\n wrapper.className = 'wr-decode__slots';\n wrapper.setAttribute('aria-hidden', 'true');\n const slots: DecodeSlot[] = [];\n\n for (const node of original) {\n if (node.nodeType !== Node.TEXT_NODE) {\n // An inline element (`<code>`, `<a>`) moves whole and does not scramble; a comment keeps its place.\n wrapper.append(node);\n continue;\n }\n // `split` on a capturing group alternates: a run of text, then the spaces after it.\n (node.textContent ?? '').split(BREAKING_SPACES).forEach((run, i) => {\n if (run === '') return;\n if (i % 2 === 1) {\n wrapper.append(run);\n return;\n }\n for (const grapheme of graphemes(run)) {\n if (/^\\s+$/.test(grapheme)) {\n wrapper.append(grapheme);\n continue;\n }\n const shape = decodeShape(grapheme);\n const el = document.createElement('span');\n el.className = `wr-decode__slot wr-decode__slot--${shape} wr-decode__slot--scramble`;\n el.textContent = grapheme;\n slots.push({\n el,\n glyphs: [...new Set(graphemes(custom && custom.length > 0 ? custom : GLYPHS[shape]))],\n at: 0,\n locked: false,\n });\n wrapper.append(el);\n }\n });\n }\n\n if (slots.length === 0) {\n this.playing = false;\n return;\n }\n\n const gap = staggerGap('letters', slots.length, this.stagger() ?? DECODE_GAP);\n this.slots = slots.map((slot, i) => ({ ...slot, at: DECODE_HOLD + i * gap }));\n this.lastGlyph = -Infinity;\n for (const slot of this.slots) slot.el.dataset['glyph'] = pick(slot.glyphs);\n\n const copy = document.createElement('span');\n copy.className = 'wr-decode__sr';\n copy.textContent = text;\n\n this.original = original;\n wrapper.style.setProperty('--wr-decode-settle', `${DECODE_SETTLE}ms`);\n host.replaceChildren(wrapper, copy);\n host.classList.add('wr-decode--run');\n }\n\n /**\n * Put the authored children back, the same node objects, drop the slots and\n * stop the frames. Idempotent: the end of a play and destroy both call it.\n */\n private restore(): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.playing = false;\n this.started = null;\n if (!this.original) return;\n const host = this.host.nativeElement;\n host.replaceChildren(...this.original);\n host.classList.remove('wr-decode--run');\n this.original = null;\n this.slots = [];\n }\n}\n\n// The timings and the shape rule, for the spec; the entry point does not export them.\nexport { DECODE_GAP, DECODE_GLYPH_MS, DECODE_HOLD, DECODE_SETTLE, decodeShape };\n","/**\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\nexport { WrDecode } from './decode';\nexport type { WrDecodeShape, WrDecodeTrigger } from './types';\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,SAAkD;CACtD,OAAO;CACP,OAAO;CACP,OAAO;CACP,QAAQ;AACT;AAGD,SAAS,YAAY,UAAgB;CACnC,IAAI,OAAO,KAAK,QAAQ,GAAG,OAAO;CAClC,MAAM,QAAQ,SAAS,YAAW;CAElC,IAAI,UADU,SAAS,YACT,GAAO,OAAO;CAC5B,OAAO,aAAa,QAAQ,UAA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A;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,gBAAA,YAAA;EAAA,UAAA;CAAA,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EAJpB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,OAAO,YAAW;EAC3B,CAAA"}
1
+ {"version":3,"file":"ngwr-animations-decode.mjs","names":[],"sources":["../../../projects/lib/animations/decode/decode.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 { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { BREAKING_SPACES, FOCUSABLE, VIEW_THRESHOLD, graphemes, optionalMs, staggerGap } from '../internal';\n\nimport type { WrDecodeShape, WrDecodeTrigger } from './types';\n\n/** How long a glyph stays before the next one, in ms: fast enough to read as noise, slow enough to read as glyphs. */\nconst DECODE_GLYPH_MS = 55;\n\n/** How long the whole text scrambles before the first slot locks, in ms. */\nconst DECODE_HOLD = 360;\n\n/** The gap between one slot locking and the next when `stagger` is not set, in ms. */\nconst DECODE_GAP = 36;\n\n/** How long a locked slot takes to ease from the tint to the text colour, in ms. */\nconst DECODE_SETTLE = 240;\n\nconst GLYPHS: Readonly<Record<WrDecodeShape, string>> = {\n upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',\n lower: 'abcdefghijklmnopqrstuvwxyz',\n digit: '0123456789',\n symbol: '#%&*+-=<>?!/\\\\~',\n};\n\n/** The shape of one grapheme: what its random stand-ins are drawn from. */\nfunction decodeShape(grapheme: string): WrDecodeShape {\n if (/^\\d$/.test(grapheme)) return 'digit';\n const upper = grapheme.toUpperCase();\n const lower = grapheme.toLowerCase();\n if (upper === lower) return 'symbol';\n return grapheme === upper ? 'upper' : 'lower';\n}\n\n/** A random glyph from `glyphs`, another than `current` when there is a choice, so every reroll is a visible change. */\nfunction pick(glyphs: readonly string[], current?: string): string {\n if (glyphs.length < 2) return glyphs[0] ?? '';\n let glyph: string;\n do {\n glyph = glyphs[Math.floor(Math.random() * glyphs.length)];\n } while (glyph === current);\n return glyph;\n}\n\ninterface DecodeSlot {\n readonly el: HTMLElement;\n readonly glyphs: readonly string[];\n /** When the slot locks, in ms from the first glyph. */\n readonly at: number;\n locked: boolean;\n}\n\n/**\n * A readout locking on: when it plays, every character of the host's text\n * shows random glyphs that change quickly, then settles on its real character,\n * one after another in reading order. The line never moves while it plays:\n * the real character stays in its slot, hidden, and the glyph is painted over\n * it, centred, out of flow, so a wide stand-in may overlap its neighbour but\n * never pushes it. A glyph keeps the shape of the character it stands in for\n * (upper, lower, digit, or a symbol for punctuation) so the word shape stays\n * readable; spaces never scramble. The host keeps its own tag and its authored\n * children: they are moved out while the slots play and the same nodes are\n * moved back when the last slot has settled, so selection, find-in-page and\n * Angular bindings inside work as before. While split, the slots are\n * `aria-hidden` and a visually-hidden copy of the text stands beside them, so\n * a screen reader hears the text once and never the noise. Nothing plays\n * under `prefers-reduced-motion: reduce`, on the server or, in `view` mode,\n * without `IntersectionObserver`.\n */\n@Directive({\n selector: '[wrDecode]',\n host: { class: 'wr-decode' },\n})\nexport class WrDecode {\n /**\n * `view` plays once, the first time most of the host is in the viewport.\n * `hover` plays on every pointer enter and focus of the host or its closest\n * focusable ancestor, but never restarts while already playing. @default 'view'\n */\n readonly trigger = input<WrDecodeTrigger>('view');\n\n /**\n * The characters random glyphs are drawn from, for every slot. Unset, each\n * slot draws from the shape of its own character: uppercase letters and\n * digits for an uppercase letter, lowercase for lowercase, digits for a digit,\n * a few symbols for anything else.\n */\n readonly glyphs = input<string | null>(null);\n\n /**\n * Gap between one slot locking and the next, in ms. Unset, 36. Either way\n * the locks spread over 1.2 s at most, so for a long text the gap shrinks\n * until the last slot locks by then.\n */\n readonly stagger = input<number | null, unknown>(null, { transform: optionalMs });\n\n /** Pause between the trigger and the first glyph, in ms. The text stands as authored meanwhile. @default 0 */\n readonly delay = input(0, { transform: wrNumAttr(0) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private observer: IntersectionObserver | null = null;\n private listeners: AbortController | null = null;\n private frame = 0;\n /** The host's authored children while they are out of the DOM, else `null`. */\n private original: ChildNode[] | null = null;\n private slots: DecodeSlot[] = [];\n private started: number | null = null;\n private lastGlyph = -Infinity;\n private playing = false;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/decode');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n if (this.trigger() === 'hover') {\n this.listen();\n return;\n }\n if (typeof IntersectionObserver === 'undefined') return;\n this.observer = new IntersectionObserver(\n entries => {\n if (!entries.some(entry => entry.isIntersecting)) return;\n this.observer?.disconnect();\n this.observer = null;\n this.start();\n },\n { threshold: VIEW_THRESHOLD }\n );\n this.observer.observe(this.host.nativeElement);\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.observer?.disconnect();\n this.observer = null;\n this.listeners?.abort();\n this.listeners = null;\n this.restore();\n });\n }\n\n /** `hover` mode: the closest focusable ancestor is what a keyboard reaches, so it is what both events are read on. */\n private listen(): void {\n const host = this.host.nativeElement;\n const target = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n target.addEventListener('pointerenter', () => this.start(), options);\n target.addEventListener('focusin', () => this.start(), options);\n }\n\n /** Begin a play, unless one is running or motion is reduced now. The DOM is touched only once the delay has passed. */\n private start(): void {\n if (this.playing || this.platform.prefersReducedMotion()) return;\n this.playing = true;\n this.started = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n private tick(now: number): void {\n this.started ??= now;\n const elapsed = now - this.started - Math.max(0, this.delay());\n if (elapsed < 0) {\n this.frame = requestAnimationFrame(t => this.tick(t));\n return;\n }\n if (!this.original) {\n this.arm();\n if (!this.original) return;\n }\n\n const reroll = now - this.lastGlyph >= DECODE_GLYPH_MS;\n if (reroll) this.lastGlyph = now;\n let busy = false;\n for (const slot of this.slots) {\n if (slot.locked) continue;\n if (elapsed >= slot.at) {\n slot.locked = true;\n slot.el.classList.remove('wr-decode__slot--scramble');\n continue;\n }\n busy = true;\n if (reroll) slot.el.dataset['glyph'] = pick(slot.glyphs, slot.el.dataset['glyph']);\n }\n if (!busy && elapsed >= this.slots[this.slots.length - 1].at + DECODE_SETTLE) {\n this.restore();\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Split the authored children into slots and scramble them in one task, so\n * the first frame the slots can be seen in already shows glyphs. A slot holds\n * its real character as its only text; the glyph lives in `data-glyph` and is\n * painted by the stylesheet, so the slot's width is the character's.\n */\n private arm(): void {\n const host = this.host.nativeElement;\n const original = Array.from(host.childNodes);\n const text = host.textContent ?? '';\n const custom = this.glyphs();\n const wrapper = document.createElement('span');\n wrapper.className = 'wr-decode__slots';\n wrapper.setAttribute('aria-hidden', 'true');\n const slots: DecodeSlot[] = [];\n\n for (const node of original) {\n if (node.nodeType !== Node.TEXT_NODE) {\n // An inline element (`<code>`, `<a>`) moves whole and does not scramble; a comment keeps its place.\n wrapper.append(node);\n continue;\n }\n // `split` on a capturing group alternates: a run of text, then the spaces after it.\n (node.textContent ?? '').split(BREAKING_SPACES).forEach((run, i) => {\n if (run === '') return;\n if (i % 2 === 1) {\n wrapper.append(run);\n return;\n }\n for (const grapheme of graphemes(run)) {\n if (/^\\s+$/.test(grapheme)) {\n wrapper.append(grapheme);\n continue;\n }\n const shape = decodeShape(grapheme);\n const el = document.createElement('span');\n el.className = `wr-decode__slot wr-decode__slot--${shape} wr-decode__slot--scramble`;\n el.textContent = grapheme;\n slots.push({\n el,\n glyphs: [...new Set(graphemes(custom && custom.length > 0 ? custom : GLYPHS[shape]))],\n at: 0,\n locked: false,\n });\n wrapper.append(el);\n }\n });\n }\n\n if (slots.length === 0) {\n this.playing = false;\n return;\n }\n\n const gap = staggerGap('letters', slots.length, this.stagger() ?? DECODE_GAP);\n this.slots = slots.map((slot, i) => ({ ...slot, at: DECODE_HOLD + i * gap }));\n this.lastGlyph = -Infinity;\n for (const slot of this.slots) slot.el.dataset['glyph'] = pick(slot.glyphs);\n\n const copy = document.createElement('span');\n copy.className = 'wr-decode__sr';\n copy.textContent = text;\n\n this.original = original;\n wrapper.style.setProperty('--wr-decode-settle', `${DECODE_SETTLE}ms`);\n host.replaceChildren(wrapper, copy);\n host.classList.add('wr-decode--run');\n }\n\n /**\n * Put the authored children back, the same node objects, drop the slots and\n * stop the frames. Idempotent: the end of a play and destroy both call it.\n */\n private restore(): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.playing = false;\n this.started = null;\n if (!this.original) return;\n const host = this.host.nativeElement;\n host.replaceChildren(...this.original);\n host.classList.remove('wr-decode--run');\n this.original = null;\n this.slots = [];\n }\n}\n\n// The timings and the shape rule, for the spec; the entry point does not export them.\nexport { DECODE_GAP, DECODE_GLYPH_MS, DECODE_HOLD, DECODE_SETTLE, decodeShape };\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,SAAkD;CACtD,OAAO;CACP,OAAO;CACP,OAAO;CACP,QAAQ;AACT;AAGD,SAAS,YAAY,UAAgB;CACnC,IAAI,OAAO,KAAK,QAAQ,GAAG,OAAO;CAClC,MAAM,QAAQ,SAAS,YAAW;CAElC,IAAI,UADU,SAAS,YACT,GAAO,OAAO;CAC5B,OAAO,aAAa,QAAQ,UAAU;AACxC;AAGA,SAA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A,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,gBAAA,YAAA;EAAA,UAAA;CAAA,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EAJpB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,OAAO,YAAW;EAC3B,CAAA"}
@@ -176,7 +176,7 @@ var WrDestruct = class WrDestruct {
176
176
  }
177
177
  static ɵfac = i0.ɵɵngDeclareFactory({
178
178
  minVersion: "12.0.0",
179
- version: "22.2.6",
179
+ version: "22.3.0",
180
180
  ngImport: i0,
181
181
  type: WrDestruct,
182
182
  deps: [],
@@ -184,7 +184,7 @@ var WrDestruct = class WrDestruct {
184
184
  });
185
185
  static ɵdir = i0.ɵɵngDeclareDirective({
186
186
  minVersion: "17.1.0",
187
- version: "22.2.6",
187
+ version: "22.3.0",
188
188
  type: WrDestruct,
189
189
  isStandalone: true,
190
190
  selector: "[wrDestruct]",
@@ -201,7 +201,7 @@ var WrDestruct = class WrDestruct {
201
201
  };
202
202
  i0.ɵɵngDeclareClassMetadata({
203
203
  minVersion: "12.0.0",
204
- version: "22.2.6",
204
+ version: "22.3.0",
205
205
  ngImport: i0,
206
206
  type: WrDestruct,
207
207
  decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-destruct.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/destruct/destruct.ts","../../../projects/lib/animations/destruct/public-api.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 { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { FOCUSABLE, roundTo } from '../internal';\n\n/** How far a pixel of the text may move at full noise, each way, in em: 2.4px on 16px text. */\nconst DESTRUCT_SHIFT = 0.15;\n\n/**\n * How long one noise field stays before the next replaces it, in ms: about 15\n * fields a second. The displacement eases every frame; only the field steps.\n */\nconst DESTRUCT_STEP = 66;\n\n/** Time constant of the ease in, in seconds: 63% of the way after this long, 95% after three times it. */\nconst RISE = 0.12;\n\n/** Time constant of the ease out, in seconds: the calm is slower than the onset. */\nconst FALL = 0.3;\n\n/** The longest step one frame may integrate, in seconds: a stalled frame eases a little, never jumps. */\nconst MAX_STEP = 0.1;\n\n/** Closer than this to the target, the intensity is the target. */\nconst SNAP = 0.01;\n\n/**\n * How many waves of noise fit in one em, across and down. Across, about one:\n * each letter of a short word leans its own way. Down, more: a line of pixels\n * through a glyph shifts apart from the line under it, the tear of a weak\n * signal. In em so a heading and a footnote wobble alike at their own size.\n */\nconst WAVES_X = 1;\nconst WAVES_Y = 2;\n\n/** Octaves of the fractal noise: the second adds the fine grain over the sway. */\nconst OCTAVES = 2;\n\n/** The fallback font size, in px, where the computed style gives none. */\nconst FONT_SIZE = 16;\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/**\n * Text that wobbles with a fine, living noise, as if seen through heat haze\n * or over a weak signal, while a pointer is over it or focus is in it, and\n * settles back to crisp, still text when the pointer leaves.\n *\n * The text stays real text: no copy, no canvas. One hidden inline `<svg>`,\n * put beside the host, holds a filter of two primitives, `feTurbulence`\n * (fractal noise) feeding `feDisplacementMap`, and the host wears it through\n * `filter: url(#id)` while the noise is above zero. So selection, copy,\n * find-in-page, a screen reader and the host's own styling see the element\n * as it was. The frequency of the noise is set from the host's font size, so\n * the waves are the same share of a glyph at any size, and the peak shift is\n * `shift` em of it, small enough that the word reads at full noise.\n *\n * One `requestAnimationFrame` loop runs only while the noise is above zero:\n * each frame the intensity eases toward its target (one while a pointer is\n * over the host or its closest focusable ancestor, or focus is in it; zero\n * otherwise) by an exponential step, faster in than out, and the\n * displacement's `scale` follows it. The noise field itself steps to a new\n * seed about fifteen times a second, not every frame: often enough to live,\n * seldom enough to read as haze, not a strobe. When the intensity reaches\n * zero the filter comes off the host entirely, the loop idles, and the text\n * renders exactly as without the effect. A hidden document pauses the loop\n * where it is.\n *\n * Nothing mounts under `prefers-reduced-motion: reduce`, under\n * `forced-colors: active` or on the server, and a preference that flips\n * mid-run clears the filter at once. Destroy removes the `<svg>`, the filter\n * and the listeners, and cancels the loop.\n */\n@Directive({\n selector: '[wrDestruct]',\n host: { class: 'wr-destruct' },\n})\nexport class WrDestruct {\n /** How far a pixel of the text may move at full noise, each way, in em of the host's font size. @default 0.15 */\n readonly shift = input(DESTRUCT_SHIFT, { transform: wrNumAttr(DESTRUCT_SHIFT) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private readonly id = wrRandomId('wr-destruct');\n private readonly hot = signal(false);\n private listeners: AbortController | null = null;\n private svg: SVGSVGElement | null = null;\n private turbulence: SVGElement | null = null;\n private map: SVGElement | null = null;\n private frame: number | null = null;\n /** The timestamp of the last frame, or `null` when the next one is the first after a start. */\n private last: number | null = null;\n /** When the noise field last stepped, or `null` before the first step of a run. */\n private stepped: number | null = null;\n private seed = 0;\n private intensity = 0;\n /** The peak shift, in px, for the current run. */\n private peak = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/destruct');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n // The stylesheet paints no filter under forced colours: nothing to mount.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n this.mount();\n this.listen();\n });\n\n // One place decides what the loop does: reduced motion clears, a hidden\n // page pauses, otherwise a frame is asked for and the tick decides when\n // to idle. `shift` is read so a new peak reaches a run in flight.\n effect(() => {\n const hot = this.hot();\n const visible = this.platform.pageVisible();\n const reduced = this.platform.prefersReducedMotion();\n this.shift();\n untracked(() => {\n if (reduced) this.clear();\n else if (!visible) this.pause();\n else if (hot || this.intensity > 0) this.start();\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n this.clear();\n this.svg?.remove();\n this.svg = null;\n this.turbulence = null;\n this.map = null;\n });\n }\n\n /**\n * The filter, in a 0 by 0 `<svg>` right after the host: it lives and dies\n * with the host's subtree, and the host's own nodes are not touched. The\n * region is wider than the box by a quarter each way, so a pixel moved\n * off the edge of the glyphs is drawn, not cut.\n */\n private mount(): void {\n const svg = this.doc.createElementNS(SVG, 'svg');\n svg.setAttribute('class', 'wr-destruct__filter');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n svg.setAttribute('width', '0');\n svg.setAttribute('height', '0');\n const filter = this.doc.createElementNS(SVG, 'filter');\n filter.setAttribute('id', this.id);\n filter.setAttribute('x', '-25%');\n filter.setAttribute('y', '-25%');\n filter.setAttribute('width', '150%');\n filter.setAttribute('height', '150%');\n const turbulence = this.doc.createElementNS(SVG, 'feTurbulence');\n turbulence.setAttribute('type', 'fractalNoise');\n turbulence.setAttribute('numOctaves', String(OCTAVES));\n turbulence.setAttribute('seed', String(this.seed));\n turbulence.setAttribute('result', 'noise');\n const map = this.doc.createElementNS(SVG, 'feDisplacementMap');\n map.setAttribute('in', 'SourceGraphic');\n map.setAttribute('in2', 'noise');\n map.setAttribute('scale', '0');\n map.setAttribute('xChannelSelector', 'R');\n map.setAttribute('yChannelSelector', 'G');\n filter.append(turbulence, map);\n svg.append(filter);\n this.host.nativeElement.after(svg);\n this.svg = svg;\n this.turbulence = turbulence;\n this.map = map;\n }\n\n /** The closest focusable ancestor is what a keyboard reaches, so it is what focus is read on; the pointer is read there too. */\n private listen(): void {\n const host = this.host.nativeElement;\n const source = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n source.addEventListener('pointerenter', () => this.hot.set(true), options);\n source.addEventListener('pointerleave', () => this.hot.set(false), options);\n source.addEventListener('focusin', () => this.hot.set(true), options);\n source.addEventListener('focusout', () => this.hot.set(false), options);\n }\n\n /**\n * Ask for a frame, unless one is pending or nothing is mounted. A run that\n * starts from rest measures the host first: the font size may have changed\n * with the viewport since the last one.\n */\n private start(): void {\n if (this.frame !== null || !this.svg) return;\n if (this.intensity === 0) this.measure();\n this.last = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /** The peak shift and the noise frequency, from the host's font size, so both scale with the text. */\n private measure(): void {\n const computed = this.doc.defaultView?.getComputedStyle(this.host.nativeElement).fontSize;\n const parsed = computed === undefined ? NaN : parseFloat(computed);\n const size = Number.isFinite(parsed) && parsed > 0 ? parsed : FONT_SIZE;\n this.peak = Math.max(0, this.shift()) * size;\n this.turbulence?.setAttribute('baseFrequency', `${roundTo(WAVES_X / size, 4)} ${roundTo(WAVES_Y / size, 4)}`);\n }\n\n /** Drop the pending frame. The intensity and the filter stay where they are, so a restart continues from them. */\n private pause(): void {\n if (this.frame === null) return;\n cancelAnimationFrame(this.frame);\n this.frame = null;\n this.last = null;\n }\n\n /** Off at once: no frame, no filter, intensity zero. */\n private clear(): void {\n this.pause();\n this.intensity = 0;\n this.stepped = null;\n this.paint();\n }\n\n /**\n * One frame: ease the intensity toward its target, step the noise field\n * when its time has come, paint. The first frame after a start has no\n * length, so a pause of any length moves nothing when the loop resumes.\n */\n private tick(now: number): void {\n const dt = this.last === null ? 0 : Math.min(Math.max(0, now - this.last) / 1000, MAX_STEP);\n this.last = now;\n const target = this.hot() ? 1 : 0;\n const glide = target > this.intensity ? RISE : FALL;\n this.intensity += (target - this.intensity) * (1 - Math.exp(-dt / glide));\n if (Math.abs(target - this.intensity) < SNAP) this.intensity = target;\n if (this.intensity > 0 && (this.stepped === null || now - this.stepped >= DESTRUCT_STEP)) {\n this.stepped = now;\n this.turbulence?.setAttribute('seed', String(++this.seed));\n }\n this.paint();\n if (this.intensity === 0 && target === 0) {\n // Still, and asked to be: no frame until a pointer or focus arrives.\n this.frame = null;\n this.last = null;\n this.stepped = null;\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Written to the DOM by hand: a binding would wait for change detection,\n * and this is every frame. At zero the filter comes off the host entirely;\n * above it the displacement's `scale` is twice the shift, since the map\n * moves a pixel by `scale` times the noise's distance from its middle.\n */\n private paint(): void {\n if (!this.map) return;\n const el = this.host.nativeElement;\n if (this.intensity === 0) {\n el.classList.remove('wr-destruct--on');\n el.style.removeProperty('--wr-destruct-filter');\n this.map.setAttribute('scale', '0');\n return;\n }\n this.map.setAttribute('scale', String(roundTo(2 * this.peak * this.intensity, 2)));\n if (!el.classList.contains('wr-destruct--on')) {\n el.style.setProperty('--wr-destruct-filter', `url(#${this.id})`);\n el.classList.add('wr-destruct--on');\n }\n }\n}\n\nexport { DESTRUCT_SHIFT, DESTRUCT_STEP };\n","/**\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\nexport { WrDestruct } from './destruct';\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,iBAAiB;AASvB,MAAM,OAAO;AAGb,MAAM,OAAO;AAGb,MAAM,WAAW;AAGjB,MAAM,OAAO;AAQb,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,MAAM,UAAU;AAGhB,MAAM,YAAY;AAElB,MAAM,MAAM;AAoCZ,IAAa,aAAb,MAAa,WAAU;CAEZ,QAAQ,MAAM,gBAAc;EAAA,GAAA,YAAA,EAAA,WAAA,QAAA,+BAAA,CAAA;EAAI,WAAW,UAAU,cAAc;CAAC,CAAA;CAE5D,OAAO,OAAgC,UAA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UAAU;GACV,MAAM,EAAE,OAAO,cAAa;EAC7B,CAAA"}
1
+ {"version":3,"file":"ngwr-animations-destruct.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/destruct/destruct.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 { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { FOCUSABLE, roundTo } from '../internal';\n\n/** How far a pixel of the text may move at full noise, each way, in em: 2.4px on 16px text. */\nconst DESTRUCT_SHIFT = 0.15;\n\n/**\n * How long one noise field stays before the next replaces it, in ms: about 15\n * fields a second. The displacement eases every frame; only the field steps.\n */\nconst DESTRUCT_STEP = 66;\n\n/** Time constant of the ease in, in seconds: 63% of the way after this long, 95% after three times it. */\nconst RISE = 0.12;\n\n/** Time constant of the ease out, in seconds: the calm is slower than the onset. */\nconst FALL = 0.3;\n\n/** The longest step one frame may integrate, in seconds: a stalled frame eases a little, never jumps. */\nconst MAX_STEP = 0.1;\n\n/** Closer than this to the target, the intensity is the target. */\nconst SNAP = 0.01;\n\n/**\n * How many waves of noise fit in one em, across and down. Across, about one:\n * each letter of a short word leans its own way. Down, more: a line of pixels\n * through a glyph shifts apart from the line under it, the tear of a weak\n * signal. In em so a heading and a footnote wobble alike at their own size.\n */\nconst WAVES_X = 1;\nconst WAVES_Y = 2;\n\n/** Octaves of the fractal noise: the second adds the fine grain over the sway. */\nconst OCTAVES = 2;\n\n/** The fallback font size, in px, where the computed style gives none. */\nconst FONT_SIZE = 16;\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/**\n * Text that wobbles with a fine, living noise, as if seen through heat haze\n * or over a weak signal, while a pointer is over it or focus is in it, and\n * settles back to crisp, still text when the pointer leaves.\n *\n * The text stays real text: no copy, no canvas. One hidden inline `<svg>`,\n * put beside the host, holds a filter of two primitives, `feTurbulence`\n * (fractal noise) feeding `feDisplacementMap`, and the host wears it through\n * `filter: url(#id)` while the noise is above zero. So selection, copy,\n * find-in-page, a screen reader and the host's own styling see the element\n * as it was. The frequency of the noise is set from the host's font size, so\n * the waves are the same share of a glyph at any size, and the peak shift is\n * `shift` em of it, small enough that the word reads at full noise.\n *\n * One `requestAnimationFrame` loop runs only while the noise is above zero:\n * each frame the intensity eases toward its target (one while a pointer is\n * over the host or its closest focusable ancestor, or focus is in it; zero\n * otherwise) by an exponential step, faster in than out, and the\n * displacement's `scale` follows it. The noise field itself steps to a new\n * seed about fifteen times a second, not every frame: often enough to live,\n * seldom enough to read as haze, not a strobe. When the intensity reaches\n * zero the filter comes off the host entirely, the loop idles, and the text\n * renders exactly as without the effect. A hidden document pauses the loop\n * where it is.\n *\n * Nothing mounts under `prefers-reduced-motion: reduce`, under\n * `forced-colors: active` or on the server, and a preference that flips\n * mid-run clears the filter at once. Destroy removes the `<svg>`, the filter\n * and the listeners, and cancels the loop.\n */\n@Directive({\n selector: '[wrDestruct]',\n host: { class: 'wr-destruct' },\n})\nexport class WrDestruct {\n /** How far a pixel of the text may move at full noise, each way, in em of the host's font size. @default 0.15 */\n readonly shift = input(DESTRUCT_SHIFT, { transform: wrNumAttr(DESTRUCT_SHIFT) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private readonly id = wrRandomId('wr-destruct');\n private readonly hot = signal(false);\n private listeners: AbortController | null = null;\n private svg: SVGSVGElement | null = null;\n private turbulence: SVGElement | null = null;\n private map: SVGElement | null = null;\n private frame: number | null = null;\n /** The timestamp of the last frame, or `null` when the next one is the first after a start. */\n private last: number | null = null;\n /** When the noise field last stepped, or `null` before the first step of a run. */\n private stepped: number | null = null;\n private seed = 0;\n private intensity = 0;\n /** The peak shift, in px, for the current run. */\n private peak = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/destruct');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n // The stylesheet paints no filter under forced colours: nothing to mount.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n this.mount();\n this.listen();\n });\n\n // One place decides what the loop does: reduced motion clears, a hidden\n // page pauses, otherwise a frame is asked for and the tick decides when\n // to idle. `shift` is read so a new peak reaches a run in flight.\n effect(() => {\n const hot = this.hot();\n const visible = this.platform.pageVisible();\n const reduced = this.platform.prefersReducedMotion();\n this.shift();\n untracked(() => {\n if (reduced) this.clear();\n else if (!visible) this.pause();\n else if (hot || this.intensity > 0) this.start();\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n this.clear();\n this.svg?.remove();\n this.svg = null;\n this.turbulence = null;\n this.map = null;\n });\n }\n\n /**\n * The filter, in a 0 by 0 `<svg>` right after the host: it lives and dies\n * with the host's subtree, and the host's own nodes are not touched. The\n * region is wider than the box by a quarter each way, so a pixel moved\n * off the edge of the glyphs is drawn, not cut.\n */\n private mount(): void {\n const svg = this.doc.createElementNS(SVG, 'svg');\n svg.setAttribute('class', 'wr-destruct__filter');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n svg.setAttribute('width', '0');\n svg.setAttribute('height', '0');\n const filter = this.doc.createElementNS(SVG, 'filter');\n filter.setAttribute('id', this.id);\n filter.setAttribute('x', '-25%');\n filter.setAttribute('y', '-25%');\n filter.setAttribute('width', '150%');\n filter.setAttribute('height', '150%');\n const turbulence = this.doc.createElementNS(SVG, 'feTurbulence');\n turbulence.setAttribute('type', 'fractalNoise');\n turbulence.setAttribute('numOctaves', String(OCTAVES));\n turbulence.setAttribute('seed', String(this.seed));\n turbulence.setAttribute('result', 'noise');\n const map = this.doc.createElementNS(SVG, 'feDisplacementMap');\n map.setAttribute('in', 'SourceGraphic');\n map.setAttribute('in2', 'noise');\n map.setAttribute('scale', '0');\n map.setAttribute('xChannelSelector', 'R');\n map.setAttribute('yChannelSelector', 'G');\n filter.append(turbulence, map);\n svg.append(filter);\n this.host.nativeElement.after(svg);\n this.svg = svg;\n this.turbulence = turbulence;\n this.map = map;\n }\n\n /** The closest focusable ancestor is what a keyboard reaches, so it is what focus is read on; the pointer is read there too. */\n private listen(): void {\n const host = this.host.nativeElement;\n const source = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n source.addEventListener('pointerenter', () => this.hot.set(true), options);\n source.addEventListener('pointerleave', () => this.hot.set(false), options);\n source.addEventListener('focusin', () => this.hot.set(true), options);\n source.addEventListener('focusout', () => this.hot.set(false), options);\n }\n\n /**\n * Ask for a frame, unless one is pending or nothing is mounted. A run that\n * starts from rest measures the host first: the font size may have changed\n * with the viewport since the last one.\n */\n private start(): void {\n if (this.frame !== null || !this.svg) return;\n if (this.intensity === 0) this.measure();\n this.last = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /** The peak shift and the noise frequency, from the host's font size, so both scale with the text. */\n private measure(): void {\n const computed = this.doc.defaultView?.getComputedStyle(this.host.nativeElement).fontSize;\n const parsed = computed === undefined ? NaN : parseFloat(computed);\n const size = Number.isFinite(parsed) && parsed > 0 ? parsed : FONT_SIZE;\n this.peak = Math.max(0, this.shift()) * size;\n this.turbulence?.setAttribute('baseFrequency', `${roundTo(WAVES_X / size, 4)} ${roundTo(WAVES_Y / size, 4)}`);\n }\n\n /** Drop the pending frame. The intensity and the filter stay where they are, so a restart continues from them. */\n private pause(): void {\n if (this.frame === null) return;\n cancelAnimationFrame(this.frame);\n this.frame = null;\n this.last = null;\n }\n\n /** Off at once: no frame, no filter, intensity zero. */\n private clear(): void {\n this.pause();\n this.intensity = 0;\n this.stepped = null;\n this.paint();\n }\n\n /**\n * One frame: ease the intensity toward its target, step the noise field\n * when its time has come, paint. The first frame after a start has no\n * length, so a pause of any length moves nothing when the loop resumes.\n */\n private tick(now: number): void {\n const dt = this.last === null ? 0 : Math.min(Math.max(0, now - this.last) / 1000, MAX_STEP);\n this.last = now;\n const target = this.hot() ? 1 : 0;\n const glide = target > this.intensity ? RISE : FALL;\n this.intensity += (target - this.intensity) * (1 - Math.exp(-dt / glide));\n if (Math.abs(target - this.intensity) < SNAP) this.intensity = target;\n if (this.intensity > 0 && (this.stepped === null || now - this.stepped >= DESTRUCT_STEP)) {\n this.stepped = now;\n this.turbulence?.setAttribute('seed', String(++this.seed));\n }\n this.paint();\n if (this.intensity === 0 && target === 0) {\n // Still, and asked to be: no frame until a pointer or focus arrives.\n this.frame = null;\n this.last = null;\n this.stepped = null;\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Written to the DOM by hand: a binding would wait for change detection,\n * and this is every frame. At zero the filter comes off the host entirely;\n * above it the displacement's `scale` is twice the shift, since the map\n * moves a pixel by `scale` times the noise's distance from its middle.\n */\n private paint(): void {\n if (!this.map) return;\n const el = this.host.nativeElement;\n if (this.intensity === 0) {\n el.classList.remove('wr-destruct--on');\n el.style.removeProperty('--wr-destruct-filter');\n this.map.setAttribute('scale', '0');\n return;\n }\n this.map.setAttribute('scale', String(roundTo(2 * this.peak * this.intensity, 2)));\n if (!el.classList.contains('wr-destruct--on')) {\n el.style.setProperty('--wr-destruct-filter', `url(#${this.id})`);\n el.classList.add('wr-destruct--on');\n }\n }\n}\n\nexport { DESTRUCT_SHIFT, DESTRUCT_STEP };\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,iBAAiB;AASvB,MAAM,OAAO;AAGb,MAAM,OAAO;AAGb,MAAM,WAAW;AAGjB,MAAM,OAAO;AAQb,MAAM,UAAU;AAChB,MAAM,UAAU;A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AA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,MAAA,EAAA,gBAAA,cAAA;EAAA,UAAA;CAAA,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EAJtB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,OAAO,cAAa;EAC7B,CAAA"}
@@ -234,7 +234,7 @@ var WrDotGrid = class WrDotGrid {
234
234
  }
235
235
  static ɵfac = i0.ɵɵngDeclareFactory({
236
236
  minVersion: "12.0.0",
237
- version: "22.2.6",
237
+ version: "22.3.0",
238
238
  ngImport: i0,
239
239
  type: WrDotGrid,
240
240
  deps: [],
@@ -242,7 +242,7 @@ var WrDotGrid = class WrDotGrid {
242
242
  });
243
243
  static ɵcmp = i0.ɵɵngDeclareComponent({
244
244
  minVersion: "17.2.0",
245
- version: "22.2.6",
245
+ version: "22.3.0",
246
246
  type: WrDotGrid,
247
247
  isStandalone: true,
248
248
  selector: "wr-dot-grid",
@@ -280,7 +280,7 @@ var WrDotGrid = class WrDotGrid {
280
280
  };
281
281
  i0.ɵɵngDeclareClassMetadata({
282
282
  minVersion: "12.0.0",
283
- version: "22.2.6",
283
+ version: "22.3.0",
284
284
  ngImport: i0,
285
285
  type: WrDotGrid,
286
286
  decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-animations-dot-grid.mjs","names":[],"sources":["../../../projects/lib/animations/dot-grid/dot-grid.ts","../../../projects/lib/animations/dot-grid/dot-grid.html","../../../projects/lib/animations/dot-grid/public-api.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 { Component, DestroyRef, ElementRef, ViewEncapsulation, inject, input, viewChild } from '@angular/core';\n\nimport { wrClamp, wrNumAttr, wrResolveCssColorChannels, wrCheckStyles } from 'ngwr/utils';\n\nimport { MAX_DPR, MAX_PIXELS, createCanvasBackdrop } from '../internal';\n\n/** How far a dot is pushed at the pointer itself, in px. */\nconst PUSH = 14;\n/** Spring that returns a pushed dot, tuned per 60Hz frame: it overshoots about 15% and settles in half a second. */\nconst STIFFNESS = 0.12;\nconst DAMPING = 0.72;\n/** How much of the gap to its target a dot's light closes per 60Hz frame. */\nconst LIGHT_EASE = 0.18;\n/** Below this, in px and in light, a dot counts as at rest and snaps there. */\nconst REST_EPS = 0.02;\n/** The light is quantised into this many fill colours, so a frame is a handful of paths, not one per dot. */\nconst LEVELS = 8;\n/** A dot's radius at rest and fully lit, in px. */\nconst RADIUS = 1.1;\nconst RADIUS_LIT = 1.9;\n/** How much of its colour a dot shows at rest and fully lit. */\nconst ALPHA = 0.32;\nconst ALPHA_LIT = 0.75;\n/** A tap's ring: how far it travels and how long it takes. */\nconst PULSE_REACH = 220;\nconst PULSE_MS = 650;\nconst PULSE_WIDTH = 36;\nconst TAU = Math.PI * 2;\n\n/**\n * One damped spring step on one axis, in place: `vel[i]` is updated, then\n * added to `off[i]`. `scale` is the frame length in 60Hz frames, so a slow\n * frame takes a longer step and a fast screen a shorter one, and the motion\n * reads the same on both.\n */\nexport function dotGridSpringStep(\n off: Float32Array,\n vel: Float32Array,\n i: number,\n target: number,\n scale: number\n): void {\n const k = STIFFNESS * scale;\n const damping = DAMPING ** scale;\n vel[i] = (vel[i] + (target - off[i]) * k) * damping;\n off[i] += vel[i];\n}\n\n/** Where the dots of a `width` by `height` field sit, centred, `spacing` apart. */\nexport function dotGridLayout(\n width: number,\n height: number,\n spacing: number\n): { cols: number; rows: number; x: Float32Array<ArrayBuffer>; y: Float32Array<ArrayBuffer> } {\n const gap = Math.max(8, spacing);\n const cols = width > 0 && height > 0 ? Math.floor(width / gap) + 1 : 0;\n const rows = cols > 0 ? Math.floor(height / gap) + 1 : 0;\n const x0 = (width - (cols - 1) * gap) / 2;\n const y0 = (height - (rows - 1) * gap) / 2;\n const x = new Float32Array(cols * rows);\n const y = new Float32Array(cols * rows);\n for (let c = 0; c < cols; c++) {\n for (let r = 0; r < rows; r++) {\n const i = c * rows + r;\n x[i] = x0 + c * gap;\n y[i] = y0 + r * gap;\n }\n }\n return { cols, rows, x, y };\n}\n\n/**\n * An even field of small, faint dots behind a section's content. Near the\n * pointer the dots light up toward the primary colour and are pushed gently\n * away; each one follows a damped spring back to its place when the pointer\n * moves on, so a fast sweep leaves a short, soft wake that settles. With no\n * pointer the field rests.\n *\n * Fills its parent, which must be positioned (`position: relative`) and\n * isolated (`isolation: isolate`): the host is absolute, `inset: 0`, at\n * `z-index: -1`, so it lands at the floor of the parent's own stacking\n * context, under the content and over the page background. The parent takes\n * the pointer: the host and its canvas never do. One canvas through\n * `createCanvasBackdrop`, redrawn only while something moves: the frame loop\n * runs while the pointer is over the parent or a dot is still settling, and\n * only while the host is on screen and the document is visible; at rest the\n * still field is drawn once. Touch never pushes, so a\n * scroll over the section is never fought; a tap sends one ring of light out\n * from the finger instead.\n *\n * Colours come from the `--wr-dot-grid-*` hooks through `wrResolveCssColorChannels`,\n * re-read when the scheme changes. Under `prefers-reduced-motion: reduce` only\n * the still field is drawn; under `forced-colors: active` nothing is. The server\n * renders the empty canvas, absolutely positioned, so the browser's first draw\n * shifts no layout. Decorative: `aria-hidden`, no pointer events. Styles:\n * `@use 'ngwr/animations/dot-grid'`.\n */\n@Component({\n selector: 'wr-dot-grid',\n templateUrl: './dot-grid.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-dot-grid', 'aria-hidden': 'true' },\n})\nexport class WrDotGrid {\n /** Distance between two dots, in px. @default 26 */\n readonly spacing = input(26, { transform: wrNumAttr(26) });\n\n /** How far from the pointer a dot still lights and moves, in px. @default 140 */\n readonly reach = input(140, { transform: wrNumAttr(140) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly canvasRef = viewChild.required<ElementRef<HTMLCanvasElement>>('canvas');\n\n /** One fill per light level, rest first, and the radius that goes with it. */\n private fills: string[] = [];\n private radii: number[] = [];\n\n // One entry per dot, column-major\n private count = 0;\n private baseX = new Float32Array(0);\n private baseY = new Float32Array(0);\n private offX = new Float32Array(0);\n private offY = new Float32Array(0);\n private velX = new Float32Array(0);\n private velY = new Float32Array(0);\n private light = new Float32Array(0);\n /** Each dot's light level this frame, so the draw groups dots by fill. */\n private level = new Uint8Array(0);\n\n private pointerX = NaN;\n private pointerY = NaN;\n private pulseX = NaN;\n private pulseY = NaN;\n private pulseAge = Infinity;\n /** True while every dot sits at its place, unlit and still. */\n private settled = true;\n\n private pointerTarget: HTMLElement | null = null;\n\n private readonly backdrop = createCanvasBackdrop(() => this.canvasRef().nativeElement, {\n colors: canvas => this.resolveColors(canvas),\n layout: (width, height) => this.layout(width, height),\n active: () => this.pointerInside || !this.settled,\n advance: dt => this.advance(dt),\n draw: (ctx, width, height) => this.draw(ctx, width, height),\n rest: () => this.rest(),\n mounted: () => this.listen(),\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/dot-grid');\n inject(DestroyRef).onDestroy(() => {\n this.pointerTarget?.removeEventListener('pointermove', this.onPointerMove);\n this.pointerTarget?.removeEventListener('pointerleave', this.onPointerLeave);\n this.pointerTarget?.removeEventListener('pointerdown', this.onPointerDown);\n this.pointerTarget = null;\n });\n }\n\n /** The parent takes the pointer: the host and its canvas never do. */\n private listen(): void {\n const target = this.host.nativeElement.parentElement;\n this.pointerTarget = target;\n target?.addEventListener('pointermove', this.onPointerMove, { passive: true });\n target?.addEventListener('pointerleave', this.onPointerLeave, { passive: true });\n target?.addEventListener('pointerdown', this.onPointerDown, { passive: true });\n }\n\n // Pointer\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n // A finger that moves is scrolling: the field must never fight it.\n if (event.pointerType === 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pointerX = event.clientX - rect.left;\n this.pointerY = event.clientY - rect.top;\n this.settled = false;\n this.backdrop.sync();\n };\n\n private readonly onPointerLeave = (): void => {\n this.pointerX = NaN;\n this.pointerY = NaN;\n this.backdrop.sync();\n };\n\n private readonly onPointerDown = (event: PointerEvent): void => {\n if (event.pointerType !== 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pulseX = event.clientX - rect.left;\n this.pulseY = event.clientY - rect.top;\n this.pulseAge = 0;\n this.settled = false;\n this.backdrop.sync();\n };\n\n // Layout\n\n private resolveColors(canvas: HTMLCanvasElement): void {\n const ink = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-ink)', '#6b7280');\n const glow = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-glow)', '#3969e2');\n this.fills = [];\n this.radii = [];\n for (let l = 0; l < LEVELS; l++) {\n const t = l / (LEVELS - 1);\n const channel = (c: number): number => Math.round((ink[c] + (glow[c] - ink[c]) * t) * 255);\n const alpha = ALPHA + (ALPHA_LIT - ALPHA) * t;\n this.fills.push(`rgba(${channel(0)}, ${channel(1)}, ${channel(2)}, ${alpha.toFixed(3)})`);\n this.radii.push(RADIUS + (RADIUS_LIT - RADIUS) * t);\n }\n }\n\n private layout(width: number, height: number): void {\n const { x, y } = dotGridLayout(width, height, this.spacing());\n this.count = x.length;\n this.baseX = x;\n this.baseY = y;\n this.offX = new Float32Array(this.count);\n this.offY = new Float32Array(this.count);\n this.velX = new Float32Array(this.count);\n this.velY = new Float32Array(this.count);\n this.light = new Float32Array(this.count);\n this.level = new Uint8Array(this.count);\n this.settled = true;\n }\n\n // Motion\n\n /** Whether the pointer rests over the parent. */\n private get pointerInside(): boolean {\n return !Number.isNaN(this.pointerX);\n }\n\n /** Every dot back at its place, unlit and still. */\n private rest(): void {\n this.offX.fill(0);\n this.offY.fill(0);\n this.velX.fill(0);\n this.velY.fill(0);\n this.light.fill(0);\n this.level.fill(0);\n this.pulseAge = Infinity;\n this.settled = true;\n }\n\n /** Moves every dot one frame: the pointer's push and light, the tap's ring, then the springs. */\n private advance(dt: number): void {\n const scale = Math.min(2, dt / 16.7);\n const ease = 1 - (1 - LIGHT_EASE) ** scale;\n const reach = this.reach();\n const reach2 = reach * reach;\n const px = this.pointerX;\n const py = this.pointerY;\n const pointing = this.pointerInside;\n\n this.pulseAge += dt;\n const pulsing = this.pulseAge < PULSE_MS;\n const pulseT = this.pulseAge / PULSE_MS;\n const pulseR = PULSE_REACH * (1 - (1 - pulseT) ** 2);\n const pulseStrength = pulsing ? 1 - pulseT : 0;\n\n let settled = true;\n for (let i = 0; i < this.count; i++) {\n const x = this.baseX[i];\n const y = this.baseY[i];\n let targetX = 0;\n let targetY = 0;\n let targetLight = 0;\n if (pointing) {\n const dx = x - px;\n const dy = y - py;\n const d2 = dx * dx + dy * dy;\n if (d2 < reach2) {\n const d = Math.sqrt(d2);\n const w = (1 - d / reach) ** 2;\n targetLight = w;\n if (d > 0) {\n targetX = (dx / d) * w * PUSH;\n targetY = (dy / d) * w * PUSH;\n }\n }\n }\n if (pulsing) {\n const d = Math.hypot(x - this.pulseX, y - this.pulseY);\n const band = Math.abs(d - pulseR);\n if (band < PULSE_WIDTH) {\n targetLight = Math.max(targetLight, (1 - band / PULSE_WIDTH) * pulseStrength);\n }\n }\n\n dotGridSpringStep(this.offX, this.velX, i, targetX, scale);\n dotGridSpringStep(this.offY, this.velY, i, targetY, scale);\n this.light[i] += (targetLight - this.light[i]) * ease;\n\n const still =\n Math.abs(this.offX[i]) < REST_EPS &&\n Math.abs(this.offY[i]) < REST_EPS &&\n Math.abs(this.velX[i]) < REST_EPS &&\n Math.abs(this.velY[i]) < REST_EPS &&\n this.light[i] < REST_EPS;\n if (still) {\n this.offX[i] = 0;\n this.offY[i] = 0;\n this.velX[i] = 0;\n this.velY[i] = 0;\n this.light[i] = 0;\n } else {\n settled = false;\n }\n this.level[i] = Math.round(wrClamp(this.light[i], 0, 1) * (LEVELS - 1));\n }\n this.settled = settled && !pulsing;\n }\n\n /** One frame: one path per light level, every dot at that level in it. */\n private draw(ctx: CanvasRenderingContext2D, width: number, height: number): void {\n if (this.fills.length === 0) return;\n ctx.clearRect(0, 0, width, height);\n for (let l = 0; l < LEVELS; l++) {\n const r = this.radii[l];\n let any = false;\n ctx.beginPath();\n for (let i = 0; i < this.count; i++) {\n if (this.level[i] !== l) continue;\n const x = this.baseX[i] + this.offX[i];\n const y = this.baseY[i] + this.offY[i];\n ctx.moveTo(x + r, y);\n ctx.arc(x, y, r, 0, TAU);\n any = true;\n }\n if (!any) continue;\n ctx.fillStyle = this.fills[l];\n ctx.fill();\n }\n }\n}\n\nexport { LEVELS as DOT_GRID_LEVELS, MAX_DPR as DOT_GRID_MAX_DPR, MAX_PIXELS as DOT_GRID_MAX_PIXELS };\n","<canvas #canvas class=\"wr-dot-grid__canvas\"></canvas>\n","/**\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\nexport { WrDotGrid } from './dot-grid';\n"],"mappings":";;;;;;;;;;AAcA,MAAM,OAAO;AAEb,MAAM,YAAY;AAClB,MAAM,UAAU;AAIhB,MAAM,WAAW;AAIjB,MAAM,SAAS;AAGf,MAAM,QAAQ;AAGd,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,MAAM,KAAK,KAAK;AAQtB,SAAgB,kBACd,KACA,KACA,GACA,QACA,OAAa;CAEb,MAAM,IAAI,YAAY;CACtB,MAAM,UAAU,WAAW;CAC3B,IAAI,MAAM,IAAI,MAAM,SAAS,IAAI,MAAM,KAAK;CAC5C,IAAI,MAAM,IAAI;AAChB;AAGA,SAAgB,cACd,OACA,QACA,SAAe;CAEf,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO;CAC/B,MAAM,OAAO,QAAQ,KAAK,SAAS,IAAI,KAAK,MAAM,QAAQ,GAAG,IAAI,IAAI;CACrE,MAAM,OAAO,OAAO,IAAI,KAAK,MAAM,SAAS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CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-animations-dot-grid.mjs","names":[],"sources":["../../../projects/lib/animations/dot-grid/dot-grid.ts","../../../projects/lib/animations/dot-grid/dot-grid.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 { Component, DestroyRef, ElementRef, ViewEncapsulation, inject, input, viewChild } from '@angular/core';\n\nimport { wrClamp, wrNumAttr, wrResolveCssColorChannels, wrCheckStyles } from 'ngwr/utils';\n\nimport { MAX_DPR, MAX_PIXELS, createCanvasBackdrop } from '../internal';\n\n/** How far a dot is pushed at the pointer itself, in px. */\nconst PUSH = 14;\n/** Spring that returns a pushed dot, tuned per 60Hz frame: it overshoots about 15% and settles in half a second. */\nconst STIFFNESS = 0.12;\nconst DAMPING = 0.72;\n/** How much of the gap to its target a dot's light closes per 60Hz frame. */\nconst LIGHT_EASE = 0.18;\n/** Below this, in px and in light, a dot counts as at rest and snaps there. */\nconst REST_EPS = 0.02;\n/** The light is quantised into this many fill colours, so a frame is a handful of paths, not one per dot. */\nconst LEVELS = 8;\n/** A dot's radius at rest and fully lit, in px. */\nconst RADIUS = 1.1;\nconst RADIUS_LIT = 1.9;\n/** How much of its colour a dot shows at rest and fully lit. */\nconst ALPHA = 0.32;\nconst ALPHA_LIT = 0.75;\n/** A tap's ring: how far it travels and how long it takes. */\nconst PULSE_REACH = 220;\nconst PULSE_MS = 650;\nconst PULSE_WIDTH = 36;\nconst TAU = Math.PI * 2;\n\n/**\n * One damped spring step on one axis, in place: `vel[i]` is updated, then\n * added to `off[i]`. `scale` is the frame length in 60Hz frames, so a slow\n * frame takes a longer step and a fast screen a shorter one, and the motion\n * reads the same on both.\n */\nexport function dotGridSpringStep(\n off: Float32Array,\n vel: Float32Array,\n i: number,\n target: number,\n scale: number\n): void {\n const k = STIFFNESS * scale;\n const damping = DAMPING ** scale;\n vel[i] = (vel[i] + (target - off[i]) * k) * damping;\n off[i] += vel[i];\n}\n\n/** Where the dots of a `width` by `height` field sit, centred, `spacing` apart. */\nexport function dotGridLayout(\n width: number,\n height: number,\n spacing: number\n): { cols: number; rows: number; x: Float32Array<ArrayBuffer>; y: Float32Array<ArrayBuffer> } {\n const gap = Math.max(8, spacing);\n const cols = width > 0 && height > 0 ? Math.floor(width / gap) + 1 : 0;\n const rows = cols > 0 ? Math.floor(height / gap) + 1 : 0;\n const x0 = (width - (cols - 1) * gap) / 2;\n const y0 = (height - (rows - 1) * gap) / 2;\n const x = new Float32Array(cols * rows);\n const y = new Float32Array(cols * rows);\n for (let c = 0; c < cols; c++) {\n for (let r = 0; r < rows; r++) {\n const i = c * rows + r;\n x[i] = x0 + c * gap;\n y[i] = y0 + r * gap;\n }\n }\n return { cols, rows, x, y };\n}\n\n/**\n * An even field of small, faint dots behind a section's content. Near the\n * pointer the dots light up toward the primary colour and are pushed gently\n * away; each one follows a damped spring back to its place when the pointer\n * moves on, so a fast sweep leaves a short, soft wake that settles. With no\n * pointer the field rests.\n *\n * Fills its parent, which must be positioned (`position: relative`) and\n * isolated (`isolation: isolate`): the host is absolute, `inset: 0`, at\n * `z-index: -1`, so it lands at the floor of the parent's own stacking\n * context, under the content and over the page background. The parent takes\n * the pointer: the host and its canvas never do. One canvas through\n * `createCanvasBackdrop`, redrawn only while something moves: the frame loop\n * runs while the pointer is over the parent or a dot is still settling, and\n * only while the host is on screen and the document is visible; at rest the\n * still field is drawn once. Touch never pushes, so a\n * scroll over the section is never fought; a tap sends one ring of light out\n * from the finger instead.\n *\n * Colours come from the `--wr-dot-grid-*` hooks through `wrResolveCssColorChannels`,\n * re-read when the scheme changes. Under `prefers-reduced-motion: reduce` only\n * the still field is drawn; under `forced-colors: active` nothing is. The server\n * renders the empty canvas, absolutely positioned, so the browser's first draw\n * shifts no layout. Decorative: `aria-hidden`, no pointer events. Styles:\n * `@use 'ngwr/animations/dot-grid'`.\n */\n@Component({\n selector: 'wr-dot-grid',\n templateUrl: './dot-grid.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-dot-grid', 'aria-hidden': 'true' },\n})\nexport class WrDotGrid {\n /** Distance between two dots, in px. @default 26 */\n readonly spacing = input(26, { transform: wrNumAttr(26) });\n\n /** How far from the pointer a dot still lights and moves, in px. @default 140 */\n readonly reach = input(140, { transform: wrNumAttr(140) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly canvasRef = viewChild.required<ElementRef<HTMLCanvasElement>>('canvas');\n\n /** One fill per light level, rest first, and the radius that goes with it. */\n private fills: string[] = [];\n private radii: number[] = [];\n\n // One entry per dot, column-major\n private count = 0;\n private baseX = new Float32Array(0);\n private baseY = new Float32Array(0);\n private offX = new Float32Array(0);\n private offY = new Float32Array(0);\n private velX = new Float32Array(0);\n private velY = new Float32Array(0);\n private light = new Float32Array(0);\n /** Each dot's light level this frame, so the draw groups dots by fill. */\n private level = new Uint8Array(0);\n\n private pointerX = NaN;\n private pointerY = NaN;\n private pulseX = NaN;\n private pulseY = NaN;\n private pulseAge = Infinity;\n /** True while every dot sits at its place, unlit and still. */\n private settled = true;\n\n private pointerTarget: HTMLElement | null = null;\n\n private readonly backdrop = createCanvasBackdrop(() => this.canvasRef().nativeElement, {\n colors: canvas => this.resolveColors(canvas),\n layout: (width, height) => this.layout(width, height),\n active: () => this.pointerInside || !this.settled,\n advance: dt => this.advance(dt),\n draw: (ctx, width, height) => this.draw(ctx, width, height),\n rest: () => this.rest(),\n mounted: () => this.listen(),\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/dot-grid');\n inject(DestroyRef).onDestroy(() => {\n this.pointerTarget?.removeEventListener('pointermove', this.onPointerMove);\n this.pointerTarget?.removeEventListener('pointerleave', this.onPointerLeave);\n this.pointerTarget?.removeEventListener('pointerdown', this.onPointerDown);\n this.pointerTarget = null;\n });\n }\n\n /** The parent takes the pointer: the host and its canvas never do. */\n private listen(): void {\n const target = this.host.nativeElement.parentElement;\n this.pointerTarget = target;\n target?.addEventListener('pointermove', this.onPointerMove, { passive: true });\n target?.addEventListener('pointerleave', this.onPointerLeave, { passive: true });\n target?.addEventListener('pointerdown', this.onPointerDown, { passive: true });\n }\n\n // Pointer\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n // A finger that moves is scrolling: the field must never fight it.\n if (event.pointerType === 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pointerX = event.clientX - rect.left;\n this.pointerY = event.clientY - rect.top;\n this.settled = false;\n this.backdrop.sync();\n };\n\n private readonly onPointerLeave = (): void => {\n this.pointerX = NaN;\n this.pointerY = NaN;\n this.backdrop.sync();\n };\n\n private readonly onPointerDown = (event: PointerEvent): void => {\n if (event.pointerType !== 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pulseX = event.clientX - rect.left;\n this.pulseY = event.clientY - rect.top;\n this.pulseAge = 0;\n this.settled = false;\n this.backdrop.sync();\n };\n\n // Layout\n\n private resolveColors(canvas: HTMLCanvasElement): void {\n const ink = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-ink)', '#6b7280');\n const glow = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-glow)', '#3969e2');\n this.fills = [];\n this.radii = [];\n for (let l = 0; l < LEVELS; l++) {\n const t = l / (LEVELS - 1);\n const channel = (c: number): number => Math.round((ink[c] + (glow[c] - ink[c]) * t) * 255);\n const alpha = ALPHA + (ALPHA_LIT - ALPHA) * t;\n this.fills.push(`rgba(${channel(0)}, ${channel(1)}, ${channel(2)}, ${alpha.toFixed(3)})`);\n this.radii.push(RADIUS + (RADIUS_LIT - RADIUS) * t);\n }\n }\n\n private layout(width: number, height: number): void {\n const { x, y } = dotGridLayout(width, height, this.spacing());\n this.count = x.length;\n this.baseX = x;\n this.baseY = y;\n this.offX = new Float32Array(this.count);\n this.offY = new Float32Array(this.count);\n this.velX = new Float32Array(this.count);\n this.velY = new Float32Array(this.count);\n this.light = new Float32Array(this.count);\n this.level = new Uint8Array(this.count);\n this.settled = true;\n }\n\n // Motion\n\n /** Whether the pointer rests over the parent. */\n private get pointerInside(): boolean {\n return !Number.isNaN(this.pointerX);\n }\n\n /** Every dot back at its place, unlit and still. */\n private rest(): void {\n this.offX.fill(0);\n this.offY.fill(0);\n this.velX.fill(0);\n this.velY.fill(0);\n this.light.fill(0);\n this.level.fill(0);\n this.pulseAge = Infinity;\n this.settled = true;\n }\n\n /** Moves every dot one frame: the pointer's push and light, the tap's ring, then the springs. */\n private advance(dt: number): void {\n const scale = Math.min(2, dt / 16.7);\n const ease = 1 - (1 - LIGHT_EASE) ** scale;\n const reach = this.reach();\n const reach2 = reach * reach;\n const px = this.pointerX;\n const py = this.pointerY;\n const pointing = this.pointerInside;\n\n this.pulseAge += dt;\n const pulsing = this.pulseAge < PULSE_MS;\n const pulseT = this.pulseAge / PULSE_MS;\n const pulseR = PULSE_REACH * (1 - (1 - pulseT) ** 2);\n const pulseStrength = pulsing ? 1 - pulseT : 0;\n\n let settled = true;\n for (let i = 0; i < this.count; i++) {\n const x = this.baseX[i];\n const y = this.baseY[i];\n let targetX = 0;\n let targetY = 0;\n let targetLight = 0;\n if (pointing) {\n const dx = x - px;\n const dy = y - py;\n const d2 = dx * dx + dy * dy;\n if (d2 < reach2) {\n const d = Math.sqrt(d2);\n const w = (1 - d / reach) ** 2;\n targetLight = w;\n if (d > 0) {\n targetX = (dx / d) * w * PUSH;\n targetY = (dy / d) * w * PUSH;\n }\n }\n }\n if (pulsing) {\n const d = Math.hypot(x - this.pulseX, y - this.pulseY);\n const band = Math.abs(d - pulseR);\n if (band < PULSE_WIDTH) {\n targetLight = Math.max(targetLight, (1 - band / PULSE_WIDTH) * pulseStrength);\n }\n }\n\n dotGridSpringStep(this.offX, this.velX, i, targetX, scale);\n dotGridSpringStep(this.offY, this.velY, i, targetY, scale);\n this.light[i] += (targetLight - this.light[i]) * ease;\n\n const still =\n Math.abs(this.offX[i]) < REST_EPS &&\n Math.abs(this.offY[i]) < REST_EPS &&\n Math.abs(this.velX[i]) < REST_EPS &&\n Math.abs(this.velY[i]) < REST_EPS &&\n this.light[i] < REST_EPS;\n if (still) {\n this.offX[i] = 0;\n this.offY[i] = 0;\n this.velX[i] = 0;\n this.velY[i] = 0;\n this.light[i] = 0;\n } else {\n settled = false;\n }\n this.level[i] = Math.round(wrClamp(this.light[i], 0, 1) * (LEVELS - 1));\n }\n this.settled = settled && !pulsing;\n }\n\n /** One frame: one path per light level, every dot at that level in it. */\n private draw(ctx: CanvasRenderingContext2D, width: number, height: number): void {\n if (this.fills.length === 0) return;\n ctx.clearRect(0, 0, width, height);\n for (let l = 0; l < LEVELS; l++) {\n const r = this.radii[l];\n let any = false;\n ctx.beginPath();\n for (let i = 0; i < this.count; i++) {\n if (this.level[i] !== l) continue;\n const x = this.baseX[i] + this.offX[i];\n const y = this.baseY[i] + this.offY[i];\n ctx.moveTo(x + r, y);\n ctx.arc(x, y, r, 0, TAU);\n any = true;\n }\n if (!any) continue;\n ctx.fillStyle = this.fills[l];\n ctx.fill();\n }\n }\n}\n\nexport { LEVELS as DOT_GRID_LEVELS, MAX_DPR as DOT_GRID_MAX_DPR, MAX_PIXELS as DOT_GRID_MAX_PIXELS };\n","<canvas #canvas class=\"wr-dot-grid__canvas\"></canvas>\n"],"mappings":";;;;;;;;;;AAcA,MAAM,OAAO;AAEb,MAAM,YAAY;AAClB,MAAM,UAAU;AAIhB,MAAM,WAAW;AAIjB,MAAM,SAAS;AAGf,MAAM,QAAQ;AAGd,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,MAAM,KAAK,KAAK;AAQtB,SAAgB,kBACd,KACA,KACA,GACA,Q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UAAA;GAAa,eAER,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAe,eAAe;GAAM;GAAE,UAAA;EAAA,CAAA;CAU0B,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
@@ -440,7 +440,7 @@ var WrFallingLetters = class WrFallingLetters {
440
440
  }
441
441
  static ɵfac = i0.ɵɵngDeclareFactory({
442
442
  minVersion: "12.0.0",
443
- version: "22.2.6",
443
+ version: "22.3.0",
444
444
  ngImport: i0,
445
445
  type: WrFallingLetters,
446
446
  deps: [],
@@ -448,7 +448,7 @@ var WrFallingLetters = class WrFallingLetters {
448
448
  });
449
449
  static ɵdir = i0.ɵɵngDeclareDirective({
450
450
  minVersion: "17.1.0",
451
- version: "22.2.6",
451
+ version: "22.3.0",
452
452
  type: WrFallingLetters,
453
453
  isStandalone: true,
454
454
  selector: "[wrFallingLetters]",
@@ -480,7 +480,7 @@ var WrFallingLetters = class WrFallingLetters {
480
480
  };
481
481
  i0.ɵɵngDeclareClassMetadata({
482
482
  minVersion: "12.0.0",
483
- version: "22.2.6",
483
+ version: "22.3.0",
484
484
  ngImport: i0,
485
485
  type: WrFallingLetters,
486
486
  decorators: [{