ngwr 16.3.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 (295) hide show
  1. package/carousel/styles/_index.scss +53 -1
  2. package/charts/bar-chart/styles/_index.scss +494 -305
  3. package/charts/boxplot-chart/styles/_index.scss +114 -48
  4. package/charts/bullet-chart/styles/_index.scss +113 -42
  5. package/charts/calendar-heatmap/styles/_index.scss +111 -20
  6. package/charts/candlestick-chart/styles/_index.scss +61 -26
  7. package/charts/chart-legend/styles/_index.scss +119 -1
  8. package/charts/core/styles/_index.scss +201 -5
  9. package/charts/donut-chart/styles/_index.scss +76 -21
  10. package/charts/funnel-chart/styles/_index.scss +66 -38
  11. package/charts/gauge/styles/_index.scss +12 -1
  12. package/charts/heatmap-chart/styles/_index.scss +90 -53
  13. package/charts/line-chart/styles/_index.scss +143 -139
  14. package/charts/meter-group/styles/_index.scss +87 -25
  15. package/charts/radar-chart/styles/_index.scss +82 -40
  16. package/charts/scatter-chart/styles/_index.scss +117 -44
  17. package/charts/sparkline/styles/_index.scss +7 -1
  18. package/charts/treemap-chart/styles/_index.scss +94 -42
  19. package/charts/waterfall-chart/styles/_index.scss +150 -87
  20. package/color-picker/styles/_index.scss +7 -3
  21. package/copy-value/styles/_index.scss +21 -2
  22. package/date-stamp/styles/_index.scss +2 -1
  23. package/dialog/styles/_index.scss +6 -0
  24. package/drawer/styles/_index.scss +5 -1
  25. package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
  26. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  27. package/fesm2022/ngwr-carousel-testing.mjs +27 -1
  28. package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
  29. package/fesm2022/ngwr-carousel.mjs +86 -4
  30. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  31. package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
  32. package/fesm2022/ngwr-cascader.mjs +56 -25
  33. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  34. package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
  35. package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
  36. package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
  37. package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
  38. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
  39. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
  40. package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
  41. package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
  42. package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
  43. package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
  44. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
  45. package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
  46. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
  47. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
  48. package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
  49. package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
  50. package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
  51. package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
  52. package/fesm2022/ngwr-charts-core.mjs +299 -18
  53. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  54. package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
  55. package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
  56. package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
  57. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
  58. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
  59. package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
  60. package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
  61. package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
  62. package/fesm2022/ngwr-charts-gauge.mjs +98 -12
  63. package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
  64. package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
  65. package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
  66. package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
  67. package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
  68. package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
  69. package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
  70. package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
  71. package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
  72. package/fesm2022/ngwr-charts-meter-group.mjs +223 -31
  73. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  74. package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
  75. package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
  76. package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
  77. package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
  78. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
  79. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
  80. package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
  81. package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
  82. package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
  83. package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
  84. package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
  85. package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
  86. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
  87. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
  88. package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
  89. package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
  90. package/fesm2022/ngwr-color-picker.mjs +44 -4
  91. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  92. package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
  93. package/fesm2022/ngwr-context-menu.mjs +60 -17
  94. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  95. package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
  96. package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
  97. package/fesm2022/ngwr-copy-value.mjs +38 -2
  98. package/fesm2022/ngwr-copy-value.mjs.map +1 -1
  99. package/fesm2022/ngwr-date-picker.mjs +56 -8
  100. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  101. package/fesm2022/ngwr-dialog.mjs +13 -5
  102. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  103. package/fesm2022/ngwr-drawer.mjs +19 -3
  104. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  105. package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
  106. package/fesm2022/ngwr-dropdown.mjs +49 -6
  107. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  108. package/fesm2022/ngwr-editor.mjs +1 -0
  109. package/fesm2022/ngwr-editor.mjs.map +1 -1
  110. package/fesm2022/ngwr-file-upload.mjs +7 -3
  111. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  112. package/fesm2022/ngwr-graph-testing.mjs +27 -0
  113. package/fesm2022/ngwr-graph-testing.mjs.map +1 -1
  114. package/fesm2022/ngwr-graph.mjs +643 -14
  115. package/fesm2022/ngwr-graph.mjs.map +1 -1
  116. package/fesm2022/ngwr-i18n-ar.mjs +13 -4
  117. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  118. package/fesm2022/ngwr-i18n-cs.mjs +13 -4
  119. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  120. package/fesm2022/ngwr-i18n-de.mjs +13 -4
  121. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  122. package/fesm2022/ngwr-i18n-en.mjs +13 -4
  123. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  124. package/fesm2022/ngwr-i18n-es.mjs +13 -4
  125. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  126. package/fesm2022/ngwr-i18n-fr.mjs +13 -4
  127. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  128. package/fesm2022/ngwr-i18n-he.mjs +13 -4
  129. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  130. package/fesm2022/ngwr-i18n-hi.mjs +13 -4
  131. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  132. package/fesm2022/ngwr-i18n-id.mjs +13 -4
  133. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  134. package/fesm2022/ngwr-i18n-it.mjs +13 -4
  135. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  136. package/fesm2022/ngwr-i18n-ja.mjs +13 -4
  137. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  138. package/fesm2022/ngwr-i18n-ko.mjs +13 -4
  139. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  140. package/fesm2022/ngwr-i18n-nl.mjs +13 -4
  141. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  142. package/fesm2022/ngwr-i18n-pl.mjs +13 -4
  143. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  144. package/fesm2022/ngwr-i18n-pt.mjs +13 -4
  145. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  146. package/fesm2022/ngwr-i18n-ru.mjs +13 -4
  147. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  148. package/fesm2022/ngwr-i18n-sv.mjs +13 -4
  149. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  150. package/fesm2022/ngwr-i18n-tr.mjs +13 -4
  151. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  152. package/fesm2022/ngwr-i18n-uk.mjs +13 -4
  153. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  154. package/fesm2022/ngwr-i18n-vi.mjs +13 -4
  155. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  156. package/fesm2022/ngwr-i18n-zh-tw.mjs +13 -4
  157. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  158. package/fesm2022/ngwr-i18n-zh.mjs +13 -4
  159. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  160. package/fesm2022/ngwr-lightbox.mjs +22 -5
  161. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  162. package/fesm2022/ngwr-list.mjs +2 -2
  163. package/fesm2022/ngwr-list.mjs.map +1 -1
  164. package/fesm2022/ngwr-overlay.mjs +21 -2
  165. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  166. package/fesm2022/ngwr-pagination.mjs +1 -0
  167. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  168. package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
  169. package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
  170. package/fesm2022/ngwr-popconfirm.mjs +41 -5
  171. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  172. package/fesm2022/ngwr-popover.mjs +67 -12
  173. package/fesm2022/ngwr-popover.mjs.map +1 -1
  174. package/fesm2022/ngwr-schema-form.mjs +3 -0
  175. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  176. package/fesm2022/ngwr-select.mjs +100 -3
  177. package/fesm2022/ngwr-select.mjs.map +1 -1
  178. package/fesm2022/ngwr-sortable-list.mjs +2 -2
  179. package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
  180. package/fesm2022/ngwr-table-testing.mjs +71 -3
  181. package/fesm2022/ngwr-table-testing.mjs.map +1 -1
  182. package/fesm2022/ngwr-table.mjs +173 -11
  183. package/fesm2022/ngwr-table.mjs.map +1 -1
  184. package/fesm2022/ngwr-tour-testing.mjs +13 -1
  185. package/fesm2022/ngwr-tour-testing.mjs.map +1 -1
  186. package/fesm2022/ngwr-tour.mjs +25 -16
  187. package/fesm2022/ngwr-tour.mjs.map +1 -1
  188. package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
  189. package/fesm2022/ngwr-tree.mjs +52 -8
  190. package/fesm2022/ngwr-tree.mjs.map +1 -1
  191. package/fesm2022/ngwr-utils.mjs +64 -1
  192. package/fesm2022/ngwr-utils.mjs.map +1 -1
  193. package/fesm2022/ngwr-version.mjs +1 -1
  194. package/fesm2022/ngwr-version.mjs.map +1 -1
  195. package/fesm2022/ngwr-window.mjs +16 -9
  196. package/fesm2022/ngwr-window.mjs.map +1 -1
  197. package/graph/styles/_index.scss +87 -0
  198. package/i18n/ar.json +13 -4
  199. package/i18n/cs.json +13 -4
  200. package/i18n/de.json +13 -4
  201. package/i18n/en.json +13 -4
  202. package/i18n/es.json +13 -4
  203. package/i18n/fr.json +13 -4
  204. package/i18n/he.json +13 -4
  205. package/i18n/hi.json +13 -4
  206. package/i18n/id.json +13 -4
  207. package/i18n/it.json +13 -4
  208. package/i18n/ja.json +13 -4
  209. package/i18n/ko.json +13 -4
  210. package/i18n/nl.json +13 -4
  211. package/i18n/pl.json +13 -4
  212. package/i18n/pt.json +13 -4
  213. package/i18n/ru.json +13 -4
  214. package/i18n/sv.json +13 -4
  215. package/i18n/tr.json +13 -4
  216. package/i18n/uk.json +13 -4
  217. package/i18n/vi.json +13 -4
  218. package/i18n/zh-TW.json +13 -4
  219. package/i18n/zh.json +13 -4
  220. package/llms-full.txt +12 -12
  221. package/llms.txt +64 -27
  222. package/package.json +1 -1
  223. package/popconfirm/styles/_index.scss +6 -0
  224. package/popover/styles/_index.scss +24 -13
  225. package/schematics/collection.json +5 -0
  226. package/schematics/eject/index.js +158 -0
  227. package/schematics/eject/schema.js +8 -0
  228. package/schematics/eject/schema.json +24 -0
  229. package/schematics/eject/source.js +295 -0
  230. package/schematics/use/symbol-map.json +2 -0
  231. package/select/styles/_index.scss +13 -0
  232. package/skills/ngwr/SKILL.md +30 -3
  233. package/skills/ngwr/references/catalog.md +2 -2
  234. package/table/styles/_index.scss +24 -0
  235. package/theme/styles/_focus.scss +11 -1
  236. package/tour/styles/_index.scss +6 -0
  237. package/types/ngwr-carousel-testing.d.ts +29 -6
  238. package/types/ngwr-carousel.d.ts +52 -5
  239. package/types/ngwr-cascader-testing.d.ts +4 -3
  240. package/types/ngwr-cascader.d.ts +29 -7
  241. package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
  242. package/types/ngwr-charts-bar-chart.d.ts +220 -48
  243. package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
  244. package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
  245. package/types/ngwr-charts-bullet-chart.d.ts +72 -12
  246. package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
  247. package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
  248. package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
  249. package/types/ngwr-charts-chart-legend.d.ts +142 -5
  250. package/types/ngwr-charts-core.d.ts +259 -21
  251. package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
  252. package/types/ngwr-charts-donut-chart.d.ts +124 -16
  253. package/types/ngwr-charts-funnel-chart.d.ts +62 -6
  254. package/types/ngwr-charts-gauge-testing.d.ts +5 -1
  255. package/types/ngwr-charts-gauge.d.ts +72 -10
  256. package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
  257. package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
  258. package/types/ngwr-charts-line-chart.d.ts +215 -86
  259. package/types/ngwr-charts-meter-group.d.ts +96 -7
  260. package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
  261. package/types/ngwr-charts-radar-chart.d.ts +148 -28
  262. package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
  263. package/types/ngwr-charts-scatter-chart.d.ts +188 -18
  264. package/types/ngwr-charts-sparkline.d.ts +26 -4
  265. package/types/ngwr-charts-treemap-chart.d.ts +121 -23
  266. package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
  267. package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
  268. package/types/ngwr-color-picker.d.ts +27 -0
  269. package/types/ngwr-context-menu-testing.d.ts +10 -9
  270. package/types/ngwr-context-menu.d.ts +19 -0
  271. package/types/ngwr-copy-value.d.ts +8 -0
  272. package/types/ngwr-date-picker.d.ts +34 -2
  273. package/types/ngwr-dialog.d.ts +30 -10
  274. package/types/ngwr-drawer.d.ts +32 -1
  275. package/types/ngwr-dropdown-testing.d.ts +8 -5
  276. package/types/ngwr-dropdown.d.ts +31 -6
  277. package/types/ngwr-file-upload.d.ts +8 -2
  278. package/types/ngwr-graph-testing.d.ts +28 -0
  279. package/types/ngwr-graph.d.ts +263 -91
  280. package/types/ngwr-lightbox.d.ts +15 -0
  281. package/types/ngwr-overlay.d.ts +16 -1
  282. package/types/ngwr-popconfirm-testing.d.ts +11 -2
  283. package/types/ngwr-popconfirm.d.ts +28 -1
  284. package/types/ngwr-popover.d.ts +59 -9
  285. package/types/ngwr-select.d.ts +37 -0
  286. package/types/ngwr-table-testing.d.ts +52 -1
  287. package/types/ngwr-table.d.ts +102 -10
  288. package/types/ngwr-tour-testing.d.ts +10 -0
  289. package/types/ngwr-tour.d.ts +32 -4
  290. package/types/ngwr-tree-testing.d.ts +1 -2
  291. package/types/ngwr-tree.d.ts +35 -2
  292. package/types/ngwr-utils.d.ts +79 -1
  293. package/types/ngwr-version.d.ts +1 -1
  294. package/types/ngwr-window.d.ts +14 -11
  295. package/window/styles/_index.scss +5 -10
@@ -33,7 +33,19 @@ var WrTourHarness = class WrTourHarness extends ComponentHarness {
33
33
  };
34
34
  }
35
35
  async getAccessibleName() {
36
- return (await this.host()).getAttribute("aria-label");
36
+ return this.referenced("aria-labelledby");
37
+ }
38
+ async getDescription() {
39
+ return this.referenced("aria-describedby");
40
+ }
41
+ async referenced(attribute) {
42
+ const ids = (await (await this.host()).getAttribute(attribute) ?? "").split(/\s+/).filter(Boolean);
43
+ const texts = [];
44
+ for (const id of ids) {
45
+ const element = await this.locatorForOptional(`[id="${id}"]`)();
46
+ if (element) texts.push(await element.text());
47
+ }
48
+ return texts.length ? texts.join(" ") : null;
37
49
  }
38
50
  async isModal() {
39
51
  const host = await this.host();
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-tour-testing.mjs","names":[],"sources":["../../../projects/lib/tour/testing/wr-tour-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 { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport { WrButtonHarness } from 'ngwr/button/testing';\n\nimport type { WrTourHarnessFilters, WrTourProgress } from './types';\n\n/**\n * Test harness for the card `WrTour` shows beside the spotlit element.\n *\n * `WrTour` is a service with no element of its own, so there is nothing in your\n * fixture to load: the popup is a portal in the NGWR overlay container, and this\n * comes from `TestbedHarnessEnvironment.documentRootLoader()`. **One card exists at\n * a time** — the service tears the whole step down before opening the next — so a\n * harness held across {@link next} is pointed at a detached element, and a fresh one\n * has to be fetched per step.\n *\n * **The card is rebuilt per step, and that is what makes `getHarnessOrNull` the way\n * to ask whether a tour is running.** There is no \"closed\" state to read: the popup,\n * the overlay and the spotlight all go away together.\n *\n * **What \"last\" means here is not `current === total`.** A step whose target is not\n * on the page is skipped, so a tour of three steps can show two, and the service\n * looks AHEAD for a reachable one to decide what the primary button says.\n * {@link getProgress} reports the printed count, {@link getPrimaryLabel} what the\n * button actually reads — asserting the second is what catches a card that says\n * \"Next\" and then ends the tour.\n *\n * @example\n * ```ts\n * const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n * tour.start(steps);\n * await fixture.whenStable();\n *\n * const card = await rootLoader.getHarness(WrTourHarness);\n * expect(await card.getTitle()).toBe('Search');\n * await card.next();\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrTourHarness extends ComponentHarness {\n static hostSelector = '.wr-tour-popup';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrTourHarnessFilters = {}): HarnessPredicate<WrTourHarness> {\n return new HarnessPredicate(WrTourHarness, options)\n .addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title))\n .addOption('content', options.content, (harness, content) =>\n HarnessPredicate.stringMatches(harness.getContent(), content)\n );\n }\n\n /**\n * Whether this card is still on the page.\n *\n * For a harness you are already HOLDING: moving to another step disposes the\n * overlay, so this flips to `false` where a fresh `getHarnessOrNull()` answers\n * with the NEW card rather than with nothing.\n */\n async isShowing(): Promise<boolean> {\n return (await this.host()).matchesSelector('body .wr-tour-popup');\n }\n\n /** The step's heading, or `null` for a step given no `title`. */\n async getTitle(): Promise<string | null> {\n const title = await this.locatorForOptional('.wr-tour-popup__title')();\n return title ? title.text() : null;\n }\n\n /** The step's body copy. */\n async getContent(): Promise<string> {\n return (await this.locatorFor('.wr-tour-popup__content')()).text();\n }\n\n /** The progress line as printed, e.g. `Step 2 of 4`. */\n async getProgressText(): Promise<string> {\n return (await this.locatorFor('.wr-tour-popup__progress')()).text();\n }\n\n /**\n * The two numbers out of the progress line, or `null` when it does not hold two.\n *\n * Parsed from the rendered string rather than asked of the service, because the\n * service is not something a harness can reach — and the string is what the user\n * actually gets. A catalog that spells the numbers as words, or reverses them,\n * makes this `null` instead of a wrong answer; assert {@link getProgressText} in\n * that case.\n *\n * `total` is how many steps the tour was STARTED with, not how many it will show:\n * a step whose target is missing is skipped and still counted here, which is the\n * component's own choice and worth knowing before writing an assertion on it.\n */\n async getProgress(): Promise<WrTourProgress | null> {\n const digits = (await this.getProgressText()).match(/\\d+/g);\n if (!digits || digits.length < 2) return null;\n return { current: Number(digits[0]), total: Number(digits[1]) };\n }\n\n /**\n * The name the card announces — its title and the progress line, or just the\n * progress line for an untitled step.\n *\n * The card is an `aria-modal` dialog, so it needs a name; the progress line is\n * what an untitled step has instead of one.\n */\n async getAccessibleName(): Promise<string | null> {\n return (await this.host()).getAttribute('aria-label');\n }\n\n /** Whether the card announces itself as a modal dialog. */\n async isModal(): Promise<boolean> {\n const host = await this.host();\n return (await host.getAttribute('role')) === 'dialog' && (await host.getAttribute('aria-modal')) === 'true';\n }\n\n /**\n * Whether the card offers a Back button — which is the same question as \"is this\n * the first step\", since the button is only rendered past it.\n */\n async hasBack(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-tour-popup__action--back')()) !== null;\n }\n\n /**\n * What the primary button READS — the \"next\" label, or the \"done\" one on the last\n * step the user will see.\n *\n * The assertion worth writing, and not derivable from the count: the service looks\n * ahead for a step whose target is still on the page, so a tour whose last step is\n * hidden ends one card early and this is the only place that shows.\n */\n async getPrimaryLabel(): Promise<string> {\n return (await this.primary()).getText();\n }\n\n /** The Skip button's label. */\n async getSkipLabel(): Promise<string> {\n return (await this.skip()).getText();\n }\n\n /** The Back button's label. Throws on the first step, where there is none. */\n async getBackLabel(): Promise<string> {\n return (await this.backButton('getBackLabel')).getText();\n }\n\n /**\n * Press the primary button — the next step, or the end of the tour.\n *\n * Composed through {@link WrButtonHarness} rather than clicking an element: these\n * are `wr-btn`s, and that harness already knows how one reports being off.\n */\n async next(): Promise<void> {\n await (await this.primary()).click();\n }\n\n /** Press Back. Throws on the first step, where the button is not rendered. */\n async back(): Promise<void> {\n await (await this.backButton('back')).click();\n }\n\n /** Press Skip — ending the tour without finishing it. */\n async skipTour(): Promise<void> {\n await (await this.skip()).click();\n }\n\n private async primary(): Promise<WrButtonHarness> {\n return this.locatorFor(WrButtonHarness.with({ selector: '.wr-tour-popup__action--next' }))();\n }\n\n private async skip(): Promise<WrButtonHarness> {\n return this.locatorFor(WrButtonHarness.with({ selector: '.wr-tour-popup__action--skip' }))();\n }\n\n private async backButton(method: string): Promise<WrButtonHarness> {\n const button = await this.locatorForOptional(WrButtonHarness.with({ selector: '.wr-tour-popup__action--back' }))();\n if (!button) {\n throw new Error(\n `WrTourHarness.${method}(): this card has no Back button — the tour is on its first step, where it is `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M,UAAO;EACX,OAAQ,MAAM,KAAK,mBAAmB,8BAA8B,CAAC,CAAA,MAAQ;CAC/E;CAUA,MAAM,kBAAe;EACnB,QAAQ,MAAM,KAAK,QAAO,EAAA,CAAI,QAAO;CACvC;CAGA,MAAM,eAAY;EAChB,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,QAAO;CACpC;CAGA,MAAM,eAAY;EAChB,QAAQ,MAAM,KAAK,WAAW,cAAc,EAAA,CAAG,QAAO;CACxD;CAQA,MAAM,OAAI;EACR,OAAO,MAAM,KAAK,QAAO,EAAA,CAAI,MAAK;CACpC;CAGA,MAAM,OAAI;EACR,OAAO,MAAM,KAAK,WAAW,MAAM,EAAA,CAAG,MAAK;CAC7C;CAGA,MAAM,WAAQ;EACZ,OAAO,MAAM,KAAK,KAAI,EAAA,CAAI,MAAK;CACjC;CAEQ,MAAM,UAAO;EACnB,OAAO,KAAK,WAAW,gBAAgB,KAAK,EAAE,UAAU,+BAA8B,CAAE,CAAC,CAAC,CAAA;CAC5F;CAEQ,MAAM,OAAI;EAChB,OAAO,KAAK,WAAW,gBAAgB,KAAK,EAAE,UAAU,+BAA8B,CAAE,CAAC,CAAC,CAAA;CAC5F;CAEQ,MAAM,WAAW,QAAc;EACrC,MAAM,SAAS,MAAM,KAAK,mBAAmB,gBAAgB,KAAK,EAAE,UAAU,+BAA8B,CAAE,CAAC,CAAC,CAAA;EAChH,IAAI,CAAC,QACH,MAAM,IAAI,MACR,iBAAiB,OAAM,mGACC;EAG5B,OAAO;CACT"}
1
+ {"version":3,"file":"ngwr-tour-testing.mjs","names":[],"sources":["../../../projects/lib/tour/testing/wr-tour-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 { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport { WrButtonHarness } from 'ngwr/button/testing';\n\nimport type { WrTourHarnessFilters, WrTourProgress } from './types';\n\n/**\n * Test harness for the card `WrTour` shows beside the spotlit element.\n *\n * `WrTour` is a service with no element of its own, so there is nothing in your\n * fixture to load: the popup is a portal in the NGWR overlay container, and this\n * comes from `TestbedHarnessEnvironment.documentRootLoader()`. **One card exists at\n * a time** — the service tears the whole step down before opening the next — so a\n * harness held across {@link next} is pointed at a detached element, and a fresh one\n * has to be fetched per step.\n *\n * **The card is rebuilt per step, and that is what makes `getHarnessOrNull` the way\n * to ask whether a tour is running.** There is no \"closed\" state to read: the popup,\n * the overlay and the spotlight all go away together.\n *\n * **What \"last\" means here is not `current === total`.** A step whose target is not\n * on the page is skipped, so a tour of three steps can show two, and the service\n * looks AHEAD for a reachable one to decide what the primary button says.\n * {@link getProgress} reports the printed count, {@link getPrimaryLabel} what the\n * button actually reads — asserting the second is what catches a card that says\n * \"Next\" and then ends the tour.\n *\n * @example\n * ```ts\n * const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n * tour.start(steps);\n * await fixture.whenStable();\n *\n * const card = await rootLoader.getHarness(WrTourHarness);\n * expect(await card.getTitle()).toBe('Search');\n * await card.next();\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrTourHarness extends ComponentHarness {\n static hostSelector = '.wr-tour-popup';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrTourHarnessFilters = {}): HarnessPredicate<WrTourHarness> {\n return new HarnessPredicate(WrTourHarness, options)\n .addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title))\n .addOption('content', options.content, (harness, content) =>\n HarnessPredicate.stringMatches(harness.getContent(), content)\n );\n }\n\n /**\n * Whether this card is still on the page.\n *\n * For a harness you are already HOLDING: moving to another step disposes the\n * overlay, so this flips to `false` where a fresh `getHarnessOrNull()` answers\n * with the NEW card rather than with nothing.\n */\n async isShowing(): Promise<boolean> {\n return (await this.host()).matchesSelector('body .wr-tour-popup');\n }\n\n /** The step's heading, or `null` for a step given no `title`. */\n async getTitle(): Promise<string | null> {\n const title = await this.locatorForOptional('.wr-tour-popup__title')();\n return title ? title.text() : null;\n }\n\n /** The step's body copy. */\n async getContent(): Promise<string> {\n return (await this.locatorFor('.wr-tour-popup__content')()).text();\n }\n\n /** The progress line as printed, e.g. `Step 2 of 4`. */\n async getProgressText(): Promise<string> {\n return (await this.locatorFor('.wr-tour-popup__progress')()).text();\n }\n\n /**\n * The two numbers out of the progress line, or `null` when it does not hold two.\n *\n * Parsed from the rendered string rather than asked of the service, because the\n * service is not something a harness can reach — and the string is what the user\n * actually gets. A catalog that spells the numbers as words, or reverses them,\n * makes this `null` instead of a wrong answer; assert {@link getProgressText} in\n * that case.\n *\n * `total` is how many steps the tour was STARTED with, not how many it will show:\n * a step whose target is missing is skipped and still counted here, which is the\n * component's own choice and worth knowing before writing an assertion on it.\n */\n async getProgress(): Promise<WrTourProgress | null> {\n const digits = (await this.getProgressText()).match(/\\d+/g);\n if (!digits || digits.length < 2) return null;\n return { current: Number(digits[0]), total: Number(digits[1]) };\n }\n\n /**\n * The name the card announces — its title and the progress line, or just the\n * progress line for an untitled step.\n *\n * The card is an `aria-modal` dialog, so it needs a name; the progress line is\n * what an untitled step has instead of one.\n */\n async getAccessibleName(): Promise<string | null> {\n return this.referenced('aria-labelledby');\n }\n\n /**\n * What the card is described by, which is what a screen reader reads after the\n * name when focus enters the dialog: the step's text.\n */\n async getDescription(): Promise<string | null> {\n return this.referenced('aria-describedby');\n }\n\n /**\n * The text of the elements an id-list attribute of the card names, joined by a\n * space, or `null` when the attribute is absent or names nothing in the card.\n */\n private async referenced(attribute: string): Promise<string | null> {\n const ids = ((await (await this.host()).getAttribute(attribute)) ?? '').split(/\\s+/).filter(Boolean);\n const texts: string[] = [];\n for (const id of ids) {\n const element = await this.locatorForOptional(`[id=\"${id}\"]`)();\n if (element) texts.push(await element.text());\n }\n return texts.length ? texts.join(' ') : null;\n }\n\n /** Whether the card announces itself as a modal dialog. */\n async isModal(): Promise<boolean> {\n const host = await this.host();\n return (await host.getAttribute('role')) === 'dialog' && (await host.getAttribute('aria-modal')) === 'true';\n }\n\n /**\n * Whether the card offers a Back button — which is the same question as \"is this\n * the first step\", since the button is only rendered past it.\n */\n async hasBack(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-tour-popup__action--back')()) !== null;\n }\n\n /**\n * What the primary button READS — the \"next\" label, or the \"done\" one on the last\n * step the user will see.\n *\n * The assertion worth writing, and not derivable from the count: the service looks\n * ahead for a step whose target is still on the page, so a tour whose last step is\n * hidden ends one card early and this is the only place that shows.\n */\n async getPrimaryLabel(): Promise<string> {\n return (await this.primary()).getText();\n }\n\n /** The Skip button's label. */\n async getSkipLabel(): Promise<string> {\n return (await this.skip()).getText();\n }\n\n /** The Back button's label. Throws on the first step, where there is none. */\n async getBackLabel(): Promise<string> {\n return (await this.backButton('getBackLabel')).getText();\n }\n\n /**\n * Press the primary button — the next step, or the end of the tour.\n *\n * Composed through {@link WrButtonHarness} rather than clicking an element: these\n * are `wr-btn`s, and that harness already knows how one reports being off.\n */\n async next(): Promise<void> {\n await (await this.primary()).click();\n }\n\n /** Press Back. Throws on the first step, where the button is not rendered. */\n async back(): Promise<void> {\n await (await this.backButton('back')).click();\n }\n\n /** Press Skip — ending the tour without finishing it. */\n async skipTour(): Promise<void> {\n await (await this.skip()).click();\n }\n\n private async primary(): Promise<WrButtonHarness> {\n return this.locatorFor(WrButtonHarness.with({ selector: '.wr-tour-popup__action--next' }))();\n }\n\n private async skip(): Promise<WrButtonHarness> {\n return this.locatorFor(WrButtonHarness.with({ selector: '.wr-tour-popup__action--skip' }))();\n }\n\n private async backButton(method: string): Promise<WrButtonHarness> {\n const button = await this.locatorForOptional(WrButtonHarness.with({ selector: '.wr-tour-popup__action--back' }))();\n if (!button) {\n throw new Error(\n `WrTourHarness.${method}(): this card has no Back button — the tour is on its first step, where it is ` +\n 'not rendered at all.'\n );\n }\n return button;\n }\n}\n"],"mappings":";;;;;;;;AA+CA,IA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ChH,IAAI,CAAC,QACH,MAAM,IAAI,MACR,iBAAiB,OAAM,mGACC;EAG5B,OAAO;CACT"}
@@ -1,13 +1,13 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { Component, DOCUMENT, DestroyRef, EnvironmentInjector, InjectionToken, Injector, PLATFORM_ID, Service, ViewEncapsulation, computed, inject, signal } from "@angular/core";
3
3
  import { Location, isPlatformBrowser } from "@angular/common";
4
- import { wrCheckStyles, wrToClassList } from "ngwr/utils";
4
+ import { wrCheckStyles, wrRandomId, wrToClassList } from "ngwr/utils";
5
5
  import { useI18nFormatter, wrReadI18nText } from "ngwr/i18n";
6
6
  import { Directionality } from "@angular/cdk/bidi";
7
7
  import { WrButton } from "ngwr/button";
8
8
  import { ScrollStrategyOptions } from "@angular/cdk/overlay";
9
9
  import { ComponentPortal } from "@angular/cdk/portal";
10
- import { WR_OVERLAY, wrFollowDirection, wrMirrorOffsets } from "ngwr/overlay";
10
+ import { WR_OVERLAY, wrFocusOverlay, wrFollowDirection, wrMirrorOffsets } from "ngwr/overlay";
11
11
  import { ConfigurableFocusTrapFactory } from "@angular/cdk/a11y";
12
12
  /**
13
13
  * @license
@@ -32,10 +32,10 @@ var WrTourPopup = class WrTourPopup {
32
32
  current: this.tour.index() + 1,
33
33
  total: this.tour.total()
34
34
  }), ...ngDevMode ? [{ debugName: "progressText" }] : /* istanbul ignore next */ []);
35
- ariaLabel = computed(() => {
36
- const title = this.tour.step()?.title;
37
- return title ? `${title} — ${this.progressText()}` : this.progressText();
38
- }, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
35
+ titleId = wrRandomId("wr-tour-title");
36
+ progressId = wrRandomId("wr-tour-progress");
37
+ contentId = wrRandomId("wr-tour-content");
38
+ labelledBy = computed(() => this.tour.step()?.title ? `${this.titleId} ${this.progressId}` : this.progressId, ...ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []);
39
39
  static ɵfac = i0.ɵɵngDeclareFactory({
40
40
  minVersion: "12.0.0",
41
41
  version: "22.2.6",
@@ -55,11 +55,14 @@ var WrTourPopup = class WrTourPopup {
55
55
  "role": "dialog",
56
56
  "aria-modal": "true"
57
57
  },
58
- properties: { "attr.aria-label": "ariaLabel()" },
58
+ properties: {
59
+ "attr.aria-labelledby": "labelledBy()",
60
+ "attr.aria-describedby": "contentId"
61
+ },
59
62
  classAttribute: "wr-tour-popup"
60
63
  },
61
64
  ngImport: i0,
62
- template: "@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <!-- The three buttons are told apart by a class rather than by their position in\n the row: the back button is conditional, so an index means one thing on the\n first step and another everywhere else — and the labels are translated. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--skip\"\n (click)=\"tour.stop()\"\n >\n {{ skipLabel() }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--back\"\n (click)=\"tour.prev()\"\n >\n {{ backLabel() }}\n </button>\n }\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n class=\"wr-tour-popup__action wr-tour-popup__action--next\"\n (click)=\"tour.next()\"\n >\n {{ isLast() ? doneLabel() : nextLabel() }}\n </button>\n</div>\n",
65
+ template: "@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\" [id]=\"progressId\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\" [id]=\"titleId\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\" [id]=\"contentId\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <!-- The three buttons are told apart by a class rather than by their position in\n the row: the back button is conditional, so an index means one thing on the\n first step and another everywhere else — and the labels are translated. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--skip\"\n (click)=\"tour.stop()\"\n >\n {{ skipLabel() }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--back\"\n (click)=\"tour.prev()\"\n >\n {{ backLabel() }}\n </button>\n }\n <!-- Under `autoFocus: 'first-tabbable'` focus opens on the button that walks the\n tour, not on Skip, the first in the row: the focus trap reads\n `cdkFocusInitial`, as the confirm dialog has it. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n class=\"wr-tour-popup__action wr-tour-popup__action--next\"\n [attr.cdkFocusInitial]=\"tour.focusNext() ? '' : null\"\n (click)=\"tour.next()\"\n >\n {{ isLast() ? doneLabel() : nextLabel() }}\n </button>\n</div>\n",
63
66
  dependencies: [{
64
67
  kind: "component",
65
68
  type: WrButton,
@@ -94,10 +97,11 @@ i0.ɵɵngDeclareClassMetadata({
94
97
  class: "wr-tour-popup",
95
98
  role: "dialog",
96
99
  "aria-modal": "true",
97
- "[attr.aria-label]": "ariaLabel()"
100
+ "[attr.aria-labelledby]": "labelledBy()",
101
+ "[attr.aria-describedby]": "contentId"
98
102
  },
99
103
  imports: [WrButton],
100
- template: "@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <!-- The three buttons are told apart by a class rather than by their position in\n the row: the back button is conditional, so an index means one thing on the\n first step and another everywhere else — and the labels are translated. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--skip\"\n (click)=\"tour.stop()\"\n >\n {{ skipLabel() }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--back\"\n (click)=\"tour.prev()\"\n >\n {{ backLabel() }}\n </button>\n }\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n class=\"wr-tour-popup__action wr-tour-popup__action--next\"\n (click)=\"tour.next()\"\n >\n {{ isLast() ? doneLabel() : nextLabel() }}\n </button>\n</div>\n"
104
+ template: "@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\" [id]=\"progressId\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\" [id]=\"titleId\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\" [id]=\"contentId\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <!-- The three buttons are told apart by a class rather than by their position in\n the row: the back button is conditional, so an index means one thing on the\n first step and another everywhere else — and the labels are translated. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--skip\"\n (click)=\"tour.stop()\"\n >\n {{ skipLabel() }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--back\"\n (click)=\"tour.prev()\"\n >\n {{ backLabel() }}\n </button>\n }\n <!-- Under `autoFocus: 'first-tabbable'` focus opens on the button that walks the\n tour, not on Skip, the first in the row: the focus trap reads\n `cdkFocusInitial`, as the confirm dialog has it. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n class=\"wr-tour-popup__action wr-tour-popup__action--next\"\n [attr.cdkFocusInitial]=\"tour.focusNext() ? '' : null\"\n (click)=\"tour.next()\"\n >\n {{ isLast() ? doneLabel() : nextLabel() }}\n </button>\n</div>\n"
101
105
  }]
102
106
  }],
103
107
  ctorParameters: () => []
@@ -177,6 +181,8 @@ var WrTour = class WrTour {
177
181
  detachKeydown = null;
178
182
  detachReposition = null;
179
183
  restoreFocus = null;
184
+ autoFocus = "dialog";
185
+ focusNext = () => this.autoFocus === "first-tabbable";
180
186
  stopWatchingUrl = null;
181
187
  active = computed(() => this.cursor() >= 0, ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
182
188
  index = computed(() => this.cursor(), ...ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []);
@@ -189,10 +195,11 @@ var WrTour = class WrTour {
189
195
  constructor() {
190
196
  inject(DestroyRef).onDestroy(() => this.stop());
191
197
  }
192
- start(steps) {
198
+ start(steps, options = {}) {
193
199
  if (!this.isBrowser || steps.length === 0) return;
194
200
  this.stop();
195
201
  this.steps.set(steps);
202
+ this.autoFocus = options.autoFocus ?? "dialog";
196
203
  this.restoreFocus = this.document.activeElement;
197
204
  this.stopWatchingUrl = this.location.onUrlChange(() => this.stop());
198
205
  this.goTo(0, 1);
@@ -224,11 +231,13 @@ var WrTour = class WrTour {
224
231
  this.stop();
225
232
  return;
226
233
  }
234
+ const active = this.document.activeElement;
235
+ const hadFocus = !!active && !!this.overlayRef?.overlayElement.contains(active);
227
236
  this.teardownStep();
228
237
  this.cursor.set(i);
229
238
  this.noStepAfter.set(!this.anyResolvableAfter(i));
230
239
  this.noStepBefore.set(!this.anyResolvableBefore(i));
231
- this.openStep(steps[i]);
240
+ this.openStep(steps[i], hadFocus);
232
241
  }
233
242
  anyResolvableAfter(index) {
234
243
  const steps = this.steps();
@@ -244,7 +253,7 @@ var WrTour = class WrTour {
244
253
  if (typeof step.target !== "string") return step.target.isConnected ? step.target : null;
245
254
  return this.document.querySelector(step.target);
246
255
  }
247
- openStep(step) {
256
+ openStep(step, hadFocus) {
248
257
  const target = this.resolve(step);
249
258
  if (!target) return;
250
259
  target.scrollIntoView({
@@ -276,9 +285,9 @@ var WrTour = class WrTour {
276
285
  useValue: this
277
286
  }]
278
287
  }));
279
- const ref = this.overlayRef.attach(portal);
280
- this.focusTrap = this.focusTrapFactory.create(ref.location.nativeElement);
281
- this.focusTrap.focusInitialElementWhenReady();
288
+ const card = this.overlayRef.attach(portal).location.nativeElement;
289
+ this.focusTrap = this.focusTrapFactory.create(card);
290
+ wrFocusOverlay(card, this.focusTrap, this.autoFocus === false && hadFocus ? "dialog" : this.autoFocus, this.injector);
282
291
  const onKey = (event) => {
283
292
  if (event.key === "Escape" && !event.defaultPrevented) {
284
293
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-tour.mjs","names":[],"sources":["../../../projects/lib/tour/tour-popup.ts","../../../projects/lib/tour/tour-popup.html","../../../projects/lib/tour/tour.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, InjectionToken, ViewEncapsulation, computed, inject } from '@angular/core';\n\nimport { WrButton } from 'ngwr/button';\nimport { wrReadI18nText, useI18nFormatter } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrTourStep } from './types';\n\n/** What the popup needs from the running tour, without importing the service (cycle). */\nexport interface WrTourController {\n readonly index: () => number;\n readonly total: () => number;\n readonly step: () => WrTourStep | null;\n /**\n * Whether this is the last step the user will actually see — the service looks\n * ahead for a reachable one, because a trailing step whose target is missing gets\n * skipped and the raw count would call the final card \"Next\".\n */\n readonly isLast: () => boolean;\n /**\n * Whether this is the first step the user will actually see — the service looks\n * BEHIND for a reachable one, for the mirror reason: a leading step whose target\n * is missing gets skipped, so the tour opens on a later index and the raw one\n * would put a Back button on the very first card.\n */\n readonly isFirst: () => boolean;\n next(): void;\n prev(): void;\n stop(): void;\n}\n\n/** Provided by `WrTour` when it attaches the popup portal. */\nexport const WR_TOUR_STEP = new InjectionToken<WrTourController>('WR_TOUR_STEP');\n\n/**\n * The card a tour shows next to the spotlit element. Rendered by `WrTour` into\n * a CDK overlay — not something you place yourself.\n *\n * @see https://ngwr.dev/reference/services/tour\n */\n@Component({\n selector: 'wr-tour-popup',\n templateUrl: './tour-popup.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-tour-popup', role: 'dialog', 'aria-modal': 'true', '[attr.aria-label]': 'ariaLabel()' },\n imports: [WrButton],\n})\nexport class WrTourPopup {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('tour');\n }\n\n protected readonly tour = inject(WR_TOUR_STEP);\n\n // `wrReadI18nText`, not `useI18nText`: these have no consumer-facing input to\n // forward. Both helpers are reactive.\n protected readonly nextLabel = wrReadI18nText('tour.next', 'Next');\n protected readonly backLabel = wrReadI18nText('tour.back', 'Back');\n protected readonly doneLabel = wrReadI18nText('tour.done', 'Done');\n protected readonly skipLabel = wrReadI18nText('tour.skip', 'Skip tour');\n\n /** `Step {{current}} of {{total}}` — also the dialog's accessible name. */\n protected readonly progress = useI18nFormatter('tour.progress', 'Step {{current}} of {{total}}');\n\n // From the service, not `index() >= total() - 1`: a trailing step whose target is\n // missing gets skipped, so the raw count called the final card \"Next\" and then\n // ended the tour when it was pressed.\n protected readonly isLast = computed(() => this.tour.isLast());\n // Same story at the other end, and the same fix: `index() <= 0` rendered a Back\n // button on the first card of a tour whose leading step had been skipped, and\n // `prev()` walks off the start and returns — so the button did nothing at all.\n protected readonly isFirst = computed(() => this.tour.isFirst());\n\n protected readonly progressText = computed(() =>\n this.progress({ current: this.tour.index() + 1, total: this.tour.total() })\n );\n\n protected readonly ariaLabel = computed(() => {\n const title = this.tour.step()?.title;\n return title ? `${title} — ${this.progressText()}` : this.progressText();\n });\n}\n","@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <!-- The three buttons are told apart by a class rather than by their position in\n the row: the back button is conditional, so an index means one thing on the\n first step and another everywhere else — and the labels are translated. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--skip\"\n (click)=\"tour.stop()\"\n >\n {{ skipLabel() }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--back\"\n (click)=\"tour.prev()\"\n >\n {{ backLabel() }}\n </button>\n }\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n class=\"wr-tour-popup__action wr-tour-popup__action--next\"\n (click)=\"tour.next()\"\n >\n {{ isLast() ? doneLabel() : nextLabel() }}\n </button>\n</div>\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 ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { type ConnectedPosition, type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal } from '@angular/cdk/portal';\nimport { Location, isPlatformBrowser } from '@angular/common';\nimport {\n DOCUMENT,\n DestroyRef,\n EnvironmentInjector,\n Injector,\n PLATFORM_ID,\n Service,\n computed,\n inject,\n signal,\n} from '@angular/core';\n\nimport { WR_OVERLAY, wrFollowDirection, wrMirrorOffsets } from 'ngwr/overlay';\nimport { wrToClassList } from 'ngwr/utils';\n\nimport { WR_TOUR_STEP, WrTourPopup } from './tour-popup';\nimport type { WrTourPlacement, WrTourStep } from './types';\n\n/** Fallback order per preferred side — the opposite side first, then the sides. */\nconst FALLBACKS: Record<WrTourPlacement, readonly WrTourPlacement[]> = {\n bottom: ['bottom', 'top', 'right', 'left'],\n top: ['top', 'bottom', 'right', 'left'],\n left: ['left', 'right', 'bottom', 'top'],\n right: ['right', 'left', 'bottom', 'top'],\n};\n\nconst CONNECTED: Record<\n WrTourPlacement,\n {\n originX: 'start' | 'center' | 'end';\n originY: 'top' | 'center' | 'bottom';\n overlayX: 'start' | 'center' | 'end';\n overlayY: 'top' | 'center' | 'bottom';\n }\n> = {\n bottom: { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top' },\n top: { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom' },\n left: { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center' },\n right: { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center' },\n};\n\n/**\n * Guided product tour: a spotlight over one element at a time plus a popup\n * explaining it.\n *\n * Steps are data, not markup — call `start()` with an array and the service owns\n * the overlay, the cut-out, focus and the keyboard. A step whose target is not\n * on the page is skipped rather than shown floating, so a tour survives a\n * feature being hidden behind a flag or a permission.\n *\n * @example\n * ```ts\n * private readonly tour = inject(WrTour);\n *\n * showMeAround(): void {\n * this.tour.start([\n * { target: '[data-tour=\"search\"]', title: 'Search', content: 'Find anything by name.' },\n * { target: '[data-tour=\"filters\"]', content: 'Narrow the list down.', placement: 'right' },\n * ]);\n * }\n * ```\n *\n * @see https://ngwr.dev/reference/services/tour\n */\n@Service()\nexport class WrTour {\n private readonly overlay = inject(WR_OVERLAY);\n private readonly dir = inject(Directionality, { optional: true });\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly injector = inject(EnvironmentInjector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly document = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly location = inject(Location);\n\n private readonly steps = signal<readonly WrTourStep[]>([]);\n private readonly cursor = signal(-1);\n\n private overlayRef: OverlayRef | null = null;\n private focusTrap: ConfigurableFocusTrap | null = null;\n private spotlight: HTMLElement | null = null;\n private detachKeydown: (() => void) | null = null;\n private detachReposition: (() => void) | null = null;\n private restoreFocus: HTMLElement | null = null;\n private stopWatchingUrl: (() => void) | null = null;\n\n /** Whether a tour is running. */\n readonly active = computed(() => this.cursor() >= 0);\n\n /** Zero-based index of the current step, `-1` when idle. */\n readonly index = computed(() => this.cursor());\n\n /** How many steps this tour has. */\n readonly total = computed(() => this.steps().length);\n\n /** The step being shown, or `null` when idle. */\n readonly step = computed<WrTourStep | null>(() => this.steps()[this.cursor()] ?? null);\n\n // Whether any step AFTER the current one can actually be shown. Settled once per\n // move, in `goTo`, because reachability is a DOM question and not a signal.\n private readonly noStepAfter = signal(false);\n\n // The same question looking the other way. Settled in `goTo` for the same reason.\n //\n // `true` at rest, and the asymmetry with `noStepAfter` is deliberate: with no\n // tour running there is no step, so both questions are vacuous, and the pair\n // is set to whatever keeps a naive template honest. `@if (!tour.isFirst())`\n // around a Back button is the obvious way to write it, and at `false` that\n // button appears with no tour on screen.\n private readonly noStepBefore = signal(true);\n\n /**\n * Whether this is the last step the user will see. Not `index() === total() - 1`:\n * a trailing step whose target is missing is skipped, so comparing against the\n * raw count left the primary button reading \"Next\" on the final card and then\n * ending the tour when it was pressed. `false` while no tour is running.\n */\n readonly isLast = computed(() => this.noStepAfter());\n\n /**\n * Whether this is the first step the user will see. Not `index() === 0`, for the\n * mirror of the reason above: a LEADING step whose target is missing is skipped,\n * so the tour opens on a later index and the raw one put a Back button on the\n * first card — one that did nothing at all, because `prev()` walks off the start\n * and returns without moving. `true` while no tour is running — see the signal\n * it reads.\n */\n readonly isFirst = computed(() => this.noStepBefore());\n\n constructor() {\n // Everything this service owns lives OUTSIDE its own injector: a CDK overlay, a\n // div appended to `document.body`, a document keydown listener and two window\n // listeners. Nothing removes them when the injector goes, so a tour running at\n // teardown left its cut-out on the page.\n inject(DestroyRef).onDestroy(() => this.stop());\n }\n\n /**\n * Begin a tour. Restarts if one is already running. A no-op under SSR — a\n * tour is a client-side affordance and there is nothing to spotlight on the\n * server.\n */\n start(steps: readonly WrTourStep[]): void {\n if (!this.isBrowser || steps.length === 0) return;\n this.stop();\n this.steps.set(steps);\n this.restoreFocus = this.document.activeElement as HTMLElement | null;\n // A tour belongs to the page it was started on, the way `WrDialog` and\n // `WrDrawerManager` tie a modal to its URL. Nothing ended it on navigation,\n // so following a link mid-tour left the card pointing at an element the\n // router had just removed — the cut-out collapsed to a 12px box at the\n // corner, its 9999px shadow dimming the whole new page, and focus trapped in\n // a card about the page the user had left. `onUrlChange` rather than\n // `subscribe()`, which hears popstate alone and misses `router.navigate()`.\n this.stopWatchingUrl = this.location.onUrlChange(() => this.stop());\n this.goTo(0, 1);\n }\n\n /** Advance; finishes the tour past the last step. */\n next(): void {\n this.goTo(this.cursor() + 1, 1);\n }\n\n /** Go back; stays put on the first step. */\n prev(): void {\n this.goTo(this.cursor() - 1, -1);\n }\n\n /** End the tour and return focus where it was. */\n stop(): void {\n // Unhooked a microtask late, as `WrDialog` does: `Location` notifies with a\n // `forEach`, and unregistering from inside that notification splices the\n // array it is walking, which would skip the listener after ours.\n const unwatch = this.stopWatchingUrl;\n this.stopWatchingUrl = null;\n if (unwatch) queueMicrotask(unwatch);\n this.teardownStep();\n this.steps.set([]);\n this.cursor.set(-1);\n // Back to their resting answers. Without this a finished tour left both\n // holding whatever its last step said, so `isFirst` and `isLast` were the\n // only two signals here that still described a tour that had ended — while\n // `active`, `index`, `total` and `step` all reported idle.\n this.noStepAfter.set(false);\n this.noStepBefore.set(true);\n this.restoreFocus?.focus?.();\n this.restoreFocus = null;\n }\n\n /**\n * Move to `index`, skipping steps whose target is not in the DOM. `direction`\n * says which way to keep skipping, so a missing step never traps the tour\n * between two dead ends.\n */\n private goTo(index: number, direction: 1 | -1): void {\n const steps = this.steps();\n let i = index;\n while (i >= 0 && i < steps.length && this.resolve(steps[i]) === null) i += direction;\n\n if (i < 0) {\n // Ran off the start while going back — stay where we were.\n return;\n }\n if (i >= steps.length) {\n this.stop();\n return;\n }\n\n this.teardownStep();\n this.cursor.set(i);\n this.noStepAfter.set(!this.anyResolvableAfter(i));\n this.noStepBefore.set(!this.anyResolvableBefore(i));\n this.openStep(steps[i]);\n }\n\n /** Whether the tour has a step past `index` that can actually be shown. */\n private anyResolvableAfter(index: number): boolean {\n const steps = this.steps();\n for (let i = index + 1; i < steps.length; i += 1) {\n if (this.resolve(steps[i]) !== null) return true;\n }\n return false;\n }\n\n /** Whether the tour has a step before `index` that can actually be shown. */\n private anyResolvableBefore(index: number): boolean {\n const steps = this.steps();\n for (let i = index - 1; i >= 0; i -= 1) {\n if (this.resolve(steps[i]) !== null) return true;\n }\n return false;\n }\n\n private resolve(step: WrTourStep): HTMLElement | null {\n if (typeof step.target !== 'string') return step.target.isConnected ? step.target : null;\n return this.document.querySelector<HTMLElement>(step.target);\n }\n\n private openStep(step: WrTourStep): void {\n const target = this.resolve(step);\n if (!target) return;\n\n target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' });\n\n // The cut-out is a bare element sized to the target with an enormous spread\n // shadow: everything outside it dims, the target itself stays untouched.\n // Cheaper and far more robust than a clip-path polygon, and it needs no\n // recompute when the page reflows beyond moving the box.\n const spotlight = this.document.createElement('div');\n spotlight.className = 'wr-tour__spotlight';\n spotlight.setAttribute('aria-hidden', 'true');\n this.document.body.appendChild(spotlight);\n this.spotlight = spotlight;\n this.placeSpotlight(target);\n\n const placement = step.placement ?? 'bottom';\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(target)\n .withPositions(this.stepPositions(placement, this.isRtl()))\n .withPush(true);\n\n this.overlayRef = this.overlay.create({\n positionStrategy,\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: wrToClassList('wr-tour-overlay', step.panelClass),\n });\n\n // The CDK read the direction once, just now. A tour is long-lived by nature\n // — a step can sit on screen while the user changes a language setting — and\n // without this the card keeps the direction the step opened in, with the\n // 12px gap that held it clear of the spotlight now pointing into it.\n // Per step, because every move disposes this ref and builds the next.\n //\n // The cut-out moves with it. The target itself changes place when the page\n // mirrors, and the spotlight is re-measured only on scroll and resize, so a\n // flip left it highlighting empty space while the card, re-placed by the CDK,\n // pointed at the target sitting under the dim. The flip has already been laid\n // out by the time this runs — the CDK measures the same element right after.\n wrFollowDirection(this.overlayRef, this.dir, this.injector, direction => {\n positionStrategy.withPositions(this.stepPositions(placement, direction === 'rtl'));\n this.placeSpotlight(target);\n });\n\n const portal = new ComponentPortal(\n WrTourPopup,\n null,\n Injector.create({ parent: this.injector, providers: [{ provide: WR_TOUR_STEP, useValue: this }] })\n );\n const ref = this.overlayRef.attach(portal);\n\n // Kept on the instance, not in a local: a trap registers with CDK's\n // `FocusTrapManager` and installs a capture-phase document focus listener, so an\n // undestroyed one leaks per STEP and every tour left a stack of them behind.\n this.focusTrap = this.focusTrapFactory.create(ref.location.nativeElement as HTMLElement);\n void this.focusTrap.focusInitialElementWhenReady();\n\n const onKey = (event: KeyboardEvent): void => {\n // The listener is on the document, so a step shown over a dialog would see the\n // Escape that dialog just handled and close the tour too.\n if (event.key === 'Escape' && !event.defaultPrevented) {\n event.preventDefault();\n this.stop();\n }\n };\n this.document.addEventListener('keydown', onKey);\n this.detachKeydown = () => this.document.removeEventListener('keydown', onKey);\n\n const reposition = (): void => this.placeSpotlight(target);\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n this.detachReposition = () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n };\n }\n\n /**\n * The card's fallback table for one placement, with its inline offsets already\n * mirrored. Built per call rather than per step: the direction can change while\n * the step is on screen, and a table is what has to be rebuilt when it does.\n */\n private stepPositions(placement: WrTourPlacement, isRtl: boolean): ConnectedPosition[] {\n return wrMirrorOffsets(\n FALLBACKS[placement].map(side => ({\n ...CONNECTED[side],\n offsetY: side === 'bottom' ? 12 : side === 'top' ? -12 : 0,\n offsetX: side === 'right' ? 12 : side === 'left' ? -12 : 0,\n })),\n isRtl\n );\n }\n\n private placeSpotlight(target: HTMLElement): void {\n const el = this.spotlight;\n if (!el) return;\n const r = target.getBoundingClientRect();\n const pad = 6;\n el.style.top = `${r.top - pad}px`;\n el.style.left = `${r.left - pad}px`;\n el.style.width = `${r.width + pad * 2}px`;\n el.style.height = `${r.height + pad * 2}px`;\n }\n\n private teardownStep(): void {\n this.focusTrap?.destroy();\n this.focusTrap = null;\n this.detachKeydown?.();\n this.detachKeydown = null;\n this.detachReposition?.();\n this.detachReposition = null;\n this.overlayRef?.dispose();\n this.overlayRef = null;\n this.spotlight?.remove();\n this.spotlight = null;\n }\n\n /**\n * Whether the app reads right-to-left.\n *\n * Optional inject: `Directionality` is root-provided, so this is never null in\n * an app — but a bare `TestBed` that provides nothing should still get a\n * component that works, and defaulting to LTR is the honest fallback.\n */\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAa,eAAe,IAAI,eAAiC,cAAc;AAe/E,IAAa,cAAb,MAAa,YAAW;CACtB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,MAAM;CACzE;CAEmB,OAAO,OAAO,YAAY;CAI1B,YAAY,eAAe,aAAa,MAAM;CAC9C,YAAY,eAAe,aAAa,MAAM;CAC9C,YAAY,eAAe,aAAa,MAAM;CAC9C,YAAY,eAAe,aAAa,WAAW;CAGnD,WAAW,iBAAiB,iBAAiB,+BAA+B;CAK5E,SAAS,eAAe,KAAK,KAAK,OAAM,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAI3C,UAAU,eAAe,KAAK,KAAK,QAAO,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAE7C,eAAe,eAChC,KAAK,SAAS;EAAE,SAAS,KA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r-tour.mjs","names":[],"sources":["../../../projects/lib/tour/tour-popup.ts","../../../projects/lib/tour/tour-popup.html","../../../projects/lib/tour/tour.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, InjectionToken, ViewEncapsulation, computed, inject } from '@angular/core';\n\nimport { WrButton } from 'ngwr/button';\nimport { wrReadI18nText, useI18nFormatter } from 'ngwr/i18n';\nimport { wrCheckStyles, wrRandomId } from 'ngwr/utils';\n\nimport type { WrTourStep } from './types';\n\n/** What the popup needs from the running tour, without importing the service (cycle). */\nexport interface WrTourController {\n readonly index: () => number;\n readonly total: () => number;\n readonly step: () => WrTourStep | null;\n /**\n * Whether this is the last step the user will actually see — the service looks\n * ahead for a reachable one, because a trailing step whose target is missing gets\n * skipped and the raw count would call the final card \"Next\".\n */\n readonly isLast: () => boolean;\n /**\n * Whether this is the first step the user will actually see — the service looks\n * BEHIND for a reachable one, for the mirror reason: a leading step whose target\n * is missing gets skipped, so the tour opens on a later index and the raw one\n * would put a Back button on the very first card.\n */\n readonly isFirst: () => boolean;\n /** Whether the card opens with focus on Next: the tour's `autoFocus` is `'first-tabbable'`. */\n readonly focusNext: () => boolean;\n next(): void;\n prev(): void;\n stop(): void;\n}\n\n/** Provided by `WrTour` when it attaches the popup portal. */\nexport const WR_TOUR_STEP = new InjectionToken<WrTourController>('WR_TOUR_STEP');\n\n/**\n * The card a tour shows next to the spotlit element. Rendered by `WrTour` into\n * a CDK overlay — not something you place yourself.\n *\n * @see https://ngwr.dev/reference/services/tour\n */\n@Component({\n selector: 'wr-tour-popup',\n templateUrl: './tour-popup.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-tour-popup',\n role: 'dialog',\n 'aria-modal': 'true',\n '[attr.aria-labelledby]': 'labelledBy()',\n '[attr.aria-describedby]': 'contentId',\n },\n imports: [WrButton],\n})\nexport class WrTourPopup {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('tour');\n }\n\n protected readonly tour = inject(WR_TOUR_STEP);\n\n // `wrReadI18nText`, not `useI18nText`: these have no consumer-facing input to\n // forward. Both helpers are reactive.\n protected readonly nextLabel = wrReadI18nText('tour.next', 'Next');\n protected readonly backLabel = wrReadI18nText('tour.back', 'Back');\n protected readonly doneLabel = wrReadI18nText('tour.done', 'Done');\n protected readonly skipLabel = wrReadI18nText('tour.skip', 'Skip tour');\n\n /** `Step {{current}} of {{total}}`, the second half of the dialog's name. */\n protected readonly progress = useI18nFormatter('tour.progress', 'Step {{current}} of {{total}}');\n\n // From the service, not `index() >= total() - 1`: a trailing step whose target is\n // missing gets skipped, so the raw count called the final card \"Next\" and then\n // ended the tour when it was pressed.\n protected readonly isLast = computed(() => this.tour.isLast());\n // Same story at the other end, and the same fix: `index() <= 0` rendered a Back\n // button on the first card of a tour whose leading step had been skipped, and\n // `prev()` walks off the start and returns — so the button did nothing at all.\n protected readonly isFirst = computed(() => this.tour.isFirst());\n\n protected readonly progressText = computed(() =>\n this.progress({ current: this.tour.index() + 1, total: this.tour.total() })\n );\n\n protected readonly titleId = wrRandomId('wr-tour-title');\n protected readonly progressId = wrRandomId('wr-tour-progress');\n protected readonly contentId = wrRandomId('wr-tour-content');\n\n /**\n * The dialog is named by its title and the progress line, or by the progress\n * line alone for an untitled step, and described by the step's text: a screen\n * reader reads a dialog's name and description when focus enters it, and\n * nothing else of what it holds.\n */\n protected readonly labelledBy = computed(() =>\n this.tour.step()?.title ? `${this.titleId} ${this.progressId}` : this.progressId\n );\n}\n","@let step = tour.step();\n\n<p class=\"wr-tour-popup__progress\" [id]=\"progressId\">{{ progressText() }}</p>\n\n@if (step?.title; as title) {\n <h2 class=\"wr-tour-popup__title\" [id]=\"titleId\">{{ title }}</h2>\n}\n\n<p class=\"wr-tour-popup__content\" [id]=\"contentId\">{{ step?.content }}</p>\n\n<div class=\"wr-tour-popup__actions\">\n <!-- The three buttons are told apart by a class rather than by their position in\n the row: the back button is conditional, so an index means one thing on the\n first step and another everywhere else — and the labels are translated. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--skip\"\n (click)=\"tour.stop()\"\n >\n {{ skipLabel() }}\n </button>\n\n <span class=\"wr-tour-popup__spacer\"></span>\n\n @if (!isFirst()) {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-tour-popup__action wr-tour-popup__action--back\"\n (click)=\"tour.prev()\"\n >\n {{ backLabel() }}\n </button>\n }\n <!-- Under `autoFocus: 'first-tabbable'` focus opens on the button that walks the\n tour, not on Skip, the first in the row: the focus trap reads\n `cdkFocusInitial`, as the confirm dialog has it. -->\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n color=\"primary\"\n class=\"wr-tour-popup__action wr-tour-popup__action--next\"\n [attr.cdkFocusInitial]=\"tour.focusNext() ? '' : null\"\n (click)=\"tour.next()\"\n >\n {{ isLast() ? doneLabel() : nextLabel() }}\n </button>\n</div>\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 ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { type ConnectedPosition, type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal } from '@angular/cdk/portal';\nimport { Location, isPlatformBrowser } from '@angular/common';\nimport {\n DOCUMENT,\n DestroyRef,\n EnvironmentInjector,\n Injector,\n PLATFORM_ID,\n Service,\n computed,\n inject,\n signal,\n} from '@angular/core';\n\nimport { WR_OVERLAY, type WrOverlayAutoFocus, wrFocusOverlay, wrFollowDirection, wrMirrorOffsets } from 'ngwr/overlay';\nimport { wrToClassList } from 'ngwr/utils';\n\nimport { WR_TOUR_STEP, WrTourPopup } from './tour-popup';\nimport type { WrTourOptions, WrTourPlacement, WrTourStep } from './types';\n\n/** Fallback order per preferred side — the opposite side first, then the sides. */\nconst FALLBACKS: Record<WrTourPlacement, readonly WrTourPlacement[]> = {\n bottom: ['bottom', 'top', 'right', 'left'],\n top: ['top', 'bottom', 'right', 'left'],\n left: ['left', 'right', 'bottom', 'top'],\n right: ['right', 'left', 'bottom', 'top'],\n};\n\nconst CONNECTED: Record<\n WrTourPlacement,\n {\n originX: 'start' | 'center' | 'end';\n originY: 'top' | 'center' | 'bottom';\n overlayX: 'start' | 'center' | 'end';\n overlayY: 'top' | 'center' | 'bottom';\n }\n> = {\n bottom: { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top' },\n top: { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom' },\n left: { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center' },\n right: { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center' },\n};\n\n/**\n * Guided product tour: a spotlight over one element at a time plus a popup\n * explaining it.\n *\n * Steps are data, not markup — call `start()` with an array and the service owns\n * the overlay, the cut-out, focus and the keyboard. A step whose target is not\n * on the page is skipped rather than shown floating, so a tour survives a\n * feature being hidden behind a flag or a permission.\n *\n * @example\n * ```ts\n * private readonly tour = inject(WrTour);\n *\n * showMeAround(): void {\n * this.tour.start([\n * { target: '[data-tour=\"search\"]', title: 'Search', content: 'Find anything by name.' },\n * { target: '[data-tour=\"filters\"]', content: 'Narrow the list down.', placement: 'right' },\n * ]);\n * }\n * ```\n *\n * @see https://ngwr.dev/reference/services/tour\n */\n@Service()\nexport class WrTour {\n private readonly overlay = inject(WR_OVERLAY);\n private readonly dir = inject(Directionality, { optional: true });\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly injector = inject(EnvironmentInjector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly document = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly location = inject(Location);\n\n private readonly steps = signal<readonly WrTourStep[]>([]);\n private readonly cursor = signal(-1);\n\n private overlayRef: OverlayRef | null = null;\n private focusTrap: ConfigurableFocusTrap | null = null;\n private spotlight: HTMLElement | null = null;\n private detachKeydown: (() => void) | null = null;\n private detachReposition: (() => void) | null = null;\n private restoreFocus: HTMLElement | null = null;\n private autoFocus: WrOverlayAutoFocus = 'dialog';\n /** `focusNext` for the card, see {@link WrTourController}. */\n readonly focusNext = (): boolean => this.autoFocus === 'first-tabbable';\n private stopWatchingUrl: (() => void) | null = null;\n\n /** Whether a tour is running. */\n readonly active = computed(() => this.cursor() >= 0);\n\n /** Zero-based index of the current step, `-1` when idle. */\n readonly index = computed(() => this.cursor());\n\n /** How many steps this tour has. */\n readonly total = computed(() => this.steps().length);\n\n /** The step being shown, or `null` when idle. */\n readonly step = computed<WrTourStep | null>(() => this.steps()[this.cursor()] ?? null);\n\n // Whether any step AFTER the current one can actually be shown. Settled once per\n // move, in `goTo`, because reachability is a DOM question and not a signal.\n private readonly noStepAfter = signal(false);\n\n // The same question looking the other way. Settled in `goTo` for the same reason.\n //\n // `true` at rest, and the asymmetry with `noStepAfter` is deliberate: with no\n // tour running there is no step, so both questions are vacuous, and the pair\n // is set to whatever keeps a naive template honest. `@if (!tour.isFirst())`\n // around a Back button is the obvious way to write it, and at `false` that\n // button appears with no tour on screen.\n private readonly noStepBefore = signal(true);\n\n /**\n * Whether this is the last step the user will see. Not `index() === total() - 1`:\n * a trailing step whose target is missing is skipped, so comparing against the\n * raw count left the primary button reading \"Next\" on the final card and then\n * ending the tour when it was pressed. `false` while no tour is running.\n */\n readonly isLast = computed(() => this.noStepAfter());\n\n /**\n * Whether this is the first step the user will see. Not `index() === 0`, for the\n * mirror of the reason above: a LEADING step whose target is missing is skipped,\n * so the tour opens on a later index and the raw one put a Back button on the\n * first card — one that did nothing at all, because `prev()` walks off the start\n * and returns without moving. `true` while no tour is running — see the signal\n * it reads.\n */\n readonly isFirst = computed(() => this.noStepBefore());\n\n constructor() {\n // Everything this service owns lives OUTSIDE its own injector: a CDK overlay, a\n // div appended to `document.body`, a document keydown listener and two window\n // listeners. Nothing removes them when the injector goes, so a tour running at\n // teardown left its cut-out on the page.\n inject(DestroyRef).onDestroy(() => this.stop());\n }\n\n /**\n * Begin a tour. Restarts if one is already running. A no-op under SSR — a\n * tour is a client-side affordance and there is nothing to spotlight on the\n * server.\n */\n start(steps: readonly WrTourStep[], options: WrTourOptions = {}): void {\n if (!this.isBrowser || steps.length === 0) return;\n this.stop();\n this.steps.set(steps);\n this.autoFocus = options.autoFocus ?? 'dialog';\n this.restoreFocus = this.document.activeElement as HTMLElement | null;\n // A tour belongs to the page it was started on, the way `WrDialog` and\n // `WrDrawerManager` tie a modal to its URL. Nothing ended it on navigation,\n // so following a link mid-tour left the card pointing at an element the\n // router had just removed — the cut-out collapsed to a 12px box at the\n // corner, its 9999px shadow dimming the whole new page, and focus trapped in\n // a card about the page the user had left. `onUrlChange` rather than\n // `subscribe()`, which hears popstate alone and misses `router.navigate()`.\n this.stopWatchingUrl = this.location.onUrlChange(() => this.stop());\n this.goTo(0, 1);\n }\n\n /** Advance; finishes the tour past the last step. */\n next(): void {\n this.goTo(this.cursor() + 1, 1);\n }\n\n /** Go back; stays put on the first step. */\n prev(): void {\n this.goTo(this.cursor() - 1, -1);\n }\n\n /** End the tour and return focus where it was. */\n stop(): void {\n // Unhooked a microtask late, as `WrDialog` does: `Location` notifies with a\n // `forEach`, and unregistering from inside that notification splices the\n // array it is walking, which would skip the listener after ours.\n const unwatch = this.stopWatchingUrl;\n this.stopWatchingUrl = null;\n if (unwatch) queueMicrotask(unwatch);\n this.teardownStep();\n this.steps.set([]);\n this.cursor.set(-1);\n // Back to their resting answers. Without this a finished tour left both\n // holding whatever its last step said, so `isFirst` and `isLast` were the\n // only two signals here that still described a tour that had ended — while\n // `active`, `index`, `total` and `step` all reported idle.\n this.noStepAfter.set(false);\n this.noStepBefore.set(true);\n this.restoreFocus?.focus?.();\n this.restoreFocus = null;\n }\n\n /**\n * Move to `index`, skipping steps whose target is not in the DOM. `direction`\n * says which way to keep skipping, so a missing step never traps the tour\n * between two dead ends.\n */\n private goTo(index: number, direction: 1 | -1): void {\n const steps = this.steps();\n let i = index;\n while (i >= 0 && i < steps.length && this.resolve(steps[i]) === null) i += direction;\n\n if (i < 0) {\n // Ran off the start while going back — stay where we were.\n return;\n }\n if (i >= steps.length) {\n this.stop();\n return;\n }\n\n // Focus inside the card that is about to go stays in the tour: the next card\n // takes it, whatever `autoFocus` says about a card opening.\n const active = this.document.activeElement;\n const hadFocus = !!active && !!this.overlayRef?.overlayElement.contains(active);\n this.teardownStep();\n this.cursor.set(i);\n this.noStepAfter.set(!this.anyResolvableAfter(i));\n this.noStepBefore.set(!this.anyResolvableBefore(i));\n this.openStep(steps[i], hadFocus);\n }\n\n /** Whether the tour has a step past `index` that can actually be shown. */\n private anyResolvableAfter(index: number): boolean {\n const steps = this.steps();\n for (let i = index + 1; i < steps.length; i += 1) {\n if (this.resolve(steps[i]) !== null) return true;\n }\n return false;\n }\n\n /** Whether the tour has a step before `index` that can actually be shown. */\n private anyResolvableBefore(index: number): boolean {\n const steps = this.steps();\n for (let i = index - 1; i >= 0; i -= 1) {\n if (this.resolve(steps[i]) !== null) return true;\n }\n return false;\n }\n\n private resolve(step: WrTourStep): HTMLElement | null {\n if (typeof step.target !== 'string') return step.target.isConnected ? step.target : null;\n return this.document.querySelector<HTMLElement>(step.target);\n }\n\n private openStep(step: WrTourStep, hadFocus: boolean): void {\n const target = this.resolve(step);\n if (!target) return;\n\n target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' });\n\n // The cut-out is a bare element sized to the target with an enormous spread\n // shadow: everything outside it dims, the target itself stays untouched.\n // Cheaper and far more robust than a clip-path polygon, and it needs no\n // recompute when the page reflows beyond moving the box.\n const spotlight = this.document.createElement('div');\n spotlight.className = 'wr-tour__spotlight';\n spotlight.setAttribute('aria-hidden', 'true');\n this.document.body.appendChild(spotlight);\n this.spotlight = spotlight;\n this.placeSpotlight(target);\n\n const placement = step.placement ?? 'bottom';\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(target)\n .withPositions(this.stepPositions(placement, this.isRtl()))\n .withPush(true);\n\n this.overlayRef = this.overlay.create({\n positionStrategy,\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: wrToClassList('wr-tour-overlay', step.panelClass),\n });\n\n // The CDK read the direction once, just now. A tour is long-lived by nature\n // — a step can sit on screen while the user changes a language setting — and\n // without this the card keeps the direction the step opened in, with the\n // 12px gap that held it clear of the spotlight now pointing into it.\n // Per step, because every move disposes this ref and builds the next.\n //\n // The cut-out moves with it. The target itself changes place when the page\n // mirrors, and the spotlight is re-measured only on scroll and resize, so a\n // flip left it highlighting empty space while the card, re-placed by the CDK,\n // pointed at the target sitting under the dim. The flip has already been laid\n // out by the time this runs — the CDK measures the same element right after.\n wrFollowDirection(this.overlayRef, this.dir, this.injector, direction => {\n positionStrategy.withPositions(this.stepPositions(placement, direction === 'rtl'));\n this.placeSpotlight(target);\n });\n\n const portal = new ComponentPortal(\n WrTourPopup,\n null,\n Injector.create({ parent: this.injector, providers: [{ provide: WR_TOUR_STEP, useValue: this }] })\n );\n const ref = this.overlayRef.attach(portal);\n\n // Kept on the instance, not in a local: a trap registers with CDK's\n // `FocusTrapManager` and installs a capture-phase document focus listener, so an\n // undestroyed one leaks per STEP and every tour left a stack of them behind.\n const card = ref.location.nativeElement as HTMLElement;\n this.focusTrap = this.focusTrapFactory.create(card);\n // Onto Next only when asked. Otherwise the card itself takes focus, so the\n // keyboard is in the tour and no button is lit; under `false` only when the\n // card before it held focus, which would otherwise fall to `<body>`.\n wrFocusOverlay(\n card,\n this.focusTrap,\n this.autoFocus === false && hadFocus ? 'dialog' : this.autoFocus,\n this.injector\n );\n\n const onKey = (event: KeyboardEvent): void => {\n // The listener is on the document, so a step shown over a dialog would see the\n // Escape that dialog just handled and close the tour too.\n if (event.key === 'Escape' && !event.defaultPrevented) {\n event.preventDefault();\n this.stop();\n }\n };\n this.document.addEventListener('keydown', onKey);\n this.detachKeydown = () => this.document.removeEventListener('keydown', onKey);\n\n const reposition = (): void => this.placeSpotlight(target);\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n this.detachReposition = () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n };\n }\n\n /**\n * The card's fallback table for one placement, with its inline offsets already\n * mirrored. Built per call rather than per step: the direction can change while\n * the step is on screen, and a table is what has to be rebuilt when it does.\n */\n private stepPositions(placement: WrTourPlacement, isRtl: boolean): ConnectedPosition[] {\n return wrMirrorOffsets(\n FALLBACKS[placement].map(side => ({\n ...CONNECTED[side],\n offsetY: side === 'bottom' ? 12 : side === 'top' ? -12 : 0,\n offsetX: side === 'right' ? 12 : side === 'left' ? -12 : 0,\n })),\n isRtl\n );\n }\n\n private placeSpotlight(target: HTMLElement): void {\n const el = this.spotlight;\n if (!el) return;\n const r = target.getBoundingClientRect();\n const pad = 6;\n el.style.top = `${r.top - pad}px`;\n el.style.left = `${r.left - pad}px`;\n el.style.width = `${r.width + pad * 2}px`;\n el.style.height = `${r.height + pad * 2}px`;\n }\n\n private teardownStep(): void {\n this.focusTrap?.destroy();\n this.focusTrap = null;\n this.detachKeydown?.();\n this.detachKeydown = null;\n this.detachReposition?.();\n this.detachReposition = null;\n this.overlayRef?.dispose();\n this.overlayRef = null;\n this.spotlight?.remove();\n this.spotlight = null;\n }\n\n /**\n * Whether the app reads right-to-left.\n *\n * Optional inject: `Directionality` is root-provided, so this is never null in\n * an app — but a bare `TestBed` that provides nothing should still get a\n * component that works, and defaulting to LTR is the honest fallback.\n */\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,MAAa,eAAe,IAAI,eAAiC,cAAc;AAqB/E,IAAa,cAAb,MAAa,YAAW;CACtB,cAAA;EACE,IAAI,OAAO,cAAc,eA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AAG,EAAE,MAAM,IAAG;EAC7B,GAAG,MAAM,OAAO,GAAG,EAAE,OAAO,IAAG;EAC/B,GAAG,MAAM,QAAQ,GAAG,EAAE,QAAQ,GAAO;EACrC,GAAG,MAAM,SAAS,GAAG,EAAE,SAAS,GAAO;CACzC;CAEQ,eAAY;EAClB,KAAK,WAAW,QAAO;EACvB,KAAK,YAAY;EACjB,KAAK,gBAAe;EACpB,KAAK,gBAAgB;EACrB,KAAK,mBAAkB;EACvB,KAAK,mBAAmB;EACxB,KAAK,YAAY,QAAO;EACxB,KAAK,aAAa;EAClB,KAAK,WAAW,OAAM;EACtB,KAAK,YAAY;CACnB;CASQ,QAAK;EACX,OAAO,KAAK,KAAK,UAAU;CAC7B;CA9TW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAM,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAN,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAM,CAAA;;AAAN,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAM,YAAA,CAAA,EADlB,MAAA,Q"}
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-tree-testing.mjs","names":[],"sources":["../../../projects/lib/tree/testing/wr-tree-node-harness.ts","../../../projects/lib/tree/testing/wr-tree-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 { ComponentHarness, HarnessPredicate, type TestElement } from '@angular/cdk/testing';\n\nimport type { WrTreeNodeHarnessFilters } from './types';\n\n/**\n * Test harness for one node of a `<wr-tree>` — a `role=\"treeitem\"` row.\n *\n * Everything about a tree's shape that a screen reader gets lives on these rows:\n * the list itself is FLAT, with no `role=\"group\"` and no nesting, so `aria-level`,\n * `aria-posinset` and `aria-setsize` are the only place the hierarchy exists. The\n * indent is decoration.\n *\n * @example\n * ```ts\n * const src = await tree.getNode({ label: 'src' });\n *\n * await src.expand();\n * expect(await src.getLevel()).toBe(1);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrTreeNodeHarness extends ComponentHarness {\n /**\n * The row, and nothing else the list can hold.\n *\n * A windowed tree pads its list with `<li class=\"wr-tree__spacer\" role=\"presentation\">`\n * at each end, so `li` would hand back up to two \"nodes\" with no label and no\n * state. `[role=\"treeitem\"]` selects exactly the same set as this class.\n */\n static hostSelector = '.wr-tree__row';\n\n /** Build a predicate that narrows the query. */\n static with(options: WrTreeNodeHarnessFilters = {}): HarnessPredicate<WrTreeNodeHarness> {\n return new HarnessPredicate(WrTreeNodeHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled)\n .addOption(\n 'expanded',\n options.expanded,\n // A leaf is not a closed branch: it announces no `aria-expanded` at all, so\n // it matches neither value rather than answering `false` and turning\n // `{ expanded: false }` into \"every row that is not open\".\n async (harness, expanded) => (await harness.isExpandable()) && (await harness.isExpanded()) === expanded\n )\n .addOption('level', options.level, async (harness, level) => (await harness.getLevel()) === level);\n }\n\n /**\n * The node's label.\n *\n * Read from `.wr-tree__label` rather than from the row's text, so the answer stays\n * the label alone however the row is decorated around it.\n */\n async getLabel(): Promise<string> {\n return (await this.locatorFor('.wr-tree__label')()).text();\n }\n\n /** The node's 1-based depth, as the row announces it (`aria-level`). */\n async getLevel(): Promise<number> {\n return this.announcedNumber('aria-level');\n }\n\n /**\n * The node's 1-based position within its SIBLING GROUP (`aria-posinset`) — not its\n * position in the flat list of visible rows.\n *\n * `src`'s first child is `posinset` 1 even though it is the second row on screen.\n * That is what ARIA asks for, and the whole reason the attribute is needed here:\n * the rendered list cannot express the nesting on its own.\n */\n async getPosInSet(): Promise<number> {\n return this.announcedNumber('aria-posinset');\n }\n\n /** How many nodes are in this node's sibling group, itself included (`aria-setsize`). */\n async getSetSize(): Promise<number> {\n return this.announcedNumber('aria-setsize');\n }\n\n /**\n * The node's index in the full list of VISIBLE nodes — every rendered row plus the\n * ones a window left out, in the order the tree would show them.\n *\n * It is the index the tree's own keyboard code addresses rows by, and while the\n * tree is windowed it is the only way to place a row: DOM order then says nothing,\n * because the rows in the DOM are a slice.\n */\n async getIndex(): Promise<number> {\n return this.announcedNumber('data-tree-index');\n }\n\n /**\n * The row's DOM id, or `null`.\n *\n * Only a windowed tree gives its rows ids, because that is the shape where the\n * list keeps focus and names the cursor row with `aria-activedescendant` — the id\n * exists to be pointed at.\n */\n async getId(): Promise<string | null> {\n return (await this.host()).getAttribute('id');\n }\n\n /**\n * Whether the node is a branch — it has children, whether or not they are showing.\n *\n * From `aria-expanded`: only a branch carries it, and a branch that does not is\n * announced as a leaf, so the user never learns there is anything underneath. The\n * toggle element cannot answer this — a leaf renders a `<span>` with the same\n * `.wr-tree__toggle` class purely to hold the indent.\n */\n async isExpandable(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) !== null;\n }\n\n /** Whether the branch is open. A leaf is never expanded. */\n async isExpanded(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Whether the branch is loading its children (`aria-busy`), which is the time\n * between the first expand of a `hasChildren` node and its `loadChildren`\n * answering.\n */\n async isLoading(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-busy')) === 'true';\n }\n\n /**\n * Open the branch. Already-open branches are left alone; a leaf throws.\n *\n * A lazy branch is waited for: the tree holds a pending task while\n * `loadChildren` runs, so this resolves with the children rendered, or with\n * the error row. A loader that never answers never lets it resolve, and a\n * spec about the loading row itself clicks the toggle through\n * {@link toggleExpand} instead.\n */\n async expand(): Promise<void> {\n if (await this.isExpanded()) return;\n await this.toggleExpand();\n for (let pass = 0; (await this.isLoading()) && pass < 20; pass += 1) await this.forceStabilize();\n\n if (!(await this.isExpanded())) {\n throw new Error(\n `WrTreeNodeHarness.expand(): \"${await this.getLabel()}\" did not open. A disabled node ignores its ` +\n 'own toggle, and so does every node of a disabled tree.'\n );\n }\n }\n\n /** Close the branch. Already-closed branches are left alone; a leaf throws. */\n async collapse(): Promise<void> {\n if (!(await this.isExpanded())) {\n // A closed branch is fine to ask twice; a leaf is a mistake worth naming.\n await this.toggleElement();\n return;\n }\n await this.toggleExpand();\n\n if (await this.isExpanded()) {\n throw new Error(\n `WrTreeNodeHarness.collapse(): \"${await this.getLabel()}\" did not close. A disabled node ignores ` +\n 'its own toggle, and so does every node of a disabled tree.'\n );\n }\n }\n\n /**\n * Click the branch's expand toggle.\n *\n * Expanding is the TOGGLE's job and not the row's: a click anywhere else in the row\n * selects instead, which is the one thing a spec driving this by hand tends to get\n * wrong.\n */\n async toggleExpand(): Promise<void> {\n await (await this.toggleElement()).click();\n }\n\n /**\n * Whether the node is selected.\n *\n * From `aria-selected` rather than the `--selected` modifier: both are public, but\n * the attribute is what a screen reader acts on, and a row that looks selected\n * without saying so is the bug worth catching.\n */\n async isSelected(): Promise<boolean> {\n const host = await this.host();\n // A `cascade` tree announces `aria-checked` in place of `aria-selected`.\n return (\n (await host.getAttribute('aria-selected')) === 'true' || (await host.getAttribute('aria-checked')) === 'true'\n );\n }\n\n /**\n * Whether the node is PARTLY checked: a `cascade` tree's ancestor with some,\n * not all, of what is below it checked (`aria-checked=\"mixed\"`). It is not\n * selected then, and it is not in the value.\n */\n async isMixed(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-checked')) === 'mixed';\n }\n\n /** Whether the row can be dragged right now (`draggable=\"true\"`). */\n async isDraggable(): Promise<boolean> {\n return (await (await this.host()).getAttribute('draggable')) === 'true';\n }\n\n /**\n * Whether the tree offers selection at all.\n *\n * A `selectionMode=\"none\"` tree announces NO `aria-selected` on its rows, which is\n * how an unselectable node differs from one that is merely unselected — the two\n * look identical otherwise.\n */\n async isSelectable(): Promise<boolean> {\n const host = await this.host();\n return (await host.getAttribute('aria-selected')) !== null || (await host.getAttribute('aria-checked')) !== null;\n }\n\n /**\n * Whether the node refuses interaction (`aria-disabled`).\n *\n * True for EVERY node while the whole tree is disabled, not just for the ones the\n * data marks — the row announces the effective state, which is the one a user runs\n * into.\n */\n async isDisabled(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-disabled')) === 'true';\n }\n\n /**\n * Whether the node is where the keyboard cursor sits.\n *\n * The two patterns publish the cursor differently, and this covers both: a tree\n * that renders every row hands the single tab stop to the cursor row (roving\n * tabindex), while a windowed one keeps focus on the list and marks the row with\n * the `--active` modifier plus the list's `aria-activedescendant`.\n * `WrTreeHarness.getActiveNodeLabel()` reads that reference itself.\n */\n async isActive(): Promise<boolean> {\n const host = await this.host();\n return (await host.getAttribute('tabindex')) === '0' || host.hasClass('wr-tree__row--active');\n }\n\n /**\n * Whether the row holds real DOM focus.\n *\n * Deliberately separate from {@link isActive}: in a windowed tree the two DIVERGE\n * by design — focus stays on the `role=\"tree\"` list and only the announced cursor\n * moves — so a spec asserting that a key press moved focus needs to know which of\n * the two it is asking about.\n */\n async isFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\n }\n\n /**\n * Click the node — which SELECTS it. A disabled node, and any node of a\n * `selectionMode=\"none\"` tree, ignores the click.\n *\n * In multi mode a plain click REPLACES the selection rather than adding to it (the\n * component's deliberate choice: one selected node clicked again clears it, and any\n * other click starts over from that node). {@link ctrlClick} is how a selection is\n * accumulated.\n */\n async click(): Promise<void> {\n return (await this.host()).click();\n }\n\n /**\n * Ctrl-click the node — ADDS it to the selection, or removes it, in multi mode.\n *\n * The component takes Cmd as well as Ctrl; the harness sends Ctrl because a unit\n * test has no platform. In single mode it behaves exactly like {@link click}.\n */\n async ctrlClick(): Promise<void> {\n return (await this.host()).click({ control: true });\n }\n\n /** The branch's toggle button, or a failure that says this row is a leaf. */\n private async toggleElement(): Promise<TestElement> {\n // `button` is load-bearing: a leaf renders a `<span>` with the same\n // `.wr-tree__toggle` class to hold the indent, and taking that for a control\n // would report every leaf as a branch that refused to open.\n const toggle = await this.locatorForOptional('button.wr-tree__toggle')();\n if (!toggle) {\n throw new Error(`WrTreeNodeHarness: \"${await this.getLabel()}\" is a leaf — there is no branch to open or close.`);\n }\n return toggle;\n }\n\n /** A numeric attribute every row carries, or a failure that says the row is broken. */\n private async announcedNumber(attribute: string): Promise<number> {\n const value = await (await this.host()).getAttribute(attribute);\n if (value === null) {\n throw new Error(\n `WrTreeNodeHarness: this row announces no \\`${attribute}\\`. Every row of a \\`<wr-tree>\\` carries ` +\n 'one, so a missing value is a rendering fault rather than a state worth reporting as null.'\n );\n }\n return Number.parseInt(value, 10);\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 {\n ContentContainerComponentHarness,\n type HarnessLoader,\n HarnessPredicate,\n TestKey,\n type TestElement,\n} from '@angular/cdk/testing';\n\nimport type { WrTreeHarnessFilters, WrTreeNodeHarnessFilters } from './types';\nimport { WrTreeNodeHarness } from './wr-tree-node-harness';\n\n/** How many levels {@link WrTreeHarness.expandAll} is willing to walk. */\nconst MAX_EXPAND_PASSES = 20;\n\n/**\n * Test harness for `<wr-tree>`, with {@link WrTreeNodeHarness} for one row.\n *\n * The component has two render shapes and this harness covers both:\n * - `openOn=\"inline\"` (default) — the rows live in the host, and the tree is always\n * showing them.\n * - `openOn=\"overlay\"` — a `role=\"combobox\"` trigger opens a panel that is a template\n * portal in the shared overlay container, a sibling of the whole app. Nothing in it\n * is a descendant of the host, so every row is read through the document root,\n * SCOPED by the `aria-controls` id the trigger publishes — which is what keeps two\n * trees on one page from answering with each other's nodes.\n *\n * A tree is data-driven and projects nothing, so the scoped loader exists to point the\n * node queries at the right shape rather than to reach a consumer's own components: the\n * inherited `getHarness(…)` resolves wherever THIS tree's rows are, and there is nothing\n * else in there.\n *\n * Two things the harness cannot do, both jsdom rather than the component:\n * - it never clicks a row by coordinate, and it drives the cursor with the KEYBOARD,\n * which is the accessible path anyway. There is no layout in a unit test, so a\n * hit test would answer with nothing.\n * - it offers no SCROLL for a windowed tree. jsdom does remember a `scrollTop` write,\n * but it fires no `scroll` event for it, so the tree — which learns its offset from\n * that event — would not move until the caller also dispatched one and waited a\n * frame: a scroll gesture that only works because the test faked the notification.\n * The keyboard moves the window honestly instead — see {@link focusLast}. (jsdom has\n * no `Element.scrollTo` at all, which the tree calls while windowed, so a spec for\n * that shape has to stub it.)\n *\n * @example\n * ```ts\n * const tree = await loader.getHarness(WrTreeHarness);\n *\n * await (await tree.getNode({ label: 'src' })).expand();\n * await tree.selectNode({ label: 'main.ts' });\n *\n * expect(await tree.getSelectedLabels()).toEqual(['main.ts']);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrTreeHarness extends ContentContainerComponentHarness {\n static hostSelector = 'wr-tree';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrTreeHarnessFilters = {}): HarnessPredicate<WrTreeHarness> {\n return new HarnessPredicate(WrTreeHarness, options)\n .addOption('text', options.text, (harness, text) =>\n HarnessPredicate.stringMatches(harness.triggerTextIfAny(), text)\n )\n .addOption('nodeLabel', options.nodeLabel, async (harness, label) => {\n for (const shown of await harness.nodeLabelsIfShowing()) {\n if (await HarnessPredicate.stringMatches(shown, label)) return true;\n }\n return false;\n })\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled)\n .addOption('open', options.open, async (harness, open) => (await harness.isOpen()) === open);\n }\n\n /** Whether this tree is the combobox shape (`openOn=\"overlay\"`) rather than inline. */\n async isOverlay(): Promise<boolean> {\n return (await this.host()).hasClass('wr-tree--combobox');\n }\n\n /**\n * Whether the rows are showing.\n *\n * From the trigger's `aria-expanded` rather than the `--open` modifier: both are\n * public, but that attribute is the promise the combobox makes to a screen reader.\n * An inline tree is always open — its rows are part of the host and there is\n * nothing to open or close.\n */\n async isOpen(): Promise<boolean> {\n if (!(await this.isOverlay())) return true;\n return (await (await this.trigger()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Open the panel. An already-open tree — and every inline one — is left alone.\n *\n * Note for a spec with two overlay trees: this clicks, and a click is an outside\n * pointer event for every other open overlay, so it closes any panel already up.\n * There is no second gesture to swap in: the trigger is opened by its `click`\n * handler, and while a real keyboard user reaches that through a `<button>`'s native\n * activation, a SYNTHETIC Enter / Space never produces a click — so a harness cannot\n * open a panel any other way.\n */\n async open(): Promise<void> {\n if (await this.isOpen()) return;\n\n await (await this.trigger()).click();\n if (await this.isOpen()) return;\n\n throw new Error(\n 'WrTreeHarness.open(): the panel did not open. A disabled tree refuses the trigger and closes any ' +\n 'panel that was up, so check `disabled` first.'\n );\n }\n\n /** Close the panel with Escape. An already-closed tree is left alone. */\n async close(): Promise<void> {\n // Not a no-op for an inline tree: asking to close one means the spec believes it\n // has a panel, and it does not.\n const trigger = await this.trigger();\n if (!(await this.isOpen())) return;\n\n // Escape reaches the tree through the CDK's keyboard dispatcher, which hands it to\n // the top-most overlay — so it does not matter that focus may be on a row inside.\n await trigger.sendKeys(TestKey.ESCAPE);\n }\n\n /**\n * Whether the tree refuses interaction.\n *\n * The host modifier is the only answer both shapes carry: an inline tree has no\n * control of its own to mark `disabled`, and a closed overlay tree has no rows to\n * read `aria-disabled` from. The rows do announce it — see\n * {@link WrTreeNodeHarness.isDisabled}.\n */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('wr-tree--disabled');\n }\n\n /**\n * Whether the tree takes more than one selected node.\n *\n * From the list's `aria-multiselectable`, which is what a screen reader acts on. The\n * list does not exist while an overlay panel is closed, so the host modifier answers\n * then — it is only painted in the combobox shape, which is exactly the shape that\n * can be asked while closed.\n */\n async isMultiple(): Promise<boolean> {\n if (await this.isOpen()) {\n return (await (await this.list()).getAttribute('aria-multiselectable')) === 'true';\n }\n return (await this.host()).hasClass('wr-tree--multi');\n }\n\n /**\n * How much the tree lets you select.\n *\n * `'none'` is not \"nothing selected\": it is a tree whose rows announce no\n * `aria-selected` at all, and telling that from `'single'` needs a row — so an empty\n * tree throws rather than guessing.\n */\n async getSelectionMode(): Promise<'none' | 'single' | 'multi'> {\n if (await this.isMultiple()) return 'multi';\n\n const [first] = await this.getNodes();\n if (!first) {\n throw new Error(\n 'WrTreeHarness.getSelectionMode(): this tree renders no nodes, and single vs none is only visible ' +\n 'on a row — `selectionMode=\"none\"` is the absence of `aria-selected`, so there is nothing to read.'\n );\n }\n return (await first.isSelectable()) ? 'single' : 'none';\n }\n\n /**\n * Whether the list is WINDOWED right now.\n *\n * Read from the list's modifier rather than from the input, and that is the point:\n * `virtualScroll` only takes effect when there is something to window, so an empty\n * tree renders the plain shape however the input is set.\n */\n async isVirtual(): Promise<boolean> {\n return (await this.list()).hasClass('wr-tree__list--virtual');\n }\n\n /**\n * The role the list announces — `tree`.\n *\n * Worth asking: rendered without it, the rows are a bag of names, identical on\n * screen and structureless to anyone not looking at it.\n */\n async getRole(): Promise<string | null> {\n return (await this.list()).getAttribute('role');\n }\n\n /**\n * What the trigger shows as the selection: the chip labels joined by `', '` in multi\n * mode, the label in single mode, and `''` when nothing is selected (the placeholder\n * is showing). The `+N more` chip a `maxTagCount` produces is NOT part of it — it is\n * a count rather than a selection, and {@link getOverflowText} reads it. Inline trees\n * have no trigger and throw.\n */\n async getValueText(): Promise<string> {\n await this.trigger();\n\n const chips = await this.getChipLabels();\n if (chips.length > 0) return chips.join(', ');\n\n const value = await this.locatorForOptional('.wr-tree__value')();\n return value ? value.text() : '';\n }\n\n /** The placeholder, or `null` when a selection is hiding it. */\n async getPlaceholder(): Promise<string | null> {\n await this.trigger();\n\n const placeholder = await this.locatorForOptional('.wr-tree__placeholder')();\n return placeholder ? placeholder.text() : null;\n }\n\n /**\n * The chip labels on the trigger, in order (multi mode).\n *\n * The `+N more` overflow chip is not one of them — it is a count, not a selection.\n * {@link getOverflowText} reads it.\n */\n async getChipLabels(): Promise<string[]> {\n await this.trigger();\n\n const labels = await this.locatorForAll('.wr-tree__chip-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /**\n * The `+N more` chip's text, or `null` when every selected node has a chip of its\n * own. Only a `maxTagCount` below the number selected produces one.\n */\n async getOverflowText(): Promise<string | null> {\n await this.trigger();\n\n const more = await this.locatorForOptional('.wr-tree__chip--more')();\n return more ? more.text() : null;\n }\n\n /** Remove one chip by its label. */\n async removeChip(label: string): Promise<void> {\n const labels = await this.getChipLabels();\n const index = labels.indexOf(label);\n if (index < 0) {\n throw new Error(\n `WrTreeHarness.removeChip(): no chip labelled \"${label}\". The trigger shows [${labels.join(', ')}] — ` +\n 'a selection past `maxTagCount` has no chip to remove.'\n );\n }\n\n // Label and remove control are emitted once per chip by the same loop, so the two\n // lists line up by index.\n const removes = await this.locatorForAll('.wr-tree__chip-remove')();\n await removes[index].click();\n }\n\n /** Click the clear (×) control on the trigger. */\n async clear(): Promise<void> {\n await this.trigger();\n\n const clear = await this.locatorForOptional('.wr-tree__clear')();\n if (!clear) {\n throw new Error(\n 'WrTreeHarness.clear(): this trigger has no clear control — `clearable` is off, nothing is ' +\n 'selected, or the tree is disabled.'\n );\n }\n await clear.click();\n }\n\n /**\n * Backspace on the closed overlay trigger — the keyboard route to the ×.\n *\n * In single mode it clears (only while `clearable` is on); in multi mode it\n * drops the LAST chip, one per call, whatever `clearable` says. Both ×\n * controls are `tabindex=\"-1\"` spans inside the trigger, so a key can never\n * reach them directly. In single mode this is the ONLY keyboard route back to\n * no selection; in multi mode a keyboard user can also toggle a row off in the\n * panel ({@link selectNode} with `additive`). {@link clear} / {@link removeChip}\n * prove the pointer path and nothing more.\n *\n * The key is honoured only on the CLOSED trigger, so an open panel is closed\n * first with Escape — the step a keyboard user takes too, since focus sits in\n * the panel while it is up.\n *\n * Does nothing, rather than throwing, where the component does nothing —\n * nothing selected, disabled or read-only — so a spec asserts the outcome on\n * the value.\n */\n async clearByKeyboard(): Promise<void> {\n if (await this.isOpen()) await this.close();\n await (await this.trigger()).sendKeys(TestKey.BACKSPACE);\n }\n\n /**\n * The nodes currently rendered, in the order they are shown.\n *\n * A collapsed branch's children are not rendered at all, so this is the VISIBLE\n * tree — expand first to reach deeper.\n *\n * While {@link isVirtual} is true it is narrower still: the list holds only the\n * window around the scroll offset — padded by a spacer at whichever end has rows\n * outside it, so a window resting at the top has one and a window in the middle has\n * two — and this returns the WINDOW, not the dataset. Nothing in the DOM carries a\n * total —\n * `aria-setsize` counts a SIBLING GROUP, not the flat list — so the harness cannot\n * offer one; {@link WrTreeNodeHarness.getIndex} places each row in the full visible\n * list, and the `[nodes]` data is where the total actually lives.\n *\n * Throws while an overlay panel is closed: the rows do not exist anywhere until it\n * opens, and an empty array reads like a tree that rendered nothing.\n */\n async getNodes(filters: WrTreeNodeHarnessFilters = {}): Promise<WrTreeNodeHarness[]> {\n return this.getAllHarnesses(WrTreeNodeHarness.with(filters));\n }\n\n /** The labels of the nodes currently rendered, in order. */\n async getNodeLabels(): Promise<string[]> {\n const nodes = await this.getNodes();\n return Promise.all(nodes.map(node => node.getLabel()));\n }\n\n /** The first node matching the filters, or a failure that says what is showing. */\n async getNode(filters: WrTreeNodeHarnessFilters): Promise<WrTreeNodeHarness> {\n const [node] = await this.getNodes(filters);\n if (!node) {\n const showing = await this.getNodeLabels();\n throw new Error(\n `WrTreeHarness.getNode(): no node matched ${JSON.stringify(filters)}. The tree is showing ` +\n `[${showing.join(', ')}] — a node inside a collapsed branch is not rendered at all, and a ` +\n 'windowed tree only renders its window.'\n );\n }\n return node;\n }\n\n /**\n * Open the panel if needed, then select the first node matching the filters.\n *\n * `additive` ctrl-clicks instead, which is how a multi-mode selection is built up: a\n * plain click there REPLACES the selection, by the component's own choice.\n *\n * Throws rather than clicking into the void on a disabled node or a\n * `selectionMode=\"none\"` tree — both ignore the click, and the silence turns into a\n * confusing failure at the next assertion. Reach for `getNode().click()` when\n * proving exactly that.\n */\n async selectNode(filters: WrTreeNodeHarnessFilters, options: { additive?: boolean } = {}): Promise<void> {\n await this.open();\n\n const node = await this.getNode(filters);\n const label = await node.getLabel();\n\n if (!(await node.isSelectable())) {\n throw new Error(\n `WrTreeHarness.selectNode(): \"${label}\" announces no selected state, so this tree is in ` +\n 'selectionMode=\"none\" — clicking it cannot select anything.'\n );\n }\n if (await node.isDisabled()) {\n throw new Error(\n `WrTreeHarness.selectNode(): \"${label}\" is disabled and the tree ignores the click. A disabled ` +\n 'TREE disables every node — check isDisabled() on the tree too.'\n );\n }\n\n await (options.additive === true ? node.ctrlClick() : node.click());\n }\n\n /**\n * The labels of the selected nodes, in row order.\n *\n * Only among the rows that are RENDERED: a selected node inside a collapsed branch,\n * or outside a window, is not here. The `[(selected)]` model is the whole set.\n */\n async getSelectedLabels(): Promise<string[]> {\n const nodes = await this.getNodes({ selected: true });\n return Promise.all(nodes.map(node => node.getLabel()));\n }\n\n /**\n * Open every branch, level by level — each pass reveals the next one down.\n *\n * Refuses on a windowed tree instead of half-doing it: only the window is rendered,\n * so the branches outside it cannot be reached from the DOM at all. Write the\n * `[(expanded)]` model there.\n */\n async expandAll(): Promise<void> {\n if (await this.isVirtual()) {\n throw new Error(\n 'WrTreeHarness.expandAll(): a windowed tree renders only its window, so this cannot reach the ' +\n 'branches outside it. Set the `[(expanded)]` model instead.'\n );\n }\n\n for (let pass = 0; pass < MAX_EXPAND_PASSES; pass++) {\n const collapsed = await this.getNodes({ expanded: false });\n if (collapsed.length === 0) return;\n for (const node of collapsed) await node.expand();\n }\n\n throw new Error(\n `WrTreeHarness.expandAll(): still finding closed branches after ${MAX_EXPAND_PASSES} levels — is the ` +\n 'node data recursive?'\n );\n }\n\n /**\n * The label of the node the keyboard cursor is on, or `null`.\n *\n * Read the way the shape publishes it: a windowed tree keeps focus on the list and\n * names the row with `aria-activedescendant` (which goes `null` while the cursor has\n * been scrolled out of the window, so the reference never dangles at a row that was\n * removed), while a plain one hands the single tab stop to the cursor row.\n */\n async getActiveNodeLabel(): Promise<string | null> {\n const nodes = await this.getNodes();\n\n if (await this.isVirtual()) {\n const active = await (await this.list()).getAttribute('aria-activedescendant');\n if (!active) return null;\n for (const node of nodes) {\n if ((await node.getId()) === active) return node.getLabel();\n }\n return null;\n }\n\n for (const node of nodes) {\n if (await node.isActive()) return node.getLabel();\n }\n return null;\n }\n\n /** Move the cursor down one row — ArrowDown. Stops at the last row. */\n async focusNext(): Promise<void> {\n await this.press(TestKey.DOWN_ARROW);\n }\n\n /** Move the cursor up one row — ArrowUp. Stops at the first row. */\n async focusPrevious(): Promise<void> {\n await this.press(TestKey.UP_ARROW);\n }\n\n /** Move the cursor to the first row — Home. */\n async focusFirst(): Promise<void> {\n await this.press(TestKey.HOME);\n }\n\n /**\n * Move the cursor to the last row — End.\n *\n * On a windowed tree this also moves the WINDOW: the tree writes its scroll offset\n * synchronously so the row it is about to point at exists in the same change\n * detection pass. It is the honest way to reach the far end of a window in a unit\n * test — jsdom keeps a `scrollTop` write but never fires the `scroll` event the tree\n * listens for, so a scroll gesture would move the window only for a test that also\n * dispatched the notification itself.\n */\n async focusLast(): Promise<void> {\n await this.press(TestKey.END);\n }\n\n /**\n * ArrowRight on the cursor row — the APG's one key with two jobs: it OPENS a closed\n * branch, and on an already-open one it steps into the first child. A leaf ignores\n * it.\n *\n * These two send the PHYSICAL key, because that is what a keyboard has. Under\n * `dir=\"rtl\"` the tree follows the indent and swaps the pair, so a spec exercising\n * an RTL tree opens with {@link collapseActive} and closes with this one. The\n * names describe the LTR job, which is the one worth naming.\n */\n async expandActive(): Promise<void> {\n await this.press(TestKey.RIGHT_ARROW);\n }\n\n /**\n * ArrowLeft on the cursor row — CLOSES an open branch, and on anything else steps\n * out to the parent row. A root-level leaf ignores it.\n *\n * Physical, and mirrored by the component under `dir=\"rtl\"` — see\n * {@link expandActive}.\n */\n async collapseActive(): Promise<void> {\n await this.press(TestKey.LEFT_ARROW);\n }\n\n /**\n * Select the cursor row from the keyboard — Enter.\n *\n * `additive` holds Ctrl, the keyboard twin of {@link WrTreeNodeHarness.ctrlClick}:\n * in multi mode a plain Enter replaces the selection, Ctrl-Enter adds to it. A\n * disabled row is skipped by the component, silently — assert the model.\n */\n async selectActive(options: { additive?: boolean } = {}): Promise<void> {\n const list = await this.list();\n if (options.additive === true) {\n await list.sendKeys({ control: true }, TestKey.ENTER);\n return;\n }\n await list.sendKeys(TestKey.ENTER);\n }\n\n /**\n * Whether the node with this label is PARTLY checked, in a `cascade` tree.\n * Throws when no such node is showing.\n */\n async isMixed(label: string | RegExp): Promise<boolean> {\n return (await this.getNode({ label })).isMixed();\n }\n\n /**\n * What the tree's live region last said, `''` when it has said nothing. Only a\n * `draggable` tree has one, and only the keyboard move writes to it.\n */\n async getAnnouncement(): Promise<string> {\n const region = await this.scoped('[role=\"status\"]');\n return region ? (await region.text()).trim() : '';\n }\n\n /** The label of the row a keyboard move is holding, or `null`. */\n async getHeldLabel(): Promise<string | null> {\n const [held] = await this.getNodes({ selector: '.wr-tree__row--dragging' });\n return held ? held.getLabel() : null;\n }\n\n /**\n * The row the drop indicator is on and how: `before` or `after` it, or\n * `inside` when the held row would become its child. `null` with no move in\n * progress. The class is all a unit test can read: where the line is drawn\n * is layout, and jsdom has none.\n */\n async getDropMark(): Promise<{ label: string; position: 'before' | 'after' | 'inside' } | null> {\n for (const position of ['before', 'after', 'inside'] as const) {\n const [row] = await this.getNodes({ selector: `.wr-tree__row--drop-${position}` });\n if (row) return { label: await row.getLabel(), position };\n }\n return null;\n }\n\n /**\n * Pick the cursor row up from the keyboard: Alt+Enter. Throws when the row\n * was not picked up, which is a tree that is not `draggable`, a disabled row,\n * a filtered tree, or a row that `loadChildren` supplied.\n */\n async grabActive(): Promise<void> {\n await (await this.list()).sendKeys({ alt: true }, TestKey.ENTER);\n if ((await this.getHeldLabel()) === null) {\n throw new Error(\n 'WrTreeHarness.grabActive(): the cursor row was not picked up. The tree has to be `draggable` with ' +\n 'no `filter` set, and the row enabled and part of `nodes` rather than loaded by `loadChildren`.'\n );\n }\n }\n\n /**\n * Move the held row: `up` and `down` among its siblings, `in` to become the\n * last child of the sibling above, `out` to follow its parent. The PHYSICAL\n * arrows, so under `dir=\"rtl\"` the last two swap, as {@link expandActive}\n * does. A refused step moves nothing: assert {@link getDropMark} or the\n * announcement.\n */\n async moveHeld(direction: 'up' | 'down' | 'in' | 'out'): Promise<void> {\n const keys = { up: TestKey.UP_ARROW, down: TestKey.DOWN_ARROW, in: TestKey.RIGHT_ARROW, out: TestKey.LEFT_ARROW };\n await this.press(keys[direction]);\n }\n\n /** Drop the held row where the indicator is: Enter. The tree emits `nodeMove` and moves nothing itself. */\n async dropHeld(): Promise<void> {\n await this.press(TestKey.ENTER);\n }\n\n /** Put the held row back: Escape. */\n async cancelHeld(): Promise<void> {\n await this.press(TestKey.ESCAPE);\n }\n\n /**\n * The loader every node query runs through — the host inline, THIS tree's overlay\n * panel otherwise.\n *\n * Scoped by the published panel id rather than by `.wr-tree-panel`: the overlay\n * container is shared, so a bare class query would answer with whichever tree\n * happened to open first.\n */\n protected override async getRootHarnessLoader(): Promise<HarnessLoader> {\n if (!(await this.isOverlay())) return super.getRootHarnessLoader();\n return this.documentRootLocatorFactory().harnessLoaderFor(`#${await this.panelId()}`);\n }\n\n /** An element beside the list, in the host inline and in this tree's panel otherwise. */\n private async scoped(selector: string): Promise<TestElement | null> {\n if (!(await this.isOverlay())) return this.locatorForOptional(selector)();\n return this.documentRootLocatorFactory().locatorForOptional(`#${await this.panelId()} ${selector}`)();\n }\n\n /**\n * Send a key to the `role=\"tree\"` list.\n *\n * The list owns the keydown handler in both patterns — the roving-tabindex one\n * focuses a row, whose event bubbles to exactly here — so this is the honest target\n * either way, and the one that works when jsdom has left real focus on `<body>`.\n */\n private async press(key: TestKey): Promise<void> {\n await (await this.list()).sendKeys(key);\n }\n\n /**\n * The `<ul role=\"tree\">` of THIS tree — in the host inline, in this tree's own\n * overlay panel otherwise.\n */\n private async list(): Promise<TestElement> {\n if (!(await this.isOverlay())) return this.locatorFor('.wr-tree__list')();\n return this.documentRootLocatorFactory().locatorFor(`#${await this.panelId()} .wr-tree__list`)();\n }\n\n /** The combobox trigger, or a failure that says this tree renders inline. */\n private async trigger(): Promise<TestElement> {\n const trigger = await this.locatorForOptional('.wr-tree__trigger')();\n if (!trigger) {\n throw new Error(\n 'WrTreeHarness: this tree renders inline, so it has no trigger, no chips and no panel — its rows ' +\n 'are part of the host. `openOn=\"overlay\"` is the combobox shape.'\n );\n }\n return trigger;\n }\n\n /** The id the trigger publishes as `aria-controls`, which its panel carries. */\n private async panelId(): Promise<string> {\n const id = await (await this.trigger()).getAttribute('aria-controls');\n if (!id) {\n throw new Error(\n 'WrTreeHarness: the trigger publishes no `aria-controls` id, so its panel cannot be told apart ' +\n \"from another tree's.\"\n );\n }\n if (!(await this.isOpen())) {\n throw new Error('WrTreeHarness: the panel is closed — call open() first. A closed tree renders no rows.');\n }\n return id;\n }\n\n /** The trigger's text for the `text` filter, or `null` for an inline tree (which never matches). */\n private async triggerTextIfAny(): Promise<string | null> {\n const trigger = await this.locatorForOptional('.wr-tree__trigger')();\n return trigger ? this.getValueText() : null;\n }\n\n /** The rendered labels for the `nodeLabel` filter — a closed tree matches nothing rather than failing. */\n private async nodeLabelsIfShowing(): Promise<string[]> {\n if (!(await this.isOpen())) return [];\n return this.getNodeLabels();\n }\n}\n"],"mappings":";;;;;;;AA6BA,IAAa,oBAAb,MAAa,0BAA0B,iBAAgB;CAQrD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAoC,CAAA,GAAE;EAChD,OAAO,IAAI,iBAAiB,mBAAmB,OAAO,CAAC,CACpD,UAAU,SAAS,QAAQ,QAAQ,SAAS,UAAU,iBAAiB,cAAc,QAAQ,SAAQ,GAAI,KAAK,CAAC,CAAC,CAChH,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,Q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,GAAG;CACxC;CAMQ,MAAM,OAAI;EAChB,IAAI,CAAE,MAAM,KAAK,UAAS,GAAK,OAAO,KAAK,WAAW,gBAAgB,CAAC,CAAA;EACvE,OAAO,KAAK,2BAA0B,CAAE,CAAC,WAAW,IAAI,MAAM,KAAK,QAAO,EAAE,gBAAiB,CAAC,CAAA;CAChG;CAGQ,MAAM,UAAO;EACnB,MAAM,UAAU,MAAM,KAAK,mBAAmB,mBAAmB,CAAC,CAAA;EAClE,IAAI,CAAC,SACH,MAAM,IAAI,MACR,mKACmE;EAGvE,OAAO;CACT;CAGQ,MAAM,UAAO;EACnB,MAAM,KAAK,OAAO,MAAM,KAAK,QAAO,EAAA,CAAI,aAAa,eAAe;EACpE,IAAI,CAAC,IACH,MAAM,IAAI,MACR,oHACwB;EAG5B,IAAI,CAAE,MAAM,KAAK,OAAM,GACrB,MAAM,IAAI,MAAM,wFAAwF;EAE1G,OAAO;CACT;CAGQ,MAAM,mBAAgB;EAE5B,OAAO,MADe,KAAK,mBAAmB,mBAAmB,CAAC,CAAA,IACjD,KAAK,aAAY,IAAK;CACzC;CAGQ,MAAM,sBAAmB;EAC/B,IAAI,CAAE,MAAM,KAAK,OAAM,GAAK,OAAO,CAAA;EACnC,OAAO,KAAK,cAAa;CAC3B"}
1
+ {"version":3,"file":"ngwr-tree-testing.mjs","names":[],"sources":["../../../projects/lib/tree/testing/wr-tree-node-harness.ts","../../../projects/lib/tree/testing/wr-tree-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 { ComponentHarness, HarnessPredicate, type TestElement } from '@angular/cdk/testing';\n\nimport type { WrTreeNodeHarnessFilters } from './types';\n\n/**\n * Test harness for one node of a `<wr-tree>` — a `role=\"treeitem\"` row.\n *\n * Everything about a tree's shape that a screen reader gets lives on these rows:\n * the list itself is FLAT, with no `role=\"group\"` and no nesting, so `aria-level`,\n * `aria-posinset` and `aria-setsize` are the only place the hierarchy exists. The\n * indent is decoration.\n *\n * @example\n * ```ts\n * const src = await tree.getNode({ label: 'src' });\n *\n * await src.expand();\n * expect(await src.getLevel()).toBe(1);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrTreeNodeHarness extends ComponentHarness {\n /**\n * The row, and nothing else the list can hold.\n *\n * A windowed tree pads its list with `<li class=\"wr-tree__spacer\" role=\"presentation\">`\n * at each end, so `li` would hand back up to two \"nodes\" with no label and no\n * state. `[role=\"treeitem\"]` selects exactly the same set as this class.\n */\n static hostSelector = '.wr-tree__row';\n\n /** Build a predicate that narrows the query. */\n static with(options: WrTreeNodeHarnessFilters = {}): HarnessPredicate<WrTreeNodeHarness> {\n return new HarnessPredicate(WrTreeNodeHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled)\n .addOption(\n 'expanded',\n options.expanded,\n // A leaf is not a closed branch: it announces no `aria-expanded` at all, so\n // it matches neither value rather than answering `false` and turning\n // `{ expanded: false }` into \"every row that is not open\".\n async (harness, expanded) => (await harness.isExpandable()) && (await harness.isExpanded()) === expanded\n )\n .addOption('level', options.level, async (harness, level) => (await harness.getLevel()) === level);\n }\n\n /**\n * The node's label.\n *\n * Read from `.wr-tree__label` rather than from the row's text, so the answer stays\n * the label alone however the row is decorated around it.\n */\n async getLabel(): Promise<string> {\n return (await this.locatorFor('.wr-tree__label')()).text();\n }\n\n /** The node's 1-based depth, as the row announces it (`aria-level`). */\n async getLevel(): Promise<number> {\n return this.announcedNumber('aria-level');\n }\n\n /**\n * The node's 1-based position within its SIBLING GROUP (`aria-posinset`) — not its\n * position in the flat list of visible rows.\n *\n * `src`'s first child is `posinset` 1 even though it is the second row on screen.\n * That is what ARIA asks for, and the whole reason the attribute is needed here:\n * the rendered list cannot express the nesting on its own.\n */\n async getPosInSet(): Promise<number> {\n return this.announcedNumber('aria-posinset');\n }\n\n /** How many nodes are in this node's sibling group, itself included (`aria-setsize`). */\n async getSetSize(): Promise<number> {\n return this.announcedNumber('aria-setsize');\n }\n\n /**\n * The node's index in the full list of VISIBLE nodes — every rendered row plus the\n * ones a window left out, in the order the tree would show them.\n *\n * It is the index the tree's own keyboard code addresses rows by, and while the\n * tree is windowed it is the only way to place a row: DOM order then says nothing,\n * because the rows in the DOM are a slice.\n */\n async getIndex(): Promise<number> {\n return this.announcedNumber('data-tree-index');\n }\n\n /**\n * The row's DOM id, or `null`.\n *\n * Only a windowed tree gives its rows ids, because that is the shape where the\n * list keeps focus and names the cursor row with `aria-activedescendant` — the id\n * exists to be pointed at.\n */\n async getId(): Promise<string | null> {\n return (await this.host()).getAttribute('id');\n }\n\n /**\n * Whether the node is a branch — it has children, whether or not they are showing.\n *\n * From `aria-expanded`: only a branch carries it, and a branch that does not is\n * announced as a leaf, so the user never learns there is anything underneath. The\n * toggle element cannot answer this — a leaf renders a `<span>` with the same\n * `.wr-tree__toggle` class purely to hold the indent.\n */\n async isExpandable(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) !== null;\n }\n\n /** Whether the branch is open. A leaf is never expanded. */\n async isExpanded(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Whether the branch is loading its children (`aria-busy`), which is the time\n * between the first expand of a `hasChildren` node and its `loadChildren`\n * answering.\n */\n async isLoading(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-busy')) === 'true';\n }\n\n /**\n * Open the branch. Already-open branches are left alone; a leaf throws.\n *\n * A lazy branch is waited for: the tree holds a pending task while\n * `loadChildren` runs, so this resolves with the children rendered, or with\n * the error row. A loader that never answers never lets it resolve, and a\n * spec about the loading row itself clicks the toggle through\n * {@link toggleExpand} instead.\n */\n async expand(): Promise<void> {\n if (await this.isExpanded()) return;\n await this.toggleExpand();\n for (let pass = 0; (await this.isLoading()) && pass < 20; pass += 1) await this.forceStabilize();\n\n if (!(await this.isExpanded())) {\n throw new Error(\n `WrTreeNodeHarness.expand(): \"${await this.getLabel()}\" did not open. A disabled node ignores its ` +\n 'own toggle, and so does every node of a disabled tree.'\n );\n }\n }\n\n /** Close the branch. Already-closed branches are left alone; a leaf throws. */\n async collapse(): Promise<void> {\n if (!(await this.isExpanded())) {\n // A closed branch is fine to ask twice; a leaf is a mistake worth naming.\n await this.toggleElement();\n return;\n }\n await this.toggleExpand();\n\n if (await this.isExpanded()) {\n throw new Error(\n `WrTreeNodeHarness.collapse(): \"${await this.getLabel()}\" did not close. A disabled node ignores ` +\n 'its own toggle, and so does every node of a disabled tree.'\n );\n }\n }\n\n /**\n * Click the branch's expand toggle.\n *\n * Expanding is the TOGGLE's job and not the row's: a click anywhere else in the row\n * selects instead, which is the one thing a spec driving this by hand tends to get\n * wrong.\n */\n async toggleExpand(): Promise<void> {\n await (await this.toggleElement()).click();\n }\n\n /**\n * Whether the node is selected.\n *\n * From `aria-selected` rather than the `--selected` modifier: both are public, but\n * the attribute is what a screen reader acts on, and a row that looks selected\n * without saying so is the bug worth catching.\n */\n async isSelected(): Promise<boolean> {\n const host = await this.host();\n // A `cascade` tree announces `aria-checked` in place of `aria-selected`.\n return (\n (await host.getAttribute('aria-selected')) === 'true' || (await host.getAttribute('aria-checked')) === 'true'\n );\n }\n\n /**\n * Whether the node is PARTLY checked: a `cascade` tree's ancestor with some,\n * not all, of what is below it checked (`aria-checked=\"mixed\"`). It is not\n * selected then, and it is not in the value.\n */\n async isMixed(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-checked')) === 'mixed';\n }\n\n /** Whether the row can be dragged right now (`draggable=\"true\"`). */\n async isDraggable(): Promise<boolean> {\n return (await (await this.host()).getAttribute('draggable')) === 'true';\n }\n\n /**\n * Whether the tree offers selection at all.\n *\n * A `selectionMode=\"none\"` tree announces NO `aria-selected` on its rows, which is\n * how an unselectable node differs from one that is merely unselected — the two\n * look identical otherwise.\n */\n async isSelectable(): Promise<boolean> {\n const host = await this.host();\n return (await host.getAttribute('aria-selected')) !== null || (await host.getAttribute('aria-checked')) !== null;\n }\n\n /**\n * Whether the node refuses interaction (`aria-disabled`).\n *\n * True for EVERY node while the whole tree is disabled, not just for the ones the\n * data marks — the row announces the effective state, which is the one a user runs\n * into.\n */\n async isDisabled(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-disabled')) === 'true';\n }\n\n /**\n * Whether the node is where the keyboard cursor sits.\n *\n * The two patterns publish the cursor differently, and this covers both: a tree\n * that renders every row hands the single tab stop to the cursor row (roving\n * tabindex), while a windowed one keeps focus on the list and marks the row with\n * the `--active` modifier plus the list's `aria-activedescendant`.\n * `WrTreeHarness.getActiveNodeLabel()` reads that reference itself.\n */\n async isActive(): Promise<boolean> {\n const host = await this.host();\n return (await host.getAttribute('tabindex')) === '0' || host.hasClass('wr-tree__row--active');\n }\n\n /**\n * Whether the row holds real DOM focus.\n *\n * Deliberately separate from {@link isActive}: in a windowed tree the two DIVERGE\n * by design — focus stays on the `role=\"tree\"` list and only the announced cursor\n * moves — so a spec asserting that a key press moved focus needs to know which of\n * the two it is asking about.\n */\n async isFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\n }\n\n /**\n * Click the node — which SELECTS it. A disabled node, and any node of a\n * `selectionMode=\"none\"` tree, ignores the click.\n *\n * In multi mode a plain click REPLACES the selection rather than adding to it (the\n * component's deliberate choice: one selected node clicked again clears it, and any\n * other click starts over from that node). {@link ctrlClick} is how a selection is\n * accumulated.\n */\n async click(): Promise<void> {\n return (await this.host()).click();\n }\n\n /**\n * Ctrl-click the node — ADDS it to the selection, or removes it, in multi mode.\n *\n * The component takes Cmd as well as Ctrl; the harness sends Ctrl because a unit\n * test has no platform. In single mode it behaves exactly like {@link click}.\n */\n async ctrlClick(): Promise<void> {\n return (await this.host()).click({ control: true });\n }\n\n /** The branch's toggle button, or a failure that says this row is a leaf. */\n private async toggleElement(): Promise<TestElement> {\n // `button` is load-bearing: a leaf renders a `<span>` with the same\n // `.wr-tree__toggle` class to hold the indent, and taking that for a control\n // would report every leaf as a branch that refused to open.\n const toggle = await this.locatorForOptional('button.wr-tree__toggle')();\n if (!toggle) {\n throw new Error(`WrTreeNodeHarness: \"${await this.getLabel()}\" is a leaf — there is no branch to open or close.`);\n }\n return toggle;\n }\n\n /** A numeric attribute every row carries, or a failure that says the row is broken. */\n private async announcedNumber(attribute: string): Promise<number> {\n const value = await (await this.host()).getAttribute(attribute);\n if (value === null) {\n throw new Error(\n `WrTreeNodeHarness: this row announces no \\`${attribute}\\`. Every row of a \\`<wr-tree>\\` carries ` +\n 'one, so a missing value is a rendering fault rather than a state worth reporting as null.'\n );\n }\n return Number.parseInt(value, 10);\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 {\n ContentContainerComponentHarness,\n type HarnessLoader,\n HarnessPredicate,\n TestKey,\n type TestElement,\n} from '@angular/cdk/testing';\n\nimport type { WrTreeHarnessFilters, WrTreeNodeHarnessFilters } from './types';\nimport { WrTreeNodeHarness } from './wr-tree-node-harness';\n\n/** How many levels {@link WrTreeHarness.expandAll} is willing to walk. */\nconst MAX_EXPAND_PASSES = 20;\n\n/**\n * Test harness for `<wr-tree>`, with {@link WrTreeNodeHarness} for one row.\n *\n * The component has two render shapes and this harness covers both:\n * - `openOn=\"inline\"` (default) — the rows live in the host, and the tree is always\n * showing them.\n * - `openOn=\"overlay\"` — a `role=\"combobox\"` trigger opens a panel that is a template\n * portal in the shared overlay container, a sibling of the whole app. Nothing in it\n * is a descendant of the host, so every row is read through the document root,\n * SCOPED by the `aria-controls` id the trigger publishes — which is what keeps two\n * trees on one page from answering with each other's nodes.\n *\n * A tree is data-driven and projects nothing, so the scoped loader exists to point the\n * node queries at the right shape rather than to reach a consumer's own components: the\n * inherited `getHarness(…)` resolves wherever THIS tree's rows are, and there is nothing\n * else in there.\n *\n * Two things the harness cannot do, both jsdom rather than the component:\n * - it never clicks a row by coordinate, and it drives the cursor with the KEYBOARD,\n * which is the accessible path anyway. There is no layout in a unit test, so a\n * hit test would answer with nothing.\n * - it offers no SCROLL for a windowed tree. jsdom does remember a `scrollTop` write,\n * but it fires no `scroll` event for it, so the tree — which learns its offset from\n * that event — would not move until the caller also dispatched one and waited a\n * frame: a scroll gesture that only works because the test faked the notification.\n * The keyboard moves the window honestly instead — see {@link focusLast}. (jsdom has\n * no `Element.scrollTo` at all, which the tree calls while windowed, so a spec for\n * that shape has to stub it.)\n *\n * @example\n * ```ts\n * const tree = await loader.getHarness(WrTreeHarness);\n *\n * await (await tree.getNode({ label: 'src' })).expand();\n * await tree.selectNode({ label: 'main.ts' });\n *\n * expect(await tree.getSelectedLabels()).toEqual(['main.ts']);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrTreeHarness extends ContentContainerComponentHarness {\n static hostSelector = 'wr-tree';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrTreeHarnessFilters = {}): HarnessPredicate<WrTreeHarness> {\n return new HarnessPredicate(WrTreeHarness, options)\n .addOption('text', options.text, (harness, text) =>\n HarnessPredicate.stringMatches(harness.triggerTextIfAny(), text)\n )\n .addOption('nodeLabel', options.nodeLabel, async (harness, label) => {\n for (const shown of await harness.nodeLabelsIfShowing()) {\n if (await HarnessPredicate.stringMatches(shown, label)) return true;\n }\n return false;\n })\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled)\n .addOption('open', options.open, async (harness, open) => (await harness.isOpen()) === open);\n }\n\n /** Whether this tree is the combobox shape (`openOn=\"overlay\"`) rather than inline. */\n async isOverlay(): Promise<boolean> {\n return (await this.host()).hasClass('wr-tree--combobox');\n }\n\n /**\n * Whether the rows are showing.\n *\n * From the trigger's `aria-expanded` rather than the `--open` modifier: both are\n * public, but that attribute is the promise the combobox makes to a screen reader.\n * An inline tree is always open — its rows are part of the host and there is\n * nothing to open or close.\n */\n async isOpen(): Promise<boolean> {\n if (!(await this.isOverlay())) return true;\n return (await (await this.trigger()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Open the panel. An already-open tree — and every inline one — is left alone.\n *\n * Note for a spec with two overlay trees: this clicks, and a click is an outside\n * pointer event for every other open overlay, so it closes any panel already up.\n * There is no second gesture to swap in: the trigger is opened by its `click`\n * handler, and while a real keyboard user reaches that through a `<button>`'s native\n * activation, a SYNTHETIC Enter / Space never produces a click — so a harness cannot\n * open a panel any other way.\n */\n async open(): Promise<void> {\n if (await this.isOpen()) return;\n\n await (await this.trigger()).click();\n if (await this.isOpen()) return;\n\n throw new Error(\n 'WrTreeHarness.open(): the panel did not open. A disabled tree refuses the trigger and closes any ' +\n 'panel that was up, so check `disabled` first.'\n );\n }\n\n /** Close the panel with Escape. An already-closed tree is left alone. */\n async close(): Promise<void> {\n // Not a no-op for an inline tree: asking to close one means the spec believes it\n // has a panel, and it does not.\n const trigger = await this.trigger();\n if (!(await this.isOpen())) return;\n\n // Escape reaches the tree through the CDK's keyboard dispatcher, which hands it to\n // the top-most overlay — so it does not matter that focus may be on a row inside.\n await trigger.sendKeys(TestKey.ESCAPE);\n }\n\n /**\n * Whether the tree refuses interaction.\n *\n * The host modifier is the only answer both shapes carry: an inline tree has no\n * control of its own to mark `disabled`, and a closed overlay tree has no rows to\n * read `aria-disabled` from. The rows do announce it — see\n * {@link WrTreeNodeHarness.isDisabled}.\n */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('wr-tree--disabled');\n }\n\n /**\n * Whether the tree takes more than one selected node.\n *\n * From the list's `aria-multiselectable`, which is what a screen reader acts on. The\n * list does not exist while an overlay panel is closed, so the host modifier answers\n * then — it is only painted in the combobox shape, which is exactly the shape that\n * can be asked while closed.\n */\n async isMultiple(): Promise<boolean> {\n if (await this.isOpen()) {\n return (await (await this.list()).getAttribute('aria-multiselectable')) === 'true';\n }\n return (await this.host()).hasClass('wr-tree--multi');\n }\n\n /**\n * How much the tree lets you select.\n *\n * `'none'` is not \"nothing selected\": it is a tree whose rows announce no\n * `aria-selected` at all, and telling that from `'single'` needs a row — so an empty\n * tree throws rather than guessing.\n */\n async getSelectionMode(): Promise<'none' | 'single' | 'multi'> {\n if (await this.isMultiple()) return 'multi';\n\n const [first] = await this.getNodes();\n if (!first) {\n throw new Error(\n 'WrTreeHarness.getSelectionMode(): this tree renders no nodes, and single vs none is only visible ' +\n 'on a row — `selectionMode=\"none\"` is the absence of `aria-selected`, so there is nothing to read.'\n );\n }\n return (await first.isSelectable()) ? 'single' : 'none';\n }\n\n /**\n * Whether the list is WINDOWED right now.\n *\n * Read from the list's modifier rather than from the input, and that is the point:\n * `virtualScroll` only takes effect when there is something to window, so an empty\n * tree renders the plain shape however the input is set.\n */\n async isVirtual(): Promise<boolean> {\n return (await this.list()).hasClass('wr-tree__list--virtual');\n }\n\n /**\n * The role the list announces — `tree`.\n *\n * Worth asking: rendered without it, the rows are a bag of names, identical on\n * screen and structureless to anyone not looking at it.\n */\n async getRole(): Promise<string | null> {\n return (await this.list()).getAttribute('role');\n }\n\n /**\n * What the trigger shows as the selection: the chip labels joined by `', '` in multi\n * mode, the label in single mode, and `''` when nothing is selected (the placeholder\n * is showing). The `+N more` chip a `maxTagCount` produces is NOT part of it — it is\n * a count rather than a selection, and {@link getOverflowText} reads it. Inline trees\n * have no trigger and throw.\n */\n async getValueText(): Promise<string> {\n await this.trigger();\n\n const chips = await this.getChipLabels();\n if (chips.length > 0) return chips.join(', ');\n\n const value = await this.locatorForOptional('.wr-tree__value')();\n return value ? value.text() : '';\n }\n\n /** The placeholder, or `null` when a selection is hiding it. */\n async getPlaceholder(): Promise<string | null> {\n await this.trigger();\n\n const placeholder = await this.locatorForOptional('.wr-tree__placeholder')();\n return placeholder ? placeholder.text() : null;\n }\n\n /**\n * The chip labels on the trigger, in order (multi mode).\n *\n * The `+N more` overflow chip is not one of them — it is a count, not a selection.\n * {@link getOverflowText} reads it.\n */\n async getChipLabels(): Promise<string[]> {\n await this.trigger();\n\n const labels = await this.locatorForAll('.wr-tree__chip-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /**\n * The `+N more` chip's text, or `null` when every selected node has a chip of its\n * own. Only a `maxTagCount` below the number selected produces one.\n */\n async getOverflowText(): Promise<string | null> {\n await this.trigger();\n\n const more = await this.locatorForOptional('.wr-tree__chip--more')();\n return more ? more.text() : null;\n }\n\n /** Remove one chip by its label. */\n async removeChip(label: string): Promise<void> {\n const labels = await this.getChipLabels();\n const index = labels.indexOf(label);\n if (index < 0) {\n throw new Error(\n `WrTreeHarness.removeChip(): no chip labelled \"${label}\". The trigger shows [${labels.join(', ')}] — ` +\n 'a selection past `maxTagCount` has no chip to remove.'\n );\n }\n\n // Label and remove control are emitted once per chip by the same loop, so the two\n // lists line up by index.\n const removes = await this.locatorForAll('.wr-tree__chip-remove')();\n await removes[index].click();\n }\n\n /** Click the clear (×) control on the trigger. */\n async clear(): Promise<void> {\n await this.trigger();\n\n const clear = await this.locatorForOptional('.wr-tree__clear')();\n if (!clear) {\n throw new Error(\n 'WrTreeHarness.clear(): this trigger has no clear control — `clearable` is off, nothing is ' +\n 'selected, or the tree is disabled.'\n );\n }\n await clear.click();\n }\n\n /**\n * Backspace on the closed overlay trigger — the keyboard route to the ×.\n *\n * In single mode it clears (only while `clearable` is on); in multi mode it\n * drops the LAST chip, one per call, whatever `clearable` says. Both ×\n * controls are `tabindex=\"-1\"` spans inside the trigger, so a key can never\n * reach them directly. In single mode this is the ONLY keyboard route back to\n * no selection; in multi mode a keyboard user can also toggle a row off in the\n * panel ({@link selectNode} with `additive`). {@link clear} / {@link removeChip}\n * prove the pointer path and nothing more.\n *\n * The key is honoured only on the CLOSED trigger, so an open panel is closed\n * first with Escape — the step a keyboard user takes too.\n *\n * Does nothing, rather than throwing, where the component does nothing —\n * nothing selected, disabled or read-only — so a spec asserts the outcome on\n * the value.\n */\n async clearByKeyboard(): Promise<void> {\n if (await this.isOpen()) await this.close();\n await (await this.trigger()).sendKeys(TestKey.BACKSPACE);\n }\n\n /**\n * The nodes currently rendered, in the order they are shown.\n *\n * A collapsed branch's children are not rendered at all, so this is the VISIBLE\n * tree — expand first to reach deeper.\n *\n * While {@link isVirtual} is true it is narrower still: the list holds only the\n * window around the scroll offset — padded by a spacer at whichever end has rows\n * outside it, so a window resting at the top has one and a window in the middle has\n * two — and this returns the WINDOW, not the dataset. Nothing in the DOM carries a\n * total —\n * `aria-setsize` counts a SIBLING GROUP, not the flat list — so the harness cannot\n * offer one; {@link WrTreeNodeHarness.getIndex} places each row in the full visible\n * list, and the `[nodes]` data is where the total actually lives.\n *\n * Throws while an overlay panel is closed: the rows do not exist anywhere until it\n * opens, and an empty array reads like a tree that rendered nothing.\n */\n async getNodes(filters: WrTreeNodeHarnessFilters = {}): Promise<WrTreeNodeHarness[]> {\n return this.getAllHarnesses(WrTreeNodeHarness.with(filters));\n }\n\n /** The labels of the nodes currently rendered, in order. */\n async getNodeLabels(): Promise<string[]> {\n const nodes = await this.getNodes();\n return Promise.all(nodes.map(node => node.getLabel()));\n }\n\n /** The first node matching the filters, or a failure that says what is showing. */\n async getNode(filters: WrTreeNodeHarnessFilters): Promise<WrTreeNodeHarness> {\n const [node] = await this.getNodes(filters);\n if (!node) {\n const showing = await this.getNodeLabels();\n throw new Error(\n `WrTreeHarness.getNode(): no node matched ${JSON.stringify(filters)}. The tree is showing ` +\n `[${showing.join(', ')}] — a node inside a collapsed branch is not rendered at all, and a ` +\n 'windowed tree only renders its window.'\n );\n }\n return node;\n }\n\n /**\n * Open the panel if needed, then select the first node matching the filters.\n *\n * `additive` ctrl-clicks instead, which is how a multi-mode selection is built up: a\n * plain click there REPLACES the selection, by the component's own choice.\n *\n * Throws rather than clicking into the void on a disabled node or a\n * `selectionMode=\"none\"` tree — both ignore the click, and the silence turns into a\n * confusing failure at the next assertion. Reach for `getNode().click()` when\n * proving exactly that.\n */\n async selectNode(filters: WrTreeNodeHarnessFilters, options: { additive?: boolean } = {}): Promise<void> {\n await this.open();\n\n const node = await this.getNode(filters);\n const label = await node.getLabel();\n\n if (!(await node.isSelectable())) {\n throw new Error(\n `WrTreeHarness.selectNode(): \"${label}\" announces no selected state, so this tree is in ` +\n 'selectionMode=\"none\" — clicking it cannot select anything.'\n );\n }\n if (await node.isDisabled()) {\n throw new Error(\n `WrTreeHarness.selectNode(): \"${label}\" is disabled and the tree ignores the click. A disabled ` +\n 'TREE disables every node — check isDisabled() on the tree too.'\n );\n }\n\n await (options.additive === true ? node.ctrlClick() : node.click());\n }\n\n /**\n * The labels of the selected nodes, in row order.\n *\n * Only among the rows that are RENDERED: a selected node inside a collapsed branch,\n * or outside a window, is not here. The `[(selected)]` model is the whole set.\n */\n async getSelectedLabels(): Promise<string[]> {\n const nodes = await this.getNodes({ selected: true });\n return Promise.all(nodes.map(node => node.getLabel()));\n }\n\n /**\n * Open every branch, level by level — each pass reveals the next one down.\n *\n * Refuses on a windowed tree instead of half-doing it: only the window is rendered,\n * so the branches outside it cannot be reached from the DOM at all. Write the\n * `[(expanded)]` model there.\n */\n async expandAll(): Promise<void> {\n if (await this.isVirtual()) {\n throw new Error(\n 'WrTreeHarness.expandAll(): a windowed tree renders only its window, so this cannot reach the ' +\n 'branches outside it. Set the `[(expanded)]` model instead.'\n );\n }\n\n for (let pass = 0; pass < MAX_EXPAND_PASSES; pass++) {\n const collapsed = await this.getNodes({ expanded: false });\n if (collapsed.length === 0) return;\n for (const node of collapsed) await node.expand();\n }\n\n throw new Error(\n `WrTreeHarness.expandAll(): still finding closed branches after ${MAX_EXPAND_PASSES} levels — is the ` +\n 'node data recursive?'\n );\n }\n\n /**\n * The label of the node the keyboard cursor is on, or `null`.\n *\n * Read the way the shape publishes it: a windowed tree keeps focus on the list and\n * names the row with `aria-activedescendant` (which goes `null` while the cursor has\n * been scrolled out of the window, so the reference never dangles at a row that was\n * removed), while a plain one hands the single tab stop to the cursor row.\n */\n async getActiveNodeLabel(): Promise<string | null> {\n const nodes = await this.getNodes();\n\n if (await this.isVirtual()) {\n const active = await (await this.list()).getAttribute('aria-activedescendant');\n if (!active) return null;\n for (const node of nodes) {\n if ((await node.getId()) === active) return node.getLabel();\n }\n return null;\n }\n\n for (const node of nodes) {\n if (await node.isActive()) return node.getLabel();\n }\n return null;\n }\n\n /** Move the cursor down one row — ArrowDown. Stops at the last row. */\n async focusNext(): Promise<void> {\n await this.press(TestKey.DOWN_ARROW);\n }\n\n /** Move the cursor up one row — ArrowUp. Stops at the first row. */\n async focusPrevious(): Promise<void> {\n await this.press(TestKey.UP_ARROW);\n }\n\n /** Move the cursor to the first row — Home. */\n async focusFirst(): Promise<void> {\n await this.press(TestKey.HOME);\n }\n\n /**\n * Move the cursor to the last row — End.\n *\n * On a windowed tree this also moves the WINDOW: the tree writes its scroll offset\n * synchronously so the row it is about to point at exists in the same change\n * detection pass. It is the honest way to reach the far end of a window in a unit\n * test — jsdom keeps a `scrollTop` write but never fires the `scroll` event the tree\n * listens for, so a scroll gesture would move the window only for a test that also\n * dispatched the notification itself.\n */\n async focusLast(): Promise<void> {\n await this.press(TestKey.END);\n }\n\n /**\n * ArrowRight on the cursor row — the APG's one key with two jobs: it OPENS a closed\n * branch, and on an already-open one it steps into the first child. A leaf ignores\n * it.\n *\n * These two send the PHYSICAL key, because that is what a keyboard has. Under\n * `dir=\"rtl\"` the tree follows the indent and swaps the pair, so a spec exercising\n * an RTL tree opens with {@link collapseActive} and closes with this one. The\n * names describe the LTR job, which is the one worth naming.\n */\n async expandActive(): Promise<void> {\n await this.press(TestKey.RIGHT_ARROW);\n }\n\n /**\n * ArrowLeft on the cursor row — CLOSES an open branch, and on anything else steps\n * out to the parent row. A root-level leaf ignores it.\n *\n * Physical, and mirrored by the component under `dir=\"rtl\"` — see\n * {@link expandActive}.\n */\n async collapseActive(): Promise<void> {\n await this.press(TestKey.LEFT_ARROW);\n }\n\n /**\n * Select the cursor row from the keyboard — Enter.\n *\n * `additive` holds Ctrl, the keyboard twin of {@link WrTreeNodeHarness.ctrlClick}:\n * in multi mode a plain Enter replaces the selection, Ctrl-Enter adds to it. A\n * disabled row is skipped by the component, silently — assert the model.\n */\n async selectActive(options: { additive?: boolean } = {}): Promise<void> {\n const list = await this.list();\n if (options.additive === true) {\n await list.sendKeys({ control: true }, TestKey.ENTER);\n return;\n }\n await list.sendKeys(TestKey.ENTER);\n }\n\n /**\n * Whether the node with this label is PARTLY checked, in a `cascade` tree.\n * Throws when no such node is showing.\n */\n async isMixed(label: string | RegExp): Promise<boolean> {\n return (await this.getNode({ label })).isMixed();\n }\n\n /**\n * What the tree's live region last said, `''` when it has said nothing. Only a\n * `draggable` tree has one, and only the keyboard move writes to it.\n */\n async getAnnouncement(): Promise<string> {\n const region = await this.scoped('[role=\"status\"]');\n return region ? (await region.text()).trim() : '';\n }\n\n /** The label of the row a keyboard move is holding, or `null`. */\n async getHeldLabel(): Promise<string | null> {\n const [held] = await this.getNodes({ selector: '.wr-tree__row--dragging' });\n return held ? held.getLabel() : null;\n }\n\n /**\n * The row the drop indicator is on and how: `before` or `after` it, or\n * `inside` when the held row would become its child. `null` with no move in\n * progress. The class is all a unit test can read: where the line is drawn\n * is layout, and jsdom has none.\n */\n async getDropMark(): Promise<{ label: string; position: 'before' | 'after' | 'inside' } | null> {\n for (const position of ['before', 'after', 'inside'] as const) {\n const [row] = await this.getNodes({ selector: `.wr-tree__row--drop-${position}` });\n if (row) return { label: await row.getLabel(), position };\n }\n return null;\n }\n\n /**\n * Pick the cursor row up from the keyboard: Alt+Enter. Throws when the row\n * was not picked up, which is a tree that is not `draggable`, a disabled row,\n * a filtered tree, or a row that `loadChildren` supplied.\n */\n async grabActive(): Promise<void> {\n await (await this.list()).sendKeys({ alt: true }, TestKey.ENTER);\n if ((await this.getHeldLabel()) === null) {\n throw new Error(\n 'WrTreeHarness.grabActive(): the cursor row was not picked up. The tree has to be `draggable` with ' +\n 'no `filter` set, and the row enabled and part of `nodes` rather than loaded by `loadChildren`.'\n );\n }\n }\n\n /**\n * Move the held row: `up` and `down` among its siblings, `in` to become the\n * last child of the sibling above, `out` to follow its parent. The PHYSICAL\n * arrows, so under `dir=\"rtl\"` the last two swap, as {@link expandActive}\n * does. A refused step moves nothing: assert {@link getDropMark} or the\n * announcement.\n */\n async moveHeld(direction: 'up' | 'down' | 'in' | 'out'): Promise<void> {\n const keys = { up: TestKey.UP_ARROW, down: TestKey.DOWN_ARROW, in: TestKey.RIGHT_ARROW, out: TestKey.LEFT_ARROW };\n await this.press(keys[direction]);\n }\n\n /** Drop the held row where the indicator is: Enter. The tree emits `nodeMove` and moves nothing itself. */\n async dropHeld(): Promise<void> {\n await this.press(TestKey.ENTER);\n }\n\n /** Put the held row back: Escape. */\n async cancelHeld(): Promise<void> {\n await this.press(TestKey.ESCAPE);\n }\n\n /**\n * The loader every node query runs through — the host inline, THIS tree's overlay\n * panel otherwise.\n *\n * Scoped by the published panel id rather than by `.wr-tree-panel`: the overlay\n * container is shared, so a bare class query would answer with whichever tree\n * happened to open first.\n */\n protected override async getRootHarnessLoader(): Promise<HarnessLoader> {\n if (!(await this.isOverlay())) return super.getRootHarnessLoader();\n return this.documentRootLocatorFactory().harnessLoaderFor(`#${await this.panelId()}`);\n }\n\n /** An element beside the list, in the host inline and in this tree's panel otherwise. */\n private async scoped(selector: string): Promise<TestElement | null> {\n if (!(await this.isOverlay())) return this.locatorForOptional(selector)();\n return this.documentRootLocatorFactory().locatorForOptional(`#${await this.panelId()} ${selector}`)();\n }\n\n /**\n * Send a key to the `role=\"tree\"` list.\n *\n * The list owns the keydown handler in both patterns — the roving-tabindex one\n * focuses a row, whose event bubbles to exactly here — so this is the honest target\n * either way, and the one that works when jsdom has left real focus on `<body>`.\n */\n private async press(key: TestKey): Promise<void> {\n await (await this.list()).sendKeys(key);\n }\n\n /**\n * The `<ul role=\"tree\">` of THIS tree — in the host inline, in this tree's own\n * overlay panel otherwise.\n */\n private async list(): Promise<TestElement> {\n if (!(await this.isOverlay())) return this.locatorFor('.wr-tree__list')();\n return this.documentRootLocatorFactory().locatorFor(`#${await this.panelId()} .wr-tree__list`)();\n }\n\n /** The combobox trigger, or a failure that says this tree renders inline. */\n private async trigger(): Promise<TestElement> {\n const trigger = await this.locatorForOptional('.wr-tree__trigger')();\n if (!trigger) {\n throw new Error(\n 'WrTreeHarness: this tree renders inline, so it has no trigger, no chips and no panel — its rows ' +\n 'are part of the host. `openOn=\"overlay\"` is the combobox shape.'\n );\n }\n return trigger;\n }\n\n /** The id the trigger publishes as `aria-controls`, which its panel carries. */\n private async panelId(): Promise<string> {\n const id = await (await this.trigger()).getAttribute('aria-controls');\n if (!id) {\n throw new Error(\n 'WrTreeHarness: the trigger publishes no `aria-controls` id, so its panel cannot be told apart ' +\n \"from another tree's.\"\n );\n }\n if (!(await this.isOpen())) {\n throw new Error('WrTreeHarness: the panel is closed — call open() first. A closed tree renders no rows.');\n }\n return id;\n }\n\n /** The trigger's text for the `text` filter, or `null` for an inline tree (which never matches). */\n private async triggerTextIfAny(): Promise<string | null> {\n const trigger = await this.locatorForOptional('.wr-tree__trigger')();\n return trigger ? this.getValueText() : null;\n }\n\n /** The rendered labels for the `nodeLabel` filter — a closed tree matches nothing rather than failing. */\n private async nodeLabelsIfShowing(): Promise<string[]> {\n if (!(await this.isOpen())) return [];\n return this.getNodeLabels();\n }\n}\n"],"mappings":";;;;;;;AA6BA,IAAa,oBAAb,MAAa,0BAA0B,iBAAgB;CAQrD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAoC,CAAA,GAAE;EAChD,OAAO,IAAI,iBAAiB,mBAAmB,OAAO,CAAC,CACpD,UAAU,SAAS,QAAQ,QAAQ,SAAS,UAAU,iBAAiB,cAAc,QAAQ,SAAQ,GAAI,KAAK,CAAC,CAAC,CAChH,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ,CAAC,CAC/G,UAAU,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