directix 1.0.0 → 1.2.0
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 +294 -25
- package/dist/index.cjs +4077 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1627 -54
- package/dist/index.iife.js +4076 -340
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +2 -2
- package/dist/index.mjs +4078 -215
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -11
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/directix)
|
|
4
4
|
[](https://www.npmjs.com/package/directix)
|
|
5
|
-
[](https://github.com/saqqdy/directix/blob/
|
|
5
|
+
[](https://github.com/saqqdy/directix/blob/master/LICENSE)
|
|
6
6
|
|
|
7
7
|
**[中文文档](README_CN.md)**
|
|
8
8
|
|
|
@@ -10,12 +10,13 @@ A comprehensive, easy-to-use, and high-performance Vue custom directives library
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
- 🎯 **Comprehensive** -
|
|
14
|
-
- 🔄 **Vue 2/3 Compatible** -
|
|
13
|
+
- 🎯 **Comprehensive** - 33 commonly used directives
|
|
14
|
+
- 🔄 **Vue 2/3 Compatible** - Single codebase supports both Vue 2 and Vue 3
|
|
15
15
|
- 📦 **Tree-shakable** - Import only what you need
|
|
16
16
|
- 🔒 **TypeScript** - Full TypeScript support with type definitions
|
|
17
|
-
- 🚀 **SSR Friendly** -
|
|
17
|
+
- 🚀 **SSR Friendly** - Multiple directives support SSR out of the box
|
|
18
18
|
- 📦 **Multiple Formats** - ESM, CJS, and IIFE (CDN) formats available
|
|
19
|
+
- ⚡ **Zero Dependencies** - Lightweight with minimal bundle size
|
|
19
20
|
|
|
20
21
|
## Online Demo
|
|
21
22
|
|
|
@@ -23,8 +24,8 @@ Try it online with StackBlitz:
|
|
|
23
24
|
|
|
24
25
|
| Demo | Link |
|
|
25
26
|
|------|------|
|
|
26
|
-
| Vue 3 | [](https://stackblitz.com/github/saqqdy/directix/tree/
|
|
27
|
-
| Vue 2 | [](https://stackblitz.com/github/saqqdy/directix/tree/
|
|
27
|
+
| Vue 3 | [](https://stackblitz.com/github/saqqdy/directix/tree/master/examples/vue3) |
|
|
28
|
+
| Vue 2 | [](https://stackblitz.com/github/saqqdy/directix/tree/master/examples/vue2) |
|
|
28
29
|
|
|
29
30
|
## Installation
|
|
30
31
|
|
|
@@ -63,7 +64,7 @@ You can also use Directix via CDN:
|
|
|
63
64
|
<script src="https://unpkg.com/directix/dist/index.iife.min.js"></script>
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
The CDN build
|
|
67
|
+
The CDN build works seamlessly with both Vue 2 and Vue 3.
|
|
67
68
|
|
|
68
69
|
## Requirements
|
|
69
70
|
|
|
@@ -114,37 +115,81 @@ Vue.directive('click-outside', vClickOutside)
|
|
|
114
115
|
|
|
115
116
|
### Event Directives
|
|
116
117
|
|
|
117
|
-
| Directive | Description |
|
|
118
|
-
|
|
119
|
-
| `v-click-outside` | Detect clicks outside an element |
|
|
118
|
+
| Directive | Description | SSR |
|
|
119
|
+
|-----------|-------------|-----|
|
|
120
|
+
| `v-click-outside` | Detect clicks outside an element | ❌ |
|
|
120
121
|
| `v-debounce` | Debounce event handlers | ✅ |
|
|
121
122
|
| `v-throttle` | Throttle event handlers | ✅ |
|
|
122
|
-
| `v-long-press` | Detect long press events |
|
|
123
|
+
| `v-long-press` | Detect long press events | ❌ |
|
|
124
|
+
| `v-hover` | Hover state detection | ❌ |
|
|
125
|
+
| `v-touch` | Touch gesture detection (swipe, pinch, rotate) | ❌ |
|
|
123
126
|
|
|
124
127
|
### Form Directives
|
|
125
128
|
|
|
126
|
-
| Directive | Description |
|
|
127
|
-
|
|
128
|
-
| `v-copy` | Copy text to clipboard |
|
|
129
|
+
| Directive | Description | SSR |
|
|
130
|
+
|-----------|-------------|-----|
|
|
131
|
+
| `v-copy` | Copy text to clipboard | ❌ |
|
|
129
132
|
| `v-focus` | Auto focus an element | ✅ |
|
|
130
|
-
| `v-mask` | Input masking |
|
|
133
|
+
| `v-mask` | Input masking | ❌ |
|
|
134
|
+
| `v-trim` | Trim input whitespace | ✅ |
|
|
135
|
+
| `v-money` | Currency format input | ❌ |
|
|
136
|
+
| `v-number` | Number format input | ❌ |
|
|
137
|
+
|
|
138
|
+
### Format Directives
|
|
139
|
+
|
|
140
|
+
| Directive | Description | SSR |
|
|
141
|
+
|-----------|-------------|-----|
|
|
142
|
+
| `v-uppercase` | Convert text to uppercase | ✅ |
|
|
143
|
+
| `v-lowercase` | Convert text to lowercase | ✅ |
|
|
144
|
+
| `v-capitalcase` | Capitalize first letter | ✅ |
|
|
145
|
+
| `v-truncate` | Truncate text with ellipsis | ✅ |
|
|
131
146
|
|
|
132
147
|
### Visibility Directives
|
|
133
148
|
|
|
134
|
-
| Directive | Description |
|
|
135
|
-
|
|
136
|
-
| `v-lazy` | Lazy load images |
|
|
137
|
-
| `v-intersect` | Detect element intersection |
|
|
138
|
-
| `v-visible` | Control element visibility |
|
|
149
|
+
| Directive | Description | SSR |
|
|
150
|
+
|-----------|-------------|-----|
|
|
151
|
+
| `v-lazy` | Lazy load images | ❌ |
|
|
152
|
+
| `v-intersect` | Detect element intersection | ❌ |
|
|
153
|
+
| `v-visible` | Control element visibility | ✅ |
|
|
154
|
+
| `v-loading` | Show loading overlay | ✅ |
|
|
155
|
+
|
|
156
|
+
### Scroll Directives
|
|
157
|
+
|
|
158
|
+
| Directive | Description | SSR |
|
|
159
|
+
|-----------|-------------|-----|
|
|
160
|
+
| `v-scroll` | Scroll event handling | ❌ |
|
|
161
|
+
| `v-infinite-scroll` | Infinite scrolling | ❌ |
|
|
162
|
+
| `v-sticky` | Sticky positioning | ❌ |
|
|
139
163
|
|
|
140
164
|
### Security Directives
|
|
141
165
|
|
|
142
|
-
| Directive | Description |
|
|
143
|
-
|
|
144
|
-
| `v-permission` | Permission-based element control |
|
|
145
|
-
| `v-sanitize` | Sanitize HTML content |
|
|
166
|
+
| Directive | Description | SSR |
|
|
167
|
+
|-----------|-------------|-----|
|
|
168
|
+
| `v-permission` | Permission-based element control | ✅ |
|
|
169
|
+
| `v-sanitize` | Sanitize HTML content | ✅ |
|
|
170
|
+
|
|
171
|
+
### Effect Directives
|
|
172
|
+
|
|
173
|
+
| Directive | Description | SSR |
|
|
174
|
+
|-----------|-------------|-----|
|
|
175
|
+
| `v-ripple` | Material design ripple effect | ❌ |
|
|
176
|
+
| `v-draggable` | Make elements draggable | ❌ |
|
|
177
|
+
|
|
178
|
+
### Observer Directives
|
|
179
|
+
|
|
180
|
+
| Directive | Description | SSR |
|
|
181
|
+
|-----------|-------------|-----|
|
|
182
|
+
| `v-resize` | Element resize observer | ❌ |
|
|
183
|
+
| `v-mutation` | DOM mutation observer | ❌ |
|
|
184
|
+
|
|
185
|
+
### UI Directives
|
|
186
|
+
|
|
187
|
+
| Directive | Description | SSR |
|
|
188
|
+
|-----------|-------------|-----|
|
|
189
|
+
| `v-tooltip` | Tooltip component | ❌ |
|
|
190
|
+
| `v-image-preview` | Image preview with zoom | ❌ |
|
|
146
191
|
|
|
147
|
-
> ✅ =
|
|
192
|
+
> ✅ = SSR compatible | ❌ = Not SSR compatible
|
|
148
193
|
|
|
149
194
|
## Usage Examples
|
|
150
195
|
|
|
@@ -261,6 +306,230 @@ Auto focus an element when mounted.
|
|
|
261
306
|
</template>
|
|
262
307
|
```
|
|
263
308
|
|
|
309
|
+
### v-permission
|
|
310
|
+
|
|
311
|
+
Control element visibility based on user permissions.
|
|
312
|
+
|
|
313
|
+
```vue
|
|
314
|
+
<template>
|
|
315
|
+
<!-- Simple permission check -->
|
|
316
|
+
<button v-permission="'admin'">Admin Only</button>
|
|
317
|
+
|
|
318
|
+
<!-- Multiple permissions (OR logic) -->
|
|
319
|
+
<button v-permission="['admin', 'editor']">Admin or Editor</button>
|
|
320
|
+
|
|
321
|
+
<!-- AND logic -->
|
|
322
|
+
<button v-permission="{ value: ['read', 'write'], mode: 'every' }">
|
|
323
|
+
Requires both permissions
|
|
324
|
+
</button>
|
|
325
|
+
|
|
326
|
+
<!-- Disable instead of remove -->
|
|
327
|
+
<button v-permission="{ value: 'admin', action: 'disable' }">
|
|
328
|
+
Disabled for non-admin
|
|
329
|
+
</button>
|
|
330
|
+
</template>
|
|
331
|
+
|
|
332
|
+
<script setup>
|
|
333
|
+
import { configurePermission } from 'directix'
|
|
334
|
+
|
|
335
|
+
configurePermission({
|
|
336
|
+
getPermissions: () => ['read', 'write'],
|
|
337
|
+
getRoles: () => ['editor'],
|
|
338
|
+
roleMap: {
|
|
339
|
+
admin: ['*'],
|
|
340
|
+
editor: ['read', 'write', 'edit']
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
</script>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### v-lazy
|
|
347
|
+
|
|
348
|
+
Lazy load images when they enter the viewport.
|
|
349
|
+
|
|
350
|
+
```vue
|
|
351
|
+
<template>
|
|
352
|
+
<!-- Simple usage -->
|
|
353
|
+
<img v-lazy="imageUrl" />
|
|
354
|
+
|
|
355
|
+
<!-- With placeholder and error image -->
|
|
356
|
+
<img v-lazy="{ src: imageUrl, placeholder: '/placeholder.png', error: '/error.png' }" />
|
|
357
|
+
</template>
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### v-mask
|
|
361
|
+
|
|
362
|
+
Input masking for formatted input.
|
|
363
|
+
|
|
364
|
+
```vue
|
|
365
|
+
<template>
|
|
366
|
+
<!-- Phone number -->
|
|
367
|
+
<input v-mask="'(###) ###-####'" placeholder="Phone" />
|
|
368
|
+
|
|
369
|
+
<!-- Date -->
|
|
370
|
+
<input v-mask="'##/##/####'" placeholder="MM/DD/YYYY" />
|
|
371
|
+
|
|
372
|
+
<!-- SSN -->
|
|
373
|
+
<input v-mask="{ mask: '###-##-####', placeholder: '_' }" placeholder="SSN" />
|
|
374
|
+
</template>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### v-loading
|
|
378
|
+
|
|
379
|
+
Show loading overlay on elements.
|
|
380
|
+
|
|
381
|
+
```vue
|
|
382
|
+
<template>
|
|
383
|
+
<!-- Simple usage -->
|
|
384
|
+
<div v-loading="isLoading">Content</div>
|
|
385
|
+
|
|
386
|
+
<!-- With options -->
|
|
387
|
+
<div v-loading="{ value: isLoading, text: 'Loading...', lock: true }">
|
|
388
|
+
Content with locked scroll
|
|
389
|
+
</div>
|
|
390
|
+
</template>
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### v-sanitize
|
|
394
|
+
|
|
395
|
+
Sanitize HTML content to prevent XSS attacks.
|
|
396
|
+
|
|
397
|
+
```vue
|
|
398
|
+
<template>
|
|
399
|
+
<!-- Simple usage -->
|
|
400
|
+
<div v-sanitize="userContent"></div>
|
|
401
|
+
|
|
402
|
+
<!-- With custom allowed tags -->
|
|
403
|
+
<div v-sanitize="{ html: userContent, allowedTags: ['b', 'i', 'u'] }"></div>
|
|
404
|
+
</template>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### v-tooltip
|
|
408
|
+
|
|
409
|
+
Display tooltips on hover or click.
|
|
410
|
+
|
|
411
|
+
```vue
|
|
412
|
+
<template>
|
|
413
|
+
<!-- Simple usage -->
|
|
414
|
+
<button v-tooltip="'Tooltip content'">Hover me</button>
|
|
415
|
+
|
|
416
|
+
<!-- With options -->
|
|
417
|
+
<button v-tooltip="{ content: 'Tooltip', placement: 'bottom', trigger: 'click' }">
|
|
418
|
+
Click me
|
|
419
|
+
</button>
|
|
420
|
+
</template>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### v-image-preview
|
|
424
|
+
|
|
425
|
+
Preview images with zoom and gesture support.
|
|
426
|
+
|
|
427
|
+
```vue
|
|
428
|
+
<template>
|
|
429
|
+
<!-- Simple usage -->
|
|
430
|
+
<img v-image-preview src="thumbnail.jpg" data-preview="full.jpg" />
|
|
431
|
+
|
|
432
|
+
<!-- With options -->
|
|
433
|
+
<img v-image-preview="{ src: 'thumbnail.jpg', previewSrc: 'full.jpg', enablePinchZoom: true }" />
|
|
434
|
+
</template>
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### v-draggable
|
|
438
|
+
|
|
439
|
+
Make elements draggable.
|
|
440
|
+
|
|
441
|
+
```vue
|
|
442
|
+
<template>
|
|
443
|
+
<!-- Simple usage -->
|
|
444
|
+
<div v-draggable>Drag me</div>
|
|
445
|
+
|
|
446
|
+
<!-- With constraints -->
|
|
447
|
+
<div v-draggable="{ axis: 'x', bounds: 'parent' }">Horizontal drag only</div>
|
|
448
|
+
</template>
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### v-uppercase / v-lowercase / v-capitalcase
|
|
452
|
+
|
|
453
|
+
Transform text case.
|
|
454
|
+
|
|
455
|
+
```vue
|
|
456
|
+
<template>
|
|
457
|
+
<input v-uppercase placeholder="Auto uppercase" />
|
|
458
|
+
<input v-lowercase placeholder="Auto lowercase" />
|
|
459
|
+
<input v-capitalcase placeholder="Capitalize first letter" />
|
|
460
|
+
</template>
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### v-truncate
|
|
464
|
+
|
|
465
|
+
Truncate text with ellipsis.
|
|
466
|
+
|
|
467
|
+
```vue
|
|
468
|
+
<template>
|
|
469
|
+
<!-- Simple usage -->
|
|
470
|
+
<p v-truncate="50">Long text here...</p>
|
|
471
|
+
|
|
472
|
+
<!-- With options -->
|
|
473
|
+
<p v-truncate="{ length: 100, suffix: '...', position: 'end' }">Long text...</p>
|
|
474
|
+
</template>
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### v-touch
|
|
478
|
+
|
|
479
|
+
Detect touch gestures.
|
|
480
|
+
|
|
481
|
+
```vue
|
|
482
|
+
<template>
|
|
483
|
+
<div v-touch="{ onSwipe: handleSwipe, onPinch: handlePinch }">
|
|
484
|
+
Swipe or pinch here
|
|
485
|
+
</div>
|
|
486
|
+
</template>
|
|
487
|
+
|
|
488
|
+
<script setup>
|
|
489
|
+
function handleSwipe(direction) {
|
|
490
|
+
console.log('Swiped:', direction) // 'left', 'right', 'up', 'down'
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function handlePinch(scale) {
|
|
494
|
+
console.log('Pinched:', scale)
|
|
495
|
+
}
|
|
496
|
+
</script>
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### v-trim
|
|
500
|
+
|
|
501
|
+
Trim input whitespace.
|
|
502
|
+
|
|
503
|
+
```vue
|
|
504
|
+
<template>
|
|
505
|
+
<!-- Trim on blur (default) -->
|
|
506
|
+
<input v-trim />
|
|
507
|
+
|
|
508
|
+
<!-- Trim on input -->
|
|
509
|
+
<input v-trim="{ position: 'both', event: 'input' }" />
|
|
510
|
+
</template>
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### v-money
|
|
514
|
+
|
|
515
|
+
Currency format input.
|
|
516
|
+
|
|
517
|
+
```vue
|
|
518
|
+
<template>
|
|
519
|
+
<input v-money="{ prefix: '$', precision: 2 }" placeholder="Enter amount" />
|
|
520
|
+
</template>
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### v-number
|
|
524
|
+
|
|
525
|
+
Number format input.
|
|
526
|
+
|
|
527
|
+
```vue
|
|
528
|
+
<template>
|
|
529
|
+
<input v-number="{ precision: 2, min: 0, max: 100 }" placeholder="Enter number" />
|
|
530
|
+
</template>
|
|
531
|
+
```
|
|
532
|
+
|
|
264
533
|
## API Reference
|
|
265
534
|
|
|
266
535
|
### DirectiveInstallOptions
|