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
package/docs/component-index.md
CHANGED
|
@@ -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
|
|
|
@@ -68,7 +69,7 @@ import { Button, Input, Form } from 'vlite3'
|
|
|
68
69
|
| DateRangePicker | Advanced | Pick a start–end date range (reports, filters) | [DateRangePicker.md](./components/date-range-picker.md) |
|
|
69
70
|
| DateTime | Core | Format and display dates/times consistently | [DateTime.md](./components/date-time.md) |
|
|
70
71
|
| Dropdown | Core | Single-select menus, nested actions, remote search | [Dropdown.md](./components/dropdown.md) |
|
|
71
|
-
| EditableTitle | Core |
|
|
72
|
+
| EditableTitle | Core | Create/rename title row with IconPicker + edit/delete actions | [EditableTitle.md](./components/editable-title.md) |
|
|
72
73
|
| Empty | Core | Friendly “no data yet” placeholders | [Empty.md](./components/empty.md) |
|
|
73
74
|
| ExportData | Advanced | Download table data as Excel / CSV / JSON | [ExportData.md](./components/export-data.md) |
|
|
74
75
|
| FilePicker | Core | Upload one or many files from the device | [FilePicker.md](./components/file-picker.md) |
|
|
@@ -147,7 +148,7 @@ import { Button, Input, Form } from 'vlite3'
|
|
|
147
148
|
| Component | Purpose | Use when… | Doc |
|
|
148
149
|
| :--- | :--- | :--- | :--- |
|
|
149
150
|
| **Input** | Single-line text entry | Names, emails, codes, search boxes | [Input.md](./components/input.md) |
|
|
150
|
-
| **EditableTitle** |
|
|
151
|
+
| **EditableTitle** | Create/rename title row with optional IconPicker + delete | List items, project rows, section titles | [EditableTitle.md](./components/editable-title.md) |
|
|
151
152
|
| **Textarea** | Multi-line text entry | Notes, descriptions, rejection reasons | [Textarea.md](./components/textarea.md) |
|
|
152
153
|
| **NumberInput** | Numeric entry with constraints | Qty, rates, percentages, sequenced numbers | [NumberInput.md](./components/number-input.md) |
|
|
153
154
|
| **CheckBox** | Boolean or multi-check options | Agree terms, select rows, feature flags | [CheckBox.md](./components/checkbox.md) |
|
|
@@ -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 |
|
|
309
|
-
| **Total linked from this index** | **
|
|
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,26 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
**Import:** `import { EditableTitle } from 'vlite3'`
|
|
4
4
|
|
|
5
|
-
Inline
|
|
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
|
-
The component owns
|
|
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
|
+
|
|
9
|
+
**List performance:** `IconPicker` is mounted lazily (on hover/focus/first activate) so long project lists do not pay the iconify picker cost per idle row. Prefer `v-memo` on parent `v-for` rows that render `EditableTitle`.
|
|
8
10
|
|
|
9
11
|
### Props
|
|
10
12
|
|
|
11
13
|
| Prop | Type | Default | Description |
|
|
12
14
|
| :--- | :--- | :--- | :--- |
|
|
13
15
|
| `modelValue` | `string` | `''` | Current title (`v-model`) |
|
|
14
|
-
| `icon` | `string` | `lucide:file-text` | Leading icon (
|
|
16
|
+
| `icon` | `string` | `lucide:file-text` | Leading icon (`v-model:icon`) |
|
|
15
17
|
| `showIcon` | `boolean` | `true` | Render the leading icon |
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
18
|
+
| `canChangeIcon` | `boolean` | `true` | Allow changing the icon via `IconPicker` (independent of whether `icon` is already set; empty values use a fallback glyph) |
|
|
19
|
+
| `iconPickerPosition` | `string` | `bottom-start` | `IconPicker` dropdown placement |
|
|
20
|
+
| `editable` | `boolean` | `true` | Allow title rename (independent of icon/delete) |
|
|
21
|
+
| `create` | `boolean` | `false` | Creation mode — mounts already editing; confirms via `create` |
|
|
22
|
+
| `canDelete` | `boolean` | `false` | Show trailing delete action |
|
|
23
|
+
| `deleteIcon` | `string` | `lucide:trash-2` | Delete action icon |
|
|
24
|
+
| `deleteLabel` | `string` | `Delete` | Accessible label for delete |
|
|
25
|
+
| `disabled` | `boolean` | `false` | Disable all interactions + muted styling |
|
|
26
|
+
| `readonly` | `boolean` | `false` | Block title/icon/delete without muted chrome |
|
|
19
27
|
| `variant` | `'background' \| 'transparent'` | `background` | Surface treatment |
|
|
20
28
|
| `size` | `'sm' \| 'md' \| 'lg'` | `md` | Typography and spacing scale |
|
|
21
|
-
| `maxWidth` | `string \| number` | — | Max width of the root
|
|
29
|
+
| `maxWidth` | `string \| number` | — | Max width of the root |
|
|
22
30
|
| `placeholder` | `string` | `''` | Shown when the title/draft is empty |
|
|
23
31
|
| `editIcon` | `string` | `lucide:square-pen` | Trailing edit action icon |
|
|
24
|
-
| `saveOnBlur` | `boolean` | `true` | Commit
|
|
32
|
+
| `saveOnBlur` | `boolean` | `true` | Commit (rename or create) when the input blurs |
|
|
25
33
|
| `editLabel` | `string` | `Edit title` | Accessible label for the edit button |
|
|
26
34
|
| `class` | `any` | `''` | Extra classes on the root |
|
|
27
35
|
|
|
@@ -29,97 +37,183 @@ The component owns edit UI state internally. Consumers bind the title value only
|
|
|
29
37
|
|
|
30
38
|
| Event | Payload | Description |
|
|
31
39
|
| :--- | :--- | :--- |
|
|
32
|
-
| `update:modelValue` | `string` |
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
40
|
+
| `update:modelValue` | `string` | Title changed on rename/create commit |
|
|
41
|
+
| `update:icon` | `string` | Icon selected via `IconPicker` |
|
|
42
|
+
| `edit-start` | — | Rename edit mode began |
|
|
43
|
+
| `change` | `string` | Rename commit |
|
|
44
|
+
| `save` | `string` | Rename commit (alias of `change`) |
|
|
45
|
+
| `create` | `string` | Creation confirmed with a non-empty title |
|
|
46
|
+
| `cancel` | — | Escape / empty create blur / programmatic cancel |
|
|
47
|
+
| `delete` | — | Delete action clicked (consumer confirms/persists) |
|
|
37
48
|
| `focus` | `FocusEvent` | Input focus while editing |
|
|
38
49
|
| `blur` | `FocusEvent` | Input blur while editing |
|
|
39
50
|
|
|
40
51
|
### Public methods
|
|
41
52
|
|
|
42
|
-
Exposed via template ref
|
|
53
|
+
Exposed via template ref:
|
|
43
54
|
|
|
44
55
|
| Method | Description |
|
|
45
56
|
| :--- | :--- |
|
|
46
|
-
| `startEdit()` | Enter
|
|
47
|
-
| `save()` / `commit()` | Commit the draft |
|
|
48
|
-
| `cancel()` | Discard the draft
|
|
49
|
-
| `focus()` | Focus the input, or start editing when allowed
|
|
50
|
-
|
|
51
|
-
### Editing behaviour
|
|
52
|
-
|
|
53
|
-
- Click **Edit** (or call `startEdit()` / `focus()`) to enter edit mode; the title is selected for quick replacement via `Input`’s public `focus()` / `select()` contract.
|
|
54
|
-
- Edit mode is **internal UI state**. Parents do not bind or synchronize an `editing` flag.
|
|
55
|
-
- While editing, the Edit affordance is **fully hidden** (layout space still reserved). There is never a visible Edit control that ignores clicks.
|
|
56
|
-
- **Enter** commits.
|
|
57
|
-
- **Escape** cancels and restores the previous title.
|
|
58
|
-
- Blur follows `saveOnBlur` (default `true`). Blur commit is deferred past the click sequence so clicking Edit on another `EditableTitle` still works.
|
|
59
|
-
- Whitespace-only drafts do **not** wipe a valid title — the previous value is kept.
|
|
60
|
-
- Empty titles are only accepted when the previous value was already empty.
|
|
61
|
-
- Disabled / readonly / `editable=false` never enter editing. If those flags flip on while editing, the session is cancelled.
|
|
57
|
+
| `startEdit()` | Enter rename mode |
|
|
58
|
+
| `save()` / `commit()` | Commit the draft (`create` or `save`) |
|
|
59
|
+
| `cancel()` | Discard the draft / cancel creation |
|
|
60
|
+
| `focus()` | Focus the input, or start editing when allowed |
|
|
62
61
|
|
|
63
|
-
###
|
|
62
|
+
### Permissions
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
fixed icon | flexible constrained title | fixed action
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Long titles truncate with ellipsis in display mode. In edit mode the input keeps the same middle width and scrolls internally — it never expands the component. The edit action slot is always reserved when editing is allowed, so hover reveal does not shift the title.
|
|
70
|
-
|
|
71
|
-
### Variants
|
|
64
|
+
Keep these independent:
|
|
72
65
|
|
|
73
|
-
|
|
|
66
|
+
| Flag | Controls |
|
|
74
67
|
| :--- | :--- |
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
68
|
+
| `editable` | Title rename |
|
|
69
|
+
| `canChangeIcon` | Icon picker |
|
|
70
|
+
| `canDelete` | Delete action |
|
|
71
|
+
| `disabled` / `readonly` | Block interactions globally |
|
|
77
72
|
|
|
78
|
-
###
|
|
73
|
+
### Creation mode
|
|
79
74
|
|
|
80
75
|
```vue
|
|
81
76
|
<script setup lang="ts">
|
|
82
77
|
import { ref } from 'vue'
|
|
83
78
|
import { EditableTitle } from 'vlite3'
|
|
84
79
|
|
|
85
|
-
const
|
|
80
|
+
const isCreating = ref(false)
|
|
81
|
+
const newName = ref('')
|
|
82
|
+
const newIcon = ref('lucide:box')
|
|
83
|
+
|
|
84
|
+
function startCreate() {
|
|
85
|
+
if (isCreating.value) return // one blank editor at a time
|
|
86
|
+
newName.value = ''
|
|
87
|
+
isCreating.value = true
|
|
88
|
+
}
|
|
86
89
|
|
|
87
|
-
function
|
|
88
|
-
// Persist
|
|
89
|
-
console.log(
|
|
90
|
+
function onCreate(name: string) {
|
|
91
|
+
// Persist new item — icon is already on newIcon via v-model:icon
|
|
92
|
+
console.log(name, newIcon.value)
|
|
93
|
+
isCreating.value = false
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function onCancelCreate() {
|
|
97
|
+
isCreating.value = false
|
|
90
98
|
}
|
|
91
99
|
</script>
|
|
92
100
|
|
|
93
101
|
<template>
|
|
102
|
+
<button type="button" @click="startCreate">+</button>
|
|
103
|
+
|
|
94
104
|
<EditableTitle
|
|
95
|
-
v-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
v-if="isCreating"
|
|
106
|
+
create
|
|
107
|
+
v-model="newName"
|
|
108
|
+
v-model:icon="newIcon"
|
|
109
|
+
placeholder="Enter name..."
|
|
110
|
+
@create="onCreate"
|
|
111
|
+
@cancel="onCancelCreate" />
|
|
99
112
|
</template>
|
|
100
113
|
```
|
|
101
114
|
|
|
102
|
-
|
|
115
|
+
Behaviour:
|
|
116
|
+
|
|
117
|
+
- Mounts already editing and focused.
|
|
118
|
+
- **Enter** emits `create` when the trimmed title is non-empty.
|
|
119
|
+
- **Escape** emits `cancel` (parent removes the temporary row).
|
|
120
|
+
- Empty blur (with `saveOnBlur`) cancels creation; non-empty blur creates.
|
|
121
|
+
- Empty Enter does **not** create — the field stays open.
|
|
122
|
+
- Opening `IconPicker` does not accidentally commit/cancel via blur.
|
|
123
|
+
|
|
124
|
+
### Rename + icon + delete
|
|
103
125
|
|
|
104
126
|
```vue
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
127
|
+
<EditableTitle
|
|
128
|
+
v-model="project.name"
|
|
129
|
+
v-model:icon="project.icon"
|
|
130
|
+
variant="transparent"
|
|
131
|
+
size="sm"
|
|
132
|
+
:can-delete="projects.length > 1"
|
|
133
|
+
@save="(name) => renameProject(project.id, name)"
|
|
134
|
+
@update:icon="(icon) => updateIcon(project.id, icon)"
|
|
135
|
+
@delete="requestDelete(project.id)" />
|
|
136
|
+
```
|
|
109
137
|
|
|
110
|
-
|
|
111
|
-
const titleRef = ref<EditableTitleExpose | null>(null)
|
|
112
|
-
</script>
|
|
138
|
+
`EditableTitle` emits `delete` only — keep confirmation modals and API calls in the consumer.
|
|
113
139
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
140
|
+
### Editing behaviour (rename)
|
|
141
|
+
|
|
142
|
+
- Click **Edit** (or `startEdit()` / `focus()`) to rename; existing title is selected.
|
|
143
|
+
- While renaming, Edit is hidden (layout reserved); Delete and any custom action slots stay available.
|
|
144
|
+
- **Enter** / blur (`saveOnBlur`) commits via `save` / `change`.
|
|
145
|
+
- **Escape** restores the previous title and emits `cancel`.
|
|
146
|
+
- Whitespace-only drafts do not wipe a valid title.
|
|
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 hide idle actions; 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 remain available while editing, in `readonly`, and when Edit/Delete are disabled — unless the consumer chooses to hide them.
|
|
186
|
+
|
|
187
|
+
### Layout
|
|
188
|
+
|
|
189
|
+
```text
|
|
190
|
+
[Icon / IconPicker] [Flexible Title] [Custom Before] [Edit] [Delete] [Custom After]
|
|
118
191
|
```
|
|
119
192
|
|
|
193
|
+
Without custom slots (existing consumers):
|
|
194
|
+
|
|
195
|
+
```text
|
|
196
|
+
[Icon / IconPicker] [Flexible Title] [Edit] [Delete]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Creation mode (unchanged unless custom slots are supplied):
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
[Icon / IconPicker] [Focused New Title Input]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Long titles truncate; the action region is reserved so hover reveal, entering edit mode, and toggling Edit/Delete never shifts the title, icon, or surrounding content. While renaming, Edit is replaced by an invisible spacer of the same size — custom before/after actions keep their natural width and do not collapse. Icon picker / edit / delete / custom-action clicks use `stopPropagation` so parent row navigation is not triggered.
|
|
206
|
+
|
|
207
|
+
### Variants
|
|
208
|
+
|
|
209
|
+
| Value | Description |
|
|
210
|
+
| :--- | :--- |
|
|
211
|
+
| `background` | Soft filled surface with generous rounded corners |
|
|
212
|
+
| `transparent` | No container background — for list rows / headers |
|
|
213
|
+
|
|
120
214
|
### Accessibility
|
|
121
215
|
|
|
122
|
-
- Edit
|
|
123
|
-
-
|
|
124
|
-
- On touch / coarse pointers
|
|
125
|
-
-
|
|
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`.
|
|
218
|
+
- On touch / coarse pointers, actions stay visible.
|
|
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 |
|
|
@@ -31,6 +37,7 @@ A spreadsheet-like tab interface supporting drag-and-drop reordering, inline edi
|
|
|
31
37
|
- `default`: The main content area displayed below the tabs.
|
|
32
38
|
- `left-addons`: Rendered to the left of the tabs container. Useful for global controls.
|
|
33
39
|
- `right-addons`: Rendered to the extreme right of the header, alongside the `fixed-right` add button.
|
|
40
|
+
- `sheet-actions`: Appended inside each sheet's context menu. Receives `{ sheet: WorkbookSheet }`.
|
|
34
41
|
|
|
35
42
|
### Sheet Object (`WorkbookSheet`)
|
|
36
43
|
|
|
@@ -42,10 +49,73 @@ interface WorkbookSheet {
|
|
|
42
49
|
icon?: string
|
|
43
50
|
closable?: boolean
|
|
44
51
|
disabled?: boolean
|
|
52
|
+
canRename?: boolean // Per-sheet override
|
|
53
|
+
canDuplicate?: boolean // Per-sheet override
|
|
54
|
+
canDelete?: boolean // Per-sheet override
|
|
55
|
+
canChangeIcon?: boolean // Per-sheet override
|
|
45
56
|
[key: string]: any // Custom data
|
|
46
57
|
}
|
|
47
58
|
```
|
|
48
59
|
|
|
60
|
+
### Custom sheet context-menu actions
|
|
61
|
+
|
|
62
|
+
`customOptions` appends consumer-owned actions after the built-in Rename,
|
|
63
|
+
Duplicate, and Delete items. Each callback receives the sheet that opened the
|
|
64
|
+
menu, so one shared action definition can operate on any Workbook sheet.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
interface WorkbookCustomOption {
|
|
68
|
+
label: string
|
|
69
|
+
icon?: string
|
|
70
|
+
action: string | number
|
|
71
|
+
disabled?: boolean
|
|
72
|
+
onClick: (sheet: WorkbookSheet) => void | Promise<void>
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```vue
|
|
77
|
+
<script setup lang="ts">
|
|
78
|
+
import type { WorkbookCustomOption } from 'vlite3'
|
|
79
|
+
|
|
80
|
+
const customOptions: WorkbookCustomOption[] = [
|
|
81
|
+
{
|
|
82
|
+
label: 'Share',
|
|
83
|
+
icon: 'lucide:share-2',
|
|
84
|
+
action: 'share',
|
|
85
|
+
onClick: (sheet) => shareSheet(sheet.id),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: 'Export',
|
|
89
|
+
icon: 'lucide:download',
|
|
90
|
+
action: 'export',
|
|
91
|
+
onClick: (sheet) => exportSheet(sheet),
|
|
92
|
+
},
|
|
93
|
+
]
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<Workbook :sheets="sheets" :custom-options="customOptions" />
|
|
98
|
+
</template>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
For fully custom menu content, use `sheet-actions`. It is rendered in the same
|
|
102
|
+
context menu after the normal options and receives the current sheet.
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<Workbook :sheets="sheets">
|
|
106
|
+
<template #sheet-actions="{ sheet }">
|
|
107
|
+
<button type="button" class="w-full px-2 py-1.5 text-left" @click="archiveSheet(sheet.id)">
|
|
108
|
+
Archive {{ sheet.title }}
|
|
109
|
+
</button>
|
|
110
|
+
</template>
|
|
111
|
+
</Workbook>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Custom actions do not replace built-in actions or bypass their permissions:
|
|
115
|
+
`canRename`, `canDuplicate`, and `canDelete` continue to govern only their
|
|
116
|
+
matching built-in controls. A context-menu trigger is still shown when a sheet
|
|
117
|
+
has custom options or `sheet-actions`, even if every built-in action is hidden.
|
|
118
|
+
|
|
49
119
|
### Events
|
|
50
120
|
|
|
51
121
|
- `@update:modelValue` (id: `string`): Emitted when active sheet changes (v-model binding).
|
|
@@ -100,3 +170,20 @@ const handleAdd = () => {
|
|
|
100
170
|
<!-- Content -->
|
|
101
171
|
</Workbook>
|
|
102
172
|
```
|
|
173
|
+
|
|
174
|
+
#### Granular action permissions
|
|
175
|
+
|
|
176
|
+
`editable` remains the global master switch. Use the action props to hide
|
|
177
|
+
individual controls; a per-sheet value takes precedence over the Workbook
|
|
178
|
+
default.
|
|
179
|
+
|
|
180
|
+
```vue
|
|
181
|
+
<Workbook
|
|
182
|
+
:can-rename="canRename"
|
|
183
|
+
:can-duplicate="canDuplicate"
|
|
184
|
+
:can-delete="canDelete"
|
|
185
|
+
:can-change-icon="false"
|
|
186
|
+
:sheets="[
|
|
187
|
+
{ id: 'private', title: 'Private', canRename: false, canDuplicate: false },
|
|
188
|
+
]" />
|
|
189
|
+
```
|