@fibery/react 3.1.4 → 3.1.6
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/lib/compose-event-handlers.d.ts +1 -3
- package/lib/compose-event-handlers.js +1 -2
- package/lib/create-context.d.ts +1 -3
- package/lib/create-context.js +1 -2
- package/lib/get-ref-value.d.ts +1 -3
- package/lib/get-ref-value.js +1 -2
- package/lib/prevent-default.d.ts +1 -3
- package/lib/prevent-default.js +1 -2
- package/lib/react-node-to-string.d.ts +1 -3
- package/lib/react-node-to-string.js +2 -3
- package/lib/shared-query-client-provider.d.ts +0 -2
- package/lib/shared-query-client-provider.js +1 -2
- package/lib/stop-propagation.d.ts +1 -3
- package/lib/stop-propagation.js +1 -2
- package/lib/use-callback-ref.d.ts +1 -3
- package/lib/use-callback-ref.js +2 -3
- package/lib/use-composed-refs.d.ts +1 -3
- package/lib/use-composed-refs.js +1 -2
- package/lib/use-controllable-state/use-controllable-state.d.ts +1 -3
- package/lib/use-controllable-state/use-controllable-state.js +4 -4
- package/lib/use-drag.d.ts +1 -3
- package/lib/use-drag.js +1 -2
- package/lib/use-focus-outside.d.ts +1 -3
- package/lib/use-focus-outside.js +1 -2
- package/lib/use-is-mounted.d.ts +1 -3
- package/lib/use-is-mounted.js +1 -2
- package/lib/use-pointer-down-outside.d.ts +1 -3
- package/lib/use-pointer-down-outside.js +1 -2
- package/lib/use-previous.d.ts +1 -3
- package/lib/use-previous.js +1 -2
- package/lib/use-resize-observer.d.ts +1 -3
- package/lib/use-resize-observer.js +1 -2
- package/lib/use-restore-focus.d.ts +1 -3
- package/lib/use-restore-focus.js +1 -2
- package/lib/use-size.d.ts +1 -3
- package/lib/use-size.js +1 -2
- package/lib/use-visibility-state.d.ts +1 -3
- package/lib/use-visibility-state.js +1 -2
- package/lib/wrap.d.ts +1 -3
- package/lib/wrap.js +1 -2
- package/package.json +3 -3
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
//#region src/compose-event-handlers.d.ts
|
|
2
1
|
export declare function composeEventHandlers<E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
|
|
3
2
|
checkForDefaultPrevented?: boolean | undefined;
|
|
4
|
-
}): (event: E) => void;
|
|
5
|
-
//#endregion
|
|
3
|
+
}): (event: E) => void;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/compose-event-handlers.ts
|
|
2
2
|
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
3
3
|
return function handleEvent(event) {
|
|
4
4
|
originalEventHandler?.(event);
|
|
5
5
|
if (checkForDefaultPrevented === false || !event.defaultPrevented) ourEventHandler?.(event);
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { composeEventHandlers };
|
package/lib/create-context.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import { Context } from "react";
|
|
3
|
-
|
|
4
|
-
export declare const createContext: <CtxType>(displayName: string, defaultCtx?: CtxType) => [React$1.Provider<CtxType>, () => CtxType, Context<CtxType>];
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const createContext: <CtxType>(displayName: string, defaultCtx?: CtxType) => [React$1.Provider<CtxType>, () => CtxType, Context<CtxType>];
|
package/lib/create-context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
|
-
|
|
2
|
+
// src/create-context.ts
|
|
3
3
|
const createContext = (displayName, defaultCtx) => {
|
|
4
4
|
const Context = React$1.createContext(defaultCtx);
|
|
5
5
|
Context.displayName = displayName;
|
|
@@ -14,5 +14,4 @@ const createContext = (displayName, defaultCtx) => {
|
|
|
14
14
|
Context
|
|
15
15
|
];
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { createContext };
|
package/lib/get-ref-value.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
|
-
//#region src/get-ref-value.d.ts
|
|
3
2
|
/** Returns current value if refOrValue is RefObject otherwise returns itself */
|
|
4
|
-
export declare const getRefValue: <Value>(refOrValue: RefObject<Value | null> | Value | null) => Value | null;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const getRefValue: <Value>(refOrValue: RefObject<Value | null> | Value | null) => Value | null;
|
package/lib/get-ref-value.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/get-ref-value.ts
|
|
2
2
|
/** Returns current value if refOrValue is RefObject otherwise returns itself */
|
|
3
3
|
const getRefValue = (refOrValue) => refOrValue && typeof refOrValue === "object" && "current" in refOrValue ? refOrValue.current : refOrValue;
|
|
4
|
-
//#endregion
|
|
5
4
|
export { getRefValue };
|
package/lib/prevent-default.d.ts
CHANGED
package/lib/prevent-default.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/react-node-to-string.d.ts
|
|
3
2
|
/**
|
|
4
3
|
*
|
|
5
4
|
* Debug util to get text content of react node. Might be useful for logging.
|
|
6
5
|
* Based on https://github.com/fernandopasik/react-children-utilities/blob/main/src/lib/onlyText.ts
|
|
7
6
|
*/
|
|
8
|
-
export declare const reactNodeToString: (node: ReactNode | ReactNode[]) => string;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare const reactNodeToString: (node: ReactNode | ReactNode[]) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Children, isValidElement } from "react";
|
|
2
|
-
|
|
2
|
+
// src/react-node-to-string.ts
|
|
3
3
|
const nodeToString = (child) => {
|
|
4
4
|
if (typeof child === "string" || typeof child === "number") return child.toString();
|
|
5
5
|
return "";
|
|
@@ -13,12 +13,11 @@ const hasChildren = (node) => isValidElement(node) && Boolean(node.props.childre
|
|
|
13
13
|
const reactNodeToString = (node) => {
|
|
14
14
|
if (!(node instanceof Array) && !isValidElement(node)) return nodeToString(node);
|
|
15
15
|
return Children.toArray(node).reduce((text, child) => {
|
|
16
|
-
let newText
|
|
16
|
+
let newText;
|
|
17
17
|
if (hasChildren(child)) newText = reactNodeToString(child.props.children);
|
|
18
18
|
else if (isValidElement(child) && !hasChildren(child)) newText = "";
|
|
19
19
|
else newText = nodeToString(child);
|
|
20
20
|
return text.concat(newText);
|
|
21
21
|
}, "");
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
export { reactNodeToString };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { QueryClient } from "@tanstack/react-query";
|
|
2
|
-
//#region src/shared-query-client-provider.d.ts
|
|
3
2
|
declare const Provider: import("react").Provider<QueryClient | null>, useContext: () => QueryClient | null;
|
|
4
|
-
//#endregion
|
|
5
3
|
export { Provider as SharedQueryClientProvider, useContext as useSharedQueryClient };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createContext } from "./create-context.js";
|
|
2
|
-
|
|
2
|
+
// src/shared-query-client-provider.tsx
|
|
3
3
|
const [Provider, useContext] = createContext("SharedQueryClientProvider", null);
|
|
4
|
-
//#endregion
|
|
5
4
|
export { Provider as SharedQueryClientProvider, useContext as useSharedQueryClient };
|
package/lib/stop-propagation.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region src/use-callback-ref.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Hook to wrap callback in ref
|
|
4
3
|
* so it doesn't trigger re-renders and remains up-to-date
|
|
5
4
|
*
|
|
6
5
|
* Could be replaced with https://github.com/reactjs/rfcs/pull/220 in future
|
|
7
6
|
*/
|
|
8
|
-
export declare const useCallbackRef: <T extends (...args: any[]) => any>(callback?: T) => T;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare const useCallbackRef: <T extends (...args: any[]) => any>(callback?: T) => T;
|
package/lib/use-callback-ref.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
2
|
-
|
|
2
|
+
// src/use-callback-ref.ts
|
|
3
3
|
/**
|
|
4
4
|
* Hook to wrap callback in ref
|
|
5
5
|
* so it doesn't trigger re-renders and remains up-to-date
|
|
@@ -11,7 +11,6 @@ const useCallbackRef = (callback) => {
|
|
|
11
11
|
useLayoutEffect(() => {
|
|
12
12
|
callbackRef.current = callback;
|
|
13
13
|
});
|
|
14
|
-
return useCallback((
|
|
14
|
+
return useCallback((...args) => callbackRef.current?.(...args), []);
|
|
15
15
|
};
|
|
16
|
-
//#endregion
|
|
17
16
|
export { useCallbackRef };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
//#region src/use-composed-refs.d.ts
|
|
3
2
|
export declare const composeRefs: <T>(...refs: Array<React.Ref<T> | undefined>) => (node: T | null) => void;
|
|
4
3
|
/**
|
|
5
4
|
* Hook to compose multiple refs
|
|
6
5
|
* Accepts callback refs and RefObject(s)
|
|
7
6
|
*/
|
|
8
|
-
export declare const useComposedRefs: <T>(...refs: Array<React.Ref<T> | undefined>) => React.RefCallback<T>;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare const useComposedRefs: <T>(...refs: Array<React.Ref<T> | undefined>) => React.RefCallback<T>;
|
package/lib/use-composed-refs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
|
-
|
|
2
|
+
// src/use-composed-refs.ts
|
|
3
3
|
const composeRefs = (...refs) => {
|
|
4
4
|
return function setRefs(node) {
|
|
5
5
|
refs.forEach((ref) => {
|
|
@@ -16,5 +16,4 @@ const composeRefs = (...refs) => {
|
|
|
16
16
|
const useComposedRefs = (...refs) => {
|
|
17
17
|
return useCallback(composeRefs(...refs), refs);
|
|
18
18
|
};
|
|
19
|
-
//#endregion
|
|
20
19
|
export { composeRefs, useComposedRefs };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
//#region src/use-controllable-state/use-controllable-state.d.ts
|
|
3
2
|
type UseControllableStateProps<TState> = {
|
|
4
3
|
/** value to be used in controlled mode */
|
|
5
4
|
value?: TState;
|
|
@@ -12,5 +11,4 @@ type UseControllableStateProps<TState> = {
|
|
|
12
11
|
* React hook to support both controlled/uncontrolled modes
|
|
13
12
|
* @see https://reactjs.org/docs/uncontrolled-components.html
|
|
14
13
|
*/
|
|
15
|
-
export declare const useControllableState: <TState>({ value, defaultValue, onChange }: UseControllableStateProps<TState>) => [TState, Dispatch<SetStateAction<TState>>];
|
|
16
|
-
//#endregion
|
|
14
|
+
export declare const useControllableState: <TState>({ value, defaultValue, onChange }: UseControllableStateProps<TState>) => [TState, Dispatch<SetStateAction<TState>>];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallbackRef } from "../use-callback-ref.js";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
|
|
3
|
+
// src/use-controllable-state/use-controllable-state.ts
|
|
4
4
|
/**
|
|
5
5
|
* React hook to support both controlled/uncontrolled modes
|
|
6
6
|
* @see https://reactjs.org/docs/uncontrolled-components.html
|
|
@@ -12,11 +12,12 @@ const useControllableState = ({ value, defaultValue, onChange }) => {
|
|
|
12
12
|
const state = isControlled ? value : uncontrolledState;
|
|
13
13
|
const prevUncontrolledStateRef = useRef(uncontrolledState);
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
|
|
15
|
+
const previousState = prevUncontrolledStateRef.current;
|
|
16
|
+
if (previousState !== uncontrolledState && !Object.is(previousState, uncontrolledState)) {
|
|
16
17
|
onChangeState(uncontrolledState);
|
|
17
18
|
prevUncontrolledStateRef.current = uncontrolledState;
|
|
18
19
|
}
|
|
19
|
-
});
|
|
20
|
+
}, [uncontrolledState, onChangeState]);
|
|
20
21
|
return [state, useCallback((nextValue) => {
|
|
21
22
|
if (isControlled) {
|
|
22
23
|
const nextState = nextValue instanceof Function ? nextValue(value) : nextValue;
|
|
@@ -31,5 +32,4 @@ const useControllableState = ({ value, defaultValue, onChange }) => {
|
|
|
31
32
|
value
|
|
32
33
|
])];
|
|
33
34
|
};
|
|
34
|
-
//#endregion
|
|
35
35
|
export { useControllableState };
|
package/lib/use-drag.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/use-drag.d.ts
|
|
2
1
|
type Point = {
|
|
3
2
|
x: number;
|
|
4
3
|
y: number;
|
|
@@ -20,5 +19,4 @@ export declare const useDrag: ({ threshold, onDragStart, onDrag, onDragEnd }: {
|
|
|
20
19
|
onPointerDown: (e: React.PointerEvent) => void;
|
|
21
20
|
onPointerMove: (e: React.PointerEvent) => void;
|
|
22
21
|
onPointerUp: (e: React.PointerEvent) => void;
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
22
|
+
};
|
package/lib/use-drag.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef } from "react";
|
|
2
|
-
|
|
2
|
+
// src/use-drag.ts
|
|
3
3
|
/**
|
|
4
4
|
* very simple hook for simple isolated drag-like operations.
|
|
5
5
|
* e.g. dragging border to resize, when you dont need drop targets, auto-scroll, etc.
|
|
@@ -74,5 +74,4 @@ const useDrag = ({ threshold = 0, onDragStart, onDrag, onDragEnd }) => {
|
|
|
74
74
|
onPointerUp
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
-
//#endregion
|
|
78
77
|
export { useDrag };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/use-focus-outside.d.ts
|
|
2
1
|
type OnFocusOutside = (event: FocusEvent) => void;
|
|
3
2
|
/**
|
|
4
3
|
* Hook to react on focus moving outside of react tree including portals
|
|
@@ -8,5 +7,4 @@ type OnFocusOutside = (event: FocusEvent) => void;
|
|
|
8
7
|
export declare const useFocusOutside: (onFocusOutside?: OnFocusOutside) => {
|
|
9
8
|
onFocusCapture: () => void;
|
|
10
9
|
onBlurCapture: () => void;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
10
|
+
};
|
package/lib/use-focus-outside.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallbackRef } from "./use-callback-ref.js";
|
|
2
2
|
import { useLayoutEffect, useRef } from "react";
|
|
3
|
-
|
|
3
|
+
// src/use-focus-outside.ts
|
|
4
4
|
/**
|
|
5
5
|
* Hook to react on focus moving outside of react tree including portals
|
|
6
6
|
*
|
|
@@ -25,5 +25,4 @@ const useFocusOutside = (onFocusOutside) => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
28
|
export { useFocusOutside };
|
package/lib/use-is-mounted.d.ts
CHANGED
package/lib/use-is-mounted.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
2
|
-
|
|
2
|
+
// src/use-is-mounted.ts
|
|
3
3
|
function useIsMounted() {
|
|
4
4
|
const mountedRef = useRef(false);
|
|
5
5
|
const isMounted = useCallback(() => mountedRef.current, []);
|
|
@@ -11,5 +11,4 @@ function useIsMounted() {
|
|
|
11
11
|
}, []);
|
|
12
12
|
return isMounted;
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { useIsMounted };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/use-pointer-down-outside.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Inspired by radix
|
|
4
3
|
* https://github.com/radix-ui/primitives/blob/c31c97274ff357aea99afe6c01c1c8c58b6356e0/packages/react/dismissable-layer/src/DismissableLayer.tsx#L223
|
|
@@ -10,5 +9,4 @@
|
|
|
10
9
|
*/
|
|
11
10
|
export declare function usePointerDownOutside(onPointerDownOutside?: (event: PointerEvent) => void): {
|
|
12
11
|
onPointerDownCapture: () => boolean;
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
12
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallbackRef } from "./use-callback-ref.js";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
|
-
|
|
3
|
+
// src/use-pointer-down-outside.tsx
|
|
4
4
|
/**
|
|
5
5
|
* Inspired by radix
|
|
6
6
|
* https://github.com/radix-ui/primitives/blob/c31c97274ff357aea99afe6c01c1c8c58b6356e0/packages/react/dismissable-layer/src/DismissableLayer.tsx#L223
|
|
@@ -64,5 +64,4 @@ function usePointerDownOutside(onPointerDownOutside) {
|
|
|
64
64
|
}, [handlePointerDownOutside]);
|
|
65
65
|
return { onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true };
|
|
66
66
|
}
|
|
67
|
-
//#endregion
|
|
68
67
|
export { usePointerDownOutside };
|
package/lib/use-previous.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region src/use-previous.d.ts
|
|
2
1
|
export declare function usePrevious<T>(value: T): T | null;
|
|
3
2
|
/**
|
|
4
3
|
* Like {@link usePrevious}, but on the first render it returns the current value
|
|
5
4
|
* instead of `null` — for effects that only want to react to actual changes.
|
|
6
5
|
*/
|
|
7
|
-
export declare function usePreviousValue<T>(value: T): T;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function usePreviousValue<T>(value: T): T;
|
package/lib/use-previous.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
2
|
+
// src/use-previous.ts
|
|
3
3
|
function usePrevious(value) {
|
|
4
4
|
const ref = useRef(null);
|
|
5
5
|
useEffect(() => {
|
|
@@ -18,5 +18,4 @@ function usePreviousValue(value) {
|
|
|
18
18
|
}, [value]);
|
|
19
19
|
return ref.current;
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { usePrevious, usePreviousValue };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
2
|
import { ResizeListenerCallback } from "@fibery/helpers/utils/resize-listener";
|
|
3
|
-
//#region src/use-resize-observer.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* React hook to observe provided element with ResizeObserver
|
|
6
5
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
|
|
@@ -9,5 +8,4 @@ export declare const useResizeObserver: <TargetElement extends HTMLElement>(
|
|
|
9
8
|
/** React ref created by `useRef()` or an HTML element */
|
|
10
9
|
target: RefObject<TargetElement | null> | TargetElement | null,
|
|
11
10
|
/**Invoked with a single `ResizeObserverEntry` any time the `target` resizes */
|
|
12
|
-
callback: ResizeListenerCallback) => ResizeObserver;
|
|
13
|
-
//#endregion
|
|
11
|
+
callback: ResizeListenerCallback) => ResizeObserver;
|
|
@@ -3,7 +3,7 @@ import { useCallbackRef } from "./use-callback-ref.js";
|
|
|
3
3
|
import { useLayoutEffect } from "react";
|
|
4
4
|
import { batchResizeCallbacks, getResizeListener } from "@fibery/helpers/utils/resize-listener";
|
|
5
5
|
import { flushSync } from "react-dom";
|
|
6
|
-
|
|
6
|
+
// src/use-resize-observer.ts
|
|
7
7
|
batchResizeCallbacks(flushSync);
|
|
8
8
|
/**
|
|
9
9
|
* React hook to observe provided element with ResizeObserver
|
|
@@ -30,5 +30,4 @@ const useResizeObserver = (target, callback) => {
|
|
|
30
30
|
]);
|
|
31
31
|
return resizeListener.observer;
|
|
32
32
|
};
|
|
33
|
-
//#endregion
|
|
34
33
|
export { useResizeObserver };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region src/use-restore-focus.d.ts
|
|
2
1
|
export declare const useRestoreFocus: <T extends HTMLElement>() => {
|
|
3
2
|
inputRef: import("react").RefObject<T | null>;
|
|
4
3
|
selectorOpen: boolean;
|
|
5
4
|
onOpen: () => void;
|
|
6
5
|
onClose: () => void;
|
|
7
6
|
onOpenChange: (value: boolean) => void;
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
7
|
+
};
|
package/lib/use-restore-focus.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useRef, useState } from "react";
|
|
2
|
-
|
|
2
|
+
// src/use-restore-focus.ts
|
|
3
3
|
const useRestoreFocus = () => {
|
|
4
4
|
const inputRef = useRef(null);
|
|
5
5
|
const restoreFocus = useCallback(() => {
|
|
@@ -22,5 +22,4 @@ const useRestoreFocus = () => {
|
|
|
22
22
|
}, [onClose, onOpen])
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
//#endregion
|
|
26
25
|
export { useRestoreFocus };
|
package/lib/use-size.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
|
-
//#region src/use-size.d.ts
|
|
3
2
|
type Size = {
|
|
4
3
|
width: number;
|
|
5
4
|
height: number;
|
|
@@ -9,5 +8,4 @@ type Size = {
|
|
|
9
8
|
*/
|
|
10
9
|
export declare const useSize: <TargetElement extends HTMLElement>(
|
|
11
10
|
/** React ref created by `useRef()` or an HTML element */
|
|
12
|
-
target: RefObject<TargetElement | null> | TargetElement | null) => Size;
|
|
13
|
-
//#endregion
|
|
11
|
+
target: RefObject<TargetElement | null> | TargetElement | null) => Size;
|
package/lib/use-size.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRefValue } from "./get-ref-value.js";
|
|
2
2
|
import { useResizeObserver } from "./use-resize-observer.js";
|
|
3
3
|
import { useLayoutEffect, useState } from "react";
|
|
4
|
-
|
|
4
|
+
// src/use-size.ts
|
|
5
5
|
const calculateSize = (element) => {
|
|
6
6
|
const rect = element?.getBoundingClientRect();
|
|
7
7
|
return {
|
|
@@ -33,5 +33,4 @@ const useSize = (target) => {
|
|
|
33
33
|
});
|
|
34
34
|
return size;
|
|
35
35
|
};
|
|
36
|
-
//#endregion
|
|
37
36
|
export { useSize };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
-
|
|
2
|
+
// src/use-visibility-state.ts
|
|
3
3
|
const subscribe = (onChange) => {
|
|
4
4
|
document.addEventListener("visibilitychange", onChange);
|
|
5
5
|
return () => document.removeEventListener("visibilitychange", onChange);
|
|
@@ -8,5 +8,4 @@ const getSnapshot = () => document.visibilityState;
|
|
|
8
8
|
function useVisibilityState() {
|
|
9
9
|
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
10
10
|
}
|
|
11
|
-
//#endregion
|
|
12
11
|
export { useVisibilityState };
|
package/lib/wrap.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSX } from "react";
|
|
2
|
-
//#region src/wrap.d.ts
|
|
3
2
|
type OwnProps<Wrapper extends React.ElementType> = {
|
|
4
3
|
if?: boolean;
|
|
5
4
|
with: Wrapper;
|
|
@@ -23,5 +22,4 @@ type Props<Wrapper extends React.ElementType> = OwnProps<Wrapper> & Omit<React.C
|
|
|
23
22
|
* </Wrap>
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
|
-
export declare const Wrap: <T extends React.ElementType>({ if: condition, with: With, children, className, ...rest }: Props<T>) => JSX.Element;
|
|
27
|
-
//#endregion
|
|
25
|
+
export declare const Wrap: <T extends React.ElementType>({ if: condition, with: With, children, className, ...rest }: Props<T>) => JSX.Element;
|
package/lib/wrap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// src/wrap.tsx
|
|
3
3
|
/**
|
|
4
4
|
* React component to conditionally wrap children
|
|
5
5
|
* WARNING!: use carefully since it causes re-mount of component when condition changes
|
|
@@ -24,5 +24,4 @@ const Wrap = ({ if: condition, with: With, children, className, ...rest }) => {
|
|
|
24
24
|
children
|
|
25
25
|
}) : children;
|
|
26
26
|
};
|
|
27
|
-
//#endregion
|
|
28
27
|
export { Wrap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/react",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fibery/helpers": "
|
|
23
|
-
"@tanstack/react-query": "5.
|
|
22
|
+
"@fibery/helpers": "7.1.0",
|
|
23
|
+
"@tanstack/react-query": "5.107.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^19.0.0",
|