@vunset/vue 1.0.0-rc.1 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,7 +79,7 @@ import { DataTable } from '@vunset/vue/data-table';
79
79
 
80
80
  ## Documentation
81
81
 
82
- [github.com/vunset/vunset/tree/main/docs](https://github.com/vunset/vunset/tree/main/docs)
82
+ [vunset.com/get-started](https://vunset.com/get-started)
83
83
 
84
84
  ## License
85
85
 
@@ -0,0 +1,9 @@
1
+ type Point = readonly [x: number, y: number];
2
+ /** An SVG path bending smoothly through `points`, in `x` order, without overshooting any of them. */
3
+ export declare function monotonePath(points: readonly Point[]): string;
4
+ /**
5
+ * The closed SVG path between two such curves: along `top`, then back along
6
+ * `bottom`. Both run through the same `x` positions, in order.
7
+ */
8
+ export declare function monotoneAreaPath(top: readonly Point[], bottom: readonly Point[]): string;
9
+ export {};
@@ -0,0 +1,57 @@
1
+ //#region src/components/chart/chart-curve.ts
2
+ var round = (value) => Math.round(value * 1e3) / 1e3;
3
+ /**
4
+ * Each tangent of a monotone cubic through `points` (Steffen's limiter): the
5
+ * curve bends through every point but never past one, so a peak is drawn at
6
+ * its value. The ends take the tangent that leaves the curve straight there.
7
+ */
8
+ function monotoneTangents(points) {
9
+ const last = points.length - 1;
10
+ const widths = [];
11
+ const slopes = [];
12
+ for (let index = 0; index < last; index++) {
13
+ const width = points[index + 1][0] - points[index][0];
14
+ widths.push(width);
15
+ const rise = points[index + 1][1] - points[index][1];
16
+ slopes.push(width ? rise / width : rise ? Math.sign(rise) * Infinity : 0);
17
+ }
18
+ const tangents = new Array(points.length).fill(0);
19
+ for (let index = 1; index < last; index++) {
20
+ const [before, after] = [slopes[index - 1], slopes[index]];
21
+ const span = widths[index - 1] + widths[index];
22
+ const weighted = span ? (before * widths[index] + after * widths[index - 1]) / span : 0;
23
+ tangents[index] = (Math.sign(before) + Math.sign(after)) * Math.min(Math.abs(before), Math.abs(after), .5 * Math.abs(weighted));
24
+ }
25
+ tangents[0] = widths[0] ? (3 * slopes[0] - tangents[1]) / 2 : tangents[1];
26
+ tangents[last] = widths[last - 1] ? (3 * slopes[last - 1] - tangents[last - 1]) / 2 : tangents[last - 1];
27
+ return tangents.map((tangent) => Number.isFinite(tangent) ? tangent : 0);
28
+ }
29
+ /** The path commands after the first point: cubic segments, or a straight one between two points. */
30
+ function monotoneSegments(points) {
31
+ if (points.length < 3) return points.slice(1).map(([x, y]) => `L${round(x)},${round(y)}`);
32
+ const tangents = monotoneTangents(points);
33
+ return points.slice(1).map(([x, y], offset) => {
34
+ const [startX, startY] = points[offset];
35
+ const third = (x - startX) / 3;
36
+ return `C${round(startX + third)},${round(startY + tangents[offset] * third)},${round(x - third)},${round(y - tangents[offset + 1] * third)},${round(x)},${round(y)}`;
37
+ });
38
+ }
39
+ /** An SVG path bending smoothly through `points`, in `x` order, without overshooting any of them. */
40
+ function monotonePath(points) {
41
+ if (points.length === 0) return "";
42
+ const start = `M${round(points[0][0])},${round(points[0][1])}`;
43
+ return points.length === 1 ? `${start}Z` : start + monotoneSegments(points).join("");
44
+ }
45
+ /**
46
+ * The closed SVG path between two such curves: along `top`, then back along
47
+ * `bottom`. Both run through the same `x` positions, in order.
48
+ */
49
+ function monotoneAreaPath(top, bottom) {
50
+ if (top.length === 0 || bottom.length === 0) return "";
51
+ const back = [...bottom].reverse();
52
+ const along = monotoneSegments(top).join("");
53
+ const returning = monotoneSegments(back).join("");
54
+ return `M${round(top[0][0])},${round(top[0][1])}${along}L${round(back[0][0])},${round(back[0][1])}${returning}Z`;
55
+ }
56
+ //#endregion
57
+ export { monotoneAreaPath, monotonePath };
@@ -1,3 +1,4 @@
1
+ import type { ChartCurve } from '@tanstack/charts';
1
2
  /**
2
3
  * An evenly spaced few of a row axis' positions, for `numTicks`. The axis
3
4
  * labels every row otherwise, leaving out the ones that would collide.
@@ -30,4 +31,4 @@ export declare const rowFocus: (horizontal?: boolean) => {
30
31
  /** A chart's accessible name: what it plots, in the reader's words. */
31
32
  export declare const chartName: (categories: string[], labelFormat: ((category: string) => string) | undefined, fallback: string) => string;
32
33
  /** A line's run between its points: bending through them, or straight. TanStack draws straight by default. */
33
- export declare const curveOf: (curve: "smooth" | "linear") => import("@tanstack/charts").ChartCurve | undefined;
34
+ export declare const curveOf: (curve: "smooth" | "linear") => ChartCurve | undefined;
@@ -1,6 +1,5 @@
1
+ import { monotoneAreaPath, monotonePath } from "./chart-curve.js";
1
2
  import { formatNumber } from "@vunset/utils";
2
- import { d3Curve } from "@tanstack/charts";
3
- import { curveMonotoneX } from "d3-shape";
4
3
  //#region src/components/chart/chart-scales.ts
5
4
  /**
6
5
  * An evenly spaced few of a row axis' positions, for `numTicks`. The axis
@@ -32,7 +31,10 @@ var rowFocus = (horizontal = false) => ({
32
31
  });
33
32
  /** A chart's accessible name: what it plots, in the reader's words. */
34
33
  var chartName = (categories, labelFormat, fallback) => categories.map((category) => labelFormat ? labelFormat(category) : category).join(", ") || fallback;
35
- var SMOOTH = d3Curve(curveMonotoneX);
34
+ var SMOOTH = {
35
+ line: monotonePath,
36
+ area: monotoneAreaPath
37
+ };
36
38
  /** A line's run between its points: bending through them, or straight. TanStack draws straight by default. */
37
39
  var curveOf = (curve) => curve === "smooth" ? SMOOTH : void 0;
38
40
  //#endregion
@@ -11,7 +11,7 @@ declare var __VLS_8: {
11
11
  readOnly: boolean;
12
12
  required: boolean;
13
13
  invalid: boolean;
14
- transitionStatus: import("../..").TransitionStatus;
14
+ transitionStatus: import("../../index.ts").TransitionStatus;
15
15
  };
16
16
  type __VLS_Slots = {} & {
17
17
  default?: (props: typeof __VLS_8) => any;
@@ -4,8 +4,8 @@ type __VLS_Props = {
4
4
  };
5
5
  declare var __VLS_8: {
6
6
  open: boolean;
7
- mode: import("../..").CalendarSelectionMode;
8
- view: import("../..").CalendarView;
7
+ mode: import("../calendar/use-calendar.ts").CalendarSelectionMode;
8
+ view: import("../calendar/use-calendar.ts").CalendarView;
9
9
  month: number;
10
10
  year: number;
11
11
  monthLabel: string;
@@ -4,8 +4,8 @@ type __VLS_Props = {
4
4
  };
5
5
  declare var __VLS_8: {
6
6
  open: boolean;
7
- mode: import("../..").CalendarSelectionMode;
8
- view: import("../..").CalendarView;
7
+ mode: import("../calendar/use-calendar.ts").CalendarSelectionMode;
8
+ view: import("../calendar/use-calendar.ts").CalendarView;
9
9
  month: number;
10
10
  year: number;
11
11
  monthLabel: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunset/vue",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "Headless, unstyled Vue 3 components: keyboard, focus and ARIA handled, the look left to you.",
5
5
  "keywords": [
6
6
  "vue",
@@ -20,7 +20,7 @@
20
20
  "url": "git+https://github.com/vunset/vunset.git",
21
21
  "directory": "packages/vue"
22
22
  },
23
- "homepage": "https://github.com/vunset/vunset#readme",
23
+ "homepage": "https://vunset.com/get-started",
24
24
  "bugs": "https://github.com/vunset/vunset/issues",
25
25
  "type": "module",
26
26
  "sideEffects": false,
@@ -47,8 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@floating-ui/vue": "^2.0.1",
50
- "@vunset/utils": "1.0.0-rc.1",
51
- "d3-shape": "^3.2.0"
50
+ "@vunset/utils": "1.0.0-rc.2"
52
51
  },
53
52
  "peerDependencies": {
54
53
  "@tanstack/charts": "^1.1.0",