@vielzeug/prism 2.1.0 → 2.1.2

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 (99) hide show
  1. package/dist/animation/easing.cjs.map +1 -1
  2. package/dist/animation/easing.js.map +1 -1
  3. package/dist/animation/index.d.ts +2 -2
  4. package/dist/animation/index.d.ts.map +1 -1
  5. package/dist/axes/axis.cjs.map +1 -1
  6. package/dist/axes/axis.d.ts.map +1 -1
  7. package/dist/axes/axis.js.map +1 -1
  8. package/dist/axes/grid.cjs.map +1 -1
  9. package/dist/axes/grid.d.ts.map +1 -1
  10. package/dist/axes/grid.js.map +1 -1
  11. package/dist/charts/area/area-chart.cjs.map +1 -1
  12. package/dist/charts/area/area-chart.d.ts.map +1 -1
  13. package/dist/charts/area/area-chart.js.map +1 -1
  14. package/dist/charts/area/area-renderer.cjs +1 -1
  15. package/dist/charts/area/area-renderer.cjs.map +1 -1
  16. package/dist/charts/area/area-renderer.d.ts.map +1 -1
  17. package/dist/charts/area/area-renderer.js +14 -14
  18. package/dist/charts/area/area-renderer.js.map +1 -1
  19. package/dist/charts/bar/bar-chart.cjs.map +1 -1
  20. package/dist/charts/bar/bar-chart.d.ts.map +1 -1
  21. package/dist/charts/bar/bar-chart.js.map +1 -1
  22. package/dist/charts/bar/bar-renderer.cjs +1 -1
  23. package/dist/charts/bar/bar-renderer.cjs.map +1 -1
  24. package/dist/charts/bar/bar-renderer.d.ts.map +1 -1
  25. package/dist/charts/bar/bar-renderer.js +24 -24
  26. package/dist/charts/bar/bar-renderer.js.map +1 -1
  27. package/dist/charts/line/line-chart.cjs.map +1 -1
  28. package/dist/charts/line/line-chart.d.ts.map +1 -1
  29. package/dist/charts/line/line-chart.js.map +1 -1
  30. package/dist/charts/line/line-renderer.cjs +1 -1
  31. package/dist/charts/line/line-renderer.cjs.map +1 -1
  32. package/dist/charts/line/line-renderer.d.ts.map +1 -1
  33. package/dist/charts/line/line-renderer.js +34 -34
  34. package/dist/charts/line/line-renderer.js.map +1 -1
  35. package/dist/charts/pie/pie-chart.cjs +1 -1
  36. package/dist/charts/pie/pie-chart.cjs.map +1 -1
  37. package/dist/charts/pie/pie-chart.d.ts.map +1 -1
  38. package/dist/charts/pie/pie-chart.js +34 -34
  39. package/dist/charts/pie/pie-chart.js.map +1 -1
  40. package/dist/charts/sparkline/sparkline.cjs +1 -1
  41. package/dist/charts/sparkline/sparkline.cjs.map +1 -1
  42. package/dist/charts/sparkline/sparkline.d.ts.map +1 -1
  43. package/dist/charts/sparkline/sparkline.js +64 -64
  44. package/dist/charts/sparkline/sparkline.js.map +1 -1
  45. package/dist/core/cartesian-model.cjs.map +1 -1
  46. package/dist/core/cartesian-model.d.ts.map +1 -1
  47. package/dist/core/cartesian-model.js.map +1 -1
  48. package/dist/core/cartesian-scales.cjs.map +1 -1
  49. package/dist/core/cartesian-scales.d.ts.map +1 -1
  50. package/dist/core/cartesian-scales.js.map +1 -1
  51. package/dist/core/chart-base.cjs +1 -1
  52. package/dist/core/chart-base.cjs.map +1 -1
  53. package/dist/core/chart-base.d.ts +1 -1
  54. package/dist/core/chart-base.d.ts.map +1 -1
  55. package/dist/core/chart-base.js +12 -12
  56. package/dist/core/chart-base.js.map +1 -1
  57. package/dist/core/chart-scaffold.cjs.map +1 -1
  58. package/dist/core/chart-scaffold.d.ts +2 -2
  59. package/dist/core/chart-scaffold.d.ts.map +1 -1
  60. package/dist/core/chart-scaffold.js.map +1 -1
  61. package/dist/core/index.d.ts +2 -2
  62. package/dist/core/index.d.ts.map +1 -1
  63. package/dist/index.cjs +1 -1
  64. package/dist/index.d.ts +7 -7
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +8 -8
  67. package/dist/interaction/crosshair.cjs.map +1 -1
  68. package/dist/interaction/crosshair.d.ts +2 -2
  69. package/dist/interaction/crosshair.d.ts.map +1 -1
  70. package/dist/interaction/crosshair.js.map +1 -1
  71. package/dist/interaction/index.d.ts +3 -3
  72. package/dist/interaction/index.d.ts.map +1 -1
  73. package/dist/interaction/legend.cjs.map +1 -1
  74. package/dist/interaction/legend.d.ts +1 -1
  75. package/dist/interaction/legend.d.ts.map +1 -1
  76. package/dist/interaction/legend.js.map +1 -1
  77. package/dist/interaction/series-interaction.cjs.map +1 -1
  78. package/dist/interaction/series-interaction.d.ts.map +1 -1
  79. package/dist/interaction/series-interaction.js.map +1 -1
  80. package/dist/interaction/tooltip.cjs.map +1 -1
  81. package/dist/interaction/tooltip.d.ts +1 -1
  82. package/dist/interaction/tooltip.d.ts.map +1 -1
  83. package/dist/interaction/tooltip.js.map +1 -1
  84. package/dist/prism.cjs +1 -1
  85. package/dist/prism.cjs.map +1 -1
  86. package/dist/prism.iife.js +1 -1
  87. package/dist/prism.iife.js.map +1 -1
  88. package/dist/prism.js +1 -1
  89. package/dist/prism.js.map +1 -1
  90. package/dist/scales/band.cjs.map +1 -1
  91. package/dist/scales/band.d.ts.map +1 -1
  92. package/dist/scales/band.js.map +1 -1
  93. package/dist/scales/linear.cjs.map +1 -1
  94. package/dist/scales/linear.js.map +1 -1
  95. package/dist/svg/index.d.ts +1 -1
  96. package/dist/svg/index.d.ts.map +1 -1
  97. package/dist/svg/text.cjs.map +1 -1
  98. package/dist/svg/text.js.map +1 -1
  99. package/package.json +32 -32
@@ -1 +1 @@
1
- {"version":3,"file":"cartesian-model.d.ts","sourceRoot":"","sources":["../../src/core/cartesian-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAI9C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACjD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CACpB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,M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AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EACvD,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,IAAI,EAAE,SAAS,CAAC,SAAS,KAAK,EAAE,CAAC,EAAE,GAClC,cAAc,CAAC,CAAC,CAAC,CA0BnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"cartesian-model.js","names":[],"sources":["../../src/core/cartesian-model.ts"],"sourcesContent":["import type { Datum, Series } from '../types';\n\nimport { warn } from '../_dev';\n\nexport type CartesianKey = string;\n\nexport interface CartesianSeries<S extends Series = Series> {\n readonly byKey: ReadonlyMap<CartesianKey, Datum>;\n readonly config: S;\n}\n\nexport interface CartesianModel<S extends Series = Series> {\n readonly domain: CartesianKey[];\n readonly labels: ReadonlyMap<CartesianKey, Datum['key']>;\n readonly series: readonly CartesianSeries<S>[];\n}\n\nexport function keyId(key: Datum['key']): CartesianKey {\n if (key instanceof Date) return `date:${key.getTime()}`;\n\n return `${typeof key}:${String(key)}`;\n}\n\nexport function normalizeCartesianSeries<S extends Series>(\n series: readonly S[],\n data: readonly (readonly Datum[])[],\n): CartesianModel<S> {\n const domain: CartesianKey[] = [];\n const labels = new Map<CartesianKey, Datum['key']>();\n const normalized = series.map((config, seriesIndex) => {\n const byKey = new Map<CartesianKey, Datum>();\n\n for (const datum of data[seriesIndex] ?? []) {\n const id = keyId(datum.key);\n\n if (byKey.has(id)) {\n warn(`Duplicate datum key \"${String(datum.key)}\" in series \"${config.name}\"; keeping the first value.`);\n continue;\n }\n\n byKey.set(id, datum);\n\n if (!labels.has(id)) {\n labels.set(id, datum.key);\n domain.push(id);\n }\n }\n\n return { byKey, config } satisfies CartesianSeries<S>;\n });\n\n return { domain, labels, series: normalized };\n}\n"],"mappings":";;AAiBA,SAAgB,EAAM,GAAiC;CAGrD,OAFI,aAAe,OAAa,QAAQ,EAAI,QAAQ,MAE7C,GAAG,OAAO,EAAI,GAAG,OAAO,CAAG;AACpC;AAEA,SAAgB,EACd,GACA,GACmB;CACnB,IAAM,IAAyB,CAAC,GAC1B,oBAAS,IAAI,IAAgC;CAuBnD,OAAO;EAAE;EAAQ;EAAQ,QAtBN,EAAO,KAAK,GAAQ,MAAgB;GACrD,IAAM,oBAAQ,IAAI,IAAyB;GAE3C,KAAK,IAAM,KAAS,EAAK,MAAgB,CAAC,GAAG;IAC3C,IAAM,IAAK,EAAM,EAAM,GAAG;IAE1B,IAAI,EAAM,IAAI,CAAE,GAAG;KACjB,AAAK,GAAwB,OAAO,EAAM,GAAG,EAAxC,EAAyD,EAAO,KAAhE;KACL;IACF;IAIA,AAFA,EAAM,IAAI,GAAI,CAAK,GAEd,EAAO,IAAI,CAAE,MAChB,EAAO,IAAI,GAAI,EAAM,GAAG,GACxB,EAAO,KAAK,CAAE;GAElB;GAEA,OAAO;IAAE;IAAO;GAAO;EACzB,CAEiC;CAAW;AAC9C"}
1
+ {"version":3,"file":"cartesian-model.js","names":[],"sources":["../../src/core/cartesian-model.ts"],"sourcesContent":["import { warn } from '../_dev';\nimport type { Datum, Series } from '../types';\n\nexport type CartesianKey = string;\n\nexport interface CartesianSeries<S extends Series = Series> {\n readonly byKey: ReadonlyMap<CartesianKey, Datum>;\n readonly config: S;\n}\n\nexport interface CartesianModel<S extends Series = Series> {\n readonly domain: CartesianKey[];\n readonly labels: ReadonlyMap<CartesianKey, Datum['key']>;\n readonly series: readonly CartesianSeries<S>[];\n}\n\nexport function keyId(key: Datum['key']): CartesianKey {\n if (key instanceof Date) return `date:${key.getTime()}`;\n\n return `${typeof key}:${String(key)}`;\n}\n\nexport function normalizeCartesianSeries<S extends Series>(\n series: readonly S[],\n data: readonly (readonly Datum[])[],\n): CartesianModel<S> {\n const domain: CartesianKey[] = [];\n const labels = new Map<CartesianKey, Datum['key']>();\n const normalized = series.map((config, seriesIndex) => {\n const byKey = new Map<CartesianKey, Datum>();\n\n for (const datum of data[seriesIndex] ?? []) {\n const id = keyId(datum.key);\n\n if (byKey.has(id)) {\n warn(`Duplicate datum key \"${String(datum.key)}\" in series \"${config.name}\"; keeping the first value.`);\n continue;\n }\n\n byKey.set(id, datum);\n\n if (!labels.has(id)) {\n labels.set(id, datum.key);\n domain.push(id);\n }\n }\n\n return { byKey, config } satisfies CartesianSeries<S>;\n });\n\n return { domain, labels, series: normalized };\n}\n"],"mappings":";;AAgBA,SAAgB,EAAM,GAAiC;CAGrD,OAFI,aAAe,OAAa,QAAQ,EAAI,QAAQ,MAE7C,GAAG,OAAO,EAAI,GAAG,OAAO,CAAG;AACpC;AAEA,SAAgB,EACd,GACA,GACmB;CACnB,IAAM,IAAyB,CAAC,GAC1B,oBAAS,IAAI,IAAgC;CAuBnD,OAAO;EAAE;EAAQ;EAAQ,QAtBN,EAAO,KAAK,GAAQ,MAAgB;GACrD,IAAM,oBAAQ,IAAI,IAAyB;GAE3C,KAAK,IAAM,KAAS,EAAK,MAAgB,CAAC,GAAG;IAC3C,IAAM,IAAK,EAAM,EAAM,GAAG;IAE1B,IAAI,EAAM,IAAI,CAAE,GAAG;KACjB,AAAK,GAAwB,OAAO,EAAM,GAAG,EAAxC,EAAyD,EAAO,KAAhE;KACL;IACF;IAIA,AAFA,EAAM,IAAI,GAAI,CAAK,GAEd,EAAO,IAAI,CAAE,MAChB,EAAO,IAAI,GAAI,EAAM,GAAG,GACxB,EAAO,KAAK,CAAE;GAElB;GAEA,OAAO;IAAE;IAAO;GAAO;EACzB,CAEiC;CAAW;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"cartesian-scales.cjs","names":[],"sources":["../../src/core/cartesian-scales.ts"],"sourcesContent":["import type { Scale } from '../types';\n\nimport { warn } from '../_dev';\nimport { linearScale } from '../scales/linear';\nimport { timeScale } from '../scales/time';\n\nexport function buildXScale(allX: (Date | number)[], width: number): Scale<Date> | Scale<number> {\n if (allX.length === 0) return linearScale({ domain: [0, 1], range: [0, width] });\n\n if (allX.some((v) => v == null)) {\n warn(\n 'buildXScale: one or more x values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX.some((v) => typeof v === 'number' && !Number.isFinite(v))) {\n warn('buildXScale: one or more x values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX[0] instanceof Date) {\n const dates = allX as Date[];\n const minMs = Math.min(...dates.map(Number));\n const maxMs = Math.max(...dates.map(Number));\n const min = new Date(minMs);\n const max = new Date(minMs === maxMs ? maxMs + 1 : maxMs);\n\n return timeScale({ domain: [min, max], range: [0, width] });\n }\n\n const nums = allX as number[];\n const minN = Math.min(...nums);\n const maxN = Math.max(...nums);\n\n return linearScale({ domain: [minN, minN === maxN ? maxN + 1 : maxN], nice: false, range: [0, width] });\n}\n\nexport function buildYScale(allY: number[], height: number, includeZero = true): Scale<number> {\n if (allY.length === 0) return linearScale({ domain: [0, 1], range: [height, 0] });\n\n if (allY.some((v) => v == null)) {\n warn(\n 'buildYScale: one or more y values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n if (allY.some((v) => !Number.isFinite(v))) {\n warn('buildYScale: one or more y values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n const rawMin = Math.min(...allY);\n const minY = includeZero ? Math.min(0, rawMin) : rawMin;\n const maxY = Math.max(...allY);\n\n return linearScale({ domain: [minY, minY === maxY ? maxY + 1 : maxY], range: [height, 0] });\n}\n"],"mappings":"+FAMA,SAAgB,EAAY,EAAyB,EAA4C,CAW/F,GAVI,EAAK,SAAW,GAEhB,EAAK,KAAM,GAAM,GAAK,IAAI,GAQ1B,EAAK,KAAM,GAAM,OAAO,GAAM,UAAY,CAAC,OAAO,SAAS,CAAC,CAAC,EAG/D,OAAO,EAAA,YAAY,CAAE,OAAQ,CAAC,EAAG,CAAC,EAAG,MAAO,CAAC,EAAG,CAAK,CAAE,CAAC,EAG1D,GAAI,EAAK,aAAc,KAAM,CAC3B,IAAM,EAAQ,EACR,EAAQ,KAAK,IAAI,GAAG,EAAM,IAAI,MAAM,CAAC,EACrC,EAAQ,KAAK,IAAI,GAAG,EAAM,IAAI,MAAM,CAAC,EACrC,EAAM,IAAI,KAAK,CAAK,EACpB,EAAM,IAAI,KAAK,IAAU,EAAQ,EAAQ,EAAI,CAAK,EAExD,OAAO,EAAA,UAAU,CAAE,OAAQ,CAAC,EAAK,CAAG,EAAG,MAAO,CAAC,EAAG,CAAK,CAAE,CAAC,CAC5D,CAEA,IAAM,EAAO,EACP,EAAO,KAAK,IAAI,GAAG,CAAI,EACvB,EAAO,KAAK,IAAI,GAAG,CAAI,EAE7B,OAAO,EAAA,YAAY,CAAE,OAAQ,CAAC,EAAM,IAAS,EAAO,EAAO,EAAI,CAAI,EAAG,KAAM,GAAO,MAAO,CAAC,EAAG,CAAK,CAAE,CAAC,CACxG,CAEA,SAAgB,EAAY,EAAgB,EAAgB,EAAc,GAAqB,CAW7F,GAVI,EAAK,SAAW,GAEhB,EAAK,KAAM,GAAM,GAAK,IAAI,GAQ1B,EAAK,KAAM,GAAM,CAAC,OAAO,SAAS,CAAC,CAAC,EAGtC,OAAO,EAAA,YAAY,CAAE,OAAQ,CAAC,EAAG,CAAC,EAAG,MAAO,CAAC,EAAQ,CAAC,CAAE,CAAC,EAG3D,IAAM,EAAS,KAAK,IAAI,GAAG,CAAI,EACzB,EAAO,EAAc,KAAK,IAAI,EAAG,CAAM,EAAI,EAC3C,EAAO,KAAK,IAAI,GAAG,CAAI,EAE7B,OAAO,EAAA,YAAY,CAAE,OAAQ,CAAC,EAAM,IAAS,EAAO,EAAO,EAAI,CAAI,EAAG,MAAO,CAAC,EAAQ,CAAC,CAAE,CAAC,CAC5F"}
1
+ {"version":3,"file":"cartesian-scales.cjs","names":[],"sources":["../../src/core/cartesian-scales.ts"],"sourcesContent":["import { warn } from '../_dev';\nimport { linearScale } from '../scales/linear';\nimport { timeScale } from '../scales/time';\nimport type { Scale } from '../types';\n\nexport function buildXScale(allX: (Date | number)[], width: number): Scale<Date> | Scale<number> {\n if (allX.length === 0) return linearScale({ domain: [0, 1], range: [0, width] });\n\n if (allX.some((v) => v == null)) {\n warn(\n 'buildXScale: one or more x values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX.some((v) => typeof v === 'number' && !Number.isFinite(v))) {\n warn('buildXScale: one or more x values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX[0] instanceof Date) {\n const dates = allX as Date[];\n const minMs = Math.min(...dates.map(Number));\n const maxMs = Math.max(...dates.map(Number));\n const min = new Date(minMs);\n const max = new Date(minMs === maxMs ? maxMs + 1 : maxMs);\n\n return timeScale({ domain: [min, max], range: [0, width] });\n }\n\n const nums = allX as number[];\n const minN = Math.min(...nums);\n const maxN = Math.max(...nums);\n\n return linearScale({ domain: [minN, minN === maxN ? maxN + 1 : maxN], nice: false, range: [0, width] });\n}\n\nexport function buildYScale(allY: number[], height: number, includeZero = true): Scale<number> {\n if (allY.length === 0) return linearScale({ domain: [0, 1], range: [height, 0] });\n\n if (allY.some((v) => v == null)) {\n warn(\n 'buildYScale: one or more y values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n if (allY.some((v) => !Number.isFinite(v))) {\n warn('buildYScale: one or more y values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n const rawMin = Math.min(...allY);\n const minY = includeZero ? Math.min(0, rawMin) : rawMin;\n const maxY = Math.max(...allY);\n\n return linearScale({ domain: [minY, minY === maxY ? maxY + 1 : maxY], range: [height, 0] });\n}\n"],"mappings":"+FAKA,SAAgB,EAAY,EAAyB,EAA4C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,YAAY,CAAE,OAAQ,CAAC,EAAM,IAAS,EAAO,EAAO,EAAI,CAAI,EAAG,MAAO,CAAC,EAAQ,CAAC,CAAE,CAAC,CAC5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"cartesian-scales.d.ts","sourceRoot":"","sources":["../../src/core/cartesian-scales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAMtC,wBAAgB,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAgC/F;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,UAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAsB7F"}
1
+ {"version":3,"file":"cartesian-scales.d.ts","sourceRoot":"","sources":["../../src/core/cartesian-scales.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,wBAAgB,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAgC/F;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,UAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAsB7F"}
@@ -1 +1 @@
1
- {"version":3,"file":"cartesian-scales.js","names":[],"sources":["../../src/core/cartesian-scales.ts"],"sourcesContent":["import type { Scale } from '../types';\n\nimport { warn } from '../_dev';\nimport { linearScale } from '../scales/linear';\nimport { timeScale } from '../scales/time';\n\nexport function buildXScale(allX: (Date | number)[], width: number): Scale<Date> | Scale<number> {\n if (allX.length === 0) return linearScale({ domain: [0, 1], range: [0, width] });\n\n if (allX.some((v) => v == null)) {\n warn(\n 'buildXScale: one or more x values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX.some((v) => typeof v === 'number' && !Number.isFinite(v))) {\n warn('buildXScale: one or more x values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX[0] instanceof Date) {\n const dates = allX as Date[];\n const minMs = Math.min(...dates.map(Number));\n const maxMs = Math.max(...dates.map(Number));\n const min = new Date(minMs);\n const max = new Date(minMs === maxMs ? maxMs + 1 : maxMs);\n\n return timeScale({ domain: [min, max], range: [0, width] });\n }\n\n const nums = allX as number[];\n const minN = Math.min(...nums);\n const maxN = Math.max(...nums);\n\n return linearScale({ domain: [minN, minN === maxN ? maxN + 1 : maxN], nice: false, range: [0, width] });\n}\n\nexport function buildYScale(allY: number[], height: number, includeZero = true): Scale<number> {\n if (allY.length === 0) return linearScale({ domain: [0, 1], range: [height, 0] });\n\n if (allY.some((v) => v == null)) {\n warn(\n 'buildYScale: one or more y values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n if (allY.some((v) => !Number.isFinite(v))) {\n warn('buildYScale: one or more y values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n const rawMin = Math.min(...allY);\n const minY = includeZero ? Math.min(0, rawMin) : rawMin;\n const maxY = Math.max(...allY);\n\n return linearScale({ domain: [minY, minY === maxY ? maxY + 1 : maxY], range: [height, 0] });\n}\n"],"mappings":";;;;AAMA,SAAgB,EAAY,GAAyB,GAA4C;CAW/F,IAVI,EAAK,WAAW,KAEhB,EAAK,MAAM,MAAM,KAAK,IAAI,KAQ1B,EAAK,MAAM,MAAM,OAAO,KAAM,Y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artesian-scales.js","names":[],"sources":["../../src/core/cartesian-scales.ts"],"sourcesContent":["import { warn } from '../_dev';\nimport { linearScale } from '../scales/linear';\nimport { timeScale } from '../scales/time';\nimport type { Scale } from '../types';\n\nexport function buildXScale(allX: (Date | number)[], width: number): Scale<Date> | Scale<number> {\n if (allX.length === 0) return linearScale({ domain: [0, 1], range: [0, width] });\n\n if (allX.some((v) => v == null)) {\n warn(\n 'buildXScale: one or more x values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX.some((v) => typeof v === 'number' && !Number.isFinite(v))) {\n warn('buildXScale: one or more x values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [0, width] });\n }\n\n if (allX[0] instanceof Date) {\n const dates = allX as Date[];\n const minMs = Math.min(...dates.map(Number));\n const maxMs = Math.max(...dates.map(Number));\n const min = new Date(minMs);\n const max = new Date(minMs === maxMs ? maxMs + 1 : maxMs);\n\n return timeScale({ domain: [min, max], range: [0, width] });\n }\n\n const nums = allX as number[];\n const minN = Math.min(...nums);\n const maxN = Math.max(...nums);\n\n return linearScale({ domain: [minN, minN === maxN ? maxN + 1 : maxN], nice: false, range: [0, width] });\n}\n\nexport function buildYScale(allY: number[], height: number, includeZero = true): Scale<number> {\n if (allY.length === 0) return linearScale({ domain: [0, 1], range: [height, 0] });\n\n if (allY.some((v) => v == null)) {\n warn(\n 'buildYScale: one or more y values are null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n if (allY.some((v) => !Number.isFinite(v))) {\n warn('buildYScale: one or more y values are NaN or Infinity — check upstream data for invalid arithmetic.');\n\n return linearScale({ domain: [0, 1], range: [height, 0] });\n }\n\n const rawMin = Math.min(...allY);\n const minY = includeZero ? Math.min(0, rawMin) : rawMin;\n const maxY = Math.max(...allY);\n\n return linearScale({ domain: [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AAM,IAAI,GAC3C,IAAO,KAAK,IAAI,GAAG,CAAI;CAE7B,OAAO,EAAY;EAAE,QAAQ,CAAC,GAAM,MAAS,IAAO,IAAO,IAAI,CAAI;EAAG,OAAO,CAAC,GAAQ,CAAC;CAAE,CAAC;AAC5F"}
@@ -1,2 +1,2 @@
1
- const e=require("../errors.cjs");require("../_dev.cjs");const t=require("../svg/element.cjs"),n=require("./layout.cjs"),r=require("./responsive.cjs");let i=require("@vielzeug/ripple");function a(a,o){if(!(typeof a==`object`&&a&&a.nodeType===1&&typeof a.appendChild==`function`&&typeof a.getBoundingClientRect==`function`)){let t=a,n=t===null?`null`:typeof t==`object`?t.constructor?.name??`object`:typeof t;throw new e.PrismRenderError(`Invalid chart configuration: \`container\` must be a DOM Element, received ${n}.`)}let s=n.resolveMargin(o.margin),c=o.a11y??(o.ariaLabel?{ariaLabel:o.ariaLabel}:void 0),l=t.createSvgElement(`svg`,{...o.ariaHidden||c?.decorative?{"aria-hidden":`true`}:{...c?{"aria-label":c.ariaLabel,tabindex:`0`}:{},role:`img`},class:`prism-chart`,style:`display:block;width:100%;height:100%`}),u=t.createSvgElement(`g`,{class:`prism-chart-area`,transform:`translate(${s.left},${s.top})`});l.appendChild(u);let d=a.getBoundingClientRect();d.width===0||d.height;let f=typeof getComputedStyle<`u`?getComputedStyle(a):null;f&&f.position;let p=(0,i.signal)({height:d.height||300,margin:s,width:d.width||600}),m=r.observeResize(a,(e,n)=>{p.value={height:n,margin:s,width:e},t.setAttributes(l,{height:n,viewBox:`0 0 ${e} ${n}`,width:e})}),h=d.width||600,g=d.height||300;return t.setAttributes(l,{height:g,viewBox:`0 0 ${h} ${g}`,width:h}),a.appendChild(l),{chartArea:u,dimensions:p,dispose(){m(),l.remove()},svg:l}}exports.createChartBase=a;
1
+ require("../_dev.cjs");const e=require("../svg/element.cjs"),t=require("../errors.cjs"),n=require("./layout.cjs"),r=require("./responsive.cjs");let i=require("@vielzeug/ripple");function a(a,o){if(!(typeof a==`object`&&a&&a.nodeType===1&&typeof a.appendChild==`function`&&typeof a.getBoundingClientRect==`function`)){let e=a,n=e===null?`null`:typeof e==`object`?e.constructor?.name??`object`:typeof e;throw new t.PrismRenderError(`Invalid chart configuration: \`container\` must be a DOM Element, received ${n}.`)}let s=n.resolveMargin(o.margin),c=o.a11y??(o.ariaLabel?{ariaLabel:o.ariaLabel}:void 0),l=e.createSvgElement(`svg`,{...o.ariaHidden||c?.decorative?{"aria-hidden":`true`}:{...c?{"aria-label":c.ariaLabel,tabindex:`0`}:{},role:`img`},class:`prism-chart`,style:`display:block;width:100%;height:100%`}),u=e.createSvgElement(`g`,{class:`prism-chart-area`,transform:`translate(${s.left},${s.top})`});l.appendChild(u);let d=a.getBoundingClientRect();d.width===0||d.height;let f=typeof getComputedStyle<`u`?getComputedStyle(a):null;f&&f.position;let p=(0,i.signal)({height:d.height||300,margin:s,width:d.width||600}),m=r.observeResize(a,(t,n)=>{p.value={height:n,margin:s,width:t},e.setAttributes(l,{height:n,viewBox:`0 0 ${t} ${n}`,width:t})}),h=d.width||600,g=d.height||300;return e.setAttributes(l,{height:g,viewBox:`0 0 ${h} ${g}`,width:h}),a.appendChild(l),{chartArea:u,dimensions:p,dispose(){m(),l.remove()},svg:l}}exports.createChartBase=a;
2
2
  //# sourceMappingURL=chart-base.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-base.cjs","names":[],"sources":["../../src/core/chart-base.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { signal } from '@vielzeug/ripple';\n\nimport type { ChartA11y, ChartDimensions, ChartMargin } from '../types';\n\nimport { warn } from '../_dev';\nimport { PrismRenderError } from '../errors';\nimport { createSvgElement, setAttributes } from '../svg/element';\nimport { resolveMargin } from './layout';\nimport { observeResize } from './responsive';\n\nexport interface ChartBase {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n svg: SVGSVGElement;\n dispose(): void;\n}\n\nexport function createChartBase(\n container: HTMLElement,\n options: { a11y?: ChartA11y; ariaHidden?: boolean; ariaLabel?: string; margin?: Partial<ChartMargin> },\n): ChartBase {\n // Duck-typed rather than `instanceof Element` — an `instanceof` check would reject a\n // structurally valid Element from a different realm (e.g. an Element created via\n // `iframe.contentDocument.createElement(...)`, whose prototype chain terminates in that\n // iframe's own `Element` constructor), which is a legitimate usage pattern this package\n // doesn't otherwise restrict.\n const isElementLike =\n typeof container === 'object' &&\n container !== null &&\n container.nodeType === 1 &&\n typeof container.appendChild === 'function' &&\n typeof container.getBoundingClientRect === 'function';\n\n if (!isElementLike) {\n const received: unknown = container;\n const kind =\n received === null\n ? 'null'\n : typeof received === 'object'\n ? (received.constructor?.name ?? 'object')\n : typeof received;\n\n throw new PrismRenderError(`Invalid chart configuration: \\`container\\` must be a DOM Element, received ${kind}.`);\n }\n\n const margin = resolveMargin(options.margin);\n const a11y = options.a11y ?? (options.ariaLabel ? { ariaLabel: options.ariaLabel } : undefined);\n const svg = createSvgElement('svg', {\n ...(options.ariaHidden || a11y?.decorative\n ? { 'aria-hidden': 'true' }\n : {\n ...(a11y ? { 'aria-label': a11y.ariaLabel, tabindex: '0' } : {}),\n role: 'img',\n }),\n class: 'prism-chart',\n style: 'display:block;width:100%;height:100%',\n });\n\n const chartAreaGroup = createSvgElement('g', {\n class: 'prism-chart-area',\n transform: `translate(${margin.left},${margin.top})`,\n });\n\n svg.appendChild(chartAreaGroup);\n\n const rect = container.getBoundingClientRect();\n\n if (rect.width === 0 || rect.height === 0) {\n warn(\n 'Chart container has zero dimensions. Ensure the container has a defined width and height before mounting a chart.',\n );\n }\n\n const computedStyle = typeof getComputedStyle !== 'undefined' ? getComputedStyle(container) : null;\n\n if (computedStyle && computedStyle.position === 'static') {\n warn(\n 'Chart container has position:static. Set position:relative (or absolute/fixed) on the container so tooltip and overlay elements are positioned correctly.',\n );\n }\n\n const dimensions = signal<ChartDimensions>({\n height: rect.height || 300,\n margin,\n width: rect.width || 600,\n });\n\n const stopObserving = observeResize(container, (width, height) => {\n dimensions.value = { height, margin, width };\n setAttributes(svg, { height, viewBox: `0 0 ${width} ${height}`, width });\n });\n\n const initialWidth = rect.width || 600;\n const initialHeight = rect.height || 300;\n\n setAttributes(svg, {\n height: initialHeight,\n viewBox: `0 0 ${initialWidth} ${initialHeight}`,\n width: initialWidth,\n });\n\n container.appendChild(svg);\n\n return {\n chartArea: chartAreaGroup,\n dimensions,\n dispose() {\n stopObserving();\n svg.remove();\n },\n svg,\n };\n}\n"],"mappings":"wLAmBA,SAAgB,EACd,EACA,EACW,CAaX,GAAI,EANF,OAAO,GAAc,UACrB,GACA,EAAU,WAAa,GACvB,OAAO,EAAU,aAAgB,YACjC,OAAO,EAAU,uBAA0B,YAEzB,CAClB,IAAM,EAAoB,EACpB,EACJ,IAAa,KACT,OACA,OAAO,GAAa,SACjB,EAAS,aAAa,MAAQ,SAC/B,OAAO,EAEf,MAAM,IAAI,EAAA,iBAAiB,8EAA8E,EAAK,EAAE,CAClH,CAEA,IAAM,EAAS,EAAA,cAAc,EAAQ,MAAM,EACrC,EAAO,EAAQ,OAAS,EAAQ,UAAY,CAAE,UAAW,EAAQ,SAAU,EAAI,IAAA,IAC/E,EAAM,EAAA,iBAAiB,MAAO,CAClC,GAAI,EAAQ,YAAc,GAAM,WAC5B,CAAE,cAAe,MAAO,EACxB,CACE,GAAI,EAAO,CAAE,aAAc,EAAK,UAAW,SAAU,GAAI,EAAI,CAAC,EAC9D,KAAM,KACR,EACJ,MAAO,cACP,MAAO,sCACT,CAAC,EAEK,EAAiB,EAAA,iBAAiB,IAAK,CAC3C,MAAO,mBACP,UAAW,aAAa,EAAO,KAAK,GAAG,EAAO,IAAI,EACpD,CAAC,EAED,EAAI,YAAY,CAAc,EAE9B,IAAM,EAAO,EAAU,sBAAsB,EAEzC,EAAK,QAAU,GAAK,EAAK,OAM7B,IAAM,EAAgB,OAAO,iBAAqB,IAAc,iBAAiB,CAAS,EAAI,KAE1F,GAAiB,EAAc,SAMnC,IAAM,GAAA,EAAa,EAAA,OAAA,CAAwB,CACzC,OAAQ,EAAK,QAAU,IACvB,SACA,MAAO,EAAK,OAAS,GACvB,CAAC,EAEK,EAAgB,EAAA,cAAc,GAAY,EAAO,IAAW,CAChE,EAAW,MAAQ,CAAE,SAAQ,SAAQ,OAAM,EAC3C,EAAA,cAAc,EAAK,CAAE,SAAQ,QAAS,OAAO,EAAM,GAAG,IAAU,OAAM,CAAC,CACzE,CAAC,EAEK,EAAe,EAAK,OAAS,IAC7B,EAAgB,EAAK,QAAU,IAUrC,OARA,EAAA,cAAc,EAAK,CACjB,OAAQ,EACR,QAAS,OAAO,EAAa,GAAG,IAChC,MAAO,CACT,CAAC,EAED,EAAU,YAAY,CAAG,EAElB,CACL,UAAW,EACX,aACA,SAAU,CACR,EAAc,EACd,EAAI,OAAO,CACb,EACA,KACF,CACF"}
1
+ {"version":3,"file":"chart-base.cjs","names":[],"sources":["../../src/core/chart-base.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { signal } from '@vielzeug/ripple';\nimport { warn } from '../_dev';\nimport { PrismRenderError } from '../errors';\nimport { createSvgElement, setAttributes } from '../svg/element';\nimport type { ChartA11y, ChartDimensions, ChartMargin } from '../types';\nimport { resolveMargin } from './layout';\nimport { observeResize } from './responsive';\n\nexport interface ChartBase {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n dispose(): void;\n svg: SVGSVGElement;\n}\n\nexport function createChartBase(\n container: HTMLElement,\n options: { a11y?: ChartA11y; ariaHidden?: boolean; ariaLabel?: string; margin?: Partial<ChartMargin> },\n): ChartBase {\n // Duck-typed rather than `instanceof Element` — an `instanceof` check would reject a\n // structurally valid Element from a different realm (e.g. an Element created via\n // `iframe.contentDocument.createElement(...)`, whose prototype chain terminates in that\n // iframe's own `Element` constructor), which is a legitimate usage pattern this package\n // doesn't otherwise restrict.\n const isElementLike =\n typeof container === 'object' &&\n container !== null &&\n container.nodeType === 1 &&\n typeof container.appendChild === 'function' &&\n typeof container.getBoundingClientRect === 'function';\n\n if (!isElementLike) {\n const received: unknown = container;\n const kind =\n received === null\n ? 'null'\n : typeof received === 'object'\n ? (received.constructor?.name ?? 'object')\n : typeof received;\n\n throw new PrismRenderError(`Invalid chart configuration: \\`container\\` must be a DOM Element, received ${kind}.`);\n }\n\n const margin = resolveMargin(options.margin);\n const a11y = options.a11y ?? (options.ariaLabel ? { ariaLabel: options.ariaLabel } : undefined);\n const svg = createSvgElement('svg', {\n ...(options.ariaHidden || a11y?.decorative\n ? { 'aria-hidden': 'true' }\n : {\n ...(a11y ? { 'aria-label': a11y.ariaLabel, tabindex: '0' } : {}),\n role: 'img',\n }),\n class: 'prism-chart',\n style: 'display:block;width:100%;height:100%',\n });\n\n const chartAreaGroup = createSvgElement('g', {\n class: 'prism-chart-area',\n transform: `translate(${margin.left},${margin.top})`,\n });\n\n svg.appendChild(chartAreaGroup);\n\n const rect = container.getBoundingClientRect();\n\n if (rect.width === 0 || rect.height === 0) {\n warn(\n 'Chart container has zero dimensions. Ensure the container has a defined width and height before mounting a chart.',\n );\n }\n\n const computedStyle = typeof getComputedStyle !== 'undefined' ? getComputedStyle(container) : null;\n\n if (computedStyle && computedStyle.position === 'static') {\n warn(\n 'Chart container has position:static. Set position:relative (or absolute/fixed) on the container so tooltip and overlay elements are positioned correctly.',\n );\n }\n\n const dimensions = signal<ChartDimensions>({\n height: rect.height || 300,\n margin,\n width: rect.width || 600,\n });\n\n const stopObserving = observeResize(container, (width, height) => {\n dimensions.value = { height, margin, width };\n setAttributes(svg, { height, viewBox: `0 0 ${width} ${height}`, width });\n });\n\n const initialWidth = rect.width || 600;\n const initialHeight = rect.height || 300;\n\n setAttributes(svg, {\n height: initialHeight,\n viewBox: `0 0 ${initialWidth} ${initialHeight}`,\n width: initialWidth,\n });\n\n container.appendChild(svg);\n\n return {\n chartArea: chartAreaGroup,\n dimensions,\n dispose() {\n stopObserving();\n svg.remove();\n },\n svg,\n };\n}\n"],"mappings":"kLAiBA,SAAgB,EACd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AUrC,OARA,EAAA,cAAc,EAAK,CACjB,OAAQ,EACR,QAAS,OAAO,EAAa,GAAG,IAChC,MAAO,CACT,CAAC,EAED,EAAU,YAAY,CAAG,EAElB,CACL,UAAW,EACX,aACA,SAAU,CACR,EAAc,EACd,EAAI,OAAO,CACb,EACA,KACF,CACF"}
@@ -3,8 +3,8 @@ import type { ChartA11y, ChartDimensions, ChartMargin } from '../types';
3
3
  export interface ChartBase {
4
4
  chartArea: SVGGElement;
5
5
  dimensions: Readable<ChartDimensions>;
6
- svg: SVGSVGElement;
7
6
  dispose(): void;
7
+ svg: SVGSVGElement;
8
8
  }
9
9
  export declare function createChartBase(container: HTMLElement, options: {
10
10
  a11y?: ChartA11y;
@@ -1 +1 @@
1
- {"version":3,"file":"chart-base.d.ts","sourceRoot":"","sources":["../../src/core/chart-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAQxE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IACtC,GAAG,EAAE,aAAa,CAAC;IACnB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;CAAE,GACrG,SAAS,CA4FX"}
1
+ {"version":3,"file":"chart-base.d.ts","sourceRoot":"","sources":["../../src/core/chart-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMjD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIxE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IACtC,OAAO,IAAI,IAAI,CAAC;IAChB,GAAG,EAAE,aAAa,CAAC;CACpB;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;CAAE,GACrG,SAAS,CA4FX"}
@@ -1,16 +1,16 @@
1
- import { PrismRenderError as e } from "../errors.js";
2
1
  import "../_dev.js";
3
- import { createSvgElement as t, setAttributes as n } from "../svg/element.js";
2
+ import { createSvgElement as e, setAttributes as t } from "../svg/element.js";
3
+ import { PrismRenderError as n } from "../errors.js";
4
4
  import { resolveMargin as r } from "./layout.js";
5
5
  import { observeResize as i } from "./responsive.js";
6
6
  import { signal as a } from "@vielzeug/ripple";
7
7
  //#region src/core/chart-base.ts
8
8
  function o(o, s) {
9
9
  if (!(typeof o == "object" && o && o.nodeType === 1 && typeof o.appendChild == "function" && typeof o.getBoundingClientRect == "function")) {
10
- let t = o, n = t === null ? "null" : typeof t == "object" ? t.constructor?.name ?? "object" : typeof t;
11
- throw new e(`Invalid chart configuration: \`container\` must be a DOM Element, received ${n}.`);
10
+ let e = o, t = e === null ? "null" : typeof e == "object" ? e.constructor?.name ?? "object" : typeof e;
11
+ throw new n(`Invalid chart configuration: \`container\` must be a DOM Element, received ${t}.`);
12
12
  }
13
- let c = r(s.margin), l = s.a11y ?? (s.ariaLabel ? { ariaLabel: s.ariaLabel } : void 0), u = t("svg", {
13
+ let c = r(s.margin), l = s.a11y ?? (s.ariaLabel ? { ariaLabel: s.ariaLabel } : void 0), u = e("svg", {
14
14
  ...s.ariaHidden || l?.decorative ? { "aria-hidden": "true" } : {
15
15
  ...l ? {
16
16
  "aria-label": l.ariaLabel,
@@ -20,7 +20,7 @@ function o(o, s) {
20
20
  },
21
21
  class: "prism-chart",
22
22
  style: "display:block;width:100%;height:100%"
23
- }), d = t("g", {
23
+ }), d = e("g", {
24
24
  class: "prism-chart-area",
25
25
  transform: `translate(${c.left},${c.top})`
26
26
  });
@@ -33,18 +33,18 @@ function o(o, s) {
33
33
  height: f.height || 300,
34
34
  margin: c,
35
35
  width: f.width || 600
36
- }), h = i(o, (e, t) => {
36
+ }), h = i(o, (e, n) => {
37
37
  m.value = {
38
- height: t,
38
+ height: n,
39
39
  margin: c,
40
40
  width: e
41
- }, n(u, {
42
- height: t,
43
- viewBox: `0 0 ${e} ${t}`,
41
+ }, t(u, {
42
+ height: n,
43
+ viewBox: `0 0 ${e} ${n}`,
44
44
  width: e
45
45
  });
46
46
  }), g = f.width || 600, _ = f.height || 300;
47
- return n(u, {
47
+ return t(u, {
48
48
  height: _,
49
49
  viewBox: `0 0 ${g} ${_}`,
50
50
  width: g
@@ -1 +1 @@
1
- {"version":3,"file":"chart-base.js","names":[],"sources":["../../src/core/chart-base.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { signal } from '@vielzeug/ripple';\n\nimport type { ChartA11y, ChartDimensions, ChartMargin } from '../types';\n\nimport { warn } from '../_dev';\nimport { PrismRenderError } from '../errors';\nimport { createSvgElement, setAttributes } from '../svg/element';\nimport { resolveMargin } from './layout';\nimport { observeResize } from './responsive';\n\nexport interface ChartBase {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n svg: SVGSVGElement;\n dispose(): void;\n}\n\nexport function createChartBase(\n container: HTMLElement,\n options: { a11y?: ChartA11y; ariaHidden?: boolean; ariaLabel?: string; margin?: Partial<ChartMargin> },\n): ChartBase {\n // Duck-typed rather than `instanceof Element` — an `instanceof` check would reject a\n // structurally valid Element from a different realm (e.g. an Element created via\n // `iframe.contentDocument.createElement(...)`, whose prototype chain terminates in that\n // iframe's own `Element` constructor), which is a legitimate usage pattern this package\n // doesn't otherwise restrict.\n const isElementLike =\n typeof container === 'object' &&\n container !== null &&\n container.nodeType === 1 &&\n typeof container.appendChild === 'function' &&\n typeof container.getBoundingClientRect === 'function';\n\n if (!isElementLike) {\n const received: unknown = container;\n const kind =\n received === null\n ? 'null'\n : typeof received === 'object'\n ? (received.constructor?.name ?? 'object')\n : typeof received;\n\n throw new PrismRenderError(`Invalid chart configuration: \\`container\\` must be a DOM Element, received ${kind}.`);\n }\n\n const margin = resolveMargin(options.margin);\n const a11y = options.a11y ?? (options.ariaLabel ? { ariaLabel: options.ariaLabel } : undefined);\n const svg = createSvgElement('svg', {\n ...(options.ariaHidden || a11y?.decorative\n ? { 'aria-hidden': 'true' }\n : {\n ...(a11y ? { 'aria-label': a11y.ariaLabel, tabindex: '0' } : {}),\n role: 'img',\n }),\n class: 'prism-chart',\n style: 'display:block;width:100%;height:100%',\n });\n\n const chartAreaGroup = createSvgElement('g', {\n class: 'prism-chart-area',\n transform: `translate(${margin.left},${margin.top})`,\n });\n\n svg.appendChild(chartAreaGroup);\n\n const rect = container.getBoundingClientRect();\n\n if (rect.width === 0 || rect.height === 0) {\n warn(\n 'Chart container has zero dimensions. Ensure the container has a defined width and height before mounting a chart.',\n );\n }\n\n const computedStyle = typeof getComputedStyle !== 'undefined' ? getComputedStyle(container) : null;\n\n if (computedStyle && computedStyle.position === 'static') {\n warn(\n 'Chart container has position:static. Set position:relative (or absolute/fixed) on the container so tooltip and overlay elements are positioned correctly.',\n );\n }\n\n const dimensions = signal<ChartDimensions>({\n height: rect.height || 300,\n margin,\n width: rect.width || 600,\n });\n\n const stopObserving = observeResize(container, (width, height) => {\n dimensions.value = { height, margin, width };\n setAttributes(svg, { height, viewBox: `0 0 ${width} ${height}`, width });\n });\n\n const initialWidth = rect.width || 600;\n const initialHeight = rect.height || 300;\n\n setAttributes(svg, {\n height: initialHeight,\n viewBox: `0 0 ${initialWidth} ${initialHeight}`,\n width: initialWidth,\n });\n\n container.appendChild(svg);\n\n return {\n chartArea: chartAreaGroup,\n dimensions,\n dispose() {\n stopObserving();\n svg.remove();\n },\n svg,\n };\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,EACd,GACA,GACW;CAaX,IAAI,EANF,OAAO,KAAc,YACrB,KACA,EAAU,aAAa,KACvB,OAAO,EAAU,eAAgB,cACjC,OAAO,EAAU,yBAA0B,aAEzB;EAClB,IAAM,IAAoB,GACpB,IACJ,MAAa,OACT,SACA,OAAO,KAAa,WACjB,EAAS,aAAa,QAAQ,WAC/B,OAAO;EAEf,MAAM,IAAI,EAAiB,8EAA8E,EAAK,EAAE;CAClH;CAEA,IAAM,IAAS,EAAc,EAAQ,MAAM,GACrC,IAAO,EAAQ,SAAS,EAAQ,YAAY,EAAE,WAAW,EAAQ,UAAU,IAAI,KAAA,IAC/E,IAAM,EAAiB,OAAO;EAClC,GAAI,EAAQ,cAAc,GAAM,aAC5B,EAAE,eAAe,OAAO,IACxB;GACE,GAAI,IAAO;IAAE,cAAc,EAAK;IAAW,UAAU;GAAI,IAAI,CAAC;GAC9D,MAAM;EACR;EACJ,OAAO;EACP,OAAO;CACT,CAAC,GAEK,IAAiB,EAAiB,KAAK;EAC3C,OAAO;EACP,WAAW,aAAa,EAAO,KAAK,GAAG,EAAO,IAAI;CACpD,CAAC;CAED,EAAI,YAAY,CAAc;CAE9B,IAAM,IAAO,EAAU,sBAAsB;CAE7C,AAAI,EAAK,UAAU,KAAK,EAAK;CAM7B,IAAM,IAAgB,OAAO,mBAAqB,MAAc,iBAAiB,CAAS,IAAI;CAE9F,AAAI,KAAiB,EAAc;CAMnC,IAAM,IAAa,EAAwB;EACzC,QAAQ,EAAK,UAAU;EACvB;EACA,OAAO,EAAK,SAAS;CACvB,CAAC,GAEK,IAAgB,EAAc,IAAY,GAAO,MAAW;EAEhE,AADA,EAAW,QAAQ;GAAE;GAAQ;GAAQ;EAAM,GAC3C,EAAc,GAAK;GAAE;GAAQ,SAAS,OAAO,EAAM,GAAG;GAAU;EAAM,CAAC;CACzE,CAAC,GAEK,IAAe,EAAK,SAAS,KAC7B,IAAgB,EAAK,UAAU;CAUrC,OARA,EAAc,GAAK;EACjB,QAAQ;EACR,SAAS,OAAO,EAAa,GAAG;EAChC,OAAO;CACT,CAAC,GAED,EAAU,YAAY,CAAG,GAElB;EACL,WAAW;EACX;EACA,UAAU;GAER,AADA,EAAc,GACd,EAAI,OAAO;EACb;EACA;CACF;AACF"}
1
+ {"version":3,"file":"chart-base.js","names":[],"sources":["../../src/core/chart-base.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { signal } from '@vielzeug/ripple';\nimport { warn } from '../_dev';\nimport { PrismRenderError } from '../errors';\nimport { createSvgElement, setAttributes } from '../svg/element';\nimport type { ChartA11y, ChartDimensions, ChartMargin } from '../types';\nimport { resolveMargin } from './layout';\nimport { observeResize } from './responsive';\n\nexport interface ChartBase {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n dispose(): void;\n svg: SVGSVGElement;\n}\n\nexport function createChartBase(\n container: HTMLElement,\n options: { a11y?: ChartA11y; ariaHidden?: boolean; ariaLabel?: string; margin?: Partial<ChartMargin> },\n): ChartBase {\n // Duck-typed rather than `instanceof Element` — an `instanceof` check would reject a\n // structurally valid Element from a different realm (e.g. an Element created via\n // `iframe.contentDocument.createElement(...)`, whose prototype chain terminates in that\n // iframe's own `Element` constructor), which is a legitimate usage pattern this package\n // doesn't otherwise restrict.\n const isElementLike =\n typeof container === 'object' &&\n container !== null &&\n container.nodeType === 1 &&\n typeof container.appendChild === 'function' &&\n typeof container.getBoundingClientRect === 'function';\n\n if (!isElementLike) {\n const received: unknown = container;\n const kind =\n received === null\n ? 'null'\n : typeof received === 'object'\n ? (received.constructor?.name ?? 'object')\n : typeof received;\n\n throw new PrismRenderError(`Invalid chart configuration: \\`container\\` must be a DOM Element, received ${kind}.`);\n }\n\n const margin = resolveMargin(options.margin);\n const a11y = options.a11y ?? (options.ariaLabel ? { ariaLabel: options.ariaLabel } : undefined);\n const svg = createSvgElement('svg', {\n ...(options.ariaHidden || a11y?.decorative\n ? { 'aria-hidden': 'true' }\n : {\n ...(a11y ? { 'aria-label': a11y.ariaLabel, tabindex: '0' } : {}),\n role: 'img',\n }),\n class: 'prism-chart',\n style: 'display:block;width:100%;height:100%',\n });\n\n const chartAreaGroup = createSvgElement('g', {\n class: 'prism-chart-area',\n transform: `translate(${margin.left},${margin.top})`,\n });\n\n svg.appendChild(chartAreaGroup);\n\n const rect = container.getBoundingClientRect();\n\n if (rect.width === 0 || rect.height === 0) {\n warn(\n 'Chart container has zero dimensions. Ensure the container has a defined width and height before mounting a chart.',\n );\n }\n\n const computedStyle = typeof getComputedStyle !== 'undefined' ? getComputedStyle(container) : null;\n\n if (computedStyle && computedStyle.position === 'static') {\n warn(\n 'Chart container has position:static. Set position:relative (or absolute/fixed) on the container so tooltip and overlay elements are positioned correctly.',\n );\n }\n\n const dimensions = signal<ChartDimensions>({\n height: rect.height || 300,\n margin,\n width: rect.width || 600,\n });\n\n const stopObserving = observeResize(container, (width, height) => {\n dimensions.value = { height, margin, width };\n setAttributes(svg, { height, viewBox: `0 0 ${width} ${height}`, width });\n });\n\n const initialWidth = rect.width || 600;\n const initialHeight = rect.height || 300;\n\n setAttributes(svg, {\n height: initialHeight,\n viewBox: `0 0 ${initialWidth} ${initialHeight}`,\n width: initialWidth,\n });\n\n container.appendChild(svg);\n\n return {\n chartArea: chartAreaGroup,\n dimensions,\n dispose() {\n stopObserving();\n svg.remove();\n },\n svg,\n };\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,EACd,GACA,GACW;CAaX,IAAI,EANF,OAAO,KAAc,YACrB,KACA,EAAU,aAAa,KACvB,OAAO,EAAU,eAAgB,cACjC,OAAO,EAAU,yBAA0B,aAEzB;EAClB,I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AAO;EACb;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"chart-scaffold.cjs","names":[],"sources":["../../src/core/chart-scaffold.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { createScope, effect } from '@vielzeug/ripple';\n\nimport type { CrosshairState } from '../interaction/crosshair';\nimport type { LegendState } from '../interaction/legend';\nimport type { TooltipState } from '../interaction/tooltip';\nimport type { BaseChartConfig, ChartDimensions, ChartHandle, ChartPlugin, ChartPluginContext } from '../types';\n\nimport { error } from '../_dev';\nimport { createLegend } from '../interaction/legend';\nimport { createTooltip } from '../interaction/tooltip';\nimport { createSvgElement, removeChildren } from '../svg/element';\nimport { createChartBase } from './chart-base';\n\nexport interface ScaffoldGroups {\n grid: SVGGElement;\n series: SVGGElement;\n xAxis: SVGGElement;\n yAxis: SVGGElement;\n}\n\n/**\n * Clears a cartesian chart's series/grid/axis groups and hides its legend/tooltip/crosshair —\n * shared by every cartesian chart factory's \"no data\" early-return so a reactive series\n * transitioning to empty leaves a fully blank chart, not a half-cleared one.\n */\nexport function clearCartesianDom(\n groups: ScaffoldGroups,\n legend: LegendState | null,\n tooltip: TooltipState | null,\n crosshair?: CrosshairState | null,\n): void {\n removeChildren(groups.series);\n removeChildren(groups.grid);\n removeChildren(groups.xAxis);\n removeChildren(groups.yAxis);\n legend?.update([]);\n tooltip?.hide();\n crosshair?.hide();\n}\n\nexport interface ScaffoldContext {\n chartArea: SVGGElement;\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n groups: ScaffoldGroups;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface RadialScaffoldContext {\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface ChartEventHandlers {\n onClick?: (event: MouseEvent) => void;\n onKeyDown?: (event: KeyboardEvent) => void;\n onMouseLeave?: (event: MouseEvent) => void;\n onMouseMove?: (event: MouseEvent) => void;\n}\n\nfunction runScaffold<TCtx>(\n container: HTMLElement,\n config: BaseChartConfig,\n buildCtx: (\n base: {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n svg: SVGSVGElement;\n },\n tooltip: TooltipState | null,\n legend: LegendState | null,\n disposalSignal: AbortSignal,\n ) => TCtx,\n renderFn: (ctx: TCtx) => ChartEventHandlers | void,\n): ChartHandle {\n const base = createChartBase(container, { a11y: config.a11y, ariaLabel: config.ariaLabel, margin: config.margin });\n const tooltip = config.tooltip ? createTooltip(container, config.tooltip) : null;\n const legend = config.legend ? createLegend(container, config.legend) : null;\n const ac = new AbortController();\n const ctx = buildCtx(base, tooltip, legend, ac.signal);\n\n let disposed = false;\n const events = makeEventManager(base.svg);\n\n const scope = createScope();\n\n scope.run(() => {\n effect(\n () => {\n if (disposed) return;\n\n events.attach(renderFn(ctx));\n },\n { scheduler: 'microtask' },\n );\n });\n\n const installedPlugins: ChartPlugin[] = [];\n\n if (config.plugins) {\n const pluginCtx: ChartPluginContext = {\n container,\n dimensions: base.dimensions,\n disposalSignal: ac.signal,\n svg: base.svg,\n };\n\n for (const plugin of config.plugins) {\n try {\n plugin.install(pluginCtx);\n installedPlugins.push(plugin);\n } catch (err) {\n error('A chart plugin threw during install() — skipping it; the rest of the chart still renders.', err);\n }\n }\n }\n\n return {\n get disposalSignal(): AbortSignal {\n return ac.signal;\n },\n\n dispose() {\n if (disposed) return;\n\n disposed = true;\n ac.abort();\n events.detach();\n\n for (const p of installedPlugins) {\n try {\n p.dispose();\n } catch (err) {\n error('A chart plugin threw during dispose() — continuing to tear down the rest of the chart.', err);\n }\n }\n\n tooltip?.dispose();\n legend?.dispose();\n scope.dispose();\n base.dispose();\n },\n\n get disposed(): boolean {\n return disposed;\n },\n\n el: base.svg,\n\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\nfunction makeEventManager(svg: SVGSVGElement): {\n attach(handlers: ChartEventHandlers | void): void;\n detach(): void;\n} {\n let active: ChartEventHandlers | null = null;\n\n return {\n attach(handlers) {\n if (active) {\n if (active.onMouseMove) svg.removeEventListener('mousemove', active.onMouseMove);\n\n if (active.onMouseLeave) svg.removeEventListener('mouseleave', active.onMouseLeave);\n\n if (active.onClick) svg.removeEventListener('click', active.onClick);\n\n if (active.onKeyDown) svg.removeEventListener('keydown', active.onKeyDown);\n\n active = null;\n }\n\n if (!handlers) return;\n\n active = handlers;\n\n if (handlers.onMouseMove) svg.addEventListener('mousemove', handlers.onMouseMove);\n\n if (handlers.onMouseLeave) svg.addEventListener('mouseleave', handlers.onMouseLeave);\n\n if (handlers.onClick) svg.addEventListener('click', handlers.onClick);\n\n if (handlers.onKeyDown) svg.addEventListener('keydown', handlers.onKeyDown);\n },\n detach() {\n this.attach(undefined);\n },\n };\n}\n\n/**\n * Cartesian scaffold: provides grid/axis/series SVG groups and a reactive\n * render loop. `renderFn` is called inside a reactive effect; it returns\n * optional `ChartEventHandlers` that are attached/replaced on every render.\n */\nexport function createChartScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: ScaffoldContext) => ChartEventHandlers | void,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) => {\n const groups: ScaffoldGroups = {\n // Grid lines are purely decorative relative to the root svg's own role=\"img\"/aria-label.\n // Axis groups are NOT hidden wholesale — they can contain a meaningful `.prism-axis-title`;\n // `renderAxis` marks its own decorative tick lines/labels individually instead.\n grid: createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-grid' }),\n series: createSvgElement('g', { class: 'prism-series' }),\n xAxis: createSvgElement('g', { class: 'prism-x-axis' }),\n yAxis: createSvgElement('g', { class: 'prism-y-axis' }),\n };\n\n base.chartArea.appendChild(groups.grid);\n base.chartArea.appendChild(groups.xAxis);\n base.chartArea.appendChild(groups.yAxis);\n base.chartArea.appendChild(groups.series);\n\n return {\n chartArea: base.chartArea,\n container,\n dimensions: base.dimensions,\n disposalSignal,\n groups,\n legend,\n svg: base.svg,\n tooltip,\n } satisfies ScaffoldContext;\n },\n renderFn,\n );\n}\n\n/**\n * Radial scaffold: for charts that do not use cartesian axis groups\n * (pie, donut, semi). Provides only tooltip, legend, and the SVG root.\n */\nexport function createRadialScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: RadialScaffoldContext) => ChartEventHandlers | void,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) =>\n ({\n container,\n dimensions: base.dimensions,\n disposalSignal,\n legend,\n svg: base.svg,\n tooltip,\n }) satisfies RadialScaffoldContext,\n renderFn,\n );\n}\n"],"mappings":"4MA2BA,SAAgB,EACd,EACA,EACA,EACA,EACM,CACN,EAAA,eAAe,EAAO,MAAM,EAC5B,EAAA,eAAe,EAAO,IAAI,EAC1B,EAAA,eAAe,EAAO,KAAK,EAC3B,EAAA,eAAe,EAAO,KAAK,EAC3B,GAAQ,OAAO,CAAC,CAAC,EACjB,GAAS,KAAK,EACd,GAAW,KAAK,CAClB,CA+BA,SAAS,EACP,EACA,EACA,EAUA,EACa,CACb,IAAM,EAAO,EAAA,gBAAgB,EAAW,CAAE,KAAM,EAAO,KAAM,UAAW,EAAO,UAAW,OAAQ,EAAO,MAAO,CAAC,EAC3G,EAAU,EAAO,QAAU,EAAA,cAAc,EAAW,EAAO,OAAO,EAAI,KACtE,EAAS,EAAO,OAAS,EAAA,aAAa,EAAW,EAAO,MAAM,EAAI,KAClE,EAAK,IAAI,gBACT,EAAM,EAAS,EAAM,EAAS,EAAQ,EAAG,MAAM,EAEjD,EAAW,GACT,EAAS,EAAiB,EAAK,GAAG,EAElC,GAAA,EAAQ,EAAA,YAAA,CAAY,EAE1B,EAAM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EAAS,OAAO,EAEhE,EAAS,WAAW,EAAI,iBAAiB,UAAW,EAAS,SAAS,EAC5E,EACA,QAAS,CACP,KAAK,OAAO,IAAA,EAAS,CACvB,CACF,CACF,CAOA,SAAgB,EACd,EACA,EACA,EACa,CACb,OAAO,EACL,EACA,GACC,EAAM,EAAS,EAAQ,IAAmB,CACzC,IAAM,EAAyB,CAI7B,KAAM,EAAA,iBAAiB,IAAK,CAAE,cAAe,OAAQ,MAAO,YAAa,CAAC,EAC1E,OAAQ,EAAA,iBAAiB,IAAK,CAAE,MAAO,cAAe,CAAC,EACvD,MAAO,EAAA,iBAAiB,IAAK,CAAE,MAAO,cAAe,CAAC,EACtD,MAAO,EAAA,iBAAiB,IAAK,CAAE,MAAO,cAAe,CAAC,CACxD,EAOA,OALA,EAAK,UAAU,YAAY,EAAO,IAAI,EACtC,EAAK,UAAU,YAAY,EAAO,KAAK,EACvC,EAAK,UAAU,YAAY,EAAO,KAAK,EACvC,EAAK,UAAU,YAAY,EAAO,MAAM,EAEjC,CACL,UAAW,EAAK,UAChB,YACA,WAAY,EAAK,WACjB,iBACA,SACA,SACA,IAAK,EAAK,IACV,SACF,CACF,EACA,CACF,CACF,CAMA,SAAgB,EACd,EACA,EACA,EACa,CACb,OAAO,EACL,EACA,GACC,EAAM,EAAS,EAAQ,KACrB,CACC,YACA,WAAY,EAAK,WACjB,iBACA,SACA,IAAK,EAAK,IACV,SACF,GACF,CACF,CACF"}
1
+ {"version":3,"file":"chart-scaffold.cjs","names":[],"sources":["../../src/core/chart-scaffold.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { createScope, effect } from '@vielzeug/ripple';\nimport { error } from '../_dev';\nimport type { CrosshairState } from '../interaction/crosshair';\nimport type { LegendState } from '../interaction/legend';\nimport { createLegend } from '../interaction/legend';\nimport type { TooltipState } from '../interaction/tooltip';\nimport { createTooltip } from '../interaction/tooltip';\nimport { createSvgElement, removeChildren } from '../svg/element';\nimport type { BaseChartConfig, ChartDimensions, ChartHandle, ChartPlugin, ChartPluginContext } from '../types';\nimport { createChartBase } from './chart-base';\n\nexport interface ScaffoldGroups {\n grid: SVGGElement;\n series: SVGGElement;\n xAxis: SVGGElement;\n yAxis: SVGGElement;\n}\n\n/**\n * Clears a cartesian chart's series/grid/axis groups and hides its legend/tooltip/crosshair —\n * shared by every cartesian chart factory's \"no data\" early-return so a reactive series\n * transitioning to empty leaves a fully blank chart, not a half-cleared one.\n */\nexport function clearCartesianDom(\n groups: ScaffoldGroups,\n legend: LegendState | null,\n tooltip: TooltipState | null,\n crosshair?: CrosshairState | null,\n): void {\n removeChildren(groups.series);\n removeChildren(groups.grid);\n removeChildren(groups.xAxis);\n removeChildren(groups.yAxis);\n legend?.update([]);\n tooltip?.hide();\n crosshair?.hide();\n}\n\nexport interface ScaffoldContext {\n chartArea: SVGGElement;\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n groups: ScaffoldGroups;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface RadialScaffoldContext {\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface ChartEventHandlers {\n onClick?: (event: MouseEvent) => void;\n onKeyDown?: (event: KeyboardEvent) => void;\n onMouseLeave?: (event: MouseEvent) => void;\n onMouseMove?: (event: MouseEvent) => void;\n}\n\nfunction runScaffold<TCtx>(\n container: HTMLElement,\n config: BaseChartConfig,\n buildCtx: (\n base: {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n svg: SVGSVGElement;\n },\n tooltip: TooltipState | null,\n legend: LegendState | null,\n disposalSignal: AbortSignal,\n ) => TCtx,\n renderFn: (ctx: TCtx) => ChartEventHandlers | undefined,\n): ChartHandle {\n const base = createChartBase(container, { a11y: config.a11y, ariaLabel: config.ariaLabel, margin: config.margin });\n const tooltip = config.tooltip ? createTooltip(container, config.tooltip) : null;\n const legend = config.legend ? createLegend(container, config.legend) : null;\n const ac = new AbortController();\n const ctx = buildCtx(base, tooltip, legend, ac.signal);\n\n let disposed = false;\n const events = makeEventManager(base.svg);\n\n const scope = createScope();\n\n scope.run(() => {\n effect(\n () => {\n if (disposed) return;\n\n events.attach(renderFn(ctx));\n },\n { scheduler: 'microtask' },\n );\n });\n\n const installedPlugins: ChartPlugin[] = [];\n\n if (config.plugins) {\n const pluginCtx: ChartPluginContext = {\n container,\n dimensions: base.dimensions,\n disposalSignal: ac.signal,\n svg: base.svg,\n };\n\n for (const plugin of config.plugins) {\n try {\n plugin.install(pluginCtx);\n installedPlugins.push(plugin);\n } catch (err) {\n error('A chart plugin threw during install() — skipping it; the rest of the chart still renders.', err);\n }\n }\n }\n\n return {\n get disposalSignal(): AbortSignal {\n return ac.signal;\n },\n\n dispose() {\n if (disposed) return;\n\n disposed = true;\n ac.abort();\n events.detach();\n\n for (const p of installedPlugins) {\n try {\n p.dispose();\n } catch (err) {\n error('A chart plugin threw during dispose() — continuing to tear down the rest of the chart.', err);\n }\n }\n\n tooltip?.dispose();\n legend?.dispose();\n scope.dispose();\n base.dispose();\n },\n\n get disposed(): boolean {\n return disposed;\n },\n\n el: base.svg,\n\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\nfunction makeEventManager(svg: SVGSVGElement): {\n attach(handlers: ChartEventHandlers | undefined): void;\n detach(): void;\n} {\n let active: ChartEventHandlers | null = null;\n\n return {\n attach(handlers) {\n if (active) {\n if (active.onMouseMove) svg.removeEventListener('mousemove', active.onMouseMove);\n\n if (active.onMouseLeave) svg.removeEventListener('mouseleave', active.onMouseLeave);\n\n if (active.onClick) svg.removeEventListener('click', active.onClick);\n\n if (active.onKeyDown) svg.removeEventListener('keydown', active.onKeyDown);\n\n active = null;\n }\n\n if (!handlers) return;\n\n active = handlers;\n\n if (handlers.onMouseMove) svg.addEventListener('mousemove', handlers.onMouseMove);\n\n if (handlers.onMouseLeave) svg.addEventListener('mouseleave', handlers.onMouseLeave);\n\n if (handlers.onClick) svg.addEventListener('click', handlers.onClick);\n\n if (handlers.onKeyDown) svg.addEventListener('keydown', handlers.onKeyDown);\n },\n detach() {\n this.attach(undefined);\n },\n };\n}\n\n/**\n * Cartesian scaffold: provides grid/axis/series SVG groups and a reactive\n * render loop. `renderFn` is called inside a reactive effect; it returns\n * optional `ChartEventHandlers` that are attached/replaced on every render.\n */\nexport function createChartScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: ScaffoldContext) => ChartEventHandlers | undefined,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) => {\n const groups: ScaffoldGroups = {\n // Grid lines are purely decorative relative to the root svg's own role=\"img\"/aria-label.\n // Axis groups are NOT hidden wholesale — they can contain a meaningful `.prism-axis-title`;\n // `renderAxis` marks its own decorative tick lines/labels individually instead.\n grid: createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-grid' }),\n series: createSvgElement('g', { class: 'prism-series' }),\n xAxis: createSvgElement('g', { class: 'prism-x-axis' }),\n yAxis: createSvgElement('g', { class: 'prism-y-axis' }),\n };\n\n base.chartArea.appendChild(groups.grid);\n base.chartArea.appendChild(groups.xAxis);\n base.chartArea.appendChild(groups.yAxis);\n base.chartArea.appendChild(groups.series);\n\n return {\n chartArea: base.chartArea,\n container,\n dimensions: base.dimensions,\n disposalSignal,\n groups,\n legend,\n svg: base.svg,\n tooltip,\n } satisfies ScaffoldContext;\n },\n renderFn,\n );\n}\n\n/**\n * Radial scaffold: for charts that do not use cartesian axis groups\n * (pie, donut, semi). Provides only tooltip, legend, and the SVG root.\n */\nexport function createRadialScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: RadialScaffoldContext) => ChartEventHandlers | undefined,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) =>\n ({\n container,\n dimensions: base.dimensions,\n disposalSignal,\n legend,\n svg: base.svg,\n tooltip,\n }) satisfies RadialScaffoldContext,\n renderFn,\n );\n}\n"],"mappings":"4MAyBA,SAAgB,EACd,EACA,EACA,EACA,EACM,CACN,EAAA,eAAe,EAAO,MAAM,EAC5B,EAAA,eAAe,EAAO,IAAI,EAC1B,EAAA,eAAe,EAAO,KAAK,EAC3B,EAAA,eAAe,EAAO,KAAK,EAC3B,GAAQ,OAAO,CAAC,CAAC,EACjB,GAAS,KAAK,EACd,GAAW,KAAK,CAClB,CA+BA,SAAS,EACP,EACA,EACA,EAUA,EACa,CACb,IAAM,EAAO,EAAA,gBAAgB,EAAW,CAAE,KAAM,EAAO,KAAM,UAAW,EAAO,UAAW,OAAQ,EAAO,MAAO,CAAC,EAC3G,EAAU,EAAO,QAAU,EAAA,cAAc,EAAW,EAAO,OAAO,EAAI,KACtE,EAAS,EAAO,OAAS,EAAA,aAAa,EAAW,EAAO,MAAM,EAAI,KAClE,EAAK,IAAI,gBACT,EAAM,EAAS,EAAM,EAAS,EAAQ,EAAG,MAAM,EAEjD,EAAW,GACT,EAAS,EAAiB,EAAK,GAAG,EAElC,GAAA,EAAQ,EAAA,YAAA,CAAY,EAE1B,EAAM,QAAU,EACd,EAAA,EAAA,OAAA,KACQ,CACA,GAEJ,EAAO,OAAO,EAAS,CAAG,CAAC,CAC7B,EACA,CAAE,UAAW,WAAY,CAC3B,CACF,CAAC,EAED,IAAM,EAAkC,CAAC,EAEzC,GAAI,EAAO,QAAS,CAClB,IAAM,EAAgC,CACpC,YACA,WAAY,EAAK,WACjB,eAAgB,EAAG,OACnB,IAAK,EAAK,GACZ,EAEA,IAAK,IAAM,KAAU,EAAO,QAC1B,GAAI,CACF,EAAO,QAAQ,CAAS,EACxB,EAAiB,KAAK,CAAM,CAC9B,MAAc,CA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O,EAAA,iBAAiB,IAAK,CAAE,MAAO,cAAe,CAAC,EACtD,MAAO,EAAA,iBAAiB,IAAK,CAAE,MAAO,cAAe,CAAC,CACxD,EAOA,OALA,EAAK,UAAU,YAAY,EAAO,IAAI,EACtC,EAAK,UAAU,YAAY,EAAO,KAAK,EACvC,EAAK,UAAU,YAAY,EAAO,KAAK,EACvC,EAAK,UAAU,YAAY,EAAO,MAAM,EAEjC,CACL,UAAW,EAAK,UAChB,YACA,WAAY,EAAK,WACjB,iBACA,SACA,SACA,IAAK,EAAK,IACV,SACF,CACF,EACA,CACF,CACF,CAMA,SAAgB,EACd,EACA,EACA,EACa,CACb,OAAO,EACL,EACA,GACC,EAAM,EAAS,EAAQ,KACrB,CACC,YACA,WAAY,EAAK,WACjB,iBACA,SACA,IAAK,EAAK,IACV,SACF,GACF,CACF,CACF"}
@@ -46,10 +46,10 @@ export interface ChartEventHandlers {
46
46
  * render loop. `renderFn` is called inside a reactive effect; it returns
47
47
  * optional `ChartEventHandlers` that are attached/replaced on every render.
48
48
  */
49
- export declare function createChartScaffold(container: HTMLElement, config: BaseChartConfig, renderFn: (ctx: ScaffoldContext) => ChartEventHandlers | void): ChartHandle;
49
+ export declare function createChartScaffold(container: HTMLElement, config: BaseChartConfig, renderFn: (ctx: ScaffoldContext) => ChartEventHandlers | undefined): ChartHandle;
50
50
  /**
51
51
  * Radial scaffold: for charts that do not use cartesian axis groups
52
52
  * (pie, donut, semi). Provides only tooltip, legend, and the SVG root.
53
53
  */
54
- export declare function createRadialScaffold(container: HTMLElement, config: BaseChartConfig, renderFn: (ctx: RadialScaffoldContext) => ChartEventHandlers | void): ChartHandle;
54
+ export declare function createRadialScaffold(container: HTMLElement, config: BaseChartConfig, renderFn: (ctx: RadialScaffoldContext) => ChartEventHandlers | undefined): ChartHandle;
55
55
  //# sourceMappingURL=chart-scaffold.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-scaffold.d.ts","sourceRoot":"","sources":["../../src/core/chart-sc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C,GAAG,EAAE,eAAe,KAAK,kBAAkB,GAAG,SAAS,GACjE,WAAW,CAiCb;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,CAAC,GAAG,EAAE,qBAAqB,KAAK,kBAAkB,GAAG,SAAS,GACvE,WAAW,CAeb"}
@@ -1 +1 @@
1
- {"version":3,"file":"chart-scaffold.js","names":[],"sources":["../../src/core/chart-scaffold.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { createScope, effect } from '@vielzeug/ripple';\n\nimport type { CrosshairState } from '../interaction/crosshair';\nimport type { LegendState } from '../interaction/legend';\nimport type { TooltipState } from '../interaction/tooltip';\nimport type { BaseChartConfig, ChartDimensions, ChartHandle, ChartPlugin, ChartPluginContext } from '../types';\n\nimport { error } from '../_dev';\nimport { createLegend } from '../interaction/legend';\nimport { createTooltip } from '../interaction/tooltip';\nimport { createSvgElement, removeChildren } from '../svg/element';\nimport { createChartBase } from './chart-base';\n\nexport interface ScaffoldGroups {\n grid: SVGGElement;\n series: SVGGElement;\n xAxis: SVGGElement;\n yAxis: SVGGElement;\n}\n\n/**\n * Clears a cartesian chart's series/grid/axis groups and hides its legend/tooltip/crosshair —\n * shared by every cartesian chart factory's \"no data\" early-return so a reactive series\n * transitioning to empty leaves a fully blank chart, not a half-cleared one.\n */\nexport function clearCartesianDom(\n groups: ScaffoldGroups,\n legend: LegendState | null,\n tooltip: TooltipState | null,\n crosshair?: CrosshairState | null,\n): void {\n removeChildren(groups.series);\n removeChildren(groups.grid);\n removeChildren(groups.xAxis);\n removeChildren(groups.yAxis);\n legend?.update([]);\n tooltip?.hide();\n crosshair?.hide();\n}\n\nexport interface ScaffoldContext {\n chartArea: SVGGElement;\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n groups: ScaffoldGroups;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface RadialScaffoldContext {\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface ChartEventHandlers {\n onClick?: (event: MouseEvent) => void;\n onKeyDown?: (event: KeyboardEvent) => void;\n onMouseLeave?: (event: MouseEvent) => void;\n onMouseMove?: (event: MouseEvent) => void;\n}\n\nfunction runScaffold<TCtx>(\n container: HTMLElement,\n config: BaseChartConfig,\n buildCtx: (\n base: {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n svg: SVGSVGElement;\n },\n tooltip: TooltipState | null,\n legend: LegendState | null,\n disposalSignal: AbortSignal,\n ) => TCtx,\n renderFn: (ctx: TCtx) => ChartEventHandlers | void,\n): ChartHandle {\n const base = createChartBase(container, { a11y: config.a11y, ariaLabel: config.ariaLabel, margin: config.margin });\n const tooltip = config.tooltip ? createTooltip(container, config.tooltip) : null;\n const legend = config.legend ? createLegend(container, config.legend) : null;\n const ac = new AbortController();\n const ctx = buildCtx(base, tooltip, legend, ac.signal);\n\n let disposed = false;\n const events = makeEventManager(base.svg);\n\n const scope = createScope();\n\n scope.run(() => {\n effect(\n () => {\n if (disposed) return;\n\n events.attach(renderFn(ctx));\n },\n { scheduler: 'microtask' },\n );\n });\n\n const installedPlugins: ChartPlugin[] = [];\n\n if (config.plugins) {\n const pluginCtx: ChartPluginContext = {\n container,\n dimensions: base.dimensions,\n disposalSignal: ac.signal,\n svg: base.svg,\n };\n\n for (const plugin of config.plugins) {\n try {\n plugin.install(pluginCtx);\n installedPlugins.push(plugin);\n } catch (err) {\n error('A chart plugin threw during install() — skipping it; the rest of the chart still renders.', err);\n }\n }\n }\n\n return {\n get disposalSignal(): AbortSignal {\n return ac.signal;\n },\n\n dispose() {\n if (disposed) return;\n\n disposed = true;\n ac.abort();\n events.detach();\n\n for (const p of installedPlugins) {\n try {\n p.dispose();\n } catch (err) {\n error('A chart plugin threw during dispose() — continuing to tear down the rest of the chart.', err);\n }\n }\n\n tooltip?.dispose();\n legend?.dispose();\n scope.dispose();\n base.dispose();\n },\n\n get disposed(): boolean {\n return disposed;\n },\n\n el: base.svg,\n\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\nfunction makeEventManager(svg: SVGSVGElement): {\n attach(handlers: ChartEventHandlers | void): void;\n detach(): void;\n} {\n let active: ChartEventHandlers | null = null;\n\n return {\n attach(handlers) {\n if (active) {\n if (active.onMouseMove) svg.removeEventListener('mousemove', active.onMouseMove);\n\n if (active.onMouseLeave) svg.removeEventListener('mouseleave', active.onMouseLeave);\n\n if (active.onClick) svg.removeEventListener('click', active.onClick);\n\n if (active.onKeyDown) svg.removeEventListener('keydown', active.onKeyDown);\n\n active = null;\n }\n\n if (!handlers) return;\n\n active = handlers;\n\n if (handlers.onMouseMove) svg.addEventListener('mousemove', handlers.onMouseMove);\n\n if (handlers.onMouseLeave) svg.addEventListener('mouseleave', handlers.onMouseLeave);\n\n if (handlers.onClick) svg.addEventListener('click', handlers.onClick);\n\n if (handlers.onKeyDown) svg.addEventListener('keydown', handlers.onKeyDown);\n },\n detach() {\n this.attach(undefined);\n },\n };\n}\n\n/**\n * Cartesian scaffold: provides grid/axis/series SVG groups and a reactive\n * render loop. `renderFn` is called inside a reactive effect; it returns\n * optional `ChartEventHandlers` that are attached/replaced on every render.\n */\nexport function createChartScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: ScaffoldContext) => ChartEventHandlers | void,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) => {\n const groups: ScaffoldGroups = {\n // Grid lines are purely decorative relative to the root svg's own role=\"img\"/aria-label.\n // Axis groups are NOT hidden wholesale — they can contain a meaningful `.prism-axis-title`;\n // `renderAxis` marks its own decorative tick lines/labels individually instead.\n grid: createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-grid' }),\n series: createSvgElement('g', { class: 'prism-series' }),\n xAxis: createSvgElement('g', { class: 'prism-x-axis' }),\n yAxis: createSvgElement('g', { class: 'prism-y-axis' }),\n };\n\n base.chartArea.appendChild(groups.grid);\n base.chartArea.appendChild(groups.xAxis);\n base.chartArea.appendChild(groups.yAxis);\n base.chartArea.appendChild(groups.series);\n\n return {\n chartArea: base.chartArea,\n container,\n dimensions: base.dimensions,\n disposalSignal,\n groups,\n legend,\n svg: base.svg,\n tooltip,\n } satisfies ScaffoldContext;\n },\n renderFn,\n );\n}\n\n/**\n * Radial scaffold: for charts that do not use cartesian axis groups\n * (pie, donut, semi). Provides only tooltip, legend, and the SVG root.\n */\nexport function createRadialScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: RadialScaffoldContext) => ChartEventHandlers | void,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) =>\n ({\n container,\n dimensions: base.dimensions,\n disposalSignal,\n legend,\n svg: base.svg,\n tooltip,\n }) satisfies RadialScaffoldContext,\n renderFn,\n );\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,EACd,GACA,GACA,GACA,GACM;CAON,AANA,EAAe,EAAO,MAAM,GAC5B,EAAe,EAAO,IAAI,GAC1B,EAAe,EAAO,KAAK,GAC3B,EAAe,EAAO,KAAK,GAC3B,GAAQ,OAAO,CAAC,CAAC,GACjB,GAAS,KAAK,GACd,GAAW,KAAK;AAClB;AA+BA,SAAS,EACP,GACA,GACA,GAUA,GACa;CACb,IAAM,IAAO,EAAgB,GAAW;EAAE,MAAM,EAAO;EAAM,WAAW,EAAO;EAAW,QAAQ,EAAO;CAAO,CAAC,GAC3G,IAAU,EAAO,UAAU,EAAc,GAAW,EAAO,OAAO,IAAI,MACtE,IAAS,EAAO,SAAS,EAAa,GAA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GAEhE,OAGN,MAEL,IAAS,GAEL,EAAS,eAAa,EAAI,iBAAiB,aAAa,EAAS,WAAW,GAE5E,EAAS,gBAAc,EAAI,iBAAiB,cAAc,EAAS,YAAY,GAE/E,EAAS,WAAS,EAAI,iBAAiB,SAAS,EAAS,OAAO,GAEhE,EAAS,aAAW,EAAI,iBAAiB,WAAW,EAAS,SAAS;EAC5E;EACA,SAAS;GACP,KAAK,OAAO,KAAA,CAAS;EACvB;CACF;AACF;AAOA,SAAgB,EACd,GACA,GACA,GACa;CACb,OAAO,EACL,GACA,IACC,GAAM,GAAS,GAAQ,MAAmB;EACzC,IAAM,IAAyB;GAI7B,MAAM,EAAiB,KAAK;IAAE,eAAe;IAAQ,OAAO;GAAa,CAAC;GAC1E,QAAQ,EAAiB,KAAK,EAAE,OAAO,eAAe,CAAC;GACvD,OAAO,EAAiB,KAAK,EAAE,OAAO,eAAe,CAAC;GACtD,OAAO,EAAiB,KAAK,EAAE,OAAO,eAAe,CAAC;EACxD;EAOA,OALA,EAAK,UAAU,YAAY,EAAO,IAAI,GACtC,EAAK,UAAU,YAAY,EAAO,KAAK,GACvC,EAAK,UAAU,YAAY,EAAO,KAAK,GACvC,EAAK,UAAU,YAAY,EAAO,MAAM,GAEjC;GACL,WAAW,EAAK;GAChB;GACA,YAAY,EAAK;GACjB;GACA;GACA;GACA,KAAK,EAAK;GACV;EACF;CACF,GACA,CACF;AACF;AAMA,SAAgB,EACd,GACA,GACA,GACa;CACb,OAAO,EACL,GACA,IACC,GAAM,GAAS,GAAQ,OACrB;EACC;EACA,YAAY,EAAK;EACjB;EACA;EACA,KAAK,EAAK;EACV;CACF,IACF,CACF;AACF"}
1
+ {"version":3,"file":"chart-scaffold.js","names":[],"sources":["../../src/core/chart-scaffold.ts"],"sourcesContent":["import type { Readable } from '@vielzeug/ripple';\n\nimport { createScope, effect } from '@vielzeug/ripple';\nimport { error } from '../_dev';\nimport type { CrosshairState } from '../interaction/crosshair';\nimport type { LegendState } from '../interaction/legend';\nimport { createLegend } from '../interaction/legend';\nimport type { TooltipState } from '../interaction/tooltip';\nimport { createTooltip } from '../interaction/tooltip';\nimport { createSvgElement, removeChildren } from '../svg/element';\nimport type { BaseChartConfig, ChartDimensions, ChartHandle, ChartPlugin, ChartPluginContext } from '../types';\nimport { createChartBase } from './chart-base';\n\nexport interface ScaffoldGroups {\n grid: SVGGElement;\n series: SVGGElement;\n xAxis: SVGGElement;\n yAxis: SVGGElement;\n}\n\n/**\n * Clears a cartesian chart's series/grid/axis groups and hides its legend/tooltip/crosshair —\n * shared by every cartesian chart factory's \"no data\" early-return so a reactive series\n * transitioning to empty leaves a fully blank chart, not a half-cleared one.\n */\nexport function clearCartesianDom(\n groups: ScaffoldGroups,\n legend: LegendState | null,\n tooltip: TooltipState | null,\n crosshair?: CrosshairState | null,\n): void {\n removeChildren(groups.series);\n removeChildren(groups.grid);\n removeChildren(groups.xAxis);\n removeChildren(groups.yAxis);\n legend?.update([]);\n tooltip?.hide();\n crosshair?.hide();\n}\n\nexport interface ScaffoldContext {\n chartArea: SVGGElement;\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n groups: ScaffoldGroups;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface RadialScaffoldContext {\n container: HTMLElement;\n dimensions: Readable<ChartDimensions>;\n /** Aborted when the chart is disposed — renderers use this to stop rescheduling in-flight `requestAnimationFrame` transitions. */\n disposalSignal: AbortSignal;\n legend: LegendState | null;\n svg: SVGSVGElement;\n tooltip: TooltipState | null;\n}\n\nexport interface ChartEventHandlers {\n onClick?: (event: MouseEvent) => void;\n onKeyDown?: (event: KeyboardEvent) => void;\n onMouseLeave?: (event: MouseEvent) => void;\n onMouseMove?: (event: MouseEvent) => void;\n}\n\nfunction runScaffold<TCtx>(\n container: HTMLElement,\n config: BaseChartConfig,\n buildCtx: (\n base: {\n chartArea: SVGGElement;\n dimensions: Readable<ChartDimensions>;\n svg: SVGSVGElement;\n },\n tooltip: TooltipState | null,\n legend: LegendState | null,\n disposalSignal: AbortSignal,\n ) => TCtx,\n renderFn: (ctx: TCtx) => ChartEventHandlers | undefined,\n): ChartHandle {\n const base = createChartBase(container, { a11y: config.a11y, ariaLabel: config.ariaLabel, margin: config.margin });\n const tooltip = config.tooltip ? createTooltip(container, config.tooltip) : null;\n const legend = config.legend ? createLegend(container, config.legend) : null;\n const ac = new AbortController();\n const ctx = buildCtx(base, tooltip, legend, ac.signal);\n\n let disposed = false;\n const events = makeEventManager(base.svg);\n\n const scope = createScope();\n\n scope.run(() => {\n effect(\n () => {\n if (disposed) return;\n\n events.attach(renderFn(ctx));\n },\n { scheduler: 'microtask' },\n );\n });\n\n const installedPlugins: ChartPlugin[] = [];\n\n if (config.plugins) {\n const pluginCtx: ChartPluginContext = {\n container,\n dimensions: base.dimensions,\n disposalSignal: ac.signal,\n svg: base.svg,\n };\n\n for (const plugin of config.plugins) {\n try {\n plugin.install(pluginCtx);\n installedPlugins.push(plugin);\n } catch (err) {\n error('A chart plugin threw during install() — skipping it; the rest of the chart still renders.', err);\n }\n }\n }\n\n return {\n get disposalSignal(): AbortSignal {\n return ac.signal;\n },\n\n dispose() {\n if (disposed) return;\n\n disposed = true;\n ac.abort();\n events.detach();\n\n for (const p of installedPlugins) {\n try {\n p.dispose();\n } catch (err) {\n error('A chart plugin threw during dispose() — continuing to tear down the rest of the chart.', err);\n }\n }\n\n tooltip?.dispose();\n legend?.dispose();\n scope.dispose();\n base.dispose();\n },\n\n get disposed(): boolean {\n return disposed;\n },\n\n el: base.svg,\n\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\nfunction makeEventManager(svg: SVGSVGElement): {\n attach(handlers: ChartEventHandlers | undefined): void;\n detach(): void;\n} {\n let active: ChartEventHandlers | null = null;\n\n return {\n attach(handlers) {\n if (active) {\n if (active.onMouseMove) svg.removeEventListener('mousemove', active.onMouseMove);\n\n if (active.onMouseLeave) svg.removeEventListener('mouseleave', active.onMouseLeave);\n\n if (active.onClick) svg.removeEventListener('click', active.onClick);\n\n if (active.onKeyDown) svg.removeEventListener('keydown', active.onKeyDown);\n\n active = null;\n }\n\n if (!handlers) return;\n\n active = handlers;\n\n if (handlers.onMouseMove) svg.addEventListener('mousemove', handlers.onMouseMove);\n\n if (handlers.onMouseLeave) svg.addEventListener('mouseleave', handlers.onMouseLeave);\n\n if (handlers.onClick) svg.addEventListener('click', handlers.onClick);\n\n if (handlers.onKeyDown) svg.addEventListener('keydown', handlers.onKeyDown);\n },\n detach() {\n this.attach(undefined);\n },\n };\n}\n\n/**\n * Cartesian scaffold: provides grid/axis/series SVG groups and a reactive\n * render loop. `renderFn` is called inside a reactive effect; it returns\n * optional `ChartEventHandlers` that are attached/replaced on every render.\n */\nexport function createChartScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: ScaffoldContext) => ChartEventHandlers | undefined,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) => {\n const groups: ScaffoldGroups = {\n // Grid lines are purely decorative relative to the root svg's own role=\"img\"/aria-label.\n // Axis groups are NOT hidden wholesale — they can contain a meaningful `.prism-axis-title`;\n // `renderAxis` marks its own decorative tick lines/labels individually instead.\n grid: createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-grid' }),\n series: createSvgElement('g', { class: 'prism-series' }),\n xAxis: createSvgElement('g', { class: 'prism-x-axis' }),\n yAxis: createSvgElement('g', { class: 'prism-y-axis' }),\n };\n\n base.chartArea.appendChild(groups.grid);\n base.chartArea.appendChild(groups.xAxis);\n base.chartArea.appendChild(groups.yAxis);\n base.chartArea.appendChild(groups.series);\n\n return {\n chartArea: base.chartArea,\n container,\n dimensions: base.dimensions,\n disposalSignal,\n groups,\n legend,\n svg: base.svg,\n tooltip,\n } satisfies ScaffoldContext;\n },\n renderFn,\n );\n}\n\n/**\n * Radial scaffold: for charts that do not use cartesian axis groups\n * (pie, donut, semi). Provides only tooltip, legend, and the SVG root.\n */\nexport function createRadialScaffold(\n container: HTMLElement,\n config: BaseChartConfig,\n renderFn: (ctx: RadialScaffoldContext) => ChartEventHandlers | undefined,\n): ChartHandle {\n return runScaffold(\n container,\n config,\n (base, tooltip, legend, disposalSignal) =>\n ({\n container,\n dimensions: base.dimensions,\n disposalSignal,\n legend,\n svg: base.svg,\n tooltip,\n }) satisfies RadialScaffoldContext,\n renderFn,\n );\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,EACd,GACA,GACA,GACA,GACM;CAON,AANA,EAAe,EAAO,MAAM,GAC5B,EAAe,EAAO,IAAI,GAC1B,EAAe,EAAO,KAAK,GAC3B,EAAe,EAAO,KAAK,GAC3B,GAAQ,OAAO,CAAC,CAAC,GACjB,GAAS,KAAK,GACd,GAAW,KAAK;AAClB;AA+BA,SAAS,EACP,GACA,GACA,GAUA,GACa;CACb,IAAM,IAAO,EAAgB,GAAW;EAAE,MAAM,EAAO;EAAM,WAAW,EAAO;EAAW,QAAQ,EAAO;CAAO,CAAC,GAC3G,IAAU,EAAO,UAAU,EAAc,GAAW,EAAO,OAAO,IAAI,MACtE,IAAS,EAAO,SAAS,EAAa,GAAW,EAAO,MAAM,IAAI,MAClE,IAAK,IAAI,gBAAgB,GACzB,IAAM,EAAS,GAAM,GAAS,GAAQ,EAAG,MAAM,GAEjD,IAAW,IACT,IAAS,EAAiB,EAAK,GAAG,GAElC,IAAQ,EAAY;CAE1B,EAAM,UAAU;EACd,QACQ;GACA,KAEJ,EAAO,OAAO,EAAS,CAAG,CAAC;EAC7B,GACA,EAAE,WAAW,YAAY,CAC3B;CACF,CAAC;CAED,IAAM,IAAkC,CAAC;CAEzC,IAAI,EAAO,SAAS;EAClB,IAAM,IAAgC;GACpC;GACA,YAAY,EAAK;GACjB,gBAAgB,EAAG;GACnB,KAAK,EAAK;EACZ;EAEA,KAAK,IAAM,KAAU,EAAO,SA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O;GAAa,CAAC;GAC1E,QAAQ,EAAiB,KAAK,EAAE,OAAO,eAAe,CAAC;GACvD,OAAO,EAAiB,KAAK,EAAE,OAAO,eAAe,CAAC;GACtD,OAAO,EAAiB,KAAK,EAAE,OAAO,eAAe,CAAC;EACxD;EAOA,OALA,EAAK,UAAU,YAAY,EAAO,IAAI,GACtC,EAAK,UAAU,YAAY,EAAO,KAAK,GACvC,EAAK,UAAU,YAAY,EAAO,KAAK,GACvC,EAAK,UAAU,YAAY,EAAO,MAAM,GAEjC;GACL,WAAW,EAAK;GAChB;GACA,YAAY,EAAK;GACjB;GACA;GACA;GACA,KAAK,EAAK;GACV;EACF;CACF,GACA,CACF;AACF;AAMA,SAAgB,EACd,GACA,GACA,GACa;CACb,OAAO,EACL,GACA,IACC,GAAM,GAAS,GAAQ,OACrB;EACC;EACA,YAAY,EAAK;EACjB;EACA;EACA,KAAK,EAAK;EACV;CACF,IACF,CACF;AACF"}
@@ -1,7 +1,7 @@
1
- export { createChartBase } from './chart-base';
2
1
  export type { ChartBase } from './chart-base';
3
- export { createChartScaffold, createRadialScaffold } from './chart-scaffold';
2
+ export { createChartBase } from './chart-base';
4
3
  export type { ChartEventHandlers, RadialScaffoldContext, ScaffoldContext, ScaffoldGroups } from './chart-scaffold';
4
+ export { createChartScaffold, createRadialScaffold } from './chart-scaffold';
5
5
  export { chartArea, resolveMargin } from './layout';
6
6
  export { observeResize } from './responsive';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./errors.cjs"),t=require("./scales/linear.cjs"),n=require("./scales/time.cjs"),r=require("./theme/index.cjs"),i=require("./charts/area/area-chart.cjs"),a=require("./scales/band.cjs"),o=require("./animation/transition.cjs"),s=require("./charts/bar/bar-chart.cjs"),c=require("./charts/line/line-chart.cjs"),l=require("./charts/pie/pie-chart.cjs"),u=require("./charts/sparkline/sparkline.cjs");exports.PrismDisposedError=e.PrismDisposedError,exports.PrismError=e.PrismError,exports.PrismRenderError=e.PrismRenderError,exports.animate=o.animate,exports.bandScale=a.bandScale,exports.createAreaChart=i.createAreaChart,exports.createBarChart=s.createBarChart,exports.createLineChart=c.createLineChart,exports.createPieChart=l.createPieChart,exports.createSparkline=u.createSparkline,exports.linearScale=t.linearScale,exports.resetTheme=r.resetTheme,exports.seriesColor=r.seriesColor,exports.setTheme=r.setTheme,exports.timeScale=n.timeScale;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./animation/transition.cjs"),t=require("./scales/linear.cjs"),n=require("./scales/time.cjs"),r=require("./errors.cjs"),i=require("./theme/index.cjs"),a=require("./charts/area/area-chart.cjs"),o=require("./scales/band.cjs"),s=require("./charts/bar/bar-chart.cjs"),c=require("./charts/line/line-chart.cjs"),l=require("./charts/pie/pie-chart.cjs"),u=require("./charts/sparkline/sparkline.cjs");exports.PrismDisposedError=r.PrismDisposedError,exports.PrismError=r.PrismError,exports.PrismRenderError=r.PrismRenderError,exports.animate=e.animate,exports.bandScale=o.bandScale,exports.createAreaChart=a.createAreaChart,exports.createBarChart=s.createBarChart,exports.createLineChart=c.createLineChart,exports.createPieChart=l.createPieChart,exports.createSparkline=u.createSparkline,exports.linearScale=t.linearScale,exports.resetTheme=i.resetTheme,exports.seriesColor=i.seriesColor,exports.setTheme=i.setTheme,exports.timeScale=n.timeScale;
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- export type { AreaChartConfig, AreaSeriesConfig, AxisConfig, AxisPosition, BandScale, BarChartConfig, BarSeriesConfig, BarVariant, BaseChartConfig, ChartA11y, ChartDimensions, ChartEvent, ChartHandle, ChartMargin, ChartPlugin, ChartPluginContext, CrosshairConfig, Datum, GridConfig, LegendConfig, LegendPosition, LineChartConfig, LineSeriesConfig, MaybeSignal, PieChartConfig, PieSliceConfig, PieVariant, PrismTheme, Scale, Series, SparklineConfig, SparklineVariant, StackSegment, TooltipConfig, TransitionConfig, } from './types';
2
- export { PrismDisposedError, PrismError, PrismRenderError } from './errors';
1
+ export type { EasingFn } from './animation/easing';
2
+ export type { AnimationTarget } from './animation/transition';
3
+ export { animate } from './animation/transition';
3
4
  export { createAreaChart } from './charts/area';
4
5
  export { createBarChart } from './charts/bar';
5
6
  export { createLineChart } from './charts/line';
6
7
  export { createPieChart } from './charts/pie';
7
8
  export { createSparkline } from './charts/sparkline';
9
+ export { PrismDisposedError, PrismError, PrismRenderError } from './errors';
10
+ export type { LegendState } from './interaction/legend';
11
+ export type { TooltipState } from './interaction/tooltip';
8
12
  export { bandScale } from './scales/band';
9
13
  export { linearScale } from './scales/linear';
10
14
  export { timeScale } from './scales/time';
11
- export { animate } from './animation/transition';
12
- export type { AnimationTarget } from './animation/transition';
13
- export type { EasingFn } from './animation/easing';
14
- export type { LegendState } from './interaction/legend';
15
- export type { TooltipState } from './interaction/tooltip';
16
15
  export type { Point } from './svg/path';
17
16
  export { resetTheme, seriesColor, setTheme } from './theme';
17
+ export type { AreaChartConfig, AreaSeriesConfig, AxisConfig, AxisPosition, BandScale, BarChartConfig, BarSeriesConfig, BarVariant, BaseChartConfig, ChartA11y, ChartDimensions, ChartEvent, ChartHandle, ChartMargin, ChartPlugin, ChartPluginContext, CrosshairConfig, Datum, GridConfig, LegendConfig, LegendPosition, LineChartConfig, LineSeriesConfig, MaybeSignal, PieChartConfig, PieSliceConfig, PieVariant, PrismTheme, Scale, Series, SparklineConfig, SparklineVariant, StackSegment, TooltipConfig, TransitionConfig, } from './types';
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,KAAK,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,KAAK,EACL,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5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oB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5E,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,KAAK,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,KAAK,EACL,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { PrismDisposedError as e, PrismError as t, PrismRenderError as n } from "./errors.js";
2
- import { linearScale as r } from "./scales/linear.js";
3
- import { timeScale as i } from "./scales/time.js";
4
- import { resetTheme as a, seriesColor as o, setTheme as s } from "./theme/index.js";
5
- import { createAreaChart as c } from "./charts/area/area-chart.js";
6
- import { bandScale as l } from "./scales/band.js";
7
- import { animate as u } from "./animation/transition.js";
1
+ import { animate as e } from "./animation/transition.js";
2
+ import { linearScale as t } from "./scales/linear.js";
3
+ import { timeScale as n } from "./scales/time.js";
4
+ import { PrismDisposedError as r, PrismError as i, PrismRenderError as a } from "./errors.js";
5
+ import { resetTheme as o, seriesColor as s, setTheme as c } from "./theme/index.js";
6
+ import { createAreaChart as l } from "./charts/area/area-chart.js";
7
+ import { bandScale as u } from "./scales/band.js";
8
8
  import { createBarChart as d } from "./charts/bar/bar-chart.js";
9
9
  import { createLineChart as f } from "./charts/line/line-chart.js";
10
10
  import { createPieChart as p } from "./charts/pie/pie-chart.js";
11
11
  import { createSparkline as m } from "./charts/sparkline/sparkline.js";
12
- export { e as PrismDisposedError, t as PrismError, n as PrismRenderError, u as animate, l as bandScale, c as createAreaChart, d as createBarChart, f as createLineChart, p as createPieChart, m as createSparkline, r as linearScale, a as resetTheme, o as seriesColor, s as setTheme, i as timeScale };
12
+ export { r as PrismDisposedError, i as PrismError, a as PrismRenderError, e as animate, u as bandScale, l as createAreaChart, d as createBarChart, f as createLineChart, p as createPieChart, m as createSparkline, t as linearScale, o as resetTheme, s as seriesColor, c as setTheme, n as timeScale };
@@ -1 +1 @@
1
- {"version":3,"file":"crosshair.cjs","names":[],"sources":["../../src/interaction/crosshair.ts"],"sourcesContent":["import type { CrosshairConfig } from '../types';\n\nimport { createSvgElement, setAttributes } from '../svg/element';\n\nexport interface CrosshairState {\n hide(): void;\n /** When `false`, the crosshair follows the raw mouse position instead of snapping to the nearest datum. */\n readonly snap: boolean;\n /**\n * @param announceText Optional text describing the value at the crosshair position,\n * announced via the crosshair's ARIA live region — used when no tooltip is also shown.\n */\n show(x: number, y: number, width: number, height: number, announceText?: string): void;\n}\n\nexport function createCrosshair(parent: SVGGElement, config?: CrosshairConfig | true): CrosshairState {\n const showVertical = config === true || config?.vertical !== false;\n const showHorizontal = config !== true && config?.horizontal === true;\n const snap = config === true || config?.snap !== false;\n\n const group = createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-crosshair', style: 'display:none' });\n\n const vLine = showVertical\n ? createSvgElement('line', { class: 'prism-crosshair-v', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n const hLine = showHorizontal\n ? createSvgElement('line', { class: 'prism-crosshair-h', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n\n if (vLine) group.appendChild(vLine);\n\n if (hLine) group.appendChild(hLine);\n\n parent.appendChild(group);\n\n // Non-modal status region for screen readers — the visual crosshair lines above are\n // aria-hidden (purely decorative), so the current value is announced here instead.\n // Positioned off-canvas rather than visually hidden via CSS so it works without prism's stylesheet.\n const liveRegion = createSvgElement('text', {\n 'aria-live': 'polite',\n class: 'prism-crosshair-live',\n role: 'status',\n x: -9999,\n y: -9999,\n });\n\n parent.appendChild(liveRegion);\n\n return {\n hide() {\n group.style.display = 'none';\n liveRegion.textContent = '';\n },\n show(x: number, y: number, width: number, height: number, announceText?: string) {\n group.style.display = '';\n\n if (vLine) setAttributes(vLine, { x1: x, x2: x, y1: 0, y2: height });\n\n if (hLine) setAttributes(hLine, { x1: 0, x2: width, y1: y, y2: y });\n\n if (announceText !== undefined) liveRegion.textContent = announceText;\n },\n snap,\n };\n}\n"],"mappings":"sCAeA,SAAgB,EAAgB,EAAqB,EAAiD,CACpG,IAAM,EAAe,IAAW,IAAQ,GAAQ,WAAa,GACvD,EAAiB,IAAW,IAAQ,GAAQ,aAAe,GAC3D,EAAO,IAAW,IAAQ,GAAQ,OAAS,GAE3C,EAAQ,EAAA,iBAAiB,IAAK,CAAE,cAAe,OAAQ,MAAO,kBAAmB,MAAO,cAAe,CAAC,EAExG,EAAQ,EACV,EAAA,iBAAiB,OAAQ,CAAE,MAAO,oBAAqB,mBAAoB,kCAAmC,CAAC,EAC/G,KACE,EAAQ,EACV,EAAA,iBAAiB,OAAQ,CAAE,MAAO,oBAAqB,mBAAoB,kCAAmC,CAAC,EAC/G,KAEA,GAAO,EAAM,YAAY,CAAK,EAE9B,GAAO,EAAM,YAAY,CAAK,EAElC,EAAO,YAAY,CAAK,EAKxB,IAAM,EAAa,EAAA,iBAAiB,OAAQ,CAC1C,YAAa,SACb,MAAO,uBACP,KAAM,SACN,EAAG,MACH,EAAG,KACL,CAAC,EAID,OAFA,EAAO,YAAY,CAAU,EAEtB,CACL,MAAO,CACL,EAAM,MAAM,QAAU,OACtB,EAAW,YAAc,EAC3B,EACA,KAAK,EAAW,EAAW,EAAe,EAAgB,EAAuB,CAC/E,EAAM,MAAM,QAAU,GAElB,GAAO,EAAA,cAAc,EAAO,CAAE,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,CAAO,CAAC,EAE/D,GAAO,EAAA,cAAc,EAAO,CAAE,GAAI,EAAG,GAAI,EAAO,GAAI,EAAG,GAAI,CAAE,CAAC,EAE9D,IAAiB,IAAA,KAAW,EAAW,YAAc,EAC3D,EACA,MACF,CACF"}
1
+ {"version":3,"file":"crosshair.cjs","names":[],"sources":["../../src/interaction/crosshair.ts"],"sourcesContent":["import { createSvgElement, setAttributes } from '../svg/element';\nimport type { CrosshairConfig } from '../types';\n\nexport interface CrosshairState {\n hide(): void;\n /**\n * @param announceText Optional text describing the value at the crosshair position,\n * announced via the crosshair's ARIA live region — used when no tooltip is also shown.\n */\n show(x: number, y: number, width: number, height: number, announceText?: string): void;\n /** When `false`, the crosshair follows the raw mouse position instead of snapping to the nearest datum. */\n readonly snap: boolean;\n}\n\nexport function createCrosshair(parent: SVGGElement, config?: CrosshairConfig | true): CrosshairState {\n const showVertical = config === true || config?.vertical !== false;\n const showHorizontal = config !== true && config?.horizontal === true;\n const snap = config === true || config?.snap !== false;\n\n const group = createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-crosshair', style: 'display:none' });\n\n const vLine = showVertical\n ? createSvgElement('line', { class: 'prism-crosshair-v', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n const hLine = showHorizontal\n ? createSvgElement('line', { class: 'prism-crosshair-h', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n\n if (vLine) group.appendChild(vLine);\n\n if (hLine) group.appendChild(hLine);\n\n parent.appendChild(group);\n\n // Non-modal status region for screen readers — the visual crosshair lines above are\n // aria-hidden (purely decorative), so the current value is announced here instead.\n // Positioned off-canvas rather than visually hidden via CSS so it works without prism's stylesheet.\n const liveRegion = createSvgElement('text', {\n 'aria-live': 'polite',\n class: 'prism-crosshair-live',\n role: 'status',\n x: -9999,\n y: -9999,\n });\n\n parent.appendChild(liveRegion);\n\n return {\n hide() {\n group.style.display = 'none';\n liveRegion.textContent = '';\n },\n show(x: number, y: number, width: number, height: number, announceText?: string) {\n group.style.display = '';\n\n if (vLine) setAttributes(vLine, { x1: x, x2: x, y1: 0, y2: height });\n\n if (hLine) setAttributes(hLine, { x1: 0, x2: width, y1: y, y2: y });\n\n if (announceText !== undefined) liveRegion.textContent = announceText;\n },\n snap,\n };\n}\n"],"mappings":"sCAcA,SAAgB,EAAgB,EAAqB,EAAiD,CACpG,IAAM,EAAe,IAAW,IAAQ,GAAQ,WAAa,GACvD,EAAiB,IAAW,IAAQ,GAAQ,aAAe,GAC3D,EAAO,IAAW,IAAQ,GAAQ,OAAS,GAE3C,EAAQ,EAAA,iBAAiB,IAAK,CAAE,cAAe,OAAQ,MAAO,kBAAmB,MAAO,cAAe,CAAC,EAExG,EAAQ,EACV,EAAA,iBAAiB,OAAQ,CAAE,MAAO,oBAAqB,mBAAoB,kCAAmC,CAAC,EAC/G,KACE,EAAQ,EACV,EAAA,iBAAiB,OAAQ,CAAE,MAAO,oBAAqB,mBAAoB,kCAAmC,CAAC,EAC/G,KAEA,GAAO,EAAM,YAAY,CAAK,EAE9B,GAAO,EAAM,YAAY,CAAK,EAElC,EAAO,YAAY,CAAK,EAKxB,IAAM,EAAa,EAAA,iBAAiB,OAAQ,CAC1C,YAAa,SACb,MAAO,uBACP,KAAM,SACN,EAAG,MACH,EAAG,KACL,CAAC,EAID,OAFA,EAAO,YAAY,CAAU,EAEtB,CACL,MAAO,CACL,EAAM,MAAM,QAAU,OACtB,EAAW,YAAc,EAC3B,EACA,KAAK,EAAW,EAAW,EAAe,EAAgB,EAAuB,CAC/E,EAAM,MAAM,QAAU,GAElB,GAAO,EAAA,cAAc,EAAO,CAAE,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,CAAO,CAAC,EAE/D,GAAO,EAAA,cAAc,EAAO,CAAE,GAAI,EAAG,GAAI,EAAO,GAAI,EAAG,GAAI,CAAE,CAAC,EAE9D,IAAiB,IAAA,KAAW,EAAW,YAAc,EAC3D,EACA,MACF,CACF"}
@@ -1,13 +1,13 @@
1
1
  import type { CrosshairConfig } from '../types';
2
2
  export interface CrosshairState {
3
3
  hide(): void;
4
- /** When `false`, the crosshair follows the raw mouse position instead of snapping to the nearest datum. */
5
- readonly snap: boolean;
6
4
  /**
7
5
  * @param announceText Optional text describing the value at the crosshair position,
8
6
  * announced via the crosshair's ARIA live region — used when no tooltip is also shown.
9
7
  */
10
8
  show(x: number, y: number, width: number, height: number, announceText?: string): void;
9
+ /** When `false`, the crosshair follows the raw mouse position instead of snapping to the nearest datum. */
10
+ readonly snap: boolean;
11
11
  }
12
12
  export declare function createCrosshair(parent: SVGGElement, config?: CrosshairConfig | true): CrosshairState;
13
13
  //# sourceMappingURL=crosshair.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crosshair.d.ts","sourceRoot":"","sources":["../../src/interaction/crosshair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhD,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;IACb,2GAA2G;IAC3G,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxF;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,cAAc,CAiDpG"}
1
+ {"version":3,"file":"crosshair.d.ts","sourceRoot":"","sources":["../../src/interaction/crosshair.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvF,2GAA2G;IAC3G,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,cAAc,CAiDpG"}
@@ -1 +1 @@
1
- {"version":3,"file":"crosshair.js","names":[],"sources":["../../src/interaction/crosshair.ts"],"sourcesContent":["import type { CrosshairConfig } from '../types';\n\nimport { createSvgElement, setAttributes } from '../svg/element';\n\nexport interface CrosshairState {\n hide(): void;\n /** When `false`, the crosshair follows the raw mouse position instead of snapping to the nearest datum. */\n readonly snap: boolean;\n /**\n * @param announceText Optional text describing the value at the crosshair position,\n * announced via the crosshair's ARIA live region — used when no tooltip is also shown.\n */\n show(x: number, y: number, width: number, height: number, announceText?: string): void;\n}\n\nexport function createCrosshair(parent: SVGGElement, config?: CrosshairConfig | true): CrosshairState {\n const showVertical = config === true || config?.vertical !== false;\n const showHorizontal = config !== true && config?.horizontal === true;\n const snap = config === true || config?.snap !== false;\n\n const group = createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-crosshair', style: 'display:none' });\n\n const vLine = showVertical\n ? createSvgElement('line', { class: 'prism-crosshair-v', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n const hLine = showHorizontal\n ? createSvgElement('line', { class: 'prism-crosshair-h', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n\n if (vLine) group.appendChild(vLine);\n\n if (hLine) group.appendChild(hLine);\n\n parent.appendChild(group);\n\n // Non-modal status region for screen readers — the visual crosshair lines above are\n // aria-hidden (purely decorative), so the current value is announced here instead.\n // Positioned off-canvas rather than visually hidden via CSS so it works without prism's stylesheet.\n const liveRegion = createSvgElement('text', {\n 'aria-live': 'polite',\n class: 'prism-crosshair-live',\n role: 'status',\n x: -9999,\n y: -9999,\n });\n\n parent.appendChild(liveRegion);\n\n return {\n hide() {\n group.style.display = 'none';\n liveRegion.textContent = '';\n },\n show(x: number, y: number, width: number, height: number, announceText?: string) {\n group.style.display = '';\n\n if (vLine) setAttributes(vLine, { x1: x, x2: x, y1: 0, y2: height });\n\n if (hLine) setAttributes(hLine, { x1: 0, x2: width, y1: y, y2: y });\n\n if (announceText !== undefined) liveRegion.textContent = announceText;\n },\n snap,\n };\n}\n"],"mappings":";;AAeA,SAAgB,EAAgB,GAAqB,GAAiD;CACpG,IAAM,IAAe,MAAW,MAAQ,GAAQ,aAAa,IACvD,IAAiB,MAAW,MAAQ,GAAQ,eAAe,IAC3D,IAAO,MAAW,MAAQ,GAAQ,SAAS,IAE3C,IAAQ,EAAiB,KAAK;EAAE,eAAe;EAAQ,OAAO;EAAmB,OAAO;CAAe,CAAC,GAExG,IAAQ,IACV,EAAiB,QAAQ;EAAE,OAAO;EAAqB,oBAAoB;CAAmC,CAAC,IAC/G,MACE,IAAQ,IACV,EAAiB,QAAQ;EAAE,OAAO;EAAqB,oBAAoB;CAAmC,CAAC,IAC/G;CAMJ,AAJI,KAAO,EAAM,YAAY,CAAK,GAE9B,KAAO,EAAM,YAAY,CAAK,GAElC,EAAO,YAAY,CAAK;CAKxB,IAAM,IAAa,EAAiB,QAAQ;EAC1C,aAAa;EACb,OAAO;EACP,MAAM;EACN,GAAG;EACH,GAAG;CACL,CAAC;CAID,OAFA,EAAO,YAAY,CAAU,GAEtB;EACL,OAAO;GAEL,AADA,EAAM,MAAM,UAAU,QACtB,EAAW,cAAc;EAC3B;EACA,KAAK,GAAW,GAAW,GAAe,GAAgB,GAAuB;GAO/E,AANA,EAAM,MAAM,UAAU,IAElB,KAAO,EAAc,GAAO;IAAE,IAAI;IAAG,IAAI;IAAG,IAAI;IAAG,IAAI;GAAO,CAAC,GAE/D,KAAO,EAAc,GAAO;IAAE,IAAI;IAAG,IAAI;IAAO,IAAI;IAAG,IAAI;GAAE,CAAC,GAE9D,MAAiB,KAAA,MAAW,EAAW,cAAc;EAC3D;EACA;CACF;AACF"}
1
+ {"version":3,"file":"crosshair.js","names":[],"sources":["../../src/interaction/crosshair.ts"],"sourcesContent":["import { createSvgElement, setAttributes } from '../svg/element';\nimport type { CrosshairConfig } from '../types';\n\nexport interface CrosshairState {\n hide(): void;\n /**\n * @param announceText Optional text describing the value at the crosshair position,\n * announced via the crosshair's ARIA live region — used when no tooltip is also shown.\n */\n show(x: number, y: number, width: number, height: number, announceText?: string): void;\n /** When `false`, the crosshair follows the raw mouse position instead of snapping to the nearest datum. */\n readonly snap: boolean;\n}\n\nexport function createCrosshair(parent: SVGGElement, config?: CrosshairConfig | true): CrosshairState {\n const showVertical = config === true || config?.vertical !== false;\n const showHorizontal = config !== true && config?.horizontal === true;\n const snap = config === true || config?.snap !== false;\n\n const group = createSvgElement('g', { 'aria-hidden': 'true', class: 'prism-crosshair', style: 'display:none' });\n\n const vLine = showVertical\n ? createSvgElement('line', { class: 'prism-crosshair-v', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n const hLine = showHorizontal\n ? createSvgElement('line', { class: 'prism-crosshair-h', 'stroke-dasharray': 'var(--prism-crosshair-dash, 4 2)' })\n : null;\n\n if (vLine) group.appendChild(vLine);\n\n if (hLine) group.appendChild(hLine);\n\n parent.appendChild(group);\n\n // Non-modal status region for screen readers — the visual crosshair lines above are\n // aria-hidden (purely decorative), so the current value is announced here instead.\n // Positioned off-canvas rather than visually hidden via CSS so it works without prism's stylesheet.\n const liveRegion = createSvgElement('text', {\n 'aria-live': 'polite',\n class: 'prism-crosshair-live',\n role: 'status',\n x: -9999,\n y: -9999,\n });\n\n parent.appendChild(liveRegion);\n\n return {\n hide() {\n group.style.display = 'none';\n liveRegion.textContent = '';\n },\n show(x: number, y: number, width: number, height: number, announceText?: string) {\n group.style.display = '';\n\n if (vLine) setAttributes(vLine, { x1: x, x2: x, y1: 0, y2: height });\n\n if (hLine) setAttributes(hLine, { x1: 0, x2: width, y1: y, y2: y });\n\n if (announceText !== undefined) liveRegion.textContent = announceText;\n },\n snap,\n };\n}\n"],"mappings":";;AAcA,SAAgB,EAAgB,GAAqB,GAAiD;CACpG,IAAM,IAAe,MAAW,MAAQ,GAAQ,aAAa,IACvD,IAAiB,MAAW,MAAQ,GAAQ,eAAe,IAC3D,IAAO,MAAW,MAAQ,GAAQ,SAAS,IAE3C,IAAQ,EAAiB,KAAK;EAAE,eAAe;EAAQ,OAAO;EAAmB,OAAO;CAAe,CAAC,GAExG,IAAQ,IACV,EAAiB,QAAQ;EAAE,OAAO;EAAqB,oBAAoB;CAAmC,CAAC,IAC/G,MACE,IAAQ,IACV,EAAiB,QAAQ;EAAE,OAAO;EAAqB,oBAAoB;CAAmC,CAAC,IAC/G;CAMJ,AAJI,KAAO,EAAM,YAAY,CAAK,GAE9B,KAAO,EAAM,YAAY,CAAK,GAElC,EAAO,YAAY,CAAK;CAKxB,IAAM,IAAa,EAAiB,QAAQ;EAC1C,aAAa;EACb,OAAO;EACP,MAAM;EACN,GAAG;EACH,GAAG;CACL,CAAC;CAID,OAFA,EAAO,YAAY,CAAU,GAEtB;EACL,OAAO;GAEL,AADA,EAAM,MAAM,UAAU,QACtB,EAAW,cAAc;EAC3B;EACA,KAAK,GAAW,GAAW,GAAe,GAAgB,GAAuB;GAO/E,AANA,EAAM,MAAM,UAAU,IAElB,KAAO,EAAc,GAAO;IAAE,IAAI;IAAG,IAAI;IAAG,IAAI;IAAG,IAAI;GAAO,CAAC,GAE/D,KAAO,EAAc,GAAO;IAAE,IAAI;IAAG,IAAI;IAAO,IAAI;IAAG,IAAI;GAAE,CAAC,GAE9D,MAAiB,KAAA,MAAW,EAAW,cAAc;EAC3D;EACA;CACF;AACF"}
@@ -1,9 +1,9 @@
1
- export { createCrosshair } from './crosshair';
2
1
  export type { CrosshairState } from './crosshair';
2
+ export { createCrosshair } from './crosshair';
3
3
  export { getMousePosition } from './events';
4
4
  export { nearestPointX } from './hit-test';
5
- export { createLegend } from './legend';
6
5
  export type { LegendState } from './legend';
7
- export { createTooltip } from './tooltip';
6
+ export { createLegend } from './legend';
8
7
  export type { TooltipState } from './tooltip';
8
+ export { createTooltip } from './tooltip';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interaction/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"legend.cjs","names":[],"sources":["../../src/interaction/legend.ts"],"sourcesContent":["import type { LegendConfig, LegendPosition } from '../types';\n\nexport interface LegendState {\n dispose(): void;\n [Symbol.dispose](): void;\n el: HTMLDivElement | null;\n update(series: { color: string; name: string }[]): void;\n}\n\nfunction resolvePosition(config: LegendConfig | true): LegendPosition {\n if (config === true) return 'bottom';\n\n return config.position ?? 'bottom';\n}\n\nexport function createLegend(container: HTMLElement, config: LegendConfig | true): LegendState {\n const position = resolvePosition(config);\n const el = document.createElement('div');\n\n el.className = `prism-legend prism-legend-${position}`;\n\n if (position === 'top') {\n container.insertBefore(el, container.firstChild);\n } else {\n container.appendChild(el);\n }\n\n const disposeHandle = (): void => {\n el.remove();\n };\n\n return {\n dispose: disposeHandle,\n el,\n [Symbol.dispose]: disposeHandle,\n update(series) {\n el.innerHTML = '';\n for (const s of series) {\n const item = document.createElement('div');\n\n item.className = 'prism-legend-item';\n\n const dot = document.createElement('span');\n\n dot.className = 'prism-legend-dot';\n dot.style.backgroundColor = s.color;\n\n const label = document.createElement('span');\n\n label.className = 'prism-legend-label';\n label.textContent = s.name;\n\n item.appendChild(dot);\n item.appendChild(label);\n el.appendChild(item);\n }\n },\n };\n}\n"],"mappings":"AASA,SAAS,EAAgB,EAA6C,CAGpE,OAFI,IAAW,GAAa,SAErB,EAAO,UAAY,QAC5B,CAEA,SAAgB,EAAa,EAAwB,EAA0C,CAC7F,IAAM,EAAW,EAAgB,CAAM,EACjC,EAAK,SAAS,cAAc,KAAK,EAEvC,EAAG,UAAY,6BAA6B,IAExC,IAAa,MACf,EAAU,aAAa,EAAI,EAAU,UAAU,EAE/C,EAAU,YAAY,CAAE,EAG1B,IAAM,MAA4B,CAChC,EAAG,OAAO,CACZ,EAEA,MAAO,CACL,QAAS,EACT,MACC,OAAO,SAAU,EAClB,OAAO,EAAQ,CACb,EAAG,UAAY,GACf,IAAK,IAAM,KAAK,EAAQ,CACtB,IAAM,EAAO,SAAS,cAAc,KAAK,EAEzC,EAAK,UAAY,oBAEjB,IAAM,EAAM,SAAS,cAAc,MAAM,EAEzC,EAAI,UAAY,mBAChB,EAAI,MAAM,gBAAkB,EAAE,MAE9B,IAAM,EAAQ,SAAS,cAAc,MAAM,EAE3C,EAAM,UAAY,qBAClB,EAAM,YAAc,EAAE,KAEtB,EAAK,YAAY,CAAG,EACpB,EAAK,YAAY,CAAK,EACtB,EAAG,YAAY,CAAI,CACrB,CACF,CACF,CACF"}
1
+ {"version":3,"file":"legend.cjs","names":[],"sources":["../../src/interaction/legend.ts"],"sourcesContent":["import type { LegendConfig, LegendPosition } from '../types';\n\nexport interface LegendState {\n dispose(): void;\n el: HTMLDivElement | null;\n update(series: { color: string; name: string }[]): void;\n [Symbol.dispose](): void;\n}\n\nfunction resolvePosition(config: LegendConfig | true): LegendPosition {\n if (config === true) return 'bottom';\n\n return config.position ?? 'bottom';\n}\n\nexport function createLegend(container: HTMLElement, config: LegendConfig | true): LegendState {\n const position = resolvePosition(config);\n const el = document.createElement('div');\n\n el.className = `prism-legend prism-legend-${position}`;\n\n if (position === 'top') {\n container.insertBefore(el, container.firstChild);\n } else {\n container.appendChild(el);\n }\n\n const disposeHandle = (): void => {\n el.remove();\n };\n\n return {\n dispose: disposeHandle,\n el,\n [Symbol.dispose]: disposeHandle,\n update(series) {\n el.innerHTML = '';\n for (const s of series) {\n const item = document.createElement('div');\n\n item.className = 'prism-legend-item';\n\n const dot = document.createElement('span');\n\n dot.className = 'prism-legend-dot';\n dot.style.backgroundColor = s.color;\n\n const label = document.createElement('span');\n\n label.className = 'prism-legend-label';\n label.textContent = s.name;\n\n item.appendChild(dot);\n item.appendChild(label);\n el.appendChild(item);\n }\n },\n };\n}\n"],"mappings":"AASA,SAAS,EAAgB,EAA6C,CAGpE,OAFI,IAAW,GAAa,SAErB,EAAO,UAAY,QAC5B,CAEA,SAAgB,EAAa,EAAwB,EAA0C,CAC7F,IAAM,EAAW,EAAgB,CAAM,EACjC,EAAK,SAAS,cAAc,KAAK,EAEvC,EAAG,UAAY,6BAA6B,IAExC,IAAa,MACf,EAAU,aAAa,EAAI,EAAU,UAAU,EAE/C,EAAU,YAAY,CAAE,EAG1B,IAAM,MAA4B,CAChC,EAAG,OAAO,CACZ,EAEA,MAAO,CACL,QAAS,EACT,MACC,OAAO,SAAU,EAClB,OAAO,EAAQ,CACb,EAAG,UAAY,GACf,IAAK,IAAM,KAAK,EAAQ,CACtB,IAAM,EAAO,SAAS,cAAc,KAAK,EAEzC,EAAK,UAAY,oBAEjB,IAAM,EAAM,SAAS,cAAc,MAAM,EAEzC,EAAI,UAAY,mBAChB,EAAI,MAAM,gBAAkB,EAAE,MAE9B,IAAM,EAAQ,SAAS,cAAc,MAAM,EAE3C,EAAM,UAAY,qBAClB,EAAM,YAAc,EAAE,KAEtB,EAAK,YAAY,CAAG,EACpB,EAAK,YAAY,CAAK,EACtB,EAAG,YAAY,CAAI,CACrB,CACF,CACF,CACF"}
@@ -1,12 +1,12 @@
1
1
  import type { LegendConfig } from '../types';
2
2
  export interface LegendState {
3
3
  dispose(): void;
4
- [Symbol.dispose](): void;
5
4
  el: HTMLDivElement | null;
6
5
  update(series: {
7
6
  color: string;
8
7
  name: string;
9
8
  }[]): void;
9
+ [Symbol.dispose](): void;
10
10
  }
11
11
  export declare function createLegend(container: HTMLElement, config: LegendConfig | true): LegendState;
12
12
  //# sourceMappingURL=legend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/interaction/legend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,IAAI,CAAC;IAChB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IACzB,EAAE,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,IAAI,CAAC;CACzD;AAQD,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,WAAW,CA2C7F"}
1
+ {"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/interaction/legend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,IAAI,CAAC;IAChB,EAAE,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,IAAI,CAAC;IACxD,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B;AAQD,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,WAAW,CA2C7F"}