@varlet/use 2.16.7 → 2.16.8-alpha.1695227124357

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/lib/index.d.ts CHANGED
@@ -65,4 +65,6 @@ declare function useTouch(): {
65
65
  endTouch: () => void;
66
66
  };
67
67
 
68
- export { TouchDirection, UseChildrenBaseProvider, UseClickOutsideTarget, UseEventListenerOptions, UseEventListenerTarget, keyInProvides, onSmartMounted, onSmartUnmounted, onWindowResize, useChildren, useClickOutside, useEventListener, useInitialized, useParent, useTouch };
68
+ declare function useId(): vue.Ref<string | undefined>;
69
+
70
+ export { TouchDirection, UseChildrenBaseProvider, UseClickOutsideTarget, UseEventListenerOptions, UseEventListenerTarget, keyInProvides, onSmartMounted, onSmartUnmounted, onWindowResize, useChildren, useClickOutside, useEventListener, useId, useInitialized, useParent, useTouch };
package/lib/index.js CHANGED
@@ -365,6 +365,17 @@ function useTouch() {
365
365
  endTouch
366
366
  };
367
367
  }
368
+
369
+ // src/useId.ts
370
+ import { ref as ref3, getCurrentInstance as getCurrentInstance3 } from "vue";
371
+ import { kebabCase } from "@varlet/shared";
372
+ function useId() {
373
+ const id = ref3();
374
+ const instance = getCurrentInstance3();
375
+ const name = kebabCase(instance.type.name);
376
+ id.value = process.env.NODE_ENV === "test" ? `${name}-mock-id` : `${name}-${instance.uid}`;
377
+ return id;
378
+ }
368
379
  export {
369
380
  keyInProvides,
370
381
  onSmartMounted,
@@ -373,6 +384,7 @@ export {
373
384
  useChildren,
374
385
  useClickOutside,
375
386
  useEventListener,
387
+ useId,
376
388
  useInitialized,
377
389
  useParent,
378
390
  useTouch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/use",
3
- "version": "2.16.7",
3
+ "version": "2.16.8-alpha.1695227124357",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
@@ -24,9 +24,10 @@
24
24
  "url": "https://github.com/varletjs/varlet/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@varlet/shared": "2.16.7"
27
+ "@varlet/shared": "2.16.8-alpha.1695227124357"
28
28
  },
29
29
  "devDependencies": {
30
+ "@types/node": "^18.7.18",
30
31
  "tsup": "7.2.0",
31
32
  "typescript": "^5.1.5",
32
33
  "vue": "3.3.4"