extra-react-hooks 0.1.4 → 0.1.8
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/CHANGELOG.md +61 -0
- package/README.md +32 -0
- package/dist/es2015/index.min.mjs +2 -2
- package/dist/es2015/index.min.mjs.map +1 -1
- package/dist/es2015/index.mjs +103 -66
- package/dist/es2015/index.mjs.map +1 -1
- package/dist/es2015/index.umd.js +108 -67
- package/dist/es2015/index.umd.js.map +1 -1
- package/dist/es2015/index.umd.min.js +2 -2
- package/dist/es2015/index.umd.min.js.map +1 -1
- package/dist/es2018/index.min.mjs +2 -2
- package/dist/es2018/index.min.mjs.map +1 -1
- package/dist/es2018/index.mjs +103 -66
- package/dist/es2018/index.mjs.map +1 -1
- package/dist/es2018/index.umd.js +108 -67
- package/dist/es2018/index.umd.js.map +1 -1
- package/dist/es2018/index.umd.min.js +2 -2
- package/dist/es2018/index.umd.min.js.map +1 -1
- package/lib/es2015/index.d.ts +4 -0
- package/lib/es2015/index.js +4 -0
- package/lib/es2015/index.js.map +1 -1
- package/lib/es2015/use-force-update.d.ts +1 -0
- package/lib/es2015/use-force-update.js +10 -0
- package/lib/es2015/use-force-update.js.map +1 -0
- package/lib/es2015/use-increment.d.ts +1 -0
- package/lib/es2015/use-increment.js +16 -0
- package/lib/es2015/use-increment.js.map +1 -0
- package/lib/es2015/use-is-mounted.js +2 -2
- package/lib/es2015/use-is-mounted.js.map +1 -1
- package/lib/es2015/use-mount.js +1 -1
- package/lib/es2015/use-mount.js.map +1 -1
- package/lib/es2015/use-resize-observer.d.ts +2 -0
- package/lib/es2015/use-resize-observer.js +18 -0
- package/lib/es2015/use-resize-observer.js.map +1 -0
- package/lib/es2015/use-single-selection.js +5 -5
- package/lib/es2015/use-single-selection.js.map +1 -1
- package/lib/es2015/use-state-cycle.js +8 -5
- package/lib/es2015/use-state-cycle.js.map +1 -1
- package/lib/es2015/use-step.d.ts +1 -0
- package/lib/es2015/use-step.js +32 -0
- package/lib/es2015/use-step.js.map +1 -0
- package/lib/es2015/use-toggle.js +1 -1
- package/lib/es2015/use-toggle.js.map +1 -1
- package/lib/es2018/index.d.ts +4 -0
- package/lib/es2018/index.js +4 -0
- package/lib/es2018/index.js.map +1 -1
- package/lib/es2018/use-force-update.d.ts +1 -0
- package/lib/es2018/use-force-update.js +10 -0
- package/lib/es2018/use-force-update.js.map +1 -0
- package/lib/es2018/use-increment.d.ts +1 -0
- package/lib/es2018/use-increment.js +16 -0
- package/lib/es2018/use-increment.js.map +1 -0
- package/lib/es2018/use-is-mounted.js +2 -2
- package/lib/es2018/use-is-mounted.js.map +1 -1
- package/lib/es2018/use-mount.js +1 -1
- package/lib/es2018/use-mount.js.map +1 -1
- package/lib/es2018/use-resize-observer.d.ts +2 -0
- package/lib/es2018/use-resize-observer.js +18 -0
- package/lib/es2018/use-resize-observer.js.map +1 -0
- package/lib/es2018/use-single-selection.js +5 -5
- package/lib/es2018/use-single-selection.js.map +1 -1
- package/lib/es2018/use-state-cycle.js +8 -5
- package/lib/es2018/use-state-cycle.js.map +1 -1
- package/lib/es2018/use-step.d.ts +1 -0
- package/lib/es2018/use-step.js +32 -0
- package/lib/es2018/use-step.js.map +1 -0
- package/lib/es2018/use-toggle.js +1 -1
- package/lib/es2018/use-toggle.js.map +1 -1
- package/package.json +28 -22
package/lib/es2015/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
export * from './use-increment';
|
|
1
2
|
export * from './use-is-mounted';
|
|
2
3
|
export * from './use-mount';
|
|
3
4
|
export * from './use-single-selection';
|
|
4
5
|
export * from './use-state-cycle';
|
|
5
6
|
export * from './use-toggle';
|
|
7
|
+
export * from './use-resize-observer';
|
|
8
|
+
export * from './use-step';
|
|
9
|
+
export * from './use-force-update';
|
package/lib/es2015/index.js
CHANGED
|
@@ -10,9 +10,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./use-increment"), exports);
|
|
13
14
|
__exportStar(require("./use-is-mounted"), exports);
|
|
14
15
|
__exportStar(require("./use-mount"), exports);
|
|
15
16
|
__exportStar(require("./use-single-selection"), exports);
|
|
16
17
|
__exportStar(require("./use-state-cycle"), exports);
|
|
17
18
|
__exportStar(require("./use-toggle"), exports);
|
|
19
|
+
__exportStar(require("./use-resize-observer"), exports);
|
|
20
|
+
__exportStar(require("./use-step"), exports);
|
|
21
|
+
__exportStar(require("./use-force-update"), exports);
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
package/lib/es2015/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useForceUpdate(): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useForceUpdate = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useForceUpdate() {
|
|
6
|
+
const [, setState] = (0, react_1.useState)({});
|
|
7
|
+
return () => setState({});
|
|
8
|
+
}
|
|
9
|
+
exports.useForceUpdate = useForceUpdate;
|
|
10
|
+
//# sourceMappingURL=use-force-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-update.js","sourceRoot":"","sources":["../../src/use-force-update.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,cAAc;IAC5B,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAA;IAEjC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAC3B,CAAC;AAJD,wCAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIncrement(initialValue: number): [value: number, increment: (step?: number) => void, reset: () => void];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIncrement = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useIncrement(initialValue) {
|
|
6
|
+
const [value, setValue] = (0, react_1.useState)(initialValue);
|
|
7
|
+
const increment = (0, react_1.useCallback)((step = 1) => {
|
|
8
|
+
setValue(value => value + step);
|
|
9
|
+
}, []);
|
|
10
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
11
|
+
setValue(initialValue);
|
|
12
|
+
}, []);
|
|
13
|
+
return [value, increment, reset];
|
|
14
|
+
}
|
|
15
|
+
exports.useIncrement = useIncrement;
|
|
16
|
+
//# sourceMappingURL=use-increment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-increment.js","sourceRoot":"","sources":["../../src/use-increment.ts"],"names":[],"mappings":";;;AAAA,iCAA6C;AAE7C,SAAgB,YAAY,CAC1B,YAAoB;IAEpB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAE,IAAA,gBAAQ,EAAC,YAAY,CAAC,CAAA;IAC/C,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,CAAC,OAAe,CAAC,EAAE,EAAE;QACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IACjC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,YAAY,CAAC,CAAA;IACxB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;AAClC,CAAC;AAZD,oCAYC"}
|
|
@@ -4,8 +4,8 @@ exports.useIsMounted = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const use_mount_1 = require("./use-mount");
|
|
6
6
|
function useIsMounted() {
|
|
7
|
-
const isMounted = react_1.useRef(false);
|
|
8
|
-
use_mount_1.useMount(() => {
|
|
7
|
+
const isMounted = (0, react_1.useRef)(false);
|
|
8
|
+
(0, use_mount_1.useMount)(() => {
|
|
9
9
|
isMounted.current = true;
|
|
10
10
|
return () => {
|
|
11
11
|
isMounted.current = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-mounted.js","sourceRoot":"","sources":["../../src/use-is-mounted.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,2CAAsC;AAEtC,SAAgB,YAAY;IAC1B,MAAM,SAAS,GAAG,cAAM,
|
|
1
|
+
{"version":3,"file":"use-is-mounted.js","sourceRoot":"","sources":["../../src/use-is-mounted.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,2CAAsC;AAEtC,SAAgB,YAAY;IAC1B,MAAM,SAAS,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAA;IAE/B,IAAA,oBAAQ,EAAC,GAAG,EAAE;QACZ,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;QACxB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,OAAO,GAAG,KAAK,CAAA;QAC3B,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAA;AAChC,CAAC;AAXD,oCAWC"}
|
package/lib/es2015/use-mount.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useMount = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useMount(effect) {
|
|
6
|
-
react_1.useEffect(effect, []);
|
|
6
|
+
(0, react_1.useEffect)(effect, []);
|
|
7
7
|
}
|
|
8
8
|
exports.useMount = useMount;
|
|
9
9
|
//# sourceMappingURL=use-mount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mount.js","sourceRoot":"","sources":["../../src/use-mount.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AAEjD,SAAgB,QAAQ,CAAC,MAAsB;IAC7C,iBAAS,
|
|
1
|
+
{"version":3,"file":"use-mount.js","sourceRoot":"","sources":["../../src/use-mount.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AAEjD,SAAgB,QAAQ,CAAC,MAAsB;IAC7C,IAAA,iBAAS,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACvB,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useResizeObserver = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const types_1 = require("@blackglory/types");
|
|
6
|
+
function useResizeObserver(callback, refs) {
|
|
7
|
+
const deps = refs.map(x => x.current);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
const observer = new ResizeObserver(callback);
|
|
10
|
+
refs
|
|
11
|
+
.map(x => x.current)
|
|
12
|
+
.filter(types_1.isntNull)
|
|
13
|
+
.forEach(x => observer.observe(x));
|
|
14
|
+
return () => observer.disconnect();
|
|
15
|
+
}, deps);
|
|
16
|
+
}
|
|
17
|
+
exports.useResizeObserver = useResizeObserver;
|
|
18
|
+
//# sourceMappingURL=use-resize-observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resize-observer.js","sourceRoot":"","sources":["../../src/use-resize-observer.ts"],"names":[],"mappings":";;;AAAA,iCAA8D;AAC9D,6CAA4C;AAE5C,SAAgB,iBAAiB,CAC/B,QAAgC,EAChC,IAAmE;IAEnE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAErC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;QAE7C,IAAI;aACD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aACnB,MAAM,CAAC,gBAAQ,CAAC;aAChB,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAEpC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC;AAhBD,8CAgBC"}
|
|
@@ -5,13 +5,13 @@ const react_1 = require("react");
|
|
|
5
5
|
const types_1 = require("@blackglory/types");
|
|
6
6
|
const errors_1 = require("@blackglory/errors");
|
|
7
7
|
function useSingleSelection(values, defaultIndex) {
|
|
8
|
-
errors_1.assert(values.length > 0, 'The parameter values must be a non-empty array');
|
|
9
|
-
if (types_1.isntUndefined(defaultIndex)) {
|
|
10
|
-
errors_1.assert(defaultIndex >= 0 && defaultIndex < values.length, 'The parameter defaultIndex must be in the range of 0 to values.length');
|
|
8
|
+
(0, errors_1.assert)(values.length > 0, 'The parameter values must be a non-empty array');
|
|
9
|
+
if ((0, types_1.isntUndefined)(defaultIndex)) {
|
|
10
|
+
(0, errors_1.assert)(defaultIndex >= 0 && defaultIndex < values.length, 'The parameter defaultIndex must be in the range of 0 to values.length');
|
|
11
11
|
}
|
|
12
|
-
const [selectedIndex, setSelectedIndex] = react_1.useState(defaultIndex);
|
|
12
|
+
const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(defaultIndex);
|
|
13
13
|
return {
|
|
14
|
-
value: types_1.isUndefined(selectedIndex) ? undefined : values[selectedIndex],
|
|
14
|
+
value: (0, types_1.isUndefined)(selectedIndex) ? undefined : values[selectedIndex],
|
|
15
15
|
options: values.map((value, index) => ({
|
|
16
16
|
value,
|
|
17
17
|
index,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-single-selection.js","sourceRoot":"","sources":["../../src/use-single-selection.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,6CAA8D;AAC9D,+CAA2C;AAiB3C,SAAgB,kBAAkB,CAAI,MAAW,EAAE,YAAqB;IACtE,eAAM,
|
|
1
|
+
{"version":3,"file":"use-single-selection.js","sourceRoot":"","sources":["../../src/use-single-selection.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,6CAA8D;AAC9D,+CAA2C;AAiB3C,SAAgB,kBAAkB,CAAI,MAAW,EAAE,YAAqB;IACtE,IAAA,eAAM,EAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,gDAAgD,CAAC,CAAA;IAC3E,IAAI,IAAA,qBAAa,EAAC,YAAY,CAAC,EAAE;QAC/B,IAAA,eAAM,EACJ,YAAY,IAAI,CAAC,IAAI,YAAY,GAAG,MAAM,CAAC,MAAM,EACjD,uEAAuE,CACxE,CAAA;KACF;IAED,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAqB,YAAY,CAAC,CAAA;IAEpF,OAAO;QACL,KAAK,EAAE,IAAA,mBAAW,EAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QACrE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACrC,KAAK;YACL,KAAK;YACL,QAAQ,EAAE,KAAK,KAAK,aAAa;YACjC,MAAM,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;SACtC,CAAC,CAAC;KACJ,CAAA;AACH,CAAC;AApBD,gDAoBC"}
|
|
@@ -3,15 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useStateCycle = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useStateCycle(stateList, initialStateIndex = 0) {
|
|
6
|
-
const [index, setIndex] = react_1.useState(initialStateIndex);
|
|
7
|
-
return [
|
|
6
|
+
const [index, setIndex] = (0, react_1.useState)(initialStateIndex);
|
|
7
|
+
return [
|
|
8
|
+
stateList[index],
|
|
9
|
+
() => setIndex(index => {
|
|
8
10
|
if (index + 1 < stateList.length) {
|
|
9
|
-
|
|
11
|
+
return index + 1;
|
|
10
12
|
}
|
|
11
13
|
else {
|
|
12
|
-
|
|
14
|
+
return 0;
|
|
13
15
|
}
|
|
14
|
-
}
|
|
16
|
+
})
|
|
17
|
+
];
|
|
15
18
|
}
|
|
16
19
|
exports.useStateCycle = useStateCycle;
|
|
17
20
|
//# sourceMappingURL=use-state-cycle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-state-cycle.js","sourceRoot":"","sources":["../../src/use-state-cycle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,aAAa,CAC3B,SAAsB,EACtB,oBAA4B,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"use-state-cycle.js","sourceRoot":"","sources":["../../src/use-state-cycle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,aAAa,CAC3B,SAAsB,EACtB,oBAA4B,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,CAAA;IAErD,OAAO;QACL,SAAS,CAAC,KAAK,CAAC;QAChB,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACrB,IAAI,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE;gBAChC,OAAO,KAAK,GAAG,CAAC,CAAA;aACjB;iBAAM;gBACL,OAAO,CAAC,CAAA;aACT;QACH,CAAC,CAAC;KACH,CAAA;AACH,CAAC;AAhBD,sCAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useStep<T>(steps: [T, ...T[]], initialStepIndex?: number): [currentStep: T, next: () => void, previous: () => void];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStep = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useStep(steps, initialStepIndex = 0) {
|
|
6
|
+
const [index, setIndex] = (0, react_1.useState)(initialStepIndex);
|
|
7
|
+
return [
|
|
8
|
+
steps[index],
|
|
9
|
+
() => {
|
|
10
|
+
setIndex(index => {
|
|
11
|
+
if (index === steps.length - 1) {
|
|
12
|
+
return index;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return index + 1;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
() => {
|
|
20
|
+
setIndex(index => {
|
|
21
|
+
if (index === 0) {
|
|
22
|
+
return index;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return index - 1;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
exports.useStep = useStep;
|
|
32
|
+
//# sourceMappingURL=use-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-step.js","sourceRoot":"","sources":["../../src/use-step.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,OAAO,CACrB,KAAkB,EAClB,mBAA2B,CAAC;IAE5B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,gBAAgB,CAAC,CAAA;IAEpD,OAAO;QACL,KAAK,CAAC,KAAK,CAAC;QACZ,GAAG,EAAE;YACH,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACf,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC9B,OAAO,KAAK,CAAA;iBACb;qBAAM;oBACL,OAAO,KAAK,GAAG,CAAC,CAAA;iBACjB;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,GAAG,EAAE;YACH,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACf,IAAI,KAAK,KAAK,CAAC,EAAE;oBACf,OAAO,KAAK,CAAA;iBACb;qBAAM;oBACL,OAAO,KAAK,GAAG,CAAC,CAAA;iBACjB;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC;AA3BD,0BA2BC"}
|
package/lib/es2015/use-toggle.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useToggle = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useToggle(initialState = false) {
|
|
6
|
-
const [state, setState] = react_1.useState(initialState);
|
|
6
|
+
const [state, setState] = (0, react_1.useState)(initialState);
|
|
7
7
|
const toggle = () => setState(state => !state);
|
|
8
8
|
return [state, toggle];
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-toggle.js","sourceRoot":"","sources":["../../src/use-toggle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,SAAS,CAAC,eAAwB,KAAK;IAErD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"use-toggle.js","sourceRoot":"","sources":["../../src/use-toggle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,SAAS,CAAC,eAAwB,KAAK;IAErD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,YAAY,CAAC,CAAA;IAChD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;IAE9C,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AACxB,CAAC;AAND,8BAMC"}
|
package/lib/es2018/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
export * from './use-increment';
|
|
1
2
|
export * from './use-is-mounted';
|
|
2
3
|
export * from './use-mount';
|
|
3
4
|
export * from './use-single-selection';
|
|
4
5
|
export * from './use-state-cycle';
|
|
5
6
|
export * from './use-toggle';
|
|
7
|
+
export * from './use-resize-observer';
|
|
8
|
+
export * from './use-step';
|
|
9
|
+
export * from './use-force-update';
|
package/lib/es2018/index.js
CHANGED
|
@@ -10,9 +10,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./use-increment"), exports);
|
|
13
14
|
__exportStar(require("./use-is-mounted"), exports);
|
|
14
15
|
__exportStar(require("./use-mount"), exports);
|
|
15
16
|
__exportStar(require("./use-single-selection"), exports);
|
|
16
17
|
__exportStar(require("./use-state-cycle"), exports);
|
|
17
18
|
__exportStar(require("./use-toggle"), exports);
|
|
19
|
+
__exportStar(require("./use-resize-observer"), exports);
|
|
20
|
+
__exportStar(require("./use-step"), exports);
|
|
21
|
+
__exportStar(require("./use-force-update"), exports);
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
package/lib/es2018/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useForceUpdate(): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useForceUpdate = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useForceUpdate() {
|
|
6
|
+
const [, setState] = (0, react_1.useState)({});
|
|
7
|
+
return () => setState({});
|
|
8
|
+
}
|
|
9
|
+
exports.useForceUpdate = useForceUpdate;
|
|
10
|
+
//# sourceMappingURL=use-force-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-update.js","sourceRoot":"","sources":["../../src/use-force-update.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,cAAc;IAC5B,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAA;IAEjC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAC3B,CAAC;AAJD,wCAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIncrement(initialValue: number): [value: number, increment: (step?: number) => void, reset: () => void];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIncrement = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useIncrement(initialValue) {
|
|
6
|
+
const [value, setValue] = (0, react_1.useState)(initialValue);
|
|
7
|
+
const increment = (0, react_1.useCallback)((step = 1) => {
|
|
8
|
+
setValue(value => value + step);
|
|
9
|
+
}, []);
|
|
10
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
11
|
+
setValue(initialValue);
|
|
12
|
+
}, []);
|
|
13
|
+
return [value, increment, reset];
|
|
14
|
+
}
|
|
15
|
+
exports.useIncrement = useIncrement;
|
|
16
|
+
//# sourceMappingURL=use-increment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-increment.js","sourceRoot":"","sources":["../../src/use-increment.ts"],"names":[],"mappings":";;;AAAA,iCAA6C;AAE7C,SAAgB,YAAY,CAC1B,YAAoB;IAEpB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAE,IAAA,gBAAQ,EAAC,YAAY,CAAC,CAAA;IAC/C,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,CAAC,OAAe,CAAC,EAAE,EAAE;QACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IACjC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,YAAY,CAAC,CAAA;IACxB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;AAClC,CAAC;AAZD,oCAYC"}
|
|
@@ -4,8 +4,8 @@ exports.useIsMounted = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const use_mount_1 = require("./use-mount");
|
|
6
6
|
function useIsMounted() {
|
|
7
|
-
const isMounted = react_1.useRef(false);
|
|
8
|
-
use_mount_1.useMount(() => {
|
|
7
|
+
const isMounted = (0, react_1.useRef)(false);
|
|
8
|
+
(0, use_mount_1.useMount)(() => {
|
|
9
9
|
isMounted.current = true;
|
|
10
10
|
return () => {
|
|
11
11
|
isMounted.current = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-mounted.js","sourceRoot":"","sources":["../../src/use-is-mounted.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,2CAAsC;AAEtC,SAAgB,YAAY;IAC1B,MAAM,SAAS,GAAG,cAAM,
|
|
1
|
+
{"version":3,"file":"use-is-mounted.js","sourceRoot":"","sources":["../../src/use-is-mounted.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,2CAAsC;AAEtC,SAAgB,YAAY;IAC1B,MAAM,SAAS,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAA;IAE/B,IAAA,oBAAQ,EAAC,GAAG,EAAE;QACZ,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;QACxB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,OAAO,GAAG,KAAK,CAAA;QAC3B,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAA;AAChC,CAAC;AAXD,oCAWC"}
|
package/lib/es2018/use-mount.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useMount = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useMount(effect) {
|
|
6
|
-
react_1.useEffect(effect, []);
|
|
6
|
+
(0, react_1.useEffect)(effect, []);
|
|
7
7
|
}
|
|
8
8
|
exports.useMount = useMount;
|
|
9
9
|
//# sourceMappingURL=use-mount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mount.js","sourceRoot":"","sources":["../../src/use-mount.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AAEjD,SAAgB,QAAQ,CAAC,MAAsB;IAC7C,iBAAS,
|
|
1
|
+
{"version":3,"file":"use-mount.js","sourceRoot":"","sources":["../../src/use-mount.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AAEjD,SAAgB,QAAQ,CAAC,MAAsB;IAC7C,IAAA,iBAAS,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACvB,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useResizeObserver = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const types_1 = require("@blackglory/types");
|
|
6
|
+
function useResizeObserver(callback, refs) {
|
|
7
|
+
const deps = refs.map(x => x.current);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
const observer = new ResizeObserver(callback);
|
|
10
|
+
refs
|
|
11
|
+
.map(x => x.current)
|
|
12
|
+
.filter(types_1.isntNull)
|
|
13
|
+
.forEach(x => observer.observe(x));
|
|
14
|
+
return () => observer.disconnect();
|
|
15
|
+
}, deps);
|
|
16
|
+
}
|
|
17
|
+
exports.useResizeObserver = useResizeObserver;
|
|
18
|
+
//# sourceMappingURL=use-resize-observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resize-observer.js","sourceRoot":"","sources":["../../src/use-resize-observer.ts"],"names":[],"mappings":";;;AAAA,iCAA8D;AAC9D,6CAA4C;AAE5C,SAAgB,iBAAiB,CAC/B,QAAgC,EAChC,IAAmE;IAEnE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAErC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;QAE7C,IAAI;aACD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aACnB,MAAM,CAAC,gBAAQ,CAAC;aAChB,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAEpC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC;AAhBD,8CAgBC"}
|
|
@@ -5,13 +5,13 @@ const react_1 = require("react");
|
|
|
5
5
|
const types_1 = require("@blackglory/types");
|
|
6
6
|
const errors_1 = require("@blackglory/errors");
|
|
7
7
|
function useSingleSelection(values, defaultIndex) {
|
|
8
|
-
errors_1.assert(values.length > 0, 'The parameter values must be a non-empty array');
|
|
9
|
-
if (types_1.isntUndefined(defaultIndex)) {
|
|
10
|
-
errors_1.assert(defaultIndex >= 0 && defaultIndex < values.length, 'The parameter defaultIndex must be in the range of 0 to values.length');
|
|
8
|
+
(0, errors_1.assert)(values.length > 0, 'The parameter values must be a non-empty array');
|
|
9
|
+
if ((0, types_1.isntUndefined)(defaultIndex)) {
|
|
10
|
+
(0, errors_1.assert)(defaultIndex >= 0 && defaultIndex < values.length, 'The parameter defaultIndex must be in the range of 0 to values.length');
|
|
11
11
|
}
|
|
12
|
-
const [selectedIndex, setSelectedIndex] = react_1.useState(defaultIndex);
|
|
12
|
+
const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(defaultIndex);
|
|
13
13
|
return {
|
|
14
|
-
value: types_1.isUndefined(selectedIndex) ? undefined : values[selectedIndex],
|
|
14
|
+
value: (0, types_1.isUndefined)(selectedIndex) ? undefined : values[selectedIndex],
|
|
15
15
|
options: values.map((value, index) => ({
|
|
16
16
|
value,
|
|
17
17
|
index,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-single-selection.js","sourceRoot":"","sources":["../../src/use-single-selection.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,6CAA8D;AAC9D,+CAA2C;AAiB3C,SAAgB,kBAAkB,CAAI,MAAW,EAAE,YAAqB;IACtE,eAAM,
|
|
1
|
+
{"version":3,"file":"use-single-selection.js","sourceRoot":"","sources":["../../src/use-single-selection.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,6CAA8D;AAC9D,+CAA2C;AAiB3C,SAAgB,kBAAkB,CAAI,MAAW,EAAE,YAAqB;IACtE,IAAA,eAAM,EAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,gDAAgD,CAAC,CAAA;IAC3E,IAAI,IAAA,qBAAa,EAAC,YAAY,CAAC,EAAE;QAC/B,IAAA,eAAM,EACJ,YAAY,IAAI,CAAC,IAAI,YAAY,GAAG,MAAM,CAAC,MAAM,EACjD,uEAAuE,CACxE,CAAA;KACF;IAED,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAqB,YAAY,CAAC,CAAA;IAEpF,OAAO;QACL,KAAK,EAAE,IAAA,mBAAW,EAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QACrE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACrC,KAAK;YACL,KAAK;YACL,QAAQ,EAAE,KAAK,KAAK,aAAa;YACjC,MAAM,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;SACtC,CAAC,CAAC;KACJ,CAAA;AACH,CAAC;AApBD,gDAoBC"}
|
|
@@ -3,15 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useStateCycle = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useStateCycle(stateList, initialStateIndex = 0) {
|
|
6
|
-
const [index, setIndex] = react_1.useState(initialStateIndex);
|
|
7
|
-
return [
|
|
6
|
+
const [index, setIndex] = (0, react_1.useState)(initialStateIndex);
|
|
7
|
+
return [
|
|
8
|
+
stateList[index],
|
|
9
|
+
() => setIndex(index => {
|
|
8
10
|
if (index + 1 < stateList.length) {
|
|
9
|
-
|
|
11
|
+
return index + 1;
|
|
10
12
|
}
|
|
11
13
|
else {
|
|
12
|
-
|
|
14
|
+
return 0;
|
|
13
15
|
}
|
|
14
|
-
}
|
|
16
|
+
})
|
|
17
|
+
];
|
|
15
18
|
}
|
|
16
19
|
exports.useStateCycle = useStateCycle;
|
|
17
20
|
//# sourceMappingURL=use-state-cycle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-state-cycle.js","sourceRoot":"","sources":["../../src/use-state-cycle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,aAAa,CAC3B,SAAsB,EACtB,oBAA4B,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"use-state-cycle.js","sourceRoot":"","sources":["../../src/use-state-cycle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,aAAa,CAC3B,SAAsB,EACtB,oBAA4B,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,CAAA;IAErD,OAAO;QACL,SAAS,CAAC,KAAK,CAAC;QAChB,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACrB,IAAI,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE;gBAChC,OAAO,KAAK,GAAG,CAAC,CAAA;aACjB;iBAAM;gBACL,OAAO,CAAC,CAAA;aACT;QACH,CAAC,CAAC;KACH,CAAA;AACH,CAAC;AAhBD,sCAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useStep<T>(steps: [T, ...T[]], initialStepIndex?: number): [currentStep: T, next: () => void, previous: () => void];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStep = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useStep(steps, initialStepIndex = 0) {
|
|
6
|
+
const [index, setIndex] = (0, react_1.useState)(initialStepIndex);
|
|
7
|
+
return [
|
|
8
|
+
steps[index],
|
|
9
|
+
() => {
|
|
10
|
+
setIndex(index => {
|
|
11
|
+
if (index === steps.length - 1) {
|
|
12
|
+
return index;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return index + 1;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
() => {
|
|
20
|
+
setIndex(index => {
|
|
21
|
+
if (index === 0) {
|
|
22
|
+
return index;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return index - 1;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
exports.useStep = useStep;
|
|
32
|
+
//# sourceMappingURL=use-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-step.js","sourceRoot":"","sources":["../../src/use-step.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,OAAO,CACrB,KAAkB,EAClB,mBAA2B,CAAC;IAE5B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,gBAAgB,CAAC,CAAA;IAEpD,OAAO;QACL,KAAK,CAAC,KAAK,CAAC;QACZ,GAAG,EAAE;YACH,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACf,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC9B,OAAO,KAAK,CAAA;iBACb;qBAAM;oBACL,OAAO,KAAK,GAAG,CAAC,CAAA;iBACjB;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,GAAG,EAAE;YACH,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACf,IAAI,KAAK,KAAK,CAAC,EAAE;oBACf,OAAO,KAAK,CAAA;iBACb;qBAAM;oBACL,OAAO,KAAK,GAAG,CAAC,CAAA;iBACjB;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC;AA3BD,0BA2BC"}
|
package/lib/es2018/use-toggle.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useToggle = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useToggle(initialState = false) {
|
|
6
|
-
const [state, setState] = react_1.useState(initialState);
|
|
6
|
+
const [state, setState] = (0, react_1.useState)(initialState);
|
|
7
7
|
const toggle = () => setState(state => !state);
|
|
8
8
|
return [state, toggle];
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-toggle.js","sourceRoot":"","sources":["../../src/use-toggle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,SAAS,CAAC,eAAwB,KAAK;IAErD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"use-toggle.js","sourceRoot":"","sources":["../../src/use-toggle.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,SAAgB,SAAS,CAAC,eAAwB,KAAK;IAErD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,YAAY,CAAC,CAAA;IAChD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;IAE9C,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AACxB,CAAC;AAND,8BAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extra-react-hooks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
|
|
17
|
-
"test": "
|
|
18
|
-
"test:
|
|
19
|
-
"test:coverage": "jest --coverage --config jest.config.js",
|
|
17
|
+
"test": "karma start karma.config.js --single-run",
|
|
18
|
+
"test:dev": "karma start karma.config.js",
|
|
20
19
|
"prepublishOnly": "run-s clean build bundle",
|
|
21
20
|
"clean": "run-p clean:*",
|
|
22
21
|
"clean:build": "rimraf lib",
|
|
@@ -38,38 +37,45 @@
|
|
|
38
37
|
}
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@commitlint/
|
|
43
|
-
"@
|
|
40
|
+
"@blackglory/wait-for": "^0.3.5",
|
|
41
|
+
"@commitlint/cli": "^15.0.0",
|
|
42
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
43
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
44
44
|
"@rollup/plugin-json": "^4.1.0",
|
|
45
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
45
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
46
46
|
"@rollup/plugin-replace": "^3.0.0",
|
|
47
|
-
"@rollup/plugin-typescript": "^8.
|
|
48
|
-
"@testing-library/react
|
|
49
|
-
"@
|
|
50
|
-
"@types/
|
|
51
|
-
"@
|
|
52
|
-
"@typescript-eslint/
|
|
53
|
-
"eslint": "^
|
|
47
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
48
|
+
"@testing-library/react": "^12.1.2",
|
|
49
|
+
"@testing-library/react-hooks": "^7.0.2",
|
|
50
|
+
"@types/jasmine": "^3.10.2",
|
|
51
|
+
"@types/react": "^17.0.37",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
|
53
|
+
"@typescript-eslint/parser": "^5.6.0",
|
|
54
|
+
"eslint": "^8.4.1",
|
|
54
55
|
"husky": "^4.3.8",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
56
|
+
"karma": "^6.3.9",
|
|
57
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
58
|
+
"karma-jasmine": "^4.0.1",
|
|
59
|
+
"karma-webpack": "^5.0.0",
|
|
57
60
|
"npm-run-all": "^4.1.5",
|
|
58
61
|
"react": "^17.0.2",
|
|
62
|
+
"react-dom": "^17.0.2",
|
|
59
63
|
"react-test-renderer": "^17.0.2",
|
|
60
64
|
"rimraf": "^3.0.2",
|
|
61
|
-
"rollup": "^2.
|
|
65
|
+
"rollup": "^2.61.1",
|
|
62
66
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
63
67
|
"rollup-plugin-terser": "^7.0.2",
|
|
64
|
-
"standard-version": "^9.3.
|
|
65
|
-
"ts-
|
|
68
|
+
"standard-version": "^9.3.2",
|
|
69
|
+
"ts-loader": "^9.2.6",
|
|
70
|
+
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
66
71
|
"tscpaths": "^0.0.9",
|
|
67
72
|
"tslib": "^2.3.1",
|
|
68
|
-
"typescript": "^4.3
|
|
73
|
+
"typescript": "^4.5.3",
|
|
74
|
+
"webpack": "^5.65.0"
|
|
69
75
|
},
|
|
70
76
|
"dependencies": {
|
|
71
77
|
"@blackglory/errors": "^1.1.2",
|
|
72
|
-
"@blackglory/types": "^0.
|
|
78
|
+
"@blackglory/types": "^0.5.2"
|
|
73
79
|
},
|
|
74
80
|
"peerDependencies": {
|
|
75
81
|
"react": ">= 16.8"
|