@radix-ui/react-use-previous 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,3 +1,3 @@
1
- export function usePrevious<T>(value: T): T;
1
+ declare function usePrevious<T>(value: T): T;
2
2
 
3
- //# sourceMappingURL=index.d.ts.map
3
+ export { usePrevious };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export function usePrevious<T>(value: T): T;
1
+ declare function usePrevious<T>(value: T): T;
2
2
 
3
- //# sourceMappingURL=index.d.ts.map
3
+ export { usePrevious };
package/dist/index.js CHANGED
@@ -1,30 +1,45 @@
1
- var $kjM8v$react = require("react");
2
-
3
- function $parcel$export(e, n, v, s) {
4
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
5
- }
6
-
7
- $parcel$export(module.exports, "usePrevious", () => $11bc82d0001dc9a8$export$5cae361ad82dce8b);
8
-
9
- function $11bc82d0001dc9a8$export$5cae361ad82dce8b(value) {
10
- const ref = $kjM8v$react.useRef({
11
- value: value,
12
- previous: value
13
- }); // We compare values before making an update to ensure that
14
- // a change has been made. This ensures the previous value is
15
- // persisted correctly between renders.
16
- return $kjM8v$react.useMemo(()=>{
17
- if (ref.current.value !== value) {
18
- ref.current.previous = ref.current.value;
19
- ref.current.value = value;
20
- }
21
- return ref.current.previous;
22
- }, [
23
- value
24
- ]);
25
- }
26
-
27
-
28
-
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
+ ));
29
31
 
32
+ // packages/react/use-previous/src/usePrevious.tsx
33
+ var React = __toESM(__require("react"));
34
+ function usePrevious(value) {
35
+ const ref = React.useRef({ value, previous: value });
36
+ return React.useMemo(() => {
37
+ if (ref.current.value !== value) {
38
+ ref.current.previous = ref.current.value;
39
+ ref.current.value = value;
40
+ }
41
+ return ref.current.previous;
42
+ }, [value]);
43
+ }
44
+ })();
30
45
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;ACAA;AAEA,SAASA,yCAAT,CAAwBE,KAAxB,EAAkC;IAChC,MAAMC,GAAG,GAAGF,mBAAA,CAAa;QAH3B,OAG6BC,KAAF;QAASG,QAAQ,EAAEH,KAAVG;KAAtB,CAAZ,AADgC,EAGhC,2DAFyB;IAGzB,6DAAA;IACA,uCAAA;IACA,OAAOJ,oBAAA,CAAc,IAAM;QACzB,IAAIE,GAAG,CAACI,OAAJ,CAAYL,KAAZ,KAAsBA,KAA1B,EAAiC;YAC/BC,GAAG,CAACI,OAAJ,CAAYF,QAAZ,GAAuBF,GAAG,CAACI,OAAJ,CAAYL,KAAnC,CAAAC;YACAA,GAAG,CAACI,OAAJ,CAAYL,KAAZ,GAAoBA,KAApB,CAAAC;SACD;QACD,OAAOA,GAAG,CAACI,OAAJ,CAAYF,QAAnB,CAAA;KALK,EAMJ;QAACH,KAAD;KANI,CAAP,CAMC;CACF;;ADfD","sources":["packages/react/use-previous/src/index.ts","packages/react/use-previous/src/usePrevious.tsx"],"sourcesContent":["export { usePrevious } from './usePrevious';\n","import * as React from 'react';\n\nfunction usePrevious<T>(value: T) {\n const ref = React.useRef({ value, previous: value });\n\n // We compare values before making an update to ensure that\n // a change has been made. This ensures the previous value is\n // persisted correctly between renders.\n return React.useMemo(() => {\n if (ref.current.value !== value) {\n ref.current.previous = ref.current.value;\n ref.current.value = value;\n }\n return ref.current.previous;\n }, [value]);\n}\n\nexport { usePrevious };\n"],"names":["usePrevious","React","value","ref","useRef","previous","useMemo","current"],"version":3,"file":"index.js.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/usePrevious.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\nfunction usePrevious<T>(value: T) {\n const ref = React.useRef({ value, previous: value });\n\n // We compare values before making an update to ensure that\n // a change has been made. This ensures the previous value is\n // persisted correctly between renders.\n return React.useMemo(() => {\n if (ref.current.value !== value) {\n ref.current.previous = ref.current.value;\n ref.current.value = value;\n }\n return ref.current.previous;\n }, [value]);\n}\n\nexport { usePrevious };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AAEvB,WAAS,YAAe,OAAU;AAChC,UAAM,MAAY,aAAO,EAAE,OAAO,UAAU,MAAM,CAAC;AAKnD,WAAa,cAAQ,MAAM;AACzB,UAAI,IAAI,QAAQ,UAAU,OAAO;AAC/B,YAAI,QAAQ,WAAW,IAAI,QAAQ;AACnC,YAAI,QAAQ,QAAQ;AAAA,MACtB;AACA,aAAO,IAAI,QAAQ;AAAA,IACrB,GAAG,CAAC,KAAK,CAAC;AAAA,EACZ;",
6
+ "names": []
7
+ }
package/dist/index.mjs CHANGED
@@ -1,26 +1,16 @@
1
- import {useRef as $8LvvK$useRef, useMemo as $8LvvK$useMemo} from "react";
2
-
3
-
4
- function $010c2913dbd2fe3d$export$5cae361ad82dce8b(value) {
5
- const ref = $8LvvK$useRef({
6
- value: value,
7
- previous: value
8
- }); // We compare values before making an update to ensure that
9
- // a change has been made. This ensures the previous value is
10
- // persisted correctly between renders.
11
- return $8LvvK$useMemo(()=>{
12
- if (ref.current.value !== value) {
13
- ref.current.previous = ref.current.value;
14
- ref.current.value = value;
15
- }
16
- return ref.current.previous;
17
- }, [
18
- value
19
- ]);
1
+ // packages/react/use-previous/src/usePrevious.tsx
2
+ import * as React from "react";
3
+ function usePrevious(value) {
4
+ const ref = React.useRef({ value, previous: value });
5
+ return React.useMemo(() => {
6
+ if (ref.current.value !== value) {
7
+ ref.current.previous = ref.current.value;
8
+ ref.current.value = value;
9
+ }
10
+ return ref.current.previous;
11
+ }, [value]);
20
12
  }
21
-
22
-
23
-
24
-
25
- export {$010c2913dbd2fe3d$export$5cae361ad82dce8b as usePrevious};
13
+ export {
14
+ usePrevious
15
+ };
26
16
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"mappings":";;ACAA;AAEA,SAASA,yCAAT,CAAwBE,KAAxB,EAAkC;IAChC,MAAMC,GAAG,GAAGF,aAAA,CAAa;QAH3B,OAG6BC,KAAF;QAASG,QAAQ,EAAEH,KAAVG;KAAtB,CAAZ,AADgC,EAGhC,2DAFyB;IAGzB,6DAAA;IACA,uCAAA;IACA,OAAOJ,cAAA,CAAc,IAAM;QACzB,IAAIE,GAAG,CAACI,OAAJ,CAAYL,KAAZ,KAAsBA,KAA1B,EAAiC;YAC/BC,GAAG,CAACI,OAAJ,CAAYF,QAAZ,GAAuBF,GAAG,CAACI,OAAJ,CAAYL,KAAnC,CAAAC;YACAA,GAAG,CAACI,OAAJ,CAAYL,KAAZ,GAAoBA,KAApB,CAAAC;SACD;QACD,OAAOA,GAAG,CAACI,OAAJ,CAAYF,QAAnB,CAAA;KALK,EAMJ;QAACH,KAAD;KANI,CAAP,CAMC;CACF;;ADfD","sources":["packages/react/use-previous/src/index.ts","packages/react/use-previous/src/usePrevious.tsx"],"sourcesContent":["export { usePrevious } from './usePrevious';\n","import * as React from 'react';\n\nfunction usePrevious<T>(value: T) {\n const ref = React.useRef({ value, previous: value });\n\n // We compare values before making an update to ensure that\n // a change has been made. This ensures the previous value is\n // persisted correctly between renders.\n return React.useMemo(() => {\n if (ref.current.value !== value) {\n ref.current.previous = ref.current.value;\n ref.current.value = value;\n }\n return ref.current.previous;\n }, [value]);\n}\n\nexport { usePrevious };\n"],"names":["usePrevious","React","value","ref","useRef","previous","useMemo","current"],"version":3,"file":"index.mjs.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/usePrevious.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\nfunction usePrevious<T>(value: T) {\n const ref = React.useRef({ value, previous: value });\n\n // We compare values before making an update to ensure that\n // a change has been made. This ensures the previous value is\n // persisted correctly between renders.\n return React.useMemo(() => {\n if (ref.current.value !== value) {\n ref.current.previous = ref.current.value;\n ref.current.value = value;\n }\n return ref.current.previous;\n }, [value]);\n}\n\nexport { usePrevious };\n"],
5
+ "mappings": ";AAAA,YAAY,WAAW;AAEvB,SAAS,YAAe,OAAU;AAChC,QAAM,MAAY,aAAO,EAAE,OAAO,UAAU,MAAM,CAAC;AAKnD,SAAa,cAAQ,MAAM;AACzB,QAAI,IAAI,QAAQ,UAAU,OAAO;AAC/B,UAAI,QAAQ,WAAW,IAAI,QAAQ;AACnC,UAAI,QAAQ,QAAQ;AAAA,IACtB;AACA,WAAO,IAAI,QAAQ;AAAA,EACrB,GAAG,CAAC,KAAK,CAAC;AACZ;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-use-previous",
3
- "version": "1.0.1",
3
+ "version": "1.1.0-rc.2",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -44,7 +44,5 @@
44
44
  "bugs": {
45
45
  "url": "https://github.com/radix-ui/primitives/issues"
46
46
  },
47
- "dependencies": {
48
- "@babel/runtime": "^7.13.10"
49
- }
47
+ "stableVersion": "1.0.1"
50
48
  }
@@ -1 +0,0 @@
1
- {"mappings":"AAEA,4BAAqB,CAAC,EAAE,KAAK,EAAE,CAAC,KAa/B","sources":["packages/react/use-previous/src/packages/react/use-previous/src/usePrevious.tsx","packages/react/use-previous/src/packages/react/use-previous/src/index.ts","packages/react/use-previous/src/index.ts"],"sourcesContent":[null,null,"export { usePrevious } from './usePrevious';\n"],"names":[],"version":3,"file":"index.d.ts.map"}