@aiszlab/relax 1.2.63 → 1.2.65
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/dom/scroll-to.js +5 -2
- package/dist/hooks/use-boolean.js +1 -1
- package/dist/hooks/use-click-away.d.ts +2 -1
- package/dist/hooks/use-click-away.js +6 -1
- package/dist/hooks/use-controlled-state.js +1 -1
- package/dist/hooks/use-counter.js +1 -1
- package/dist/hooks/use-device-pixel-ratio.js +1 -1
- package/dist/hooks/use-focus.js +1 -1
- package/dist/hooks/use-force-update.js +1 -1
- package/dist/hooks/use-hover.js +1 -1
- package/dist/hooks/use-image-loader.js +1 -1
- package/dist/hooks/use-media-query.js +1 -1
- package/dist/hooks/use-network.d.ts +5 -0
- package/dist/hooks/use-scroll-locker.js +16 -11
- package/dist/hooks/use-togglable.d.ts +7 -2
- package/dist/hooks/use-togglable.js +37 -35
- package/dist/hooks/use-unmount.d.ts +7 -0
- package/dist/hooks/use-unmount.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/is/is-complex.js +1 -1
- package/dist/is/is-dom-usable.js +2 -1
- package/dist/is/is-empty.js +1 -1
- package/dist/is/is-refable.js +1 -1
- package/dist/types/arrayable.d.ts +1 -0
- package/dist/utils/replace.js +1 -1
- package/dist/utils/set-style.js +1 -1
- package/dist/utils/tagged-template-literals.js +3 -1
- package/dist/utils/to-array.js +1 -1
- package/dist/utils/to-form-data.js +1 -1
- package/dist/utils/waitable.js +23 -16
- package/package.json +5 -2
- package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -153
package/dist/dom/scroll-to.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
3
|
+
import _classPrivateFieldInitSpec from '@babel/runtime/helpers/classPrivateFieldInitSpec';
|
|
4
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet2';
|
|
2
5
|
|
|
3
6
|
var _scrolled = /*#__PURE__*/new WeakMap();
|
|
4
7
|
var Scroller = /*#__PURE__*/function () {
|
|
@@ -11,7 +14,7 @@ var Scroller = /*#__PURE__*/function () {
|
|
|
11
14
|
return _createClass(Scroller, [{
|
|
12
15
|
key: "scrolled",
|
|
13
16
|
get: function get() {
|
|
14
|
-
return
|
|
17
|
+
return _classPrivateFieldGet(_scrolled, this);
|
|
15
18
|
}
|
|
16
19
|
}, {
|
|
17
20
|
key: "currentAt",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type MutableRefObject } from "react";
|
|
2
|
+
import type { Arrayable } from "../types/arrayable";
|
|
2
3
|
/**
|
|
3
4
|
* @description
|
|
4
5
|
* click away
|
|
5
6
|
*/
|
|
6
|
-
export declare const useClickAway: (onClickAway: (event: MouseEvent) => void, target: MutableRefObject<HTMLElement | null
|
|
7
|
+
export declare const useClickAway: (onClickAway: (event: MouseEvent) => void, target: Arrayable<MutableRefObject<HTMLElement | null>>) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useEvent } from './use-event.js';
|
|
3
3
|
import { contains } from '../dom/contains.js';
|
|
4
|
+
import { toArray } from '../utils/to-array.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @description
|
|
@@ -8,7 +9,11 @@ import { contains } from '../dom/contains.js';
|
|
|
8
9
|
*/
|
|
9
10
|
var useClickAway = function useClickAway(onClickAway, target) {
|
|
10
11
|
var clickAway = useEvent(function (event) {
|
|
11
|
-
|
|
12
|
+
var targets = toArray(target);
|
|
13
|
+
var isContained = targets.some(function (_target) {
|
|
14
|
+
return contains(_target.current, event.target);
|
|
15
|
+
});
|
|
16
|
+
if (isContained) return;
|
|
12
17
|
onClickAway(event);
|
|
13
18
|
});
|
|
14
19
|
useEffect(function () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { isStateGetter } from '../is/is-state-getter.js';
|
|
4
4
|
import { isUndefined } from '../is/is-undefined.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { useState, useCallback, useMemo } from 'react';
|
|
3
3
|
import { clamp } from '../utils/clamp.js';
|
|
4
4
|
import { useDefault } from './use-default.js';
|
package/dist/hooks/use-focus.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { useBoolean } from './use-boolean.js';
|
|
4
4
|
import { chain } from '../utils/chain.js';
|
package/dist/hooks/use-hover.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { useBoolean } from './use-boolean.js';
|
|
4
4
|
import { chain } from '../utils/chain.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { useMemo, useState, useEffect } from 'react';
|
|
3
3
|
import { toArray } from '../utils/to-array.js';
|
|
4
4
|
import { useEvent } from './use-event.js';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
3
|
+
import _classPrivateFieldInitSpec from '@babel/runtime/helpers/classPrivateFieldInitSpec';
|
|
4
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet2';
|
|
5
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet2';
|
|
2
6
|
import { useLayoutEffect } from 'react';
|
|
3
7
|
import { isOverflow } from '../is/is-overflow.js';
|
|
4
8
|
import { setStyle } from '../utils/set-style.js';
|
|
@@ -18,7 +22,7 @@ var ScrollLocker = /*#__PURE__*/function () {
|
|
|
18
22
|
return _createClass(ScrollLocker, [{
|
|
19
23
|
key: "barSize",
|
|
20
24
|
get: function get() {
|
|
21
|
-
if (
|
|
25
|
+
if (_classPrivateFieldGet(_barSize, this)) return _classPrivateFieldGet(_barSize, this);
|
|
22
26
|
// how to calculate dom scroll bar size
|
|
23
27
|
// create a backend dom element, set force scrollable
|
|
24
28
|
var _target = document.createElement("div");
|
|
@@ -30,12 +34,12 @@ var ScrollLocker = /*#__PURE__*/function () {
|
|
|
30
34
|
_target.attributeStyleMap.set("overflow", "scroll");
|
|
31
35
|
// calculate, then clear
|
|
32
36
|
document.body.appendChild(_target);
|
|
33
|
-
|
|
37
|
+
_classPrivateFieldSet(_barSize, this, {
|
|
34
38
|
width: _target.offsetWidth - _target.clientWidth,
|
|
35
39
|
height: _target.offsetHeight - _target.clientHeight
|
|
36
40
|
});
|
|
37
41
|
document.body.removeChild(_target);
|
|
38
|
-
return
|
|
42
|
+
return _classPrivateFieldGet(_barSize, this);
|
|
39
43
|
}
|
|
40
44
|
}, {
|
|
41
45
|
key: "isOverflow",
|
|
@@ -47,10 +51,10 @@ var ScrollLocker = /*#__PURE__*/function () {
|
|
|
47
51
|
value: function lock() {
|
|
48
52
|
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.body;
|
|
49
53
|
// if locked, do not lock again
|
|
50
|
-
if (
|
|
54
|
+
if (_classPrivateFieldGet(_locked, this).has(element)) return;
|
|
51
55
|
// if target is not scrollable, do not lock
|
|
52
56
|
if (!isOverflow(element)) return;
|
|
53
|
-
|
|
57
|
+
_classPrivateFieldGet(_locked, this).set(element, setStyle(element, {
|
|
54
58
|
overflow: "hidden",
|
|
55
59
|
width: "calc(100% - ".concat(this.barSize.width, "px)")
|
|
56
60
|
}));
|
|
@@ -60,10 +64,10 @@ var ScrollLocker = /*#__PURE__*/function () {
|
|
|
60
64
|
value: function unlock() {
|
|
61
65
|
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.body;
|
|
62
66
|
// not locked, no need to unlock
|
|
63
|
-
if (!
|
|
67
|
+
if (!_classPrivateFieldGet(_locked, this).has(element)) return;
|
|
64
68
|
// reset style, in lock, some styled are setted
|
|
65
|
-
setStyle(element,
|
|
66
|
-
|
|
69
|
+
setStyle(element, _classPrivateFieldGet(_locked, this).get(element));
|
|
70
|
+
_classPrivateFieldGet(_locked, this)["delete"](element);
|
|
67
71
|
}
|
|
68
72
|
}]);
|
|
69
73
|
}();
|
|
@@ -75,7 +79,8 @@ var ScrollLocker = /*#__PURE__*/function () {
|
|
|
75
79
|
var _scrollLocker = {
|
|
76
80
|
_: null
|
|
77
81
|
};
|
|
78
|
-
var useScrollLocker = function useScrollLocker(
|
|
82
|
+
var useScrollLocker = function useScrollLocker() {
|
|
83
|
+
var isLock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
79
84
|
useLayoutEffect(function () {
|
|
80
85
|
var scrollLocker = new ScrollLocker();
|
|
81
86
|
if (!!isLock) {
|
|
@@ -86,7 +91,7 @@ var useScrollLocker = function useScrollLocker(isLock) {
|
|
|
86
91
|
return function () {
|
|
87
92
|
scrollLocker.unlock(document.body);
|
|
88
93
|
};
|
|
89
|
-
}, [
|
|
94
|
+
}, [isLock]);
|
|
90
95
|
};
|
|
91
96
|
|
|
92
97
|
export { useScrollLocker };
|
|
@@ -19,7 +19,7 @@ type TogglableKey = {
|
|
|
19
19
|
* @description
|
|
20
20
|
* extra options
|
|
21
21
|
*/
|
|
22
|
-
type
|
|
22
|
+
type UseTogglableOptions = {
|
|
23
23
|
/**
|
|
24
24
|
* @description
|
|
25
25
|
* default toggled
|
|
@@ -35,12 +35,17 @@ type Options = {
|
|
|
35
35
|
* on toggle callback
|
|
36
36
|
*/
|
|
37
37
|
onToggle?: (keys: Key[]) => void;
|
|
38
|
+
/**
|
|
39
|
+
* @description
|
|
40
|
+
* default toggled keys
|
|
41
|
+
*/
|
|
42
|
+
defaultToggledKeys?: Key[];
|
|
38
43
|
};
|
|
39
44
|
/**
|
|
40
45
|
* @description
|
|
41
46
|
* toggle able
|
|
42
47
|
*/
|
|
43
|
-
export declare const useTogglable: (togglableKeys: TogglableKey[], { onToggle,
|
|
48
|
+
export declare const useTogglable: (togglableKeys: TogglableKey[], { onToggle, defaultToggledKeys, isDefaultToggled, toggledKeys }?: UseTogglableOptions) => {
|
|
44
49
|
toggledKeys: Set<Key>;
|
|
45
50
|
isToggled: (key: Key) => boolean;
|
|
46
51
|
toggle: (key: Key) => void;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
3
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
4
|
+
import _classPrivateFieldInitSpec from '@babel/runtime/helpers/classPrivateFieldInitSpec';
|
|
5
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet2';
|
|
6
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet2';
|
|
2
7
|
import { useMemo, useCallback } from 'react';
|
|
3
8
|
import { useControlledState } from './use-controlled-state.js';
|
|
4
9
|
import { useEvent } from './use-event.js';
|
|
5
10
|
|
|
6
|
-
var _excluded = ["onToggle"];
|
|
7
11
|
var _groupedLeaves = /*#__PURE__*/new WeakMap();
|
|
8
12
|
var Tree = /*#__PURE__*/function () {
|
|
9
13
|
function Tree() {
|
|
10
14
|
_classCallCheck(this, Tree);
|
|
11
15
|
_classPrivateFieldInitSpec(this, _groupedLeaves, void 0);
|
|
12
|
-
|
|
16
|
+
_classPrivateFieldSet(_groupedLeaves, this, new Map());
|
|
13
17
|
}
|
|
14
18
|
return _createClass(Tree, [{
|
|
15
19
|
key: "groupedLeaves",
|
|
16
20
|
get: function get() {
|
|
17
|
-
return
|
|
21
|
+
return _classPrivateFieldGet(_groupedLeaves, this);
|
|
18
22
|
}
|
|
19
23
|
}, {
|
|
20
24
|
key: "grow",
|
|
@@ -30,7 +34,7 @@ var Tree = /*#__PURE__*/function () {
|
|
|
30
34
|
}, {
|
|
31
35
|
key: "collect",
|
|
32
36
|
value: function collect(leaf) {
|
|
33
|
-
|
|
37
|
+
_classPrivateFieldGet(_groupedLeaves, this).has(leaf.key) ? _classPrivateFieldGet(_groupedLeaves, this).get(leaf.key).add(leaf) : _classPrivateFieldGet(_groupedLeaves, this).set(leaf.key, new Set([leaf]));
|
|
34
38
|
}
|
|
35
39
|
}, {
|
|
36
40
|
key: "toggle",
|
|
@@ -42,7 +46,7 @@ var Tree = /*#__PURE__*/function () {
|
|
|
42
46
|
}, {
|
|
43
47
|
key: "toggleBy",
|
|
44
48
|
value: function toggleBy(key, isToggled, _toggledKeys) {
|
|
45
|
-
var _classPrivateFieldGet2
|
|
49
|
+
var _classPrivateFieldGet2;
|
|
46
50
|
var toggledKeys = new Set(_toggledKeys);
|
|
47
51
|
// toggle current leaf
|
|
48
52
|
if (isToggled) {
|
|
@@ -50,7 +54,7 @@ var Tree = /*#__PURE__*/function () {
|
|
|
50
54
|
} else {
|
|
51
55
|
toggledKeys["delete"](key);
|
|
52
56
|
}
|
|
53
|
-
return Array.from((_classPrivateFieldGet2
|
|
57
|
+
return Array.from((_classPrivateFieldGet2 = _classPrivateFieldGet(_groupedLeaves, this).get(key)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : []).reduce(function (prev, leaf) {
|
|
54
58
|
// deep fall, add or remove child key
|
|
55
59
|
return leaf.rise(
|
|
56
60
|
// deep rise, add or remove parent key
|
|
@@ -70,17 +74,17 @@ var Leaf = /*#__PURE__*/function () {
|
|
|
70
74
|
_classPrivateFieldInitSpec(this, _belongTo, void 0);
|
|
71
75
|
_classPrivateFieldInitSpec(this, _parent, void 0);
|
|
72
76
|
_classPrivateFieldInitSpec(this, _children, void 0);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
_classPrivateFieldSet(_key, this, props.key);
|
|
78
|
+
_classPrivateFieldSet(_parent, this, props.parent);
|
|
79
|
+
_classPrivateFieldSet(_belongTo, this, props.belongTo);
|
|
80
|
+
_classPrivateFieldSet(_children, this, []);
|
|
77
81
|
// when leaf has grew, let tree collect leaf
|
|
78
|
-
|
|
82
|
+
_classPrivateFieldGet(_belongTo, this).collect(this);
|
|
79
83
|
}
|
|
80
84
|
return _createClass(Leaf, [{
|
|
81
85
|
key: "key",
|
|
82
86
|
get: function get() {
|
|
83
|
-
return
|
|
87
|
+
return _classPrivateFieldGet(_key, this);
|
|
84
88
|
}
|
|
85
89
|
}, {
|
|
86
90
|
key: "grow",
|
|
@@ -92,9 +96,9 @@ var Leaf = /*#__PURE__*/function () {
|
|
|
92
96
|
var child = new Leaf({
|
|
93
97
|
key: node.key,
|
|
94
98
|
parent: _this,
|
|
95
|
-
belongTo:
|
|
99
|
+
belongTo: _classPrivateFieldGet(_belongTo, _this)
|
|
96
100
|
}).grow(node.children);
|
|
97
|
-
|
|
101
|
+
_classPrivateFieldGet(_children, _this).push(child);
|
|
98
102
|
});
|
|
99
103
|
return this;
|
|
100
104
|
}
|
|
@@ -102,22 +106,22 @@ var Leaf = /*#__PURE__*/function () {
|
|
|
102
106
|
key: "rise",
|
|
103
107
|
value: function rise(_toggledKeys) {
|
|
104
108
|
var rised = new Set(_toggledKeys);
|
|
105
|
-
if (!
|
|
106
|
-
var isChildrenToggled =
|
|
109
|
+
if (!_classPrivateFieldGet(_parent, this)) return rised;
|
|
110
|
+
var isChildrenToggled = _classPrivateFieldGet(_children, _classPrivateFieldGet(_parent, this)).every(function (child) {
|
|
107
111
|
return rised.has(child.key);
|
|
108
112
|
});
|
|
109
113
|
if (isChildrenToggled) {
|
|
110
|
-
rised.add(
|
|
114
|
+
rised.add(_classPrivateFieldGet(_parent, this).key);
|
|
111
115
|
} else {
|
|
112
|
-
rised["delete"](
|
|
116
|
+
rised["delete"](_classPrivateFieldGet(_parent, this).key);
|
|
113
117
|
}
|
|
114
118
|
// go on parent
|
|
115
|
-
return
|
|
119
|
+
return _classPrivateFieldGet(_parent, this).rise(rised);
|
|
116
120
|
}
|
|
117
121
|
}, {
|
|
118
122
|
key: "fall",
|
|
119
123
|
value: function fall(isToggled, toggledKeys) {
|
|
120
|
-
return
|
|
124
|
+
return _classPrivateFieldGet(_children, this).reduce(function (prev, leaf) {
|
|
121
125
|
// deep loop, remove or add key
|
|
122
126
|
var fell = leaf.fall(isToggled, prev);
|
|
123
127
|
// toggle true, add current leaf key
|
|
@@ -139,36 +143,34 @@ var Leaf = /*#__PURE__*/function () {
|
|
|
139
143
|
var useTogglable = function useTogglable(togglableKeys) {
|
|
140
144
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
141
145
|
onToggle = _ref.onToggle,
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
_ref$defaultToggledKe = _ref.defaultToggledKeys,
|
|
147
|
+
defaultToggledKeys = _ref$defaultToggledKe === void 0 ? [] : _ref$defaultToggledKe,
|
|
148
|
+
isDefaultToggled = _ref.isDefaultToggled,
|
|
149
|
+
toggledKeys = _ref.toggledKeys;
|
|
150
|
+
// re-create tree when togglable keys changed
|
|
144
151
|
var tree = useMemo(function () {
|
|
145
152
|
return togglableKeys.reduce(function (_tree, togglable) {
|
|
146
153
|
return _tree.grow(togglable);
|
|
147
154
|
}, new Tree());
|
|
148
155
|
}, [togglableKeys]);
|
|
149
|
-
|
|
150
|
-
var _useControlledState = useControlledState(
|
|
156
|
+
// use controlled state to record toggled keys
|
|
157
|
+
var _useControlledState = useControlledState(toggledKeys, {
|
|
151
158
|
defaultState: function defaultState() {
|
|
152
|
-
return
|
|
153
|
-
leaves.forEach(function (leaf) {
|
|
154
|
-
return prev.add(leaf.key);
|
|
155
|
-
});
|
|
156
|
-
return prev;
|
|
157
|
-
}, new Set())) : [];
|
|
159
|
+
return isDefaultToggled ? Array.from(tree.groupedLeaves.keys()) : defaultToggledKeys;
|
|
158
160
|
}
|
|
159
161
|
}),
|
|
160
162
|
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
161
163
|
_toggledKeys = _useControlledState2[0],
|
|
162
164
|
_setToggledKeys = _useControlledState2[1];
|
|
163
|
-
|
|
165
|
+
// use set for toggled keys to make it read easily
|
|
164
166
|
var readableToggledKeys = useMemo(function () {
|
|
165
167
|
return new Set(_toggledKeys);
|
|
166
168
|
}, [_toggledKeys]);
|
|
167
|
-
|
|
169
|
+
// check current key is toggled
|
|
168
170
|
var isToggled = useCallback(function (key) {
|
|
169
|
-
return
|
|
171
|
+
return readableToggledKeys.has(key);
|
|
170
172
|
}, [readableToggledKeys]);
|
|
171
|
-
|
|
173
|
+
// toggle one key
|
|
172
174
|
var toggle = useEvent(function (key) {
|
|
173
175
|
// get new toggled keys by toggle current key
|
|
174
176
|
var _toggledKeys = Array.from(tree.toggle(key, readableToggledKeys));
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { useDevicePixelRatio } from "./hooks/use-device-pixel-ratio";
|
|
|
28
28
|
export { useIdentity } from "./hooks/use-identity";
|
|
29
29
|
export { useMediaQuery } from "./hooks/use-media-query";
|
|
30
30
|
export { useClickAway } from "./hooks/use-click-away";
|
|
31
|
+
export { useUnmount } from "./hooks/use-unmount";
|
|
31
32
|
/**
|
|
32
33
|
* @description
|
|
33
34
|
* is
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { useDevicePixelRatio } from './hooks/use-device-pixel-ratio.js';
|
|
|
24
24
|
export { useIdentity } from './hooks/use-identity.js';
|
|
25
25
|
export { useMediaQuery } from './hooks/use-media-query.js';
|
|
26
26
|
export { useClickAway } from './hooks/use-click-away.js';
|
|
27
|
+
export { useUnmount } from './hooks/use-unmount.js';
|
|
27
28
|
export { isRefable } from './is/is-refable.js';
|
|
28
29
|
export { isUndefined } from './is/is-undefined.js';
|
|
29
30
|
export { isStateGetter } from './is/is-state-getter.js';
|
package/dist/is/is-complex.js
CHANGED
package/dist/is/is-dom-usable.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* if there is dom
|
|
4
4
|
*/
|
|
5
5
|
var isDomUsable = function isDomUsable() {
|
|
6
|
-
|
|
6
|
+
var _window$document;
|
|
7
|
+
return typeof window === "undefined" || !((_window$document = window.document) !== null && _window$document !== void 0 && _window$document.createElement);
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export { isDomUsable };
|
package/dist/is/is-empty.js
CHANGED
package/dist/is/is-refable.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Arrayable<T> = T | T[];
|
package/dist/utils/replace.js
CHANGED
package/dist/utils/set-style.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _construct from '@babel/runtime/helpers/construct';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @description
|
package/dist/utils/to-array.js
CHANGED
package/dist/utils/waitable.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
3
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
4
|
+
import _classPrivateMethodInitSpec from '@babel/runtime/helpers/classPrivateMethodInitSpec';
|
|
5
|
+
import _classPrivateFieldInitSpec from '@babel/runtime/helpers/classPrivateFieldInitSpec';
|
|
6
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet2';
|
|
7
|
+
import _assertClassBrand from '@babel/runtime/helpers/assertClassBrand';
|
|
8
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet2';
|
|
2
9
|
import { Observable, switchMap, from, of } from 'rxjs';
|
|
3
10
|
import { isThenable } from '../is/is-thenable.js';
|
|
4
11
|
|
|
@@ -22,11 +29,11 @@ var Waitable = /*#__PURE__*/function () {
|
|
|
22
29
|
_classPrivateFieldInitSpec(this, _timer, void 0);
|
|
23
30
|
_classPrivateFieldInitSpec(this, _pipe, void 0);
|
|
24
31
|
_classPrivateFieldInitSpec(this, _callback, void 0);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
_classPrivateFieldSet(_cook$, this, null);
|
|
33
|
+
_classPrivateFieldSet(_waiter$, this, null);
|
|
34
|
+
_classPrivateFieldSet(_pipe, this, props.pipe);
|
|
35
|
+
_classPrivateFieldSet(_timer, this, props.timer);
|
|
36
|
+
_classPrivateFieldSet(_callback, this, props.callback);
|
|
30
37
|
_assertClassBrand(_Waitable_brand, this, _use).call(this);
|
|
31
38
|
}
|
|
32
39
|
return _createClass(Waitable, [{
|
|
@@ -40,8 +47,8 @@ var Waitable = /*#__PURE__*/function () {
|
|
|
40
47
|
* so it will make some async problems, pls attention
|
|
41
48
|
*/
|
|
42
49
|
function flush() {
|
|
43
|
-
var _classPrivateFieldGet2
|
|
44
|
-
(_classPrivateFieldGet2
|
|
50
|
+
var _classPrivateFieldGet2;
|
|
51
|
+
(_classPrivateFieldGet2 = _classPrivateFieldGet(_waiter$, this)) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.complete();
|
|
45
52
|
_assertClassBrand(_Waitable_brand, this, _use).call(this);
|
|
46
53
|
}
|
|
47
54
|
/**
|
|
@@ -54,8 +61,8 @@ var Waitable = /*#__PURE__*/function () {
|
|
|
54
61
|
key: "abort",
|
|
55
62
|
value: function abort() {
|
|
56
63
|
var _classPrivateFieldGet3, _classPrivateFieldGet4;
|
|
57
|
-
(_classPrivateFieldGet3 =
|
|
58
|
-
(_classPrivateFieldGet4 =
|
|
64
|
+
(_classPrivateFieldGet3 = _classPrivateFieldGet(_cook$, this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.unsubscribe();
|
|
65
|
+
(_classPrivateFieldGet4 = _classPrivateFieldGet(_waiter$, this)) === null || _classPrivateFieldGet4 === void 0 || _classPrivateFieldGet4.error();
|
|
59
66
|
_assertClassBrand(_Waitable_brand, this, _use).call(this);
|
|
60
67
|
}
|
|
61
68
|
/**
|
|
@@ -69,21 +76,21 @@ var Waitable = /*#__PURE__*/function () {
|
|
|
69
76
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
70
77
|
args[_key] = arguments[_key];
|
|
71
78
|
}
|
|
72
|
-
(_classPrivateFieldGet5 =
|
|
79
|
+
(_classPrivateFieldGet5 = _classPrivateFieldGet(_waiter$, this)) === null || _classPrivateFieldGet5 === void 0 || _classPrivateFieldGet5.next(args);
|
|
73
80
|
}
|
|
74
81
|
}]);
|
|
75
82
|
}();
|
|
76
83
|
function _use() {
|
|
77
84
|
var _this = this;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}).pipe(
|
|
85
|
+
_classPrivateFieldSet(_cook$, this, new Observable(function (subscriber) {
|
|
86
|
+
_classPrivateFieldSet(_waiter$, _this, subscriber);
|
|
87
|
+
}).pipe(_classPrivateFieldGet(_timer, this), switchMap(function (args) {
|
|
81
88
|
var _classPrivateFieldGet6;
|
|
82
|
-
var piped = (_classPrivateFieldGet6 =
|
|
89
|
+
var piped = (_classPrivateFieldGet6 = _classPrivateFieldGet(_pipe, _this)).call.apply(_classPrivateFieldGet6, [_this].concat(_toConsumableArray(args)));
|
|
83
90
|
return isThenable(piped) ? from(piped) : of(piped);
|
|
84
91
|
})).subscribe(function (args) {
|
|
85
92
|
var _classPrivateFieldGet7;
|
|
86
|
-
(_classPrivateFieldGet7 =
|
|
93
|
+
(_classPrivateFieldGet7 = _classPrivateFieldGet(_callback, _this)) === null || _classPrivateFieldGet7 === void 0 || _classPrivateFieldGet7.call.apply(_classPrivateFieldGet7, [_this].concat(_toConsumableArray(args)));
|
|
87
94
|
}));
|
|
88
95
|
}
|
|
89
96
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiszlab/relax",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.65",
|
|
4
4
|
"description": "react utils collection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,12 +22,15 @@
|
|
|
22
22
|
"test": "jest"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@babel/runtime": "^7.24.8",
|
|
25
26
|
"react-is": "^18.2.0",
|
|
26
27
|
"rxjs": "^7.8.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@babel/core": "^7.24.9",
|
|
31
|
+
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
30
32
|
"@babel/preset-env": "^7.24.8",
|
|
33
|
+
"@babel/preset-react": "^7.24.7",
|
|
31
34
|
"@babel/preset-typescript": "^7.24.7",
|
|
32
35
|
"@jest/globals": "^29.7.0",
|
|
33
36
|
"@rollup/plugin-babel": "^6.0.4",
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
"jest-environment-jsdom": "^29.7.0",
|
|
42
45
|
"react": "18",
|
|
43
46
|
"react-dom": "18",
|
|
44
|
-
"rollup": "^4.
|
|
47
|
+
"rollup": "^4.19.0",
|
|
45
48
|
"typescript": "5.5.3"
|
|
46
49
|
},
|
|
47
50
|
"peerDependencies": {
|
|
@@ -1,153 +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 _construct(t, e, r) {
|
|
35
|
-
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
36
|
-
var o = [null];
|
|
37
|
-
o.push.apply(o, e);
|
|
38
|
-
var p = new (t.bind.apply(t, o))();
|
|
39
|
-
return p;
|
|
40
|
-
}
|
|
41
|
-
function _defineProperties(e, r) {
|
|
42
|
-
for (var t = 0; t < r.length; t++) {
|
|
43
|
-
var o = r[t];
|
|
44
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function _createClass(e, r, t) {
|
|
48
|
-
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
49
|
-
writable: !1
|
|
50
|
-
}), e;
|
|
51
|
-
}
|
|
52
|
-
function _isNativeReflectConstruct() {
|
|
53
|
-
try {
|
|
54
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
55
|
-
} catch (t) {}
|
|
56
|
-
return (_isNativeReflectConstruct = function () {
|
|
57
|
-
return !!t;
|
|
58
|
-
})();
|
|
59
|
-
}
|
|
60
|
-
function _iterableToArray(r) {
|
|
61
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
62
|
-
}
|
|
63
|
-
function _iterableToArrayLimit(r, l) {
|
|
64
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
65
|
-
if (null != t) {
|
|
66
|
-
var e,
|
|
67
|
-
n,
|
|
68
|
-
i,
|
|
69
|
-
u,
|
|
70
|
-
a = [],
|
|
71
|
-
f = !0,
|
|
72
|
-
o = !1;
|
|
73
|
-
try {
|
|
74
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
75
|
-
if (Object(t) !== t) return;
|
|
76
|
-
f = !1;
|
|
77
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
78
|
-
} catch (r) {
|
|
79
|
-
o = !0, n = r;
|
|
80
|
-
} finally {
|
|
81
|
-
try {
|
|
82
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
83
|
-
} finally {
|
|
84
|
-
if (o) throw n;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return a;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function _nonIterableRest() {
|
|
91
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
|
-
}
|
|
93
|
-
function _nonIterableSpread() {
|
|
94
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
95
|
-
}
|
|
96
|
-
function _objectWithoutProperties(e, t) {
|
|
97
|
-
if (null == e) return {};
|
|
98
|
-
var o,
|
|
99
|
-
r,
|
|
100
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
101
|
-
if (Object.getOwnPropertySymbols) {
|
|
102
|
-
var s = Object.getOwnPropertySymbols(e);
|
|
103
|
-
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
104
|
-
}
|
|
105
|
-
return i;
|
|
106
|
-
}
|
|
107
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
108
|
-
if (null == r) return {};
|
|
109
|
-
var t = {};
|
|
110
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
111
|
-
if (e.includes(n)) continue;
|
|
112
|
-
t[n] = r[n];
|
|
113
|
-
}
|
|
114
|
-
return t;
|
|
115
|
-
}
|
|
116
|
-
function _slicedToArray(r, e) {
|
|
117
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
118
|
-
}
|
|
119
|
-
function _toConsumableArray(r) {
|
|
120
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
121
|
-
}
|
|
122
|
-
function _toPrimitive(t, r) {
|
|
123
|
-
if ("object" != typeof t || !t) return t;
|
|
124
|
-
var e = t[Symbol.toPrimitive];
|
|
125
|
-
if (void 0 !== e) {
|
|
126
|
-
var i = e.call(t, r );
|
|
127
|
-
if ("object" != typeof i) return i;
|
|
128
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
129
|
-
}
|
|
130
|
-
return (String )(t);
|
|
131
|
-
}
|
|
132
|
-
function _toPropertyKey(t) {
|
|
133
|
-
var i = _toPrimitive(t, "string");
|
|
134
|
-
return "symbol" == typeof i ? i : i + "";
|
|
135
|
-
}
|
|
136
|
-
function _typeof(o) {
|
|
137
|
-
"@babel/helpers - typeof";
|
|
138
|
-
|
|
139
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
140
|
-
return typeof o;
|
|
141
|
-
} : function (o) {
|
|
142
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
143
|
-
}, _typeof(o);
|
|
144
|
-
}
|
|
145
|
-
function _unsupportedIterableToArray(r, a) {
|
|
146
|
-
if (r) {
|
|
147
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
148
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
149
|
-
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;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
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, _construct as construct, _createClass as createClass, _isNativeReflectConstruct as isNativeReflectConstruct, _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 };
|