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,17 +1,23 @@
1
- import { defineComponent as P, ref as y, shallowRef as A, watch as M, computed as W, openBlock as o, createElementBlock as c, createElementVNode as f, renderSlot as v, createCommentVNode as h, createVNode as g, unref as I, withCtx as Y, Fragment as j, renderList as F, isMemoSame as R, createBlock as q, normalizeClass as G } from "vue";
2
- import { useScroll as H } from "@vueuse/core";
3
- import { VueDraggable as J } from "vue-draggable-plus";
4
- import K from "./Sheet.vue.js";
5
- import p from "./WorkbookAddButton.vue.js";
6
- const O = { class: "flex flex-col w-full font-sans" }, Q = { class: "flex items-end w-full border-b px-1" }, X = {
1
+ import { defineComponent as j, ref as S, shallowRef as F, watch as q, openBlock as d, createElementBlock as c, createElementVNode as f, renderSlot as g, createCommentVNode as x, createVNode as b, unref as V, withCtx as $, Fragment as G, renderList as H, isMemoSame as J, createBlock as K, createSlots as Q, normalizeClass as X } from "vue";
2
+ import { useScroll as Z } from "@vueuse/core";
3
+ import { VueDraggable as _ } from "vue-draggable-plus";
4
+ import ee from "./Sheet.vue.js";
5
+ import E from "./WorkbookAddButton.vue.js";
6
+ const te = { class: "flex flex-col w-full font-sans" }, ne = { class: "flex items-end w-full border-b px-1" }, ae = {
7
7
  key: 0,
8
8
  class: "flex items-center"
9
- }, Z = { class: "flex items-center mb-0.5 z-20 sticky right-0 ml-auto box-decoration-clone" }, _ = { key: 0 }, ee = { key: 1 }, te = { class: "flex-1 relative bg-white w-full" }, de = /* @__PURE__ */ P({
9
+ }, le = { class: "flex items-center mb-0.5 z-20 sticky right-0 ml-auto box-decoration-clone" }, oe = { key: 0 }, se = { key: 1 }, ie = { class: "flex-1 relative bg-white w-full" }, me = /* @__PURE__ */ j({
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" },
@@ -23,150 +29,178 @@ const O = { class: "flex flex-col w-full font-sans" }, Q = { class: "flex items-
23
29
  inactiveItemClass: { default: "" },
24
30
  confirmDelete: { type: Boolean, default: !1 },
25
31
  confirmDeleteTexts: {},
32
+ menuWidth: { default: "140px" },
26
33
  allowIconChange: { type: Boolean, default: !0 }
27
34
  },
28
35
  emits: ["update:modelValue", "update:sheets", "change", "add", "delete", "duplicate", "edit-start", "edit-end"],
29
- setup(l, { emit: D }) {
30
- const i = l, s = D, m = y(null), u = y(null), { arrivedState: V } = H(m), d = A([...i.sheets]);
31
- M(
32
- () => [...i.sheets],
36
+ setup(a, { emit: U }) {
37
+ const l = a, s = U, m = S(null), u = S(null), { arrivedState: W } = Z(m), i = F([...l.sheets]);
38
+ q(
39
+ () => [...l.sheets],
33
40
  (e) => {
34
41
  let n = !1;
35
- if (e.length !== d.value.length)
42
+ if (e.length !== i.value.length)
36
43
  n = !0;
37
44
  else
38
45
  for (let t = 0; t < e.length; t++)
39
- if (e[t] !== d.value[t] || e[t].id !== d.value[t].id) {
46
+ if (e[t] !== i.value[t] || e[t].id !== i.value[t].id) {
40
47
  n = !0;
41
48
  break;
42
49
  }
43
- n && (d.value = e);
50
+ n && (i.value = e);
44
51
  }
45
52
  );
46
- const B = (e) => {
47
- d.value = e, s("update:sheets", e);
48
- }, S = (e) => {
53
+ const A = (e) => {
54
+ i.value = e, s("update:sheets", e);
55
+ }, M = (e) => {
49
56
  s("update:modelValue", e), s("change", e);
50
- }, x = () => {
51
- i.sheets.length >= i.maxSheets || s("add");
52
- }, E = (e, n) => {
53
- const t = i.sheets.findIndex((a) => a.id === e);
54
- if (t !== -1) {
55
- const a = [...i.sheets];
56
- a[t] = { ...a[t], title: n }, s("update:sheets", a);
57
+ }, k = () => {
58
+ l.sheets.length >= l.maxSheets || s("add");
59
+ }, R = (e, n) => {
60
+ const t = l.sheets.findIndex((o) => o.id === e);
61
+ if (t !== -1 && v(l.sheets[t])) {
62
+ const o = [...l.sheets];
63
+ o[t] = { ...o[t], title: n }, s("update:sheets", o);
57
64
  }
58
- }, U = (e, n) => {
59
- const t = i.sheets.findIndex((a) => a.id === e);
60
- if (t !== -1) {
61
- const a = [...i.sheets];
62
- a[t] = { ...a[t], icon: n }, s("update:sheets", a);
65
+ }, T = (e, n) => {
66
+ const t = l.sheets.findIndex((o) => o.id === e);
67
+ if (t !== -1 && C(l.sheets[t])) {
68
+ const o = [...l.sheets];
69
+ o[t] = { ...o[t], icon: n }, s("update:sheets", o);
63
70
  }
64
- }, $ = (e) => {
65
- u.value = e, s("edit-start", e);
66
- }, T = (e) => {
67
- u.value = null, s("edit-end", e);
68
71
  }, z = (e) => {
69
- s("duplicate", e);
72
+ const n = l.sheets.find((t) => t.id === e);
73
+ !n || !v(n) || (u.value = e, s("edit-start", e));
70
74
  }, L = (e) => {
71
- const n = i.sheets.findIndex((a) => a.id === e);
72
- if (n === -1) return;
73
- const t = [...i.sheets];
74
- if (t.splice(n, 1), s("update:sheets", t), s("delete", e), i.modelValue === e) {
75
- let a = "";
75
+ u.value = null, s("edit-end", e);
76
+ }, N = (e) => {
77
+ const n = l.sheets.find((t) => t.id === e);
78
+ !n || !w(n) || s("duplicate", e);
79
+ }, O = (e) => {
80
+ const n = l.sheets.findIndex((o) => o.id === e);
81
+ if (n === -1 || !y(l.sheets[n])) return;
82
+ if (!l.autoDelete) {
83
+ s("delete", e);
84
+ return;
85
+ }
86
+ const t = [...l.sheets];
87
+ if (t.splice(n, 1), s("update:sheets", t), s("delete", e), l.modelValue === e) {
88
+ let o = "";
76
89
  if (t.length > 0) {
77
- const k = Math.min(n, t.length - 1);
78
- a = t[k].id;
90
+ const D = Math.min(n, t.length - 1);
91
+ o = t[D].id;
79
92
  }
80
- s("update:modelValue", a), s("change", a);
93
+ s("update:modelValue", o), s("change", o);
81
94
  }
82
- }, N = (e) => {
95
+ }, P = (e) => {
83
96
  m.value && e.deltaY !== 0 && (m.value.scrollLeft += e.deltaY, e.preventDefault());
84
- }, b = W(() => i.sheets.length > 1);
85
- return (e, n) => (o(), c("div", O, [
86
- f("div", Q, [
87
- e.$slots["left-addons"] ? (o(), c("div", X, [
88
- v(e.$slots, "left-addons", {}, void 0, !0)
89
- ])) : h("", !0),
97
+ }, h = (e, n) => l.editable ? (e[n] ?? l[n] ?? !0) === !0 : !1, v = (e) => h(e, "canRename"), w = (e) => h(e, "canDuplicate"), C = (e) => h(e, "canChangeIcon") && l.allowIconChange, y = (e) => l.sheets.length > 1 && h(e, "canDelete"), p = (e) => e.showContextMenu !== !1;
98
+ return (e, n) => (d(), c("div", te, [
99
+ f("div", ne, [
100
+ e.$slots["left-addons"] ? (d(), c("div", ae, [
101
+ g(e.$slots, "left-addons", {}, void 0, !0)
102
+ ])) : x("", !0),
90
103
  f("div", {
91
104
  ref_key: "scrollContainer",
92
105
  ref: m,
93
106
  class: "flex-1 flex items-end overflow-x-auto scrollbar-none overscroll-contain sheet-container",
94
107
  style: { "scrollbar-width": "none", "-ms-overflow-style": "none" },
95
- onWheel: N
108
+ onWheel: P
96
109
  }, [
97
- g(I(J), {
98
- "model-value": d.value,
99
- "onUpdate:modelValue": B,
100
- disabled: !i.draggable || !!u.value,
110
+ b(V(_), {
111
+ "model-value": i.value,
112
+ "onUpdate:modelValue": A,
113
+ disabled: !l.draggable || !!u.value,
101
114
  animation: 150,
102
115
  class: "flex items-end min-w-max"
103
116
  }, {
104
- default: Y(() => [
105
- (o(!0), c(j, null, F(d.value, (t, a, k, r) => {
106
- const C = [
117
+ default: $(() => [
118
+ (d(!0), c(G, null, H(i.value, (t, o, D, r) => {
119
+ const I = [
107
120
  t.id,
108
121
  t.title,
109
122
  t.icon,
110
- l.modelValue === t.id,
123
+ a.modelValue === t.id,
111
124
  u.value === t.id,
112
- b.value,
113
- l.confirmDelete,
114
- l.allowIconChange,
115
- l.itemClass,
116
- l.activeItemClass,
117
- l.inactiveItemClass
125
+ v(t),
126
+ w(t),
127
+ y(t),
128
+ C(t),
129
+ p(t),
130
+ a.customOptions,
131
+ e.$slots["sheet-actions"],
132
+ a.confirmDelete,
133
+ a.allowIconChange,
134
+ a.menuWidth,
135
+ a.itemClass,
136
+ a.activeItemClass,
137
+ a.inactiveItemClass
118
138
  ];
119
- if (r && r.el && r.key === t.id && R(r, C)) return r;
120
- const w = (o(), q(K, {
139
+ if (r && r.el && r.key === t.id && J(r, I)) return r;
140
+ const B = (d(), K(ee, {
121
141
  key: t.id,
122
142
  sheet: t,
123
- "is-active": l.modelValue === t.id,
143
+ "is-active": a.modelValue === t.id,
124
144
  "is-editing": u.value === t.id,
125
- "can-delete": b.value,
126
- "confirm-delete": l.confirmDelete,
127
- "confirm-delete-texts": l.confirmDeleteTexts,
128
- "allow-icon-change": l.allowIconChange,
129
- "item-class": l.itemClass,
130
- "active-item-class": l.activeItemClass,
131
- "inactive-item-class": l.inactiveItemClass,
132
- onSelect: S,
133
- "onUpdate:title": E,
134
- "onUpdate:icon": U,
135
- onEditStart: $,
136
- onEditEnd: T,
137
- onDuplicate: z,
138
- onDelete: L
139
- }, null, 8, ["sheet", "is-active", "is-editing", "can-delete", "confirm-delete", "confirm-delete-texts", "allow-icon-change", "item-class", "active-item-class", "inactive-item-class"]));
140
- return w.memo = C, w;
145
+ "can-rename": v(t),
146
+ "can-duplicate": w(t),
147
+ "can-delete": y(t),
148
+ "show-context-menu": p(t),
149
+ "custom-options": a.customOptions,
150
+ "confirm-delete": a.confirmDelete,
151
+ "confirm-delete-texts": a.confirmDeleteTexts,
152
+ "allow-icon-change": a.allowIconChange,
153
+ "can-change-icon": C(t),
154
+ "menu-width": a.menuWidth,
155
+ "item-class": a.itemClass,
156
+ "active-item-class": a.activeItemClass,
157
+ "inactive-item-class": a.inactiveItemClass,
158
+ onSelect: M,
159
+ "onUpdate:title": R,
160
+ "onUpdate:icon": T,
161
+ onEditStart: z,
162
+ onEditEnd: L,
163
+ onDuplicate: N,
164
+ onDelete: O
165
+ }, Q({ _: 2 }, [
166
+ e.$slots["sheet-actions"] ? {
167
+ name: "sheet-actions",
168
+ fn: $(({ sheet: Y }) => [
169
+ g(e.$slots, "sheet-actions", { sheet: Y }, void 0, !0)
170
+ ]),
171
+ key: "0"
172
+ } : void 0
173
+ ]), 1032, ["sheet", "is-active", "is-editing", "can-rename", "can-duplicate", "can-delete", "show-context-menu", "custom-options", "confirm-delete", "confirm-delete-texts", "allow-icon-change", "can-change-icon", "menu-width", "item-class", "active-item-class", "inactive-item-class"]));
174
+ return B.memo = I, B;
141
175
  }, n, 0), 128))
142
176
  ]),
143
- _: 1
177
+ _: 3
144
178
  }, 8, ["model-value", "disabled"]),
145
- l.addable && l.addButtonPosition === "attached" ? (o(), c("div", {
179
+ a.addable && a.addButtonPosition === "attached" ? (d(), c("div", {
146
180
  key: 0,
147
- class: G(["shrink-0 sticky right-0 z-10 bg-body flex items-center justify-center h-full", {
148
- "shadow-[-18px_0_24px_-4px_#fff] dark:shadow-[-18px_0_24px_-4px_#000]": !I(V).right
181
+ class: X(["shrink-0 sticky right-0 z-10 bg-body flex items-center justify-center h-full", {
182
+ "shadow-[-18px_0_24px_-4px_#fff] dark:shadow-[-18px_0_24px_-4px_#000]": !V(W).right
149
183
  }])
150
184
  }, [
151
- g(p, { onClick: x })
152
- ], 2)) : h("", !0),
185
+ b(E, { onClick: k })
186
+ ], 2)) : x("", !0),
153
187
  n[2] || (n[2] = f("div", { class: "w-1 shrink-0" }, null, -1))
154
188
  ], 544),
155
- f("div", Z, [
156
- l.addable && l.addButtonPosition === "fixed-right" ? (o(), c("div", _, [
157
- g(p, { onClick: x })
158
- ])) : h("", !0),
159
- e.$slots["right-addons"] ? (o(), c("div", ee, [
160
- v(e.$slots, "right-addons", {}, void 0, !0)
161
- ])) : h("", !0)
189
+ f("div", le, [
190
+ a.addable && a.addButtonPosition === "fixed-right" ? (d(), c("div", oe, [
191
+ b(E, { onClick: k })
192
+ ])) : x("", !0),
193
+ e.$slots["right-addons"] ? (d(), c("div", se, [
194
+ g(e.$slots, "right-addons", {}, void 0, !0)
195
+ ])) : x("", !0)
162
196
  ])
163
197
  ]),
164
- f("div", te, [
165
- v(e.$slots, "default", {}, void 0, !0)
198
+ f("div", ie, [
199
+ g(e.$slots, "default", {}, void 0, !0)
166
200
  ])
167
201
  ]));
168
202
  }
169
203
  });
170
204
  export {
171
- de as default
205
+ me as default
172
206
  };
@@ -6,14 +6,40 @@ 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;
14
+ /** Explicitly show or hide this sheet's context-menu trigger. */
15
+ showContextMenu?: boolean;
9
16
  [key: string]: any;
10
17
  }
18
+ /** A consumer-owned context-menu action rendered alongside Workbook's built-in sheet actions. */
19
+ export interface WorkbookCustomOption {
20
+ label: string;
21
+ icon?: string;
22
+ /** Stable identifier for this action within the consumer's domain. */
23
+ action: string | number;
24
+ disabled?: boolean;
25
+ /** Invoked with the sheet whose context menu triggered the action. */
26
+ onClick: (sheet: WorkbookSheet) => void | Promise<void>;
27
+ }
11
28
  export type SheetPosition = 'top' | 'bottom' | 'left' | 'right';
12
29
  export type AddButtonPosition = 'attached' | 'fixed-right';
13
30
  export interface WorkbookProps {
14
31
  modelValue?: string;
15
32
  sheets?: WorkbookSheet[];
16
33
  editable?: boolean;
34
+ /** Global defaults; individual sheets may override each action. */
35
+ canRename?: boolean;
36
+ canDuplicate?: boolean;
37
+ canDelete?: boolean;
38
+ canChangeIcon?: boolean;
39
+ /** Additional context-menu actions appended after the built-in sheet actions. */
40
+ customOptions?: WorkbookCustomOption[];
41
+ /** When false, emit `delete` without removing the sheet locally. */
42
+ autoDelete?: boolean;
17
43
  addable?: boolean;
18
44
  draggable?: boolean;
19
45
  addButtonPosition?: AddButtonPosition;
@@ -30,6 +56,8 @@ export interface WorkbookProps {
30
56
  confirm?: string;
31
57
  cancel?: string;
32
58
  };
59
+ /** Width of each sheet's context-menu dropdown (passed to Dropdown `width`). */
60
+ menuWidth?: string;
33
61
  allowIconChange?: boolean;
34
62
  }
35
63
  export interface SheetEvent {
package/docs/README.md CHANGED
@@ -13,4 +13,5 @@ npx vlite3-docs
13
13
  Entry points:
14
14
 
15
15
  - [Component index](./component-index.md)
16
+ - [Design system](./design.md)
16
17
  - [Setup](./getting-started/setup.md)
@@ -23,6 +23,7 @@ import { Button, Input, Form } from 'vlite3'
23
23
  | Guides | [`guides/`](./guides/) |
24
24
  | Utilities | [`utilities/`](./utilities/) |
25
25
  | Composables | [`composables/`](./composables/) |
26
+ | Design system | [`design.md`](./design.md) |
26
27
 
27
28
  ---
28
29
 
@@ -270,6 +271,7 @@ import { Button, Input, Form } from 'vlite3'
270
271
 
271
272
  | Doc | Purpose | Use when… | Link |
272
273
  | :--- | :--- | :--- | :--- |
274
+ | **Design** | Design-system tokens (Clean) for colors, type, and surfaces | Visual consistency / token reference | [design.md](./design.md) |
273
275
  | **Theming** | Design tokens, Tailwind v4, dark mode | Changing brand colors / theme behavior | [theming.md](./guides/theming.md) |
274
276
  | **Utility / Composables** | Shared composables (`useKeyStroke`, etc.) | Keyboard shortcuts and reusable logic | [utilities.md](./utilities/utilities.md) |
275
277
  | **useTheme** | Theme state and helpers | Reading or toggling light/dark theme | [use-theme.md](./composables/use-theme.md) |
@@ -285,6 +287,7 @@ import { Button, Input, Form } from 'vlite3'
285
287
 
286
288
  | Need | Prefer | Also see |
287
289
  | :--- | :--- | :--- |
290
+ | Design tokens / visual system | [Design](./design.md) | [Theming](./guides/theming.md), [useTheme](./composables/use-theme.md) |
288
291
  | Full authenticated app chrome | [AppShell](./components/app-shell.md) | [Navbar](./components/navbar.md), [SidebarMenu](./components/sidebar-menu.md), [SidePanel](./components/side-panel.md) |
289
292
  | Standard list / CRUD page | [Screen](./components/screen.md) | [DataTable](./components/data-table.md), [Empty](./components/empty.md) |
290
293
  | Create/edit record form | [Forms](./components/forms.md) | [CustomFields](./components/custom-fields.md), [Testing-Forms](./guides/testing-forms.md) |
@@ -305,8 +308,8 @@ import { Button, Input, Form } from 'vlite3'
305
308
  | Core components | 67 |
306
309
  | Advanced components | 27 |
307
310
  | Guides | 2 |
308
- | Guides, utilities & composables | 8 |
309
- | **Total linked from this index** | **104** |
311
+ | Guides, utilities & composables | 9 |
312
+ | **Total linked from this index** | **105** |
310
313
 
311
314
  # Usage for agents
312
315
  open the file to discover component.
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Import:** `import { EditableTitle } from 'vlite3'`
4
4
 
5
- Inline create / rename title row with optional leading `IconPicker`, edit action, and delete action. Display text and the editing field share the same typography so entering/leaving edit mode does not jump, resize, or shift layout.
5
+ Inline create / rename title row with optional leading `IconPicker`, edit action, delete action, and consumer-defined action slots before/after the built-ins. Display text and the editing field share the same typography so entering/leaving edit mode does not jump, resize, or shift layout.
6
6
 
7
7
  The component owns temporary UI state (editing / create focus). Consumers bind the title value (and optionally the icon) and handle persistence on `create`, `save`, `update:icon`, and `delete`.
8
8
 
@@ -140,24 +140,69 @@ Behaviour:
140
140
  ### Editing behaviour (rename)
141
141
 
142
142
  - Click **Edit** (or `startEdit()` / `focus()`) to rename; existing title is selected.
143
- - While renaming, Edit is hidden (layout reserved); Delete stays available when `canDelete`.
143
+ - While renaming (or in create mode), Edit, Delete, and custom action slots are all hidden so the field owns the row.
144
144
  - **Enter** / blur (`saveOnBlur`) commits via `save` / `change`.
145
145
  - **Escape** restores the previous title and emits `cancel`.
146
146
  - Whitespace-only drafts do not wipe a valid title.
147
147
 
148
+ ### Slots
149
+
150
+ | Slot | Description |
151
+ | :--- | :--- |
152
+ | `actions-before` | Custom action(s) rendered **before** the built-in Edit control |
153
+ | `actions-after` | Custom action(s) rendered **after** the built-in Delete control |
154
+
155
+ Order is fixed and predictable:
156
+
157
+ ```text
158
+ Title → actions-before → Edit → Delete → actions-after
159
+ ```
160
+
161
+ Custom slots are **not** gated by `editable`, `canDelete`, or `readonly` — the consumer owns visibility and meaning. Omit a slot entirely when unused; empty slots do not reserve space or introduce gaps.
162
+
163
+ ```vue
164
+ <EditableTitle
165
+ v-model="item.name"
166
+ :can-delete="true"
167
+ @delete="handleDelete">
168
+ <template #actions-before>
169
+ <Button as-icon variant="ghost" size="xs" icon="lucide:copy" aria-label="Duplicate" @click="duplicate" />
170
+ </template>
171
+
172
+ <template #actions-after>
173
+ <Button as-icon variant="ghost" size="xs" icon="lucide:share-2" aria-label="Share" @click="share" />
174
+ <Button as-icon variant="ghost" size="xs" icon="lucide:more-horizontal" aria-label="More" @click="openMenu" />
175
+ </template>
176
+ </EditableTitle>
177
+ ```
178
+
179
+ Guidance:
180
+
181
+ - Pass one or many controls inside either slot; the slot wrapper uses the same action gap as Edit/Delete.
182
+ - Prefer the same ghost icon-button sizing as the built-ins (`xs` for `sm`/`md`, `sm` for `lg`) so the row stays aligned.
183
+ - Custom actions participate in the same hover / `:focus-within` reveal as Edit/Delete (fine pointers use `display: none` when idle so they do not reserve width; touch/coarse pointers keep them visible).
184
+ - Clicks inside custom slots stop row navigation and arm the same blur-suppression path as Delete / IconPicker, so `saveOnBlur` does not commit/exit edit before the consumer action runs.
185
+ - Custom actions are hidden while editing / creating (same as Edit/Delete). They remain available in `readonly` and when built-in Edit/Delete are disabled — unless the consumer chooses to hide them.
186
+
148
187
  ### Layout
149
188
 
189
+ ```text
190
+ [Icon / IconPicker] [Flexible Title] [Custom Before] [Edit] [Delete] [Custom After]
191
+ ```
192
+
193
+ Without custom slots (existing consumers):
194
+
150
195
  ```text
151
196
  [Icon / IconPicker] [Flexible Title] [Edit] [Delete]
152
197
  ```
153
198
 
154
- Creation mode:
199
+ Creation mode (unchanged unless custom slots are supplied):
155
200
 
156
201
  ```text
157
202
  [Icon / IconPicker] [Focused New Title Input]
158
203
  ```
159
204
 
160
- Long titles truncate; action slots are reserved so hover reveal never shifts the title. Icon picker / edit / delete clicks use `stopPropagation` so parent row navigation is not triggered.
205
+ Long titles truncate and use the full row width while actions are idle. On fine pointers, the action column is `display: none` until hover or `:focus-within`, then `display: flex` — so idle rows do not reserve action width. A zero-width height lock matching the action hit target keeps row height stable on reveal and while editing (when the whole action column is omitted). Touch / coarse pointers keep actions visible when not editing. Icon picker / edit / delete / custom-action clicks use `stopPropagation` so parent row navigation is not triggered.
161
206
 
162
207
  ### Variants
163
208
 
@@ -168,7 +213,7 @@ Long titles truncate; action slots are reserved so hover reveal never shifts the
168
213
 
169
214
  ### Accessibility
170
215
 
171
- - Edit and Delete are real buttons with accessible names.
172
- - Revealed on container hover **and** keyboard `:focus-within`.
173
- - On touch / coarse pointers, actions stay visible.
216
+ - Edit and Delete are real buttons with accessible names; custom slot content should provide its own accessible names.
217
+ - Built-in and custom actions are revealed on container hover **and** keyboard `:focus-within` (`display: flex`; idle fine-pointer rows use `display: none`).
218
+ - On touch / coarse pointers, actions stay visible when not editing.
174
219
  - Icon picker trigger is a labeled button and does not start title editing.
@@ -13,6 +13,12 @@ A spreadsheet-like tab interface supporting drag-and-drop reordering, inline edi
13
13
  | `sheets` | `WorkbookSheet[]` | `[]` | Array of sheet objects (v-model:sheets) |
14
14
  | `modelValue` | `string` | `''` | Active sheet ID (v-model) |
15
15
  | `editable` | `boolean` | `true` | Enable renaming and context menus |
16
+ | `canRename` | `boolean` | `true` | Default visibility for Rename |
17
+ | `canDuplicate` | `boolean` | `true` | Default visibility for Duplicate |
18
+ | `canDelete` | `boolean` | `true` | Default visibility for Delete |
19
+ | `canChangeIcon` | `boolean` | `true` | Default visibility for icon picker |
20
+ | `customOptions` | `WorkbookCustomOption[]` | `[]` | Additional sheet context-menu actions |
21
+ | `autoDelete` | `boolean` | `true` | Remove locally before emitting `delete` |
16
22
  | `addable` | `boolean` | `true` | Show add button |
17
23
  | `draggable` | `boolean` | `true` | Enable drag-and-drop reordering |
18
24
  | `addButtonPosition` | `'attached' \| 'fixed-right'` | `'fixed-right'` | Position of the add button |
@@ -21,6 +27,7 @@ A spreadsheet-like tab interface supporting drag-and-drop reordering, inline edi
21
27
  | `maxSheets` | `number` | `50` | Maximum number of sheets |
22
28
  | `confirmDelete` | `boolean` | `false` | Show delete confirmation modal |
23
29
  | `confirmDeleteTexts`| `object` | — | Custom text for delete confirmation |
30
+ | `menuWidth` | `string` | `'140px'` | Width of each sheet context-menu dropdown |
24
31
  | `class` | `string` | — | Custom wrapper class |
25
32
  | `itemClass` | `string` | — | Class for sheet tabs |
26
33
  | `activeItemClass` | `string` | — | Class for active sheet tab |
@@ -31,6 +38,7 @@ A spreadsheet-like tab interface supporting drag-and-drop reordering, inline edi
31
38
  - `default`: The main content area displayed below the tabs.
32
39
  - `left-addons`: Rendered to the left of the tabs container. Useful for global controls.
33
40
  - `right-addons`: Rendered to the extreme right of the header, alongside the `fixed-right` add button.
41
+ - `sheet-actions`: Appended inside each sheet's context menu. Receives `{ sheet: WorkbookSheet }`.
34
42
 
35
43
  ### Sheet Object (`WorkbookSheet`)
36
44
 
@@ -42,10 +50,77 @@ interface WorkbookSheet {
42
50
  icon?: string
43
51
  closable?: boolean
44
52
  disabled?: boolean
53
+ canRename?: boolean // Per-sheet override
54
+ canDuplicate?: boolean // Per-sheet override
55
+ canDelete?: boolean // Per-sheet override
56
+ canChangeIcon?: boolean // Per-sheet override
57
+ showContextMenu?: boolean // Per-sheet context-menu trigger override
45
58
  [key: string]: any // Custom data
46
59
  }
47
60
  ```
48
61
 
62
+ ### Custom sheet context-menu actions
63
+
64
+ `customOptions` appends consumer-owned actions after the built-in Rename,
65
+ Duplicate, and Delete items. Each callback receives the sheet that opened the
66
+ menu, so one shared action definition can operate on any Workbook sheet.
67
+
68
+ ```typescript
69
+ interface WorkbookCustomOption {
70
+ label: string
71
+ icon?: string
72
+ action: string | number
73
+ disabled?: boolean
74
+ onClick: (sheet: WorkbookSheet) => void | Promise<void>
75
+ }
76
+ ```
77
+
78
+ ```vue
79
+ <script setup lang="ts">
80
+ import type { WorkbookCustomOption } from 'vlite3'
81
+
82
+ const customOptions: WorkbookCustomOption[] = [
83
+ {
84
+ label: 'Share',
85
+ icon: 'lucide:share-2',
86
+ action: 'share',
87
+ onClick: (sheet) => shareSheet(sheet.id),
88
+ },
89
+ {
90
+ label: 'Export',
91
+ icon: 'lucide:download',
92
+ action: 'export',
93
+ onClick: (sheet) => exportSheet(sheet),
94
+ },
95
+ ]
96
+ </script>
97
+
98
+ <template>
99
+ <Workbook :sheets="sheets" :custom-options="customOptions" />
100
+ </template>
101
+ ```
102
+
103
+ For custom rendered actions appended after the built-in menu options, use
104
+ `sheet-actions`. It receives the current sheet. Selecting an appended action
105
+ closes the context menu before the consumer callback completes.
106
+
107
+ ```vue
108
+ <Workbook :sheets="sheets">
109
+ <template #sheet-actions="{ sheet }">
110
+ <button type="button" class="w-full px-2 py-1.5 text-left" @click="archiveSheet(sheet.id)">
111
+ Archive {{ sheet.title }}
112
+ </button>
113
+ </template>
114
+ </Workbook>
115
+ ```
116
+
117
+ Custom actions do not replace built-in actions or bypass their permissions:
118
+ `canRename`, `canDuplicate`, and `canDelete` continue to govern only their
119
+ matching built-in controls. A context-menu trigger is still shown when a sheet
120
+ has custom options or `sheet-actions`, even if every built-in action is hidden.
121
+ Set `showContextMenu: false` on a sheet with no available built-in or custom
122
+ action to suppress its trigger without affecting other sheets.
123
+
49
124
  ### Events
50
125
 
51
126
  - `@update:modelValue` (id: `string`): Emitted when active sheet changes (v-model binding).
@@ -100,3 +175,20 @@ const handleAdd = () => {
100
175
  <!-- Content -->
101
176
  </Workbook>
102
177
  ```
178
+
179
+ #### Granular action permissions
180
+
181
+ `editable` remains the global master switch. Use the action props to hide
182
+ individual controls; a per-sheet value takes precedence over the Workbook
183
+ default.
184
+
185
+ ```vue
186
+ <Workbook
187
+ :can-rename="canRename"
188
+ :can-duplicate="canDuplicate"
189
+ :can-delete="canDelete"
190
+ :can-change-icon="false"
191
+ :sheets="[
192
+ { id: 'private', title: 'Private', canRename: false, canDuplicate: false },
193
+ ]" />
194
+ ```