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 +1 @@
1
- {"version":3,"file":"ngwr-charts-donut-chart-testing.mjs","names":[],"sources":["../../../projects/lib/charts/donut-chart/testing/wr-donut-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';\n\nimport type { WrDonutChartHarnessFilters, WrDonutChartLegendEntry } from './types';\n\n/**\n * Test harness for `<wr-donut-chart>`.\n *\n * **The ring itself is unreadable, and that is by design.** The slices are SVG\n * paths inside a `role=\"img\"` drawing: a screen reader is given that drawing's\n * `aria-label` and nothing else, and a spec cannot get a label or a value off a\n * path's `d`. {@link getLegend} is where the numbers are — which is also the\n * argument for keeping `showLegend` on, since with it off the only other text is\n * whatever {@link getCenterValue} and {@link getCenterLabel} were given.\n *\n * The name is read off the `<svg>` rather than off the surface that wraps it, and\n * the two are not interchangeable: `img` makes its whole subtree presentational, so\n * a name on the wrapper would take the centre text down with it.\n *\n * {@link getSliceCount} is therefore the one thing the ring answers: how many\n * wedges were drawn. Compare it with the legend's length to catch a slice that was\n * filtered out of one and not the other — apart from a slice hidden through\n * `hiddenSegments`, which keeps its legend row and draws no wedge by design;\n * {@link getLegendHarness} says which rows those are.\n *\n * @example\n * ```ts\n * const chart = await loader.getHarness(WrDonutChartHarness);\n *\n * expect(await chart.getSliceCount()).toBe(3);\n * expect(await chart.getLegend()).toEqual([\n * { label: 'Direct', value: '48' },\n * { label: 'Search', value: '32' },\n * { label: 'Social', value: '20' },\n * ]);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrDonutChartHarness extends ComponentHarness {\n static hostSelector = 'wr-donut-chart';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrDonutChartHarnessFilters = {}): HarnessPredicate<WrDonutChartHarness> {\n return new HarnessPredicate(WrDonutChartHarness, options)\n .addOption('ariaLabel', options.ariaLabel, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getAccessibleName(), label)\n )\n .addOption('sliceLabel', options.sliceLabel, async (harness, label) => {\n for (const entry of await harness.getLegend()) {\n if (await HarnessPredicate.stringMatches(entry.label, label)) return true;\n }\n return false;\n });\n }\n\n /** The name the ring announces — the whole chart's, since the slices announce nothing. */\n async getAccessibleName(): Promise<string | null> {\n return (await this.locatorFor('.wr-donut-chart__surface svg')()).getAttribute('aria-label');\n }\n\n /**\n * How many wedges were drawn. A hidden slice draws none, and nor does a chart that is\n * empty, loading or failed. The invisible hover target a sliver gets over the ring\n * (`.wr-donut-chart__hit`) and the track an empty ring keeps (`.wr-donut-chart__track`)\n * are not wedges and are not counted.\n */\n async getSliceCount(): Promise<number> {\n return (await this.locatorForAll('.wr-donut-chart__slice')()).length;\n }\n\n /**\n * Whether the chart is a pie (`pie`), read off its `wr-donut-chart--pie` modifier.\n * Not whether the slices reach the centre — a `thickness` of 0 does that too, and keeps\n * the centre text — since a path's `d` is not read, for the reason given in the class\n * note. A pie renders no centre text: {@link getCenterValue} and {@link getCenterLabel}\n * answer `null` for it whatever was bound.\n */\n async isPie(): Promise<boolean> {\n return (await this.host()).hasClass('wr-donut-chart--pie');\n }\n\n /**\n * Whether the legend is rendered: `showLegend` is not off, `legendPosition` is not\n * `none`, and there are two segments or more - or one, with `showLegend` set.\n */\n async hasLegend(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-donut-chart__legend')()) !== null;\n }\n\n /**\n * The legend as a {@link WrChartLegendHarness}: each row's key and its hidden state\n * and, with `toggleableLegend`, the toggles that show and hide a slice. Not the same\n * thing as {@link getLegend}, which reads the rows' text and stays as it was.\n *\n * Throws when the chart draws no legend (`showLegend` off, `legendPosition=\"none\"`, no\n * segments, or a single one under `showLegend=\"auto\"`) rather than answering with an\n * 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 'WrDonutChartHarness.getLegendHarness(): the chart draws no legend — `showLegend` is off or there are no ' +\n 'segments. Ask hasLegend() first.'\n );\n }\n return legend;\n }\n\n /** The legend rows in order — the only textual form the data has. Hidden slices included. */\n async getLegend(): Promise<WrDonutChartLegendEntry[]> {\n const labels = await this.locatorForAll('.wr-donut-chart__legend-label')();\n const values = await this.locatorForAll('.wr-donut-chart__legend-value')();\n\n return Promise.all(\n labels.map(async (label, index) => ({\n label: await label.text(),\n value: (await values[index]?.text()) ?? '',\n }))\n );\n }\n\n /** The big number in the middle, or `null` when the chart has none — a pie never has. */\n async getCenterValue(): Promise<string | null> {\n const center = await this.locatorForOptional('.wr-donut-chart__center-value')();\n return center ? center.text() : null;\n }\n\n /** The caption under the centre value, or `null` — a pie never has one. */\n async getCenterLabel(): Promise<string | null> {\n const center = await this.locatorForOptional('.wr-donut-chart__center-label')();\n return center ? center.text() : null;\n }\n\n /**\n * The chart's outer size in pixels, read off the `style` ATTRIBUTE.\n *\n * NOT `getCssValue()`, which is `getComputedStyle()` — the same rule this\n * file's class note already states and this method alone broke. A computed\n * read answers from the LAID-OUT box, so it agrees with the inline value in\n * jsdom (which lays nothing out and echoes the declaration) and disagrees in a\n * browser, where sub-pixel rounding turns a declared 240 into 239.5. A harness\n * 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-donut-chart__surface')()).getAttribute('style');\n const match = /width:\\s*([\\d.]+)px/.exec(style ?? '');\n if (!match) {\n throw new Error(\n `WrDonutChartHarness.getSize(): no inline width on .wr-donut-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"],"mappings":";;;;;;;;AA+CA,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,cAAc,QAAQ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AO,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"}
1
+ {"version":3,"file":"ngwr-charts-donut-chart-testing.mjs","names":[],"sources":["../../../projects/lib/charts/donut-chart/testing/wr-donut-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';\n\nimport type { WrDonutChartHarnessFilters, WrDonutChartLegendEntry, WrDonutChartTableRow } 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<WrDonutChartTableRow> {\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-donut-chart>`.\n *\n * **The ring itself is unreadable, and that is by design.** The slices are SVG\n * paths inside a `role=\"img\"` drawing: a screen reader is given that drawing's\n * `aria-label` and nothing else, and a spec cannot get a label or a value off a\n * path's `d`. {@link getLegend} is where the numbers are — which is also the\n * argument for keeping `showLegend` on, since with it off the only other text is\n * whatever {@link getCenterValue} and {@link getCenterLabel} were given, unless\n * `dataTable` is on: {@link getTableRows} then reads every slice shown, with its share.\n *\n * The name is read off the `<svg>` rather than off the surface that wraps it, and\n * the two are not interchangeable: `img` makes its whole subtree presentational, so\n * a name on the wrapper would take the centre text down with it.\n *\n * {@link getSliceCount} is therefore the one thing the ring answers: how many\n * wedges were drawn. Compare it with the legend's length to catch a slice that was\n * filtered out of one and not the other — apart from a slice hidden through\n * `hiddenSegments`, which keeps its legend row and draws no wedge by design;\n * {@link getLegendHarness} says which rows those are.\n *\n * @example\n * ```ts\n * const chart = await loader.getHarness(WrDonutChartHarness);\n *\n * expect(await chart.getSliceCount()).toBe(3);\n * expect(await chart.getLegend()).toEqual([\n * { label: 'Direct', value: '48' },\n * { label: 'Search', value: '32' },\n * { label: 'Social', value: '20' },\n * ]);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrDonutChartHarness extends ComponentHarness {\n static hostSelector = 'wr-donut-chart';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrDonutChartHarnessFilters = {}): HarnessPredicate<WrDonutChartHarness> {\n return new HarnessPredicate(WrDonutChartHarness, options)\n .addOption('ariaLabel', options.ariaLabel, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getAccessibleName(), label)\n )\n .addOption('sliceLabel', options.sliceLabel, async (harness, label) => {\n for (const entry of await harness.getLegend()) {\n if (await HarnessPredicate.stringMatches(entry.label, label)) return true;\n }\n return false;\n });\n }\n\n /** The name the ring announces — the whole chart's, since the slices announce nothing. */\n async getAccessibleName(): Promise<string | null> {\n return (await this.locatorFor('.wr-donut-chart__surface svg')()).getAttribute('aria-label');\n }\n\n /**\n * How many wedges were drawn. A hidden slice draws none, and nor does a chart that is\n * empty, loading or failed. The invisible hover target a sliver gets over the ring\n * (`.wr-donut-chart__hit`) and the track an empty ring keeps (`.wr-donut-chart__track`)\n * are not wedges and are not counted.\n */\n async getSliceCount(): Promise<number> {\n return (await this.locatorForAll('.wr-donut-chart__slice')()).length;\n }\n\n /**\n * Whether the chart is a pie (`pie`), read off its `wr-donut-chart--pie` modifier.\n * Not whether the slices reach the centre — a `thickness` of 0 does that too, and keeps\n * the centre text — since a path's `d` is not read, for the reason given in the class\n * note. A pie renders no centre text: {@link getCenterValue} and {@link getCenterLabel}\n * answer `null` for it whatever was bound.\n */\n async isPie(): Promise<boolean> {\n return (await this.host()).hasClass('wr-donut-chart--pie');\n }\n\n /**\n * Whether the legend is rendered: `showLegend` is not off, `legendPosition` is not\n * `none`, and there are two segments or more - or one, with `showLegend` set.\n */\n async hasLegend(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-donut-chart__legend')()) !== null;\n }\n\n /**\n * The legend as a {@link WrChartLegendHarness}: each row's key and its hidden state\n * and, with `toggleableLegend`, the toggles that show and hide a slice. Not the same\n * thing as {@link getLegend}, which reads the rows' text and stays as it was.\n *\n * Throws when the chart draws no legend (`showLegend` off, `legendPosition=\"none\"`, no\n * segments, or a single one under `showLegend=\"auto\"`) rather than answering with an\n * 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 'WrDonutChartHarness.getLegendHarness(): the chart draws no legend — `showLegend` is off or there are no ' +\n 'segments. Ask hasLegend() first.'\n );\n }\n return legend;\n }\n\n /** The legend rows in order — the only textual form the data has. Hidden slices included. */\n async getLegend(): Promise<WrDonutChartLegendEntry[]> {\n const labels = await this.locatorForAll('.wr-donut-chart__legend-label')();\n const values = await this.locatorForAll('.wr-donut-chart__legend-value')();\n\n return Promise.all(\n labels.map(async (label, index) => ({\n label: await label.text(),\n value: (await values[index]?.text()) ?? '',\n }))\n );\n }\n\n /** Whether the hidden data table is rendered (`dataTable`, while the chart draws its slices). */\n async hasDataTable(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-chart-table')()) !== null;\n }\n\n /**\n * The data table's column headings: the value's name and the share's.\n *\n * Throws when the chart renders no table (`dataTable` off, or a state in the slices'\n * place) rather than answering with no columns.\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 slice shown, in the data's own order: its label, its\n * value and its share of the ring, as a screen reader walks them. A slice hidden\n * through `hiddenSegments` has no row, and one that draws nothing an empty share.\n *\n * Throws when the chart renders no table, for the reason {@link getTableColumns} gives.\n */\n async getTableRows(): Promise<WrDonutChartTableRow[]> {\n await this.assertDataTable('getTableRows');\n const rows = await this.locatorForAll(TableRowHarness)();\n return Promise.all(rows.map(row => row.read()));\n }\n\n /** The big number in the middle, or `null` when the chart has none — a pie never has. */\n async getCenterValue(): Promise<string | null> {\n const center = await this.locatorForOptional('.wr-donut-chart__center-value')();\n return center ? center.text() : null;\n }\n\n /** The caption under the centre value, or `null` — a pie never has one. */\n async getCenterLabel(): Promise<string | null> {\n const center = await this.locatorForOptional('.wr-donut-chart__center-label')();\n return center ? center.text() : null;\n }\n\n /**\n * The chart's outer size in pixels, read off the `style` ATTRIBUTE.\n *\n * NOT `getCssValue()`, which is `getComputedStyle()` — the same rule this\n * file's class note already states and this method alone broke. A computed\n * read answers from the LAID-OUT box, so it agrees with the inline value in\n * jsdom (which lays nothing out and echoes the declaration) and disagrees in a\n * browser, where sub-pixel rounding turns a declared 240 into 239.5. A harness\n * 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-donut-chart__surface')()).getAttribute('style');\n const match = /width:\\s*([\\d.]+)px/.exec(style ?? '');\n if (!match) {\n throw new Error(\n `WrDonutChartHarness.getSize(): no inline width on .wr-donut-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 `WrDonutChartHarness.${method}(): the chart renders no data table: \\`dataTable\\` is off, or there ` +\n 'is nothing to tabulate. Ask hasDataTable() first.'\n );\n }\n }\n}\n"],"mappings":";;;;;;;;A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WAAW,MAAM,EAAE;CACnC;CAEQ,MAAM,gBAAgB,QAAc;EAC1C,IAAI,CAAE,MAAM,KAAK,aAAY,GAC3B,MAAM,IAAI,MACR,uBAAuB,OAAM,sHACwB;CAG3D"}
@@ -1,11 +1,11 @@
1
1
  import * as i0 from "@angular/core";
2
- import { Component, ViewEncapsulation, computed, input, model, viewChild } from "@angular/core";
2
+ import { Component, LOCALE_ID, ViewEncapsulation, computed, inject, input, model, viewChild } from "@angular/core";
3
3
  import { coerceBooleanProperty, coerceNumberProperty } from "@angular/cdk/coercion";
4
4
  import { NgTemplateOutlet } from "@angular/common";
5
5
  import { wrCheckStyles } from "ngwr/utils";
6
- import { useI18nText } from "ngwr/i18n";
6
+ import { useI18nText, wrReadI18nText } from "ngwr/i18n";
7
7
  import { WR_CHART_LEGEND_BLOCK, WrChartLegend } from "ngwr/charts/chart-legend";
8
- import { WrChartState, useChartHover, useChartNumbers, useChartState, wrChartColor } from "ngwr/charts/core";
8
+ import { WrChartState, WrChartTable, useChartHover, useChartNumbers, useChartState, wrChartColor, wrChartNumberFormat } from "ngwr/charts/core";
9
9
  import { useChartTooltip, wrCoerceChartTooltip } from "ngwr/popover";
10
10
  /**
11
11
  * @license
@@ -76,7 +76,22 @@ var WrDonutChart = class WrDonutChart {
76
76
  transform: wrCoerceChartTooltip
77
77
  });
78
78
  valueFormat = input(null, ...ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []);
79
+ dataTable = input(false, {
80
+ ...ngDevMode ? { debugName: "dataTable" } : /* istanbul ignore next */ {},
81
+ transform: coerceBooleanProperty
82
+ });
83
+ valueName = wrReadI18nText("donutChart.value", "Value");
84
+ shareName = wrReadI18nText("donutChart.share", "Share");
79
85
  numbers = useChartNumbers(this.valueFormat);
86
+ locale = inject(LOCALE_ID);
87
+ shares = wrChartNumberFormat(this.locale, {
88
+ style: "percent",
89
+ maximumFractionDigits: 1
90
+ });
91
+ smallShares = wrChartNumberFormat(this.locale, {
92
+ style: "percent",
93
+ maximumSignificantDigits: 2
94
+ });
80
95
  hidden = computed(() => new Set(this.hiddenSegments()), ...ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []);
81
96
  svg = viewChild("svg", ...ngDevMode ? [{ debugName: "svg" }] : /* istanbul ignore next */ []);
82
97
  outerR = 50;
@@ -209,6 +224,17 @@ var WrDonutChart = class WrDonutChart {
209
224
  loadingLabel: this.loadingLabel,
210
225
  errorLabel: this.errorLabel
211
226
  });
227
+ tableData = computed(() => ({
228
+ caption: this.resolvedAriaLabel(),
229
+ columns: [this.valueName(), this.shareName()],
230
+ groups: [{ rows: this.slices().filter((slice) => !slice.hidden).map((slice) => {
231
+ const share = slice.percent / 100;
232
+ return {
233
+ header: slice.label,
234
+ cells: [slice.text, share > 0 ? (share < .01 ? this.smallShares : this.shares).format(share) : ""]
235
+ };
236
+ }) }]
237
+ }), ...ngDevMode ? [{ debugName: "tableData" }] : /* istanbul ignore next */ []);
212
238
  track = computed(() => this.state() || this.slices().every((slice) => !slice.path) ? this.arcPath(0, Math.PI * 2) : null, ...ngDevMode ? [{ debugName: "track" }] : /* istanbul ignore next */ []);
213
239
  tip = useChartTooltip(this.tooltip, (index) => {
214
240
  const slice = this.slices()[index];
@@ -412,6 +438,13 @@ var WrDonutChart = class WrDonutChart {
412
438
  isSignal: true,
413
439
  isRequired: false,
414
440
  transformFunction: null
441
+ },
442
+ dataTable: {
443
+ classPropertyName: "dataTable",
444
+ publicName: "dataTable",
445
+ isSignal: true,
446
+ isRequired: false,
447
+ transformFunction: null
415
448
  }
416
449
  },
417
450
  outputs: { hiddenSegments: "hiddenSegmentsChange" },
@@ -431,7 +464,7 @@ var WrDonutChart = class WrDonutChart {
431
464
  isSignal: true
432
465
  }],
433
466
  ngImport: i0,
434
- template: "@let shown = state();\n\n<!-- The legend, drawn before the drawing 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. The key\n is `aria-hidden`: the row's text is its name, and the dot carries no word of its own. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-donut-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div class=\"wr-donut-chart__surface\" [style.width.px]=\"size()\">\n <!-- The name sits on the DRAWING, not on this wrapper. `img` is a\n children-presentational role, so with it out here WebKit dropped the whole\n subtree — including the centre value and label, which are real text and are\n the headline datum the legend does not carry. -->\n <svg #svg viewBox=\"0 0 100 100\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\">\n @if (track(); as ring) {\n <!-- The frame the chart keeps with no slice to draw: the ring itself, as a track. -->\n <path class=\"wr-donut-chart__track\" [attr.d]=\"ring\" />\n }\n <!-- Every slice is stroked in the SURFACE colour (`--wr-donut-chart-slice-gap-color`,\n from the stylesheet), so adjacent arcs are separated by a visible gap rather than\n by the boundary between two fills. Without it the only thing dividing two slices\n is the colour change itself, and for a reader who cannot separate hue two\n neighbours merge into one arc and the chart reads as having fewer slices than it\n has. A gap is a shape, and it survives greyscale, printing and a monochrome\n display. The stroke does not scale with the drawing, so the gap is the same\n pixels at any `size`; its width is the stylesheet's. -->\n @if (!shown) {\n @for (slice of slices(); track $index) {\n <!-- A hidden slice draws nothing at all; the index stays the slice's own, which is\n what the tooltip looks it up by. `data-wr-index` is what the chart's one hover\n listener reads, and `data-wr-series` the slice's legend row, which the hover\n dims by. -->\n @if (!slice.hidden) {\n <path\n class=\"wr-donut-chart__slice\"\n [attr.d]=\"slice.path\"\n [attr.fill]=\"slice.color\"\n [style.--wr-donut-chart-slice-color]=\"slice.color\"\n [attr.data-wr-index]=\"$index\"\n [attr.data-wr-series]=\"$index\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n <!-- A sliver's wider hover target in a pie, filled with nothing: see `hits`, which is\n empty for the ring and with the tooltip off. Last, so it wins the pointer over the\n slices it reaches into; `fill`, so the unpainted stroke is not hit-tested and the\n edges stay where `hits` put them. It carries its slice's index and legend row, so\n the hover reads it as the slice. -->\n @for (hit of hits(); track hit.index) {\n <path\n class=\"wr-donut-chart__hit\"\n [attr.d]=\"hit.path\"\n [attr.data-wr-index]=\"hit.index\"\n [attr.data-wr-series]=\"hit.index\"\n fill=\"none\"\n pointer-events=\"fill\"\n />\n }\n }\n </svg>\n <!-- Never with `pie`: a pie has no hole to print in. -->\n @if (showCenter()) {\n <div class=\"wr-donut-chart__center\">\n @if (centerValue()) {\n <div class=\"wr-donut-chart__center-value\">{{ centerValue() }}</div>\n }\n @if (centerLabel()) {\n <div class=\"wr-donut-chart__center-label\">{{ centerLabel() }}</div>\n }\n </div>\n }\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the track the chart keeps. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n",
467
+ template: "@let shown = state();\n\n<!-- The legend, drawn before the drawing 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. The key\n is `aria-hidden`: the row's text is its name, and the dot carries no word of its own. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-donut-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div class=\"wr-donut-chart__surface\" [style.width.px]=\"size()\">\n <!-- The name sits on the DRAWING, not on this wrapper. `img` is a\n children-presentational role, so with it out here WebKit dropped the whole\n subtree — including the centre value and label, which are real text and are\n the headline datum the legend does not carry. -->\n <svg #svg viewBox=\"0 0 100 100\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\">\n @if (track(); as ring) {\n <!-- The frame the chart keeps with no slice to draw: the ring itself, as a track. -->\n <path class=\"wr-donut-chart__track\" [attr.d]=\"ring\" />\n }\n <!-- Every slice is stroked in the SURFACE colour (`--wr-donut-chart-slice-gap-color`,\n from the stylesheet), so adjacent arcs are separated by a visible gap rather than\n by the boundary between two fills. Without it the only thing dividing two slices\n is the colour change itself, and for a reader who cannot separate hue two\n neighbours merge into one arc and the chart reads as having fewer slices than it\n has. A gap is a shape, and it survives greyscale, printing and a monochrome\n display. The stroke does not scale with the drawing, so the gap is the same\n pixels at any `size`; its width is the stylesheet's. -->\n @if (!shown) {\n @for (slice of slices(); track $index) {\n <!-- A hidden slice draws nothing at all; the index stays the slice's own, which is\n what the tooltip looks it up by. `data-wr-index` is what the chart's one hover\n listener reads, and `data-wr-series` the slice's legend row, which the hover\n dims by. -->\n @if (!slice.hidden) {\n <path\n class=\"wr-donut-chart__slice\"\n [attr.d]=\"slice.path\"\n [attr.fill]=\"slice.color\"\n [style.--wr-donut-chart-slice-color]=\"slice.color\"\n [attr.data-wr-index]=\"$index\"\n [attr.data-wr-series]=\"$index\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n <!-- A sliver's wider hover target in a pie, filled with nothing: see `hits`, which is\n empty for the ring and with the tooltip off. Last, so it wins the pointer over the\n slices it reaches into; `fill`, so the unpainted stroke is not hit-tested and the\n edges stay where `hits` put them. It carries its slice's index and legend row, so\n the hover reads it as the slice. -->\n @for (hit of hits(); track hit.index) {\n <path\n class=\"wr-donut-chart__hit\"\n [attr.d]=\"hit.path\"\n [attr.data-wr-index]=\"hit.index\"\n [attr.data-wr-series]=\"hit.index\"\n fill=\"none\"\n pointer-events=\"fill\"\n />\n }\n }\n </svg>\n <!-- Never with `pie`: a pie has no hole to print in. -->\n @if (showCenter()) {\n <div class=\"wr-donut-chart__center\">\n @if (centerValue()) {\n <div class=\"wr-donut-chart__center-value\">{{ centerValue() }}</div>\n }\n @if (centerLabel()) {\n <div class=\"wr-donut-chart__center-label\">{{ centerLabel() }}</div>\n }\n </div>\n }\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the track the chart keeps. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n@if (dataTable() && !shown) {\n <!-- The figures for a screen reader, beside the drawing rather than inside its `img`,\n which would make them presentational. Clipped to nothing by its own stylesheet, so\n it takes no room and draws nothing. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n",
435
468
  dependencies: [
436
469
  {
437
470
  kind: "directive",
@@ -462,6 +495,12 @@ var WrDonutChart = class WrDonutChart {
462
495
  type: WrChartState,
463
496
  selector: "wr-chart-state",
464
497
  inputs: ["kind", "label"]
498
+ },
499
+ {
500
+ kind: "component",
501
+ type: WrChartTable,
502
+ selector: "wr-chart-table",
503
+ inputs: ["data"]
465
504
  }
466
505
  ],
467
506
  viewProviders: [{
@@ -490,13 +529,14 @@ i0.ɵɵngDeclareClassMetadata({
490
529
  imports: [
491
530
  NgTemplateOutlet,
492
531
  WrChartLegend,
493
- WrChartState
532
+ WrChartState,
533
+ WrChartTable
494
534
  ],
495
535
  viewProviders: [{
496
536
  provide: WR_CHART_LEGEND_BLOCK,
497
537
  useValue: "wr-donut-chart"
498
538
  }],
499
- template: "@let shown = state();\n\n<!-- The legend, drawn before the drawing 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. The key\n is `aria-hidden`: the row's text is its name, and the dot carries no word of its own. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-donut-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div class=\"wr-donut-chart__surface\" [style.width.px]=\"size()\">\n <!-- The name sits on the DRAWING, not on this wrapper. `img` is a\n children-presentational role, so with it out here WebKit dropped the whole\n subtree — including the centre value and label, which are real text and are\n the headline datum the legend does not carry. -->\n <svg #svg viewBox=\"0 0 100 100\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\">\n @if (track(); as ring) {\n <!-- The frame the chart keeps with no slice to draw: the ring itself, as a track. -->\n <path class=\"wr-donut-chart__track\" [attr.d]=\"ring\" />\n }\n <!-- Every slice is stroked in the SURFACE colour (`--wr-donut-chart-slice-gap-color`,\n from the stylesheet), so adjacent arcs are separated by a visible gap rather than\n by the boundary between two fills. Without it the only thing dividing two slices\n is the colour change itself, and for a reader who cannot separate hue two\n neighbours merge into one arc and the chart reads as having fewer slices than it\n has. A gap is a shape, and it survives greyscale, printing and a monochrome\n display. The stroke does not scale with the drawing, so the gap is the same\n pixels at any `size`; its width is the stylesheet's. -->\n @if (!shown) {\n @for (slice of slices(); track $index) {\n <!-- A hidden slice draws nothing at all; the index stays the slice's own, which is\n what the tooltip looks it up by. `data-wr-index` is what the chart's one hover\n listener reads, and `data-wr-series` the slice's legend row, which the hover\n dims by. -->\n @if (!slice.hidden) {\n <path\n class=\"wr-donut-chart__slice\"\n [attr.d]=\"slice.path\"\n [attr.fill]=\"slice.color\"\n [style.--wr-donut-chart-slice-color]=\"slice.color\"\n [attr.data-wr-index]=\"$index\"\n [attr.data-wr-series]=\"$index\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n <!-- A sliver's wider hover target in a pie, filled with nothing: see `hits`, which is\n empty for the ring and with the tooltip off. Last, so it wins the pointer over the\n slices it reaches into; `fill`, so the unpainted stroke is not hit-tested and the\n edges stay where `hits` put them. It carries its slice's index and legend row, so\n the hover reads it as the slice. -->\n @for (hit of hits(); track hit.index) {\n <path\n class=\"wr-donut-chart__hit\"\n [attr.d]=\"hit.path\"\n [attr.data-wr-index]=\"hit.index\"\n [attr.data-wr-series]=\"hit.index\"\n fill=\"none\"\n pointer-events=\"fill\"\n />\n }\n }\n </svg>\n <!-- Never with `pie`: a pie has no hole to print in. -->\n @if (showCenter()) {\n <div class=\"wr-donut-chart__center\">\n @if (centerValue()) {\n <div class=\"wr-donut-chart__center-value\">{{ centerValue() }}</div>\n }\n @if (centerLabel()) {\n <div class=\"wr-donut-chart__center-label\">{{ centerLabel() }}</div>\n }\n </div>\n }\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the track the chart keeps. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n"
539
+ template: "@let shown = state();\n\n<!-- The legend, drawn before the drawing 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. The key\n is `aria-hidden`: the row's text is its name, and the dot carries no word of its own. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-donut-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div class=\"wr-donut-chart__surface\" [style.width.px]=\"size()\">\n <!-- The name sits on the DRAWING, not on this wrapper. `img` is a\n children-presentational role, so with it out here WebKit dropped the whole\n subtree — including the centre value and label, which are real text and are\n the headline datum the legend does not carry. -->\n <svg #svg viewBox=\"0 0 100 100\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\">\n @if (track(); as ring) {\n <!-- The frame the chart keeps with no slice to draw: the ring itself, as a track. -->\n <path class=\"wr-donut-chart__track\" [attr.d]=\"ring\" />\n }\n <!-- Every slice is stroked in the SURFACE colour (`--wr-donut-chart-slice-gap-color`,\n from the stylesheet), so adjacent arcs are separated by a visible gap rather than\n by the boundary between two fills. Without it the only thing dividing two slices\n is the colour change itself, and for a reader who cannot separate hue two\n neighbours merge into one arc and the chart reads as having fewer slices than it\n has. A gap is a shape, and it survives greyscale, printing and a monochrome\n display. The stroke does not scale with the drawing, so the gap is the same\n pixels at any `size`; its width is the stylesheet's. -->\n @if (!shown) {\n @for (slice of slices(); track $index) {\n <!-- A hidden slice draws nothing at all; the index stays the slice's own, which is\n what the tooltip looks it up by. `data-wr-index` is what the chart's one hover\n listener reads, and `data-wr-series` the slice's legend row, which the hover\n dims by. -->\n @if (!slice.hidden) {\n <path\n class=\"wr-donut-chart__slice\"\n [attr.d]=\"slice.path\"\n [attr.fill]=\"slice.color\"\n [style.--wr-donut-chart-slice-color]=\"slice.color\"\n [attr.data-wr-index]=\"$index\"\n [attr.data-wr-series]=\"$index\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n <!-- A sliver's wider hover target in a pie, filled with nothing: see `hits`, which is\n empty for the ring and with the tooltip off. Last, so it wins the pointer over the\n slices it reaches into; `fill`, so the unpainted stroke is not hit-tested and the\n edges stay where `hits` put them. It carries its slice's index and legend row, so\n the hover reads it as the slice. -->\n @for (hit of hits(); track hit.index) {\n <path\n class=\"wr-donut-chart__hit\"\n [attr.d]=\"hit.path\"\n [attr.data-wr-index]=\"hit.index\"\n [attr.data-wr-series]=\"hit.index\"\n fill=\"none\"\n pointer-events=\"fill\"\n />\n }\n }\n </svg>\n <!-- Never with `pie`: a pie has no hole to print in. -->\n @if (showCenter()) {\n <div class=\"wr-donut-chart__center\">\n @if (centerValue()) {\n <div class=\"wr-donut-chart__center-value\">{{ centerValue() }}</div>\n }\n @if (centerLabel()) {\n <div class=\"wr-donut-chart__center-label\">{{ centerLabel() }}</div>\n }\n </div>\n }\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the track the chart keeps. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n@if (dataTable() && !shown) {\n <!-- The figures for a screen reader, beside the drawing rather than inside its `img`,\n which would make them presentational. Clipped to nothing by its own stylesheet, so\n it takes no room and draws nothing. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n"
500
540
  }]
501
541
  }],
502
542
  ctorParameters: () => [],
@@ -656,6 +696,14 @@ i0.ɵɵngDeclareClassMetadata({
656
696
  required: false
657
697
  }]
658
698
  }],
699
+ dataTable: [{
700
+ type: i0.Input,
701
+ args: [{
702
+ isSignal: true,
703
+ alias: "dataTable",
704
+ required: false
705
+ }]
706
+ }],
659
707
  svg: [{
660
708
  type: i0.ViewChild,
661
709
  args: ["svg", { isSignal: true }]
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-charts-donut-chart.mjs","names":[],"sources":["../../../projects/lib/charts/donut-chart/donut-chart.ts","../../../projects/lib/charts/donut-chart/donut-chart.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 { Component, type ElementRef, ViewEncapsulation, computed, input, model, viewChild } 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 { WrChartState, useChartHover, useChartNumbers, useChartState, wrChartColor } from 'ngwr/charts/core';\nimport { useI18nText } from 'ngwr/i18n';\nimport { useChartTooltip, wrCoerceChartTooltip } from 'ngwr/popover';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrDonutSegment } from './types';\n\n/**\n * A segment's contribution to the ring. `Math.max(0, NaN)` is NaN, and the running total\n * carries it forward — so one non-finite datum used to take out its own arc AND every arc\n * after it, writing the literal text `NaN` into the path `d`.\n */\nfunction weight(value: number): number {\n return Number.isFinite(value) ? Math.max(0, value) : 0;\n}\n\n/**\n * How wide a slice's hover target is at least, along the outer edge, in CSS px. A\n * slice narrower than that — a share of a percent or two, which at the default 200px\n * is a few px of arc — is a target no pointer lands on, so it gets a wider one; see\n * `hits`.\n */\nconst HIT_PX = 12;\n\n/**\n * The widest that target may grow, in radians, whatever the chart's size: on a 48px\n * chart 12px of arc is a third of a quarter turn, which would take too much of the\n * slices beside it.\n */\nconst MAX_HIT_ANGLE = Math.PI / 12;\n\n/**\n * Donut chart, and with `pie` a pie chart. Optional center text via inputs.\n *\n * @example\n * ```html\n * <wr-donut-chart [segments]=\"[\n * { label: 'Used', value: 60 },\n * { label: 'Free', value: 40 }\n * ]\" centerLabel=\"Disk\" centerValue=\"60%\" />\n *\n * <wr-donut-chart [segments]=\"segments\" pie />\n * ```\n *\n * **The look is the chart theme's.** A slice with no `color` takes the next colour of\n * the shared palette (`--wr-chart-1` to `--wr-chart-8`), and every two slices are parted\n * by a line in `--wr-chart-separator`, 1px at any `size`. Hovering a slice or a legend\n * row dims the others.\n *\n * **The legend** is a `ul[wr-chart-legend]` (`ngwr/charts/chart-legend`), placed by\n * `legendPosition` and left out for a single slice unless `showLegend` asks for it. With\n * `toggleableLegend` its rows show and hide their slices through `hiddenSegments`.\n *\n * **Empty, loading, error.** With nothing to draw the chart keeps its ring as a track\n * and says \"No data\"; `loading` and `error` put their own message there in place of the\n * slices.\n *\n * @see https://ngwr.dev/charts/donut-chart\n */\n@Component({\n selector: 'wr-donut-chart',\n templateUrl: './donut-chart.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n // `wr-chart--legend`: the shared rule that keeps the legend's room from the drawing.\n class: 'wr-donut-chart wr-chart--legend',\n '[class.wr-donut-chart--pie]': 'pie()',\n '[class.wr-donut-chart--gapless]': 'gapless()',\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-donut-chart__legend-item`, `__swatch`, `__legend-label` and\n // `__legend-value`.\n viewProviders: [{ provide: WR_CHART_LEGEND_BLOCK, useValue: 'wr-donut-chart' }],\n})\nexport class WrDonutChart {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/donut-chart');\n // One listener pair for the whole chart: a slice and a sliver's wider target each\n // carry `data-wr-index`, and `data-wr-series` for the dim.\n useChartHover({ enter: index => this.tip.enter(index), leave: event => this.tip.leave(event) });\n }\n\n /**\n * The slices, drawn clockwise from twelve o'clock. A segment with no `color`\n * takes the next colour of the chart palette, `--wr-chart-1` to `--wr-chart-8`.\n */\n readonly segments = input<readonly WrDonutSegment[]>([]);\n\n /**\n * Accessible name of the drawing. The arcs carry no text and the legend is optional, so\n * with `showLegend: false` this and the centre text are the whole of what a screen reader\n * gets. Falls back to `donutChart.label`, or to `donutChart.pieLabel` with `pie`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n private readonly donutLabel = useI18nText(this.ariaLabel, 'donutChart.label', 'Donut chart');\n private readonly pieLabel = useI18nText(this.ariaLabel, 'donutChart.pieLabel', 'Pie chart');\n\n protected readonly resolvedAriaLabel = computed(() => (this.pie() ? this.pieLabel() : this.donutLabel()));\n\n /** Diameter in CSS pixels. @default 200 */\n readonly size = input(200, { transform: (v: unknown): number => Math.max(48, coerceNumberProperty(v, 200)) });\n\n /**\n * Inner-ring thickness as a percent of radius (0–100). `0` fills to the centre, and\n * keeps the centre text; `pie` ignores it. @default 30\n */\n readonly thickness = input(30, {\n transform: (v: unknown): number => Math.min(100, Math.max(0, coerceNumberProperty(v, 30))),\n });\n\n /**\n * Draw a pie chart: every slice fills to the centre, whatever `thickness` says, and\n * the host takes the `wr-donut-chart--pie` modifier. A pie has no hole to print in, so\n * `centerValue` and `centerLabel` are not rendered. Everything else is the donut's: the\n * slices run clockwise from twelve o'clock, with the same gap between them, the legend\n * and its toggle, and the tooltip — which in a pie also opens from a wider, invisible\n * target over a slice too thin to point at (see `tooltip`). The drawing's name falls\n * back to `donutChart.pieLabel`. @default false\n */\n readonly pie = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Draw the slices edge to edge, with no gap between them: each is stroked in its own\n * colour rather than the surface's, and the host takes the `wr-donut-chart--gapless`\n * modifier. The gap is a shape that tells two neighbours apart without hue, so with it\n * off only the colour change divides them; keep the legend or the tooltip on where the\n * chart has to read without hue. @default false\n */\n readonly gapless = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Show the legend. `'auto'` shows it when there is something to tell apart - two\n * segments or more - and leaves it out for a single one; `true` shows it for one\n * segment too. @default 'auto'\n */\n readonly showLegend = input<boolean | 'auto', unknown>('auto', {\n transform: (value: unknown): boolean | 'auto' => (value === 'auto' ? 'auto' : coerceBooleanProperty(value)),\n });\n\n /**\n * Where the legend sits: `bottom` or `top` of the chart 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 slice from outside. @default 'bottom'\n */\n readonly legendPosition = input<WrChartLegendPosition>('bottom');\n\n /**\n * A request for the chart's data is in flight: the slices give way to the loading\n * message, over the ring drawn as a track. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The chart's data failed to load: the slices give way to the error message. `loading`\n * wins while both are set. @default false\n */\n readonly error = input(false, { transform: coerceBooleanProperty });\n\n /** The message shown when there is nothing to draw. 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 /**\n * Make each legend row a toggle button that shows and hides its slice, through\n * `hiddenSegments`. A row is a `<button aria-pressed>`, pressed while its slice is\n * shown, so the legend becomes one tab stop per slice. @default false\n */\n readonly toggleableLegend = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The positions in `segments` of the slices that are hidden. Positions rather than\n * labels, since two slices 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 slice is left out of the ring, and the slices still shown RE-NORMALISE:\n * they share the whole ring between them, each at its share of their own total. A\n * donut reads as the parts of the whole it draws, so leaving the hidden slice's arc\n * as a gap would show a whole that no longer adds up, and turning a slice off is how\n * a reader asks \"of the rest, how much is each?\". The tooltip cannot open on a slice\n * that is not drawn. The legend keeps the hidden slice's row, struck through and with\n * its own value, so it can be shown again; the row says \"hidden\" to a screen reader as\n * well, through `aria-pressed` on a toggle and a visually hidden word otherwise. The\n * centre text is printed as given, so a host that writes a total there works it out\n * from this list. A position past the end of `segments` is kept and ignored.\n */\n readonly hiddenSegments = model<readonly number[]>([]);\n\n /** Bold value text in the center. Not rendered with `pie`, which has no hole to hold it. */\n readonly centerValue = input<string>('');\n\n /** Smaller label under the value. Not rendered with `pie`, which has no hole to hold it. */\n readonly centerLabel = input<string>('');\n\n /**\n * Whether the centre text renders: some is given, there is a hole to print it in, and\n * no state's message is there instead.\n */\n protected readonly showCenter = computed(\n () => !this.pie() && !this.state() && (!!this.centerValue() || !!this.centerLabel())\n );\n\n /**\n * Show a tooltip with the slice's label and value on hover. Pointer only — the legend\n * prints the same numbers, and with `showLegend` off `ariaLabel` is where to say\n * them. With `pie`, a slice too thin to land a pointer on, a sliver of a few degrees,\n * is hovered over a wider strip than it draws, through an invisible\n * `.wr-donut-chart__hit` over the pie: widened toward 12px of outer arc (15° on a\n * chart under about 92px) out of what the wider slices beside it can spare, each of\n * which keeps that much of its own. A sliver whose neighbours are slivers too, or\n * have little to spare, gets a narrower target or none, and is read in the legend.\n * The ring draws no such target.\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. `null` uses `Intl.NumberFormat`\n * in `LOCALE_ID`. The centre text is printed as given.\n */\n readonly valueFormat = input<((value: number) => string) | null>(null);\n\n /** Each value as the legend and the tooltip print it: exact, in `LOCALE_ID` unless `valueFormat` is given. */\n private readonly numbers = useChartNumbers(this.valueFormat);\n\n private readonly hidden = computed(() => new Set(this.hiddenSegments()));\n\n private readonly svg = viewChild<ElementRef<SVGSVGElement>>('svg');\n\n // Drawn in a 100×100 viewBox.\n private readonly outerR = 50;\n\n protected readonly innerR = computed(() => {\n const thickness = this.thickness();\n // A pie, or a thickness of 0: fill all the way to the center, not a zero-width ring.\n if (this.pie() || thickness === 0) return 0;\n return this.outerR * (1 - thickness / 100);\n });\n\n /** The sum the ring is divided by: the slices still shown (see `hiddenSegments`). */\n protected readonly total = computed(() => {\n const hidden = this.hidden();\n const sum = this.segments().reduce((acc, s, i) => acc + (hidden.has(i) ? 0 : weight(s.value)), 0);\n return sum > 0 ? sum : 1;\n });\n\n /**\n * Resolved slices ready for the template — each carries its arc path.\n *\n * Angles are in the drawing's own frame, where 0 is three o'clock and a positive\n * angle turns clockwise, because y runs downwards. The ring starts a quarter turn\n * back from there, at twelve o'clock, which is where the input's JSDoc always said\n * it started and where a reader looks for the first slice; it used to start at three.\n */\n protected readonly slices = computed(() => {\n const total = this.total();\n const hidden = this.hidden();\n const origin = -Math.PI / 2;\n let cumulative = 0;\n return this.segments().map((s, i) => {\n const value = weight(s.value);\n const isHidden = hidden.has(i);\n // A hidden slice takes no turn of the ring, so the next slice starts where the last\n // shown one ended.\n const share = isHidden ? 0 : value;\n const startAngle = origin + (cumulative / total) * Math.PI * 2;\n cumulative += share;\n const endAngle = origin + (cumulative / total) * Math.PI * 2;\n return {\n label: s.label,\n value,\n // The segment's own figure, which a negative one keeps although it draws nothing:\n // the weight is the arc's, not the data's, and printing it named a \"0\" the data\n // never had. A value that is not a number has no figure to print.\n text: Number.isFinite(s.value) ? this.numbers.value(s.value) : '',\n color: s.color ?? wrChartColor(i),\n hidden: isHidden,\n path: isHidden ? '' : this.arcPath(startAngle, endAngle),\n percent: (share / total) * 100,\n startAngle,\n endAngle,\n midAngle: (startAngle + endAngle) / 2,\n };\n });\n });\n\n /**\n * In a pie, a wider hover target for every slice too thin to land a pointer on: an\n * invisible wedge over the slice, drawn above the pie, widened toward `HIT_PX` of outer\n * arc (`MAX_HIT_ANGLE` at most, which binds below about 92px) out of the wider slices\n * beside it.\n *\n * A wider slice gives away only what it can spare: it keeps `HIT_PX` of outer arc of its\n * own (the same `MAX_HIT_ANGLE` cap), however many slivers reach into it, so a slice\n * that was easy to point at stays easy, and its middle, where its own chip points, is\n * never covered. Two slivers reaching into one slice from either side split what it\n * spares. A sliver asks half its shortfall of each wider neighbour, or all of it of the\n * only one; what one side cannot give, the other gives if it can. Between two slivers\n * side by side the boundary stays their shared edge, so of a run of slivers only the two\n * at its ends grow, and the legend is where the rest are read — as it is for a sliver\n * whose neighbours have little to spare, which gets the narrower target they leave it.\n * A slice that draws nothing — a zero, or a hidden slice — has nothing to point at and\n * gets no target, and nor does one with no wider neighbour.\n *\n * Pie only, and only while the tooltip is on, which is all it is for: the ring draws\n * exactly what it drew before `pie` existed. The wedge is filled with nothing and\n * hit-tested through `pointer-events=\"fill\"`, which reads its interior whatever its\n * paint and never its unpainted stroke, so its edges are the ones computed here; it\n * paints in no theme and in no forced-colors palette.\n */\n protected readonly hits = computed(() => {\n if (!this.pie() || !this.tooltip() || this.state()) return [];\n const min = Math.min(MAX_HIT_ANGLE, HIT_PX / (this.size() / 2));\n const drawn = this.slices()\n .map((slice, index) => ({ index, start: slice.startAngle, end: slice.endAngle }))\n .filter(slice => slice.end - slice.start > 0);\n const count = drawn.length;\n if (count < 2) return [];\n const width = drawn.map(slice => slice.end - slice.start);\n const thin = width.map(w => w < min);\n const prev = (k: number): number => (k - 1 + count) % count;\n const next = (k: number): number => (k + 1) % count;\n // What each wider slice can give away and still keep `min` of its own.\n const spare = width.map((w, k) => (thin[k] ? 0 : w - min));\n // How far each sliver asks to reach on each side: into a wider neighbour only.\n const ask = width.map((w, k) => {\n if (!thin[k]) return { before: 0, after: 0 };\n const before = !thin[prev(k)];\n const after = !thin[next(k)];\n const share = (min - w) / (before && after ? 2 : 1);\n return { before: before ? share : 0, after: after ? share : 0 };\n });\n const reach = width.map(() => ({ before: 0, after: 0 }));\n // A wider slice is reached into by the sliver before it, past its own end, and by the\n // one after it, past its own start — the same sliver from both sides when there are\n // only two slices. Each gets what it asks while the two fit in the spare; past that,\n // at least half of it, and more where the other asks for less.\n width.forEach((_, j) => {\n if (thin[j]) return;\n const fromBefore = thin[prev(j)] ? ask[prev(j)].after : 0;\n const fromAfter = thin[next(j)] ? ask[next(j)].before : 0;\n const claims = (fromBefore > 0 ? 1 : 0) + (fromAfter > 0 ? 1 : 0);\n if (claims === 0) return;\n const fair = spare[j] / claims;\n const toBefore = Math.min(fromBefore, Math.max(fair, spare[j] - fromAfter));\n const toAfter = Math.min(fromAfter, Math.max(fair, spare[j] - fromBefore));\n if (toBefore > 0) reach[prev(j)].after = toBefore;\n if (toAfter > 0) reach[next(j)].before = toAfter;\n spare[j] = Math.max(0, spare[j] - toBefore - toAfter);\n });\n // What one side could not give, the other side gives out of what it has left.\n width.forEach((w, k) => {\n if (!thin[k]) return;\n let short = min - w - reach[k].before - reach[k].after;\n for (const [side, j] of [\n ['before', prev(k)],\n ['after', next(k)],\n ] as const) {\n if (short <= 0 || thin[j]) continue;\n const more = Math.min(short, spare[j]);\n reach[k][side] += more;\n spare[j] -= more;\n short -= more;\n }\n });\n return drawn.flatMap((slice, k) => {\n const { before, after } = reach[k];\n if (!thin[k] || before + after <= 0) return [];\n return [{ index: slice.index, path: this.arcPath(slice.start - before, slice.end + after) }];\n });\n });\n\n /**\n * The legend's rows: every slice, hidden ones included, each with its own figure — a\n * negative one included, which draws no slice — and no value at all for a segment whose\n * value is not a number.\n */\n protected readonly legendItems = computed<readonly WrChartLegendItem[]>(() =>\n this.slices().map(({ label, color, text }) => ({ label, color, value: text === '' ? null : text }))\n );\n\n /**\n * Whether the chart draws its legend: unless `legendPosition` is `none` or `showLegend`\n * is off, and under `showLegend=\"auto\"` only with two segments or more, since a single\n * slice has nothing to tell apart.\n */\n protected readonly legendShown = computed(() => {\n const show = this.showLegend();\n const rows = this.legendItems().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 drawing, 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 drawing 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 /**\n * Whether the chart has nothing to draw: no segment, or none with a share to take. A\n * slice hidden from the legend still counts, so hiding every slice is not \"No data\".\n */\n private readonly empty = computed(() => this.segments().every(s => weight(s.value) === 0));\n\n /** What the chart shows in place of its slices, or `null` while it draws them. */\n protected readonly state = useChartState({\n loading: this.loading,\n error: this.error,\n empty: this.empty,\n emptyLabel: this.emptyLabel,\n loadingLabel: this.loadingLabel,\n errorLabel: this.errorLabel,\n });\n\n /**\n * The whole ring, or the whole disc of a pie, as one path: the frame the chart keeps\n * while it has no slice to draw - under a state, or with every slice hidden.\n */\n protected readonly track = computed(() =>\n this.state() || this.slices().every(slice => !slice.path) ? this.arcPath(0, Math.PI * 2) : null\n );\n\n /**\n * One tooltip for the whole chart, pointing at the hovered slice: at the middle of\n * its OUTER arc, on the side that part of the ring faces — above for a slice whose\n * middle is in the top quarter, below for the bottom one, beside it for the two at\n * three and nine o'clock. From there the chip sits clear of the ring, and the way\n * onto it runs straight out of the slice that opened it, over nothing else.\n *\n * Not the slice's `<path>` element: its box is most of the ring for any slice past\n * a quarter, so the chip would point at the middle of the chart. And not the middle\n * of the band: a chip there lies over the ring, under a pointer resting on it —\n * measured in Chromium, the inner half of a lower slice landed on its own chip. A\n * tiny slice keeps its own mid-angle, so the arrow says which sliver it is.\n */\n protected readonly tip = useChartTooltip(this.tooltip, index => {\n const slice = this.slices()[index];\n const svg = this.svg()?.nativeElement;\n // No slice is drawn under a state, so a chip open on one lets go.\n if (!slice?.path || !svg || this.state()) return null;\n const box = svg.getBoundingClientRect();\n // The drawing's y runs downwards, so a positive sine is the lower half.\n const cos = Math.cos(slice.midAngle);\n const sin = Math.sin(slice.midAngle);\n const side = Math.abs(cos) > Math.abs(sin) ? (cos > 0 ? 'right' : 'left') : sin > 0 ? 'bottom' : 'top';\n return {\n datum: { label: slice.label, value: slice.text, color: slice.color },\n anchor: {\n x: box.left + ((50 + this.outerR * cos) / 100) * box.width,\n y: box.top + ((50 + this.outerR * sin) / 100) * box.height,\n },\n side,\n };\n });\n\n // Helpers\n\n /** SVG path for one donut slice using outer and inner arcs. */\n private arcPath(start: number, end: number): string {\n const cx = 50;\n const cy = 50;\n const ro = this.outerR;\n const ri = this.innerR();\n const sweep = end - start;\n if (sweep <= 0) return '';\n // Full-circle slice — two halves so the arc can render.\n if (sweep >= Math.PI * 2 - 1e-6) {\n const path = [\n `M ${cx + ro} ${cy}`,\n `A ${ro} ${ro} 0 1 1 ${cx - ro} ${cy}`,\n `A ${ro} ${ro} 0 1 1 ${cx + ro} ${cy}`,\n ];\n if (ri > 0) {\n path.push(`M ${cx + ri} ${cy}`, `A ${ri} ${ri} 0 1 0 ${cx - ri} ${cy}`, `A ${ri} ${ri} 0 1 0 ${cx + ri} ${cy}`);\n }\n return path.join(' ');\n }\n const largeArc = sweep > Math.PI ? 1 : 0;\n const sox = cx + ro * Math.cos(start);\n const soy = cy + ro * Math.sin(start);\n const eox = cx + ro * Math.cos(end);\n const eoy = cy + ro * Math.sin(end);\n if (ri === 0) {\n return `M ${cx} ${cy} L ${sox.toFixed(2)} ${soy.toFixed(2)} A ${ro} ${ro} 0 ${largeArc} 1 ${eox.toFixed(2)} ${eoy.toFixed(2)} Z`;\n }\n const eix = cx + ri * Math.cos(end);\n const eiy = cy + ri * Math.sin(end);\n const six = cx + ri * Math.cos(start);\n const siy = cy + ri * Math.sin(start);\n return [\n `M ${sox.toFixed(2)} ${soy.toFixed(2)}`,\n `A ${ro} ${ro} 0 ${largeArc} 1 ${eox.toFixed(2)} ${eoy.toFixed(2)}`,\n `L ${eix.toFixed(2)} ${eiy.toFixed(2)}`,\n `A ${ri} ${ri} 0 ${largeArc} 0 ${six.toFixed(2)} ${siy.toFixed(2)}`,\n 'Z',\n ].join(' ');\n }\n}\n\nexport type { WrDonutSegment } from './types';\n","@let shown = state();\n\n<!-- The legend, drawn before the drawing 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. The key\n is `aria-hidden`: the row's text is its name, and the dot carries no word of its own. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-donut-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div class=\"wr-donut-chart__surface\" [style.width.px]=\"size()\">\n <!-- The name sits on the DRAWING, not on this wrapper. `img` is a\n children-presentational role, so with it out here WebKit dropped the whole\n subtree — including the centre value and label, which are real text and are\n the headline datum the legend does not carry. -->\n <svg #svg viewBox=\"0 0 100 100\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\">\n @if (track(); as ring) {\n <!-- The frame the chart keeps with no slice to draw: the ring itself, as a track. -->\n <path class=\"wr-donut-chart__track\" [attr.d]=\"ring\" />\n }\n <!-- Every slice is stroked in the SURFACE colour (`--wr-donut-chart-slice-gap-color`,\n from the stylesheet), so adjacent arcs are separated by a visible gap rather than\n by the boundary between two fills. Without it the only thing dividing two slices\n is the colour change itself, and for a reader who cannot separate hue two\n neighbours merge into one arc and the chart reads as having fewer slices than it\n has. A gap is a shape, and it survives greyscale, printing and a monochrome\n display. The stroke does not scale with the drawing, so the gap is the same\n pixels at any `size`; its width is the stylesheet's. -->\n @if (!shown) {\n @for (slice of slices(); track $index) {\n <!-- A hidden slice draws nothing at all; the index stays the slice's own, which is\n what the tooltip looks it up by. `data-wr-index` is what the chart's one hover\n listener reads, and `data-wr-series` the slice's legend row, which the hover\n dims by. -->\n @if (!slice.hidden) {\n <path\n class=\"wr-donut-chart__slice\"\n [attr.d]=\"slice.path\"\n [attr.fill]=\"slice.color\"\n [style.--wr-donut-chart-slice-color]=\"slice.color\"\n [attr.data-wr-index]=\"$index\"\n [attr.data-wr-series]=\"$index\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n <!-- A sliver's wider hover target in a pie, filled with nothing: see `hits`, which is\n empty for the ring and with the tooltip off. Last, so it wins the pointer over the\n slices it reaches into; `fill`, so the unpainted stroke is not hit-tested and the\n edges stay where `hits` put them. It carries its slice's index and legend row, so\n the hover reads it as the slice. -->\n @for (hit of hits(); track hit.index) {\n <path\n class=\"wr-donut-chart__hit\"\n [attr.d]=\"hit.path\"\n [attr.data-wr-index]=\"hit.index\"\n [attr.data-wr-series]=\"hit.index\"\n fill=\"none\"\n pointer-events=\"fill\"\n />\n }\n }\n </svg>\n <!-- Never with `pie`: a pie has no hole to print in. -->\n @if (showCenter()) {\n <div class=\"wr-donut-chart__center\">\n @if (centerValue()) {\n <div class=\"wr-donut-chart__center-value\">{{ centerValue() }}</div>\n }\n @if (centerLabel()) {\n <div class=\"wr-donut-chart__center-label\">{{ centerLabel() }}</div>\n }\n </div>\n }\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the track the chart keeps. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n"],"mappings":";;;;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,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,sBAAA;EAAA,CAAA;EAAA,aAAA,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,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,KAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAK,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-charts-donut-chart.mjs","names":[],"sources":["../../../projects/lib/charts/donut-chart/donut-chart.ts","../../../projects/lib/charts/donut-chart/donut-chart.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 LOCALE_ID,\n ViewEncapsulation,\n computed,\n inject,\n input,\n model,\n viewChild,\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 WrChartTable,\n type WrChartTableData,\n useChartHover,\n useChartNumbers,\n useChartState,\n wrChartColor,\n wrChartNumberFormat,\n} from 'ngwr/charts/core';\nimport { useI18nText, wrReadI18nText } from 'ngwr/i18n';\nimport { useChartTooltip, wrCoerceChartTooltip } from 'ngwr/popover';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrDonutSegment } from './types';\n\n/**\n * A segment's contribution to the ring. `Math.max(0, NaN)` is NaN, and the running total\n * carries it forward — so one non-finite datum used to take out its own arc AND every arc\n * after it, writing the literal text `NaN` into the path `d`.\n */\nfunction weight(value: number): number {\n return Number.isFinite(value) ? Math.max(0, value) : 0;\n}\n\n/**\n * How wide a slice's hover target is at least, along the outer edge, in CSS px. A\n * slice narrower than that — a share of a percent or two, which at the default 200px\n * is a few px of arc — is a target no pointer lands on, so it gets a wider one; see\n * `hits`.\n */\nconst HIT_PX = 12;\n\n/**\n * The widest that target may grow, in radians, whatever the chart's size: on a 48px\n * chart 12px of arc is a third of a quarter turn, which would take too much of the\n * slices beside it.\n */\nconst MAX_HIT_ANGLE = Math.PI / 12;\n\n/**\n * Donut chart, and with `pie` a pie chart. Optional center text via inputs.\n *\n * @example\n * ```html\n * <wr-donut-chart [segments]=\"[\n * { label: 'Used', value: 60 },\n * { label: 'Free', value: 40 }\n * ]\" centerLabel=\"Disk\" centerValue=\"60%\" />\n *\n * <wr-donut-chart [segments]=\"segments\" pie />\n * ```\n *\n * **The look is the chart theme's.** A slice with no `color` takes the next colour of\n * the shared palette (`--wr-chart-1` to `--wr-chart-8`), and every two slices are parted\n * by a line in `--wr-chart-separator`, 1px at any `size`. Hovering a slice or a legend\n * row dims the others.\n *\n * **The legend** is a `ul[wr-chart-legend]` (`ngwr/charts/chart-legend`), placed by\n * `legendPosition` and left out for a single slice unless `showLegend` asks for it. With\n * `toggleableLegend` its rows show and hide their slices through `hiddenSegments`.\n *\n * **Empty, loading, error.** With nothing to draw the chart keeps its ring as a track\n * and says \"No data\"; `loading` and `error` put their own message there in place of the\n * slices.\n *\n * **What a screen reader gets.** The drawing is one named `role=\"img\"`, so the figures are\n * in text only in the legend, which a single slice and `showLegend=\"false\"` leave out.\n * `dataTable` renders every slice shown with its value and its share as a table a reader\n * can walk cell by cell.\n *\n * @see https://ngwr.dev/charts/donut-chart\n */\n@Component({\n selector: 'wr-donut-chart',\n templateUrl: './donut-chart.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n // `wr-chart--legend`: the shared rule that keeps the legend's room from the drawing.\n class: 'wr-donut-chart wr-chart--legend',\n '[class.wr-donut-chart--pie]': 'pie()',\n '[class.wr-donut-chart--gapless]': 'gapless()',\n '[class.wr-chart--legend-side]': 'legendShown() && legendSide()',\n },\n imports: [NgTemplateOutlet, WrChartLegend, WrChartState, WrChartTable],\n // The legend's rows keep the classes this chart drew before it drew them through\n // `WrChartLegend`: `.wr-donut-chart__legend-item`, `__swatch`, `__legend-label` and\n // `__legend-value`.\n viewProviders: [{ provide: WR_CHART_LEGEND_BLOCK, useValue: 'wr-donut-chart' }],\n})\nexport class WrDonutChart {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/donut-chart');\n // One listener pair for the whole chart: a slice and a sliver's wider target each\n // carry `data-wr-index`, and `data-wr-series` for the dim.\n useChartHover({ enter: index => this.tip.enter(index), leave: event => this.tip.leave(event) });\n }\n\n /**\n * The slices, drawn clockwise from twelve o'clock. A segment with no `color`\n * takes the next colour of the chart palette, `--wr-chart-1` to `--wr-chart-8`.\n */\n readonly segments = input<readonly WrDonutSegment[]>([]);\n\n /**\n * Accessible name of the drawing, and the caption of the data table. The arcs carry no\n * text and the legend is optional, so with `showLegend: false` this and the centre text\n * are the whole of what a screen reader gets unless `dataTable` renders the figures.\n * Falls back to `donutChart.label`, or to `donutChart.pieLabel` with `pie`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n private readonly donutLabel = useI18nText(this.ariaLabel, 'donutChart.label', 'Donut chart');\n private readonly pieLabel = useI18nText(this.ariaLabel, 'donutChart.pieLabel', 'Pie chart');\n\n protected readonly resolvedAriaLabel = computed(() => (this.pie() ? this.pieLabel() : this.donutLabel()));\n\n /** Diameter in CSS pixels. @default 200 */\n readonly size = input(200, { transform: (v: unknown): number => Math.max(48, coerceNumberProperty(v, 200)) });\n\n /**\n * Inner-ring thickness as a percent of radius (0–100). `0` fills to the centre, and\n * keeps the centre text; `pie` ignores it. @default 30\n */\n readonly thickness = input(30, {\n transform: (v: unknown): number => Math.min(100, Math.max(0, coerceNumberProperty(v, 30))),\n });\n\n /**\n * Draw a pie chart: every slice fills to the centre, whatever `thickness` says, and\n * the host takes the `wr-donut-chart--pie` modifier. A pie has no hole to print in, so\n * `centerValue` and `centerLabel` are not rendered. Everything else is the donut's: the\n * slices run clockwise from twelve o'clock, with the same gap between them, the legend\n * and its toggle, and the tooltip — which in a pie also opens from a wider, invisible\n * target over a slice too thin to point at (see `tooltip`). The drawing's name falls\n * back to `donutChart.pieLabel`. @default false\n */\n readonly pie = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Draw the slices edge to edge, with no gap between them: each is stroked in its own\n * colour rather than the surface's, and the host takes the `wr-donut-chart--gapless`\n * modifier. The gap is a shape that tells two neighbours apart without hue, so with it\n * off only the colour change divides them; keep the legend or the tooltip on where the\n * chart has to read without hue. @default false\n */\n readonly gapless = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Show the legend. `'auto'` shows it when there is something to tell apart - two\n * segments or more - and leaves it out for a single one; `true` shows it for one\n * segment too. @default 'auto'\n */\n readonly showLegend = input<boolean | 'auto', unknown>('auto', {\n transform: (value: unknown): boolean | 'auto' => (value === 'auto' ? 'auto' : coerceBooleanProperty(value)),\n });\n\n /**\n * Where the legend sits: `bottom` or `top` of the chart 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 slice from outside. @default 'bottom'\n */\n readonly legendPosition = input<WrChartLegendPosition>('bottom');\n\n /**\n * A request for the chart's data is in flight: the slices give way to the loading\n * message, over the ring drawn as a track. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The chart's data failed to load: the slices give way to the error message. `loading`\n * wins while both are set. @default false\n */\n readonly error = input(false, { transform: coerceBooleanProperty });\n\n /** The message shown when there is nothing to draw. 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 /**\n * Make each legend row a toggle button that shows and hides its slice, through\n * `hiddenSegments`. A row is a `<button aria-pressed>`, pressed while its slice is\n * shown, so the legend becomes one tab stop per slice. @default false\n */\n readonly toggleableLegend = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The positions in `segments` of the slices that are hidden. Positions rather than\n * labels, since two slices 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 slice is left out of the ring, and the slices still shown RE-NORMALISE:\n * they share the whole ring between them, each at its share of their own total. A\n * donut reads as the parts of the whole it draws, so leaving the hidden slice's arc\n * as a gap would show a whole that no longer adds up, and turning a slice off is how\n * a reader asks \"of the rest, how much is each?\". The tooltip cannot open on a slice\n * that is not drawn. The legend keeps the hidden slice's row, struck through and with\n * its own value, so it can be shown again; the row says \"hidden\" to a screen reader as\n * well, through `aria-pressed` on a toggle and a visually hidden word otherwise. The\n * centre text is printed as given, so a host that writes a total there works it out\n * from this list. A position past the end of `segments` is kept and ignored.\n */\n readonly hiddenSegments = model<readonly number[]>([]);\n\n /** Bold value text in the center. Not rendered with `pie`, which has no hole to hold it. */\n readonly centerValue = input<string>('');\n\n /** Smaller label under the value. Not rendered with `pie`, which has no hole to hold it. */\n readonly centerLabel = input<string>('');\n\n /**\n * Whether the centre text renders: some is given, there is a hole to print it in, and\n * no state's message is there instead.\n */\n protected readonly showCenter = computed(\n () => !this.pie() && !this.state() && (!!this.centerValue() || !!this.centerLabel())\n );\n\n /**\n * Show a tooltip with the slice's label and value on hover. Pointer only — the legend\n * prints the same numbers, and with `showLegend` off `ariaLabel` is where to say\n * them. With `pie`, a slice too thin to land a pointer on, a sliver of a few degrees,\n * is hovered over a wider strip than it draws, through an invisible\n * `.wr-donut-chart__hit` over the pie: widened toward 12px of outer arc (15° on a\n * chart under about 92px) out of what the wider slices beside it can spare, each of\n * which keeps that much of its own. A sliver whose neighbours are slivers too, or\n * have little to spare, gets a narrower target or none, and is read in the legend.\n * The ring draws no such target.\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, the tooltip and the data table. `null` uses\n * `Intl.NumberFormat` in `LOCALE_ID`. The centre text is printed as given.\n */\n readonly valueFormat = input<((value: number) => string) | null>(null);\n\n /**\n * Render the chart's figures as a table that only assistive technology reaches: a row\n * per slice shown, headed by its label, with its value as the legend writes it and its\n * share of the ring, a percentage in `LOCALE_ID`. A slice hidden through\n * `hiddenSegments` has no row, and a slice that draws nothing has an empty share. The\n * table gives way with the slices while the chart is empty, `loading` or in `error`.\n *\n * The drawing is one named `role=\"img\"`, which hides everything inside it, and the\n * legend is left out for a single slice and with `showLegend` off, so without the table\n * the numbers may be nowhere a screen reader can walk. It is rendered beside the\n * drawing, clipped to nothing: it takes no room, draws nothing and holds no tab stop.\n * @default false\n */\n readonly dataTable = input(false, { transform: coerceBooleanProperty });\n\n /** The headings of the data table's two columns. */\n private readonly valueName = wrReadI18nText('donutChart.value', 'Value');\n private readonly shareName = wrReadI18nText('donutChart.share', 'Share');\n\n /** Each value as the legend, the tooltip and the data table print it: exact, in `LOCALE_ID` unless `valueFormat` is given. */\n private readonly numbers = useChartNumbers(this.valueFormat);\n\n private readonly locale = inject(LOCALE_ID);\n /** Shares from one percent up, to one decimal. */\n private readonly shares = wrChartNumberFormat(this.locale, { style: 'percent', maximumFractionDigits: 1 });\n /** Shares below one percent, to two significant digits, so a sliver does not read `0%`. */\n private readonly smallShares = wrChartNumberFormat(this.locale, { style: 'percent', maximumSignificantDigits: 2 });\n\n private readonly hidden = computed(() => new Set(this.hiddenSegments()));\n\n private readonly svg = viewChild<ElementRef<SVGSVGElement>>('svg');\n\n // Drawn in a 100×100 viewBox.\n private readonly outerR = 50;\n\n protected readonly innerR = computed(() => {\n const thickness = this.thickness();\n // A pie, or a thickness of 0: fill all the way to the center, not a zero-width ring.\n if (this.pie() || thickness === 0) return 0;\n return this.outerR * (1 - thickness / 100);\n });\n\n /** The sum the ring is divided by: the slices still shown (see `hiddenSegments`). */\n protected readonly total = computed(() => {\n const hidden = this.hidden();\n const sum = this.segments().reduce((acc, s, i) => acc + (hidden.has(i) ? 0 : weight(s.value)), 0);\n return sum > 0 ? sum : 1;\n });\n\n /**\n * Resolved slices ready for the template — each carries its arc path.\n *\n * Angles are in the drawing's own frame, where 0 is three o'clock and a positive\n * angle turns clockwise, because y runs downwards. The ring starts a quarter turn\n * back from there, at twelve o'clock, which is where the input's JSDoc always said\n * it started and where a reader looks for the first slice; it used to start at three.\n */\n protected readonly slices = computed(() => {\n const total = this.total();\n const hidden = this.hidden();\n const origin = -Math.PI / 2;\n let cumulative = 0;\n return this.segments().map((s, i) => {\n const value = weight(s.value);\n const isHidden = hidden.has(i);\n // A hidden slice takes no turn of the ring, so the next slice starts where the last\n // shown one ended.\n const share = isHidden ? 0 : value;\n const startAngle = origin + (cumulative / total) * Math.PI * 2;\n cumulative += share;\n const endAngle = origin + (cumulative / total) * Math.PI * 2;\n return {\n label: s.label,\n value,\n // The segment's own figure, which a negative one keeps although it draws nothing:\n // the weight is the arc's, not the data's, and printing it named a \"0\" the data\n // never had. A value that is not a number has no figure to print.\n text: Number.isFinite(s.value) ? this.numbers.value(s.value) : '',\n color: s.color ?? wrChartColor(i),\n hidden: isHidden,\n path: isHidden ? '' : this.arcPath(startAngle, endAngle),\n percent: (share / total) * 100,\n startAngle,\n endAngle,\n midAngle: (startAngle + endAngle) / 2,\n };\n });\n });\n\n /**\n * In a pie, a wider hover target for every slice too thin to land a pointer on: an\n * invisible wedge over the slice, drawn above the pie, widened toward `HIT_PX` of outer\n * arc (`MAX_HIT_ANGLE` at most, which binds below about 92px) out of the wider slices\n * beside it.\n *\n * A wider slice gives away only what it can spare: it keeps `HIT_PX` of outer arc of its\n * own (the same `MAX_HIT_ANGLE` cap), however many slivers reach into it, so a slice\n * that was easy to point at stays easy, and its middle, where its own chip points, is\n * never covered. Two slivers reaching into one slice from either side split what it\n * spares. A sliver asks half its shortfall of each wider neighbour, or all of it of the\n * only one; what one side cannot give, the other gives if it can. Between two slivers\n * side by side the boundary stays their shared edge, so of a run of slivers only the two\n * at its ends grow, and the legend is where the rest are read — as it is for a sliver\n * whose neighbours have little to spare, which gets the narrower target they leave it.\n * A slice that draws nothing — a zero, or a hidden slice — has nothing to point at and\n * gets no target, and nor does one with no wider neighbour.\n *\n * Pie only, and only while the tooltip is on, which is all it is for: the ring draws\n * exactly what it drew before `pie` existed. The wedge is filled with nothing and\n * hit-tested through `pointer-events=\"fill\"`, which reads its interior whatever its\n * paint and never its unpainted stroke, so its edges are the ones computed here; it\n * paints in no theme and in no forced-colors palette.\n */\n protected readonly hits = computed(() => {\n if (!this.pie() || !this.tooltip() || this.state()) return [];\n const min = Math.min(MAX_HIT_ANGLE, HIT_PX / (this.size() / 2));\n const drawn = this.slices()\n .map((slice, index) => ({ index, start: slice.startAngle, end: slice.endAngle }))\n .filter(slice => slice.end - slice.start > 0);\n const count = drawn.length;\n if (count < 2) return [];\n const width = drawn.map(slice => slice.end - slice.start);\n const thin = width.map(w => w < min);\n const prev = (k: number): number => (k - 1 + count) % count;\n const next = (k: number): number => (k + 1) % count;\n // What each wider slice can give away and still keep `min` of its own.\n const spare = width.map((w, k) => (thin[k] ? 0 : w - min));\n // How far each sliver asks to reach on each side: into a wider neighbour only.\n const ask = width.map((w, k) => {\n if (!thin[k]) return { before: 0, after: 0 };\n const before = !thin[prev(k)];\n const after = !thin[next(k)];\n const share = (min - w) / (before && after ? 2 : 1);\n return { before: before ? share : 0, after: after ? share : 0 };\n });\n const reach = width.map(() => ({ before: 0, after: 0 }));\n // A wider slice is reached into by the sliver before it, past its own end, and by the\n // one after it, past its own start — the same sliver from both sides when there are\n // only two slices. Each gets what it asks while the two fit in the spare; past that,\n // at least half of it, and more where the other asks for less.\n width.forEach((_, j) => {\n if (thin[j]) return;\n const fromBefore = thin[prev(j)] ? ask[prev(j)].after : 0;\n const fromAfter = thin[next(j)] ? ask[next(j)].before : 0;\n const claims = (fromBefore > 0 ? 1 : 0) + (fromAfter > 0 ? 1 : 0);\n if (claims === 0) return;\n const fair = spare[j] / claims;\n const toBefore = Math.min(fromBefore, Math.max(fair, spare[j] - fromAfter));\n const toAfter = Math.min(fromAfter, Math.max(fair, spare[j] - fromBefore));\n if (toBefore > 0) reach[prev(j)].after = toBefore;\n if (toAfter > 0) reach[next(j)].before = toAfter;\n spare[j] = Math.max(0, spare[j] - toBefore - toAfter);\n });\n // What one side could not give, the other side gives out of what it has left.\n width.forEach((w, k) => {\n if (!thin[k]) return;\n let short = min - w - reach[k].before - reach[k].after;\n for (const [side, j] of [\n ['before', prev(k)],\n ['after', next(k)],\n ] as const) {\n if (short <= 0 || thin[j]) continue;\n const more = Math.min(short, spare[j]);\n reach[k][side] += more;\n spare[j] -= more;\n short -= more;\n }\n });\n return drawn.flatMap((slice, k) => {\n const { before, after } = reach[k];\n if (!thin[k] || before + after <= 0) return [];\n return [{ index: slice.index, path: this.arcPath(slice.start - before, slice.end + after) }];\n });\n });\n\n /**\n * The legend's rows: every slice, hidden ones included, each with its own figure — a\n * negative one included, which draws no slice — and no value at all for a segment whose\n * value is not a number.\n */\n protected readonly legendItems = computed<readonly WrChartLegendItem[]>(() =>\n this.slices().map(({ label, color, text }) => ({ label, color, value: text === '' ? null : text }))\n );\n\n /**\n * Whether the chart draws its legend: unless `legendPosition` is `none` or `showLegend`\n * is off, and under `showLegend=\"auto\"` only with two segments or more, since a single\n * slice has nothing to tell apart.\n */\n protected readonly legendShown = computed(() => {\n const show = this.showLegend();\n const rows = this.legendItems().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 drawing, 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 drawing 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 /**\n * Whether the chart has nothing to draw: no segment, or none with a share to take. A\n * slice hidden from the legend still counts, so hiding every slice is not \"No data\".\n */\n private readonly empty = computed(() => this.segments().every(s => weight(s.value) === 0));\n\n /** What the chart shows in place of its slices, or `null` while it draws them. */\n protected readonly state = useChartState({\n loading: this.loading,\n error: this.error,\n empty: this.empty,\n emptyLabel: this.emptyLabel,\n loadingLabel: this.loadingLabel,\n errorLabel: this.errorLabel,\n });\n\n /**\n * The figures for `dataTable`: the chart's name as the caption, a row per slice shown,\n * and its value and its share of the ring as the columns.\n */\n protected readonly tableData = computed<WrChartTableData>(() => ({\n caption: this.resolvedAriaLabel(),\n columns: [this.valueName(), this.shareName()],\n groups: [\n {\n rows: this.slices()\n .filter(slice => !slice.hidden)\n .map(slice => {\n const share = slice.percent / 100;\n return {\n header: slice.label,\n cells: [slice.text, share > 0 ? (share < 0.01 ? this.smallShares : this.shares).format(share) : ''],\n };\n }),\n },\n ],\n }));\n\n /**\n * The whole ring, or the whole disc of a pie, as one path: the frame the chart keeps\n * while it has no slice to draw - under a state, or with every slice hidden.\n */\n protected readonly track = computed(() =>\n this.state() || this.slices().every(slice => !slice.path) ? this.arcPath(0, Math.PI * 2) : null\n );\n\n /**\n * One tooltip for the whole chart, pointing at the hovered slice: at the middle of\n * its OUTER arc, on the side that part of the ring faces — above for a slice whose\n * middle is in the top quarter, below for the bottom one, beside it for the two at\n * three and nine o'clock. From there the chip sits clear of the ring, and the way\n * onto it runs straight out of the slice that opened it, over nothing else.\n *\n * Not the slice's `<path>` element: its box is most of the ring for any slice past\n * a quarter, so the chip would point at the middle of the chart. And not the middle\n * of the band: a chip there lies over the ring, under a pointer resting on it —\n * measured in Chromium, the inner half of a lower slice landed on its own chip. A\n * tiny slice keeps its own mid-angle, so the arrow says which sliver it is.\n */\n protected readonly tip = useChartTooltip(this.tooltip, index => {\n const slice = this.slices()[index];\n const svg = this.svg()?.nativeElement;\n // No slice is drawn under a state, so a chip open on one lets go.\n if (!slice?.path || !svg || this.state()) return null;\n const box = svg.getBoundingClientRect();\n // The drawing's y runs downwards, so a positive sine is the lower half.\n const cos = Math.cos(slice.midAngle);\n const sin = Math.sin(slice.midAngle);\n const side = Math.abs(cos) > Math.abs(sin) ? (cos > 0 ? 'right' : 'left') : sin > 0 ? 'bottom' : 'top';\n return {\n datum: { label: slice.label, value: slice.text, color: slice.color },\n anchor: {\n x: box.left + ((50 + this.outerR * cos) / 100) * box.width,\n y: box.top + ((50 + this.outerR * sin) / 100) * box.height,\n },\n side,\n };\n });\n\n // Helpers\n\n /** SVG path for one donut slice using outer and inner arcs. */\n private arcPath(start: number, end: number): string {\n const cx = 50;\n const cy = 50;\n const ro = this.outerR;\n const ri = this.innerR();\n const sweep = end - start;\n if (sweep <= 0) return '';\n // Full-circle slice — two halves so the arc can render.\n if (sweep >= Math.PI * 2 - 1e-6) {\n const path = [\n `M ${cx + ro} ${cy}`,\n `A ${ro} ${ro} 0 1 1 ${cx - ro} ${cy}`,\n `A ${ro} ${ro} 0 1 1 ${cx + ro} ${cy}`,\n ];\n if (ri > 0) {\n path.push(`M ${cx + ri} ${cy}`, `A ${ri} ${ri} 0 1 0 ${cx - ri} ${cy}`, `A ${ri} ${ri} 0 1 0 ${cx + ri} ${cy}`);\n }\n return path.join(' ');\n }\n const largeArc = sweep > Math.PI ? 1 : 0;\n const sox = cx + ro * Math.cos(start);\n const soy = cy + ro * Math.sin(start);\n const eox = cx + ro * Math.cos(end);\n const eoy = cy + ro * Math.sin(end);\n if (ri === 0) {\n return `M ${cx} ${cy} L ${sox.toFixed(2)} ${soy.toFixed(2)} A ${ro} ${ro} 0 ${largeArc} 1 ${eox.toFixed(2)} ${eoy.toFixed(2)} Z`;\n }\n const eix = cx + ri * Math.cos(end);\n const eiy = cy + ri * Math.sin(end);\n const six = cx + ri * Math.cos(start);\n const siy = cy + ri * Math.sin(start);\n return [\n `M ${sox.toFixed(2)} ${soy.toFixed(2)}`,\n `A ${ro} ${ro} 0 ${largeArc} 1 ${eox.toFixed(2)} ${eoy.toFixed(2)}`,\n `L ${eix.toFixed(2)} ${eiy.toFixed(2)}`,\n `A ${ri} ${ri} 0 ${largeArc} 0 ${six.toFixed(2)} ${siy.toFixed(2)}`,\n 'Z',\n ].join(' ');\n }\n}\n\nexport type { WrDonutSegment } from './types';\n","@let shown = state();\n\n<!-- The legend, drawn before the drawing 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. The key\n is `aria-hidden`: the row's text is its name, and the dot carries no word of its own. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-donut-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSegments\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<div class=\"wr-donut-chart__surface\" [style.width.px]=\"size()\">\n <!-- The name sits on the DRAWING, not on this wrapper. `img` is a\n children-presentational role, so with it out here WebKit dropped the whole\n subtree — including the centre value and label, which are real text and are\n the headline datum the legend does not carry. -->\n <svg #svg viewBox=\"0 0 100 100\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\">\n @if (track(); as ring) {\n <!-- The frame the chart keeps with no slice to draw: the ring itself, as a track. -->\n <path class=\"wr-donut-chart__track\" [attr.d]=\"ring\" />\n }\n <!-- Every slice is stroked in the SURFACE colour (`--wr-donut-chart-slice-gap-color`,\n from the stylesheet), so adjacent arcs are separated by a visible gap rather than\n by the boundary between two fills. Without it the only thing dividing two slices\n is the colour change itself, and for a reader who cannot separate hue two\n neighbours merge into one arc and the chart reads as having fewer slices than it\n has. A gap is a shape, and it survives greyscale, printing and a monochrome\n display. The stroke does not scale with the drawing, so the gap is the same\n pixels at any `size`; its width is the stylesheet's. -->\n @if (!shown) {\n @for (slice of slices(); track $index) {\n <!-- A hidden slice draws nothing at all; the index stays the slice's own, which is\n what the tooltip looks it up by. `data-wr-index` is what the chart's one hover\n listener reads, and `data-wr-series` the slice's legend row, which the hover\n dims by. -->\n @if (!slice.hidden) {\n <path\n class=\"wr-donut-chart__slice\"\n [attr.d]=\"slice.path\"\n [attr.fill]=\"slice.color\"\n [style.--wr-donut-chart-slice-color]=\"slice.color\"\n [attr.data-wr-index]=\"$index\"\n [attr.data-wr-series]=\"$index\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n <!-- A sliver's wider hover target in a pie, filled with nothing: see `hits`, which is\n empty for the ring and with the tooltip off. Last, so it wins the pointer over the\n slices it reaches into; `fill`, so the unpainted stroke is not hit-tested and the\n edges stay where `hits` put them. It carries its slice's index and legend row, so\n the hover reads it as the slice. -->\n @for (hit of hits(); track hit.index) {\n <path\n class=\"wr-donut-chart__hit\"\n [attr.d]=\"hit.path\"\n [attr.data-wr-index]=\"hit.index\"\n [attr.data-wr-series]=\"hit.index\"\n fill=\"none\"\n pointer-events=\"fill\"\n />\n }\n }\n </svg>\n <!-- Never with `pie`: a pie has no hole to print in. -->\n @if (showCenter()) {\n <div class=\"wr-donut-chart__center\">\n @if (centerValue()) {\n <div class=\"wr-donut-chart__center-value\">{{ centerValue() }}</div>\n }\n @if (centerLabel()) {\n <div class=\"wr-donut-chart__center-label\">{{ centerLabel() }}</div>\n }\n </div>\n }\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the track the chart keeps. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n@if (dataTable() && !shown) {\n <!-- The figures for a screen reader, beside the drawing rather than inside its `img`,\n which would make them presentational. Clipped to nothing by its own stylesheet, so\n it takes no room and draws nothing. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgDA,SAAS,OAAO,OAAa;CAC3B,OAAO,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AACvD;AAQA,MAAM,SAAS;AAOf,MAAM,gBAAgB,KAAK,KAAK;AAoDhC,IAAa,eAAb,MAAa,aAAY;CACvB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,oBAAoB;EAGrF,cAAc;GAAE,QAAO,UAAS,KAAK,IAAI,MAAM,KAAK;GAAG,QAAO,UAAS,KAAK,IAAI,MAAM,KAAK;EAAC,CAAE;CAChG;CAMS,WAAW,MAAiC,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAQ/C,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE9B,aAAa,YAAY,KAAK,WAAW,oBAAoB,aAAa;CAC1E,WAAW,YAAY,KAAK,WAAW,uBAAuB,WAAW;CAEvE,oBAAoB,eAAgB,KAAK,IAAG,IAAK,KAAK,SAAQ,IAAK,KAAK,WAAU,GAAI,GAAA,YAAA,CAAA,EAAA,WAAA,oBAAA,CAAA,+BAAA,CAAA,CAAA;CAGhG,OAAO,MAAM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AA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,kBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,gBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,sBAAA;EAAA,CAAA;EAAA,aAAA,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,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,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,KAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAK,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
@@ -6,6 +6,17 @@ import { WrChartLegendHarness } from "ngwr/charts/chart-legend/testing";
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
8
8
  */
9
+ var TableRowHarness = class extends ComponentHarness {
10
+ static hostSelector = ".wr-chart-table tbody tr";
11
+ async read() {
12
+ const header = await this.locatorFor("th[scope=\"row\"]")();
13
+ const cells = await this.locatorForAll("td")();
14
+ return {
15
+ header: await header.text(),
16
+ cells: await Promise.all(cells.map((cell) => cell.text()))
17
+ };
18
+ }
19
+ };
9
20
  const SLICE_SIZE = /(?:^|;)\s*--wr-meter-group-slice-size\s*:\s*([\d.]+)/;
10
21
  var WrMeterGroupHarness = class WrMeterGroupHarness extends ComponentHarness {
11
22
  static hostSelector = "wr-meter-group";
@@ -65,6 +76,22 @@ var WrMeterGroupHarness = class WrMeterGroupHarness extends ComponentHarness {
65
76
  const values = await this.locatorForAll(".wr-meter-group__legend-value")();
66
77
  return Promise.all(values.map((value) => value.text()));
67
78
  }
79
+ async hasDataTable() {
80
+ return await this.locatorForOptional(".wr-chart-table")() !== null;
81
+ }
82
+ async getTableColumns() {
83
+ await this.assertDataTable("getTableColumns");
84
+ const headings = await this.locatorForAll(".wr-chart-table thead th[scope=\"col\"]")();
85
+ return Promise.all(headings.map((heading) => heading.text()));
86
+ }
87
+ async getTableRows() {
88
+ await this.assertDataTable("getTableRows");
89
+ const rows = await this.locatorForAll(TableRowHarness)();
90
+ return Promise.all(rows.map((row) => row.read()));
91
+ }
92
+ async assertDataTable(method) {
93
+ if (!await this.hasDataTable()) throw new Error(`WrMeterGroupHarness.${method}(): the meter renders no data table: \`dataTable\` is off, or there is nothing to tabulate. Ask hasDataTable() first.`);
94
+ }
68
95
  };
69
96
  export { WrMeterGroupHarness };
70
97
 
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-charts-meter-group-testing.mjs","names":[],"sources":["../../../projects/lib/charts/meter-group/testing/wr-meter-group-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';\n\nimport type { WrMeterGroupHarnessFilters, WrMeterGroupSlice } from './types';\n\n/** The share of the bar the component writes onto a band, 0 to 1, out of its inline `style`. */\nconst SLICE_SIZE = /(?:^|;)\\s*--wr-meter-group-slice-size\\s*:\\s*([\\d.]+)/;\n\n/**\n * Test harness for `<wr-meter-group>` — one bar divided into labelled bands.\n *\n * **The bar is a single `progressbar`, and its value is the TOTAL.** The bands\n * themselves announce nothing: they carry a hover tooltip (or, with `tooltip` off, a\n * `title`) for a mouse and their share as an inline width, and the legend is where\n * their labels and values are readable. So a\n * spec that wants \"how much of each\" reads {@link getSlices} for the shares or\n * {@link getLegendLabels} / {@link getLegendValues} for what is printed, and one that\n * wants \"how full\" reads {@link getValue}.\n *\n * **A band's share is read off the `style` ATTRIBUTE, not through `getCssValue()`**,\n * and the difference is not cosmetic: `getCssValue()` is `getComputedStyle()`, and\n * `width` resolves to the USED value — so the declared `30%` comes straight back in\n * jsdom and arrives as `180px` on a 600px bar in a real browser, and the same harness\n * answered 30 here and 180 under a browser runner with nothing to say which one you\n * got.\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrMeterGroupHarness extends ComponentHarness {\n static hostSelector = 'wr-meter-group';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrMeterGroupHarnessFilters = {}): HarnessPredicate<WrMeterGroupHarness> {\n return new HarnessPredicate(WrMeterGroupHarness, options)\n .addOption('ariaLabel', options.ariaLabel, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getAccessibleName(), label)\n )\n .addOption('sliceLabel', options.sliceLabel, async (harness, label) => {\n for (const printed of await harness.getLegendLabels()) {\n if (await HarnessPredicate.stringMatches(printed, label)) return true;\n }\n return false;\n });\n }\n\n private readonly bar = this.locatorFor('.wr-meter-group__bar');\n\n /** The role the bar announces — `progressbar`, for the total. */\n async getRole(): Promise<string | null> {\n return (await this.bar()).getAttribute('role');\n }\n\n /** The bar's accessible name. */\n async getAccessibleName(): Promise<string | null> {\n return (await this.bar()).getAttribute('aria-label');\n }\n\n /** The total the bands add up to, from `aria-valuenow`. */\n async getValue(): Promise<number> {\n return this.numberAttribute('aria-valuenow', 'getValue');\n }\n\n /** The full capacity, from `aria-valuemax` — given, or the sum of the bands. */\n async getMax(): Promise<number> {\n return this.numberAttribute('aria-valuemax', 'getMax');\n }\n\n /**\n * A finite number off one of the bar's attributes, or a sentence saying which one it\n * lacks. `Number(null)` is `0`, so a lost binding read as an empty bar.\n */\n private async numberAttribute(name: string, method: string): Promise<number> {\n const raw = await (await this.bar()).getAttribute(name);\n const value = raw === null ? Number.NaN : Number.parseFloat(raw);\n if (!Number.isFinite(value)) {\n throw new Error(\n `WrMeterGroupHarness.${method}(): the bar carries ${name}=\"${raw ?? ''}\", which the component writes as a ` +\n 'finite number on every meter group.'\n );\n }\n return value;\n }\n\n /** The bands, in order, with the share of the bar each takes. A hidden segment draws no band. */\n async getSlices(): Promise<WrMeterGroupSlice[]> {\n const slices = await this.locatorForAll('.wr-meter-group__slice')();\n\n return Promise.all(\n slices.map(async slice => {\n // `data-label`, which the band carries whatever `tooltip` says. The `title`\n // this used to read is written only while the tooltip is off, so reading it\n // would answer `null` for every band of a default meter.\n const label = await slice.getAttribute('data-label');\n return { label, percent: WrMeterGroupHarness.percentOf(label, await slice.getAttribute('style')) };\n })\n );\n }\n\n /** Parse one band's declared share. See the class note on why this is not `getCssValue()`. */\n private static percentOf(label: string | null, style: string | null): number {\n const match = SLICE_SIZE.exec(style ?? '');\n if (!match) {\n throw new Error(\n `WrMeterGroupHarness.getSlices(): the band ${label === null ? '(untitled)' : `\"${label}\"`} carries no ` +\n `inline share of the bar (style: \"${style ?? ''}\"). The component writes one for every band, since the ` +\n 'total always falls back to 1 — so its absence is the bug, and reporting 0 would read as an empty band.'\n );\n }\n return Math.round(Number.parseFloat(match[1]) * 1e5) / 1e3;\n }\n\n /** Whether the legend is rendered (`showLegend`, and at least one band). */\n async hasLegend(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-meter-group__legend')()) !== null;\n }\n\n /**\n * The legend as a {@link WrChartLegendHarness}: each row's key and its hidden state\n * and, with `toggleableLegend`, the toggles that show and hide a segment.\n *\n * Throws when the group draws no legend (`showLegend` off, or no segments) rather\n * than 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 'WrMeterGroupHarness.getLegendHarness(): the group draws no legend — `showLegend` is off or there are no ' +\n 'segments. Ask hasLegend() first.'\n );\n }\n return legend;\n }\n\n /** The legend's labels, in order — hidden segments included, since their rows stay. */\n async getLegendLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-meter-group__legend-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /** The legend's values, in order — empty when `showValues` is off. */\n async getLegendValues(): Promise<string[]> {\n const values = await this.locatorForAll('.wr-meter-group__legend-value')();\n return Promise.all(values.map(value => value.text()));\n }\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,aAAa;AAsBnB,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,cAAc,QAAQ,YAAY,OAAO,SAAS,UAAS;GACpE,KAAK,MAAM,WAAW,MAAM,QAAQ,gBAAe,GACjD,IAAI,MAAM,iBAAiB,cAAc,SAAS,KAAK,GAAG,OAAO;GAEnE,OAAO;EACT,CAAC;CACL;CAEiB,MAAM,KAAK,WAAW,sBAAsB;CAG7D,MAAM,UAAO;EACX,QAAQ,MAAM,KAAK,IAAG,EAAA,CAAI,aAAa,MAAM;CAC/C;CAGA,MAAM,oBAAiB;EACrB,QAAQ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AO;CACT;CAGA,MAAM,kBAAe;EACnB,MAAM,SAAS,MAAM,KAAK,cAAc,+BAA+B,CAAC,CAAA;EACxE,OAAO,QAAQ,IAAI,OAAO,KAAI,UAAS,MAAM,KAAI,CAAE,CAAC;CACtD;CAGA,MAAM,kBAAe;EACnB,MAAM,SAAS,MAAM,KAAK,cAAc,+BAA+B,CAAC,CAAA;EACxE,OAAO,QAAQ,IAAI,OAAO,KAAI,UAAS,MAAM,KAAI,CAAE,CAAC;CACtD"}
1
+ {"version":3,"file":"ngwr-charts-meter-group-testing.mjs","names":[],"sources":["../../../projects/lib/charts/meter-group/testing/wr-meter-group-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';\n\nimport type { WrMeterGroupHarnessFilters, WrMeterGroupSlice, WrMeterGroupTableRow } from './types';\n\n/**\n * One body row of the meter'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<WrMeterGroupTableRow> {\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/** The share of the bar the component writes onto a band, 0 to 1, out of its inline `style`. */\nconst SLICE_SIZE = /(?:^|;)\\s*--wr-meter-group-slice-size\\s*:\\s*([\\d.]+)/;\n\n/**\n * Test harness for `<wr-meter-group>` — one bar divided into labelled bands.\n *\n * **The bar is a single `progressbar`, and its value is the TOTAL.** The bands\n * themselves announce nothing: they carry a hover tooltip (or, with `tooltip` off, a\n * `title`) for a mouse and their share as an inline width, and the legend is where\n * their labels and values are readable. So a\n * spec that wants \"how much of each\" reads {@link getSlices} for the shares or\n * {@link getLegendLabels} / {@link getLegendValues} for what is printed, and one that\n * wants \"how full\" reads {@link getValue}.\n *\n * **A band's share is read off the `style` ATTRIBUTE, not through `getCssValue()`**,\n * and the difference is not cosmetic: `getCssValue()` is `getComputedStyle()`, and\n * `width` resolves to the USED value — so the declared `30%` comes straight back in\n * jsdom and arrives as `180px` on a 600px bar in a real browser, and the same harness\n * answered 30 here and 180 under a browser runner with nothing to say which one you\n * got.\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrMeterGroupHarness extends ComponentHarness {\n static hostSelector = 'wr-meter-group';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrMeterGroupHarnessFilters = {}): HarnessPredicate<WrMeterGroupHarness> {\n return new HarnessPredicate(WrMeterGroupHarness, options)\n .addOption('ariaLabel', options.ariaLabel, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getAccessibleName(), label)\n )\n .addOption('sliceLabel', options.sliceLabel, async (harness, label) => {\n for (const printed of await harness.getLegendLabels()) {\n if (await HarnessPredicate.stringMatches(printed, label)) return true;\n }\n return false;\n });\n }\n\n private readonly bar = this.locatorFor('.wr-meter-group__bar');\n\n /** The role the bar announces — `progressbar`, for the total. */\n async getRole(): Promise<string | null> {\n return (await this.bar()).getAttribute('role');\n }\n\n /** The bar's accessible name. */\n async getAccessibleName(): Promise<string | null> {\n return (await this.bar()).getAttribute('aria-label');\n }\n\n /** The total the bands add up to, from `aria-valuenow`. */\n async getValue(): Promise<number> {\n return this.numberAttribute('aria-valuenow', 'getValue');\n }\n\n /** The full capacity, from `aria-valuemax` — given, or the sum of the bands. */\n async getMax(): Promise<number> {\n return this.numberAttribute('aria-valuemax', 'getMax');\n }\n\n /**\n * A finite number off one of the bar's attributes, or a sentence saying which one it\n * lacks. `Number(null)` is `0`, so a lost binding read as an empty bar.\n */\n private async numberAttribute(name: string, method: string): Promise<number> {\n const raw = await (await this.bar()).getAttribute(name);\n const value = raw === null ? Number.NaN : Number.parseFloat(raw);\n if (!Number.isFinite(value)) {\n throw new Error(\n `WrMeterGroupHarness.${method}(): the bar carries ${name}=\"${raw ?? ''}\", which the component writes as a ` +\n 'finite number on every meter group.'\n );\n }\n return value;\n }\n\n /** The bands, in order, with the share of the bar each takes. A hidden segment draws no band. */\n async getSlices(): Promise<WrMeterGroupSlice[]> {\n const slices = await this.locatorForAll('.wr-meter-group__slice')();\n\n return Promise.all(\n slices.map(async slice => {\n // `data-label`, which the band carries whatever `tooltip` says. The `title`\n // this used to read is written only while the tooltip is off, so reading it\n // would answer `null` for every band of a default meter.\n const label = await slice.getAttribute('data-label');\n return { label, percent: WrMeterGroupHarness.percentOf(label, await slice.getAttribute('style')) };\n })\n );\n }\n\n /** Parse one band's declared share. See the class note on why this is not `getCssValue()`. */\n private static percentOf(label: string | null, style: string | null): number {\n const match = SLICE_SIZE.exec(style ?? '');\n if (!match) {\n throw new Error(\n `WrMeterGroupHarness.getSlices(): the band ${label === null ? '(untitled)' : `\"${label}\"`} carries no ` +\n `inline share of the bar (style: \"${style ?? ''}\"). The component writes one for every band, since the ` +\n 'total always falls back to 1 — so its absence is the bug, and reporting 0 would read as an empty band.'\n );\n }\n return Math.round(Number.parseFloat(match[1]) * 1e5) / 1e3;\n }\n\n /** Whether the legend is rendered (`showLegend`, and at least one band). */\n async hasLegend(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-meter-group__legend')()) !== null;\n }\n\n /**\n * The legend as a {@link WrChartLegendHarness}: each row's key and its hidden state\n * and, with `toggleableLegend`, the toggles that show and hide a segment.\n *\n * Throws when the group draws no legend (`showLegend` off, or no segments) rather\n * than 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 'WrMeterGroupHarness.getLegendHarness(): the group draws no legend — `showLegend` is off or there are no ' +\n 'segments. Ask hasLegend() first.'\n );\n }\n return legend;\n }\n\n /** The legend's labels, in order — hidden segments included, since their rows stay. */\n async getLegendLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-meter-group__legend-label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /** The legend's values, in order — empty when `showValues` is off. */\n async getLegendValues(): Promise<string[]> {\n const values = await this.locatorForAll('.wr-meter-group__legend-value')();\n return Promise.all(values.map(value => value.text()));\n }\n\n /** Whether the hidden data table is rendered (`dataTable`, while the meter draws its segments). */\n async hasDataTable(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-chart-table')()) !== null;\n }\n\n /**\n * The data table's column headings: the value's name and the share's.\n *\n * Throws when the meter renders no table (`dataTable` off, or a state in the legend's\n * place) rather than answering with no columns.\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 segment shown, in the data's own order: its label, its\n * value and its share of the total, as a screen reader walks them. A segment hidden\n * through `hiddenSegments` has no row, and one that draws nothing an empty share.\n *\n * Throws when the meter renders no table, for the reason {@link getTableColumns} gives.\n */\n async getTableRows(): Promise<WrMeterGroupTableRow[]> {\n await this.assertDataTable('getTableRows');\n const rows = await this.locatorForAll(TableRowHarness)();\n return Promise.all(rows.map(row => row.read()));\n }\n\n private async assertDataTable(method: string): Promise<void> {\n if (!(await this.hasDataTable())) {\n throw new Error(\n `WrMeterGroupHarness.${method}(): the meter renders no data table: \\`dataTable\\` is off, or there ` +\n 'is nothing to tabulate. Ask hasDataTable() first.'\n );\n }\n }\n}\n"],"mappings":";;;;;;;;AAiBA,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;EA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