hys-ui 0.3.0 → 0.4.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 +21 -0
- package/README.md +68 -73
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +5 -41
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +146 -2
- package/dist/components/HysButton/HysButton.vue.js +2 -2
- package/dist/components/HysButton/HysButton2.vue.js +227 -60
- package/dist/components/HysButtonGroup/HysButtonGroup.vue.js +7 -0
- package/dist/components/HysButtonGroup/HysButtonGroup2.vue.js +51 -0
- package/dist/components/HysMention/HysMention.vue.js +1 -1
- package/dist/components/HysMention/HysMention2.vue.js +1092 -154
- package/dist/components/HysModal/HysModal.vue.js +3 -3
- package/dist/components/HysModal/HysModal2.vue.js +81 -80
- package/dist/components/HysPagination/HysPagination.vue.js +2 -2
- package/dist/components/HysPagination/HysPagination2.vue.js +243 -180
- package/dist/components/HysSearch/HysSearch.vue.js +5 -82
- package/dist/components/HysSearch/HysSearch2.vue.js +176 -2
- package/dist/components/HysSelect/HysSelect.vue.js +2 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +472 -443
- package/dist/components/HysSplitPane/HysSplitPane.vue.js +315 -58
- package/dist/components/HysSplitPane/HysSplitPane3.vue.js +5 -0
- package/dist/components/HysTable/HysTable.vue.js +2 -2
- package/dist/components/HysTable/HysTable2.vue.js +1418 -1150
- package/dist/components/HysTour/HysTour.vue.js +291 -67
- package/dist/components/HysTour/HysTour3.vue.js +5 -0
- package/dist/composables/buttonGroup.js +12 -0
- package/dist/composables/floatingPosition.js +18 -0
- package/dist/composables/mentionDocument.js +79 -0
- package/dist/composables/mentionEditor.js +58 -0
- package/dist/composables/selectOptions.js +44 -38
- package/dist/composables/splitPaneSizes.js +58 -0
- package/dist/composables/table.js +128 -105
- package/dist/composables/useDialog.js +50 -50
- package/dist/composables/useFloating.js +107 -103
- package/dist/composables/useMentionCaret.js +81 -0
- package/dist/composables/useMentionList.js +81 -0
- package/dist/composables/useMentionModel.js +90 -0
- package/dist/composables/useMentionOptions.js +421 -0
- package/dist/composables/useSplitPaneDrag.js +52 -0
- package/dist/composables/useSplitPaneStorage.js +38 -0
- package/dist/composables/useTable.js +344 -312
- package/dist/composables/useTableSticky.js +79 -0
- package/dist/composables/useTourLayout.js +129 -0
- package/dist/config.js +11 -11
- package/dist/index.js +175 -156
- package/dist/internal/MultiSplitPane.vue.js +305 -0
- package/dist/internal/MultiSplitPane2.vue.js +4 -0
- package/dist/style.css +1 -1
- package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +61 -7
- package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +1 -1
- package/dist/types/components/HysButton/HysButton.vue.d.ts +82 -22
- package/dist/types/components/HysButtonGroup/HysButtonGroup.vue.d.ts +30 -0
- package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
- package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +2 -2
- package/dist/types/components/HysContextMenu/HysMenuPanel.vue.d.ts +2 -2
- package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +2 -2
- package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -1
- package/dist/types/components/HysMention/HysMention.vue.d.ts +91 -40
- package/dist/types/components/HysModal/HysModal.vue.d.ts +1 -1
- package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
- package/dist/types/components/HysPagination/HysPagination.vue.d.ts +55 -4
- package/dist/types/components/HysRating/HysRating.vue.d.ts +1 -1
- package/dist/types/components/HysSearch/HysSearch.vue.d.ts +45 -7
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +6 -1
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +125 -14
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
- package/dist/types/components/HysTable/HysTable.vue.d.ts +1740 -3
- package/dist/types/components/HysTour/HysTour.vue.d.ts +46 -9
- package/dist/types/composables/buttonGroup.d.ts +9 -0
- package/dist/types/composables/floatingPosition.d.ts +14 -0
- package/dist/types/composables/mention.d.ts +284 -0
- package/dist/types/composables/mentionDocument.d.ts +15 -0
- package/dist/types/composables/mentionEditor.d.ts +7 -0
- package/dist/types/composables/modal.d.ts +2 -0
- package/dist/types/composables/selectOptions.d.ts +5 -0
- package/dist/types/composables/splitPaneSizes.d.ts +11 -0
- package/dist/types/composables/table.d.ts +116 -6
- package/dist/types/composables/tour.d.ts +68 -0
- package/dist/types/composables/useFloating.d.ts +1 -1
- package/dist/types/composables/useMentionCaret.d.ts +6 -0
- package/dist/types/composables/useMentionList.d.ts +23 -0
- package/dist/types/composables/useMentionModel.d.ts +14 -0
- package/dist/types/composables/useMentionOptions.d.ts +26 -0
- package/dist/types/composables/useSplitPaneDrag.d.ts +14 -0
- package/dist/types/composables/useSplitPaneStorage.d.ts +4 -0
- package/dist/types/composables/useTable.d.ts +7 -3
- package/dist/types/composables/useTableSticky.d.ts +22 -0
- package/dist/types/composables/useTourLayout.d.ts +33 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/index.d.ts +36 -1
- package/dist/types/internal/MultiSplitPane.vue.d.ts +54 -0
- package/package.json +3 -2
- package/dist/components/HysSplitPane/HysSplitPane2.vue.js +0 -4
- package/dist/components/HysTour/HysTour2.vue.js +0 -4
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
import { useHysControlState as
|
|
3
|
-
import { popupSize as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { inject as T, ref as E, shallowRef as Y, watch as D, onDeactivated as U, onBeforeUnmount as V, computed as X, nextTick as G } from "vue";
|
|
2
|
+
import { useHysControlState as J } from "./formContext.js";
|
|
3
|
+
import { popupSize as Q } from "../motion/popup.js";
|
|
4
|
+
import { positionFloating as Z } from "./floatingPosition.js";
|
|
5
|
+
import { overlayOwnerKey as _, registerOverlay as ee } from "./overlayManager.js";
|
|
6
|
+
function re(v, n, e = {}) {
|
|
7
|
+
const { disabled: k } = J({}), m = T(_, void 0), c = E(!1), W = Y(), p = E(!1), L = E({
|
|
7
8
|
position: "fixed",
|
|
8
9
|
top: "0px",
|
|
9
10
|
left: "0px",
|
|
10
11
|
visibility: "hidden"
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
});
|
|
13
|
+
function A() {
|
|
14
|
+
return typeof e.placement == "function" ? e.placement() : e.placement ?? "bottom-start";
|
|
15
|
+
}
|
|
16
|
+
const C = E(A());
|
|
17
|
+
let $ = 0, w, r, y = 0;
|
|
18
|
+
function F() {
|
|
19
|
+
var R, S, H;
|
|
20
|
+
if (!c.value || !v.value || !n.value) return;
|
|
21
|
+
const t = v.value.getBoundingClientRect();
|
|
22
|
+
if (!t.width && !t.height) {
|
|
23
|
+
u();
|
|
19
24
|
return;
|
|
20
25
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
w += m.scrollLeft - U.left - m.clientLeft, x += m.scrollTop - U.top - m.clientTop;
|
|
26
|
+
const a = Number.isFinite(e.gap) ? e.gap : 8, i = Number.isFinite(e.padding) ? Math.max(0, e.padding) : 10, l = document.documentElement.clientWidth, o = document.documentElement.clientHeight, d = Math.min(t.width, Math.max(0, l - 2 * i)), g = typeof e.matchWidth == "function" ? e.matchWidth() : e.matchWidth, h = (R = e.maxWidth) == null ? void 0 : R.call(e), P = h !== void 0 && (typeof h != "number" || Number.isFinite(h)) ? `min(${typeof h == "number" ? Math.max(0, h) + "px" : h},calc(100vw - ${i * 2}px))` : `calc(100vw - ${i * 2}px)`, b = (S = e.width) == null ? void 0 : S.call(e), x = typeof b == "number" ? Number.isFinite(b) ? Math.max(0, b) + "px" : void 0 : b;
|
|
27
|
+
x !== void 0 ? (n.value.style.width = x, n.value.style.minWidth = "0", n.value.style.maxWidth = P) : g === !0 && (n.value.style.width = `${d}px`, n.value.style.minWidth = "0", n.value.style.maxWidth = `${d}px`), x === void 0 && g === "min" && (n.value.style.width = "max-content", n.value.style.minWidth = `${d}px`, n.value.style.maxWidth = `calc(100vw - ${i * 2}px)`);
|
|
28
|
+
const z = Z(
|
|
29
|
+
t,
|
|
30
|
+
Q(n.value),
|
|
31
|
+
{ width: l, height: o },
|
|
32
|
+
A(),
|
|
33
|
+
a,
|
|
34
|
+
i,
|
|
35
|
+
e.autoAdjustOverflow !== !1
|
|
36
|
+
);
|
|
37
|
+
let { x: O, y: M } = z;
|
|
38
|
+
if (C.value = z.placement, (H = e.onPosition) == null || H.call(e, { anchor: t, ...z }), e.strategy === "absolute") {
|
|
39
|
+
n.value.style.position = "absolute";
|
|
40
|
+
const f = n.value.offsetParent;
|
|
41
|
+
if (f && f !== document.body && f !== document.documentElement) {
|
|
42
|
+
const j = f.getBoundingClientRect();
|
|
43
|
+
O += f.scrollLeft - j.left - f.clientLeft, M += f.scrollTop - j.top - f.clientTop;
|
|
40
44
|
} else
|
|
41
|
-
|
|
45
|
+
O += window.scrollX, M += window.scrollY;
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
...
|
|
45
|
-
position:
|
|
46
|
-
left: `${Math.round(
|
|
47
|
-
top: `${Math.round(
|
|
47
|
+
L.value = {
|
|
48
|
+
...x !== void 0 ? { width: x, minWidth: "0" } : g === !0 ? { width: `${d}px`, minWidth: "0" } : g === "min" ? { width: "max-content", minWidth: `${d}px` } : {},
|
|
49
|
+
position: e.strategy ?? "fixed",
|
|
50
|
+
left: `${Math.round(O)}px`,
|
|
51
|
+
top: `${Math.round(M)}px`,
|
|
48
52
|
visibility: "visible",
|
|
49
53
|
zIndex: "1200",
|
|
50
54
|
maxWidth: P,
|
|
@@ -53,110 +57,110 @@ function de(g, r, t = {}) {
|
|
|
53
57
|
overscrollBehavior: "contain"
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
|
-
function
|
|
57
|
-
cancelAnimationFrame(
|
|
60
|
+
function s() {
|
|
61
|
+
cancelAnimationFrame($), $ = requestAnimationFrame(F);
|
|
58
62
|
}
|
|
59
|
-
function
|
|
60
|
-
var
|
|
61
|
-
!(
|
|
63
|
+
function I(t) {
|
|
64
|
+
var a, i;
|
|
65
|
+
!(r != null && r()) || e.closeOnOutside === !1 || !((a = v.value) != null && a.contains(t.target)) && !((i = n.value) != null && i.contains(t.target)) && u();
|
|
62
66
|
}
|
|
63
|
-
function
|
|
64
|
-
var
|
|
65
|
-
if (!(!
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
else if (
|
|
67
|
+
function q(t) {
|
|
68
|
+
var a, i;
|
|
69
|
+
if (!(!c.value || !(r != null && r()))) {
|
|
70
|
+
if (t.key === "Escape" && e.closeOnEscape !== !1)
|
|
71
|
+
t.preventDefault(), t.stopImmediatePropagation(), u(!0);
|
|
72
|
+
else if (t.key === "Tab" && e.closeOnTab !== !1) {
|
|
69
73
|
const l = document.activeElement;
|
|
70
|
-
if ((
|
|
71
|
-
|
|
74
|
+
if ((a = v.value) != null && a.contains(l)) {
|
|
75
|
+
u();
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
74
|
-
if ((i =
|
|
75
|
-
const
|
|
76
|
-
|
|
78
|
+
if ((i = n.value) != null && i.contains(l)) {
|
|
79
|
+
const o = Array.from(
|
|
80
|
+
n.value.querySelectorAll(
|
|
77
81
|
'a[href],button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),[tabindex]:not([tabindex="-1"])'
|
|
78
82
|
)
|
|
79
83
|
).filter(
|
|
80
84
|
(d) => d.getClientRects().length && !d.closest("[inert]")
|
|
81
85
|
);
|
|
82
|
-
(!
|
|
86
|
+
(!o.length || l === (t.shiftKey ? o[0] : o.at(-1))) && u(!0);
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
|
-
function
|
|
88
|
-
var
|
|
89
|
-
document.removeEventListener("pointerdown",
|
|
91
|
+
function B() {
|
|
92
|
+
var t, a;
|
|
93
|
+
document.removeEventListener("pointerdown", I, !0), document.removeEventListener("keydown", q, !0), window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0), (t = window.visualViewport) == null || t.removeEventListener("resize", s), (a = window.visualViewport) == null || a.removeEventListener("scroll", s), cancelAnimationFrame($), w == null || w(), w = void 0, W.value = void 0, r = void 0;
|
|
90
94
|
}
|
|
91
|
-
function
|
|
95
|
+
function u(t = !1, a = !1) {
|
|
92
96
|
var i, l;
|
|
93
|
-
if (!(!
|
|
94
|
-
|
|
97
|
+
if (!(!a && c.value && ((i = e.requestOpen) == null ? void 0 : i.call(e, !1, t)) === !1) && (y++, !!c.value && (c.value = !1, B(), t && ((l = v.value) != null && l.isConnected)))) {
|
|
98
|
+
p.value = !0;
|
|
95
99
|
try {
|
|
96
|
-
|
|
100
|
+
v.value.focus();
|
|
97
101
|
} finally {
|
|
98
|
-
|
|
102
|
+
p.value = !1;
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
|
-
async function
|
|
103
|
-
var l,
|
|
104
|
-
if (
|
|
105
|
-
if (
|
|
106
|
-
|
|
106
|
+
async function N(t = !1) {
|
|
107
|
+
var l, o, d;
|
|
108
|
+
if (k.value || (m == null ? void 0 : m.value) === !1) return;
|
|
109
|
+
if (c.value) {
|
|
110
|
+
s();
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
|
-
if (!
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
113
|
+
if (!t && ((l = e.requestOpen) == null ? void 0 : l.call(e, !0)) === !1) return;
|
|
114
|
+
const a = ++y;
|
|
115
|
+
if (c.value = !0, L.value = {
|
|
112
116
|
position: "fixed",
|
|
113
117
|
top: "0px",
|
|
114
118
|
left: "0px",
|
|
115
119
|
visibility: "hidden"
|
|
116
|
-
}, await
|
|
117
|
-
const i =
|
|
120
|
+
}, await G(), a !== y || !c.value) return;
|
|
121
|
+
const i = ee(
|
|
118
122
|
"floating",
|
|
119
|
-
() =>
|
|
120
|
-
|
|
123
|
+
() => u(!0),
|
|
124
|
+
e.zIndex
|
|
121
125
|
);
|
|
122
|
-
|
|
126
|
+
W.value = i, w = i.unregister, r = i.isTop, F(), document.addEventListener("pointerdown", I, !0), document.addEventListener("keydown", q, !0), window.addEventListener("resize", s), window.addEventListener("scroll", s, !0), (o = window.visualViewport) == null || o.addEventListener("resize", s), (d = window.visualViewport) == null || d.addEventListener("scroll", s);
|
|
123
127
|
}
|
|
124
|
-
function
|
|
125
|
-
return
|
|
128
|
+
function K() {
|
|
129
|
+
return c.value ? u() : N();
|
|
126
130
|
}
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
+
return D(
|
|
132
|
+
k,
|
|
133
|
+
(t) => {
|
|
134
|
+
t && u(!1, !0);
|
|
131
135
|
},
|
|
132
136
|
{ flush: "sync" }
|
|
133
|
-
),
|
|
134
|
-
() =>
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
+
), U(() => u(!1, !0)), D(
|
|
138
|
+
() => m == null ? void 0 : m.value,
|
|
139
|
+
(t) => {
|
|
140
|
+
t === !1 && u(!1, !0);
|
|
137
141
|
},
|
|
138
142
|
{ flush: "sync" }
|
|
139
|
-
),
|
|
140
|
-
|
|
143
|
+
), V(() => {
|
|
144
|
+
y++, B();
|
|
141
145
|
}), {
|
|
142
|
-
open:
|
|
143
|
-
style:
|
|
144
|
-
var
|
|
146
|
+
open: c,
|
|
147
|
+
style: X(() => {
|
|
148
|
+
var t;
|
|
145
149
|
return {
|
|
146
|
-
...
|
|
147
|
-
zIndex: String(((
|
|
150
|
+
...L.value,
|
|
151
|
+
zIndex: String(((t = W.value) == null ? void 0 : t.zIndex.value) ?? 1200)
|
|
148
152
|
};
|
|
149
153
|
}),
|
|
150
|
-
placement:
|
|
151
|
-
update:
|
|
152
|
-
show:
|
|
153
|
-
close:
|
|
154
|
-
toggle:
|
|
155
|
-
restoringFocus:
|
|
156
|
-
schedule:
|
|
157
|
-
isTop: () => (
|
|
154
|
+
placement: C,
|
|
155
|
+
update: F,
|
|
156
|
+
show: N,
|
|
157
|
+
close: u,
|
|
158
|
+
toggle: K,
|
|
159
|
+
restoringFocus: p,
|
|
160
|
+
schedule: s,
|
|
161
|
+
isTop: () => (r == null ? void 0 : r()) ?? !1
|
|
158
162
|
};
|
|
159
163
|
}
|
|
160
164
|
export {
|
|
161
|
-
|
|
165
|
+
re as useFloating
|
|
162
166
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { computed as x, onBeforeUnmount as y, onDeactivated as C } from "vue";
|
|
2
|
+
function L(r, a, p) {
|
|
3
|
+
let e;
|
|
4
|
+
function d() {
|
|
5
|
+
e == null || e.remove(), e = void 0;
|
|
6
|
+
}
|
|
7
|
+
function f() {
|
|
8
|
+
const t = r.value, o = t.getBoundingClientRect();
|
|
9
|
+
if (!o.width && !o.height) return o;
|
|
10
|
+
const n = getComputedStyle(t);
|
|
11
|
+
e || (e = document.createElement("div"), e.setAttribute("aria-hidden", "true"), document.body.append(e));
|
|
12
|
+
for (const l of [
|
|
13
|
+
"direction",
|
|
14
|
+
"font",
|
|
15
|
+
"font-family",
|
|
16
|
+
"font-size",
|
|
17
|
+
"font-weight",
|
|
18
|
+
"font-style",
|
|
19
|
+
"font-variant",
|
|
20
|
+
"letter-spacing",
|
|
21
|
+
"word-spacing",
|
|
22
|
+
"text-transform",
|
|
23
|
+
"text-indent",
|
|
24
|
+
"text-align",
|
|
25
|
+
"line-height",
|
|
26
|
+
"padding-top",
|
|
27
|
+
"padding-right",
|
|
28
|
+
"padding-bottom",
|
|
29
|
+
"padding-left",
|
|
30
|
+
"border-top-width",
|
|
31
|
+
"border-right-width",
|
|
32
|
+
"border-bottom-width",
|
|
33
|
+
"border-left-width",
|
|
34
|
+
"border-style",
|
|
35
|
+
"box-sizing",
|
|
36
|
+
"tab-size"
|
|
37
|
+
])
|
|
38
|
+
e.style.setProperty(l, n.getPropertyValue(l));
|
|
39
|
+
const s = parseFloat(n.borderLeftWidth) || 0, g = parseFloat(n.borderRightWidth) || 0, u = parseFloat(n.borderTopWidth) || 0, b = t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement && t.wrap === "off";
|
|
40
|
+
Object.assign(e.style, {
|
|
41
|
+
position: "fixed",
|
|
42
|
+
top: "0px",
|
|
43
|
+
left: "-10000px",
|
|
44
|
+
visibility: "hidden",
|
|
45
|
+
pointerEvents: "none",
|
|
46
|
+
height: "auto",
|
|
47
|
+
overflow: "hidden",
|
|
48
|
+
whiteSpace: b ? "pre" : "pre-wrap",
|
|
49
|
+
overflowWrap: "break-word",
|
|
50
|
+
wordBreak: n.wordBreak,
|
|
51
|
+
width: (t.clientWidth ? t.clientWidth + s + g : o.width) + "px"
|
|
52
|
+
});
|
|
53
|
+
const c = p();
|
|
54
|
+
e.textContent = a.value.slice(0, c);
|
|
55
|
+
const i = document.createElement("span");
|
|
56
|
+
i.textContent = a.value.slice(c) || "", e.append(i);
|
|
57
|
+
const w = parseFloat(n.lineHeight) || (parseFloat(n.fontSize) || 14) * 1.6, m = o.left + i.offsetLeft + s - t.scrollLeft, v = o.top + i.offsetTop + u - t.scrollTop;
|
|
58
|
+
return new window.DOMRect(m, v, 1, w);
|
|
59
|
+
}
|
|
60
|
+
const h = x(
|
|
61
|
+
() => r.value ? {
|
|
62
|
+
getBoundingClientRect: f,
|
|
63
|
+
contains: (t) => {
|
|
64
|
+
var o;
|
|
65
|
+
return !!((o = r.value) != null && o.contains(t));
|
|
66
|
+
},
|
|
67
|
+
focus: () => {
|
|
68
|
+
var t;
|
|
69
|
+
return (t = r.value) == null ? void 0 : t.focus();
|
|
70
|
+
},
|
|
71
|
+
get isConnected() {
|
|
72
|
+
var t;
|
|
73
|
+
return !!((t = r.value) != null && t.isConnected);
|
|
74
|
+
}
|
|
75
|
+
} : void 0
|
|
76
|
+
);
|
|
77
|
+
return y(d), C(d), { anchor: h, removeMirror: d };
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
L as useMentionCaret
|
|
81
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { computed as u, ref as m, watch as R } from "vue";
|
|
2
|
+
function F(o, H, s, M) {
|
|
3
|
+
const c = u(() => {
|
|
4
|
+
const e = /* @__PURE__ */ new Map();
|
|
5
|
+
for (const l of H.value) {
|
|
6
|
+
const i = l.option.group ?? "", t = e.get(i);
|
|
7
|
+
t ? t.push(l) : e.set(i, [l]);
|
|
8
|
+
}
|
|
9
|
+
let a = 0;
|
|
10
|
+
return [...e].flatMap(([l, i]) => [
|
|
11
|
+
...l ? [{ key: "group:" + l, group: l }] : [],
|
|
12
|
+
...i.map((t) => ({ key: t.key, entry: t, index: a++ }))
|
|
13
|
+
]);
|
|
14
|
+
}), x = u(
|
|
15
|
+
() => c.value.flatMap(
|
|
16
|
+
(e) => "entry" in e && !e.entry.user.disabled ? [e.entry] : []
|
|
17
|
+
)
|
|
18
|
+
), r = m(0), v = m(240), n = u(
|
|
19
|
+
() => o.itemHeight && Number.isFinite(o.itemHeight) ? Math.max(20, o.itemHeight) : 44
|
|
20
|
+
), f = u(
|
|
21
|
+
() => o.overscan !== void 0 && Number.isFinite(o.overscan) ? Math.max(0, Math.floor(o.overscan)) : 4
|
|
22
|
+
), h = u(
|
|
23
|
+
() => o.virtual ? Math.max(
|
|
24
|
+
0,
|
|
25
|
+
Math.floor(r.value / n.value) - f.value
|
|
26
|
+
) : 0
|
|
27
|
+
), d = u(
|
|
28
|
+
() => o.virtual ? Math.ceil((r.value + v.value) / n.value) + f.value : c.value.length
|
|
29
|
+
), y = u(() => c.value.slice(h.value, d.value)), T = u(
|
|
30
|
+
() => o.virtual ? h.value * n.value : 0
|
|
31
|
+
), b = u(
|
|
32
|
+
() => o.virtual ? Math.max(0, c.value.length - d.value) * n.value : 0
|
|
33
|
+
);
|
|
34
|
+
function p() {
|
|
35
|
+
const e = s.value;
|
|
36
|
+
e && (r.value = e.scrollTop, e.scrollHeight > e.clientHeight && e.scrollHeight - e.scrollTop - e.clientHeight <= n.value && M());
|
|
37
|
+
}
|
|
38
|
+
function w() {
|
|
39
|
+
r.value = 0, s.value && (s.value.scrollTop = 0);
|
|
40
|
+
}
|
|
41
|
+
R(
|
|
42
|
+
s,
|
|
43
|
+
(e, a, l) => {
|
|
44
|
+
if (!e) return;
|
|
45
|
+
const i = () => {
|
|
46
|
+
v.value = e.clientHeight || 240;
|
|
47
|
+
};
|
|
48
|
+
i();
|
|
49
|
+
const t = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(i);
|
|
50
|
+
t == null || t.observe(e), l(() => t == null ? void 0 : t.disconnect());
|
|
51
|
+
},
|
|
52
|
+
{ flush: "post" }
|
|
53
|
+
);
|
|
54
|
+
function k(e) {
|
|
55
|
+
var g;
|
|
56
|
+
const a = s.value;
|
|
57
|
+
if (!a) return;
|
|
58
|
+
if (!o.virtual) {
|
|
59
|
+
(g = a.querySelector('[data-active="true"]')) == null || g.scrollIntoView({ block: "nearest" });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const l = c.value.findIndex((S) => S.key === e);
|
|
63
|
+
if (l < 0) return;
|
|
64
|
+
const i = l * n.value, t = a.clientHeight || v.value;
|
|
65
|
+
i < a.scrollTop ? a.scrollTop = i : i + n.value > a.scrollTop + t && (a.scrollTop = i + n.value - t), r.value = a.scrollTop;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
rows: c,
|
|
69
|
+
enabled: x,
|
|
70
|
+
visibleRows: y,
|
|
71
|
+
topSpacer: T,
|
|
72
|
+
bottomSpacer: b,
|
|
73
|
+
rowHeight: n,
|
|
74
|
+
onScroll: p,
|
|
75
|
+
reset: w,
|
|
76
|
+
ensureVisible: k
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
F as useMentionList
|
|
81
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ref as j, computed as R, shallowRef as A, watch as B, nextTick as C } from "vue";
|
|
2
|
+
import { normalizeMentionEntities as M, rebaseMentionEntities as K } from "./mentionDocument.js";
|
|
3
|
+
function b(e) {
|
|
4
|
+
return JSON.stringify([
|
|
5
|
+
typeof e.id,
|
|
6
|
+
e.id,
|
|
7
|
+
e.type,
|
|
8
|
+
e.prefix,
|
|
9
|
+
e.text
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
function D(e, n) {
|
|
13
|
+
function i(a, u) {
|
|
14
|
+
const d = /* @__PURE__ */ new Map();
|
|
15
|
+
for (const l of u) {
|
|
16
|
+
const r = b(l);
|
|
17
|
+
d.set(r, (d.get(r) ?? 0) + 1);
|
|
18
|
+
}
|
|
19
|
+
return a.filter((l) => {
|
|
20
|
+
const r = b(l), v = d.get(r) ?? 0;
|
|
21
|
+
return v ? (d.set(r, v - 1), !1) : !0;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
added: i(n, e),
|
|
26
|
+
removed: i(e, n)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function T(e, n) {
|
|
30
|
+
return e.length === n.length && e.every(
|
|
31
|
+
(i, a) => i.start === n[a].start && i.end === n[a].end && b(i) === b(n[a]) && i.label === n[a].label && i.value === n[a].value && i.payload === n[a].payload
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function H(e, n, i) {
|
|
35
|
+
var z;
|
|
36
|
+
const a = j(e.defaultValue ?? ""), u = R(() => e.modelValue ?? a.value), d = e.defaultEntities ?? ((z = e.parseEntities) == null ? void 0 : z.call(e, u.value)) ?? [], l = A({
|
|
37
|
+
text: u.value,
|
|
38
|
+
entities: M(u.value, d)
|
|
39
|
+
}), r = R(() => {
|
|
40
|
+
const t = u.value, o = e.entities ?? (l.value.text === t ? l.value.entities : K(l.value, t)), f = M(t, o);
|
|
41
|
+
return e.invalidEntity === "text" && e.validateEntity ? f.filter(e.validateEntity) : f;
|
|
42
|
+
}), v = R(() => ({
|
|
43
|
+
text: u.value,
|
|
44
|
+
entities: r.value
|
|
45
|
+
}));
|
|
46
|
+
let s, V = 0;
|
|
47
|
+
const m = [], w = [];
|
|
48
|
+
B(
|
|
49
|
+
u,
|
|
50
|
+
(t) => {
|
|
51
|
+
var o;
|
|
52
|
+
e.entities !== void 0 || (s == null ? void 0 : s.text) === t || (l.value = {
|
|
53
|
+
text: t,
|
|
54
|
+
entities: M(t, [
|
|
55
|
+
...K(l.value, t),
|
|
56
|
+
...((o = e.parseEntities) == null ? void 0 : o.call(e, t)) ?? []
|
|
57
|
+
])
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
{ flush: "sync" }
|
|
61
|
+
);
|
|
62
|
+
async function q(t, o, f, y = !0, E = !1) {
|
|
63
|
+
const c = v.value, h = M(t.text, t.entities), x = t.text !== c.text;
|
|
64
|
+
if (!x && T(c.entities, h) || !E && e.beforeRemove && D(c.entities, h).removed.some(
|
|
65
|
+
(S) => {
|
|
66
|
+
var J;
|
|
67
|
+
return ((J = e.beforeRemove) == null ? void 0 : J.call(e, S)) === !1;
|
|
68
|
+
}
|
|
69
|
+
) || (s == null ? void 0 : s.text) === t.text && T(s.entities, h))
|
|
70
|
+
return !1;
|
|
71
|
+
const k = { text: t.text, entities: h }, O = ++V;
|
|
72
|
+
if (s = k, x && e.modelValue === void 0 && (a.value = t.text), f == null || f(), n(k, c, x), await C(), O !== V || (s = void 0, u.value !== t.text)) return !1;
|
|
73
|
+
e.entities === void 0 && (l.value = k);
|
|
74
|
+
const g = v.value;
|
|
75
|
+
return !x && T(g.entities, c.entities) ? !1 : (y && (m.push({ ...c, selection: o }), m.length > 100 && m.shift(), w.length = 0), i(g, c), !0);
|
|
76
|
+
}
|
|
77
|
+
async function N(t, o) {
|
|
78
|
+
const f = t === "undo" ? m : w, y = t === "undo" ? w : m, E = f.at(-1);
|
|
79
|
+
if (!E) return;
|
|
80
|
+
const c = v.value;
|
|
81
|
+
if (await q(E, o, void 0, !1))
|
|
82
|
+
return f.pop(), y.push({ ...c, selection: o }), E.selection;
|
|
83
|
+
}
|
|
84
|
+
return { value: u, entities: r, document: v, commit: q, history: N };
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
D as diffMentionEntities,
|
|
88
|
+
b as mentionEntityKey,
|
|
89
|
+
H as useMentionModel
|
|
90
|
+
};
|