@vielzeug/prism 3.0.0 → 26.10.1
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.
- package/README.md +2 -2
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +1 -5
- package/dist/_dev.js.map +1 -1
- package/dist/animation/easing.cjs +1 -1
- package/dist/animation/easing.cjs.map +1 -1
- package/dist/animation/easing.js +1 -13
- package/dist/animation/easing.js.map +1 -1
- package/dist/animation/motion.cjs +1 -1
- package/dist/animation/motion.cjs.map +1 -1
- package/dist/animation/motion.js +1 -12
- package/dist/animation/motion.js.map +1 -1
- package/dist/animation/transition.cjs +1 -1
- package/dist/animation/transition.cjs.map +1 -1
- package/dist/animation/transition.js +1 -28
- package/dist/animation/transition.js.map +1 -1
- package/dist/animation/tween.cjs +1 -1
- package/dist/animation/tween.cjs.map +1 -1
- package/dist/animation/tween.js +1 -7
- package/dist/animation/tween.js.map +1 -1
- package/dist/axes/axis.cjs +1 -1
- package/dist/axes/axis.cjs.map +1 -1
- package/dist/axes/axis.d.ts +2 -2
- package/dist/axes/axis.d.ts.map +1 -1
- package/dist/axes/axis.js +1 -63
- package/dist/axes/axis.js.map +1 -1
- package/dist/axes/grid.cjs +1 -1
- package/dist/axes/grid.cjs.map +1 -1
- package/dist/axes/grid.js +1 -29
- package/dist/axes/grid.js.map +1 -1
- package/dist/axes/scale-utils.cjs +1 -1
- package/dist/axes/scale-utils.cjs.map +1 -1
- package/dist/axes/scale-utils.d.ts +1 -1
- package/dist/axes/scale-utils.js +1 -10
- package/dist/axes/scale-utils.js.map +1 -1
- package/dist/charts/area/area-chart.cjs +1 -1
- package/dist/charts/area/area-chart.cjs.map +1 -1
- package/dist/charts/area/area-chart.d.ts.map +1 -1
- package/dist/charts/area/area-chart.js +1 -57
- package/dist/charts/area/area-chart.js.map +1 -1
- package/dist/charts/area/area-renderer.cjs +1 -1
- package/dist/charts/area/area-renderer.cjs.map +1 -1
- package/dist/charts/area/area-renderer.d.ts +4 -2
- package/dist/charts/area/area-renderer.d.ts.map +1 -1
- package/dist/charts/area/area-renderer.js +1 -73
- package/dist/charts/area/area-renderer.js.map +1 -1
- package/dist/charts/bar/bar-chart.cjs +1 -1
- package/dist/charts/bar/bar-chart.cjs.map +1 -1
- package/dist/charts/bar/bar-chart.d.ts.map +1 -1
- package/dist/charts/bar/bar-chart.js +1 -169
- package/dist/charts/bar/bar-chart.js.map +1 -1
- package/dist/charts/bar/bar-hit-test.cjs +1 -1
- package/dist/charts/bar/bar-hit-test.cjs.map +1 -1
- package/dist/charts/bar/bar-hit-test.d.ts +0 -5
- package/dist/charts/bar/bar-hit-test.d.ts.map +1 -1
- package/dist/charts/bar/bar-hit-test.js +1 -29
- package/dist/charts/bar/bar-hit-test.js.map +1 -1
- package/dist/charts/bar/bar-renderer.cjs +1 -1
- package/dist/charts/bar/bar-renderer.cjs.map +1 -1
- package/dist/charts/bar/bar-renderer.d.ts +1 -1
- package/dist/charts/bar/bar-renderer.d.ts.map +1 -1
- package/dist/charts/bar/bar-renderer.js +1 -106
- package/dist/charts/bar/bar-renderer.js.map +1 -1
- package/dist/charts/line/line-chart.cjs +1 -1
- package/dist/charts/line/line-chart.cjs.map +1 -1
- package/dist/charts/line/line-chart.d.ts.map +1 -1
- package/dist/charts/line/line-chart.js +1 -58
- package/dist/charts/line/line-chart.js.map +1 -1
- package/dist/charts/line/line-renderer.cjs +1 -1
- package/dist/charts/line/line-renderer.cjs.map +1 -1
- package/dist/charts/line/line-renderer.d.ts +3 -2
- package/dist/charts/line/line-renderer.d.ts.map +1 -1
- package/dist/charts/line/line-renderer.js +1 -100
- package/dist/charts/line/line-renderer.js.map +1 -1
- package/dist/charts/pie/pie-chart.cjs +1 -1
- package/dist/charts/pie/pie-chart.cjs.map +1 -1
- package/dist/charts/pie/pie-chart.d.ts.map +1 -1
- package/dist/charts/pie/pie-chart.js +1 -165
- package/dist/charts/pie/pie-chart.js.map +1 -1
- package/dist/charts/pie/pie-renderer.cjs +1 -1
- package/dist/charts/pie/pie-renderer.cjs.map +1 -1
- package/dist/charts/pie/pie-renderer.d.ts.map +1 -1
- package/dist/charts/pie/pie-renderer.js +1 -76
- package/dist/charts/pie/pie-renderer.js.map +1 -1
- package/dist/charts/radar/index.d.ts +2 -0
- package/dist/charts/radar/index.d.ts.map +1 -0
- package/dist/charts/radar/radar-chart.cjs +2 -0
- package/dist/charts/radar/radar-chart.cjs.map +1 -0
- package/dist/charts/radar/radar-chart.d.ts +3 -0
- package/dist/charts/radar/radar-chart.d.ts.map +1 -0
- package/dist/charts/radar/radar-chart.js +2 -0
- package/dist/charts/radar/radar-chart.js.map +1 -0
- package/dist/charts/radar/radar-geometry.cjs +2 -0
- package/dist/charts/radar/radar-geometry.cjs.map +1 -0
- package/dist/charts/radar/radar-geometry.d.ts +22 -0
- package/dist/charts/radar/radar-geometry.d.ts.map +1 -0
- package/dist/charts/radar/radar-geometry.js +2 -0
- package/dist/charts/radar/radar-geometry.js.map +1 -0
- package/dist/charts/sparkline/sparkline.cjs +1 -1
- package/dist/charts/sparkline/sparkline.cjs.map +1 -1
- package/dist/charts/sparkline/sparkline.d.ts.map +1 -1
- package/dist/charts/sparkline/sparkline.js +1 -191
- package/dist/charts/sparkline/sparkline.js.map +1 -1
- package/dist/core/cartesian-model.cjs +1 -1
- package/dist/core/cartesian-model.cjs.map +1 -1
- package/dist/core/cartesian-model.js +1 -30
- package/dist/core/cartesian-model.js.map +1 -1
- package/dist/core/cartesian-scales.cjs +1 -1
- package/dist/core/cartesian-scales.cjs.map +1 -1
- package/dist/core/cartesian-scales.js +1 -37
- package/dist/core/cartesian-scales.js.map +1 -1
- package/dist/core/chart-base.cjs +1 -1
- package/dist/core/chart-base.cjs.map +1 -1
- package/dist/core/chart-base.d.ts +9 -0
- package/dist/core/chart-base.d.ts.map +1 -1
- package/dist/core/chart-base.js +1 -53
- package/dist/core/chart-base.js.map +1 -1
- package/dist/core/chart-scaffold.cjs +1 -1
- package/dist/core/chart-scaffold.cjs.map +1 -1
- package/dist/core/chart-scaffold.d.ts +7 -3
- package/dist/core/chart-scaffold.d.ts.map +1 -1
- package/dist/core/chart-scaffold.js +1 -89
- package/dist/core/chart-scaffold.js.map +1 -1
- package/dist/core/ids.cjs +2 -0
- package/dist/core/ids.cjs.map +1 -0
- package/dist/core/ids.d.ts +3 -0
- package/dist/core/ids.d.ts.map +1 -0
- package/dist/core/ids.js +2 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/core/layout.cjs +1 -1
- package/dist/core/layout.cjs.map +1 -1
- package/dist/core/layout.js +1 -22
- package/dist/core/layout.js.map +1 -1
- package/dist/core/polar.cjs +2 -0
- package/dist/core/polar.cjs.map +1 -0
- package/dist/core/polar.d.ts +5 -0
- package/dist/core/polar.d.ts.map +1 -0
- package/dist/core/polar.js +2 -0
- package/dist/core/polar.js.map +1 -0
- package/dist/core/responsive.cjs +1 -1
- package/dist/core/responsive.cjs.map +1 -1
- package/dist/core/responsive.js +1 -19
- package/dist/core/responsive.js.map +1 -1
- package/dist/devtools/index.d.ts +1 -1
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js +1 -18
- package/dist/devtools.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -9
- package/dist/errors.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -11
- package/dist/interaction/announcer.cjs +2 -0
- package/dist/interaction/announcer.cjs.map +1 -0
- package/dist/interaction/announcer.d.ts +13 -0
- package/dist/interaction/announcer.d.ts.map +1 -0
- package/dist/interaction/announcer.js +2 -0
- package/dist/interaction/announcer.js.map +1 -0
- package/dist/interaction/crosshair.cjs +1 -1
- package/dist/interaction/crosshair.cjs.map +1 -1
- package/dist/interaction/crosshair.d.ts +1 -5
- package/dist/interaction/crosshair.d.ts.map +1 -1
- package/dist/interaction/crosshair.js +1 -45
- package/dist/interaction/crosshair.js.map +1 -1
- package/dist/interaction/events.cjs +1 -1
- package/dist/interaction/events.cjs.map +1 -1
- package/dist/interaction/events.js +1 -11
- package/dist/interaction/events.js.map +1 -1
- package/dist/interaction/legend.cjs +1 -1
- package/dist/interaction/legend.cjs.map +1 -1
- package/dist/interaction/legend.js +1 -30
- package/dist/interaction/legend.js.map +1 -1
- package/dist/interaction/series-interaction.cjs +1 -1
- package/dist/interaction/series-interaction.cjs.map +1 -1
- package/dist/interaction/series-interaction.d.ts +11 -1
- package/dist/interaction/series-interaction.d.ts.map +1 -1
- package/dist/interaction/series-interaction.js +1 -97
- package/dist/interaction/series-interaction.js.map +1 -1
- package/dist/interaction/tooltip.cjs +1 -1
- package/dist/interaction/tooltip.cjs.map +1 -1
- package/dist/interaction/tooltip.d.ts +12 -1
- package/dist/interaction/tooltip.d.ts.map +1 -1
- package/dist/interaction/tooltip.js +1 -63
- package/dist/interaction/tooltip.js.map +1 -1
- package/dist/prism.cjs +1 -1
- package/dist/prism.cjs.map +1 -1
- package/dist/prism.iife.js +1 -1
- package/dist/prism.iife.js.map +1 -1
- package/dist/prism.js +1 -1
- package/dist/prism.js.map +1 -1
- package/dist/scales/band.cjs +1 -1
- package/dist/scales/band.cjs.map +1 -1
- package/dist/scales/band.js +1 -39
- package/dist/scales/band.js.map +1 -1
- package/dist/scales/linear.cjs +1 -1
- package/dist/scales/linear.cjs.map +1 -1
- package/dist/scales/linear.js +1 -43
- package/dist/scales/linear.js.map +1 -1
- package/dist/scales/time.cjs +1 -1
- package/dist/scales/time.cjs.map +1 -1
- package/dist/scales/time.js +1 -61
- package/dist/scales/time.js.map +1 -1
- package/dist/svg/element.cjs +1 -1
- package/dist/svg/element.cjs.map +1 -1
- package/dist/svg/element.js +1 -22
- package/dist/svg/element.js.map +1 -1
- package/dist/svg/path.cjs +1 -1
- package/dist/svg/path.cjs.map +1 -1
- package/dist/svg/path.js +1 -48
- package/dist/svg/path.js.map +1 -1
- package/dist/svg/text.cjs +1 -1
- package/dist/svg/text.cjs.map +1 -1
- package/dist/svg/text.d.ts +1 -0
- package/dist/svg/text.d.ts.map +1 -1
- package/dist/svg/text.js +1 -9
- package/dist/svg/text.js.map +1 -1
- package/dist/theme/index.cjs +1 -1
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.js +1 -19
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/prism.css +214 -7
- package/dist/types.d.ts +65 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vielzeug/prism
|
|
2
2
|
|
|
3
|
-
> Responsive SVG charts with explicit updates
|
|
3
|
+
> Responsive SVG charts with explicit updates: line, bar, area, pie, radar, sparkline
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -60,4 +60,4 @@ chart.dispose();
|
|
|
60
60
|
|
|
61
61
|
## License
|
|
62
62
|
|
|
63
|
-
MIT © [Helmuth Saatkamp](https://github.com/helmuthdu)
|
|
63
|
+
MIT © [Helmuth Saatkamp](https://github.com/helmuthdu): part of the [Vielzeug](https://github.com/helmuthdu/vielzeug) monorepo.
|
package/dist/_dev.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){}exports.warn=
|
|
1
|
+
function warn(e){}function devOnly(e){}exports.devOnly=devOnly,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
|
|
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,CAWA,SAAgB,QAAQ,EAAsB,CAE9C"}
|
package/dist/_dev.js
CHANGED
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
|
|
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,CAWA,SAAgB,QAAQ,EAAsB,CAE9C"}
|
|
@@ -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
|
|
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'`)
|
|
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"}
|
package/dist/animation/easing.js
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
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'`)
|
|
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
|
|
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,
|
|
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"}
|
package/dist/animation/motion.js
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
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":"
|
|
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
|
|
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,
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/animation/tween.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
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,
|
|
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"}
|
package/dist/animation/tween.js
CHANGED
|
@@ -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":"
|
|
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"}
|
package/dist/axes/axis.cjs
CHANGED
|
@@ -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
|
|
1
|
+
const e=require("../svg/element.cjs"),t=require("../svg/text.cjs"),n=require("./scale-utils.cjs");var r=11,i=8,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 categoryTickCount(e,n,a,o){if(e.length===0)return 0;let s=o?Math.max(...e.map(e=>t.estimateTextWidth(n(e),r))):r*1.3;return Math.max(1,Math.min(e.length,Math.floor(a/(s+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=a.tickFormat??defaultTickFormat,m=a.tickCount===void 0&&`bandwidth`in i?categoryTickCount(i.domain,p,o,l):resolveTickCount(a,o,s),h=i.ticks(m);for(let a of h){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(p(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
|
package/dist/axes/axis.cjs.map
CHANGED
|
@@ -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
|
|
1
|
+
{"version":3,"file":"axis.cjs","names":[],"sources":["../../src/axes/axis.ts"],"sourcesContent":["import { createSvgElement, removeChildren, setAttributes } from '../svg/element';\nimport { createTextElement, estimateTextWidth } from '../svg/text';\nimport type { AxisConfig, AxisPosition } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\n/** Default `--prism-font-size-label` in px, used to estimate category label size. */\nconst LABEL_FONT_SIZE = 11;\nconst LABEL_GAP = 8;\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/** How many category labels fit along the axis without their estimated boxes overlapping. */\nfunction categoryTickCount(\n domain: readonly string[],\n format: (value: string) => string,\n length: number,\n isHorizontal: boolean,\n): number {\n if (domain.length === 0) return 0;\n\n const size = isHorizontal\n ? Math.max(...domain.map((value) => estimateTextWidth(format(value), LABEL_FONT_SIZE)))\n : LABEL_FONT_SIZE * 1.3;\n\n return Math.max(1, Math.min(domain.length, Math.floor(length / (size + LABEL_GAP))));\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 format = config.tickFormat ?? defaultTickFormat;\n const tickCount =\n config.tickCount === undefined && 'bandwidth' in scale\n ? categoryTickCount(scale.domain, format, length, isHorizontal)\n : resolveTickCount(config, length, defaultPosition);\n const ticks = scale.ticks(tickCount);\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":"kGAMA,IAAM,EAAkB,GAClB,EAAY,EAEZ,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,CAGA,SAAS,kBACP,EACA,EACA,EACA,EACQ,CACR,GAAI,EAAO,SAAW,EAAG,MAAO,GAEhC,IAAM,EAAO,EACT,KAAK,IAAI,GAAG,EAAO,IAAK,GAAU,EAAA,kBAAkB,EAAO,CAAK,EAAG,CAAe,CAAC,CAAC,EACpF,EAAkB,IAEtB,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,EAAO,OAAQ,KAAK,MAAM,GAAU,EAAO,EAAU,CAAC,CAAC,CACrF,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,EAAS,EAAO,YAAc,kBAC9B,EACJ,EAAO,YAAc,IAAA,IAAa,cAAe,EAC7C,kBAAkB,EAAM,OAAQ,EAAQ,EAAQ,CAAY,EAC5D,iBAAiB,EAAQ,EAAQ,CAAe,EAChD,EAAQ,EAAM,MAAM,CAAS,EAEnC,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"}
|
package/dist/axes/axis.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { AxisConfig, AxisPosition } from '../types';
|
|
2
2
|
import { type AnyScale } from './scale-utils';
|
|
3
3
|
/**
|
|
4
|
-
* Resolves the tick count an axis will render for a given scale/length
|
|
4
|
+
* Resolves the tick count an axis will render for a given scale/length: shared with
|
|
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
8
|
export declare function positionAxis(parent: SVGGElement, position: AxisPosition, width: number, height: number): void;
|
|
9
9
|
export declare function resolveTickCount(config: AxisConfig, length: number, defaultPosition: AxisPosition): number;
|
|
10
10
|
/**
|
|
11
|
-
* `defaultPosition` is applied when `config.position` is unset
|
|
11
|
+
* `defaultPosition` is applied when `config.position` is unset: pass `'bottom'` for an
|
|
12
12
|
* xAxis call and `'left'` for a yAxis call so an unconfigured axis renders on its
|
|
13
13
|
* conventional side instead of always defaulting to a horizontal bottom axis.
|
|
14
14
|
*/
|
package/dist/axes/axis.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AASvD;;;;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;AAkBD;;;;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,CAqEN"}
|
package/dist/axes/axis.js
CHANGED
|
@@ -1,64 +1,2 @@
|
|
|
1
|
-
import
|
|
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, r) {
|
|
10
|
-
let i = t === "bottom" ? `translate(0,${r})` : t === "right" ? `translate(${n},0)` : void 0;
|
|
11
|
-
i ? e.setAttribute("transform", i) : e.removeAttribute("transform");
|
|
12
|
-
}
|
|
13
|
-
function s(e, t, n) {
|
|
14
|
-
let r = e.position ?? n, i = r === "bottom" || r === "top" ? Math.max(2, Math.floor(t / 80)) : Math.max(2, Math.floor(t / 50));
|
|
15
|
-
return e.tickCount ?? i;
|
|
16
|
-
}
|
|
17
|
-
function c(o, c, l, u, d = "bottom") {
|
|
18
|
-
t(o);
|
|
19
|
-
let f = l.position ?? d, p = f === "bottom" || f === "top", m = f === "top" || f === "left", h = m ? -1 : 1, g = e("line", {
|
|
20
|
-
"aria-hidden": "true",
|
|
21
|
-
class: "prism-axis-line",
|
|
22
|
-
x1: 0,
|
|
23
|
-
x2: p ? u : 0,
|
|
24
|
-
y1: 0,
|
|
25
|
-
y2: p ? 0 : u
|
|
26
|
-
});
|
|
27
|
-
o.appendChild(g);
|
|
28
|
-
let _ = c.ticks(s(l, u, d)), v = l.tickFormat ?? a;
|
|
29
|
-
for (let t of _) {
|
|
30
|
-
let n = i(c, t), a = e("line", {
|
|
31
|
-
"aria-hidden": "true",
|
|
32
|
-
class: "prism-axis-tick",
|
|
33
|
-
x1: p ? n : 0,
|
|
34
|
-
x2: p ? n : 6 * h,
|
|
35
|
-
y1: p ? 0 : n,
|
|
36
|
-
y2: p ? 6 * h : n
|
|
37
|
-
});
|
|
38
|
-
o.appendChild(a);
|
|
39
|
-
let s = r(v(t), {
|
|
40
|
-
"aria-hidden": "true",
|
|
41
|
-
class: "prism-axis-label",
|
|
42
|
-
"dominant-baseline": p ? m ? "auto" : "hanging" : "middle",
|
|
43
|
-
"text-anchor": p ? "middle" : m ? "end" : "start",
|
|
44
|
-
x: p ? n : 6 * h * 1.5,
|
|
45
|
-
y: p ? 6 * h * 1.5 : n
|
|
46
|
-
});
|
|
47
|
-
o.appendChild(s);
|
|
48
|
-
}
|
|
49
|
-
if (l.label) {
|
|
50
|
-
let e = r(l.label, {
|
|
51
|
-
class: "prism-axis-title",
|
|
52
|
-
"dominant-baseline": "middle",
|
|
53
|
-
"text-anchor": "middle"
|
|
54
|
-
});
|
|
55
|
-
p ? n(e, {
|
|
56
|
-
x: u / 2,
|
|
57
|
-
y: 6 * h * 6
|
|
58
|
-
}) : n(e, { transform: `translate(${6 * h * 7}, ${u / 2}) rotate(-90)` }), o.appendChild(e);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { o as positionAxis, c as renderAxis, s as resolveTickCount };
|
|
63
|
-
|
|
1
|
+
import{createSvgElement as e,removeChildren as t,setAttributes as n}from"../svg/element.js";import{createTextElement as r,estimateTextWidth as i}from"../svg/text.js";import{mapTick as a}from"./scale-utils.js";var o=11,s=8,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 categoryTickCount(e,t,n,r){if(e.length===0)return 0;let a=r?Math.max(...e.map(e=>i(t(e),o))):o*1.3;return Math.max(1,Math.min(e.length,Math.floor(n/(a+s))))}function renderAxis(i,o,s,c,l=`bottom`){t(i);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});i.appendChild(m);let h=s.tickFormat??defaultTickFormat,g=s.tickCount===void 0&&`bandwidth`in o?categoryTickCount(o.domain,h,c,d):resolveTickCount(s,c,l),_=o.ticks(g);for(let t of _){let n=a(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});i.appendChild(s);let c=r(h(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});i.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)`}),i.appendChild(e)}}export{positionAxis,renderAxis,resolveTickCount};
|
|
64
2
|
//# sourceMappingURL=axis.js.map
|
package/dist/axes/axis.js.map
CHANGED
|
@@ -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
|
|
1
|
+
{"version":3,"file":"axis.js","names":[],"sources":["../../src/axes/axis.ts"],"sourcesContent":["import { createSvgElement, removeChildren, setAttributes } from '../svg/element';\nimport { createTextElement, estimateTextWidth } from '../svg/text';\nimport type { AxisConfig, AxisPosition } from '../types';\nimport { type AnyScale, mapTick } from './scale-utils';\n\n/** Default `--prism-font-size-label` in px, used to estimate category label size. */\nconst LABEL_FONT_SIZE = 11;\nconst LABEL_GAP = 8;\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/** How many category labels fit along the axis without their estimated boxes overlapping. */\nfunction categoryTickCount(\n domain: readonly string[],\n format: (value: string) => string,\n length: number,\n isHorizontal: boolean,\n): number {\n if (domain.length === 0) return 0;\n\n const size = isHorizontal\n ? Math.max(...domain.map((value) => estimateTextWidth(format(value), LABEL_FONT_SIZE)))\n : LABEL_FONT_SIZE * 1.3;\n\n return Math.max(1, Math.min(domain.length, Math.floor(length / (size + LABEL_GAP))));\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 format = config.tickFormat ?? defaultTickFormat;\n const tickCount =\n config.tickCount === undefined && 'bandwidth' in scale\n ? categoryTickCount(scale.domain, format, length, isHorizontal)\n : resolveTickCount(config, length, defaultPosition);\n const ticks = scale.ticks(tickCount);\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":"iNAMA,IAAM,EAAkB,GAClB,EAAY,EAEZ,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,CAGA,SAAS,kBACP,EACA,EACA,EACA,EACQ,CACR,GAAI,EAAO,SAAW,EAAG,MAAO,GAEhC,IAAM,EAAO,EACT,KAAK,IAAI,GAAG,EAAO,IAAK,GAAU,EAAkB,EAAO,CAAK,EAAG,CAAe,CAAC,CAAC,EACpF,EAAkB,IAEtB,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,EAAO,OAAQ,KAAK,MAAM,GAAU,EAAO,EAAU,CAAC,CAAC,CACrF,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,EAAS,EAAO,YAAc,kBAC9B,EACJ,EAAO,YAAc,IAAA,IAAa,cAAe,EAC7C,kBAAkB,EAAM,OAAQ,EAAQ,EAAQ,CAAY,EAC5D,iBAAiB,EAAQ,EAAQ,CAAe,EAChD,EAAQ,EAAM,MAAM,CAAS,EAEnC,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"}
|
package/dist/axes/grid.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../svg/element.cjs"),t=require("./scale-utils.cjs");function
|
|
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
|
package/dist/axes/grid.cjs.map
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
package/dist/axes/grid.js.map
CHANGED
|
@@ -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":"
|
|
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
|
|
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
|
|
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"}
|
|
@@ -4,7 +4,7 @@ export type AnyScale = BandScale | Scale<Date> | Scale<number>;
|
|
|
4
4
|
* Maps a tick value through any of prism's three scale kinds, centering band-scale
|
|
5
5
|
* ticks on their band (bandScale.map() returns a band's left edge by design).
|
|
6
6
|
*
|
|
7
|
-
* Overloaded so a caller's `tick` type must match the scale kind it's paired with
|
|
7
|
+
* Overloaded so a caller's `tick` type must match the scale kind it's paired with :
|
|
8
8
|
* `AxisConfig`/`GridConfig` accept any scale kind, so the runtime discrimination
|
|
9
9
|
* inside the implementation is unavoidable, but the overload set keeps that a single
|
|
10
10
|
* isolated cast here instead of an unchecked `Date | number | string` accepted at
|
package/dist/axes/scale-utils.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale-utils.js","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
|
|
1
|
+
{"version":3,"file":"scale-utils.js","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,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../svg/element.cjs"),t=require("../../axes/axis.cjs"),n=require("../../axes/grid.cjs"),r=require("../../core/cartesian-scales.cjs"),i=require("../../core/layout.cjs"),a=require("../../core/chart-scaffold.cjs"),o=require("../../interaction/crosshair.cjs"),s=require("../../interaction/series-interaction.cjs"),c=require("../../theme/index.cjs"),l=require("./area-renderer.cjs");function
|
|
1
|
+
const e=require("../../svg/element.cjs"),t=require("../../axes/axis.cjs"),n=require("../../axes/grid.cjs"),r=require("../../core/cartesian-scales.cjs"),i=require("../../core/layout.cjs"),a=require("../../core/chart-scaffold.cjs"),o=require("../../interaction/crosshair.cjs"),s=require("../../interaction/series-interaction.cjs"),c=require("../../theme/index.cjs"),l=require("./area-renderer.cjs");function createAreaChart(u,d){let f=null,p=null,m=d.series;return a.createChartScaffold(u,d,u=>{let{groups:h,legend:g,tooltip:_}=u,v=u.dimensions,y=i.chartArea(v.width,v.height,v.margin),b=m.map(e=>e.data),x=b.flat().map(e=>e.key),S=b.flat().map(e=>e.value);if(x.length===0){a.clearCartesianDom(h,g,_,f),p?.replaceChildren();return}d.crosshair&&!f&&(f=o.createCrosshair(u.chartArea,d.crosshair));let C=r.buildXScale(x,y.width),w=r.buildYScale(S,y.height),T=w.map(0);for(d.yAxis?.grid&&n.renderGrid(h.grid,w,d.yAxis.grid,y.width,`horizontal`,t.resolveTickCount(d.yAxis,y.height,`left`)),d.xAxis?.grid&&n.renderGrid(h.grid,C,d.xAxis.grid,y.height,`vertical`,t.resolveTickCount(d.xAxis,y.width,`bottom`)),d.xAxis&&(t.positionAxis(h.xAxis,d.xAxis.position??`bottom`,y.width,y.height),t.renderAxis(h.xAxis,C,d.xAxis,y.width,`bottom`)),d.yAxis&&(t.positionAxis(h.yAxis,d.yAxis.position??`left`,y.width,y.height),t.renderAxis(h.yAxis,w,d.yAxis,y.height,`left`));h.series.children.length>m.length;)h.series.removeChild(h.series.lastChild);let E=[];for(let t=0;t<m.length;t++){let n=m[t],r=h.series.children[t];r||(r=e.createSvgElement(`g`,{class:`prism-area-series`}),h.series.appendChild(r));let i=l.computeAreaPoints(b[t],C,w);E.push(i),l.renderArea(r,i,T,{color:c.seriesColor(t,n.color),curve:n.curve??`linear`,disposalSignal:u.disposalSignal,fill:n.fill??`gradient`,fillOpacity:n.fillOpacity,showLine:n.showLine!==!1,transition:d.transition})}return g?.update(m.map((e,t)=>({color:c.seriesColor(t,e.color),name:e.name}))),_?.hide(),p=s.ensureMarkerGroup(u.chartArea,p),s.createSeriesInteraction({announcer:u.announcer,colors:()=>m.map((e,t)=>c.seriesColor(t,e.color)),crosshair:f,dims:()=>u.dimensions,getData:()=>b,getPoints:()=>E,getSeriesList:()=>m,markers:p,onClick:d.onClick,onHover:d.onHover,seriesGroup:h.series,svg:u.svg,tooltip:_})},e=>{m=e})}exports.createAreaChart=createAreaChart;
|
|
2
2
|
//# sourceMappingURL=area-chart.cjs.map
|