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