ngwr 16.4.0 → 16.5.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 (258) hide show
  1. package/charts/bar-chart/styles/_index.scss +494 -305
  2. package/charts/boxplot-chart/styles/_index.scss +114 -48
  3. package/charts/bullet-chart/styles/_index.scss +113 -42
  4. package/charts/calendar-heatmap/styles/_index.scss +111 -20
  5. package/charts/candlestick-chart/styles/_index.scss +61 -26
  6. package/charts/chart-legend/styles/_index.scss +119 -1
  7. package/charts/core/styles/_index.scss +201 -5
  8. package/charts/donut-chart/styles/_index.scss +76 -21
  9. package/charts/funnel-chart/styles/_index.scss +66 -38
  10. package/charts/gauge/styles/_index.scss +12 -1
  11. package/charts/heatmap-chart/styles/_index.scss +90 -53
  12. package/charts/line-chart/styles/_index.scss +143 -139
  13. package/charts/meter-group/styles/_index.scss +87 -25
  14. package/charts/radar-chart/styles/_index.scss +82 -40
  15. package/charts/scatter-chart/styles/_index.scss +117 -44
  16. package/charts/sparkline/styles/_index.scss +7 -1
  17. package/charts/treemap-chart/styles/_index.scss +94 -42
  18. package/charts/waterfall-chart/styles/_index.scss +150 -87
  19. package/color-picker/styles/_index.scss +7 -3
  20. package/copy-value/styles/_index.scss +21 -2
  21. package/date-stamp/styles/_index.scss +2 -1
  22. package/dialog/styles/_index.scss +6 -0
  23. package/drawer/styles/_index.scss +5 -1
  24. package/fesm2022/ngwr-carousel-testing.mjs +4 -1
  25. package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
  26. package/fesm2022/ngwr-carousel.mjs +21 -2
  27. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  28. package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
  29. package/fesm2022/ngwr-cascader.mjs +48 -4
  30. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  31. package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
  32. package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
  33. package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
  34. package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
  35. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
  36. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
  37. package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
  38. package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
  39. package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
  40. package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
  41. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
  42. package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
  43. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
  44. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
  45. package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
  46. package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
  47. package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
  48. package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
  49. package/fesm2022/ngwr-charts-core.mjs +299 -18
  50. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  51. package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
  52. package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
  53. package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
  54. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
  55. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
  56. package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
  57. package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
  58. package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
  59. package/fesm2022/ngwr-charts-gauge.mjs +98 -12
  60. package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
  61. package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
  62. package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
  63. package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
  64. package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
  65. package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
  66. package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
  67. package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
  68. package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
  69. package/fesm2022/ngwr-charts-meter-group.mjs +223 -31
  70. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  71. package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
  72. package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
  73. package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
  74. package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
  75. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
  76. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
  77. package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
  78. package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
  79. package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
  80. package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
  81. package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
  82. package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
  83. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
  84. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
  85. package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
  86. package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
  87. package/fesm2022/ngwr-color-picker.mjs +44 -4
  88. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  89. package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
  90. package/fesm2022/ngwr-context-menu.mjs +47 -19
  91. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  92. package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
  93. package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
  94. package/fesm2022/ngwr-copy-value.mjs +38 -2
  95. package/fesm2022/ngwr-copy-value.mjs.map +1 -1
  96. package/fesm2022/ngwr-date-picker.mjs +56 -8
  97. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  98. package/fesm2022/ngwr-dialog.mjs +13 -5
  99. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  100. package/fesm2022/ngwr-drawer.mjs +19 -3
  101. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  102. package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
  103. package/fesm2022/ngwr-dropdown.mjs +35 -6
  104. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  105. package/fesm2022/ngwr-editor.mjs +1 -0
  106. package/fesm2022/ngwr-editor.mjs.map +1 -1
  107. package/fesm2022/ngwr-graph.mjs +81 -13
  108. package/fesm2022/ngwr-graph.mjs.map +1 -1
  109. package/fesm2022/ngwr-i18n-ar.mjs +5 -0
  110. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  111. package/fesm2022/ngwr-i18n-cs.mjs +5 -0
  112. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  113. package/fesm2022/ngwr-i18n-de.mjs +5 -0
  114. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  115. package/fesm2022/ngwr-i18n-en.mjs +5 -0
  116. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  117. package/fesm2022/ngwr-i18n-es.mjs +5 -0
  118. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  119. package/fesm2022/ngwr-i18n-fr.mjs +5 -0
  120. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  121. package/fesm2022/ngwr-i18n-he.mjs +5 -0
  122. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  123. package/fesm2022/ngwr-i18n-hi.mjs +5 -0
  124. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  125. package/fesm2022/ngwr-i18n-id.mjs +5 -0
  126. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  127. package/fesm2022/ngwr-i18n-it.mjs +5 -0
  128. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  129. package/fesm2022/ngwr-i18n-ja.mjs +5 -0
  130. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  131. package/fesm2022/ngwr-i18n-ko.mjs +5 -0
  132. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  133. package/fesm2022/ngwr-i18n-nl.mjs +5 -0
  134. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  135. package/fesm2022/ngwr-i18n-pl.mjs +5 -0
  136. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  137. package/fesm2022/ngwr-i18n-pt.mjs +5 -0
  138. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  139. package/fesm2022/ngwr-i18n-ru.mjs +5 -0
  140. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  141. package/fesm2022/ngwr-i18n-sv.mjs +5 -0
  142. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  143. package/fesm2022/ngwr-i18n-tr.mjs +5 -0
  144. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  145. package/fesm2022/ngwr-i18n-uk.mjs +5 -0
  146. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  147. package/fesm2022/ngwr-i18n-vi.mjs +5 -0
  148. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  149. package/fesm2022/ngwr-i18n-zh-tw.mjs +5 -0
  150. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  151. package/fesm2022/ngwr-i18n-zh.mjs +5 -0
  152. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  153. package/fesm2022/ngwr-lightbox.mjs +20 -3
  154. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  155. package/fesm2022/ngwr-overlay.mjs +21 -2
  156. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  157. package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
  158. package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
  159. package/fesm2022/ngwr-popconfirm.mjs +41 -5
  160. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  161. package/fesm2022/ngwr-popover.mjs +67 -12
  162. package/fesm2022/ngwr-popover.mjs.map +1 -1
  163. package/fesm2022/ngwr-schema-form.mjs +2 -0
  164. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  165. package/fesm2022/ngwr-table.mjs +2 -0
  166. package/fesm2022/ngwr-table.mjs.map +1 -1
  167. package/fesm2022/ngwr-tour.mjs +14 -9
  168. package/fesm2022/ngwr-tour.mjs.map +1 -1
  169. package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
  170. package/fesm2022/ngwr-tree.mjs +49 -16
  171. package/fesm2022/ngwr-tree.mjs.map +1 -1
  172. package/fesm2022/ngwr-version.mjs +1 -1
  173. package/fesm2022/ngwr-version.mjs.map +1 -1
  174. package/fesm2022/ngwr-window.mjs +16 -9
  175. package/fesm2022/ngwr-window.mjs.map +1 -1
  176. package/i18n/ar.json +5 -0
  177. package/i18n/cs.json +5 -0
  178. package/i18n/de.json +5 -0
  179. package/i18n/en.json +5 -0
  180. package/i18n/es.json +5 -0
  181. package/i18n/fr.json +5 -0
  182. package/i18n/he.json +5 -0
  183. package/i18n/hi.json +5 -0
  184. package/i18n/id.json +5 -0
  185. package/i18n/it.json +5 -0
  186. package/i18n/ja.json +5 -0
  187. package/i18n/ko.json +5 -0
  188. package/i18n/nl.json +5 -0
  189. package/i18n/pl.json +5 -0
  190. package/i18n/pt.json +5 -0
  191. package/i18n/ru.json +5 -0
  192. package/i18n/sv.json +5 -0
  193. package/i18n/tr.json +5 -0
  194. package/i18n/uk.json +5 -0
  195. package/i18n/vi.json +5 -0
  196. package/i18n/zh-TW.json +5 -0
  197. package/i18n/zh.json +5 -0
  198. package/llms-full.txt +8 -8
  199. package/llms.txt +7 -3
  200. package/package.json +1 -1
  201. package/popconfirm/styles/_index.scss +6 -0
  202. package/popover/styles/_index.scss +24 -13
  203. package/schematics/use/symbol-map.json +1 -0
  204. package/skills/ngwr/references/catalog.md +1 -1
  205. package/tour/styles/_index.scss +6 -0
  206. package/types/ngwr-carousel-testing.d.ts +6 -4
  207. package/types/ngwr-carousel.d.ts +14 -3
  208. package/types/ngwr-cascader-testing.d.ts +4 -3
  209. package/types/ngwr-cascader.d.ts +27 -3
  210. package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
  211. package/types/ngwr-charts-bar-chart.d.ts +220 -48
  212. package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
  213. package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
  214. package/types/ngwr-charts-bullet-chart.d.ts +72 -12
  215. package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
  216. package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
  217. package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
  218. package/types/ngwr-charts-chart-legend.d.ts +142 -5
  219. package/types/ngwr-charts-core.d.ts +259 -21
  220. package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
  221. package/types/ngwr-charts-donut-chart.d.ts +124 -16
  222. package/types/ngwr-charts-funnel-chart.d.ts +62 -6
  223. package/types/ngwr-charts-gauge-testing.d.ts +5 -1
  224. package/types/ngwr-charts-gauge.d.ts +72 -10
  225. package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
  226. package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
  227. package/types/ngwr-charts-line-chart.d.ts +215 -86
  228. package/types/ngwr-charts-meter-group.d.ts +96 -7
  229. package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
  230. package/types/ngwr-charts-radar-chart.d.ts +148 -28
  231. package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
  232. package/types/ngwr-charts-scatter-chart.d.ts +188 -18
  233. package/types/ngwr-charts-sparkline.d.ts +26 -4
  234. package/types/ngwr-charts-treemap-chart.d.ts +121 -23
  235. package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
  236. package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
  237. package/types/ngwr-color-picker.d.ts +27 -0
  238. package/types/ngwr-context-menu-testing.d.ts +10 -9
  239. package/types/ngwr-context-menu.d.ts +17 -0
  240. package/types/ngwr-copy-value.d.ts +8 -0
  241. package/types/ngwr-date-picker.d.ts +34 -2
  242. package/types/ngwr-dialog.d.ts +30 -10
  243. package/types/ngwr-drawer.d.ts +32 -1
  244. package/types/ngwr-dropdown-testing.d.ts +8 -5
  245. package/types/ngwr-dropdown.d.ts +29 -6
  246. package/types/ngwr-graph.d.ts +22 -6
  247. package/types/ngwr-lightbox.d.ts +15 -0
  248. package/types/ngwr-overlay.d.ts +16 -1
  249. package/types/ngwr-popconfirm-testing.d.ts +11 -2
  250. package/types/ngwr-popconfirm.d.ts +28 -1
  251. package/types/ngwr-popover.d.ts +59 -9
  252. package/types/ngwr-table.d.ts +1 -1
  253. package/types/ngwr-tour.d.ts +21 -2
  254. package/types/ngwr-tree-testing.d.ts +1 -2
  255. package/types/ngwr-tree.d.ts +33 -2
  256. package/types/ngwr-version.d.ts +1 -1
  257. package/types/ngwr-window.d.ts +14 -11
  258. package/window/styles/_index.scss +5 -10
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-overlay.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/overlay/wr-anchored-positions.ts","../../../projects/lib/overlay/wr-overlay-close.ts","../../../projects/lib/overlay/wr-follow-direction.ts","../../../projects/lib/overlay/wr-follow-size.ts","../../../projects/lib/overlay/wr-mirror-offsets.ts","../../../projects/lib/overlay/wr-outside-click.ts","../../../projects/lib/overlay/wr-overlay-container.ts","../../../projects/lib/overlay/wr-overlay-order.ts","../../../projects/lib/overlay/tokens/wr-overlay-container.token.ts","../../../projects/lib/overlay/tokens/wr-overlay.token.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 type { ConnectedPosition } from '@angular/cdk/overlay';\n\n/**\n * Where an anchored panel sits relative to its trigger: a side, optionally\n * aligned to the trigger's start or end edge. The one set `wr-popover`,\n * `wr-dropdown` and `wr-popconfirm` take as `position`.\n *\n * `left` / `right` and `-start` / `-end` are logical: under `dir=\"rtl\"` they\n * mirror, the name staying as written.\n */\nexport type WrAnchoredPosition =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\n/**\n * The CDK geometry for each placement: one position, no gap and no fallbacks.\n *\n * Everything anchors on `start` / `end` or `center`, which the CDK resolves\n * against the direction, so the table itself needs no mirroring. A gap added by\n * `wrAnchoredPositions` is an offset in physical pixels and does: see\n * `wrMirrorOffsets`.\n *\n * @internal\n */\nexport const WR_ANCHORED_POSITIONS: Record<WrAnchoredPosition, ConnectedPosition> = {\n top: { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom' },\n 'top-start': { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n 'top-end': { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },\n bottom: { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top' },\n 'bottom-start': { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n 'bottom-end': { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },\n left: { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center' },\n 'left-start': { originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },\n 'left-end': { originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },\n right: { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center' },\n 'right-start': { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },\n 'right-end': { originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },\n};\n\n/**\n * What each placement is allowed to flip to when it does not fit, best first.\n * The requested placement always leads, so a panel that fits never moves.\n *\n * Alignment is preserved down the whole chain — a `-start` panel stays\n * `-start` — because the alignment is the author's answer to \"which end of the\n * trigger does this belong to\", and a flip is about the side, not about that.\n *\n * The two axes are deliberately NOT symmetric. A block-axis placement (`top*` /\n * `bottom*`) flips only to its opposite, the classic behaviour, so a dropdown-ish\n * panel can never surprise anyone by appearing beside its trigger. An inline-axis\n * one (`left*` / `right*`) also gets the two block-axis sides, because on a phone\n * NEITHER side fits: at 375px a 233px panel beside a mid-page trigger overflows\n * by 109px to the right and 97px to the left, and only below/above has room.\n *\n * @internal\n */\nexport const WR_ANCHORED_FALLBACKS: Record<WrAnchoredPosition, readonly WrAnchoredPosition[]> = {\n top: ['top', 'bottom'],\n 'top-start': ['top-start', 'bottom-start'],\n 'top-end': ['top-end', 'bottom-end'],\n bottom: ['bottom', 'top'],\n 'bottom-start': ['bottom-start', 'top-start'],\n 'bottom-end': ['bottom-end', 'top-end'],\n left: ['left', 'right', 'bottom', 'top'],\n 'left-start': ['left-start', 'right-start', 'bottom-start', 'top-start'],\n 'left-end': ['left-end', 'right-end', 'bottom-end', 'top-end'],\n right: ['right', 'left', 'bottom', 'top'],\n 'right-start': ['right-start', 'left-start', 'bottom-start', 'top-start'],\n 'right-end': ['right-end', 'left-end', 'bottom-end', 'top-end'],\n};\n\n/** How a host dresses the links `wrAnchoredPositions` returns. @internal */\nexport interface WrAnchoredPositionsOptions {\n /**\n * Distance between the trigger and the panel, in px, as a CDK offset pointing\n * away from the trigger. Left out by a host whose gap is padding on the pane.\n *\n * It is the reason a flip list matters rather than being a nicety: the\n * flexible strategy emits `offsetX` as a `transform` on the pane, AFTER\n * `withPush` has already decided the coordinate. Push therefore parks a\n * right-anchored panel flush against the viewport edge and the offset then\n * shoves it back out, so a side placement that does not fit loses its border\n * and corner off-screen no matter how hard push works.\n */\n readonly gap?: number;\n /**\n * The pane's base class. Each link is tagged `<paneClass>--<placement>`, so\n * the pane names the placement it ACTUALLY took: the CDK applies a position's\n * own `panelClass` when it lands on it and clears it on the next one. Left\n * out by a host that writes the class itself.\n */\n readonly paneClass?: string;\n}\n\n/**\n * The list `withPositions()` wants for a placement: its fallback chain in\n * order, as fresh objects, so a caller may also tell which link the CDK landed\n * on by the identity of the position it reports back.\n *\n * @internal\n */\nexport function wrAnchoredPositions(\n position: WrAnchoredPosition,\n options: WrAnchoredPositionsOptions = {}\n): ConnectedPosition[] {\n const { gap, paneClass } = options;\n return WR_ANCHORED_FALLBACKS[position].map(name => {\n const link: ConnectedPosition = { ...WR_ANCHORED_POSITIONS[name] };\n if (gap) {\n if (name.startsWith('top')) link.offsetY = -gap;\n else if (name.startsWith('bottom')) link.offsetY = gap;\n else if (name.startsWith('left')) link.offsetX = -gap;\n else link.offsetX = gap;\n }\n if (paneClass) link.panelClass = `${paneClass}--${name}`;\n return link;\n });\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\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/** The same 24×24 stroked ✕ the rest of the library's chrome draws (alert, toast, lightbox). */\nconst CLOSE_ICON_ATTRS: readonly (readonly [string, string])[] = [\n ['class', 'wr-icon__svg'],\n ['viewBox', '0 0 24 24'],\n ['fill', 'none'],\n ['stroke', 'currentColor'],\n ['stroke-width', '2'],\n ['stroke-linecap', 'round'],\n ['stroke-linejoin', 'round'],\n ['aria-hidden', 'true'],\n];\nconst CLOSE_ICON_PATHS: readonly string[] = ['M18 6 6 18', 'm6 6 12 12'];\n\n/**\n * Builds the ✕ node by node.\n *\n * It was one `innerHTML = CLOSE_ICON`, and the string was a compile-time\n * constant, so it was never an injection risk — it was an AVAILABILITY one.\n * Under `require-trusted-types-for 'script'` an `innerHTML` write throws\n * `TrustedHTML assignment` whatever the string is, and the throw landed after\n * the overlay was on screen: a modal with no ✕, no backdrop subscription and no\n * Escape handler, over the whole application. `createElementNS` is not a\n * Trusted Types sink, so there is nothing left to police.\n */\nfunction createCloseIcon(doc: Document): SVGSVGElement {\n const svg = doc.createElementNS(SVG_NS, 'svg');\n // `setAttribute`, not `.className` — on an SVG element that property is an\n // `SVGAnimatedString` and assigning a string to it silently does nothing.\n for (const [name, value] of CLOSE_ICON_ATTRS) svg.setAttribute(name, value);\n for (const d of CLOSE_ICON_PATHS) {\n const path = doc.createElementNS(SVG_NS, 'path');\n path.setAttribute('d', d);\n svg.appendChild(path);\n }\n return svg;\n}\n\n/**\n * Appends a dismiss (✕) button to a service-opened overlay panel.\n *\n * `WrDialog` and `WrDrawerManager` build their panel around a component the\n * consumer supplies, so there is no template of their own to put a corner button\n * in — they call this instead. Component-driven overlays (`<wr-drawer>`) render\n * the same markup in their template.\n *\n * Uses `host.ownerDocument` rather than the global `document`, so it carries no\n * hidden browser-only assumption; callers still gate on the platform because\n * they have nothing to append to on the server.\n *\n * @param host Panel element the button is appended to (and positioned against).\n * @param className BEM class for the button, e.g. `wr-dialog__close`.\n * @param label Accessible name — already localized by the caller.\n * @param onClose Invoked on click.\n */\nexport function wrAppendOverlayClose(\n host: HTMLElement,\n className: string,\n label: string,\n onClose: () => void\n): HTMLButtonElement {\n const button = host.ownerDocument.createElement('button');\n button.type = 'button';\n button.className = className;\n button.setAttribute('aria-label', label);\n button.appendChild(createCloseIcon(host.ownerDocument));\n button.addEventListener('click', onClose);\n host.appendChild(button);\n return button;\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\nimport type { Direction, Directionality } from '@angular/cdk/bidi';\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport { type Injector, effect, untracked } from '@angular/core';\n\nimport { Subscription } from 'rxjs';\n\nimport { wrNoop } from 'ngwr/utils';\n\n/**\n * Keep an OPEN overlay on the application's reading direction.\n *\n * The CDK reads the direction ONCE, as a string, when the overlay is created\n * (`overlayConfig.direction ||= directionality.value`), writes it as the host's\n * `dir` on attach, and never looks at it again — `updatePosition()` does not\n * touch it and `setDirection()` is the only thing that does. So an application\n * that flips direction while a panel is open mirrors the page and leaves the\n * panel behind, still `ltr`, still resolving `start` to the left. This site's\n * own LTR/RTL switch is the demonstration: it lives inside a `wr-dropdown`, and\n * the `wr-segmented` it is built from reads `Directionality` live — so the thumb\n * slides to the other slot while the pane around it still renders `ltr`, and\n * parks under the wrong label.\n *\n * Call it once per `OverlayRef`, right after `overlay.create(...)`. The follower\n * ends itself when that overlay detaches or is disposed, so a reopen — which is\n * always a NEW ref in this library — needs a new call, and the returned teardown\n * is only for stopping early.\n *\n * `onDirectionChange` is for the sites whose position LIST is itself\n * direction-dependent (the four that pass their table through\n * {@link wrMirrorOffsets}): it runs with the new direction already on the ref\n * and before the overlay repositions, so the strategy is carrying the mirrored\n * offsets by the time the CDK re-resolves them.\n *\n * SSR-safe: it touches no browser global of its own, and the CDK's position\n * strategies no-op off the browser, so a flip on the server only rewrites the\n * attribute.\n *\n * @param overlayRef The overlay to keep in step, freshly created.\n * @param dir The `Directionality` the caller injected. `null` — an optional\n * inject with no provider, i.e. a bare `TestBed` — means there is nothing\n * ambient to follow and this does nothing at all.\n * @param injector Owns the `valueSignal` watch; the caller's own is right.\n * @param onDirectionChange Re-applies direction-dependent state, e.g.\n * `strategy.withPositions(wrMirrorOffsets(TABLE, direction === 'rtl'))`.\n * @returns Stops following. Idempotent, and unnecessary in the normal case.\n *\n * @example\n * ```ts\n * this.overlayRef = this.overlay.create({ positionStrategy, ... });\n * wrFollowDirection(this.overlayRef, this.dir, this.injector, direction =>\n * positionStrategy.withPositions(\n * wrMirrorOffsets(wrPopconfirmPositions(this.position()), direction === 'rtl')\n * )\n * );\n * ```\n */\nexport function wrFollowDirection(\n overlayRef: OverlayRef,\n dir: Directionality | null,\n injector: Injector,\n onDirectionChange?: (direction: Direction) => void\n): () => void {\n if (!dir) return wrNoop;\n\n const apply = (next: Direction): void => {\n // Comparing against the REF rather than a direction captured up here does\n // three jobs at once: the watch's mandatory first run is a no-op, a flip\n // that arrives down both channels is applied once, and a same-value write\n // never yanks a panel the user is reading.\n if (next === overlayRef.getDirection()) return;\n\n overlayRef.setDirection(next); // rewrites the host's `dir`; it does NOT reposition\n onDirectionChange?.(next); // the caller re-mirrors its position list here\n overlayRef.updatePosition(); // re-resolves start/end against the direction just set\n };\n\n // Two channels, because they are not the same thing. `valueSignal` is the\n // state — `Directionality.value` is a getter over it, so nothing can change\n // direction without writing it. `change` is an EventEmitter the root instance\n // never emits: it reads the document once at construction and only completes\n // the emitter on destroy, so it belongs to the `[dir]` directive (and to an\n // app, like this site's header, that emits it by hand as a courtesy). Keying\n // on `change` alone would be dead for an app that just writes the signal;\n // keying on the signal alone would ignore the `{ value, change }` test double\n // that a dozen of the library's RTL specs hand their component.\n //\n // `untracked` because of WHERE this is called from: half the call sites open\n // their overlay out of an `effect(() => { if (this.isOpen()) … })`, and\n // `effect()` refuses in dev mode to be created inside a reactive context.\n // Laundering only the CREATION is exactly right — the watch below still\n // depends on `valueSignal` and on nothing else.\n const watch = untracked(() =>\n effect(\n () => {\n // Read as a plain optional function rather than as a `Signal`, because\n // the case being guarded is a double that has no signal at all: falling\n // back to `value` registers no dependency, so the watch simply never\n // re-runs and `change` carries that case on its own.\n const read: (() => Direction) | undefined = dir.valueSignal;\n apply(read ? read() : dir.value);\n },\n { injector }\n )\n );\n\n // rxjs owns the teardown, and an `OverlayRef` is why. Open and close happen in\n // an event handler or an effect, never in an injection context, so the idiom\n // that suggests itself — `takeUntilDestroyed(destroyRef)` — would tie this to\n // the DIRECTIVE's lifetime: a menu opened fifty times would leave fifty\n // followers behind, each pinning a disposed ref. (`WrOutsideClick`'s JSDoc\n // records that same mistake, made at ten call sites.) `detachments()` is the\n // overlay's own lifetime and the one channel every dismissal goes through.\n // And it is not hygiene: `setDirection()` writes through the host element\n // `dispose()` nulls, so a watch that outlives its overlay THROWS on the next\n // flip.\n const teardown = new Subscription();\n const stop = (): void => teardown.unsubscribe();\n\n teardown.add(() => watch.destroy());\n teardown.add(dir.change.subscribe(apply));\n // Both handlers, for the reason `WrOutsideClick` gives: a live ref arrives\n // through `next`, one already disposed before this call has only `complete`\n // left to give.\n teardown.add(overlayRef.detachments().subscribe({ next: stop, complete: stop }));\n\n // `Subscription.unsubscribe()` is a no-op once closed, so the caller's copy of\n // this and the automatic one cannot fight, and calling it twice is free.\n return stop;\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\nimport type { OverlayRef } from '@angular/cdk/overlay';\n\nimport { wrNoop } from 'ngwr/utils';\n\n/**\n * Keep an OPEN overlay positioned as its content changes size.\n *\n * The CDK positions a pane once, when it attaches, and again on scroll or\n * resize of the window. A panel whose content renders after that, or grows later\n * (a time row that appears, a calendar that gains a sixth week), is measured at\n * its first, smaller size: flipped above the origin at that height, it then\n * grows downward over the field it belongs to. This watches the pane with a\n * `ResizeObserver` and calls `updatePosition()` on every change, so the flip\n * decision always uses the size the panel has now.\n *\n * Call it once per `OverlayRef`, right after `attach(...)`. It ends itself when\n * the overlay detaches or is disposed. No-op where `ResizeObserver` does not\n * exist (SSR, old engines).\n *\n * @param overlayRef The overlay to keep in place.\n * @returns Stops observing. Idempotent, and unnecessary in the normal case.\n */\nexport function wrFollowSize(overlayRef: OverlayRef): () => void {\n if (typeof ResizeObserver === 'undefined') return wrNoop;\n\n const observer = new ResizeObserver(() => overlayRef.updatePosition());\n observer.observe(overlayRef.overlayElement);\n\n const stop = (): void => {\n observer.disconnect();\n subscription.unsubscribe();\n };\n // Both handlers: a live ref arrives through `next`, a disposed one only completes.\n const subscription = overlayRef.detachments().subscribe({ next: stop, complete: stop });\n return stop;\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\nimport type { ConnectedPosition } from '@angular/cdk/overlay';\n\n/**\n * Mirror the horizontal offsets of a connected-position list for RTL.\n *\n * The CDK mirrors `originX` / `overlayX` under `dir=\"rtl\"` — a `start` anchor\n * resolves to the origin's right edge — but it does NOT mirror `offsetX`, which\n * it adds to the final PHYSICAL x (`_getOffset` returns `position.offsetX`\n * verbatim). So a position that meant \"sit to the inline-start of the trigger,\n * 8px clear of it\" keeps its `-8` under RTL, where the panel is now on the\n * right: the gap becomes an 8px OVERLAP, and the panel sits on top of the thing\n * it is describing.\n *\n * Nothing in the CDK will do this for us, and the amount is per position, so\n * every ngwr overlay that offsets along the inline axis passes its list through\n * here. `offsetY` is untouched: the block axis does not flip.\n *\n * @example\n * ```ts\n * const dir = inject(Directionality, { optional: true });\n *\n * strategy.withPositions(wrMirrorOffsets(wrAnchoredPositions(position, { gap: 8 }), dir?.value === 'rtl'));\n * ```\n */\nexport function wrMirrorOffsets(positions: readonly ConnectedPosition[], isRtl: boolean): ConnectedPosition[] {\n // Copied rather than mutated even when there is nothing to do: the position\n // tables are module-level constants shared by every instance, so handing back\n // the same objects invites a caller to write through them.\n if (!isRtl) return positions.map(position => ({ ...position }));\n\n return positions.map(position => ({\n ...position,\n ...(position.offsetX == null ? {} : { offsetX: -position.offsetX }),\n }));\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\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { PLATFORM_ID, Service, inject } from '@angular/core';\n\nimport { Observable, type Subscriber } from 'rxjs';\n\n/** One live subscription to `WrOutsideClick.outsidePointerEvents()`. */\ninterface Watcher {\n readonly overlayRef: OverlayRef;\n readonly subscriber: Subscriber<MouseEvent>;\n}\n\n/**\n * Shadow-piercing `event.target` — `composedPath()[0]` is the real originator\n * when the click started inside a shadow root, where `target` is retargeted to\n * the host.\n */\nfunction eventTarget(event: Event): EventTarget | null {\n if (event.composedPath) {\n try {\n return event.composedPath()[0] ?? event.target;\n } catch {\n /* Detached / synthetic events can throw — fall through to `target`. */\n }\n }\n return event.target;\n}\n\n/** `parent.contains(child)`, but stepping out of shadow roots through their hosts. */\nfunction containsAcrossShadow(parent: Node, child: EventTarget | null): boolean {\n const hasShadowRoot = typeof ShadowRoot !== 'undefined';\n let current = child as Node | null;\n while (current) {\n if (current === parent) return true;\n current = hasShadowRoot && current instanceof ShadowRoot ? current.host : current.parentNode;\n }\n return false;\n}\n\n/**\n * Outside-click source for overlays — a drop-in replacement for\n * `OverlayRef.outsidePointerEvents()`.\n *\n * **Why this exists.** CDK's `OverlayOutsideClickDispatcher` binds its\n * listeners to `document.body`. When page content is shorter than the viewport,\n * a click in the empty space below it targets `<html>` — and `<html>` is\n * `body`'s *parent*, so the event bubbles straight to the document and `body`\n * never sees it. The overlay silently stays open. Listening on the document\n * itself catches both cases, and costs nothing else.\n *\n * Semantics are otherwise identical to the CDK's, deliberately:\n *\n * - Emits on `click` / `auxclick` / `contextmenu`, in the capture phase, and\n * tracks `pointerdown` so a `click` is judged by where the press *started*\n * (a drag that ends outside the pane doesn't count as an outside click).\n * - Walks watchers top-most first and stops at the first one that contains the\n * event, so clicking inside a stacked overlay can't close the ones beneath\n * it (a `wr-select` opened inside a `wr-popover`, say).\n * - Fires for the very click that opened the overlay, which is why every caller\n * also ignores events landing on its own trigger.\n *\n * Registration is per subscription: the document listeners go up with the first\n * watcher and come down with the last, so an app with no open overlay has none.\n * That sentence was aspirational until v11 — see {@link outsidePointerEvents}.\n */\n@Service()\nexport class WrOutsideClick {\n private readonly doc = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /** In attach order — last is top-most. */\n private readonly watchers: Watcher[] = [];\n private cleanup: (() => void) | null = null;\n private pressOrigin: EventTarget | null = null;\n\n /**\n * Emits every `click` / `auxclick` / `contextmenu` that lands outside the\n * given overlay's pane, for as long as the overlay is attached.\n *\n * **It completes when the overlay detaches, and that is load-bearing.** Every\n * one of the ten call sites subscribes inside its own `openOverlay()` and\n * pipes `takeUntilDestroyed(destroyRef)` — a DIRECTIVE lifetime, not an\n * overlay one — and none of them unsubscribes on close, because the natural\n * reading of that idiom is \"this ends with the component\". Without the\n * completion below the teardown never ran: one watcher accumulated per OPEN\n * for the life of the page, each pinning a disposed `OverlayRef` (and through\n * it a detached pane, its portal outlet and their injectors), the four\n * capture-phase document listeners could never come down because\n * `watchers.length` never reached zero, and every click on the page walked a\n * list that only grew. A `mode=\"tooltip\"` popover made it unbounded — one\n * permanent watcher per hover.\n *\n * Completing here rather than fixing ten call sites is deliberate: the next\n * component to open an overlay would have made the same reasonable mistake.\n * It is also what CDK's own `OverlayRef.outsidePointerEvents()` does.\n */\n outsidePointerEvents(overlayRef: OverlayRef): Observable<MouseEvent> {\n return new Observable<MouseEvent>(subscriber => {\n if (!this.isBrowser) return;\n\n const watcher: Watcher = { overlayRef, subscriber };\n this.watchers.push(watcher);\n if (this.watchers.length === 1) this.listen();\n\n // BOTH handlers, and the second one is not defensive padding. `dispose()`\n // emits a detachment and then completes the subject, so a live overlay\n // arrives through `next` — but a ref that was already disposed before\n // anyone subscribed has nothing left to emit and arrives through\n // `complete` alone. Listening for `next` only left exactly the watcher\n // this whole change exists to remove.\n const ended = (): void => subscriber.complete();\n const detached = overlayRef.detachments().subscribe({ next: ended, complete: ended });\n\n return () => {\n detached.unsubscribe();\n const index = this.watchers.indexOf(watcher);\n if (index > -1) this.watchers.splice(index, 1);\n if (!this.watchers.length) this.unlisten();\n };\n });\n }\n\n private readonly onPointerDown = (event: Event): void => {\n this.pressOrigin = eventTarget(event);\n };\n\n private readonly onClick = (event: Event): void => {\n const target = eventTarget(event);\n // `detail > 0` means the click really came from a pointer press. A click\n // activated by Enter or Space carries `detail: 0` and has no `pointerdown`\n // of its own — so trusting a leftover origin there judged it by a press\n // that belonged to something else entirely. A press inside the pane that\n // never produced a click (a drag released off-window, a node removed under\n // the finger, a cancelled touch) survives in `pressOrigin`, and the next\n // keyboard activation anywhere on the page then read as \"inside\": the panel\n // would not close, for keyboard users only.\n const fromPointer = event.type === 'click' && (event as MouseEvent).detail > 0;\n const origin = fromPointer && this.pressOrigin ? this.pressOrigin : target;\n this.pressOrigin = null;\n\n // Snapshot: a watcher that closes on this event unsubscribes synchronously,\n // mutating `watchers` while we're walking it.\n const watchers = this.watchers.slice();\n for (let i = watchers.length - 1; i > -1; i--) {\n const { overlayRef, subscriber } = watchers[i];\n if (!overlayRef.hasAttached()) continue;\n\n const pane = overlayRef.overlayElement;\n if (containsAcrossShadow(pane, target) || containsAcrossShadow(pane, origin)) break;\n\n subscriber.next(event as MouseEvent);\n }\n };\n\n private listen(): void {\n const options: AddEventListenerOptions = { capture: true };\n const doc = this.doc;\n\n doc.addEventListener('pointerdown', this.onPointerDown, options);\n doc.addEventListener('click', this.onClick, options);\n doc.addEventListener('auxclick', this.onClick, options);\n doc.addEventListener('contextmenu', this.onClick, options);\n\n this.cleanup = () => {\n doc.removeEventListener('pointerdown', this.onPointerDown, options);\n doc.removeEventListener('click', this.onClick, options);\n doc.removeEventListener('auxclick', this.onClick, options);\n doc.removeEventListener('contextmenu', this.onClick, options);\n };\n }\n\n private unlisten(): void {\n this.cleanup?.();\n this.cleanup = null;\n this.pressOrigin = null;\n }\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\nimport { OverlayContainer } from '@angular/cdk/overlay';\nimport { _isTestEnvironment } from '@angular/cdk/platform';\nimport { Service } from '@angular/core';\n\nconst CONTAINER_CLASS = 'wr-overlay-container';\nconst PLATFORM_ATTR = 'data-wr-platform';\n\n/**\n * The overlay container every NGWR overlay renders into — a CDK\n * `OverlayContainer` subclass that tags its element with\n * `.wr-overlay-container` in addition to CDK's own `.cdk-overlay-container`.\n *\n * It is what `WR_OVERLAY_CONTAINER` resolves to by default, and it is never\n * provided as CDK's root `OverlayContainer`: that one stays the element\n * Angular Material, NG-ZORRO and every other CDK consumer share, so NGWR's\n * overlays sit in an element of their own. The class is the stable hook for\n * styling them, e.g.:\n *\n * ```scss\n * .wr-overlay-container .cdk-overlay-pane { font-size: var(--wr-text-sm); }\n * ```\n *\n * Not a z-index: CDK 22 promotes overlays into the top layer, which no\n * z-index reaches.\n */\n@Service()\nexport class WrOverlayContainer extends OverlayContainer {\n // Not `super._createContainer()`: CDK stamps its element `platform=\"test\"`\n // (or `\"server\"`) and, creating one, removes every `.cdk-overlay-container`\n // carrying either — so under Karma, Jasmine, Jest or Mocha the root container\n // and this one would detach each other. Same conditions, own attribute, and\n // only its own leftovers swept; CDK's class stays for the structural styles.\n protected override _createContainer(): void {\n const testing = _isTestEnvironment();\n\n if (this._platform.isBrowser || testing) {\n this._document\n .querySelectorAll(\n `.${CONTAINER_CLASS}[${PLATFORM_ATTR}=\"server\"], .${CONTAINER_CLASS}[${PLATFORM_ATTR}=\"test\"]`\n )\n .forEach(stale => stale.remove());\n }\n\n const container = this._document.createElement('div');\n container.classList.add('cdk-overlay-container', CONTAINER_CLASS);\n if (testing) container.setAttribute(PLATFORM_ATTR, 'test');\n else if (!this._platform.isBrowser) container.setAttribute(PLATFORM_ATTR, 'server');\n\n this._document.body.appendChild(container);\n this._containerElement = container;\n }\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\nimport { Service } from '@angular/core';\n\ninterface Layer {\n readonly host: HTMLElement;\n readonly coversToasts: boolean;\n}\n\n/**\n * Move a popover host to the end of the top layer. Both calls run in one\n * task, so no frame shows it hidden. A host that is not a popover (jsdom,\n * `usePopover: false`) has no place in the top layer to change.\n */\nfunction reshow(host: Element): void {\n if (!host.isConnected || !host.hasAttribute('popover')) return;\n try {\n (host as HTMLElement).hidePopover();\n (host as HTMLElement).showPopover();\n } catch {\n // `hidePopover` throws on a host that is not showing: nothing to move.\n }\n}\n\n/**\n * Keeps the global toast host under the overlays opened with\n * `toasts: 'below'`, and above every other one.\n *\n * The top layer is ordered by the moment of promotion and by nothing else, so\n * the only way to put the toast host under an overlay is to promote that\n * overlay again after it. The toast host therefore belongs right under the\n * trailing run of covering overlays: the ones opened after the last overlay\n * that wants toasts above it. A covering overlay under such an overlay cannot\n * be moved over the toasts without also moving over the modal above it, so the\n * newer overlay's rule wins until it closes.\n *\n * @internal\n */\n@Service()\nexport class WrOverlayOrder {\n /** Open overlays in the order they were promoted. */\n private readonly layers: Layer[] = [];\n private toasts: HTMLElement | null = null;\n /** How many of `layers` sit under the toast host. */\n private under = 0;\n /** Something may have joined the top layer since the toast host was last raised. */\n private stale = true;\n private placing = false;\n\n // Neither event bubbles out of a shadow tree, so a popover shown inside one\n // goes unseen until an overlay joins the container.\n private readonly onBeforeToggle = (event: Event): void => {\n if (this.placing || event.target === this.toasts) return;\n if ((event as ToggleEvent).newState === 'open') this.stale = true;\n };\n private readonly onFullscreenChange = (): void => {\n this.stale = true;\n };\n\n /**\n * Register an overlay right after it is attached, which is when the CDK\n * promotes it. Returns the function that takes it off the list.\n */\n add(host: HTMLElement, toasts: 'above' | 'below' = 'above'): () => void {\n const layer: Layer = { host, coversToasts: toasts === 'below' };\n this.layers.push(layer);\n this.stale = true;\n return () => {\n const at = this.layers.indexOf(layer);\n if (at < 0) return;\n this.layers.splice(at, 1);\n if (at < this.under) this.under--;\n // The overlay that goes may have been the one deciding for those under it.\n this.place(false);\n };\n }\n\n /**\n * Put the toast host on top, then every overlay that covers toasts over it.\n * Returns whether anything had to move.\n */\n raiseToasts(host: HTMLElement): boolean {\n if (host !== this.toasts) {\n this.dropToasts();\n this.toasts = host;\n this.under = this.layers.length;\n this.stale = true;\n // `beforetoggle` does not bubble, so it is caught on the way down.\n host.ownerDocument.addEventListener('beforetoggle', this.onBeforeToggle, true);\n host.ownerDocument.addEventListener('fullscreenchange', this.onFullscreenChange);\n }\n return this.place(true);\n }\n\n /** An overlay that is not on the list was promoted. */\n joined(): void {\n this.stale = true;\n }\n\n dropToasts(): void {\n const doc = this.toasts?.ownerDocument;\n doc?.removeEventListener('beforetoggle', this.onBeforeToggle, true);\n doc?.removeEventListener('fullscreenchange', this.onFullscreenChange);\n this.toasts = null;\n }\n\n /**\n * @param raise with no covering overlay open, raise the host even where the\n * list says it is on top, if a popover this list does not know may have joined.\n */\n private place(raise: boolean): boolean {\n const toasts = this.toasts;\n if (!toasts) return false;\n\n let start = this.layers.length;\n while (start > 0 && this.layers[start - 1].coversToasts) start--;\n const covering = this.layers.slice(start);\n // Already right under the covering overlays: moving anything would only\n // put the toasts over them for the length of this call.\n if (this.under === start && (covering.length > 0 || !raise || !this.stale)) return false;\n\n const doc = toasts.ownerDocument;\n const focused = doc.activeElement as HTMLElement | null;\n\n this.placing = true;\n reshow(toasts);\n this.under = start;\n this.stale = false;\n\n if (covering.length > 0) {\n // Whatever was attached after the first covering overlay sits above it\n // (a select panel inside the dialog), and has to stay there. Hosts are\n // appended on attach, so the siblings after it are those, in order.\n const above = new Set<Element>();\n for (let el: Element | null = covering[0].host; el; el = el.nextElementSibling) above.add(el);\n for (const layer of covering) above.add(layer.host);\n above.delete(toasts);\n above.forEach(reshow);\n }\n this.placing = false;\n\n // Showing a popover runs its focusing steps, which move focus to an\n // `autofocus` descendant.\n if (focused?.isConnected && doc.activeElement !== focused) focused.focus({ preventScroll: true });\n return true;\n }\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\nimport type { OverlayContainer } from '@angular/cdk/overlay';\nimport { InjectionToken, inject } from '@angular/core';\n\nimport { WrOverlayContainer } from '../wr-overlay-container';\n\n/**\n * Injection token for the overlay container NGWR components render into.\n *\n * Isolated by default: a `WrOverlayContainer`, tagged `.wr-overlay-container`,\n * and never CDK's root `OverlayContainer`. Every CDK consumer that shares the\n * root one (Angular Material, NG-ZORRO) shares its element too, and with it\n * the z-index stacking, the `.cdk-overlay-pane` rules and the lifecycle — so\n * one library's overlays end up under, restyled by or torn down with\n * another's. CDK's root container is left untouched for them.\n *\n * @internal\n */\nexport const WR_OVERLAY_CONTAINER = new InjectionToken<OverlayContainer>('WR_OVERLAY_CONTAINER', {\n providedIn: 'root',\n factory: () => inject(WrOverlayContainer),\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\nimport { Overlay, OverlayContainer, OverlayPositionBuilder } from '@angular/cdk/overlay';\nimport { EnvironmentInjector, InjectionToken, Injector, inject } from '@angular/core';\n\nimport { WR_OVERLAY_CONTAINER } from './wr-overlay-container.token';\n\n/**\n * Injection token for the CDK `Overlay` service NGWR components should\n * use to open panels.\n *\n * Isolated by default: a fresh `Overlay` bound to `WR_OVERLAY_CONTAINER`\n * rather than CDK's root one, so NGWR overlays never share a DOM root — and\n * with it z-index, styles and lifecycle — with Angular Material, NG-ZORRO or\n * any other CDK consumer. CDK's root `Overlay` and `OverlayContainer` are\n * left untouched, so those libraries keep theirs.\n *\n * @internal — directives/services inside the lib inject this instead of\n * CDK's `Overlay` directly.\n */\nexport const WR_OVERLAY = new InjectionToken<Overlay>('WR_OVERLAY', {\n providedIn: 'root',\n factory: (): Overlay => {\n const parent = inject(EnvironmentInjector);\n const container = inject(WR_OVERLAY_CONTAINER);\n\n // `Overlay` reads `OverlayContainer` from its own injector, so a child that\n // answers with ours gets a fresh instance bound to it. Providing either in\n // the root instead would move every other CDK consumer into it as well.\n // The position builder comes along because a connected position strategy\n // measures the container it reads from its builder's injector: left in the\n // root, the first dropdown created CDK's own container just to measure it.\n const child = Injector.create({\n parent,\n providers: [\n { provide: OverlayContainer, useValue: container },\n { provide: OverlayPositionBuilder, useClass: OverlayPositionBuilder },\n { provide: Overlay, useClass: Overlay },\n ],\n });\n\n return child.get(Overlay);\n },\n});\n"],"mappings":";;;;;;;;;;;;;AAyCA,MAAa,wBAAuE;CAClF,KAAK;EAAE,SAAS;EAAU,SAAS;EAAO,UAAU;EAAU,UAAU;CAAQ;CAChF,aAAa;EAAE,SAAS;EAAS,SAAS;EAAO,UAAU;EAAS,UAAU;CAAQ;CACtF,WAAW;EAAE,SAAS;EAAO,SAAS;EAAO,UAAU;EAAO,UAAU;CAAQ;CAChF,QAAQ;EAAE,SAAS;EAAU,SAAS;EAAU,UAAU;EAAU,UAAU;CAAK;CACnF,gBAAgB;EAAE,SAAS;EAAS,SAAS;EAAU,UAAU;EAAS,UAAU;CAAK;CACzF,cAAc;EAAE,SAAS;EAAO,SAAS;EAAU,UAAU;EAAO,UAAU;CAAK;CACnF,MAAM;EAAE,SAAS;EAAS,SAAS;EAAU,UAAU;EAAO,UAAU;CAAQ;CAChF,cAAc;EAAE,SAAS;EAAS,SAAS;EAAO,UAAU;EAAO,UAAU;CAAK;CAClF,YAAY;EAAE,SAAS;EAAS,SAAS;EAAU,UAAU;EAAO,UAAU;CAAQ;CACtF,OAAO;EAAE,SAAS;EAAO,SAAS;EAAU,UAAU;EAAS,UAAU;CAAQ;CACjF,eAAe;EAAE,SAAS;EAAO,SAAS;EAAO,UAAU;EAAS,UAAU;CAAK;CACnF,aAAa;EAAE,SAAS;EAAO,SAAS;EAAU,UAAU;EAAS,UAAU;CAAQ;AACxF;AAmBD,MAAa,wBAAmF;CAC9F,KAAK,CAAC,OAAO,QAAQ;CACrB,aAAa,CAAC,aAAa,cAAc;CACzC,WAAW,CAAC,WAAW,YAAY;CACnC,QAAQ,CAAC,UAAU,KAAK;CACxB,gBAAgB,CAAC,gB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O,mBAAmB;EACzC,MAAM,YAAY,OAAO,oBAAoB;EAiB7C,OATc,SAAS,OAAO;GAC5B;GACA,WAAW;IACT;KAAE,SAAS;KAAkB,UAAU;IAAS;IAChD;KAAE,SAAS;KAAwB,UAAU;IAAsB;IACnE;KAAE,SAAS;KAAS,UAAU;IAAO;GACtC;EACF,CAEM,CAAA,CAAM,IAAI,OAAO;CAC1B;AACD,CAAA"}
1
+ {"version":3,"file":"ngwr-overlay.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/overlay/wr-anchored-positions.ts","../../../projects/lib/overlay/wr-overlay-close.ts","../../../projects/lib/overlay/wr-focus-overlay.ts","../../../projects/lib/overlay/wr-follow-direction.ts","../../../projects/lib/overlay/wr-follow-size.ts","../../../projects/lib/overlay/wr-mirror-offsets.ts","../../../projects/lib/overlay/wr-outside-click.ts","../../../projects/lib/overlay/wr-overlay-container.ts","../../../projects/lib/overlay/wr-overlay-order.ts","../../../projects/lib/overlay/tokens/wr-overlay-container.token.ts","../../../projects/lib/overlay/tokens/wr-overlay.token.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 type { ConnectedPosition } from '@angular/cdk/overlay';\n\n/**\n * Where an anchored panel sits relative to its trigger: a side, optionally\n * aligned to the trigger's start or end edge. The one set `wr-popover`,\n * `wr-dropdown` and `wr-popconfirm` take as `position`.\n *\n * `left` / `right` and `-start` / `-end` are logical: under `dir=\"rtl\"` they\n * mirror, the name staying as written.\n */\nexport type WrAnchoredPosition =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\n/**\n * The CDK geometry for each placement: one position, no gap and no fallbacks.\n *\n * Everything anchors on `start` / `end` or `center`, which the CDK resolves\n * against the direction, so the table itself needs no mirroring. A gap added by\n * `wrAnchoredPositions` is an offset in physical pixels and does: see\n * `wrMirrorOffsets`.\n *\n * @internal\n */\nexport const WR_ANCHORED_POSITIONS: Record<WrAnchoredPosition, ConnectedPosition> = {\n top: { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom' },\n 'top-start': { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n 'top-end': { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },\n bottom: { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top' },\n 'bottom-start': { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n 'bottom-end': { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },\n left: { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center' },\n 'left-start': { originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },\n 'left-end': { originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },\n right: { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center' },\n 'right-start': { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },\n 'right-end': { originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },\n};\n\n/**\n * What each placement is allowed to flip to when it does not fit, best first.\n * The requested placement always leads, so a panel that fits never moves.\n *\n * Alignment is preserved down the whole chain — a `-start` panel stays\n * `-start` — because the alignment is the author's answer to \"which end of the\n * trigger does this belong to\", and a flip is about the side, not about that.\n *\n * The two axes are deliberately NOT symmetric. A block-axis placement (`top*` /\n * `bottom*`) flips only to its opposite, the classic behaviour, so a dropdown-ish\n * panel can never surprise anyone by appearing beside its trigger. An inline-axis\n * one (`left*` / `right*`) also gets the two block-axis sides, because on a phone\n * NEITHER side fits: at 375px a 233px panel beside a mid-page trigger overflows\n * by 109px to the right and 97px to the left, and only below/above has room.\n *\n * @internal\n */\nexport const WR_ANCHORED_FALLBACKS: Record<WrAnchoredPosition, readonly WrAnchoredPosition[]> = {\n top: ['top', 'bottom'],\n 'top-start': ['top-start', 'bottom-start'],\n 'top-end': ['top-end', 'bottom-end'],\n bottom: ['bottom', 'top'],\n 'bottom-start': ['bottom-start', 'top-start'],\n 'bottom-end': ['bottom-end', 'top-end'],\n left: ['left', 'right', 'bottom', 'top'],\n 'left-start': ['left-start', 'right-start', 'bottom-start', 'top-start'],\n 'left-end': ['left-end', 'right-end', 'bottom-end', 'top-end'],\n right: ['right', 'left', 'bottom', 'top'],\n 'right-start': ['right-start', 'left-start', 'bottom-start', 'top-start'],\n 'right-end': ['right-end', 'left-end', 'bottom-end', 'top-end'],\n};\n\n/** How a host dresses the links `wrAnchoredPositions` returns. @internal */\nexport interface WrAnchoredPositionsOptions {\n /**\n * Distance between the trigger and the panel, in px, as a CDK offset pointing\n * away from the trigger. Left out by a host whose gap is padding on the pane.\n *\n * It is the reason a flip list matters rather than being a nicety: the\n * flexible strategy emits `offsetX` as a `transform` on the pane, AFTER\n * `withPush` has already decided the coordinate. Push therefore parks a\n * right-anchored panel flush against the viewport edge and the offset then\n * shoves it back out, so a side placement that does not fit loses its border\n * and corner off-screen no matter how hard push works.\n */\n readonly gap?: number;\n /**\n * The pane's base class. Each link is tagged `<paneClass>--<placement>`, so\n * the pane names the placement it ACTUALLY took: the CDK applies a position's\n * own `panelClass` when it lands on it and clears it on the next one. Left\n * out by a host that writes the class itself.\n */\n readonly paneClass?: string;\n}\n\n/**\n * The list `withPositions()` wants for a placement: its fallback chain in\n * order, as fresh objects, so a caller may also tell which link the CDK landed\n * on by the identity of the position it reports back.\n *\n * @internal\n */\nexport function wrAnchoredPositions(\n position: WrAnchoredPosition,\n options: WrAnchoredPositionsOptions = {}\n): ConnectedPosition[] {\n const { gap, paneClass } = options;\n return WR_ANCHORED_FALLBACKS[position].map(name => {\n const link: ConnectedPosition = { ...WR_ANCHORED_POSITIONS[name] };\n if (gap) {\n if (name.startsWith('top')) link.offsetY = -gap;\n else if (name.startsWith('bottom')) link.offsetY = gap;\n else if (name.startsWith('left')) link.offsetX = -gap;\n else link.offsetX = gap;\n }\n if (paneClass) link.panelClass = `${paneClass}--${name}`;\n return link;\n });\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\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/** The same 24×24 stroked ✕ the rest of the library's chrome draws (alert, toast, lightbox). */\nconst CLOSE_ICON_ATTRS: readonly (readonly [string, string])[] = [\n ['class', 'wr-icon__svg'],\n ['viewBox', '0 0 24 24'],\n ['fill', 'none'],\n ['stroke', 'currentColor'],\n ['stroke-width', '2'],\n ['stroke-linecap', 'round'],\n ['stroke-linejoin', 'round'],\n ['aria-hidden', 'true'],\n];\nconst CLOSE_ICON_PATHS: readonly string[] = ['M18 6 6 18', 'm6 6 12 12'];\n\n/**\n * Builds the ✕ node by node.\n *\n * It was one `innerHTML = CLOSE_ICON`, and the string was a compile-time\n * constant, so it was never an injection risk — it was an AVAILABILITY one.\n * Under `require-trusted-types-for 'script'` an `innerHTML` write throws\n * `TrustedHTML assignment` whatever the string is, and the throw landed after\n * the overlay was on screen: a modal with no ✕, no backdrop subscription and no\n * Escape handler, over the whole application. `createElementNS` is not a\n * Trusted Types sink, so there is nothing left to police.\n */\nfunction createCloseIcon(doc: Document): SVGSVGElement {\n const svg = doc.createElementNS(SVG_NS, 'svg');\n // `setAttribute`, not `.className` — on an SVG element that property is an\n // `SVGAnimatedString` and assigning a string to it silently does nothing.\n for (const [name, value] of CLOSE_ICON_ATTRS) svg.setAttribute(name, value);\n for (const d of CLOSE_ICON_PATHS) {\n const path = doc.createElementNS(SVG_NS, 'path');\n path.setAttribute('d', d);\n svg.appendChild(path);\n }\n return svg;\n}\n\n/**\n * Appends a dismiss (✕) button to a service-opened overlay panel.\n *\n * `WrDialog` and `WrDrawerManager` build their panel around a component the\n * consumer supplies, so there is no template of their own to put a corner button\n * in — they call this instead. Component-driven overlays (`<wr-drawer>`) render\n * the same markup in their template.\n *\n * Uses `host.ownerDocument` rather than the global `document`, so it carries no\n * hidden browser-only assumption; callers still gate on the platform because\n * they have nothing to append to on the server.\n *\n * @param host Panel element the button is appended to (and positioned against).\n * @param className BEM class for the button, e.g. `wr-dialog__close`.\n * @param label Accessible name — already localized by the caller.\n * @param onClose Invoked on click.\n */\nexport function wrAppendOverlayClose(\n host: HTMLElement,\n className: string,\n label: string,\n onClose: () => void\n): HTMLButtonElement {\n const button = host.ownerDocument.createElement('button');\n button.type = 'button';\n button.className = className;\n button.setAttribute('aria-label', label);\n button.appendChild(createCloseIcon(host.ownerDocument));\n button.addEventListener('click', onClose);\n host.appendChild(button);\n return button;\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\nimport type { FocusTrap } from '@angular/cdk/a11y';\nimport { type Injector, afterNextRender } from '@angular/core';\n\nconst INITIAL = '[cdkFocusInitial], [cdk-focus-initial]';\n\n/**\n * Moves focus into a freshly opened modal overlay the way its `autoFocus`\n * option asks. An element marked `cdkFocusInitial` wins in every mode.\n *\n * `'first-tabbable'` is the focus trap's own initial focus. `'dialog'` focuses\n * the panel (made programmatically focusable with `tabindex=\"-1\"`), `false`\n * leaves focus where it is. Both wait for the next render, because the content\n * is not in the DOM before that.\n *\n * @internal\n */\nexport function wrFocusOverlay(host: HTMLElement, trap: FocusTrap, mode: WrOverlayAutoFocus, injector: Injector): void {\n if (mode === 'first-tabbable') {\n void trap.focusInitialElementWhenReady();\n return;\n }\n if (mode === 'dialog') host.setAttribute('tabindex', '-1');\n afterNextRender(\n () => {\n if (!host.isConnected) return;\n if (host.querySelector(INITIAL)) trap.focusInitialElement();\n else if (mode === 'dialog') host.focus({ preventScroll: true });\n },\n { injector }\n );\n}\n\n/** What a dialog or drawer does with focus when it opens. */\nexport type WrOverlayAutoFocus = 'first-tabbable' | 'dialog' | false;\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\nimport type { Direction, Directionality } from '@angular/cdk/bidi';\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport { type Injector, effect, untracked } from '@angular/core';\n\nimport { Subscription } from 'rxjs';\n\nimport { wrNoop } from 'ngwr/utils';\n\n/**\n * Keep an OPEN overlay on the application's reading direction.\n *\n * The CDK reads the direction ONCE, as a string, when the overlay is created\n * (`overlayConfig.direction ||= directionality.value`), writes it as the host's\n * `dir` on attach, and never looks at it again — `updatePosition()` does not\n * touch it and `setDirection()` is the only thing that does. So an application\n * that flips direction while a panel is open mirrors the page and leaves the\n * panel behind, still `ltr`, still resolving `start` to the left. This site's\n * own LTR/RTL switch is the demonstration: it lives inside a `wr-dropdown`, and\n * the `wr-segmented` it is built from reads `Directionality` live — so the thumb\n * slides to the other slot while the pane around it still renders `ltr`, and\n * parks under the wrong label.\n *\n * Call it once per `OverlayRef`, right after `overlay.create(...)`. The follower\n * ends itself when that overlay detaches or is disposed, so a reopen — which is\n * always a NEW ref in this library — needs a new call, and the returned teardown\n * is only for stopping early.\n *\n * `onDirectionChange` is for the sites whose position LIST is itself\n * direction-dependent (the four that pass their table through\n * {@link wrMirrorOffsets}): it runs with the new direction already on the ref\n * and before the overlay repositions, so the strategy is carrying the mirrored\n * offsets by the time the CDK re-resolves them.\n *\n * SSR-safe: it touches no browser global of its own, and the CDK's position\n * strategies no-op off the browser, so a flip on the server only rewrites the\n * attribute.\n *\n * @param overlayRef The overlay to keep in step, freshly created.\n * @param dir The `Directionality` the caller injected. `null` — an optional\n * inject with no provider, i.e. a bare `TestBed` — means there is nothing\n * ambient to follow and this does nothing at all.\n * @param injector Owns the `valueSignal` watch; the caller's own is right.\n * @param onDirectionChange Re-applies direction-dependent state, e.g.\n * `strategy.withPositions(wrMirrorOffsets(TABLE, direction === 'rtl'))`.\n * @returns Stops following. Idempotent, and unnecessary in the normal case.\n *\n * @example\n * ```ts\n * this.overlayRef = this.overlay.create({ positionStrategy, ... });\n * wrFollowDirection(this.overlayRef, this.dir, this.injector, direction =>\n * positionStrategy.withPositions(\n * wrMirrorOffsets(wrPopconfirmPositions(this.position()), direction === 'rtl')\n * )\n * );\n * ```\n */\nexport function wrFollowDirection(\n overlayRef: OverlayRef,\n dir: Directionality | null,\n injector: Injector,\n onDirectionChange?: (direction: Direction) => void\n): () => void {\n if (!dir) return wrNoop;\n\n const apply = (next: Direction): void => {\n // Comparing against the REF rather than a direction captured up here does\n // three jobs at once: the watch's mandatory first run is a no-op, a flip\n // that arrives down both channels is applied once, and a same-value write\n // never yanks a panel the user is reading.\n if (next === overlayRef.getDirection()) return;\n\n overlayRef.setDirection(next); // rewrites the host's `dir`; it does NOT reposition\n onDirectionChange?.(next); // the caller re-mirrors its position list here\n overlayRef.updatePosition(); // re-resolves start/end against the direction just set\n };\n\n // Two channels, because they are not the same thing. `valueSignal` is the\n // state — `Directionality.value` is a getter over it, so nothing can change\n // direction without writing it. `change` is an EventEmitter the root instance\n // never emits: it reads the document once at construction and only completes\n // the emitter on destroy, so it belongs to the `[dir]` directive (and to an\n // app, like this site's header, that emits it by hand as a courtesy). Keying\n // on `change` alone would be dead for an app that just writes the signal;\n // keying on the signal alone would ignore the `{ value, change }` test double\n // that a dozen of the library's RTL specs hand their component.\n //\n // `untracked` because of WHERE this is called from: half the call sites open\n // their overlay out of an `effect(() => { if (this.isOpen()) … })`, and\n // `effect()` refuses in dev mode to be created inside a reactive context.\n // Laundering only the CREATION is exactly right — the watch below still\n // depends on `valueSignal` and on nothing else.\n const watch = untracked(() =>\n effect(\n () => {\n // Read as a plain optional function rather than as a `Signal`, because\n // the case being guarded is a double that has no signal at all: falling\n // back to `value` registers no dependency, so the watch simply never\n // re-runs and `change` carries that case on its own.\n const read: (() => Direction) | undefined = dir.valueSignal;\n apply(read ? read() : dir.value);\n },\n { injector }\n )\n );\n\n // rxjs owns the teardown, and an `OverlayRef` is why. Open and close happen in\n // an event handler or an effect, never in an injection context, so the idiom\n // that suggests itself — `takeUntilDestroyed(destroyRef)` — would tie this to\n // the DIRECTIVE's lifetime: a menu opened fifty times would leave fifty\n // followers behind, each pinning a disposed ref. (`WrOutsideClick`'s JSDoc\n // records that same mistake, made at ten call sites.) `detachments()` is the\n // overlay's own lifetime and the one channel every dismissal goes through.\n // And it is not hygiene: `setDirection()` writes through the host element\n // `dispose()` nulls, so a watch that outlives its overlay THROWS on the next\n // flip.\n const teardown = new Subscription();\n const stop = (): void => teardown.unsubscribe();\n\n teardown.add(() => watch.destroy());\n teardown.add(dir.change.subscribe(apply));\n // Both handlers, for the reason `WrOutsideClick` gives: a live ref arrives\n // through `next`, one already disposed before this call has only `complete`\n // left to give.\n teardown.add(overlayRef.detachments().subscribe({ next: stop, complete: stop }));\n\n // `Subscription.unsubscribe()` is a no-op once closed, so the caller's copy of\n // this and the automatic one cannot fight, and calling it twice is free.\n return stop;\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\nimport type { OverlayRef } from '@angular/cdk/overlay';\n\nimport { wrNoop } from 'ngwr/utils';\n\n/**\n * Keep an OPEN overlay positioned as its content changes size.\n *\n * The CDK positions a pane once, when it attaches, and again on scroll or\n * resize of the window. A panel whose content renders after that, or grows later\n * (a time row that appears, a calendar that gains a sixth week), is measured at\n * its first, smaller size: flipped above the origin at that height, it then\n * grows downward over the field it belongs to. This watches the pane with a\n * `ResizeObserver` and calls `updatePosition()` on every change, so the flip\n * decision always uses the size the panel has now.\n *\n * Call it once per `OverlayRef`, right after `attach(...)`. It ends itself when\n * the overlay detaches or is disposed. No-op where `ResizeObserver` does not\n * exist (SSR, old engines).\n *\n * @param overlayRef The overlay to keep in place.\n * @returns Stops observing. Idempotent, and unnecessary in the normal case.\n */\nexport function wrFollowSize(overlayRef: OverlayRef): () => void {\n if (typeof ResizeObserver === 'undefined') return wrNoop;\n\n const observer = new ResizeObserver(() => overlayRef.updatePosition());\n observer.observe(overlayRef.overlayElement);\n\n const stop = (): void => {\n observer.disconnect();\n subscription.unsubscribe();\n };\n // Both handlers: a live ref arrives through `next`, a disposed one only completes.\n const subscription = overlayRef.detachments().subscribe({ next: stop, complete: stop });\n return stop;\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\nimport type { ConnectedPosition } from '@angular/cdk/overlay';\n\n/**\n * Mirror the horizontal offsets of a connected-position list for RTL.\n *\n * The CDK mirrors `originX` / `overlayX` under `dir=\"rtl\"` — a `start` anchor\n * resolves to the origin's right edge — but it does NOT mirror `offsetX`, which\n * it adds to the final PHYSICAL x (`_getOffset` returns `position.offsetX`\n * verbatim). So a position that meant \"sit to the inline-start of the trigger,\n * 8px clear of it\" keeps its `-8` under RTL, where the panel is now on the\n * right: the gap becomes an 8px OVERLAP, and the panel sits on top of the thing\n * it is describing.\n *\n * Nothing in the CDK will do this for us, and the amount is per position, so\n * every ngwr overlay that offsets along the inline axis passes its list through\n * here. `offsetY` is untouched: the block axis does not flip.\n *\n * @example\n * ```ts\n * const dir = inject(Directionality, { optional: true });\n *\n * strategy.withPositions(wrMirrorOffsets(wrAnchoredPositions(position, { gap: 8 }), dir?.value === 'rtl'));\n * ```\n */\nexport function wrMirrorOffsets(positions: readonly ConnectedPosition[], isRtl: boolean): ConnectedPosition[] {\n // Copied rather than mutated even when there is nothing to do: the position\n // tables are module-level constants shared by every instance, so handing back\n // the same objects invites a caller to write through them.\n if (!isRtl) return positions.map(position => ({ ...position }));\n\n return positions.map(position => ({\n ...position,\n ...(position.offsetX == null ? {} : { offsetX: -position.offsetX }),\n }));\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\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { PLATFORM_ID, Service, inject } from '@angular/core';\n\nimport { Observable, type Subscriber } from 'rxjs';\n\n/** One live subscription to `WrOutsideClick.outsidePointerEvents()`. */\ninterface Watcher {\n readonly overlayRef: OverlayRef;\n readonly subscriber: Subscriber<MouseEvent>;\n}\n\n/**\n * Shadow-piercing `event.target` — `composedPath()[0]` is the real originator\n * when the click started inside a shadow root, where `target` is retargeted to\n * the host.\n */\nfunction eventTarget(event: Event): EventTarget | null {\n if (event.composedPath) {\n try {\n return event.composedPath()[0] ?? event.target;\n } catch {\n /* Detached / synthetic events can throw — fall through to `target`. */\n }\n }\n return event.target;\n}\n\n/** `parent.contains(child)`, but stepping out of shadow roots through their hosts. */\nfunction containsAcrossShadow(parent: Node, child: EventTarget | null): boolean {\n const hasShadowRoot = typeof ShadowRoot !== 'undefined';\n let current = child as Node | null;\n while (current) {\n if (current === parent) return true;\n current = hasShadowRoot && current instanceof ShadowRoot ? current.host : current.parentNode;\n }\n return false;\n}\n\n/**\n * Outside-click source for overlays — a drop-in replacement for\n * `OverlayRef.outsidePointerEvents()`.\n *\n * **Why this exists.** CDK's `OverlayOutsideClickDispatcher` binds its\n * listeners to `document.body`. When page content is shorter than the viewport,\n * a click in the empty space below it targets `<html>` — and `<html>` is\n * `body`'s *parent*, so the event bubbles straight to the document and `body`\n * never sees it. The overlay silently stays open. Listening on the document\n * itself catches both cases, and costs nothing else.\n *\n * Semantics are otherwise identical to the CDK's, deliberately:\n *\n * - Emits on `click` / `auxclick` / `contextmenu`, in the capture phase, and\n * tracks `pointerdown` so a `click` is judged by where the press *started*\n * (a drag that ends outside the pane doesn't count as an outside click).\n * - Walks watchers top-most first and stops at the first one that contains the\n * event, so clicking inside a stacked overlay can't close the ones beneath\n * it (a `wr-select` opened inside a `wr-popover`, say).\n * - Fires for the very click that opened the overlay, which is why every caller\n * also ignores events landing on its own trigger.\n *\n * Registration is per subscription: the document listeners go up with the first\n * watcher and come down with the last, so an app with no open overlay has none.\n * That sentence was aspirational until v11 — see {@link outsidePointerEvents}.\n */\n@Service()\nexport class WrOutsideClick {\n private readonly doc = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /** In attach order — last is top-most. */\n private readonly watchers: Watcher[] = [];\n private cleanup: (() => void) | null = null;\n private pressOrigin: EventTarget | null = null;\n\n /**\n * Emits every `click` / `auxclick` / `contextmenu` that lands outside the\n * given overlay's pane, for as long as the overlay is attached.\n *\n * **It completes when the overlay detaches, and that is load-bearing.** Every\n * one of the ten call sites subscribes inside its own `openOverlay()` and\n * pipes `takeUntilDestroyed(destroyRef)` — a DIRECTIVE lifetime, not an\n * overlay one — and none of them unsubscribes on close, because the natural\n * reading of that idiom is \"this ends with the component\". Without the\n * completion below the teardown never ran: one watcher accumulated per OPEN\n * for the life of the page, each pinning a disposed `OverlayRef` (and through\n * it a detached pane, its portal outlet and their injectors), the four\n * capture-phase document listeners could never come down because\n * `watchers.length` never reached zero, and every click on the page walked a\n * list that only grew. A `mode=\"tooltip\"` popover made it unbounded — one\n * permanent watcher per hover.\n *\n * Completing here rather than fixing ten call sites is deliberate: the next\n * component to open an overlay would have made the same reasonable mistake.\n * It is also what CDK's own `OverlayRef.outsidePointerEvents()` does.\n */\n outsidePointerEvents(overlayRef: OverlayRef): Observable<MouseEvent> {\n return new Observable<MouseEvent>(subscriber => {\n if (!this.isBrowser) return;\n\n const watcher: Watcher = { overlayRef, subscriber };\n this.watchers.push(watcher);\n if (this.watchers.length === 1) this.listen();\n\n // BOTH handlers, and the second one is not defensive padding. `dispose()`\n // emits a detachment and then completes the subject, so a live overlay\n // arrives through `next` — but a ref that was already disposed before\n // anyone subscribed has nothing left to emit and arrives through\n // `complete` alone. Listening for `next` only left exactly the watcher\n // this whole change exists to remove.\n const ended = (): void => subscriber.complete();\n const detached = overlayRef.detachments().subscribe({ next: ended, complete: ended });\n\n return () => {\n detached.unsubscribe();\n const index = this.watchers.indexOf(watcher);\n if (index > -1) this.watchers.splice(index, 1);\n if (!this.watchers.length) this.unlisten();\n };\n });\n }\n\n private readonly onPointerDown = (event: Event): void => {\n this.pressOrigin = eventTarget(event);\n };\n\n private readonly onClick = (event: Event): void => {\n const target = eventTarget(event);\n // `detail > 0` means the click really came from a pointer press. A click\n // activated by Enter or Space carries `detail: 0` and has no `pointerdown`\n // of its own — so trusting a leftover origin there judged it by a press\n // that belonged to something else entirely. A press inside the pane that\n // never produced a click (a drag released off-window, a node removed under\n // the finger, a cancelled touch) survives in `pressOrigin`, and the next\n // keyboard activation anywhere on the page then read as \"inside\": the panel\n // would not close, for keyboard users only.\n const fromPointer = event.type === 'click' && (event as MouseEvent).detail > 0;\n const origin = fromPointer && this.pressOrigin ? this.pressOrigin : target;\n this.pressOrigin = null;\n\n // Snapshot: a watcher that closes on this event unsubscribes synchronously,\n // mutating `watchers` while we're walking it.\n const watchers = this.watchers.slice();\n for (let i = watchers.length - 1; i > -1; i--) {\n const { overlayRef, subscriber } = watchers[i];\n if (!overlayRef.hasAttached()) continue;\n\n const pane = overlayRef.overlayElement;\n if (containsAcrossShadow(pane, target) || containsAcrossShadow(pane, origin)) break;\n\n subscriber.next(event as MouseEvent);\n }\n };\n\n private listen(): void {\n const options: AddEventListenerOptions = { capture: true };\n const doc = this.doc;\n\n doc.addEventListener('pointerdown', this.onPointerDown, options);\n doc.addEventListener('click', this.onClick, options);\n doc.addEventListener('auxclick', this.onClick, options);\n doc.addEventListener('contextmenu', this.onClick, options);\n\n this.cleanup = () => {\n doc.removeEventListener('pointerdown', this.onPointerDown, options);\n doc.removeEventListener('click', this.onClick, options);\n doc.removeEventListener('auxclick', this.onClick, options);\n doc.removeEventListener('contextmenu', this.onClick, options);\n };\n }\n\n private unlisten(): void {\n this.cleanup?.();\n this.cleanup = null;\n this.pressOrigin = null;\n }\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\nimport { OverlayContainer } from '@angular/cdk/overlay';\nimport { _isTestEnvironment } from '@angular/cdk/platform';\nimport { Service } from '@angular/core';\n\nconst CONTAINER_CLASS = 'wr-overlay-container';\nconst PLATFORM_ATTR = 'data-wr-platform';\n\n/**\n * The overlay container every NGWR overlay renders into — a CDK\n * `OverlayContainer` subclass that tags its element with\n * `.wr-overlay-container` in addition to CDK's own `.cdk-overlay-container`.\n *\n * It is what `WR_OVERLAY_CONTAINER` resolves to by default, and it is never\n * provided as CDK's root `OverlayContainer`: that one stays the element\n * Angular Material, NG-ZORRO and every other CDK consumer share, so NGWR's\n * overlays sit in an element of their own. The class is the stable hook for\n * styling them, e.g.:\n *\n * ```scss\n * .wr-overlay-container .cdk-overlay-pane { font-size: var(--wr-text-sm); }\n * ```\n *\n * Not a z-index: CDK 22 promotes overlays into the top layer, which no\n * z-index reaches.\n */\n@Service()\nexport class WrOverlayContainer extends OverlayContainer {\n // Not `super._createContainer()`: CDK stamps its element `platform=\"test\"`\n // (or `\"server\"`) and, creating one, removes every `.cdk-overlay-container`\n // carrying either — so under Karma, Jasmine, Jest or Mocha the root container\n // and this one would detach each other. Same conditions, own attribute, and\n // only its own leftovers swept; CDK's class stays for the structural styles.\n protected override _createContainer(): void {\n const testing = _isTestEnvironment();\n\n if (this._platform.isBrowser || testing) {\n this._document\n .querySelectorAll(\n `.${CONTAINER_CLASS}[${PLATFORM_ATTR}=\"server\"], .${CONTAINER_CLASS}[${PLATFORM_ATTR}=\"test\"]`\n )\n .forEach(stale => stale.remove());\n }\n\n const container = this._document.createElement('div');\n container.classList.add('cdk-overlay-container', CONTAINER_CLASS);\n if (testing) container.setAttribute(PLATFORM_ATTR, 'test');\n else if (!this._platform.isBrowser) container.setAttribute(PLATFORM_ATTR, 'server');\n\n this._document.body.appendChild(container);\n this._containerElement = container;\n }\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\nimport { Service } from '@angular/core';\n\ninterface Layer {\n readonly host: HTMLElement;\n readonly coversToasts: boolean;\n}\n\n/**\n * Move a popover host to the end of the top layer. Both calls run in one\n * task, so no frame shows it hidden. A host that is not a popover (jsdom,\n * `usePopover: false`) has no place in the top layer to change.\n */\nfunction reshow(host: Element): void {\n if (!host.isConnected || !host.hasAttribute('popover')) return;\n try {\n (host as HTMLElement).hidePopover();\n (host as HTMLElement).showPopover();\n } catch {\n // `hidePopover` throws on a host that is not showing: nothing to move.\n }\n}\n\n/**\n * Keeps the global toast host under the overlays opened with\n * `toasts: 'below'`, and above every other one.\n *\n * The top layer is ordered by the moment of promotion and by nothing else, so\n * the only way to put the toast host under an overlay is to promote that\n * overlay again after it. The toast host therefore belongs right under the\n * trailing run of covering overlays: the ones opened after the last overlay\n * that wants toasts above it. A covering overlay under such an overlay cannot\n * be moved over the toasts without also moving over the modal above it, so the\n * newer overlay's rule wins until it closes.\n *\n * @internal\n */\n@Service()\nexport class WrOverlayOrder {\n /** Open overlays in the order they were promoted. */\n private readonly layers: Layer[] = [];\n private toasts: HTMLElement | null = null;\n /** How many of `layers` sit under the toast host. */\n private under = 0;\n /** Something may have joined the top layer since the toast host was last raised. */\n private stale = true;\n private placing = false;\n\n // Neither event bubbles out of a shadow tree, so a popover shown inside one\n // goes unseen until an overlay joins the container.\n private readonly onBeforeToggle = (event: Event): void => {\n if (this.placing || event.target === this.toasts) return;\n if ((event as ToggleEvent).newState === 'open') this.stale = true;\n };\n private readonly onFullscreenChange = (): void => {\n this.stale = true;\n };\n\n /**\n * Register an overlay right after it is attached, which is when the CDK\n * promotes it. Returns the function that takes it off the list.\n */\n add(host: HTMLElement, toasts: 'above' | 'below' = 'above'): () => void {\n const layer: Layer = { host, coversToasts: toasts === 'below' };\n this.layers.push(layer);\n this.stale = true;\n return () => {\n const at = this.layers.indexOf(layer);\n if (at < 0) return;\n this.layers.splice(at, 1);\n if (at < this.under) this.under--;\n // The overlay that goes may have been the one deciding for those under it.\n this.place(false);\n };\n }\n\n /**\n * Put the toast host on top, then every overlay that covers toasts over it.\n * Returns whether anything had to move.\n */\n raiseToasts(host: HTMLElement): boolean {\n if (host !== this.toasts) {\n this.dropToasts();\n this.toasts = host;\n this.under = this.layers.length;\n this.stale = true;\n // `beforetoggle` does not bubble, so it is caught on the way down.\n host.ownerDocument.addEventListener('beforetoggle', this.onBeforeToggle, true);\n host.ownerDocument.addEventListener('fullscreenchange', this.onFullscreenChange);\n }\n return this.place(true);\n }\n\n /** An overlay that is not on the list was promoted. */\n joined(): void {\n this.stale = true;\n }\n\n dropToasts(): void {\n const doc = this.toasts?.ownerDocument;\n doc?.removeEventListener('beforetoggle', this.onBeforeToggle, true);\n doc?.removeEventListener('fullscreenchange', this.onFullscreenChange);\n this.toasts = null;\n }\n\n /**\n * @param raise with no covering overlay open, raise the host even where the\n * list says it is on top, if a popover this list does not know may have joined.\n */\n private place(raise: boolean): boolean {\n const toasts = this.toasts;\n if (!toasts) return false;\n\n let start = this.layers.length;\n while (start > 0 && this.layers[start - 1].coversToasts) start--;\n const covering = this.layers.slice(start);\n // Already right under the covering overlays: moving anything would only\n // put the toasts over them for the length of this call.\n if (this.under === start && (covering.length > 0 || !raise || !this.stale)) return false;\n\n const doc = toasts.ownerDocument;\n const focused = doc.activeElement as HTMLElement | null;\n\n this.placing = true;\n reshow(toasts);\n this.under = start;\n this.stale = false;\n\n if (covering.length > 0) {\n // Whatever was attached after the first covering overlay sits above it\n // (a select panel inside the dialog), and has to stay there. Hosts are\n // appended on attach, so the siblings after it are those, in order.\n const above = new Set<Element>();\n for (let el: Element | null = covering[0].host; el; el = el.nextElementSibling) above.add(el);\n for (const layer of covering) above.add(layer.host);\n above.delete(toasts);\n above.forEach(reshow);\n }\n this.placing = false;\n\n // Showing a popover runs its focusing steps, which move focus to an\n // `autofocus` descendant.\n if (focused?.isConnected && doc.activeElement !== focused) focused.focus({ preventScroll: true });\n return true;\n }\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\nimport type { OverlayContainer } from '@angular/cdk/overlay';\nimport { InjectionToken, inject } from '@angular/core';\n\nimport { WrOverlayContainer } from '../wr-overlay-container';\n\n/**\n * Injection token for the overlay container NGWR components render into.\n *\n * Isolated by default: a `WrOverlayContainer`, tagged `.wr-overlay-container`,\n * and never CDK's root `OverlayContainer`. Every CDK consumer that shares the\n * root one (Angular Material, NG-ZORRO) shares its element too, and with it\n * the z-index stacking, the `.cdk-overlay-pane` rules and the lifecycle — so\n * one library's overlays end up under, restyled by or torn down with\n * another's. CDK's root container is left untouched for them.\n *\n * @internal\n */\nexport const WR_OVERLAY_CONTAINER = new InjectionToken<OverlayContainer>('WR_OVERLAY_CONTAINER', {\n providedIn: 'root',\n factory: () => inject(WrOverlayContainer),\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\nimport { Overlay, OverlayContainer, OverlayPositionBuilder } from '@angular/cdk/overlay';\nimport { EnvironmentInjector, InjectionToken, Injector, inject } from '@angular/core';\n\nimport { WR_OVERLAY_CONTAINER } from './wr-overlay-container.token';\n\n/**\n * Injection token for the CDK `Overlay` service NGWR components should\n * use to open panels.\n *\n * Isolated by default: a fresh `Overlay` bound to `WR_OVERLAY_CONTAINER`\n * rather than CDK's root one, so NGWR overlays never share a DOM root — and\n * with it z-index, styles and lifecycle — with Angular Material, NG-ZORRO or\n * any other CDK consumer. CDK's root `Overlay` and `OverlayContainer` are\n * left untouched, so those libraries keep theirs.\n *\n * @internal — directives/services inside the lib inject this instead of\n * CDK's `Overlay` directly.\n */\nexport const WR_OVERLAY = new InjectionToken<Overlay>('WR_OVERLAY', {\n providedIn: 'root',\n factory: (): Overlay => {\n const parent = inject(EnvironmentInjector);\n const container = inject(WR_OVERLAY_CONTAINER);\n\n // `Overlay` reads `OverlayContainer` from its own injector, so a child that\n // answers with ours gets a fresh instance bound to it. Providing either in\n // the root instead would move every other CDK consumer into it as well.\n // The position builder comes along because a connected position strategy\n // measures the container it reads from its builder's injector: left in the\n // root, the first dropdown created CDK's own container just to measure it.\n const child = Injector.create({\n parent,\n providers: [\n { provide: OverlayContainer, useValue: container },\n { provide: OverlayPositionBuilder, useClass: OverlayPositionBuilder },\n { provide: Overlay, useClass: Overlay },\n ],\n });\n\n return child.get(Overlay);\n },\n});\n"],"mappings":";;;;;;;;;;;;;AAyCA,MAAa,wBAAuE;CAClF,KAAK;EAAE,SAAS;EAAU,SAAS;EAAO,UAAU;EAAU,UAAU;CAAQ;CAChF,aAAa;EAAE,SAAS;EAAS,SAAS;EAAO,UAAU;EAAS,UAAU;CAAQ;CACtF,WAAW;EAAE,SAAS;EAAO,SAAS;EAAO,UAAU;EAAO,UAAU;CAAQ;CAChF,QAAQ;EAAE,SAAS;EAAU,SAAS;EAAU,UAAU;EAAU,UAAU;CAAK;CACnF,gBAAgB;EAAE,SAAS;EAAS,SAAS;EAAU,UAAU;EAAS,UAAU;CAAK;CACzF,cAAc;EAAE,SAAS;EAAO,SAAS;EAAU,UAAU;EAAO,UAAU;CAAK;CACnF,MAAM;EAAE,SAAS;EAAS,SAAS;EAAU,UAAU;EAAO,UAAU;CAAQ;CAChF,cAAc;EAAE,SAAS;EAAS,SAAS;EAAO,UAAU;EAAO,UAAU;CAAK;CAClF,YAAY;EAAE,SAAS;EAAS,SAAS;EAAU,UAAU;EAAO,UAAU;CAAQ;CACtF,OAAO;EAAE,SAAS;EAAO,SAAS;EAAU,UAAU;EAAS,UAAU;CAAQ;CACjF,eAAe;EAAE,SAAS;EAAO,SAAS;EAAO,UAAU;EAAS,UAAU;CAAK;CACnF,aAAa;EAAE,SAAS;EAAO,SAAS;EAAU,UAAU;EAAS,UAAU;CAAQ;AACxF;AAmBD,MAAa,wBAAmF;CAC9F,KAAK,CAAC,OAAO,QAAQ;CACrB,aAAa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EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAc,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAd,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAc,CAAA;;AAAd,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAc,YAAA,CAAA,EAD1B,MAAA,Q;;;;;;;;ACnBD,MAAa,uBAAuB,IAAI,eAAiC,wBAAwB;CAC/F,YAAY;CACZ,eAAe,OAAO,kBAAkB;AACzC,CAAA;;;;;;;ACFD,MAAa,aAAa,IAAI,eAAwB,cAAc;CAClE,YAAY;CACZ,eAAuB;EACrB,MAAM,SAAS,OAAO,mBAAmB;EACzC,MAAM,YAAY,OAAO,oBAAoB;EAiB7C,OATc,SAAS,OAAO;GAC5B;GACA,WAAW;IACT;KAAE,SAAS;KAAkB,UAAU;IAAS;IAChD;KAAE,SAAS;KAAwB,UAAU;IAAsB;IACnE;KAAE,SAAS;KAAS,UAAU;IAAO;GACtC;EACF,CAEM,CAAA,CAAM,IAAI,OAAO;CAC1B;AACD,CAAA"}
@@ -59,11 +59,14 @@ var WrPopconfirmHarness = class WrPopconfirmHarness extends ContentContainerComp
59
59
  async confirm() {
60
60
  return (await this.action("confirm")).click();
61
61
  }
62
+ async isPanelFocused() {
63
+ return (await this.pane()).isFocused();
64
+ }
62
65
  async cancel() {
63
66
  return (await this.action("cancel")).click();
64
67
  }
65
68
  async sendEscape() {
66
- return (await this.pane()).sendKeys(TestKey.ESCAPE);
69
+ return (await this.inPanel(".wr-popconfirm")).sendKeys(TestKey.ESCAPE);
67
70
  }
68
71
  async clickOutside() {
69
72
  const id = await this.panelId();
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-popconfirm-testing.mjs","names":[],"sources":["../../../projects/lib/popconfirm/testing/wr-popconfirm-harness.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 {\n ContentContainerComponentHarness,\n type HarnessLoader,\n HarnessPredicate,\n TestKey,\n type TestElement,\n} from '@angular/cdk/testing';\n\nimport type { WrPopconfirmPosition } from 'ngwr/popconfirm';\nimport { WR_COLORS, type WrColor } from 'ngwr/theme';\n\nimport type { WrPopconfirmHarnessFilters } from './types';\n\n/** The two answers a popconfirm offers, which are also its two action modifiers. */\ntype WrPopconfirmAction = 'confirm' | 'cancel';\n\n/**\n * Test harness for `[wrPopconfirm]` — the \"are you sure?\" dialog anchored to its\n * trigger.\n *\n * The panel is NOT inside the trigger: it is a component portal in the overlay\n * container, a sibling of the whole app. So everything about it is reached\n * through the document root, scoped by the `aria-controls` id the trigger\n * publishes while the dialog is showing — which is what keeps two popconfirms\n * from reading each other's question, and why every panel reader throws while the\n * dialog is shut: there is no element to answer about.\n *\n * **The two actions are told apart by their own modifiers**, never by position.\n * `.wr-popconfirm__action--cancel` and `--confirm` are what `cancel()` and\n * `confirm()` click, so a template that ever reorders the pair cannot silently\n * turn a spec's \"cancel\" into a delete.\n *\n * Being a CONTENT CONTAINER means a consumer's own harnesses resolve INSIDE this\n * instance's panel — `popconfirm.getHarness(WrButtonHarness…)` reaches the\n * buttons without the spec ever naming the overlay.\n *\n * @example\n * ```ts\n * const loader = TestbedHarnessEnvironment.loader(fixture);\n * const remove = await loader.getHarness(WrPopconfirmHarness.with({ triggerText: 'Delete' }));\n *\n * await remove.open();\n * expect(await remove.getMessage()).toBe('Delete this item?');\n * await remove.confirm();\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrPopconfirmHarness extends ContentContainerComponentHarness {\n /**\n * The directive's host — whatever element the consumer put `[wrPopconfirm]` on.\n *\n * Matched by the marker class, not by `[wrPopconfirm]`: the question is normally\n * BOUND (`[wrPopconfirm]=\"question\"`), and a property binding leaves no\n * attribute in the DOM at all. Same shape as `.wr-popover-trigger` and\n * `.wr-dropdown-trigger`.\n */\n static hostSelector = '.wr-popconfirm-trigger';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrPopconfirmHarnessFilters = {}): HarnessPredicate<WrPopconfirmHarness> {\n return new HarnessPredicate(WrPopconfirmHarness, options)\n .addOption('triggerText', options.triggerText, (harness, text) =>\n HarnessPredicate.stringMatches(harness.getTriggerText(), text)\n )\n .addOption('open', options.open, async (harness, open) => (await harness.isOpen()) === open)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n /** The trigger's own visible label. The question inside the panel is `getMessage()`. */\n async getTriggerText(): Promise<string> {\n return (await this.host()).text();\n }\n\n /**\n * Whether the dialog is showing.\n *\n * Read from `aria-expanded` rather than from a class, because that is the whole\n * of what the trigger tells a screen reader — the directive puts no open-state\n * class on its host at all.\n */\n async isOpen(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Whether `wrPopconfirmDisabled` has turned the question off — read from\n * `wr-popconfirm-trigger--disabled`, the one mark a disabled trigger carries.\n * The HOST's own `disabled` is another question: the directive never sets it,\n * so ask the host's harness (`WrButtonHarness.isDisabled()`).\n */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('wr-popconfirm-trigger--disabled');\n }\n\n /** Whether the trigger currently has keyboard focus — the state it is handed back on close. */\n async isTriggerFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\n }\n\n /**\n * Press the trigger to open the dialog.\n *\n * Throws when nothing opens, because the reason is always worth failing on: a\n * native `<button disabled>` trigger never receives the click at all. (A\n * DISABLED `<wr-btn>` is a jsdom blind spot in the other direction — it is kept\n * inert by `pointer-events: none`, which jsdom does not apply, so it opens here\n * and would not in a browser.)\n */\n async open(): Promise<void> {\n if (await this.isOpen()) return;\n\n await (await this.host()).click();\n if (await this.isOpen()) return;\n\n throw new Error(\n 'WrPopconfirmHarness.open(): the dialog did not open. A disabled trigger takes no click — assert ' +\n 'the disabled state instead of trying to open it.'\n );\n }\n\n /**\n * Press the trigger again to take the question back.\n *\n * This is the ONE way out that answers nothing: the directive treats a second\n * press as withdrawing the question, so `cancelled` does NOT fire — unlike\n * `cancel()`, `sendEscape()` and `clickOutside()`, which all emit it. Use this\n * when a spec needs the panel gone without recording an answer.\n */\n async close(): Promise<void> {\n if (!(await this.isOpen())) return;\n\n await (await this.host()).click();\n if (!(await this.isOpen())) return;\n\n throw new Error('WrPopconfirmHarness.close(): the dialog is still open after a second press of the trigger.');\n }\n\n /** The question being asked. */\n async getMessage(): Promise<string> {\n return (await this.inPanel('.wr-popconfirm__message')).text();\n }\n\n /**\n * The confirm button's label.\n *\n * Resolved, not given: `confirmText` falls back to the `popconfirm.confirm`\n * catalog entry, so a localized app reads its own word here and a spec that\n * asserted the English default would be asserting the wrong thing.\n */\n async getConfirmText(): Promise<string> {\n return (await this.action('confirm')).text();\n }\n\n /** The cancel button's label — `cancelText`, or the `popconfirm.cancel` catalog entry. */\n async getCancelText(): Promise<string> {\n return (await this.action('cancel')).text();\n }\n\n /**\n * Both action labels in the order they are rendered: cancel first, confirm\n * second.\n *\n * That order is deliberate and worth reading — the destructive choice is the one\n * being confirmed, so the safe one comes first and takes the initial focus.\n */\n async getActionLabels(): Promise<string[]> {\n const actions = await this.allInPanel('.wr-popconfirm__action');\n return Promise.all(actions.map(action => action.text()));\n }\n\n /**\n * The confirm button's intent colour.\n *\n * Checked against `WR_COLORS` rather than pattern-matched out of the class list:\n * `wr-btn--*` also spells the size, the shape and the icon position, so only the\n * intent list can say which of them is a colour. Today `WrButton` happens to\n * emit the colour first, so a first-match regex would agree — but that order is\n * not a contract, and the same regex on a button with no colour answers `sm`.\n * Never `null` in practice — `confirmColor` defaults to `primary` — but typed\n * for it, since the button itself allows no colour at all.\n */\n async getConfirmColor(): Promise<WrColor | null> {\n const classes = (await (await this.action('confirm')).getAttribute('class')) ?? '';\n const present = classes.split(/\\s+/);\n return WR_COLORS.find(color => present.includes(`wr-btn--${color}`)) ?? null;\n }\n\n /** Which action holds keyboard focus, by label, or `null` when focus is elsewhere. */\n async getFocusedActionLabel(): Promise<string | null> {\n for (const action of await this.allInPanel('.wr-popconfirm__action')) {\n if (await action.isFocused()) return action.text();\n }\n return null;\n }\n\n /** Answer the question: click confirm, which emits `confirmed` and closes the dialog. */\n async confirm(): Promise<void> {\n return (await this.action('confirm')).click();\n }\n\n /** Decline: click cancel, which emits `cancelled` and closes the dialog. */\n async cancel(): Promise<void> {\n return (await this.action('cancel')).click();\n }\n\n /**\n * Dismiss with Escape, which emits `cancelled`.\n *\n * Sent at the pane rather than at the focused button, because the target makes\n * no difference: the key is picked up by the overlay's keyboard dispatcher,\n * which keeps one listener on the document and routes to the topmost overlay.\n * The pane is the one element guaranteed to be there.\n */\n async sendEscape(): Promise<void> {\n return (await this.pane()).sendKeys(TestKey.ESCAPE);\n }\n\n /**\n * Dismiss by pressing outside the panel, which emits `cancelled`.\n *\n * The press lands on the overlay CONTAINER — an ancestor of the pane (the CDK\n * puts a host `<div>` between the two), and so outside the panel by the only\n * measure that matters here, since the dismissal is decided by whether the press\n * started inside the pane. With two dialogs showing it dismisses BOTH: neither\n * pane contains the container. jsdom has no layout\n * and no `document.elementFromPoint`, so a harness cannot aim at \"whatever is\n * under the pointer\"; to dismiss by pressing a specific element instead, click\n * that element's own `TestElement`.\n */\n async clickOutside(): Promise<void> {\n const id = await this.panelId();\n const container = await this.documentRootLocatorFactory().locatorFor('.cdk-overlay-container')();\n\n await container.click();\n if (!(await this.isOpen())) return;\n\n throw new Error(\n `WrPopconfirmHarness.clickOutside(): the dialog (#${id}) is still open. An outside press is judged ` +\n 'by where it started, so a press that began inside the panel does not dismiss it.'\n );\n }\n\n /**\n * The role the open panel announces — `'dialog'`.\n *\n * Worth asserting rather than assuming: the directive sets it on the OVERLAY\n * PANE, not on the panel component a consumer can see in the template.\n */\n async getRole(): Promise<string | null> {\n return (await this.pane()).getAttribute('role');\n }\n\n /**\n * The dialog's accessible name — the `ariaLabel` input, or the catalog's\n * `popconfirm.label`.\n *\n * A `role=\"dialog\"` with no name announces as a bare \"dialog\" and trips axe's\n * `aria-dialog-name`, which is why there is always one.\n */\n async getLabel(): Promise<string | null> {\n return (await this.pane()).getAttribute('aria-label');\n }\n\n /**\n * Whether the dialog claims modality.\n *\n * `false`, deliberately, and worth pinning: focus is moved into the panel but\n * NOT trapped, because Escape and an outside click both dismiss — trapping\n * would only make it harder to leave.\n */\n async isModal(): Promise<boolean> {\n return (await (await this.pane()).getAttribute('aria-modal')) === 'true';\n }\n\n /**\n * The text a screen reader reads as the dialog's DESCRIPTION, resolved through\n * `aria-describedby` the way an assistive technology would.\n *\n * This is the question, and it is the entire content of a confirmation: without\n * the link the dialog announces its name and then nothing at all.\n */\n async getDescriptionText(): Promise<string | null> {\n const id = await (await this.pane()).getAttribute('aria-describedby');\n if (!id) return null;\n\n const described = await this.documentRootLocatorFactory().locatorForOptional(`#${id}`)();\n return described ? described.text() : null;\n }\n\n /**\n * Which side of the trigger the panel is anchored to, and how it is aligned.\n *\n * Read off the pane's public modifier class — `position` is an input, so a\n * bound one never reaches the DOM, and the panel's own offset is a CDK inline\n * style that says nothing in a layout-less jsdom. The class names the side the\n * panel LANDED on, which is the one asked for unless it had no room there and\n * flipped; in jsdom, with no layout to run out of, the two are the same.\n */\n async getPosition(): Promise<WrPopconfirmPosition | null> {\n const classes = (await (await this.pane()).getAttribute('class')) ?? '';\n const modifier = /wr-popconfirm-overlay--([a-z-]+)/.exec(classes);\n return modifier ? (modifier[1] as WrPopconfirmPosition) : null;\n }\n\n /**\n * Harnesses for anything inside the panel resolve within THIS instance's dialog.\n *\n * Scoped by the published id rather than by `.wr-popconfirm`: the overlay\n * container is shared, so a class query would answer with whichever popconfirm\n * opened first.\n */\n protected override async getRootHarnessLoader(): Promise<HarnessLoader> {\n return this.documentRootLocatorFactory().harnessLoaderFor(`#${await this.panelId()}`);\n }\n\n /**\n * One of the two action buttons.\n *\n * By its own modifier class, never by index: both are a `<wr-btn size=\"sm\">`, so\n * before the modifiers existed the only thing telling them apart was document\n * order — and a harness that clicked \"the second button\" would go on passing\n * while it started confirming what a spec meant to cancel.\n */\n private async action(role: WrPopconfirmAction): Promise<TestElement> {\n return this.inPanel(`.wr-popconfirm__action--${role}`);\n }\n\n /** One element inside THIS instance's panel. */\n private async inPanel(selector: string): Promise<TestElement> {\n return this.documentRootLocatorFactory().locatorFor(`#${await this.panelId()} ${selector}`)();\n }\n\n /** Every matching element inside THIS instance's panel, in document order. */\n private async allInPanel(selector: string): Promise<TestElement[]> {\n return this.documentRootLocatorFactory().locatorForAll(`#${await this.panelId()} ${selector}`)();\n }\n\n /** This instance's overlay pane — the element carrying the dialog semantics. */\n private async pane(): Promise<TestElement> {\n return this.documentRootLocatorFactory().locatorFor(`#${await this.panelId()}`)();\n }\n\n /** The id the trigger publishes for its dialog, which exists only while the dialog does. */\n private async panelId(): Promise<string> {\n const id = await (await this.host()).getAttribute('aria-controls');\n\n if (!id) {\n throw new Error(\n 'WrPopconfirmHarness: nothing is showing. The trigger publishes its dialog id as aria-controls ' +\n 'only while the dialog is open — call open() first.'\n );\n }\n return id;\n }\n}\n"],"mappings":";;;;;;;;AAuDA,IAAa,sBAAb,MAAa,4BAA4B,iCAAgC;CASvE,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAsC,CAAA,GAAE;EAClD,OAAO,IAAI,iBAAiB,qBAAqB,OAAO,CAAC,CACtD,UAAU,eAAe,QAAQ,cAAc,SAAS,SACvD,iBAAiB,cAAc,QAAQ,eAAc,GAAI,IAAI,CAAC,CAC/D,CACA,UAAU,QAAQ,QAAQ,MAAM,OAAO,SAAS,SAAU,MAAM,QAAQ,OAAM,MAAQ,IAAI,CAAC,CAC3F,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ;CACnH;CAGA,MAAM,iBAAc;EAClB,QAAQ,MAAM,KAA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KAAK,OAAO;EAChE,OAAO,WAAY,SAAS,KAA8B;CAC5D;CASmB,MAAM,uBAAoB;EAC3C,OAAO,KAAK,2BAA0B,CAAE,CAAC,iBAAiB,IAAI,MAAM,KAAK,QAAO,GAAI;CACtF;CAUQ,MAAM,OAAO,MAAwB;EAC3C,OAAO,KAAK,QAAQ,2BAA2B,MAAM;CACvD;CAGQ,MAAM,QAAQ,UAAgB;EACpC,OAAO,KAAK,2BAA0B,CAAE,CAAC,WAAW,IAAI,MAAM,KAAK,QAAO,EAAE,GAAI,UAAU,CAAC,CAAA;CAC7F;CAGQ,MAAM,WAAW,UAAgB;EACvC,OAAO,KAAK,2BAA0B,CAAE,CAAC,cAAc,IAAI,MAAM,KAAK,QAAO,EAAE,GAAI,UAAU,CAAC,CAAA;CAChG;CAGQ,MAAM,OAAI;EAChB,OAAO,KAAK,2BAA0B,CAAE,CAAC,WAAW,IAAI,MAAM,KAAK,QAAO,GAAI,CAAC,CAAA;CACjF;CAGQ,MAAM,UAAO;EACnB,MAAM,KAAK,OAAO,MAAM,KAAK,KAAI,EAAA,CAAI,aAAa,eAAe;EAEjE,IAAI,CAAC,IACH,MAAM,IAAI,MACR,kJACsD;EAG1D,OAAO;CACT"}
1
+ {"version":3,"file":"ngwr-popconfirm-testing.mjs","names":[],"sources":["../../../projects/lib/popconfirm/testing/wr-popconfirm-harness.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 {\n ContentContainerComponentHarness,\n type HarnessLoader,\n HarnessPredicate,\n TestKey,\n type TestElement,\n} from '@angular/cdk/testing';\n\nimport type { WrPopconfirmPosition } from 'ngwr/popconfirm';\nimport { WR_COLORS, type WrColor } from 'ngwr/theme';\n\nimport type { WrPopconfirmHarnessFilters } from './types';\n\n/** The two answers a popconfirm offers, which are also its two action modifiers. */\ntype WrPopconfirmAction = 'confirm' | 'cancel';\n\n/**\n * Test harness for `[wrPopconfirm]` — the \"are you sure?\" dialog anchored to its\n * trigger.\n *\n * The panel is NOT inside the trigger: it is a component portal in the overlay\n * container, a sibling of the whole app. So everything about it is reached\n * through the document root, scoped by the `aria-controls` id the trigger\n * publishes while the dialog is showing — which is what keeps two popconfirms\n * from reading each other's question, and why every panel reader throws while the\n * dialog is shut: there is no element to answer about.\n *\n * **The two actions are told apart by their own modifiers**, never by position.\n * `.wr-popconfirm__action--cancel` and `--confirm` are what `cancel()` and\n * `confirm()` click, so a template that ever reorders the pair cannot silently\n * turn a spec's \"cancel\" into a delete.\n *\n * Being a CONTENT CONTAINER means a consumer's own harnesses resolve INSIDE this\n * instance's panel — `popconfirm.getHarness(WrButtonHarness…)` reaches the\n * buttons without the spec ever naming the overlay.\n *\n * @example\n * ```ts\n * const loader = TestbedHarnessEnvironment.loader(fixture);\n * const remove = await loader.getHarness(WrPopconfirmHarness.with({ triggerText: 'Delete' }));\n *\n * await remove.open();\n * expect(await remove.getMessage()).toBe('Delete this item?');\n * await remove.confirm();\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrPopconfirmHarness extends ContentContainerComponentHarness {\n /**\n * The directive's host — whatever element the consumer put `[wrPopconfirm]` on.\n *\n * Matched by the marker class, not by `[wrPopconfirm]`: the question is normally\n * BOUND (`[wrPopconfirm]=\"question\"`), and a property binding leaves no\n * attribute in the DOM at all. Same shape as `.wr-popover-trigger` and\n * `.wr-dropdown-trigger`.\n */\n static hostSelector = '.wr-popconfirm-trigger';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrPopconfirmHarnessFilters = {}): HarnessPredicate<WrPopconfirmHarness> {\n return new HarnessPredicate(WrPopconfirmHarness, options)\n .addOption('triggerText', options.triggerText, (harness, text) =>\n HarnessPredicate.stringMatches(harness.getTriggerText(), text)\n )\n .addOption('open', options.open, async (harness, open) => (await harness.isOpen()) === open)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n /** The trigger's own visible label. The question inside the panel is `getMessage()`. */\n async getTriggerText(): Promise<string> {\n return (await this.host()).text();\n }\n\n /**\n * Whether the dialog is showing.\n *\n * Read from `aria-expanded` rather than from a class, because that is the whole\n * of what the trigger tells a screen reader — the directive puts no open-state\n * class on its host at all.\n */\n async isOpen(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Whether `wrPopconfirmDisabled` has turned the question off — read from\n * `wr-popconfirm-trigger--disabled`, the one mark a disabled trigger carries.\n * The HOST's own `disabled` is another question: the directive never sets it,\n * so ask the host's harness (`WrButtonHarness.isDisabled()`).\n */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('wr-popconfirm-trigger--disabled');\n }\n\n /** Whether the trigger currently has keyboard focus — the state it is handed back on close. */\n async isTriggerFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\n }\n\n /**\n * Press the trigger to open the dialog.\n *\n * Throws when nothing opens, because the reason is always worth failing on: a\n * native `<button disabled>` trigger never receives the click at all. (A\n * DISABLED `<wr-btn>` is a jsdom blind spot in the other direction — it is kept\n * inert by `pointer-events: none`, which jsdom does not apply, so it opens here\n * and would not in a browser.)\n */\n async open(): Promise<void> {\n if (await this.isOpen()) return;\n\n await (await this.host()).click();\n if (await this.isOpen()) return;\n\n throw new Error(\n 'WrPopconfirmHarness.open(): the dialog did not open. A disabled trigger takes no click — assert ' +\n 'the disabled state instead of trying to open it.'\n );\n }\n\n /**\n * Press the trigger again to take the question back.\n *\n * This is the ONE way out that answers nothing: the directive treats a second\n * press as withdrawing the question, so `cancelled` does NOT fire — unlike\n * `cancel()`, `sendEscape()` and `clickOutside()`, which all emit it. Use this\n * when a spec needs the panel gone without recording an answer.\n */\n async close(): Promise<void> {\n if (!(await this.isOpen())) return;\n\n await (await this.host()).click();\n if (!(await this.isOpen())) return;\n\n throw new Error('WrPopconfirmHarness.close(): the dialog is still open after a second press of the trigger.');\n }\n\n /** The question being asked. */\n async getMessage(): Promise<string> {\n return (await this.inPanel('.wr-popconfirm__message')).text();\n }\n\n /**\n * The confirm button's label.\n *\n * Resolved, not given: `confirmText` falls back to the `popconfirm.confirm`\n * catalog entry, so a localized app reads its own word here and a spec that\n * asserted the English default would be asserting the wrong thing.\n */\n async getConfirmText(): Promise<string> {\n return (await this.action('confirm')).text();\n }\n\n /** The cancel button's label — `cancelText`, or the `popconfirm.cancel` catalog entry. */\n async getCancelText(): Promise<string> {\n return (await this.action('cancel')).text();\n }\n\n /**\n * Both action labels in the order they are rendered: cancel first, confirm\n * second.\n *\n * That order is deliberate and worth reading — the destructive choice is the one\n * being confirmed, so the safe one comes first and takes the initial focus.\n */\n async getActionLabels(): Promise<string[]> {\n const actions = await this.allInPanel('.wr-popconfirm__action');\n return Promise.all(actions.map(action => action.text()));\n }\n\n /**\n * The confirm button's intent colour.\n *\n * Checked against `WR_COLORS` rather than pattern-matched out of the class list:\n * `wr-btn--*` also spells the size, the shape and the icon position, so only the\n * intent list can say which of them is a colour. Today `WrButton` happens to\n * emit the colour first, so a first-match regex would agree — but that order is\n * not a contract, and the same regex on a button with no colour answers `sm`.\n * Never `null` in practice — `confirmColor` defaults to `primary` — but typed\n * for it, since the button itself allows no colour at all.\n */\n async getConfirmColor(): Promise<WrColor | null> {\n const classes = (await (await this.action('confirm')).getAttribute('class')) ?? '';\n const present = classes.split(/\\s+/);\n return WR_COLORS.find(color => present.includes(`wr-btn--${color}`)) ?? null;\n }\n\n /**\n * Which action holds keyboard focus, by label, or `null` when focus is\n * elsewhere: on the panel itself right after it opens, unless `wrPopconfirmAutoFocus` is\n * `'first-tabbable'`.\n */\n async getFocusedActionLabel(): Promise<string | null> {\n for (const action of await this.allInPanel('.wr-popconfirm__action')) {\n if (await action.isFocused()) return action.text();\n }\n return null;\n }\n\n /** Answer the question: click confirm, which emits `confirmed` and closes the dialog. */\n async confirm(): Promise<void> {\n return (await this.action('confirm')).click();\n }\n\n /** Whether the panel itself holds focus, as it does right after it opens by default. */\n async isPanelFocused(): Promise<boolean> {\n return (await this.pane()).isFocused();\n }\n\n /** Decline: click cancel, which emits `cancelled` and closes the dialog. */\n async cancel(): Promise<void> {\n return (await this.action('cancel')).click();\n }\n\n /**\n * Dismiss with Escape, which emits `cancelled`.\n *\n * Sent at the pane rather than at the focused button, because the target makes\n * no difference: the key is picked up by the overlay's keyboard dispatcher,\n * which keeps one listener on the document and routes to the topmost overlay.\n * The panel inside the pane is the one element guaranteed to be there, and it\n * is not the pane itself: `sendKeys` focuses its target first, and the pane\n * takes focus, so typing at one of two open dialogs would dismiss the other by\n * moving focus out of it.\n */\n async sendEscape(): Promise<void> {\n return (await this.inPanel('.wr-popconfirm')).sendKeys(TestKey.ESCAPE);\n }\n\n /**\n * Dismiss by pressing outside the panel, which emits `cancelled`.\n *\n * The press lands on the overlay CONTAINER — an ancestor of the pane (the CDK\n * puts a host `<div>` between the two), and so outside the panel by the only\n * measure that matters here, since the dismissal is decided by whether the press\n * started inside the pane. With two dialogs showing it dismisses BOTH: neither\n * pane contains the container. jsdom has no layout\n * and no `document.elementFromPoint`, so a harness cannot aim at \"whatever is\n * under the pointer\"; to dismiss by pressing a specific element instead, click\n * that element's own `TestElement`.\n */\n async clickOutside(): Promise<void> {\n const id = await this.panelId();\n const container = await this.documentRootLocatorFactory().locatorFor('.cdk-overlay-container')();\n\n await container.click();\n if (!(await this.isOpen())) return;\n\n throw new Error(\n `WrPopconfirmHarness.clickOutside(): the dialog (#${id}) is still open. An outside press is judged ` +\n 'by where it started, so a press that began inside the panel does not dismiss it.'\n );\n }\n\n /**\n * The role the open panel announces — `'dialog'`.\n *\n * Worth asserting rather than assuming: the directive sets it on the OVERLAY\n * PANE, not on the panel component a consumer can see in the template.\n */\n async getRole(): Promise<string | null> {\n return (await this.pane()).getAttribute('role');\n }\n\n /**\n * The dialog's accessible name — the `ariaLabel` input, or the catalog's\n * `popconfirm.label`.\n *\n * A `role=\"dialog\"` with no name announces as a bare \"dialog\" and trips axe's\n * `aria-dialog-name`, which is why there is always one.\n */\n async getLabel(): Promise<string | null> {\n return (await this.pane()).getAttribute('aria-label');\n }\n\n /**\n * Whether the dialog claims modality.\n *\n * `false`, deliberately, and worth pinning: focus is moved into the panel but\n * NOT trapped, because Escape and an outside click both dismiss — trapping\n * would only make it harder to leave.\n */\n async isModal(): Promise<boolean> {\n return (await (await this.pane()).getAttribute('aria-modal')) === 'true';\n }\n\n /**\n * The text a screen reader reads as the dialog's DESCRIPTION, resolved through\n * `aria-describedby` the way an assistive technology would.\n *\n * This is the question, and it is the entire content of a confirmation: without\n * the link the dialog announces its name and then nothing at all.\n */\n async getDescriptionText(): Promise<string | null> {\n const id = await (await this.pane()).getAttribute('aria-describedby');\n if (!id) return null;\n\n const described = await this.documentRootLocatorFactory().locatorForOptional(`#${id}`)();\n return described ? described.text() : null;\n }\n\n /**\n * Which side of the trigger the panel is anchored to, and how it is aligned.\n *\n * Read off the pane's public modifier class — `position` is an input, so a\n * bound one never reaches the DOM, and the panel's own offset is a CDK inline\n * style that says nothing in a layout-less jsdom. The class names the side the\n * panel LANDED on, which is the one asked for unless it had no room there and\n * flipped; in jsdom, with no layout to run out of, the two are the same.\n */\n async getPosition(): Promise<WrPopconfirmPosition | null> {\n const classes = (await (await this.pane()).getAttribute('class')) ?? '';\n const modifier = /wr-popconfirm-overlay--([a-z-]+)/.exec(classes);\n return modifier ? (modifier[1] as WrPopconfirmPosition) : null;\n }\n\n /**\n * Harnesses for anything inside the panel resolve within THIS instance's dialog.\n *\n * Scoped by the published id rather than by `.wr-popconfirm`: the overlay\n * container is shared, so a class query would answer with whichever popconfirm\n * opened first.\n */\n protected override async getRootHarnessLoader(): Promise<HarnessLoader> {\n return this.documentRootLocatorFactory().harnessLoaderFor(`#${await this.panelId()}`);\n }\n\n /**\n * One of the two action buttons.\n *\n * By its own modifier class, never by index: both are a `<wr-btn size=\"sm\">`, so\n * before the modifiers existed the only thing telling them apart was document\n * order — and a harness that clicked \"the second button\" would go on passing\n * while it started confirming what a spec meant to cancel.\n */\n private async action(role: WrPopconfirmAction): Promise<TestElement> {\n return this.inPanel(`.wr-popconfirm__action--${role}`);\n }\n\n /** One element inside THIS instance's panel. */\n private async inPanel(selector: string): Promise<TestElement> {\n return this.documentRootLocatorFactory().locatorFor(`#${await this.panelId()} ${selector}`)();\n }\n\n /** Every matching element inside THIS instance's panel, in document order. */\n private async allInPanel(selector: string): Promise<TestElement[]> {\n return this.documentRootLocatorFactory().locatorForAll(`#${await this.panelId()} ${selector}`)();\n }\n\n /** This instance's overlay pane — the element carrying the dialog semantics. */\n private async pane(): Promise<TestElement> {\n return this.documentRootLocatorFactory().locatorFor(`#${await this.panelId()}`)();\n }\n\n /** The id the trigger publishes for its dialog, which exists only while the dialog does. */\n private async panelId(): Promise<string> {\n const id = await (await this.host()).getAttribute('aria-controls');\n\n if (!id) {\n throw new Error(\n 'WrPopconfirmHarness: nothing is showing. The trigger publishes its dialog id as aria-controls ' +\n 'only while the dialog is open — call open() first.'\n );\n }\n return id;\n }\n}\n"],"mappings":";;;;;;;;AAuDA,IAAa,sBAAb,MAAa,4BAA4B,iCAAgC;CASvE,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAsC,CAAA,GAAE;EAClD,OAAO,IAAI,iBAAiB,qBAAqB,OAAO,CAAC,CACtD,UAAU,eAAe,QAAQ,cAAc,SAAS,SACvD,iBAAiB,cAAc,QAAQ,eAAc,GAAI,IAAI,CAAC,CAC/D,CACA,UAAU,QAAQ,QAAQ,MAAM,OAAO,SAAS,SAAU,MAAM,QAAQ,OAAM,MAAQ,IAAI,CAAC,CAC3F,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ;CACnH;CAGA,MAAM,iBAAc;EAClB,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,KAAI;CACjC;CASA,MAAM,SAAM;EACV,OAAQ,OAAO,MAAM,KAAK,KAAI,EAAA,CAAI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EAChE,OAAO,WAAY,SAAS,KAA8B;CAC5D;CASmB,MAAM,uBAAoB;EAC3C,OAAO,KAAK,2BAA0B,CAAE,CAAC,iBAAiB,IAAI,MAAM,KAAK,QAAO,GAAI;CACtF;CAUQ,MAAM,OAAO,MAAwB;EAC3C,OAAO,KAAK,QAAQ,2BAA2B,MAAM;CACvD;CAGQ,MAAM,QAAQ,UAAgB;EACpC,OAAO,KAAK,2BAA0B,CAAE,CAAC,WAAW,IAAI,MAAM,KAAK,QAAO,EAAE,GAAI,UAAU,CAAC,CAAA;CAC7F;CAGQ,MAAM,WAAW,UAAgB;EACvC,OAAO,KAAK,2BAA0B,CAAE,CAAC,cAAc,IAAI,MAAM,KAAK,QAAO,EAAE,GAAI,UAAU,CAAC,CAAA;CAChG;CAGQ,MAAM,OAAI;EAChB,OAAO,KAAK,2BAA0B,CAAE,CAAC,WAAW,IAAI,MAAM,KAAK,QAAO,GAAI,CAAC,CAAA;CACjF;CAGQ,MAAM,UAAO;EACnB,MAAM,KAAK,OAAO,MAAM,KAAK,KAAI,EAAA,CAAI,aAAa,eAAe;EAEjE,IAAI,CAAC,IACH,MAAM,IAAI,MACR,kJACsD;EAG1D,OAAO;CACT"}
@@ -8,8 +8,8 @@ import { WrButton } from "ngwr/button";
8
8
  import { ScrollStrategyOptions } from "@angular/cdk/overlay";
9
9
  import { ComponentPortal } from "@angular/cdk/portal";
10
10
  import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
11
- import { WR_OVERLAY, WrOutsideClick, wrAnchoredPositions, wrFollowDirection, wrMirrorOffsets } from "ngwr/overlay";
12
- import { FocusMonitor } from "@angular/cdk/a11y";
11
+ import { WR_OVERLAY, WrOutsideClick, wrAnchoredPositions, wrFocusOverlay, wrFollowDirection, wrMirrorOffsets } from "ngwr/overlay";
12
+ import { FocusMonitor, FocusTrapFactory } from "@angular/cdk/a11y";
13
13
  /**
14
14
  * @license
15
15
  *
@@ -206,6 +206,10 @@ var WrPopconfirm = class WrPopconfirm {
206
206
  resolvedAriaLabel = useI18nText(this.ariaLabel, "popconfirm.label", "Confirm action");
207
207
  confirmColor = input("primary", ...ngDevMode ? [{ debugName: "confirmColor" }] : /* istanbul ignore next */ []);
208
208
  panelClass = input(null, ...ngDevMode ? [{ debugName: "panelClass" }] : /* istanbul ignore next */ []);
209
+ autoFocus = input("dialog", {
210
+ ...ngDevMode ? { debugName: "autoFocus" } : /* istanbul ignore next */ {},
211
+ alias: "wrPopconfirmAutoFocus"
212
+ });
209
213
  disabled = input(false, {
210
214
  ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
211
215
  alias: "wrPopconfirmDisabled",
@@ -215,6 +219,7 @@ var WrPopconfirm = class WrPopconfirm {
215
219
  cancelled = output();
216
220
  host = inject(ElementRef);
217
221
  focusMonitor = inject(FocusMonitor);
222
+ focusTraps = inject(FocusTrapFactory);
218
223
  overlay = inject(WR_OVERLAY);
219
224
  dir = inject(Directionality, { optional: true });
220
225
  outsideClick = inject(WrOutsideClick);
@@ -225,6 +230,7 @@ var WrPopconfirm = class WrPopconfirm {
225
230
  openState = signal(false, ...ngDevMode ? [{ debugName: "openState" }] : /* istanbul ignore next */ []);
226
231
  isOpen = this.openState.asReadonly();
227
232
  overlayRef = null;
233
+ finder = null;
228
234
  uid = ++popconfirmUid;
229
235
  panelId = `wr-popconfirm-${this.uid}`;
230
236
  messageId = `wr-popconfirm-message-${this.uid}`;
@@ -257,6 +263,7 @@ var WrPopconfirm = class WrPopconfirm {
257
263
  pane.setAttribute("aria-modal", "false");
258
264
  pane.setAttribute("aria-label", this.resolvedAriaLabel());
259
265
  pane.setAttribute("aria-describedby", this.messageId);
266
+ pane.tabIndex = -1;
260
267
  const portal = new ComponentPortal(WrPopconfirmPanel, this.vcr);
261
268
  const ref = this.overlayRef.attach(portal);
262
269
  ref.setInput("message", this.message());
@@ -265,7 +272,8 @@ var WrPopconfirm = class WrPopconfirm {
265
272
  ref.setInput("cancelText", this.resolvedCancel());
266
273
  ref.setInput("confirmColor", this.confirmColor());
267
274
  ref.changeDetectorRef.detectChanges();
268
- pane.querySelector(".wr-popconfirm__actions wr-btn")?.focus();
275
+ this.finder = this.focusTraps.create(pane, true);
276
+ wrFocusOverlay(pane, this.finder, this.autoFocus(), this.injector);
269
277
  pane.addEventListener("keydown", this.onPaneKeydown);
270
278
  pane.addEventListener("focusout", this.onPaneFocusOut);
271
279
  this.openState.set(true);
@@ -299,6 +307,8 @@ var WrPopconfirm = class WrPopconfirm {
299
307
  const returnFocus = pane.contains(document.activeElement);
300
308
  pane.removeEventListener("keydown", this.onPaneKeydown);
301
309
  pane.removeEventListener("focusout", this.onPaneFocusOut);
310
+ this.finder?.destroy();
311
+ this.finder = null;
302
312
  this.overlayRef.dispose();
303
313
  this.overlayRef = null;
304
314
  this.openState.set(false);
@@ -310,12 +320,19 @@ var WrPopconfirm = class WrPopconfirm {
310
320
  const stops = [...pane.querySelectorAll(".wr-popconfirm__action")];
311
321
  const active = document.activeElement;
312
322
  if (event.shiftKey) {
313
- if (active !== stops[0]) return;
323
+ if (active !== pane && active !== stops[0]) return;
314
324
  event.preventDefault();
315
325
  } else if (active !== stops.at(-1)) return;
316
326
  wrRestoreFocus(this.host.nativeElement, this.focusMonitor);
317
327
  this.dismiss();
318
328
  };
329
+ onTriggerKeydown(event) {
330
+ const pane = this.overlayRef?.overlayElement;
331
+ if (!pane || event.key !== "Tab" || event.shiftKey || event.defaultPrevented) return;
332
+ if (event.target !== this.host.nativeElement) return;
333
+ event.preventDefault();
334
+ (pane.querySelector(".wr-popconfirm__action") ?? pane).focus();
335
+ }
319
336
  onPaneFocusOut = (event) => {
320
337
  const next = event.relatedTarget;
321
338
  if (!next || this.holdsFocus(next)) return;
@@ -395,6 +412,13 @@ var WrPopconfirm = class WrPopconfirm {
395
412
  isRequired: false,
396
413
  transformFunction: null
397
414
  },
415
+ autoFocus: {
416
+ classPropertyName: "autoFocus",
417
+ publicName: "wrPopconfirmAutoFocus",
418
+ isSignal: true,
419
+ isRequired: false,
420
+ transformFunction: null
421
+ },
398
422
  disabled: {
399
423
  classPropertyName: "disabled",
400
424
  publicName: "wrPopconfirmDisabled",
@@ -408,7 +432,10 @@ var WrPopconfirm = class WrPopconfirm {
408
432
  cancelled: "cancelled"
409
433
  },
410
434
  host: {
411
- listeners: { "click": "toggle($event)" },
435
+ listeners: {
436
+ "click": "toggle($event)",
437
+ "keydown": "onTriggerKeydown($event)"
438
+ },
412
439
  properties: {
413
440
  "class.wr-popconfirm-trigger--disabled": "disabled()",
414
441
  "attr.aria-haspopup": "disabled() ? null : \"dialog\"",
@@ -435,6 +462,7 @@ i0.ɵɵngDeclareClassMetadata({
435
462
  class: "wr-popconfirm-trigger",
436
463
  "[class.wr-popconfirm-trigger--disabled]": "disabled()",
437
464
  "(click)": "toggle($event)",
465
+ "(keydown)": "onTriggerKeydown($event)",
438
466
  "[attr.aria-haspopup]": "disabled() ? null : \"dialog\"",
439
467
  "[attr.aria-expanded]": "disabled() ? null : isOpen()",
440
468
  "[attr.aria-controls]": "isOpen() ? panelId : null"
@@ -499,6 +527,14 @@ i0.ɵɵngDeclareClassMetadata({
499
527
  required: false
500
528
  }]
501
529
  }],
530
+ autoFocus: [{
531
+ type: i0.Input,
532
+ args: [{
533
+ isSignal: true,
534
+ alias: "wrPopconfirmAutoFocus",
535
+ required: false
536
+ }]
537
+ }],
502
538
  disabled: [{
503
539
  type: i0.Input,
504
540
  args: [{