directix 1.0.0 → 1.1.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/directix.svg)](https://www.npmjs.com/package/directix)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/directix.svg)](https://www.npmjs.com/package/directix)
5
- [![GitHub license](https://img.shields.io/github/license/saqqdy/directix)](https://github.com/saqqdy/directix/blob/main/LICENSE)
5
+ [![GitHub license](https://img.shields.io/github/license/saqqdy/directix)](https://github.com/saqqdy/directix/blob/master/LICENSE)
6
6
 
7
7
  **[中文文档](README_CN.md)**
8
8
 
@@ -10,11 +10,11 @@ A comprehensive, easy-to-use, and high-performance Vue custom directives library
10
10
 
11
11
  ## Features
12
12
 
13
- - 🎯 **Comprehensive** - 30+ commonly used directives
14
- - 🔄 **Vue 2/3 Compatible** - Built on [vue-demi](https://github.com/vueuse/vue-demi), single codebase supports both versions
13
+ - 🎯 **Comprehensive** - 21+ 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** - Works with Nuxt and other SSR frameworks
17
+ - 🚀 **SSR Friendly** - 7 directives support SSR out of the box
18
18
  - 📦 **Multiple Formats** - ESM, CJS, and IIFE (CDN) formats available
19
19
 
20
20
  ## Online Demo
@@ -23,8 +23,8 @@ Try it online with StackBlitz:
23
23
 
24
24
  | Demo | Link |
25
25
  |------|------|
26
- | Vue 3 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/saqqdy/directix/tree/main/examples/vue3) |
27
- | Vue 2 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/saqqdy/directix/tree/main/examples/vue2) |
26
+ | Vue 3 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/saqqdy/directix/tree/master/examples/vue3) |
27
+ | Vue 2 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/saqqdy/directix/tree/master/examples/vue2) |
28
28
 
29
29
  ## Installation
30
30
 
@@ -63,7 +63,7 @@ You can also use Directix via CDN:
63
63
  <script src="https://unpkg.com/directix/dist/index.iife.min.js"></script>
64
64
  ```
65
65
 
66
- The CDN build includes `vue-demi` bundled internally, so it works seamlessly with both Vue 2 and Vue 3.
66
+ The CDN build works seamlessly with both Vue 2 and Vue 3.
67
67
 
68
68
  ## Requirements
69
69
 
@@ -114,37 +114,60 @@ Vue.directive('click-outside', vClickOutside)
114
114
 
115
115
  ### Event Directives
116
116
 
117
- | Directive | Description | Status |
118
- |-----------|-------------|--------|
119
- | `v-click-outside` | Detect clicks outside an element | ✅ |
120
- | `v-debounce` | Debounce event handlers | ✅ |
121
- | `v-throttle` | Throttle event handlers | ✅ |
122
- | `v-long-press` | Detect long press events | |
117
+ | Directive | Description | SSR | Status |
118
+ |-----------|-------------|-----|--------|
119
+ | `v-click-outside` | Detect clicks outside an element | ❌ | ✅ |
120
+ | `v-debounce` | Debounce event handlers | ✅ | ✅ |
121
+ | `v-throttle` | Throttle event handlers | ✅ | ✅ |
122
+ | `v-long-press` | Detect long press events | | ✅ |
123
123
 
124
124
  ### Form Directives
125
125
 
126
- | Directive | Description | Status |
127
- |-----------|-------------|--------|
128
- | `v-copy` | Copy text to clipboard | ✅ |
129
- | `v-focus` | Auto focus an element | ✅ |
130
- | `v-mask` | Input masking | |
126
+ | Directive | Description | SSR | Status |
127
+ |-----------|-------------|-----|--------|
128
+ | `v-copy` | Copy text to clipboard | ❌ | ✅ |
129
+ | `v-focus` | Auto focus an element | ✅ | ✅ |
130
+ | `v-mask` | Input masking | | ✅ |
131
131
 
132
132
  ### Visibility Directives
133
133
 
134
- | Directive | Description | Status |
135
- |-----------|-------------|--------|
136
- | `v-lazy` | Lazy load images | |
137
- | `v-intersect` | Detect element intersection | |
138
- | `v-visible` | Control element visibility | |
134
+ | Directive | Description | SSR | Status |
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 | ✅ | ✅ |
140
+
141
+ ### Scroll Directives
142
+
143
+ | Directive | Description | SSR | Status |
144
+ |-----------|-------------|-----|--------|
145
+ | `v-scroll` | Scroll event handling | ❌ | ✅ |
146
+ | `v-infinite-scroll` | Infinite scrolling | ❌ | ✅ |
147
+ | `v-sticky` | Sticky positioning | ❌ | ✅ |
139
148
 
140
149
  ### Security Directives
141
150
 
142
- | Directive | Description | Status |
143
- |-----------|-------------|--------|
144
- | `v-permission` | Permission-based element control | |
145
- | `v-sanitize` | Sanitize HTML content | |
151
+ | Directive | Description | SSR | Status |
152
+ |-----------|-------------|-----|--------|
153
+ | `v-permission` | Permission-based element control | | ✅ |
154
+ | `v-sanitize` | Sanitize HTML content | | ✅ |
155
+
156
+ ### Effect Directives
157
+
158
+ | Directive | Description | SSR | Status |
159
+ |-----------|-------------|-----|--------|
160
+ | `v-hover` | Hover state detection | ❌ | ✅ |
161
+ | `v-ripple` | Material design ripple effect | ❌ | ✅ |
146
162
 
147
- > = Available | ⏳ = Coming soon
163
+ ### Observer Directives
164
+
165
+ | Directive | Description | SSR | Status |
166
+ |-----------|-------------|-----|--------|
167
+ | `v-resize` | Element resize observer | ❌ | ✅ |
168
+ | `v-mutation` | DOM mutation observer | ❌ | ✅ |
169
+
170
+ > ✅ = Available | ❌ = Not SSR compatible
148
171
 
149
172
  ## Usage Examples
150
173
 
@@ -261,6 +284,104 @@ Auto focus an element when mounted.
261
284
  </template>
262
285
  ```
263
286
 
287
+ ### v-permission
288
+
289
+ Control element visibility based on user permissions.
290
+
291
+ ```vue
292
+ <template>
293
+ <!-- Simple permission check -->
294
+ <button v-permission="'admin'">Admin Only</button>
295
+
296
+ <!-- Multiple permissions (OR logic) -->
297
+ <button v-permission="['admin', 'editor']">Admin or Editor</button>
298
+
299
+ <!-- AND logic -->
300
+ <button v-permission="{ value: ['read', 'write'], mode: 'every' }">
301
+ Requires both permissions
302
+ </button>
303
+
304
+ <!-- Disable instead of remove -->
305
+ <button v-permission="{ value: 'admin', action: 'disable' }">
306
+ Disabled for non-admin
307
+ </button>
308
+ </template>
309
+
310
+ <script setup>
311
+ import { configurePermission } from 'directix'
312
+
313
+ configurePermission({
314
+ getPermissions: () => ['read', 'write'],
315
+ getRoles: () => ['editor'],
316
+ roleMap: {
317
+ admin: ['*'],
318
+ editor: ['read', 'write', 'edit']
319
+ }
320
+ })
321
+ </script>
322
+ ```
323
+
324
+ ### v-lazy
325
+
326
+ Lazy load images when they enter the viewport.
327
+
328
+ ```vue
329
+ <template>
330
+ <!-- Simple usage -->
331
+ <img v-lazy="imageUrl" />
332
+
333
+ <!-- With placeholder and error image -->
334
+ <img v-lazy="{ src: imageUrl, placeholder: '/placeholder.png', error: '/error.png' }" />
335
+ </template>
336
+ ```
337
+
338
+ ### v-mask
339
+
340
+ Input masking for formatted input.
341
+
342
+ ```vue
343
+ <template>
344
+ <!-- Phone number -->
345
+ <input v-mask="'(###) ###-####'" placeholder="Phone" />
346
+
347
+ <!-- Date -->
348
+ <input v-mask="'##/##/####'" placeholder="MM/DD/YYYY" />
349
+
350
+ <!-- SSN -->
351
+ <input v-mask="{ mask: '###-##-####', placeholder: '_' }" placeholder="SSN" />
352
+ </template>
353
+ ```
354
+
355
+ ### v-loading
356
+
357
+ Show loading overlay on elements.
358
+
359
+ ```vue
360
+ <template>
361
+ <!-- Simple usage -->
362
+ <div v-loading="isLoading">Content</div>
363
+
364
+ <!-- With options -->
365
+ <div v-loading="{ value: isLoading, text: 'Loading...', lock: true }">
366
+ Content with locked scroll
367
+ </div>
368
+ </template>
369
+ ```
370
+
371
+ ### v-sanitize
372
+
373
+ Sanitize HTML content to prevent XSS attacks.
374
+
375
+ ```vue
376
+ <template>
377
+ <!-- Simple usage -->
378
+ <div v-sanitize="userContent"></div>
379
+
380
+ <!-- With custom allowed tags -->
381
+ <div v-sanitize="{ html: userContent, allowedTags: ['b', 'i', 'u'] }"></div>
382
+ </template>
383
+ ```
384
+
264
385
  ## API Reference
265
386
 
266
387
  ### DirectiveInstallOptions