@radix-ui/react-use-rect 1.0.1 → 1.1.0-rc.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.
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +48 -32
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +19 -28
- 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,8 +1,9 @@
|
|
|
1
|
-
import { Measurable } from
|
|
1
|
+
import { Measurable } from '@radix-ui/rect';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Use this custom hook to get access to an element's rect (getBoundingClientRect)
|
|
4
5
|
* and observe it along time.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare function useRect(measurable: Measurable | null): ClientRect | undefined;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
export { useRect };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Measurable } from
|
|
1
|
+
import { Measurable } from '@radix-ui/rect';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Use this custom hook to get access to an element's rect (getBoundingClientRect)
|
|
4
5
|
* and observe it along time.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare function useRect(measurable: Measurable | null): ClientRect | undefined;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
export { useRect };
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,50 @@
|
|
|
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/use-rect/src/useRect.tsx
|
|
33
|
+
var React = __toESM(__require("react"));
|
|
34
|
+
var import_rect = __require("@radix-ui/rect");
|
|
35
|
+
function useRect(measurable) {
|
|
36
|
+
const [rect, setRect] = React.useState();
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (measurable) {
|
|
39
|
+
const unobserve = (0, import_rect.observeElementRect)(measurable, setRect);
|
|
40
|
+
return () => {
|
|
41
|
+
setRect(void 0);
|
|
42
|
+
unobserve();
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}, [measurable]);
|
|
28
47
|
return rect;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
34
50
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/useRect.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { observeElementRect } from '@radix-ui/rect';\n\nimport type { Measurable } from '@radix-ui/rect';\n\n/**\n * Use this custom hook to get access to an element's rect (getBoundingClientRect)\n * and observe it along time.\n */\nfunction useRect(measurable: Measurable | null) {\n const [rect, setRect] = React.useState<ClientRect>();\n React.useEffect(() => {\n if (measurable) {\n const unobserve = observeElementRect(measurable, setRect);\n return () => {\n setRect(undefined);\n unobserve();\n };\n }\n return;\n }, [measurable]);\n return rect;\n}\n\nexport { useRect };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AACvB,oBAAmC;AAQnC,WAAS,QAAQ,YAA+B;AAC9C,UAAM,CAAC,MAAM,OAAO,IAAU,eAAqB;AACnD,IAAM,gBAAU,MAAM;AACpB,UAAI,YAAY;AACd,cAAM,gBAAY,gCAAmB,YAAY,OAAO;AACxD,eAAO,MAAM;AACX,kBAAQ,MAAS;AACjB,oBAAU;AAAA,QACZ;AAAA,MACF;AACA;AAAA,IACF,GAAG,CAAC,UAAU,CAAC;AACf,WAAO;AAAA,EACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return;
|
|
20
|
-
}, [
|
|
21
|
-
measurable
|
|
22
|
-
]);
|
|
23
|
-
return rect;
|
|
1
|
+
// packages/react/use-rect/src/useRect.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { observeElementRect } from "@radix-ui/rect";
|
|
4
|
+
function useRect(measurable) {
|
|
5
|
+
const [rect, setRect] = React.useState();
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
if (measurable) {
|
|
8
|
+
const unobserve = observeElementRect(measurable, setRect);
|
|
9
|
+
return () => {
|
|
10
|
+
setRect(void 0);
|
|
11
|
+
unobserve();
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return;
|
|
15
|
+
}, [measurable]);
|
|
16
|
+
return rect;
|
|
24
17
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export {$ccac1052a272b78b$export$9823a655542017cd as useRect};
|
|
18
|
+
export {
|
|
19
|
+
useRect
|
|
20
|
+
};
|
|
30
21
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/useRect.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { observeElementRect } from '@radix-ui/rect';\n\nimport type { Measurable } from '@radix-ui/rect';\n\n/**\n * Use this custom hook to get access to an element's rect (getBoundingClientRect)\n * and observe it along time.\n */\nfunction useRect(measurable: Measurable | null) {\n const [rect, setRect] = React.useState<ClientRect>();\n React.useEffect(() => {\n if (measurable) {\n const unobserve = observeElementRect(measurable, setRect);\n return () => {\n setRect(undefined);\n unobserve();\n };\n }\n return;\n }, [measurable]);\n return rect;\n}\n\nexport { useRect };\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AAQnC,SAAS,QAAQ,YAA+B;AAC9C,QAAM,CAAC,MAAM,OAAO,IAAU,eAAqB;AACnD,EAAM,gBAAU,MAAM;AACpB,QAAI,YAAY;AACd,YAAM,YAAY,mBAAmB,YAAY,OAAO;AACxD,aAAO,MAAM;AACX,gBAAQ,MAAS;AACjB,kBAAU;AAAA,MACZ;AAAA,IACF;AACA;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AACf,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-use-rect",
|
|
3
|
-
"version": "1.0.1",
|
|
3
|
+
"version": "1.1.0-rc.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"version": "yarn version"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@radix-ui/rect": "1.0.1"
|
|
31
|
+
"@radix-ui/rect": "1.1.0-rc.1"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"@types/react": "*",
|
|
@@ -47,5 +46,6 @@
|
|
|
47
46
|
},
|
|
48
47
|
"bugs": {
|
|
49
48
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
50
|
-
}
|
|
49
|
+
},
|
|
50
|
+
"stableVersion": "1.0.1"
|
|
51
51
|
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";AAKA;;;GAGG;AACH,wBAAiB,UAAU,EAAE,UAAU,GAAG,IAAI,0BAa7C","sources":["packages/react/use-rect/src/packages/react/use-rect/src/useRect.tsx","packages/react/use-rect/src/packages/react/use-rect/src/index.ts","packages/react/use-rect/src/index.ts"],"sourcesContent":[null,null,"export { useRect } from './useRect';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|