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.
- package/CHANGELOG.md +31 -0
- package/README.md +137 -125
- package/dist/blessing-ui.css +38 -2
- 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.vue.d.ts +10 -0
- package/dist/components/BlessCodeBlock.vue_vue_type_script_setup_true_lang.js +39 -33
- 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/BlessCropper.vue.d.ts +16 -0
- package/dist/components/BlessCropper.vue_vue_type_script_setup_true_lang.js +47 -39
- 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/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.vue.d.ts +12 -0
- package/dist/components/BlessGantt.vue_vue_type_script_setup_true_lang.js +74 -68
- 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.vue.d.ts +12 -0
- package/dist/components/BlessKanban.vue_vue_type_script_setup_true_lang.js +127 -97
- 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/BlessMarquee.vue.d.ts +4 -0
- package/dist/components/BlessMarquee.vue_vue_type_script_setup_true_lang.js +32 -27
- 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/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.vue.d.ts +10 -0
- package/dist/components/BlessShortcutRecorder.vue_vue_type_script_setup_true_lang.js +50 -40
- package/dist/components/BlessSignaturePad.vue.d.ts +1 -1
- package/dist/components/BlessSliderCaptcha.vue.d.ts +5 -0
- package/dist/components/BlessSliderCaptcha.vue_vue_type_script_setup_true_lang.js +89 -84
- package/dist/components/BlessSortable.css +1 -1
- package/dist/components/BlessSortable.vue.d.ts +19 -1
- package/dist/components/BlessSortable.vue_vue_type_script_setup_true_lang.js +103 -55
- 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/BlessSteps.vue.d.ts +2 -0
- package/dist/components/BlessSteps.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/components/BlessSwipeDeck.vue.d.ts +1 -1
- package/dist/components/BlessSwipeDeck.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/components/BlessTimer.vue.d.ts +18 -0
- package/dist/components/BlessTimer.vue_vue_type_script_setup_true_lang.js +52 -43
- 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/dayBlocks.d.ts +11 -0
- package/dist/composables/dayBlocks.js +26 -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/schedule.d.ts +27 -0
- package/dist/composables/schedule.js +54 -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 +42 -2
- package/dist/composables/useSortable.js +87 -14
- package/dist/index.d.ts +25 -1
- package/dist/index.js +78 -63
- package/package.json +4 -2
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { evaluate as e, usedNames as t } from "../composables/formula.js";
|
|
2
|
+
import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, defineComponent as s, mergeModels as c, nextTick as l, normalizeClass as u, onMounted as d, openBlock as f, ref as p, renderList as m, toDisplayString as h, unref as g, useId as _, useModel as v, vModelText as y, watch as b, withDirectives as x } from "vue";
|
|
3
|
+
//#region src/components/BlessFormula.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var S = ["for"], C = [
|
|
5
|
+
"id",
|
|
6
|
+
"placeholder",
|
|
7
|
+
"disabled",
|
|
8
|
+
"aria-invalid",
|
|
9
|
+
"aria-describedby"
|
|
10
|
+
], w = ["aria-label"], T = [
|
|
11
|
+
"aria-pressed",
|
|
12
|
+
"title",
|
|
13
|
+
"disabled",
|
|
14
|
+
"onClick"
|
|
15
|
+
], E = ["id"], D = { class: "bless-formula__error" }, O = {
|
|
16
|
+
key: 1,
|
|
17
|
+
class: "bless-formula__value"
|
|
18
|
+
}, k = /*@__PURE__*/ s({
|
|
19
|
+
name: "BlessFormula",
|
|
20
|
+
__name: "BlessFormula",
|
|
21
|
+
props: /*@__PURE__*/ c({
|
|
22
|
+
variables: { default: () => [] },
|
|
23
|
+
functions: {},
|
|
24
|
+
label: { default: "Formula" },
|
|
25
|
+
placeholder: { default: "price * qty" },
|
|
26
|
+
disabled: { type: Boolean },
|
|
27
|
+
locale: {},
|
|
28
|
+
labels: {}
|
|
29
|
+
}, {
|
|
30
|
+
modelValue: { default: "" },
|
|
31
|
+
modelModifiers: {}
|
|
32
|
+
}),
|
|
33
|
+
emits: /*@__PURE__*/ c(["result"], ["update:modelValue"]),
|
|
34
|
+
setup(s, { emit: c }) {
|
|
35
|
+
let k = s, A = v(s, "modelValue"), j = c, M = r(() => ({
|
|
36
|
+
insert: "Insert a value",
|
|
37
|
+
result: (e) => `= ${e}`,
|
|
38
|
+
use: (e) => `Use “${e}”`,
|
|
39
|
+
error: (e) => {
|
|
40
|
+
switch (e.code) {
|
|
41
|
+
case "unexpected": return e.name ? `Unexpected “${e.name}” at position ${e.pos + 1}` : "The formula ends too soon";
|
|
42
|
+
case "unclosed": return "A bracket is not closed";
|
|
43
|
+
case "unknown-variable": return `Unknown value “${e.name}”${e.suggestion ? ` — did you mean “${e.suggestion}”?` : ""}`;
|
|
44
|
+
case "unknown-function": return `Unknown function “${e.name}”${e.suggestion ? ` — did you mean “${e.suggestion}”?` : ""}`;
|
|
45
|
+
case "arity": return `${e.name} needs a value to work on`;
|
|
46
|
+
case "divide-by-zero": return "Division by zero";
|
|
47
|
+
default: return "The result is not a number";
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
...k.labels
|
|
51
|
+
})), N = _(), P = p(), F = r(() => Object.fromEntries(k.variables.map((e) => [e.name, e.value]))), I = r(() => e(A.value, F.value, k.functions)), L = r(() => !I.value.ok && I.value.error.code === "empty"), R = r(() => I.value.ok || L.value ? null : I.value.error), z = r(() => I.value.ok ? new Intl.NumberFormat(k.locale, { maximumFractionDigits: 6 }).format(I.value.value) : ""), B = r(() => new Set(t(A.value))), V = () => j("result", I.value.ok ? I.value.value : null);
|
|
52
|
+
d(V), b(I, V);
|
|
53
|
+
async function H(e) {
|
|
54
|
+
let t = P.value, n = A.value, r = t?.selectionStart ?? n.length, i = t?.selectionEnd ?? n.length, a = /[A-Za-z0-9_.)]/, o = r > 0 && a.test(n[r - 1]) ? " " : "", s = i < n.length && a.test(n[i]) ? " " : "";
|
|
55
|
+
A.value = n.slice(0, r) + o + e + s + n.slice(i);
|
|
56
|
+
let c = r + o.length + e.length;
|
|
57
|
+
await l(), t?.focus(), t?.setSelectionRange(c, c);
|
|
58
|
+
}
|
|
59
|
+
function U(e) {
|
|
60
|
+
A.value = A.value.slice(0, e.pos) + e.suggestion + A.value.slice(e.pos + e.length), l(() => P.value?.focus());
|
|
61
|
+
}
|
|
62
|
+
return (e, t) => (f(), a("div", { class: u(["bless-formula", { "bless-formula--bad": R.value }]) }, [
|
|
63
|
+
o("label", {
|
|
64
|
+
class: "bless-formula__label",
|
|
65
|
+
for: `${g(N)}-in`
|
|
66
|
+
}, h(s.label), 9, S),
|
|
67
|
+
x(o("input", {
|
|
68
|
+
id: `${g(N)}-in`,
|
|
69
|
+
ref_key: "input",
|
|
70
|
+
ref: P,
|
|
71
|
+
"onUpdate:modelValue": t[0] ||= (e) => A.value = e,
|
|
72
|
+
class: "bless-formula__input",
|
|
73
|
+
type: "text",
|
|
74
|
+
spellcheck: "false",
|
|
75
|
+
autocomplete: "off",
|
|
76
|
+
autocapitalize: "off",
|
|
77
|
+
placeholder: s.placeholder,
|
|
78
|
+
disabled: s.disabled,
|
|
79
|
+
"aria-invalid": R.value ? !0 : void 0,
|
|
80
|
+
"aria-describedby": `${g(N)}-out`
|
|
81
|
+
}, null, 8, C), [[y, A.value]]),
|
|
82
|
+
s.variables.length ? (f(), a("div", {
|
|
83
|
+
key: 0,
|
|
84
|
+
class: "bless-formula__vars",
|
|
85
|
+
role: "group",
|
|
86
|
+
"aria-label": M.value.insert
|
|
87
|
+
}, [(f(!0), a(n, null, m(s.variables, (e) => (f(), a("button", {
|
|
88
|
+
key: e.name,
|
|
89
|
+
type: "button",
|
|
90
|
+
class: "bless-formula__chip",
|
|
91
|
+
"aria-pressed": B.value.has(e.name),
|
|
92
|
+
title: `${e.name} = ${e.value}`,
|
|
93
|
+
disabled: s.disabled,
|
|
94
|
+
onClick: (t) => H(e.name)
|
|
95
|
+
}, h(e.label ?? e.name), 9, T))), 128))], 8, w)) : i("", !0),
|
|
96
|
+
o("p", {
|
|
97
|
+
id: `${g(N)}-out`,
|
|
98
|
+
class: "bless-formula__out",
|
|
99
|
+
role: "status",
|
|
100
|
+
"aria-live": "polite"
|
|
101
|
+
}, [R.value ? (f(), a(n, { key: 0 }, [o("span", D, h(M.value.error(R.value)), 1), R.value.suggestion ? (f(), a("button", {
|
|
102
|
+
key: 0,
|
|
103
|
+
type: "button",
|
|
104
|
+
class: "bless-formula__fix",
|
|
105
|
+
onClick: t[1] ||= (e) => U(R.value)
|
|
106
|
+
}, h(M.value.use(R.value.suggestion)), 1)) : i("", !0)], 64)) : I.value.ok ? (f(), a("span", O, h(M.value.result(z.value)), 1)) : i("", !0)], 8, E)
|
|
107
|
+
], 2));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
//#endregion
|
|
111
|
+
export { k as default };
|
|
@@ -24,6 +24,12 @@ declare const __VLS_export: import('vue').DefineComponent<{
|
|
|
24
24
|
/** drag a bar to move it and its ends to resize it; Alt + arrows from the keyboard */
|
|
25
25
|
editable?: boolean;
|
|
26
26
|
label?: string;
|
|
27
|
+
/** the sentence read for a bar and the one announced after an edit; dates arrive formatted */
|
|
28
|
+
labels?: Partial<{
|
|
29
|
+
span: (task: string, from: string, to: string) => string;
|
|
30
|
+
done: (percent: number) => string;
|
|
31
|
+
after: (names: string[]) => string;
|
|
32
|
+
}>;
|
|
27
33
|
} & {
|
|
28
34
|
/** the schedule; with `editable`, moves and resizes come back through here */
|
|
29
35
|
tasks: BlessGanttTask[];
|
|
@@ -49,6 +55,12 @@ declare const __VLS_export: import('vue').DefineComponent<{
|
|
|
49
55
|
/** drag a bar to move it and its ends to resize it; Alt + arrows from the keyboard */
|
|
50
56
|
editable?: boolean;
|
|
51
57
|
label?: string;
|
|
58
|
+
/** the sentence read for a bar and the one announced after an edit; dates arrive formatted */
|
|
59
|
+
labels?: Partial<{
|
|
60
|
+
span: (task: string, from: string, to: string) => string;
|
|
61
|
+
done: (percent: number) => string;
|
|
62
|
+
after: (names: string[]) => string;
|
|
63
|
+
}>;
|
|
52
64
|
} & {
|
|
53
65
|
/** the schedule; with `editable`, moves and resizes come back through here */
|
|
54
66
|
tasks: BlessGanttTask[];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { isoToday as e } from "../composables/date.js";
|
|
2
2
|
import { Fragment as t, computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, mergeModels as s, normalizeClass as c, normalizeStyle as l, openBlock as u, ref as d, renderList as f, toDisplayString as p, useModel as m } from "vue";
|
|
3
3
|
//#region src/components/BlessGantt.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var
|
|
4
|
+
var ee = ["aria-label"], h = { class: "bless-gantt__scroll" }, g = { class: "bless-gantt__labels" }, _ = ["title"], te = {
|
|
5
5
|
class: "bless-gantt__head",
|
|
6
6
|
"aria-hidden": "true"
|
|
7
|
-
},
|
|
7
|
+
}, v = { class: "bless-gantt__months" }, y = {
|
|
8
8
|
key: 0,
|
|
9
9
|
class: "bless-gantt__days"
|
|
10
|
-
},
|
|
10
|
+
}, b = ["width", "height"], x = ["d"], ne = [
|
|
11
11
|
"tabindex",
|
|
12
12
|
"aria-label",
|
|
13
13
|
"aria-pressed",
|
|
@@ -15,7 +15,7 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
15
15
|
"onFocus",
|
|
16
16
|
"onKeydown",
|
|
17
17
|
"onPointerdown"
|
|
18
|
-
],
|
|
18
|
+
], S = ["onPointerdown"], re = ["onPointerdown"], ie = {
|
|
19
19
|
class: "bless-gantt__live",
|
|
20
20
|
"aria-live": "polite"
|
|
21
21
|
}, C = /*@__PURE__*/ o({
|
|
@@ -29,7 +29,8 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
29
29
|
locale: {},
|
|
30
30
|
labelWidth: { default: 160 },
|
|
31
31
|
editable: { type: Boolean },
|
|
32
|
-
label: { default: "Schedule" }
|
|
32
|
+
label: { default: "Schedule" },
|
|
33
|
+
labels: {}
|
|
33
34
|
}, {
|
|
34
35
|
tasks: { required: !0 },
|
|
35
36
|
tasksModifiers: {},
|
|
@@ -38,82 +39,87 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
38
39
|
}),
|
|
39
40
|
emits: /*@__PURE__*/ s(["select", "change"], ["update:tasks", "update:selected"]),
|
|
40
41
|
setup(o, { emit: s }) {
|
|
41
|
-
let C = o, w =
|
|
42
|
+
let C = o, w = n(() => ({
|
|
43
|
+
span: (e, t, n) => `${e}: ${t} to ${n}`,
|
|
44
|
+
done: (e) => `${e}% done`,
|
|
45
|
+
after: (e) => `after ${e.join(" and ")}`,
|
|
46
|
+
...C.labels
|
|
47
|
+
})), T = m(o, "tasks"), E = m(o, "selected"), D = s, O = 864e5, k = (e) => {
|
|
42
48
|
let [t, n, r] = e.split("-").map(Number);
|
|
43
|
-
return Date.UTC(t, (n ?? 1) - 1, r ?? 1) /
|
|
44
|
-
},
|
|
45
|
-
let t =
|
|
49
|
+
return Date.UTC(t, (n ?? 1) - 1, r ?? 1) / O;
|
|
50
|
+
}, A = (e) => /* @__PURE__ */ new Date(e * O), j = (e) => A(e).toISOString().slice(0, 10), M = d(null), N = (e) => {
|
|
51
|
+
let t = k(e.start), n = k(e.end), r = M.value;
|
|
46
52
|
return r && r.id === e.id && (r.mode === "move" ? (t = r.s + r.delta, n = r.e + r.delta) : r.mode === "start" ? t = Math.min(r.s + r.delta, r.e) : n = Math.max(r.e + r.delta, r.s)), {
|
|
47
53
|
s: t,
|
|
48
54
|
e: n
|
|
49
55
|
};
|
|
50
|
-
},
|
|
56
|
+
}, P = n(() => C.from ? k(C.from) : Math.min(...T.value.map((e) => N(e).s), k(e()))), F = n(() => C.to ? k(C.to) : Math.max(...T.value.map((e) => N(e).e), P.value)), I = n(() => Math.max(1, F.value - P.value + 1)), L = n(() => I.value * C.dayWidth), R = (e) => new Intl.DateTimeFormat(C.locale, {
|
|
51
57
|
...e,
|
|
52
58
|
timeZone: "UTC"
|
|
53
|
-
}),
|
|
59
|
+
}), ae = n(() => R({
|
|
54
60
|
month: "long",
|
|
55
61
|
year: "numeric"
|
|
56
|
-
})), z = n(() =>
|
|
62
|
+
})), z = n(() => R({
|
|
57
63
|
month: "short",
|
|
58
64
|
day: "numeric"
|
|
59
|
-
})),
|
|
65
|
+
})), oe = n(() => {
|
|
60
66
|
let e = [];
|
|
61
|
-
for (let t = 0; t <
|
|
62
|
-
let n =
|
|
67
|
+
for (let t = 0; t < I.value; t++) {
|
|
68
|
+
let n = A(P.value + t);
|
|
63
69
|
(!e.length || n.getUTCDate() === 1) && e.push({
|
|
64
|
-
text:
|
|
70
|
+
text: ae.value.format(n),
|
|
65
71
|
left: t * C.dayWidth,
|
|
66
72
|
width: 0
|
|
67
73
|
}), e.at(-1).width += C.dayWidth;
|
|
68
74
|
}
|
|
69
75
|
return e;
|
|
70
|
-
}), B = n(() => C.dayWidth < 12 ? [] : Array.from({ length:
|
|
71
|
-
let n =
|
|
76
|
+
}), B = n(() => C.dayWidth < 12 ? [] : Array.from({ length: I.value }, (e, t) => {
|
|
77
|
+
let n = A(P.value + t), r = n.getUTCDay();
|
|
72
78
|
return {
|
|
73
79
|
n: n.getUTCDate(),
|
|
74
80
|
weekend: r === 0 || r === 6
|
|
75
81
|
};
|
|
76
82
|
})), V = (e) => {
|
|
77
|
-
let t =
|
|
83
|
+
let t = N(e), n = Math.max(t.s, P.value), r = Math.min(t.e, F.value);
|
|
78
84
|
return {
|
|
79
|
-
left: `${(n -
|
|
85
|
+
left: `${(n - P.value) * C.dayWidth}px`,
|
|
80
86
|
width: `${Math.max(1, r - n + 1) * C.dayWidth}px`
|
|
81
87
|
};
|
|
82
88
|
}, H = n(() => {
|
|
83
|
-
let t =
|
|
84
|
-
return t >=
|
|
85
|
-
}), U = (e) => Math.min(100, Math.max(0, e.progress ?? 0)),
|
|
86
|
-
let t =
|
|
87
|
-
return
|
|
89
|
+
let t = k(e());
|
|
90
|
+
return t >= P.value && t <= F.value ? (t - P.value + .5) * C.dayWidth : null;
|
|
91
|
+
}), U = (e) => Math.min(100, Math.max(0, e.progress ?? 0)), se = (e) => {
|
|
92
|
+
let t = N(e), n = (e.after ?? []).map((e) => T.value.find((t) => t.id === e)?.label).filter(Boolean);
|
|
93
|
+
return w.value.span(e.label, z.value.format(A(t.s)), z.value.format(A(t.e))) + (e.progress == null ? "" : `, ${w.value.done(U(e))}`) + (n.length ? `, ${w.value.after(n)}` : "");
|
|
88
94
|
}, W = n(() => {
|
|
89
95
|
let e = [], t = C.rowHeight;
|
|
90
|
-
return
|
|
96
|
+
return T.value.forEach((n, r) => {
|
|
91
97
|
for (let i of n.after ?? []) {
|
|
92
|
-
let a =
|
|
98
|
+
let a = T.value.findIndex((e) => e.id === i);
|
|
93
99
|
if (a < 0) continue;
|
|
94
|
-
let o = V(
|
|
100
|
+
let o = V(T.value[a]), s = V(n), c = parseFloat(o.left) + parseFloat(o.width), l = parseFloat(s.left), u = a * t + t / 2, d = r * t + t / 2, f = u + (d > u ? t / 2 : -t / 2);
|
|
95
101
|
e.push(l >= c + 12 ? `M${c} ${u}H${c + 6}V${d}H${l - 1}` : `M${c} ${u}H${c + 6}V${f}H${l - 8}V${d}H${l - 1}`);
|
|
96
102
|
}
|
|
97
103
|
}), e;
|
|
98
104
|
}), G = d(""), K = !1;
|
|
99
105
|
function q(e, t, n) {
|
|
100
|
-
C.editable && !n.button && (n.stopPropagation(), n.currentTarget.setPointerCapture?.(n.pointerId),
|
|
106
|
+
C.editable && !n.button && (n.stopPropagation(), n.currentTarget.setPointerCapture?.(n.pointerId), M.value = {
|
|
101
107
|
id: e.id,
|
|
102
108
|
mode: t,
|
|
103
109
|
x0: n.clientX,
|
|
104
|
-
s:
|
|
105
|
-
e:
|
|
110
|
+
s: k(e.start),
|
|
111
|
+
e: k(e.end),
|
|
106
112
|
delta: 0
|
|
107
113
|
});
|
|
108
114
|
}
|
|
109
115
|
function J(e) {
|
|
110
|
-
let t =
|
|
116
|
+
let t = M.value;
|
|
111
117
|
t && (t.delta = Math.round((e.clientX - t.x0) / C.dayWidth));
|
|
112
118
|
}
|
|
113
119
|
function Y() {
|
|
114
|
-
let e =
|
|
115
|
-
if (!e || (
|
|
116
|
-
let t =
|
|
120
|
+
let e = M.value;
|
|
121
|
+
if (!e || (M.value = null, K = e.delta !== 0, e.delta === 0)) return;
|
|
122
|
+
let t = T.value.find((t) => t.id === e.id), n = e.mode === "move" ? {
|
|
117
123
|
s: e.s + e.delta,
|
|
118
124
|
e: e.e + e.delta
|
|
119
125
|
} : e.mode === "start" ? {
|
|
@@ -127,33 +133,33 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
127
133
|
}
|
|
128
134
|
function X(e, t, n) {
|
|
129
135
|
let r = {
|
|
130
|
-
start:
|
|
131
|
-
end:
|
|
136
|
+
start: j(t),
|
|
137
|
+
end: j(n)
|
|
132
138
|
};
|
|
133
|
-
|
|
139
|
+
T.value = T.value.map((t) => t.id === e.id ? {
|
|
134
140
|
...t,
|
|
135
141
|
...r
|
|
136
|
-
} : t),
|
|
142
|
+
} : t), D("change", {
|
|
137
143
|
...e,
|
|
138
144
|
...r
|
|
139
|
-
}, r), G.value =
|
|
145
|
+
}, r), G.value = w.value.span(e.label, z.value.format(A(t)), z.value.format(A(n)));
|
|
140
146
|
}
|
|
141
147
|
let Z = d(), Q = d(0);
|
|
142
|
-
function
|
|
143
|
-
let n = t.key === "ArrowDown" ? e + 1 : t.key === "ArrowUp" ? e - 1 : t.key === "Home" ? 0 : t.key === "End" ?
|
|
148
|
+
function ce(e, t) {
|
|
149
|
+
let n = t.key === "ArrowDown" ? e + 1 : t.key === "ArrowUp" ? e - 1 : t.key === "Home" ? 0 : t.key === "End" ? T.value.length - 1 : null;
|
|
144
150
|
if (n != null) {
|
|
145
151
|
t.preventDefault();
|
|
146
|
-
let e = Math.min(
|
|
152
|
+
let e = Math.min(T.value.length - 1, Math.max(0, n));
|
|
147
153
|
Q.value = e, Z.value?.querySelectorAll(".bless-gantt__bar")[e]?.focus();
|
|
148
154
|
} else if (C.editable && t.altKey && (t.key === "ArrowLeft" || t.key === "ArrowRight")) {
|
|
149
155
|
t.preventDefault();
|
|
150
|
-
let n =
|
|
151
|
-
t.shiftKey ? X(n,
|
|
152
|
-
} else (t.key === "Enter" || t.key === " ") && (t.preventDefault(), $(
|
|
156
|
+
let n = T.value[e], r = t.key === "ArrowRight" ? 1 : -1;
|
|
157
|
+
t.shiftKey ? X(n, k(n.start), Math.max(k(n.start), k(n.end) + r)) : X(n, k(n.start) + r, k(n.end) + r);
|
|
158
|
+
} else (t.key === "Enter" || t.key === " ") && (t.preventDefault(), $(T.value[e]));
|
|
153
159
|
}
|
|
154
160
|
function $(e) {
|
|
155
161
|
if (K) return void (K = !1);
|
|
156
|
-
|
|
162
|
+
E.value = E.value === e.id ? null : e.id, D("select", e);
|
|
157
163
|
}
|
|
158
164
|
return (e, n) => (u(), i("div", {
|
|
159
165
|
ref_key: "root",
|
|
@@ -161,35 +167,35 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
161
167
|
class: "bless-gantt",
|
|
162
168
|
role: "group",
|
|
163
169
|
"aria-label": o.label
|
|
164
|
-
}, [a("div",
|
|
170
|
+
}, [a("div", h, [a("div", {
|
|
165
171
|
class: "bless-gantt__body",
|
|
166
172
|
style: l({ "--bless-gantt-label": `${o.labelWidth}px` })
|
|
167
|
-
}, [a("div",
|
|
173
|
+
}, [a("div", g, [n[0] ||= a("div", {
|
|
168
174
|
class: "bless-gantt__corner",
|
|
169
175
|
style: { height: "56px" }
|
|
170
|
-
}, null, -1), (u(!0), i(t, null, f(
|
|
176
|
+
}, null, -1), (u(!0), i(t, null, f(T.value, (e) => (u(), i("div", {
|
|
171
177
|
key: e.id,
|
|
172
178
|
class: "bless-gantt__label",
|
|
173
179
|
style: l({ height: `${o.rowHeight}px` }),
|
|
174
180
|
title: e.label
|
|
175
|
-
}, p(e.label), 13,
|
|
181
|
+
}, p(e.label), 13, _))), 128))]), a("div", {
|
|
176
182
|
class: "bless-gantt__plot",
|
|
177
|
-
style: l({ width: `${
|
|
178
|
-
}, [a("div",
|
|
183
|
+
style: l({ width: `${L.value}px` })
|
|
184
|
+
}, [a("div", te, [a("div", v, [(u(!0), i(t, null, f(oe.value, (e) => (u(), i("span", {
|
|
179
185
|
key: e.left,
|
|
180
186
|
class: "bless-gantt__month",
|
|
181
187
|
style: l({
|
|
182
188
|
left: `${e.left}px`,
|
|
183
189
|
width: `${e.width}px`
|
|
184
190
|
})
|
|
185
|
-
}, p(e.text), 5))), 128))]), B.value.length ? (u(), i("div",
|
|
191
|
+
}, p(e.text), 5))), 128))]), B.value.length ? (u(), i("div", y, [(u(!0), i(t, null, f(B.value, (e, t) => (u(), i("span", {
|
|
186
192
|
key: t,
|
|
187
193
|
class: c(["bless-gantt__day", { "bless-gantt__day--weekend": e.weekend }]),
|
|
188
194
|
style: l({ width: `${o.dayWidth}px` })
|
|
189
195
|
}, p(e.n), 7))), 128))])) : r("", !0)]), a("div", {
|
|
190
196
|
class: "bless-gantt__rows",
|
|
191
197
|
style: l({
|
|
192
|
-
height: `${
|
|
198
|
+
height: `${T.value.length * o.rowHeight}px`,
|
|
193
199
|
backgroundSize: `${o.dayWidth}px 100%`
|
|
194
200
|
})
|
|
195
201
|
}, [
|
|
@@ -202,8 +208,8 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
202
208
|
W.value.length ? (u(), i("svg", {
|
|
203
209
|
key: 1,
|
|
204
210
|
class: "bless-gantt__arrows",
|
|
205
|
-
width:
|
|
206
|
-
height:
|
|
211
|
+
width: L.value,
|
|
212
|
+
height: T.value.length * o.rowHeight,
|
|
207
213
|
"aria-hidden": "true"
|
|
208
214
|
}, [n[1] ||= a("defs", null, [a("marker", {
|
|
209
215
|
id: "bless-gantt-head",
|
|
@@ -220,14 +226,14 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
220
226
|
key: t,
|
|
221
227
|
d: e,
|
|
222
228
|
"marker-end": "url(#bless-gantt-head)"
|
|
223
|
-
}, null, 8,
|
|
224
|
-
(u(!0), i(t, null, f(
|
|
229
|
+
}, null, 8, x))), 128))], 8, b)) : r("", !0),
|
|
230
|
+
(u(!0), i(t, null, f(T.value, (e, n) => (u(), i("button", {
|
|
225
231
|
key: e.id,
|
|
226
232
|
type: "button",
|
|
227
233
|
class: c(["bless-gantt__bar", {
|
|
228
|
-
"bless-gantt__bar--on":
|
|
234
|
+
"bless-gantt__bar--on": E.value === e.id,
|
|
229
235
|
"bless-gantt__bar--edit": o.editable,
|
|
230
|
-
"bless-gantt__bar--drag":
|
|
236
|
+
"bless-gantt__bar--drag": M.value?.id === e.id
|
|
231
237
|
}]),
|
|
232
238
|
style: l({
|
|
233
239
|
...V(e),
|
|
@@ -235,11 +241,11 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
235
241
|
height: `${o.rowHeight - 12}px`
|
|
236
242
|
}),
|
|
237
243
|
tabindex: n === Q.value ? 0 : -1,
|
|
238
|
-
"aria-label":
|
|
239
|
-
"aria-pressed":
|
|
244
|
+
"aria-label": se(e),
|
|
245
|
+
"aria-pressed": E.value === e.id,
|
|
240
246
|
onClick: (t) => (Q.value = n, $(e)),
|
|
241
247
|
onFocus: (e) => Q.value = n,
|
|
242
|
-
onKeydown: (e) =>
|
|
248
|
+
onKeydown: (e) => ce(n, e),
|
|
243
249
|
onPointerdown: (t) => q(e, "move", t),
|
|
244
250
|
onPointermove: J,
|
|
245
251
|
onPointerup: Y,
|
|
@@ -251,19 +257,19 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
|
|
|
251
257
|
onPointermove: J,
|
|
252
258
|
onPointerup: Y,
|
|
253
259
|
onPointercancel: Y
|
|
254
|
-
}, null, 40,
|
|
260
|
+
}, null, 40, S), a("span", {
|
|
255
261
|
class: "bless-gantt__grip bless-gantt__grip--end",
|
|
256
262
|
"aria-hidden": "true",
|
|
257
263
|
onPointerdown: (t) => q(e, "end", t),
|
|
258
264
|
onPointermove: J,
|
|
259
265
|
onPointerup: Y,
|
|
260
266
|
onPointercancel: Y
|
|
261
|
-
}, null, 40,
|
|
267
|
+
}, null, 40, re)], 64)) : r("", !0), e.progress == null ? r("", !0) : (u(), i("span", {
|
|
262
268
|
key: 1,
|
|
263
269
|
class: "bless-gantt__done",
|
|
264
270
|
style: l({ width: `${U(e)}%` })
|
|
265
|
-
}, null, 4))], 46,
|
|
266
|
-
], 4)], 4)], 4)]), a("span",
|
|
271
|
+
}, null, 4))], 46, ne))), 128))
|
|
272
|
+
], 4)], 4)], 4)]), a("span", ie, p(G.value), 1)], 8, ee));
|
|
267
273
|
}
|
|
268
274
|
});
|
|
269
275
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bless-canvas{box-sizing:border-box;background:var(--bless-color-surface);border:var(--bless-border-width) solid var(--bless-color-border);cursor:grab;touch-action:none;-webkit-user-select:none;user-select:none;width:100%;min-height:240px;font-family:var(--bless-font-sans);font-size:var(--bless-text-sm);color:var(--bless-color-text);position:relative;overflow:hidden}.bless-canvas--grid{background-image:radial-gradient(circle, color-mix(in srgb, var(--bless-color-text-muted) 45%, transparent) 1px, transparent 1.5px)}.bless-canvas--pan{cursor:grabbing}.bless-canvas:focus-visible{outline:2px solid var(--bless-color-accent);outline-offset:2px}.bless-canvas__layer{transform-origin:0 0;width:0;height:0;position:absolute;top:0;left:0}.bless-canvas__controls{gap:var(--bless-space-1);cursor:default;display:flex;position:absolute;inset-block-end:var(--bless-space-2);inset-inline-end:var(--bless-space-2)}.bless-canvas__live{clip-path:inset(50%);width:1px;height:1px;position:absolute;overflow:hidden}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { InjectionKey, Ref } from 'vue';
|
|
2
|
+
import { CanvasView } from '../composables/canvasView';
|
|
3
|
+
export type { CanvasView } from '../composables/canvasView';
|
|
4
|
+
/** what a canvas hands to the things placed on it */
|
|
5
|
+
export interface BlessCanvasContext {
|
|
6
|
+
view: Ref<CanvasView>;
|
|
7
|
+
/** a pointer position in the page -> a point in the canvas' own (world) coordinates */
|
|
8
|
+
toWorld: (clientX: number, clientY: number) => {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare const blessCanvasKey: InjectionKey<BlessCanvasContext>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
declare const __VLS_export: __VLS_WithSlots<import('vue').DefineComponent<{
|
|
17
|
+
minZoom?: number;
|
|
18
|
+
maxZoom?: number;
|
|
19
|
+
/** draw a dot grid that moves and scales with the view */
|
|
20
|
+
grid?: boolean;
|
|
21
|
+
/** the + / − / fit buttons in the corner */
|
|
22
|
+
controls?: boolean;
|
|
23
|
+
/** turn the plain mouse wheel into zoom (otherwise it pans, and Ctrl+wheel or a pinch zooms) */
|
|
24
|
+
wheelZoom?: boolean;
|
|
25
|
+
label?: string;
|
|
26
|
+
labels?: Partial<{
|
|
27
|
+
zoomIn: string;
|
|
28
|
+
zoomOut: string;
|
|
29
|
+
reset: string;
|
|
30
|
+
zoom: (percent: number) => string;
|
|
31
|
+
hint: string;
|
|
32
|
+
}>;
|
|
33
|
+
} & {
|
|
34
|
+
view?: CanvasView;
|
|
35
|
+
}, {
|
|
36
|
+
zoomBy: (factor: number, at?: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
}) => void;
|
|
40
|
+
reset: () => void;
|
|
41
|
+
fit: (rect: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
}, pad?: number) => void;
|
|
47
|
+
centerOn: (x: number, y: number) => void;
|
|
48
|
+
toWorld: (cx: number, cy: number) => {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
};
|
|
52
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
53
|
+
"update:view": (value: CanvasView) => any;
|
|
54
|
+
}, string, import('vue').PublicProps, Readonly<{
|
|
55
|
+
minZoom?: number;
|
|
56
|
+
maxZoom?: number;
|
|
57
|
+
/** draw a dot grid that moves and scales with the view */
|
|
58
|
+
grid?: boolean;
|
|
59
|
+
/** the + / − / fit buttons in the corner */
|
|
60
|
+
controls?: boolean;
|
|
61
|
+
/** turn the plain mouse wheel into zoom (otherwise it pans, and Ctrl+wheel or a pinch zooms) */
|
|
62
|
+
wheelZoom?: boolean;
|
|
63
|
+
label?: string;
|
|
64
|
+
labels?: Partial<{
|
|
65
|
+
zoomIn: string;
|
|
66
|
+
zoomOut: string;
|
|
67
|
+
reset: string;
|
|
68
|
+
zoom: (percent: number) => string;
|
|
69
|
+
hint: string;
|
|
70
|
+
}>;
|
|
71
|
+
} & {
|
|
72
|
+
view?: CanvasView;
|
|
73
|
+
}> & Readonly<{
|
|
74
|
+
"onUpdate:view"?: ((value: CanvasView) => any) | undefined;
|
|
75
|
+
}>, {
|
|
76
|
+
label: string;
|
|
77
|
+
grid: boolean;
|
|
78
|
+
controls: boolean;
|
|
79
|
+
minZoom: number;
|
|
80
|
+
maxZoom: number;
|
|
81
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
|
|
82
|
+
default?: (props: {
|
|
83
|
+
view: CanvasView;
|
|
84
|
+
zoom: number;
|
|
85
|
+
}) => any;
|
|
86
|
+
}>;
|
|
87
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
88
|
+
new (): {
|
|
89
|
+
$slots: S;
|
|
90
|
+
};
|
|
91
|
+
};
|