@aiszlab/relax 1.2.55 → 1.2.57
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/package.json +8 -8
- package/dist/__test__/hooks/use-boolean.test.d.ts +0 -4
- package/dist/__test__/hooks/use-identity.test.d.ts +0 -4
- package/dist/__test__/hooks/use-mount.test.d.ts +0 -4
- package/dist/__test__/hooks/use-mounted.test.d.ts +0 -4
- package/dist/__test__/hooks/use-timeout.test.d.ts +0 -4
- package/dist/__test__/is/is-null.test.d.ts +0 -1
- package/dist/__test__/is/is-thenable.test.d.ts +0 -1
- package/dist/__test__/utils/chain.test.d.ts +0 -1
- package/dist/__test__/utils/clamp.test.d.ts +0 -1
- package/dist/__test__/utils/clone.test.d.ts +0 -1
- package/dist/__test__/utils/debounce.test.d.ts +0 -1
- package/dist/__test__/utils/effect.test.d.ts +0 -1
- package/dist/__test__/utils/exclude.test.d.ts +0 -1
- package/dist/__test__/utils/throttle.test.d.ts +0 -1
- package/dist/__test__/utils/to-array.test.d.ts +0 -1
- package/dist/__test__/utils/to-form-data.test.d.ts +0 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -138
- package/dist/dom/contains.d.ts +0 -1
- package/dist/dom/contains.js +0 -20
- package/dist/dom/index.d.ts +0 -3
- package/dist/dom/index.js +0 -2
- package/dist/dom/scroll-to.d.ts +0 -19
- package/dist/dom/scroll-to.js +0 -69
- package/dist/hooks/use-boolean.d.ts +0 -19
- package/dist/hooks/use-boolean.js +0 -34
- package/dist/hooks/use-controlled-state.d.ts +0 -17
- package/dist/hooks/use-controlled-state.js +0 -40
- package/dist/hooks/use-counter.d.ts +0 -33
- package/dist/hooks/use-counter.js +0 -59
- package/dist/hooks/use-debounce-callback.d.ts +0 -18
- package/dist/hooks/use-debounce-callback.js +0 -81
- package/dist/hooks/use-default.d.ts +0 -8
- package/dist/hooks/use-default.js +0 -14
- package/dist/hooks/use-device-pixel-ratio.d.ts +0 -6
- package/dist/hooks/use-device-pixel-ratio.js +0 -20
- package/dist/hooks/use-event.d.ts +0 -2
- package/dist/hooks/use-event.js +0 -12
- package/dist/hooks/use-focus.d.ts +0 -15
- package/dist/hooks/use-focus.js +0 -31
- package/dist/hooks/use-force-update.d.ts +0 -7
- package/dist/hooks/use-force-update.js +0 -21
- package/dist/hooks/use-hover.d.ts +0 -8
- package/dist/hooks/use-hover.js +0 -25
- package/dist/hooks/use-identity.d.ts +0 -5
- package/dist/hooks/use-identity.js +0 -20
- package/dist/hooks/use-image-loader.d.ts +0 -12
- package/dist/hooks/use-image-loader.js +0 -54
- package/dist/hooks/use-media-query.d.ts +0 -7
- package/dist/hooks/use-memorable.d.ts +0 -1
- package/dist/hooks/use-memorable.js +0 -14
- package/dist/hooks/use-mount.d.ts +0 -8
- package/dist/hooks/use-mount.js +0 -16
- package/dist/hooks/use-mounted.d.ts +0 -8
- package/dist/hooks/use-mounted.js +0 -16
- package/dist/hooks/use-mutate-observer.d.ts +0 -1
- package/dist/hooks/use-mutate-observer.js +0 -28
- package/dist/hooks/use-raf.d.ts +0 -7
- package/dist/hooks/use-raf.js +0 -26
- package/dist/hooks/use-reactive.d.ts +0 -6
- package/dist/hooks/use-refs.d.ts +0 -5
- package/dist/hooks/use-refs.js +0 -31
- package/dist/hooks/use-scroll-locker.d.ts +0 -5
- package/dist/hooks/use-scroll-locker.js +0 -92
- package/dist/hooks/use-scrollable.d.ts +0 -17
- package/dist/hooks/use-scrollable.js +0 -43
- package/dist/hooks/use-throttle-callback.d.ts +0 -18
- package/dist/hooks/use-throttle-callback.js +0 -83
- package/dist/hooks/use-timeout.d.ts +0 -10
- package/dist/hooks/use-timeout.js +0 -68
- package/dist/hooks/use-toggleable.d.ts +0 -48
- package/dist/hooks/use-toggleable.js +0 -186
- package/dist/hooks/use-update-effect.d.ts +0 -3
- package/dist/hooks/use-update-effect.js +0 -19
- package/dist/index.d.ts +0 -61
- package/dist/index.js +0 -49
- package/dist/is/is-array.d.ts +0 -5
- package/dist/is/is-array.js +0 -9
- package/dist/is/is-complex.d.ts +0 -5
- package/dist/is/is-complex.js +0 -11
- package/dist/is/is-dom-usable.d.ts +0 -5
- package/dist/is/is-dom-usable.js +0 -9
- package/dist/is/is-empty.d.ts +0 -7
- package/dist/is/is-empty.js +0 -25
- package/dist/is/is-function.d.ts +0 -5
- package/dist/is/is-function.js +0 -9
- package/dist/is/is-mobile.d.ts +0 -5
- package/dist/is/is-mobile.js +0 -13
- package/dist/is/is-null.d.ts +0 -5
- package/dist/is/is-null.js +0 -9
- package/dist/is/is-overflow.d.ts +0 -5
- package/dist/is/is-overflow.js +0 -14
- package/dist/is/is-pointer-usable.d.ts +0 -5
- package/dist/is/is-primitive.d.ts +0 -5
- package/dist/is/is-refable.d.ts +0 -5
- package/dist/is/is-refable.js +0 -34
- package/dist/is/is-state-getter.d.ts +0 -6
- package/dist/is/is-state-getter.js +0 -9
- package/dist/is/is-style-element.d.ts +0 -5
- package/dist/is/is-style-element.js +0 -9
- package/dist/is/is-thenable.d.ts +0 -5
- package/dist/is/is-thenable.js +0 -9
- package/dist/is/is-undefined.d.ts +0 -5
- package/dist/is/is-undefined.js +0 -9
- package/dist/is/is-void.d.ts +0 -5
- package/dist/is/is-void.js +0 -12
- package/dist/types/first.d.ts +0 -1
- package/dist/types/index.d.ts +0 -8
- package/dist/types/last.d.ts +0 -1
- package/dist/types/nullable.d.ts +0 -5
- package/dist/types/partialable.d.ts +0 -5
- package/dist/types/required-in.d.ts +0 -5
- package/dist/types/state.d.ts +0 -10
- package/dist/types/thenable-effect-callback.d.ts +0 -6
- package/dist/types/voidable.d.ts +0 -7
- package/dist/utils/chain.d.ts +0 -2
- package/dist/utils/chain.js +0 -15
- package/dist/utils/clamp.d.ts +0 -9
- package/dist/utils/clamp.js +0 -13
- package/dist/utils/clone.d.ts +0 -6
- package/dist/utils/debounce.d.ts +0 -23
- package/dist/utils/debounce.js +0 -32
- package/dist/utils/effect.d.ts +0 -7
- package/dist/utils/effect.js +0 -16
- package/dist/utils/exclude.d.ts +0 -10
- package/dist/utils/exclude.js +0 -18
- package/dist/utils/range.d.ts +0 -7
- package/dist/utils/range.js +0 -16
- package/dist/utils/set-style.d.ts +0 -6
- package/dist/utils/set-style.js +0 -21
- package/dist/utils/throttle.d.ts +0 -5
- package/dist/utils/throttle.js +0 -32
- package/dist/utils/to-array.d.ts +0 -18
- package/dist/utils/to-array.js +0 -25
- package/dist/utils/to-form-data.d.ts +0 -5
- package/dist/utils/to-form-data.js +0 -27
- package/dist/utils/to-function.d.ts +0 -1
- package/dist/utils/to-function.js +0 -13
- package/dist/utils/unique.d.ts +0 -10
- package/dist/utils/unique.js +0 -16
- package/dist/utils/waitable.d.ts +0 -36
- package/dist/utils/waitable.js +0 -90
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiszlab/relax",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.57",
|
|
4
4
|
"description": "react utils collection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"rxjs": "^7.8.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/core": "^7.24.
|
|
30
|
-
"@babel/preset-env": "^7.24.
|
|
31
|
-
"@babel/preset-typescript": "^7.24.
|
|
29
|
+
"@babel/core": "^7.24.7",
|
|
30
|
+
"@babel/preset-env": "^7.24.7",
|
|
31
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
32
|
+
"@jest/globals": "^29.7.0",
|
|
32
33
|
"@rollup/plugin-babel": "^6.0.4",
|
|
33
34
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
34
35
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
35
|
-
"@testing-library/react": "^
|
|
36
|
-
"@types/jest": "^29.5.12",
|
|
36
|
+
"@testing-library/react": "^16.0.0",
|
|
37
37
|
"@types/react": "^18",
|
|
38
38
|
"@types/react-dom": "^18",
|
|
39
39
|
"@types/react-is": "^18",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"jest-environment-jsdom": "^29.7.0",
|
|
42
42
|
"react": "18",
|
|
43
43
|
"react-dom": "18",
|
|
44
|
-
"rollup": "^4.
|
|
45
|
-
"typescript": "5.
|
|
44
|
+
"rollup": "^4.18.1",
|
|
45
|
+
"typescript": "5.5.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "18",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
function _arrayLikeToArray(r, a) {
|
|
2
|
-
(null == a || a > r.length) && (a = r.length);
|
|
3
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4
|
-
return n;
|
|
5
|
-
}
|
|
6
|
-
function _arrayWithHoles(r) {
|
|
7
|
-
if (Array.isArray(r)) return r;
|
|
8
|
-
}
|
|
9
|
-
function _arrayWithoutHoles(r) {
|
|
10
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
11
|
-
}
|
|
12
|
-
function _assertClassBrand(e, t, n) {
|
|
13
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
14
|
-
throw new TypeError("Private element is not present on this object");
|
|
15
|
-
}
|
|
16
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
17
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
18
|
-
}
|
|
19
|
-
function _classCallCheck(a, n) {
|
|
20
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
21
|
-
}
|
|
22
|
-
function _classPrivateFieldGet2(s, a) {
|
|
23
|
-
return s.get(_assertClassBrand(s, a));
|
|
24
|
-
}
|
|
25
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
26
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
27
|
-
}
|
|
28
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
29
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
30
|
-
}
|
|
31
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
32
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
33
|
-
}
|
|
34
|
-
function _defineProperties(e, r) {
|
|
35
|
-
for (var t = 0; t < r.length; t++) {
|
|
36
|
-
var o = r[t];
|
|
37
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function _createClass(e, r, t) {
|
|
41
|
-
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
42
|
-
writable: !1
|
|
43
|
-
}), e;
|
|
44
|
-
}
|
|
45
|
-
function _iterableToArray(r) {
|
|
46
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
47
|
-
}
|
|
48
|
-
function _iterableToArrayLimit(r, l) {
|
|
49
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
50
|
-
if (null != t) {
|
|
51
|
-
var e,
|
|
52
|
-
n,
|
|
53
|
-
i,
|
|
54
|
-
u,
|
|
55
|
-
a = [],
|
|
56
|
-
f = !0,
|
|
57
|
-
o = !1;
|
|
58
|
-
try {
|
|
59
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
60
|
-
if (Object(t) !== t) return;
|
|
61
|
-
f = !1;
|
|
62
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
63
|
-
} catch (r) {
|
|
64
|
-
o = !0, n = r;
|
|
65
|
-
} finally {
|
|
66
|
-
try {
|
|
67
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
68
|
-
} finally {
|
|
69
|
-
if (o) throw n;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return a;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function _nonIterableRest() {
|
|
76
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
77
|
-
}
|
|
78
|
-
function _nonIterableSpread() {
|
|
79
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
80
|
-
}
|
|
81
|
-
function _objectWithoutProperties(e, t) {
|
|
82
|
-
if (null == e) return {};
|
|
83
|
-
var o,
|
|
84
|
-
r,
|
|
85
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
86
|
-
if (Object.getOwnPropertySymbols) {
|
|
87
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
88
|
-
for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
89
|
-
}
|
|
90
|
-
return i;
|
|
91
|
-
}
|
|
92
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
93
|
-
if (null == r) return {};
|
|
94
|
-
var t = {};
|
|
95
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
96
|
-
if (e.indexOf(n) >= 0) continue;
|
|
97
|
-
t[n] = r[n];
|
|
98
|
-
}
|
|
99
|
-
return t;
|
|
100
|
-
}
|
|
101
|
-
function _slicedToArray(r, e) {
|
|
102
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
103
|
-
}
|
|
104
|
-
function _toConsumableArray(r) {
|
|
105
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
106
|
-
}
|
|
107
|
-
function _toPrimitive(t, r) {
|
|
108
|
-
if ("object" != typeof t || !t) return t;
|
|
109
|
-
var e = t[Symbol.toPrimitive];
|
|
110
|
-
if (void 0 !== e) {
|
|
111
|
-
var i = e.call(t, r );
|
|
112
|
-
if ("object" != typeof i) return i;
|
|
113
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
114
|
-
}
|
|
115
|
-
return (String )(t);
|
|
116
|
-
}
|
|
117
|
-
function _toPropertyKey(t) {
|
|
118
|
-
var i = _toPrimitive(t, "string");
|
|
119
|
-
return "symbol" == typeof i ? i : i + "";
|
|
120
|
-
}
|
|
121
|
-
function _typeof(o) {
|
|
122
|
-
"@babel/helpers - typeof";
|
|
123
|
-
|
|
124
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
125
|
-
return typeof o;
|
|
126
|
-
} : function (o) {
|
|
127
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
128
|
-
}, _typeof(o);
|
|
129
|
-
}
|
|
130
|
-
function _unsupportedIterableToArray(r, a) {
|
|
131
|
-
if (r) {
|
|
132
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
133
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
134
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _assertClassBrand as assertClassBrand, _checkPrivateRedeclaration as checkPrivateRedeclaration, _classCallCheck as classCallCheck, _classPrivateFieldGet2 as classPrivateFieldGet2, _classPrivateFieldInitSpec as classPrivateFieldInitSpec, _classPrivateFieldSet2 as classPrivateFieldSet2, _classPrivateMethodInitSpec as classPrivateMethodInitSpec, _createClass as createClass, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _slicedToArray as slicedToArray, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _typeof as typeof, _unsupportedIterableToArray as unsupportedIterableToArray };
|
package/dist/dom/contains.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const contains: (root: Node | null | undefined, n?: Node | null) => boolean;
|
package/dist/dom/contains.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var contains = function contains(root, n) {
|
|
2
|
-
if (!root) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
// Use native if support
|
|
6
|
-
if (root.contains) {
|
|
7
|
-
return root.contains(n !== null && n !== void 0 ? n : null);
|
|
8
|
-
}
|
|
9
|
-
// `document.contains` not support with IE11
|
|
10
|
-
var node = n;
|
|
11
|
-
while (node) {
|
|
12
|
-
if (node === root) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
node = node.parentNode;
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { contains };
|
package/dist/dom/index.d.ts
DELETED
package/dist/dom/index.js
DELETED
package/dist/dom/scroll-to.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Direction = 'horizontal' | 'vertical';
|
|
2
|
-
interface ScrollBy {
|
|
3
|
-
/**
|
|
4
|
-
* @description
|
|
5
|
-
* duration
|
|
6
|
-
*/
|
|
7
|
-
duration: number;
|
|
8
|
-
/**
|
|
9
|
-
* @description
|
|
10
|
-
* direction
|
|
11
|
-
*/
|
|
12
|
-
direction?: Direction;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @description
|
|
16
|
-
* scroll to for wrapper element
|
|
17
|
-
*/
|
|
18
|
-
export declare const scrollTo: (target: HTMLElement, to: number, { duration, direction }?: ScrollBy) => void;
|
|
19
|
-
export {};
|
package/dist/dom/scroll-to.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createClass as _createClass, classPrivateFieldGet2 as _classPrivateFieldGet2, classCallCheck as _classCallCheck, classPrivateFieldInitSpec as _classPrivateFieldInitSpec } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
|
|
3
|
-
var _scrolled = /*#__PURE__*/new WeakMap();
|
|
4
|
-
var Scroller = /*#__PURE__*/function () {
|
|
5
|
-
function Scroller() {
|
|
6
|
-
var _scroller$_;
|
|
7
|
-
_classCallCheck(this, Scroller);
|
|
8
|
-
_classPrivateFieldInitSpec(this, _scrolled, new Map());
|
|
9
|
-
return (_scroller$_ = _scroller._) !== null && _scroller$_ !== void 0 ? _scroller$_ : _scroller._ = this;
|
|
10
|
-
}
|
|
11
|
-
return _createClass(Scroller, [{
|
|
12
|
-
key: "scrolled",
|
|
13
|
-
get: function get() {
|
|
14
|
-
return _classPrivateFieldGet2(_scrolled, this);
|
|
15
|
-
}
|
|
16
|
-
}, {
|
|
17
|
-
key: "currentAt",
|
|
18
|
-
value: function currentAt(direction) {
|
|
19
|
-
return direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
|
|
20
|
-
}
|
|
21
|
-
}]);
|
|
22
|
-
}();
|
|
23
|
-
/**
|
|
24
|
-
* @description
|
|
25
|
-
* scroll to for wrapper element
|
|
26
|
-
*/
|
|
27
|
-
// singleton mode
|
|
28
|
-
var _scroller = {
|
|
29
|
-
_: null
|
|
30
|
-
};
|
|
31
|
-
var scrollTo = function scrollTo(target, to) {
|
|
32
|
-
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
33
|
-
duration: 0,
|
|
34
|
-
direction: 'vertical'
|
|
35
|
-
},
|
|
36
|
-
_ref$duration = _ref.duration,
|
|
37
|
-
duration = _ref$duration === void 0 ? 0 : _ref$duration,
|
|
38
|
-
_ref$direction = _ref.direction,
|
|
39
|
-
direction = _ref$direction === void 0 ? 'vertical' : _ref$direction;
|
|
40
|
-
var scroller = new Scroller();
|
|
41
|
-
var scrolled = scroller.scrolled.get(target);
|
|
42
|
-
var currentAtProperty = scroller.currentAt(direction);
|
|
43
|
-
if (scrolled) {
|
|
44
|
-
cancelAnimationFrame(scrolled);
|
|
45
|
-
scroller.scrolled["delete"](target);
|
|
46
|
-
}
|
|
47
|
-
// if duration <= 0, jump immediately
|
|
48
|
-
if (duration <= 0) {
|
|
49
|
-
scroller.scrolled.set(target, requestAnimationFrame(function () {
|
|
50
|
-
target[currentAtProperty] = to;
|
|
51
|
-
}));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// animate
|
|
55
|
-
var currentAt = target[currentAtProperty];
|
|
56
|
-
var difference = to - currentAt;
|
|
57
|
-
var step = difference / duration * 10;
|
|
58
|
-
scroller.scrolled.set(target, requestAnimationFrame(function () {
|
|
59
|
-
target[currentAtProperty] = currentAt + step;
|
|
60
|
-
// over end, stop any animation
|
|
61
|
-
if (target[currentAtProperty] === to) return;
|
|
62
|
-
scrollTo(target, to, {
|
|
63
|
-
duration: duration - 10,
|
|
64
|
-
direction: direction
|
|
65
|
-
});
|
|
66
|
-
}));
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export { scrollTo };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
-
import type { State } from '../types';
|
|
3
|
-
type UsedBoolean = [
|
|
4
|
-
boolean,
|
|
5
|
-
{
|
|
6
|
-
turnOn: () => void;
|
|
7
|
-
turnOff: () => void;
|
|
8
|
-
toggle: () => void;
|
|
9
|
-
setBoolean: Dispatch<SetStateAction<boolean>>;
|
|
10
|
-
}
|
|
11
|
-
];
|
|
12
|
-
/**
|
|
13
|
-
* @author murukal
|
|
14
|
-
*
|
|
15
|
-
* @description
|
|
16
|
-
* boolean state, in relax, we already create some api to easy use
|
|
17
|
-
*/
|
|
18
|
-
export declare const useBoolean: (initialState?: State<boolean>) => UsedBoolean;
|
|
19
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { useState, useCallback } from 'react';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @author murukal
|
|
6
|
-
*
|
|
7
|
-
* @description
|
|
8
|
-
* boolean state, in relax, we already create some api to easy use
|
|
9
|
-
*/
|
|
10
|
-
var useBoolean = function useBoolean(initialState) {
|
|
11
|
-
var _useState = useState(initialState !== null && initialState !== void 0 ? initialState : false),
|
|
12
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
-
isOn = _useState2[0],
|
|
14
|
-
setIsOn = _useState2[1];
|
|
15
|
-
var turnOn = useCallback(function () {
|
|
16
|
-
return setIsOn(true);
|
|
17
|
-
}, []);
|
|
18
|
-
var turnOff = useCallback(function () {
|
|
19
|
-
return setIsOn(false);
|
|
20
|
-
}, []);
|
|
21
|
-
var toggle = useCallback(function () {
|
|
22
|
-
return setIsOn(function (_isOn) {
|
|
23
|
-
return !_isOn;
|
|
24
|
-
});
|
|
25
|
-
}, []);
|
|
26
|
-
return [isOn, {
|
|
27
|
-
turnOn: turnOn,
|
|
28
|
-
turnOff: turnOff,
|
|
29
|
-
toggle: toggle,
|
|
30
|
-
setBoolean: setIsOn
|
|
31
|
-
}];
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { useBoolean };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
-
import type { State } from '../types';
|
|
3
|
-
interface Props<T> {
|
|
4
|
-
/**
|
|
5
|
-
* @description
|
|
6
|
-
* default value
|
|
7
|
-
*/
|
|
8
|
-
defaultState?: State<T>;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @author murukal
|
|
12
|
-
*
|
|
13
|
-
* @description
|
|
14
|
-
* controlled state
|
|
15
|
-
*/
|
|
16
|
-
export declare const useControlledState: <T>(controlledState: T, { defaultState }?: Props<T>) => [T, Dispatch<SetStateAction<T>>];
|
|
17
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { isStateGetter } from '../is/is-state-getter.js';
|
|
4
|
-
import { isUndefined } from '../is/is-undefined.js';
|
|
5
|
-
import { useUpdateEffect } from './use-update-effect.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @author murukal
|
|
9
|
-
*
|
|
10
|
-
* @description
|
|
11
|
-
* controlled state
|
|
12
|
-
*/
|
|
13
|
-
var useControlledState = function useControlledState(controlledState) {
|
|
14
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
15
|
-
defaultState = _ref.defaultState;
|
|
16
|
-
/// initialize state
|
|
17
|
-
var _useState = useState(function () {
|
|
18
|
-
// default use controlled state
|
|
19
|
-
if (!isUndefined(controlledState)) {
|
|
20
|
-
return controlledState;
|
|
21
|
-
}
|
|
22
|
-
// not controlled use default prop
|
|
23
|
-
if (isUndefined(defaultState)) return controlledState;
|
|
24
|
-
if (isStateGetter(defaultState)) return defaultState();
|
|
25
|
-
return defaultState;
|
|
26
|
-
}),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
_state = _useState2[0],
|
|
29
|
-
_setState = _useState2[1];
|
|
30
|
-
/// sync value back to `undefined` when it from control to un-control
|
|
31
|
-
useUpdateEffect(function () {
|
|
32
|
-
if (!isUndefined(controlledState)) return;
|
|
33
|
-
_setState(controlledState !== null && controlledState !== void 0 ? controlledState : defaultState);
|
|
34
|
-
}, [controlledState]);
|
|
35
|
-
/// use controlled
|
|
36
|
-
var state = !isUndefined(controlledState) ? controlledState : _state;
|
|
37
|
-
return [state, _setState];
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { useControlledState };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
-
import type { State } from '../types';
|
|
3
|
-
type Props = {
|
|
4
|
-
/**
|
|
5
|
-
* @description
|
|
6
|
-
* max: count will not be greater than max
|
|
7
|
-
*/
|
|
8
|
-
max?: number;
|
|
9
|
-
/**
|
|
10
|
-
* @description
|
|
11
|
-
* min: count will not be smaller than min
|
|
12
|
-
*/
|
|
13
|
-
min?: number;
|
|
14
|
-
};
|
|
15
|
-
type UsedCounter = [
|
|
16
|
-
number,
|
|
17
|
-
{
|
|
18
|
-
add: (step?: number) => void;
|
|
19
|
-
subtract: (step?: number) => void;
|
|
20
|
-
first: () => void;
|
|
21
|
-
last: () => void;
|
|
22
|
-
reset: () => void;
|
|
23
|
-
setCount: Dispatch<SetStateAction<number>>;
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* @author murukal
|
|
28
|
-
*
|
|
29
|
-
* @description
|
|
30
|
-
* a number counter with some useful apis
|
|
31
|
-
*/
|
|
32
|
-
export declare const useCounter: (initialState?: State<number>, { max, min }?: Props) => UsedCounter;
|
|
33
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { useState, useCallback, useMemo } from 'react';
|
|
3
|
-
import { clamp } from '../utils/clamp.js';
|
|
4
|
-
import { useDefault } from './use-default.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @author murukal
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* a number counter with some useful apis
|
|
11
|
-
*/
|
|
12
|
-
var useCounter = function useCounter() {
|
|
13
|
-
var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
14
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
15
|
-
_ref$max = _ref.max,
|
|
16
|
-
max = _ref$max === void 0 ? Infinity : _ref$max,
|
|
17
|
-
_ref$min = _ref.min,
|
|
18
|
-
min = _ref$min === void 0 ? -Infinity : _ref$min;
|
|
19
|
-
// memorized first time prop value
|
|
20
|
-
var defaultState = useDefault(initialState);
|
|
21
|
-
var _useState = useState(defaultState),
|
|
22
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
-
_count = _useState2[0],
|
|
24
|
-
_setCount = _useState2[1];
|
|
25
|
-
var add = useCallback(function () {
|
|
26
|
-
var step = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
27
|
-
_setCount(function (prev) {
|
|
28
|
-
return Math.min(max, prev + step);
|
|
29
|
-
});
|
|
30
|
-
}, [max]);
|
|
31
|
-
var subtract = useCallback(function () {
|
|
32
|
-
var step = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
33
|
-
_setCount(function (prev) {
|
|
34
|
-
return Math.max(min, prev - step);
|
|
35
|
-
});
|
|
36
|
-
}, [min]);
|
|
37
|
-
var first = useCallback(function () {
|
|
38
|
-
_setCount(min);
|
|
39
|
-
}, [min]);
|
|
40
|
-
var last = useCallback(function () {
|
|
41
|
-
_setCount(max);
|
|
42
|
-
}, [max]);
|
|
43
|
-
var reset = useCallback(function () {
|
|
44
|
-
_setCount(defaultState);
|
|
45
|
-
}, []);
|
|
46
|
-
var count = useMemo(function () {
|
|
47
|
-
return clamp(_count, min, max);
|
|
48
|
-
}, [_count, min, max]);
|
|
49
|
-
return [count, {
|
|
50
|
-
add: add,
|
|
51
|
-
subtract: subtract,
|
|
52
|
-
first: first,
|
|
53
|
-
last: last,
|
|
54
|
-
reset: reset,
|
|
55
|
-
setCount: _setCount
|
|
56
|
-
}];
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export { useCounter };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Debounced, type Debouncer } from '../utils/debounce';
|
|
2
|
-
import { type Callable } from './use-event';
|
|
3
|
-
/**
|
|
4
|
-
* @author murukal
|
|
5
|
-
*
|
|
6
|
-
* @description
|
|
7
|
-
* debounce callback
|
|
8
|
-
*
|
|
9
|
-
* @param callback
|
|
10
|
-
* @param wait number
|
|
11
|
-
* @description
|
|
12
|
-
* The delay time (in milliseconds) until the debounce function is called.
|
|
13
|
-
* default 1000
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* 1000
|
|
17
|
-
*/
|
|
18
|
-
export declare const useDebounceCallback: <T extends Callable, R extends unknown[] = Parameters<T>>(debouncer: T | Debouncer<T, R>, wait?: number) => Debounced<T>;
|