@fibery/react 1.4.3 → 1.4.5

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/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "@fibery/react",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "files": [
7
7
  "src"
8
8
  ],
9
9
  "peerDependencies": {
10
- "react": "^18.2.0"
10
+ "react": "18.2.0"
11
11
  },
12
12
  "dependencies": {
13
13
  "@tanstack/react-query": "5.62.7",
14
- "@fibery/helpers": "1.3.2"
14
+ "@fibery/helpers": "1.3.4"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@testing-library/react": "13.4.0",
18
18
  "@testing-library/react-hooks": "7.0.2",
19
- "@types/jest": "27.0.1",
19
+ "@types/jest": "30.0.0",
20
20
  "@types/react": "18.0.26",
21
21
  "@types/react-dom": "18.0.10",
22
- "jest": "27.5.1",
23
- "jest-junit": "13.0.0",
22
+ "jest": "30.2.0",
23
+ "jest-junit": "16.0.0",
24
24
  "react": "18.2.0",
25
25
  "react-dom": "18.2.0",
26
26
  "react-test-renderer": "18.2.0",
27
- "typescript": "5.8.3",
28
- "@fibery/babel-preset": "7.4.0",
29
- "@fibery/eslint-config": "8.6.1"
27
+ "typescript": "5.9.3",
28
+ "@fibery/eslint-config": "8.6.2",
29
+ "@fibery/babel-preset": "7.4.1"
30
30
  },
31
31
  "jest": {
32
32
  "coveragePathIgnorePatterns": [
@@ -1,9 +1,10 @@
1
1
  import * as React from "react";
2
+ import {Context} from "react";
2
3
 
3
4
  export const createContext = <CtxType>(
4
5
  displayName: string,
5
6
  defaultCtx?: CtxType
6
- ): [React.Provider<CtxType>, () => CtxType] => {
7
+ ): [React.Provider<CtxType>, () => CtxType, Context<CtxType>] => {
7
8
  const Context = React.createContext(defaultCtx as CtxType);
8
9
 
9
10
  Context.displayName = displayName;
@@ -15,5 +16,6 @@ export const createContext = <CtxType>(
15
16
  }
16
17
  return ctx;
17
18
  }
18
- return [Context.Provider, useContext];
19
+
20
+ return [Context.Provider, useContext, Context];
19
21
  };
@@ -1,7 +1,7 @@
1
1
  import {useEffect, useRef} from "react";
2
2
 
3
3
  export function usePrevious<T>(value: T) {
4
- const ref = useRef<T>();
4
+ const ref = useRef<T | null>(null);
5
5
  useEffect(() => {
6
6
  ref.current = value;
7
7
  }, [value]);
@@ -16,6 +16,16 @@ export const useRestoreFocus = <T extends HTMLElement>() => {
16
16
  setSelectorOpen(false);
17
17
  restoreFocus();
18
18
  }, [restoreFocus]);
19
+ const onOpenChange = useCallback(
20
+ (value: boolean) => {
21
+ if (value) {
22
+ onOpen();
23
+ } else {
24
+ onClose();
25
+ }
26
+ },
27
+ [onClose, onOpen]
28
+ );
19
29
 
20
- return {inputRef, selectorOpen, onOpen, onClose};
30
+ return {inputRef, selectorOpen, onOpen, onClose, onOpenChange};
21
31
  };