vlite3 1.5.12 → 1.5.14
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/README.md +20 -8
- package/components/Accordion/AccordionContent.vue.js +2 -2
- package/components/CommandPalette/CommandPaletteContent2.vue.js +1 -1
- package/components/CommandPalette/{CommandPaletteItem2.vue.js → CommandPaletteItem.vue.js} +1 -1
- package/components/Form/AccordionView2.vue.js +1 -1
- package/components/Form/Form.vue.js +2 -2
- package/components/NavbarCommandPalette.vue.js +1 -1
- package/components/PanZoomViewport/PanZoomViewport.vue.d.ts +7 -7
- package/components/PanZoomViewport/PanZoomViewport.vue.js +1 -1
- package/components/Tabes/Tabes.vue.js +2 -2
- package/docs/README.md +16 -0
- package/docs/component-index.md +313 -0
- package/docs/components/accordion.md +52 -0
- package/docs/components/alert.md +34 -0
- package/docs/components/app-shell.md +371 -0
- package/docs/components/async-select.md +264 -0
- package/docs/components/attachments-list.md +231 -0
- package/docs/components/avatar-group.md +74 -0
- package/docs/components/avatar-uploader.md +61 -0
- package/docs/components/avatar.md +28 -0
- package/docs/components/badge.md +81 -0
- package/docs/components/barcode.md +42 -0
- package/docs/components/beacon.md +29 -0
- package/docs/components/breadcrumb.md +317 -0
- package/docs/components/button-group.md +35 -0
- package/docs/components/button.md +86 -0
- package/docs/components/calendar.md +95 -0
- package/docs/components/carousel.md +122 -0
- package/docs/components/cart.md +533 -0
- package/docs/components/category-manager.md +269 -0
- package/docs/components/category-menu.md +251 -0
- package/docs/components/charts.md +1456 -0
- package/docs/components/chat.md +330 -0
- package/docs/components/checkbox.md +31 -0
- package/docs/components/chip.md +137 -0
- package/docs/components/choice-box.md +40 -0
- package/docs/components/clipboard.md +105 -0
- package/docs/components/clock.md +70 -0
- package/docs/components/color-picker.md +82 -0
- package/docs/components/command-palette.md +214 -0
- package/docs/components/comment-thread.md +171 -0
- package/docs/components/confirmation-modal.md +50 -0
- package/docs/components/custom-fields-display.md +94 -0
- package/docs/components/custom-fields.md +97 -0
- package/docs/components/data-list.md +93 -0
- package/docs/components/data-table.md +922 -0
- package/docs/components/date-picker.md +58 -0
- package/docs/components/date-range-picker.md +24 -0
- package/docs/components/date-time.md +104 -0
- package/docs/components/dropdown.md +740 -0
- package/docs/components/empty.md +100 -0
- package/docs/components/export-data.md +320 -0
- package/docs/components/file-picker.md +83 -0
- package/docs/components/file-preview.md +42 -0
- package/docs/components/file-tree.md +144 -0
- package/docs/components/footer.md +251 -0
- package/docs/components/forms.md +776 -0
- package/docs/components/gantt-chart.md +767 -0
- package/docs/components/google-login.md +67 -0
- package/docs/components/google-map.md +128 -0
- package/docs/components/heatmap.md +80 -0
- package/docs/components/icon-picker.md +58 -0
- package/docs/components/icon.md +176 -0
- package/docs/components/image-comparison.md +51 -0
- package/docs/components/image-magnifier.md +26 -0
- package/docs/components/import-data.md +521 -0
- package/docs/components/input.md +58 -0
- package/docs/components/invoice.md +339 -0
- package/docs/components/kanban.md +302 -0
- package/docs/components/label.md +25 -0
- package/docs/components/list.md +419 -0
- package/docs/components/masonry.md +55 -0
- package/docs/components/modal.md +133 -0
- package/docs/components/multi-select.md +54 -0
- package/docs/components/navbar.md +403 -0
- package/docs/components/number-input.md +41 -0
- package/docs/components/otp-input.md +68 -0
- package/docs/components/pagination.md +83 -0
- package/docs/components/pan-zoom-viewport.md +245 -0
- package/docs/components/permission-editor.md +322 -0
- package/docs/components/persona.md +56 -0
- package/docs/components/price.md +106 -0
- package/docs/components/pricing-plan.md +68 -0
- package/docs/components/progress-bar.md +53 -0
- package/docs/components/qr-code.md +59 -0
- package/docs/components/rating.md +59 -0
- package/docs/components/rich-text-editor.md +210 -0
- package/docs/components/scale-generator.md +101 -0
- package/docs/components/screen.md +208 -0
- package/docs/components/seo-provider.md +189 -0
- package/docs/components/side-panel.md +94 -0
- package/docs/components/sidebar-menu.md +422 -0
- package/docs/components/skeleton.md +115 -0
- package/docs/components/slider.md +48 -0
- package/docs/components/spinner.md +27 -0
- package/docs/components/splitter.md +97 -0
- package/docs/components/stats.md +234 -0
- package/docs/components/status-chip.md +232 -0
- package/docs/components/switch.md +23 -0
- package/docs/components/tabs.md +335 -0
- package/docs/components/tag-input.md +55 -0
- package/docs/components/textarea.md +31 -0
- package/docs/components/theme-provider.md +130 -0
- package/docs/components/theme-toggle.md +36 -0
- package/docs/components/thumbnail-selector.md +186 -0
- package/docs/components/timeline.md +225 -0
- package/docs/components/toast-notification.md +89 -0
- package/docs/components/tooltip.md +31 -0
- package/docs/components/workbook.md +102 -0
- package/docs/composables/use-theme.md +59 -0
- package/docs/getting-started/setup.md +176 -0
- package/docs/guides/draggable.md +211 -0
- package/docs/guides/internationalization.md +281 -0
- package/docs/guides/performance.md +118 -0
- package/docs/guides/testing-forms.md +154 -0
- package/docs/guides/testing-overlays.md +131 -0
- package/docs/guides/theming.md +124 -0
- package/docs/utilities/search.md +580 -0
- package/docs/utilities/utilities.md +371 -0
- package/docs-manifest.json +336 -0
- package/package.json +5 -13
- package/scripts/generate-docs-manifest.js +207 -0
- package/scripts/sync-docs.js +754 -0
- package/style.css +1 -1
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# PanZoomViewport
|
|
2
|
+
|
|
3
|
+
**Import:** `import { PanZoomViewport } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
`PanZoomViewport` is a generic, transform-only viewport for navigating any
|
|
6
|
+
slotted interface, document, diagram, preview, dashboard, or editor surface.
|
|
7
|
+
It owns one `{ scale, x, y }` transform and never reflows the slotted content.
|
|
8
|
+
Zoom, pan input sources, and horizontal/vertical transform movement can each be
|
|
9
|
+
disabled independently. Every new capability flag defaults to `true`, so existing
|
|
10
|
+
consumers retain the full interaction model.
|
|
11
|
+
|
|
12
|
+
It is intentionally separate from `ScaleGenerator`: use `ScaleGenerator` when
|
|
13
|
+
content only needs to fit a target width, use `PanZoomViewport` when users need
|
|
14
|
+
interactive zooming and panning, or compose them when interactive zoom must be
|
|
15
|
+
relative to a responsive fit baseline.
|
|
16
|
+
|
|
17
|
+
## Gestures
|
|
18
|
+
|
|
19
|
+
- Trackpad pinch or Ctrl/Command + wheel zooms around the pointer.
|
|
20
|
+
- Ordinary wheel and two-finger trackpad movement pans on both axes.
|
|
21
|
+
- Space + primary-button drag and middle-button drag pan with pointer capture.
|
|
22
|
+
- Direct primary-button/touch drag is opt-in through `panOnPrimaryDrag` so
|
|
23
|
+
controls inside arbitrary content keep their native behavior by default.
|
|
24
|
+
- Focus the viewport to use Ctrl/Command + `+`, `-`, or `0`, and the arrow keys.
|
|
25
|
+
- A nested scrollable descendant consumes ordinary wheel input while it can
|
|
26
|
+
scroll in that direction. The viewport takes over only at its boundary.
|
|
27
|
+
|
|
28
|
+
Wheel handlers are attached only to the viewport. Browser page zoom and
|
|
29
|
+
horizontal history navigation are prevented only while the component is
|
|
30
|
+
actively consuming a gesture.
|
|
31
|
+
|
|
32
|
+
## Props
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
| :--- | :--- | :--- | :--- |
|
|
36
|
+
| `modelValue` | `PanZoomViewportTransform` | `{ scale: 1, x: 0, y: 0 }` | Reactive transform used by `v-model`. |
|
|
37
|
+
| `contentWidth` | `number` | natural | Optional fixed unscaled content width. |
|
|
38
|
+
| `contentHeight` | `number` | natural | Optional fixed unscaled content height. |
|
|
39
|
+
| `minScale` | `number` | `0.1` | Lower bound applied to every zoom source, fit, reset, and controlled transform. |
|
|
40
|
+
| `maxScale` | `number` | `4` | Upper bound applied to every zoom source and controlled transform. |
|
|
41
|
+
| `zoomStep` | `number` | `0.2` | Multiplicative step for zoom controls. |
|
|
42
|
+
| `wheelZoomSpeed` | `number` | `0.002` | Exponential wheel/pinch sensitivity. |
|
|
43
|
+
| `keyboardPanStep` | `number` | `40` | Local pixels moved by an arrow key. |
|
|
44
|
+
| `fitPadding` | `number` | `24` | Default inset used by fit-to-content. |
|
|
45
|
+
| `fitMode` | `'contain' \| 'width' \| 'height'` | `'contain'` | Default fit strategy. |
|
|
46
|
+
| `fitAlignX` | `'start' \| 'center' \| 'end'` | `'center'` | Default horizontal alignment after fitting. |
|
|
47
|
+
| `fitAlignY` | `'start' \| 'center' \| 'end'` | `'center'` | Default vertical alignment after fitting. |
|
|
48
|
+
| `initialFit` | `boolean` | `false` | Fit after the first measurement without an initial animation. |
|
|
49
|
+
| `autoFitOnResize` | `boolean` | `false` | Refit when the viewport size changes. |
|
|
50
|
+
| `zoomEnabled` | `boolean` | `true` | Enables wheel, keyboard, and controller-driven zoom. |
|
|
51
|
+
| `zoomInEnabled` | `boolean` | `true` | Enables scale increases while below `maxScale`. |
|
|
52
|
+
| `zoomOutEnabled` | `boolean` | `true` | Enables scale decreases while above `minScale`. |
|
|
53
|
+
| `panEnabled` | `boolean` | `true` | Master switch for component-owned transform translation. |
|
|
54
|
+
| `pointerPanEnabled` | `boolean` | `true` | Enables Space-, middle-button-, and configured primary-button drag panning. |
|
|
55
|
+
| `wheelPanEnabled` | `boolean` | `true` | Enables component-owned ordinary wheel/trackpad translation. |
|
|
56
|
+
| `keyboardPanEnabled` | `boolean` | `true` | Enables component-owned arrow-key translation. |
|
|
57
|
+
| `horizontalPanEnabled` | `boolean` | `true` | Enables horizontal transform translation. |
|
|
58
|
+
| `verticalPanEnabled` | `boolean` | `true` | Enables vertical transform translation. |
|
|
59
|
+
| `panOnWheel` | `boolean` | `true` | Pan on ordinary wheel/trackpad input. |
|
|
60
|
+
| `wheelZoomMode` | `'modifier' \| 'always' \| 'disabled'` | `'modifier'` | Controls which wheel gestures zoom. |
|
|
61
|
+
| `panOnPrimaryDrag` | `boolean` | `false` | Enables direct primary-button/touch panning outside editable controls. |
|
|
62
|
+
| `keyboard` | `boolean` | `true` | Enables focused keyboard navigation. |
|
|
63
|
+
| `disabled` | `boolean` | `false` | Disables gestures and keyboard handling; imperative controls remain available. |
|
|
64
|
+
| `ariaLabel` | `string` | `'Pan and zoom viewport'` | Accessible region label. |
|
|
65
|
+
| `contentClass` | `string` | `''` | Extra class for the transformed content layer. |
|
|
66
|
+
|
|
67
|
+
## Transform and events
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
interface PanZoomViewportTransform {
|
|
71
|
+
scale: number
|
|
72
|
+
x: number
|
|
73
|
+
y: number
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- `@update:modelValue` provides the sanitized transform at most once per
|
|
78
|
+
animation frame during continuous gestures.
|
|
79
|
+
- `@change` provides the transform plus a source such as `wheel`, `pointer`,
|
|
80
|
+
`fit`, `reset`, or `keyboard`.
|
|
81
|
+
- `@update:viewportSize` and `@update:contentSize` report unscaled geometry.
|
|
82
|
+
- `@update:ready` fires after initial measurement and optional fitting.
|
|
83
|
+
- `@pan-start` and `@pan-end` describe pointer-drag sessions.
|
|
84
|
+
- `@zoom-availability-change` reports reactive `canZoomIn` and `canZoomOut`
|
|
85
|
+
values for disabling external controls.
|
|
86
|
+
|
|
87
|
+
The default slot receives `transform`, `viewportSize`, `contentSize`, `ready`,
|
|
88
|
+
`panning`, `canZoomIn`, and `canZoomOut`.
|
|
89
|
+
|
|
90
|
+
## Imperative controls
|
|
91
|
+
|
|
92
|
+
A component ref exposes:
|
|
93
|
+
|
|
94
|
+
- `zoomIn`, `zoomOut`, and `setScale`
|
|
95
|
+
- `panBy`, in local or client/visual coordinate space
|
|
96
|
+
- `setTransform` and `reset`
|
|
97
|
+
- `fitToContent`, with contain/width/height and alignment options
|
|
98
|
+
- `canZoomIn()` and `canZoomOut()` for external control state
|
|
99
|
+
- `focus` and `getViewportElement`
|
|
100
|
+
|
|
101
|
+
Control methods accept `behavior: 'auto' | 'smooth'`. Smooth transitions are
|
|
102
|
+
automatically disabled when reduced motion is preferred. Zoom methods can use
|
|
103
|
+
the viewport center or an explicit local/client anchor.
|
|
104
|
+
|
|
105
|
+
All component-owned scale changes use one bound/direction resolver. Non-finite
|
|
106
|
+
requests retain the current safe scale. Non-positive bounds use the documented
|
|
107
|
+
defaults; when a valid minimum exceeds the requested maximum, the effective
|
|
108
|
+
maximum collapses to the minimum so the configured floor is never lowered.
|
|
109
|
+
Direction flags override the available range: when one is `false`, that
|
|
110
|
+
direction remains unavailable even away from its bound.
|
|
111
|
+
|
|
112
|
+
## Usage
|
|
113
|
+
|
|
114
|
+
```vue
|
|
115
|
+
<script setup lang="ts">
|
|
116
|
+
import { ref } from 'vue'
|
|
117
|
+
import {
|
|
118
|
+
PanZoomViewport,
|
|
119
|
+
type PanZoomViewportExposed,
|
|
120
|
+
type PanZoomViewportTransform,
|
|
121
|
+
} from 'vlite3'
|
|
122
|
+
|
|
123
|
+
const viewport = ref<PanZoomViewportExposed | null>(null)
|
|
124
|
+
const transform = ref<PanZoomViewportTransform>({ scale: 1, x: 0, y: 0 })
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<template>
|
|
128
|
+
<div class="h-[32rem]">
|
|
129
|
+
<PanZoomViewport
|
|
130
|
+
ref="viewport"
|
|
131
|
+
v-model="transform"
|
|
132
|
+
:content-width="1200"
|
|
133
|
+
fit-mode="width"
|
|
134
|
+
initial-fit
|
|
135
|
+
auto-fit-on-resize>
|
|
136
|
+
<Dashboard />
|
|
137
|
+
</PanZoomViewport>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<button
|
|
141
|
+
:disabled="!viewport?.canZoomOut()"
|
|
142
|
+
@click="viewport?.zoomOut({ behavior: 'smooth' })">
|
|
143
|
+
Zoom out
|
|
144
|
+
</button>
|
|
145
|
+
<span>{{ Math.round(transform.scale * 100) }}%</span>
|
|
146
|
+
<button
|
|
147
|
+
:disabled="!viewport?.canZoomIn()"
|
|
148
|
+
@click="viewport?.zoomIn({ behavior: 'smooth' })">
|
|
149
|
+
Zoom in
|
|
150
|
+
</button>
|
|
151
|
+
<button @click="viewport?.fitToContent({ mode: 'width' })">Fit width</button>
|
|
152
|
+
<button @click="viewport?.setScale(1)">100%</button>
|
|
153
|
+
</template>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Zoom-only with native scrolling
|
|
157
|
+
|
|
158
|
+
Wrap the viewport in an `overflow: auto` element and turn off component-owned
|
|
159
|
+
movement. Disabled axes expose a scaled layout footprint to the nearest native
|
|
160
|
+
scroll ancestor, while the content itself remains transform-scaled. Ordinary
|
|
161
|
+
wheel, trackpad, pointer-drag, and arrow-key movement then falls through to the
|
|
162
|
+
browser; modifier-wheel/pinch zoom remains pointer anchored by updating the
|
|
163
|
+
ancestor's native scroll position.
|
|
164
|
+
|
|
165
|
+
```vue
|
|
166
|
+
<div class="canvas-scroll" style="height: 32rem; overflow: auto; overscroll-behavior: contain">
|
|
167
|
+
<PanZoomViewport
|
|
168
|
+
v-model="transform"
|
|
169
|
+
:content-width="1200"
|
|
170
|
+
:min-scale="1"
|
|
171
|
+
:max-scale="4"
|
|
172
|
+
zoom-enabled
|
|
173
|
+
zoom-in-enabled
|
|
174
|
+
zoom-out-enabled
|
|
175
|
+
:pan-enabled="false"
|
|
176
|
+
:pointer-pan-enabled="false"
|
|
177
|
+
:wheel-pan-enabled="false"
|
|
178
|
+
:keyboard-pan-enabled="false"
|
|
179
|
+
:horizontal-pan-enabled="false"
|
|
180
|
+
:vertical-pan-enabled="false"
|
|
181
|
+
:pan-on-wheel="false"
|
|
182
|
+
wheel-zoom-mode="modifier">
|
|
183
|
+
<Dashboard />
|
|
184
|
+
</PanZoomViewport>
|
|
185
|
+
</div>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Axis flags can be mixed. For example, disabling only vertical transform
|
|
189
|
+
movement delegates that axis to a native vertical scroll ancestor while the
|
|
190
|
+
component continues to own horizontal translation.
|
|
191
|
+
|
|
192
|
+
### Zoom relative to a fitted baseline
|
|
193
|
+
|
|
194
|
+
`minScale` and `maxScale` always describe the transform owned by
|
|
195
|
+
`PanZoomViewport`. When its slot contains an independently fitted surface,
|
|
196
|
+
that transform is naturally a user multiplier. Keep `ScaleGenerator` inside
|
|
197
|
+
the viewport, size the viewport's content footprint to the fitted frame, and
|
|
198
|
+
use a minimum multiplier of `1`:
|
|
199
|
+
|
|
200
|
+
```vue
|
|
201
|
+
<PanZoomViewport
|
|
202
|
+
v-model="userZoom"
|
|
203
|
+
:content-width="fittedFrameWidth"
|
|
204
|
+
:min-scale="1"
|
|
205
|
+
:max-scale="4"
|
|
206
|
+
:fit-padding="24"
|
|
207
|
+
:pan-enabled="false"
|
|
208
|
+
:horizontal-pan-enabled="false"
|
|
209
|
+
:vertical-pan-enabled="false"
|
|
210
|
+
@update:viewport-size="updateViewportSize">
|
|
211
|
+
<ScaleGenerator
|
|
212
|
+
:enabled="true"
|
|
213
|
+
:target-width="1200"
|
|
214
|
+
:min-scale="0.1"
|
|
215
|
+
:max-scale="1"
|
|
216
|
+
horizontal-align="left">
|
|
217
|
+
<Dashboard />
|
|
218
|
+
</ScaleGenerator>
|
|
219
|
+
</PanZoomViewport>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Here `fittedFrameWidth` is the target width capped to the viewport's available
|
|
223
|
+
width after padding. `ScaleGenerator` derives and continuously updates the fit
|
|
224
|
+
scale from that frame. If the fit scale is `0.62`, user zoom `1` renders at
|
|
225
|
+
`0.62`, user zoom `1.5` renders at `0.93`, and user zoom `2` renders at `1.24`.
|
|
226
|
+
Resizing changes only the fit scale; the user multiplier remains unchanged.
|
|
227
|
+
Fit, reset, and “100%” controls should set the multiplier to `1`, not set the
|
|
228
|
+
combined rendered scale to `1`.
|
|
229
|
+
|
|
230
|
+
## Coordinate and performance behavior
|
|
231
|
+
|
|
232
|
+
- Pointer anchors and client-space pan deltas are derived from
|
|
233
|
+
`getBoundingClientRect()` and normalized by the viewport's layout size. This
|
|
234
|
+
keeps navigation accurate under transformed ancestors and browser zoom.
|
|
235
|
+
- Wheel delta modes are normalized for pixel, line, and page devices.
|
|
236
|
+
- Gesture updates are coalesced with `requestAnimationFrame`; content navigation
|
|
237
|
+
remains a CSS `translate3d`/`scale` transform. Native-scroll mode additionally
|
|
238
|
+
updates only the outer footprint and native scroll offsets.
|
|
239
|
+
- The content layer uses `will-change: transform` and both layers use
|
|
240
|
+
`contain: layout style`.
|
|
241
|
+
- Resize observers, animation frames, pointer capture, listeners, and
|
|
242
|
+
transition timers are cleaned up on unmount. Browser globals are guarded for
|
|
243
|
+
SSR imports.
|
|
244
|
+
- The viewport uses `overscroll-behavior: none` locally. It does not install a
|
|
245
|
+
page-wide wheel listener or interfere with content outside its bounds.
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
# PermissionEditor
|
|
2
|
+
|
|
3
|
+
**Import:** `import { PermissionEditor } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
A single-role permission editor that renders grouped permissions with search, bulk group toggle, module filtering, and select-all controls. The `v-model` is a flat `string[]` of granted permission keys.
|
|
6
|
+
|
|
7
|
+
Use this when you need to assign permissions to a single role or user. For managing permissions across multiple roles simultaneously, use [`PermissionMatrix`](./PermissionMatrix.md).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
| :---------------- | :------------------------ | :----------- | :------------------------------------------------------------------------------------------------ |
|
|
15
|
+
| `modelValue` | `string[]` | — | **Required.** Array of granted permission keys (v-model) |
|
|
16
|
+
| `groups` | `PermissionGroup[]` | — | **Required.** Permission groups with nested permissions |
|
|
17
|
+
| `toggleMode` | `PermissionToggleMode` | `'checkbox'` | Toggle display mode for each permission row |
|
|
18
|
+
| `searchable` | `boolean` | `true` | Show search input above the permission list |
|
|
19
|
+
| `collapsible` | `boolean` | `true` | Allow groups to be collapsed/expanded by clicking their header |
|
|
20
|
+
| `readonly` | `boolean` | `false` | Disable all toggles — display-only mode |
|
|
21
|
+
| `size` | `PermissionMatrixSize` | `'md'` | Size variant affecting padding and text size |
|
|
22
|
+
| `class` | `string` | `''` | Extra CSS classes applied to the root element |
|
|
23
|
+
| `defaultExpanded` | `string[]` | `[]` | Group keys to start expanded. All other groups start collapsed. If empty, all groups are expanded |
|
|
24
|
+
| `layout` | `PermissionEditorLayout` | `'list'` | Layout mode: `'list'` (default grouped list) or `'matrix'` (table with action columns) |
|
|
25
|
+
| `matrixGroups` | `PermissionMatrixGroup[]` | `[]` | Matrix groups — used when `layout` is `'matrix'` |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Events
|
|
30
|
+
|
|
31
|
+
| Event | Payload | Description |
|
|
32
|
+
| :------------------ | :--------- | :----------------------------------------------- |
|
|
33
|
+
| `update:modelValue` | `string[]` | Emitted when the selected permission keys change |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Slots
|
|
38
|
+
|
|
39
|
+
| Slot | Description |
|
|
40
|
+
| :--- | :--------------------------------------------- |
|
|
41
|
+
| — | No named slots. All UI is rendered internally. |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Types
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
/** A single permission definition */
|
|
49
|
+
export interface PermissionDef {
|
|
50
|
+
/** Unique key, e.g. 'hrm_manage_payroll' */
|
|
51
|
+
key: string
|
|
52
|
+
/** Display label, e.g. 'Manage Payroll' */
|
|
53
|
+
label: string
|
|
54
|
+
/** Optional tooltip description shown as an info icon next to the label */
|
|
55
|
+
description?: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Group of permissions under a module/category */
|
|
59
|
+
export interface PermissionGroup {
|
|
60
|
+
/** Unique group key, e.g. 'hrm' */
|
|
61
|
+
key: string
|
|
62
|
+
/** Display label, e.g. 'HRM' */
|
|
63
|
+
label: string
|
|
64
|
+
/** Optional icon (Iconify format), e.g. 'lucide:briefcase' */
|
|
65
|
+
icon?: string
|
|
66
|
+
/** Permissions belonging to this group */
|
|
67
|
+
permissions: PermissionDef[]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type PermissionToggleMode = 'checkbox' | 'switch'
|
|
71
|
+
export type PermissionMatrixSize = 'sm' | 'md'
|
|
72
|
+
export type PermissionEditorLayout = 'list' | 'matrix'
|
|
73
|
+
|
|
74
|
+
/** A column (action) in the matrix layout */
|
|
75
|
+
export interface PermissionMatrixAction {
|
|
76
|
+
key: string // e.g. 'create'
|
|
77
|
+
label: string // e.g. 'Create'
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A row (entity) in the matrix layout */
|
|
81
|
+
export interface PermissionMatrixRow {
|
|
82
|
+
key: string // e.g. 'employee'
|
|
83
|
+
label: string // e.g. 'Employee'
|
|
84
|
+
/** Which action keys this row supports. Others render as disabled. */
|
|
85
|
+
actions: string[]
|
|
86
|
+
/** If true, key is `{prefix}-{row.key}` instead of `{prefix}-{row.key}-{action.key}` */
|
|
87
|
+
singleKey?: boolean
|
|
88
|
+
description?: string
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A group of matrix rows sharing the same actions */
|
|
92
|
+
export interface PermissionMatrixGroup {
|
|
93
|
+
key: string // permission prefix, e.g. 'hrm'
|
|
94
|
+
label: string
|
|
95
|
+
icon?: string
|
|
96
|
+
actions: PermissionMatrixAction[]
|
|
97
|
+
rows: PermissionMatrixRow[]
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Features
|
|
104
|
+
|
|
105
|
+
- **Search** — Filters permissions and group labels in real time. Groups containing matches auto-expand; unmatched groups collapse. The original collapsed state is restored when the search is cleared.
|
|
106
|
+
- **Module filter dropdown** — A filter button opens a multi-select dropdown to show only specific groups. An active filter count badge appears on the button. A "Clear filters" link resets the selection.
|
|
107
|
+
- **Bulk group toggle** — Each group header has a checkbox or switch that selects/deselects all permissions in that group. An indeterminate state is shown when only some permissions are selected.
|
|
108
|
+
- **Select All / Clear** — Top-bar controls to select all permissions across all groups or clear all selections at once. The "Clear" button is hidden when nothing is selected.
|
|
109
|
+
- **Stats counter** — Displays `{selected} / {total} selected` in the top bar.
|
|
110
|
+
- **Collapsible groups** — Clicking a group header toggles it open or closed. Manual toggles persist through search cycles.
|
|
111
|
+
- **`defaultExpanded`** — Seed which groups open on mount; all others start collapsed.
|
|
112
|
+
- **Readonly mode** — All toggles are visually disabled; no changes can be made.
|
|
113
|
+
- **Size variants** — `sm` reduces padding and font sizes for compact layouts.
|
|
114
|
+
- **Tooltips** — Permissions with a `description` field render an info icon that shows a tooltip on hover.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Matrix Layout
|
|
119
|
+
|
|
120
|
+
Set `layout="matrix"` and pass `matrixGroups` to render permissions as a table with action columns (Create, Delete, View, Update, Manage, etc.) and entity rows. Cells map to permission keys using the pattern `{group.key}-{row.key}-{action.key}` (e.g. `hrm-employee-create`). Rows with `singleKey: true` produce `{group.key}-{row.key}` regardless of action.
|
|
121
|
+
|
|
122
|
+
```vue
|
|
123
|
+
<script setup lang="ts">
|
|
124
|
+
import { ref } from 'vue'
|
|
125
|
+
import { PermissionEditor } from 'vlite3'
|
|
126
|
+
import type { PermissionMatrixGroup } from 'vlite3'
|
|
127
|
+
|
|
128
|
+
const matrixGroups: PermissionMatrixGroup[] = [
|
|
129
|
+
{
|
|
130
|
+
key: 'hrm',
|
|
131
|
+
label: 'HRM',
|
|
132
|
+
icon: 'lucide:briefcase',
|
|
133
|
+
actions: [
|
|
134
|
+
{ key: 'create', label: 'Create' },
|
|
135
|
+
{ key: 'delete', label: 'Delete' },
|
|
136
|
+
{ key: 'view', label: 'View' },
|
|
137
|
+
{ key: 'update', label: 'Update' },
|
|
138
|
+
{ key: 'manage', label: 'Manage' },
|
|
139
|
+
],
|
|
140
|
+
rows: [
|
|
141
|
+
{ key: 'employee', label: 'Employee', actions: ['create', 'delete', 'view', 'update'] },
|
|
142
|
+
{ key: 'branch', label: 'Branch', actions: ['create', 'delete', 'view', 'update'] },
|
|
143
|
+
{ key: 'can-share', label: 'Can Share', actions: ['manage'], singleKey: true },
|
|
144
|
+
{ key: 'can-download', label: 'Can Download', actions: ['manage'], singleKey: true },
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
const perms = ref<string[]>([
|
|
150
|
+
'hrm-employee-view',
|
|
151
|
+
'hrm-employee-delete',
|
|
152
|
+
'hrm-employee-create',
|
|
153
|
+
'hrm-branch-create',
|
|
154
|
+
'hrm-branch-view',
|
|
155
|
+
'hrm-can-share',
|
|
156
|
+
'hrm-can-download',
|
|
157
|
+
])
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<template>
|
|
161
|
+
<PermissionEditor v-model="perms" layout="matrix" :matrix-groups="matrixGroups" />
|
|
162
|
+
</template>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Output:**
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
[
|
|
169
|
+
"hrm-employee-view",
|
|
170
|
+
"hrm-employee-delete",
|
|
171
|
+
"hrm-employee-create",
|
|
172
|
+
"hrm-branch-create",
|
|
173
|
+
"hrm-branch-view",
|
|
174
|
+
"hrm-can-share",
|
|
175
|
+
"hrm-can-download"
|
|
176
|
+
]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Usage
|
|
182
|
+
|
|
183
|
+
### Basic (Checkbox mode)
|
|
184
|
+
|
|
185
|
+
```vue
|
|
186
|
+
<script setup lang="ts">
|
|
187
|
+
import { ref } from 'vue'
|
|
188
|
+
import { PermissionEditor } from 'vlite3'
|
|
189
|
+
import type { PermissionGroup } from 'vlite3'
|
|
190
|
+
|
|
191
|
+
const groups: PermissionGroup[] = [
|
|
192
|
+
{
|
|
193
|
+
key: 'users',
|
|
194
|
+
label: 'Users',
|
|
195
|
+
icon: 'lucide:users',
|
|
196
|
+
permissions: [
|
|
197
|
+
{
|
|
198
|
+
key: 'users_manage_employees',
|
|
199
|
+
label: 'Manage Employees',
|
|
200
|
+
description: 'Create, edit, delete employee records',
|
|
201
|
+
},
|
|
202
|
+
{ key: 'users_view_employees', label: 'View Employees' },
|
|
203
|
+
{ key: 'users_manage_customers', label: 'Manage Customers' },
|
|
204
|
+
{ key: 'users_view_customers', label: 'View Customers' },
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
key: 'hrm',
|
|
209
|
+
label: 'HRM',
|
|
210
|
+
icon: 'lucide:briefcase',
|
|
211
|
+
permissions: [
|
|
212
|
+
{
|
|
213
|
+
key: 'hrm_manage_payroll',
|
|
214
|
+
label: 'Manage Payroll',
|
|
215
|
+
description: 'Create and edit payroll runs',
|
|
216
|
+
},
|
|
217
|
+
{ key: 'hrm_view_payroll', label: 'View Payroll' },
|
|
218
|
+
{ key: 'hrm_manage_leaves', label: 'Manage Leaves' },
|
|
219
|
+
{ key: 'hrm_view_leaves', label: 'View Leaves' },
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
const selectedPermissions = ref<string[]>([
|
|
225
|
+
'users_view_employees',
|
|
226
|
+
'hrm_view_payroll',
|
|
227
|
+
'hrm_view_leaves',
|
|
228
|
+
])
|
|
229
|
+
</script>
|
|
230
|
+
|
|
231
|
+
<template>
|
|
232
|
+
<PermissionEditor v-model="selectedPermissions" :groups="groups" />
|
|
233
|
+
</template>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
### Switch mode
|
|
239
|
+
|
|
240
|
+
```vue
|
|
241
|
+
<PermissionEditor v-model="selectedPermissions" :groups="groups" toggle-mode="switch" />
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
### Controlling which groups start expanded
|
|
247
|
+
|
|
248
|
+
Use `defaultExpanded` to open only specific groups on mount. All other groups will start collapsed.
|
|
249
|
+
|
|
250
|
+
```vue
|
|
251
|
+
<PermissionEditor
|
|
252
|
+
v-model="selectedPermissions"
|
|
253
|
+
:groups="groups"
|
|
254
|
+
:default-expanded="['users', 'hrm']" />
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### Readonly mode
|
|
260
|
+
|
|
261
|
+
```vue
|
|
262
|
+
<PermissionEditor v-model="selectedPermissions" :groups="groups" readonly />
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
### Compact size
|
|
268
|
+
|
|
269
|
+
```vue
|
|
270
|
+
<PermissionEditor v-model="selectedPermissions" :groups="groups" size="sm" />
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### Without search
|
|
276
|
+
|
|
277
|
+
```vue
|
|
278
|
+
<PermissionEditor v-model="selectedPermissions" :groups="groups" :searchable="false" />
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### Non-collapsible groups
|
|
284
|
+
|
|
285
|
+
```vue
|
|
286
|
+
<PermissionEditor v-model="selectedPermissions" :groups="groups" :collapsible="false" />
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### Reading the selected value
|
|
292
|
+
|
|
293
|
+
The `v-model` is a plain `string[]` of granted permission keys. You can inspect or submit it directly.
|
|
294
|
+
|
|
295
|
+
```vue
|
|
296
|
+
<script setup lang="ts">
|
|
297
|
+
import { ref } from 'vue'
|
|
298
|
+
import { PermissionEditor } from 'vlite3'
|
|
299
|
+
|
|
300
|
+
const perms = ref<string[]>([])
|
|
301
|
+
|
|
302
|
+
function save() {
|
|
303
|
+
console.log('Granted permissions:', perms.value)
|
|
304
|
+
// e.g. ['users_view_employees', 'hrm_view_payroll']
|
|
305
|
+
}
|
|
306
|
+
</script>
|
|
307
|
+
|
|
308
|
+
<template>
|
|
309
|
+
<PermissionEditor v-model="perms" :groups="groups" />
|
|
310
|
+
<button @click="save">Save Role</button>
|
|
311
|
+
</template>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Behavior Notes
|
|
317
|
+
|
|
318
|
+
- The **module filter dropdown** and **search** are additive — both can be active simultaneously. Only groups/permissions matching all active filters are shown.
|
|
319
|
+
- When **search is cleared**, the collapsed state reverts to its last manually set state (not the initial `defaultExpanded`). This means if a user manually collapses a group during a search session, that state is preserved after clearing search.
|
|
320
|
+
- The **group bulk checkbox** shows an indeterminate state when some (but not all) permissions in that group are selected. Clicking it when indeterminate selects all; clicking it when all are selected deselects all.
|
|
321
|
+
- In **readonly mode**, `selectAll` and `deselectAll` are no-ops and the top-bar action buttons are hidden.
|
|
322
|
+
- **`defaultExpanded`** only runs on `onMounted`. Changing it after mount has no effect.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Persona
|
|
2
|
+
|
|
3
|
+
**Import:** `import { Persona } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
A visual representation of a person inside your application. The component consists of an avatar, an optional online status (presence) indicator, a primary name (label), and a secondary details (secondary label).
|
|
6
|
+
|
|
7
|
+
### Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| :--------------- | :----------------------------------------------------------------- | :-------- | :--------------------------------------------------- |
|
|
11
|
+
| `src` | `string` | — | Image Source URL (passed to Avatar `src`) |
|
|
12
|
+
| `link` | `string` | — | Link to navigate to. Transforms wrapper to `router-link` |
|
|
13
|
+
| `alt` | `string` | `Avatar` | Image alt text (also used for fallback initials prep)|
|
|
14
|
+
| `fallback` | `string` | — | Custom fallback initials if image fails or missing |
|
|
15
|
+
| `size` | `AvatarSize` (`xs`, `sm`, `md`, `lg`, `xl`, `2xl`) | `md` | Dimensions scaling for both Avatar and texts |
|
|
16
|
+
| `rounded` | `AvatarRounded` | `full` | Rounding of the Avatar |
|
|
17
|
+
| `presence` | `online` \| `offline` \| `busy` \| `dnd` \| `away` | — | Type of presence badge displayed on the avatar |
|
|
18
|
+
| `label` | `string` | — | Primary display text (usually Name) |
|
|
19
|
+
| `secondaryLabel` | `string` | — | Secondary text underneath label (Job, Status) |
|
|
20
|
+
| `labelTheme` | `default` \| `primary` \| `danger` \| *etc* | `default` | Color theme for the primary label |
|
|
21
|
+
| `hideDetails` | `boolean` | `false` | Option to visually hide the `label` and `secondary` |
|
|
22
|
+
| `class` | `any` | — | Custom classes for the container wrapper |
|
|
23
|
+
|
|
24
|
+
### Usage
|
|
25
|
+
|
|
26
|
+
```vue
|
|
27
|
+
<!-- Basic -->
|
|
28
|
+
<Persona label="Olivia Martin" secondaryLabel="Frontend Engineer" fallback="OM" />
|
|
29
|
+
|
|
30
|
+
<!-- With Custom Label Theme -->
|
|
31
|
+
<Persona label="Premium Member" secondaryLabel="Subscribed" labelTheme="primary" fallback="PM" />
|
|
32
|
+
|
|
33
|
+
<!-- With Src & Presence -->
|
|
34
|
+
<Persona
|
|
35
|
+
src="https://unsplash.com/photos/123/download?w=64"
|
|
36
|
+
alt="Olivia"
|
|
37
|
+
label="Olivia Martin"
|
|
38
|
+
presence="online"
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<!-- Navigation Link -->
|
|
42
|
+
<Persona
|
|
43
|
+
link="/users/1"
|
|
44
|
+
label="Olivia Martin"
|
|
45
|
+
secondaryLabel="View Profile"
|
|
46
|
+
presence="online"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<!-- Presence Do Not Disturb -->
|
|
50
|
+
<Persona
|
|
51
|
+
fallback="OM"
|
|
52
|
+
label="Olivia Martin"
|
|
53
|
+
presence="dnd"
|
|
54
|
+
size="lg"
|
|
55
|
+
/>
|
|
56
|
+
```
|