ngwr 16.4.0 → 16.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/charts/bar-chart/styles/_index.scss +494 -305
  2. package/charts/boxplot-chart/styles/_index.scss +114 -48
  3. package/charts/bullet-chart/styles/_index.scss +113 -42
  4. package/charts/calendar-heatmap/styles/_index.scss +111 -20
  5. package/charts/candlestick-chart/styles/_index.scss +61 -26
  6. package/charts/chart-legend/styles/_index.scss +119 -1
  7. package/charts/core/styles/_index.scss +201 -5
  8. package/charts/donut-chart/styles/_index.scss +76 -21
  9. package/charts/funnel-chart/styles/_index.scss +66 -38
  10. package/charts/gauge/styles/_index.scss +12 -1
  11. package/charts/heatmap-chart/styles/_index.scss +90 -53
  12. package/charts/line-chart/styles/_index.scss +143 -139
  13. package/charts/meter-group/styles/_index.scss +87 -25
  14. package/charts/radar-chart/styles/_index.scss +82 -40
  15. package/charts/scatter-chart/styles/_index.scss +117 -44
  16. package/charts/sparkline/styles/_index.scss +7 -1
  17. package/charts/treemap-chart/styles/_index.scss +94 -42
  18. package/charts/waterfall-chart/styles/_index.scss +150 -87
  19. package/color-picker/styles/_index.scss +7 -3
  20. package/copy-value/styles/_index.scss +21 -2
  21. package/date-stamp/styles/_index.scss +2 -1
  22. package/dialog/styles/_index.scss +6 -0
  23. package/drawer/styles/_index.scss +5 -1
  24. package/fesm2022/ngwr-carousel-testing.mjs +4 -1
  25. package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
  26. package/fesm2022/ngwr-carousel.mjs +21 -2
  27. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  28. package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
  29. package/fesm2022/ngwr-cascader.mjs +48 -4
  30. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  31. package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
  32. package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
  33. package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
  34. package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
  35. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
  36. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
  37. package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
  38. package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
  39. package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
  40. package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
  41. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
  42. package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
  43. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
  44. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
  45. package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
  46. package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
  47. package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
  48. package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
  49. package/fesm2022/ngwr-charts-core.mjs +299 -18
  50. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  51. package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
  52. package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
  53. package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
  54. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
  55. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
  56. package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
  57. package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
  58. package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
  59. package/fesm2022/ngwr-charts-gauge.mjs +98 -12
  60. package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
  61. package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
  62. package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
  63. package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
  64. package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
  65. package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
  66. package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
  67. package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
  68. package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
  69. package/fesm2022/ngwr-charts-meter-group.mjs +223 -31
  70. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  71. package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
  72. package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
  73. package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
  74. package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
  75. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
  76. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
  77. package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
  78. package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
  79. package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
  80. package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
  81. package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
  82. package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
  83. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
  84. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
  85. package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
  86. package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
  87. package/fesm2022/ngwr-color-picker.mjs +44 -4
  88. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  89. package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
  90. package/fesm2022/ngwr-context-menu.mjs +47 -19
  91. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  92. package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
  93. package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
  94. package/fesm2022/ngwr-copy-value.mjs +38 -2
  95. package/fesm2022/ngwr-copy-value.mjs.map +1 -1
  96. package/fesm2022/ngwr-date-picker.mjs +56 -8
  97. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  98. package/fesm2022/ngwr-dialog.mjs +13 -5
  99. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  100. package/fesm2022/ngwr-drawer.mjs +19 -3
  101. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  102. package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
  103. package/fesm2022/ngwr-dropdown.mjs +35 -6
  104. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  105. package/fesm2022/ngwr-editor.mjs +1 -0
  106. package/fesm2022/ngwr-editor.mjs.map +1 -1
  107. package/fesm2022/ngwr-graph.mjs +81 -13
  108. package/fesm2022/ngwr-graph.mjs.map +1 -1
  109. package/fesm2022/ngwr-i18n-ar.mjs +5 -0
  110. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  111. package/fesm2022/ngwr-i18n-cs.mjs +5 -0
  112. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  113. package/fesm2022/ngwr-i18n-de.mjs +5 -0
  114. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  115. package/fesm2022/ngwr-i18n-en.mjs +5 -0
  116. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  117. package/fesm2022/ngwr-i18n-es.mjs +5 -0
  118. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  119. package/fesm2022/ngwr-i18n-fr.mjs +5 -0
  120. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  121. package/fesm2022/ngwr-i18n-he.mjs +5 -0
  122. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  123. package/fesm2022/ngwr-i18n-hi.mjs +5 -0
  124. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  125. package/fesm2022/ngwr-i18n-id.mjs +5 -0
  126. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  127. package/fesm2022/ngwr-i18n-it.mjs +5 -0
  128. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  129. package/fesm2022/ngwr-i18n-ja.mjs +5 -0
  130. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  131. package/fesm2022/ngwr-i18n-ko.mjs +5 -0
  132. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  133. package/fesm2022/ngwr-i18n-nl.mjs +5 -0
  134. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  135. package/fesm2022/ngwr-i18n-pl.mjs +5 -0
  136. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  137. package/fesm2022/ngwr-i18n-pt.mjs +5 -0
  138. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  139. package/fesm2022/ngwr-i18n-ru.mjs +5 -0
  140. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  141. package/fesm2022/ngwr-i18n-sv.mjs +5 -0
  142. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  143. package/fesm2022/ngwr-i18n-tr.mjs +5 -0
  144. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  145. package/fesm2022/ngwr-i18n-uk.mjs +5 -0
  146. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  147. package/fesm2022/ngwr-i18n-vi.mjs +5 -0
  148. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  149. package/fesm2022/ngwr-i18n-zh-tw.mjs +5 -0
  150. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  151. package/fesm2022/ngwr-i18n-zh.mjs +5 -0
  152. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  153. package/fesm2022/ngwr-lightbox.mjs +20 -3
  154. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  155. package/fesm2022/ngwr-overlay.mjs +21 -2
  156. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  157. package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
  158. package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
  159. package/fesm2022/ngwr-popconfirm.mjs +41 -5
  160. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  161. package/fesm2022/ngwr-popover.mjs +67 -12
  162. package/fesm2022/ngwr-popover.mjs.map +1 -1
  163. package/fesm2022/ngwr-schema-form.mjs +2 -0
  164. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  165. package/fesm2022/ngwr-table.mjs +2 -0
  166. package/fesm2022/ngwr-table.mjs.map +1 -1
  167. package/fesm2022/ngwr-tour.mjs +14 -9
  168. package/fesm2022/ngwr-tour.mjs.map +1 -1
  169. package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
  170. package/fesm2022/ngwr-tree.mjs +49 -16
  171. package/fesm2022/ngwr-tree.mjs.map +1 -1
  172. package/fesm2022/ngwr-version.mjs +1 -1
  173. package/fesm2022/ngwr-version.mjs.map +1 -1
  174. package/fesm2022/ngwr-window.mjs +16 -9
  175. package/fesm2022/ngwr-window.mjs.map +1 -1
  176. package/i18n/ar.json +5 -0
  177. package/i18n/cs.json +5 -0
  178. package/i18n/de.json +5 -0
  179. package/i18n/en.json +5 -0
  180. package/i18n/es.json +5 -0
  181. package/i18n/fr.json +5 -0
  182. package/i18n/he.json +5 -0
  183. package/i18n/hi.json +5 -0
  184. package/i18n/id.json +5 -0
  185. package/i18n/it.json +5 -0
  186. package/i18n/ja.json +5 -0
  187. package/i18n/ko.json +5 -0
  188. package/i18n/nl.json +5 -0
  189. package/i18n/pl.json +5 -0
  190. package/i18n/pt.json +5 -0
  191. package/i18n/ru.json +5 -0
  192. package/i18n/sv.json +5 -0
  193. package/i18n/tr.json +5 -0
  194. package/i18n/uk.json +5 -0
  195. package/i18n/vi.json +5 -0
  196. package/i18n/zh-TW.json +5 -0
  197. package/i18n/zh.json +5 -0
  198. package/llms-full.txt +8 -8
  199. package/llms.txt +7 -3
  200. package/package.json +1 -1
  201. package/popconfirm/styles/_index.scss +6 -0
  202. package/popover/styles/_index.scss +24 -13
  203. package/schematics/use/symbol-map.json +1 -0
  204. package/skills/ngwr/references/catalog.md +1 -1
  205. package/tour/styles/_index.scss +6 -0
  206. package/types/ngwr-carousel-testing.d.ts +6 -4
  207. package/types/ngwr-carousel.d.ts +14 -3
  208. package/types/ngwr-cascader-testing.d.ts +4 -3
  209. package/types/ngwr-cascader.d.ts +27 -3
  210. package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
  211. package/types/ngwr-charts-bar-chart.d.ts +220 -48
  212. package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
  213. package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
  214. package/types/ngwr-charts-bullet-chart.d.ts +72 -12
  215. package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
  216. package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
  217. package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
  218. package/types/ngwr-charts-chart-legend.d.ts +142 -5
  219. package/types/ngwr-charts-core.d.ts +259 -21
  220. package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
  221. package/types/ngwr-charts-donut-chart.d.ts +124 -16
  222. package/types/ngwr-charts-funnel-chart.d.ts +62 -6
  223. package/types/ngwr-charts-gauge-testing.d.ts +5 -1
  224. package/types/ngwr-charts-gauge.d.ts +72 -10
  225. package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
  226. package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
  227. package/types/ngwr-charts-line-chart.d.ts +215 -86
  228. package/types/ngwr-charts-meter-group.d.ts +96 -7
  229. package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
  230. package/types/ngwr-charts-radar-chart.d.ts +148 -28
  231. package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
  232. package/types/ngwr-charts-scatter-chart.d.ts +188 -18
  233. package/types/ngwr-charts-sparkline.d.ts +26 -4
  234. package/types/ngwr-charts-treemap-chart.d.ts +121 -23
  235. package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
  236. package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
  237. package/types/ngwr-color-picker.d.ts +27 -0
  238. package/types/ngwr-context-menu-testing.d.ts +10 -9
  239. package/types/ngwr-context-menu.d.ts +17 -0
  240. package/types/ngwr-copy-value.d.ts +8 -0
  241. package/types/ngwr-date-picker.d.ts +34 -2
  242. package/types/ngwr-dialog.d.ts +30 -10
  243. package/types/ngwr-drawer.d.ts +32 -1
  244. package/types/ngwr-dropdown-testing.d.ts +8 -5
  245. package/types/ngwr-dropdown.d.ts +29 -6
  246. package/types/ngwr-graph.d.ts +22 -6
  247. package/types/ngwr-lightbox.d.ts +15 -0
  248. package/types/ngwr-overlay.d.ts +16 -1
  249. package/types/ngwr-popconfirm-testing.d.ts +11 -2
  250. package/types/ngwr-popconfirm.d.ts +28 -1
  251. package/types/ngwr-popover.d.ts +59 -9
  252. package/types/ngwr-table.d.ts +1 -1
  253. package/types/ngwr-tour.d.ts +21 -2
  254. package/types/ngwr-tree-testing.d.ts +1 -2
  255. package/types/ngwr-tree.d.ts +33 -2
  256. package/types/ngwr-version.d.ts +1 -1
  257. package/types/ngwr-window.d.ts +14 -11
  258. package/window/styles/_index.scss +5 -10
@@ -1,11 +1,12 @@
1
1
  import * as i0 from "@angular/core";
2
- import { Component, ViewEncapsulation, computed, input, model, viewChildren } from "@angular/core";
2
+ import { Component, ViewEncapsulation, computed, input, model, viewChild, viewChildren } from "@angular/core";
3
3
  import { coerceBooleanProperty, coerceNumberProperty } from "@angular/cdk/coercion";
4
+ import { NgTemplateOutlet } from "@angular/common";
4
5
  import { wrCheckStyles } from "ngwr/utils";
5
6
  import { useI18nText } from "ngwr/i18n";
6
7
  import { WR_CHART_LEGEND_BLOCK, WrChartLegend } from "ngwr/charts/chart-legend";
7
- import { useChartNumbers, wrChartColor } from "ngwr/charts/core";
8
- import { useChartTooltip } from "ngwr/popover";
8
+ import { WrChartState, useChartHover, useChartNumbers, useChartState, wrChartColor, wrChartRound } from "ngwr/charts/core";
9
+ import { useChartTooltip, wrCoerceChartTooltip } from "ngwr/popover";
9
10
  /**
10
11
  * @license
11
12
  *
@@ -15,6 +16,10 @@ import { useChartTooltip } from "ngwr/popover";
15
16
  var WrMeterGroup = class WrMeterGroup {
16
17
  constructor() {
17
18
  if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("charts/meter-group");
19
+ useChartHover({
20
+ enter: (index) => this.tip.enter(index),
21
+ leave: (event) => this.tip.leave(event)
22
+ });
18
23
  }
19
24
  ariaLabel = input(null, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
20
25
  resolvedAriaLabel = useI18nText(this.ariaLabel, "meterGroup.label", "Meter");
@@ -25,8 +30,20 @@ var WrMeterGroup = class WrMeterGroup {
25
30
  });
26
31
  showLegend = input(true, {
27
32
  ...ngDevMode ? { debugName: "showLegend" } : /* istanbul ignore next */ {},
33
+ transform: (value) => value === "auto" ? "auto" : coerceBooleanProperty(value)
34
+ });
35
+ legendPosition = input("bottom", ...ngDevMode ? [{ debugName: "legendPosition" }] : /* istanbul ignore next */ []);
36
+ loading = input(false, {
37
+ ...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
38
+ transform: coerceBooleanProperty
39
+ });
40
+ error = input(false, {
41
+ ...ngDevMode ? { debugName: "error" } : /* istanbul ignore next */ {},
28
42
  transform: coerceBooleanProperty
29
43
  });
44
+ emptyLabel = input(null, ...ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []);
45
+ loadingLabel = input(null, ...ngDevMode ? [{ debugName: "loadingLabel" }] : /* istanbul ignore next */ []);
46
+ errorLabel = input(null, ...ngDevMode ? [{ debugName: "errorLabel" }] : /* istanbul ignore next */ []);
30
47
  showValues = input(true, {
31
48
  ...ngDevMode ? { debugName: "showValues" } : /* istanbul ignore next */ {},
32
49
  transform: coerceBooleanProperty
@@ -38,10 +55,11 @@ var WrMeterGroup = class WrMeterGroup {
38
55
  hiddenSegments = model([], ...ngDevMode ? [{ debugName: "hiddenSegments" }] : /* istanbul ignore next */ []);
39
56
  tooltip = input(true, {
40
57
  ...ngDevMode ? { debugName: "tooltip" } : /* istanbul ignore next */ {},
41
- transform: coerceBooleanProperty
58
+ transform: wrCoerceChartTooltip
42
59
  });
43
60
  valueFormat = input(null, ...ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []);
44
61
  numbers = useChartNumbers(this.valueFormat);
62
+ barEl = viewChild.required("bar", ...ngDevMode ? [{ debugName: "barEl" }] : /* istanbul ignore next */ []);
45
63
  sliceEls = viewChildren("slice", ...ngDevMode ? [{ debugName: "sliceEls" }] : /* istanbul ignore next */ []);
46
64
  static amount(raw) {
47
65
  return Number.isFinite(raw) ? Math.max(0, raw) : 0;
@@ -71,7 +89,20 @@ var WrMeterGroup = class WrMeterGroup {
71
89
  percent: hidden.has(i) ? 0 : WrMeterGroup.amount(segment.value) / max * 100
72
90
  }));
73
91
  }, ...ngDevMode ? [{ debugName: "slices" }] : /* istanbul ignore next */ []);
74
- bands = computed(() => this.slices().filter((slice) => !slice.hidden), ...ngDevMode ? [{ debugName: "bands" }] : /* istanbul ignore next */ []);
92
+ bands = computed(() => {
93
+ const shown = this.slices().filter((slice) => !slice.hidden);
94
+ let end = 0;
95
+ return shown.map((slice, at) => {
96
+ const size = slice.percent / 100;
97
+ end = Math.min(1, end + size);
98
+ return {
99
+ ...slice,
100
+ size: wrChartRound(size, 5),
101
+ end: wrChartRound(end, 5),
102
+ layer: shown.length - at
103
+ };
104
+ });
105
+ }, ...ngDevMode ? [{ debugName: "bands" }] : /* istanbul ignore next */ []);
75
106
  legendItems = computed(() => {
76
107
  const values = this.showValues();
77
108
  return this.slices().map(({ label, color, text }) => ({
@@ -81,19 +112,51 @@ var WrMeterGroup = class WrMeterGroup {
81
112
  }));
82
113
  }, ...ngDevMode ? [{ debugName: "legendItems" }] : /* istanbul ignore next */ []);
83
114
  tip = useChartTooltip(this.tooltip, (index) => {
84
- const slice = this.slices()[index];
85
- if (!slice || slice.hidden) return null;
86
- const el = this.sliceEls()[this.bands().indexOf(slice)]?.nativeElement;
87
- if (!el) return null;
115
+ const at = this.bands().findIndex((band) => band.index === index);
116
+ const band = this.bands()[at];
117
+ const el = this.sliceEls()[at]?.nativeElement;
118
+ if (!band || !el) return null;
119
+ const bar = this.barEl().nativeElement;
120
+ const box = bar.getBoundingClientRect();
121
+ const rtl = getComputedStyle(bar).direction === "rtl";
122
+ const width = band.size * box.width;
123
+ const x = rtl ? box.right - band.end * box.width : box.left + band.end * box.width - width;
88
124
  return {
89
125
  datum: {
90
- label: slice.label,
91
- value: slice.text,
92
- color: slice.color
126
+ label: band.label,
127
+ value: band.text,
128
+ color: band.color
93
129
  },
94
- anchor: el
130
+ anchor: {
131
+ x,
132
+ y: box.top,
133
+ width,
134
+ height: box.height
135
+ }
95
136
  };
96
137
  });
138
+ legendShown = computed(() => {
139
+ const show = this.showLegend();
140
+ const rows = this.slices().length;
141
+ if (show === false || rows === 0 || this.legendPosition() === "none") return false;
142
+ return show === true || rows > 1;
143
+ }, ...ngDevMode ? [{ debugName: "legendShown" }] : /* istanbul ignore next */ []);
144
+ legendFirst = computed(() => {
145
+ const position = this.legendPosition();
146
+ return position === "top" || position === "start";
147
+ }, ...ngDevMode ? [{ debugName: "legendFirst" }] : /* istanbul ignore next */ []);
148
+ legendSide = computed(() => {
149
+ const position = this.legendPosition();
150
+ return position === "start" || position === "end";
151
+ }, ...ngDevMode ? [{ debugName: "legendSide" }] : /* istanbul ignore next */ []);
152
+ state = useChartState({
153
+ loading: this.loading,
154
+ error: this.error,
155
+ empty: computed(() => this.segments().length === 0),
156
+ emptyLabel: this.emptyLabel,
157
+ loadingLabel: this.loadingLabel,
158
+ errorLabel: this.errorLabel
159
+ });
97
160
  static ɵfac = i0.ɵɵngDeclareFactory({
98
161
  minVersion: "12.0.0",
99
162
  version: "22.2.6",
@@ -137,6 +200,48 @@ var WrMeterGroup = class WrMeterGroup {
137
200
  isRequired: false,
138
201
  transformFunction: null
139
202
  },
203
+ legendPosition: {
204
+ classPropertyName: "legendPosition",
205
+ publicName: "legendPosition",
206
+ isSignal: true,
207
+ isRequired: false,
208
+ transformFunction: null
209
+ },
210
+ loading: {
211
+ classPropertyName: "loading",
212
+ publicName: "loading",
213
+ isSignal: true,
214
+ isRequired: false,
215
+ transformFunction: null
216
+ },
217
+ error: {
218
+ classPropertyName: "error",
219
+ publicName: "error",
220
+ isSignal: true,
221
+ isRequired: false,
222
+ transformFunction: null
223
+ },
224
+ emptyLabel: {
225
+ classPropertyName: "emptyLabel",
226
+ publicName: "emptyLabel",
227
+ isSignal: true,
228
+ isRequired: false,
229
+ transformFunction: null
230
+ },
231
+ loadingLabel: {
232
+ classPropertyName: "loadingLabel",
233
+ publicName: "loadingLabel",
234
+ isSignal: true,
235
+ isRequired: false,
236
+ transformFunction: null
237
+ },
238
+ errorLabel: {
239
+ classPropertyName: "errorLabel",
240
+ publicName: "errorLabel",
241
+ isSignal: true,
242
+ isRequired: false,
243
+ transformFunction: null
244
+ },
140
245
  showValues: {
141
246
  classPropertyName: "showValues",
142
247
  publicName: "showValues",
@@ -174,28 +279,56 @@ var WrMeterGroup = class WrMeterGroup {
174
279
  }
175
280
  },
176
281
  outputs: { hiddenSegments: "hiddenSegmentsChange" },
177
- host: { classAttribute: "wr-meter-group" },
282
+ host: {
283
+ properties: { "class.wr-chart--legend-side": "legendShown() && legendSide()" },
284
+ classAttribute: "wr-meter-group wr-chart--legend"
285
+ },
178
286
  viewQueries: [{
287
+ propertyName: "barEl",
288
+ first: true,
289
+ predicate: ["bar"],
290
+ descendants: true,
291
+ isSignal: true
292
+ }, {
179
293
  propertyName: "sliceEls",
180
294
  predicate: ["slice"],
181
295
  descendants: true,
182
296
  isSignal: true
183
297
  }],
184
298
  ngImport: i0,
185
- template: "<div\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n [attr.aria-valuetext]=\"totalText()\"\n>\n <!-- Only the shown segments draw a band; each keeps its segment's own position, which\n is what the tooltip looks it up by. `data-label` is what the harness reads a band's\n label from; the `title` it used to read is only written while the tooltip is off. -->\n @for (slice of bands(); track slice.index) {\n <span\n #slice\n class=\"wr-meter-group__slice\"\n [attr.title]=\"tooltip() ? null : slice.label\"\n [attr.data-label]=\"slice.label\"\n [style.width.%]=\"slice.percent\"\n [style.background]=\"slice.color\"\n (mouseenter)=\"tip.enter(slice.index)\"\n (mouseleave)=\"tip.leave($event)\"\n ></span>\n }\n</div>\n\n@if (showLegend() && slices().length > 0) {\n <ul\n wr-chart-legend\n class=\"wr-meter-group__legend\"\n [items]=\"legendItems()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n}\n",
186
- dependencies: [{
187
- kind: "component",
188
- type: WrChartLegend,
189
- selector: "ul[wr-chart-legend]",
190
- inputs: [
191
- "items",
192
- "toggleable",
193
- "hiddenSeries",
194
- "ariaLabel",
195
- "hiddenLabel"
196
- ],
197
- outputs: ["hiddenSeriesChange", "toggled"]
198
- }],
299
+ template: "@let shown = state();\n\n<!-- The legend, drawn before the bar or after it so it is in the DOM where it is on\n screen: a toggleable legend's rows are tab stops, and their order follows it. A row's\n position is its segment's, which is the `data-wr-series` the segment's band carries. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-meter-group__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (!shown && legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div\n #bar\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n [attr.aria-valuetext]=\"totalText()\"\n>\n <!-- Only the shown segments draw a band; each keeps its segment's own position, which\n is what the tooltip looks it up by. `data-label` is what the harness reads a band's\n label from; the `title` it used to read is only written while the tooltip is off.\n A band is as wide as the bar and slid back to end at `--wr-meter-group-slice-end`,\n under the bands before it, so its length is a transform; `-size` is its own share. -->\n @if (!shown || shown.kind === 'empty') {\n @for (slice of bands(); track slice.index) {\n <span\n #slice\n class=\"wr-meter-group__slice\"\n [attr.title]=\"tooltip() ? null : slice.label\"\n [attr.data-label]=\"slice.label\"\n [attr.data-wr-index]=\"slice.index\"\n [attr.data-wr-series]=\"slice.index\"\n [style.--wr-meter-group-slice-size]=\"slice.size\"\n [style.--wr-meter-group-slice-end]=\"slice.end\"\n [style.z-index]=\"slice.layer\"\n [style.background]=\"slice.color\"\n ></span>\n }\n }\n</div>\n\n@if (shown) {\n <!-- In the legend's place: a bar is too thin to carry a message over it. -->\n <div class=\"wr-meter-group__status\">\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n </div>\n} @else if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n",
300
+ dependencies: [
301
+ {
302
+ kind: "directive",
303
+ type: NgTemplateOutlet,
304
+ selector: "[ngTemplateOutlet]",
305
+ inputs: [
306
+ "ngTemplateOutletContext",
307
+ "ngTemplateOutlet",
308
+ "ngTemplateOutletInjector"
309
+ ]
310
+ },
311
+ {
312
+ kind: "component",
313
+ type: WrChartLegend,
314
+ selector: "ul[wr-chart-legend]",
315
+ inputs: [
316
+ "items",
317
+ "position",
318
+ "toggleable",
319
+ "hiddenSeries",
320
+ "ariaLabel",
321
+ "hiddenLabel"
322
+ ],
323
+ outputs: ["hiddenSeriesChange", "toggled"]
324
+ },
325
+ {
326
+ kind: "component",
327
+ type: WrChartState,
328
+ selector: "wr-chart-state",
329
+ inputs: ["kind", "label"]
330
+ }
331
+ ],
199
332
  viewProviders: [{
200
333
  provide: WR_CHART_LEGEND_BLOCK,
201
334
  useValue: "wr-meter-group"
@@ -213,13 +346,20 @@ i0.ɵɵngDeclareClassMetadata({
213
346
  args: [{
214
347
  selector: "wr-meter-group",
215
348
  encapsulation: ViewEncapsulation.None,
216
- host: { class: "wr-meter-group" },
217
- imports: [WrChartLegend],
349
+ host: {
350
+ class: "wr-meter-group wr-chart--legend",
351
+ "[class.wr-chart--legend-side]": "legendShown() && legendSide()"
352
+ },
353
+ imports: [
354
+ NgTemplateOutlet,
355
+ WrChartLegend,
356
+ WrChartState
357
+ ],
218
358
  viewProviders: [{
219
359
  provide: WR_CHART_LEGEND_BLOCK,
220
360
  useValue: "wr-meter-group"
221
361
  }],
222
- template: "<div\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n [attr.aria-valuetext]=\"totalText()\"\n>\n <!-- Only the shown segments draw a band; each keeps its segment's own position, which\n is what the tooltip looks it up by. `data-label` is what the harness reads a band's\n label from; the `title` it used to read is only written while the tooltip is off. -->\n @for (slice of bands(); track slice.index) {\n <span\n #slice\n class=\"wr-meter-group__slice\"\n [attr.title]=\"tooltip() ? null : slice.label\"\n [attr.data-label]=\"slice.label\"\n [style.width.%]=\"slice.percent\"\n [style.background]=\"slice.color\"\n (mouseenter)=\"tip.enter(slice.index)\"\n (mouseleave)=\"tip.leave($event)\"\n ></span>\n }\n</div>\n\n@if (showLegend() && slices().length > 0) {\n <ul\n wr-chart-legend\n class=\"wr-meter-group__legend\"\n [items]=\"legendItems()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n}\n"
362
+ template: "@let shown = state();\n\n<!-- The legend, drawn before the bar or after it so it is in the DOM where it is on\n screen: a toggleable legend's rows are tab stops, and their order follows it. A row's\n position is its segment's, which is the `data-wr-series` the segment's band carries. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-meter-group__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (!shown && legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div\n #bar\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n [attr.aria-valuetext]=\"totalText()\"\n>\n <!-- Only the shown segments draw a band; each keeps its segment's own position, which\n is what the tooltip looks it up by. `data-label` is what the harness reads a band's\n label from; the `title` it used to read is only written while the tooltip is off.\n A band is as wide as the bar and slid back to end at `--wr-meter-group-slice-end`,\n under the bands before it, so its length is a transform; `-size` is its own share. -->\n @if (!shown || shown.kind === 'empty') {\n @for (slice of bands(); track slice.index) {\n <span\n #slice\n class=\"wr-meter-group__slice\"\n [attr.title]=\"tooltip() ? null : slice.label\"\n [attr.data-label]=\"slice.label\"\n [attr.data-wr-index]=\"slice.index\"\n [attr.data-wr-series]=\"slice.index\"\n [style.--wr-meter-group-slice-size]=\"slice.size\"\n [style.--wr-meter-group-slice-end]=\"slice.end\"\n [style.z-index]=\"slice.layer\"\n [style.background]=\"slice.color\"\n ></span>\n }\n }\n</div>\n\n@if (shown) {\n <!-- In the legend's place: a bar is too thin to carry a message over it. -->\n <div class=\"wr-meter-group__status\">\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n </div>\n} @else if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n"
223
363
  }]
224
364
  }],
225
365
  ctorParameters: () => [],
@@ -256,6 +396,54 @@ i0.ɵɵngDeclareClassMetadata({
256
396
  required: false
257
397
  }]
258
398
  }],
399
+ legendPosition: [{
400
+ type: i0.Input,
401
+ args: [{
402
+ isSignal: true,
403
+ alias: "legendPosition",
404
+ required: false
405
+ }]
406
+ }],
407
+ loading: [{
408
+ type: i0.Input,
409
+ args: [{
410
+ isSignal: true,
411
+ alias: "loading",
412
+ required: false
413
+ }]
414
+ }],
415
+ error: [{
416
+ type: i0.Input,
417
+ args: [{
418
+ isSignal: true,
419
+ alias: "error",
420
+ required: false
421
+ }]
422
+ }],
423
+ emptyLabel: [{
424
+ type: i0.Input,
425
+ args: [{
426
+ isSignal: true,
427
+ alias: "emptyLabel",
428
+ required: false
429
+ }]
430
+ }],
431
+ loadingLabel: [{
432
+ type: i0.Input,
433
+ args: [{
434
+ isSignal: true,
435
+ alias: "loadingLabel",
436
+ required: false
437
+ }]
438
+ }],
439
+ errorLabel: [{
440
+ type: i0.Input,
441
+ args: [{
442
+ isSignal: true,
443
+ alias: "errorLabel",
444
+ required: false
445
+ }]
446
+ }],
259
447
  showValues: [{
260
448
  type: i0.Input,
261
449
  args: [{
@@ -299,6 +487,10 @@ i0.ɵɵngDeclareClassMetadata({
299
487
  required: false
300
488
  }]
301
489
  }],
490
+ barEl: [{
491
+ type: i0.ViewChild,
492
+ args: ["bar", { isSignal: true }]
493
+ }],
302
494
  sliceEls: [{
303
495
  type: i0.ViewChildren,
304
496
  args: ["slice", { isSignal: true }]
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-charts-meter-group.mjs","names":[],"sources":["../../../projects/lib/charts/meter-group/meter-group.ts","../../../projects/lib/charts/meter-group/meter-group.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, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, type ElementRef, ViewEncapsulation, computed, input, model, viewChildren } from '@angular/core';\n\nimport { WR_CHART_LEGEND_BLOCK, WrChartLegend, type WrChartLegendItem } from 'ngwr/charts/chart-legend';\nimport { wrChartColor, useChartNumbers } from 'ngwr/charts/core';\nimport { useI18nText } from 'ngwr/i18n';\nimport { useChartTooltip } from 'ngwr/popover';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrMeterSegment } from './types';\n\n/**\n * Stacked-segment progress bar. Visualises a breakdown of a total —\n * disk usage, budget, vote share, etc. Each segment contributes a slice\n * proportional to its `value` relative to the sum of the segments shown (or the\n * explicit `max`).\n *\n * @example\n * ```html\n * <wr-meter-group\n * [segments]=\"[\n * { label: 'Used', value: 60 },\n * { label: 'Reserved', value: 25, color: 'var(--wr-color-warning)' }\n * ]\"\n * [max]=\"100\"\n * />\n * ```\n *\n * The legend is a `ul[wr-chart-legend]` (`ngwr/charts/chart-legend`), and with\n * `toggleableLegend` its rows show and hide their segments through `hiddenSegments`.\n *\n * @see https://ngwr.dev/charts/meter-group\n */\n@Component({\n selector: 'wr-meter-group',\n templateUrl: './meter-group.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-meter-group' },\n imports: [WrChartLegend],\n // The legend's rows keep the classes this chart drew before it drew them through\n // `WrChartLegend`: `.wr-meter-group__legend-item`, `__swatch`, `__legend-label` and\n // `__legend-value`.\n viewProviders: [{ provide: WR_CHART_LEGEND_BLOCK, useValue: 'wr-meter-group' }],\n})\nexport class WrMeterGroup {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/meter-group');\n }\n\n /** Accessible name — the role needs one. Falls back to `meterGroup.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'meterGroup.label', 'Meter');\n\n /**\n * The parts of the bar, in order. Each segment is drawn as its share of `max` when\n * set, else of the sum of the segments shown, so they need not add up to anything in\n * particular.\n */\n readonly segments = input<readonly WrMeterSegment[]>([]);\n\n /** Explicit total, a capacity the segments fill. `0` (default) uses the sum of the segments shown. @default 0 */\n readonly max = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /** Show the labelled legend under the bar. @default true */\n readonly showLegend = input(true, { transform: coerceBooleanProperty });\n\n /** Show each segment's value in the legend, next to its label. @default true */\n readonly showValues = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Make each legend row a toggle button that shows and hides its segment, through\n * `hiddenSegments`. A row is a `<button aria-pressed>`, pressed while its segment is\n * shown, so the legend becomes one tab stop per segment. @default false\n */\n readonly toggleableLegend = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The positions in `segments` of the segments that are hidden. Positions rather than\n * labels, since two segments may share a label. A toggleable legend writes it, and a\n * host may bind it with or without one: `[(hiddenSegments)]`.\n *\n * A hidden segment is left out of the bar and out of the sum. With no `max`, the\n * segments still shown share the whole bar between them, each at its share of their\n * own total, as `wr-donut-chart`'s slices do: the bar is the whole of what it draws.\n * An explicit `max` is a capacity rather than a sum, so it stays, and the hidden\n * segment's share becomes empty track. Either way the bar announces the total of the\n * segments shown (`aria-valuenow`, `aria-valuetext`), since that is what it draws, and\n * the tooltip cannot open on a segment that is not drawn. The legend keeps the hidden\n * segment's row, struck through and with its own value, so it can be shown again; the\n * row says \"hidden\" to a screen reader as well, through `aria-pressed` on a toggle and\n * a visually hidden word otherwise. A position past the end of `segments` is kept and\n * ignored.\n */\n readonly hiddenSegments = model<readonly number[]>([]);\n\n /**\n * Show a tooltip with the segment's label and value on hover. It replaces the\n * band's `title`, which is written only while this is off — or the browser would\n * open a second copy a moment later. @default true\n */\n readonly tooltip = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Writes every value in the legend and the tooltip, and the total the bar announces\n * as `aria-valuetext`. `null` uses `Intl.NumberFormat` in `LOCALE_ID`.\n * `aria-valuenow` stays a number.\n */\n readonly valueFormat = input<((value: number) => string) | null>(null);\n\n /** Each value as the legend, the tooltip and the bar print it: never compact, in `LOCALE_ID` unless `valueFormat` is given. */\n private readonly numbers = useChartNumbers(this.valueFormat);\n\n private readonly sliceEls = viewChildren<ElementRef<HTMLElement>>('slice');\n\n /**\n * A segment's contribution, floored at `0` and with anything non-finite read\n * as `0`. One `NaN` used to poison the whole bar: the sum is `NaN` as soon as\n * one value is, so the total fell back to `1` and every OTHER segment was\n * asked for a width of `value * 100`%, while `aria-valuenow` announced `NaN`.\n */\n private static amount(raw: number): number {\n return Number.isFinite(raw) ? Math.max(0, raw) : 0;\n }\n\n private readonly hidden = computed(() => new Set(this.hiddenSegments()));\n\n /** What the segments still shown add up to (see `hiddenSegments`). */\n private readonly shownSum = computed(() => {\n const hidden = this.hidden();\n return this.segments().reduce((acc, s, i) => acc + (hidden.has(i) ? 0 : WrMeterGroup.amount(s.value)), 0);\n });\n\n protected readonly resolvedMax = computed(() => {\n const explicit = this.max();\n if (explicit > 0) return explicit;\n const sum = this.shownSum();\n return sum > 0 ? sum : 1;\n });\n\n /**\n * Sum of the segments, for `aria-valuenow`. `role=\"progressbar\"` without it\n * announces no value at all, so the bar was invisible to assistive tech.\n *\n * Capped at the total, because segments summing past an explicit `max` used\n * to announce a value outside the range they were announced against.\n */\n protected readonly totalValue = computed(() => Math.min(this.resolvedMax(), this.shownSum()));\n\n /**\n * The total as the bar announces it — `aria-valuetext`, written the way the legend\n * writes each figure — so a `valueFormat` that adds a unit reaches a screen reader\n * too, rather than a bare percentage of `aria-valuemax`. The gauge does the same.\n */\n protected readonly totalText = computed(() => this.numbers.value(this.totalValue()));\n\n protected readonly slices = computed(() => {\n const hidden = this.hidden();\n const max = this.resolvedMax();\n return this.segments().map((segment, i) => ({\n index: i,\n label: segment.label,\n // The legend keeps a negative value visible — it is data the caller gave\n // us — but not a non-finite one, which reads as the literal text `NaN`.\n text: this.numbers.value(Number.isFinite(segment.value) ? segment.value : 0),\n color: segment.color ?? wrChartColor(i),\n hidden: hidden.has(i),\n percent: hidden.has(i) ? 0 : (WrMeterGroup.amount(segment.value) / max) * 100,\n }));\n });\n\n /**\n * The bands drawn, in order: every segment but the hidden ones. A hidden band is left\n * out rather than drawn at zero width, since a zero band still lays its gap over the\n * boundary and would leave a double one.\n */\n protected readonly bands = computed(() => this.slices().filter(slice => !slice.hidden));\n\n /** The legend's rows: every segment, hidden ones included, with its value unless `showValues` is off. */\n protected readonly legendItems = computed<readonly WrChartLegendItem[]>(() => {\n const values = this.showValues();\n return this.slices().map(({ label, color, text }) => ({ label, color, value: values ? text : null }));\n });\n\n /**\n * One tooltip for the whole bar, pointing at the hovered band, with the value as\n * the legend prints it. Asked by the segment's own position, and the drawn bands are\n * only the shown ones, so the band is found among them by that position.\n */\n protected readonly tip = useChartTooltip(this.tooltip, index => {\n const slice = this.slices()[index];\n if (!slice || slice.hidden) return null;\n const el = this.sliceEls()[this.bands().indexOf(slice)]?.nativeElement;\n if (!el) return null;\n return { datum: { label: slice.label, value: slice.text, color: slice.color }, anchor: el };\n });\n}\n","<div\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n [attr.aria-valuetext]=\"totalText()\"\n>\n <!-- Only the shown segments draw a band; each keeps its segment's own position, which\n is what the tooltip looks it up by. `data-label` is what the harness reads a band's\n label from; the `title` it used to read is only written while the tooltip is off. -->\n @for (slice of bands(); track slice.index) {\n <span\n #slice\n class=\"wr-meter-group__slice\"\n [attr.title]=\"tooltip() ? null : slice.label\"\n [attr.data-label]=\"slice.label\"\n [style.width.%]=\"slice.percent\"\n [style.background]=\"slice.color\"\n (mouseenter)=\"tip.enter(slice.index)\"\n (mouseleave)=\"tip.leave($event)\"\n ></span>\n }\n</div>\n\n@if (showLegend() && slices().length > 0) {\n <ul\n wr-chart-legend\n class=\"wr-meter-group__legend\"\n [items]=\"legendItems()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n}\n"],"mappings":";;;;;;;;;;;;;;AAmDA,IAAa,eAAb,MAAa,aAAY;CACvB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,oBAAoB;CACvF;CAGS,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,oBAAoB,OAAO;CAOrF,WAAW,MAAiC,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAG/C,MAAM,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,MAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,GAAG,qBAAqB,GAAG,CAAC,CAAC;CAAC,CAAA;CAG3F,aAAa,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,aAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAG3D,aAAa,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,aAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAO3D,mBAAmB,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,mBAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAmBlE,iBAAiB,MAAyB,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,iBAAA,CAAA,+BAAA,CAAA,CAAA;CAO7C,UAAU,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAOxD,cAAc,MAA0C,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AA;GAAA,MAAA,CAAA,sBAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-charts-meter-group.mjs","names":[],"sources":["../../../projects/lib/charts/meter-group/meter-group.ts","../../../projects/lib/charts/meter-group/meter-group.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, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { NgTemplateOutlet } from '@angular/common';\nimport {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n input,\n model,\n viewChild,\n viewChildren,\n} from '@angular/core';\n\nimport {\n WR_CHART_LEGEND_BLOCK,\n WrChartLegend,\n type WrChartLegendItem,\n type WrChartLegendPosition,\n} from 'ngwr/charts/chart-legend';\nimport {\n WrChartState,\n useChartHover,\n useChartNumbers,\n useChartState,\n wrChartColor,\n wrChartRound,\n} from 'ngwr/charts/core';\nimport { useI18nText } from 'ngwr/i18n';\nimport { useChartTooltip, wrCoerceChartTooltip } from 'ngwr/popover';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrMeterSegment } from './types';\n\n/**\n * Stacked-segment progress bar. Visualises a breakdown of a total —\n * disk usage, budget, vote share, etc. Each segment contributes a slice\n * proportional to its `value` relative to the sum of the segments shown (or the\n * explicit `max`).\n *\n * @example\n * ```html\n * <wr-meter-group\n * [segments]=\"[\n * { label: 'Used', value: 60 },\n * { label: 'Reserved', value: 25, color: 'var(--wr-color-warning)' }\n * ]\"\n * [max]=\"100\"\n * />\n * ```\n *\n * The legend is a `ul[wr-chart-legend]` (`ngwr/charts/chart-legend`), and with\n * `toggleableLegend` its rows show and hide their segments through `hiddenSegments`.\n * `legendPosition` puts it under the bar, over it or beside it.\n *\n * **On the chart theme.** A segment with no `color` takes the next colour of the chart\n * palette (`--wr-chart-1` to `-8`), solid, and a 1px line in the surface parts two\n * segments. Hovering a segment or its legend row dims the others. With no segment the\n * bar is an empty track with \"No data\" under it; `loading` and `error` put their own\n * message there.\n *\n * @see https://ngwr.dev/charts/meter-group\n */\n@Component({\n selector: 'wr-meter-group',\n templateUrl: './meter-group.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n // `wr-chart--legend`: the shared rule that keeps the legend's room from the bar.\n class: 'wr-meter-group wr-chart--legend',\n '[class.wr-chart--legend-side]': 'legendShown() && legendSide()',\n },\n imports: [NgTemplateOutlet, WrChartLegend, WrChartState],\n // The legend's rows keep the classes this chart drew before it drew them through\n // `WrChartLegend`: `.wr-meter-group__legend-item`, `__swatch`, `__legend-label` and\n // `__legend-value`.\n viewProviders: [{ provide: WR_CHART_LEGEND_BLOCK, useValue: 'wr-meter-group' }],\n})\nexport class WrMeterGroup {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/meter-group');\n // One pair of listeners on the host, not two on every band: the band under the pointer\n // is the nearest element up from it carrying `data-wr-index`, its segment's position.\n useChartHover({ enter: index => this.tip.enter(index), leave: event => this.tip.leave(event) });\n }\n\n /** Accessible name — the role needs one. Falls back to `meterGroup.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'meterGroup.label', 'Meter');\n\n /**\n * The parts of the bar, in order. Each segment is drawn as its share of `max` when\n * set, else of the sum of the segments shown, so they need not add up to anything in\n * particular.\n */\n readonly segments = input<readonly WrMeterSegment[]>([]);\n\n /** Explicit total, a capacity the segments fill. `0` (default) uses the sum of the segments shown. @default 0 */\n readonly max = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /**\n * Show the labelled legend. `'auto'` leaves it out for a single segment, which has\n * nothing to tell apart; `true` shows it for one too, since the row carries the value.\n * @default true\n */\n readonly showLegend = input<boolean | 'auto', unknown>(true, {\n transform: (value: unknown): boolean | 'auto' => (value === 'auto' ? 'auto' : coerceBooleanProperty(value)),\n });\n\n /**\n * Where the legend sits: `bottom` or `top` of the bar as a wrapping row, `start` or\n * `end` of it as a column, or `none` for no legend at all - `hiddenSegments` still\n * hides a segment from outside. @default 'bottom'\n */\n readonly legendPosition = input<WrChartLegendPosition>('bottom');\n\n /**\n * A request for the meter's data is in flight: the bar empties and the loading message\n * takes the legend's place. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The meter's data failed to load: the bar empties and the error message takes the\n * legend's place. `loading` wins while both are set. @default false\n */\n readonly error = input(false, { transform: coerceBooleanProperty });\n\n /** The message shown when there is no segment. Falls back to `chart.empty`, then `'No data'`. */\n readonly emptyLabel = input<string | null>(null);\n\n /** The message shown while `loading`. Falls back to `chart.loading`, then `'Loading…'`. */\n readonly loadingLabel = input<string | null>(null);\n\n /** The message shown on `error`. Falls back to `chart.error`, then `'Could not load'`. */\n readonly errorLabel = input<string | null>(null);\n\n /** Show each segment's value in the legend, next to its label. @default true */\n readonly showValues = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Make each legend row a toggle button that shows and hides its segment, through\n * `hiddenSegments`. A row is a `<button aria-pressed>`, pressed while its segment is\n * shown, so the legend becomes one tab stop per segment. @default false\n */\n readonly toggleableLegend = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The positions in `segments` of the segments that are hidden. Positions rather than\n * labels, since two segments may share a label. A toggleable legend writes it, and a\n * host may bind it with or without one: `[(hiddenSegments)]`.\n *\n * A hidden segment is left out of the bar and out of the sum. With no `max`, the\n * segments still shown share the whole bar between them, each at its share of their\n * own total, as `wr-donut-chart`'s slices do: the bar is the whole of what it draws.\n * An explicit `max` is a capacity rather than a sum, so it stays, and the hidden\n * segment's share becomes empty track. Either way the bar announces the total of the\n * segments shown (`aria-valuenow`, `aria-valuetext`), since that is what it draws, and\n * the tooltip cannot open on a segment that is not drawn. The legend keeps the hidden\n * segment's row, struck through and with its own value, so it can be shown again; the\n * row says \"hidden\" to a screen reader as well, through `aria-pressed` on a toggle and\n * a visually hidden word otherwise. A position past the end of `segments` is kept and\n * ignored.\n */\n readonly hiddenSegments = model<readonly number[]>([]);\n\n /**\n * Show a tooltip with the segment's label and value on hover. It replaces the band's\n * `title`, which is written only while this is off — or the browser would open a\n * second copy a moment later.\n *\n * By default the pointer passes under the chip to the chart, so the next section\n * answers at once and the chip closes off the chart; `'hoverable'` lets the pointer\n * rest on the chip instead, as WCAG 1.4.13 asks of a hint. @default true\n */\n readonly tooltip = input<boolean | 'hoverable', unknown>(true, { transform: wrCoerceChartTooltip });\n\n /**\n * Writes every value in the legend and the tooltip, and the total the bar announces\n * as `aria-valuetext`. `null` uses `Intl.NumberFormat` in `LOCALE_ID`.\n * `aria-valuenow` stays a number.\n */\n readonly valueFormat = input<((value: number) => string) | null>(null);\n\n /** Each value as the legend, the tooltip and the bar print it: never compact, in `LOCALE_ID` unless `valueFormat` is given. */\n private readonly numbers = useChartNumbers(this.valueFormat);\n\n private readonly barEl = viewChild.required<ElementRef<HTMLElement>>('bar');\n private readonly sliceEls = viewChildren<ElementRef<HTMLElement>>('slice');\n\n /**\n * A segment's contribution, floored at `0` and with anything non-finite read\n * as `0`. One `NaN` used to poison the whole bar: the sum is `NaN` as soon as\n * one value is, so the total fell back to `1` and every OTHER segment was\n * asked for a width of `value * 100`%, while `aria-valuenow` announced `NaN`.\n */\n private static amount(raw: number): number {\n return Number.isFinite(raw) ? Math.max(0, raw) : 0;\n }\n\n private readonly hidden = computed(() => new Set(this.hiddenSegments()));\n\n /** What the segments still shown add up to (see `hiddenSegments`). */\n private readonly shownSum = computed(() => {\n const hidden = this.hidden();\n return this.segments().reduce((acc, s, i) => acc + (hidden.has(i) ? 0 : WrMeterGroup.amount(s.value)), 0);\n });\n\n protected readonly resolvedMax = computed(() => {\n const explicit = this.max();\n if (explicit > 0) return explicit;\n const sum = this.shownSum();\n return sum > 0 ? sum : 1;\n });\n\n /**\n * Sum of the segments, for `aria-valuenow`. `role=\"progressbar\"` without it\n * announces no value at all, so the bar was invisible to assistive tech.\n *\n * Capped at the total, because segments summing past an explicit `max` used\n * to announce a value outside the range they were announced against.\n */\n protected readonly totalValue = computed(() => Math.min(this.resolvedMax(), this.shownSum()));\n\n /**\n * The total as the bar announces it — `aria-valuetext`, written the way the legend\n * writes each figure — so a `valueFormat` that adds a unit reaches a screen reader\n * too, rather than a bare percentage of `aria-valuemax`. The gauge does the same.\n */\n protected readonly totalText = computed(() => this.numbers.value(this.totalValue()));\n\n protected readonly slices = computed(() => {\n const hidden = this.hidden();\n const max = this.resolvedMax();\n return this.segments().map((segment, i) => ({\n index: i,\n label: segment.label,\n // The legend keeps a negative value visible — it is data the caller gave\n // us — but not a non-finite one, which reads as the literal text `NaN`.\n text: this.numbers.value(Number.isFinite(segment.value) ? segment.value : 0),\n color: segment.color ?? wrChartColor(i),\n hidden: hidden.has(i),\n percent: hidden.has(i) ? 0 : (WrMeterGroup.amount(segment.value) / max) * 100,\n }));\n });\n\n /**\n * The bands drawn, in order: every segment but the hidden ones. A hidden band is left\n * out rather than drawn at zero width, since a zero band still lays its gap over the\n * boundary and would leave a double one.\n */\n protected readonly bands = computed(() => {\n const shown = this.slices().filter(slice => !slice.hidden);\n let end = 0;\n return shown.map((slice, at) => {\n const size = slice.percent / 100;\n end = Math.min(1, end + size);\n return {\n ...slice,\n /** Its share of the bar, 0 to 1. */\n size: wrChartRound(size, 5),\n /**\n * Where it ends, as a share of the bar from its start. Every band is as wide as the\n * bar and slid back so that it ends here, under the bands before it: its length on\n * screen is then a transform, and a new value lays nothing out.\n */\n end: wrChartRound(end, 5),\n /** Its place in the pile: the first band on top, so each covers the start of the next. */\n layer: shown.length - at,\n };\n });\n });\n\n /** The legend's rows: every segment, hidden ones included, with its value unless `showValues` is off. */\n protected readonly legendItems = computed<readonly WrChartLegendItem[]>(() => {\n const values = this.showValues();\n return this.slices().map(({ label, color, text }) => ({ label, color, value: values ? text : null }));\n });\n\n /**\n * One tooltip for the whole bar, pointing at the hovered band, with the value as\n * the legend prints it. Asked by the segment's own position, and the drawn bands are\n * only the shown ones, so the band is found among them by that position.\n */\n protected readonly tip = useChartTooltip(this.tooltip, index => {\n const at = this.bands().findIndex(band => band.index === index);\n const band = this.bands()[at];\n const el = this.sliceEls()[at]?.nativeElement;\n if (!band || !el) return null;\n // The band's own box is as wide as the bar, most of it out of sight under the bands\n // before it, so the chip points at the part of the bar the band shows.\n const bar = this.barEl().nativeElement;\n const box = bar.getBoundingClientRect();\n const rtl = getComputedStyle(bar).direction === 'rtl';\n const width = band.size * box.width;\n const x = rtl ? box.right - band.end * box.width : box.left + band.end * box.width - width;\n return {\n datum: { label: band.label, value: band.text, color: band.color },\n anchor: { x, y: box.top, width, height: box.height },\n };\n });\n\n /**\n * Whether the meter draws its legend: unless `showLegend` is off, `legendPosition` is\n * `none`, or there is no segment. Under `showLegend=\"auto\"` a single segment draws none.\n */\n protected readonly legendShown = computed(() => {\n const show = this.showLegend();\n const rows = this.slices().length;\n if (show === false || rows === 0 || this.legendPosition() === 'none') return false;\n return show === true || rows > 1;\n });\n\n /** Whether the legend comes before the bar, in the DOM as on screen: above it, or at inline start. */\n protected readonly legendFirst = computed(() => {\n const position = this.legendPosition();\n return position === 'top' || position === 'start';\n });\n\n /** Whether the legend sits beside the bar rather than above or below it. */\n protected readonly legendSide = computed(() => {\n const position = this.legendPosition();\n return position === 'start' || position === 'end';\n });\n\n /** What the meter shows in place of its legend, or `null` while it draws its segments. */\n protected readonly state = useChartState({\n loading: this.loading,\n error: this.error,\n empty: computed(() => this.segments().length === 0),\n emptyLabel: this.emptyLabel,\n loadingLabel: this.loadingLabel,\n errorLabel: this.errorLabel,\n });\n}\n","@let shown = state();\n\n<!-- The legend, drawn before the bar or after it so it is in the DOM where it is on\n screen: a toggleable legend's rows are tab stops, and their order follows it. A row's\n position is its segment's, which is the `data-wr-series` the segment's band carries. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-meter-group__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (!shown && legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div\n #bar\n class=\"wr-meter-group__bar\"\n role=\"progressbar\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"resolvedMax()\"\n [attr.aria-valuenow]=\"totalValue()\"\n [attr.aria-valuetext]=\"totalText()\"\n>\n <!-- Only the shown segments draw a band; each keeps its segment's own position, which\n is what the tooltip looks it up by. `data-label` is what the harness reads a band's\n label from; the `title` it used to read is only written while the tooltip is off.\n A band is as wide as the bar and slid back to end at `--wr-meter-group-slice-end`,\n under the bands before it, so its length is a transform; `-size` is its own share. -->\n @if (!shown || shown.kind === 'empty') {\n @for (slice of bands(); track slice.index) {\n <span\n #slice\n class=\"wr-meter-group__slice\"\n [attr.title]=\"tooltip() ? null : slice.label\"\n [attr.data-label]=\"slice.label\"\n [attr.data-wr-index]=\"slice.index\"\n [attr.data-wr-series]=\"slice.index\"\n [style.--wr-meter-group-slice-size]=\"slice.size\"\n [style.--wr-meter-group-slice-end]=\"slice.end\"\n [style.z-index]=\"slice.layer\"\n [style.background]=\"slice.color\"\n ></span>\n }\n }\n</div>\n\n@if (shown) {\n <!-- In the legend's place: a bar is too thin to carry a message over it. -->\n <div class=\"wr-meter-group__status\">\n <wr-chart-state [kind]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A,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAK,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CACR,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
@@ -60,7 +60,8 @@ var WrRadarChartHarness = class WrRadarChartHarness extends ComponentHarness {
60
60
  return (await this.locatorForAll(".wr-radar-chart__area")()).length;
61
61
  }
62
62
  async getDotCount() {
63
- return (await this.locatorForAll(".wr-radar-chart__dot")()).length;
63
+ const series = await this.locatorForAll(".wr-radar-chart__dot")();
64
+ return (await Promise.all(series.map((path) => path.getAttribute("d")))).reduce((count, d) => count + (d?.match(/M/g)?.length ?? 0), 0);
64
65
  }
65
66
  async hasLegend() {
66
67
  return await this.locatorForOptional(".wr-radar-chart__legend")() !== null;
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-charts-radar-chart-testing.mjs","names":[],"sources":["../../../projects/lib/charts/radar-chart/testing/wr-radar-chart-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport { WrChartLegendHarness } from 'ngwr/charts/chart-legend/testing';\nimport type { WrRadarVariant } from 'ngwr/charts/radar-chart';\n\nimport type { WrRadarChartHarnessFilters, WrRadarChartPolygon, WrRadarChartTableRow } from './types';\n\n/**\n * One body row of the chart's data table, so its header and cells are read off the row\n * they sit in rather than matched up by position across the whole table.\n */\nclass TableRowHarness extends ComponentHarness {\n static hostSelector = '.wr-chart-table tbody tr';\n\n async read(): Promise<WrRadarChartTableRow> {\n const header = await this.locatorFor('th[scope=\"row\"]')();\n const cells = await this.locatorForAll('td')();\n return { header: await header.text(), cells: await Promise.all(cells.map(cell => cell.text())) };\n }\n}\n\n/**\n * Test harness for `<wr-radar-chart>`.\n *\n * **The polygons' geometry is not read.** Where a vertex lands moves with the scale and\n * the drawing's box, so this harness counts what was drawn and reads what is TEXT: the\n * axis names, the ring values, the legend and the data table. Those are what a reader\n * gets, and they are what breaks when the data wiring does. The one thing it does read off\n * a path is whether the outline CLOSES ({@link getPolygons}): a series with a missing\n * value is drawn open across the gap and never filled, and an outline closed across a\n * value the series does not have is exactly the defect worth catching.\n *\n * **The tooltip cannot be opened from a spec.** It follows the pointer by its angle from\n * the drawing's centre, measured off the drawing's box, which jsdom reports as 0×0 — so\n * there is deliberately no `hoverAxis()`. The numbers it would show are in the data table\n * (`dataTable`), which {@link getTableRows} reads, and which is where a screen reader\n * finds them too.\n *\n * Labels are positioned by the stylesheet from numbers the component writes; with no\n * layout in jsdom there is no method for where a label sits or whether it was ellipsised.\n *\n * @example\n * ```ts\n * const chart = await loader.getHarness(WrRadarChartHarness);\n *\n * expect(await chart.getAxisLabels()).toEqual(['Speed', 'Power', 'Range']);\n * expect(await chart.getPolygonCount()).toBe(2);\n * expect((await chart.getPolygons()).every(p => p.closed)).toBe(true);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrRadarChartHarness extends ComponentHarness {\n static hostSelector = 'wr-radar-chart';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrRadarChartHarnessFilters = {}): HarnessPredicate<WrRadarChartHarness> {\n return new HarnessPredicate(WrRadarChartHarness, options)\n .addOption('ariaLabel', options.ariaLabel, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getAccessibleName(), label)\n )\n .addOption('axisLabel', options.axisLabel, async (harness, label) => {\n for (const axis of await harness.getAxisLabels()) {\n if (await HarnessPredicate.stringMatches(axis, label)) return true;\n }\n return false;\n });\n }\n\n /**\n * The drawing's accessible name — the only name it has. Read off the `<svg>`, which\n * carries the `img` role, rather than off the surface round it: a name on the wrapper\n * would take the axis names beside the drawing out of the accessibility tree.\n */\n async getAccessibleName(): Promise<string | null> {\n return (await this.locatorFor('.wr-radar-chart__svg')()).getAttribute('aria-label');\n }\n\n /**\n * How the chart draws its series (`variant`): `'polygon'` or `'polar-area'`, read off\n * the host's BEM modifier, which the component writes for either one.\n *\n * Throws when the host carries neither modifier rather than answering `'polygon'` by\n * default: a chart that lost its variant binding would otherwise read as the default\n * exactly when the binding is what broke.\n */\n async getVariant(): Promise<WrRadarVariant> {\n const host = await this.host();\n if (await host.hasClass('wr-radar-chart--polar-area')) return 'polar-area';\n if (await host.hasClass('wr-radar-chart--polygon')) return 'polygon';\n throw new Error(\n 'WrRadarChartHarness.getVariant(): the host carries neither .wr-radar-chart--polygon nor ' +\n '.wr-radar-chart--polar-area. The component writes one unconditionally, so its absence is the bug.'\n );\n }\n\n /** The axis names round the drawing, clockwise from twelve o'clock, as given — the full text, ellipsised or not. */\n async getAxisLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-radar-chart__axis-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /** The ring values beside the first axis, from the outer ring in. `[]` with `showGrid` off. */\n async getRingLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-radar-chart__ring-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /** Whether the web is drawn (`showGrid`): the rings and the spokes. */\n async hasGrid(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-radar-chart__ring')()) !== null;\n }\n\n /**\n * How many series outlines were drawn: one per series shown that has at least one\n * value, and none at all with fewer than three axes. In the polar-area variant a\n * series' outline is the one silhouette round its wedges, so this still counts series,\n * not wedges.\n *\n * Worth comparing with the legend: both come from the same list, so a mismatch is a\n * series filtered out of one of them. The difference by design is a series hidden\n * through `hiddenSeries`, which keeps its legend row and draws no outline — the legend\n * harness's `getHidden()` names those.\n */\n async getPolygonCount(): Promise<number> {\n return (await this.locatorForAll('.wr-radar-chart__line')()).length;\n }\n\n /**\n * Every outline drawn, in order: the colour and dash the component wrote on it, and\n * whether it closes. Closed is read off the path's own closing command, which is what\n * makes a browser close the shape. In the polar-area variant the outline is the\n * silhouette round the series' wedges, which always closes, and a missing value is a\n * missing wedge — which {@link getDotCount} and the data table show instead.\n */\n async getPolygons(): Promise<WrRadarChartPolygon[]> {\n const lines = await this.locatorForAll('.wr-radar-chart__line')();\n return Promise.all(\n lines.map(async line => ({\n color: await line.getAttribute('stroke'),\n dash: (await line.getAttribute('stroke-dasharray')) ?? '',\n closed: /Z\\s*$/i.test((await line.getAttribute('d')) ?? ''),\n }))\n );\n }\n\n /**\n * How many polygons are filled (`fill`). Only a closed outline is ever filled, so with\n * `fill` on this is the number of closed outlines in {@link getPolygons}; anything more\n * is a fill drawn across a missing value. In the polar-area variant it is one per\n * series drawn, each fill covering that series' wedges.\n */\n async getAreaCount(): Promise<number> {\n return (await this.locatorForAll('.wr-radar-chart__area')()).length;\n }\n\n /** How many value dots were drawn across every series (`showDots`). A missing value has none. */\n async getDotCount(): Promise<number> {\n return (await this.locatorForAll('.wr-radar-chart__dot')()).length;\n }\n\n /** Whether the legend is rendered (`showLegend`, and at least one series). */\n async hasLegend(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-radar-chart__legend')()) !== null;\n }\n\n /**\n * The legend, as a {@link WrChartLegendHarness}: each row's name, its key and its hidden\n * state and, with `toggleableLegend`, the toggles that show and hide a series.\n *\n * Throws when the chart draws no legend (`showLegend` off, or no series) rather than\n * answering with an empty one: {@link hasLegend} is the question for that.\n */\n async getLegendHarness(): Promise<WrChartLegendHarness> {\n const legend = await this.locatorForOptional(WrChartLegendHarness)();\n if (!legend) {\n throw new Error(\n 'WrRadarChartHarness.getLegendHarness(): the chart draws no legend — `showLegend` is off or there are no ' +\n 'series. Ask hasLegend() first.'\n );\n }\n return legend;\n }\n\n /** Whether the hidden data table is rendered (`dataTable`). */\n async hasDataTable(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-chart-table')()) !== null;\n }\n\n /**\n * The data table's column headings: one per series shown, in order. Hidden series\n * leave the table.\n *\n * Throws when the chart renders no table (`dataTable` off) rather than answering with\n * no columns, which is also what a table of fully hidden series answers.\n */\n async getTableColumns(): Promise<string[]> {\n await this.assertDataTable('getTableColumns');\n const headings = await this.locatorForAll('.wr-chart-table thead th[scope=\"col\"]')();\n return Promise.all(headings.map(heading => heading.text()));\n }\n\n /**\n * The data table's rows, one per axis: its name and each series' own value, as a screen\n * reader walks them. A value outside a fixed `max` is drawn on the edge and tabulated as\n * itself, and a missing one is `''`.\n *\n * Throws when the chart renders no table (`dataTable` off), for the reason\n * {@link getTableColumns} gives.\n */\n async getTableRows(): Promise<WrRadarChartTableRow[]> {\n await this.assertDataTable('getTableRows');\n const rows = await this.locatorForAll(TableRowHarness)();\n return Promise.all(rows.map(row => row.read()));\n }\n\n /**\n * The drawing's diameter in pixels — `size` as the component wrote it — read off the\n * `style` ATTRIBUTE of the surface.\n *\n * NOT `getCssValue()`, which is `getComputedStyle()`: a computed read answers from the\n * LAID-OUT box, which agrees with the inline value in jsdom and disagrees in a browser,\n * where the drawing shrinks in a narrow container and sub-pixel rounding moves the rest.\n * A harness that answers differently in the two places it runs is worse than one that\n * refuses.\n */\n async getSize(): Promise<number> {\n const style = await (await this.locatorFor('.wr-radar-chart__surface')()).getAttribute('style');\n const match = /width:\\s*([\\d.]+)px/.exec(style ?? '');\n if (!match) {\n throw new Error(\n `WrRadarChartHarness.getSize(): no inline width on .wr-radar-chart__surface (style: \"${style ?? ''}\"). ` +\n 'The component writes one unconditionally, so its absence is the bug rather than a zero.'\n );\n }\n return Number.parseFloat(match[1]);\n }\n\n private async assertDataTable(method: string): Promise<void> {\n if (!(await this.hasDataTable())) {\n throw new Error(\n `WrRadarChartHarness.${method}(): the chart renders no data table — \\`dataTable\\` is off. Ask hasDataTable() first.`\n );\n }\n }\n}\n"],"mappings":";;;;;;;;AA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CAAC;CAC5D;CAUA,MAAM,eAAY;EAChB,MAAM,KAAK,gBAAgB,cAAc;EACzC,MAAM,OAAO,MAAM,KAAK,cAAc,eAAe,CAAC,CAAA;EACtD,OAAO,QAAQ,IAAI,KAAK,KAAI,QAAO,IAAI,KAAI,CAAE,CAAC;CAChD;CAYA,MAAM,UAAO;EACX,MAAM,QAAQ,OAAO,MAAM,KAAK,WAAW,0BAA0B,CAAC,CAAA,EAAA,CAAI,aAAa,OAAO;EAC9F,MAAM,QAAQ,sBAAsB,KAAK,SAAS,EAAE;EACpD,IAAI,CAAC,OACH,MAAM,IAAI,MACR,uFAAuF,SAAS,GAAE,4FACP;EAG/F,OAAO,OAAO,WAAW,MAAM,EAAE;CACnC;CAEQ,MAAM,gBAAgB,QAAc;EAC1C,IAAI,CAAE,MAAM,KAAK,aAAY,GAC3B,MAAM,IAAI,MACR,uBAAuB,OAAM,sFAAuF;CAG1H"}
1
+ {"version":3,"file":"ngwr-charts-radar-chart-testing.mjs","names":[],"sources":["../../../projects/lib/charts/radar-chart/testing/wr-radar-chart-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport { WrChartLegendHarness } from 'ngwr/charts/chart-legend/testing';\nimport type { WrRadarVariant } from 'ngwr/charts/radar-chart';\n\nimport type { WrRadarChartHarnessFilters, WrRadarChartPolygon, WrRadarChartTableRow } from './types';\n\n/**\n * One body row of the chart's data table, so its header and cells are read off the row\n * they sit in rather than matched up by position across the whole table.\n */\nclass TableRowHarness extends ComponentHarness {\n static hostSelector = '.wr-chart-table tbody tr';\n\n async read(): Promise<WrRadarChartTableRow> {\n const header = await this.locatorFor('th[scope=\"row\"]')();\n const cells = await this.locatorForAll('td')();\n return { header: await header.text(), cells: await Promise.all(cells.map(cell => cell.text())) };\n }\n}\n\n/**\n * Test harness for `<wr-radar-chart>`.\n *\n * **The polygons' geometry is not read.** Where a vertex lands moves with the scale and\n * the drawing's box, so this harness counts what was drawn and reads what is TEXT: the\n * axis names, the ring values, the legend and the data table. Those are what a reader\n * gets, and they are what breaks when the data wiring does. The one thing it does read off\n * a path is whether the outline CLOSES ({@link getPolygons}): a series with a missing\n * value is drawn open across the gap and never filled, and an outline closed across a\n * value the series does not have is exactly the defect worth catching.\n *\n * **The tooltip cannot be opened from a spec.** It follows the pointer by its angle from\n * the drawing's centre, measured off the drawing's box, which jsdom reports as 0×0 — so\n * there is deliberately no `hoverAxis()`. The numbers it would show are in the data table\n * (`dataTable`), which {@link getTableRows} reads, and which is where a screen reader\n * finds them too.\n *\n * Labels are positioned by the stylesheet from numbers the component writes; with no\n * layout in jsdom there is no method for where a label sits or whether it was ellipsised.\n *\n * @example\n * ```ts\n * const chart = await loader.getHarness(WrRadarChartHarness);\n *\n * expect(await chart.getAxisLabels()).toEqual(['Speed', 'Power', 'Range']);\n * expect(await chart.getPolygonCount()).toBe(2);\n * expect((await chart.getPolygons()).every(p => p.closed)).toBe(true);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrRadarChartHarness extends ComponentHarness {\n static hostSelector = 'wr-radar-chart';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrRadarChartHarnessFilters = {}): HarnessPredicate<WrRadarChartHarness> {\n return new HarnessPredicate(WrRadarChartHarness, options)\n .addOption('ariaLabel', options.ariaLabel, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getAccessibleName(), label)\n )\n .addOption('axisLabel', options.axisLabel, async (harness, label) => {\n for (const axis of await harness.getAxisLabels()) {\n if (await HarnessPredicate.stringMatches(axis, label)) return true;\n }\n return false;\n });\n }\n\n /**\n * The drawing's accessible name — the only name it has. Read off the `<svg>`, which\n * carries the `img` role, rather than off the surface round it: a name on the wrapper\n * would take the axis names beside the drawing out of the accessibility tree.\n */\n async getAccessibleName(): Promise<string | null> {\n return (await this.locatorFor('.wr-radar-chart__svg')()).getAttribute('aria-label');\n }\n\n /**\n * How the chart draws its series (`variant`): `'polygon'` or `'polar-area'`, read off\n * the host's BEM modifier, which the component writes for either one.\n *\n * Throws when the host carries neither modifier rather than answering `'polygon'` by\n * default: a chart that lost its variant binding would otherwise read as the default\n * exactly when the binding is what broke.\n */\n async getVariant(): Promise<WrRadarVariant> {\n const host = await this.host();\n if (await host.hasClass('wr-radar-chart--polar-area')) return 'polar-area';\n if (await host.hasClass('wr-radar-chart--polygon')) return 'polygon';\n throw new Error(\n 'WrRadarChartHarness.getVariant(): the host carries neither .wr-radar-chart--polygon nor ' +\n '.wr-radar-chart--polar-area. The component writes one unconditionally, so its absence is the bug.'\n );\n }\n\n /** The axis names round the drawing, clockwise from twelve o'clock, as given — the full text, ellipsised or not. */\n async getAxisLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-radar-chart__axis-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /**\n * The ring values printed between two spokes, from the outer ring in: one closer than a\n * line to the last is left out, though its ring is drawn. `[]` with `showGrid` off, and\n * while the chart is empty, loading or failed.\n */\n async getRingLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-radar-chart__ring-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /** Whether the web is drawn (`showGrid`): the rings and the spokes. */\n async hasGrid(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-radar-chart__ring')()) !== null;\n }\n\n /**\n * How many series outlines were drawn: one per series shown that has at least one\n * value, and none at all with fewer than three axes. In the polar-area variant a\n * series' outline is the one silhouette round its wedges, so this still counts series,\n * not wedges.\n *\n * Worth comparing with the legend: both come from the same list, so a mismatch is a\n * series filtered out of one of them. The difference by design is a series hidden\n * through `hiddenSeries`, which keeps its legend row and draws no outline — the legend\n * harness's `getHidden()` names those.\n */\n async getPolygonCount(): Promise<number> {\n return (await this.locatorForAll('.wr-radar-chart__line')()).length;\n }\n\n /**\n * Every outline drawn, in order: the colour and dash the component wrote on it, and\n * whether it closes. Closed is read off the path's own closing command, which is what\n * makes a browser close the shape. In the polar-area variant the outline is the\n * silhouette round the series' wedges, which always closes, and a missing value is a\n * missing wedge — which {@link getDotCount} and the data table show instead.\n */\n async getPolygons(): Promise<WrRadarChartPolygon[]> {\n const lines = await this.locatorForAll('.wr-radar-chart__line')();\n return Promise.all(\n lines.map(async line => ({\n color: await line.getAttribute('stroke'),\n dash: (await line.getAttribute('stroke-dasharray')) ?? '',\n closed: /Z\\s*$/i.test((await line.getAttribute('d')) ?? ''),\n }))\n );\n }\n\n /**\n * How many polygons are filled (`fill`). Only a closed outline is ever filled, so with\n * `fill` on this is the number of closed outlines in {@link getPolygons}; anything more\n * is a fill drawn across a missing value. In the polar-area variant it is one per\n * series drawn, each fill covering that series' wedges.\n */\n async getAreaCount(): Promise<number> {\n return (await this.locatorForAll('.wr-radar-chart__area')()).length;\n }\n\n /**\n * How many value dots were drawn across every series (`showDots`). A missing value has\n * none. A series' dots are ONE path, a subpath each, so this counts the subpaths rather\n * than the `.wr-radar-chart__dot` elements, which are one per series.\n */\n async getDotCount(): Promise<number> {\n const series = await this.locatorForAll('.wr-radar-chart__dot')();\n const paths = await Promise.all(series.map(path => path.getAttribute('d')));\n return paths.reduce((count, d) => count + (d?.match(/M/g)?.length ?? 0), 0);\n }\n\n /**\n * Whether the legend is rendered: `showLegend` is not off, `legendPosition` is not\n * `none`, and there are two series or more - or one, with `showLegend` set.\n */\n async hasLegend(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-radar-chart__legend')()) !== null;\n }\n\n /**\n * The legend, as a {@link WrChartLegendHarness}: each row's name, its key and its hidden\n * state and, with `toggleableLegend`, the toggles that show and hide a series.\n *\n * Throws when the chart draws no legend (`showLegend` off, or no series) rather than\n * answering with an empty one: {@link hasLegend} is the question for that.\n */\n async getLegendHarness(): Promise<WrChartLegendHarness> {\n const legend = await this.locatorForOptional(WrChartLegendHarness)();\n if (!legend) {\n throw new Error(\n 'WrRadarChartHarness.getLegendHarness(): the chart draws no legend — `showLegend` is off or there are no ' +\n 'series. Ask hasLegend() first.'\n );\n }\n return legend;\n }\n\n /** Whether the hidden data table is rendered (`dataTable`). */\n async hasDataTable(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-chart-table')()) !== null;\n }\n\n /**\n * The data table's column headings: one per series shown, in order. Hidden series\n * leave the table.\n *\n * Throws when the chart renders no table (`dataTable` off) rather than answering with\n * no columns, which is also what a table of fully hidden series answers.\n */\n async getTableColumns(): Promise<string[]> {\n await this.assertDataTable('getTableColumns');\n const headings = await this.locatorForAll('.wr-chart-table thead th[scope=\"col\"]')();\n return Promise.all(headings.map(heading => heading.text()));\n }\n\n /**\n * The data table's rows, one per axis: its name and each series' own value, as a screen\n * reader walks them. A value outside a fixed `max` is drawn on the edge and tabulated as\n * itself, and a missing one is `''`.\n *\n * Throws when the chart renders no table (`dataTable` off), for the reason\n * {@link getTableColumns} gives.\n */\n async getTableRows(): Promise<WrRadarChartTableRow[]> {\n await this.assertDataTable('getTableRows');\n const rows = await this.locatorForAll(TableRowHarness)();\n return Promise.all(rows.map(row => row.read()));\n }\n\n /**\n * The drawing's diameter in pixels — `size` as the component wrote it — read off the\n * `style` ATTRIBUTE of the surface.\n *\n * NOT `getCssValue()`, which is `getComputedStyle()`: a computed read answers from the\n * LAID-OUT box, which agrees with the inline value in jsdom and disagrees in a browser,\n * where the drawing shrinks in a narrow container and sub-pixel rounding moves the rest.\n * A harness that answers differently in the two places it runs is worse than one that\n * refuses.\n */\n async getSize(): Promise<number> {\n const style = await (await this.locatorFor('.wr-radar-chart__surface')()).getAttribute('style');\n const match = /width:\\s*([\\d.]+)px/.exec(style ?? '');\n if (!match) {\n throw new Error(\n `WrRadarChartHarness.getSize(): no inline width on .wr-radar-chart__surface (style: \"${style ?? ''}\"). ` +\n 'The component writes one unconditionally, so its absence is the bug rather than a zero.'\n );\n }\n return Number.parseFloat(match[1]);\n }\n\n private async assertDataTable(method: string): Promise<void> {\n if (!(await this.hasDataTable())) {\n throw new Error(\n `WrRadarChartHarness.${method}(): the chart renders no data table — \\`dataTable\\` is off. Ask hasDataTable() first.`\n );\n }\n }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAM,kBAAN,cAA8B,iBAAgB;CAC5C,OAAO,eAAe;CAEtB,MAAM,OAAI;EACR,MAAM,SAAS,MAAM,KAAK,WAAW,mBAAiB,CAAC,CAAA;EACvD,MAAM,QAAQ,MAAM,KAAK,cAAc,IAAI,CAAC,CAAA;EAC5C,OAAO;GAAE,QAAQ,MAAM,OAAO,KAAI;GAAI,OAAO,MAAM,QAAQ,IAAI,MAAM,KAAI,SAAQ,KAAK,KAAI,CAAE,CAAC;EAAC;CAChG;;AAkCF,IAAa,sBAAb,MAAa,4BAA4B,iBAAgB;CACvD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAsC,CAAA,GAAE;EAClD,OAAO,IAAI,iBAAiB,qBAAqB,OAAO,CAAC,CACtD,UAAU,aAAa,QAAQ,YAAY,SAAS,UACnD,iBAAiB,cAAc,QAAQ,kBAAiB,GAAI,KAAK,CAAC,CACnE,CACA,UAAU,aAAa,QAAQ,WAAW,OAAO,SAAS,UAAS;GAClE,KAAK,MAAM,QAAQ,MAAM,QAAQ,cAAa,GAC5C,IAAI,MAAM,iBAAiB,cAAc,MAAM,KAAK,GAAG,OAAO;GAEhE,OAAO;EACT,CAAC;CACL;CAOA,MAAM,oBAAiB;EACrB,QAAQ,MAAM,KAAK,WAAW,sBAAsB,CAAC,CAAA,EAAA,CAAI,aAAa,YAAY;CACpF;CAUA,MAAM,aAAU;EACd,MAAM,OAAO,MAAM,KAAK,KAAI;EAC5B,IAAI,MAAM,KAAK,SAAS,4BAA4B,GAAG,OAAO;EAC9D,IAAI,MAAM,KAAK,SAAS,yBAAyB,GAAG,OAAO;EAC3D,MAAM,IAAI,MACR,2LACqG;CAEzG;CAGA,MAAM,gBAAa;EACjB,MAAM,SAAS,MAAM,KAAK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