blessing-ui 0.2.0 → 0.3.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 (133) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +137 -125
  3. package/dist/blessing-ui.css +38 -2
  4. package/dist/components/BlessAnnotator.css +1 -0
  5. package/dist/components/BlessAnnotator.js +6 -0
  6. package/dist/components/BlessAnnotator.vue.d.ts +71 -0
  7. package/dist/components/BlessAnnotator.vue_vue_type_script_setup_true_lang.js +264 -0
  8. package/dist/components/BlessAttachment.vue.d.ts +4 -1
  9. package/dist/components/BlessAttachment.vue_vue_type_script_setup_true_lang.js +3 -2
  10. package/dist/components/BlessCalendar.vue.d.ts +4 -0
  11. package/dist/components/BlessCalendar.vue_vue_type_script_setup_true_lang.js +65 -60
  12. package/dist/components/BlessCarousel.vue.d.ts +3 -0
  13. package/dist/components/BlessCarousel.vue_vue_type_script_setup_true_lang.js +10 -9
  14. package/dist/components/BlessCoachmark.css +1 -0
  15. package/dist/components/BlessCoachmark.js +6 -0
  16. package/dist/components/BlessCoachmark.vue.d.ts +40 -0
  17. package/dist/components/BlessCoachmark.vue_vue_type_script_setup_true_lang.js +74 -0
  18. package/dist/components/BlessCodeBlock.vue.d.ts +10 -0
  19. package/dist/components/BlessCodeBlock.vue_vue_type_script_setup_true_lang.js +39 -33
  20. package/dist/components/BlessCombobox.vue.d.ts +2 -0
  21. package/dist/components/BlessCombobox.vue_vue_type_script_setup_true_lang.js +3 -2
  22. package/dist/components/BlessCommand.css +1 -1
  23. package/dist/components/BlessCommand.vue.d.ts +26 -0
  24. package/dist/components/BlessCommand.vue_vue_type_script_setup_true_lang.js +137 -70
  25. package/dist/components/BlessConfetti.css +1 -0
  26. package/dist/components/BlessConfetti.js +6 -0
  27. package/dist/components/BlessConfetti.vue.d.ts +40 -0
  28. package/dist/components/BlessConfetti.vue_vue_type_script_setup_true_lang.js +77 -0
  29. package/dist/components/BlessCropper.vue.d.ts +16 -0
  30. package/dist/components/BlessCropper.vue_vue_type_script_setup_true_lang.js +47 -39
  31. package/dist/components/BlessDataTable.vue.d.ts +6 -0
  32. package/dist/components/BlessDataTable.vue_vue_type_script_setup_true_lang.js +56 -42
  33. package/dist/components/BlessDataView.vue.d.ts +7 -0
  34. package/dist/components/BlessDataView.vue_vue_type_script_setup_true_lang.js +38 -31
  35. package/dist/components/BlessDatePicker.vue.d.ts +3 -0
  36. package/dist/components/BlessDatePicker.vue_vue_type_script_setup_true_lang.js +46 -45
  37. package/dist/components/BlessDock.css +1 -0
  38. package/dist/components/BlessDock.js +6 -0
  39. package/dist/components/BlessDock.vue.d.ts +55 -0
  40. package/dist/components/BlessDock.vue_vue_type_script_setup_true_lang.js +100 -0
  41. package/dist/components/BlessEditor.vue.d.ts +2 -0
  42. package/dist/components/BlessEditor.vue_vue_type_script_setup_true_lang.js +23 -22
  43. package/dist/components/BlessFileInput.vue.d.ts +2 -0
  44. package/dist/components/BlessFileInput.vue_vue_type_script_setup_true_lang.js +3 -2
  45. package/dist/components/BlessFormula.css +1 -0
  46. package/dist/components/BlessFormula.js +6 -0
  47. package/dist/components/BlessFormula.vue.d.ts +53 -0
  48. package/dist/components/BlessFormula.vue_vue_type_script_setup_true_lang.js +111 -0
  49. package/dist/components/BlessGantt.vue.d.ts +12 -0
  50. package/dist/components/BlessGantt.vue_vue_type_script_setup_true_lang.js +74 -68
  51. package/dist/components/BlessInfiniteCanvas.css +1 -0
  52. package/dist/components/BlessInfiniteCanvas.js +6 -0
  53. package/dist/components/BlessInfiniteCanvas.vue.d.ts +91 -0
  54. package/dist/components/BlessInfiniteCanvas.vue_vue_type_script_setup_true_lang.js +232 -0
  55. package/dist/components/BlessInputNumber.vue.d.ts +5 -0
  56. package/dist/components/BlessInputNumber.vue_vue_type_script_setup_true_lang.js +39 -34
  57. package/dist/components/BlessKanban.vue.d.ts +12 -0
  58. package/dist/components/BlessKanban.vue_vue_type_script_setup_true_lang.js +127 -97
  59. package/dist/components/BlessLoadingBar.vue.d.ts +2 -0
  60. package/dist/components/BlessLoadingBar.vue_vue_type_script_setup_true_lang.js +8 -3
  61. package/dist/components/BlessMarquee.vue.d.ts +4 -0
  62. package/dist/components/BlessMarquee.vue_vue_type_script_setup_true_lang.js +32 -27
  63. package/dist/components/BlessNodeGraph.css +1 -0
  64. package/dist/components/BlessNodeGraph.js +6 -0
  65. package/dist/components/BlessNodeGraph.vue.d.ts +110 -0
  66. package/dist/components/BlessNodeGraph.vue_vue_type_script_setup_true_lang.js +321 -0
  67. package/dist/components/BlessOnboardingChecklist.css +1 -0
  68. package/dist/components/BlessOnboardingChecklist.js +6 -0
  69. package/dist/components/BlessOnboardingChecklist.vue.d.ts +72 -0
  70. package/dist/components/BlessOnboardingChecklist.vue_vue_type_script_setup_true_lang.js +157 -0
  71. package/dist/components/BlessOrderList.vue.d.ts +5 -0
  72. package/dist/components/BlessOrderList.vue_vue_type_script_setup_true_lang.js +62 -56
  73. package/dist/components/BlessPagination.vue.d.ts +2 -0
  74. package/dist/components/BlessPagination.vue_vue_type_script_setup_true_lang.js +2 -1
  75. package/dist/components/BlessPickList.vue.d.ts +5 -0
  76. package/dist/components/BlessPickList.vue_vue_type_script_setup_true_lang.js +55 -49
  77. package/dist/components/BlessRangeCalendar.css +1 -0
  78. package/dist/components/BlessRangeCalendar.js +6 -0
  79. package/dist/components/BlessRangeCalendar.vue.d.ts +51 -0
  80. package/dist/components/BlessRangeCalendar.vue_vue_type_script_setup_true_lang.js +217 -0
  81. package/dist/components/BlessScheduler.css +1 -0
  82. package/dist/components/BlessScheduler.js +6 -0
  83. package/dist/components/BlessScheduler.vue.d.ts +95 -0
  84. package/dist/components/BlessScheduler.vue_vue_type_script_setup_true_lang.js +347 -0
  85. package/dist/components/BlessShortcutRecorder.vue.d.ts +10 -0
  86. package/dist/components/BlessShortcutRecorder.vue_vue_type_script_setup_true_lang.js +50 -40
  87. package/dist/components/BlessSignaturePad.vue.d.ts +1 -1
  88. package/dist/components/BlessSliderCaptcha.vue.d.ts +5 -0
  89. package/dist/components/BlessSliderCaptcha.vue_vue_type_script_setup_true_lang.js +89 -84
  90. package/dist/components/BlessSortable.css +1 -1
  91. package/dist/components/BlessSortable.vue.d.ts +19 -1
  92. package/dist/components/BlessSortable.vue_vue_type_script_setup_true_lang.js +103 -55
  93. package/dist/components/BlessSparkline.css +1 -0
  94. package/dist/components/BlessSparkline.js +6 -0
  95. package/dist/components/BlessSparkline.vue.d.ts +28 -0
  96. package/dist/components/BlessSparkline.vue_vue_type_script_setup_true_lang.js +107 -0
  97. package/dist/components/BlessSteps.vue.d.ts +2 -0
  98. package/dist/components/BlessSteps.vue_vue_type_script_setup_true_lang.js +3 -2
  99. package/dist/components/BlessSwipeDeck.vue.d.ts +1 -1
  100. package/dist/components/BlessSwipeDeck.vue_vue_type_script_setup_true_lang.js +2 -1
  101. package/dist/components/BlessTimer.vue.d.ts +18 -0
  102. package/dist/components/BlessTimer.vue_vue_type_script_setup_true_lang.js +52 -43
  103. package/dist/components/BlessTour.vue.d.ts +1 -0
  104. package/dist/components/BlessTour.vue_vue_type_script_setup_true_lang.js +48 -42
  105. package/dist/components/BlessTreemap.css +1 -0
  106. package/dist/components/BlessTreemap.js +6 -0
  107. package/dist/components/BlessTreemap.vue.d.ts +46 -0
  108. package/dist/components/BlessTreemap.vue_vue_type_script_setup_true_lang.js +137 -0
  109. package/dist/components/BlessUploader.vue.d.ts +11 -0
  110. package/dist/components/BlessUploader.vue_vue_type_script_setup_true_lang.js +80 -69
  111. package/dist/composables/annotate.d.ts +35 -0
  112. package/dist/composables/annotate.js +33 -0
  113. package/dist/composables/canvasView.d.ts +21 -0
  114. package/dist/composables/canvasView.js +23 -0
  115. package/dist/composables/confetti.d.ts +32 -0
  116. package/dist/composables/confetti.js +23 -0
  117. package/dist/composables/dayBlocks.d.ts +11 -0
  118. package/dist/composables/dayBlocks.js +26 -0
  119. package/dist/composables/formula.d.ts +28 -0
  120. package/dist/composables/formula.js +161 -0
  121. package/dist/composables/graph.d.ts +19 -0
  122. package/dist/composables/graph.js +16 -0
  123. package/dist/composables/schedule.d.ts +27 -0
  124. package/dist/composables/schedule.js +54 -0
  125. package/dist/composables/treemap.d.ts +23 -0
  126. package/dist/composables/treemap.js +77 -0
  127. package/dist/composables/useAutoScroll.d.ts +15 -0
  128. package/dist/composables/useAutoScroll.js +32 -0
  129. package/dist/composables/useSortable.d.ts +42 -2
  130. package/dist/composables/useSortable.js +87 -14
  131. package/dist/index.d.ts +25 -1
  132. package/dist/index.js +78 -63
  133. package/package.json +4 -2
@@ -0,0 +1,33 @@
1
+ //#region src/composables/annotate.ts
2
+ var e = .02, t = (e) => e.w != null && e.h != null, n = (e, t, n) => Math.min(n, Math.max(t, e)), r = (e) => Math.round(e * 1e4) / 1e4;
3
+ function i(e, t) {
4
+ let i = n(Math.min(e.x, t.x), 0, 1), a = n(Math.min(e.y, t.y), 0, 1), o = n(Math.max(e.x, t.x), 0, 1), s = n(Math.max(e.y, t.y), 0, 1);
5
+ return {
6
+ x: r(i),
7
+ y: r(a),
8
+ w: r(o - i),
9
+ h: r(s - a)
10
+ };
11
+ }
12
+ function a(e, t, i) {
13
+ let a = e.w ?? 0, o = e.h ?? 0;
14
+ return {
15
+ ...e,
16
+ x: r(n(e.x + t, 0, 1 - a)),
17
+ y: r(n(e.y + i, 0, 1 - o))
18
+ };
19
+ }
20
+ function o(i, a, o) {
21
+ return t(i) ? {
22
+ ...i,
23
+ w: r(n(i.w + a, e, 1 - i.x)),
24
+ h: r(n(i.h + o, e, 1 - i.y))
25
+ } : i;
26
+ }
27
+ function s(e) {
28
+ let t = new Set(e.map((e) => e.id)), n = 1;
29
+ for (; t.has(`r${n}`);) n++;
30
+ return `r${n}`;
31
+ }
32
+ //#endregion
33
+ export { e as MIN_SIDE, i as boxFrom, t as isBox, a as moveRegion, s as nextId, o as resizeRegion };
@@ -0,0 +1,21 @@
1
+ export interface CanvasView {
2
+ /** where the world's origin sits inside the viewport, px */
3
+ x: number;
4
+ y: number;
5
+ zoom: number;
6
+ }
7
+ export declare const clampZoom: (z: number, min: number, max: number) => number;
8
+ /** The world point under a viewport point (px relative to the viewport's top-left). */
9
+ export declare const toWorld: (v: CanvasView, px: number, py: number) => {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ /** Zoom by `factor` keeping the world point under (`px`, `py`) where it is. */
14
+ export declare function zoomAt(v: CanvasView, factor: number, px: number, py: number, min: number, max: number): CanvasView;
15
+ /** The view that shows a world rectangle centred in a viewport of `w` × `h`, with `pad` px around. */
16
+ export declare function fitRect(r: {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ }, w: number, h: number, min: number, max: number, pad?: number): CanvasView;
@@ -0,0 +1,23 @@
1
+ //#region src/composables/canvasView.ts
2
+ var e = (e, t, n) => Math.min(n, Math.max(t, e)), t = (e, t, n) => ({
3
+ x: (t - e.x) / e.zoom,
4
+ y: (n - e.y) / e.zoom
5
+ });
6
+ function n(t, n, r, i, a, o) {
7
+ let s = e(t.zoom * n, a, o), c = s / t.zoom;
8
+ return {
9
+ zoom: s,
10
+ x: r - (r - t.x) * c,
11
+ y: i - (i - t.y) * c
12
+ };
13
+ }
14
+ function r(t, n, r, i, a, o = 32) {
15
+ let s = e(Math.min((n - o * 2) / (t.width || 1), (r - o * 2) / (t.height || 1)), i, a);
16
+ return {
17
+ zoom: s,
18
+ x: (n - t.width * s) / 2 - t.x * s,
19
+ y: (r - t.height * s) / 2 - t.y * s
20
+ };
21
+ }
22
+ //#endregion
23
+ export { e as clampZoom, r as fitRect, t as toWorld, n as zoomAt };
@@ -0,0 +1,32 @@
1
+ export interface Particle {
2
+ x: number;
3
+ y: number;
4
+ vx: number;
5
+ vy: number;
6
+ size: number;
7
+ rot: number;
8
+ vr: number;
9
+ color: string;
10
+ round: boolean;
11
+ /** 0..1 of its life left; fades out over the last part */
12
+ life: number;
13
+ }
14
+ export interface BurstOptions {
15
+ count: number;
16
+ /** viewport px */
17
+ origin: {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ /** where the burst points, degrees, 0 = right, 270 = up */
22
+ angle: number;
23
+ /** total width of the cone, degrees */
24
+ spread: number;
25
+ /** px per second at launch (the strongest piece) */
26
+ power: number;
27
+ colors: string[];
28
+ }
29
+ /** The pieces of one burst; `rand` is injected so a test can fix it. */
30
+ export declare function burst(o: BurstOptions, rand?: () => number): Particle[];
31
+ /** Advance a piece by `dt` seconds: gravity pulls down, the air slows it, it fades near the end. */
32
+ export declare function step(p: Particle, dt: number, gravity: number, lifetime: number): void;
@@ -0,0 +1,23 @@
1
+ //#region src/composables/confetti.ts
2
+ function e(e, t = Math.random) {
3
+ return Array.from({ length: e.count }, (n, r) => {
4
+ let i = (e.angle + (t() - .5) * e.spread) * Math.PI / 180, a = e.power * (.45 + t() * .55);
5
+ return {
6
+ x: e.origin.x,
7
+ y: e.origin.y,
8
+ vx: Math.cos(i) * a,
9
+ vy: Math.sin(i) * a,
10
+ size: 5 + t() * 6,
11
+ rot: t() * Math.PI * 2,
12
+ vr: (t() - .5) * 12,
13
+ color: e.colors[r % e.colors.length],
14
+ round: t() < .3,
15
+ life: 1
16
+ };
17
+ });
18
+ }
19
+ function t(e, t, n, r) {
20
+ e.vx *= 1 - 1.6 * t, e.vy = e.vy * (1 - 1.6 * t) + n * t, e.x += e.vx * t, e.y += e.vy * t, e.rot += e.vr * t, e.life -= t / r;
21
+ }
22
+ //#endregion
23
+ export { e as burst, t as step };
@@ -0,0 +1,11 @@
1
+ export interface DayBlock {
2
+ start: string;
3
+ end: string;
4
+ count: number;
5
+ }
6
+ /** Every day from `a` to `b` inclusive, whichever comes first, as ISO strings. */
7
+ export declare function rangeBetween(a: string, b: string): string[];
8
+ /** Runs of consecutive days in a set of dates, in order. */
9
+ export declare function blocks(dates: readonly string[]): DayBlock[];
10
+ /** `current` with `range` added (`set`) or removed (`clear`), skipping days `ok` refuses; sorted. */
11
+ export declare function applyRange(current: readonly string[], range: readonly string[], mode: "set" | "clear", ok?: (iso: string) => boolean): string[];
@@ -0,0 +1,26 @@
1
+ import { addDays as e, fromISO as t, toISO as n } from "./date.js";
2
+ //#region src/composables/dayBlocks.ts
3
+ function r(r, i) {
4
+ let [a, o] = r <= i ? [r, i] : [i, r], s = [];
5
+ for (let r = t(a), i = t(o); r <= i; r = e(r, 1)) s.push(n(r));
6
+ return s;
7
+ }
8
+ function i(r) {
9
+ let i = [...new Set(r)].sort(), a = [];
10
+ for (let r of i) {
11
+ let i = a.at(-1);
12
+ i && n(e(t(i.end), 1)) === r ? (i.end = r, i.count++) : a.push({
13
+ start: r,
14
+ end: r,
15
+ count: 1
16
+ });
17
+ }
18
+ return a;
19
+ }
20
+ function a(e, t, n, r = () => !0) {
21
+ let i = new Set(e);
22
+ for (let e of t) r(e) && (n === "set" ? i.add(e) : i.delete(e));
23
+ return [...i].sort();
24
+ }
25
+ //#endregion
26
+ export { a as applyRange, i as blocks, r as rangeBetween };
@@ -0,0 +1,28 @@
1
+ export type FormulaErrorCode = "empty" | "unexpected" | "unclosed" | "unknown-variable" | "unknown-function" | "arity" | "divide-by-zero" | "not-finite";
2
+ export interface FormulaError {
3
+ code: FormulaErrorCode;
4
+ /** where in the source it went wrong (0-based), and how many characters */
5
+ pos: number;
6
+ length: number;
7
+ /** the variable or function the error is about, or the unexpected text */
8
+ name?: string;
9
+ /** the closest known name, when there is one */
10
+ suggestion?: string;
11
+ }
12
+ export type FormulaResult = {
13
+ ok: true;
14
+ value: number;
15
+ } | {
16
+ ok: false;
17
+ error: FormulaError;
18
+ };
19
+ export type FormulaFns = Record<string, (...args: number[]) => number>;
20
+ export declare const builtins: FormulaFns;
21
+ export declare function closest(name: string, known: readonly string[]): string | undefined;
22
+ /**
23
+ * Evaluate `+ - * / ^`, brackets, numbers, named values and functions. There is no `eval`: the
24
+ * source is parsed by recursive descent, so only numbers can come out and nothing can run.
25
+ */
26
+ export declare function evaluate(src: string, vars?: Readonly<Record<string, number>>, fns?: FormulaFns): FormulaResult;
27
+ /** The names the formula refers to as values (not function names). */
28
+ export declare function usedNames(src: string): string[];
@@ -0,0 +1,161 @@
1
+ //#region src/composables/formula.ts
2
+ var e = {
3
+ sum: (...e) => e.reduce((e, t) => e + t, 0),
4
+ min: (...e) => Math.min(...e),
5
+ max: (...e) => Math.max(...e),
6
+ avg: (...e) => e.reduce((e, t) => e + t, 0) / e.length,
7
+ abs: (e) => Math.abs(e),
8
+ sqrt: (e) => Math.sqrt(e),
9
+ floor: (e) => Math.floor(e),
10
+ ceil: (e) => Math.ceil(e),
11
+ round: (e, t = 0) => {
12
+ let n = 10 ** t;
13
+ return Math.round(e * n) / n;
14
+ }
15
+ };
16
+ function t(e) {
17
+ let t = [], n = /\s+|(\d+\.?\d*|\.\d+)|([A-Za-z_][A-Za-z0-9_]*)|([-+*/^(),])|(.)/gy, r;
18
+ for (; n.lastIndex < e.length && (r = n.exec(e));) if (r[1]) t.push({
19
+ t: "num",
20
+ v: r[1],
21
+ pos: r.index
22
+ });
23
+ else if (r[2]) t.push({
24
+ t: "id",
25
+ v: r[2],
26
+ pos: r.index
27
+ });
28
+ else if (r[3]) t.push({
29
+ t: "op",
30
+ v: r[3],
31
+ pos: r.index
32
+ });
33
+ else if (r[4]) return {
34
+ code: "unexpected",
35
+ pos: r.index,
36
+ length: 1,
37
+ name: r[4]
38
+ };
39
+ return t.push({
40
+ t: "end",
41
+ v: "",
42
+ pos: e.length
43
+ }), t;
44
+ }
45
+ function n(e, t) {
46
+ let n = Array.from({ length: e.length + 1 }, (e, n) => [n, ...Array(t.length).fill(0)]);
47
+ for (let e = 1; e <= t.length; e++) n[0][e] = e;
48
+ for (let r = 1; r <= e.length; r++) for (let i = 1; i <= t.length; i++) n[r][i] = Math.min(n[r - 1][i] + 1, n[r][i - 1] + 1, n[r - 1][i - 1] + (e[r - 1].toLowerCase() === t[i - 1].toLowerCase() ? 0 : 1));
49
+ for (let r = 2; r <= e.length; r++) for (let i = 2; i <= t.length; i++) e[r - 1] === t[i - 2] && e[r - 2] === t[i - 1] && (n[r][i] = Math.min(n[r][i], n[r - 2][i - 2] + 1));
50
+ return n[e.length][t.length];
51
+ }
52
+ function r(e, t) {
53
+ let r, i = Math.min(2, Math.max(1, Math.floor(e.length / 3)));
54
+ for (let a of t) {
55
+ let t = n(e, a);
56
+ t <= i && (i = t, r = a);
57
+ }
58
+ return r;
59
+ }
60
+ var i = class extends Error {
61
+ error;
62
+ constructor(e) {
63
+ super(e.code), this.error = e;
64
+ }
65
+ };
66
+ function a(n, a = {}, o = {}) {
67
+ let s = Object.assign(Object.create(null), e, o), c = t(n);
68
+ if (!Array.isArray(c)) return {
69
+ ok: !1,
70
+ error: c
71
+ };
72
+ if (c.length === 1) return {
73
+ ok: !1,
74
+ error: {
75
+ code: "empty",
76
+ pos: 0,
77
+ length: 0
78
+ }
79
+ };
80
+ let l = 0, u = () => c[l], d = () => c[l++], f = (e) => {
81
+ throw new i(e);
82
+ }, p = (e, t, n = {}) => f({
83
+ code: t,
84
+ pos: e.pos,
85
+ length: Math.max(1, e.v.length),
86
+ name: e.v || void 0,
87
+ ...n
88
+ }), m = (e, t) => Number.isFinite(e) ? e : p(t, "not-finite");
89
+ function h() {
90
+ let e = g();
91
+ for (; u().t === "op" && (u().v === "+" || u().v === "-");) {
92
+ let t = d().v, n = g();
93
+ e = t === "+" ? e + n : e - n;
94
+ }
95
+ return e;
96
+ }
97
+ function g() {
98
+ let e = _();
99
+ for (; u().t === "op" && (u().v === "*" || u().v === "/");) {
100
+ let t = d(), n = _();
101
+ t.v === "/" && n === 0 && p(t, "divide-by-zero"), e = t.v === "*" ? e * n : e / n;
102
+ }
103
+ return e;
104
+ }
105
+ function _() {
106
+ if (u().t === "op" && (u().v === "-" || u().v === "+")) {
107
+ let e = d().v, t = _();
108
+ return e === "-" ? -t : t;
109
+ }
110
+ return v();
111
+ }
112
+ function v() {
113
+ let e = y();
114
+ if (u().t === "op" && u().v === "^") {
115
+ let t = d();
116
+ return m(e ** _(), t);
117
+ }
118
+ return e;
119
+ }
120
+ function y() {
121
+ let e = d();
122
+ if (e.t === "num") return Number(e.v);
123
+ if (e.t === "id") {
124
+ if (u().t === "op" && u().v === "(") {
125
+ d();
126
+ let t = [];
127
+ if (u().t !== "op" || u().v !== ")") do
128
+ t.push(h());
129
+ while (u().t === "op" && u().v === "," && d());
130
+ (u().t !== "op" || u().v !== ")") && p(u(), "unclosed"), d();
131
+ let n = Object.hasOwn(s, e.v) ? s[e.v] : void 0;
132
+ return n ? !t.length && n.length > 0 ? p(e, "arity") : m(n(...t), e) : p(e, "unknown-function", { suggestion: r(e.v, Object.keys(s)) });
133
+ }
134
+ return Object.hasOwn(a, e.v) ? a[e.v] : p(e, "unknown-variable", { suggestion: r(e.v, Object.keys(a)) });
135
+ }
136
+ if (e.t === "op" && e.v === "(") {
137
+ let e = h();
138
+ return (u().t !== "op" || u().v !== ")") && p(u(), "unclosed"), d(), e;
139
+ }
140
+ return p(e, (e.t, "unexpected"));
141
+ }
142
+ try {
143
+ let e = h();
144
+ return u().t !== "end" && p(u(), "unexpected"), {
145
+ ok: !0,
146
+ value: m(e, c[0])
147
+ };
148
+ } catch (e) {
149
+ if (e instanceof i) return {
150
+ ok: !1,
151
+ error: e.error
152
+ };
153
+ throw e;
154
+ }
155
+ }
156
+ function o(e) {
157
+ let n = t(e);
158
+ return Array.isArray(n) ? [...new Set(n.filter((e, t) => e.t === "id" && (n[t + 1]?.t !== "op" || n[t + 1]?.v !== "(")).map((e) => e.v))] : [];
159
+ }
160
+ //#endregion
161
+ export { e as builtins, r as closest, a as evaluate, o as usedNames };
@@ -0,0 +1,19 @@
1
+ export interface GraphEdge {
2
+ from: string;
3
+ to: string;
4
+ label?: string;
5
+ }
6
+ export declare const edgeKey: (e: Pick<GraphEdge, "from" | "to">) => string;
7
+ /** True when `target` can be reached from `start` by following edges forward. */
8
+ export declare function reaches(edges: readonly GraphEdge[], start: string, target: string): boolean;
9
+ /** Why `from -> to` cannot be added, or null when it can. */
10
+ export declare function linkProblem(edges: readonly GraphEdge[], from: string, to: string, acyclic?: boolean): "self" | "exists" | "cycle" | null;
11
+ /** A smooth S-curve from an output port at `a` to an input port at `b`. */
12
+ export declare function edgePath(a: {
13
+ x: number;
14
+ y: number;
15
+ }, b: {
16
+ x: number;
17
+ y: number;
18
+ }): string;
19
+ export declare const snapTo: (v: number, grid: number) => number;
@@ -0,0 +1,16 @@
1
+ //#region src/composables/graph.ts
2
+ var e = (e) => `${e.from}->${e.to}`;
3
+ function t(e, t, n) {
4
+ let r = /* @__PURE__ */ new Set(), i = (t) => t === n || !r.has(t) && (r.add(t), e.some((e) => e.from === t && i(e.to)));
5
+ return i(t);
6
+ }
7
+ function n(e, n, r, i = !1) {
8
+ return n === r ? "self" : e.some((e) => e.from === n && e.to === r) ? "exists" : i && t(e, r, n) ? "cycle" : null;
9
+ }
10
+ function r(e, t) {
11
+ let n = Math.max(48, Math.abs(t.x - e.x) / 2);
12
+ return `M${e.x} ${e.y}C${e.x + n} ${e.y} ${t.x - n} ${t.y} ${t.x} ${t.y}`;
13
+ }
14
+ var i = (e, t) => t > 0 ? Math.round(e / t) * t : e;
15
+ //#endregion
16
+ export { e as edgeKey, r as edgePath, n as linkProblem, t as reaches, i as snapTo };
@@ -0,0 +1,27 @@
1
+ /** An event on one day. `start` and `end` are minutes after midnight, local time, `start < end`. */
2
+ export interface ScheduleEvent {
3
+ id: string;
4
+ title: string;
5
+ /** `YYYY-MM-DD` */
6
+ date: string;
7
+ start: number;
8
+ end: number;
9
+ }
10
+ export declare const snapTo: (m: number, step: number) => number;
11
+ /** `540` -> "09:00" (24 h), or the locale's style with `locale`. */
12
+ export declare function fmtTime(minutes: number, locale?: string): string;
13
+ /** The first day of the week (`weekStart` 0 = Sunday, 1 = Monday) that contains `iso`. */
14
+ export declare function weekOf(iso: string, weekStart: 0 | 1): string;
15
+ /**
16
+ * Side-by-side columns for events that overlap: an event gets a `lane` (0, 1, …) and the number of
17
+ * `lanes` its cluster of overlapping events needs, so each is drawn `1 / lanes` wide.
18
+ */
19
+ export declare function layoutDay(events: readonly ScheduleEvent[]): Map<string, {
20
+ lane: number;
21
+ lanes: number;
22
+ }>;
23
+ /** `e` shifted by `minutes` and `days`, keeping its length and staying inside [lo, hi]. */
24
+ export declare function moveEvent(e: ScheduleEvent, minutes: number, days: number, lo: number, hi: number): ScheduleEvent;
25
+ /** `e` with its end moved by `minutes`: at least `min` long, and not past `hi`. */
26
+ export declare function resizeEvent(e: ScheduleEvent, minutes: number, min: number, hi: number): ScheduleEvent;
27
+ export declare function nextEventId(events: readonly ScheduleEvent[]): string;
@@ -0,0 +1,54 @@
1
+ import { addDays as e, fromISO as t, toISO as n } from "./date.js";
2
+ //#region src/composables/schedule.ts
3
+ var r = (e, t) => Math.round(e / t) * t, i = (e, t, n) => Math.min(n, Math.max(t, e));
4
+ function a(e, t) {
5
+ let n = new Date(2e3, 0, 1, Math.floor(e / 60) % 24, e % 60);
6
+ return t ? new Intl.DateTimeFormat(t, {
7
+ hour: "numeric",
8
+ minute: "2-digit"
9
+ }).format(n) : `${String(n.getHours()).padStart(2, "0")}:${String(n.getMinutes()).padStart(2, "0")}`;
10
+ }
11
+ function o(r, i) {
12
+ let a = t(r);
13
+ return n(e(a, -((a.getDay() - i + 7) % 7)));
14
+ }
15
+ function s(e) {
16
+ let t = /* @__PURE__ */ new Map(), n = [...e].sort((e, t) => e.start - t.start || e.end - t.end), r = [], i = [], a = -Infinity, o = () => {
17
+ for (let e of r) t.set(e.id, {
18
+ lane: e.lane,
19
+ lanes: i.length
20
+ });
21
+ r = [], i = [];
22
+ };
23
+ for (let e of n) {
24
+ e.start >= a && o();
25
+ let t = i.findIndex((t) => t <= e.start);
26
+ t < 0 && (t = i.length), i[t] = e.end, r.push({
27
+ id: e.id,
28
+ lane: t
29
+ }), a = Math.max(a, e.end);
30
+ }
31
+ return o(), t;
32
+ }
33
+ function c(r, a, o, s, c) {
34
+ let l = r.end - r.start, u = i(r.start + a, s, Math.max(s, c - l));
35
+ return {
36
+ ...r,
37
+ date: o ? n(e(t(r.date), o)) : r.date,
38
+ start: u,
39
+ end: u + l
40
+ };
41
+ }
42
+ function l(e, t, n, r) {
43
+ return {
44
+ ...e,
45
+ end: i(e.end + t, e.start + n, Math.max(e.start + n, r))
46
+ };
47
+ }
48
+ function u(e) {
49
+ let t = new Set(e.map((e) => e.id)), n = 1;
50
+ for (; t.has(`e${n}`);) n++;
51
+ return `e${n}`;
52
+ }
53
+ //#endregion
54
+ export { a as fmtTime, s as layoutDay, c as moveEvent, u as nextEventId, l as resizeEvent, r as snapTo, o as weekOf };
@@ -0,0 +1,23 @@
1
+ export interface Rect {
2
+ x: number;
3
+ y: number;
4
+ w: number;
5
+ h: number;
6
+ }
7
+ export interface TreemapNode {
8
+ id: string;
9
+ label: string;
10
+ /** a leaf's size; a node with `children` is the sum of them */
11
+ value?: number;
12
+ children?: TreemapNode[];
13
+ /** a token name (`chart-2`, `success`…) or any CSS colour; children inherit it */
14
+ color?: string;
15
+ }
16
+ export declare const totalOf: (n: TreemapNode) => number;
17
+ /**
18
+ * Squarified treemap (Bruls, Huijsmans, van Wijk): tiles whose areas are proportional to
19
+ * `values`, kept close to square so they stay readable. Rects come back in the input order.
20
+ */
21
+ export declare function squarify(values: readonly number[], w: number, h: number): Rect[];
22
+ /** The tile in direction `dir` from tile `from`: the nearest centre that lies that way. */
23
+ export declare function neighbour(rects: readonly Rect[], from: number, dir: "left" | "right" | "up" | "down"): number;
@@ -0,0 +1,77 @@
1
+ //#region src/composables/treemap.ts
2
+ var e = (t) => t.children?.length ? t.children.reduce((t, n) => t + e(n), 0) : Math.max(0, t.value ?? 0);
3
+ function t(e, t, n) {
4
+ let r = e.map(() => ({
5
+ x: 0,
6
+ y: 0,
7
+ w: 0,
8
+ h: 0
9
+ })), i = e.reduce((e, t) => e + Math.max(0, t), 0);
10
+ if (!i || t <= 0 || n <= 0) return r;
11
+ let a = e.map((e, t) => t).sort((t, n) => e[n] - e[t]), o = a.map((r) => Math.max(0, e[r]) / i * t * n), s = [...r], c = {
12
+ x: 0,
13
+ y: 0,
14
+ w: t,
15
+ h: n
16
+ }, l = (e, t) => {
17
+ let n = e.reduce((e, t) => e + t, 0), r = Math.min(...e), i = Math.max(...e);
18
+ return Math.max(t * t * i / (n * n), n * n / (t * t * r));
19
+ }, u = (e, t) => {
20
+ let n = t.reduce((e, t) => e + t, 0);
21
+ if (c.w >= c.h) {
22
+ let r = n / c.h, i = c.y;
23
+ t.forEach((t, n) => {
24
+ let o = t / r;
25
+ s[a[e + n]] = {
26
+ x: c.x,
27
+ y: i,
28
+ w: r,
29
+ h: o
30
+ }, i += o;
31
+ }), c = {
32
+ x: c.x + r,
33
+ y: c.y,
34
+ w: c.w - r,
35
+ h: c.h
36
+ };
37
+ } else {
38
+ let r = n / c.w, i = c.x;
39
+ t.forEach((t, n) => {
40
+ let o = t / r;
41
+ s[a[e + n]] = {
42
+ x: i,
43
+ y: c.y,
44
+ w: o,
45
+ h: r
46
+ }, i += o;
47
+ }), c = {
48
+ x: c.x,
49
+ y: c.y + r,
50
+ w: c.w,
51
+ h: c.h - r
52
+ };
53
+ }
54
+ }, d = 0, f = [];
55
+ for (let e = 0; e < o.length; e++) {
56
+ let t = o[e];
57
+ if (!t) continue;
58
+ let n = Math.min(c.w, c.h);
59
+ !f.length || l([...f, t], n) <= l(f, n) ? f.push(t) : (u(d, f), d = e, f = [t]);
60
+ }
61
+ return f.length && u(d, f), s;
62
+ }
63
+ function n(e, t, n) {
64
+ let r = (e) => ({
65
+ x: e.x + e.w / 2,
66
+ y: e.y + e.h / 2
67
+ }), i = r(e[t]), a = -1, o = Infinity;
68
+ return e.forEach((e, s) => {
69
+ if (s === t || !e.w) return;
70
+ let c = r(e), l = c.x - i.x, u = c.y - i.y, d = n === "left" ? -l : n === "right" ? l : n === "up" ? -u : u;
71
+ if (d <= 0) return;
72
+ let f = d + Math.abs(n === "left" || n === "right" ? u : l) * 2;
73
+ f < o && (o = f, a = s);
74
+ }), a < 0 ? t : a;
75
+ }
76
+ //#endregion
77
+ export { n as neighbour, t as squarify, e as totalOf };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Pixels to scroll per frame for a pointer at `pos` on an axis running from `min` to `max`:
3
+ * 0 in the middle, growing to ±`top` as it nears either end (negative = toward `min`).
4
+ */
5
+ export declare function edgeSpeed(pos: number, min: number, max: number, edge?: number, top?: number): number;
6
+ /**
7
+ * While a drag is held near the edge of `box` (sideways) or of the window (up and down), keep
8
+ * scrolling it; `onScroll` fires after each nudge so the drop target can be worked out again.
9
+ * Call `point` from the pointer-move handler, `start` on grab and `stop` on drop or cancel.
10
+ */
11
+ export declare function useAutoScroll(box: () => HTMLElement | null | undefined, onScroll: () => void): {
12
+ point(px: number, py: number): void;
13
+ start(): void;
14
+ stop(): void;
15
+ };
@@ -0,0 +1,32 @@
1
+ //#region src/composables/useAutoScroll.ts
2
+ function e(e, t, n, r = 48, i = 18) {
3
+ return n - t < r * 2 ? 0 : e < t + r ? -Math.min(i, Math.ceil((t + r - e) / r * i)) : e > n - r ? Math.min(i, Math.ceil((e - (n - r)) / r * i)) : 0;
4
+ }
5
+ function t(t, n) {
6
+ let r = 0, i = 0, a = 0, o = () => {
7
+ let s = !1, c = t();
8
+ if (c) {
9
+ let t = c.getBoundingClientRect(), n = e(i, t.left, t.right), r = c.scrollLeft;
10
+ n && (c.scrollLeft += n), s ||= c.scrollLeft !== r;
11
+ }
12
+ let l = e(a, 0, window.innerHeight);
13
+ if (l) {
14
+ let e = window.scrollY;
15
+ window.scrollBy(0, l), s ||= window.scrollY !== e;
16
+ }
17
+ s && n(), r = requestAnimationFrame(o);
18
+ };
19
+ return {
20
+ point(e, t) {
21
+ i = e, a = t;
22
+ },
23
+ start() {
24
+ cancelAnimationFrame(r), r = requestAnimationFrame(o);
25
+ },
26
+ stop() {
27
+ cancelAnimationFrame(r), r = 0;
28
+ }
29
+ };
30
+ }
31
+ //#endregion
32
+ export { e as edgeSpeed, t as useAutoScroll };