@radix-ui/react-id 1.0.1 → 1.1.0-rc.2
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +44 -27
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +14 -22
- package/dist/index.mjs.map +7 -1
- package/package.json +4 -4
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
declare function useId(deterministicId?: string): string;
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export { useId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
declare function useId(deterministicId?: string): string;
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export { useId };
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
// packages/react/id/src/id.tsx
|
|
33
|
+
var React = __toESM(__require("react"));
|
|
34
|
+
var import_react_use_layout_effect = __require("@radix-ui/react-use-layout-effect");
|
|
35
|
+
var useReactId = React["useId".toString()] || (() => void 0);
|
|
36
|
+
var count = 0;
|
|
37
|
+
function useId(deterministicId) {
|
|
38
|
+
const [id, setId] = React.useState(useReactId());
|
|
39
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
40
|
+
if (!deterministicId) setId((reactId) => reactId ?? String(count++));
|
|
41
|
+
}, [deterministicId]);
|
|
42
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
43
|
+
}
|
|
44
|
+
})();
|
|
28
45
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/id.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\n\n// We `toString()` to prevent bundlers from trying to `import { useId } from 'react';`\nconst useReactId = (React as any)['useId'.toString()] || (() => undefined);\nlet count = 0;\n\nfunction useId(deterministicId?: string): string {\n const [id, setId] = React.useState<string | undefined>(useReactId());\n // React versions older than 18 will have client-side ids only.\n useLayoutEffect(() => {\n if (!deterministicId) setId((reactId) => reactId ?? String(count++));\n }, [deterministicId]);\n return deterministicId || (id ? `radix-${id}` : '');\n}\n\nexport { useId };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AACvB,uCAAgC;AAGhC,MAAM,aAAc,MAAc,QAAQ,SAAS,CAAC,MAAM,MAAM;AAChE,MAAI,QAAQ;AAEZ,WAAS,MAAM,iBAAkC;AAC/C,UAAM,CAAC,IAAI,KAAK,IAAU,eAA6B,WAAW,CAAC;AAEnE,wDAAgB,MAAM;AACpB,UAAI,CAAC,gBAAiB,OAAM,CAAC,YAAY,WAAW,OAAO,OAAO,CAAC;AAAA,IACrE,GAAG,CAAC,eAAe,CAAC;AACpB,WAAO,oBAAoB,KAAK,SAAS,EAAE,KAAK;AAAA,EAClD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!deterministicId) setId((reactId)=>reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
|
|
13
|
-
);
|
|
14
|
-
}, [
|
|
15
|
-
deterministicId
|
|
16
|
-
]);
|
|
17
|
-
return deterministicId || (id ? `radix-${id}` : '');
|
|
1
|
+
// packages/react/id/src/id.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
|
|
4
|
+
var useReactId = React["useId".toString()] || (() => void 0);
|
|
5
|
+
var count = 0;
|
|
6
|
+
function useId(deterministicId) {
|
|
7
|
+
const [id, setId] = React.useState(useReactId());
|
|
8
|
+
useLayoutEffect(() => {
|
|
9
|
+
if (!deterministicId) setId((reactId) => reactId ?? String(count++));
|
|
10
|
+
}, [deterministicId]);
|
|
11
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export {$1746a345f3d73bb7$export$f680877a34711e37 as useId};
|
|
13
|
+
export {
|
|
14
|
+
useId
|
|
15
|
+
};
|
|
24
16
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/id.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\n\n// We `toString()` to prevent bundlers from trying to `import { useId } from 'react';`\nconst useReactId = (React as any)['useId'.toString()] || (() => undefined);\nlet count = 0;\n\nfunction useId(deterministicId?: string): string {\n const [id, setId] = React.useState<string | undefined>(useReactId());\n // React versions older than 18 will have client-side ids only.\n useLayoutEffect(() => {\n if (!deterministicId) setId((reactId) => reactId ?? String(count++));\n }, [deterministicId]);\n return deterministicId || (id ? `radix-${id}` : '');\n}\n\nexport { useId };\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAGhC,IAAM,aAAc,MAAc,QAAQ,SAAS,CAAC,MAAM,MAAM;AAChE,IAAI,QAAQ;AAEZ,SAAS,MAAM,iBAAkC;AAC/C,QAAM,CAAC,IAAI,KAAK,IAAU,eAA6B,WAAW,CAAC;AAEnE,kBAAgB,MAAM;AACpB,QAAI,CAAC,gBAAiB,OAAM,CAAC,YAAY,WAAW,OAAO,OAAO,CAAC;AAAA,EACrE,GAAG,CAAC,eAAe,CAAC;AACpB,SAAO,oBAAoB,KAAK,SAAS,EAAE,KAAK;AAClD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-id",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
"@radix-ui/react-use-layout-effect": "1.1.0-rc.2"
|
|
49
|
+
},
|
|
50
|
+
"stableVersion": "1.0.1"
|
|
51
51
|
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAOA,sBAAe,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAO/C","sources":["packages/react/id/src/packages/react/id/src/id.tsx","packages/react/id/src/packages/react/id/src/index.ts","packages/react/id/src/index.ts"],"sourcesContent":[null,null,"export { useId } from './id';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|