@aiszlab/relax 1.2.51 → 1.2.53

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.
@@ -2,4 +2,4 @@
2
2
  * @description
3
3
  * extends from react `useId`
4
4
  */
5
- export declare const useIdentity: (signal: string) => [string, () => string];
5
+ export declare const useIdentity: (signal?: string) => [string, () => string];
@@ -0,0 +1,20 @@
1
+ import { useId, useRef, useCallback } from 'react';
2
+
3
+ /**
4
+ * @description
5
+ * extends from react `useId`
6
+ */
7
+ var useIdentity = function useIdentity() {
8
+ var signal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
9
+ var id = useId();
10
+ var count = useRef(0);
11
+ var unique = useCallback(function () {
12
+ if (!signal) {
13
+ return "".concat(id).concat(count.current++);
14
+ }
15
+ return "".concat(id).concat(signal, ":").concat(count.current++);
16
+ }, []);
17
+ return [id, unique];
18
+ };
19
+
20
+ export { useIdentity };
package/dist/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export { useMemorable } from './hooks/use-memorable';
25
25
  export { useMutateObserver } from './hooks/use-mutate-observer';
26
26
  export { useRaf } from './hooks/use-raf';
27
27
  export { useDevicePixelRatio } from './hooks/use-device-pixel-ratio';
28
+ export { useIdentity } from './hooks/use-identity';
28
29
  /**
29
30
  * @description
30
31
  * is
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ export { useMemorable } from './hooks/use-memorable.js';
21
21
  export { useMutateObserver } from './hooks/use-mutate-observer.js';
22
22
  export { useRaf } from './hooks/use-raf.js';
23
23
  export { useDevicePixelRatio } from './hooks/use-device-pixel-ratio.js';
24
+ export { useIdentity } from './hooks/use-identity.js';
24
25
  export { isRefable } from './is/is-refable.js';
25
26
  export { isUndefined } from './is/is-undefined.js';
26
27
  export { isStateGetter } from './is/is-state-getter.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "1.2.51",
3
+ "version": "1.2.53",
4
4
  "description": "react utils collection",
5
5
  "type": "module",
6
6
  "exports": {