vlite3 1.4.32 → 1.4.33
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/components/CategoryManager/CategoryManager.vue2.js +1 -1
- package/components/CategoryManager/CategoryNode.vue.js +30 -30
- package/components/CategoryMenu/CategoryMenu.vue.js +9 -11
- package/components/Chart/GanttChart.vue.d.ts +5 -1
- package/components/Chart/GanttChart.vue.js +2 -2
- package/components/Chart/GanttChart.vue2.js +977 -812
- package/components/Chart/GanttChartConnectorRouting.d.ts +83 -0
- package/components/Chart/GanttChartConnectorRouting.js +405 -0
- package/components/Chart/GanttChartDependencyUtils.js +43 -47
- package/components/Chart/types.d.ts +16 -1
- package/components/ColorPicker/ColorIro.vue2.js +78 -64
- package/components/ColorPicker/ColorPicker.vue.d.ts +5 -0
- package/components/ColorPicker/ColorPicker.vue.js +110 -64
- package/components/ColorPicker/constants.d.ts +2 -0
- package/components/ColorPicker/constants.js +4 -0
- package/components/ColorPicker/index.d.ts +1 -0
- package/components/CommandPalette/CommandPaletteContent.vue2.js +1 -1
- package/components/CommandPalette/{CommandPaletteItem.vue.js → CommandPaletteItem.vue2.js} +1 -1
- package/components/Dropdown/Dropdown.vue.js +100 -97
- package/components/Dropdown/DropdownMenu.vue.js +1 -1
- package/components/Form/{AccordionView.vue2.js → AccordionView.vue.js} +1 -1
- package/components/Form/FormField.vue.js +9 -8
- package/components/Form/index.vue2.js +1 -1
- package/components/Kanban/Kanban.vue.d.ts +16 -2
- package/components/Kanban/Kanban.vue.js +2 -2
- package/components/Kanban/Kanban.vue2.js +150 -86
- package/components/Kanban/types.d.ts +37 -0
- package/components/NavbarCommandPalette.vue.js +1 -1
- package/components/Screen/ScreenFilter.vue.js +1 -1
- package/components/ToastNotification.vue.js +1 -1
- package/components/ToastNotification.vue2.js +3 -3
- package/components/index.d.ts +1 -1
- package/composables/useKeyStroke.d.ts +18 -0
- package/composables/useKeyStroke.js +103 -77
- package/composables/useTheme.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +235 -233
- package/package.json +10 -3
- package/style.css +1 -1
- package/utils/environment.d.ts +29 -0
- package/utils/environment.js +4 -0
- package/utils/functions.js +14 -13
- /package/components/Dropdown/{DropdownMenu.vue2.js → DropdownMenu.vue3.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as G, ref as K, watch as U, openBlock as C, createElementBlock as P, normalizeClass as j, Fragment as q, renderList as w, createBlock as z, withCtx as v, renderSlot as g, mergeProps as h } from "vue";
|
|
2
|
+
import F from "./KanbanBoard.vue.js";
|
|
3
|
+
const T = /* @__PURE__ */ G({
|
|
4
4
|
__name: "Kanban",
|
|
5
5
|
props: {
|
|
6
6
|
columns: {},
|
|
@@ -17,109 +17,173 @@ const U = /* @__PURE__ */ D({
|
|
|
17
17
|
draggableClass: {},
|
|
18
18
|
ghostClass: {},
|
|
19
19
|
class: { default: "h-full w-full" },
|
|
20
|
-
isItemDisabled: {}
|
|
20
|
+
isItemDisabled: {},
|
|
21
|
+
onItemMoved: {}
|
|
21
22
|
},
|
|
22
|
-
emits: ["change", "move", "update:data", "item-
|
|
23
|
-
setup(
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
[() =>
|
|
27
|
-
([e,
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
emits: ["change", "move", "update:data", "item-move-failed"],
|
|
24
|
+
setup(l, { emit: B }) {
|
|
25
|
+
const s = l, c = B, u = K({}), d = K({}), p = K(!1);
|
|
26
|
+
U(
|
|
27
|
+
[() => s.data, () => s.rawData],
|
|
28
|
+
([e, a]) => {
|
|
29
|
+
if (!p.value)
|
|
30
|
+
if (a && Array.isArray(a)) {
|
|
31
|
+
const o = {};
|
|
32
|
+
s.columns.forEach((t) => o[t.id] = []), a.forEach((t) => {
|
|
33
|
+
const i = t[s.groupKey];
|
|
34
|
+
o[i] ? o[i].push({ ...t }) : o[i] = [{ ...t }];
|
|
35
|
+
}), Object.keys(o).forEach((t) => {
|
|
36
|
+
o[t].sort((i, r) => (i[s.positionKey] || 0) - (r[s.positionKey] || 0));
|
|
37
|
+
}), d.value = o;
|
|
38
|
+
} else e && (d.value = { ...e });
|
|
37
39
|
},
|
|
38
40
|
{ immediate: !0, deep: !0 }
|
|
39
41
|
);
|
|
40
|
-
const
|
|
41
|
-
let
|
|
42
|
-
return
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
const A = (e, a) => {
|
|
43
|
+
let o = 0, t = 0;
|
|
44
|
+
return a > 0 && (o = Number(e[a - 1]?.[s.positionKey]) || 0), a < e.length - 1 && (t = Number(e[a + 1]?.[s.positionKey]) || 0), o === 0 && t === 0 ? 1024 : o === 0 ? t / 2 : t === 0 ? o + 1024 : (o + t) / 2;
|
|
45
|
+
}, E = (e) => {
|
|
46
|
+
p.value = !0;
|
|
47
|
+
try {
|
|
48
|
+
const a = s.itemKey, o = { ...d.value }, t = [...o[e.toColumnId] || []];
|
|
49
|
+
let i = t.find((n) => n?.[a] === e.itemId) || e.item;
|
|
50
|
+
const r = t.findIndex((n) => n?.[a] === e.itemId);
|
|
51
|
+
if (r >= 0)
|
|
52
|
+
i = t.splice(r, 1)[0];
|
|
53
|
+
else if (e.fromColumnId === e.toColumnId) {
|
|
54
|
+
const n = t.findIndex((m) => m?.[a] === e.itemId);
|
|
55
|
+
n >= 0 && (i = t.splice(n, 1)[0]);
|
|
56
|
+
}
|
|
57
|
+
if (!i) return;
|
|
58
|
+
if (i[s.positionKey] = e.previousPosition, i[s.groupKey] = e.previousGroupValue, e.fromColumnId === e.toColumnId) {
|
|
59
|
+
const n = Math.min(Math.max(e.oldIndex, 0), t.length);
|
|
60
|
+
t.splice(n, 0, i), o[e.toColumnId] = t;
|
|
61
|
+
} else {
|
|
62
|
+
o[e.toColumnId] = t;
|
|
63
|
+
const n = [...o[e.fromColumnId] || []], m = n.findIndex((f) => f?.[a] === e.itemId);
|
|
64
|
+
m >= 0 && n.splice(m, 1);
|
|
65
|
+
const I = Math.min(Math.max(e.oldIndex, 0), n.length);
|
|
66
|
+
n.splice(I, 0, i), o[e.fromColumnId] = n;
|
|
67
|
+
}
|
|
68
|
+
d.value = o, s.data && c("update:data", { ...o });
|
|
69
|
+
} finally {
|
|
70
|
+
queueMicrotask(() => {
|
|
71
|
+
p.value = !1;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, k = async (e, a, o, t) => {
|
|
75
|
+
const i = d.value[e];
|
|
76
|
+
if (!i) return;
|
|
77
|
+
const r = i[a];
|
|
78
|
+
if (!r) return;
|
|
79
|
+
const n = r[s.itemKey], m = r[s.positionKey], I = r[s.groupKey], f = A(i, a);
|
|
80
|
+
r[s.positionKey] = f, r[s.groupKey] = e;
|
|
81
|
+
const y = () => E({
|
|
82
|
+
itemId: n,
|
|
83
|
+
item: r,
|
|
84
|
+
fromColumnId: o,
|
|
85
|
+
toColumnId: e,
|
|
86
|
+
oldIndex: t,
|
|
87
|
+
previousPosition: m,
|
|
88
|
+
previousGroupValue: I
|
|
89
|
+
}), V = {
|
|
90
|
+
fromColumnId: o,
|
|
91
|
+
oldIndex: t,
|
|
92
|
+
newIndex: a,
|
|
93
|
+
previousPosition: m,
|
|
94
|
+
revert: y
|
|
95
|
+
};
|
|
96
|
+
c("move", {
|
|
97
|
+
itemId: n,
|
|
98
|
+
item: r,
|
|
99
|
+
fromColumnId: o,
|
|
100
|
+
toColumnId: e,
|
|
101
|
+
oldIndex: t,
|
|
102
|
+
newIndex: a
|
|
103
|
+
});
|
|
104
|
+
const D = s.onItemMoved;
|
|
105
|
+
if (D)
|
|
106
|
+
try {
|
|
107
|
+
await D(n, e, f, r, V) === !1 && y();
|
|
108
|
+
} catch (M) {
|
|
109
|
+
y(), c("item-move-failed", {
|
|
110
|
+
itemId: n,
|
|
111
|
+
toColumnId: e,
|
|
112
|
+
fromColumnId: o,
|
|
113
|
+
newPosition: f,
|
|
114
|
+
item: r,
|
|
115
|
+
error: M
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, b = (e) => s.columns.find((a) => a.id === e)?.disabled === !0, $ = (e) => {
|
|
119
|
+
if (c("change", e), e.type === "remove")
|
|
120
|
+
u.value.remove = { columnId: e.columnId, event: e.event };
|
|
53
121
|
else if (e.type === "add")
|
|
54
|
-
|
|
122
|
+
u.value.add = { columnId: e.columnId, event: e.event };
|
|
55
123
|
else if (e.type === "update") {
|
|
56
|
-
if (
|
|
57
|
-
|
|
124
|
+
if (b(e.columnId)) {
|
|
125
|
+
u.value = {};
|
|
58
126
|
return;
|
|
59
127
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
newIndex: e.event.newIndex
|
|
67
|
-
});
|
|
128
|
+
k(
|
|
129
|
+
e.columnId,
|
|
130
|
+
e.event.newIndex,
|
|
131
|
+
e.columnId,
|
|
132
|
+
e.event.oldIndex
|
|
133
|
+
);
|
|
68
134
|
}
|
|
69
|
-
if (
|
|
70
|
-
const { remove:
|
|
71
|
-
if (
|
|
72
|
-
|
|
135
|
+
if (u.value.remove && u.value.add) {
|
|
136
|
+
const { remove: a, add: o } = u.value;
|
|
137
|
+
if (b(a.columnId) || b(o.columnId)) {
|
|
138
|
+
u.value = {};
|
|
73
139
|
return;
|
|
74
140
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
newIndex: t.event.newIndex
|
|
82
|
-
}), r.value = {};
|
|
141
|
+
k(
|
|
142
|
+
o.columnId,
|
|
143
|
+
o.event.newIndex,
|
|
144
|
+
a.columnId,
|
|
145
|
+
a.event.oldIndex
|
|
146
|
+
), u.value = {};
|
|
83
147
|
}
|
|
84
148
|
setTimeout(() => {
|
|
85
|
-
|
|
149
|
+
u.value = {};
|
|
86
150
|
}, 100);
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
return (e,
|
|
91
|
-
class:
|
|
151
|
+
}, L = (e, a) => {
|
|
152
|
+
d.value[e] = a, s.data && c("update:data", { ...s.data, [e]: a });
|
|
153
|
+
}, N = (e) => d.value[e] || [];
|
|
154
|
+
return (e, a) => (C(), P("div", {
|
|
155
|
+
class: j([
|
|
92
156
|
"flex gap-4 scrollbar-thin overflow-x-auto p-1 scrollbar-thin-x scrollable-container",
|
|
93
|
-
|
|
157
|
+
s.class
|
|
94
158
|
])
|
|
95
159
|
}, [
|
|
96
|
-
(
|
|
97
|
-
key:
|
|
98
|
-
column:
|
|
99
|
-
group:
|
|
100
|
-
"item-key":
|
|
101
|
-
"load-data":
|
|
102
|
-
"column-data":
|
|
103
|
-
"board-class":
|
|
104
|
-
"header-class":
|
|
105
|
-
"body-class":
|
|
106
|
-
"draggable-class":
|
|
107
|
-
"ghost-class":
|
|
108
|
-
"is-item-disabled":
|
|
109
|
-
onChange:
|
|
110
|
-
"onUpdate:columnData": (
|
|
160
|
+
(C(!0), P(q, null, w(l.columns, (o) => (C(), z(F, {
|
|
161
|
+
key: o.id,
|
|
162
|
+
column: o,
|
|
163
|
+
group: l.group,
|
|
164
|
+
"item-key": l.itemKey,
|
|
165
|
+
"load-data": l.loadData,
|
|
166
|
+
"column-data": N(o.id),
|
|
167
|
+
"board-class": l.boardClass,
|
|
168
|
+
"header-class": l.headerClass,
|
|
169
|
+
"body-class": l.bodyClass,
|
|
170
|
+
"draggable-class": l.draggableClass,
|
|
171
|
+
"ghost-class": l.ghostClass,
|
|
172
|
+
"is-item-disabled": l.isItemDisabled,
|
|
173
|
+
onChange: $,
|
|
174
|
+
"onUpdate:columnData": (t) => L(o.id, t)
|
|
111
175
|
}, {
|
|
112
|
-
header:
|
|
113
|
-
|
|
176
|
+
header: v((t) => [
|
|
177
|
+
g(e.$slots, "column-header", h({ ref_for: !0 }, t), void 0, !0)
|
|
114
178
|
]),
|
|
115
|
-
"prepend-item":
|
|
116
|
-
|
|
179
|
+
"prepend-item": v((t) => [
|
|
180
|
+
g(e.$slots, "prepend-item", h({ ref_for: !0 }, t), void 0, !0)
|
|
117
181
|
]),
|
|
118
|
-
item:
|
|
119
|
-
|
|
182
|
+
item: v((t) => [
|
|
183
|
+
g(e.$slots, "item", h({ ref_for: !0 }, t), void 0, !0)
|
|
120
184
|
]),
|
|
121
|
-
"append-item":
|
|
122
|
-
|
|
185
|
+
"append-item": v((t) => [
|
|
186
|
+
g(e.$slots, "append-item", h({ ref_for: !0 }, t), void 0, !0)
|
|
123
187
|
]),
|
|
124
188
|
_: 3
|
|
125
189
|
}, 8, ["column", "group", "item-key", "load-data", "column-data", "board-class", "header-class", "body-class", "draggable-class", "ghost-class", "is-item-disabled", "onUpdate:columnData"]))), 128))
|
|
@@ -127,5 +191,5 @@ const U = /* @__PURE__ */ D({
|
|
|
127
191
|
}
|
|
128
192
|
});
|
|
129
193
|
export {
|
|
130
|
-
|
|
194
|
+
T as default
|
|
131
195
|
};
|
|
@@ -38,6 +38,36 @@ export interface KanbanMoveEvent {
|
|
|
38
38
|
oldIndex: number;
|
|
39
39
|
newIndex: number;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Extra context passed as the 5th argument to `onItemMoved` / `@item-moved`.
|
|
43
|
+
* `revert()` restores the card to its pre-drop column and index immediately.
|
|
44
|
+
*/
|
|
45
|
+
export interface KanbanItemMovedMeta {
|
|
46
|
+
fromColumnId: string | number;
|
|
47
|
+
oldIndex: number;
|
|
48
|
+
newIndex: number;
|
|
49
|
+
previousPosition: any;
|
|
50
|
+
/** Imperative escape hatch — usually unnecessary; the board auto-reverts on reject/false. */
|
|
51
|
+
revert: () => void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Async move handler. Return a Promise that settles when the server confirms.
|
|
55
|
+
*
|
|
56
|
+
* - resolve / return `void` | `true` → keep the optimistic placement
|
|
57
|
+
* - return `false` → auto-revert the card to its previous column/index
|
|
58
|
+
* - reject / throw → auto-revert (same as `false`)
|
|
59
|
+
*
|
|
60
|
+
* Bound via `:on-item-moved` or `@item-moved` (both map to this prop).
|
|
61
|
+
*/
|
|
62
|
+
export type KanbanItemMovedHandler = (itemId: string | number, toColumnId: string | number, newPosition: number, item: any, meta: KanbanItemMovedMeta) => void | boolean | Promise<void | boolean>;
|
|
63
|
+
export interface KanbanItemMoveFailedPayload {
|
|
64
|
+
itemId: string | number;
|
|
65
|
+
toColumnId: string | number;
|
|
66
|
+
fromColumnId: string | number;
|
|
67
|
+
newPosition: number;
|
|
68
|
+
item: any;
|
|
69
|
+
error: unknown;
|
|
70
|
+
}
|
|
41
71
|
export interface KanbanProps {
|
|
42
72
|
columns: KanbanColumn[];
|
|
43
73
|
group?: string;
|
|
@@ -61,4 +91,11 @@ export interface KanbanProps {
|
|
|
61
91
|
* Example: :is-item-disabled="(item) => item.locked === true"
|
|
62
92
|
*/
|
|
63
93
|
isItemDisabled?: (item: any) => boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Called after an optimistic drop. Await a mutation here — if it rejects
|
|
96
|
+
* (or returns `false`), the board automatically moves the card back.
|
|
97
|
+
*
|
|
98
|
+
* Use `@item-moved` or `:on-item-moved` — both bind this prop.
|
|
99
|
+
*/
|
|
100
|
+
onItemMoved?: KanbanItemMovedHandler;
|
|
64
101
|
}
|
|
@@ -3,7 +3,7 @@ import L from "./Icon.vue.js";
|
|
|
3
3
|
import v from "./Modal.vue.js";
|
|
4
4
|
import N from "./CommandPalette/CommandPaletteContent.vue.js";
|
|
5
5
|
import { $t as U } from "../utils/i18n.js";
|
|
6
|
-
/* empty css
|
|
6
|
+
/* empty css */
|
|
7
7
|
const V = { class: "block truncate -text-fs-1.5" }, S = { class: "ml-auto inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-mono font-medium border border-border/80 bg-background text-muted-foreground ml-1" }, A = /* @__PURE__ */ x({
|
|
8
8
|
__name: "NavbarCommandPalette",
|
|
9
9
|
props: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./ToastNotification.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import t from "../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const r = /* @__PURE__ */ t(o, [["__scopeId", "data-v-
|
|
4
|
+
const r = /* @__PURE__ */ t(o, [["__scopeId", "data-v-b3a7f1a6"]]);
|
|
5
5
|
export {
|
|
6
6
|
r as default
|
|
7
7
|
};
|
|
@@ -87,7 +87,7 @@ const Z = {
|
|
|
87
87
|
(o(), y(U, { to: "body" }, [
|
|
88
88
|
(o(), i(v, null, _(V, (t) => m("div", {
|
|
89
89
|
key: t,
|
|
90
|
-
class: g(["fixed z-[9999999999]! px-4 flex flex-col gap-2 transition-all duration-300 max-w-full sm:max-w-120", [
|
|
90
|
+
class: g(["fixed z-[9999999999]! pointer-events-none px-4 flex flex-col gap-2 transition-all duration-300 max-w-full sm:max-w-120", [
|
|
91
91
|
N[t],
|
|
92
92
|
t.includes("center") ? "items-center" : t.includes("right") ? "items-end" : "items-start"
|
|
93
93
|
]]),
|
|
@@ -95,7 +95,7 @@ const Z = {
|
|
|
95
95
|
onMouseleave: j
|
|
96
96
|
}, [
|
|
97
97
|
m("div", {
|
|
98
|
-
class: g(["relative w-full transition-all
|
|
98
|
+
class: g(["relative w-full transition-all", [{ "flex-col-reverse": t.includes("top") }]])
|
|
99
99
|
}, [
|
|
100
100
|
w(q, {
|
|
101
101
|
name: d(t).length <= 1 ? "first-toast" : "stack-toast",
|
|
@@ -117,7 +117,7 @@ const Z = {
|
|
|
117
117
|
if (a && a.key === r.id && J(a, u)) return a;
|
|
118
118
|
const f = (o(), i("div", {
|
|
119
119
|
key: r.id,
|
|
120
|
-
class: g(["toast-item col-start-1 h-max row-start-1 mb-1 w-auto border pl-4 pr-6 py-2.5 flex gap-2.5 items-start transition-all duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] transform-gpu", [
|
|
120
|
+
class: g(["toast-item pointer-events-auto col-start-1 h-max row-start-1 mb-1 w-auto border pl-4 pr-6 py-2.5 flex gap-2.5 items-start transition-all duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] transform-gpu", [
|
|
121
121
|
D(r.type),
|
|
122
122
|
r.description || r.action ? "rounded-xl" : "rounded-full"
|
|
123
123
|
]]),
|
package/components/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export * from './Cart';
|
|
|
15
15
|
export { default as CheckBox } from './CheckBox.vue';
|
|
16
16
|
export { Chip } from './Chip';
|
|
17
17
|
export { ChoiceBox } from './ChoiceBox';
|
|
18
|
-
export { ColorPicker } from './ColorPicker';
|
|
18
|
+
export { ColorPicker, COLOR_PICKER_RESET_VALUE } from './ColorPicker';
|
|
19
19
|
export { default as ConfirmationModal } from './ConfirmationModal.vue';
|
|
20
20
|
export { CustomFields } from './Form';
|
|
21
21
|
export { DataList } from './DataList';
|
|
@@ -12,7 +12,25 @@ interface KeyStrokeComposable {
|
|
|
12
12
|
offKeyStroke: (key: string | string[], handler?: KeyStrokeHandler) => void;
|
|
13
13
|
destroy: () => void;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* SSR-safe keyboard composable.
|
|
17
|
+
*
|
|
18
|
+
* Components may call `useKeyStroke()` and register handlers unconditionally
|
|
19
|
+
* during `setup()` — including on the server. Registrations are stored in
|
|
20
|
+
* plain per-composable state; actual DOM listeners are attached only in the
|
|
21
|
+
* browser, after the owning component has mounted (or immediately when used
|
|
22
|
+
* outside a component in a browser context). Default event targets are
|
|
23
|
+
* resolved lazily at attach time, never during registration.
|
|
24
|
+
*/
|
|
15
25
|
export declare const useKeyStroke: () => KeyStrokeComposable;
|
|
26
|
+
/**
|
|
27
|
+
* SSR-safe advanced keyboard-shortcut composable.
|
|
28
|
+
*
|
|
29
|
+
* Combination parsing, meta⇄ctrl alternatives, and matching order are
|
|
30
|
+
* unchanged. Global `window`/`document` listeners are attached only in the
|
|
31
|
+
* browser after mount (or immediately when used outside a component in a
|
|
32
|
+
* browser context) and are always detached on unmount.
|
|
33
|
+
*/
|
|
16
34
|
export declare const useAdvancedKeyStroke: () => {
|
|
17
35
|
onKeyStroke: (keys: string, handler: KeyStrokeHandler) => void;
|
|
18
36
|
offKeyStroke: (keys: string, handler?: KeyStrokeHandler) => void;
|
|
@@ -1,94 +1,120 @@
|
|
|
1
|
-
import { onUnmounted as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { getCurrentInstance as A, onMounted as T, onUnmounted as D, unref as x } from "vue";
|
|
2
|
+
import { isBrowser as S } from "../utils/environment.js";
|
|
3
|
+
const U = () => {
|
|
4
|
+
const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), u = [], m = A();
|
|
5
|
+
let p = S && !m;
|
|
6
|
+
const g = (n) => n ? n.toLowerCase() : "", v = (n) => {
|
|
7
|
+
const s = g(n.key), r = o.get(s);
|
|
8
|
+
r && r.forEach(({ handler: f, options: d }) => {
|
|
9
|
+
d?.preventDefault && n.preventDefault(), d?.stopPropagation && n.stopPropagation(), f(n);
|
|
7
10
|
});
|
|
8
|
-
},
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
|
|
11
|
+
}, k = (n) => S ? x(n) ?? document : null, E = (n) => {
|
|
12
|
+
const s = k(n.target);
|
|
13
|
+
if (!s) return;
|
|
14
|
+
const r = n.capture ?? !1, f = i.get(s);
|
|
15
|
+
f?.has(r) || (s.addEventListener("keydown", v, {
|
|
16
|
+
passive: n.passive ?? !0,
|
|
17
|
+
capture: r
|
|
18
|
+
}), i.set(s, (f ?? /* @__PURE__ */ new Set()).add(r)));
|
|
19
|
+
}, C = (n) => {
|
|
20
|
+
p ? E(n) : u.push(n);
|
|
21
|
+
}, M = () => {
|
|
22
|
+
i.forEach((n, s) => {
|
|
23
|
+
n.forEach((r) => {
|
|
24
|
+
s.removeEventListener("keydown", v, { capture: r });
|
|
25
|
+
});
|
|
26
|
+
}), i.clear(), u.length = 0;
|
|
27
|
+
}, z = (n, s, r = {}) => {
|
|
28
|
+
(Array.isArray(n) ? n : [n]).forEach((d) => {
|
|
29
|
+
const l = g(d);
|
|
30
|
+
o.has(l) || o.set(l, /* @__PURE__ */ new Set());
|
|
31
|
+
const K = o.get(l);
|
|
32
|
+
let b = !1;
|
|
33
|
+
K.forEach((t) => {
|
|
34
|
+
t.handler === s && (b = !0);
|
|
35
|
+
}), b || K.add({ handler: s, options: r });
|
|
36
|
+
}), C(r);
|
|
37
|
+
}, w = (n, s) => {
|
|
38
|
+
(Array.isArray(n) ? n : [n]).forEach((f) => {
|
|
39
|
+
const d = g(f), l = o.get(d);
|
|
40
|
+
l && (s ? l.forEach((K) => {
|
|
41
|
+
K.handler === s && l.delete(K);
|
|
42
|
+
}) : l.clear(), l.size === 0 && o.delete(d));
|
|
43
|
+
}), o.size === 0 && M();
|
|
44
|
+
}, L = () => {
|
|
45
|
+
M(), o.clear();
|
|
26
46
|
};
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
}), {
|
|
30
|
-
onKeyStroke:
|
|
31
|
-
offKeyStroke:
|
|
32
|
-
destroy:
|
|
47
|
+
return m && (T(() => {
|
|
48
|
+
p = !0, u.splice(0).forEach(E);
|
|
49
|
+
}), D(L)), {
|
|
50
|
+
onKeyStroke: z,
|
|
51
|
+
offKeyStroke: w,
|
|
52
|
+
destroy: L
|
|
33
53
|
};
|
|
34
|
-
},
|
|
35
|
-
const o = /* @__PURE__ */ new Set(),
|
|
36
|
-
let
|
|
37
|
-
const
|
|
54
|
+
}, q = () => {
|
|
55
|
+
const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
56
|
+
let u = null, m = !1, p = !1;
|
|
57
|
+
const g = A();
|
|
58
|
+
let v = S && !g;
|
|
59
|
+
const k = (t) => {
|
|
38
60
|
if (!t) return "";
|
|
39
61
|
const e = t.toLowerCase();
|
|
40
62
|
return e === "cmd" || e === "meta" || e === "metakey" ? "meta" : e === "ctrl" || e === "control" || e === "controlkey" ? "ctrl" : e === "alt" || e === "option" || e === "altkey" ? "alt" : e === "shift" || e === "shiftkey" ? "shift" : e;
|
|
41
|
-
},
|
|
42
|
-
const e = [t.join("+")], h = t.includes("meta"),
|
|
63
|
+
}, E = (t) => t.toLowerCase().split("+").map((e) => e.trim()).map(k).sort(), C = (t) => {
|
|
64
|
+
const e = [t.join("+")], h = t.includes("meta"), y = t.includes("ctrl");
|
|
43
65
|
if (h) {
|
|
44
|
-
const
|
|
45
|
-
e.push(
|
|
46
|
-
} else if (
|
|
47
|
-
const
|
|
48
|
-
e.push(
|
|
66
|
+
const a = t.map((c) => c === "meta" ? "ctrl" : c);
|
|
67
|
+
e.push(a.join("+"));
|
|
68
|
+
} else if (y) {
|
|
69
|
+
const a = t.map((c) => c === "ctrl" ? "meta" : c);
|
|
70
|
+
e.push(a.join("+"));
|
|
49
71
|
}
|
|
50
72
|
return e;
|
|
51
|
-
},
|
|
73
|
+
}, M = (t) => {
|
|
52
74
|
const e = [];
|
|
53
75
|
return t.metaKey && e.push("meta"), t.ctrlKey && e.push("ctrl"), t.altKey && e.push("alt"), t.shiftKey && e.push("shift"), e.sort();
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
}, z = (t, e) => t.length !== e.length ? !1 : t.every((h, y) => h === e[y]), w = () => {
|
|
77
|
+
u && (clearTimeout(u), u = null);
|
|
78
|
+
}, L = (t) => {
|
|
79
|
+
const e = k(t.key);
|
|
80
|
+
w();
|
|
81
|
+
const y = [...M(t)];
|
|
82
|
+
["meta", "ctrl", "alt", "shift"].includes(e) || y.push(e), y.sort(), i.forEach((a, c) => {
|
|
83
|
+
const j = E(c);
|
|
84
|
+
z(j, y) && a.forEach((R) => R(t));
|
|
85
|
+
}), u = setTimeout(() => {
|
|
86
|
+
o.clear(), u = null;
|
|
63
87
|
}, 100);
|
|
64
|
-
},
|
|
65
|
-
const e =
|
|
66
|
-
o.delete(e),
|
|
67
|
-
},
|
|
68
|
-
o.clear(),
|
|
69
|
-
},
|
|
70
|
-
document.hidden && (o.clear(),
|
|
88
|
+
}, n = (t) => {
|
|
89
|
+
const e = k(t.key);
|
|
90
|
+
o.delete(e), w();
|
|
91
|
+
}, s = () => {
|
|
92
|
+
o.clear(), w();
|
|
93
|
+
}, r = () => {
|
|
94
|
+
document.hidden && (o.clear(), w());
|
|
95
|
+
}, f = () => {
|
|
96
|
+
!S || m || (m = !0, window.addEventListener("keydown", L, { passive: !1 }), window.addEventListener("keyup", n, { passive: !1 }), window.addEventListener("blur", s, { passive: !0 }), document.addEventListener("visibilitychange", r, { passive: !0 }));
|
|
71
97
|
}, d = () => {
|
|
72
|
-
window.
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}, E = () => {
|
|
87
|
-
m(), r.clear(), o.clear();
|
|
98
|
+
m && (m = !1, window.removeEventListener("keydown", L), window.removeEventListener("keyup", n), window.removeEventListener("blur", s), document.removeEventListener("visibilitychange", r)), w();
|
|
99
|
+
}, l = (t, e) => {
|
|
100
|
+
const h = E(t);
|
|
101
|
+
C(h).forEach((a) => {
|
|
102
|
+
i.has(a) || i.set(a, /* @__PURE__ */ new Set()), i.get(a).add(e);
|
|
103
|
+
}), p = !0, v && f();
|
|
104
|
+
}, K = (t, e) => {
|
|
105
|
+
const h = E(t);
|
|
106
|
+
C(h).forEach((a) => {
|
|
107
|
+
const c = i.get(a);
|
|
108
|
+
c && (e ? c.delete(e) : c.clear(), c.size === 0 && i.delete(a));
|
|
109
|
+
}), i.size === 0 && (p = !1, d());
|
|
110
|
+
}, b = () => {
|
|
111
|
+
d(), i.clear(), o.clear(), p = !1;
|
|
88
112
|
};
|
|
89
|
-
return
|
|
113
|
+
return g && (T(() => {
|
|
114
|
+
v = !0, p && f();
|
|
115
|
+
}), D(b)), { onKeyStroke: l, offKeyStroke: K, destroy: b };
|
|
90
116
|
};
|
|
91
117
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
118
|
+
q as useAdvancedKeyStroke,
|
|
119
|
+
U as useKeyStroke
|
|
94
120
|
};
|
package/composables/useTheme.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ export { default as ThemeToggle } from './components/ThemeToggle.vue';
|
|
|
97
97
|
export { default as GoogleLogin } from './components/GoogleLogin.vue';
|
|
98
98
|
export { default as GoogleMap } from './components/GoogleMap.vue';
|
|
99
99
|
export { default as ColorPicker } from './components/ColorPicker/ColorPicker.vue';
|
|
100
|
+
export { COLOR_PICKER_RESET_VALUE } from './components/ColorPicker/constants';
|
|
100
101
|
export { default as ConfirmationModal } from './components/ConfirmationModal.vue';
|
|
101
102
|
export { default as ToastNotification } from './components/ToastNotification.vue';
|
|
102
103
|
export { default as CommandPaletteContent } from './components/CommandPalette/CommandPaletteContent.vue';
|