@aiszlab/relax 1.2.38 → 1.2.39

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.
Files changed (80) hide show
  1. package/dist/_virtual/_rollupPluginBabelHelpers.js +153 -0
  2. package/dist/dom/contains.js +16 -16
  3. package/dist/dom/scroll-to.js +59 -43
  4. package/dist/hooks/use-boolean.js +23 -11
  5. package/dist/hooks/use-controlled-state.js +26 -23
  6. package/dist/hooks/use-counter.js +48 -21
  7. package/dist/hooks/use-debounce-callback.js +57 -33
  8. package/dist/hooks/use-default.js +2 -2
  9. package/dist/hooks/use-event.js +7 -5
  10. package/dist/hooks/use-focus.js +25 -10
  11. package/dist/hooks/use-force-update.js +12 -6
  12. package/dist/hooks/use-hover.js +19 -10
  13. package/dist/hooks/use-image-loader.js +42 -29
  14. package/dist/hooks/use-memorable.js +9 -9
  15. package/dist/hooks/use-mount.js +5 -5
  16. package/dist/hooks/use-mounted.js +5 -5
  17. package/dist/hooks/use-refs.js +18 -16
  18. package/dist/hooks/use-scroll-locker.js +75 -62
  19. package/dist/hooks/use-scrollable.js +33 -31
  20. package/dist/hooks/use-throttle-callback.d.ts +3 -3
  21. package/dist/hooks/use-throttle-callback.js +61 -35
  22. package/dist/hooks/use-timeout.js +8 -9
  23. package/dist/hooks/use-toggleable.js +165 -124
  24. package/dist/hooks/use-update-effect.js +13 -14
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +7 -6
  27. package/dist/is/is-array.js +2 -2
  28. package/dist/is/is-complex.js +4 -2
  29. package/dist/is/is-dom-usable.js +2 -2
  30. package/dist/is/is-empty.js +13 -13
  31. package/dist/is/is-function.js +2 -2
  32. package/dist/is/is-mobile.js +6 -9
  33. package/dist/is/is-null.js +2 -2
  34. package/dist/is/is-overflow.js +7 -7
  35. package/dist/is/is-refable.js +20 -19
  36. package/dist/is/is-state-getter.js +2 -2
  37. package/dist/is/is-style-element.js +2 -2
  38. package/dist/is/is-thenable/index.js +9 -0
  39. package/dist/is/is-thenable/index.test.d.ts +1 -0
  40. package/dist/is/is-undefined.js +2 -2
  41. package/dist/is/is-void.js +2 -2
  42. package/dist/utils/{chain.d.ts → chain/index.d.ts} +1 -1
  43. package/dist/utils/chain/index.js +15 -0
  44. package/dist/utils/chain/index.test.d.ts +1 -0
  45. package/dist/utils/{clamp.js → clamp/index.js} +2 -2
  46. package/dist/utils/clamp/index.test.d.ts +1 -0
  47. package/dist/utils/clone/index.test.d.ts +1 -0
  48. package/dist/utils/debounce/index.d.ts +23 -0
  49. package/dist/utils/debounce/index.js +32 -0
  50. package/dist/utils/debounce/index.test.d.ts +1 -0
  51. package/dist/utils/{effect.d.ts → effect/index.d.ts} +1 -1
  52. package/dist/utils/effect/index.js +16 -0
  53. package/dist/utils/effect/index.test.d.ts +1 -0
  54. package/dist/utils/exclude/index.d.ts +7 -0
  55. package/dist/utils/exclude/index.js +14 -0
  56. package/dist/utils/exclude/index.test.d.ts +1 -0
  57. package/dist/utils/range.js +7 -3
  58. package/dist/utils/set-style.js +14 -10
  59. package/dist/utils/{throttle.d.ts → throttle/index.d.ts} +3 -3
  60. package/dist/utils/throttle/index.js +32 -0
  61. package/dist/utils/throttle/index.test.d.ts +1 -0
  62. package/dist/utils/to-array/index.d.ts +18 -0
  63. package/dist/utils/to-array/index.js +25 -0
  64. package/dist/utils/to-array/index.test.d.ts +1 -0
  65. package/dist/utils/to-function.js +8 -6
  66. package/dist/utils/unique.js +4 -4
  67. package/dist/utils/waitable/index.d.ts +36 -0
  68. package/dist/utils/waitable/index.js +90 -0
  69. package/package.json +7 -4
  70. package/dist/is/is-thenable.js +0 -9
  71. package/dist/utils/chain.js +0 -9
  72. package/dist/utils/debounce.d.ts +0 -56
  73. package/dist/utils/debounce.js +0 -77
  74. package/dist/utils/effect.js +0 -18
  75. package/dist/utils/throttle.js +0 -17
  76. package/dist/utils/to-array.d.ts +0 -5
  77. package/dist/utils/to-array.js +0 -12
  78. /package/dist/is/{is-thenable.d.ts → is-thenable/index.d.ts} +0 -0
  79. /package/dist/utils/{clamp.d.ts → clamp/index.d.ts} +0 -0
  80. /package/dist/utils/{clone.d.ts → clone/index.d.ts} +0 -0
@@ -1,21 +1,30 @@
1
1
  import { useRef, useEffect, useMemo } from 'react';
2
- import { throttle } from '../utils/throttle.js';
2
+ import { throttle } from '../utils/throttle/index.js';
3
3
  import { useEvent } from './use-event.js';
4
4
  import { isFunction } from '../is/is-function.js';
5
5
  import { useDefault } from './use-default.js';
6
6
 
7
- const useThrottler = (debouncer) => {
8
- const _debouncer = useMemo(() => {
9
- return isFunction(debouncer) ? { callback: debouncer, pipeable: null } : debouncer;
10
- }, [debouncer]);
11
- return {
12
- callback: useEvent((...args) => {
13
- return _debouncer.callback(...args);
14
- }),
15
- pipeable: useEvent((...args) => {
16
- return _debouncer.pipeable?.(...args) ?? args;
17
- })
18
- };
7
+ var useThrottler = function useThrottler(throttler) {
8
+ var _useMemo = useMemo(function () {
9
+ return isFunction(throttler) ? {
10
+ callback: throttler,
11
+ pipe: null
12
+ } : throttler;
13
+ }, [throttler]),
14
+ callback = _useMemo.callback,
15
+ pipe = _useMemo.pipe;
16
+ return {
17
+ callback: useEvent(function () {
18
+ return callback.apply(void 0, arguments);
19
+ }),
20
+ pipe: useEvent(function () {
21
+ var _pipe;
22
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
+ args[_key] = arguments[_key];
24
+ }
25
+ return (_pipe = pipe === null || pipe === void 0 ? void 0 : pipe.apply(void 0, args)) !== null && _pipe !== void 0 ? _pipe : args;
26
+ })
27
+ };
19
28
  };
20
29
  /**
21
30
  * @author murukal
@@ -24,34 +33,51 @@ const useThrottler = (debouncer) => {
24
33
  * throttle callback
25
34
  *
26
35
  * @param callback
27
- * @param duration number
36
+ * @param wait number
28
37
  * @description
29
- * The duration time (in milliseconds) until the throttle function is called.
38
+ * The wait time (in milliseconds) until the throttle function is called.
30
39
  * default 1000
31
40
  *
32
41
  * @example
33
42
  * 1000
34
43
  */
35
- const useThrottleCallback = (throttler, duration = 1000) => {
36
- const throttled = useRef(null);
37
- const { callback, pipeable } = useThrottler(throttler);
38
- useEffect(() => {
39
- const _throttled = throttle({
40
- callback,
41
- pipeable
42
- }, duration);
43
- throttled.current = _throttled;
44
- // dispose
45
- return () => {
46
- _throttled.abort();
47
- throttled.current = null;
48
- };
49
- }, [duration]);
50
- return useDefault(() => ({
51
- next: (...args) => throttled.current?.next(...args),
52
- flush: () => throttled.current?.flush(),
53
- abort: () => throttled.current?.abort()
54
- }));
44
+ var useThrottleCallback = function useThrottleCallback(throttler) {
45
+ var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
46
+ var throttled = useRef(null);
47
+ var _useThrottler = useThrottler(throttler),
48
+ callback = _useThrottler.callback,
49
+ pipe = _useThrottler.pipe;
50
+ useEffect(function () {
51
+ var _throttled = throttle({
52
+ callback: callback,
53
+ pipe: pipe
54
+ }, wait);
55
+ throttled.current = _throttled;
56
+ // dispose
57
+ return function () {
58
+ _throttled.abort();
59
+ throttled.current = null;
60
+ };
61
+ }, [wait]);
62
+ return useDefault(function () {
63
+ return {
64
+ next: function next() {
65
+ var _throttled$current;
66
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
67
+ args[_key2] = arguments[_key2];
68
+ }
69
+ return (_throttled$current = throttled.current) === null || _throttled$current === void 0 ? void 0 : _throttled$current.next.apply(_throttled$current, args);
70
+ },
71
+ flush: function flush() {
72
+ var _throttled$current2;
73
+ return (_throttled$current2 = throttled.current) === null || _throttled$current2 === void 0 ? void 0 : _throttled$current2.flush();
74
+ },
75
+ abort: function abort() {
76
+ var _throttled$current3;
77
+ return (_throttled$current3 = throttled.current) === null || _throttled$current3 === void 0 ? void 0 : _throttled$current3.abort();
78
+ }
79
+ };
80
+ });
55
81
  };
56
82
 
57
83
  export { useThrottleCallback };
@@ -6,15 +6,14 @@ import { useEffect } from 'react';
6
6
  * @description
7
7
  * timeout effect
8
8
  */
9
- const useTimeout = (handler, wait) => {
10
- useEffect(() => {
11
- const timer = setTimeout(handler, wait);
12
- return () => {
13
- if (!timer)
14
- return;
15
- clearTimeout(timer);
16
- };
17
- }, [wait]);
9
+ var useTimeout = function useTimeout(handler, wait) {
10
+ useEffect(function () {
11
+ var timer = setTimeout(handler, wait);
12
+ return function () {
13
+ if (!timer) return;
14
+ clearTimeout(timer);
15
+ };
16
+ }, [wait]);
18
17
  };
19
18
 
20
19
  export { useTimeout };
@@ -1,145 +1,186 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, createClass as _createClass, classPrivateFieldGet2 as _classPrivateFieldGet2, classCallCheck as _classCallCheck, classPrivateFieldInitSpec as _classPrivateFieldInitSpec, classPrivateFieldSet2 as _classPrivateFieldSet2 } from '../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import { useMemo, useCallback } from 'react';
2
3
  import { useControlledState } from './use-controlled-state.js';
3
4
 
4
- class Tree {
5
- #groupedLeaves;
6
- constructor() {
7
- this.#groupedLeaves = new Map();
5
+ var _excluded = ["onToggle"];
6
+ var _groupedLeaves = /*#__PURE__*/new WeakMap();
7
+ var Tree = /*#__PURE__*/function () {
8
+ function Tree() {
9
+ _classCallCheck(this, Tree);
10
+ _classPrivateFieldInitSpec(this, _groupedLeaves, void 0);
11
+ _classPrivateFieldSet2(_groupedLeaves, this, new Map());
12
+ }
13
+ return _createClass(Tree, [{
14
+ key: "groupedLeaves",
15
+ get: function get() {
16
+ return _classPrivateFieldGet2(_groupedLeaves, this);
8
17
  }
9
- get groupedLeaves() {
10
- return this.#groupedLeaves;
18
+ }, {
19
+ key: "grow",
20
+ value: function grow(toggleableKey) {
21
+ // create leaf, leaf will auto trigger tree collect callback
22
+ new Leaf({
23
+ key: toggleableKey.key,
24
+ parent: null,
25
+ belongTo: this
26
+ }).grow(toggleableKey.children);
27
+ return this;
11
28
  }
12
- grow(toggleableKey) {
13
- // create leaf, leaf will auto trigger tree collect callback
14
- new Leaf({
15
- key: toggleableKey.key,
16
- parent: null,
17
- belongTo: this
18
- }).grow(toggleableKey.children);
19
- return this;
29
+ }, {
30
+ key: "collect",
31
+ value: function collect(leaf) {
32
+ _classPrivateFieldGet2(_groupedLeaves, this).has(leaf.key) ? _classPrivateFieldGet2(_groupedLeaves, this).get(leaf.key).add(leaf) : _classPrivateFieldGet2(_groupedLeaves, this).set(leaf.key, new Set([leaf]));
20
33
  }
21
- collect(leaf) {
22
- this.#groupedLeaves.has(leaf.key)
23
- ? this.#groupedLeaves.get(leaf.key).add(leaf)
24
- : this.#groupedLeaves.set(leaf.key, new Set([leaf]));
34
+ }, {
35
+ key: "toggle",
36
+ value: function toggle(key, toggledKeys) {
37
+ var hasToggled = toggledKeys.has(key);
38
+ var _isToggled = !hasToggled;
39
+ return this.toggleBy(key, _isToggled, toggledKeys);
25
40
  }
26
- toggle(key, toggledKeys) {
27
- const hasToggled = toggledKeys.has(key);
28
- const _isToggled = !hasToggled;
29
- return this.toggleBy(key, _isToggled, toggledKeys);
30
- }
31
- toggleBy(key, isToggled, toggledKeys) {
32
- return Array.from(this.#groupedLeaves.get(key) ?? []).reduce((prev, leaf) => {
33
- // deep fall, add or remove child key
34
- const fell = leaf.fall(isToggled, prev);
35
- // deep rise, add or remove parent key
36
- const rised = leaf.rise(fell);
37
- return rised;
38
- }, new Set(toggledKeys));
41
+ }, {
42
+ key: "toggleBy",
43
+ value: function toggleBy(key, isToggled, toggledKeys) {
44
+ var _classPrivateFieldGet2$1;
45
+ return Array.from((_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_groupedLeaves, this).get(key)) !== null && _classPrivateFieldGet2$1 !== void 0 ? _classPrivateFieldGet2$1 : []).reduce(function (prev, leaf) {
46
+ // deep fall, add or remove child key
47
+ var fell = leaf.fall(isToggled, prev);
48
+ // deep rise, add or remove parent key
49
+ var rised = leaf.rise(fell);
50
+ return rised;
51
+ }, new Set(toggledKeys));
39
52
  }
40
- }
41
- class Leaf {
42
- #key;
43
- #belongTo;
44
- #parent;
45
- #children;
46
- constructor(props) {
47
- this.#key = props.key;
48
- this.#parent = props.parent;
49
- this.#belongTo = props.belongTo;
50
- this.#children = [];
51
- // when leaf has grew, let tree collect leaf
52
- this.#belongTo.collect(this);
53
+ }]);
54
+ }();
55
+ var _key = /*#__PURE__*/new WeakMap();
56
+ var _belongTo = /*#__PURE__*/new WeakMap();
57
+ var _parent = /*#__PURE__*/new WeakMap();
58
+ var _children = /*#__PURE__*/new WeakMap();
59
+ var Leaf = /*#__PURE__*/function () {
60
+ function Leaf(props) {
61
+ _classCallCheck(this, Leaf);
62
+ _classPrivateFieldInitSpec(this, _key, void 0);
63
+ _classPrivateFieldInitSpec(this, _belongTo, void 0);
64
+ _classPrivateFieldInitSpec(this, _parent, void 0);
65
+ _classPrivateFieldInitSpec(this, _children, void 0);
66
+ _classPrivateFieldSet2(_key, this, props.key);
67
+ _classPrivateFieldSet2(_parent, this, props.parent);
68
+ _classPrivateFieldSet2(_belongTo, this, props.belongTo);
69
+ _classPrivateFieldSet2(_children, this, []);
70
+ // when leaf has grew, let tree collect leaf
71
+ _classPrivateFieldGet2(_belongTo, this).collect(this);
72
+ }
73
+ return _createClass(Leaf, [{
74
+ key: "key",
75
+ get: function get() {
76
+ return _classPrivateFieldGet2(_key, this);
53
77
  }
54
- get key() {
55
- return this.#key;
78
+ }, {
79
+ key: "grow",
80
+ value: function grow() {
81
+ var _this = this;
82
+ var toggleableKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
83
+ if (toggleableKeys.length > 0) {
84
+ toggleableKeys.forEach(function (_toggleableKey) {
85
+ var child = new Leaf({
86
+ key: _toggleableKey.key,
87
+ parent: _this,
88
+ belongTo: _classPrivateFieldGet2(_belongTo, _this)
89
+ }).grow(_toggleableKey.children);
90
+ _classPrivateFieldGet2(_children, _this).push(child);
91
+ });
92
+ }
93
+ return this;
56
94
  }
57
- grow(toggleableKeys = []) {
58
- if (toggleableKeys.length > 0) {
59
- toggleableKeys.forEach((_toggleableKey) => {
60
- const child = new Leaf({
61
- key: _toggleableKey.key,
62
- parent: this,
63
- belongTo: this.#belongTo
64
- }).grow(_toggleableKey.children);
65
- this.#children.push(child);
66
- });
67
- }
68
- return this;
95
+ }, {
96
+ key: "rise",
97
+ value: function rise(toggledKeys) {
98
+ // if current key is toggled or children is all toggled
99
+ // just add current key into toggled keys
100
+ // else remove current key
101
+ var isToggled = toggledKeys.has(_classPrivateFieldGet2(_key, this)) || _classPrivateFieldGet2(_children, this).every(function (child) {
102
+ return toggledKeys.has(child.key);
103
+ });
104
+ var rised = new Set(toggledKeys);
105
+ if (isToggled) {
106
+ rised.add(_classPrivateFieldGet2(_key, this));
107
+ } else {
108
+ rised["delete"](_classPrivateFieldGet2(_key, this));
109
+ }
110
+ if (_classPrivateFieldGet2(_parent, this)) {
111
+ return _classPrivateFieldGet2(_parent, this).rise(rised);
112
+ }
113
+ return rised;
69
114
  }
70
- rise(toggledKeys) {
71
- // if current key is toggled or children is all toggled
72
- // just add current key into toggled keys
73
- // else remove current key
74
- const isToggled = toggledKeys.has(this.#key) || this.#children.every((child) => toggledKeys.has(child.key));
75
- const rised = new Set(toggledKeys);
115
+ }, {
116
+ key: "fall",
117
+ value: function fall(isToggled, toggledKeys) {
118
+ var _this2 = this;
119
+ return _classPrivateFieldGet2(_children, this).reduce(function (prev, leaf) {
120
+ // deep loop, remove or add key
121
+ var fell = leaf.fall(isToggled, prev);
122
+ // toggle true, add key
123
+ // toggle false, remove key
76
124
  if (isToggled) {
77
- rised.add(this.#key);
78
- }
79
- else {
80
- rised.delete(this.#key);
125
+ fell.add(_classPrivateFieldGet2(_key, _this2));
126
+ } else {
127
+ fell["delete"](_classPrivateFieldGet2(_key, _this2));
81
128
  }
82
- if (this.#parent) {
83
- return this.#parent.rise(rised);
84
- }
85
- return rised;
129
+ return fell;
130
+ }, new Set(toggledKeys));
86
131
  }
87
- fall(isToggled, toggledKeys) {
88
- return this.#children.reduce((prev, leaf) => {
89
- // deep loop, remove or add key
90
- const fell = leaf.fall(isToggled, prev);
91
- // toggle true, add key
92
- // toggle false, remove key
93
- if (isToggled) {
94
- fell.add(this.#key);
95
- }
96
- else {
97
- fell.delete(this.#key);
98
- }
99
- return fell;
100
- }, new Set(toggledKeys));
101
- }
102
- }
132
+ }]);
133
+ }();
103
134
  /**
104
135
  * @description
105
136
  * toggle able
106
137
  */
107
- const useToggleable = (toggleableKeys, { onToggle, ...options } = {}) => {
108
- /// re-create tree when toggleable keys changed
109
- const tree = useMemo(() => {
110
- return toggleableKeys.reduce((_tree, toggleable) => {
111
- return _tree.grow(toggleable);
112
- }, new Tree());
113
- }, [toggleableKeys]);
114
- /// use controlled state to record toggled keys
115
- const [_toggledKeys, _setToggledKeys] = useControlledState(options.toggledKeys, {
116
- defaultState: () => {
117
- return options.isDefaultToggled
118
- ? Array.from(Array.from(tree.groupedLeaves.values()).reduce((prev, leaves) => {
119
- leaves.forEach((leaf) => prev.add(leaf.key));
120
- return prev;
121
- }, new Set()))
122
- : [];
123
- }
124
- });
125
- /// use set for toggled keys to make it read-only
126
- const readableToggledKeys = useMemo(() => new Set(_toggledKeys), [_toggledKeys]);
127
- /// check current key is toggled
128
- const isToggled = useCallback((key) => !readableToggledKeys || readableToggledKeys.has(key), [readableToggledKeys]);
129
- /// toggle one key
130
- const toggle = useCallback((key) => {
131
- // get new toggled keys by toggle current key
132
- const _toggledKeys = Array.from(tree.toggle(key, readableToggledKeys));
133
- // set state
134
- _setToggledKeys(_toggledKeys);
135
- // trigger on toggle callback
136
- onToggle?.(_toggledKeys);
137
- }, [tree, readableToggledKeys, _setToggledKeys, onToggle]);
138
- return {
139
- toggledKeys: readableToggledKeys,
140
- isToggled,
141
- toggle
142
- };
138
+ var useToggleable = function useToggleable(toggleableKeys) {
139
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
140
+ onToggle = _ref.onToggle,
141
+ options = _objectWithoutProperties(_ref, _excluded);
142
+ /// re-create tree when toggleable keys changed
143
+ var tree = useMemo(function () {
144
+ return toggleableKeys.reduce(function (_tree, toggleable) {
145
+ return _tree.grow(toggleable);
146
+ }, new Tree());
147
+ }, [toggleableKeys]);
148
+ /// use controlled state to record toggled keys
149
+ var _useControlledState = useControlledState(options.toggledKeys, {
150
+ defaultState: function defaultState() {
151
+ return options.isDefaultToggled ? Array.from(Array.from(tree.groupedLeaves.values()).reduce(function (prev, leaves) {
152
+ leaves.forEach(function (leaf) {
153
+ return prev.add(leaf.key);
154
+ });
155
+ return prev;
156
+ }, new Set())) : [];
157
+ }
158
+ }),
159
+ _useControlledState2 = _slicedToArray(_useControlledState, 2),
160
+ _toggledKeys = _useControlledState2[0],
161
+ _setToggledKeys = _useControlledState2[1];
162
+ /// use set for toggled keys to make it read-only
163
+ var readableToggledKeys = useMemo(function () {
164
+ return new Set(_toggledKeys);
165
+ }, [_toggledKeys]);
166
+ /// check current key is toggled
167
+ var isToggled = useCallback(function (key) {
168
+ return !readableToggledKeys || readableToggledKeys.has(key);
169
+ }, [readableToggledKeys]);
170
+ /// toggle one key
171
+ var toggle = useCallback(function (key) {
172
+ // get new toggled keys by toggle current key
173
+ var _toggledKeys = Array.from(tree.toggle(key, readableToggledKeys));
174
+ // set state
175
+ _setToggledKeys(_toggledKeys);
176
+ // trigger on toggle callback
177
+ onToggle === null || onToggle === void 0 || onToggle(_toggledKeys);
178
+ }, [tree, readableToggledKeys, _setToggledKeys, onToggle]);
179
+ return {
180
+ toggledKeys: readableToggledKeys,
181
+ isToggled: isToggled,
182
+ toggle: toggle
183
+ };
143
184
  };
144
185
 
145
186
  export { useToggleable };
@@ -1,20 +1,19 @@
1
1
  import { useRef, useEffect } from 'react';
2
2
  import { useMounted } from './use-mounted.js';
3
- import { effect } from '../utils/effect.js';
3
+ import { effect } from '../utils/effect/index.js';
4
4
 
5
- const useUpdateEffect = (callback, deps) => {
6
- const isMounted = useRef(false);
7
- useEffect(() => {
8
- if (!isMounted.current)
9
- return;
10
- return effect(callback);
11
- }, deps);
12
- useMounted(() => {
13
- isMounted.current = true;
14
- return () => {
15
- isMounted.current = false;
16
- };
17
- });
5
+ var useUpdateEffect = function useUpdateEffect(callback, deps) {
6
+ var isMounted = useRef(false);
7
+ useEffect(function () {
8
+ if (!isMounted.current) return;
9
+ return effect(callback);
10
+ }, deps);
11
+ useMounted(function () {
12
+ isMounted.current = true;
13
+ return function () {
14
+ isMounted.current = false;
15
+ };
16
+ });
18
17
  };
19
18
 
20
19
  export { useUpdateEffect };
package/dist/index.d.ts CHANGED
@@ -52,3 +52,4 @@ export { chain } from './utils/chain';
52
52
  export { debounce } from './utils/debounce';
53
53
  export { toArray } from './utils/to-array';
54
54
  export { toFunction } from './utils/to-function';
55
+ export { exclude } from './utils/exclude';
package/dist/index.js CHANGED
@@ -31,12 +31,13 @@ export { isMobile } from './is/is-mobile.js';
31
31
  export { isOverflow } from './is/is-overflow.js';
32
32
  export { isStyleElement } from './is/is-style-element.js';
33
33
  export { isFunction } from './is/is-function.js';
34
- export { isThenable } from './is/is-thenable.js';
35
- export { effect } from './utils/effect.js';
34
+ export { isThenable } from './is/is-thenable/index.js';
35
+ export { effect } from './utils/effect/index.js';
36
36
  export { unique, uniqueBy } from './utils/unique.js';
37
37
  export { range } from './utils/range.js';
38
- export { clamp } from './utils/clamp.js';
39
- export { chain } from './utils/chain.js';
40
- export { debounce } from './utils/debounce.js';
41
- export { toArray } from './utils/to-array.js';
38
+ export { clamp } from './utils/clamp/index.js';
39
+ export { chain } from './utils/chain/index.js';
40
+ export { debounce } from './utils/debounce/index.js';
41
+ export { toArray } from './utils/to-array/index.js';
42
42
  export { toFunction } from './utils/to-function.js';
43
+ export { exclude } from './utils/exclude/index.js';
@@ -2,8 +2,8 @@
2
2
  * @description
3
3
  * is array
4
4
  */
5
- const isArray = (value) => {
6
- return Array.isArray(value);
5
+ var isArray = function isArray(value) {
6
+ return Array.isArray(value);
7
7
  };
8
8
 
9
9
  export { isArray };
@@ -1,9 +1,11 @@
1
+ import { typeof as _typeof } from '../_virtual/_rollupPluginBabelHelpers.js';
2
+
1
3
  /**
2
4
  * @description
3
5
  * complex
4
6
  */
5
- const isComplex = (value) => {
6
- return typeof value === 'object' || typeof value === 'function';
7
+ var isComplex = function isComplex(value) {
8
+ return _typeof(value) === 'object' || typeof value === 'function';
7
9
  };
8
10
 
9
11
  export { isComplex };
@@ -2,8 +2,8 @@
2
2
  * @description
3
3
  * if there is dom
4
4
  */
5
- const isDomUsable = () => {
6
- return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
5
+ var isDomUsable = function isDomUsable() {
6
+ return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
7
7
  };
8
8
 
9
9
  export { isDomUsable };
@@ -1,3 +1,4 @@
1
+ import { typeof as _typeof } from '../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import { isVoid } from './is-void.js';
2
3
  import { isArray } from './is-array.js';
3
4
 
@@ -7,19 +8,18 @@ import { isArray } from './is-array.js';
7
8
  * @description
8
9
  * is empty
9
10
  */
10
- const isEmpty = (value) => {
11
- // null or undefined
12
- if (isVoid(value))
13
- return true;
14
- // object
15
- if (typeof value === 'object') {
16
- return Object.keys(value).length === 0;
17
- }
18
- // array
19
- if (isArray(value)) {
20
- return value.length === 0;
21
- }
22
- return !!value;
11
+ var isEmpty = function isEmpty(value) {
12
+ // null or undefined
13
+ if (isVoid(value)) return true;
14
+ // object
15
+ if (_typeof(value) === 'object') {
16
+ return Object.keys(value).length === 0;
17
+ }
18
+ // array
19
+ if (isArray(value)) {
20
+ return value.length === 0;
21
+ }
22
+ return !!value;
23
23
  };
24
24
 
25
25
  export { isEmpty };
@@ -2,8 +2,8 @@
2
2
  * @description
3
3
  * if is function
4
4
  */
5
- const isFunction = (value) => {
6
- return typeof value === 'function';
5
+ var isFunction = function isFunction(value) {
6
+ return typeof value === 'function';
7
7
  };
8
8
 
9
9
  export { isFunction };
@@ -2,15 +2,12 @@
2
2
  * @description
3
3
  * is mobile
4
4
  */
5
- const isMobile = () => {
6
- if (typeof navigator === 'undefined' || typeof window === 'undefined') {
7
- return false;
8
- }
9
- const agent = navigator.userAgent ||
10
- navigator.vendor ||
11
- window.opera;
12
- return (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) ||
13
- /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent?.substring(0, 4)));
5
+ var isMobile = function isMobile() {
6
+ if (typeof navigator === 'undefined' || typeof window === 'undefined') {
7
+ return false;
8
+ }
9
+ var agent = navigator.userAgent || navigator.vendor || window.opera;
10
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substring(0, 4));
14
11
  };
15
12
 
16
13
  export { isMobile };
@@ -2,8 +2,8 @@
2
2
  * @description
3
3
  * is null
4
4
  */
5
- const isNull = (value) => {
6
- return value === null;
5
+ var isNull = function isNull(value) {
6
+ return value === null;
7
7
  };
8
8
 
9
9
  export { isNull };