@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.
Files changed (99) hide show
  1. package/README.md +8 -254
  2. package/index.d.ts +2 -2
  3. package/index.js +2 -2
  4. package/package.json +1 -8
  5. package/utils/build-array.test.js +10 -0
  6. package/utils/camel-case-to-dash.test.js +8 -0
  7. package/utils/format-bytes.d.ts +1 -0
  8. package/utils/format-bytes.js +10 -0
  9. package/utils/format-bytes.test.js +9 -0
  10. package/utils/image.d.ts +0 -22
  11. package/utils/image.js +0 -41
  12. package/utils/{isBrowser.test.js → is-browser.test.js} +3 -3
  13. package/utils/{isServer.js → is-server.js} +2 -2
  14. package/utils/is-server.test.js +12 -0
  15. package/utils/trim-trailing-zeros.test.js +6 -6
  16. package/{Validators/FormValidator.js → validators/form-validator.js} +3 -3
  17. package/validators/form-validator.test.js +45 -0
  18. package/validators/validator.test.js +17 -0
  19. package/Validators/FormValidator.test.js +0 -45
  20. package/Validators/Validator.test.js +0 -17
  21. package/components/hide.d.ts +0 -10
  22. package/components/hide.js +0 -16
  23. package/components/show.d.ts +0 -10
  24. package/components/show.js +0 -16
  25. package/hooks/_useSimulatedButton.d.ts +0 -19
  26. package/hooks/_useSimulatedButton.js +0 -54
  27. package/hooks/useAnchorProps.d.ts +0 -14
  28. package/hooks/useAnchorProps.js +0 -68
  29. package/hooks/useBodyScrollLock.d.ts +0 -12
  30. package/hooks/useBodyScrollLock.js +0 -37
  31. package/hooks/useButtonProps.d.ts +0 -12
  32. package/hooks/useButtonProps.js +0 -61
  33. package/hooks/useClickableProps.d.ts +0 -14
  34. package/hooks/useClickableProps.js +0 -46
  35. package/hooks/useFocusReturn.d.ts +0 -4
  36. package/hooks/useFocusReturn.js +0 -37
  37. package/hooks/useFocusTrap.d.ts +0 -5
  38. package/hooks/useFocusTrap.js +0 -148
  39. package/hooks/useInputFocus.d.ts +0 -10
  40. package/hooks/useInputFocus.js +0 -29
  41. package/hooks/useIsMounted.d.ts +0 -4
  42. package/hooks/useIsMounted.js +0 -12
  43. package/hooks/useIsomorphicLayoutEffect.d.ts +0 -5
  44. package/hooks/useIsomorphicLayoutEffect.js +0 -9
  45. package/hooks/useKey.d.ts +0 -19
  46. package/hooks/useKey.js +0 -30
  47. package/hooks/useLatest.d.ts +0 -4
  48. package/hooks/useLatest.js +0 -12
  49. package/hooks/useMinWindowWidth.d.ts +0 -4
  50. package/hooks/useMinWindowWidth.js +0 -31
  51. package/hooks/useMouseDragToScroll.d.ts +0 -5
  52. package/hooks/useMouseDragToScroll.js +0 -41
  53. package/hooks/useOnMount.d.ts +0 -5
  54. package/hooks/useOnMount.js +0 -12
  55. package/hooks/useOnUnmount.d.ts +0 -5
  56. package/hooks/useOnUnmount.js +0 -17
  57. package/hooks/useOnUpdate.d.ts +0 -5
  58. package/hooks/useOnUpdate.js +0 -17
  59. package/hooks/usePagination.d.ts +0 -5
  60. package/hooks/usePagination.js +0 -23
  61. package/hooks/usePrevious.d.ts +0 -4
  62. package/hooks/usePrevious.js +0 -14
  63. package/hooks/useRafState.d.ts +0 -5
  64. package/hooks/useRafState.js +0 -20
  65. package/hooks/useTabs.d.ts +0 -16
  66. package/hooks/useTabs.js +0 -43
  67. package/hooks/useWindowScroll.d.ts +0 -7
  68. package/hooks/useWindowScroll.js +0 -24
  69. package/hooks/useWindowSize.d.ts +0 -7
  70. package/hooks/useWindowSize.js +0 -21
  71. package/next/index.d.ts +0 -2
  72. package/next/index.js +0 -7
  73. package/next/query-param.test.js +0 -35
  74. package/utils/buildArray.test.js +0 -10
  75. package/utils/camelCaseToDash.test.js +0 -8
  76. package/utils/composeRefs.d.ts +0 -5
  77. package/utils/composeRefs.js +0 -18
  78. package/utils/isServer.test.js +0 -12
  79. /package/utils/{bodyScrollLock.d.ts → body-scroll-lock.d.ts} +0 -0
  80. /package/utils/{bodyScrollLock.js → body-scroll-lock.js} +0 -0
  81. /package/utils/{buildArray.d.ts → build-array.d.ts} +0 -0
  82. /package/utils/{buildArray.js → build-array.js} +0 -0
  83. /package/{Validators/FormValidator.test.d.ts → utils/build-array.test.d.ts} +0 -0
  84. /package/utils/{camelCaseToDash.d.ts → camel-case-to-dash.d.ts} +0 -0
  85. /package/utils/{camelCaseToDash.js → camel-case-to-dash.js} +0 -0
  86. /package/{Validators/Validator.test.d.ts → utils/camel-case-to-dash.test.d.ts} +0 -0
  87. /package/{next/query-param.test.d.ts → utils/format-bytes.test.d.ts} +0 -0
  88. /package/utils/{isBrowser.d.ts → is-browser.d.ts} +0 -0
  89. /package/utils/{isBrowser.js → is-browser.js} +0 -0
  90. /package/utils/{buildArray.test.d.ts → is-browser.test.d.ts} +0 -0
  91. /package/utils/{isServer.d.ts → is-server.d.ts} +0 -0
  92. /package/utils/{camelCaseToDash.test.d.ts → is-server.test.d.ts} +0 -0
  93. /package/utils/{trimTrailingZeros.d.ts → trim-trailing-zeros.d.ts} +0 -0
  94. /package/utils/{trimTrailingZeros.js → trim-trailing-zeros.js} +0 -0
  95. /package/{Validators/FormValidator.d.ts → validators/form-validator.d.ts} +0 -0
  96. /package/{utils/isBrowser.test.d.ts → validators/form-validator.test.d.ts} +0 -0
  97. /package/{Validators/Validator.d.ts → validators/validator.d.ts} +0 -0
  98. /package/{Validators/Validator.js → validators/validator.js} +0 -0
  99. /package/{utils/isServer.test.d.ts → validators/validator.test.d.ts} +0 -0
@@ -1,5 +0,0 @@
1
- import { useEffect } from "react";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare const useIsomorphicLayoutEffect: typeof useEffect;
@@ -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
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated Use import from @uxf/core-react instead.
3
- */
4
- export declare function useLatest<T>(current: T): import("react").MutableRefObject<T>;
@@ -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,4 +0,0 @@
1
- /**
2
- * @deprecated Use import from @uxf/core-react instead.
3
- */
4
- export declare function useMinWindowWidth(minWidth: number, debounce?: number): boolean | undefined;
@@ -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,5 +0,0 @@
1
- import { CSSProperties, RefObject } from "react";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare function useMouseDragToScroll<T extends HTMLElement>(containerRef: RefObject<T>): CSSProperties | undefined;
@@ -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
- }
@@ -1,5 +0,0 @@
1
- import { EffectCallback } from "react";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare function useOnMount(effect: EffectCallback): void;
@@ -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
- }
@@ -1,5 +0,0 @@
1
- import { EffectCallback } from "react";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare function useOnUnmount(effect: EffectCallback): void;
@@ -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
- }
@@ -1,5 +0,0 @@
1
- import { DependencyList, EffectCallback } from "react";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare function useOnUpdate(effect: EffectCallback, deps: DependencyList): void;
@@ -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
- }
@@ -1,5 +0,0 @@
1
- import { PaginationConfig, PaginationItem } from "../utils/pagination";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare const usePagination: (config: PaginationConfig) => PaginationItem[];
@@ -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;
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated Use import from @uxf/core-react instead.
3
- */
4
- export declare function usePrevious<T>(current: T): import("react").MutableRefObject<T>;
@@ -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
- }
@@ -1,5 +0,0 @@
1
- import { Dispatch, SetStateAction } from "react";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare function useRafState<S = undefined>(initialState?: S | (() => S)): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
@@ -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
- }
@@ -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
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * @deprecated Use import from @uxf/core-react instead.
3
- */
4
- export declare function useWindowScroll(): {
5
- x: number;
6
- y: number;
7
- } | undefined;
@@ -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
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * @deprecated Use import from @uxf/core-react instead.
3
- */
4
- export declare function useWindowSize(): {
5
- width: number;
6
- height: number;
7
- } | undefined;
@@ -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
@@ -1,2 +0,0 @@
1
- export declare const queryParamToString: (param?: string | string[]) => string;
2
- export declare const queryParamToNumber: (param?: string | string[]) => number;
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;
@@ -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
- });
@@ -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
- });
@@ -1,5 +0,0 @@
1
- import { Ref, RefCallback } from "react";
2
- /**
3
- * @deprecated Use import from @uxf/core-react instead.
4
- */
5
- export declare function composeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T>;
@@ -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
- }
@@ -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