@vielzeug/prism 2.2.6 → 26.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/README.md +19 -40
  2. package/dist/_dev.cjs +1 -1
  3. package/dist/_dev.cjs.map +1 -1
  4. package/dist/_dev.js +1 -6
  5. package/dist/_dev.js.map +1 -1
  6. package/dist/animation/easing.cjs +1 -1
  7. package/dist/animation/easing.cjs.map +1 -1
  8. package/dist/animation/easing.js +1 -13
  9. package/dist/animation/easing.js.map +1 -1
  10. package/dist/animation/motion.cjs +1 -1
  11. package/dist/animation/motion.cjs.map +1 -1
  12. package/dist/animation/motion.js +1 -12
  13. package/dist/animation/motion.js.map +1 -1
  14. package/dist/animation/transition.cjs +1 -1
  15. package/dist/animation/transition.cjs.map +1 -1
  16. package/dist/animation/transition.js +1 -28
  17. package/dist/animation/transition.js.map +1 -1
  18. package/dist/animation/tween.cjs +1 -1
  19. package/dist/animation/tween.cjs.map +1 -1
  20. package/dist/animation/tween.js +1 -7
  21. package/dist/animation/tween.js.map +1 -1
  22. package/dist/axes/axis.cjs +1 -1
  23. package/dist/axes/axis.cjs.map +1 -1
  24. package/dist/axes/axis.d.ts +1 -0
  25. package/dist/axes/axis.d.ts.map +1 -1
  26. package/dist/axes/axis.js +1 -59
  27. package/dist/axes/axis.js.map +1 -1
  28. package/dist/axes/grid.cjs +1 -1
  29. package/dist/axes/grid.cjs.map +1 -1
  30. package/dist/axes/grid.js +1 -29
  31. package/dist/axes/grid.js.map +1 -1
  32. package/dist/axes/scale-utils.cjs +1 -1
  33. package/dist/axes/scale-utils.cjs.map +1 -1
  34. package/dist/axes/scale-utils.js +1 -10
  35. package/dist/axes/scale-utils.js.map +1 -1
  36. package/dist/charts/area/area-chart.cjs +1 -1
  37. package/dist/charts/area/area-chart.cjs.map +1 -1
  38. package/dist/charts/area/area-chart.d.ts +2 -2
  39. package/dist/charts/area/area-chart.d.ts.map +1 -1
  40. package/dist/charts/area/area-chart.js +1 -61
  41. package/dist/charts/area/area-chart.js.map +1 -1
  42. package/dist/charts/area/area-renderer.cjs +1 -1
  43. package/dist/charts/area/area-renderer.cjs.map +1 -1
  44. package/dist/charts/area/area-renderer.d.ts +2 -2
  45. package/dist/charts/area/area-renderer.d.ts.map +1 -1
  46. package/dist/charts/area/area-renderer.js +1 -73
  47. package/dist/charts/area/area-renderer.js.map +1 -1
  48. package/dist/charts/bar/bar-chart.cjs +1 -1
  49. package/dist/charts/bar/bar-chart.cjs.map +1 -1
  50. package/dist/charts/bar/bar-chart.d.ts +2 -2
  51. package/dist/charts/bar/bar-chart.d.ts.map +1 -1
  52. package/dist/charts/bar/bar-chart.js +1 -172
  53. package/dist/charts/bar/bar-chart.js.map +1 -1
  54. package/dist/charts/bar/bar-hit-test.cjs +1 -1
  55. package/dist/charts/bar/bar-hit-test.cjs.map +1 -1
  56. package/dist/charts/bar/bar-hit-test.js +1 -28
  57. package/dist/charts/bar/bar-hit-test.js.map +1 -1
  58. package/dist/charts/bar/bar-renderer.cjs +1 -1
  59. package/dist/charts/bar/bar-renderer.cjs.map +1 -1
  60. package/dist/charts/bar/bar-renderer.js +1 -106
  61. package/dist/charts/bar/bar-renderer.js.map +1 -1
  62. package/dist/charts/line/line-chart.cjs +1 -1
  63. package/dist/charts/line/line-chart.cjs.map +1 -1
  64. package/dist/charts/line/line-chart.d.ts +2 -2
  65. package/dist/charts/line/line-chart.d.ts.map +1 -1
  66. package/dist/charts/line/line-chart.js +1 -62
  67. package/dist/charts/line/line-chart.js.map +1 -1
  68. package/dist/charts/line/line-renderer.cjs +1 -1
  69. package/dist/charts/line/line-renderer.cjs.map +1 -1
  70. package/dist/charts/line/line-renderer.d.ts +2 -2
  71. package/dist/charts/line/line-renderer.d.ts.map +1 -1
  72. package/dist/charts/line/line-renderer.js +1 -100
  73. package/dist/charts/line/line-renderer.js.map +1 -1
  74. package/dist/charts/pie/pie-chart.cjs +1 -1
  75. package/dist/charts/pie/pie-chart.cjs.map +1 -1
  76. package/dist/charts/pie/pie-chart.d.ts +2 -2
  77. package/dist/charts/pie/pie-chart.d.ts.map +1 -1
  78. package/dist/charts/pie/pie-chart.js +1 -160
  79. package/dist/charts/pie/pie-chart.js.map +1 -1
  80. package/dist/charts/pie/pie-renderer.cjs +1 -1
  81. package/dist/charts/pie/pie-renderer.cjs.map +1 -1
  82. package/dist/charts/pie/pie-renderer.js +1 -76
  83. package/dist/charts/pie/pie-renderer.js.map +1 -1
  84. package/dist/charts/sparkline/sparkline.cjs +1 -1
  85. package/dist/charts/sparkline/sparkline.cjs.map +1 -1
  86. package/dist/charts/sparkline/sparkline.d.ts +2 -2
  87. package/dist/charts/sparkline/sparkline.d.ts.map +1 -1
  88. package/dist/charts/sparkline/sparkline.js +1 -192
  89. package/dist/charts/sparkline/sparkline.js.map +1 -1
  90. package/dist/core/cartesian-model.cjs +1 -1
  91. package/dist/core/cartesian-model.cjs.map +1 -1
  92. package/dist/core/cartesian-model.js +1 -30
  93. package/dist/core/cartesian-model.js.map +1 -1
  94. package/dist/core/cartesian-scales.cjs +1 -1
  95. package/dist/core/cartesian-scales.cjs.map +1 -1
  96. package/dist/core/cartesian-scales.js +1 -37
  97. package/dist/core/cartesian-scales.js.map +1 -1
  98. package/dist/core/chart-base.cjs +1 -1
  99. package/dist/core/chart-base.cjs.map +1 -1
  100. package/dist/core/chart-base.d.ts +2 -4
  101. package/dist/core/chart-base.d.ts.map +1 -1
  102. package/dist/core/chart-base.js +1 -62
  103. package/dist/core/chart-base.js.map +1 -1
  104. package/dist/core/chart-scaffold.cjs +1 -1
  105. package/dist/core/chart-scaffold.cjs.map +1 -1
  106. package/dist/core/chart-scaffold.d.ts +9 -10
  107. package/dist/core/chart-scaffold.d.ts.map +1 -1
  108. package/dist/core/chart-scaffold.js +1 -101
  109. package/dist/core/chart-scaffold.js.map +1 -1
  110. package/dist/core/index.d.ts +0 -1
  111. package/dist/core/index.d.ts.map +1 -1
  112. package/dist/core/layout.cjs +1 -1
  113. package/dist/core/layout.cjs.map +1 -1
  114. package/dist/core/layout.js +1 -22
  115. package/dist/core/layout.js.map +1 -1
  116. package/dist/core/responsive.cjs +1 -1
  117. package/dist/core/responsive.cjs.map +1 -1
  118. package/dist/core/responsive.js +1 -19
  119. package/dist/core/responsive.js.map +1 -1
  120. package/dist/devtools.cjs +1 -1
  121. package/dist/devtools.cjs.map +1 -1
  122. package/dist/devtools.js +1 -18
  123. package/dist/devtools.js.map +1 -1
  124. package/dist/errors.cjs +1 -1
  125. package/dist/errors.cjs.map +1 -1
  126. package/dist/errors.js +1 -9
  127. package/dist/errors.js.map +1 -1
  128. package/dist/index.cjs +1 -1
  129. package/dist/index.d.ts +2 -6
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +1 -12
  132. package/dist/interaction/crosshair.cjs +1 -1
  133. package/dist/interaction/crosshair.cjs.map +1 -1
  134. package/dist/interaction/crosshair.js +1 -45
  135. package/dist/interaction/crosshair.js.map +1 -1
  136. package/dist/interaction/events.cjs +1 -1
  137. package/dist/interaction/events.cjs.map +1 -1
  138. package/dist/interaction/events.js +1 -11
  139. package/dist/interaction/events.js.map +1 -1
  140. package/dist/interaction/legend.cjs +1 -1
  141. package/dist/interaction/legend.cjs.map +1 -1
  142. package/dist/interaction/legend.js +1 -30
  143. package/dist/interaction/legend.js.map +1 -1
  144. package/dist/interaction/series-interaction.cjs +1 -1
  145. package/dist/interaction/series-interaction.cjs.map +1 -1
  146. package/dist/interaction/series-interaction.js +1 -97
  147. package/dist/interaction/series-interaction.js.map +1 -1
  148. package/dist/interaction/tooltip.cjs +1 -1
  149. package/dist/interaction/tooltip.cjs.map +1 -1
  150. package/dist/interaction/tooltip.d.ts.map +1 -1
  151. package/dist/interaction/tooltip.js +1 -63
  152. package/dist/interaction/tooltip.js.map +1 -1
  153. package/dist/prism.cjs +1 -1
  154. package/dist/prism.cjs.map +1 -1
  155. package/dist/prism.iife.js +1 -1
  156. package/dist/prism.iife.js.map +1 -1
  157. package/dist/prism.js +1 -1
  158. package/dist/prism.js.map +1 -1
  159. package/dist/scales/band.cjs +1 -1
  160. package/dist/scales/band.cjs.map +1 -1
  161. package/dist/scales/band.js +1 -39
  162. package/dist/scales/band.js.map +1 -1
  163. package/dist/scales/linear.cjs +1 -1
  164. package/dist/scales/linear.cjs.map +1 -1
  165. package/dist/scales/linear.js +1 -43
  166. package/dist/scales/linear.js.map +1 -1
  167. package/dist/scales/time.cjs +1 -1
  168. package/dist/scales/time.cjs.map +1 -1
  169. package/dist/scales/time.js +1 -61
  170. package/dist/scales/time.js.map +1 -1
  171. package/dist/svg/element.cjs +1 -1
  172. package/dist/svg/element.cjs.map +1 -1
  173. package/dist/svg/element.js +1 -22
  174. package/dist/svg/element.js.map +1 -1
  175. package/dist/svg/path.cjs +1 -1
  176. package/dist/svg/path.cjs.map +1 -1
  177. package/dist/svg/path.js +1 -48
  178. package/dist/svg/path.js.map +1 -1
  179. package/dist/svg/text.cjs +1 -1
  180. package/dist/svg/text.cjs.map +1 -1
  181. package/dist/svg/text.js +1 -9
  182. package/dist/svg/text.js.map +1 -1
  183. package/dist/theme/index.cjs +1 -1
  184. package/dist/theme/index.cjs.map +1 -1
  185. package/dist/theme/index.js +1 -19
  186. package/dist/theme/index.js.map +1 -1
  187. package/dist/types.d.ts +24 -48
  188. package/dist/types.d.ts.map +1 -1
  189. package/package.json +8 -9
  190. package/dist/core/resolve.cjs +0 -2
  191. package/dist/core/resolve.cjs.map +0 -1
  192. package/dist/core/resolve.d.ts +0 -9
  193. package/dist/core/resolve.d.ts.map +0 -1
  194. package/dist/core/resolve.js +0 -15
  195. package/dist/core/resolve.js.map +0 -1
package/README.md CHANGED
@@ -1,72 +1,50 @@
1
1
  # @vielzeug/prism
2
2
 
3
- > Reactive SVG charting library — line, bar, area, pie, and sparkline charts with keyed data, accessible interactions, and signal-driven updates.
4
-
5
- [![npm version](https://img.shields.io/npm/v/@vielzeug/prism)](https://www.npmjs.com/package/@vielzeug/prism) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
-
7
- <details>
8
- <summary>Quick Reference</summary>
9
-
10
- **Package:** `@vielzeug/prism` &nbsp;·&nbsp; **Category:** UI / Visualization
11
-
12
- **Key exports:** `createLineChart`, `createBarChart`, `createAreaChart`, `createPieChart`, `createSparkline`, `linearScale`, `timeScale`, `bandScale`, `seriesColor`, `setTheme`
13
-
14
- **When to use:** Data visualization with reactive charts that auto-update when signal-based data sources change. Renders accessible SVG, themeable via CSS custom properties.
15
-
16
- **Related:** [@vielzeug/ripple](https://vielzeug.dev/ripple/) · [@vielzeug/refine](https://vielzeug.dev/refine/) · [@vielzeug/orbit](https://vielzeug.dev/orbit/)
17
-
18
- </details>
19
-
20
- `@vielzeug/prism` is part of Vielzeug. It depends on Orbit for tooltips and Ripple for reactivity, and ships as a TypeScript package with ESM+CJS output.
3
+ > Responsive SVG charts with explicit updates — line, bar, area, pie, sparkline
21
4
 
22
5
  ## Installation
23
6
 
24
7
  ```sh
25
- # pnpm
26
8
  pnpm add @vielzeug/prism
27
- # npm
28
9
  npm install @vielzeug/prism
29
- # yarn
30
10
  yarn add @vielzeug/prism
31
11
  ```
32
12
 
33
- ## Sub-paths
34
-
35
- | Import | Purpose |
36
- | -------------------------- | -------------------------------------------------------------- |
37
- | `@vielzeug/prism` | Chart factories, scales, and types |
38
- | `@vielzeug/prism/theme` | Default CSS custom properties (light + dark mode) |
39
- | `@vielzeug/prism/devtools` | `warn` / `issue` helpers (dev-only, tree-shaken in production) |
40
-
41
13
  ## Quick Start
42
14
 
43
15
  ```ts
44
16
  import { createLineChart, setTheme } from '@vielzeug/prism';
45
- import { signal } from '@vielzeug/ripple';
46
17
  import '@vielzeug/prism/theme';
47
18
 
48
19
  // Optional: apply a custom color palette at startup
49
20
  setTheme({ colors: ['#6366f1', '#22d3ee', '#f59e0b', '#10b981'] });
50
21
 
51
- const data = signal([
52
- { x: 1, y: 10 },
53
- { x: 2, y: 25 },
54
- { x: 3, y: 18 },
55
- { x: 4, y: 32 },
56
- ]);
22
+ let series = [
23
+ {
24
+ color: '#3b82f6',
25
+ data: [
26
+ { key: 1, value: 10 },
27
+ { key: 2, value: 25 },
28
+ { key: 3, value: 18 },
29
+ { key: 4, value: 32 },
30
+ ],
31
+ name: 'Revenue',
32
+ },
33
+ ];
57
34
 
58
35
  const chart = createLineChart(document.getElementById('chart')!, {
59
36
  a11y: { ariaLabel: 'Revenue by month' },
60
- series: [{ name: 'Revenue', data, color: '#3b82f6' }],
37
+ series,
61
38
  xAxis: { position: 'bottom' },
62
39
  yAxis: { position: 'left', grid: true },
63
40
  tooltip: true,
64
41
  crosshair: true,
65
- onHover: (event) => console.log(event?.point),
42
+ onHover: (event) => console.log(event?.datum),
66
43
  });
67
44
 
68
- // Data updates → chart re-renders automatically
69
- data.value = [...data.value, { x: 5, y: 28 }];
45
+ // Replace data explicitly when application state changes
46
+ series = [{ ...series[0]!, data: [...series[0]!.data, { key: 5, value: 28 }] }];
47
+ chart.update(series);
70
48
 
71
49
  // Cleanup (also works with TC39 `using` declarations)
72
50
  chart.dispose();
@@ -78,6 +56,7 @@ chart.dispose();
78
56
  - [Usage Guide](https://vielzeug.dev/prism/usage)
79
57
  - [API Reference](https://vielzeug.dev/prism/api)
80
58
  - [Examples](https://vielzeug.dev/prism/examples)
59
+ - [Migration Guide](https://vielzeug.dev/prism/migration)
81
60
 
82
61
  ## License
83
62
 
package/dist/_dev.cjs CHANGED
@@ -1,2 +1,2 @@
1
- function e(e){}function t(e,...t){}exports.error=t,exports.warn=e;
1
+ function warn(e){}exports.warn=warn;
2
2
  //# sourceMappingURL=_dev.cjs.map
package/dist/_dev.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/**\n * Emits a `console.error` in development builds only.\n * @internal\n */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/prism] ${msg}`, ...args);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AASA,SAAgB,EAAK,EAAmB,CAExC,CAMA,SAAgB,EAAM,EAAa,GAAG,EAAuB,CAE7D"}
1
+ {"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/**\n * Emits a `console.error` in development builds only.\n * @internal\n */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/prism] ${msg}`, ...args);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AASA,SAAgB,KAAK,EAAmB,CAExC"}
package/dist/_dev.js CHANGED
@@ -1,7 +1,2 @@
1
- //#region src/_dev.ts
2
- function e(e) {}
3
- function t(e, ...t) {}
4
- //#endregion
5
- export { t as error, e as warn };
6
-
1
+ function warn(e){}export{warn};
7
2
  //# sourceMappingURL=_dev.js.map
package/dist/_dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/**\n * Emits a `console.error` in development builds only.\n * @internal\n */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/prism] ${msg}`, ...args);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":";AASA,SAAgB,EAAK,GAAmB,CAExC;AAMA,SAAgB,EAAM,GAAa,GAAG,GAAuB,CAE7D"}
1
+ {"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/**\n * Emits a `console.error` in development builds only.\n * @internal\n */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/prism] ${msg}`, ...args);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AASA,SAAgB,KAAK,EAAmB,CAExC"}
@@ -1,2 +1,2 @@
1
- var e={"ease-in":e=>e*e,"ease-in-out":e=>e<.5?2*e*e:1-(-2*e+2)**2/2,"ease-out":e=>1-(1-e)*(1-e),linear:e=>e};function t(t){return typeof t==`function`?t:t!==void 0&&Object.hasOwn(e,t)?e[t]:e[`ease-out`]}exports.easings=e,exports.resolveEasing=t;
1
+ var e={"ease-in":e=>e*e,"ease-in-out":e=>e<.5?2*e*e:1-(-2*e+2)**2/2,"ease-out":e=>1-(1-e)*(1-e),linear:e=>e};function resolveEasing(t){return typeof t==`function`?t:t!==void 0&&Object.hasOwn(e,t)?e[t]:e[`ease-out`]}exports.easings=e,exports.resolveEasing=resolveEasing;
2
2
  //# sourceMappingURL=easing.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"easing.cjs","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\nexport const easings: Record<string, EasingFn> = {\n 'ease-in': (t) => t * t,\n 'ease-in-out': (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2),\n 'ease-out': (t) => 1 - (1 - t) * (1 - t),\n linear: (t) => t,\n};\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`) — a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) return easings[easing];\n\n return easings['ease-out'];\n}\n"],"mappings":"AAEA,IAAa,EAAoC,CAC/C,UAAY,GAAM,EAAI,EACtB,cAAgB,GAAO,EAAI,GAAM,EAAI,EAAI,EAAI,GAAK,GAAK,EAAI,IAAM,EAAI,EACrE,WAAa,GAAM,GAAK,EAAI,IAAM,EAAI,GACtC,OAAS,GAAM,CACjB,EAEA,SAAgB,EAAc,EAAgE,CAS5F,OARI,OAAO,GAAW,WAAmB,EAMrC,IAAW,IAAA,IAAa,OAAO,OAAO,EAAS,CAAM,EAAU,EAAQ,GAEpE,EAAQ,WACjB"}
1
+ {"version":3,"file":"easing.cjs","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\nexport const easings: Record<string, EasingFn> = {\n 'ease-in': (t) => t * t,\n 'ease-in-out': (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2),\n 'ease-out': (t) => 1 - (1 - t) * (1 - t),\n linear: (t) => t,\n};\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`) — a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) return easings[easing];\n\n return easings['ease-out'];\n}\n"],"mappings":"AAEA,IAAa,EAAoC,CAC/C,UAAY,GAAM,EAAI,EACtB,cAAgB,GAAO,EAAI,GAAM,EAAI,EAAI,EAAI,GAAK,GAAK,EAAI,IAAM,EAAI,EACrE,WAAa,GAAM,GAAK,EAAI,IAAM,EAAI,GACtC,OAAS,GAAM,CACjB,EAEA,SAAgB,cAAc,EAAgE,CAS5F,OARI,OAAO,GAAW,WAAmB,EAMrC,IAAW,IAAA,IAAa,OAAO,OAAO,EAAS,CAAM,EAAU,EAAQ,GAEpE,EAAQ,WACjB"}
@@ -1,14 +1,2 @@
1
- //#region src/animation/easing.ts
2
- var e = {
3
- "ease-in": (e) => e * e,
4
- "ease-in-out": (e) => e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2,
5
- "ease-out": (e) => 1 - (1 - e) * (1 - e),
6
- linear: (e) => e
7
- };
8
- function t(t) {
9
- return typeof t == "function" ? t : t !== void 0 && Object.hasOwn(e, t) ? e[t] : e["ease-out"];
10
- }
11
- //#endregion
12
- export { e as easings, t as resolveEasing };
13
-
1
+ var e={"ease-in":e=>e*e,"ease-in-out":e=>e<.5?2*e*e:1-(-2*e+2)**2/2,"ease-out":e=>1-(1-e)*(1-e),linear:e=>e};function resolveEasing(t){return typeof t==`function`?t:t!==void 0&&Object.hasOwn(e,t)?e[t]:e[`ease-out`]}export{e as easings,resolveEasing};
14
2
  //# sourceMappingURL=easing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"easing.js","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\nexport const easings: Record<string, EasingFn> = {\n 'ease-in': (t) => t * t,\n 'ease-in-out': (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2),\n 'ease-out': (t) => 1 - (1 - t) * (1 - t),\n linear: (t) => t,\n};\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`) — a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) return easings[easing];\n\n return easings['ease-out'];\n}\n"],"mappings":";AAEA,IAAa,IAAoC;CAC/C,YAAY,MAAM,IAAI;CACtB,gBAAgB,MAAO,IAAI,KAAM,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,MAAM,IAAI;CACrE,aAAa,MAAM,KAAK,IAAI,MAAM,IAAI;CACtC,SAAS,MAAM;AACjB;AAEA,SAAgB,EAAc,GAAgE;CAS5F,OARI,OAAO,KAAW,aAAmB,IAMrC,MAAW,KAAA,KAAa,OAAO,OAAO,GAAS,CAAM,IAAU,EAAQ,KAEpE,EAAQ;AACjB"}
1
+ {"version":3,"file":"easing.js","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\nexport const easings: Record<string, EasingFn> = {\n 'ease-in': (t) => t * t,\n 'ease-in-out': (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2),\n 'ease-out': (t) => 1 - (1 - t) * (1 - t),\n linear: (t) => t,\n};\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`) — a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) return easings[easing];\n\n return easings['ease-out'];\n}\n"],"mappings":"AAEA,IAAa,EAAoC,CAC/C,UAAY,GAAM,EAAI,EACtB,cAAgB,GAAO,EAAI,GAAM,EAAI,EAAI,EAAI,GAAK,GAAK,EAAI,IAAM,EAAI,EACrE,WAAa,GAAM,GAAK,EAAI,IAAM,EAAI,GACtC,OAAS,GAAM,CACjB,EAEA,SAAgB,cAAc,EAAgE,CAS5F,OARI,OAAO,GAAW,WAAmB,EAMrC,IAAW,IAAA,IAAa,OAAO,OAAO,EAAS,CAAM,EAAU,EAAQ,GAEpE,EAAQ,WACjB"}
@@ -1,2 +1,2 @@
1
- function e(e,t=300){let n=e?.preference??`system`,r=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=n===`never`||n===`system`&&r?0:e?.duration??t;return{...e,duration:i,stagger:Math.max(0,e?.stagger??0)}}exports.resolveMotion=e;
1
+ function resolveMotion(e,t=300){let n=e?.preference??`system`,r=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=n===`never`||n===`system`&&r?0:e?.duration??t;return{...e,duration:i,stagger:Math.max(0,e?.stagger??0)}}exports.resolveMotion=resolveMotion;
2
2
  //# sourceMappingURL=motion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"motion.cjs","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nexport function resolveMotion(\n config?: TransitionConfig,\n defaultDuration = 300,\n): Required<Pick<TransitionConfig, 'duration' | 'stagger'>> & TransitionConfig {\n const preference = config?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced) ? 0 : (config?.duration ?? defaultDuration);\n\n return { ...config, duration, stagger: Math.max(0, config?.stagger ?? 0) };\n}\n"],"mappings":"AAEA,SAAgB,EACd,EACA,EAAkB,IAC2D,CAC7E,IAAM,EAAa,GAAQ,YAAc,SACnC,EAAU,OAAO,WAAe,KAAe,WAAW,kCAAkC,CAAC,CAAC,QAC9F,EACJ,IAAe,SAAY,IAAe,UAAY,EAAW,EAAK,GAAQ,UAAY,EAE5F,MAAO,CAAE,GAAG,EAAQ,WAAU,QAAS,KAAK,IAAI,EAAG,GAAQ,SAAW,CAAC,CAAE,CAC3E"}
1
+ {"version":3,"file":"motion.cjs","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nexport function resolveMotion(\n config?: TransitionConfig,\n defaultDuration = 300,\n): Required<Pick<TransitionConfig, 'duration' | 'stagger'>> & TransitionConfig {\n const preference = config?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced) ? 0 : (config?.duration ?? defaultDuration);\n\n return { ...config, duration, stagger: Math.max(0, config?.stagger ?? 0) };\n}\n"],"mappings":"AAEA,SAAgB,cACd,EACA,EAAkB,IAC2D,CAC7E,IAAM,EAAa,GAAQ,YAAc,SACnC,EAAU,OAAO,WAAe,KAAe,WAAW,kCAAkC,CAAC,CAAC,QAC9F,EACJ,IAAe,SAAY,IAAe,UAAY,EAAW,EAAK,GAAQ,UAAY,EAE5F,MAAO,CAAE,GAAG,EAAQ,WAAU,QAAS,KAAK,IAAI,EAAG,GAAQ,SAAW,CAAC,CAAE,CAC3E"}
@@ -1,13 +1,2 @@
1
- //#region src/animation/motion.ts
2
- function e(e, t = 300) {
3
- let n = e?.preference ?? "system", r = typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches, i = n === "never" || n === "system" && r ? 0 : e?.duration ?? t;
4
- return {
5
- ...e,
6
- duration: i,
7
- stagger: Math.max(0, e?.stagger ?? 0)
8
- };
9
- }
10
- //#endregion
11
- export { e as resolveMotion };
12
-
1
+ function resolveMotion(e,t=300){let n=e?.preference??`system`,r=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=n===`never`||n===`system`&&r?0:e?.duration??t;return{...e,duration:i,stagger:Math.max(0,e?.stagger??0)}}export{resolveMotion};
13
2
  //# sourceMappingURL=motion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"motion.js","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nexport function resolveMotion(\n config?: TransitionConfig,\n defaultDuration = 300,\n): Required<Pick<TransitionConfig, 'duration' | 'stagger'>> & TransitionConfig {\n const preference = config?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced) ? 0 : (config?.duration ?? defaultDuration);\n\n return { ...config, duration, stagger: Math.max(0, config?.stagger ?? 0) };\n}\n"],"mappings":";AAEA,SAAgB,EACd,GACA,IAAkB,KAC2D;CAC7E,IAAM,IAAa,GAAQ,cAAc,UACnC,IAAU,OAAO,aAAe,OAAe,WAAW,kCAAkC,CAAC,CAAC,SAC9F,IACJ,MAAe,WAAY,MAAe,YAAY,IAAW,IAAK,GAAQ,YAAY;CAE5F,OAAO;EAAE,GAAG;EAAQ;EAAU,SAAS,KAAK,IAAI,GAAG,GAAQ,WAAW,CAAC;CAAE;AAC3E"}
1
+ {"version":3,"file":"motion.js","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nexport function resolveMotion(\n config?: TransitionConfig,\n defaultDuration = 300,\n): Required<Pick<TransitionConfig, 'duration' | 'stagger'>> & TransitionConfig {\n const preference = config?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced) ? 0 : (config?.duration ?? defaultDuration);\n\n return { ...config, duration, stagger: Math.max(0, config?.stagger ?? 0) };\n}\n"],"mappings":"AAEA,SAAgB,cACd,EACA,EAAkB,IAC2D,CAC7E,IAAM,EAAa,GAAQ,YAAc,SACnC,EAAU,OAAO,WAAe,KAAe,WAAW,kCAAkC,CAAC,CAAC,QAC9F,EACJ,IAAe,SAAY,IAAe,UAAY,EAAW,EAAK,GAAQ,UAAY,EAE5F,MAAO,CAAE,GAAG,EAAQ,WAAU,QAAS,KAAK,IAAI,EAAG,GAAQ,SAAW,CAAC,CAAE,CAC3E"}
@@ -1,2 +1,2 @@
1
- const e=require("./easing.cjs"),t=require("./motion.cjs"),n=require("./tween.cjs");function r(r,i,a,o){let s=t.resolveMotion(i),c=s.duration,l=e.resolveEasing(s.easing),u=s.stagger;if(c===0||r.length===0){for(let e of r)for(let[t,{to:n}]of Object.entries(e.attrs))e.el.setAttribute(t,String(n));return a?.(),()=>{}}let d=null,f=!1,p=Math.max(c,c+u*(r.length-1));function m(e){if(f||o?.aborted)return;d===null&&(d=e);let t=e-d;for(let e=0;e<r.length;e++){let i=r[e],a=u*e,o=Math.max(0,t-a),s=Math.min(1,o/c),d=l(s);for(let[e,{from:t,to:r}]of Object.entries(i.attrs))i.el.setAttribute(e,String(n.tweenNumber(t,r,d)))}t<p?requestAnimationFrame(m):a?.()}return requestAnimationFrame(m),()=>{f=!0}}exports.animate=r;
1
+ const e=require("./easing.cjs"),t=require("./motion.cjs"),n=require("./tween.cjs");function animate(r,i,a,o){let s=t.resolveMotion(i),c=s.duration,l=e.resolveEasing(s.easing),u=s.stagger;if(c===0||r.length===0){for(let e of r)for(let[t,{to:n}]of Object.entries(e.attrs))e.el.setAttribute(t,String(n));return a?.(),()=>{}}let d=null,f=!1,p=Math.max(c,c+u*(r.length-1));function frame(e){if(f||o?.aborted)return;d===null&&(d=e);let t=e-d;for(let e=0;e<r.length;e++){let i=r[e],a=u*e,o=Math.max(0,t-a),s=Math.min(1,o/c),d=l(s);for(let[e,{from:t,to:r}]of Object.entries(i.attrs))i.el.setAttribute(e,String(n.tweenNumber(t,r,d)))}t<p?requestAnimationFrame(frame):a?.()}return requestAnimationFrame(frame),()=>{f=!0}}exports.animate=animate;
2
2
  //# sourceMappingURL=transition.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transition.cjs","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\n/**\n * Runs a batch of attribute tweens, sharing one `requestAnimationFrame` loop.\n * Returns a `cancel()` function the caller can invoke to stop the loop early\n * (e.g. a fresh render superseding this batch, or `signal` aborting).\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n const duration = motion.duration;\n const easing = resolveEasing(motion.easing);\n const stagger = motion.stagger;\n\n if (duration === 0 || targets.length === 0) {\n for (const target of targets) {\n for (const [attr, { to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(to));\n }\n }\n\n onComplete?.();\n\n return () => {};\n }\n\n let startTime: number | null = null;\n let cancelled = false;\n const totalDuration = Math.max(duration, duration + stagger * (targets.length - 1));\n\n function frame(timestamp: number) {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n for (let i = 0; i < targets.length; i++) {\n const target = targets[i];\n const delay = stagger * i;\n const localElapsed = Math.max(0, elapsed - delay);\n const t = Math.min(1, localElapsed / duration);\n const eased = easing(t);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n\n if (elapsed < totalDuration) {\n requestAnimationFrame(frame);\n } else {\n onComplete?.();\n }\n }\n\n requestAnimationFrame(frame);\n\n return () => {\n cancelled = true;\n };\n}\n"],"mappings":"mFAgBA,SAAgB,EACd,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAS,EAAA,cAAc,CAAM,EAC7B,EAAW,EAAO,SAClB,EAAS,EAAA,cAAc,EAAO,MAAM,EACpC,EAAU,EAAO,QAEvB,GAAI,IAAa,GAAK,EAAQ,SAAW,EAAG,CAC1C,IAAK,IAAM,KAAU,EACnB,IAAK,GAAM,CAAC,EAAM,CAAE,SAAS,OAAO,QAAQ,EAAO,KAAK,EACtD,EAAO,GAAG,aAAa,EAAM,OAAO,CAAE,CAAC,EAM3C,OAFA,IAAa,MAEA,CAAC,CAChB,CAEA,IAAI,EAA2B,KAC3B,EAAY,GACV,EAAgB,KAAK,IAAI,EAAU,EAAW,GAAW,EAAQ,OAAS,EAAE,EAElF,SAAS,EAAM,EAAmB,CAChC,GAAI,GAAa,GAAQ,QAAS,OAE9B,IAAc,OAAM,EAAY,GAEpC,IAAM,EAAU,EAAY,EAE5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAM,EAAS,EAAQ,GACjB,EAAQ,EAAU,EAClB,EAAe,KAAK,IAAI,EAAG,EAAU,CAAK,EAC1C,EAAI,KAAK,IAAI,EAAG,EAAe,CAAQ,EACvC,EAAQ,EAAO,CAAC,EAEtB,IAAK,GAAM,CAAC,EAAM,CAAE,OAAM,SAAS,OAAO,QAAQ,EAAO,KAAK,EAC5D,EAAO,GAAG,aAAa,EAAM,OAAO,EAAA,YAAY,EAAM,EAAI,CAAK,CAAC,CAAC,CAErE,CAEI,EAAU,EACZ,sBAAsB,CAAK,EAE3B,IAAa,CAEjB,CAIA,OAFA,sBAAsB,CAAK,MAEd,CACX,EAAY,EACd,CACF"}
1
+ {"version":3,"file":"transition.cjs","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\n/**\n * Runs a batch of attribute tweens, sharing one `requestAnimationFrame` loop.\n * Returns a `cancel()` function the caller can invoke to stop the loop early\n * (e.g. a fresh render superseding this batch, or `signal` aborting).\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n const duration = motion.duration;\n const easing = resolveEasing(motion.easing);\n const stagger = motion.stagger;\n\n if (duration === 0 || targets.length === 0) {\n for (const target of targets) {\n for (const [attr, { to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(to));\n }\n }\n\n onComplete?.();\n\n return () => {};\n }\n\n let startTime: number | null = null;\n let cancelled = false;\n const totalDuration = Math.max(duration, duration + stagger * (targets.length - 1));\n\n function frame(timestamp: number) {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n for (let i = 0; i < targets.length; i++) {\n const target = targets[i];\n const delay = stagger * i;\n const localElapsed = Math.max(0, elapsed - delay);\n const t = Math.min(1, localElapsed / duration);\n const eased = easing(t);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n\n if (elapsed < totalDuration) {\n requestAnimationFrame(frame);\n } else {\n onComplete?.();\n }\n }\n\n requestAnimationFrame(frame);\n\n return () => {\n cancelled = true;\n };\n}\n"],"mappings":"mFAgBA,SAAgB,QACd,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAS,EAAA,cAAc,CAAM,EAC7B,EAAW,EAAO,SAClB,EAAS,EAAA,cAAc,EAAO,MAAM,EACpC,EAAU,EAAO,QAEvB,GAAI,IAAa,GAAK,EAAQ,SAAW,EAAG,CAC1C,IAAK,IAAM,KAAU,EACnB,IAAK,GAAM,CAAC,EAAM,CAAE,SAAS,OAAO,QAAQ,EAAO,KAAK,EACtD,EAAO,GAAG,aAAa,EAAM,OAAO,CAAE,CAAC,EAM3C,OAFA,IAAa,MAEA,CAAC,CAChB,CAEA,IAAI,EAA2B,KAC3B,EAAY,GACV,EAAgB,KAAK,IAAI,EAAU,EAAW,GAAW,EAAQ,OAAS,EAAE,EAElF,SAAS,MAAM,EAAmB,CAChC,GAAI,GAAa,GAAQ,QAAS,OAE9B,IAAc,OAAM,EAAY,GAEpC,IAAM,EAAU,EAAY,EAE5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAM,EAAS,EAAQ,GACjB,EAAQ,EAAU,EAClB,EAAe,KAAK,IAAI,EAAG,EAAU,CAAK,EAC1C,EAAI,KAAK,IAAI,EAAG,EAAe,CAAQ,EACvC,EAAQ,EAAO,CAAC,EAEtB,IAAK,GAAM,CAAC,EAAM,CAAE,OAAM,SAAS,OAAO,QAAQ,EAAO,KAAK,EAC5D,EAAO,GAAG,aAAa,EAAM,OAAO,EAAA,YAAY,EAAM,EAAI,CAAK,CAAC,CAAC,CAErE,CAEI,EAAU,EACZ,sBAAsB,KAAK,EAE3B,IAAa,CAEjB,CAIA,OAFA,sBAAsB,KAAK,MAEd,CACX,EAAY,EACd,CACF"}
@@ -1,29 +1,2 @@
1
- import { resolveEasing as e } from "./easing.js";
2
- import { resolveMotion as t } from "./motion.js";
3
- import { tweenNumber as n } from "./tween.js";
4
- //#region src/animation/transition.ts
5
- function r(r, i, a, o) {
6
- let s = t(i), c = s.duration, l = e(s.easing), u = s.stagger;
7
- if (c === 0 || r.length === 0) {
8
- for (let e of r) for (let [t, { to: n }] of Object.entries(e.attrs)) e.el.setAttribute(t, String(n));
9
- return a?.(), () => {};
10
- }
11
- let d = null, f = !1, p = Math.max(c, c + u * (r.length - 1));
12
- function m(e) {
13
- if (f || o?.aborted) return;
14
- d === null && (d = e);
15
- let t = e - d;
16
- for (let e = 0; e < r.length; e++) {
17
- let i = r[e], a = u * e, o = Math.max(0, t - a), s = Math.min(1, o / c), d = l(s);
18
- for (let [e, { from: t, to: r }] of Object.entries(i.attrs)) i.el.setAttribute(e, String(n(t, r, d)));
19
- }
20
- t < p ? requestAnimationFrame(m) : a?.();
21
- }
22
- return requestAnimationFrame(m), () => {
23
- f = !0;
24
- };
25
- }
26
- //#endregion
27
- export { r as animate };
28
-
1
+ import{resolveEasing as e}from"./easing.js";import{resolveMotion as t}from"./motion.js";import{tweenNumber as n}from"./tween.js";function animate(r,i,a,o){let s=t(i),c=s.duration,l=e(s.easing),u=s.stagger;if(c===0||r.length===0){for(let e of r)for(let[t,{to:n}]of Object.entries(e.attrs))e.el.setAttribute(t,String(n));return a?.(),()=>{}}let d=null,f=!1,p=Math.max(c,c+u*(r.length-1));function frame(e){if(f||o?.aborted)return;d===null&&(d=e);let t=e-d;for(let e=0;e<r.length;e++){let i=r[e],a=u*e,o=Math.max(0,t-a),s=Math.min(1,o/c),d=l(s);for(let[e,{from:t,to:r}]of Object.entries(i.attrs))i.el.setAttribute(e,String(n(t,r,d)))}t<p?requestAnimationFrame(frame):a?.()}return requestAnimationFrame(frame),()=>{f=!0}}export{animate};
29
2
  //# sourceMappingURL=transition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transition.js","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\n/**\n * Runs a batch of attribute tweens, sharing one `requestAnimationFrame` loop.\n * Returns a `cancel()` function the caller can invoke to stop the loop early\n * (e.g. a fresh render superseding this batch, or `signal` aborting).\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n const duration = motion.duration;\n const easing = resolveEasing(motion.easing);\n const stagger = motion.stagger;\n\n if (duration === 0 || targets.length === 0) {\n for (const target of targets) {\n for (const [attr, { to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(to));\n }\n }\n\n onComplete?.();\n\n return () => {};\n }\n\n let startTime: number | null = null;\n let cancelled = false;\n const totalDuration = Math.max(duration, duration + stagger * (targets.length - 1));\n\n function frame(timestamp: number) {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n for (let i = 0; i < targets.length; i++) {\n const target = targets[i];\n const delay = stagger * i;\n const localElapsed = Math.max(0, elapsed - delay);\n const t = Math.min(1, localElapsed / duration);\n const eased = easing(t);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n\n if (elapsed < totalDuration) {\n requestAnimationFrame(frame);\n } else {\n onComplete?.();\n }\n }\n\n requestAnimationFrame(frame);\n\n return () => {\n cancelled = true;\n };\n}\n"],"mappings":";;;;AAgBA,SAAgB,EACd,GACA,GACA,GACA,GACY;CACZ,IAAM,IAAS,EAAc,CAAM,GAC7B,IAAW,EAAO,UAClB,IAAS,EAAc,EAAO,MAAM,GACpC,IAAU,EAAO;CAEvB,IAAI,MAAa,KAAK,EAAQ,WAAW,GAAG;EAC1C,KAAK,IAAM,KAAU,GACnB,KAAK,IAAM,CAAC,GAAM,EAAE,YAAS,OAAO,QAAQ,EAAO,KAAK,GACtD,EAAO,GAAG,aAAa,GAAM,OAAO,CAAE,CAAC;EAM3C,OAFA,IAAa,SAEA,CAAC;CAChB;CAEA,IAAI,IAA2B,MAC3B,IAAY,IACV,IAAgB,KAAK,IAAI,GAAU,IAAW,KAAW,EAAQ,SAAS,EAAE;CAElF,SAAS,EAAM,GAAmB;EAChC,IAAI,KAAa,GAAQ,SAAS;EAElC,AAAI,MAAc,SAAM,IAAY;EAEpC,IAAM,IAAU,IAAY;EAE5B,KAAK,IAAI,IAAI,GAAG,IAAI,EAAQ,QAAQ,KAAK;GACvC,IAAM,IAAS,EAAQ,IACjB,IAAQ,IAAU,GAClB,IAAe,KAAK,IAAI,GAAG,IAAU,CAAK,GAC1C,IAAI,KAAK,IAAI,GAAG,IAAe,CAAQ,GACvC,IAAQ,EAAO,CAAC;GAEtB,KAAK,IAAM,CAAC,GAAM,EAAE,SAAM,YAAS,OAAO,QAAQ,EAAO,KAAK,GAC5D,EAAO,GAAG,aAAa,GAAM,OAAO,EAAY,GAAM,GAAI,CAAK,CAAC,CAAC;EAErE;EAEA,AAAI,IAAU,IACZ,sBAAsB,CAAK,IAE3B,IAAa;CAEjB;CAIA,OAFA,sBAAsB,CAAK,SAEd;EACX,IAAY;CACd;AACF"}
1
+ {"version":3,"file":"transition.js","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\n/**\n * Runs a batch of attribute tweens, sharing one `requestAnimationFrame` loop.\n * Returns a `cancel()` function the caller can invoke to stop the loop early\n * (e.g. a fresh render superseding this batch, or `signal` aborting).\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n const duration = motion.duration;\n const easing = resolveEasing(motion.easing);\n const stagger = motion.stagger;\n\n if (duration === 0 || targets.length === 0) {\n for (const target of targets) {\n for (const [attr, { to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(to));\n }\n }\n\n onComplete?.();\n\n return () => {};\n }\n\n let startTime: number | null = null;\n let cancelled = false;\n const totalDuration = Math.max(duration, duration + stagger * (targets.length - 1));\n\n function frame(timestamp: number) {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n for (let i = 0; i < targets.length; i++) {\n const target = targets[i];\n const delay = stagger * i;\n const localElapsed = Math.max(0, elapsed - delay);\n const t = Math.min(1, localElapsed / duration);\n const eased = easing(t);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n\n if (elapsed < totalDuration) {\n requestAnimationFrame(frame);\n } else {\n onComplete?.();\n }\n }\n\n requestAnimationFrame(frame);\n\n return () => {\n cancelled = true;\n };\n}\n"],"mappings":"iIAgBA,SAAgB,QACd,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAS,EAAc,CAAM,EAC7B,EAAW,EAAO,SAClB,EAAS,EAAc,EAAO,MAAM,EACpC,EAAU,EAAO,QAEvB,GAAI,IAAa,GAAK,EAAQ,SAAW,EAAG,CAC1C,IAAK,IAAM,KAAU,EACnB,IAAK,GAAM,CAAC,EAAM,CAAE,SAAS,OAAO,QAAQ,EAAO,KAAK,EACtD,EAAO,GAAG,aAAa,EAAM,OAAO,CAAE,CAAC,EAM3C,OAFA,IAAa,MAEA,CAAC,CAChB,CAEA,IAAI,EAA2B,KAC3B,EAAY,GACV,EAAgB,KAAK,IAAI,EAAU,EAAW,GAAW,EAAQ,OAAS,EAAE,EAElF,SAAS,MAAM,EAAmB,CAChC,GAAI,GAAa,GAAQ,QAAS,OAE9B,IAAc,OAAM,EAAY,GAEpC,IAAM,EAAU,EAAY,EAE5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAM,EAAS,EAAQ,GACjB,EAAQ,EAAU,EAClB,EAAe,KAAK,IAAI,EAAG,EAAU,CAAK,EAC1C,EAAI,KAAK,IAAI,EAAG,EAAe,CAAQ,EACvC,EAAQ,EAAO,CAAC,EAEtB,IAAK,GAAM,CAAC,EAAM,CAAE,OAAM,SAAS,OAAO,QAAQ,EAAO,KAAK,EAC5D,EAAO,GAAG,aAAa,EAAM,OAAO,EAAY,EAAM,EAAI,CAAK,CAAC,CAAC,CAErE,CAEI,EAAU,EACZ,sBAAsB,KAAK,EAE3B,IAAa,CAEjB,CAIA,OAFA,sBAAsB,KAAK,MAEd,CACX,EAAY,EACd,CACF"}
@@ -1,2 +1,2 @@
1
- function e(e,t,n){return e+(t-e)*n}exports.tweenNumber=e;
1
+ function tweenNumber(e,t,n){return e+(t-e)*n}exports.tweenNumber=tweenNumber;
2
2
  //# sourceMappingURL=tween.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tween.cjs","names":[],"sources":["../../src/animation/tween.ts"],"sourcesContent":["export function tweenNumber(from: number, to: number, t: number): number {\n return from + (to - from) * t;\n}\n"],"mappings":"AAAA,SAAgB,EAAY,EAAc,EAAY,EAAmB,CACvE,OAAO,GAAQ,EAAK,GAAQ,CAC9B"}
1
+ {"version":3,"file":"tween.cjs","names":[],"sources":["../../src/animation/tween.ts"],"sourcesContent":["export function tweenNumber(from: number, to: number, t: number): number {\n return from + (to - from) * t;\n}\n"],"mappings":"AAAA,SAAgB,YAAY,EAAc,EAAY,EAAmB,CACvE,OAAO,GAAQ,EAAK,GAAQ,CAC9B"}
@@ -1,8 +1,2 @@
1
- //#region src/animation/tween.ts
2
- function e(e, t, n) {
3
- return e + (t - e) * n;
4
- }
5
- //#endregion
6
- export { e as tweenNumber };
7
-
1
+ function tweenNumber(e,t,n){return e+(t-e)*n}export{tweenNumber};
8
2
  //# sourceMappingURL=tween.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tween.js","names":[],"sources":["../../src/animation/tween.ts"],"sourcesContent":["export function tweenNumber(from: number, to: number, t: number): number {\n return from + (to - from) * t;\n}\n"],"mappings":";AAAA,SAAgB,EAAY,GAAc,GAAY,GAAmB;CACvE,OAAO,KAAQ,IAAK,KAAQ;AAC9B"}
1
+ {"version":3,"file":"tween.js","names":[],"sources":["../../src/animation/tween.ts"],"sourcesContent":["export function tweenNumber(from: number, to: number, t: number): number {\n return from + (to - from) * t;\n}\n"],"mappings":"AAAA,SAAgB,YAAY,EAAc,EAAY,EAAmB,CACvE,OAAO,GAAQ,EAAK,GAAQ,CAC9B"}
@@ -1,2 +1,2 @@
1
- const e=require("../svg/element.cjs"),t=require("../svg/text.cjs"),n=require("./scale-utils.cjs");var r=e=>e instanceof Date?e.toLocaleDateString(void 0,{month:`short`,year:`numeric`}):String(e);function i(e,t,n){let r=e.position??n,i=r===`bottom`||r===`top`?Math.max(2,Math.floor(t/80)):Math.max(2,Math.floor(t/50));return e.tickCount??i}function a(a,o,s,c,l=`bottom`){e.removeChildren(a);let u=s.position??l,d=u===`bottom`||u===`top`,f=u===`top`||u===`left`,p=f?-1:1,m=e.createSvgElement(`line`,{"aria-hidden":`true`,class:`prism-axis-line`,x1:0,x2:d?c:0,y1:0,y2:d?0:c});a.appendChild(m);let h=o.ticks(i(s,c,l)),g=s.tickFormat??r;for(let r of h){let i=n.mapTick(o,r),s=e.createSvgElement(`line`,{"aria-hidden":`true`,class:`prism-axis-tick`,x1:d?i:0,x2:d?i:6*p,y1:d?0:i,y2:d?6*p:i});a.appendChild(s);let c=t.createTextElement(g(r),{"aria-hidden":`true`,class:`prism-axis-label`,"dominant-baseline":d?f?`auto`:`hanging`:`middle`,"text-anchor":d?`middle`:f?`end`:`start`,x:d?i:6*p*1.5,y:d?6*p*1.5:i});a.appendChild(c)}if(s.label){let n=t.createTextElement(s.label,{class:`prism-axis-title`,"dominant-baseline":`middle`,"text-anchor":`middle`});d?e.setAttributes(n,{x:c/2,y:6*p*3.5}):e.setAttributes(n,{transform:`translate(${6*p*4}, ${c/2}) rotate(-90)`}),a.appendChild(n)}}exports.renderAxis=a,exports.resolveTickCount=i;
1
+ const e=require("../svg/element.cjs"),t=require("../svg/text.cjs"),n=require("./scale-utils.cjs");var defaultTickFormat=e=>e instanceof Date?e.toLocaleDateString(void 0,{month:`short`,year:`numeric`}):String(e);function positionAxis(e,t,n,r){let i=t===`bottom`?`translate(0,${r})`:t===`right`?`translate(${n},0)`:void 0;i?e.setAttribute(`transform`,i):e.removeAttribute(`transform`)}function resolveTickCount(e,t,n){let r=e.position??n,i=r===`bottom`||r===`top`?Math.max(2,Math.floor(t/80)):Math.max(2,Math.floor(t/50));return e.tickCount??i}function renderAxis(r,i,a,o,s=`bottom`){e.removeChildren(r);let c=a.position??s,l=c===`bottom`||c===`top`,u=c===`top`||c===`left`,d=u?-1:1,f=e.createSvgElement(`line`,{"aria-hidden":`true`,class:`prism-axis-line`,x1:0,x2:l?o:0,y1:0,y2:l?0:o});r.appendChild(f);let p=i.ticks(resolveTickCount(a,o,s)),m=a.tickFormat??defaultTickFormat;for(let a of p){let o=n.mapTick(i,a),s=e.createSvgElement(`line`,{"aria-hidden":`true`,class:`prism-axis-tick`,x1:l?o:0,x2:l?o:6*d,y1:l?0:o,y2:l?6*d:o});r.appendChild(s);let c=t.createTextElement(m(a),{"aria-hidden":`true`,class:`prism-axis-label`,"dominant-baseline":l?u?`auto`:`hanging`:`middle`,"text-anchor":l?`middle`:u?`end`:`start`,x:l?o:6*d*1.5,y:l?6*d*1.5:o});r.appendChild(c)}if(a.label){let n=t.createTextElement(a.label,{class:`prism-axis-title`,"dominant-baseline":`middle`,"text-anchor":`middle`});l?e.setAttributes(n,{x:o/2,y:6*d*6}):e.setAttributes(n,{transform:`translate(${6*d*7}, ${o/2}) rotate(-90)`}),r.appendChild(n)}}exports.positionAxis=positionAxis,exports.renderAxis=renderAxis,exports.resolveTickCount=resolveTickCount;
2
2
  //# sourceMappingURL=axis.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"axis.cjs","names":[],"sources":["../../src/axes/axis.ts"],"sourcesContent":["import { createSvgElement, removeChildren, setAttributes } from '../svg/element';\nimport { createTextElement } from '../svg/text';\nimport type { AxisConfig, AxisPosition } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nconst defaultTickFormat = (v: Date | number | string): string =>\n v instanceof Date ? v.toLocaleDateString(undefined, { month: 'short', year: 'numeric' }) : String(v);\n\n/**\n * Resolves the tick count an axis will render for a given scale/length — shared with\n * `renderGrid` so gridlines line up with axis ticks. `defaultPosition` must match the\n * one passed to the corresponding `renderAxis` call ('bottom' for xAxis, 'left' for yAxis).\n */\nexport function resolveTickCount(config: AxisConfig, length: number, defaultPosition: AxisPosition): number {\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const defaultTickCount = isHorizontal ? Math.max(2, Math.floor(length / 80)) : Math.max(2, Math.floor(length / 50));\n\n return config.tickCount ?? defaultTickCount;\n}\n\n/**\n * `defaultPosition` is applied when `config.position` is unset — pass `'bottom'` for an\n * xAxis call and `'left'` for a yAxis call so an unconfigured axis renders on its\n * conventional side instead of always defaulting to a horizontal bottom axis.\n */\nexport function renderAxis(\n parent: SVGGElement,\n scale: AnyScale,\n config: AxisConfig,\n length: number,\n defaultPosition: AxisPosition = 'bottom',\n): void {\n removeChildren(parent);\n\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const isInverted = position === 'top' || position === 'left';\n const tickSize = 6;\n const tickDirection = isInverted ? -1 : 1;\n\n const axisLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-line',\n x1: isHorizontal ? 0 : 0,\n x2: isHorizontal ? length : 0,\n y1: isHorizontal ? 0 : 0,\n y2: isHorizontal ? 0 : length,\n });\n\n parent.appendChild(axisLine);\n\n const ticks = scale.ticks(resolveTickCount(config, length, defaultPosition));\n const format = config.tickFormat ?? defaultTickFormat;\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const tickLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-tick',\n x1: isHorizontal ? pos : 0,\n x2: isHorizontal ? pos : tickSize * tickDirection,\n y1: isHorizontal ? 0 : pos,\n y2: isHorizontal ? tickSize * tickDirection : pos,\n });\n\n parent.appendChild(tickLine);\n\n const label = createTextElement(format(tick), {\n 'aria-hidden': 'true',\n class: 'prism-axis-label',\n 'dominant-baseline': isHorizontal ? (isInverted ? 'auto' : 'hanging') : 'middle',\n 'text-anchor': isHorizontal ? 'middle' : isInverted ? 'end' : 'start',\n x: isHorizontal ? pos : tickSize * tickDirection * 1.5,\n y: isHorizontal ? tickSize * tickDirection * 1.5 : pos,\n });\n\n parent.appendChild(label);\n }\n\n if (config.label) {\n const labelEl = createTextElement(config.label, {\n class: 'prism-axis-title',\n 'dominant-baseline': 'middle',\n 'text-anchor': 'middle',\n });\n\n if (isHorizontal) {\n setAttributes(labelEl, { x: length / 2, y: tickSize * tickDirection * 3.5 });\n } else {\n setAttributes(labelEl, {\n transform: `translate(${tickSize * tickDirection * 4}, ${length / 2}) rotate(-90)`,\n });\n }\n\n parent.appendChild(labelEl);\n }\n}\n"],"mappings":"kGAKA,IAAM,EAAqB,GACzB,aAAa,KAAO,EAAE,mBAAmB,IAAA,GAAW,CAAE,MAAO,QAAS,KAAM,SAAU,CAAC,EAAI,OAAO,CAAC,EAOrG,SAAgB,EAAiB,EAAoB,EAAgB,EAAuC,CAC1G,IAAM,EAAW,EAAO,UAAY,EAE9B,EADe,IAAa,UAAY,IAAa,MACnB,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,EAAE,CAAC,EAAI,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,EAAE,CAAC,EAElH,OAAO,EAAO,WAAa,CAC7B,CAOA,SAAgB,EACd,EACA,EACA,EACA,EACA,EAAgC,SAC1B,CACN,EAAA,eAAe,CAAM,EAErB,IAAM,EAAW,EAAO,UAAY,EAC9B,EAAe,IAAa,UAAY,IAAa,MACrD,EAAa,IAAa,OAAS,IAAa,OAEhD,EAAgB,EAAa,GAAK,EAElC,EAAW,EAAA,iBAAiB,OAAQ,CACxC,cAAe,OACf,MAAO,kBACP,GAAmB,EACnB,GAAI,EAAe,EAAS,EAC5B,GAAmB,EACnB,GAAI,EAAe,EAAI,CACzB,CAAC,EAED,EAAO,YAAY,CAAQ,EAE3B,IAAM,EAAQ,EAAM,MAAM,EAAiB,EAAQ,EAAQ,CAAe,CAAC,EACrE,EAAS,EAAO,YAAc,EAEpC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAA,QAAQ,EAAO,CAAI,EACzB,EAAW,EAAA,iBAAiB,OAAQ,CACxC,cAAe,OACf,MAAO,kBACP,GAAI,EAAe,EAAM,EACzB,GAAI,EAAe,EAAM,EAAW,EACpC,GAAI,EAAe,EAAI,EACvB,GAAI,EAAe,EAAW,EAAgB,CAChD,CAAC,EAED,EAAO,YAAY,CAAQ,EAE3B,IAAM,EAAQ,EAAA,kBAAkB,EAAO,CAAI,EAAG,CAC5C,cAAe,OACf,MAAO,mBACP,oBAAqB,EAAgB,EAAa,OAAS,UAAa,SACxE,cAAe,EAAe,SAAW,EAAa,MAAQ,QAC9D,EAAG,EAAe,EAAM,EAAW,EAAgB,IACnD,EAAG,EAAe,EAAW,EAAgB,IAAM,CACrD,CAAC,EAED,EAAO,YAAY,CAAK,CAC1B,CAEA,GAAI,EAAO,MAAO,CAChB,IAAM,EAAU,EAAA,kBAAkB,EAAO,MAAO,CAC9C,MAAO,mBACP,oBAAqB,SACrB,cAAe,QACjB,CAAC,EAEG,EACF,EAAA,cAAc,EAAS,CAAE,EAAG,EAAS,EAAG,EAAG,EAAW,EAAgB,GAAI,CAAC,EAE3E,EAAA,cAAc,EAAS,CACrB,UAAW,aAAa,EAAW,EAAgB,EAAE,IAAI,EAAS,EAAE,cACtE,CAAC,EAGH,EAAO,YAAY,CAAO,CAC5B,CACF"}
1
+ {"version":3,"file":"axis.cjs","names":[],"sources":["../../src/axes/axis.ts"],"sourcesContent":["import { createSvgElement, removeChildren, setAttributes } from '../svg/element';\nimport { createTextElement } from '../svg/text';\nimport type { AxisConfig, AxisPosition } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nconst defaultTickFormat = (v: Date | number | string): string =>\n v instanceof Date ? v.toLocaleDateString(undefined, { month: 'short', year: 'numeric' }) : String(v);\n\n/**\n * Resolves the tick count an axis will render for a given scale/length — shared with\n * `renderGrid` so gridlines line up with axis ticks. `defaultPosition` must match the\n * one passed to the corresponding `renderAxis` call ('bottom' for xAxis, 'left' for yAxis).\n */\nexport function positionAxis(parent: SVGGElement, position: AxisPosition, width: number, height: number): void {\n const transform =\n position === 'bottom' ? `translate(0,${height})` : position === 'right' ? `translate(${width},0)` : undefined;\n\n if (transform) parent.setAttribute('transform', transform);\n else parent.removeAttribute('transform');\n}\n\nexport function resolveTickCount(config: AxisConfig, length: number, defaultPosition: AxisPosition): number {\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const defaultTickCount = isHorizontal ? Math.max(2, Math.floor(length / 80)) : Math.max(2, Math.floor(length / 50));\n\n return config.tickCount ?? defaultTickCount;\n}\n\n/**\n * `defaultPosition` is applied when `config.position` is unset — pass `'bottom'` for an\n * xAxis call and `'left'` for a yAxis call so an unconfigured axis renders on its\n * conventional side instead of always defaulting to a horizontal bottom axis.\n */\nexport function renderAxis(\n parent: SVGGElement,\n scale: AnyScale,\n config: AxisConfig,\n length: number,\n defaultPosition: AxisPosition = 'bottom',\n): void {\n removeChildren(parent);\n\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const isInverted = position === 'top' || position === 'left';\n const tickSize = 6;\n const tickDirection = isInverted ? -1 : 1;\n\n const axisLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-line',\n x1: isHorizontal ? 0 : 0,\n x2: isHorizontal ? length : 0,\n y1: isHorizontal ? 0 : 0,\n y2: isHorizontal ? 0 : length,\n });\n\n parent.appendChild(axisLine);\n\n const ticks = scale.ticks(resolveTickCount(config, length, defaultPosition));\n const format = config.tickFormat ?? defaultTickFormat;\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const tickLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-tick',\n x1: isHorizontal ? pos : 0,\n x2: isHorizontal ? pos : tickSize * tickDirection,\n y1: isHorizontal ? 0 : pos,\n y2: isHorizontal ? tickSize * tickDirection : pos,\n });\n\n parent.appendChild(tickLine);\n\n const label = createTextElement(format(tick), {\n 'aria-hidden': 'true',\n class: 'prism-axis-label',\n 'dominant-baseline': isHorizontal ? (isInverted ? 'auto' : 'hanging') : 'middle',\n 'text-anchor': isHorizontal ? 'middle' : isInverted ? 'end' : 'start',\n x: isHorizontal ? pos : tickSize * tickDirection * 1.5,\n y: isHorizontal ? tickSize * tickDirection * 1.5 : pos,\n });\n\n parent.appendChild(label);\n }\n\n if (config.label) {\n const labelEl = createTextElement(config.label, {\n class: 'prism-axis-title',\n 'dominant-baseline': 'middle',\n 'text-anchor': 'middle',\n });\n\n if (isHorizontal) {\n setAttributes(labelEl, { x: length / 2, y: tickSize * tickDirection * 6 });\n } else {\n setAttributes(labelEl, {\n transform: `translate(${tickSize * tickDirection * 7}, ${length / 2}) rotate(-90)`,\n });\n }\n\n parent.appendChild(labelEl);\n }\n}\n"],"mappings":"kGAKA,IAAM,kBAAqB,GACzB,aAAa,KAAO,EAAE,mBAAmB,IAAA,GAAW,CAAE,MAAO,QAAS,KAAM,SAAU,CAAC,EAAI,OAAO,CAAC,EAOrG,SAAgB,aAAa,EAAqB,EAAwB,EAAe,EAAsB,CAC7G,IAAM,EACJ,IAAa,SAAW,eAAe,EAAO,GAAK,IAAa,QAAU,aAAa,EAAM,KAAO,IAAA,GAElG,EAAW,EAAO,aAAa,YAAa,CAAS,EACpD,EAAO,gBAAgB,WAAW,CACzC,CAEA,SAAgB,iBAAiB,EAAoB,EAAgB,EAAuC,CAC1G,IAAM,EAAW,EAAO,UAAY,EAE9B,EADe,IAAa,UAAY,IAAa,MACnB,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,EAAE,CAAC,EAAI,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,EAAE,CAAC,EAElH,OAAO,EAAO,WAAa,CAC7B,CAOA,SAAgB,WACd,EACA,EACA,EACA,EACA,EAAgC,SAC1B,CACN,EAAA,eAAe,CAAM,EAErB,IAAM,EAAW,EAAO,UAAY,EAC9B,EAAe,IAAa,UAAY,IAAa,MACrD,EAAa,IAAa,OAAS,IAAa,OAEhD,EAAgB,EAAa,GAAK,EAElC,EAAW,EAAA,iBAAiB,OAAQ,CACxC,cAAe,OACf,MAAO,kBACP,GAAmB,EACnB,GAAI,EAAe,EAAS,EAC5B,GAAmB,EACnB,GAAI,EAAe,EAAI,CACzB,CAAC,EAED,EAAO,YAAY,CAAQ,EAE3B,IAAM,EAAQ,EAAM,MAAM,iBAAiB,EAAQ,EAAQ,CAAe,CAAC,EACrE,EAAS,EAAO,YAAc,kBAEpC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAA,QAAQ,EAAO,CAAI,EACzB,EAAW,EAAA,iBAAiB,OAAQ,CACxC,cAAe,OACf,MAAO,kBACP,GAAI,EAAe,EAAM,EACzB,GAAI,EAAe,EAAM,EAAW,EACpC,GAAI,EAAe,EAAI,EACvB,GAAI,EAAe,EAAW,EAAgB,CAChD,CAAC,EAED,EAAO,YAAY,CAAQ,EAE3B,IAAM,EAAQ,EAAA,kBAAkB,EAAO,CAAI,EAAG,CAC5C,cAAe,OACf,MAAO,mBACP,oBAAqB,EAAgB,EAAa,OAAS,UAAa,SACxE,cAAe,EAAe,SAAW,EAAa,MAAQ,QAC9D,EAAG,EAAe,EAAM,EAAW,EAAgB,IACnD,EAAG,EAAe,EAAW,EAAgB,IAAM,CACrD,CAAC,EAED,EAAO,YAAY,CAAK,CAC1B,CAEA,GAAI,EAAO,MAAO,CAChB,IAAM,EAAU,EAAA,kBAAkB,EAAO,MAAO,CAC9C,MAAO,mBACP,oBAAqB,SACrB,cAAe,QACjB,CAAC,EAEG,EACF,EAAA,cAAc,EAAS,CAAE,EAAG,EAAS,EAAG,EAAG,EAAW,EAAgB,CAAE,CAAC,EAEzE,EAAA,cAAc,EAAS,CACrB,UAAW,aAAa,EAAW,EAAgB,EAAE,IAAI,EAAS,EAAE,cACtE,CAAC,EAGH,EAAO,YAAY,CAAO,CAC5B,CACF"}
@@ -5,6 +5,7 @@ import { type AnyScale } from './scale-utils';
5
5
  * `renderGrid` so gridlines line up with axis ticks. `defaultPosition` must match the
6
6
  * one passed to the corresponding `renderAxis` call ('bottom' for xAxis, 'left' for yAxis).
7
7
  */
8
+ export declare function positionAxis(parent: SVGGElement, position: AxisPosition, width: number, height: number): void;
8
9
  export declare function resolveTickCount(config: AxisConfig, length: number, defaultPosition: AxisPosition): number;
9
10
  /**
10
11
  * `defaultPosition` is applied when `config.position` is unset — pass `'bottom'` for an
@@ -1 +1 @@
1
- {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/axes/axis.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAW,MAAM,eAAe,CAAC;AAKvD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,GAAG,MAAM,CAM1G;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,eAAe,GAAE,YAAuB,GACvC,IAAI,CAiEN"}
1
+ {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/axes/axis.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAW,MAAM,eAAe,CAAC;AAKvD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAM7G;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,GAAG,MAAM,CAM1G;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,eAAe,GAAE,YAAuB,GACvC,IAAI,CAiEN"}
package/dist/axes/axis.js CHANGED
@@ -1,60 +1,2 @@
1
- import { createSvgElement as e, removeChildren as t, setAttributes as n } from "../svg/element.js";
2
- import { createTextElement as r } from "../svg/text.js";
3
- import { mapTick as i } from "./scale-utils.js";
4
- //#region src/axes/axis.ts
5
- var a = (e) => e instanceof Date ? e.toLocaleDateString(void 0, {
6
- month: "short",
7
- year: "numeric"
8
- }) : String(e);
9
- function o(e, t, n) {
10
- let r = e.position ?? n, i = r === "bottom" || r === "top" ? Math.max(2, Math.floor(t / 80)) : Math.max(2, Math.floor(t / 50));
11
- return e.tickCount ?? i;
12
- }
13
- function s(s, c, l, u, d = "bottom") {
14
- t(s);
15
- let f = l.position ?? d, p = f === "bottom" || f === "top", m = f === "top" || f === "left", h = m ? -1 : 1, g = e("line", {
16
- "aria-hidden": "true",
17
- class: "prism-axis-line",
18
- x1: 0,
19
- x2: p ? u : 0,
20
- y1: 0,
21
- y2: p ? 0 : u
22
- });
23
- s.appendChild(g);
24
- let _ = c.ticks(o(l, u, d)), v = l.tickFormat ?? a;
25
- for (let t of _) {
26
- let n = i(c, t), a = e("line", {
27
- "aria-hidden": "true",
28
- class: "prism-axis-tick",
29
- x1: p ? n : 0,
30
- x2: p ? n : 6 * h,
31
- y1: p ? 0 : n,
32
- y2: p ? 6 * h : n
33
- });
34
- s.appendChild(a);
35
- let o = r(v(t), {
36
- "aria-hidden": "true",
37
- class: "prism-axis-label",
38
- "dominant-baseline": p ? m ? "auto" : "hanging" : "middle",
39
- "text-anchor": p ? "middle" : m ? "end" : "start",
40
- x: p ? n : 6 * h * 1.5,
41
- y: p ? 6 * h * 1.5 : n
42
- });
43
- s.appendChild(o);
44
- }
45
- if (l.label) {
46
- let e = r(l.label, {
47
- class: "prism-axis-title",
48
- "dominant-baseline": "middle",
49
- "text-anchor": "middle"
50
- });
51
- p ? n(e, {
52
- x: u / 2,
53
- y: 6 * h * 3.5
54
- }) : n(e, { transform: `translate(${6 * h * 4}, ${u / 2}) rotate(-90)` }), s.appendChild(e);
55
- }
56
- }
57
- //#endregion
58
- export { s as renderAxis, o as resolveTickCount };
59
-
1
+ import{createSvgElement as e,removeChildren as t,setAttributes as n}from"../svg/element.js";import{createTextElement as r}from"../svg/text.js";import{mapTick as i}from"./scale-utils.js";var defaultTickFormat=e=>e instanceof Date?e.toLocaleDateString(void 0,{month:`short`,year:`numeric`}):String(e);function positionAxis(e,t,n,r){let i=t===`bottom`?`translate(0,${r})`:t===`right`?`translate(${n},0)`:void 0;i?e.setAttribute(`transform`,i):e.removeAttribute(`transform`)}function resolveTickCount(e,t,n){let r=e.position??n,i=r===`bottom`||r===`top`?Math.max(2,Math.floor(t/80)):Math.max(2,Math.floor(t/50));return e.tickCount??i}function renderAxis(a,o,s,c,l=`bottom`){t(a);let u=s.position??l,d=u===`bottom`||u===`top`,f=u===`top`||u===`left`,p=f?-1:1,m=e(`line`,{"aria-hidden":`true`,class:`prism-axis-line`,x1:0,x2:d?c:0,y1:0,y2:d?0:c});a.appendChild(m);let h=o.ticks(resolveTickCount(s,c,l)),g=s.tickFormat??defaultTickFormat;for(let t of h){let n=i(o,t),s=e(`line`,{"aria-hidden":`true`,class:`prism-axis-tick`,x1:d?n:0,x2:d?n:6*p,y1:d?0:n,y2:d?6*p:n});a.appendChild(s);let c=r(g(t),{"aria-hidden":`true`,class:`prism-axis-label`,"dominant-baseline":d?f?`auto`:`hanging`:`middle`,"text-anchor":d?`middle`:f?`end`:`start`,x:d?n:6*p*1.5,y:d?6*p*1.5:n});a.appendChild(c)}if(s.label){let e=r(s.label,{class:`prism-axis-title`,"dominant-baseline":`middle`,"text-anchor":`middle`});d?n(e,{x:c/2,y:6*p*6}):n(e,{transform:`translate(${6*p*7}, ${c/2}) rotate(-90)`}),a.appendChild(e)}}export{positionAxis,renderAxis,resolveTickCount};
60
2
  //# sourceMappingURL=axis.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"axis.js","names":[],"sources":["../../src/axes/axis.ts"],"sourcesContent":["import { createSvgElement, removeChildren, setAttributes } from '../svg/element';\nimport { createTextElement } from '../svg/text';\nimport type { AxisConfig, AxisPosition } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nconst defaultTickFormat = (v: Date | number | string): string =>\n v instanceof Date ? v.toLocaleDateString(undefined, { month: 'short', year: 'numeric' }) : String(v);\n\n/**\n * Resolves the tick count an axis will render for a given scale/length — shared with\n * `renderGrid` so gridlines line up with axis ticks. `defaultPosition` must match the\n * one passed to the corresponding `renderAxis` call ('bottom' for xAxis, 'left' for yAxis).\n */\nexport function resolveTickCount(config: AxisConfig, length: number, defaultPosition: AxisPosition): number {\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const defaultTickCount = isHorizontal ? Math.max(2, Math.floor(length / 80)) : Math.max(2, Math.floor(length / 50));\n\n return config.tickCount ?? defaultTickCount;\n}\n\n/**\n * `defaultPosition` is applied when `config.position` is unset — pass `'bottom'` for an\n * xAxis call and `'left'` for a yAxis call so an unconfigured axis renders on its\n * conventional side instead of always defaulting to a horizontal bottom axis.\n */\nexport function renderAxis(\n parent: SVGGElement,\n scale: AnyScale,\n config: AxisConfig,\n length: number,\n defaultPosition: AxisPosition = 'bottom',\n): void {\n removeChildren(parent);\n\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const isInverted = position === 'top' || position === 'left';\n const tickSize = 6;\n const tickDirection = isInverted ? -1 : 1;\n\n const axisLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-line',\n x1: isHorizontal ? 0 : 0,\n x2: isHorizontal ? length : 0,\n y1: isHorizontal ? 0 : 0,\n y2: isHorizontal ? 0 : length,\n });\n\n parent.appendChild(axisLine);\n\n const ticks = scale.ticks(resolveTickCount(config, length, defaultPosition));\n const format = config.tickFormat ?? defaultTickFormat;\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const tickLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-tick',\n x1: isHorizontal ? pos : 0,\n x2: isHorizontal ? pos : tickSize * tickDirection,\n y1: isHorizontal ? 0 : pos,\n y2: isHorizontal ? tickSize * tickDirection : pos,\n });\n\n parent.appendChild(tickLine);\n\n const label = createTextElement(format(tick), {\n 'aria-hidden': 'true',\n class: 'prism-axis-label',\n 'dominant-baseline': isHorizontal ? (isInverted ? 'auto' : 'hanging') : 'middle',\n 'text-anchor': isHorizontal ? 'middle' : isInverted ? 'end' : 'start',\n x: isHorizontal ? pos : tickSize * tickDirection * 1.5,\n y: isHorizontal ? tickSize * tickDirection * 1.5 : pos,\n });\n\n parent.appendChild(label);\n }\n\n if (config.label) {\n const labelEl = createTextElement(config.label, {\n class: 'prism-axis-title',\n 'dominant-baseline': 'middle',\n 'text-anchor': 'middle',\n });\n\n if (isHorizontal) {\n setAttributes(labelEl, { x: length / 2, y: tickSize * tickDirection * 3.5 });\n } else {\n setAttributes(labelEl, {\n transform: `translate(${tickSize * tickDirection * 4}, ${length / 2}) rotate(-90)`,\n });\n }\n\n parent.appendChild(labelEl);\n }\n}\n"],"mappings":";;;;AAKA,IAAM,KAAqB,MACzB,aAAa,OAAO,EAAE,mBAAmB,KAAA,GAAW;CAAE,OAAO;CAAS,MAAM;AAAU,CAAC,IAAI,OAAO,CAAC;AAOrG,SAAgB,EAAiB,GAAoB,GAAgB,GAAuC;CAC1G,IAAM,IAAW,EAAO,YAAY,GAE9B,IADe,MAAa,YAAY,MAAa,QACnB,KAAK,IAAI,GAAG,KAAK,MAAM,IAAS,EAAE,CAAC,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,IAAS,EAAE,CAAC;CAElH,OAAO,EAAO,aAAa;AAC7B;AAOA,SAAgB,EACd,GACA,GACA,GACA,GACA,IAAgC,UAC1B;CACN,EAAe,CAAM;CAErB,IAAM,IAAW,EAAO,YAAY,GAC9B,IAAe,MAAa,YAAY,MAAa,OACrD,IAAa,MAAa,SAAS,MAAa,QAEhD,IAAgB,IAAa,KAAK,GAElC,IAAW,EAAiB,QAAQ;EACxC,eAAe;EACf,OAAO;EACP,IAAmB;EACnB,IAAI,IAAe,IAAS;EAC5B,IAAmB;EACnB,IAAI,IAAe,IAAI;CACzB,CAAC;CAED,EAAO,YAAY,CAAQ;CAE3B,IAAM,IAAQ,EAAM,MAAM,EAAiB,GAAQ,GAAQ,CAAe,CAAC,GACrE,IAAS,EAAO,cAAc;CAEpC,KAAK,IAAM,KAAQ,GAAO;EACxB,IAAM,IAAM,EAAQ,GAAO,CAAI,GACzB,IAAW,EAAiB,QAAQ;GACxC,eAAe;GACf,OAAO;GACP,IAAI,IAAe,IAAM;GACzB,IAAI,IAAe,IAAM,IAAW;GACpC,IAAI,IAAe,IAAI;GACvB,IAAI,IAAe,IAAW,IAAgB;EAChD,CAAC;EAED,EAAO,YAAY,CAAQ;EAE3B,IAAM,IAAQ,EAAkB,EAAO,CAAI,GAAG;GAC5C,eAAe;GACf,OAAO;GACP,qBAAqB,IAAgB,IAAa,SAAS,YAAa;GACxE,eAAe,IAAe,WAAW,IAAa,QAAQ;GAC9D,GAAG,IAAe,IAAM,IAAW,IAAgB;GACnD,GAAG,IAAe,IAAW,IAAgB,MAAM;EACrD,CAAC;EAED,EAAO,YAAY,CAAK;CAC1B;CAEA,IAAI,EAAO,OAAO;EAChB,IAAM,IAAU,EAAkB,EAAO,OAAO;GAC9C,OAAO;GACP,qBAAqB;GACrB,eAAe;EACjB,CAAC;EAUD,AARI,IACF,EAAc,GAAS;GAAE,GAAG,IAAS;GAAG,GAAG,IAAW,IAAgB;EAAI,CAAC,IAE3E,EAAc,GAAS,EACrB,WAAW,aAAa,IAAW,IAAgB,EAAE,IAAI,IAAS,EAAE,eACtE,CAAC,GAGH,EAAO,YAAY,CAAO;CAC5B;AACF"}
1
+ {"version":3,"file":"axis.js","names":[],"sources":["../../src/axes/axis.ts"],"sourcesContent":["import { createSvgElement, removeChildren, setAttributes } from '../svg/element';\nimport { createTextElement } from '../svg/text';\nimport type { AxisConfig, AxisPosition } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nconst defaultTickFormat = (v: Date | number | string): string =>\n v instanceof Date ? v.toLocaleDateString(undefined, { month: 'short', year: 'numeric' }) : String(v);\n\n/**\n * Resolves the tick count an axis will render for a given scale/length — shared with\n * `renderGrid` so gridlines line up with axis ticks. `defaultPosition` must match the\n * one passed to the corresponding `renderAxis` call ('bottom' for xAxis, 'left' for yAxis).\n */\nexport function positionAxis(parent: SVGGElement, position: AxisPosition, width: number, height: number): void {\n const transform =\n position === 'bottom' ? `translate(0,${height})` : position === 'right' ? `translate(${width},0)` : undefined;\n\n if (transform) parent.setAttribute('transform', transform);\n else parent.removeAttribute('transform');\n}\n\nexport function resolveTickCount(config: AxisConfig, length: number, defaultPosition: AxisPosition): number {\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const defaultTickCount = isHorizontal ? Math.max(2, Math.floor(length / 80)) : Math.max(2, Math.floor(length / 50));\n\n return config.tickCount ?? defaultTickCount;\n}\n\n/**\n * `defaultPosition` is applied when `config.position` is unset — pass `'bottom'` for an\n * xAxis call and `'left'` for a yAxis call so an unconfigured axis renders on its\n * conventional side instead of always defaulting to a horizontal bottom axis.\n */\nexport function renderAxis(\n parent: SVGGElement,\n scale: AnyScale,\n config: AxisConfig,\n length: number,\n defaultPosition: AxisPosition = 'bottom',\n): void {\n removeChildren(parent);\n\n const position = config.position ?? defaultPosition;\n const isHorizontal = position === 'bottom' || position === 'top';\n const isInverted = position === 'top' || position === 'left';\n const tickSize = 6;\n const tickDirection = isInverted ? -1 : 1;\n\n const axisLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-line',\n x1: isHorizontal ? 0 : 0,\n x2: isHorizontal ? length : 0,\n y1: isHorizontal ? 0 : 0,\n y2: isHorizontal ? 0 : length,\n });\n\n parent.appendChild(axisLine);\n\n const ticks = scale.ticks(resolveTickCount(config, length, defaultPosition));\n const format = config.tickFormat ?? defaultTickFormat;\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const tickLine = createSvgElement('line', {\n 'aria-hidden': 'true',\n class: 'prism-axis-tick',\n x1: isHorizontal ? pos : 0,\n x2: isHorizontal ? pos : tickSize * tickDirection,\n y1: isHorizontal ? 0 : pos,\n y2: isHorizontal ? tickSize * tickDirection : pos,\n });\n\n parent.appendChild(tickLine);\n\n const label = createTextElement(format(tick), {\n 'aria-hidden': 'true',\n class: 'prism-axis-label',\n 'dominant-baseline': isHorizontal ? (isInverted ? 'auto' : 'hanging') : 'middle',\n 'text-anchor': isHorizontal ? 'middle' : isInverted ? 'end' : 'start',\n x: isHorizontal ? pos : tickSize * tickDirection * 1.5,\n y: isHorizontal ? tickSize * tickDirection * 1.5 : pos,\n });\n\n parent.appendChild(label);\n }\n\n if (config.label) {\n const labelEl = createTextElement(config.label, {\n class: 'prism-axis-title',\n 'dominant-baseline': 'middle',\n 'text-anchor': 'middle',\n });\n\n if (isHorizontal) {\n setAttributes(labelEl, { x: length / 2, y: tickSize * tickDirection * 6 });\n } else {\n setAttributes(labelEl, {\n transform: `translate(${tickSize * tickDirection * 7}, ${length / 2}) rotate(-90)`,\n });\n }\n\n parent.appendChild(labelEl);\n }\n}\n"],"mappings":"0LAKA,IAAM,kBAAqB,GACzB,aAAa,KAAO,EAAE,mBAAmB,IAAA,GAAW,CAAE,MAAO,QAAS,KAAM,SAAU,CAAC,EAAI,OAAO,CAAC,EAOrG,SAAgB,aAAa,EAAqB,EAAwB,EAAe,EAAsB,CAC7G,IAAM,EACJ,IAAa,SAAW,eAAe,EAAO,GAAK,IAAa,QAAU,aAAa,EAAM,KAAO,IAAA,GAElG,EAAW,EAAO,aAAa,YAAa,CAAS,EACpD,EAAO,gBAAgB,WAAW,CACzC,CAEA,SAAgB,iBAAiB,EAAoB,EAAgB,EAAuC,CAC1G,IAAM,EAAW,EAAO,UAAY,EAE9B,EADe,IAAa,UAAY,IAAa,MACnB,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,EAAE,CAAC,EAAI,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,EAAE,CAAC,EAElH,OAAO,EAAO,WAAa,CAC7B,CAOA,SAAgB,WACd,EACA,EACA,EACA,EACA,EAAgC,SAC1B,CACN,EAAe,CAAM,EAErB,IAAM,EAAW,EAAO,UAAY,EAC9B,EAAe,IAAa,UAAY,IAAa,MACrD,EAAa,IAAa,OAAS,IAAa,OAEhD,EAAgB,EAAa,GAAK,EAElC,EAAW,EAAiB,OAAQ,CACxC,cAAe,OACf,MAAO,kBACP,GAAmB,EACnB,GAAI,EAAe,EAAS,EAC5B,GAAmB,EACnB,GAAI,EAAe,EAAI,CACzB,CAAC,EAED,EAAO,YAAY,CAAQ,EAE3B,IAAM,EAAQ,EAAM,MAAM,iBAAiB,EAAQ,EAAQ,CAAe,CAAC,EACrE,EAAS,EAAO,YAAc,kBAEpC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAQ,EAAO,CAAI,EACzB,EAAW,EAAiB,OAAQ,CACxC,cAAe,OACf,MAAO,kBACP,GAAI,EAAe,EAAM,EACzB,GAAI,EAAe,EAAM,EAAW,EACpC,GAAI,EAAe,EAAI,EACvB,GAAI,EAAe,EAAW,EAAgB,CAChD,CAAC,EAED,EAAO,YAAY,CAAQ,EAE3B,IAAM,EAAQ,EAAkB,EAAO,CAAI,EAAG,CAC5C,cAAe,OACf,MAAO,mBACP,oBAAqB,EAAgB,EAAa,OAAS,UAAa,SACxE,cAAe,EAAe,SAAW,EAAa,MAAQ,QAC9D,EAAG,EAAe,EAAM,EAAW,EAAgB,IACnD,EAAG,EAAe,EAAW,EAAgB,IAAM,CACrD,CAAC,EAED,EAAO,YAAY,CAAK,CAC1B,CAEA,GAAI,EAAO,MAAO,CAChB,IAAM,EAAU,EAAkB,EAAO,MAAO,CAC9C,MAAO,mBACP,oBAAqB,SACrB,cAAe,QACjB,CAAC,EAEG,EACF,EAAc,EAAS,CAAE,EAAG,EAAS,EAAG,EAAG,EAAW,EAAgB,CAAE,CAAC,EAEzE,EAAc,EAAS,CACrB,UAAW,aAAa,EAAW,EAAgB,EAAE,IAAI,EAAS,EAAE,cACtE,CAAC,EAGH,EAAO,YAAY,CAAO,CAC5B,CACF"}
@@ -1,2 +1,2 @@
1
- const e=require("../svg/element.cjs"),t=require("./scale-utils.cjs");function n(n,r,i,a,o,s=10){e.removeChildren(n);let c=i!==!0&&i.color||void 0,l=i!==!0&&i.dash||void 0,u=r.ticks(s);for(let i of u){let s=t.mapTick(r,i),u={class:`prism-grid-line`,stroke:c??`var(--prism-grid-color)`,"stroke-dasharray":l,"stroke-opacity":`var(--prism-grid-opacity)`};o===`vertical`?Object.assign(u,{x1:s,x2:s,y1:0,y2:a}):Object.assign(u,{x1:0,x2:a,y1:s,y2:s}),n.appendChild(e.createSvgElement(`line`,u))}}exports.renderGrid=n;
1
+ const e=require("../svg/element.cjs"),t=require("./scale-utils.cjs");function renderGrid(n,r,i,a,o,s=10){e.removeChildren(n);let c=i!==!0&&i.color||void 0,l=i!==!0&&i.dash||void 0,u=r.ticks(s);for(let i of u){let s=t.mapTick(r,i),u={class:`prism-grid-line`,stroke:c??`var(--prism-grid-color)`,"stroke-dasharray":l,"stroke-opacity":`var(--prism-grid-opacity)`};o===`vertical`?Object.assign(u,{x1:s,x2:s,y1:0,y2:a}):Object.assign(u,{x1:0,x2:a,y1:s,y2:s}),n.appendChild(e.createSvgElement(`line`,u))}}exports.renderGrid=renderGrid;
2
2
  //# sourceMappingURL=grid.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"grid.cjs","names":[],"sources":["../../src/axes/grid.ts"],"sourcesContent":["import { createSvgElement, removeChildren } from '../svg/element';\nimport type { GridConfig } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nexport function renderGrid(\n parent: SVGGElement,\n scale: AnyScale,\n config: GridConfig | true,\n crossLength: number,\n direction: 'horizontal' | 'vertical',\n tickCount = 10,\n): void {\n removeChildren(parent);\n\n const color = (config !== true && config.color) || undefined;\n const dash = (config !== true && config.dash) || undefined;\n const ticks = scale.ticks(tickCount);\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const attrs: Record<string, number | string | undefined> = {\n class: 'prism-grid-line',\n stroke: color ?? 'var(--prism-grid-color)',\n 'stroke-dasharray': dash,\n 'stroke-opacity': 'var(--prism-grid-opacity)',\n };\n\n if (direction === 'vertical') {\n Object.assign(attrs, { x1: pos, x2: pos, y1: 0, y2: crossLength });\n } else {\n Object.assign(attrs, { x1: 0, x2: crossLength, y1: pos, y2: pos });\n }\n\n parent.appendChild(createSvgElement('line', attrs));\n }\n}\n"],"mappings":"qEAIA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,EAAY,GACN,CACN,EAAA,eAAe,CAAM,EAErB,IAAM,EAAS,IAAW,IAAQ,EAAO,OAAU,IAAA,GAC7C,EAAQ,IAAW,IAAQ,EAAO,MAAS,IAAA,GAC3C,EAAQ,EAAM,MAAM,CAAS,EAEnC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAA,QAAQ,EAAO,CAAI,EACzB,EAAqD,CACzD,MAAO,kBACP,OAAQ,GAAS,0BACjB,mBAAoB,EACpB,iBAAkB,2BACpB,EAEI,IAAc,WAChB,OAAO,OAAO,EAAO,CAAE,GAAI,EAAK,GAAI,EAAK,GAAI,EAAG,GAAI,CAAY,CAAC,EAEjE,OAAO,OAAO,EAAO,CAAE,GAAI,EAAG,GAAI,EAAa,GAAI,EAAK,GAAI,CAAI,CAAC,EAGnE,EAAO,YAAY,EAAA,iBAAiB,OAAQ,CAAK,CAAC,CACpD,CACF"}
1
+ {"version":3,"file":"grid.cjs","names":[],"sources":["../../src/axes/grid.ts"],"sourcesContent":["import { createSvgElement, removeChildren } from '../svg/element';\nimport type { GridConfig } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nexport function renderGrid(\n parent: SVGGElement,\n scale: AnyScale,\n config: GridConfig | true,\n crossLength: number,\n direction: 'horizontal' | 'vertical',\n tickCount = 10,\n): void {\n removeChildren(parent);\n\n const color = (config !== true && config.color) || undefined;\n const dash = (config !== true && config.dash) || undefined;\n const ticks = scale.ticks(tickCount);\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const attrs: Record<string, number | string | undefined> = {\n class: 'prism-grid-line',\n stroke: color ?? 'var(--prism-grid-color)',\n 'stroke-dasharray': dash,\n 'stroke-opacity': 'var(--prism-grid-opacity)',\n };\n\n if (direction === 'vertical') {\n Object.assign(attrs, { x1: pos, x2: pos, y1: 0, y2: crossLength });\n } else {\n Object.assign(attrs, { x1: 0, x2: crossLength, y1: pos, y2: pos });\n }\n\n parent.appendChild(createSvgElement('line', attrs));\n }\n}\n"],"mappings":"qEAIA,SAAgB,WACd,EACA,EACA,EACA,EACA,EACA,EAAY,GACN,CACN,EAAA,eAAe,CAAM,EAErB,IAAM,EAAS,IAAW,IAAQ,EAAO,OAAU,IAAA,GAC7C,EAAQ,IAAW,IAAQ,EAAO,MAAS,IAAA,GAC3C,EAAQ,EAAM,MAAM,CAAS,EAEnC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAA,QAAQ,EAAO,CAAI,EACzB,EAAqD,CACzD,MAAO,kBACP,OAAQ,GAAS,0BACjB,mBAAoB,EACpB,iBAAkB,2BACpB,EAEI,IAAc,WAChB,OAAO,OAAO,EAAO,CAAE,GAAI,EAAK,GAAI,EAAK,GAAI,EAAG,GAAI,CAAY,CAAC,EAEjE,OAAO,OAAO,EAAO,CAAE,GAAI,EAAG,GAAI,EAAa,GAAI,EAAK,GAAI,CAAI,CAAC,EAGnE,EAAO,YAAY,EAAA,iBAAiB,OAAQ,CAAK,CAAC,CACpD,CACF"}
package/dist/axes/grid.js CHANGED
@@ -1,30 +1,2 @@
1
- import { createSvgElement as e, removeChildren as t } from "../svg/element.js";
2
- import { mapTick as n } from "./scale-utils.js";
3
- //#region src/axes/grid.ts
4
- function r(r, i, a, o, s, c = 10) {
5
- t(r);
6
- let l = a !== !0 && a.color || void 0, u = a !== !0 && a.dash || void 0, d = i.ticks(c);
7
- for (let t of d) {
8
- let a = n(i, t), c = {
9
- class: "prism-grid-line",
10
- stroke: l ?? "var(--prism-grid-color)",
11
- "stroke-dasharray": u,
12
- "stroke-opacity": "var(--prism-grid-opacity)"
13
- };
14
- s === "vertical" ? Object.assign(c, {
15
- x1: a,
16
- x2: a,
17
- y1: 0,
18
- y2: o
19
- }) : Object.assign(c, {
20
- x1: 0,
21
- x2: o,
22
- y1: a,
23
- y2: a
24
- }), r.appendChild(e("line", c));
25
- }
26
- }
27
- //#endregion
28
- export { r as renderGrid };
29
-
1
+ import{createSvgElement as e,removeChildren as t}from"../svg/element.js";import{mapTick as n}from"./scale-utils.js";function renderGrid(r,i,a,o,s,c=10){t(r);let l=a!==!0&&a.color||void 0,u=a!==!0&&a.dash||void 0,d=i.ticks(c);for(let t of d){let a=n(i,t),c={class:`prism-grid-line`,stroke:l??`var(--prism-grid-color)`,"stroke-dasharray":u,"stroke-opacity":`var(--prism-grid-opacity)`};s===`vertical`?Object.assign(c,{x1:a,x2:a,y1:0,y2:o}):Object.assign(c,{x1:0,x2:o,y1:a,y2:a}),r.appendChild(e(`line`,c))}}export{renderGrid};
30
2
  //# sourceMappingURL=grid.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grid.js","names":[],"sources":["../../src/axes/grid.ts"],"sourcesContent":["import { createSvgElement, removeChildren } from '../svg/element';\nimport type { GridConfig } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nexport function renderGrid(\n parent: SVGGElement,\n scale: AnyScale,\n config: GridConfig | true,\n crossLength: number,\n direction: 'horizontal' | 'vertical',\n tickCount = 10,\n): void {\n removeChildren(parent);\n\n const color = (config !== true && config.color) || undefined;\n const dash = (config !== true && config.dash) || undefined;\n const ticks = scale.ticks(tickCount);\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const attrs: Record<string, number | string | undefined> = {\n class: 'prism-grid-line',\n stroke: color ?? 'var(--prism-grid-color)',\n 'stroke-dasharray': dash,\n 'stroke-opacity': 'var(--prism-grid-opacity)',\n };\n\n if (direction === 'vertical') {\n Object.assign(attrs, { x1: pos, x2: pos, y1: 0, y2: crossLength });\n } else {\n Object.assign(attrs, { x1: 0, x2: crossLength, y1: pos, y2: pos });\n }\n\n parent.appendChild(createSvgElement('line', attrs));\n }\n}\n"],"mappings":";;;AAIA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACA,IAAY,IACN;CACN,EAAe,CAAM;CAErB,IAAM,IAAS,MAAW,MAAQ,EAAO,SAAU,KAAA,GAC7C,IAAQ,MAAW,MAAQ,EAAO,QAAS,KAAA,GAC3C,IAAQ,EAAM,MAAM,CAAS;CAEnC,KAAK,IAAM,KAAQ,GAAO;EACxB,IAAM,IAAM,EAAQ,GAAO,CAAI,GACzB,IAAqD;GACzD,OAAO;GACP,QAAQ,KAAS;GACjB,oBAAoB;GACpB,kBAAkB;EACpB;EAQA,AANI,MAAc,aAChB,OAAO,OAAO,GAAO;GAAE,IAAI;GAAK,IAAI;GAAK,IAAI;GAAG,IAAI;EAAY,CAAC,IAEjE,OAAO,OAAO,GAAO;GAAE,IAAI;GAAG,IAAI;GAAa,IAAI;GAAK,IAAI;EAAI,CAAC,GAGnE,EAAO,YAAY,EAAiB,QAAQ,CAAK,CAAC;CACpD;AACF"}
1
+ {"version":3,"file":"grid.js","names":[],"sources":["../../src/axes/grid.ts"],"sourcesContent":["import { createSvgElement, removeChildren } from '../svg/element';\nimport type { GridConfig } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\nexport function renderGrid(\n parent: SVGGElement,\n scale: AnyScale,\n config: GridConfig | true,\n crossLength: number,\n direction: 'horizontal' | 'vertical',\n tickCount = 10,\n): void {\n removeChildren(parent);\n\n const color = (config !== true && config.color) || undefined;\n const dash = (config !== true && config.dash) || undefined;\n const ticks = scale.ticks(tickCount);\n\n for (const tick of ticks) {\n const pos = mapTick(scale, tick);\n const attrs: Record<string, number | string | undefined> = {\n class: 'prism-grid-line',\n stroke: color ?? 'var(--prism-grid-color)',\n 'stroke-dasharray': dash,\n 'stroke-opacity': 'var(--prism-grid-opacity)',\n };\n\n if (direction === 'vertical') {\n Object.assign(attrs, { x1: pos, x2: pos, y1: 0, y2: crossLength });\n } else {\n Object.assign(attrs, { x1: 0, x2: crossLength, y1: pos, y2: pos });\n }\n\n parent.appendChild(createSvgElement('line', attrs));\n }\n}\n"],"mappings":"oHAIA,SAAgB,WACd,EACA,EACA,EACA,EACA,EACA,EAAY,GACN,CACN,EAAe,CAAM,EAErB,IAAM,EAAS,IAAW,IAAQ,EAAO,OAAU,IAAA,GAC7C,EAAQ,IAAW,IAAQ,EAAO,MAAS,IAAA,GAC3C,EAAQ,EAAM,MAAM,CAAS,EAEnC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAQ,EAAO,CAAI,EACzB,EAAqD,CACzD,MAAO,kBACP,OAAQ,GAAS,0BACjB,mBAAoB,EACpB,iBAAkB,2BACpB,EAEI,IAAc,WAChB,OAAO,OAAO,EAAO,CAAE,GAAI,EAAK,GAAI,EAAK,GAAI,EAAG,GAAI,CAAY,CAAC,EAEjE,OAAO,OAAO,EAAO,CAAE,GAAI,EAAG,GAAI,EAAa,GAAI,EAAK,GAAI,CAAI,CAAC,EAGnE,EAAO,YAAY,EAAiB,OAAQ,CAAK,CAAC,CACpD,CACF"}
@@ -1,2 +1,2 @@
1
- function e(e){return typeof e.bandwidth==`function`}function t(t,n){return e(t)?t.map(n)+t.bandwidth()/2:t.map(n)}exports.mapTick=t;
1
+ function isBandScale(e){return typeof e.bandwidth==`function`}function mapTick(e,t){return isBandScale(e)?e.map(t)+e.bandwidth()/2:e.map(t)}exports.mapTick=mapTick;
2
2
  //# sourceMappingURL=scale-utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale-utils.cjs","names":[],"sources":["../../src/axes/scale-utils.ts"],"sourcesContent":["import type { BandScale, Scale } from '../types';\n\nexport type AnyScale = BandScale | Scale<Date> | Scale<number>;\n\nfunction isBandScale(scale: AnyScale): scale is BandScale {\n return typeof (scale as BandScale).bandwidth === 'function';\n}\n\n/**\n * Maps a tick value through any of prism's three scale kinds, centering band-scale\n * ticks on their band (bandScale.map() returns a band's left edge by design).\n *\n * Overloaded so a caller's `tick` type must match the scale kind it's paired with —\n * `AxisConfig`/`GridConfig` accept any scale kind, so the runtime discrimination\n * inside the implementation is unavoidable, but the overload set keeps that a single\n * isolated cast here instead of an unchecked `Date | number | string` accepted at\n * every call site.\n */\nexport function mapTick(scale: BandScale, tick: string): number;\nexport function mapTick(scale: Scale<Date>, tick: Date): number;\nexport function mapTick(scale: Scale<number>, tick: number): number;\n// Fallback overload for callers (axis.ts/grid.ts) holding an already-erased `AnyScale`\n// union — the type-correlated overloads above are what protect a caller with a\n// narrower, known scale type from mismatching it with the wrong tick type.\nexport function mapTick(scale: AnyScale, tick: Date | number | string): number;\nexport function mapTick(scale: AnyScale, tick: Date | number | string): number {\n if (isBandScale(scale)) return scale.map(tick as string) + scale.bandwidth() / 2;\n\n return (scale as Scale<Date | number>).map(tick as Date | number);\n}\n"],"mappings":"AAIA,SAAS,EAAY,EAAqC,CACxD,OAAO,OAAQ,EAAoB,WAAc,UACnD,CAmBA,SAAgB,EAAQ,EAAiB,EAAsC,CAG7E,OAFI,EAAY,CAAK,EAAU,EAAM,IAAI,CAAc,EAAI,EAAM,UAAU,EAAI,EAEvE,EAA+B,IAAI,CAAqB,CAClE"}
1
+ {"version":3,"file":"scale-utils.cjs","names":[],"sources":["../../src/axes/scale-utils.ts"],"sourcesContent":["import type { BandScale, Scale } from '../types';\n\nexport type AnyScale = BandScale | Scale<Date> | Scale<number>;\n\nfunction isBandScale(scale: AnyScale): scale is BandScale {\n return typeof (scale as BandScale).bandwidth === 'function';\n}\n\n/**\n * Maps a tick value through any of prism's three scale kinds, centering band-scale\n * ticks on their band (bandScale.map() returns a band's left edge by design).\n *\n * Overloaded so a caller's `tick` type must match the scale kind it's paired with —\n * `AxisConfig`/`GridConfig` accept any scale kind, so the runtime discrimination\n * inside the implementation is unavoidable, but the overload set keeps that a single\n * isolated cast here instead of an unchecked `Date | number | string` accepted at\n * every call site.\n */\nexport function mapTick(scale: BandScale, tick: string): number;\nexport function mapTick(scale: Scale<Date>, tick: Date): number;\nexport function mapTick(scale: Scale<number>, tick: number): number;\n// Fallback overload for callers (axis.ts/grid.ts) holding an already-erased `AnyScale`\n// union — the type-correlated overloads above are what protect a caller with a\n// narrower, known scale type from mismatching it with the wrong tick type.\nexport function mapTick(scale: AnyScale, tick: Date | number | string): number;\nexport function mapTick(scale: AnyScale, tick: Date | number | string): number {\n if (isBandScale(scale)) return scale.map(tick as string) + scale.bandwidth() / 2;\n\n return (scale as Scale<Date | number>).map(tick as Date | number);\n}\n"],"mappings":"AAIA,SAAS,YAAY,EAAqC,CACxD,OAAO,OAAQ,EAAoB,WAAc,UACnD,CAmBA,SAAgB,QAAQ,EAAiB,EAAsC,CAG7E,OAFI,YAAY,CAAK,EAAU,EAAM,IAAI,CAAc,EAAI,EAAM,UAAU,EAAI,EAEvE,EAA+B,IAAI,CAAqB,CAClE"}
@@ -1,11 +1,2 @@
1
- //#region src/axes/scale-utils.ts
2
- function e(e) {
3
- return typeof e.bandwidth == "function";
4
- }
5
- function t(t, n) {
6
- return e(t) ? t.map(n) + t.bandwidth() / 2 : t.map(n);
7
- }
8
- //#endregion
9
- export { t as mapTick };
10
-
1
+ function isBandScale(e){return typeof e.bandwidth==`function`}function mapTick(e,t){return isBandScale(e)?e.map(t)+e.bandwidth()/2:e.map(t)}export{mapTick};
11
2
  //# sourceMappingURL=scale-utils.js.map