directix 1.1.0 → 1.3.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 +379 -37
- package/dist/index.cjs +5081 -1790
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1162 -15
- package/dist/index.iife.js +5081 -1790
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +2 -2
- package/dist/index.mjs +5082 -1791
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -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** -
|
|
13
|
+
- 🎯 **Comprehensive** - 42 commonly used directives
|
|
14
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
|
|
|
@@ -114,60 +115,90 @@ Vue.directive('click-outside', vClickOutside)
|
|
|
114
115
|
|
|
115
116
|
### Event Directives
|
|
116
117
|
|
|
117
|
-
| Directive | Description | SSR |
|
|
118
|
-
|
|
119
|
-
| `v-click-outside` | Detect clicks outside an element | ❌ |
|
|
120
|
-
| `v-
|
|
121
|
-
| `v-
|
|
122
|
-
| `v-
|
|
118
|
+
| Directive | Description | SSR |
|
|
119
|
+
|-----------|-------------|-----|
|
|
120
|
+
| `v-click-outside` | Detect clicks outside an element | ❌ |
|
|
121
|
+
| `v-click-delay` | Delay click execution to prevent double clicks | ✅ |
|
|
122
|
+
| `v-debounce` | Debounce event handlers | ✅ |
|
|
123
|
+
| `v-throttle` | Throttle event handlers | ✅ |
|
|
124
|
+
| `v-long-press` | Detect long press events | ❌ |
|
|
125
|
+
| `v-hover` | Hover state detection | ❌ |
|
|
126
|
+
| `v-hotkey` | Keyboard shortcut binding | ✅ |
|
|
127
|
+
| `v-touch` | Touch gesture detection (swipe, pinch, rotate) | ❌ |
|
|
128
|
+
| `v-swipe` | Swipe gesture detection with mouse support | ❌ |
|
|
123
129
|
|
|
124
130
|
### Form Directives
|
|
125
131
|
|
|
126
|
-
| Directive | Description | SSR |
|
|
127
|
-
|
|
128
|
-
| `v-copy` | Copy text to clipboard | ❌ |
|
|
129
|
-
| `v-focus` | Auto focus an element | ✅ |
|
|
130
|
-
| `v-mask` | Input masking | ❌ |
|
|
132
|
+
| Directive | Description | SSR |
|
|
133
|
+
|-----------|-------------|-----|
|
|
134
|
+
| `v-copy` | Copy text to clipboard | ❌ |
|
|
135
|
+
| `v-focus` | Auto focus an element | ✅ |
|
|
136
|
+
| `v-mask` | Input masking | ❌ |
|
|
137
|
+
| `v-trim` | Trim input whitespace | ✅ |
|
|
138
|
+
| `v-money` | Currency format input | ❌ |
|
|
139
|
+
| `v-number` | Number format input | ❌ |
|
|
140
|
+
| `v-ellipsis` | Text ellipsis overflow | ✅ |
|
|
141
|
+
|
|
142
|
+
### Format Directives
|
|
143
|
+
|
|
144
|
+
| Directive | Description | SSR |
|
|
145
|
+
|-----------|-------------|-----|
|
|
146
|
+
| `v-uppercase` | Convert text to uppercase | ✅ |
|
|
147
|
+
| `v-lowercase` | Convert text to lowercase | ✅ |
|
|
148
|
+
| `v-capitalcase` | Capitalize first letter | ✅ |
|
|
149
|
+
| `v-truncate` | Truncate text with ellipsis | ✅ |
|
|
131
150
|
|
|
132
151
|
### Visibility Directives
|
|
133
152
|
|
|
134
|
-
| Directive | Description | SSR |
|
|
135
|
-
|
|
136
|
-
| `v-lazy` | Lazy load images | ❌ |
|
|
137
|
-
| `v-intersect` | Detect element intersection | ❌ |
|
|
138
|
-
| `v-visible` | Control element visibility | ✅ |
|
|
139
|
-
| `v-loading` | Show loading overlay | ✅ |
|
|
153
|
+
| Directive | Description | SSR |
|
|
154
|
+
|-----------|-------------|-----|
|
|
155
|
+
| `v-lazy` | Lazy load images | ❌ |
|
|
156
|
+
| `v-intersect` | Detect element intersection | ❌ |
|
|
157
|
+
| `v-visible` | Control element visibility | ✅ |
|
|
158
|
+
| `v-loading` | Show loading overlay | ✅ |
|
|
140
159
|
|
|
141
160
|
### Scroll Directives
|
|
142
161
|
|
|
143
|
-
| Directive | Description | SSR |
|
|
144
|
-
|
|
145
|
-
| `v-scroll` | Scroll event handling | ❌ |
|
|
146
|
-
| `v-infinite-scroll` | Infinite scrolling | ❌ |
|
|
147
|
-
| `v-sticky` | Sticky positioning | ❌ |
|
|
162
|
+
| Directive | Description | SSR |
|
|
163
|
+
|-----------|-------------|-----|
|
|
164
|
+
| `v-scroll` | Scroll event handling | ❌ |
|
|
165
|
+
| `v-infinite-scroll` | Infinite scrolling | ❌ |
|
|
166
|
+
| `v-sticky` | Sticky positioning | ❌ |
|
|
167
|
+
| `v-pull-refresh` | Pull to refresh functionality | ❌ |
|
|
168
|
+
| `v-virtual-list` | Virtual list for large datasets | ❌ |
|
|
148
169
|
|
|
149
170
|
### Security Directives
|
|
150
171
|
|
|
151
|
-
| Directive | Description | SSR |
|
|
152
|
-
|
|
153
|
-
| `v-permission` | Permission-based element control | ✅ |
|
|
154
|
-
| `v-sanitize` | Sanitize HTML content | ✅ |
|
|
172
|
+
| Directive | Description | SSR |
|
|
173
|
+
|-----------|-------------|-----|
|
|
174
|
+
| `v-permission` | Permission-based element control | ✅ |
|
|
175
|
+
| `v-sanitize` | Sanitize HTML content | ✅ |
|
|
155
176
|
|
|
156
177
|
### Effect Directives
|
|
157
178
|
|
|
158
|
-
| Directive | Description | SSR |
|
|
159
|
-
|
|
160
|
-
| `v-
|
|
161
|
-
| `v-
|
|
179
|
+
| Directive | Description | SSR |
|
|
180
|
+
|-----------|-------------|-----|
|
|
181
|
+
| `v-ripple` | Material design ripple effect | ❌ |
|
|
182
|
+
| `v-draggable` | Make elements draggable | ❌ |
|
|
162
183
|
|
|
163
184
|
### Observer Directives
|
|
164
185
|
|
|
165
|
-
| Directive | Description | SSR |
|
|
166
|
-
|
|
167
|
-
| `v-resize` | Element resize observer | ❌ |
|
|
168
|
-
| `v-mutation` | DOM mutation observer | ❌ |
|
|
186
|
+
| Directive | Description | SSR |
|
|
187
|
+
|-----------|-------------|-----|
|
|
188
|
+
| `v-resize` | Element resize observer | ❌ |
|
|
189
|
+
| `v-mutation` | DOM mutation observer | ❌ |
|
|
169
190
|
|
|
170
|
-
|
|
191
|
+
### UI Directives
|
|
192
|
+
|
|
193
|
+
| Directive | Description | SSR |
|
|
194
|
+
|-----------|-------------|-----|
|
|
195
|
+
| `v-tooltip` | Tooltip component | ❌ |
|
|
196
|
+
| `v-image-preview` | Image preview with zoom | ❌ |
|
|
197
|
+
| `v-countdown` | Countdown timer display | ✅ |
|
|
198
|
+
| `v-print` | Print element content | ❌ |
|
|
199
|
+
| `v-watermark` | Watermark overlay | ✅ |
|
|
200
|
+
|
|
201
|
+
> ✅ = SSR compatible | ❌ = Not SSR compatible
|
|
171
202
|
|
|
172
203
|
## Usage Examples
|
|
173
204
|
|
|
@@ -382,6 +413,317 @@ Sanitize HTML content to prevent XSS attacks.
|
|
|
382
413
|
</template>
|
|
383
414
|
```
|
|
384
415
|
|
|
416
|
+
### v-tooltip
|
|
417
|
+
|
|
418
|
+
Display tooltips on hover or click.
|
|
419
|
+
|
|
420
|
+
```vue
|
|
421
|
+
<template>
|
|
422
|
+
<!-- Simple usage -->
|
|
423
|
+
<button v-tooltip="'Tooltip content'">Hover me</button>
|
|
424
|
+
|
|
425
|
+
<!-- With options -->
|
|
426
|
+
<button v-tooltip="{ content: 'Tooltip', placement: 'bottom', trigger: 'click' }">
|
|
427
|
+
Click me
|
|
428
|
+
</button>
|
|
429
|
+
</template>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### v-image-preview
|
|
433
|
+
|
|
434
|
+
Preview images with zoom and gesture support.
|
|
435
|
+
|
|
436
|
+
```vue
|
|
437
|
+
<template>
|
|
438
|
+
<!-- Simple usage -->
|
|
439
|
+
<img v-image-preview src="thumbnail.jpg" data-preview="full.jpg" />
|
|
440
|
+
|
|
441
|
+
<!-- With options -->
|
|
442
|
+
<img v-image-preview="{ src: 'thumbnail.jpg', previewSrc: 'full.jpg', enablePinchZoom: true }" />
|
|
443
|
+
</template>
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### v-draggable
|
|
447
|
+
|
|
448
|
+
Make elements draggable.
|
|
449
|
+
|
|
450
|
+
```vue
|
|
451
|
+
<template>
|
|
452
|
+
<!-- Simple usage -->
|
|
453
|
+
<div v-draggable>Drag me</div>
|
|
454
|
+
|
|
455
|
+
<!-- With constraints -->
|
|
456
|
+
<div v-draggable="{ axis: 'x', bounds: 'parent' }">Horizontal drag only</div>
|
|
457
|
+
</template>
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### v-uppercase / v-lowercase / v-capitalcase
|
|
461
|
+
|
|
462
|
+
Transform text case.
|
|
463
|
+
|
|
464
|
+
```vue
|
|
465
|
+
<template>
|
|
466
|
+
<input v-uppercase placeholder="Auto uppercase" />
|
|
467
|
+
<input v-lowercase placeholder="Auto lowercase" />
|
|
468
|
+
<input v-capitalcase placeholder="Capitalize first letter" />
|
|
469
|
+
</template>
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### v-truncate
|
|
473
|
+
|
|
474
|
+
Truncate text with ellipsis.
|
|
475
|
+
|
|
476
|
+
```vue
|
|
477
|
+
<template>
|
|
478
|
+
<!-- Simple usage -->
|
|
479
|
+
<p v-truncate="50">Long text here...</p>
|
|
480
|
+
|
|
481
|
+
<!-- With options -->
|
|
482
|
+
<p v-truncate="{ length: 100, suffix: '...', position: 'end' }">Long text...</p>
|
|
483
|
+
</template>
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### v-touch
|
|
487
|
+
|
|
488
|
+
Detect touch gestures.
|
|
489
|
+
|
|
490
|
+
```vue
|
|
491
|
+
<template>
|
|
492
|
+
<div v-touch="{ onSwipe: handleSwipe, onPinch: handlePinch }">
|
|
493
|
+
Swipe or pinch here
|
|
494
|
+
</div>
|
|
495
|
+
</template>
|
|
496
|
+
|
|
497
|
+
<script setup>
|
|
498
|
+
function handleSwipe(direction) {
|
|
499
|
+
console.log('Swiped:', direction) // 'left', 'right', 'up', 'down'
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function handlePinch(scale) {
|
|
503
|
+
console.log('Pinched:', scale)
|
|
504
|
+
}
|
|
505
|
+
</script>
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### v-trim
|
|
509
|
+
|
|
510
|
+
Trim input whitespace.
|
|
511
|
+
|
|
512
|
+
```vue
|
|
513
|
+
<template>
|
|
514
|
+
<!-- Trim on blur (default) -->
|
|
515
|
+
<input v-trim />
|
|
516
|
+
|
|
517
|
+
<!-- Trim on input -->
|
|
518
|
+
<input v-trim="{ position: 'both', event: 'input' }" />
|
|
519
|
+
</template>
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### v-money
|
|
523
|
+
|
|
524
|
+
Currency format input.
|
|
525
|
+
|
|
526
|
+
```vue
|
|
527
|
+
<template>
|
|
528
|
+
<input v-money="{ prefix: '$', precision: 2 }" placeholder="Enter amount" />
|
|
529
|
+
</template>
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### v-number
|
|
533
|
+
|
|
534
|
+
Number format input.
|
|
535
|
+
|
|
536
|
+
```vue
|
|
537
|
+
<template>
|
|
538
|
+
<input v-number="{ precision: 2, min: 0, max: 100 }" placeholder="Enter number" />
|
|
539
|
+
</template>
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
### v-click-delay
|
|
543
|
+
|
|
544
|
+
Delay click execution to prevent double clicks.
|
|
545
|
+
|
|
546
|
+
```vue
|
|
547
|
+
<template>
|
|
548
|
+
<!-- Default: 300ms delay -->
|
|
549
|
+
<button v-click-delay="handleClick">Click me</button>
|
|
550
|
+
|
|
551
|
+
<!-- Custom delay time -->
|
|
552
|
+
<button v-click-delay="{ handler: handleClick, delay: 500 }">500ms delay</button>
|
|
553
|
+
</template>
|
|
554
|
+
|
|
555
|
+
<script setup>
|
|
556
|
+
function handleClick() {
|
|
557
|
+
console.log('Clicked (delayed)')
|
|
558
|
+
}
|
|
559
|
+
</script>
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### v-countdown
|
|
563
|
+
|
|
564
|
+
Countdown timer display.
|
|
565
|
+
|
|
566
|
+
```vue
|
|
567
|
+
<template>
|
|
568
|
+
<!-- Simple usage -->
|
|
569
|
+
<span v-countdown="{ time: 60 }"></span>
|
|
570
|
+
|
|
571
|
+
<!-- With callbacks -->
|
|
572
|
+
<span v-countdown="{ time: 60, onTick: handleTick, onComplete: handleComplete }"></span>
|
|
573
|
+
|
|
574
|
+
<!-- Custom format -->
|
|
575
|
+
<span v-countdown="{ time: 3600, format: 'mm:ss' }"></span>
|
|
576
|
+
</template>
|
|
577
|
+
|
|
578
|
+
<script setup>
|
|
579
|
+
function handleTick(remaining) {
|
|
580
|
+
console.log('Remaining:', remaining)
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function handleComplete() {
|
|
584
|
+
console.log('Countdown complete!')
|
|
585
|
+
}
|
|
586
|
+
</script>
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### v-ellipsis
|
|
590
|
+
|
|
591
|
+
Text ellipsis overflow with tooltip.
|
|
592
|
+
|
|
593
|
+
```vue
|
|
594
|
+
<template>
|
|
595
|
+
<!-- Simple usage -->
|
|
596
|
+
<div v-ellipsis style="width: 200px;">Long text that will be truncated</div>
|
|
597
|
+
|
|
598
|
+
<!-- With custom lines -->
|
|
599
|
+
<div v-ellipsis="{ lines: 2 }">Multi-line text with ellipsis</div>
|
|
600
|
+
</template>
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
### v-hotkey
|
|
604
|
+
|
|
605
|
+
Keyboard shortcut binding.
|
|
606
|
+
|
|
607
|
+
```vue
|
|
608
|
+
<template>
|
|
609
|
+
<!-- Simple usage -->
|
|
610
|
+
<div v-hotkey="{ 'ctrl+s': handleSave, 'ctrl+c': handleCopy }">
|
|
611
|
+
Press Ctrl+S to save
|
|
612
|
+
</div>
|
|
613
|
+
|
|
614
|
+
<!-- With modifiers -->
|
|
615
|
+
<input v-hotkey="{ 'enter': submit, 'escape': cancel }" />
|
|
616
|
+
</template>
|
|
617
|
+
|
|
618
|
+
<script setup>
|
|
619
|
+
function handleSave() {
|
|
620
|
+
console.log('Saving...')
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function handleCopy() {
|
|
624
|
+
console.log('Copying...')
|
|
625
|
+
}
|
|
626
|
+
</script>
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
### v-print
|
|
630
|
+
|
|
631
|
+
Print element content.
|
|
632
|
+
|
|
633
|
+
```vue
|
|
634
|
+
<template>
|
|
635
|
+
<!-- Simple usage -->
|
|
636
|
+
<button v-print="printRef">Print</button>
|
|
637
|
+
<div ref="printRef">Content to print</div>
|
|
638
|
+
|
|
639
|
+
<!-- Print self -->
|
|
640
|
+
<div v-print="{ self: true }">Click to print this content</div>
|
|
641
|
+
</template>
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
### v-pull-refresh
|
|
645
|
+
|
|
646
|
+
Pull to refresh functionality.
|
|
647
|
+
|
|
648
|
+
```vue
|
|
649
|
+
<template>
|
|
650
|
+
<div v-pull-refresh="handleRefresh" style="height: 400px; overflow: auto;">
|
|
651
|
+
Pull down to refresh
|
|
652
|
+
</div>
|
|
653
|
+
|
|
654
|
+
<!-- With options -->
|
|
655
|
+
<div v-pull-refresh="{ handler: handleRefresh, threshold: 80, disabled: false }">
|
|
656
|
+
Content
|
|
657
|
+
</div>
|
|
658
|
+
</template>
|
|
659
|
+
|
|
660
|
+
<script setup>
|
|
661
|
+
async function handleRefresh() {
|
|
662
|
+
// Fetch new data
|
|
663
|
+
await fetchData()
|
|
664
|
+
}
|
|
665
|
+
</script>
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
### v-swipe
|
|
669
|
+
|
|
670
|
+
Swipe gesture detection with mouse support.
|
|
671
|
+
|
|
672
|
+
```vue
|
|
673
|
+
<template>
|
|
674
|
+
<div v-swipe="handleSwipe" style="height: 200px;">
|
|
675
|
+
Swipe in any direction
|
|
676
|
+
</div>
|
|
677
|
+
|
|
678
|
+
<!-- With options -->
|
|
679
|
+
<div v-swipe="{ onSwipe: handleSwipe, threshold: 50, enableMouse: true }">
|
|
680
|
+
Swipe or drag with mouse
|
|
681
|
+
</div>
|
|
682
|
+
</template>
|
|
683
|
+
|
|
684
|
+
<script setup>
|
|
685
|
+
function handleSwipe(direction) {
|
|
686
|
+
console.log('Swiped:', direction) // 'left', 'right', 'up', 'down'
|
|
687
|
+
}
|
|
688
|
+
</script>
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
### v-virtual-list
|
|
692
|
+
|
|
693
|
+
Virtual list for rendering large datasets efficiently.
|
|
694
|
+
|
|
695
|
+
```vue
|
|
696
|
+
<template>
|
|
697
|
+
<div v-virtual-list="{ items: list, itemSize: 50 }" style="height: 500px;">
|
|
698
|
+
<template #default="{ item, index }">
|
|
699
|
+
<div :key="index">{{ item.name }}</div>
|
|
700
|
+
</template>
|
|
701
|
+
</div>
|
|
702
|
+
</template>
|
|
703
|
+
|
|
704
|
+
<script setup>
|
|
705
|
+
const list = Array.from({ length: 10000 }, (_, i) => ({ id: i, name: `Item ${i}` }))
|
|
706
|
+
</script>
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
### v-watermark
|
|
710
|
+
|
|
711
|
+
Watermark overlay.
|
|
712
|
+
|
|
713
|
+
```vue
|
|
714
|
+
<template>
|
|
715
|
+
<!-- Simple usage -->
|
|
716
|
+
<div v-watermark="'Confidential'" style="width: 100%; height: 400px;">
|
|
717
|
+
Protected content
|
|
718
|
+
</div>
|
|
719
|
+
|
|
720
|
+
<!-- With options -->
|
|
721
|
+
<div v-watermark="{ content: 'Draft', fontSize: 16, color: '#ccc', rotate: -20 }">
|
|
722
|
+
Content with watermark
|
|
723
|
+
</div>
|
|
724
|
+
</template>
|
|
725
|
+
```
|
|
726
|
+
|
|
385
727
|
## API Reference
|
|
386
728
|
|
|
387
729
|
### DirectiveInstallOptions
|