@fibery/react 2.0.10 → 3.1.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/lib/compose-event-handlers.d.ts +2 -3
- package/lib/create-context.d.ts +2 -3
- package/lib/get-ref-value.d.ts +2 -3
- package/lib/prevent-default.d.ts +2 -3
- package/lib/react-node-to-string.d.ts +2 -3
- package/lib/stop-propagation.d.ts +2 -3
- package/lib/use-callback-ref.d.ts +2 -3
- package/lib/use-composed-refs.d.ts +3 -4
- package/lib/use-controllable-state/index.js +1 -2
- package/lib/use-controllable-state/use-controllable-state.d.ts +2 -3
- package/lib/use-drag.d.ts +3 -4
- package/lib/use-focus-outside.d.ts +2 -3
- package/lib/use-is-mounted.d.ts +2 -3
- package/lib/use-pointer-down-outside.d.ts +2 -3
- package/lib/use-previous.d.ts +3 -4
- package/lib/use-resize-observer.d.ts +3 -4
- package/lib/use-restore-focus.d.ts +3 -4
- package/lib/use-size.d.ts +3 -4
- package/lib/use-visibility-state.d.ts +3 -0
- package/lib/use-visibility-state.js +12 -0
- package/lib/wrap.d.ts +3 -3
- package/package.json +5 -5
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//#region src/compose-event-handlers.d.ts
|
|
2
|
-
declare function composeEventHandlers<E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
|
|
2
|
+
export declare function composeEventHandlers<E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
|
|
3
3
|
checkForDefaultPrevented?: boolean | undefined;
|
|
4
4
|
}): (event: E) => void;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { composeEventHandlers };
|
|
5
|
+
//#endregion
|
package/lib/create-context.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import { Context } from "react";
|
|
3
3
|
//#region src/create-context.d.ts
|
|
4
|
-
declare const createContext: <CtxType>(displayName: string, defaultCtx?: CtxType) => [React$1.Provider<CtxType>, () => CtxType, Context<CtxType>];
|
|
5
|
-
//#endregion
|
|
6
|
-
export { createContext };
|
|
4
|
+
export declare const createContext: <CtxType>(displayName: string, defaultCtx?: CtxType) => [React$1.Provider<CtxType>, () => CtxType, Context<CtxType>];
|
|
5
|
+
//#endregion
|
package/lib/get-ref-value.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
2
|
//#region src/get-ref-value.d.ts
|
|
3
3
|
/** Returns current value if refOrValue is RefObject otherwise returns itself */
|
|
4
|
-
declare const getRefValue: <Value>(refOrValue: RefObject<Value> | Value | null) => Value | null;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { getRefValue };
|
|
4
|
+
export declare const getRefValue: <Value>(refOrValue: RefObject<Value | null> | Value | null) => Value | null;
|
|
5
|
+
//#endregion
|
package/lib/prevent-default.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//#region src/prevent-default.d.ts
|
|
2
|
-
declare const preventDefault: <Event extends {
|
|
2
|
+
export declare const preventDefault: <Event extends {
|
|
3
3
|
preventDefault: () => void;
|
|
4
4
|
} = React.SyntheticEvent>(e: Event) => void;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { preventDefault };
|
|
5
|
+
//#endregion
|
|
@@ -5,6 +5,5 @@ import { ReactNode } from "react";
|
|
|
5
5
|
* Debug util to get text content of react node. Might be useful for logging.
|
|
6
6
|
* Based on https://github.com/fernandopasik/react-children-utilities/blob/main/src/lib/onlyText.ts
|
|
7
7
|
*/
|
|
8
|
-
declare const reactNodeToString: (node: ReactNode | ReactNode[]) => string;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { reactNodeToString };
|
|
8
|
+
export declare const reactNodeToString: (node: ReactNode | ReactNode[]) => string;
|
|
9
|
+
//#endregion
|
|
@@ -5,6 +5,5 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Could be replaced with https://github.com/reactjs/rfcs/pull/220 in future
|
|
7
7
|
*/
|
|
8
|
-
declare const useCallbackRef: <T extends (...args: any[]) => any>(callback?: T) => T;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { useCallbackRef };
|
|
8
|
+
export declare const useCallbackRef: <T extends (...args: any[]) => any>(callback?: T) => T;
|
|
9
|
+
//#endregion
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
//#region src/use-composed-refs.d.ts
|
|
3
|
-
declare const composeRefs: <T>(...refs: Array<React.Ref<T> | undefined>) => (node: T) => void;
|
|
3
|
+
export declare const composeRefs: <T>(...refs: Array<React.Ref<T> | undefined>) => (node: T | null) => void;
|
|
4
4
|
/**
|
|
5
5
|
* Hook to compose multiple refs
|
|
6
6
|
* Accepts callback refs and RefObject(s)
|
|
7
7
|
*/
|
|
8
|
-
declare const useComposedRefs: <T>(...refs: Array<React.Ref<T> | undefined>) => React.RefCallback<T>;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { composeRefs, useComposedRefs };
|
|
8
|
+
export declare const useComposedRefs: <T>(...refs: Array<React.Ref<T> | undefined>) => React.RefCallback<T>;
|
|
9
|
+
//#endregion
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { useControllableState };
|
|
1
|
+
export { useControllableState } from "./use-controllable-state.js";
|
|
@@ -12,6 +12,5 @@ type UseControllableStateProps<TState> = {
|
|
|
12
12
|
* React hook to support both controlled/uncontrolled modes
|
|
13
13
|
* @see https://reactjs.org/docs/uncontrolled-components.html
|
|
14
14
|
*/
|
|
15
|
-
declare const useControllableState: <TState>({ value, defaultValue, onChange }: UseControllableStateProps<TState>) => [TState, Dispatch<SetStateAction<TState>>];
|
|
16
|
-
//#endregion
|
|
17
|
-
export { useControllableState };
|
|
15
|
+
export declare const useControllableState: <TState>({ value, defaultValue, onChange }: UseControllableStateProps<TState>) => [TState, Dispatch<SetStateAction<TState>>];
|
|
16
|
+
//#endregion
|
package/lib/use-drag.d.ts
CHANGED
|
@@ -9,17 +9,16 @@ type Point = {
|
|
|
9
9
|
*
|
|
10
10
|
* For complex operations you most likely want to use atlaskit/pragmatic-drag-and-drop
|
|
11
11
|
*/
|
|
12
|
-
declare const useDrag: ({ threshold, onDragStart, onDrag, onDragEnd }: {
|
|
12
|
+
export declare const useDrag: ({ threshold, onDragStart, onDrag, onDragEnd }: {
|
|
13
13
|
/** Minimum movement before drag starts */
|
|
14
14
|
threshold?: number;
|
|
15
15
|
onDragStart?: () => void;
|
|
16
16
|
onDrag?: (translation: Point) => void;
|
|
17
17
|
onDragEnd?: (translation: Point) => void;
|
|
18
18
|
}) => {
|
|
19
|
-
ref: import("react").RefObject<HTMLDivElement>;
|
|
19
|
+
ref: import("react").RefObject<HTMLDivElement | null>;
|
|
20
20
|
onPointerDown: (e: React.PointerEvent) => void;
|
|
21
21
|
onPointerMove: (e: React.PointerEvent) => void;
|
|
22
22
|
onPointerUp: (e: React.PointerEvent) => void;
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { useDrag };
|
|
24
|
+
//#endregion
|
|
@@ -5,9 +5,8 @@ type OnFocusOutside = (event: FocusEvent) => void;
|
|
|
5
5
|
*
|
|
6
6
|
* https://github.com/facebook/react/issues/19637#issuecomment-850412650
|
|
7
7
|
*/
|
|
8
|
-
declare const useFocusOutside: (onFocusOutside?: OnFocusOutside) => {
|
|
8
|
+
export declare const useFocusOutside: (onFocusOutside?: OnFocusOutside) => {
|
|
9
9
|
onFocusCapture: () => void;
|
|
10
10
|
onBlurCapture: () => void;
|
|
11
11
|
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { useFocusOutside };
|
|
12
|
+
//#endregion
|
package/lib/use-is-mounted.d.ts
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
* to mimic layer dismissing behaviour present in OS.
|
|
9
9
|
* Returns props to pass to the node we want to check for outside events.
|
|
10
10
|
*/
|
|
11
|
-
declare function usePointerDownOutside(onPointerDownOutside?: (event: PointerEvent) => void): {
|
|
11
|
+
export declare function usePointerDownOutside(onPointerDownOutside?: (event: PointerEvent) => void): {
|
|
12
12
|
onPointerDownCapture: () => boolean;
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { usePointerDownOutside };
|
|
14
|
+
//#endregion
|
package/lib/use-previous.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
//#region src/use-previous.d.ts
|
|
2
|
-
declare function usePrevious<T>(value: T): T | null;
|
|
2
|
+
export declare function usePrevious<T>(value: T): T | null;
|
|
3
3
|
/**
|
|
4
4
|
* Like {@link usePrevious}, but on the first render it returns the current value
|
|
5
5
|
* instead of `null` — for effects that only want to react to actual changes.
|
|
6
6
|
*/
|
|
7
|
-
declare function usePreviousValue<T>(value: T): T;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { usePrevious, usePreviousValue };
|
|
7
|
+
export declare function usePreviousValue<T>(value: T): T;
|
|
8
|
+
//#endregion
|
|
@@ -5,10 +5,9 @@ import { ResizeListenerCallback } from "@fibery/helpers/utils/resize-listener";
|
|
|
5
5
|
* React hook to observe provided element with ResizeObserver
|
|
6
6
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
|
|
7
7
|
*/
|
|
8
|
-
declare const useResizeObserver: <TargetElement extends HTMLElement>(
|
|
8
|
+
export declare const useResizeObserver: <TargetElement extends HTMLElement>(
|
|
9
9
|
/** React ref created by `useRef()` or an HTML element */
|
|
10
|
-
target: RefObject<TargetElement> | TargetElement | null,
|
|
10
|
+
target: RefObject<TargetElement | null> | TargetElement | null,
|
|
11
11
|
/**Invoked with a single `ResizeObserverEntry` any time the `target` resizes */
|
|
12
12
|
callback: ResizeListenerCallback) => ResizeObserver;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { useResizeObserver };
|
|
13
|
+
//#endregion
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
//#region src/use-restore-focus.d.ts
|
|
2
|
-
declare const useRestoreFocus: <T extends HTMLElement>() => {
|
|
3
|
-
inputRef: import("react").RefObject<T>;
|
|
2
|
+
export declare const useRestoreFocus: <T extends HTMLElement>() => {
|
|
3
|
+
inputRef: import("react").RefObject<T | null>;
|
|
4
4
|
selectorOpen: boolean;
|
|
5
5
|
onOpen: () => void;
|
|
6
6
|
onClose: () => void;
|
|
7
7
|
onOpenChange: (value: boolean) => void;
|
|
8
8
|
};
|
|
9
|
-
//#endregion
|
|
10
|
-
export { useRestoreFocus };
|
|
9
|
+
//#endregion
|
package/lib/use-size.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ type Size = {
|
|
|
7
7
|
/**
|
|
8
8
|
* React hook for watching size changes of HTML elements
|
|
9
9
|
*/
|
|
10
|
-
declare const useSize: <TargetElement extends HTMLElement>(
|
|
10
|
+
export declare const useSize: <TargetElement extends HTMLElement>(
|
|
11
11
|
/** React ref created by `useRef()` or an HTML element */
|
|
12
|
-
target: RefObject<TargetElement> | TargetElement | null) => Size;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { useSize };
|
|
12
|
+
target: RefObject<TargetElement | null> | TargetElement | null) => Size;
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
//#region src/use-visibility-state.ts
|
|
3
|
+
const subscribe = (onChange) => {
|
|
4
|
+
document.addEventListener("visibilitychange", onChange);
|
|
5
|
+
return () => document.removeEventListener("visibilitychange", onChange);
|
|
6
|
+
};
|
|
7
|
+
const getSnapshot = () => document.visibilityState;
|
|
8
|
+
function useVisibilityState() {
|
|
9
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { useVisibilityState };
|
package/lib/wrap.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JSX } from "react";
|
|
1
2
|
//#region src/wrap.d.ts
|
|
2
3
|
type OwnProps<Wrapper extends React.ElementType> = {
|
|
3
4
|
if?: boolean;
|
|
@@ -22,6 +23,5 @@ type Props<Wrapper extends React.ElementType> = OwnProps<Wrapper> & Omit<React.C
|
|
|
22
23
|
* </Wrap>
|
|
23
24
|
* ```
|
|
24
25
|
*/
|
|
25
|
-
declare const Wrap: <T extends React.ElementType>({ if: condition, with: With, children, className, ...rest }: Props<T>) => JSX.Element;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { Wrap };
|
|
26
|
+
export declare const Wrap: <T extends React.ElementType>({ if: condition, with: With, children, className, ...rest }: Props<T>) => JSX.Element;
|
|
27
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
22
|
+
"@fibery/helpers": "5.0.0",
|
|
23
|
+
"@tanstack/react-query": "5.104.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"react": "
|
|
27
|
-
"react-dom": "
|
|
26
|
+
"react": "^19.0.0",
|
|
27
|
+
"react-dom": "^19.0.0"
|
|
28
28
|
}
|
|
29
29
|
}
|