@w3ux/hooks 1.0.0 → 1.1.0
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/cjs/index.js +21 -0
- package/cjs/index.js.map +1 -0
- package/cjs/useEffectIgnoreInitial.js +20 -0
- package/cjs/useEffectIgnoreInitial.js.map +1 -0
- package/{index.js → mjs/index.d.ts} +0 -2
- package/mjs/index.js +5 -0
- package/mjs/index.js.map +1 -0
- package/mjs/useEffectIgnoreInitial.d.ts +1 -0
- package/mjs/useEffectIgnoreInitial.js +16 -0
- package/mjs/useEffectIgnoreInitial.js.map +1 -0
- package/package.json +9 -2
- package/index.js.map +0 -1
- package/useEffectIgnoreInitial.js +0 -23
- package/useEffectIgnoreInitial.js.map +0 -1
- /package/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/{useEffectIgnoreInitial.d.ts → cjs/useEffectIgnoreInitial.d.ts} +0 -0
package/cjs/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useEffectIgnoreInitial"), exports);
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,2DAAyC","file":"index.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nexport * from \"./useEffectIgnoreInitial\";\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useEffectIgnoreInitial = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useEffectIgnoreInitial = (fn, deps) => {
|
|
6
|
+
const isInitial = (0, react_1.useRef)(true);
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
if (!isInitial.current) {
|
|
9
|
+
if (typeof fn === "function") {
|
|
10
|
+
fn();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
isInitial.current = false;
|
|
14
|
+
}, deps ? [...deps] : undefined);
|
|
15
|
+
};
|
|
16
|
+
exports.useEffectIgnoreInitial = useEffectIgnoreInitial;
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=useEffectIgnoreInitial.js.map
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=useEffectIgnoreInitial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/useEffectIgnoreInitial.tsx"],"names":[],"mappings":";;;AAGA,iCAA0C;AAEnC,MAAM,sBAAsB,GAAG,CAAO,EAAK,EAAE,IAAS,EAAE,EAAE;IAC/D,MAAM,SAAS,GAAG,IAAA,cAAM,EAAU,IAAI,CAAC,CAAC;IACxC,IAAA,iBAAS,EACP,GAAG,EAAE;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;gBAC7B,EAAE,EAAE,CAAC;YACP,CAAC;QACH,CAAC;QACD,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;IAC5B,CAAC,EACD,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAC7B,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC","file":"useEffectIgnoreInitial.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport { useEffect, useRef } from \"react\";\n\nexport const useEffectIgnoreInitial = <T, U>(fn: T, deps: U[]) => {\n const isInitial = useRef<boolean>(true);\n useEffect(\n () => {\n if (!isInitial.current) {\n if (typeof fn === \"function\") {\n fn();\n }\n }\n isInitial.current = false;\n },\n deps ? [...deps] : undefined\n );\n};\n"]}
|
package/mjs/index.js
ADDED
package/mjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,0BAA0B,CAAC","file":"index.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nexport * from \"./useEffectIgnoreInitial\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useEffectIgnoreInitial: <T, U>(fn: T, deps: U[]) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
export const useEffectIgnoreInitial = (fn, deps) => {
|
|
3
|
+
const isInitial = useRef(true);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (!isInitial.current) {
|
|
6
|
+
if (typeof fn === "function") {
|
|
7
|
+
fn();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
isInitial.current = false;
|
|
11
|
+
}, deps ? [...deps] : undefined);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=useEffectIgnoreInitial.js.map
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=useEffectIgnoreInitial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/useEffectIgnoreInitial.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAO,EAAK,EAAE,IAAS,EAAE,EAAE;IAC/D,MAAM,SAAS,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IACxC,SAAS,CACP,GAAG,EAAE;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;gBAC7B,EAAE,EAAE,CAAC;YACP,CAAC;QACH,CAAC;QACD,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;IAC5B,CAAC,EACD,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAC7B,CAAC;AACJ,CAAC,CAAC","file":"useEffectIgnoreInitial.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport { useEffect, useRef } from \"react\";\n\nexport const useEffectIgnoreInitial = <T, U>(fn: T, deps: U[]) => {\n const isInitial = useRef<boolean>(true);\n useEffect(\n () => {\n if (!isInitial.current) {\n if (typeof fn === \"function\") {\n fn();\n }\n }\n isInitial.current = false;\n },\n deps ? [...deps] : undefined\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w3ux/hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
|
-
"
|
|
5
|
+
"main": "cjs/index.js",
|
|
6
|
+
"module": "mjs/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./mjs/index.js",
|
|
10
|
+
"require": "./cjs/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
6
13
|
"peerDependencies": {
|
|
7
14
|
"react": "^18"
|
|
8
15
|
}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA;wCACwC;AAExC,cAAc,0BAA0B,CAAC","file":"index.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nexport * from \"./useEffectIgnoreInitial\";\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
|
-
import { useEffect, useRef } from "react";
|
|
11
|
-
export var useEffectIgnoreInitial = function (fn, deps) {
|
|
12
|
-
var isInitial = useRef(true);
|
|
13
|
-
useEffect(function () {
|
|
14
|
-
if (!isInitial.current) {
|
|
15
|
-
if (typeof fn === "function") {
|
|
16
|
-
fn();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
isInitial.current = false;
|
|
20
|
-
}, deps ? __spreadArray([], deps, true) : undefined);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useEffectIgnoreInitial.tsx"],"names":[],"mappings":"AAAA;wCACwC;;;;;;;;;;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,CAAC,IAAM,sBAAsB,GAAG,UAAO,EAAK,EAAE,IAAS;IAC3D,IAAM,SAAS,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IACxC,SAAS,CACP;QACE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;gBAC7B,EAAE,EAAE,CAAC;YACP,CAAC;QACH,CAAC;QACD,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;IAC5B,CAAC,EACD,IAAI,CAAC,CAAC,mBAAK,IAAI,QAAE,CAAC,CAAC,SAAS,CAC7B,CAAC;AACJ,CAAC,CAAC","file":"useEffectIgnoreInitial.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport { useEffect, useRef } from \"react\";\n\nexport const useEffectIgnoreInitial = <T, U>(fn: T, deps: U[]) => {\n const isInitial = useRef<boolean>(true);\n useEffect(\n () => {\n if (!isInitial.current) {\n if (typeof fn === \"function\") {\n fn();\n }\n }\n isInitial.current = false;\n },\n deps ? [...deps] : undefined\n );\n};\n"]}
|
|
File without changes
|
|
File without changes
|