@websolutespa/bom-mixer-hooks 1.7.1 → 1.7.3
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +5 -4
- package/dist/index.mjs +5 -4
- package/package.json +7 -7
- package/src/useBreakpoint/useBreakpoint.ts +10 -8
- package/src/useCollectionApi/useCollectionApi.ts +2 -1
- package/src/useIntersectionObserver/useIntersectionObserver.ts +1 -1
- package/src/useLazyModules/useLazyModules.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-hooks
|
|
2
2
|
|
|
3
|
+
## 1.7.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: useIntersectionObserver
|
|
8
|
+
|
|
9
|
+
## 1.7.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updating: dependencies
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @websolutespa/bom-mixer-models@1.7.2
|
|
16
|
+
- @websolutespa/bom-mixer-store@1.7.3
|
|
17
|
+
- @websolutespa/bom-core@1.7.3
|
|
18
|
+
|
|
3
19
|
## 1.7.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { RefObject, Dispatch, SetStateAction, MutableRefObject, ComponentProps, useEffect } from 'react';
|
|
2
|
+
import react__default, { RefObject, Dispatch, SetStateAction, CSSProperties, MutableRefObject, ComponentProps, useEffect } from 'react';
|
|
3
3
|
import { ApiRequestOptions } from '@websolutespa/bom-mixer-store';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import * as zustand_middleware from 'zustand/middleware';
|
|
@@ -42,7 +42,8 @@ type Breakpoint = {
|
|
|
42
42
|
min: number;
|
|
43
43
|
max: number;
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
type MediaQuery = Record<BreakpointType, CSSProperties['width']>;
|
|
46
|
+
declare function useBreakpoint(mediaQuery?: MediaQuery): Breakpoint;
|
|
46
47
|
|
|
47
48
|
type CartProps = {
|
|
48
49
|
hydrated: boolean;
|
|
@@ -300,7 +301,7 @@ declare function useIdle(delay?: number, immediate?: boolean): boolean;
|
|
|
300
301
|
|
|
301
302
|
declare function useInfiniteLoader<T = any>(items: T[], perPage?: number, delayInMs?: number): [T[], () => void, boolean];
|
|
302
303
|
|
|
303
|
-
declare function useIntersectionObserver(ref: MutableRefObject<Node |
|
|
304
|
+
declare function useIntersectionObserver(ref: MutableRefObject<Node | null>, options?: IntersectionObserverInit): boolean;
|
|
304
305
|
declare function isElement(node?: Node): node is Element;
|
|
305
306
|
|
|
306
307
|
declare const useIsomorphicLayoutEffect: typeof useEffect;
|
package/dist/index.js
CHANGED
|
@@ -401,14 +401,15 @@ function useWindowSize() {
|
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
// src/useBreakpoint/useBreakpoint.ts
|
|
404
|
-
function useBreakpoint() {
|
|
404
|
+
function useBreakpoint(mediaQuery) {
|
|
405
405
|
const windowSize = useWindowSize();
|
|
406
406
|
const theme = (0, import_react7.useContext)(import_styled_components.ThemeContext);
|
|
407
|
-
if (!theme) {
|
|
407
|
+
if (!theme && !mediaQuery) {
|
|
408
408
|
throw new Error("useBreakpoint must be used within ThemeProvider");
|
|
409
409
|
}
|
|
410
|
-
const
|
|
411
|
-
const
|
|
410
|
+
const queries = mediaQuery || theme.mediaQuery;
|
|
411
|
+
const breakpoints = Object.keys(queries);
|
|
412
|
+
const values = Object.values(queries).map((x) => parseInt(String(x)));
|
|
412
413
|
const breakpoint = (0, import_react7.useMemo)(() => {
|
|
413
414
|
const breakpoint2 = values.reduce((p, c, i) => {
|
|
414
415
|
if (c < windowSize.width) {
|
package/dist/index.mjs
CHANGED
|
@@ -257,14 +257,15 @@ function useWindowSize() {
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
// src/useBreakpoint/useBreakpoint.ts
|
|
260
|
-
function useBreakpoint() {
|
|
260
|
+
function useBreakpoint(mediaQuery) {
|
|
261
261
|
const windowSize = useWindowSize();
|
|
262
262
|
const theme = useContext2(ThemeContext);
|
|
263
|
-
if (!theme) {
|
|
263
|
+
if (!theme && !mediaQuery) {
|
|
264
264
|
throw new Error("useBreakpoint must be used within ThemeProvider");
|
|
265
265
|
}
|
|
266
|
-
const
|
|
267
|
-
const
|
|
266
|
+
const queries = mediaQuery || theme.mediaQuery;
|
|
267
|
+
const breakpoints = Object.keys(queries);
|
|
268
|
+
const values = Object.values(queries).map((x) => parseInt(String(x)));
|
|
268
269
|
const breakpoint = useMemo(() => {
|
|
269
270
|
const breakpoint2 = values.reduce((p, c, i) => {
|
|
270
271
|
if (c < windowSize.width) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/bom-mixer-hooks",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "Mixer Hooks module of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bom",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@websolutespa/bom-mixer-store": "*",
|
|
30
30
|
"framer-motion": ">= 7.2.1",
|
|
31
31
|
"iron-session": ">= 6.2.1",
|
|
32
|
-
"next": ">=
|
|
32
|
+
"next": ">= 14.1.4",
|
|
33
33
|
"react-dom": ">= 18.2.0",
|
|
34
34
|
"react": ">= 18.2.0",
|
|
35
35
|
"styled-components": ">= 5.3.11 <6.x.x",
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
"zustand": ">= 4.4.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react": "^18.2.
|
|
41
|
-
"@types/react-dom": "^18.2.
|
|
40
|
+
"@types/react": "^18.2.75",
|
|
41
|
+
"@types/react-dom": "^18.2.24",
|
|
42
42
|
"@types/styled-components": "^5.1.26",
|
|
43
43
|
"@websolutespa/bom-cli": "*",
|
|
44
44
|
"@websolutespa/test": "*",
|
|
45
45
|
"@websolutespa/tsconfig": "*",
|
|
46
|
-
"eslint": "^
|
|
46
|
+
"eslint": "^9.0.0",
|
|
47
47
|
"eslint-config-websolute": "*",
|
|
48
48
|
"npm-run-all": "^4.1.5",
|
|
49
49
|
"raw-loader": "^4.0.2",
|
|
50
50
|
"react": "^18.2.0",
|
|
51
51
|
"styled-components": "^5.3.11",
|
|
52
|
-
"ts-node": "^10.9.
|
|
52
|
+
"ts-node": "^10.9.2",
|
|
53
53
|
"tsup": "^6.7.0",
|
|
54
|
-
"typescript": "^5.
|
|
54
|
+
"typescript": "^5.4.5"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useMemo } from 'react';
|
|
1
|
+
import { CSSProperties, useContext, useMemo } from 'react';
|
|
2
2
|
import { ThemeContext } from 'styled-components';
|
|
3
3
|
import { useWindowSize } from '../useWindowSize/useWindowSize';
|
|
4
4
|
|
|
@@ -10,19 +10,21 @@ type Breakpoint = {
|
|
|
10
10
|
max: number;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
// todo
|
|
15
|
-
const windowSize = useWindowSize();
|
|
13
|
+
type MediaQuery = Record<BreakpointType, CSSProperties['width']>;
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
export function useBreakpoint(mediaQuery?: MediaQuery): Breakpoint {
|
|
16
|
+
const windowSize = useWindowSize();
|
|
18
17
|
|
|
19
18
|
const theme = useContext(ThemeContext);
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
if (!theme && !mediaQuery) {
|
|
21
21
|
throw new Error('useBreakpoint must be used within ThemeProvider');
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const queries: MediaQuery = mediaQuery || theme.mediaQuery;
|
|
25
|
+
|
|
26
|
+
const breakpoints: BreakpointType[] = Object.keys(queries) as BreakpointType[];
|
|
27
|
+
const values: number[] = Object.values(queries).map(x => parseInt(String(x)));
|
|
26
28
|
|
|
27
29
|
const breakpoint = useMemo(() => {
|
|
28
30
|
const breakpoint = values.reduce((p, c, i) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { QueryParams, qsSerialize } from '@websolutespa/bom-core';
|
|
2
|
-
import { useApiFetch, useLayout } from '@websolutespa/bom-mixer-hooks';
|
|
3
2
|
import { ApiRequestOptions } from '@websolutespa/bom-mixer-store';
|
|
3
|
+
import { useApiFetch } from '../useApi/useApi';
|
|
4
|
+
import { useLayout } from '../useLayout/useLayout';
|
|
4
5
|
import { localCollectionDelete, localCollectionGet, localCollectionPatch, localCollectionPost, localCollectionPut } from './local.collection';
|
|
5
6
|
|
|
6
7
|
type CollectionApi = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MutableRefObject, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
export function useIntersectionObserver(
|
|
4
|
-
ref: MutableRefObject<Node |
|
|
4
|
+
ref: MutableRefObject<Node | null>,
|
|
5
5
|
options: IntersectionObserverInit = {}): boolean {
|
|
6
6
|
const {
|
|
7
7
|
threshold = 1,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createGenericContext } from '@websolutespa/bom-mixer-hooks';
|
|
2
1
|
import { ILazyModules } from '@websolutespa/bom-mixer-models';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { createGenericContext } from '../useGenericContext/useGenericContext';
|
|
4
4
|
|
|
5
5
|
export type ILazyModulesContext = ILazyModules;
|
|
6
6
|
|