@uxf/core 11.19.0 → 11.21.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 +1 -1
- package/components/hide.d.ts +3 -0
- package/components/hide.js +3 -0
- package/components/show.d.ts +3 -0
- package/components/show.js +3 -0
- package/hooks/_useSimulatedButton.d.ts +3 -0
- package/hooks/_useSimulatedButton.js +3 -0
- package/hooks/useAnchorProps.d.ts +6 -0
- package/hooks/useAnchorProps.js +3 -0
- package/hooks/useBodyScrollLock.d.ts +6 -0
- package/hooks/useBodyScrollLock.js +3 -0
- package/hooks/useButtonProps.d.ts +6 -0
- package/hooks/useButtonProps.js +3 -0
- package/hooks/useClickableProps.d.ts +6 -0
- package/hooks/useClickableProps.js +3 -0
- package/hooks/useFocusReturn.d.ts +3 -0
- package/hooks/useFocusReturn.js +3 -0
- package/hooks/useFocusTrap.d.ts +3 -0
- package/hooks/useFocusTrap.js +3 -0
- package/hooks/useInputFocus.d.ts +3 -0
- package/hooks/useInputFocus.js +3 -0
- package/hooks/useIsMounted.d.ts +3 -0
- package/hooks/useIsMounted.js +3 -0
- package/hooks/useIsomorphicLayoutEffect.d.ts +3 -0
- package/hooks/useIsomorphicLayoutEffect.js +3 -0
- package/hooks/useKey.d.ts +9 -0
- package/hooks/useKey.js +3 -0
- package/hooks/useLatest.d.ts +3 -0
- package/hooks/useLatest.js +3 -0
- package/hooks/useMinWindowWidth.d.ts +3 -0
- package/hooks/useMinWindowWidth.js +3 -0
- package/hooks/useMouseDragToScroll.d.ts +3 -0
- package/hooks/useMouseDragToScroll.js +3 -0
- package/hooks/useOnMount.d.ts +3 -0
- package/hooks/useOnMount.js +3 -0
- package/hooks/useOnUnmount.d.ts +3 -0
- package/hooks/useOnUnmount.js +3 -0
- package/hooks/useOnUpdate.d.ts +3 -0
- package/hooks/useOnUpdate.js +3 -0
- package/hooks/usePagination.d.ts +3 -0
- package/hooks/usePagination.js +3 -0
- package/hooks/usePrevious.d.ts +3 -0
- package/hooks/usePrevious.js +3 -0
- package/hooks/useRafState.d.ts +3 -0
- package/hooks/useRafState.js +3 -0
- package/hooks/useWindowScroll.d.ts +3 -0
- package/hooks/useWindowScroll.js +3 -0
- package/hooks/useWindowSize.d.ts +3 -0
- package/hooks/useWindowSize.js +3 -0
- package/package.json +1 -1
- package/utils/composeRefs.d.ts +3 -0
- package/utils/composeRefs.js +3 -0
- package/utils/image.d.ts +14 -4
- package/utils/image.js +77 -51
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ cookie.set("cookie-name", "value", /* ttl in seconds (optional) */, /* options (
|
|
|
74
74
|
cookie.delete("cookie-name", /* options (optional) */);
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
## Hooks
|
|
77
|
+
## Hooks - @deprecated - will be moved to @uxf/core-react
|
|
78
78
|
|
|
79
79
|
```tsx
|
|
80
80
|
import { useBodyScrollLock } from "@uxf/core/hooks/useBodyScrollLock";
|
package/components/hide.d.ts
CHANGED
package/components/hide.js
CHANGED
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Hide = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
10
|
+
*/
|
|
8
11
|
function Hide(props) {
|
|
9
12
|
if (props.when) {
|
|
10
13
|
return null;
|
package/components/show.d.ts
CHANGED
package/components/show.js
CHANGED
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Show = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
10
|
+
*/
|
|
8
11
|
function Show(props) {
|
|
9
12
|
if (!props.when) {
|
|
10
13
|
return null;
|
|
@@ -8,6 +8,9 @@ interface Props<T extends HTMLElement> {
|
|
|
8
8
|
onKeyUp?: KeyboardEventHandler<T>;
|
|
9
9
|
submit?: boolean;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
13
|
+
*/
|
|
11
14
|
export declare function _useSimulatedButton<T extends HTMLElement>({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, submit, }: Props<T>): {
|
|
12
15
|
onClick: MouseEventHandler<T>;
|
|
13
16
|
onKeyDown: KeyboardEventHandler<T>;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._useSimulatedButton = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function _useSimulatedButton({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, submit, }) {
|
|
6
9
|
const _onClick = (0, react_1.useCallback)((e) => {
|
|
7
10
|
var _a;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
4
|
+
*/
|
|
2
5
|
export interface UseAnchorProps {
|
|
3
6
|
analyticsCallback?: () => void;
|
|
4
7
|
disabled?: boolean;
|
|
5
8
|
loading?: boolean;
|
|
6
9
|
type?: "submit";
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
13
|
+
*/
|
|
8
14
|
export declare function useAnchorProps<T extends AnchorHTMLAttributes<HTMLAnchorElement>>({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, download, href, hrefLang, loading, media, onClick, onKeyDown, onKeyUp, ping, referrerPolicy, rel, role, tabIndex, target, type, ...restProps }: UseAnchorProps & T): T;
|
package/hooks/useAnchorProps.js
CHANGED
|
@@ -4,6 +4,9 @@ exports.useAnchorProps = void 0;
|
|
|
4
4
|
const classes_1 = require("../constants/classes");
|
|
5
5
|
const cx_1 = require("../utils/cx");
|
|
6
6
|
const _useSimulatedButton_1 = require("./_useSimulatedButton");
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
9
|
+
*/
|
|
7
10
|
function useAnchorProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, download, href, hrefLang, loading, media, onClick, onKeyDown, onKeyUp, ping, referrerPolicy, rel, role, tabIndex, target, type, ...restProps }) {
|
|
8
11
|
const isBusy = loading ? loading : Boolean(ariaBusy);
|
|
9
12
|
const isDisabled = disabled ? disabled : Boolean(ariaDisabled);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
2
|
import { BodyScrollOptions } from "../utils/bodyScrollLock";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
5
|
+
*/
|
|
3
6
|
export interface UseBodyScrollLockOptions extends BodyScrollOptions {
|
|
4
7
|
clearAllOnClose?: boolean;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
11
|
+
*/
|
|
6
12
|
export declare function useBodyScrollLock<T extends HTMLElement>(containerRef: RefObject<T>, isOpen: boolean, { allowTouchMove, clearAllOnClose, reserveScrollBarGap }?: Partial<UseBodyScrollLockOptions>): void;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useBodyScrollLock = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const bodyScrollLock_1 = require("../utils/bodyScrollLock");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
function useBodyScrollLock(containerRef, isOpen, { allowTouchMove, clearAllOnClose, reserveScrollBarGap } = {}) {
|
|
7
10
|
(0, react_1.useEffect)(() => {
|
|
8
11
|
const node = containerRef.current;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
4
|
+
*/
|
|
2
5
|
export interface UseButtonProps {
|
|
3
6
|
analyticsCallback?: () => void;
|
|
4
7
|
loading?: boolean;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
11
|
+
*/
|
|
6
12
|
export declare function useButtonProps<T extends ButtonHTMLAttributes<HTMLButtonElement>>({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, autoFocus, analyticsCallback, className, disabled, formAction, formEncType, formMethod, formNoValidate, formTarget, loading, name, onClick, role, tabIndex, type, value, ...restProps }: UseButtonProps & T): T;
|
package/hooks/useButtonProps.js
CHANGED
|
@@ -4,6 +4,9 @@ exports.useButtonProps = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const classes_1 = require("../constants/classes");
|
|
6
6
|
const cx_1 = require("../utils/cx");
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
9
|
+
*/
|
|
7
10
|
function useButtonProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, autoFocus, analyticsCallback, className, disabled, formAction, formEncType, formMethod, formNoValidate, formTarget, loading, name, onClick, role, tabIndex, type, value, ...restProps }) {
|
|
8
11
|
const isBusy = loading ? loading : Boolean(ariaBusy);
|
|
9
12
|
const isDisabled = disabled ? disabled : Boolean(ariaDisabled);
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
4
|
+
*/
|
|
2
5
|
export interface UseClickableProps {
|
|
3
6
|
analyticsCallback?: () => void;
|
|
4
7
|
disabled?: boolean;
|
|
5
8
|
loading?: boolean;
|
|
6
9
|
type?: "submit";
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
13
|
+
*/
|
|
8
14
|
export declare function useClickableProps<T extends HTMLAttributes<HTMLElement>>({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, loading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }: UseClickableProps & T): T;
|
|
@@ -4,6 +4,9 @@ exports.useClickableProps = void 0;
|
|
|
4
4
|
const classes_1 = require("../constants/classes");
|
|
5
5
|
const cx_1 = require("../utils/cx");
|
|
6
6
|
const _useSimulatedButton_1 = require("./_useSimulatedButton");
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
9
|
+
*/
|
|
7
10
|
function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, loading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }) {
|
|
8
11
|
const isBusy = loading ? loading : Boolean(ariaBusy);
|
|
9
12
|
const isDisabled = disabled ? disabled : Boolean(ariaDisabled);
|
package/hooks/useFocusReturn.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useFocusReturn = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useOnUpdate_1 = require("./useOnUpdate");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
function useFocusReturn(opened, transitionDuration = 0, shouldReturnFocus = true) {
|
|
7
10
|
const lastActiveElement = (0, react_1.useRef)();
|
|
8
11
|
const returnFocus = () => {
|
package/hooks/useFocusTrap.d.ts
CHANGED
package/hooks/useFocusTrap.js
CHANGED
|
@@ -85,6 +85,9 @@ function createAriaHider(containerNode, selector = "body > :not(script)") {
|
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
90
|
+
*/
|
|
88
91
|
function useFocusTrap(active = true) {
|
|
89
92
|
const ref = (0, react_1.useRef)();
|
|
90
93
|
const restoreAria = (0, react_1.useRef)();
|
package/hooks/useInputFocus.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { FocusEventHandler, MouseEventHandler, RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
4
|
+
*/
|
|
2
5
|
export declare function useInputFocus<T extends HTMLInputElement | HTMLTextAreaElement | HTMLElement>(focusRef: RefObject<T>, onBlur?: FocusEventHandler<T>, onFocus?: FocusEventHandler<T>): {
|
|
3
6
|
focused: boolean;
|
|
4
7
|
focus: MouseEventHandler<HTMLElement>;
|
package/hooks/useInputFocus.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useInputFocus = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function useInputFocus(focusRef, onBlur, onFocus) {
|
|
6
9
|
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
7
10
|
const focus = (0, react_1.useCallback)(() => {
|
package/hooks/useIsMounted.d.ts
CHANGED
package/hooks/useIsMounted.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useIsMounted = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function useIsMounted() {
|
|
6
9
|
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
7
10
|
(0, react_1.useEffect)(() => setIsMounted(true), []);
|
|
@@ -3,4 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useIsomorphicLayoutEffect = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const isBrowser_1 = require("../utils/isBrowser");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
exports.useIsomorphicLayoutEffect = isBrowser_1.isBrowser ? react_1.useLayoutEffect : react_1.useEffect;
|
package/hooks/useKey.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
2
|
type KeyPredicate = (e: KeyboardEvent) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
5
|
+
*/
|
|
3
6
|
export type KeyFilter = null | undefined | string | KeyPredicate;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
9
|
+
*/
|
|
4
10
|
export interface UseKeyOptions<T extends HTMLElement> {
|
|
5
11
|
disabled?: boolean;
|
|
6
12
|
targetRef?: RefObject<T>;
|
|
7
13
|
type: "keydown" | "keyup" | "keypress";
|
|
8
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
17
|
+
*/
|
|
9
18
|
export declare function useKey<T extends HTMLElement>(keyFilter: KeyFilter, callback: (e: KeyboardEvent) => void, { disabled, targetRef, type }?: Partial<UseKeyOptions<T>>): void;
|
|
10
19
|
export {};
|
package/hooks/useKey.js
CHANGED
|
@@ -7,6 +7,9 @@ const createKeyPredicate = (keyFilter) => typeof keyFilter === "function"
|
|
|
7
7
|
: typeof keyFilter === "string"
|
|
8
8
|
? (e) => e.key === keyFilter
|
|
9
9
|
: () => false;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
12
|
+
*/
|
|
10
13
|
function useKey(keyFilter, callback, { disabled, targetRef, type = "keydown" } = {}) {
|
|
11
14
|
(0, react_1.useEffect)(() => {
|
|
12
15
|
if (disabled) {
|
package/hooks/useLatest.d.ts
CHANGED
package/hooks/useLatest.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useLatest = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function useLatest(current) {
|
|
6
9
|
const storedValue = (0, react_1.useRef)(current);
|
|
7
10
|
storedValue.current = current;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useMinWindowWidth = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useRafState_1 = require("./useRafState");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
function useMinWindowWidth(minWidth, debounce = 0) {
|
|
7
10
|
const [state, setState] = (0, useRafState_1.useRafState)();
|
|
8
11
|
(0, react_1.useEffect)(() => {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useMouseDragToScroll = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function useMouseDragToScroll(containerRef) {
|
|
6
9
|
const position = (0, react_1.useRef)({ left: 0, top: 0, x: 0, y: 0 });
|
|
7
10
|
const [style, setStyle] = (0, react_1.useState)();
|
package/hooks/useOnMount.d.ts
CHANGED
package/hooks/useOnMount.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOnMount = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function useOnMount(effect) {
|
|
6
9
|
(0, react_1.useEffect)(() => {
|
|
7
10
|
return effect();
|
package/hooks/useOnUnmount.d.ts
CHANGED
package/hooks/useOnUnmount.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOnUnmount = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function useOnUnmount(effect) {
|
|
6
9
|
const effectRef = (0, react_1.useRef)(effect);
|
|
7
10
|
// update the ref each render so if it changed the newest callback will be invoked
|
package/hooks/useOnUpdate.d.ts
CHANGED
package/hooks/useOnUpdate.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOnUpdate = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function useOnUpdate(effect, deps) {
|
|
6
9
|
const firstRun = (0, react_1.useRef)(true);
|
|
7
10
|
(0, react_1.useEffect)(() => {
|
package/hooks/usePagination.d.ts
CHANGED
package/hooks/usePagination.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.usePagination = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const pagination_1 = require("../utils/pagination");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
const usePagination = (config) => {
|
|
7
10
|
return (0, react_1.useMemo)(() => (0, pagination_1.paginationGenerate)(config),
|
|
8
11
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/hooks/usePrevious.d.ts
CHANGED
package/hooks/usePrevious.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.usePrevious = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
7
|
+
*/
|
|
5
8
|
function usePrevious(current) {
|
|
6
9
|
const storedValue = (0, react_1.useRef)(current);
|
|
7
10
|
(0, react_1.useEffect)(() => {
|
package/hooks/useRafState.d.ts
CHANGED
package/hooks/useRafState.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useRafState = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useOnUnmount_1 = require("./useOnUnmount");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
function useRafState(initialState) {
|
|
7
10
|
const frame = (0, react_1.useRef)(0);
|
|
8
11
|
const [state, setState] = (0, react_1.useState)(initialState);
|
package/hooks/useWindowScroll.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useWindowScroll = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useRafState_1 = require("./useRafState");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
function useWindowScroll() {
|
|
7
10
|
const [state, setState] = (0, useRafState_1.useRafState)();
|
|
8
11
|
(0, react_1.useEffect)(() => {
|
package/hooks/useWindowSize.d.ts
CHANGED
package/hooks/useWindowSize.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useWindowSize = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useRafState_1 = require("./useRafState");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
8
|
+
*/
|
|
6
9
|
function useWindowSize() {
|
|
7
10
|
const [state, setState] = (0, useRafState_1.useRafState)();
|
|
8
11
|
(0, react_1.useEffect)(() => {
|
package/package.json
CHANGED
package/utils/composeRefs.d.ts
CHANGED
package/utils/composeRefs.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.composeRefs = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use import from @uxf/core-react instead.
|
|
6
|
+
*/
|
|
4
7
|
function composeRefs(...refs) {
|
|
5
8
|
return (value) => refs.forEach((ref) => {
|
|
6
9
|
if (!ref) {
|
package/utils/image.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ImageSource, ResizerImageProps } from "./resizer";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ImageResponse, ImageSource, ResizerImageProps, StaticImageData } from "./resizer";
|
|
3
3
|
export type Dimension = number | "auto";
|
|
4
4
|
export type Format = "avif" | "webp" | "original";
|
|
5
5
|
export type Quality = number | Record<Format, number>;
|
|
6
|
+
export declare function isSrcString(src: ImageSource): src is string;
|
|
7
|
+
export declare function isSrcImageResponse(src: ImageSource): src is ImageResponse;
|
|
8
|
+
export declare function isSrcStaticImageData(src: ImageSource): src is StaticImageData;
|
|
9
|
+
export declare function parseImgExtension(src: string): string | undefined;
|
|
6
10
|
export declare function getSvgImgUrl(src: ImageSource): string | undefined;
|
|
7
11
|
export declare function getImgQuality(quality: Quality | undefined, format: Format): number | undefined;
|
|
8
12
|
export declare function getImgUniqueIdentifier(src: ImageSource): string | undefined;
|
|
@@ -11,7 +15,10 @@ export declare function getImgElementWidth(src: ImageSource, width: number | und
|
|
|
11
15
|
export type GetImgSrcSetOptions = ResizerImageProps & {
|
|
12
16
|
maxHiDpi?: 3 | 2 | 1;
|
|
13
17
|
};
|
|
14
|
-
export declare function getImgSrcSet(src
|
|
18
|
+
export declare function getImgSrcSet(src: ImageSource, width?: Dimension, height?: Dimension, options?: GetImgSrcSetOptions): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use import from @uxf/ui instead.
|
|
21
|
+
*/
|
|
15
22
|
export type ImageSourcesOptions = Omit<GetImgSrcSetOptions, "quality" | "toFormat"> & {
|
|
16
23
|
isAvifDisabled?: boolean;
|
|
17
24
|
isWebPDisabled?: boolean;
|
|
@@ -25,5 +32,8 @@ interface ImageSourcesProps {
|
|
|
25
32
|
src: ImageSource;
|
|
26
33
|
width: Dimension;
|
|
27
34
|
}
|
|
28
|
-
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use import from @uxf/ui instead.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ImgSources(props: ImageSourcesProps): React.JSX.Element | null;
|
|
29
39
|
export {};
|
package/utils/image.js
CHANGED
|
@@ -3,93 +3,119 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ImgSources = exports.getImgSrcSet = exports.getImgElementWidth = exports.getImgElementHeight = exports.getImgUniqueIdentifier = exports.getImgQuality = exports.getSvgImgUrl = void 0;
|
|
6
|
+
exports.ImgSources = exports.getImgSrcSet = exports.getImgElementWidth = exports.getImgElementHeight = exports.getImgUniqueIdentifier = exports.getImgQuality = exports.getSvgImgUrl = exports.parseImgExtension = exports.isSrcStaticImageData = exports.isSrcImageResponse = exports.isSrcString = void 0;
|
|
7
|
+
const hide_1 = require("@uxf/core-react/components/hide");
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const hide_1 = require("../components/hide");
|
|
9
9
|
const file_1 = require("./file");
|
|
10
|
+
const is_empty_1 = require("./is-empty");
|
|
11
|
+
const is_not_nil_1 = require("./is-not-nil");
|
|
10
12
|
const resizer_1 = require("./resizer");
|
|
11
|
-
function
|
|
12
|
-
return typeof src
|
|
13
|
+
function isSrcString(src) {
|
|
14
|
+
return typeof src === "string";
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
exports.isSrcString = isSrcString;
|
|
17
|
+
function isSrcImageResponse(src) {
|
|
18
|
+
return !isSrcString(src) && "uuid" in src;
|
|
16
19
|
}
|
|
20
|
+
exports.isSrcImageResponse = isSrcImageResponse;
|
|
21
|
+
function isSrcStaticImageData(src) {
|
|
22
|
+
return !isSrcString(src) && "src" in src;
|
|
23
|
+
}
|
|
24
|
+
exports.isSrcStaticImageData = isSrcStaticImageData;
|
|
17
25
|
function parseImgExtension(src) {
|
|
18
26
|
const ext = src.slice(src.lastIndexOf(".") + 1);
|
|
19
27
|
return ext.length > 1 ? ext : undefined;
|
|
20
28
|
}
|
|
29
|
+
exports.parseImgExtension = parseImgExtension;
|
|
30
|
+
function isSvgExtension(src) {
|
|
31
|
+
return parseImgExtension(src) === "svg";
|
|
32
|
+
}
|
|
21
33
|
function getSvgImgUrl(src) {
|
|
22
|
-
if (
|
|
34
|
+
if (isSrcString(src) && isSvgExtension(src)) {
|
|
23
35
|
return src;
|
|
24
36
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return (0, file_1.getFileUrl)(imageResponse);
|
|
37
|
+
if (isSrcImageResponse(src) && isSvgExtension(src.extension)) {
|
|
38
|
+
return (0, file_1.getFileUrl)(src);
|
|
28
39
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return staticImageData.src;
|
|
40
|
+
if (isSrcStaticImageData(src) && isSvgExtension(src.src)) {
|
|
41
|
+
return src.src;
|
|
32
42
|
}
|
|
33
43
|
return undefined;
|
|
34
44
|
}
|
|
35
45
|
exports.getSvgImgUrl = getSvgImgUrl;
|
|
36
46
|
function getImgQuality(quality, format) {
|
|
37
|
-
|
|
47
|
+
if (typeof quality === "number") {
|
|
48
|
+
return quality;
|
|
49
|
+
}
|
|
50
|
+
return quality ? quality[format] : undefined;
|
|
38
51
|
}
|
|
39
52
|
exports.getImgQuality = getImgQuality;
|
|
40
53
|
function getImgUniqueIdentifier(src) {
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
return isSrcString(src)
|
|
55
|
+
? src
|
|
56
|
+
: isSrcImageResponse(src)
|
|
57
|
+
? src.uuid
|
|
58
|
+
: isSrcStaticImageData(src)
|
|
59
|
+
? src.src
|
|
60
|
+
: undefined;
|
|
43
61
|
}
|
|
44
62
|
exports.getImgUniqueIdentifier = getImgUniqueIdentifier;
|
|
45
63
|
function getImgElementHeight(src, width, height) {
|
|
46
64
|
var _a, _b;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
if (isSrcString(src) || (0, is_not_nil_1.isNotNil)(height)) {
|
|
66
|
+
return height;
|
|
67
|
+
}
|
|
68
|
+
const calculatedHeight = Math.floor((((_a = src.height) !== null && _a !== void 0 ? _a : 0) / ((_b = src.width) !== null && _b !== void 0 ? _b : 0)) * (width !== null && width !== void 0 ? width : 0));
|
|
69
|
+
return calculatedHeight === 0 ? undefined : calculatedHeight;
|
|
50
70
|
}
|
|
51
71
|
exports.getImgElementHeight = getImgElementHeight;
|
|
52
72
|
function getImgElementWidth(src, width, height) {
|
|
53
73
|
var _a, _b;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
if (isSrcString(src) || (0, is_not_nil_1.isNotNil)(width)) {
|
|
75
|
+
return width;
|
|
76
|
+
}
|
|
77
|
+
const calculatedWidth = Math.floor(((_a = src.width) !== null && _a !== void 0 ? _a : 0) / ((_b = src.height) !== null && _b !== void 0 ? _b : 0)) * (height !== null && height !== void 0 ? height : 0);
|
|
78
|
+
return calculatedWidth === 0 ? undefined : calculatedWidth;
|
|
57
79
|
}
|
|
58
80
|
exports.getImgElementWidth = getImgElementWidth;
|
|
81
|
+
function isDimensionNumber(value) {
|
|
82
|
+
return typeof value === "number";
|
|
83
|
+
}
|
|
84
|
+
function getDimension(dimension, size) {
|
|
85
|
+
return isDimensionNumber(dimension) ? dimension * size : "auto";
|
|
86
|
+
}
|
|
59
87
|
const HIDPI_SIZES = [3, 2, 1];
|
|
60
88
|
function getImgSrcSet(src, width, height, options = {}) {
|
|
61
89
|
var _a, _b;
|
|
62
|
-
if (!src) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
90
|
let toFormat;
|
|
66
91
|
let h = height !== null && height !== void 0 ? height : "auto";
|
|
67
92
|
let w = width !== null && width !== void 0 ? width : "auto";
|
|
68
|
-
if (
|
|
93
|
+
if (isSrcString(src)) {
|
|
94
|
+
if ((0, is_empty_1.isEmpty)(src)) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
69
97
|
toFormat = parseImgExtension(src);
|
|
70
98
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (!imageResponse.uuid) {
|
|
99
|
+
if (isSrcImageResponse(src)) {
|
|
100
|
+
if ((0, is_empty_1.isEmpty)(src.uuid)) {
|
|
74
101
|
return undefined;
|
|
75
102
|
}
|
|
76
|
-
toFormat = parseImgExtension(
|
|
77
|
-
h = (_a = (h ||
|
|
78
|
-
w = (_b = (w ||
|
|
103
|
+
toFormat = parseImgExtension(src.extension);
|
|
104
|
+
h = (_a = (h || src.height)) !== null && _a !== void 0 ? _a : "auto";
|
|
105
|
+
w = (_b = (w || src.width)) !== null && _b !== void 0 ? _b : "auto";
|
|
79
106
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!staticImageData.src) {
|
|
107
|
+
if (isSrcStaticImageData(src)) {
|
|
108
|
+
if ((0, is_empty_1.isEmpty)(src.src)) {
|
|
83
109
|
return undefined;
|
|
84
110
|
}
|
|
85
|
-
toFormat = parseImgExtension(
|
|
86
|
-
h = h ||
|
|
87
|
-
w = w ||
|
|
111
|
+
toFormat = parseImgExtension(src.src);
|
|
112
|
+
h = h || src.height;
|
|
113
|
+
w = w || src.width;
|
|
88
114
|
}
|
|
89
115
|
const { maxHiDpi, ...restOptions } = options;
|
|
90
|
-
if (
|
|
116
|
+
if (isDimensionNumber(h) || isDimensionNumber(w)) {
|
|
91
117
|
return (maxHiDpi ? HIDPI_SIZES.slice(-maxHiDpi) : HIDPI_SIZES)
|
|
92
|
-
.map((size) => (0, resizer_1.resizerImageUrl)(src,
|
|
118
|
+
.map((size) => (0, resizer_1.resizerImageUrl)(src, getDimension(w, size), getDimension(h, size), {
|
|
93
119
|
toFormat,
|
|
94
120
|
...restOptions,
|
|
95
121
|
}) + (size > 1 ? ` ${size}x` : ""))
|
|
@@ -98,23 +124,23 @@ function getImgSrcSet(src, width, height, options = {}) {
|
|
|
98
124
|
return (0, resizer_1.resizerImageUrl)(src, w, h, { toFormat, ...restOptions });
|
|
99
125
|
}
|
|
100
126
|
exports.getImgSrcSet = getImgSrcSet;
|
|
101
|
-
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated Use import from @uxf/ui instead.
|
|
129
|
+
*/
|
|
130
|
+
function ImgSources(props) {
|
|
102
131
|
var _a, _b, _c, _d, _e;
|
|
103
|
-
if (
|
|
132
|
+
if (isSrcString(props.src) && (0, is_empty_1.isEmpty)(props.src)) {
|
|
104
133
|
return null;
|
|
105
134
|
}
|
|
106
|
-
|
|
107
|
-
if (imageResponse && !imageResponse.uuid) {
|
|
135
|
+
if (isSrcImageResponse(props.src) && (0, is_empty_1.isEmpty)(props.src.uuid)) {
|
|
108
136
|
return null;
|
|
109
137
|
}
|
|
110
|
-
|
|
111
|
-
if (staticImageData && !staticImageData.src) {
|
|
138
|
+
if (isSrcStaticImageData(props.src) && (0, is_empty_1.isEmpty)(props.src.src)) {
|
|
112
139
|
return null;
|
|
113
140
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
141
|
+
const media = (0, is_not_nil_1.isNotNil)(props.breakpoints) && (0, is_not_nil_1.isNotNil)(props.breakpointIndex)
|
|
142
|
+
? `(min-width: ${props.breakpoints[props.breakpointIndex]})`
|
|
143
|
+
: undefined;
|
|
118
144
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
119
145
|
react_1.default.createElement(hide_1.Hide, { when: Boolean((_a = props.options) === null || _a === void 0 ? void 0 : _a.isAvifDisabled) },
|
|
120
146
|
react_1.default.createElement("source", { media: media, srcSet: getImgSrcSet(props.src, props.width, props.height, {
|
|
@@ -132,5 +158,5 @@ const ImgSources = (props) => {
|
|
|
132
158
|
...((_e = props.options) !== null && _e !== void 0 ? _e : {}),
|
|
133
159
|
quality: getImgQuality(props.quality, "original"),
|
|
134
160
|
}) })));
|
|
135
|
-
}
|
|
161
|
+
}
|
|
136
162
|
exports.ImgSources = ImgSources;
|