ngwr 16.7.1 → 16.9.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 (236) hide show
  1. package/charts/donut-chart/styles/_index.scss +9 -3
  2. package/charts/meter-group/styles/_index.scss +8 -1
  3. package/charts/sparkline/styles/_index.scss +6 -3
  4. package/command-palette/styles/_index.scss +10 -0
  5. package/descriptions/styles/_index.scss +91 -0
  6. package/fesm2022/ngwr-anchor.mjs +48 -10
  7. package/fesm2022/ngwr-anchor.mjs.map +1 -1
  8. package/fesm2022/ngwr-carousel.mjs +3 -2
  9. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  10. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -1
  11. package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
  12. package/fesm2022/ngwr-charts-core.mjs +17 -0
  13. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  14. package/fesm2022/ngwr-charts-donut-chart-testing.mjs +27 -0
  15. package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
  16. package/fesm2022/ngwr-charts-donut-chart.mjs +54 -6
  17. package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
  18. package/fesm2022/ngwr-charts-meter-group-testing.mjs +27 -0
  19. package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
  20. package/fesm2022/ngwr-charts-meter-group.mjs +54 -6
  21. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  22. package/fesm2022/ngwr-charts-sparkline-testing.mjs +27 -0
  23. package/fesm2022/ngwr-charts-sparkline-testing.mjs.map +1 -1
  24. package/fesm2022/ngwr-charts-sparkline.mjs +45 -4
  25. package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
  26. package/fesm2022/ngwr-checkbox.mjs +38 -3
  27. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  28. package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -1
  29. package/fesm2022/ngwr-color-picker.mjs +4 -3
  30. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  31. package/fesm2022/ngwr-command-palette.mjs +39 -19
  32. package/fesm2022/ngwr-command-palette.mjs.map +1 -1
  33. package/fesm2022/ngwr-compare.mjs +4 -0
  34. package/fesm2022/ngwr-compare.mjs.map +1 -1
  35. package/fesm2022/ngwr-context-menu.mjs +7 -2
  36. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  37. package/fesm2022/ngwr-cookie.mjs +6 -3
  38. package/fesm2022/ngwr-cookie.mjs.map +1 -1
  39. package/fesm2022/ngwr-date-stamp-testing.mjs +3 -0
  40. package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -1
  41. package/fesm2022/ngwr-date-stamp.mjs +81 -4
  42. package/fesm2022/ngwr-date-stamp.mjs.map +1 -1
  43. package/fesm2022/ngwr-date.mjs +16 -2
  44. package/fesm2022/ngwr-date.mjs.map +1 -1
  45. package/fesm2022/ngwr-density.mjs +4 -3
  46. package/fesm2022/ngwr-density.mjs.map +1 -1
  47. package/fesm2022/ngwr-descriptions.mjs +77 -20
  48. package/fesm2022/ngwr-descriptions.mjs.map +1 -1
  49. package/fesm2022/ngwr-dialog.mjs +10 -7
  50. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  51. package/fesm2022/ngwr-directives.mjs +12 -0
  52. package/fesm2022/ngwr-directives.mjs.map +1 -1
  53. package/fesm2022/ngwr-drawer.mjs +14 -8
  54. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  55. package/fesm2022/ngwr-editor.mjs +1 -0
  56. package/fesm2022/ngwr-editor.mjs.map +1 -1
  57. package/fesm2022/ngwr-file-upload.mjs +4 -5
  58. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  59. package/fesm2022/ngwr-form.mjs.map +1 -1
  60. package/fesm2022/ngwr-hotkey.mjs +10 -5
  61. package/fesm2022/ngwr-hotkey.mjs.map +1 -1
  62. package/fesm2022/ngwr-i18n-ar.mjs +18 -5
  63. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  64. package/fesm2022/ngwr-i18n-cs.mjs +18 -5
  65. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  66. package/fesm2022/ngwr-i18n-de.mjs +18 -5
  67. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  68. package/fesm2022/ngwr-i18n-en.mjs +18 -5
  69. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  70. package/fesm2022/ngwr-i18n-es.mjs +18 -5
  71. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  72. package/fesm2022/ngwr-i18n-fr.mjs +18 -5
  73. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  74. package/fesm2022/ngwr-i18n-he.mjs +18 -5
  75. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  76. package/fesm2022/ngwr-i18n-hi.mjs +18 -5
  77. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  78. package/fesm2022/ngwr-i18n-id.mjs +18 -5
  79. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  80. package/fesm2022/ngwr-i18n-it.mjs +18 -5
  81. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  82. package/fesm2022/ngwr-i18n-ja.mjs +18 -5
  83. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  84. package/fesm2022/ngwr-i18n-kk.mjs +18 -5
  85. package/fesm2022/ngwr-i18n-kk.mjs.map +1 -1
  86. package/fesm2022/ngwr-i18n-ko.mjs +18 -5
  87. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  88. package/fesm2022/ngwr-i18n-nl.mjs +18 -5
  89. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  90. package/fesm2022/ngwr-i18n-pl.mjs +18 -5
  91. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  92. package/fesm2022/ngwr-i18n-pt.mjs +18 -5
  93. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  94. package/fesm2022/ngwr-i18n-ru.mjs +18 -5
  95. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  96. package/fesm2022/ngwr-i18n-sv.mjs +18 -5
  97. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  98. package/fesm2022/ngwr-i18n-tr.mjs +18 -5
  99. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  100. package/fesm2022/ngwr-i18n-uk.mjs +18 -5
  101. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  102. package/fesm2022/ngwr-i18n-vi.mjs +18 -5
  103. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  104. package/fesm2022/ngwr-i18n-zh-tw.mjs +18 -5
  105. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  106. package/fesm2022/ngwr-i18n-zh.mjs +18 -5
  107. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  108. package/fesm2022/ngwr-i18n.mjs +7 -6
  109. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  110. package/fesm2022/ngwr-image-cropper-testing.mjs +33 -0
  111. package/fesm2022/ngwr-image-cropper-testing.mjs.map +1 -1
  112. package/fesm2022/ngwr-image-cropper.mjs +536 -30
  113. package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
  114. package/fesm2022/ngwr-input-number.mjs +33 -10
  115. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  116. package/fesm2022/ngwr-input-otp.mjs +24 -10
  117. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  118. package/fesm2022/ngwr-input.mjs +2 -2
  119. package/fesm2022/ngwr-input.mjs.map +1 -1
  120. package/fesm2022/ngwr-knob.mjs +5 -0
  121. package/fesm2022/ngwr-knob.mjs.map +1 -1
  122. package/fesm2022/ngwr-lightbox.mjs +5 -3
  123. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  124. package/fesm2022/ngwr-mention.mjs +2 -0
  125. package/fesm2022/ngwr-mention.mjs.map +1 -1
  126. package/fesm2022/ngwr-meta.mjs +43 -8
  127. package/fesm2022/ngwr-meta.mjs.map +1 -1
  128. package/fesm2022/ngwr-overlay.mjs +51 -2
  129. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  130. package/fesm2022/ngwr-pagination.mjs +1 -1
  131. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  132. package/fesm2022/ngwr-pipes.mjs +160 -8
  133. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  134. package/fesm2022/ngwr-popconfirm.mjs +2 -2
  135. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  136. package/fesm2022/ngwr-qr.mjs +65 -7
  137. package/fesm2022/ngwr-qr.mjs.map +1 -1
  138. package/fesm2022/ngwr-schema-form.mjs +2 -2
  139. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  140. package/fesm2022/ngwr-scroll.mjs +1 -2
  141. package/fesm2022/ngwr-scroll.mjs.map +1 -1
  142. package/fesm2022/ngwr-slider.mjs +22 -17
  143. package/fesm2022/ngwr-slider.mjs.map +1 -1
  144. package/fesm2022/ngwr-speed-dial.mjs +30 -1
  145. package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
  146. package/fesm2022/ngwr-statistic.mjs +1 -1
  147. package/fesm2022/ngwr-stepper-testing.mjs +7 -1
  148. package/fesm2022/ngwr-stepper-testing.mjs.map +1 -1
  149. package/fesm2022/ngwr-stepper.mjs +55 -4
  150. package/fesm2022/ngwr-stepper.mjs.map +1 -1
  151. package/fesm2022/ngwr-switch.mjs +33 -3
  152. package/fesm2022/ngwr-switch.mjs.map +1 -1
  153. package/fesm2022/ngwr-timeline.mjs +4 -0
  154. package/fesm2022/ngwr-timeline.mjs.map +1 -1
  155. package/fesm2022/ngwr-toolbar.mjs +171 -16
  156. package/fesm2022/ngwr-toolbar.mjs.map +1 -1
  157. package/fesm2022/ngwr-tour.mjs +8 -3
  158. package/fesm2022/ngwr-tour.mjs.map +1 -1
  159. package/fesm2022/ngwr-transfer.mjs +3 -2
  160. package/fesm2022/ngwr-transfer.mjs.map +1 -1
  161. package/fesm2022/ngwr-tree.mjs +1 -1
  162. package/fesm2022/ngwr-utils.mjs +46 -8
  163. package/fesm2022/ngwr-utils.mjs.map +1 -1
  164. package/fesm2022/ngwr-version.mjs +1 -1
  165. package/fesm2022/ngwr-version.mjs.map +1 -1
  166. package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
  167. package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
  168. package/i18n/ar.json +18 -5
  169. package/i18n/cs.json +18 -5
  170. package/i18n/de.json +18 -5
  171. package/i18n/en.json +18 -5
  172. package/i18n/es.json +18 -5
  173. package/i18n/fr.json +18 -5
  174. package/i18n/he.json +18 -5
  175. package/i18n/hi.json +18 -5
  176. package/i18n/id.json +18 -5
  177. package/i18n/it.json +18 -5
  178. package/i18n/ja.json +18 -5
  179. package/i18n/kk.json +18 -5
  180. package/i18n/ko.json +18 -5
  181. package/i18n/nl.json +18 -5
  182. package/i18n/pl.json +18 -5
  183. package/i18n/pt.json +18 -5
  184. package/i18n/ru.json +18 -5
  185. package/i18n/sv.json +18 -5
  186. package/i18n/tr.json +18 -5
  187. package/i18n/uk.json +18 -5
  188. package/i18n/vi.json +18 -5
  189. package/i18n/zh-TW.json +18 -5
  190. package/i18n/zh.json +18 -5
  191. package/image-cropper/styles/_index.scss +30 -1
  192. package/llms-full.txt +9 -9
  193. package/package.json +1 -1
  194. package/schematics/use/rule.js +1 -0
  195. package/schematics/use/symbol-map.json +2 -0
  196. package/skills/ngwr/SKILL.md +2 -2
  197. package/stepper/styles/_index.scss +33 -0
  198. package/tour/styles/_index.scss +11 -7
  199. package/types/ngwr-anchor.d.ts +14 -1
  200. package/types/ngwr-charts-donut-chart-testing.d.ts +32 -3
  201. package/types/ngwr-charts-donut-chart.d.ts +45 -6
  202. package/types/ngwr-charts-meter-group-testing.d.ts +29 -1
  203. package/types/ngwr-charts-meter-group.d.ts +43 -4
  204. package/types/ngwr-charts-sparkline-testing.d.ts +32 -2
  205. package/types/ngwr-charts-sparkline.d.ts +42 -3
  206. package/types/ngwr-checkbox.d.ts +14 -0
  207. package/types/ngwr-color-picker-testing.d.ts +1 -1
  208. package/types/ngwr-command-palette.d.ts +2 -1
  209. package/types/ngwr-date-stamp-testing.d.ts +2 -0
  210. package/types/ngwr-date-stamp.d.ts +41 -2
  211. package/types/ngwr-date.d.ts +3 -1
  212. package/types/ngwr-descriptions.d.ts +33 -5
  213. package/types/ngwr-dialog.d.ts +11 -6
  214. package/types/ngwr-directives.d.ts +1 -0
  215. package/types/ngwr-drawer.d.ts +12 -4
  216. package/types/ngwr-file-upload.d.ts +1 -1
  217. package/types/ngwr-form.d.ts +4 -0
  218. package/types/ngwr-hotkey.d.ts +2 -0
  219. package/types/ngwr-image-cropper-testing.d.ts +33 -1
  220. package/types/ngwr-image-cropper.d.ts +214 -6
  221. package/types/ngwr-input-number.d.ts +14 -2
  222. package/types/ngwr-input-otp.d.ts +2 -0
  223. package/types/ngwr-lightbox.d.ts +1 -0
  224. package/types/ngwr-meta.d.ts +13 -1
  225. package/types/ngwr-overlay.d.ts +20 -1
  226. package/types/ngwr-pipes.d.ts +125 -1
  227. package/types/ngwr-qr.d.ts +17 -0
  228. package/types/ngwr-slider.d.ts +3 -1
  229. package/types/ngwr-speed-dial.d.ts +10 -0
  230. package/types/ngwr-stepper-testing.d.ts +10 -0
  231. package/types/ngwr-stepper.d.ts +47 -1
  232. package/types/ngwr-switch.d.ts +13 -0
  233. package/types/ngwr-toolbar.d.ts +27 -0
  234. package/types/ngwr-transfer.d.ts +2 -0
  235. package/types/ngwr-utils.d.ts +61 -2
  236. package/types/ngwr-version.d.ts +1 -1
@@ -1,21 +1,157 @@
1
1
  import * as i0 from "@angular/core";
2
- import { Component, ViewEncapsulation, input } from "@angular/core";
2
+ import { Component, ElementRef, ViewEncapsulation, afterRenderEffect, computed, inject, input } from "@angular/core";
3
3
  import { coerceBooleanProperty } from "@angular/cdk/coercion";
4
- import { wrCheckStyles } from "ngwr/utils";
4
+ import { WR_KEYS, wrCheckStyles, wrHasModifier } from "ngwr/utils";
5
+ import { Directionality } from "@angular/cdk/bidi";
5
6
  /**
6
7
  * @license
7
8
  *
8
9
  * Use of this source code is governed by an MIT-style license that can be
9
10
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
10
11
  */
12
+ const CONTROL_SELECTOR = "a[href], button, input:not([type=\"hidden\"]), select, textarea, [contenteditable], [tabindex]";
13
+ const COMPOSITE_SELECTOR = [
14
+ "radiogroup",
15
+ "tablist",
16
+ "listbox",
17
+ "menu",
18
+ "menubar",
19
+ "slider",
20
+ "spinbutton",
21
+ "combobox",
22
+ "grid",
23
+ "tree",
24
+ "treegrid"
25
+ ].map((role) => `[role="${role}"]`).join(", ");
26
+ function isVisible(el) {
27
+ if (typeof el.checkVisibility !== "function") return true;
28
+ return el.checkVisibility({ visibilityProperty: true });
29
+ }
30
+ const NON_TEXT_INPUTS = /* @__PURE__ */ new Set([
31
+ "button",
32
+ "checkbox",
33
+ "submit",
34
+ "reset",
35
+ "image",
36
+ "color",
37
+ "file"
38
+ ]);
11
39
  var WrToolbar = class WrToolbar {
40
+ host = inject(ElementRef).nativeElement;
41
+ dir = inject(Directionality, { optional: true });
42
+ isRtl = computed(() => this.dir?.valueSignal() === "rtl", ...ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []);
12
43
  constructor() {
13
44
  if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("toolbar");
45
+ afterRenderEffect((onCleanup) => {
46
+ if (this.arrowKeys()) onCleanup(this.attachRoving());
47
+ });
14
48
  }
15
49
  responsive = input(false, {
16
50
  ...ngDevMode ? { debugName: "responsive" } : /* istanbul ignore next */ {},
17
51
  transform: coerceBooleanProperty
18
52
  });
53
+ arrowKeys = input(false, {
54
+ ...ngDevMode ? { debugName: "arrowKeys" } : /* istanbul ignore next */ {},
55
+ transform: coerceBooleanProperty
56
+ });
57
+ attachRoving() {
58
+ const host = this.host;
59
+ const original = /* @__PURE__ */ new Map();
60
+ const written = /* @__PURE__ */ new Map();
61
+ const changedByConsumer = (el) => written.get(el) !== el.getAttribute("tabindex");
62
+ let stop = null;
63
+ const controls = () => Array.from(host.querySelectorAll(CONTROL_SELECTOR)).filter((el) => {
64
+ if (el.matches(":disabled") || el.closest("[hidden], [inert]") || !isVisible(el)) return false;
65
+ if (changedByConsumer(el) && Number(el.getAttribute("tabindex")) < 0) return false;
66
+ return !this.ownsArrows(el);
67
+ });
68
+ const restore = (el, value) => {
69
+ if (!changedByConsumer(el)) {
70
+ if (value === null) el.removeAttribute("tabindex");
71
+ else el.setAttribute("tabindex", value);
72
+ }
73
+ written.delete(el);
74
+ };
75
+ const sync = () => {
76
+ const all = controls();
77
+ for (const [el, value] of original) {
78
+ if (all.includes(el)) continue;
79
+ restore(el, value);
80
+ original.delete(el);
81
+ }
82
+ if (!stop || !all.includes(stop)) stop = all[0] ?? null;
83
+ for (const el of all) {
84
+ if (!original.has(el) || changedByConsumer(el)) original.set(el, el.getAttribute("tabindex"));
85
+ const value = el === stop ? "0" : "-1";
86
+ el.setAttribute("tabindex", value);
87
+ written.set(el, value);
88
+ }
89
+ };
90
+ const onFocusin = (event) => {
91
+ const target = event.target;
92
+ if (target instanceof HTMLElement && controls().includes(target)) {
93
+ stop = target;
94
+ sync();
95
+ }
96
+ };
97
+ const onKeydown = (event) => {
98
+ const target = event.target;
99
+ if (!(target instanceof HTMLElement) || event.defaultPrevented || wrHasModifier(event)) return;
100
+ const all = controls();
101
+ const idx = all.indexOf(target);
102
+ if (idx < 0) return;
103
+ const forward = (idx + 1) % all.length;
104
+ const backward = (idx - 1 + all.length) % all.length;
105
+ const rtl = this.isRtl();
106
+ let next;
107
+ switch (event.key) {
108
+ case WR_KEYS.ARROW_RIGHT:
109
+ next = rtl ? backward : forward;
110
+ break;
111
+ case WR_KEYS.ARROW_LEFT:
112
+ next = rtl ? forward : backward;
113
+ break;
114
+ case WR_KEYS.HOME:
115
+ next = 0;
116
+ break;
117
+ case WR_KEYS.END:
118
+ next = all.length - 1;
119
+ break;
120
+ default: return;
121
+ }
122
+ event.preventDefault();
123
+ all[next].focus({ focusVisible: true });
124
+ };
125
+ sync();
126
+ host.addEventListener("focusin", onFocusin);
127
+ host.addEventListener("keydown", onKeydown);
128
+ const observer = new MutationObserver(sync);
129
+ observer.observe(host, {
130
+ childList: true,
131
+ subtree: true,
132
+ attributes: true,
133
+ attributeFilter: [
134
+ "disabled",
135
+ "hidden",
136
+ "inert",
137
+ "class",
138
+ "style"
139
+ ]
140
+ });
141
+ return () => {
142
+ observer.disconnect();
143
+ host.removeEventListener("focusin", onFocusin);
144
+ host.removeEventListener("keydown", onKeydown);
145
+ for (const [el, value] of original) restore(el, value);
146
+ original.clear();
147
+ };
148
+ }
149
+ ownsArrows(el) {
150
+ if (el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement || el.isContentEditable) return true;
151
+ if (el instanceof HTMLInputElement && !NON_TEXT_INPUTS.has(el.type)) return true;
152
+ const widget = el.closest(COMPOSITE_SELECTOR);
153
+ return widget !== null && widget !== this.host && this.host.contains(widget);
154
+ }
19
155
  static ɵfac = i0.ɵɵngDeclareFactory({
20
156
  minVersion: "12.0.0",
21
157
  version: "22.3.0",
@@ -30,13 +166,22 @@ var WrToolbar = class WrToolbar {
30
166
  type: WrToolbar,
31
167
  isStandalone: true,
32
168
  selector: "wr-toolbar",
33
- inputs: { responsive: {
34
- classPropertyName: "responsive",
35
- publicName: "responsive",
36
- isSignal: true,
37
- isRequired: false,
38
- transformFunction: null
39
- } },
169
+ inputs: {
170
+ responsive: {
171
+ classPropertyName: "responsive",
172
+ publicName: "responsive",
173
+ isSignal: true,
174
+ isRequired: false,
175
+ transformFunction: null
176
+ },
177
+ arrowKeys: {
178
+ classPropertyName: "arrowKeys",
179
+ publicName: "arrowKeys",
180
+ isSignal: true,
181
+ isRequired: false,
182
+ transformFunction: null
183
+ }
184
+ },
40
185
  host: {
41
186
  attributes: { "role": "toolbar" },
42
187
  properties: { "class.wr-toolbar--responsive": "responsive()" },
@@ -66,14 +211,24 @@ i0.ɵɵngDeclareClassMetadata({
66
211
  }]
67
212
  }],
68
213
  ctorParameters: () => [],
69
- propDecorators: { responsive: [{
70
- type: i0.Input,
71
- args: [{
72
- isSignal: true,
73
- alias: "responsive",
74
- required: false
214
+ propDecorators: {
215
+ responsive: [{
216
+ type: i0.Input,
217
+ args: [{
218
+ isSignal: true,
219
+ alias: "responsive",
220
+ required: false
221
+ }]
222
+ }],
223
+ arrowKeys: [{
224
+ type: i0.Input,
225
+ args: [{
226
+ isSignal: true,
227
+ alias: "arrowKeys",
228
+ required: false
229
+ }]
75
230
  }]
76
- }] }
231
+ }
77
232
  });
78
233
  export { WrToolbar };
79
234
 
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-toolbar.mjs","names":[],"sources":["../../../projects/lib/toolbar/toolbar.ts","../../../projects/lib/toolbar/toolbar.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Action bar with three named zones — `[wrToolbarStart]`,\n * `[wrToolbarCenter]`, `[wrToolbarEnd]`. Use any one or all three.\n *\n * A bare `<div>` wrapper in a zone, one with no `class` and no `style`, is laid\n * out as a wrapping row with the zone's own gap, so the controls inside it are\n * spaced exactly like controls projected one by one. The gap follows\n * `--wr-density-gap`. Give the wrapper a class or a style and its layout is\n * yours: the toolbar sets nothing on it. Put running text in a `<span>` or a\n * `<p>`, which stay in inline flow.\n *\n * @example\n * ```html\n * <wr-toolbar>\n * <div wrToolbarStart>\n * <button wr-btn>Back</button>\n * <strong>Items</strong>\n * </div>\n * <div wrToolbarCenter>\n * <wr-segmented [(value)]=\"view\" [options]=\"['grid', 'list']\" />\n * </div>\n * <div wrToolbarEnd>\n * <button wr-btn color=\"primary\">New</button>\n * </div>\n * </wr-toolbar>\n * ```\n *\n * @see https://ngwr.dev/reference/components/toolbar\n */\n@Component({\n selector: 'wr-toolbar',\n templateUrl: './toolbar.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-toolbar', role: 'toolbar', '[class.wr-toolbar--responsive]': 'responsive()' },\n})\nexport class WrToolbar {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('toolbar');\n }\n\n /**\n * Stack the zones vertically when the toolbar's own box is too narrow to fit\n * them in a row (a container query on its own width, not the viewport — so it\n * adapts inside a narrow column or split pane). @default false\n */\n readonly responsive = input(false, { transform: coerceBooleanProperty });\n}\n","<div class=\"wr-toolbar__zone wr-toolbar__zone--start\">\n <ng-content select=\"[wrToolbarStart]\" />\n</div>\n<div class=\"wr-toolbar__zone wr-toolbar__zone--center\">\n <ng-content select=\"[wrToolbarCenter]\" />\n</div>\n<div class=\"wr-toolbar__zone wr-toolbar__zone--end\">\n <ng-content select=\"[wrToolbarEnd]\" />\n</div>\n"],"mappings":";;;;;;;;;;AA+CA,IAAa,YAAb,MAAa,UAAS;CACpB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,SAAS;CAC5E;CAOS,aAAa,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,aAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAV1D,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAS,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAT,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAS,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,YAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,QAAA,UAAA;GAAA,YAAA,EAAA,gCAAA,eAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UC/CtB;EASA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADsCa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EANrB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAY,eAEP,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAc,MAAM;IAAW,kCAAkC;GAAc;GAAE,UAAA;EAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-toolbar.mjs","names":[],"sources":["../../../projects/lib/toolbar/toolbar.ts","../../../projects/lib/toolbar/toolbar.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ElementRef, ViewEncapsulation, afterRenderEffect, computed, inject, input } from '@angular/core';\n\nimport { WR_KEYS, wrCheckStyles, wrHasModifier } from 'ngwr/utils';\n\nconst CONTROL_SELECTOR = 'a[href], button, input:not([type=\"hidden\"]), select, textarea, [contenteditable], [tabindex]';\n\n/** Roles whose widget handles the arrow keys itself. */\nconst COMPOSITE_SELECTOR = [\n 'radiogroup',\n 'tablist',\n 'listbox',\n 'menu',\n 'menubar',\n 'slider',\n 'spinbutton',\n 'combobox',\n 'grid',\n 'tree',\n 'treegrid',\n]\n .map(role => `[role=\"${role}\"]`)\n .join(', ');\n\n/** `visibility: hidden` counts as hidden. An engine without `checkVisibility` is taken as visible. */\nfunction isVisible(el: HTMLElement): boolean {\n if (typeof el.checkVisibility !== 'function') return true;\n return el.checkVisibility({ visibilityProperty: true });\n}\n\nconst NON_TEXT_INPUTS = new Set(['button', 'checkbox', 'submit', 'reset', 'image', 'color', 'file']);\n\n/**\n * Action bar with three named zones — `[wrToolbarStart]`,\n * `[wrToolbarCenter]`, `[wrToolbarEnd]`. Use any one or all three.\n *\n * A bare `<div>` wrapper in a zone, one with no `class` and no `style`, is laid\n * out as a wrapping row with the zone's own gap, so the controls inside it are\n * spaced exactly like controls projected one by one. The gap follows\n * `--wr-density-gap`. Give the wrapper a class or a style and its layout is\n * yours: the toolbar sets nothing on it. Put running text in a `<span>` or a\n * `<p>`, which stay in inline flow.\n *\n * The host is `role=\"toolbar\"`. Name it with a plain `aria-label` attribute on\n * the host when the page has more than one.\n *\n * With `arrowKeys` the toolbar follows the WAI-ARIA toolbar pattern: one tab stop\n * across every enabled control of the three zones, moved with the arrow keys.\n *\n * @example\n * ```html\n * <wr-toolbar>\n * <div wrToolbarStart>\n * <button wr-btn>Back</button>\n * <strong>Items</strong>\n * </div>\n * <div wrToolbarCenter>\n * <wr-segmented [(value)]=\"view\" [options]=\"['grid', 'list']\" />\n * </div>\n * <div wrToolbarEnd>\n * <button wr-btn color=\"primary\">New</button>\n * </div>\n * </wr-toolbar>\n * ```\n *\n * @see https://ngwr.dev/reference/components/toolbar\n */\n@Component({\n selector: 'wr-toolbar',\n templateUrl: './toolbar.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-toolbar', role: 'toolbar', '[class.wr-toolbar--responsive]': 'responsive()' },\n})\nexport class WrToolbar {\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private readonly dir = inject(Directionality, { optional: true });\n private readonly isRtl = computed(() => this.dir?.valueSignal() === 'rtl');\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('toolbar');\n afterRenderEffect(onCleanup => {\n if (this.arrowKeys()) onCleanup(this.attachRoving());\n });\n }\n\n /**\n * Stack the zones vertically when the toolbar's own box is too narrow to fit\n * them in a row (a container query on its own width, not the viewport — so it\n * adapts inside a narrow column or split pane). @default false\n */\n readonly responsive = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Roving focus across the enabled controls of all zones, per the WAI-ARIA toolbar\n * pattern: one tab stop, ArrowRight / ArrowLeft (mirrored under RTL) to step with\n * wrapping, Home / End for the ends. Text fields, native radios and composite\n * widgets (radiogroup, tablist, listbox, ...) are not part of that set: they keep\n * their own tab stop and their own arrow keys, and the arrows skip over them. Tab\n * still reaches every one of them. @default false\n */\n readonly arrowKeys = input(false, { transform: coerceBooleanProperty });\n\n /** Starts listening and returns the cleanup that puts every `tabindex` back. */\n private attachRoving(): () => void {\n const host = this.host;\n const original = new Map<HTMLElement, string | null>();\n // The value last written per control: a different one now is the consumer's.\n const written = new Map<HTMLElement, string>();\n const changedByConsumer = (el: HTMLElement): boolean => written.get(el) !== el.getAttribute('tabindex');\n let stop: HTMLElement | null = null;\n\n const controls = (): HTMLElement[] =>\n Array.from(host.querySelectorAll<HTMLElement>(CONTROL_SELECTOR)).filter(el => {\n if (el.matches(':disabled') || el.closest('[hidden], [inert]') || !isVisible(el)) return false;\n // A negative tabindex that is not ours is the consumer's: out of the roving set.\n if (changedByConsumer(el) && Number(el.getAttribute('tabindex')) < 0) return false;\n // Text fields and composite widgets keep their own tab stop and their own arrows.\n return !this.ownsArrows(el);\n });\n\n const restore = (el: HTMLElement, value: string | null): void => {\n // A value the consumer wrote since is theirs to keep.\n if (!changedByConsumer(el)) {\n if (value === null) el.removeAttribute('tabindex');\n else el.setAttribute('tabindex', value);\n }\n written.delete(el);\n };\n\n const sync = (): void => {\n const all = controls();\n for (const [el, value] of original) {\n // A control that left, or stopped being eligible, gets its own tabindex back.\n if (all.includes(el)) continue;\n restore(el, value);\n original.delete(el);\n }\n if (!stop || !all.includes(stop)) stop = all[0] ?? null;\n for (const el of all) {\n if (!original.has(el) || changedByConsumer(el)) original.set(el, el.getAttribute('tabindex'));\n const value = el === stop ? '0' : '-1';\n el.setAttribute('tabindex', value);\n written.set(el, value);\n }\n };\n\n const onFocusin = (event: FocusEvent): void => {\n const target = event.target;\n if (target instanceof HTMLElement && controls().includes(target)) {\n stop = target;\n sync();\n }\n };\n\n const onKeydown = (event: KeyboardEvent): void => {\n const target = event.target;\n if (!(target instanceof HTMLElement) || event.defaultPrevented || wrHasModifier(event)) return;\n const all = controls();\n const idx = all.indexOf(target);\n if (idx < 0) return;\n const forward = (idx + 1) % all.length;\n const backward = (idx - 1 + all.length) % all.length;\n const rtl = this.isRtl();\n let next: number;\n switch (event.key) {\n case WR_KEYS.ARROW_RIGHT:\n next = rtl ? backward : forward;\n break;\n case WR_KEYS.ARROW_LEFT:\n next = rtl ? forward : backward;\n break;\n case WR_KEYS.HOME:\n next = 0;\n break;\n case WR_KEYS.END:\n next = all.length - 1;\n break;\n default:\n return;\n }\n event.preventDefault();\n // Firefox keeps a mouse-clicked control's ring off for a focus moved by script.\n all[next].focus({ focusVisible: true });\n };\n\n sync();\n host.addEventListener('focusin', onFocusin);\n host.addEventListener('keydown', onKeydown);\n const observer = new MutationObserver(sync);\n observer.observe(host, {\n childList: true,\n subtree: true,\n attributes: true,\n // Never `tabindex`: sync writes it, and watching it would loop.\n attributeFilter: ['disabled', 'hidden', 'inert', 'class', 'style'],\n });\n\n return () => {\n observer.disconnect();\n host.removeEventListener('focusin', onFocusin);\n host.removeEventListener('keydown', onKeydown);\n for (const [el, value] of original) restore(el, value);\n original.clear();\n };\n }\n\n /** Does `el` need the arrow keys for itself: a text field, or inside a composite widget? */\n private ownsArrows(el: HTMLElement): boolean {\n if (el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement || el.isContentEditable) return true;\n if (el instanceof HTMLInputElement && !NON_TEXT_INPUTS.has(el.type)) return true;\n const widget = el.closest(COMPOSITE_SELECTOR);\n return widget !== null && widget !== this.host && this.host.contains(widget);\n }\n}\n","<div class=\"wr-toolbar__zone wr-toolbar__zone--start\">\n <ng-content select=\"[wrToolbarStart]\" />\n</div>\n<div class=\"wr-toolbar__zone wr-toolbar__zone--center\">\n <ng-content select=\"[wrToolbarCenter]\" />\n</div>\n<div class=\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S,MAAM;CAC7E;CA3IW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAS,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAT,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAS,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,YAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,WAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,QAAA,UAAA;GAAA,YAAA,EAAA,gCAAA,eAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UCjFtB;EASA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADwEa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EANrB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAY,eAEP,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAc,MAAM;IAAW,kCAAkC;GAAc;GAAE,UAAA;EAAA,CAAA"}
@@ -1,7 +1,7 @@
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, wrRandomId, wrRestoreFocus, wrToClassList } from "ngwr/utils";
4
+ import { wrCheckStyles, wrIsComposing, wrRandomId, wrRestoreFocus, 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";
@@ -257,15 +257,20 @@ var WrTour = class WrTour {
257
257
  openStep(step, hadFocus) {
258
258
  const target = this.resolve(step);
259
259
  if (!target) return;
260
+ const reduced = this.document.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
260
261
  target.scrollIntoView({
261
262
  block: "center",
262
263
  inline: "nearest",
263
- behavior: "smooth"
264
+ behavior: reduced ? "instant" : "smooth"
264
265
  });
265
266
  const spotlight = this.document.createElement("div");
266
267
  spotlight.className = "wr-tour__spotlight";
267
268
  spotlight.setAttribute("aria-hidden", "true");
268
269
  this.document.body.appendChild(spotlight);
270
+ if (typeof spotlight.showPopover === "function") {
271
+ spotlight.setAttribute("popover", "manual");
272
+ spotlight.showPopover();
273
+ }
269
274
  this.spotlight = spotlight;
270
275
  this.placeSpotlight(target);
271
276
  const placement = step.placement ?? "bottom";
@@ -290,7 +295,7 @@ var WrTour = class WrTour {
290
295
  this.focusTrap = this.focusTrapFactory.create(card);
291
296
  wrFocusOverlay(card, this.focusTrap, this.autoFocus === false && hadFocus ? "dialog" : this.autoFocus, this.injector);
292
297
  const onKey = (event) => {
293
- if (event.key === "Escape" && !event.defaultPrevented) {
298
+ if (event.key === "Escape" && !event.defaultPrevented && !wrIsComposing(event)) {
294
299
  event.preventDefault();
295
300
  this.stop();
296
301
  }
@@ -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, 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 { wrRestoreFocus, 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 if (this.restoreFocus && typeof this.restoreFocus.focus === 'function') wrRestoreFocus(this.restoreFocus);\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,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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kB;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
+ {"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, 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 { wrIsComposing, wrRestoreFocus, 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 if (this.restoreFocus && typeof this.restoreFocus.focus === 'function') wrRestoreFocus(this.restoreFocus);\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 const reduced = this.document.defaultView?.matchMedia?.('(prefers-reduced-motion: reduce)').matches;\n target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: reduced ? 'instant' : '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 // Into the top layer, where a dialog or a drawer holding the target is. It is\n // promoted before the card's overlay is created, so the card stays above it.\n // Set here and not in a template: a `popover` attribute hides the element\n // until it is shown, which a browser without the API never does.\n if (typeof spotlight.showPopover === 'function') {\n spotlight.setAttribute('popover', 'manual');\n spotlight.showPopover();\n }\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 && !wrIsComposing(event)) {\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,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,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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;CAvUW,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"}
@@ -51,6 +51,7 @@ var WrTransfer = class WrTransfer {
51
51
  resolvedEmpty = useI18nText(this.emptyText, "transfer.empty", "Nothing here");
52
52
  resolvedSelectAll = useI18nText(this.selectAllLabel, "transfer.selectAll", "Select all");
53
53
  selectAllAria = useI18nFormatter("transfer.selectAllAria", "{{pane}} — {{action}}");
54
+ searchAria = useI18nFormatter("transfer.searchAria", "{{title}} - {{search}}");
54
55
  resolvedToTarget = useI18nText(this.toTargetLabel, "transfer.toTarget", "Move to selected");
55
56
  resolvedToSource = useI18nText(this.toSourceLabel, "transfer.toSource", "Move to available");
56
57
  countLabel = useI18nFormatter("transfer.count", "{{checked}} / {{total}}");
@@ -298,7 +299,7 @@ var WrTransfer = class WrTransfer {
298
299
  useValue: null
299
300
  }],
300
301
  ngImport: i0,
301
- template: "<!--\n Two panes and the buttons between them. Each pane is a PLAIN `<ul>` of\n checkboxes, deliberately: dressing it as a `role=\"listbox\"` of `role=\"option\"`\n rows reads better in the abstract but is invalid — an option may not contain an\n interactive control, and the axe gate says so. The checkbox is the thing the\n user operates, so it is the thing the semantics should describe; the pane\n heading names the group.\n-->\n@for (pane of panes; track pane) {\n @let state = pane === 'source' ? source() : target();\n @let title = pane === 'source' ? resolvedSourceTitle() : resolvedTargetTitle();\n\n <div class=\"wr-transfer__pane\" [class.wr-transfer__pane--target]=\"pane === 'target'\">\n <div class=\"wr-transfer__head\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"state.allChecked\"\n [indeterminate]=\"state.someChecked\"\n [disabled]=\"disabled() || state.enabledCount === 0\"\n [readonly]=\"readonly()\"\n [ariaLabel]=\"selectAllAria({ action: resolvedSelectAll(), pane: title })\"\n (checkedChange)=\"toggleAll(pane, $event)\"\n />\n <span class=\"wr-transfer__title\">{{ title }}</span>\n <span class=\"wr-transfer__count\">{{\n countLabel({ checked: state.checkedCount, total: state.rows.length })\n }}</span>\n </div>\n\n @if (searchable()) {\n <div class=\"wr-transfer__search\">\n <input\n wrInput\n [size]=\"controlSize()\"\n type=\"search\"\n [placeholder]=\"resolvedSearch()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"`${title} — ${resolvedSearch()}`\"\n (input)=\"onSearch(pane, $event)\"\n />\n </div>\n }\n\n <ul class=\"wr-transfer__list\" [attr.aria-label]=\"title\">\n @for (item of state.rows; track item.value) {\n <li class=\"wr-transfer__item\" [class.wr-transfer__item--disabled]=\"item.disabled\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"isChecked(pane, item)\"\n [disabled]=\"disabled() || !!item.disabled\"\n [readonly]=\"readonly()\"\n (checkedChange)=\"toggle(pane, item, $event)\"\n (touch)=\"touch.emit()\"\n >\n {{ item.label }}\n </wr-checkbox>\n </li>\n } @empty {\n <li class=\"wr-transfer__empty\">{{ resolvedEmpty() }}</li>\n }\n </ul>\n </div>\n\n <!-- The buttons live between the panes, so they are emitted after the first. -->\n @if (pane === 'source') {\n <div class=\"wr-transfer__actions\">\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-target\"\n [disabled]=\"!canMoveRight()\"\n [attr.aria-label]=\"resolvedToTarget()\"\n (click)=\"moveRight()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-source\"\n [disabled]=\"!canMoveLeft()\"\n [attr.aria-label]=\"resolvedToSource()\"\n (click)=\"moveLeft()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n </div>\n }\n}\n",
302
+ template: "<!--\n Two panes and the buttons between them. Each pane is a PLAIN `<ul>` of\n checkboxes, deliberately: dressing it as a `role=\"listbox\"` of `role=\"option\"`\n rows reads better in the abstract but is invalid — an option may not contain an\n interactive control, and the axe gate says so. The checkbox is the thing the\n user operates, so it is the thing the semantics should describe; the pane\n heading names the group.\n-->\n@for (pane of panes; track pane) {\n @let state = pane === 'source' ? source() : target();\n @let title = pane === 'source' ? resolvedSourceTitle() : resolvedTargetTitle();\n\n <div class=\"wr-transfer__pane\" [class.wr-transfer__pane--target]=\"pane === 'target'\">\n <div class=\"wr-transfer__head\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"state.allChecked\"\n [indeterminate]=\"state.someChecked\"\n [disabled]=\"disabled() || state.enabledCount === 0\"\n [readonly]=\"readonly()\"\n [ariaLabel]=\"selectAllAria({ action: resolvedSelectAll(), pane: title })\"\n (checkedChange)=\"toggleAll(pane, $event)\"\n />\n <span class=\"wr-transfer__title\">{{ title }}</span>\n <span class=\"wr-transfer__count\">{{\n countLabel({ checked: state.checkedCount, total: state.rows.length })\n }}</span>\n </div>\n\n @if (searchable()) {\n <div class=\"wr-transfer__search\">\n <input\n wrInput\n [size]=\"controlSize()\"\n type=\"search\"\n [placeholder]=\"resolvedSearch()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"searchAria({ title, search: resolvedSearch() })\"\n (input)=\"onSearch(pane, $event)\"\n />\n </div>\n }\n\n <ul class=\"wr-transfer__list\" [attr.aria-label]=\"title\">\n @for (item of state.rows; track item.value) {\n <li class=\"wr-transfer__item\" [class.wr-transfer__item--disabled]=\"item.disabled\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"isChecked(pane, item)\"\n [disabled]=\"disabled() || !!item.disabled\"\n [readonly]=\"readonly()\"\n (checkedChange)=\"toggle(pane, item, $event)\"\n (touch)=\"touch.emit()\"\n >\n {{ item.label }}\n </wr-checkbox>\n </li>\n } @empty {\n <li class=\"wr-transfer__empty\">{{ resolvedEmpty() }}</li>\n }\n </ul>\n </div>\n\n <!-- The buttons live between the panes, so they are emitted after the first. -->\n @if (pane === 'source') {\n <div class=\"wr-transfer__actions\">\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-target\"\n [disabled]=\"!canMoveRight()\"\n [attr.aria-label]=\"resolvedToTarget()\"\n (click)=\"moveRight()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-source\"\n [disabled]=\"!canMoveLeft()\"\n [attr.aria-label]=\"resolvedToSource()\"\n (click)=\"moveLeft()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n </div>\n }\n}\n",
302
303
  dependencies: [
303
304
  {
304
305
  kind: "component",
@@ -373,7 +374,7 @@ i0.ɵɵngDeclareClassMetadata({
373
374
  WrCheckbox,
374
375
  WrInput
375
376
  ],
376
- template: "<!--\n Two panes and the buttons between them. Each pane is a PLAIN `<ul>` of\n checkboxes, deliberately: dressing it as a `role=\"listbox\"` of `role=\"option\"`\n rows reads better in the abstract but is invalid — an option may not contain an\n interactive control, and the axe gate says so. The checkbox is the thing the\n user operates, so it is the thing the semantics should describe; the pane\n heading names the group.\n-->\n@for (pane of panes; track pane) {\n @let state = pane === 'source' ? source() : target();\n @let title = pane === 'source' ? resolvedSourceTitle() : resolvedTargetTitle();\n\n <div class=\"wr-transfer__pane\" [class.wr-transfer__pane--target]=\"pane === 'target'\">\n <div class=\"wr-transfer__head\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"state.allChecked\"\n [indeterminate]=\"state.someChecked\"\n [disabled]=\"disabled() || state.enabledCount === 0\"\n [readonly]=\"readonly()\"\n [ariaLabel]=\"selectAllAria({ action: resolvedSelectAll(), pane: title })\"\n (checkedChange)=\"toggleAll(pane, $event)\"\n />\n <span class=\"wr-transfer__title\">{{ title }}</span>\n <span class=\"wr-transfer__count\">{{\n countLabel({ checked: state.checkedCount, total: state.rows.length })\n }}</span>\n </div>\n\n @if (searchable()) {\n <div class=\"wr-transfer__search\">\n <input\n wrInput\n [size]=\"controlSize()\"\n type=\"search\"\n [placeholder]=\"resolvedSearch()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"`${title} — ${resolvedSearch()}`\"\n (input)=\"onSearch(pane, $event)\"\n />\n </div>\n }\n\n <ul class=\"wr-transfer__list\" [attr.aria-label]=\"title\">\n @for (item of state.rows; track item.value) {\n <li class=\"wr-transfer__item\" [class.wr-transfer__item--disabled]=\"item.disabled\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"isChecked(pane, item)\"\n [disabled]=\"disabled() || !!item.disabled\"\n [readonly]=\"readonly()\"\n (checkedChange)=\"toggle(pane, item, $event)\"\n (touch)=\"touch.emit()\"\n >\n {{ item.label }}\n </wr-checkbox>\n </li>\n } @empty {\n <li class=\"wr-transfer__empty\">{{ resolvedEmpty() }}</li>\n }\n </ul>\n </div>\n\n <!-- The buttons live between the panes, so they are emitted after the first. -->\n @if (pane === 'source') {\n <div class=\"wr-transfer__actions\">\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-target\"\n [disabled]=\"!canMoveRight()\"\n [attr.aria-label]=\"resolvedToTarget()\"\n (click)=\"moveRight()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-source\"\n [disabled]=\"!canMoveLeft()\"\n [attr.aria-label]=\"resolvedToSource()\"\n (click)=\"moveLeft()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n </div>\n }\n}\n"
377
+ template: "<!--\n Two panes and the buttons between them. Each pane is a PLAIN `<ul>` of\n checkboxes, deliberately: dressing it as a `role=\"listbox\"` of `role=\"option\"`\n rows reads better in the abstract but is invalid — an option may not contain an\n interactive control, and the axe gate says so. The checkbox is the thing the\n user operates, so it is the thing the semantics should describe; the pane\n heading names the group.\n-->\n@for (pane of panes; track pane) {\n @let state = pane === 'source' ? source() : target();\n @let title = pane === 'source' ? resolvedSourceTitle() : resolvedTargetTitle();\n\n <div class=\"wr-transfer__pane\" [class.wr-transfer__pane--target]=\"pane === 'target'\">\n <div class=\"wr-transfer__head\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"state.allChecked\"\n [indeterminate]=\"state.someChecked\"\n [disabled]=\"disabled() || state.enabledCount === 0\"\n [readonly]=\"readonly()\"\n [ariaLabel]=\"selectAllAria({ action: resolvedSelectAll(), pane: title })\"\n (checkedChange)=\"toggleAll(pane, $event)\"\n />\n <span class=\"wr-transfer__title\">{{ title }}</span>\n <span class=\"wr-transfer__count\">{{\n countLabel({ checked: state.checkedCount, total: state.rows.length })\n }}</span>\n </div>\n\n @if (searchable()) {\n <div class=\"wr-transfer__search\">\n <input\n wrInput\n [size]=\"controlSize()\"\n type=\"search\"\n [placeholder]=\"resolvedSearch()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"searchAria({ title, search: resolvedSearch() })\"\n (input)=\"onSearch(pane, $event)\"\n />\n </div>\n }\n\n <ul class=\"wr-transfer__list\" [attr.aria-label]=\"title\">\n @for (item of state.rows; track item.value) {\n <li class=\"wr-transfer__item\" [class.wr-transfer__item--disabled]=\"item.disabled\">\n <wr-checkbox\n [size]=\"controlSize()\"\n [checked]=\"isChecked(pane, item)\"\n [disabled]=\"disabled() || !!item.disabled\"\n [readonly]=\"readonly()\"\n (checkedChange)=\"toggle(pane, item, $event)\"\n (touch)=\"touch.emit()\"\n >\n {{ item.label }}\n </wr-checkbox>\n </li>\n } @empty {\n <li class=\"wr-transfer__empty\">{{ resolvedEmpty() }}</li>\n }\n </ul>\n </div>\n\n <!-- The buttons live between the panes, so they are emitted after the first. -->\n @if (pane === 'source') {\n <div class=\"wr-transfer__actions\">\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-target\"\n [disabled]=\"!canMoveRight()\"\n [attr.aria-label]=\"resolvedToTarget()\"\n (click)=\"moveRight()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n <button\n wr-btn\n type=\"button\"\n [size]=\"controlSize()\"\n color=\"primary\"\n outlined\n class=\"wr-transfer__move wr-transfer__move--to-source\"\n [disabled]=\"!canMoveLeft()\"\n [attr.aria-label]=\"resolvedToSource()\"\n (click)=\"moveLeft()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n </div>\n }\n}\n"
377
378
  }]
378
379
  }],
379
380
  ctorParameters: () => [],