@bifrostui/utils 1.3.1-beta.0 → 1.3.1-beta.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.
@@ -7,4 +7,5 @@ import useDomReady from './useDomReady';
7
7
  import useSize from './useSize';
8
8
  import useDomCss from './useDomCss';
9
9
  import useTouch from './useTouch';
10
- export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, useTouch, };
10
+ import useUniqueId from './useUniqueId';
11
+ export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, useTouch, useUniqueId, };
@@ -35,6 +35,7 @@ __export(hooks_exports, {
35
35
  useSize: () => import_useSize.default,
36
36
  useTouch: () => import_useTouch.default,
37
37
  useTouchEmulator: () => import_useTouchEmulator.default,
38
+ useUniqueId: () => import_useUniqueId.default,
38
39
  useValue: () => import_useValue.default
39
40
  });
40
41
  module.exports = __toCommonJS(hooks_exports);
@@ -47,6 +48,7 @@ var import_useDomReady = __toESM(require("./useDomReady"));
47
48
  var import_useSize = __toESM(require("./useSize"));
48
49
  var import_useDomCss = __toESM(require("./useDomCss"));
49
50
  var import_useTouch = __toESM(require("./useTouch"));
51
+ var import_useUniqueId = __toESM(require("./useUniqueId"));
50
52
  // Annotate the CommonJS export names for ESM import in node:
51
53
  0 && (module.exports = {
52
54
  useDidMountEffect,
@@ -57,5 +59,6 @@ var import_useTouch = __toESM(require("./useTouch"));
57
59
  useSize,
58
60
  useTouch,
59
61
  useTouchEmulator,
62
+ useUniqueId,
60
63
  useValue
61
64
  });
@@ -0,0 +1,2 @@
1
+ declare function useUniqueId(): string;
2
+ export default useUniqueId;
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var useUniqueId_exports = {};
19
+ __export(useUniqueId_exports, {
20
+ default: () => useUniqueId_default
21
+ });
22
+ module.exports = __toCommonJS(useUniqueId_exports);
23
+ var import_react = require("react");
24
+ let globalClientIdCounter = 0;
25
+ function useUniqueId() {
26
+ const idRef = (0, import_react.useRef)();
27
+ if (!idRef.current) {
28
+ globalClientIdCounter += 1;
29
+ idRef.current = `b${globalClientIdCounter.toString(32)}`;
30
+ }
31
+ return idRef.current;
32
+ }
33
+ var useUniqueId_default = useUniqueId;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { default as debounce } from './debounce';
2
2
  export { getStylesAndLocation, triggerEventTransform, } from './directionLocationUtil';
3
3
  export { default as convertHexToRGBA } from './hex2rgba';
4
- export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, useValue, useDomReady, useSize, useDomCss, useTouch, } from './hooks';
4
+ export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, useValue, useDomReady, useSize, useDomCss, useTouch, useUniqueId, } from './hooks';
5
5
  export { default as isDev } from './isDev';
6
6
  export { isMini, isWeapp, isAlipay, isMiniapp } from './isMini';
7
7
  export { default as setRef } from './setRef';
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ __export(src_exports, {
55
55
  useSize: () => import_hooks.useSize,
56
56
  useTouch: () => import_hooks.useTouch,
57
57
  useTouchEmulator: () => import_hooks.useTouchEmulator,
58
+ useUniqueId: () => import_hooks.useUniqueId,
58
59
  useValue: () => import_hooks.useValue
59
60
  });
60
61
  module.exports = __toCommonJS(src_exports);
@@ -102,6 +103,7 @@ __reExport(src_exports, require("./render"), module.exports);
102
103
  useSize,
103
104
  useTouch,
104
105
  useTouchEmulator,
106
+ useUniqueId,
105
107
  useValue,
106
108
  ...require("./isType"),
107
109
  ...require("./render")
@@ -7,4 +7,5 @@ import useDomReady from './useDomReady';
7
7
  import useSize from './useSize';
8
8
  import useDomCss from './useDomCss';
9
9
  import useTouch from './useTouch';
10
- export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, useTouch, };
10
+ import useUniqueId from './useUniqueId';
11
+ export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, useTouch, useUniqueId, };
package/es/hooks/index.js CHANGED
@@ -7,6 +7,7 @@ import useDomReady from "./useDomReady";
7
7
  import useSize from "./useSize";
8
8
  import useDomCss from "./useDomCss";
9
9
  import useTouch from "./useTouch";
10
+ import useUniqueId from "./useUniqueId";
10
11
  export {
11
12
  useDidMountEffect,
12
13
  useDomCss,
@@ -16,5 +17,6 @@ export {
16
17
  useSize,
17
18
  useTouch,
18
19
  useTouchEmulator,
20
+ useUniqueId,
19
21
  useValue
20
22
  };
@@ -0,0 +1,2 @@
1
+ declare function useUniqueId(): string;
2
+ export default useUniqueId;
@@ -0,0 +1,14 @@
1
+ import { useRef } from "react";
2
+ let globalClientIdCounter = 0;
3
+ function useUniqueId() {
4
+ const idRef = useRef();
5
+ if (!idRef.current) {
6
+ globalClientIdCounter += 1;
7
+ idRef.current = `b${globalClientIdCounter.toString(32)}`;
8
+ }
9
+ return idRef.current;
10
+ }
11
+ var useUniqueId_default = useUniqueId;
12
+ export {
13
+ useUniqueId_default as default
14
+ };
package/es/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { default as debounce } from './debounce';
2
2
  export { getStylesAndLocation, triggerEventTransform, } from './directionLocationUtil';
3
3
  export { default as convertHexToRGBA } from './hex2rgba';
4
- export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, useValue, useDomReady, useSize, useDomCss, useTouch, } from './hooks';
4
+ export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, useValue, useDomReady, useSize, useDomCss, useTouch, useUniqueId, } from './hooks';
5
5
  export { default as isDev } from './isDev';
6
6
  export { isMini, isWeapp, isAlipay, isMiniapp } from './isMini';
7
7
  export { default as setRef } from './setRef';
package/es/index.js CHANGED
@@ -13,7 +13,8 @@ import {
13
13
  useDomReady,
14
14
  useSize,
15
15
  useDomCss,
16
- useTouch
16
+ useTouch,
17
+ useUniqueId
17
18
  } from "./hooks";
18
19
  import { default as default4 } from "./isDev";
19
20
  import { isMini, isWeapp, isAlipay, isMiniapp } from "./isMini";
@@ -59,5 +60,6 @@ export {
59
60
  useSize,
60
61
  useTouch,
61
62
  useTouchEmulator,
63
+ useUniqueId,
62
64
  useValue
63
65
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifrostui/utils",
3
- "version": "1.3.1-beta.0",
3
+ "version": "1.3.1-beta.1",
4
4
  "description": "BUI React utilities for building components.",
5
5
  "main": "dist/index.js",
6
6
  "module": "es/index.js",