vlite3 1.5.17 → 1.5.19

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.
@@ -1,9 +1,13 @@
1
- import { WorkbookSheet } from './types';
1
+ import { WorkbookCustomOption, WorkbookSheet } from './types';
2
2
  interface Props {
3
3
  sheet: WorkbookSheet;
4
4
  isActive: boolean;
5
5
  isEditing?: boolean;
6
+ canRename?: boolean;
7
+ canDuplicate?: boolean;
6
8
  canDelete?: boolean;
9
+ showContextMenu?: boolean;
10
+ customOptions?: WorkbookCustomOption[];
7
11
  confirmDelete?: boolean;
8
12
  confirmDeleteTexts?: {
9
13
  title?: string;
@@ -12,11 +16,27 @@ interface Props {
12
16
  cancel?: string;
13
17
  };
14
18
  allowIconChange?: boolean;
19
+ canChangeIcon?: boolean;
20
+ /** Width of the sheet context-menu dropdown. */
21
+ menuWidth?: string;
15
22
  itemClass?: string;
16
23
  activeItemClass?: string;
17
24
  inactiveItemClass?: string;
18
25
  }
19
- declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
26
+ declare function __VLS_template(): {
27
+ attrs: Partial<{}>;
28
+ slots: {
29
+ 'sheet-actions'?(_: {
30
+ sheet: WorkbookSheet;
31
+ }): any;
32
+ };
33
+ refs: {
34
+ inputRef: HTMLInputElement;
35
+ };
36
+ rootEl: HTMLDivElement;
37
+ };
38
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
39
+ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
20
40
  select: (id: string) => any;
21
41
  delete: (id: string) => any;
22
42
  "update:title": (id: string, newTitle: string) => any;
@@ -36,11 +56,23 @@ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, imp
36
56
  itemClass: string;
37
57
  isEditing: boolean;
38
58
  confirmDelete: boolean;
59
+ canRename: boolean;
60
+ canDuplicate: boolean;
39
61
  canDelete: boolean;
62
+ canChangeIcon: boolean;
63
+ showContextMenu: boolean;
64
+ customOptions: WorkbookCustomOption[];
40
65
  allowIconChange: boolean;
66
+ menuWidth: string;
41
67
  activeItemClass: string;
42
68
  inactiveItemClass: string;
43
69
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
44
70
  inputRef: HTMLInputElement;
45
71
  }, HTMLDivElement>;
72
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
46
73
  export default _default;
74
+ type __VLS_WithTemplateSlots<T, S> = T & {
75
+ new (): {
76
+ $slots: S;
77
+ };
78
+ };
@@ -1,157 +1,177 @@
1
- import { defineComponent as I, ref as b, computed as v, openBlock as r, createElementBlock as d, normalizeClass as S, createElementVNode as u, withModifiers as a, createBlock as $, withCtx as x, createVNode as m, createCommentVNode as V, withDirectives as j, withKeys as g, vModelText as z, toDisplayString as K, unref as M, nextTick as N } from "vue";
2
- import y from "../Icon.vue.js";
3
- import O from "../Dropdown/Dropdown.vue.js";
4
- import { $t as l } from "../../utils/i18n.js";
1
+ import { defineComponent as M, useSlots as R, ref as k, computed as d, openBlock as r, createElementBlock as c, normalizeClass as V, createElementVNode as m, withModifiers as u, createBlock as j, withCtx as b, createVNode as f, createCommentVNode as w, withDirectives as z, withKeys as C, vModelText as A, toDisplayString as K, unref as N, createSlots as U, renderSlot as W, nextTick as P } from "vue";
2
+ import D from "../Icon.vue.js";
3
+ import q from "../Dropdown/Dropdown.vue.js";
4
+ import { $t as s } from "../../utils/i18n.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
7
  /* empty css */
8
- import R from "../Button.vue.js";
9
- import A from "../IconPicker.vue.js";
10
- const P = {
8
+ import F from "../Button.vue.js";
9
+ import G from "../IconPicker.vue.js";
10
+ const H = {
11
11
  type: "button",
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
- }, U = {
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"
13
+ }, J = {
14
14
  key: 1,
15
15
  class: "flex items-center justify-center p-0.5"
16
- }, q = { class: "flex-1 min-w-0 pr-1" }, F = ["onKeydown"], G = {
16
+ }, L = { class: "flex-1 min-w-0 pr-1" }, Q = ["onKeydown"], X = {
17
17
  key: 1,
18
18
  class: "block truncate text-sm font-medium leading-normal"
19
- }, ee = /* @__PURE__ */ I({
19
+ }, se = /* @__PURE__ */ M({
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
+ showContextMenu: { type: Boolean, default: !0 },
29
+ customOptions: { default: () => [] },
26
30
  confirmDelete: { type: Boolean, default: !1 },
27
31
  confirmDeleteTexts: {},
28
32
  allowIconChange: { type: Boolean, default: !0 },
33
+ canChangeIcon: { type: Boolean, default: !0 },
34
+ menuWidth: { default: "140px" },
29
35
  itemClass: { default: "" },
30
36
  activeItemClass: { default: "" },
31
37
  inactiveItemClass: { default: "" }
32
38
  },
33
39
  emits: ["select", "update:title", "update:icon", "edit-start", "edit-end", "duplicate", "delete"],
34
- setup(i, { emit: w }) {
35
- const e = i, o = w, f = b(null), s = b(e.sheet.title), C = v(
36
- () => e.sheet.titleI18n ? l(e.sheet.titleI18n) : e.sheet.title
37
- ), h = () => {
38
- s.value = e.sheet.title, o("edit-start", e.sheet.id), N(() => {
39
- f.value?.focus(), f.value?.select();
40
- });
40
+ setup(n, { emit: B }) {
41
+ const e = n, i = B, I = R(), p = k(null), a = k(e.sheet.title), v = k(!1), T = d(
42
+ () => e.sheet.titleI18n ? s(e.sheet.titleI18n) : e.sheet.title
43
+ ), g = () => {
44
+ e.canRename && (a.value = e.sheet.title, i("edit-start", e.sheet.id), P(() => {
45
+ p.value?.focus(), p.value?.select();
46
+ }));
41
47
  };
42
- let p = !1;
43
- const k = () => {
44
- if (!e.isEditing || p) return;
45
- p = !0;
46
- const n = s.value.trim();
47
- n ? o("update:title", e.sheet.id, n) : s.value = e.sheet.title, o("edit-end", e.sheet.id), setTimeout(() => {
48
- p = !1;
48
+ let h = !1;
49
+ const y = () => {
50
+ if (!e.isEditing || h) return;
51
+ h = !0;
52
+ const o = a.value.trim();
53
+ o ? i("update:title", e.sheet.id, o) : a.value = e.sheet.title, i("edit-end", e.sheet.id), setTimeout(() => {
54
+ h = !1;
49
55
  }, 100);
50
- }, D = () => {
51
- s.value = e.sheet.title, o("edit-end", e.sheet.id);
52
- }, T = v(() => [
53
- {
54
- label: l("vlite.workbook.rename") !== "vlite.workbook.rename" ? l("vlite.workbook.rename") : "Rename",
56
+ }, O = () => {
57
+ a.value = e.sheet.title, i("edit-end", e.sheet.id);
58
+ }, x = d(() => {
59
+ const o = [];
60
+ e.canRename && o.push({
61
+ label: s("vlite.workbook.rename") !== "vlite.workbook.rename" ? s("vlite.workbook.rename") : "Rename",
55
62
  value: "rename",
56
63
  icon: "lucide:pencil"
57
- },
58
- {
59
- label: l("vlite.workbook.duplicate") !== "vlite.workbook.duplicate" ? l("vlite.workbook.duplicate") : "Duplicate",
64
+ }), e.canDuplicate && o.push({
65
+ label: s("vlite.workbook.duplicate") !== "vlite.workbook.duplicate" ? s("vlite.workbook.duplicate") : "Duplicate",
60
66
  value: "duplicate",
61
67
  icon: "lucide:copy"
62
- },
63
- {
64
- label: l("vlite.workbook.delete") !== "vlite.workbook.delete" ? l("vlite.workbook.delete") : "Delete",
68
+ }), e.canDelete && o.push({
69
+ label: s("vlite.workbook.delete") !== "vlite.workbook.delete" ? s("vlite.workbook.delete") : "Delete",
65
70
  value: "delete",
66
71
  icon: "lucide:trash-2",
67
- disabled: !e.canDelete,
68
72
  confirmation: e.confirmDelete ? {
69
73
  title: e.confirmDeleteTexts?.title,
70
74
  description: e.confirmDeleteTexts?.description,
71
75
  confirmText: e.confirmDeleteTexts?.confirm,
72
76
  cancelText: e.confirmDeleteTexts?.cancel,
73
- variant: "danger",
74
- onConfirm: () => {
75
- e.canDelete && o("delete", e.sheet.id);
76
- }
77
+ variant: "danger"
77
78
  } : void 0
79
+ });
80
+ for (const t of e.customOptions)
81
+ o.push({
82
+ label: t.label,
83
+ value: t.action,
84
+ icon: t.icon,
85
+ disabled: t.disabled,
86
+ data: { workbookCustomOption: t }
87
+ });
88
+ return o;
89
+ }), E = d(
90
+ () => e.showContextMenu && (x.value.length > 0 || !!I["sheet-actions"])
91
+ ), S = (o) => {
92
+ const t = o.option?.data?.workbookCustomOption;
93
+ if (t) {
94
+ t.onClick(e.sheet);
95
+ return;
78
96
  }
79
- ]), B = (n) => {
80
- if (n.value === "rename" && h(), n.value === "duplicate" && o("duplicate", e.sheet.id), n.value === "delete") {
97
+ if (o.value === "rename" && g(), o.value === "duplicate" && e.canDuplicate && i("duplicate", e.sheet.id), o.value === "delete") {
81
98
  if (!e.canDelete) return;
82
- o("delete", e.sheet.id);
99
+ i("delete", e.sheet.id);
83
100
  }
84
- }, E = v(() => [
101
+ }, $ = d(() => [
85
102
  "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
103
  e.itemClass,
87
104
  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
105
  e.isEditing ? "cursor-text" : ""
89
106
  ].filter(Boolean).join(" "));
90
- return (n, t) => (r(), d("div", {
91
- class: S(E.value),
92
- onClick: t[5] || (t[5] = (c) => o("select", i.sheet.id)),
93
- onDblclick: h
107
+ return (o, t) => (r(), c("div", {
108
+ class: V($.value),
109
+ onClick: t[7] || (t[7] = (l) => i("select", n.sheet.id)),
110
+ onDblclick: g
94
111
  }, [
95
- u("div", {
96
- onClick: t[1] || (t[1] = a(() => {
112
+ m("div", {
113
+ onClick: t[1] || (t[1] = u(() => {
97
114
  }, ["stop"])),
98
115
  class: "mr-2 flex items-center shrink-0"
99
116
  }, [
100
- (i.sheet.icon || i.isEditing) && i.allowIconChange ? (r(), $(A, {
117
+ (n.sheet.icon || n.isEditing) && n.allowIconChange && n.canChangeIcon ? (r(), j(G, {
101
118
  key: 0,
102
- value: i.sheet.icon || "lucide:file",
119
+ value: n.sheet.icon || "lucide:file",
103
120
  position: "bottom-start",
104
- onOnSelect: t[0] || (t[0] = (c) => o("update:icon", i.sheet.id, c))
121
+ onOnSelect: t[0] || (t[0] = (l) => n.canChangeIcon && i("update:icon", n.sheet.id, l))
105
122
  }, {
106
- default: x(() => [
107
- u("button", P, [
108
- m(y, {
109
- icon: i.sheet.icon || "lucide:file",
123
+ default: b(() => [
124
+ m("button", H, [
125
+ f(D, {
126
+ icon: n.sheet.icon || "lucide:file",
110
127
  class: "w-4 h-4 opacity-70 hover:opacity-100 transition-opacity"
111
128
  }, null, 8, ["icon"])
112
129
  ])
113
130
  ]),
114
131
  _: 1
115
- }, 8, ["value"])) : i.sheet.icon ? (r(), d("div", U, [
116
- m(y, {
117
- icon: i.sheet.icon,
132
+ }, 8, ["value"])) : n.sheet.icon ? (r(), c("div", J, [
133
+ f(D, {
134
+ icon: n.sheet.icon,
118
135
  class: "w-4 h-4 opacity-70"
119
136
  }, null, 8, ["icon"])
120
- ])) : V("", !0)
137
+ ])) : w("", !0)
121
138
  ]),
122
- u("div", q, [
123
- i.isEditing ? j((r(), d("input", {
139
+ m("div", L, [
140
+ n.isEditing ? z((r(), c("input", {
124
141
  key: 0,
125
142
  ref_key: "inputRef",
126
- ref: f,
127
- "onUpdate:modelValue": t[2] || (t[2] = (c) => s.value = c),
143
+ ref: p,
144
+ "onUpdate:modelValue": t[2] || (t[2] = (l) => a.value = l),
128
145
  type: "text",
129
146
  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: k,
147
+ onBlur: y,
131
148
  onKeydown: [
132
- g(a(k, ["prevent"]), ["enter"]),
133
- g(a(D, ["prevent"]), ["esc"])
149
+ C(u(y, ["prevent"]), ["enter"]),
150
+ C(u(O, ["prevent"]), ["esc"])
134
151
  ],
135
- onClick: t[3] || (t[3] = a(() => {
152
+ onClick: t[3] || (t[3] = u(() => {
136
153
  }, ["stop"]))
137
- }, null, 40, F)), [
138
- [z, s.value]
139
- ]) : (r(), d("span", G, K(C.value), 1))
154
+ }, null, 40, Q)), [
155
+ [A, a.value]
156
+ ]) : (r(), c("span", X, K(T.value), 1))
140
157
  ]),
141
- u("div", {
158
+ E.value ? (r(), c("div", {
159
+ key: 0,
142
160
  class: "opacity-0 group-hover:opacity-100 transition-opacity ml-auto pl-1 -mr-2 flex items-center",
143
- onClick: t[4] || (t[4] = a(() => {
161
+ onClick: t[6] || (t[6] = u(() => {
144
162
  }, ["stop"]))
145
163
  }, [
146
- m(M(O), {
147
- options: T.value,
164
+ f(N(q), {
165
+ "is-open": v.value,
166
+ "onUpdate:isOpen": t[5] || (t[5] = (l) => v.value = l),
167
+ options: x.value,
148
168
  position: "bottom-end",
149
- width: "140px",
169
+ width: n.menuWidth,
150
170
  teleport: !0,
151
- onOnSelect: B
152
- }, {
153
- trigger: x(() => [
154
- m(R, {
171
+ onOnSelect: S
172
+ }, U({
173
+ trigger: b(() => [
174
+ f(F, {
155
175
  icon: "lucide:more-vertical",
156
176
  asIcon: "",
157
177
  size: "xs",
@@ -159,12 +179,25 @@ const P = {
159
179
  variant: "ghost"
160
180
  })
161
181
  ]),
162
- _: 1
163
- }, 8, ["options"])
164
- ])
182
+ _: 2
183
+ }, [
184
+ o.$slots["sheet-actions"] ? {
185
+ name: "footer",
186
+ fn: b(() => [
187
+ m("div", {
188
+ class: "border-t p-1 space-y-0.5",
189
+ onClickCapture: t[4] || (t[4] = (l) => v.value = !1)
190
+ }, [
191
+ W(o.$slots, "sheet-actions", { sheet: n.sheet })
192
+ ], 32)
193
+ ]),
194
+ key: "0"
195
+ } : void 0
196
+ ]), 1032, ["is-open", "options", "width"])
197
+ ])) : w("", !0)
165
198
  ], 34));
166
199
  }
167
200
  });
168
201
  export {
169
- ee as default
202
+ se as default
170
203
  };
@@ -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,17 @@ 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;
49
+ menuWidth: string;
41
50
  activeItemClass: string;
42
51
  inactiveItemClass: string;
43
52
  sheets: WorkbookSheet[];
53
+ autoDelete: boolean;
44
54
  addable: boolean;
45
55
  addButtonPosition: AddButtonPosition;
46
56
  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-e674bcbc"]]);
4
+ const _ = /* @__PURE__ */ r(o, [["__scopeId", "data-v-42c2d8b9"]]);
5
5
  export {
6
- p as default
6
+ _ as default
7
7
  };