@aiszlab/relax 1.2.11-beta.1 → 1.2.11-beta.2
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/index.cjs +7 -0
- package/dist/dom/index.mjs +1 -0
- package/dist/dom/scroll-to.cjs +62 -0
- package/dist/dom/{scroll-to.js → scroll-to.mjs} +1 -1
- package/dist/hooks/use-boolean.cjs +25 -0
- package/dist/hooks/use-controlled-state.cjs +46 -0
- package/dist/hooks/{use-controlled-state.js → use-controlled-state.mjs} +2 -2
- package/dist/hooks/use-debounce-callback.cjs +68 -0
- package/dist/hooks/use-force-update.cjs +20 -0
- package/dist/hooks/use-image-loader.cjs +42 -0
- package/dist/hooks/use-mount.cjs +26 -0
- package/dist/hooks/use-mounted.cjs +26 -0
- package/dist/hooks/use-once-state.cjs +15 -0
- package/dist/hooks/use-refs.cjs +23 -0
- package/dist/hooks/{use-refs.js → use-refs.mjs} +1 -1
- package/dist/hooks/use-scroll-locker.cjs +86 -0
- package/dist/hooks/{use-scroll-locker.js → use-scroll-locker.mjs} +3 -3
- package/dist/hooks/use-scrollable.cjs +43 -0
- package/dist/hooks/{use-scrollable.js → use-scrollable.mjs} +1 -1
- package/dist/hooks/use-timeout.cjs +23 -0
- package/dist/hooks/use-toggleable.cjs +58 -0
- package/dist/index.cjs +57 -0
- package/dist/index.mjs +26 -0
- package/dist/is/is-array.cjs +11 -0
- package/dist/is/is-complex.cjs +11 -0
- package/dist/is/is-dom-usable.cjs +11 -0
- package/dist/is/is-empty.cjs +27 -0
- package/dist/is/{is-empty.js → is-empty.mjs} +2 -2
- package/dist/is/is-function.cjs +11 -0
- package/dist/is/is-mobile.cjs +18 -0
- package/dist/is/is-null.cjs +11 -0
- package/dist/is/is-overflow.cjs +12 -0
- package/dist/is/is-refable.cjs +36 -0
- package/dist/is/is-state-getter.cjs +11 -0
- package/dist/is/is-style-element.cjs +11 -0
- package/dist/is/is-undefined.cjs +11 -0
- package/dist/is/is-void.cjs +14 -0
- package/dist/is/{is-void.js → is-void.mjs} +2 -2
- package/dist/node_modules/tslib/tslib.es6.cjs +20 -0
- package/package.json +10 -12
- package/dist/dom/index.js +0 -1
- package/dist/index.js +0 -26
- /package/dist/hooks/{use-boolean.js → use-boolean.mjs} +0 -0
- /package/dist/hooks/{use-debounce-callback.js → use-debounce-callback.mjs} +0 -0
- /package/dist/hooks/{use-force-update.js → use-force-update.mjs} +0 -0
- /package/dist/hooks/{use-image-loader.js → use-image-loader.mjs} +0 -0
- /package/dist/hooks/{use-mount.js → use-mount.mjs} +0 -0
- /package/dist/hooks/{use-mounted.js → use-mounted.mjs} +0 -0
- /package/dist/hooks/{use-once-state.js → use-once-state.mjs} +0 -0
- /package/dist/hooks/{use-timeout.js → use-timeout.mjs} +0 -0
- /package/dist/hooks/{use-toggleable.js → use-toggleable.mjs} +0 -0
- /package/dist/is/{is-array.js → is-array.mjs} +0 -0
- /package/dist/is/{is-complex.js → is-complex.mjs} +0 -0
- /package/dist/is/{is-dom-usable.js → is-dom-usable.mjs} +0 -0
- /package/dist/is/{is-function.js → is-function.mjs} +0 -0
- /package/dist/is/{is-mobile.js → is-mobile.mjs} +0 -0
- /package/dist/is/{is-null.js → is-null.mjs} +0 -0
- /package/dist/is/{is-overflow.js → is-overflow.mjs} +0 -0
- /package/dist/is/{is-refable.js → is-refable.mjs} +0 -0
- /package/dist/is/{is-state-getter.js → is-state-getter.mjs} +0 -0
- /package/dist/is/{is-style-element.js → is-style-element.mjs} +0 -0
- /package/dist/is/{is-undefined.js → is-undefined.mjs} +0 -0
- /package/dist/node_modules/tslib/{tslib.es6.js → tslib.es6.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { scrollTo } from './scroll-to.mjs';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../node_modules/tslib/tslib.es6.cjs');
|
|
4
|
+
|
|
5
|
+
var _Scroller_scrolled, _Scroller_scroller;
|
|
6
|
+
class Scroller {
|
|
7
|
+
constructor() {
|
|
8
|
+
var _a;
|
|
9
|
+
_Scroller_scrolled.set(this, new Map()
|
|
10
|
+
// singleton mode
|
|
11
|
+
);
|
|
12
|
+
// singleton mode
|
|
13
|
+
_Scroller_scroller.set(this, null);
|
|
14
|
+
return (tslib_es6.__classPrivateFieldSet(this, _Scroller_scroller, (_a = tslib_es6.__classPrivateFieldGet(this, _Scroller_scroller, "f")) !== null && _a !== void 0 ? _a : this, "f"));
|
|
15
|
+
}
|
|
16
|
+
get scrolled() {
|
|
17
|
+
return tslib_es6.__classPrivateFieldGet(this, _Scroller_scrolled, "f");
|
|
18
|
+
}
|
|
19
|
+
currentAt(direction) {
|
|
20
|
+
return direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
_Scroller_scrolled = new WeakMap(), _Scroller_scroller = new WeakMap();
|
|
24
|
+
/**
|
|
25
|
+
* @description
|
|
26
|
+
* scroll to for wrapper element
|
|
27
|
+
*/
|
|
28
|
+
const scrollTo = (target, to, { duration = 0, direction = 'vertical' } = {
|
|
29
|
+
duration: 0,
|
|
30
|
+
direction: 'vertical'
|
|
31
|
+
}) => {
|
|
32
|
+
const scroller = new Scroller();
|
|
33
|
+
const scrolled = scroller.scrolled.get(target);
|
|
34
|
+
const currentAtProperty = scroller.currentAt(direction);
|
|
35
|
+
if (scrolled) {
|
|
36
|
+
cancelAnimationFrame(scrolled);
|
|
37
|
+
scroller.scrolled.delete(target);
|
|
38
|
+
}
|
|
39
|
+
// if duration <= 0, jump immediately
|
|
40
|
+
if (duration <= 0) {
|
|
41
|
+
scroller.scrolled.set(target, requestAnimationFrame(() => {
|
|
42
|
+
target[currentAtProperty] = to;
|
|
43
|
+
}));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// animate
|
|
47
|
+
const currentAt = target[currentAtProperty];
|
|
48
|
+
const difference = to - currentAt;
|
|
49
|
+
const step = (difference / duration) * 10;
|
|
50
|
+
scroller.scrolled.set(target, requestAnimationFrame(() => {
|
|
51
|
+
target[currentAtProperty] = currentAt + step;
|
|
52
|
+
// over end, stop any animation
|
|
53
|
+
if (target[currentAtProperty] === to)
|
|
54
|
+
return;
|
|
55
|
+
scrollTo(target, to, {
|
|
56
|
+
duration: duration - 10,
|
|
57
|
+
direction
|
|
58
|
+
});
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.scrollTo = scrollTo;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* boolean state
|
|
10
|
+
*/
|
|
11
|
+
const useBoolean = (initialValue) => {
|
|
12
|
+
const [isOn, setIsOn] = react.useState(initialValue || false);
|
|
13
|
+
const turnOn = react.useCallback(() => setIsOn(true), []);
|
|
14
|
+
const turnOff = react.useCallback(() => setIsOn(false), []);
|
|
15
|
+
const toggle = react.useCallback(() => setIsOn((_isOn) => !_isOn), []);
|
|
16
|
+
return {
|
|
17
|
+
isOn,
|
|
18
|
+
turnOn,
|
|
19
|
+
turnOff,
|
|
20
|
+
toggle,
|
|
21
|
+
setIsOn
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.useBoolean = useBoolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var isStateGetter = require('../is/is-state-getter.cjs');
|
|
5
|
+
var isUndefined = require('../is/is-undefined.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @author murukal
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* controlled state
|
|
12
|
+
*/
|
|
13
|
+
const useControlledState = (controlledState, { defaultState } = {}) => {
|
|
14
|
+
/// initialize state
|
|
15
|
+
const [state, setState] = react.useState(() => {
|
|
16
|
+
// state function, run it for value
|
|
17
|
+
if (isStateGetter.isStateGetter(controlledState))
|
|
18
|
+
return controlledState();
|
|
19
|
+
// not controlled use default prop
|
|
20
|
+
if (isUndefined.isUndefined(controlledState)) {
|
|
21
|
+
if (isUndefined.isUndefined(defaultState))
|
|
22
|
+
return controlledState;
|
|
23
|
+
if (isStateGetter.isStateGetter(defaultState))
|
|
24
|
+
return defaultState();
|
|
25
|
+
return defaultState;
|
|
26
|
+
}
|
|
27
|
+
// default use controlled state
|
|
28
|
+
return controlledState;
|
|
29
|
+
});
|
|
30
|
+
react.useEffect(() => {
|
|
31
|
+
// when state is not controlled
|
|
32
|
+
if (isUndefined.isUndefined(controlledState))
|
|
33
|
+
return;
|
|
34
|
+
// if input state is function, mean it is not controlled
|
|
35
|
+
if (isStateGetter.isStateGetter(controlledState))
|
|
36
|
+
return;
|
|
37
|
+
// if state is equal with value
|
|
38
|
+
if (controlledState === state)
|
|
39
|
+
return;
|
|
40
|
+
// update inner state
|
|
41
|
+
setState(controlledState);
|
|
42
|
+
}, [controlledState]);
|
|
43
|
+
return [state, setState];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.useControlledState = useControlledState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
-
import { isStateGetter } from '../is/is-state-getter.
|
|
3
|
-
import { isUndefined } from '../is/is-undefined.
|
|
2
|
+
import { isStateGetter } from '../is/is-state-getter.mjs';
|
|
3
|
+
import { isUndefined } from '../is/is-undefined.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @author murukal
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var rxjs = require('rxjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @author murukal
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* debounce callback
|
|
11
|
+
*/
|
|
12
|
+
const useDebounceCallback = (callable, options) => {
|
|
13
|
+
var _a;
|
|
14
|
+
// delay
|
|
15
|
+
const delay = (_a = options.delay) !== null && _a !== void 0 ? _a : 1000;
|
|
16
|
+
// runner
|
|
17
|
+
const runner = react.useRef();
|
|
18
|
+
// listener
|
|
19
|
+
const listener = react.useRef();
|
|
20
|
+
/// initialze listener function for debouce
|
|
21
|
+
const initialize = react.useCallback(() => {
|
|
22
|
+
listener.current = new rxjs.Observable((subscriber) => {
|
|
23
|
+
runner.current = subscriber;
|
|
24
|
+
})
|
|
25
|
+
.pipe(rxjs.debounceTime(options.delay))
|
|
26
|
+
.subscribe({
|
|
27
|
+
next: (value) => {
|
|
28
|
+
callable(value);
|
|
29
|
+
},
|
|
30
|
+
complete: () => {
|
|
31
|
+
initialize();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}, [callable, delay]);
|
|
35
|
+
/// initialize debounce function
|
|
36
|
+
/// when delay / callable changed, need reinitialize
|
|
37
|
+
react.useEffect(() => {
|
|
38
|
+
initialize();
|
|
39
|
+
// dispose
|
|
40
|
+
return () => {
|
|
41
|
+
var _a;
|
|
42
|
+
(_a = listener.current) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
43
|
+
};
|
|
44
|
+
}, [initialize]);
|
|
45
|
+
/// next function has been debounced for hooks user
|
|
46
|
+
const next = react.useCallback((value) => {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = runner.current) === null || _a === void 0 ? void 0 : _a.next(value);
|
|
49
|
+
}, []);
|
|
50
|
+
/// flush the debounce
|
|
51
|
+
const complete = react.useCallback(() => {
|
|
52
|
+
var _a;
|
|
53
|
+
(_a = runner.current) === null || _a === void 0 ? void 0 : _a.complete();
|
|
54
|
+
}, []);
|
|
55
|
+
/// cancel only valid in debounce time
|
|
56
|
+
/// if the callback has been called, it can not be canceled
|
|
57
|
+
const cancel = react.useCallback(() => {
|
|
58
|
+
var _a;
|
|
59
|
+
(_a = listener.current) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
60
|
+
}, []);
|
|
61
|
+
return {
|
|
62
|
+
next,
|
|
63
|
+
complete,
|
|
64
|
+
cancel
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
exports.useDebounceCallback = useDebounceCallback;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* force update
|
|
8
|
+
*/
|
|
9
|
+
const useForceUpdate = () => {
|
|
10
|
+
const [times, setTimes] = react.useState(1);
|
|
11
|
+
const forceUpdate = react.useCallback(() => {
|
|
12
|
+
setTimes((prev) => prev + 1);
|
|
13
|
+
}, []);
|
|
14
|
+
return {
|
|
15
|
+
times,
|
|
16
|
+
forceUpdate
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.useForceUpdate = useForceUpdate;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var rxjs = require('rxjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @author murukal
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* image loader
|
|
11
|
+
*/
|
|
12
|
+
const useImageLoader = ({ src }) => {
|
|
13
|
+
const loader = react.useRef();
|
|
14
|
+
const [status, setStatus] = react.useState('none');
|
|
15
|
+
react.useEffect(() => {
|
|
16
|
+
if (!src) {
|
|
17
|
+
return setStatus('none');
|
|
18
|
+
}
|
|
19
|
+
// create observable to listen img status
|
|
20
|
+
new rxjs.Observable((subscriber) => {
|
|
21
|
+
loader.current = subscriber;
|
|
22
|
+
subscriber.next();
|
|
23
|
+
}).subscribe({
|
|
24
|
+
next: () => setStatus('loading'),
|
|
25
|
+
complete: () => setStatus('loaded'),
|
|
26
|
+
error: () => setStatus('error')
|
|
27
|
+
});
|
|
28
|
+
const image = new Image();
|
|
29
|
+
image.addEventListener('load', () => {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = loader.current) === null || _a === void 0 ? void 0 : _a.complete();
|
|
32
|
+
});
|
|
33
|
+
image.addEventListener('error', () => {
|
|
34
|
+
var _a;
|
|
35
|
+
(_a = loader.current) === null || _a === void 0 ? void 0 : _a.error(null);
|
|
36
|
+
});
|
|
37
|
+
image.src = src;
|
|
38
|
+
}, [src]);
|
|
39
|
+
return status;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.useImageLoader = useImageLoader;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* when components will mount
|
|
10
|
+
*/
|
|
11
|
+
const useMount = (callable) => {
|
|
12
|
+
react.useLayoutEffect(() => {
|
|
13
|
+
const called = callable();
|
|
14
|
+
// if result is void
|
|
15
|
+
if (!called) {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
// if result is promise like, return void
|
|
19
|
+
if (called.then) {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
return called;
|
|
23
|
+
}, []);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.useMount = useMount;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* when components mounted
|
|
10
|
+
*/
|
|
11
|
+
const useMounted = (callable) => {
|
|
12
|
+
react.useEffect(() => {
|
|
13
|
+
const called = callable();
|
|
14
|
+
// if result is void
|
|
15
|
+
if (!called) {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
// if result is promise like, return void
|
|
19
|
+
if (called.then) {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
return called;
|
|
23
|
+
}, []);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.useMounted = useMounted;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* state always be same after first render
|
|
10
|
+
*/
|
|
11
|
+
const useOnceState = (initialState) => {
|
|
12
|
+
return react.useState(initialState)[0];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.useOnceState = useOnceState;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var isFunction = require('../is/is-function.cjs');
|
|
5
|
+
|
|
6
|
+
const mount = (ref, trigger) => {
|
|
7
|
+
if (isFunction.isFunction(ref)) {
|
|
8
|
+
ref(trigger);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
ref.current = trigger;
|
|
12
|
+
};
|
|
13
|
+
const useRefs = (...refs) => {
|
|
14
|
+
return react.useMemo(() => {
|
|
15
|
+
return (trigger) => {
|
|
16
|
+
refs.forEach((ref) => {
|
|
17
|
+
mount(ref, trigger);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}, refs);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.useRefs = useRefs;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../node_modules/tslib/tslib.es6.cjs');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var isOverflow = require('../is/is-overflow.cjs');
|
|
6
|
+
var isStyleElement = require('../is/is-style-element.cjs');
|
|
7
|
+
|
|
8
|
+
var _ScrollLocker_scrollLocker, _ScrollLocker_barSize;
|
|
9
|
+
const isComputable = (value) => /^(.*)px$/.test(value);
|
|
10
|
+
class ScrollLocker {
|
|
11
|
+
constructor() {
|
|
12
|
+
var _a;
|
|
13
|
+
// singleton mode
|
|
14
|
+
_ScrollLocker_scrollLocker.set(this, null
|
|
15
|
+
// bar size
|
|
16
|
+
);
|
|
17
|
+
// bar size
|
|
18
|
+
_ScrollLocker_barSize.set(this, null);
|
|
19
|
+
return (tslib_es6.__classPrivateFieldSet(this, _ScrollLocker_scrollLocker, (_a = tslib_es6.__classPrivateFieldGet(this, _ScrollLocker_scrollLocker, "f")) !== null && _a !== void 0 ? _a : this, "f"));
|
|
20
|
+
}
|
|
21
|
+
get barSize() {
|
|
22
|
+
var _a;
|
|
23
|
+
if (tslib_es6.__classPrivateFieldGet(this, _ScrollLocker_barSize, "f"))
|
|
24
|
+
return tslib_es6.__classPrivateFieldGet(this, _ScrollLocker_barSize, "f");
|
|
25
|
+
const { width, height } = getComputedStyle(document.body, '::-webkit-scrollbar');
|
|
26
|
+
return (tslib_es6.__classPrivateFieldSet(this, _ScrollLocker_barSize, (_a = tslib_es6.__classPrivateFieldGet(this, _ScrollLocker_barSize, "f")) !== null && _a !== void 0 ? _a : {
|
|
27
|
+
width: isComputable(width) ? width : '0',
|
|
28
|
+
height: isComputable(height) ? height : '0'
|
|
29
|
+
}, "f"));
|
|
30
|
+
}
|
|
31
|
+
get isOverflow() {
|
|
32
|
+
return isOverflow.isOverflow();
|
|
33
|
+
}
|
|
34
|
+
get locker() {
|
|
35
|
+
return `html body {
|
|
36
|
+
overflow-y: hidden;
|
|
37
|
+
${this.isOverflow ? `width: calc(100% - ${this.barSize.width});` : ''}
|
|
38
|
+
}`;
|
|
39
|
+
}
|
|
40
|
+
get container() {
|
|
41
|
+
return document.head || document.body;
|
|
42
|
+
}
|
|
43
|
+
getLocked(id) {
|
|
44
|
+
return Array.from(this.container.children).filter((element) => isStyleElement.isStyleElement(element)).find((element) => element.id === id);
|
|
45
|
+
}
|
|
46
|
+
lock(id) {
|
|
47
|
+
if (!this.container)
|
|
48
|
+
return;
|
|
49
|
+
const locked = this.getLocked(id);
|
|
50
|
+
if (locked) {
|
|
51
|
+
if (locked.innerHTML !== this.locker) {
|
|
52
|
+
locked.innerHTML = this.locker;
|
|
53
|
+
}
|
|
54
|
+
return locked;
|
|
55
|
+
}
|
|
56
|
+
const locker = document.createElement('style');
|
|
57
|
+
locker.id = id;
|
|
58
|
+
locker.innerHTML = this.locker;
|
|
59
|
+
this.container.appendChild(locker);
|
|
60
|
+
return locker;
|
|
61
|
+
}
|
|
62
|
+
unlock(id) {
|
|
63
|
+
const locked = this.getLocked(id);
|
|
64
|
+
if (!locked)
|
|
65
|
+
return;
|
|
66
|
+
this.container.removeChild(locked);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_ScrollLocker_scrollLocker = new WeakMap(), _ScrollLocker_barSize = new WeakMap();
|
|
70
|
+
const useScrollLocker = (isLock) => {
|
|
71
|
+
const id = react.useId();
|
|
72
|
+
react.useLayoutEffect(() => {
|
|
73
|
+
const scrollLocker = new ScrollLocker();
|
|
74
|
+
if (!!isLock) {
|
|
75
|
+
scrollLocker.lock(id);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
scrollLocker.unlock(id);
|
|
79
|
+
}
|
|
80
|
+
return () => {
|
|
81
|
+
scrollLocker.unlock(id);
|
|
82
|
+
};
|
|
83
|
+
}, [!!isLock, id]);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
exports.useScrollLocker = useScrollLocker;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __classPrivateFieldSet, __classPrivateFieldGet } from '../node_modules/tslib/tslib.es6.
|
|
1
|
+
import { __classPrivateFieldSet, __classPrivateFieldGet } from '../node_modules/tslib/tslib.es6.mjs';
|
|
2
2
|
import { useId, useLayoutEffect } from 'react';
|
|
3
|
-
import { isOverflow } from '../is/is-overflow.
|
|
4
|
-
import { isStyleElement } from '../is/is-style-element.
|
|
3
|
+
import { isOverflow } from '../is/is-overflow.mjs';
|
|
4
|
+
import { isStyleElement } from '../is/is-style-element.mjs';
|
|
5
5
|
|
|
6
6
|
var _ScrollLocker_scrollLocker, _ScrollLocker_barSize;
|
|
7
7
|
const isComputable = (value) => /^(.*)px$/.test(value);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var scrollTo = require('../dom/scroll-to.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* scrollable hook
|
|
9
|
+
*/
|
|
10
|
+
const useScrollable = ({ direction = 'vertical' } = {}) => {
|
|
11
|
+
const targetRef = react.useRef(null);
|
|
12
|
+
const triggerRefs = react.useRef(new Map());
|
|
13
|
+
const scrollTo$1 = react.useCallback((to, duration = 0) => {
|
|
14
|
+
const target = targetRef.current;
|
|
15
|
+
if (!target)
|
|
16
|
+
return;
|
|
17
|
+
// use animated scroll
|
|
18
|
+
scrollTo.scrollTo(target, to, {
|
|
19
|
+
duration,
|
|
20
|
+
direction
|
|
21
|
+
});
|
|
22
|
+
}, [direction]);
|
|
23
|
+
const to = react.useCallback((key) => {
|
|
24
|
+
const trigger = triggerRefs.current.get(key);
|
|
25
|
+
if (!trigger)
|
|
26
|
+
return 0;
|
|
27
|
+
// different direction, use different property
|
|
28
|
+
return direction === 'vertical' ? trigger.offsetTop : trigger.offsetLeft;
|
|
29
|
+
}, [direction]);
|
|
30
|
+
/// set trigger
|
|
31
|
+
const setTrigger = react.useCallback((key, trigger) => {
|
|
32
|
+
triggerRefs.current.set(key, trigger);
|
|
33
|
+
}, []);
|
|
34
|
+
return {
|
|
35
|
+
targetRef,
|
|
36
|
+
triggerRefs,
|
|
37
|
+
scrollTo: scrollTo$1,
|
|
38
|
+
to,
|
|
39
|
+
setTrigger
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.useScrollable = useScrollable;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* timeout effect
|
|
10
|
+
*/
|
|
11
|
+
const useTimeout = (handler, { duration }) => {
|
|
12
|
+
const timer = react.useRef(null);
|
|
13
|
+
react.useEffect(() => {
|
|
14
|
+
timer.current = setTimeout(handler, duration);
|
|
15
|
+
return () => {
|
|
16
|
+
if (!timer.current)
|
|
17
|
+
return;
|
|
18
|
+
clearTimeout(timer.current);
|
|
19
|
+
};
|
|
20
|
+
}, [duration]);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.useTimeout = useTimeout;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* toggle able
|
|
8
|
+
*/
|
|
9
|
+
const useToggleable = ({ keys, isAllDefaultToggled } = {}) => {
|
|
10
|
+
const [toggledKeys, setToggledKeys] = react.useState(() => {
|
|
11
|
+
if (isAllDefaultToggled) {
|
|
12
|
+
return new Map(keys === null || keys === void 0 ? void 0 : keys.map((key) => [key, true]));
|
|
13
|
+
}
|
|
14
|
+
return new Map();
|
|
15
|
+
});
|
|
16
|
+
/// toggle by flag
|
|
17
|
+
const toggleBy = react.useCallback((key, isToggled) => {
|
|
18
|
+
setToggledKeys((prev) => {
|
|
19
|
+
if (isToggled) {
|
|
20
|
+
return new Map(prev).set(key, true);
|
|
21
|
+
}
|
|
22
|
+
const _toggledKeys = new Map(prev);
|
|
23
|
+
_toggledKeys.delete(key);
|
|
24
|
+
return _toggledKeys;
|
|
25
|
+
});
|
|
26
|
+
}, []);
|
|
27
|
+
/// if all key is toggled
|
|
28
|
+
const isAllToggled = react.useMemo(() => {
|
|
29
|
+
return toggledKeys.size === (keys === null || keys === void 0 ? void 0 : keys.length);
|
|
30
|
+
}, [toggledKeys, keys]);
|
|
31
|
+
/// is toggled
|
|
32
|
+
const isToggled = react.useCallback((key) => {
|
|
33
|
+
return toggledKeys.has(key);
|
|
34
|
+
}, [toggledKeys]);
|
|
35
|
+
/// toggle
|
|
36
|
+
const toggle = react.useCallback((key) => {
|
|
37
|
+
toggleBy(key, !isToggled(key));
|
|
38
|
+
}, [toggleBy, isToggled]);
|
|
39
|
+
/// toggle all
|
|
40
|
+
const toggleAll = react.useCallback(() => {
|
|
41
|
+
if (isAllToggled) {
|
|
42
|
+
setToggledKeys(new Map());
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setToggledKeys(new Map(keys === null || keys === void 0 ? void 0 : keys.map((key) => [key, true])));
|
|
46
|
+
}
|
|
47
|
+
}, [isAllToggled, keys]);
|
|
48
|
+
return {
|
|
49
|
+
toggleBy,
|
|
50
|
+
toggle,
|
|
51
|
+
toggleAll,
|
|
52
|
+
isToggled,
|
|
53
|
+
toggledKeys,
|
|
54
|
+
isAllToggled
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.useToggleable = useToggleable;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useBoolean = require('./hooks/use-boolean.cjs');
|
|
4
|
+
var useDebounceCallback = require('./hooks/use-debounce-callback.cjs');
|
|
5
|
+
var useImageLoader = require('./hooks/use-image-loader.cjs');
|
|
6
|
+
var useMount = require('./hooks/use-mount.cjs');
|
|
7
|
+
var useMounted = require('./hooks/use-mounted.cjs');
|
|
8
|
+
var useTimeout = require('./hooks/use-timeout.cjs');
|
|
9
|
+
var useControlledState = require('./hooks/use-controlled-state.cjs');
|
|
10
|
+
var useOnceState = require('./hooks/use-once-state.cjs');
|
|
11
|
+
var useScrollLocker = require('./hooks/use-scroll-locker.cjs');
|
|
12
|
+
var useForceUpdate = require('./hooks/use-force-update.cjs');
|
|
13
|
+
var useScrollable = require('./hooks/use-scrollable.cjs');
|
|
14
|
+
var useRefs = require('./hooks/use-refs.cjs');
|
|
15
|
+
var useToggleable = require('./hooks/use-toggleable.cjs');
|
|
16
|
+
var isRefable = require('./is/is-refable.cjs');
|
|
17
|
+
var isUndefined = require('./is/is-undefined.cjs');
|
|
18
|
+
var isStateGetter = require('./is/is-state-getter.cjs');
|
|
19
|
+
var isNull = require('./is/is-null.cjs');
|
|
20
|
+
var isVoid = require('./is/is-void.cjs');
|
|
21
|
+
var isArray = require('./is/is-array.cjs');
|
|
22
|
+
var isComplex = require('./is/is-complex.cjs');
|
|
23
|
+
var isEmpty = require('./is/is-empty.cjs');
|
|
24
|
+
var isDomUsable = require('./is/is-dom-usable.cjs');
|
|
25
|
+
var isMobile = require('./is/is-mobile.cjs');
|
|
26
|
+
var isOverflow = require('./is/is-overflow.cjs');
|
|
27
|
+
var isStyleElement = require('./is/is-style-element.cjs');
|
|
28
|
+
var isFunction = require('./is/is-function.cjs');
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.useBoolean = useBoolean.useBoolean;
|
|
33
|
+
exports.useDebounceCallback = useDebounceCallback.useDebounceCallback;
|
|
34
|
+
exports.useImageLoader = useImageLoader.useImageLoader;
|
|
35
|
+
exports.useMount = useMount.useMount;
|
|
36
|
+
exports.useMounted = useMounted.useMounted;
|
|
37
|
+
exports.useTimeout = useTimeout.useTimeout;
|
|
38
|
+
exports.useControlledState = useControlledState.useControlledState;
|
|
39
|
+
exports.useOnceState = useOnceState.useOnceState;
|
|
40
|
+
exports.useScrollLocker = useScrollLocker.useScrollLocker;
|
|
41
|
+
exports.useForceUpdate = useForceUpdate.useForceUpdate;
|
|
42
|
+
exports.useScrollable = useScrollable.useScrollable;
|
|
43
|
+
exports.useRefs = useRefs.useRefs;
|
|
44
|
+
exports.useToggleable = useToggleable.useToggleable;
|
|
45
|
+
exports.isRefable = isRefable.isRefable;
|
|
46
|
+
exports.isUndefined = isUndefined.isUndefined;
|
|
47
|
+
exports.isStateGetter = isStateGetter.isStateGetter;
|
|
48
|
+
exports.isNull = isNull.isNull;
|
|
49
|
+
exports.isVoid = isVoid.isVoid;
|
|
50
|
+
exports.isArray = isArray.isArray;
|
|
51
|
+
exports.isComplex = isComplex.isComplex;
|
|
52
|
+
exports.isEmpty = isEmpty.isEmpty;
|
|
53
|
+
exports.isDomUsable = isDomUsable.isDomUsable;
|
|
54
|
+
exports.isMobile = isMobile.isMobile;
|
|
55
|
+
exports.isOverflow = isOverflow.isOverflow;
|
|
56
|
+
exports.isStyleElement = isStyleElement.isStyleElement;
|
|
57
|
+
exports.isFunction = isFunction.isFunction;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { useBoolean } from './hooks/use-boolean.mjs';
|
|
2
|
+
export { useDebounceCallback } from './hooks/use-debounce-callback.mjs';
|
|
3
|
+
export { useImageLoader } from './hooks/use-image-loader.mjs';
|
|
4
|
+
export { useMount } from './hooks/use-mount.mjs';
|
|
5
|
+
export { useMounted } from './hooks/use-mounted.mjs';
|
|
6
|
+
export { useTimeout } from './hooks/use-timeout.mjs';
|
|
7
|
+
export { useControlledState } from './hooks/use-controlled-state.mjs';
|
|
8
|
+
export { useOnceState } from './hooks/use-once-state.mjs';
|
|
9
|
+
export { useScrollLocker } from './hooks/use-scroll-locker.mjs';
|
|
10
|
+
export { useForceUpdate } from './hooks/use-force-update.mjs';
|
|
11
|
+
export { useScrollable } from './hooks/use-scrollable.mjs';
|
|
12
|
+
export { useRefs } from './hooks/use-refs.mjs';
|
|
13
|
+
export { useToggleable } from './hooks/use-toggleable.mjs';
|
|
14
|
+
export { isRefable } from './is/is-refable.mjs';
|
|
15
|
+
export { isUndefined } from './is/is-undefined.mjs';
|
|
16
|
+
export { isStateGetter } from './is/is-state-getter.mjs';
|
|
17
|
+
export { isNull } from './is/is-null.mjs';
|
|
18
|
+
export { isVoid } from './is/is-void.mjs';
|
|
19
|
+
export { isArray } from './is/is-array.mjs';
|
|
20
|
+
export { isComplex } from './is/is-complex.mjs';
|
|
21
|
+
export { isEmpty } from './is/is-empty.mjs';
|
|
22
|
+
export { isDomUsable } from './is/is-dom-usable.mjs';
|
|
23
|
+
export { isMobile } from './is/is-mobile.mjs';
|
|
24
|
+
export { isOverflow } from './is/is-overflow.mjs';
|
|
25
|
+
export { isStyleElement } from './is/is-style-element.mjs';
|
|
26
|
+
export { isFunction } from './is/is-function.mjs';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isVoid = require('./is-void.cjs');
|
|
4
|
+
var isArray = require('./is-array.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @author murukal
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* is empty
|
|
11
|
+
*/
|
|
12
|
+
const isEmpty = (value) => {
|
|
13
|
+
// null or undefined
|
|
14
|
+
if (isVoid.isVoid(value))
|
|
15
|
+
return true;
|
|
16
|
+
// object
|
|
17
|
+
if (typeof value === 'object') {
|
|
18
|
+
return Object.keys(value).length === 0;
|
|
19
|
+
}
|
|
20
|
+
// array
|
|
21
|
+
if (isArray.isArray(value)) {
|
|
22
|
+
return value.length === 0;
|
|
23
|
+
}
|
|
24
|
+
return !!value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.isEmpty = isEmpty;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* is mobile
|
|
6
|
+
*/
|
|
7
|
+
const isMobile = () => {
|
|
8
|
+
if (typeof navigator === 'undefined' || typeof window === 'undefined') {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const agent = navigator.userAgent ||
|
|
12
|
+
navigator.vendor ||
|
|
13
|
+
window.opera;
|
|
14
|
+
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) ||
|
|
15
|
+
/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)));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.isMobile = isMobile;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* if is overflow
|
|
6
|
+
*/
|
|
7
|
+
function isOverflow() {
|
|
8
|
+
return (document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) &&
|
|
9
|
+
window.innerWidth > document.body.offsetWidth);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.isOverflow = isOverflow;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var reactIs = require('react-is');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
*/
|
|
9
|
+
const isRefable = (node) => {
|
|
10
|
+
if (!react.isValidElement(node)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (reactIs.isFragment(node)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return _RefableElement(node);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @description
|
|
20
|
+
* refable element
|
|
21
|
+
*/
|
|
22
|
+
const _RefableElement = (element) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const type = reactIs.isMemo(element) ? element.type.type : element.type;
|
|
25
|
+
// Function component node
|
|
26
|
+
if (typeof type === 'function' && !((_a = type.prototype) === null || _a === void 0 ? void 0 : _a.render)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// Class component
|
|
30
|
+
if (typeof element === 'function' && !((_b = element.prototype) === null || _b === void 0 ? void 0 : _b.render)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.isRefable = isRefable;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isUndefined = require('./is-undefined.cjs');
|
|
4
|
+
var isNull = require('./is-null.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* is null or undefined
|
|
9
|
+
*/
|
|
10
|
+
const isVoid = (value) => {
|
|
11
|
+
return isNull.isNull(value) || isUndefined.isUndefined(value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.isVoid = isVoid;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
6
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7
|
+
}
|
|
8
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
9
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
11
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
12
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
13
|
+
}
|
|
14
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
15
|
+
var e = new Error(message);
|
|
16
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.__classPrivateFieldGet = __classPrivateFieldGet;
|
|
20
|
+
exports.__classPrivateFieldSet = __classPrivateFieldSet;
|
package/package.json
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiszlab/relax",
|
|
3
|
-
"version": "1.2.11-beta.
|
|
3
|
+
"version": "1.2.11-beta.2",
|
|
4
4
|
"description": "react utils collection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
-
".":
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"./dist/dom/index.d.ts"
|
|
17
|
-
]
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./dom": {
|
|
13
|
+
"types": "./dist/dom/index.d.ts",
|
|
14
|
+
"import": "./dist/dom/index.mjs",
|
|
15
|
+
"require": "./dist/dom/index.cjs"
|
|
18
16
|
}
|
|
19
17
|
},
|
|
20
18
|
"scripts": {
|
package/dist/dom/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { scrollTo } from './scroll-to.js';
|
package/dist/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export { useBoolean } from './hooks/use-boolean.js';
|
|
2
|
-
export { useDebounceCallback } from './hooks/use-debounce-callback.js';
|
|
3
|
-
export { useImageLoader } from './hooks/use-image-loader.js';
|
|
4
|
-
export { useMount } from './hooks/use-mount.js';
|
|
5
|
-
export { useMounted } from './hooks/use-mounted.js';
|
|
6
|
-
export { useTimeout } from './hooks/use-timeout.js';
|
|
7
|
-
export { useControlledState } from './hooks/use-controlled-state.js';
|
|
8
|
-
export { useOnceState } from './hooks/use-once-state.js';
|
|
9
|
-
export { useScrollLocker } from './hooks/use-scroll-locker.js';
|
|
10
|
-
export { useForceUpdate } from './hooks/use-force-update.js';
|
|
11
|
-
export { useScrollable } from './hooks/use-scrollable.js';
|
|
12
|
-
export { useRefs } from './hooks/use-refs.js';
|
|
13
|
-
export { useToggleable } from './hooks/use-toggleable.js';
|
|
14
|
-
export { isRefable } from './is/is-refable.js';
|
|
15
|
-
export { isUndefined } from './is/is-undefined.js';
|
|
16
|
-
export { isStateGetter } from './is/is-state-getter.js';
|
|
17
|
-
export { isNull } from './is/is-null.js';
|
|
18
|
-
export { isVoid } from './is/is-void.js';
|
|
19
|
-
export { isArray } from './is/is-array.js';
|
|
20
|
-
export { isComplex } from './is/is-complex.js';
|
|
21
|
-
export { isEmpty } from './is/is-empty.js';
|
|
22
|
-
export { isDomUsable } from './is/is-dom-usable.js';
|
|
23
|
-
export { isMobile } from './is/is-mobile.js';
|
|
24
|
-
export { isOverflow } from './is/is-overflow.js';
|
|
25
|
-
export { isStyleElement } from './is/is-style-element.js';
|
|
26
|
-
export { isFunction } from './is/is-function.js';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|