@uxf/core 11.47.0 → 11.52.0
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/README.md +8 -254
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +1 -8
- package/utils/build-array.test.js +10 -0
- package/utils/camel-case-to-dash.test.js +8 -0
- package/utils/format-bytes.d.ts +1 -0
- package/utils/format-bytes.js +10 -0
- package/utils/format-bytes.test.js +9 -0
- package/utils/image.d.ts +0 -22
- package/utils/image.js +0 -41
- package/utils/{isBrowser.test.js → is-browser.test.js} +3 -3
- package/utils/{isServer.js → is-server.js} +2 -2
- package/utils/is-server.test.js +12 -0
- package/utils/trim-trailing-zeros.test.js +6 -6
- package/{Validators/FormValidator.js → validators/form-validator.js} +3 -3
- package/validators/form-validator.test.js +45 -0
- package/validators/validator.test.js +17 -0
- package/Validators/FormValidator.test.js +0 -45
- package/Validators/Validator.test.js +0 -17
- package/components/hide.d.ts +0 -10
- package/components/hide.js +0 -16
- package/components/show.d.ts +0 -10
- package/components/show.js +0 -16
- package/hooks/_useSimulatedButton.d.ts +0 -19
- package/hooks/_useSimulatedButton.js +0 -54
- package/hooks/useAnchorProps.d.ts +0 -14
- package/hooks/useAnchorProps.js +0 -68
- package/hooks/useBodyScrollLock.d.ts +0 -12
- package/hooks/useBodyScrollLock.js +0 -37
- package/hooks/useButtonProps.d.ts +0 -12
- package/hooks/useButtonProps.js +0 -61
- package/hooks/useClickableProps.d.ts +0 -14
- package/hooks/useClickableProps.js +0 -46
- package/hooks/useFocusReturn.d.ts +0 -4
- package/hooks/useFocusReturn.js +0 -37
- package/hooks/useFocusTrap.d.ts +0 -5
- package/hooks/useFocusTrap.js +0 -148
- package/hooks/useInputFocus.d.ts +0 -10
- package/hooks/useInputFocus.js +0 -29
- package/hooks/useIsMounted.d.ts +0 -4
- package/hooks/useIsMounted.js +0 -12
- package/hooks/useIsomorphicLayoutEffect.d.ts +0 -5
- package/hooks/useIsomorphicLayoutEffect.js +0 -9
- package/hooks/useKey.d.ts +0 -19
- package/hooks/useKey.js +0 -30
- package/hooks/useLatest.d.ts +0 -4
- package/hooks/useLatest.js +0 -12
- package/hooks/useMinWindowWidth.d.ts +0 -4
- package/hooks/useMinWindowWidth.js +0 -31
- package/hooks/useMouseDragToScroll.d.ts +0 -5
- package/hooks/useMouseDragToScroll.js +0 -41
- package/hooks/useOnMount.d.ts +0 -5
- package/hooks/useOnMount.js +0 -12
- package/hooks/useOnUnmount.d.ts +0 -5
- package/hooks/useOnUnmount.js +0 -17
- package/hooks/useOnUpdate.d.ts +0 -5
- package/hooks/useOnUpdate.js +0 -17
- package/hooks/usePagination.d.ts +0 -5
- package/hooks/usePagination.js +0 -23
- package/hooks/usePrevious.d.ts +0 -4
- package/hooks/usePrevious.js +0 -14
- package/hooks/useRafState.d.ts +0 -5
- package/hooks/useRafState.js +0 -20
- package/hooks/useTabs.d.ts +0 -16
- package/hooks/useTabs.js +0 -43
- package/hooks/useWindowScroll.d.ts +0 -7
- package/hooks/useWindowScroll.js +0 -24
- package/hooks/useWindowSize.d.ts +0 -7
- package/hooks/useWindowSize.js +0 -21
- package/next/index.d.ts +0 -2
- package/next/index.js +0 -7
- package/next/query-param.test.js +0 -35
- package/utils/buildArray.test.js +0 -10
- package/utils/camelCaseToDash.test.js +0 -8
- package/utils/composeRefs.d.ts +0 -5
- package/utils/composeRefs.js +0 -18
- package/utils/isServer.test.js +0 -12
- /package/utils/{bodyScrollLock.d.ts → body-scroll-lock.d.ts} +0 -0
- /package/utils/{bodyScrollLock.js → body-scroll-lock.js} +0 -0
- /package/utils/{buildArray.d.ts → build-array.d.ts} +0 -0
- /package/utils/{buildArray.js → build-array.js} +0 -0
- /package/{Validators/FormValidator.test.d.ts → utils/build-array.test.d.ts} +0 -0
- /package/utils/{camelCaseToDash.d.ts → camel-case-to-dash.d.ts} +0 -0
- /package/utils/{camelCaseToDash.js → camel-case-to-dash.js} +0 -0
- /package/{Validators/Validator.test.d.ts → utils/camel-case-to-dash.test.d.ts} +0 -0
- /package/{next/query-param.test.d.ts → utils/format-bytes.test.d.ts} +0 -0
- /package/utils/{isBrowser.d.ts → is-browser.d.ts} +0 -0
- /package/utils/{isBrowser.js → is-browser.js} +0 -0
- /package/utils/{buildArray.test.d.ts → is-browser.test.d.ts} +0 -0
- /package/utils/{isServer.d.ts → is-server.d.ts} +0 -0
- /package/utils/{camelCaseToDash.test.d.ts → is-server.test.d.ts} +0 -0
- /package/utils/{trimTrailingZeros.d.ts → trim-trailing-zeros.d.ts} +0 -0
- /package/utils/{trimTrailingZeros.js → trim-trailing-zeros.js} +0 -0
- /package/{Validators/FormValidator.d.ts → validators/form-validator.d.ts} +0 -0
- /package/{utils/isBrowser.test.d.ts → validators/form-validator.test.d.ts} +0 -0
- /package/{Validators/Validator.d.ts → validators/validator.d.ts} +0 -0
- /package/{Validators/Validator.js → validators/validator.js} +0 -0
- /package/{utils/isServer.test.d.ts → validators/validator.test.d.ts} +0 -0
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIsomorphicLayoutEffect = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const isBrowser_1 = require("../utils/isBrowser");
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
-
*/
|
|
9
|
-
exports.useIsomorphicLayoutEffect = isBrowser_1.isBrowser ? react_1.useLayoutEffect : react_1.useEffect;
|
package/hooks/useKey.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { RefObject } from "react";
|
|
2
|
-
type KeyPredicate = (e: KeyboardEvent) => boolean;
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
5
|
-
*/
|
|
6
|
-
export type KeyFilter = null | undefined | string | KeyPredicate;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
9
|
-
*/
|
|
10
|
-
export interface UseKeyOptions<T extends HTMLElement> {
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
targetRef?: RefObject<T>;
|
|
13
|
-
type: "keydown" | "keyup" | "keypress";
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
17
|
-
*/
|
|
18
|
-
export declare function useKey<T extends HTMLElement>(keyFilter: KeyFilter, callback: (e: KeyboardEvent) => void, { disabled, targetRef, type }?: Partial<UseKeyOptions<T>>): void;
|
|
19
|
-
export {};
|
package/hooks/useKey.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useKey = useKey;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const createKeyPredicate = (keyFilter) => typeof keyFilter === "function"
|
|
6
|
-
? keyFilter
|
|
7
|
-
: typeof keyFilter === "string"
|
|
8
|
-
? (e) => e.key === keyFilter
|
|
9
|
-
: () => false;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
12
|
-
*/
|
|
13
|
-
function useKey(keyFilter, callback, { disabled, targetRef, type = "keydown" } = {}) {
|
|
14
|
-
(0, react_1.useEffect)(() => {
|
|
15
|
-
if (disabled) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const thisNode = (targetRef ? targetRef.current : document);
|
|
19
|
-
const predicate = createKeyPredicate(keyFilter);
|
|
20
|
-
const handler = (e) => {
|
|
21
|
-
if (predicate(e)) {
|
|
22
|
-
callback(e);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
thisNode === null || thisNode === void 0 ? void 0 : thisNode.addEventListener(type, handler);
|
|
26
|
-
return () => {
|
|
27
|
-
thisNode === null || thisNode === void 0 ? void 0 : thisNode.removeEventListener(type, handler);
|
|
28
|
-
};
|
|
29
|
-
}, [callback, disabled, keyFilter, targetRef, type]);
|
|
30
|
-
}
|
package/hooks/useLatest.d.ts
DELETED
package/hooks/useLatest.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLatest = useLatest;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
-
*/
|
|
8
|
-
function useLatest(current) {
|
|
9
|
-
const storedValue = (0, react_1.useRef)(current);
|
|
10
|
-
storedValue.current = current;
|
|
11
|
-
return storedValue;
|
|
12
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMinWindowWidth = useMinWindowWidth;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useRafState_1 = require("./useRafState");
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
-
*/
|
|
9
|
-
function useMinWindowWidth(minWidth, debounce = 0) {
|
|
10
|
-
const [state, setState] = (0, useRafState_1.useRafState)();
|
|
11
|
-
(0, react_1.useEffect)(() => {
|
|
12
|
-
const stateHandler = () => setState(window.innerWidth >= minWidth);
|
|
13
|
-
let timer;
|
|
14
|
-
const handler = () => {
|
|
15
|
-
if (debounce > 0) {
|
|
16
|
-
window.clearTimeout(timer);
|
|
17
|
-
timer = window.setTimeout(stateHandler, debounce);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
stateHandler();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
stateHandler();
|
|
24
|
-
window.addEventListener("resize", handler);
|
|
25
|
-
return () => {
|
|
26
|
-
window.removeEventListener("resize", handler);
|
|
27
|
-
window.clearTimeout(timer);
|
|
28
|
-
};
|
|
29
|
-
}, [debounce, minWidth, setState]);
|
|
30
|
-
return state;
|
|
31
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMouseDragToScroll = useMouseDragToScroll;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
-
*/
|
|
8
|
-
function useMouseDragToScroll(containerRef) {
|
|
9
|
-
const position = (0, react_1.useRef)({ left: 0, top: 0, x: 0, y: 0 });
|
|
10
|
-
const [style, setStyle] = (0, react_1.useState)();
|
|
11
|
-
(0, react_1.useEffect)(() => {
|
|
12
|
-
const node = containerRef.current;
|
|
13
|
-
if (!node) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const mouseMoveHandler = (e) => {
|
|
17
|
-
const dx = e.clientX - position.current.x;
|
|
18
|
-
const dy = e.clientY - position.current.y;
|
|
19
|
-
node.scrollLeft = position.current.left - dx;
|
|
20
|
-
node.scrollTop = position.current.top - dy;
|
|
21
|
-
};
|
|
22
|
-
const mouseUpHandler = () => {
|
|
23
|
-
setStyle((prev) => ({ ...prev, cursor: "grab", userSelect: "unset" }));
|
|
24
|
-
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
25
|
-
document.removeEventListener("mouseup", mouseUpHandler);
|
|
26
|
-
};
|
|
27
|
-
const mouseDownHandler = (e) => {
|
|
28
|
-
position.current = { left: node.scrollLeft, top: node.scrollTop, x: e.clientX, y: e.clientY };
|
|
29
|
-
setStyle((prev) => ({ ...prev, cursor: "grabbing", userSelect: "none" }));
|
|
30
|
-
document.addEventListener("mousemove", mouseMoveHandler);
|
|
31
|
-
document.addEventListener("mouseup", mouseUpHandler);
|
|
32
|
-
};
|
|
33
|
-
node.addEventListener("mousedown", mouseDownHandler);
|
|
34
|
-
return () => {
|
|
35
|
-
node.removeEventListener("mousedown", mouseDownHandler);
|
|
36
|
-
document.removeEventListener("mousedown", mouseMoveHandler);
|
|
37
|
-
document.removeEventListener("mousedown", mouseUpHandler);
|
|
38
|
-
};
|
|
39
|
-
}, [containerRef]);
|
|
40
|
-
return style;
|
|
41
|
-
}
|
package/hooks/useOnMount.d.ts
DELETED
package/hooks/useOnMount.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useOnMount = useOnMount;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
-
*/
|
|
8
|
-
function useOnMount(effect) {
|
|
9
|
-
(0, react_1.useEffect)(() => {
|
|
10
|
-
return effect();
|
|
11
|
-
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
12
|
-
}
|
package/hooks/useOnUnmount.d.ts
DELETED
package/hooks/useOnUnmount.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useOnUnmount = useOnUnmount;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
-
*/
|
|
8
|
-
function useOnUnmount(effect) {
|
|
9
|
-
const effectRef = (0, react_1.useRef)(effect);
|
|
10
|
-
// update the ref each render so if it changed the newest callback will be invoked
|
|
11
|
-
effectRef.current = effect;
|
|
12
|
-
(0, react_1.useEffect)(() => {
|
|
13
|
-
return () => {
|
|
14
|
-
effectRef.current();
|
|
15
|
-
};
|
|
16
|
-
}, []);
|
|
17
|
-
}
|
package/hooks/useOnUpdate.d.ts
DELETED
package/hooks/useOnUpdate.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useOnUpdate = useOnUpdate;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
-
*/
|
|
8
|
-
function useOnUpdate(effect, deps) {
|
|
9
|
-
const firstRun = (0, react_1.useRef)(true);
|
|
10
|
-
(0, react_1.useEffect)(() => {
|
|
11
|
-
if (firstRun.current) {
|
|
12
|
-
firstRun.current = false;
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
return effect();
|
|
16
|
-
}, deps); // eslint-disable-line react-hooks/exhaustive-deps
|
|
17
|
-
}
|
package/hooks/usePagination.d.ts
DELETED
package/hooks/usePagination.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePagination = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const pagination_1 = require("../utils/pagination");
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
-
*/
|
|
9
|
-
const usePagination = (config) => {
|
|
10
|
-
return (0, react_1.useMemo)(() => (0, pagination_1.paginationGenerate)(config),
|
|
11
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
|
-
[
|
|
13
|
-
config.boundaryCount,
|
|
14
|
-
config.siblingCount,
|
|
15
|
-
config.count,
|
|
16
|
-
config.page,
|
|
17
|
-
config.hideNextButton,
|
|
18
|
-
config.hidePrevButton,
|
|
19
|
-
config.showFirstButton,
|
|
20
|
-
config.showLastButton,
|
|
21
|
-
]);
|
|
22
|
-
};
|
|
23
|
-
exports.usePagination = usePagination;
|
package/hooks/usePrevious.d.ts
DELETED
package/hooks/usePrevious.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePrevious = usePrevious;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
-
*/
|
|
8
|
-
function usePrevious(current) {
|
|
9
|
-
const storedValue = (0, react_1.useRef)(current);
|
|
10
|
-
(0, react_1.useEffect)(() => {
|
|
11
|
-
storedValue.current = current;
|
|
12
|
-
});
|
|
13
|
-
return storedValue;
|
|
14
|
-
}
|
package/hooks/useRafState.d.ts
DELETED
package/hooks/useRafState.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useRafState = useRafState;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useOnUnmount_1 = require("./useOnUnmount");
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
-
*/
|
|
9
|
-
function useRafState(initialState) {
|
|
10
|
-
const frame = (0, react_1.useRef)(0);
|
|
11
|
-
const [state, setState] = (0, react_1.useState)(initialState);
|
|
12
|
-
const setRafState = (0, react_1.useCallback)((value) => {
|
|
13
|
-
cancelAnimationFrame(frame.current);
|
|
14
|
-
frame.current = requestAnimationFrame(() => {
|
|
15
|
-
setState(value);
|
|
16
|
-
});
|
|
17
|
-
}, []);
|
|
18
|
-
(0, useOnUnmount_1.useOnUnmount)(() => cancelAnimationFrame(frame.current));
|
|
19
|
-
return [state, setRafState];
|
|
20
|
-
}
|
package/hooks/useTabs.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RefObject } from "react";
|
|
2
|
-
export interface UseTabs<T extends HTMLElement> {
|
|
3
|
-
activeTab?: number;
|
|
4
|
-
id: string;
|
|
5
|
-
tabListRef: RefObject<T>;
|
|
6
|
-
tabsCount: number;
|
|
7
|
-
}
|
|
8
|
-
/** @deprecated Will be removed from @uxf/core package in future versions.
|
|
9
|
-
* Use 'import { Tab } from "@headlessui/react";' instead */
|
|
10
|
-
export declare function useTabs<T extends HTMLElement>({ activeTab, id, tabListRef, tabsCount }: UseTabs<T>): {
|
|
11
|
-
activeTabIndex: number;
|
|
12
|
-
idPrefix: string;
|
|
13
|
-
onTabTitleClick: (index: number) => () => void;
|
|
14
|
-
tabContentIdPrefix: string;
|
|
15
|
-
tabTitleIdPrefix: string;
|
|
16
|
-
};
|
package/hooks/useTabs.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useTabs = useTabs;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useKey_1 = require("./useKey");
|
|
6
|
-
const useOnUpdate_1 = require("./useOnUpdate");
|
|
7
|
-
const LEFT_RIGHT_ARROW_KEYS = (e) => e.key === "ArrowRight" || e.key === "ArrowLeft";
|
|
8
|
-
/** @deprecated Will be removed from @uxf/core package in future versions.
|
|
9
|
-
* Use 'import { Tab } from "@headlessui/react";' instead */
|
|
10
|
-
function useTabs({ activeTab, id, tabListRef, tabsCount }) {
|
|
11
|
-
const [activeTabIndex, setActiveTabIndex] = (0, react_1.useState)(activeTab || 0);
|
|
12
|
-
const idPrefix = `${id}__tabs`;
|
|
13
|
-
const tabTitleIdPrefix = `${idPrefix}__title`;
|
|
14
|
-
const tabContentIdPrefix = `${idPrefix}__content`;
|
|
15
|
-
const onTabTitleClick = (0, react_1.useCallback)((index) => () => setActiveTabIndex(index), []);
|
|
16
|
-
(0, useOnUpdate_1.useOnUpdate)(() => {
|
|
17
|
-
if (activeTab) {
|
|
18
|
-
setActiveTabIndex(activeTab);
|
|
19
|
-
}
|
|
20
|
-
}, [activeTab]);
|
|
21
|
-
const handleArrowKeysNavigation = (0, react_1.useCallback)((e) => {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
setActiveTabIndex((current) => {
|
|
24
|
-
const first = 0;
|
|
25
|
-
const last = tabsCount - 1;
|
|
26
|
-
if (e.key === "ArrowRight") {
|
|
27
|
-
return current < last ? current + 1 : first;
|
|
28
|
-
}
|
|
29
|
-
if (e.key === "ArrowLeft") {
|
|
30
|
-
return current > first ? current - 1 : last;
|
|
31
|
-
}
|
|
32
|
-
return current;
|
|
33
|
-
});
|
|
34
|
-
}, [tabsCount]);
|
|
35
|
-
(0, useKey_1.useKey)(LEFT_RIGHT_ARROW_KEYS, handleArrowKeysNavigation, { targetRef: tabListRef });
|
|
36
|
-
return {
|
|
37
|
-
activeTabIndex,
|
|
38
|
-
idPrefix,
|
|
39
|
-
onTabTitleClick,
|
|
40
|
-
tabContentIdPrefix,
|
|
41
|
-
tabTitleIdPrefix,
|
|
42
|
-
};
|
|
43
|
-
}
|
package/hooks/useWindowScroll.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useWindowScroll = useWindowScroll;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useRafState_1 = require("./useRafState");
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
-
*/
|
|
9
|
-
function useWindowScroll() {
|
|
10
|
-
const [state, setState] = (0, useRafState_1.useRafState)();
|
|
11
|
-
(0, react_1.useEffect)(() => {
|
|
12
|
-
const handler = () => setState({
|
|
13
|
-
x: window.scrollX,
|
|
14
|
-
y: window.scrollY,
|
|
15
|
-
});
|
|
16
|
-
handler();
|
|
17
|
-
window.addEventListener("scroll", handler, {
|
|
18
|
-
capture: false,
|
|
19
|
-
passive: true,
|
|
20
|
-
});
|
|
21
|
-
return () => window.removeEventListener("scroll", handler);
|
|
22
|
-
}, [setState]);
|
|
23
|
-
return state;
|
|
24
|
-
}
|
package/hooks/useWindowSize.d.ts
DELETED
package/hooks/useWindowSize.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useWindowSize = useWindowSize;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useRafState_1 = require("./useRafState");
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
-
*/
|
|
9
|
-
function useWindowSize() {
|
|
10
|
-
const [state, setState] = (0, useRafState_1.useRafState)();
|
|
11
|
-
(0, react_1.useEffect)(() => {
|
|
12
|
-
const handler = () => setState({
|
|
13
|
-
width: window.innerWidth,
|
|
14
|
-
height: window.innerHeight,
|
|
15
|
-
});
|
|
16
|
-
handler();
|
|
17
|
-
window.addEventListener("resize", handler);
|
|
18
|
-
return () => window.removeEventListener("resize", handler);
|
|
19
|
-
}, [setState]);
|
|
20
|
-
return state;
|
|
21
|
-
}
|
package/next/index.d.ts
DELETED
package/next/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queryParamToNumber = exports.queryParamToString = void 0;
|
|
4
|
-
const queryParamToString = (param) => (typeof param === "string" ? param : "");
|
|
5
|
-
exports.queryParamToString = queryParamToString;
|
|
6
|
-
const queryParamToNumber = (param) => typeof param === "string" ? parseInt(param, 10) : 0;
|
|
7
|
-
exports.queryParamToNumber = queryParamToNumber;
|
package/next/query-param.test.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("./index");
|
|
4
|
-
describe("queryParamToString", () => {
|
|
5
|
-
it("should return the string when a string is passed", () => {
|
|
6
|
-
const result = (0, index_1.queryParamToString)("test");
|
|
7
|
-
expect(result).toBe("test");
|
|
8
|
-
});
|
|
9
|
-
it("should return an empty string when undefined is passed", () => {
|
|
10
|
-
const result = (0, index_1.queryParamToString)(undefined);
|
|
11
|
-
expect(result).toBe("");
|
|
12
|
-
});
|
|
13
|
-
it("should return an empty string when an array is passed", () => {
|
|
14
|
-
const result = (0, index_1.queryParamToString)(["test", "jest"]);
|
|
15
|
-
expect(result).toBe("");
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe("queryParamToNumber", () => {
|
|
19
|
-
it("should return the number when a valid string is passed", () => {
|
|
20
|
-
const result = (0, index_1.queryParamToNumber)("42");
|
|
21
|
-
expect(result).toBe(42);
|
|
22
|
-
});
|
|
23
|
-
it("should return 0 when undefined is passed", () => {
|
|
24
|
-
const result = (0, index_1.queryParamToNumber)(undefined);
|
|
25
|
-
expect(result).toBe(0);
|
|
26
|
-
});
|
|
27
|
-
it("should return 0 when an array is passed", () => {
|
|
28
|
-
const result = (0, index_1.queryParamToNumber)(["42", "8"]);
|
|
29
|
-
expect(result).toBe(0);
|
|
30
|
-
});
|
|
31
|
-
it("should return NaN when an invalid number string is passed", () => {
|
|
32
|
-
const result = (0, index_1.queryParamToNumber)("not a number");
|
|
33
|
-
expect(result).toBe(NaN);
|
|
34
|
-
});
|
|
35
|
-
});
|
package/utils/buildArray.test.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const buildArray_1 = require("./buildArray");
|
|
4
|
-
test("buildArray", () => {
|
|
5
|
-
expect((0, buildArray_1.buildArray)()).toStrictEqual([]);
|
|
6
|
-
expect((0, buildArray_1.buildArray)().add("uxf")).toStrictEqual(["uxf"]);
|
|
7
|
-
expect((0, buildArray_1.buildArray)().add("ux").add("fans")).toStrictEqual(["ux", "fans"]);
|
|
8
|
-
expect((0, buildArray_1.buildArray)().add("ux").when(true, "fans")).toStrictEqual(["ux", "fans"]);
|
|
9
|
-
expect((0, buildArray_1.buildArray)().add("ux").when(false, "fans")).toStrictEqual(["ux"]);
|
|
10
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const camelCaseToDash_1 = require("./camelCaseToDash");
|
|
4
|
-
test("camelCaseToDash", () => {
|
|
5
|
-
expect((0, camelCaseToDash_1.camelCaseToDash)("someName")).toBe("some-name");
|
|
6
|
-
expect((0, camelCaseToDash_1.camelCaseToDash)("camelCaseString")).toBe("camel-case-string");
|
|
7
|
-
expect((0, camelCaseToDash_1.camelCaseToDash)("seo")).toBe("seo");
|
|
8
|
-
});
|
package/utils/composeRefs.d.ts
DELETED
package/utils/composeRefs.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.composeRefs = composeRefs;
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use import from @uxf/core-react instead.
|
|
6
|
-
*/
|
|
7
|
-
function composeRefs(...refs) {
|
|
8
|
-
return (value) => refs.forEach((ref) => {
|
|
9
|
-
if (!ref) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (typeof ref === "function") {
|
|
13
|
-
ref(value);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
ref.current = value;
|
|
17
|
-
});
|
|
18
|
-
}
|
package/utils/isServer.test.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const isBrowser_1 = require("./isBrowser");
|
|
4
|
-
const isServer_1 = require("./isServer");
|
|
5
|
-
test("isServer", () => {
|
|
6
|
-
if (isBrowser_1.isBrowser) {
|
|
7
|
-
expect(isServer_1.isServer).toBeFalsy();
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
expect(isServer_1.isServer).toBeTruthy();
|
|
11
|
-
}
|
|
12
|
-
});
|
|
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
|