directix 1.3.0 → 1.4.1
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 +128 -1
- package/dist/index.cjs +4596 -436
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3587 -1455
- package/dist/index.iife.js +4597 -438
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +2 -2
- package/dist/index.mjs +4589 -429
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,13 +10,15 @@ A comprehensive, easy-to-use, and high-performance Vue custom directives library
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
- 🎯 **Comprehensive** -
|
|
13
|
+
- 🎯 **Comprehensive** - 40 commonly used directives and 40 composables
|
|
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
17
|
- 🚀 **SSR Friendly** - Multiple directives support SSR out of the box
|
|
18
18
|
- 📦 **Multiple Formats** - ESM, CJS, and IIFE (CDN) formats available
|
|
19
19
|
- ⚡ **Zero Dependencies** - Lightweight with minimal bundle size
|
|
20
|
+
- 🎨 **Composables** - Every directive has a corresponding composable for Composition API
|
|
21
|
+
- 🔧 **Utility Exports** - Export `configurePermission`, `getPermissionConfig` and other utilities for advanced usage
|
|
20
22
|
|
|
21
23
|
## Online Demo
|
|
22
24
|
|
|
@@ -111,6 +113,21 @@ app.directive('copy', vCopy)
|
|
|
111
113
|
Vue.directive('click-outside', vClickOutside)
|
|
112
114
|
```
|
|
113
115
|
|
|
116
|
+
### Using Composables
|
|
117
|
+
|
|
118
|
+
Every directive has a corresponding composable for use with the Composition API:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { useClickOutside, useCopy, useDebounce } from 'directix'
|
|
122
|
+
|
|
123
|
+
// In setup() or <script setup>
|
|
124
|
+
const { copy, copied } = useCopy({ source: textRef })
|
|
125
|
+
const { isHovering, bind } = useHover({ onEnter: handleEnter })
|
|
126
|
+
const { run: debouncedSearch } = useDebounce({ handler: search, wait: 500 })
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
See the [Composables](#composables) section below for all available composables.
|
|
130
|
+
|
|
114
131
|
## Available Directives
|
|
115
132
|
|
|
116
133
|
### Event Directives
|
|
@@ -200,6 +217,116 @@ Vue.directive('click-outside', vClickOutside)
|
|
|
200
217
|
|
|
201
218
|
> ✅ = SSR compatible | ❌ = Not SSR compatible
|
|
202
219
|
|
|
220
|
+
## Composables
|
|
221
|
+
|
|
222
|
+
Every directive has a corresponding composable function for use with the Composition API. All composables are exported from `directix`:
|
|
223
|
+
|
|
224
|
+
### Event Composables
|
|
225
|
+
|
|
226
|
+
| Composable | Description |
|
|
227
|
+
|------------|-------------|
|
|
228
|
+
| `useClickOutside` | Detect clicks outside an element |
|
|
229
|
+
| `useClickDelay` | Delay click execution |
|
|
230
|
+
| `useDebounce` | Debounce function calls |
|
|
231
|
+
| `useThrottle` | Throttle function calls |
|
|
232
|
+
| `useLongPress` | Detect long press gestures |
|
|
233
|
+
| `useHover` | Track hover state |
|
|
234
|
+
| `useHotkey` | Handle keyboard shortcuts |
|
|
235
|
+
| `useTouch` | Detect touch gestures |
|
|
236
|
+
| `useSwipe` | Detect swipe gestures |
|
|
237
|
+
|
|
238
|
+
### Form Composables
|
|
239
|
+
|
|
240
|
+
| Composable | Description |
|
|
241
|
+
|------------|-------------|
|
|
242
|
+
| `useCopy` | Copy text to clipboard |
|
|
243
|
+
| `useFocus` | Manage element focus |
|
|
244
|
+
| `useMask` | Input masking |
|
|
245
|
+
| `useTrim` | Trim input whitespace |
|
|
246
|
+
| `useMoney` | Currency formatting |
|
|
247
|
+
| `useNumber` | Number formatting |
|
|
248
|
+
| `useEllipsis` | Text ellipsis overflow |
|
|
249
|
+
|
|
250
|
+
### Format Composables
|
|
251
|
+
|
|
252
|
+
| Composable | Description |
|
|
253
|
+
|------------|-------------|
|
|
254
|
+
| `useUppercase` | Transform to uppercase |
|
|
255
|
+
| `useLowercase` | Transform to lowercase |
|
|
256
|
+
| `useCapitalcase` | Capitalize text |
|
|
257
|
+
| `useTruncate` | Truncate text |
|
|
258
|
+
|
|
259
|
+
### Visibility Composables
|
|
260
|
+
|
|
261
|
+
| Composable | Description |
|
|
262
|
+
|------------|-------------|
|
|
263
|
+
| `useLazy` | Lazy load images |
|
|
264
|
+
| `useIntersect` | Detect element intersection |
|
|
265
|
+
| `useVisible` | Control element visibility |
|
|
266
|
+
| `useLoading` | Show loading overlay |
|
|
267
|
+
|
|
268
|
+
### Scroll Composables
|
|
269
|
+
|
|
270
|
+
| Composable | Description |
|
|
271
|
+
|------------|-------------|
|
|
272
|
+
| `useScroll` | Track scroll position |
|
|
273
|
+
| `useInfiniteScroll` | Infinite scrolling |
|
|
274
|
+
| `useSticky` | Sticky positioning |
|
|
275
|
+
| `usePullRefresh` | Pull to refresh |
|
|
276
|
+
| `useVirtualList` | Virtual list for large datasets |
|
|
277
|
+
|
|
278
|
+
### Other Composables
|
|
279
|
+
|
|
280
|
+
| Composable | Description |
|
|
281
|
+
|------------|-------------|
|
|
282
|
+
| `usePermission` | Permission checking |
|
|
283
|
+
| `useSanitize` | Sanitize HTML content |
|
|
284
|
+
| `useRipple` | Material design ripple effect |
|
|
285
|
+
| `useDraggable` | Make elements draggable |
|
|
286
|
+
| `useResize` | Element resize observer |
|
|
287
|
+
| `useMutation` | DOM mutation observer |
|
|
288
|
+
| `useTooltip` | Tooltip control |
|
|
289
|
+
| `useImagePreview` | Image preview with zoom |
|
|
290
|
+
| `useCountdown` | Countdown timer |
|
|
291
|
+
| `usePrint` | Print content |
|
|
292
|
+
| `useWatermark` | Watermark overlay |
|
|
293
|
+
|
|
294
|
+
### Composable Usage Example
|
|
295
|
+
|
|
296
|
+
```vue
|
|
297
|
+
<script setup>
|
|
298
|
+
import { ref } from 'vue'
|
|
299
|
+
import { useCopy, useHover, useDebounce } from 'directix'
|
|
300
|
+
|
|
301
|
+
// useCopy
|
|
302
|
+
const text = ref('Hello World')
|
|
303
|
+
const { copy, copied } = useCopy({ source: text })
|
|
304
|
+
|
|
305
|
+
// useHover
|
|
306
|
+
const buttonRef = ref()
|
|
307
|
+
const { isHovering, bind } = useHover({
|
|
308
|
+
onEnter: () => console.log('Entered'),
|
|
309
|
+
onLeave: () => console.log('Left')
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
// useDebounce
|
|
313
|
+
const { run: debouncedSearch } = useDebounce({
|
|
314
|
+
handler: (query) => fetchResults(query),
|
|
315
|
+
wait: 500
|
|
316
|
+
})
|
|
317
|
+
</script>
|
|
318
|
+
|
|
319
|
+
<template>
|
|
320
|
+
<button @click="copy()">
|
|
321
|
+
{{ copied ? 'Copied!' : 'Copy' }}
|
|
322
|
+
</button>
|
|
323
|
+
|
|
324
|
+
<button ref="buttonRef" :class="{ active: isHovering }">
|
|
325
|
+
Hover me
|
|
326
|
+
</button>
|
|
327
|
+
</template>
|
|
328
|
+
```
|
|
329
|
+
|
|
203
330
|
## Usage Examples
|
|
204
331
|
|
|
205
332
|
### v-click-outside
|