vlite3 1.5.16 → 1.5.18
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/CategoryManager2.vue.js +2 -2
- package/components/EditableTitle/EditableTitle.vue.d.ts +194 -1
- package/components/EditableTitle/EditableTitle.vue.js +2 -2
- package/components/EditableTitle/EditableTitle2.vue.js +312 -137
- package/components/RichTextEditor/RichTextEditor.vue.js +4 -4
- package/components/RichTextEditor/RichTextLinkPopover3.vue.js +2 -2
- package/components/RichTextEditor/RichTextToolbar3.vue.js +2 -2
- package/components/Screen/ScreenFilter.vue.js +2 -2
- package/components/Workbook/Sheet.vue.d.ts +29 -2
- package/components/Workbook/Sheet.vue.js +93 -69
- package/components/Workbook/Workbook.vue.d.ts +9 -0
- package/components/Workbook/Workbook.vue.js +1 -1
- package/components/Workbook/Workbook2.vue.js +134 -105
- package/components/Workbook/types.d.ts +24 -0
- package/docs/README.md +1 -0
- package/docs/component-index.md +7 -4
- package/docs/components/editable-title.md +160 -66
- package/docs/components/workbook.md +87 -0
- package/docs/design.md +220 -0
- package/docs-manifest.json +9 -6
- package/package.json +1 -1
- package/style.css +1 -1
- package/types/editable-title.type.d.ts +24 -6
- /package/components/RichTextEditor/{RichTextLinkPopover.vue.js → RichTextLinkPopover2.vue.js} +0 -0
- /package/components/RichTextEditor/{RichTextToolbar.vue.js → RichTextToolbar2.vue.js} +0 -0
|
@@ -1,157 +1,173 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as $, useSlots as R, ref as y, computed as d, openBlock as a, createElementBlock as c, normalizeClass as M, createElementVNode as v, withModifiers as r, createBlock as V, withCtx as h, createVNode as m, createCommentVNode as x, withDirectives as j, withKeys as w, vModelText as z, toDisplayString as A, unref as K, createSlots as N, renderSlot as P, nextTick as U } from "vue";
|
|
2
|
+
import C from "../Icon.vue.js";
|
|
3
|
+
import q from "../Dropdown/Dropdown.vue.js";
|
|
4
4
|
import { $t as l } from "../../utils/i18n.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
/* empty css */
|
|
7
7
|
/* empty css */
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
const
|
|
8
|
+
import F from "../Button.vue.js";
|
|
9
|
+
import G from "../IconPicker.vue.js";
|
|
10
|
+
const H = {
|
|
11
11
|
type: "button",
|
|
12
12
|
class: "flex items-center justify-center rounded hover:bg-accent transition-colors p-0.5 outline-none focus-visible:ring-2 focus-visible:ring-primary/20 mt-1"
|
|
13
|
-
},
|
|
13
|
+
}, J = {
|
|
14
14
|
key: 1,
|
|
15
15
|
class: "flex items-center justify-center p-0.5"
|
|
16
|
-
},
|
|
16
|
+
}, L = { class: "flex-1 min-w-0 pr-1" }, Q = ["onKeydown"], W = {
|
|
17
17
|
key: 1,
|
|
18
18
|
class: "block truncate text-sm font-medium leading-normal"
|
|
19
|
-
},
|
|
19
|
+
}, le = /* @__PURE__ */ $({
|
|
20
20
|
__name: "Sheet",
|
|
21
21
|
props: {
|
|
22
22
|
sheet: {},
|
|
23
23
|
isActive: { type: Boolean },
|
|
24
24
|
isEditing: { type: Boolean, default: !1 },
|
|
25
|
+
canRename: { type: Boolean, default: !0 },
|
|
26
|
+
canDuplicate: { type: Boolean, default: !0 },
|
|
25
27
|
canDelete: { type: Boolean, default: !0 },
|
|
28
|
+
customOptions: { default: () => [] },
|
|
26
29
|
confirmDelete: { type: Boolean, default: !1 },
|
|
27
30
|
confirmDeleteTexts: {},
|
|
28
31
|
allowIconChange: { type: Boolean, default: !0 },
|
|
32
|
+
canChangeIcon: { type: Boolean, default: !0 },
|
|
29
33
|
itemClass: { default: "" },
|
|
30
34
|
activeItemClass: { default: "" },
|
|
31
35
|
inactiveItemClass: { default: "" }
|
|
32
36
|
},
|
|
33
37
|
emits: ["select", "update:title", "update:icon", "edit-start", "edit-end", "duplicate", "delete"],
|
|
34
|
-
setup(i, { emit:
|
|
35
|
-
const e = i,
|
|
38
|
+
setup(i, { emit: D }) {
|
|
39
|
+
const e = i, n = D, B = R(), f = y(null), s = y(e.sheet.title), I = d(
|
|
36
40
|
() => e.sheet.titleI18n ? l(e.sheet.titleI18n) : e.sheet.title
|
|
37
|
-
),
|
|
38
|
-
s.value = e.sheet.title,
|
|
41
|
+
), k = () => {
|
|
42
|
+
e.canRename && (s.value = e.sheet.title, n("edit-start", e.sheet.id), U(() => {
|
|
39
43
|
f.value?.focus(), f.value?.select();
|
|
40
|
-
});
|
|
44
|
+
}));
|
|
41
45
|
};
|
|
42
46
|
let p = !1;
|
|
43
|
-
const
|
|
47
|
+
const b = () => {
|
|
44
48
|
if (!e.isEditing || p) return;
|
|
45
49
|
p = !0;
|
|
46
|
-
const
|
|
47
|
-
|
|
50
|
+
const o = s.value.trim();
|
|
51
|
+
o ? n("update:title", e.sheet.id, o) : s.value = e.sheet.title, n("edit-end", e.sheet.id), setTimeout(() => {
|
|
48
52
|
p = !1;
|
|
49
53
|
}, 100);
|
|
50
|
-
},
|
|
51
|
-
s.value = e.sheet.title,
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
+
}, T = () => {
|
|
55
|
+
s.value = e.sheet.title, n("edit-end", e.sheet.id);
|
|
56
|
+
}, g = d(() => {
|
|
57
|
+
const o = [];
|
|
58
|
+
e.canRename && o.push({
|
|
54
59
|
label: l("vlite.workbook.rename") !== "vlite.workbook.rename" ? l("vlite.workbook.rename") : "Rename",
|
|
55
60
|
value: "rename",
|
|
56
61
|
icon: "lucide:pencil"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
62
|
+
}), e.canDuplicate && o.push({
|
|
59
63
|
label: l("vlite.workbook.duplicate") !== "vlite.workbook.duplicate" ? l("vlite.workbook.duplicate") : "Duplicate",
|
|
60
64
|
value: "duplicate",
|
|
61
65
|
icon: "lucide:copy"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
66
|
+
}), e.canDelete && o.push({
|
|
64
67
|
label: l("vlite.workbook.delete") !== "vlite.workbook.delete" ? l("vlite.workbook.delete") : "Delete",
|
|
65
68
|
value: "delete",
|
|
66
69
|
icon: "lucide:trash-2",
|
|
67
|
-
disabled: !e.canDelete,
|
|
68
70
|
confirmation: e.confirmDelete ? {
|
|
69
71
|
title: e.confirmDeleteTexts?.title,
|
|
70
72
|
description: e.confirmDeleteTexts?.description,
|
|
71
73
|
confirmText: e.confirmDeleteTexts?.confirm,
|
|
72
74
|
cancelText: e.confirmDeleteTexts?.cancel,
|
|
73
|
-
variant: "danger"
|
|
74
|
-
onConfirm: () => {
|
|
75
|
-
e.canDelete && o("delete", e.sheet.id);
|
|
76
|
-
}
|
|
75
|
+
variant: "danger"
|
|
77
76
|
} : void 0
|
|
77
|
+
});
|
|
78
|
+
for (const t of e.customOptions)
|
|
79
|
+
o.push({
|
|
80
|
+
label: t.label,
|
|
81
|
+
value: t.action,
|
|
82
|
+
icon: t.icon,
|
|
83
|
+
disabled: t.disabled,
|
|
84
|
+
data: { workbookCustomOption: t }
|
|
85
|
+
});
|
|
86
|
+
return o;
|
|
87
|
+
}), E = d(
|
|
88
|
+
() => g.value.length > 0 || !!B["sheet-actions"]
|
|
89
|
+
), O = (o) => {
|
|
90
|
+
const t = o.option?.data?.workbookCustomOption;
|
|
91
|
+
if (t) {
|
|
92
|
+
t.onClick(e.sheet);
|
|
93
|
+
return;
|
|
78
94
|
}
|
|
79
|
-
|
|
80
|
-
if (n.value === "rename" && h(), n.value === "duplicate" && o("duplicate", e.sheet.id), n.value === "delete") {
|
|
95
|
+
if (o.value === "rename" && k(), o.value === "duplicate" && e.canDuplicate && n("duplicate", e.sheet.id), o.value === "delete") {
|
|
81
96
|
if (!e.canDelete) return;
|
|
82
|
-
|
|
97
|
+
n("delete", e.sheet.id);
|
|
83
98
|
}
|
|
84
|
-
},
|
|
99
|
+
}, S = d(() => [
|
|
85
100
|
"group relative flex items-center min-w-[120px] max-w-[240px] h-9 px-3 border-r border-border select-none cursor-pointer transition-all duration-200 ease-out",
|
|
86
101
|
e.itemClass,
|
|
87
102
|
e.isActive ? `bg-secondary text-foreground ring-1 ring-border ring-b-0 z-10 ${e.activeItemClass}` : `text-muted-foreground hover:bg-accent/50 ${e.inactiveItemClass}`,
|
|
88
103
|
e.isEditing ? "cursor-text" : ""
|
|
89
104
|
].filter(Boolean).join(" "));
|
|
90
|
-
return (
|
|
91
|
-
class: S
|
|
92
|
-
onClick: t[5] || (t[5] = (
|
|
93
|
-
onDblclick:
|
|
105
|
+
return (o, t) => (a(), c("div", {
|
|
106
|
+
class: M(S.value),
|
|
107
|
+
onClick: t[5] || (t[5] = (u) => n("select", i.sheet.id)),
|
|
108
|
+
onDblclick: k
|
|
94
109
|
}, [
|
|
95
|
-
|
|
96
|
-
onClick: t[1] || (t[1] =
|
|
110
|
+
v("div", {
|
|
111
|
+
onClick: t[1] || (t[1] = r(() => {
|
|
97
112
|
}, ["stop"])),
|
|
98
113
|
class: "mr-2 flex items-center shrink-0"
|
|
99
114
|
}, [
|
|
100
|
-
(i.sheet.icon || i.isEditing) && i.allowIconChange ? (
|
|
115
|
+
(i.sheet.icon || i.isEditing) && i.allowIconChange && i.canChangeIcon ? (a(), V(G, {
|
|
101
116
|
key: 0,
|
|
102
117
|
value: i.sheet.icon || "lucide:file",
|
|
103
118
|
position: "bottom-start",
|
|
104
|
-
onOnSelect: t[0] || (t[0] = (
|
|
119
|
+
onOnSelect: t[0] || (t[0] = (u) => i.canChangeIcon && n("update:icon", i.sheet.id, u))
|
|
105
120
|
}, {
|
|
106
|
-
default:
|
|
107
|
-
|
|
108
|
-
m(
|
|
121
|
+
default: h(() => [
|
|
122
|
+
v("button", H, [
|
|
123
|
+
m(C, {
|
|
109
124
|
icon: i.sheet.icon || "lucide:file",
|
|
110
125
|
class: "w-4 h-4 opacity-70 hover:opacity-100 transition-opacity"
|
|
111
126
|
}, null, 8, ["icon"])
|
|
112
127
|
])
|
|
113
128
|
]),
|
|
114
129
|
_: 1
|
|
115
|
-
}, 8, ["value"])) : i.sheet.icon ? (
|
|
116
|
-
m(
|
|
130
|
+
}, 8, ["value"])) : i.sheet.icon ? (a(), c("div", J, [
|
|
131
|
+
m(C, {
|
|
117
132
|
icon: i.sheet.icon,
|
|
118
133
|
class: "w-4 h-4 opacity-70"
|
|
119
134
|
}, null, 8, ["icon"])
|
|
120
|
-
])) :
|
|
135
|
+
])) : x("", !0)
|
|
121
136
|
]),
|
|
122
|
-
|
|
123
|
-
i.isEditing ? j((
|
|
137
|
+
v("div", L, [
|
|
138
|
+
i.isEditing ? j((a(), c("input", {
|
|
124
139
|
key: 0,
|
|
125
140
|
ref_key: "inputRef",
|
|
126
141
|
ref: f,
|
|
127
|
-
"onUpdate:modelValue": t[2] || (t[2] = (
|
|
142
|
+
"onUpdate:modelValue": t[2] || (t[2] = (u) => s.value = u),
|
|
128
143
|
type: "text",
|
|
129
144
|
class: "w-full bg-transparent border-none outline-none p-0 text-sm font-medium text-foreground placeholder-muted-foreground focus:ring-0",
|
|
130
|
-
onBlur:
|
|
145
|
+
onBlur: b,
|
|
131
146
|
onKeydown: [
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
w(r(b, ["prevent"]), ["enter"]),
|
|
148
|
+
w(r(T, ["prevent"]), ["esc"])
|
|
134
149
|
],
|
|
135
|
-
onClick: t[3] || (t[3] =
|
|
150
|
+
onClick: t[3] || (t[3] = r(() => {
|
|
136
151
|
}, ["stop"]))
|
|
137
|
-
}, null, 40,
|
|
152
|
+
}, null, 40, Q)), [
|
|
138
153
|
[z, s.value]
|
|
139
|
-
]) : (
|
|
154
|
+
]) : (a(), c("span", W, A(I.value), 1))
|
|
140
155
|
]),
|
|
141
|
-
|
|
156
|
+
E.value ? (a(), c("div", {
|
|
157
|
+
key: 0,
|
|
142
158
|
class: "opacity-0 group-hover:opacity-100 transition-opacity ml-auto pl-1 -mr-2 flex items-center",
|
|
143
|
-
onClick: t[4] || (t[4] =
|
|
159
|
+
onClick: t[4] || (t[4] = r(() => {
|
|
144
160
|
}, ["stop"]))
|
|
145
161
|
}, [
|
|
146
|
-
m(
|
|
147
|
-
options:
|
|
162
|
+
m(K(q), {
|
|
163
|
+
options: g.value,
|
|
148
164
|
position: "bottom-end",
|
|
149
165
|
width: "140px",
|
|
150
166
|
teleport: !0,
|
|
151
|
-
onOnSelect:
|
|
152
|
-
}, {
|
|
153
|
-
trigger:
|
|
154
|
-
m(
|
|
167
|
+
onOnSelect: O
|
|
168
|
+
}, N({
|
|
169
|
+
trigger: h(() => [
|
|
170
|
+
m(F, {
|
|
155
171
|
icon: "lucide:more-vertical",
|
|
156
172
|
asIcon: "",
|
|
157
173
|
size: "xs",
|
|
@@ -159,12 +175,20 @@ const P = {
|
|
|
159
175
|
variant: "ghost"
|
|
160
176
|
})
|
|
161
177
|
]),
|
|
162
|
-
_:
|
|
163
|
-
},
|
|
164
|
-
|
|
178
|
+
_: 2
|
|
179
|
+
}, [
|
|
180
|
+
o.$slots["sheet-actions"] ? {
|
|
181
|
+
name: "menu",
|
|
182
|
+
fn: h(() => [
|
|
183
|
+
P(o.$slots, "sheet-actions", { sheet: i.sheet })
|
|
184
|
+
]),
|
|
185
|
+
key: "0"
|
|
186
|
+
} : void 0
|
|
187
|
+
]), 1032, ["options"])
|
|
188
|
+
])) : x("", !0)
|
|
165
189
|
], 34));
|
|
166
190
|
}
|
|
167
191
|
});
|
|
168
192
|
export {
|
|
169
|
-
|
|
193
|
+
le as default
|
|
170
194
|
};
|
|
@@ -3,6 +3,9 @@ declare function __VLS_template(): {
|
|
|
3
3
|
attrs: Partial<{}>;
|
|
4
4
|
slots: {
|
|
5
5
|
'left-addons'?(_: {}): any;
|
|
6
|
+
'sheet-actions'?(_: {
|
|
7
|
+
sheet: WorkbookSheet;
|
|
8
|
+
}): any;
|
|
6
9
|
'right-addons'?(_: {}): any;
|
|
7
10
|
default?(_: {}): any;
|
|
8
11
|
};
|
|
@@ -37,10 +40,16 @@ declare const __VLS_component: import('vue').DefineComponent<WorkbookProps, {},
|
|
|
37
40
|
modelValue: string;
|
|
38
41
|
editable: boolean;
|
|
39
42
|
confirmDelete: boolean;
|
|
43
|
+
canRename: boolean;
|
|
44
|
+
canDuplicate: boolean;
|
|
45
|
+
canDelete: boolean;
|
|
46
|
+
canChangeIcon: boolean;
|
|
47
|
+
customOptions: import('./types').WorkbookCustomOption[];
|
|
40
48
|
allowIconChange: boolean;
|
|
41
49
|
activeItemClass: string;
|
|
42
50
|
inactiveItemClass: string;
|
|
43
51
|
sheets: WorkbookSheet[];
|
|
52
|
+
autoDelete: boolean;
|
|
44
53
|
addable: boolean;
|
|
45
54
|
addButtonPosition: AddButtonPosition;
|
|
46
55
|
maxSheets: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./Workbook2.vue.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import r from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const p = /* @__PURE__ */ r(o, [["__scopeId", "data-v-
|
|
4
|
+
const p = /* @__PURE__ */ r(o, [["__scopeId", "data-v-539da423"]]);
|
|
5
5
|
export {
|
|
6
6
|
p as default
|
|
7
7
|
};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useScroll as
|
|
3
|
-
import { VueDraggable as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as Y, ref as B, shallowRef as j, watch as F, openBlock as d, createElementBlock as c, createElementVNode as f, renderSlot as g, createCommentVNode as x, createVNode as b, unref as S, withCtx as V, Fragment as q, renderList as G, isMemoSame as H, createBlock as J, createSlots as K, normalizeClass as Q } from "vue";
|
|
2
|
+
import { useScroll as X } from "@vueuse/core";
|
|
3
|
+
import { VueDraggable as Z } from "vue-draggable-plus";
|
|
4
|
+
import _ from "./Sheet.vue.js";
|
|
5
|
+
import $ from "./WorkbookAddButton.vue.js";
|
|
6
|
+
const ee = { class: "flex flex-col w-full font-sans" }, te = { class: "flex items-end w-full border-b px-1" }, le = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "flex items-center"
|
|
9
|
-
},
|
|
9
|
+
}, ae = { class: "flex items-center mb-0.5 z-20 sticky right-0 ml-auto box-decoration-clone" }, ne = { key: 0 }, oe = { key: 1 }, se = { class: "flex-1 relative bg-white w-full" }, fe = /* @__PURE__ */ Y({
|
|
10
10
|
__name: "Workbook",
|
|
11
11
|
props: {
|
|
12
12
|
modelValue: { default: "" },
|
|
13
13
|
sheets: { default: () => [] },
|
|
14
14
|
editable: { type: Boolean, default: !0 },
|
|
15
|
+
canRename: { type: Boolean, default: !0 },
|
|
16
|
+
canDuplicate: { type: Boolean, default: !0 },
|
|
17
|
+
canDelete: { type: Boolean, default: !0 },
|
|
18
|
+
canChangeIcon: { type: Boolean, default: !0 },
|
|
19
|
+
customOptions: { default: () => [] },
|
|
20
|
+
autoDelete: { type: Boolean, default: !0 },
|
|
15
21
|
addable: { type: Boolean, default: !0 },
|
|
16
22
|
draggable: { type: Boolean, default: !0 },
|
|
17
23
|
addButtonPosition: { default: "fixed-right" },
|
|
@@ -26,147 +32,170 @@ const O = { class: "flex flex-col w-full font-sans" }, Q = { class: "flex items-
|
|
|
26
32
|
allowIconChange: { type: Boolean, default: !0 }
|
|
27
33
|
},
|
|
28
34
|
emits: ["update:modelValue", "update:sheets", "change", "add", "delete", "duplicate", "edit-start", "edit-end"],
|
|
29
|
-
setup(
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
() => [...
|
|
35
|
+
setup(n, { emit: E }) {
|
|
36
|
+
const a = n, s = E, m = B(null), u = B(null), { arrivedState: U } = X(m), i = j([...a.sheets]);
|
|
37
|
+
F(
|
|
38
|
+
() => [...a.sheets],
|
|
33
39
|
(e) => {
|
|
34
|
-
let
|
|
35
|
-
if (e.length !==
|
|
36
|
-
|
|
40
|
+
let l = !1;
|
|
41
|
+
if (e.length !== i.value.length)
|
|
42
|
+
l = !0;
|
|
37
43
|
else
|
|
38
44
|
for (let t = 0; t < e.length; t++)
|
|
39
|
-
if (e[t] !==
|
|
40
|
-
|
|
45
|
+
if (e[t] !== i.value[t] || e[t].id !== i.value[t].id) {
|
|
46
|
+
l = !0;
|
|
41
47
|
break;
|
|
42
48
|
}
|
|
43
|
-
|
|
49
|
+
l && (i.value = e);
|
|
44
50
|
}
|
|
45
51
|
);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
},
|
|
52
|
+
const A = (e) => {
|
|
53
|
+
i.value = e, s("update:sheets", e);
|
|
54
|
+
}, R = (e) => {
|
|
49
55
|
s("update:modelValue", e), s("change", e);
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
const t =
|
|
54
|
-
if (t !== -1) {
|
|
55
|
-
const
|
|
56
|
-
|
|
56
|
+
}, k = () => {
|
|
57
|
+
a.sheets.length >= a.maxSheets || s("add");
|
|
58
|
+
}, T = (e, l) => {
|
|
59
|
+
const t = a.sheets.findIndex((o) => o.id === e);
|
|
60
|
+
if (t !== -1 && v(a.sheets[t])) {
|
|
61
|
+
const o = [...a.sheets];
|
|
62
|
+
o[t] = { ...o[t], title: l }, s("update:sheets", o);
|
|
57
63
|
}
|
|
58
|
-
},
|
|
59
|
-
const t =
|
|
60
|
-
if (t !== -1) {
|
|
61
|
-
const
|
|
62
|
-
|
|
64
|
+
}, z = (e, l) => {
|
|
65
|
+
const t = a.sheets.findIndex((o) => o.id === e);
|
|
66
|
+
if (t !== -1 && C(a.sheets[t])) {
|
|
67
|
+
const o = [...a.sheets];
|
|
68
|
+
o[t] = { ...o[t], icon: l }, s("update:sheets", o);
|
|
63
69
|
}
|
|
64
|
-
}, $ = (e) => {
|
|
65
|
-
u.value = e, s("edit-start", e);
|
|
66
|
-
}, T = (e) => {
|
|
67
|
-
u.value = null, s("edit-end", e);
|
|
68
|
-
}, z = (e) => {
|
|
69
|
-
s("duplicate", e);
|
|
70
70
|
}, L = (e) => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
const l = a.sheets.find((t) => t.id === e);
|
|
72
|
+
!l || !v(l) || (u.value = e, s("edit-start", e));
|
|
73
|
+
}, N = (e) => {
|
|
74
|
+
u.value = null, s("edit-end", e);
|
|
75
|
+
}, O = (e) => {
|
|
76
|
+
const l = a.sheets.find((t) => t.id === e);
|
|
77
|
+
!l || !y(l) || s("duplicate", e);
|
|
78
|
+
}, P = (e) => {
|
|
79
|
+
const l = a.sheets.findIndex((o) => o.id === e);
|
|
80
|
+
if (l === -1 || !p(a.sheets[l])) return;
|
|
81
|
+
if (!a.autoDelete) {
|
|
82
|
+
s("delete", e);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const t = [...a.sheets];
|
|
86
|
+
if (t.splice(l, 1), s("update:sheets", t), s("delete", e), a.modelValue === e) {
|
|
87
|
+
let o = "";
|
|
76
88
|
if (t.length > 0) {
|
|
77
|
-
const
|
|
78
|
-
|
|
89
|
+
const w = Math.min(l, t.length - 1);
|
|
90
|
+
o = t[w].id;
|
|
79
91
|
}
|
|
80
|
-
s("update:modelValue",
|
|
92
|
+
s("update:modelValue", o), s("change", o);
|
|
81
93
|
}
|
|
82
|
-
},
|
|
94
|
+
}, M = (e) => {
|
|
83
95
|
m.value && e.deltaY !== 0 && (m.value.scrollLeft += e.deltaY, e.preventDefault());
|
|
84
|
-
},
|
|
85
|
-
return (e,
|
|
86
|
-
f("div",
|
|
87
|
-
e.$slots["left-addons"] ? (
|
|
88
|
-
|
|
89
|
-
])) :
|
|
96
|
+
}, h = (e, l) => a.editable ? (e[l] ?? a[l] ?? !0) === !0 : !1, v = (e) => h(e, "canRename"), y = (e) => h(e, "canDuplicate"), C = (e) => h(e, "canChangeIcon") && a.allowIconChange, p = (e) => a.sheets.length > 1 && h(e, "canDelete");
|
|
97
|
+
return (e, l) => (d(), c("div", ee, [
|
|
98
|
+
f("div", te, [
|
|
99
|
+
e.$slots["left-addons"] ? (d(), c("div", le, [
|
|
100
|
+
g(e.$slots, "left-addons", {}, void 0, !0)
|
|
101
|
+
])) : x("", !0),
|
|
90
102
|
f("div", {
|
|
91
103
|
ref_key: "scrollContainer",
|
|
92
104
|
ref: m,
|
|
93
105
|
class: "flex-1 flex items-end overflow-x-auto scrollbar-none overscroll-contain sheet-container",
|
|
94
106
|
style: { "scrollbar-width": "none", "-ms-overflow-style": "none" },
|
|
95
|
-
onWheel:
|
|
107
|
+
onWheel: M
|
|
96
108
|
}, [
|
|
97
|
-
|
|
98
|
-
"model-value":
|
|
99
|
-
"onUpdate:modelValue":
|
|
100
|
-
disabled: !
|
|
109
|
+
b(S(Z), {
|
|
110
|
+
"model-value": i.value,
|
|
111
|
+
"onUpdate:modelValue": A,
|
|
112
|
+
disabled: !a.draggable || !!u.value,
|
|
101
113
|
animation: 150,
|
|
102
114
|
class: "flex items-end min-w-max"
|
|
103
115
|
}, {
|
|
104
|
-
default:
|
|
105
|
-
(
|
|
106
|
-
const
|
|
116
|
+
default: V(() => [
|
|
117
|
+
(d(!0), c(q, null, G(i.value, (t, o, w, r) => {
|
|
118
|
+
const D = [
|
|
107
119
|
t.id,
|
|
108
120
|
t.title,
|
|
109
121
|
t.icon,
|
|
110
|
-
|
|
122
|
+
n.modelValue === t.id,
|
|
111
123
|
u.value === t.id,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
v(t),
|
|
125
|
+
y(t),
|
|
126
|
+
p(t),
|
|
127
|
+
C(t),
|
|
128
|
+
n.customOptions,
|
|
129
|
+
e.$slots["sheet-actions"],
|
|
130
|
+
n.confirmDelete,
|
|
131
|
+
n.allowIconChange,
|
|
132
|
+
n.itemClass,
|
|
133
|
+
n.activeItemClass,
|
|
134
|
+
n.inactiveItemClass
|
|
118
135
|
];
|
|
119
|
-
if (r && r.el && r.key === t.id &&
|
|
120
|
-
const
|
|
136
|
+
if (r && r.el && r.key === t.id && H(r, D)) return r;
|
|
137
|
+
const I = (d(), J(_, {
|
|
121
138
|
key: t.id,
|
|
122
139
|
sheet: t,
|
|
123
|
-
"is-active":
|
|
140
|
+
"is-active": n.modelValue === t.id,
|
|
124
141
|
"is-editing": u.value === t.id,
|
|
125
|
-
"can-
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
"can-rename": v(t),
|
|
143
|
+
"can-duplicate": y(t),
|
|
144
|
+
"can-delete": p(t),
|
|
145
|
+
"custom-options": n.customOptions,
|
|
146
|
+
"confirm-delete": n.confirmDelete,
|
|
147
|
+
"confirm-delete-texts": n.confirmDeleteTexts,
|
|
148
|
+
"allow-icon-change": n.allowIconChange,
|
|
149
|
+
"can-change-icon": C(t),
|
|
150
|
+
"item-class": n.itemClass,
|
|
151
|
+
"active-item-class": n.activeItemClass,
|
|
152
|
+
"inactive-item-class": n.inactiveItemClass,
|
|
153
|
+
onSelect: R,
|
|
154
|
+
"onUpdate:title": T,
|
|
155
|
+
"onUpdate:icon": z,
|
|
156
|
+
onEditStart: L,
|
|
157
|
+
onEditEnd: N,
|
|
158
|
+
onDuplicate: O,
|
|
159
|
+
onDelete: P
|
|
160
|
+
}, K({ _: 2 }, [
|
|
161
|
+
e.$slots["sheet-actions"] ? {
|
|
162
|
+
name: "sheet-actions",
|
|
163
|
+
fn: V(({ sheet: W }) => [
|
|
164
|
+
g(e.$slots, "sheet-actions", { sheet: W }, void 0, !0)
|
|
165
|
+
]),
|
|
166
|
+
key: "0"
|
|
167
|
+
} : void 0
|
|
168
|
+
]), 1032, ["sheet", "is-active", "is-editing", "can-rename", "can-duplicate", "can-delete", "custom-options", "confirm-delete", "confirm-delete-texts", "allow-icon-change", "can-change-icon", "item-class", "active-item-class", "inactive-item-class"]));
|
|
169
|
+
return I.memo = D, I;
|
|
170
|
+
}, l, 0), 128))
|
|
142
171
|
]),
|
|
143
|
-
_:
|
|
172
|
+
_: 3
|
|
144
173
|
}, 8, ["model-value", "disabled"]),
|
|
145
|
-
|
|
174
|
+
n.addable && n.addButtonPosition === "attached" ? (d(), c("div", {
|
|
146
175
|
key: 0,
|
|
147
|
-
class:
|
|
148
|
-
"shadow-[-18px_0_24px_-4px_#fff] dark:shadow-[-18px_0_24px_-4px_#000]": !
|
|
176
|
+
class: Q(["shrink-0 sticky right-0 z-10 bg-body flex items-center justify-center h-full", {
|
|
177
|
+
"shadow-[-18px_0_24px_-4px_#fff] dark:shadow-[-18px_0_24px_-4px_#000]": !S(U).right
|
|
149
178
|
}])
|
|
150
179
|
}, [
|
|
151
|
-
|
|
152
|
-
], 2)) :
|
|
153
|
-
|
|
180
|
+
b($, { onClick: k })
|
|
181
|
+
], 2)) : x("", !0),
|
|
182
|
+
l[2] || (l[2] = f("div", { class: "w-1 shrink-0" }, null, -1))
|
|
154
183
|
], 544),
|
|
155
|
-
f("div",
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
])) :
|
|
159
|
-
e.$slots["right-addons"] ? (
|
|
160
|
-
|
|
161
|
-
])) :
|
|
184
|
+
f("div", ae, [
|
|
185
|
+
n.addable && n.addButtonPosition === "fixed-right" ? (d(), c("div", ne, [
|
|
186
|
+
b($, { onClick: k })
|
|
187
|
+
])) : x("", !0),
|
|
188
|
+
e.$slots["right-addons"] ? (d(), c("div", oe, [
|
|
189
|
+
g(e.$slots, "right-addons", {}, void 0, !0)
|
|
190
|
+
])) : x("", !0)
|
|
162
191
|
])
|
|
163
192
|
]),
|
|
164
|
-
f("div",
|
|
165
|
-
|
|
193
|
+
f("div", se, [
|
|
194
|
+
g(e.$slots, "default", {}, void 0, !0)
|
|
166
195
|
])
|
|
167
196
|
]));
|
|
168
197
|
}
|
|
169
198
|
});
|
|
170
199
|
export {
|
|
171
|
-
|
|
200
|
+
fe as default
|
|
172
201
|
};
|
|
@@ -6,14 +6,38 @@ export interface WorkbookSheet {
|
|
|
6
6
|
content?: string;
|
|
7
7
|
closable?: boolean;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
/** Per-sheet overrides. Omit to inherit the Workbook-level action policy. */
|
|
10
|
+
canRename?: boolean;
|
|
11
|
+
canDuplicate?: boolean;
|
|
12
|
+
canDelete?: boolean;
|
|
13
|
+
canChangeIcon?: boolean;
|
|
9
14
|
[key: string]: any;
|
|
10
15
|
}
|
|
16
|
+
/** A consumer-owned context-menu action rendered alongside Workbook's built-in sheet actions. */
|
|
17
|
+
export interface WorkbookCustomOption {
|
|
18
|
+
label: string;
|
|
19
|
+
icon?: string;
|
|
20
|
+
/** Stable identifier for this action within the consumer's domain. */
|
|
21
|
+
action: string | number;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Invoked with the sheet whose context menu triggered the action. */
|
|
24
|
+
onClick: (sheet: WorkbookSheet) => void | Promise<void>;
|
|
25
|
+
}
|
|
11
26
|
export type SheetPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
12
27
|
export type AddButtonPosition = 'attached' | 'fixed-right';
|
|
13
28
|
export interface WorkbookProps {
|
|
14
29
|
modelValue?: string;
|
|
15
30
|
sheets?: WorkbookSheet[];
|
|
16
31
|
editable?: boolean;
|
|
32
|
+
/** Global defaults; individual sheets may override each action. */
|
|
33
|
+
canRename?: boolean;
|
|
34
|
+
canDuplicate?: boolean;
|
|
35
|
+
canDelete?: boolean;
|
|
36
|
+
canChangeIcon?: boolean;
|
|
37
|
+
/** Additional context-menu actions appended after the built-in sheet actions. */
|
|
38
|
+
customOptions?: WorkbookCustomOption[];
|
|
39
|
+
/** When false, emit `delete` without removing the sheet locally. */
|
|
40
|
+
autoDelete?: boolean;
|
|
17
41
|
addable?: boolean;
|
|
18
42
|
draggable?: boolean;
|
|
19
43
|
addButtonPosition?: AddButtonPosition;
|