blessing-ui 0.1.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.
- package/CHANGELOG.md +69 -0
- package/README.md +139 -105
- package/dist/blessing-ui.css +97 -1
- package/dist/components/BlessAnnotator.css +1 -0
- package/dist/components/BlessAnnotator.js +6 -0
- package/dist/components/BlessAnnotator.vue.d.ts +71 -0
- package/dist/components/BlessAnnotator.vue_vue_type_script_setup_true_lang.js +264 -0
- package/dist/components/BlessAttachment.vue.d.ts +4 -1
- package/dist/components/BlessAttachment.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/components/BlessCalendar.vue.d.ts +4 -0
- package/dist/components/BlessCalendar.vue_vue_type_script_setup_true_lang.js +65 -60
- package/dist/components/BlessCarousel.vue.d.ts +3 -0
- package/dist/components/BlessCarousel.vue_vue_type_script_setup_true_lang.js +10 -9
- package/dist/components/BlessCoachmark.css +1 -0
- package/dist/components/BlessCoachmark.js +6 -0
- package/dist/components/BlessCoachmark.vue.d.ts +40 -0
- package/dist/components/BlessCoachmark.vue_vue_type_script_setup_true_lang.js +74 -0
- package/dist/components/BlessCodeBlock.css +1 -0
- package/dist/components/BlessCodeBlock.js +6 -0
- package/dist/components/BlessCodeBlock.vue.d.ts +72 -0
- package/dist/components/BlessCodeBlock.vue_vue_type_script_setup_true_lang.js +140 -0
- package/dist/components/BlessCombobox.vue.d.ts +2 -0
- package/dist/components/BlessCombobox.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/components/BlessCommand.css +1 -1
- package/dist/components/BlessCommand.vue.d.ts +26 -0
- package/dist/components/BlessCommand.vue_vue_type_script_setup_true_lang.js +137 -70
- package/dist/components/BlessConfetti.css +1 -0
- package/dist/components/BlessConfetti.js +6 -0
- package/dist/components/BlessConfetti.vue.d.ts +40 -0
- package/dist/components/BlessConfetti.vue_vue_type_script_setup_true_lang.js +77 -0
- package/dist/components/BlessCountUp.css +1 -0
- package/dist/components/BlessCountUp.js +6 -0
- package/dist/components/BlessCountUp.vue.d.ts +18 -0
- package/dist/components/BlessCountUp.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/components/BlessCropper.css +1 -0
- package/dist/components/BlessCropper.js +6 -0
- package/dist/components/BlessCropper.vue.d.ts +70 -0
- package/dist/components/BlessCropper.vue_vue_type_script_setup_true_lang.js +220 -0
- package/dist/components/BlessDataTable.vue.d.ts +6 -0
- package/dist/components/BlessDataTable.vue_vue_type_script_setup_true_lang.js +56 -42
- package/dist/components/BlessDataView.vue.d.ts +7 -0
- package/dist/components/BlessDataView.vue_vue_type_script_setup_true_lang.js +38 -31
- package/dist/components/BlessDatePicker.vue.d.ts +3 -0
- package/dist/components/BlessDatePicker.vue_vue_type_script_setup_true_lang.js +46 -45
- package/dist/components/BlessDiff.css +1 -0
- package/dist/components/BlessDiff.js +6 -0
- package/dist/components/BlessDiff.vue.d.ts +22 -0
- package/dist/components/BlessDiff.vue_vue_type_script_setup_true_lang.js +148 -0
- package/dist/components/BlessDock.css +1 -0
- package/dist/components/BlessDock.js +6 -0
- package/dist/components/BlessDock.vue.d.ts +55 -0
- package/dist/components/BlessDock.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/components/BlessEditor.vue.d.ts +2 -0
- package/dist/components/BlessEditor.vue_vue_type_script_setup_true_lang.js +23 -22
- package/dist/components/BlessFileInput.vue.d.ts +2 -0
- package/dist/components/BlessFileInput.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/components/BlessFormula.css +1 -0
- package/dist/components/BlessFormula.js +6 -0
- package/dist/components/BlessFormula.vue.d.ts +53 -0
- package/dist/components/BlessFormula.vue_vue_type_script_setup_true_lang.js +111 -0
- package/dist/components/BlessGantt.css +1 -0
- package/dist/components/BlessGantt.js +6 -0
- package/dist/components/BlessGantt.vue.d.ts +81 -0
- package/dist/components/BlessGantt.vue_vue_type_script_setup_true_lang.js +276 -0
- package/dist/components/BlessGauge.css +1 -0
- package/dist/components/BlessGauge.js +6 -0
- package/dist/components/BlessGauge.vue.d.ts +36 -0
- package/dist/components/BlessGauge.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/components/BlessHeatmapCalendar.css +1 -0
- package/dist/components/BlessHeatmapCalendar.js +6 -0
- package/dist/components/BlessHeatmapCalendar.vue.d.ts +38 -0
- package/dist/components/BlessHeatmapCalendar.vue_vue_type_script_setup_true_lang.js +146 -0
- package/dist/components/BlessHotspots.css +1 -0
- package/dist/components/BlessHotspots.js +6 -0
- package/dist/components/BlessHotspots.vue.d.ts +49 -0
- package/dist/components/BlessHotspots.vue_vue_type_script_setup_true_lang.js +127 -0
- package/dist/components/BlessInfiniteCanvas.css +1 -0
- package/dist/components/BlessInfiniteCanvas.js +6 -0
- package/dist/components/BlessInfiniteCanvas.vue.d.ts +91 -0
- package/dist/components/BlessInfiniteCanvas.vue_vue_type_script_setup_true_lang.js +232 -0
- package/dist/components/BlessInputNumber.vue.d.ts +5 -0
- package/dist/components/BlessInputNumber.vue_vue_type_script_setup_true_lang.js +39 -34
- package/dist/components/BlessKanban.css +1 -0
- package/dist/components/BlessKanban.js +6 -0
- package/dist/components/BlessKanban.vue.d.ts +67 -0
- package/dist/components/BlessKanban.vue_vue_type_script_setup_true_lang.js +195 -0
- package/dist/components/BlessLoadingBar.vue.d.ts +2 -0
- package/dist/components/BlessLoadingBar.vue_vue_type_script_setup_true_lang.js +8 -3
- package/dist/components/BlessLoupe.css +1 -0
- package/dist/components/BlessLoupe.js +6 -0
- package/dist/components/BlessLoupe.vue.d.ts +16 -0
- package/dist/components/BlessLoupe.vue_vue_type_script_setup_true_lang.js +93 -0
- package/dist/components/BlessMarquee.css +1 -0
- package/dist/components/BlessMarquee.js +6 -0
- package/dist/components/BlessMarquee.vue.d.ts +44 -0
- package/dist/components/BlessMarquee.vue_vue_type_script_setup_true_lang.js +69 -0
- package/dist/components/BlessMasonry.css +1 -0
- package/dist/components/BlessMasonry.js +6 -0
- package/dist/components/BlessMasonry.vue.d.ts +33 -0
- package/dist/components/BlessMasonry.vue_vue_type_script_setup_true_lang.js +79 -0
- package/dist/components/BlessMention.css +1 -0
- package/dist/components/BlessMention.js +6 -0
- package/dist/components/BlessMention.vue.d.ts +32 -0
- package/dist/components/BlessMention.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/components/BlessNodeGraph.css +1 -0
- package/dist/components/BlessNodeGraph.js +6 -0
- package/dist/components/BlessNodeGraph.vue.d.ts +110 -0
- package/dist/components/BlessNodeGraph.vue_vue_type_script_setup_true_lang.js +321 -0
- package/dist/components/BlessOnboardingChecklist.css +1 -0
- package/dist/components/BlessOnboardingChecklist.js +6 -0
- package/dist/components/BlessOnboardingChecklist.vue.d.ts +72 -0
- package/dist/components/BlessOnboardingChecklist.vue_vue_type_script_setup_true_lang.js +157 -0
- package/dist/components/BlessOrderList.vue.d.ts +5 -0
- package/dist/components/BlessOrderList.vue_vue_type_script_setup_true_lang.js +62 -56
- package/dist/components/BlessPagination.vue.d.ts +2 -0
- package/dist/components/BlessPagination.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/components/BlessPickList.vue.d.ts +5 -0
- package/dist/components/BlessPickList.vue_vue_type_script_setup_true_lang.js +55 -49
- package/dist/components/BlessRadialMenu.css +1 -0
- package/dist/components/BlessRadialMenu.js +6 -0
- package/dist/components/BlessRadialMenu.vue.d.ts +45 -0
- package/dist/components/BlessRadialMenu.vue_vue_type_script_setup_true_lang.js +146 -0
- package/dist/components/BlessRangeCalendar.css +1 -0
- package/dist/components/BlessRangeCalendar.js +6 -0
- package/dist/components/BlessRangeCalendar.vue.d.ts +51 -0
- package/dist/components/BlessRangeCalendar.vue_vue_type_script_setup_true_lang.js +217 -0
- package/dist/components/BlessScheduler.css +1 -0
- package/dist/components/BlessScheduler.js +6 -0
- package/dist/components/BlessScheduler.vue.d.ts +95 -0
- package/dist/components/BlessScheduler.vue_vue_type_script_setup_true_lang.js +347 -0
- package/dist/components/BlessShortcutRecorder.css +1 -0
- package/dist/components/BlessShortcutRecorder.js +6 -0
- package/dist/components/BlessShortcutRecorder.vue.d.ts +39 -0
- package/dist/components/BlessShortcutRecorder.vue_vue_type_script_setup_true_lang.js +126 -0
- package/dist/components/BlessSignaturePad.vue.d.ts +1 -1
- package/dist/components/BlessSliderCaptcha.css +1 -0
- package/dist/components/BlessSliderCaptcha.js +6 -0
- package/dist/components/BlessSliderCaptcha.vue.d.ts +38 -0
- package/dist/components/BlessSliderCaptcha.vue_vue_type_script_setup_true_lang.js +146 -0
- package/dist/components/BlessSortable.css +1 -0
- package/dist/components/BlessSortable.js +6 -0
- package/dist/components/BlessSortable.vue.d.ts +51 -0
- package/dist/components/BlessSortable.vue_vue_type_script_setup_true_lang.js +135 -0
- package/dist/components/BlessSparkline.css +1 -0
- package/dist/components/BlessSparkline.js +6 -0
- package/dist/components/BlessSparkline.vue.d.ts +28 -0
- package/dist/components/BlessSparkline.vue_vue_type_script_setup_true_lang.js +107 -0
- package/dist/components/BlessSplitView.css +1 -0
- package/dist/components/BlessSplitView.js +6 -0
- package/dist/components/BlessSplitView.vue.d.ts +61 -0
- package/dist/components/BlessSplitView.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/components/BlessSteps.vue.d.ts +2 -0
- package/dist/components/BlessSteps.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/components/BlessSwipeDeck.css +1 -0
- package/dist/components/BlessSwipeDeck.js +6 -0
- package/dist/components/BlessSwipeDeck.vue.d.ts +46 -0
- package/dist/components/BlessSwipeDeck.vue_vue_type_script_setup_true_lang.js +200 -0
- package/dist/components/BlessTimer.css +1 -0
- package/dist/components/BlessTimer.js +6 -0
- package/dist/components/BlessTimer.vue.d.ts +74 -0
- package/dist/components/BlessTimer.vue_vue_type_script_setup_true_lang.js +139 -0
- package/dist/components/BlessTour.vue.d.ts +1 -0
- package/dist/components/BlessTour.vue_vue_type_script_setup_true_lang.js +48 -42
- package/dist/components/BlessTreemap.css +1 -0
- package/dist/components/BlessTreemap.js +6 -0
- package/dist/components/BlessTreemap.vue.d.ts +46 -0
- package/dist/components/BlessTreemap.vue_vue_type_script_setup_true_lang.js +137 -0
- package/dist/components/BlessUploader.vue.d.ts +11 -0
- package/dist/components/BlessUploader.vue_vue_type_script_setup_true_lang.js +80 -69
- package/dist/composables/annotate.d.ts +35 -0
- package/dist/composables/annotate.js +33 -0
- package/dist/composables/canvasView.d.ts +21 -0
- package/dist/composables/canvasView.js +23 -0
- package/dist/composables/confetti.d.ts +32 -0
- package/dist/composables/confetti.js +23 -0
- package/dist/composables/cropBox.d.ts +22 -0
- package/dist/composables/cropBox.js +39 -0
- package/dist/composables/dayBlocks.d.ts +11 -0
- package/dist/composables/dayBlocks.js +26 -0
- package/dist/composables/diffLines.d.ts +10 -0
- package/dist/composables/diffLines.js +55 -0
- package/dist/composables/formula.d.ts +28 -0
- package/dist/composables/formula.js +161 -0
- package/dist/composables/graph.d.ts +19 -0
- package/dist/composables/graph.js +16 -0
- package/dist/composables/radial.d.ts +15 -0
- package/dist/composables/radial.js +22 -0
- package/dist/composables/schedule.d.ts +27 -0
- package/dist/composables/schedule.js +54 -0
- package/dist/composables/shortcut.d.ts +12 -0
- package/dist/composables/shortcut.js +35 -0
- package/dist/composables/treemap.d.ts +23 -0
- package/dist/composables/treemap.js +77 -0
- package/dist/composables/useAutoScroll.d.ts +15 -0
- package/dist/composables/useAutoScroll.js +32 -0
- package/dist/composables/useSortable.d.ts +58 -0
- package/dist/composables/useSortable.js +107 -0
- package/dist/index.d.ts +62 -1
- package/dist/index.js +93 -53
- package/package.json +22 -18
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/composables/cropBox.ts
|
|
2
|
+
var e = .05, t = (e, t, n) => Math.min(Math.max(e, t), n);
|
|
3
|
+
function n(e, t = .9) {
|
|
4
|
+
let n = t, r = t;
|
|
5
|
+
return e > 0 && (e > 1 ? r = n / e : n = r * e), {
|
|
6
|
+
l: (1 - n) / 2,
|
|
7
|
+
t: (1 - r) / 2,
|
|
8
|
+
r: (1 + n) / 2,
|
|
9
|
+
b: (1 + r) / 2
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function r(e, n, r) {
|
|
13
|
+
let i = e.r - e.l, a = e.b - e.t, o = t(e.l + n, 0, 1 - i), s = t(e.t + r, 0, 1 - a);
|
|
14
|
+
return {
|
|
15
|
+
l: o,
|
|
16
|
+
t: s,
|
|
17
|
+
r: o + i,
|
|
18
|
+
b: s + a
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function i(n, r, i, a, o = 0) {
|
|
22
|
+
let s = { ...n };
|
|
23
|
+
if (r.includes("w") && (s.l = t(i, 0, n.r - e)), r.includes("e") && (s.r = t(i, n.l + e, 1)), r.includes("n") && (s.t = t(a, 0, n.b - e)), r.includes("s") && (s.b = t(a, n.t + e, 1)), o > 0 && r.length === 2) {
|
|
24
|
+
let e = s.r - s.l, t = s.b - s.t, n = e / t > o ? t * o : e, i = e / t > o ? t : e / o;
|
|
25
|
+
r.includes("e") ? s.r = s.l + n : s.l = s.r - n, r.includes("s") ? s.b = s.t + i : s.t = s.b - i;
|
|
26
|
+
}
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
29
|
+
function a(n, r) {
|
|
30
|
+
let i = n.r - n.l, a = n.b - n.t, o = t((Math.min(i, a) + r) / Math.min(i, a), e / Math.min(i, a), 1 / Math.max(i, a)), s = i * o, c = a * o, l = t((n.l + n.r) / 2, s / 2, 1 - s / 2), u = t((n.t + n.b) / 2, c / 2, 1 - c / 2);
|
|
31
|
+
return {
|
|
32
|
+
l: l - s / 2,
|
|
33
|
+
t: u - c / 2,
|
|
34
|
+
r: l + s / 2,
|
|
35
|
+
b: u + c / 2
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { e as MIN, n as initialBox, r as moveBox, i as resizeBox, a as scaleBox };
|
|
@@ -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,10 @@
|
|
|
1
|
+
export interface DiffRow {
|
|
2
|
+
type: "same" | "add" | "del";
|
|
3
|
+
/** 1-based line number in the old text (not on `add`) */
|
|
4
|
+
a?: number;
|
|
5
|
+
/** 1-based line number in the new text (not on `del`) */
|
|
6
|
+
b?: number;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
/** Line diff of two texts: common prefix and suffix are peeled off, the middle is an LCS. */
|
|
10
|
+
export declare function diffLines(oldText: string, newText: string): DiffRow[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/composables/diffLines.ts
|
|
2
|
+
var e = (e) => e === "" ? [] : e.replace(/\n$/, "").split("\n"), t = 4e6;
|
|
3
|
+
function n(n, r) {
|
|
4
|
+
let i = e(n), a = e(r), o = 0;
|
|
5
|
+
for (; o < i.length && o < a.length && i[o] === a[o];) o++;
|
|
6
|
+
let s = i.length, c = a.length;
|
|
7
|
+
for (; s > o && c > o && i[s - 1] === a[c - 1];) s--, c--;
|
|
8
|
+
let l = [];
|
|
9
|
+
for (let e = 0; e < o; e++) l.push({
|
|
10
|
+
type: "same",
|
|
11
|
+
a: e + 1,
|
|
12
|
+
b: e + 1,
|
|
13
|
+
text: i[e]
|
|
14
|
+
});
|
|
15
|
+
let u = s - o, d = c - o;
|
|
16
|
+
if (u * d > t || !u || !d) {
|
|
17
|
+
for (let e = o; e < s; e++) l.push({
|
|
18
|
+
type: "del",
|
|
19
|
+
a: e + 1,
|
|
20
|
+
text: i[e]
|
|
21
|
+
});
|
|
22
|
+
for (let e = o; e < c; e++) l.push({
|
|
23
|
+
type: "add",
|
|
24
|
+
b: e + 1,
|
|
25
|
+
text: a[e]
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
let e = d + 1, t = new Uint32Array((u + 1) * e);
|
|
29
|
+
for (let n = u - 1; n >= 0; n--) for (let r = d - 1; r >= 0; r--) t[n * e + r] = i[o + n] === a[o + r] ? t[(n + 1) * e + r + 1] + 1 : Math.max(t[(n + 1) * e + r], t[n * e + r + 1]);
|
|
30
|
+
let n = 0, r = 0;
|
|
31
|
+
for (; n < u || r < d;) n < u && r < d && i[o + n] === a[o + r] ? (l.push({
|
|
32
|
+
type: "same",
|
|
33
|
+
a: o + n + 1,
|
|
34
|
+
b: o + r + 1,
|
|
35
|
+
text: i[o + n]
|
|
36
|
+
}), n++, r++) : r < d && (n === u || t[n * e + r + 1] > t[(n + 1) * e + r]) ? (l.push({
|
|
37
|
+
type: "add",
|
|
38
|
+
b: o + r + 1,
|
|
39
|
+
text: a[o + r]
|
|
40
|
+
}), r++) : (l.push({
|
|
41
|
+
type: "del",
|
|
42
|
+
a: o + n + 1,
|
|
43
|
+
text: i[o + n]
|
|
44
|
+
}), n++);
|
|
45
|
+
}
|
|
46
|
+
for (let e = 0; e < i.length - s; e++) l.push({
|
|
47
|
+
type: "same",
|
|
48
|
+
a: s + e + 1,
|
|
49
|
+
b: c + e + 1,
|
|
50
|
+
text: i[s + e]
|
|
51
|
+
});
|
|
52
|
+
return l;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { n as diffLines };
|
|
@@ -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,15 @@
|
|
|
1
|
+
/** Offset of item `i` of `n` from the centre, laid out clockwise from the top. */
|
|
2
|
+
export declare function polar(i: number, n: number, radius: number): {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Which of `n` sectors a point (dx, dy from the centre) lies in, sector 0 centred on the top;
|
|
8
|
+
* `null` inside the `dead` radius, where nothing is aimed at yet.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sectorAt(dx: number, dy: number, n: number, dead?: number): number | null;
|
|
11
|
+
/** Centre moved so a circle of `half` px stays `pad` inside a `w` x `h` box. */
|
|
12
|
+
export declare function keepInside(x: number, y: number, half: number, w: number, h: number, pad?: number): {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/composables/radial.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let r = e / t * 2 * Math.PI - Math.PI / 2;
|
|
4
|
+
return {
|
|
5
|
+
x: Math.round(Math.cos(r) * n * 100) / 100,
|
|
6
|
+
y: Math.round(Math.sin(r) * n * 100) / 100
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function t(e, t, n, r = 24) {
|
|
10
|
+
if (!n || Math.hypot(e, t) < r) return null;
|
|
11
|
+
let i = (Math.atan2(t, e) + Math.PI / 2 + 2 * Math.PI) % (2 * Math.PI);
|
|
12
|
+
return Math.round(i / (2 * Math.PI) * n) % n;
|
|
13
|
+
}
|
|
14
|
+
function n(e, t, n, r, i, a = 8) {
|
|
15
|
+
let o = n + a;
|
|
16
|
+
return {
|
|
17
|
+
x: Math.min(Math.max(e, o), Math.max(o, r - o)),
|
|
18
|
+
y: Math.min(Math.max(t, o), Math.max(o, i - o))
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { n as keepInside, e as polar, t as sectorAt };
|
|
@@ -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,12 @@
|
|
|
1
|
+
/** is this key just a modifier being held? */
|
|
2
|
+
export declare const isModifierKey: (e: Pick<KeyboardEvent, "key">) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* The combo a key event stands for, e.g. `Ctrl+Shift+K`, modifiers in a fixed order. Letters and
|
|
5
|
+
* digits come from the physical key (`code`), so Shift+1 is `Shift+1`, not `Shift+!`.
|
|
6
|
+
* Returns `null` while only modifiers are down.
|
|
7
|
+
*/
|
|
8
|
+
export declare function shortcutFromEvent(e: Pick<KeyboardEvent, "key" | "code" | "ctrlKey" | "altKey" | "shiftKey" | "metaKey">): string | null;
|
|
9
|
+
/** does `e` press exactly the combo `combo`? */
|
|
10
|
+
export declare const matchShortcut: (combo: string, e: KeyboardEvent) => boolean;
|
|
11
|
+
/** the parts of a combo, for display: `"Ctrl+K"` → `["Ctrl", "K"]` (a literal "+" key survives) */
|
|
12
|
+
export declare const splitShortcut: (combo: string) => string[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/composables/shortcut.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"Ctrl",
|
|
4
|
+
"Alt",
|
|
5
|
+
"Shift",
|
|
6
|
+
"Meta"
|
|
7
|
+
], t = {
|
|
8
|
+
" ": "Space",
|
|
9
|
+
ArrowUp: "↑",
|
|
10
|
+
ArrowDown: "↓",
|
|
11
|
+
ArrowLeft: "←",
|
|
12
|
+
ArrowRight: "→",
|
|
13
|
+
Escape: "Esc",
|
|
14
|
+
Delete: "Del"
|
|
15
|
+
}, n = (e) => [
|
|
16
|
+
"Control",
|
|
17
|
+
"Alt",
|
|
18
|
+
"Shift",
|
|
19
|
+
"Meta",
|
|
20
|
+
"AltGraph",
|
|
21
|
+
"OS"
|
|
22
|
+
].includes(e.key);
|
|
23
|
+
function r(r) {
|
|
24
|
+
if (n(r)) return null;
|
|
25
|
+
let i = /^(?:Key|Digit)(.)$/.exec(r.code), a = i ? i[1] : t[r.key] ?? (r.key.length === 1 ? r.key.toUpperCase() : r.key), o = [
|
|
26
|
+
r.ctrlKey && "Ctrl",
|
|
27
|
+
r.altKey && "Alt",
|
|
28
|
+
r.shiftKey && "Shift",
|
|
29
|
+
r.metaKey && "Meta"
|
|
30
|
+
];
|
|
31
|
+
return [...e.filter((e, t) => o[t]), a].join("+");
|
|
32
|
+
}
|
|
33
|
+
var i = (e, t) => r(t) === e, a = (e) => e.endsWith("++") ? [...e.slice(0, -2).split("+").filter(Boolean), "+"] : e.split("+");
|
|
34
|
+
//#endregion
|
|
35
|
+
export { n as isModifierKey, i as matchShortcut, r as shortcutFromEvent, a as splitShortcut };
|
|
@@ -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
|
+
};
|