ngwr 16.4.0 → 16.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/charts/bar-chart/styles/_index.scss +494 -305
  2. package/charts/boxplot-chart/styles/_index.scss +114 -48
  3. package/charts/bullet-chart/styles/_index.scss +113 -42
  4. package/charts/calendar-heatmap/styles/_index.scss +111 -20
  5. package/charts/candlestick-chart/styles/_index.scss +61 -26
  6. package/charts/chart-legend/styles/_index.scss +119 -1
  7. package/charts/core/styles/_index.scss +201 -5
  8. package/charts/donut-chart/styles/_index.scss +76 -21
  9. package/charts/funnel-chart/styles/_index.scss +66 -38
  10. package/charts/gauge/styles/_index.scss +12 -1
  11. package/charts/heatmap-chart/styles/_index.scss +90 -53
  12. package/charts/line-chart/styles/_index.scss +143 -139
  13. package/charts/meter-group/styles/_index.scss +87 -25
  14. package/charts/radar-chart/styles/_index.scss +82 -40
  15. package/charts/scatter-chart/styles/_index.scss +117 -44
  16. package/charts/sparkline/styles/_index.scss +7 -1
  17. package/charts/treemap-chart/styles/_index.scss +94 -42
  18. package/charts/waterfall-chart/styles/_index.scss +150 -87
  19. package/color-picker/styles/_index.scss +7 -3
  20. package/copy-value/styles/_index.scss +21 -2
  21. package/date-stamp/styles/_index.scss +2 -1
  22. package/dialog/styles/_index.scss +6 -0
  23. package/drawer/styles/_index.scss +5 -1
  24. package/fesm2022/ngwr-carousel-testing.mjs +4 -1
  25. package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
  26. package/fesm2022/ngwr-carousel.mjs +21 -2
  27. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  28. package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
  29. package/fesm2022/ngwr-cascader.mjs +48 -4
  30. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  31. package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
  32. package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
  33. package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
  34. package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
  35. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
  36. package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
  37. package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
  38. package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
  39. package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
  40. package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
  41. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
  42. package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
  43. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
  44. package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
  45. package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
  46. package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
  47. package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
  48. package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
  49. package/fesm2022/ngwr-charts-core.mjs +299 -18
  50. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  51. package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
  52. package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
  53. package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
  54. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
  55. package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
  56. package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
  57. package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
  58. package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
  59. package/fesm2022/ngwr-charts-gauge.mjs +98 -12
  60. package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
  61. package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
  62. package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
  63. package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
  64. package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
  65. package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
  66. package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
  67. package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
  68. package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
  69. package/fesm2022/ngwr-charts-meter-group.mjs +223 -31
  70. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  71. package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
  72. package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
  73. package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
  74. package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
  75. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
  76. package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
  77. package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
  78. package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
  79. package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
  80. package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
  81. package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
  82. package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
  83. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
  84. package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
  85. package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
  86. package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
  87. package/fesm2022/ngwr-color-picker.mjs +44 -4
  88. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  89. package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
  90. package/fesm2022/ngwr-context-menu.mjs +47 -19
  91. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  92. package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
  93. package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
  94. package/fesm2022/ngwr-copy-value.mjs +38 -2
  95. package/fesm2022/ngwr-copy-value.mjs.map +1 -1
  96. package/fesm2022/ngwr-date-picker.mjs +56 -8
  97. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  98. package/fesm2022/ngwr-dialog.mjs +13 -5
  99. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  100. package/fesm2022/ngwr-drawer.mjs +19 -3
  101. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  102. package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
  103. package/fesm2022/ngwr-dropdown.mjs +35 -6
  104. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  105. package/fesm2022/ngwr-editor.mjs +1 -0
  106. package/fesm2022/ngwr-editor.mjs.map +1 -1
  107. package/fesm2022/ngwr-graph.mjs +81 -13
  108. package/fesm2022/ngwr-graph.mjs.map +1 -1
  109. package/fesm2022/ngwr-i18n-ar.mjs +5 -0
  110. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  111. package/fesm2022/ngwr-i18n-cs.mjs +5 -0
  112. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  113. package/fesm2022/ngwr-i18n-de.mjs +5 -0
  114. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  115. package/fesm2022/ngwr-i18n-en.mjs +5 -0
  116. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  117. package/fesm2022/ngwr-i18n-es.mjs +5 -0
  118. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  119. package/fesm2022/ngwr-i18n-fr.mjs +5 -0
  120. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  121. package/fesm2022/ngwr-i18n-he.mjs +5 -0
  122. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  123. package/fesm2022/ngwr-i18n-hi.mjs +5 -0
  124. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  125. package/fesm2022/ngwr-i18n-id.mjs +5 -0
  126. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  127. package/fesm2022/ngwr-i18n-it.mjs +5 -0
  128. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  129. package/fesm2022/ngwr-i18n-ja.mjs +5 -0
  130. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  131. package/fesm2022/ngwr-i18n-ko.mjs +5 -0
  132. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  133. package/fesm2022/ngwr-i18n-nl.mjs +5 -0
  134. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  135. package/fesm2022/ngwr-i18n-pl.mjs +5 -0
  136. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  137. package/fesm2022/ngwr-i18n-pt.mjs +5 -0
  138. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  139. package/fesm2022/ngwr-i18n-ru.mjs +5 -0
  140. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  141. package/fesm2022/ngwr-i18n-sv.mjs +5 -0
  142. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  143. package/fesm2022/ngwr-i18n-tr.mjs +5 -0
  144. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  145. package/fesm2022/ngwr-i18n-uk.mjs +5 -0
  146. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  147. package/fesm2022/ngwr-i18n-vi.mjs +5 -0
  148. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  149. package/fesm2022/ngwr-i18n-zh-tw.mjs +5 -0
  150. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  151. package/fesm2022/ngwr-i18n-zh.mjs +5 -0
  152. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  153. package/fesm2022/ngwr-lightbox.mjs +20 -3
  154. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  155. package/fesm2022/ngwr-overlay.mjs +21 -2
  156. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  157. package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
  158. package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
  159. package/fesm2022/ngwr-popconfirm.mjs +41 -5
  160. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  161. package/fesm2022/ngwr-popover.mjs +67 -12
  162. package/fesm2022/ngwr-popover.mjs.map +1 -1
  163. package/fesm2022/ngwr-schema-form.mjs +2 -0
  164. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  165. package/fesm2022/ngwr-table.mjs +2 -0
  166. package/fesm2022/ngwr-table.mjs.map +1 -1
  167. package/fesm2022/ngwr-tour.mjs +14 -9
  168. package/fesm2022/ngwr-tour.mjs.map +1 -1
  169. package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
  170. package/fesm2022/ngwr-tree.mjs +49 -16
  171. package/fesm2022/ngwr-tree.mjs.map +1 -1
  172. package/fesm2022/ngwr-version.mjs +1 -1
  173. package/fesm2022/ngwr-version.mjs.map +1 -1
  174. package/fesm2022/ngwr-window.mjs +16 -9
  175. package/fesm2022/ngwr-window.mjs.map +1 -1
  176. package/i18n/ar.json +5 -0
  177. package/i18n/cs.json +5 -0
  178. package/i18n/de.json +5 -0
  179. package/i18n/en.json +5 -0
  180. package/i18n/es.json +5 -0
  181. package/i18n/fr.json +5 -0
  182. package/i18n/he.json +5 -0
  183. package/i18n/hi.json +5 -0
  184. package/i18n/id.json +5 -0
  185. package/i18n/it.json +5 -0
  186. package/i18n/ja.json +5 -0
  187. package/i18n/ko.json +5 -0
  188. package/i18n/nl.json +5 -0
  189. package/i18n/pl.json +5 -0
  190. package/i18n/pt.json +5 -0
  191. package/i18n/ru.json +5 -0
  192. package/i18n/sv.json +5 -0
  193. package/i18n/tr.json +5 -0
  194. package/i18n/uk.json +5 -0
  195. package/i18n/vi.json +5 -0
  196. package/i18n/zh-TW.json +5 -0
  197. package/i18n/zh.json +5 -0
  198. package/llms-full.txt +8 -8
  199. package/llms.txt +7 -3
  200. package/package.json +1 -1
  201. package/popconfirm/styles/_index.scss +6 -0
  202. package/popover/styles/_index.scss +24 -13
  203. package/schematics/use/symbol-map.json +1 -0
  204. package/skills/ngwr/references/catalog.md +1 -1
  205. package/tour/styles/_index.scss +6 -0
  206. package/types/ngwr-carousel-testing.d.ts +6 -4
  207. package/types/ngwr-carousel.d.ts +14 -3
  208. package/types/ngwr-cascader-testing.d.ts +4 -3
  209. package/types/ngwr-cascader.d.ts +27 -3
  210. package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
  211. package/types/ngwr-charts-bar-chart.d.ts +220 -48
  212. package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
  213. package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
  214. package/types/ngwr-charts-bullet-chart.d.ts +72 -12
  215. package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
  216. package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
  217. package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
  218. package/types/ngwr-charts-chart-legend.d.ts +142 -5
  219. package/types/ngwr-charts-core.d.ts +259 -21
  220. package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
  221. package/types/ngwr-charts-donut-chart.d.ts +124 -16
  222. package/types/ngwr-charts-funnel-chart.d.ts +62 -6
  223. package/types/ngwr-charts-gauge-testing.d.ts +5 -1
  224. package/types/ngwr-charts-gauge.d.ts +72 -10
  225. package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
  226. package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
  227. package/types/ngwr-charts-line-chart.d.ts +215 -86
  228. package/types/ngwr-charts-meter-group.d.ts +96 -7
  229. package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
  230. package/types/ngwr-charts-radar-chart.d.ts +148 -28
  231. package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
  232. package/types/ngwr-charts-scatter-chart.d.ts +188 -18
  233. package/types/ngwr-charts-sparkline.d.ts +26 -4
  234. package/types/ngwr-charts-treemap-chart.d.ts +121 -23
  235. package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
  236. package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
  237. package/types/ngwr-color-picker.d.ts +27 -0
  238. package/types/ngwr-context-menu-testing.d.ts +10 -9
  239. package/types/ngwr-context-menu.d.ts +17 -0
  240. package/types/ngwr-copy-value.d.ts +8 -0
  241. package/types/ngwr-date-picker.d.ts +34 -2
  242. package/types/ngwr-dialog.d.ts +30 -10
  243. package/types/ngwr-drawer.d.ts +32 -1
  244. package/types/ngwr-dropdown-testing.d.ts +8 -5
  245. package/types/ngwr-dropdown.d.ts +29 -6
  246. package/types/ngwr-graph.d.ts +22 -6
  247. package/types/ngwr-lightbox.d.ts +15 -0
  248. package/types/ngwr-overlay.d.ts +16 -1
  249. package/types/ngwr-popconfirm-testing.d.ts +11 -2
  250. package/types/ngwr-popconfirm.d.ts +28 -1
  251. package/types/ngwr-popover.d.ts +59 -9
  252. package/types/ngwr-table.d.ts +1 -1
  253. package/types/ngwr-tour.d.ts +21 -2
  254. package/types/ngwr-tree-testing.d.ts +1 -2
  255. package/types/ngwr-tree.d.ts +33 -2
  256. package/types/ngwr-version.d.ts +1 -1
  257. package/types/ngwr-window.d.ts +14 -11
  258. package/window/styles/_index.scss +5 -10
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-charts-chart-legend.mjs","names":[],"sources":["../../../projects/lib/charts/chart-legend/internal/chart-legend-part.ts","../../../projects/lib/charts/chart-legend/tokens/chart-legend-block.token.ts","../../../projects/lib/charts/chart-legend/chart-legend.ts","../../../projects/lib/charts/chart-legend/chart-legend.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 { Directive, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Adds the host chart's own class to one part of a legend row, beside the part's\n * static `wr-chart-legend__*` classes.\n *\n * A host `[class]` binding merges with the element's static `class`, where a\n * template's `class` plus `[class]` pair is one the template lint refuses — and the\n * static half has to stay static: `charts/stylesheets.spec.ts` reads the first class\n * of every inline-painted mark off the template to hold it to `forced-color-adjust`.\n *\n * @internal\n */\n@Directive({\n selector: '[wrChartLegendPart]',\n host: { '[class]': 'wrChartLegendPart()' },\n})\nexport class WrChartLegendPart {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/chart-legend');\n }\n\n /** The class to add; `''` adds none. */\n readonly wrChartLegendPart = input('');\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\n/**\n * The BEM block of the chart a legend is drawn inside, provided by that chart:\n * `'wr-donut-chart'` makes every row also carry `.wr-donut-chart__legend-item`,\n * its key `.wr-donut-chart__swatch`, its name `.wr-donut-chart__legend-label` and\n * its value `.wr-donut-chart__legend-value` — the classes the chart drew before it\n * drew its legend through `WrChartLegend`, which are public API and stay on the\n * same elements.\n *\n * A chart provides it in `viewProviders`, and the legend reads it with `host: true`:\n * that lookup stops at the host element of the view the legend is declared in, where\n * it sees that component's `viewProviders` and not its `providers`. So only a legend\n * in the chart's OWN template takes the block, never one further down the tree.\n *\n * @internal\n */\nexport const WR_CHART_LEGEND_BLOCK = new InjectionToken<string>('WR_CHART_LEGEND_BLOCK');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { NgTemplateOutlet } from '@angular/common';\nimport { Component, ViewEncapsulation, computed, inject, input, model, output } from '@angular/core';\n\nimport { wrChartMarkerPath } from 'ngwr/charts/core';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrChartLegendPart } from './internal/chart-legend-part';\nimport { WR_CHART_LEGEND_BLOCK } from './tokens';\nimport type { WrChartLegendItem, WrChartLegendToggle, WrChartMarker } from './types';\n\n/**\n * A chart's key: one row per series, each a swatch, a name and an optional value.\n * It stands on its own for a key that several charts share — one legend above a row\n * of sparklines — and the bar, line, donut, meter group, scatter and radar charts\n * draw their own legends with it.\n *\n * It sits on a `<ul>` the way `button[wr-btn]` sits on a `<button>`, and renders the\n * `<li>`s, so the list is the consumer's element: its class, its placement, its\n * name. The swatch follows what tells the series apart in the chart: a dot, a line\n * in the series' `dash`, or the series' `marker`. A dot is a span painted with an\n * inline background, a line or a marker is an SVG, and every key is `aria-hidden`:\n * the row's text is its name.\n *\n * **Toggling is opt-in.** With `toggleable`, every row is a\n * `<button type=\"button\" aria-pressed>` that shows and hides its series: pressed\n * means shown, and `hiddenSeries` holds the positions of the hidden ones. The rows\n * stay in the tab order, one stop each, rather than becoming one toolbar stop with\n * arrow keys: the toolbar pattern needs `role=\"toolbar\"`, which would take the\n * `<ul>`'s list role and with it the \"list, 5 items\" a reader hears, while each row\n * is an independent toggle — the Button pattern, Tab plus Space or Enter — and a\n * chart's series rarely outnumber the five colours it cycles through. A legend\n * draws nothing hidden by itself: the chart reads `hiddenSeries`.\n *\n * **A hidden row says so in both modes.** On a toggle it is `aria-pressed=\"false\"`;\n * on a legend that does not toggle, where a host has hidden the series from\n * elsewhere, the row carries a visually hidden word after its name\n * (`chartLegend.hidden`, \"hidden\"), since the strike-through and the faded key reach\n * no one who cannot see them.\n *\n * @example\n * ```html\n * <ul\n * wr-chart-legend\n * [items]=\"[\n * { label: 'Visits', color: 'var(--wr-color-primary)', value: '1,204' },\n * { label: 'Signups', color: 'var(--wr-color-success)', value: '86' }\n * ]\"\n * ></ul>\n *\n * <ul wr-chart-legend toggleable [items]=\"series\" [(hiddenSeries)]=\"hidden\"></ul>\n * ```\n *\n * @see https://ngwr.dev/charts/chart-legend\n */\n@Component({\n selector: 'ul[wr-chart-legend]',\n templateUrl: './chart-legend.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-chart-legend',\n // Written out because `list-style: none` (styles/_index.scss) drops the implicit\n // list semantics in Safari, and with them the list's `aria-label`.\n role: 'list',\n '[class.wr-chart-legend--toggleable]': 'toggleable()',\n '[attr.aria-label]': 'label()',\n },\n imports: [NgTemplateOutlet, WrChartLegendPart],\n})\nexport class WrChartLegend {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/chart-legend');\n }\n\n /** One row per series, in the chart's order. */\n readonly items = input<readonly WrChartLegendItem[]>([]);\n\n /**\n * Make each row a toggle button that shows and hides its series, through\n * `hiddenSeries` and `toggled`. @default false\n */\n readonly toggleable = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The positions in `items` of the series that are hidden, ascending. Positions\n * rather than labels: two series may share a label, and a label translated into\n * another language would no longer match the one it hid. A position past the end\n * of `items` is kept and ignored, so a series coming back finds its state.\n *\n * Written by a click on a `toggleable` row; read in either mode, so a legend that\n * does not toggle still shows a series hidden from elsewhere as hidden.\n */\n readonly hiddenSeries = model<readonly number[]>([]);\n\n /**\n * Accessible name of the list. A `toggleable` legend falls back to\n * `chartLegend.toggleLabel` (\"Toggle series visibility\"), which tells a reader\n * what its buttons do; one that does not toggle has no name unless given one.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /** Emits when a reader shows or hides a series from a `toggleable` legend, after `hiddenSeries` moves. */\n readonly toggled = output<WrChartLegendToggle>();\n\n private readonly toggleLabel = useI18nText(this.ariaLabel, 'chartLegend.toggleLabel', 'Toggle series visibility');\n\n /**\n * The word a hidden row of a legend that does not toggle carries after its name,\n * visually hidden: the strike-through and the faded key are the eye's half of the\n * state, and a toggle row's `aria-pressed` is the other half there. Falls back to\n * `chartLegend.hidden`, then `'hidden'`.\n */\n readonly hiddenLabel = input<string | null>(null);\n\n protected readonly resolvedHiddenLabel = useI18nText(this.hiddenLabel, 'chartLegend.hidden', 'hidden');\n\n protected readonly label = computed(() => (this.ariaLabel() || this.toggleable() ? this.toggleLabel() : null));\n\n private readonly block = inject(WR_CHART_LEGEND_BLOCK, { optional: true, host: true });\n\n private readonly hidden = computed(() => new Set(this.hiddenSeries()));\n\n /** Whether the series at `index` is hidden. */\n protected isHidden(index: number): boolean {\n return this.hidden().has(index);\n }\n\n /** The host chart's own class for one part of a row, or nothing outside a chart. */\n protected part(name: 'legend-item' | 'swatch' | 'legend-label' | 'legend-value'): string {\n return this.block ? `${this.block}__${name}` : '';\n }\n\n /** A marker's path, as large as a circle of radius `r` in the swatch's own units. */\n protected markerPath(shape: WrChartMarker, r: number): string {\n return wrChartMarkerPath(shape, r);\n }\n\n /** Shows or hides the series at `index`, then says so. */\n protected toggle(index: number): void {\n const current = this.hiddenSeries();\n const hide = !current.includes(index);\n this.hiddenSeries.set(hide ? [...current, index].sort((a, b) => a - b) : current.filter(i => i !== index));\n this.toggled.emit({ index, label: this.items()[index]?.label ?? '', hidden: hide });\n }\n}\n\nexport type { WrChartLegendItem, WrChartLegendToggle, WrChartMarker } from './types';\n","@for (item of items(); track $index) {\n <li\n class=\"wr-chart-legend__item\"\n [class.wr-chart-legend__item--hidden]=\"isHidden($index)\"\n [wrChartLegendPart]=\"part('legend-item')\"\n >\n @if (toggleable()) {\n <!-- Pressed means SHOWN: the button's name is the series, and pressing it turns\n that series on. The name never changes with the state, as the toggle-button\n pattern requires; the state is `aria-pressed` and the struck-through label. -->\n <button\n type=\"button\"\n class=\"wr-chart-legend__toggle\"\n [attr.aria-pressed]=\"!isHidden($index)\"\n (click)=\"toggle($index)\"\n >\n <ng-container [ngTemplateOutlet]=\"row\" [ngTemplateOutletContext]=\"{ $implicit: $index }\" />\n </button>\n } @else {\n <ng-container [ngTemplateOutlet]=\"row\" [ngTemplateOutletContext]=\"{ $implicit: $index }\" />\n }\n </li>\n}\n\n<ng-template #row let-index>\n @let item = items()[index];\n @if (item.dash !== undefined) {\n <!-- The key draws the series' own dash, not a solid block. A legend that pairs a\n coloured square with a name leaves the reader to match the square to the LINE,\n and matching by colour is the step the patterns exist to remove. -->\n <svg\n class=\"wr-chart-legend__swatch wr-chart-legend__swatch--line\"\n [wrChartLegendPart]=\"part('swatch')\"\n viewBox=\"0 0 16 2\"\n aria-hidden=\"true\"\n [attr.data-marker]=\"item.marker ?? null\"\n >\n <line\n x1=\"0\"\n y1=\"1\"\n x2=\"16\"\n y2=\"1\"\n [attr.stroke]=\"item.color\"\n [attr.stroke-dasharray]=\"item.dash || null\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n />\n @if (item.marker) {\n <path [attr.d]=\"markerPath(item.marker, 3.5)\" transform=\"translate(8 1)\" [attr.fill]=\"item.color\" />\n }\n </svg>\n } @else if (item.marker) {\n <svg\n class=\"wr-chart-legend__swatch wr-chart-legend__swatch--marker\"\n [wrChartLegendPart]=\"part('swatch')\"\n viewBox=\"-6 -6 12 12\"\n aria-hidden=\"true\"\n [attr.data-marker]=\"item.marker\"\n >\n <path [attr.d]=\"markerPath(item.marker, 5)\" [attr.fill]=\"item.color\" />\n </svg>\n } @else {\n <span\n class=\"wr-chart-legend__swatch wr-chart-legend__swatch--dot\"\n [wrChartLegendPart]=\"part('swatch')\"\n aria-hidden=\"true\"\n [style.background]=\"item.color\"\n ></span>\n }\n <span class=\"wr-chart-legend__label\" [wrChartLegendPart]=\"part('legend-label')\">{{ item.label }}</span>\n @if (!toggleable() && isHidden(index)) {\n <!-- A toggle says hidden through aria-pressed. A row that is not one has nothing but\n the strike-through and the faded key, which reach no one who cannot see them. -->\n <span class=\"wr-chart-legend__sr-only\"> {{ resolvedHiddenLabel() }} </span>\n }\n @if (item.value !== undefined && item.value !== null) {\n <span class=\"wr-chart-legend__value\" [wrChartLegendPart]=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IAGP,MAAM;IACN,uCAAuC;IACvC,qBAAqB;GACtB;GAAA,SACQ,CAAC,kBAAkB,iBAAiB;GAAC,UAAA;EAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-charts-chart-legend.mjs","names":[],"sources":["../../../projects/lib/charts/chart-legend/internal/chart-legend-part.ts","../../../projects/lib/charts/chart-legend/tokens/chart-legend-block.token.ts","../../../projects/lib/charts/chart-legend/chart-legend.ts","../../../projects/lib/charts/chart-legend/chart-legend.html","../../../projects/lib/charts/chart-legend/chart-scale.ts","../../../projects/lib/charts/chart-legend/chart-scale.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 { Directive, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Adds the host chart's own class to one part of a legend row, beside the part's\n * static `wr-chart-legend__*` classes.\n *\n * A host `[class]` binding merges with the element's static `class`, where a\n * template's `class` plus `[class]` pair is one the template lint refuses — and the\n * static half has to stay static: `charts/stylesheets.spec.ts` reads the first class\n * of every inline-painted mark off the template to hold it to `forced-color-adjust`.\n *\n * @internal\n */\n@Directive({\n selector: '[wrChartLegendPart]',\n host: { '[class]': 'wrChartLegendPart()' },\n})\nexport class WrChartLegendPart {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/chart-legend');\n }\n\n /** The class to add; `''` adds none. */\n readonly wrChartLegendPart = input('');\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\n/**\n * The BEM block of the chart a legend is drawn inside, provided by that chart:\n * `'wr-donut-chart'` makes every row also carry `.wr-donut-chart__legend-item`,\n * its key `.wr-donut-chart__swatch`, its name `.wr-donut-chart__legend-label` and\n * its value `.wr-donut-chart__legend-value` — the classes the chart drew before it\n * drew its legend through `WrChartLegend`, which are public API and stay on the\n * same elements.\n *\n * A chart provides it in `viewProviders`, and the legend reads it with `host: true`:\n * that lookup stops at the host element of the view the legend is declared in, where\n * it sees that component's `viewProviders` and not its `providers`. So only a legend\n * in the chart's OWN template takes the block, never one further down the tree.\n *\n * @internal\n */\nexport const WR_CHART_LEGEND_BLOCK = new InjectionToken<string>('WR_CHART_LEGEND_BLOCK');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { NgTemplateOutlet } from '@angular/common';\nimport { Component, ViewEncapsulation, computed, inject, input, model, output } from '@angular/core';\n\nimport { wrChartMarkerPath } from 'ngwr/charts/core';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrChartLegendPart } from './internal/chart-legend-part';\nimport { WR_CHART_LEGEND_BLOCK } from './tokens';\nimport type { WrChartLegendItem, WrChartLegendPosition, WrChartLegendToggle, WrChartMarker } from './types';\n\n/** The radius of a marker drawn as the whole key, in the swatch's own units: a 12-unit box. */\nconst MARKER_RADIUS = 5;\n\n/** The radius of a marker drawn on the middle of a line key, whose box is 16 by 2. */\nconst LINE_MARKER_RADIUS = 3.5;\n\n/** Which of the three keys a row draws. */\ntype Key = 'line' | 'marker' | 'dot';\n\n/**\n * One row as the template draws it: everything it binds, worked out once per change of\n * `items`. The template reads nothing off the item itself.\n */\ninterface Row {\n readonly label: string;\n readonly color: string;\n readonly key: Key;\n /** The dash of a line key, `null` for a solid line or another key. */\n readonly dash: string | null;\n readonly marker: WrChartMarker | null;\n /** The marker's path at the size its key draws it, `null` with no marker. */\n readonly path: string | null;\n /** The value printed after the label, `null` for none. */\n readonly value: string | null;\n}\n\n/**\n * A chart's key: one row per series, each a swatch, a name and an optional value.\n * It stands on its own for a key that several charts share — one legend above a row\n * of sparklines — and the bar, line, donut, meter group, scatter and radar charts\n * draw their own legends with it.\n *\n * It sits on a `<ul>` the way `button[wr-btn]` sits on a `<button>`, and renders the\n * `<li>`s, so the list is the consumer's element: its class, its placement, its\n * name. The swatch follows what tells the series apart in the chart: a dot, a line\n * in the series' `dash`, or the series' `marker`. A dot is a span painted with an\n * inline background, a line or a marker is an SVG, and every key is `aria-hidden`:\n * the row's text is its name.\n *\n * **`position` says where the legend sits beside its chart**: `top`, `bottom`, `start`\n * or `end`, or `none` to draw nothing. Above and below it is a wrapping row; at inline\n * start or end it is a column. A chart that draws its own legend forwards its\n * `legendPosition` here and places the list; a legend that stands alone is placed by\n * the app, and `position` only picks the row or the column.\n *\n * **Hovering a row dims the rest of its chart.** Every row carries `data-wr-series`\n * with its position, the attribute a chart puts on that series' marks, so the chart's\n * hover fades every other series while the pointer is on a row.\n *\n * **Toggling is opt-in.** With `toggleable`, every row is a\n * `<button type=\"button\" aria-pressed>` that shows and hides its series: pressed\n * means shown, and `hiddenSeries` holds the positions of the hidden ones. The rows\n * stay in the tab order, one stop each, rather than becoming one toolbar stop with\n * arrow keys: the toolbar pattern needs `role=\"toolbar\"`, which would take the\n * `<ul>`'s list role and with it the \"list, 5 items\" a reader hears, while each row\n * is an independent toggle — the Button pattern, Tab plus Space or Enter — and a\n * chart's series rarely outnumber the five colours it cycles through. A legend\n * draws nothing hidden by itself: the chart reads `hiddenSeries`.\n *\n * **A hidden row says so in both modes.** On a toggle it is `aria-pressed=\"false\"`;\n * on a legend that does not toggle, where a host has hidden the series from\n * elsewhere, the row carries a visually hidden word after its name\n * (`chartLegend.hidden`, \"hidden\"), since the strike-through and the faded key reach\n * no one who cannot see them.\n *\n * @example\n * ```html\n * <ul\n * wr-chart-legend\n * [items]=\"[\n * { label: 'Visits', color: 'var(--wr-color-primary)', value: '1,204' },\n * { label: 'Signups', color: 'var(--wr-color-success)', value: '86' }\n * ]\"\n * ></ul>\n *\n * <ul wr-chart-legend toggleable [items]=\"series\" [(hiddenSeries)]=\"hidden\"></ul>\n * ```\n *\n * @see https://ngwr.dev/charts/chart-legend\n */\n@Component({\n selector: 'ul[wr-chart-legend]',\n templateUrl: './chart-legend.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-chart-legend',\n // Written out because `list-style: none` (styles/_index.scss) drops the implicit\n // list semantics in Safari, and with them the list's `aria-label`.\n role: 'list',\n '[class.wr-chart-legend--toggleable]': 'toggleable()',\n '[class.wr-chart-legend--top]': \"position() === 'top'\",\n '[class.wr-chart-legend--bottom]': \"position() === 'bottom'\",\n '[class.wr-chart-legend--start]': \"position() === 'start'\",\n '[class.wr-chart-legend--end]': \"position() === 'end'\",\n '[class.wr-chart-legend--none]': \"position() === 'none'\",\n '[attr.aria-label]': 'label()',\n },\n imports: [NgTemplateOutlet, WrChartLegendPart],\n})\nexport class WrChartLegend {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/chart-legend');\n }\n\n /** One row per series, in the chart's order. */\n readonly items = input<readonly WrChartLegendItem[]>([]);\n\n /**\n * Where the legend sits beside its chart. `top` and `bottom` lay the rows out in a\n * wrapping line, `start` and `end` in a column, and `none` draws nothing - the\n * list stays in the DOM, hidden, so `hiddenSeries` keeps working from outside.\n * @default 'bottom'\n */\n readonly position = input<WrChartLegendPosition>('bottom');\n\n /**\n * Make each row a toggle button that shows and hides its series, through\n * `hiddenSeries` and `toggled`. @default false\n */\n readonly toggleable = input(false, { transform: coerceBooleanProperty });\n\n /**\n * The positions in `items` of the series that are hidden, ascending. Positions\n * rather than labels: two series may share a label, and a label translated into\n * another language would no longer match the one it hid. A position past the end\n * of `items` is kept and ignored, so a series coming back finds its state.\n *\n * Written by a click on a `toggleable` row; read in either mode, so a legend that\n * does not toggle still shows a series hidden from elsewhere as hidden.\n */\n readonly hiddenSeries = model<readonly number[]>([]);\n\n /**\n * Accessible name of the list. A `toggleable` legend falls back to\n * `chartLegend.toggleLabel` (\"Toggle series visibility\"), which tells a reader\n * what its buttons do; one that does not toggle has no name unless given one.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /** Emits when a reader shows or hides a series from a `toggleable` legend, after `hiddenSeries` moves. */\n readonly toggled = output<WrChartLegendToggle>();\n\n private readonly toggleLabel = useI18nText(this.ariaLabel, 'chartLegend.toggleLabel', 'Toggle series visibility');\n\n /**\n * The word a hidden row of a legend that does not toggle carries after its name,\n * visually hidden: the strike-through and the faded key are the eye's half of the\n * state, and a toggle row's `aria-pressed` is the other half there. Falls back to\n * `chartLegend.hidden`, then `'hidden'`.\n */\n readonly hiddenLabel = input<string | null>(null);\n\n protected readonly resolvedHiddenLabel = useI18nText(this.hiddenLabel, 'chartLegend.hidden', 'hidden');\n\n protected readonly label = computed(() => (this.ariaLabel() || this.toggleable() ? this.toggleLabel() : null));\n\n private readonly block = inject(WR_CHART_LEGEND_BLOCK, { optional: true, host: true });\n\n private readonly hidden = computed(() => new Set(this.hiddenSeries()));\n\n /** Whether the series at `index` is hidden. */\n protected isHidden(index: number): boolean {\n return this.hidden().has(index);\n }\n\n /**\n * The host chart's own class for each part of a row, or nothing outside a chart. Fixed\n * for the legend's life, so they are written once: asked for in the template, each was\n * built again for every part of every row on every pass over the chart, which a chart\n * makes whenever its own view is checked.\n */\n protected readonly parts = {\n item: this.block ? `${this.block}__legend-item` : '',\n swatch: this.block ? `${this.block}__swatch` : '',\n label: this.block ? `${this.block}__legend-label` : '',\n value: this.block ? `${this.block}__legend-value` : '',\n };\n\n /**\n * The rows as drawn, one per item: which key each draws and its marker's path, built\n * when `items` changes rather than on every pass. A path is a string of a dozen\n * numbers, and fifty series built fifty of them for every hover of their chart.\n */\n protected readonly rows = computed<readonly Row[]>(() =>\n this.items().map(item => {\n const marker = item.marker ?? null;\n const key: Key = item.dash !== undefined ? 'line' : marker ? 'marker' : 'dot';\n return {\n label: item.label,\n color: item.color,\n key,\n // `''` is a solid line: no dash to write.\n dash: item.dash === undefined || item.dash === '' ? null : item.dash,\n marker,\n path: marker ? wrChartMarkerPath(marker, key === 'line' ? LINE_MARKER_RADIUS : MARKER_RADIUS) : null,\n value: item.value ?? null,\n };\n })\n );\n\n /** Shows or hides the series at `index`, then says so. */\n protected toggle(index: number): void {\n const current = this.hiddenSeries();\n const hide = !current.includes(index);\n this.hiddenSeries.set(hide ? [...current, index].sort((a, b) => a - b) : current.filter(i => i !== index));\n this.toggled.emit({ index, label: this.items()[index]?.label ?? '', hidden: hide });\n }\n}\n\nexport type { WrChartLegendItem, WrChartLegendPosition, WrChartLegendToggle, WrChartMarker } from './types';\n","@for (row of rows(); track $index) {\n <li\n class=\"wr-chart-legend__item\"\n [class.wr-chart-legend__item--hidden]=\"isHidden($index)\"\n [attr.data-wr-series]=\"$index\"\n [wrChartLegendPart]=\"parts.item\"\n >\n @if (toggleable()) {\n <!-- Pressed means SHOWN: the button's name is the series, and pressing it turns\n that series on. The name never changes with the state, as the toggle-button\n pattern requires; the state is `aria-pressed` and the struck-through label. -->\n <button\n type=\"button\"\n class=\"wr-chart-legend__toggle\"\n [attr.aria-pressed]=\"!isHidden($index)\"\n (click)=\"toggle($index)\"\n >\n <ng-container [ngTemplateOutlet]=\"key\" [ngTemplateOutletContext]=\"{ $implicit: row, index: $index }\" />\n </button>\n } @else {\n <ng-container [ngTemplateOutlet]=\"key\" [ngTemplateOutletContext]=\"{ $implicit: row, index: $index }\" />\n }\n </li>\n}\n\n<!-- Every binding here reads the row the component built from its item, never the item:\n which key to draw and the marker's path are worked out once, when `items` changes. -->\n<ng-template #key let-row let-index=\"index\">\n @switch (row.key) {\n @case ('line') {\n <!-- The key draws the series' own dash, not a solid block. A legend that pairs a\n coloured square with a name leaves the reader to match the square to the LINE,\n and matching by colour is the step the patterns exist to remove. -->\n <svg\n class=\"wr-chart-legend__swatch wr-chart-legend__swatch--line\"\n [wrChartLegendPart]=\"parts.swatch\"\n viewBox=\"0 0 16 2\"\n aria-hidden=\"true\"\n [attr.data-marker]=\"row.marker\"\n >\n <line\n x1=\"0\"\n y1=\"1\"\n x2=\"16\"\n y2=\"1\"\n [attr.stroke]=\"row.color\"\n [attr.stroke-dasharray]=\"row.dash\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n />\n @if (row.path) {\n <path [attr.d]=\"row.path\" transform=\"translate(8 1)\" [attr.fill]=\"row.color\" />\n }\n </svg>\n }\n @case ('marker') {\n <svg\n class=\"wr-chart-legend__swatch wr-chart-legend__swatch--marker\"\n [wrChartLegendPart]=\"parts.swatch\"\n viewBox=\"-6 -6 12 12\"\n aria-hidden=\"true\"\n [attr.data-marker]=\"row.marker\"\n >\n <path [attr.d]=\"row.path\" [attr.fill]=\"row.color\" />\n </svg>\n }\n @default {\n <span\n class=\"wr-chart-legend__swatch wr-chart-legend__swatch--dot\"\n [wrChartLegendPart]=\"parts.swatch\"\n aria-hidden=\"true\"\n [style.background]=\"row.color\"\n ></span>\n }\n }\n <span class=\"wr-chart-legend__label\" [wrChartLegendPart]=\"parts.label\">{{ row.label }}</span>\n @if (!toggleable() && isHidden(index)) {\n <!-- A toggle says hidden through aria-pressed. A row that is not one has nothing but\n the strike-through and the faded key, which reach no one who cannot see them. -->\n <span class=\"wr-chart-legend__sr-only\"> {{ resolvedHiddenLabel() }} </span>\n }\n @if (row.value !== null) {\n <span class=\"wr-chart-legend__value\" [wrChartLegendPart]=\"parts.value\">{{ row.value }}</span>\n }\n</ng-template>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrChartLegendPart } from './internal/chart-legend-part';\nimport type { WrChartLegendPosition } from './types';\n\n/**\n * The key of a colour scale: its steps side by side, lowest first, between the labels of\n * its two ends. What a heatmap and a calendar heatmap draw where a categorical chart\n * draws `ul[wr-chart-legend]`, and it stands on its own for a key several charts share.\n *\n * Not a mode of the legend: a legend is a list of series, each a row a reader can name,\n * hover and toggle, and a scale is one ramp with two ends and no rows. It lives beside\n * the legend because it takes the legend's place: the same `position`, the same room\n * from its chart (`--wr-chart-legend-space`), the same type.\n *\n * Each step is painted by an inline background, any CSS colour, so a chart hands over the\n * paints it draws its own cells with. Whatever the chart projects into it follows the\n * ramp: a heatmap adds the key of an empty cell there.\n *\n * `block` adds the host chart's own classes to the parts, as `WR_CHART_LEGEND_BLOCK`\n * does for a legend: `<block>__legend-label`, `<block>__scale` and `<block>__swatch`,\n * the classes the heatmap drew its key with before it drew it through this.\n *\n * It announces nothing of its own: where the figures it keys are in text elsewhere, as a\n * chart's are in its data table, hide it with `aria-hidden`.\n *\n * @example\n * ```html\n * <wr-chart-scale aria-hidden=\"true\" minLabel=\"0\" maxLabel=\"120\" [steps]=\"paints\" />\n * ```\n *\n * @see https://ngwr.dev/charts/chart-legend\n */\n@Component({\n selector: 'wr-chart-scale',\n templateUrl: './chart-scale.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-chart-scale',\n '[class.wr-chart-scale--top]': \"position() === 'top'\",\n '[class.wr-chart-scale--bottom]': \"position() === 'bottom'\",\n '[class.wr-chart-scale--start]': \"position() === 'start'\",\n '[class.wr-chart-scale--end]': \"position() === 'end'\",\n '[class.wr-chart-scale--none]': \"position() === 'none'\",\n },\n imports: [WrChartLegendPart],\n})\nexport class WrChartScale {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/chart-legend');\n }\n\n /** The paint of each step, lowest first: any CSS colour, `var(--wr-…)` included. */\n readonly steps = input<readonly string[]>([]);\n\n /** What the lowest step stands for, written before the ramp. `null` writes nothing. */\n readonly minLabel = input<string | null>(null);\n\n /** What the highest step stands for, written after the ramp. `null` writes nothing. */\n readonly maxLabel = input<string | null>(null);\n\n /**\n * Where the key sits beside its chart, as a legend's `position`: it picks the margin\n * that keeps it off the chart, and `none` draws nothing. @default 'bottom'\n */\n readonly position = input<WrChartLegendPosition>('bottom');\n\n /** The host chart's block, for its own class on each part. `null` adds none. */\n readonly block = input<string | null>(null);\n\n /** The host chart's own class for each part, or nothing outside a chart. */\n protected readonly parts = computed(() => {\n const block = this.block();\n return {\n label: block ? `${block}__legend-label` : '',\n ramp: block ? `${block}__scale` : '',\n step: block ? `${block}__swatch` : '',\n };\n });\n}\n","@let part = parts();\n@if (minLabel() !== null) {\n <span class=\"wr-chart-scale__label\" [wrChartLegendPart]=\"part.label\">{{ minLabel() }}</span>\n}\n@if (steps().length > 0) {\n <span class=\"wr-chart-scale__ramp\" [wrChartLegendPart]=\"part.ramp\">\n @for (step of steps(); track $index) {\n <span class=\"wr-chart-scale__step\" [wrChartLegendPart]=\"part.step\" [style.background]=\"step\"></span>\n }\n </span>\n}\n@if (maxLabel() !== null) {\n <span class=\"wr-chart-scale__label\" [wrChartLegendPart]=\"part.label\">{{ maxLabel() }}</span>\n}\n<!-- What the chart keys beside the ramp: a heatmap's empty cell. -->\n<ng-content />\n"],"mappings":";;;;;;;;;;;;;AA0BA,IAAa,oBAAb,MAAa,kBAAiB;CAC5B,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,qBAAqB;CACxF;CAGS,oBAAoB,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,oBAAA,CAAA,+BAAA,CAAA,CAAA;CAN3B,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAiB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAjB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAiB,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,mBAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,MAAA,EAAA,YAAA,EAAA,SAAA,sBAAA,EAAA;EAAA,UAAA;CAAA,CAAA;;AAAjB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- import { Component, LOCALE_ID, ViewEncapsulation, computed, inject, input } from "@angular/core";
2
+ import { Component, DestroyRef, ElementRef, LOCALE_ID, ViewEncapsulation, afterNextRender, afterRenderEffect, computed, inject, input, signal } from "@angular/core";
3
3
  import { wrClamp, wrRound } from "ngwr/utils";
4
+ import { useI18nText } from "ngwr/i18n";
4
5
  /**
5
6
  * @license
6
7
  *
@@ -92,6 +93,118 @@ function wrChartAxis(min, max, options = {}) {
92
93
  * Use of this source code is governed by an MIT-style license that can be
93
94
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
94
95
  */
96
+ function useChartState(options) {
97
+ const loading = useI18nText(options.loadingLabel, "chart.loading", "Loading…");
98
+ const error = useI18nText(options.errorLabel, "chart.error", "Could not load");
99
+ const empty = useI18nText(options.emptyLabel, "chart.empty", "No data");
100
+ return computed(() => {
101
+ if (options.loading()) return {
102
+ kind: "loading",
103
+ label: loading()
104
+ };
105
+ if (options.error()) return {
106
+ kind: "error",
107
+ label: error()
108
+ };
109
+ if (options.empty()) return {
110
+ kind: "empty",
111
+ label: empty()
112
+ };
113
+ return null;
114
+ });
115
+ }
116
+ var WrChartState = class WrChartState {
117
+ kind = input.required(...ngDevMode ? [{ debugName: "kind" }] : /* istanbul ignore next */ []);
118
+ label = input.required(...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
119
+ static ɵfac = i0.ɵɵngDeclareFactory({
120
+ minVersion: "12.0.0",
121
+ version: "22.2.6",
122
+ ngImport: i0,
123
+ type: WrChartState,
124
+ deps: [],
125
+ target: i0.ɵɵFactoryTarget.Component
126
+ });
127
+ static ɵcmp = i0.ɵɵngDeclareComponent({
128
+ minVersion: "17.0.0",
129
+ version: "22.2.6",
130
+ type: WrChartState,
131
+ isStandalone: true,
132
+ selector: "wr-chart-state",
133
+ inputs: {
134
+ kind: {
135
+ classPropertyName: "kind",
136
+ publicName: "kind",
137
+ isSignal: true,
138
+ isRequired: true,
139
+ transformFunction: null
140
+ },
141
+ label: {
142
+ classPropertyName: "label",
143
+ publicName: "label",
144
+ isSignal: true,
145
+ isRequired: true,
146
+ transformFunction: null
147
+ }
148
+ },
149
+ host: {
150
+ properties: {
151
+ "class.wr-chart-state--empty": "kind() === 'empty'",
152
+ "class.wr-chart-state--loading": "kind() === 'loading'",
153
+ "class.wr-chart-state--error": "kind() === 'error'",
154
+ "attr.role": "kind() === 'error' ? 'alert' : 'status'"
155
+ },
156
+ classAttribute: "wr-chart-state"
157
+ },
158
+ ngImport: i0,
159
+ template: "<span class=\"wr-chart-state__plate\">\n @if (kind() === 'loading') {\n <!-- Decoration: the word beside it carries the state. -->\n <span class=\"wr-chart-state__spinner\" aria-hidden=\"true\"></span>\n }\n <span class=\"wr-chart-state__label\">{{ label() }}</span>\n</span>\n",
160
+ encapsulation: i0.ViewEncapsulation.None
161
+ });
162
+ };
163
+ i0.ɵɵngDeclareClassMetadata({
164
+ minVersion: "12.0.0",
165
+ version: "22.2.6",
166
+ ngImport: i0,
167
+ type: WrChartState,
168
+ decorators: [{
169
+ type: Component,
170
+ args: [{
171
+ selector: "wr-chart-state",
172
+ encapsulation: ViewEncapsulation.None,
173
+ host: {
174
+ class: "wr-chart-state",
175
+ "[class.wr-chart-state--empty]": "kind() === 'empty'",
176
+ "[class.wr-chart-state--loading]": "kind() === 'loading'",
177
+ "[class.wr-chart-state--error]": "kind() === 'error'",
178
+ "[attr.role]": "kind() === 'error' ? 'alert' : 'status'"
179
+ },
180
+ template: "<span class=\"wr-chart-state__plate\">\n @if (kind() === 'loading') {\n <!-- Decoration: the word beside it carries the state. -->\n <span class=\"wr-chart-state__spinner\" aria-hidden=\"true\"></span>\n }\n <span class=\"wr-chart-state__label\">{{ label() }}</span>\n</span>\n"
181
+ }]
182
+ }],
183
+ propDecorators: {
184
+ kind: [{
185
+ type: i0.Input,
186
+ args: [{
187
+ isSignal: true,
188
+ alias: "kind",
189
+ required: true
190
+ }]
191
+ }],
192
+ label: [{
193
+ type: i0.Input,
194
+ args: [{
195
+ isSignal: true,
196
+ alias: "label",
197
+ required: true
198
+ }]
199
+ }]
200
+ }
201
+ });
202
+ /**
203
+ * @license
204
+ *
205
+ * Use of this source code is governed by an MIT-style license that can be
206
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
207
+ */
95
208
  var WrChartTable = class WrChartTable {
96
209
  data = input.required(...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
97
210
  hasGroupHeaders = computed(() => this.data().groups.some((group) => !!group.header), ...ngDevMode ? [{ debugName: "hasGroupHeaders" }] : /* istanbul ignore next */ []);
@@ -151,15 +264,171 @@ i0.ɵɵngDeclareClassMetadata({
151
264
  * Use of this source code is governed by an MIT-style license that can be
152
265
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
153
266
  */
267
+ const UNMEASURED = {
268
+ width: 0,
269
+ height: 0
270
+ };
271
+ const listeners = /* @__PURE__ */ new WeakMap();
272
+ const litMarks = /* @__PURE__ */ new WeakMap();
273
+ let observer = null;
274
+ let observerType = null;
275
+ function wrChartObserveSize(element, listener) {
276
+ if (typeof ResizeObserver === "undefined") return () => void 0;
277
+ if (!observer || observerType !== ResizeObserver) {
278
+ observerType = ResizeObserver;
279
+ observer = new ResizeObserver((entries) => {
280
+ for (const entry of entries) {
281
+ const { width, height } = entry.contentRect;
282
+ listeners.get(entry.target)?.({
283
+ width,
284
+ height
285
+ });
286
+ }
287
+ });
288
+ }
289
+ const shared = observer;
290
+ listeners.set(element, listener);
291
+ shared.observe(element);
292
+ return () => {
293
+ listeners.delete(element);
294
+ shared.unobserve(element);
295
+ };
296
+ }
297
+ function useChartSize(target) {
298
+ const size = signal(UNMEASURED, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
299
+ let stop = null;
300
+ let observed = null;
301
+ afterRenderEffect(() => {
302
+ const held = target();
303
+ const element = held instanceof ElementRef ? held.nativeElement : held ?? null;
304
+ if (element === observed) return;
305
+ stop?.();
306
+ observed = element;
307
+ stop = null;
308
+ if (!element) {
309
+ size.set(UNMEASURED);
310
+ return;
311
+ }
312
+ stop = wrChartObserveSize(element, (next) => {
313
+ const current = size();
314
+ if (current.width !== next.width || current.height !== next.height) size.set(next);
315
+ });
316
+ });
317
+ inject(DestroyRef).onDestroy(() => stop?.());
318
+ return size.asReadonly();
319
+ }
320
+ function wrChartDim(host, key) {
321
+ for (const mark of litMarks.get(host) ?? []) mark.classList.remove("wr-chart-mark--on");
322
+ host.classList.toggle("wr-chart--dim", key !== null);
323
+ if (key === null) {
324
+ litMarks.delete(host);
325
+ return;
326
+ }
327
+ const marks = [...host.querySelectorAll(`[data-wr-series="${CSS.escape(key)}"]`)];
328
+ for (const mark of marks) mark.classList.add("wr-chart-mark--on");
329
+ litMarks.set(host, marks);
330
+ }
331
+ function useChartHover(handlers) {
332
+ const host = inject(ElementRef).nativeElement;
333
+ const destroyRef = inject(DestroyRef);
334
+ let index = null;
335
+ let series = null;
336
+ const dim = (key) => {
337
+ if (key === series) return;
338
+ series = key;
339
+ wrChartDim(host, key);
340
+ };
341
+ let current = null;
342
+ const band = (section) => {
343
+ current?.classList.remove("wr-chart-section--on");
344
+ current = section?.closest("[data-wr-hold]") ? section : null;
345
+ current?.classList.add("wr-chart-section--on");
346
+ };
347
+ const inHost = (el) => !!el && host.contains(el);
348
+ const over = (event) => {
349
+ const target = event.target instanceof Element ? event.target : null;
350
+ const section = target?.closest("[data-wr-index]");
351
+ const series = target?.closest("[data-wr-series]");
352
+ const held = !inHost(series) && inHost(target?.closest("[data-wr-hold]"));
353
+ if (!held) dim(inHost(series) ? series.getAttribute("data-wr-series") : null);
354
+ if (held && !inHost(section)) return;
355
+ const next = inHost(section) ? Number(section.getAttribute("data-wr-index")) : null;
356
+ if (next === index) return;
357
+ index = next;
358
+ if (next === null || !Number.isFinite(next)) {
359
+ band(null);
360
+ handlers.leave(event);
361
+ } else {
362
+ band(section ?? null);
363
+ handlers.enter(next);
364
+ }
365
+ };
366
+ const leave = (event) => {
367
+ dim(null);
368
+ if (index === null) return;
369
+ index = null;
370
+ band(null);
371
+ handlers.leave(event);
372
+ };
373
+ afterNextRender(() => {
374
+ host.addEventListener("mouseover", over);
375
+ host.addEventListener("mouseleave", leave);
376
+ destroyRef.onDestroy(() => {
377
+ host.removeEventListener("mouseover", over);
378
+ host.removeEventListener("mouseleave", leave);
379
+ });
380
+ });
381
+ }
382
+ /**
383
+ * @license
384
+ *
385
+ * Use of this source code is governed by an MIT-style license that can be
386
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
387
+ */
388
+ function wrChartLongest(labels, limit = 3) {
389
+ const longest = [];
390
+ for (const label of new Set(labels)) {
391
+ if (longest.length === limit && label.length <= longest[longest.length - 1].length) continue;
392
+ let at = longest.findIndex((kept) => kept.length < label.length);
393
+ if (at < 0) at = longest.length;
394
+ longest.splice(at, 0, label);
395
+ if (longest.length > limit) longest.pop();
396
+ }
397
+ return longest;
398
+ }
399
+ function wrChartLabelStep(count, extent, labelSize, gap = 8) {
400
+ if (!(count > 1) || !(extent > 0) || !(labelSize > 0)) return 1;
401
+ const band = extent / count;
402
+ return Math.max(1, Math.min(count, Math.ceil((labelSize + gap) / band)));
403
+ }
404
+ /**
405
+ * @license
406
+ *
407
+ * Use of this source code is governed by an MIT-style license that can be
408
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
409
+ */
154
410
  const WR_CHART_PALETTE = [
411
+ "var(--wr-chart-1)",
412
+ "var(--wr-chart-2)",
413
+ "var(--wr-chart-3)",
414
+ "var(--wr-chart-4)",
415
+ "var(--wr-chart-5)",
416
+ "var(--wr-chart-6)",
417
+ "var(--wr-chart-7)",
418
+ "var(--wr-chart-8)"
419
+ ];
420
+ function wrChartColor(index) {
421
+ return WR_CHART_PALETTE[wrap(index, WR_CHART_PALETTE.length)];
422
+ }
423
+ const WR_CHART_LEGACY_PALETTE = [
155
424
  "var(--wr-color-primary)",
156
425
  "var(--wr-color-success)",
157
426
  "var(--wr-color-warning)",
158
427
  "var(--wr-color-danger)",
159
428
  "var(--wr-color-on-surface-muted)"
160
429
  ];
161
- function wrChartColor(index) {
162
- return WR_CHART_PALETTE[wrap(index, WR_CHART_PALETTE.length)];
430
+ function wrChartLegacyColor(index) {
431
+ return WR_CHART_LEGACY_PALETTE[wrap(index, WR_CHART_LEGACY_PALETTE.length)];
163
432
  }
164
433
  const WR_CHART_DASHES = [
165
434
  "",
@@ -325,10 +594,20 @@ function lastDigit(step) {
325
594
  }
326
595
  return -21;
327
596
  }
597
+ const FORMATTERS = /* @__PURE__ */ new Map();
598
+ function wrChartNumberFormat(locale, options) {
599
+ const key = options ? `${locale}|${JSON.stringify(options)}` : locale;
600
+ let format = FORMATTERS.get(key);
601
+ if (!format) {
602
+ format = new Intl.NumberFormat(locale, options);
603
+ FORMATTERS.set(key, format);
604
+ }
605
+ return format;
606
+ }
328
607
  function useChartNumbers(valueFormat, locale = inject(LOCALE_ID)) {
329
- const numbers = new Intl.NumberFormat(locale);
330
- const smallNumbers = new Intl.NumberFormat(locale, { maximumSignificantDigits: 3 });
331
- const compactNumbers = new Intl.NumberFormat(locale, { notation: "compact" });
608
+ const numbers = wrChartNumberFormat(locale);
609
+ const smallNumbers = wrChartNumberFormat(locale, { maximumSignificantDigits: 3 });
610
+ const compactNumbers = wrChartNumberFormat(locale, { notation: "compact" });
332
611
  const value = (v, ...args) => {
333
612
  const custom = valueFormat();
334
613
  if (custom) return custom(v, ...args);
@@ -343,27 +622,19 @@ function useChartNumbers(valueFormat, locale = inject(LOCALE_ID)) {
343
622
  if (custom) return values.map((v) => custom(v, ...args));
344
623
  if (values.length === 0) return [];
345
624
  const last = lastDigit(step);
346
- const digits = last <= -21 ? fractionDigits(step) : wrClamp(-last, 0, 20);
347
- const full = new Intl.NumberFormat(locale, { maximumFractionDigits: digits });
625
+ const full = wrChartNumberFormat(locale, { maximumFractionDigits: last <= -21 ? fractionDigits(step) : wrClamp(-last, 0, 20) });
348
626
  const plain = values.map((v) => full.format(v));
349
- const compact = values.map((v) => v === 0 ? full.format(0) : new Intl.NumberFormat(locale, {
627
+ const compact = values.map((v) => v === 0 ? full.format(0) : wrChartNumberFormat(locale, {
350
628
  notation: "compact",
351
629
  maximumSignificantDigits: wrClamp(magnitude(v) - last + 1, 1, 21)
352
630
  }).format(v));
353
631
  const longest = (labels) => Math.max(...labels.map((text) => text.length));
354
632
  return longest(compact) <= longest(plain) ? compact : plain;
355
633
  };
356
- const exactNumbers = /* @__PURE__ */ new Map();
357
634
  const exact = (v, fractionDigits, ...args) => {
358
635
  const custom = valueFormat();
359
636
  if (custom) return custom(v, ...args);
360
- const digits = Number.isFinite(fractionDigits) ? wrClamp(Math.round(fractionDigits), 0, 20) : 3;
361
- let writer = exactNumbers.get(digits);
362
- if (!writer) {
363
- writer = new Intl.NumberFormat(locale, { maximumFractionDigits: digits });
364
- exactNumbers.set(digits, writer);
365
- }
366
- return writer.format(v);
637
+ return wrChartNumberFormat(locale, { maximumFractionDigits: Number.isFinite(fractionDigits) ? wrClamp(Math.round(fractionDigits), 0, 20) : 3 }).format(v);
367
638
  };
368
639
  return {
369
640
  value,
@@ -378,6 +649,16 @@ function useChartNumbers(valueFormat, locale = inject(LOCALE_ID)) {
378
649
  * Use of this source code is governed by an MIT-style license that can be
379
650
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
380
651
  */
381
- export { WR_CHART_DASHES, WR_CHART_MARKERS, WR_CHART_PALETTE, WrChartTable, useChartNumbers, wrChartAxis, wrChartColor, wrChartDash, wrChartMarker, wrChartMarkerExtent, wrChartMarkerPath };
652
+ function wrChartRound(value, digits = 4) {
653
+ const factor = 10 ** digits;
654
+ return Math.round(value * factor) / factor || 0;
655
+ }
656
+ /**
657
+ * @license
658
+ *
659
+ * Use of this source code is governed by an MIT-style license that can be
660
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
661
+ */
662
+ export { WR_CHART_DASHES, WR_CHART_LEGACY_PALETTE, WR_CHART_MARKERS, WR_CHART_PALETTE, WrChartState, WrChartTable, useChartHover, useChartNumbers, useChartSize, useChartState, wrChartAxis, wrChartColor, wrChartDash, wrChartDim, wrChartLabelStep, wrChartLegacyColor, wrChartLongest, wrChartMarker, wrChartMarkerExtent, wrChartMarkerPath, wrChartNumberFormat, wrChartObserveSize, wrChartRound };
382
663
 
383
664
  //# sourceMappingURL=ngwr-charts-core.mjs.map