@radix-ui/react-use-rect 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 CHANGED
@@ -1,8 +1,9 @@
1
- import { Measurable } from "@radix-ui/rect";
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
- export function useRect(measurable: Measurable | null): ClientRect | undefined;
7
+ declare function useRect(measurable: Measurable | null): ClientRect | undefined;
7
8
 
8
- //# sourceMappingURL=index.d.ts.map
9
+ export { useRect };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Measurable } from "@radix-ui/rect";
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
- export function useRect(measurable: Measurable | null): ClientRect | undefined;
7
+ declare function useRect(measurable: Measurable | null): ClientRect | undefined;
7
8
 
8
- //# sourceMappingURL=index.d.ts.map
9
+ export { useRect };
package/dist/index.js CHANGED
@@ -1,34 +1,50 @@
1
- var $KEKIw$react = require("react");
2
- var $KEKIw$radixuirect = require("@radix-ui/rect");
3
-
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$export(module.exports, "useRect", () => $c64cf18f363cc04f$export$9823a655542017cd);
9
-
10
-
11
- /**
12
- * Use this custom hook to get access to an element's rect (getBoundingClientRect)
13
- * and observe it along time.
14
- */ function $c64cf18f363cc04f$export$9823a655542017cd(measurable) {
15
- const [rect, setRect] = $KEKIw$react.useState();
16
- $KEKIw$react.useEffect(()=>{
17
- if (measurable) {
18
- const unobserve = $KEKIw$radixuirect.observeElementRect(measurable, setRect);
19
- return ()=>{
20
- setRect(undefined);
21
- unobserve();
22
- };
23
- }
24
- return;
25
- }, [
26
- measurable
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
- {"mappings":";;;;;;;;ACAA;;AAKA;;;GAGA,CACA,SAASA,yCAAT,CAAiBG,UAAjB,EAAgD;IAC9C,MAAM,CAACC,IAAD,EAAOC,OAAP,CAAA,GAAkBJ,qBAAA,EAAxB,AAAA;IACAA,sBAAA,CAAgB,IAAM;QACpB,IAAIE,UAAJ,EAAgB;YACd,MAAMK,SAAS,GAAGN,qCAAkB,CAACC,UAAD,EAAaE,OAAb,CAApC,AAAA;YACA,OAAO,IAAM;gBACXA,OAAO,CAACI,SAAD,CAAP,CAAAJ;gBACAG,SAAS,EAATA,CAAAA;aAFF,CAGC;SACF;QACD,OAAA;KARF,EASG;QAACL,UAAD;KATH,CASC,CAAA;IACD,OAAOC,IAAP,CAAA;CACD;;ADtBD","sources":["packages/react/use-rect/src/index.ts","packages/react/use-rect/src/useRect.tsx"],"sourcesContent":["export { useRect } from './useRect';\n","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"],"names":["useRect","React","observeElementRect","measurable","rect","setRect","useState","useEffect","unobserve","undefined"],"version":3,"file":"index.js.map"}
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
- import {useState as $jNFHB$useState, useEffect as $jNFHB$useEffect} from "react";
2
- import {observeElementRect as $jNFHB$observeElementRect} from "@radix-ui/rect";
3
-
4
-
5
-
6
- /**
7
- * Use this custom hook to get access to an element's rect (getBoundingClientRect)
8
- * and observe it along time.
9
- */ function $ccac1052a272b78b$export$9823a655542017cd(measurable) {
10
- const [rect, setRect] = $jNFHB$useState();
11
- $jNFHB$useEffect(()=>{
12
- if (measurable) {
13
- const unobserve = $jNFHB$observeElementRect(measurable, setRect);
14
- return ()=>{
15
- setRect(undefined);
16
- unobserve();
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
@@ -1 +1,7 @@
1
- {"mappings":";;;ACAA;;AAKA;;;GAGA,CACA,SAASA,yCAAT,CAAiBG,UAAjB,EAAgD;IAC9C,MAAM,CAACC,IAAD,EAAOC,OAAP,CAAA,GAAkBJ,eAAA,EAAxB,AAAA;IACAA,gBAAA,CAAgB,IAAM;QACpB,IAAIE,UAAJ,EAAgB;YACd,MAAMK,SAAS,GAAGN,yBAAkB,CAACC,UAAD,EAAaE,OAAb,CAApC,AAAA;YACA,OAAO,IAAM;gBACXA,OAAO,CAACI,SAAD,CAAP,CAAAJ;gBACAG,SAAS,EAATA,CAAAA;aAFF,CAGC;SACF;QACD,OAAA;KARF,EASG;QAACL,UAAD;KATH,CASC,CAAA;IACD,OAAOC,IAAP,CAAA;CACD;;ADtBD","sources":["packages/react/use-rect/src/index.ts","packages/react/use-rect/src/useRect.tsx"],"sourcesContent":["export { useRect } from './useRect';\n","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"],"names":["useRect","React","observeElementRect","measurable","rect","setRect","useState","useEffect","unobserve","undefined"],"version":3,"file":"index.mjs.map"}
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.2",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -28,8 +28,7 @@
28
28
  "version": "yarn version"
29
29
  },
30
30
  "dependencies": {
31
- "@babel/runtime": "^7.13.10",
32
- "@radix-ui/rect": "1.0.1"
31
+ "@radix-ui/rect": "1.1.0-rc.2"
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
  }
@@ -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"}