@astral/ui 4.86.0 → 4.87.1
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/components/NotificationList/ListItem/useLogic/useLogic.js +1 -1
- package/components/Select/Select.js +1 -1
- package/components/Select/useLogic/useLogic.d.ts +1 -1
- package/components/TagsList/types.d.ts +2 -2
- package/components/TagsList/useLogic/useLogic.js +16 -10
- package/components/TagsList/utils/getKey/getKey.js +4 -4
- package/components/createGlobalState/createGlobalState.d.ts +6 -0
- package/components/createGlobalState/createGlobalState.js +25 -0
- package/components/createGlobalState/index.d.ts +1 -0
- package/components/createGlobalState/index.js +1 -0
- package/components/createGlobalState/public.d.ts +1 -0
- package/components/createGlobalState/public.js +1 -0
- package/components/createGlobalState/utils/index.d.ts +1 -0
- package/components/createGlobalState/utils/index.js +1 -0
- package/components/createGlobalState/utils/resolveHookState/index.d.ts +1 -0
- package/components/createGlobalState/utils/resolveHookState/index.js +1 -0
- package/components/createGlobalState/utils/resolveHookState/resolveHookState.d.ts +4 -0
- package/components/createGlobalState/utils/resolveHookState/resolveHookState.js +8 -0
- package/components/createGlobalState/utils/types.d.ts +5 -0
- package/components/createGlobalState/utils/types.js +1 -0
- package/components/useDebounce/hooks/useTimeoutFn/index.d.ts +1 -0
- package/components/useDebounce/hooks/useTimeoutFn/index.js +1 -0
- package/components/useDebounce/hooks/useTimeoutFn/useTimeoutFn.d.ts +2 -0
- package/components/useDebounce/hooks/useTimeoutFn/useTimeoutFn.js +29 -0
- package/components/useDebounce/index.d.ts +1 -0
- package/components/useDebounce/index.js +1 -0
- package/components/useDebounce/public.d.ts +1 -0
- package/components/useDebounce/public.js +1 -0
- package/components/useDebounce/useDebounce.d.ts +6 -0
- package/components/useDebounce/useDebounce.js +10 -0
- package/components/useFirstMountState/index.d.ts +1 -1
- package/components/useFirstMountState/index.js +1 -1
- package/components/useFirstMountState/public.d.ts +1 -1
- package/components/useFirstMountState/public.js +1 -1
- package/components/useFirstMountState/useFirstMountState.d.ts +4 -1
- package/components/useFirstMountState/useFirstMountState.js +12 -1
- package/components/useIntersection/index.d.ts +1 -0
- package/components/useIntersection/index.js +1 -0
- package/components/useIntersection/public.d.ts +1 -0
- package/components/useIntersection/public.js +1 -0
- package/components/useIntersection/useIntersection.d.ts +5 -0
- package/components/useIntersection/useIntersection.js +22 -0
- package/components/useInterval/index.d.ts +1 -1
- package/components/useInterval/index.js +1 -1
- package/components/useInterval/public.d.ts +1 -1
- package/components/useInterval/public.js +1 -1
- package/components/useInterval/useInterval.d.ts +6 -1
- package/components/useInterval/useInterval.js +19 -1
- package/components/useIsomorphicLayoutEffect/index.d.ts +1 -0
- package/components/useIsomorphicLayoutEffect/index.js +1 -0
- package/components/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +2 -0
- package/components/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +5 -0
- package/components/useLocalStorage/index.d.ts +1 -1
- package/components/useLocalStorage/index.js +1 -1
- package/components/useLocalStorage/public.d.ts +1 -1
- package/components/useLocalStorage/public.js +1 -1
- package/components/useLocalStorage/useLocalStorage.d.ts +15 -1
- package/components/useLocalStorage/useLocalStorage.js +96 -1
- package/components/useMeasure/index.d.ts +1 -0
- package/components/useMeasure/index.js +1 -0
- package/components/useMeasure/public.d.ts +1 -0
- package/components/useMeasure/public.js +1 -0
- package/components/useMeasure/useMeasure.d.ts +13 -0
- package/components/useMeasure/useMeasure.js +42 -0
- package/components/useNewToggle/index.d.ts +1 -0
- package/components/useNewToggle/index.js +1 -0
- package/components/useNewToggle/public.d.ts +1 -0
- package/components/useNewToggle/public.js +1 -0
- package/components/useNewToggle/useNewToggle.d.ts +4 -0
- package/components/useNewToggle/useNewToggle.js +8 -0
- package/components/useRafState/hooks/useUnmount/index.d.ts +1 -0
- package/components/useRafState/hooks/useUnmount/index.js +1 -0
- package/components/useRafState/hooks/useUnmount/useUnmount.d.ts +1 -0
- package/components/useRafState/hooks/useUnmount/useUnmount.js +7 -0
- package/components/useRafState/index.d.ts +1 -0
- package/components/useRafState/index.js +1 -0
- package/components/useRafState/useRafState.d.ts +2 -0
- package/components/useRafState/useRafState.js +16 -0
- package/components/useScroll/index.d.ts +1 -0
- package/components/useScroll/index.js +1 -0
- package/components/useScroll/public.d.ts +1 -0
- package/components/useScroll/public.js +1 -0
- package/components/useScroll/useScroll.d.ts +9 -0
- package/components/useScroll/useScroll.js +39 -0
- package/components/useSet/index.d.ts +1 -1
- package/components/useSet/index.js +1 -1
- package/components/useSet/public.d.ts +1 -1
- package/components/useSet/public.js +1 -1
- package/components/useSet/useSet.d.ts +14 -1
- package/components/useSet/useSet.js +26 -1
- package/components/useSize/index.d.ts +1 -0
- package/components/useSize/index.js +1 -0
- package/components/useSize/public.d.ts +1 -0
- package/components/useSize/public.js +1 -0
- package/components/useSize/useSize.d.ts +17 -0
- package/components/useSize/useSize.js +79 -0
- package/components/useToggle/useToggle.d.ts +1 -0
- package/components/useToggle/useToggle.js +1 -0
- package/components/useUpdateEffect/index.d.ts +1 -1
- package/components/useUpdateEffect/index.js +1 -1
- package/components/useUpdateEffect/public.d.ts +1 -1
- package/components/useUpdateEffect/public.js +1 -1
- package/components/useUpdateEffect/useUpdateEffect.d.ts +5 -1
- package/components/useUpdateEffect/useUpdateEffect.js +13 -1
- package/components/useWindowScroll/index.d.ts +1 -0
- package/components/useWindowScroll/index.js +1 -0
- package/components/useWindowScroll/public.d.ts +1 -0
- package/components/useWindowScroll/public.js +1 -0
- package/components/useWindowScroll/useWindowScroll.d.ts +8 -0
- package/components/useWindowScroll/useWindowScroll.js +40 -0
- package/components/utils/addEventListenerSafe/addEventListenerSafe.d.ts +1 -0
- package/components/utils/addEventListenerSafe/addEventListenerSafe.js +5 -0
- package/components/utils/addEventListenerSafe/index.d.ts +1 -0
- package/components/utils/addEventListenerSafe/index.js +1 -0
- package/components/utils/isBrowser/index.d.ts +1 -0
- package/components/utils/isBrowser/index.js +1 -0
- package/components/utils/isBrowser/isBrowser.d.ts +1 -0
- package/components/utils/isBrowser/isBrowser.js +1 -0
- package/components/utils/removeEventListenerSafe/index.d.ts +1 -0
- package/components/utils/removeEventListenerSafe/index.js +1 -0
- package/components/utils/removeEventListenerSafe/removeEventListenerSafe.d.ts +1 -0
- package/components/utils/removeEventListenerSafe/removeEventListenerSafe.js +5 -0
- package/components/utils/replaceRaf/constants.d.ts +1 -0
- package/components/utils/replaceRaf/constants.js +1 -0
- package/components/utils/replaceRaf/index.d.ts +1 -0
- package/components/utils/replaceRaf/index.js +1 -0
- package/components/utils/replaceRaf/replaceRaf.d.ts +18 -0
- package/components/utils/replaceRaf/replaceRaf.js +81 -0
- package/node/components/NotificationList/ListItem/useLogic/useLogic.js +2 -2
- package/node/components/Select/Select.js +1 -1
- package/node/components/Select/useLogic/useLogic.d.ts +1 -1
- package/node/components/TagsList/types.d.ts +2 -2
- package/node/components/TagsList/useLogic/useLogic.js +16 -10
- package/node/components/TagsList/utils/getKey/getKey.js +4 -4
- package/node/components/createGlobalState/createGlobalState.d.ts +6 -0
- package/node/components/createGlobalState/createGlobalState.js +29 -0
- package/node/components/createGlobalState/index.d.ts +1 -0
- package/node/components/createGlobalState/index.js +17 -0
- package/node/components/createGlobalState/public.d.ts +1 -0
- package/node/components/createGlobalState/public.js +17 -0
- package/node/components/createGlobalState/utils/index.d.ts +1 -0
- package/node/components/createGlobalState/utils/index.js +17 -0
- package/node/components/createGlobalState/utils/resolveHookState/index.d.ts +1 -0
- package/node/components/createGlobalState/utils/resolveHookState/index.js +17 -0
- package/node/components/createGlobalState/utils/resolveHookState/resolveHookState.d.ts +4 -0
- package/node/components/createGlobalState/utils/resolveHookState/resolveHookState.js +12 -0
- package/node/components/createGlobalState/utils/types.d.ts +5 -0
- package/node/components/createGlobalState/utils/types.js +2 -0
- package/node/components/useDebounce/hooks/useTimeoutFn/index.d.ts +1 -0
- package/node/components/useDebounce/hooks/useTimeoutFn/index.js +17 -0
- package/node/components/useDebounce/hooks/useTimeoutFn/useTimeoutFn.d.ts +2 -0
- package/node/components/useDebounce/hooks/useTimeoutFn/useTimeoutFn.js +33 -0
- package/node/components/useDebounce/index.d.ts +1 -0
- package/node/components/useDebounce/index.js +17 -0
- package/node/components/useDebounce/public.d.ts +1 -0
- package/node/components/useDebounce/public.js +17 -0
- package/node/components/useDebounce/useDebounce.d.ts +6 -0
- package/node/components/useDebounce/useDebounce.js +14 -0
- package/node/components/useFirstMountState/index.d.ts +1 -1
- package/node/components/useFirstMountState/index.js +15 -3
- package/node/components/useFirstMountState/public.d.ts +1 -1
- package/node/components/useFirstMountState/public.js +15 -3
- package/node/components/useFirstMountState/useFirstMountState.d.ts +4 -1
- package/node/components/useFirstMountState/useFirstMountState.js +13 -2
- package/node/components/useIntersection/index.d.ts +1 -0
- package/node/components/useIntersection/index.js +17 -0
- package/node/components/useIntersection/public.d.ts +1 -0
- package/node/components/useIntersection/public.js +17 -0
- package/node/components/useIntersection/useIntersection.d.ts +5 -0
- package/node/components/useIntersection/useIntersection.js +26 -0
- package/node/components/useInterval/index.d.ts +1 -1
- package/node/components/useInterval/index.js +15 -3
- package/node/components/useInterval/public.d.ts +1 -1
- package/node/components/useInterval/public.js +15 -3
- package/node/components/useInterval/useInterval.d.ts +6 -1
- package/node/components/useInterval/useInterval.js +20 -2
- package/node/components/useIsomorphicLayoutEffect/index.d.ts +1 -0
- package/node/components/useIsomorphicLayoutEffect/index.js +17 -0
- package/node/components/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +2 -0
- package/node/components/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +8 -0
- package/node/components/useLocalStorage/index.d.ts +1 -1
- package/node/components/useLocalStorage/index.js +5 -14
- package/node/components/useLocalStorage/public.d.ts +1 -1
- package/node/components/useLocalStorage/public.js +5 -14
- package/node/components/useLocalStorage/useLocalStorage.d.ts +15 -1
- package/node/components/useLocalStorage/useLocalStorage.js +97 -2
- package/node/components/useMeasure/index.d.ts +1 -0
- package/node/components/useMeasure/index.js +8 -0
- package/node/components/useMeasure/public.d.ts +1 -0
- package/node/components/useMeasure/public.js +8 -0
- package/node/components/useMeasure/useMeasure.d.ts +13 -0
- package/node/components/useMeasure/useMeasure.js +44 -0
- package/node/components/useNewToggle/index.d.ts +1 -0
- package/node/components/useNewToggle/index.js +17 -0
- package/node/components/useNewToggle/public.d.ts +1 -0
- package/node/components/useNewToggle/public.js +17 -0
- package/node/components/useNewToggle/useNewToggle.d.ts +4 -0
- package/node/components/useNewToggle/useNewToggle.js +12 -0
- package/node/components/useRafState/hooks/useUnmount/index.d.ts +1 -0
- package/node/components/useRafState/hooks/useUnmount/index.js +17 -0
- package/node/components/useRafState/hooks/useUnmount/useUnmount.d.ts +1 -0
- package/node/components/useRafState/hooks/useUnmount/useUnmount.js +11 -0
- package/node/components/useRafState/index.d.ts +1 -0
- package/node/components/useRafState/index.js +17 -0
- package/node/components/useRafState/useRafState.d.ts +2 -0
- package/node/components/useRafState/useRafState.js +20 -0
- package/node/components/useScroll/index.d.ts +1 -0
- package/node/components/useScroll/index.js +17 -0
- package/node/components/useScroll/public.d.ts +1 -0
- package/node/components/useScroll/public.js +17 -0
- package/node/components/useScroll/useScroll.d.ts +9 -0
- package/node/components/useScroll/useScroll.js +43 -0
- package/node/components/useSet/index.d.ts +1 -1
- package/node/components/useSet/index.js +15 -3
- package/node/components/useSet/public.d.ts +1 -1
- package/node/components/useSet/public.js +15 -3
- package/node/components/useSet/useSet.d.ts +14 -1
- package/node/components/useSet/useSet.js +27 -2
- package/node/components/useSize/index.d.ts +1 -0
- package/node/components/useSize/index.js +8 -0
- package/node/components/useSize/public.d.ts +1 -0
- package/node/components/useSize/public.js +8 -0
- package/node/components/useSize/useSize.d.ts +17 -0
- package/node/components/useSize/useSize.js +106 -0
- package/node/components/useToggle/useToggle.d.ts +1 -0
- package/node/components/useToggle/useToggle.js +1 -0
- package/node/components/useUpdateEffect/index.d.ts +1 -1
- package/node/components/useUpdateEffect/index.js +15 -3
- package/node/components/useUpdateEffect/public.d.ts +1 -1
- package/node/components/useUpdateEffect/public.js +15 -3
- package/node/components/useUpdateEffect/useUpdateEffect.d.ts +5 -1
- package/node/components/useUpdateEffect/useUpdateEffect.js +14 -2
- package/node/components/useWindowScroll/index.d.ts +1 -0
- package/node/components/useWindowScroll/index.js +17 -0
- package/node/components/useWindowScroll/public.d.ts +1 -0
- package/node/components/useWindowScroll/public.js +17 -0
- package/node/components/useWindowScroll/useWindowScroll.d.ts +8 -0
- package/node/components/useWindowScroll/useWindowScroll.js +44 -0
- package/node/components/utils/addEventListenerSafe/addEventListenerSafe.d.ts +1 -0
- package/node/components/utils/addEventListenerSafe/addEventListenerSafe.js +9 -0
- package/node/components/utils/addEventListenerSafe/index.d.ts +1 -0
- package/node/components/utils/addEventListenerSafe/index.js +17 -0
- package/node/components/utils/isBrowser/index.d.ts +1 -0
- package/node/components/utils/isBrowser/index.js +17 -0
- package/node/components/utils/isBrowser/isBrowser.d.ts +1 -0
- package/node/components/utils/isBrowser/isBrowser.js +4 -0
- package/node/components/utils/removeEventListenerSafe/index.d.ts +1 -0
- package/node/components/utils/removeEventListenerSafe/index.js +17 -0
- package/node/components/utils/removeEventListenerSafe/removeEventListenerSafe.d.ts +1 -0
- package/node/components/utils/removeEventListenerSafe/removeEventListenerSafe.js +9 -0
- package/node/components/utils/replaceRaf/constants.d.ts +1 -0
- package/node/components/utils/replaceRaf/constants.js +4 -0
- package/node/components/utils/replaceRaf/index.d.ts +1 -0
- package/node/components/utils/replaceRaf/index.js +17 -0
- package/node/components/utils/replaceRaf/replaceRaf.d.ts +18 -0
- package/node/components/utils/replaceRaf/replaceRaf.js +86 -0
- package/package.json +1 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MouseEvent, type RefObject } from 'react';
|
|
2
|
-
export type TagValue = string | Record<string, unknown>;
|
|
2
|
+
export type TagValue = string | number | Record<string, unknown>;
|
|
3
3
|
export type TagsListProps<TData extends TagValue = TagValue> = {
|
|
4
4
|
/**
|
|
5
5
|
* Название класса, применяется к корневому компоненту
|
|
@@ -17,7 +17,7 @@ export type TagsListProps<TData extends TagValue = TagValue> = {
|
|
|
17
17
|
* Поле, используемое в качестве ключа списка.
|
|
18
18
|
* Если не передано, для генерации ключа будет использоваться getOptionLabel
|
|
19
19
|
*/
|
|
20
|
-
keyId?: TData extends
|
|
20
|
+
keyId?: TData extends object ? keyof TData : never;
|
|
21
21
|
/**
|
|
22
22
|
* Используется для определения строкового значения опции
|
|
23
23
|
*/
|
|
@@ -82,19 +82,25 @@ const useLogic = ({ data = [], keyId, getOptionLabel, onChange, inputContainerRe
|
|
|
82
82
|
resizeObserver.disconnect();
|
|
83
83
|
};
|
|
84
84
|
}, [data]);
|
|
85
|
+
/**
|
|
86
|
+
* Возвращает значение, по которому определяется идентичность тегов.
|
|
87
|
+
* Для примитивов сравнение идет по самому значению, keyId применим только к объектам
|
|
88
|
+
*/
|
|
89
|
+
const getComparableValue = (option) => {
|
|
90
|
+
if (typeof option !== 'object' || option === null) {
|
|
91
|
+
return option;
|
|
92
|
+
}
|
|
93
|
+
if (keyId) {
|
|
94
|
+
return option[keyId];
|
|
95
|
+
}
|
|
96
|
+
return getOptionLabel(option);
|
|
97
|
+
};
|
|
85
98
|
const getTagProps = (option) => {
|
|
86
99
|
const label = getOptionLabel(option);
|
|
87
100
|
const onDelete = () => {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
if (keyId) {
|
|
93
|
-
return value[keyId] !== option[keyId];
|
|
94
|
-
}
|
|
95
|
-
return getOptionLabel(value) !== getOptionLabel(option);
|
|
96
|
-
});
|
|
97
|
-
onChange(newValue.length ? newValue : []);
|
|
101
|
+
const deletedValue = getComparableValue(option);
|
|
102
|
+
const newValue = data.filter((value) => getComparableValue(value) !== deletedValue);
|
|
103
|
+
onChange(newValue);
|
|
98
104
|
};
|
|
99
105
|
return { label, shrinks: false, onDelete };
|
|
100
106
|
};
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getKey = void 0;
|
|
4
4
|
const getKey = (option, keyId, getOptionLabel) => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const isObjectOption = typeof option === 'object' && option !== null;
|
|
6
|
+
if (!isObjectOption) {
|
|
7
|
+
return String(option);
|
|
7
8
|
}
|
|
8
9
|
if (keyId) {
|
|
9
|
-
|
|
10
|
-
return typeof key === 'number' ? key.toString() : key;
|
|
10
|
+
return String(option[keyId]);
|
|
11
11
|
}
|
|
12
12
|
return getOptionLabel(option).toString();
|
|
13
13
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IHookStateInitAction, type IHookStateSetAction } from './utils/types';
|
|
2
|
+
export declare function createGlobalState<TState>(initialState: IHookStateInitAction<TState>): () => [TState, (state: IHookStateSetAction<TState>) => void];
|
|
3
|
+
export declare function createGlobalState<TState = undefined>(): () => [
|
|
4
|
+
TState,
|
|
5
|
+
(state: IHookStateSetAction<TState>) => void
|
|
6
|
+
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGlobalState = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useIsomorphicLayoutEffect_1 = require("../useIsomorphicLayoutEffect");
|
|
6
|
+
const resolveHookState_1 = require("./utils/resolveHookState");
|
|
7
|
+
function createGlobalState(initialState) {
|
|
8
|
+
const store = {
|
|
9
|
+
state: initialState instanceof Function ? initialState() : initialState,
|
|
10
|
+
setState(nextState) {
|
|
11
|
+
store.state = (0, resolveHookState_1.resolveHookState)(nextState, store.state);
|
|
12
|
+
store.setters.forEach((setter) => setter(store.state));
|
|
13
|
+
},
|
|
14
|
+
setters: [],
|
|
15
|
+
};
|
|
16
|
+
return () => {
|
|
17
|
+
const [globalState, stateSetter] = (0, react_1.useState)(store.state);
|
|
18
|
+
(0, react_1.useEffect)(() => () => {
|
|
19
|
+
store.setters = store.setters.filter((setter) => setter !== stateSetter);
|
|
20
|
+
}, []);
|
|
21
|
+
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(() => {
|
|
22
|
+
if (!store.setters.includes(stateSetter)) {
|
|
23
|
+
store.setters.push(stateSetter);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return [globalState, store.setState];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.createGlobalState = createGlobalState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createGlobalState';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createGlobalState"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createGlobalState';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createGlobalState"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './resolveHookState';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./resolveHookState"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './resolveHookState';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./resolveHookState"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type IHookStateInitAction, type IHookStateResolvable, type IHookStateSetAction } from '../types';
|
|
2
|
+
export declare function resolveHookState<TState>(nextState: IHookStateInitAction<TState>): TState;
|
|
3
|
+
export declare function resolveHookState<TState, TCurrentState extends TState>(nextState: IHookStateSetAction<TState>, currentState?: TCurrentState): TState;
|
|
4
|
+
export declare function resolveHookState<TState, TCurrentState extends TState>(nextState: IHookStateResolvable<TState>, currentState?: TCurrentState): TState;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveHookState = void 0;
|
|
4
|
+
function resolveHookState(nextState, currentState) {
|
|
5
|
+
if (typeof nextState === 'function') {
|
|
6
|
+
return nextState.length
|
|
7
|
+
? nextState(currentState)
|
|
8
|
+
: nextState();
|
|
9
|
+
}
|
|
10
|
+
return nextState;
|
|
11
|
+
}
|
|
12
|
+
exports.resolveHookState = resolveHookState;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type IHookStateInitialSetter<TState> = () => TState;
|
|
2
|
+
export type IHookStateInitAction<TState> = TState | IHookStateInitialSetter<TState>;
|
|
3
|
+
export type IHookStateSetter<TState> = ((prevState: TState) => TState) | (() => TState);
|
|
4
|
+
export type IHookStateSetAction<TState> = TState | IHookStateSetter<TState>;
|
|
5
|
+
export type IHookStateResolvable<TState> = TState | IHookStateInitialSetter<TState> | IHookStateSetter<TState>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useTimeoutFn';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useTimeoutFn"), exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTimeoutFn = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useTimeoutFn(fn, ms = 0) {
|
|
6
|
+
const ready = (0, react_1.useRef)(false);
|
|
7
|
+
const timeout = (0, react_1.useRef)(null);
|
|
8
|
+
const callback = (0, react_1.useRef)(fn);
|
|
9
|
+
const isReady = (0, react_1.useCallback)(() => ready.current, []);
|
|
10
|
+
const set = (0, react_1.useCallback)(() => {
|
|
11
|
+
ready.current = false;
|
|
12
|
+
timeout.current && clearTimeout(timeout.current);
|
|
13
|
+
timeout.current = setTimeout(() => {
|
|
14
|
+
ready.current = true;
|
|
15
|
+
callback.current();
|
|
16
|
+
}, ms);
|
|
17
|
+
}, [ms]);
|
|
18
|
+
const clear = (0, react_1.useCallback)(() => {
|
|
19
|
+
ready.current = null;
|
|
20
|
+
timeout.current && clearTimeout(timeout.current);
|
|
21
|
+
}, []);
|
|
22
|
+
// update ref when function changes
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
callback.current = fn;
|
|
25
|
+
}, [fn]);
|
|
26
|
+
// set on mount, clear on unmount
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
set();
|
|
29
|
+
return clear;
|
|
30
|
+
}, [ms]);
|
|
31
|
+
return [isReady, clear, set];
|
|
32
|
+
}
|
|
33
|
+
exports.useTimeoutFn = useTimeoutFn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDebounce';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useDebounce"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDebounce';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useDebounce"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DependencyList } from 'react';
|
|
2
|
+
export type UseDebounceReturn = [() => boolean | null, () => void];
|
|
3
|
+
/**
|
|
4
|
+
* Хук откладывает вызов функции, пока не пройдет переданное число миллисекунд после последнего вызова debounce-функции.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useDebounce(fn: Function, ms?: number, deps?: DependencyList): UseDebounceReturn;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDebounce = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useTimeoutFn_1 = require("./hooks/useTimeoutFn");
|
|
6
|
+
/**
|
|
7
|
+
* Хук откладывает вызов функции, пока не пройдет переданное число миллисекунд после последнего вызова debounce-функции.
|
|
8
|
+
*/
|
|
9
|
+
function useDebounce(fn, ms = 0, deps = []) {
|
|
10
|
+
const [isReady, cancel, reset] = (0, useTimeoutFn_1.useTimeoutFn)(fn, ms);
|
|
11
|
+
(0, react_1.useEffect)(reset, deps);
|
|
12
|
+
return [isReady, cancel];
|
|
13
|
+
}
|
|
14
|
+
exports.useDebounce = useDebounce;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './useFirstMountState';
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var useFirstMountState_1 = require("./useFirstMountState");
|
|
5
|
-
Object.defineProperty(exports, "useFirstMountState", { enumerable: true, get: function () { return useFirstMountState_1.useFirstMountState; } });
|
|
17
|
+
__exportStar(require("./useFirstMountState"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './useFirstMountState';
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var useFirstMountState_1 = require("./useFirstMountState");
|
|
5
|
-
Object.defineProperty(exports, "useFirstMountState", { enumerable: true, get: function () { return useFirstMountState_1.useFirstMountState; } });
|
|
17
|
+
__exportStar(require("./useFirstMountState"), exports);
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFirstMountState = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Хук возвращает true если компонент только монтировался (при первом рендере) и false в другом случае.
|
|
7
|
+
*/
|
|
8
|
+
function useFirstMountState() {
|
|
9
|
+
const isFirst = (0, react_1.useRef)(true);
|
|
10
|
+
if (isFirst.current) {
|
|
11
|
+
isFirst.current = false;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return isFirst.current;
|
|
15
|
+
}
|
|
16
|
+
exports.useFirstMountState = useFirstMountState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useIntersection';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useIntersection"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useIntersection';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useIntersection"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Хук отслеживает изменения в пересечении целевого элемента с родительским элементом или с верхним уровнем области просмотра документа.
|
|
4
|
+
*/
|
|
5
|
+
export declare const useIntersection: (ref: RefObject<HTMLElement | null>, options: IntersectionObserverInit) => IntersectionObserverEntry | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIntersection = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Хук отслеживает изменения в пересечении целевого элемента с родительским элементом или с верхним уровнем области просмотра документа.
|
|
7
|
+
*/
|
|
8
|
+
const useIntersection = (ref, options) => {
|
|
9
|
+
const [intersectionObserverEntry, setIntersectionObserverEntry] = (0, react_1.useState)(null);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (ref.current && typeof IntersectionObserver === 'function') {
|
|
12
|
+
const handler = (entries) => {
|
|
13
|
+
setIntersectionObserverEntry(entries[0]);
|
|
14
|
+
};
|
|
15
|
+
const observer = new IntersectionObserver(handler, options);
|
|
16
|
+
observer.observe(ref.current);
|
|
17
|
+
return () => {
|
|
18
|
+
setIntersectionObserverEntry(null);
|
|
19
|
+
observer.disconnect();
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return () => { };
|
|
23
|
+
}, [ref.current, options.threshold, options.root, options.rootMargin]);
|
|
24
|
+
return intersectionObserverEntry;
|
|
25
|
+
};
|
|
26
|
+
exports.useIntersection = useIntersection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './useInterval';
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var useInterval_1 = require("./useInterval");
|
|
5
|
-
Object.defineProperty(exports, "useInterval", { enumerable: true, get: function () { return useInterval_1.useInterval; } });
|
|
17
|
+
__exportStar(require("./useInterval"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './useInterval';
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var useInterval_1 = require("./useInterval");
|
|
5
|
-
Object.defineProperty(exports, "useInterval", { enumerable: true, get: function () { return useInterval_1.useInterval; } });
|
|
17
|
+
__exportStar(require("./useInterval"), exports);
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Хук для запуска функции с заданным интервалом.
|
|
3
|
+
* Если передать null, интервал не будет запущен (или будет остановлен).
|
|
4
|
+
* Если значение не указано (undefined), используется задержка 0 мс.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useInterval: (callback: Function, delay?: number | null) => void;
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useInterval = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Хук для запуска функции с заданным интервалом.
|
|
7
|
+
* Если передать null, интервал не будет запущен (или будет остановлен).
|
|
8
|
+
* Если значение не указано (undefined), используется задержка 0 мс.
|
|
9
|
+
*/
|
|
10
|
+
const useInterval = (callback, delay) => {
|
|
11
|
+
const savedCallback = (0, react_1.useRef)(() => { });
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
savedCallback.current = callback;
|
|
14
|
+
});
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
if (delay !== null) {
|
|
17
|
+
const interval = setInterval(() => savedCallback.current(), delay || 0);
|
|
18
|
+
return () => clearInterval(interval);
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}, [delay]);
|
|
22
|
+
};
|
|
23
|
+
exports.useInterval = useInterval;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useIsomorphicLayoutEffect';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useIsomorphicLayoutEffect"), exports);
|