@kaspernj/api-maker 1.0.420 → 1.0.421
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
|
@@ -17,7 +17,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayoutHeader extends
|
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
setup() {
|
|
20
|
-
const {breakpoint} = useBreakpoint()
|
|
20
|
+
const {name: breakpoint} = useBreakpoint()
|
|
21
21
|
|
|
22
22
|
this.headerActionsRef = useRef()
|
|
23
23
|
this.setInstance({breakpoint})
|
package/src/table/table.jsx
CHANGED
|
@@ -98,7 +98,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
98
98
|
|
|
99
99
|
setup() {
|
|
100
100
|
const {t} = useI18n({namespace: "js.api_maker.table"})
|
|
101
|
-
const {breakpoint} = useBreakpoint()
|
|
101
|
+
const {name: breakpoint} = useBreakpoint()
|
|
102
102
|
const queryParams = useQueryParams()
|
|
103
103
|
|
|
104
104
|
this.setInstance({
|
package/src/use-breakpoint.mjs
CHANGED
|
@@ -1,44 +1,52 @@
|
|
|
1
1
|
import {useCallback, useLayoutEffect} from "react"
|
|
2
2
|
import apiMakerConfig from "@kaspernj/api-maker/src/config.mjs"
|
|
3
|
+
import {Dimensions} from "react-native"
|
|
3
4
|
import useShape from "set-state-compare/src/use-shape.js"
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const calculateBreakPoint = useCallback(() => {
|
|
9
|
-
const windowWidth = window.innerWidth
|
|
6
|
+
const calculateBreakPoint = (window) => {
|
|
7
|
+
const windowWidth = window.width
|
|
8
|
+
const result = {}
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
for (const breakpointData of apiMakerConfig.getBreakPoints()) {
|
|
11
|
+
const breakpoint = breakpointData[0]
|
|
12
|
+
const width = breakpointData[1]
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
if (!result.name && windowWidth >= width) {
|
|
15
|
+
result.name = breakpoint
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
result[`${breakpoint}Down`] = !result.name
|
|
19
|
+
result[`${breakpoint}Up`] = Boolean(result.name)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (result.name) {
|
|
23
|
+
return result
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
throw new Error(`Couldn't not find breakpoint from window width: ${windowWidth}`)
|
|
27
|
+
}
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
const useBreakpoint = () => {
|
|
30
|
+
const s = useShape()
|
|
31
|
+
const onCalled = useCallback(({window}) => {
|
|
32
|
+
const breakpoint = calculateBreakPoint(window)
|
|
23
33
|
|
|
24
|
-
if (breakpoint != s.s.breakpoint) {
|
|
34
|
+
if (breakpoint.name != s.s.breakpoint.name) {
|
|
25
35
|
s.set({breakpoint})
|
|
26
36
|
}
|
|
27
37
|
}, [])
|
|
28
38
|
|
|
29
39
|
s.useStates({
|
|
30
|
-
breakpoint: () => calculateBreakPoint()
|
|
40
|
+
breakpoint: () => calculateBreakPoint(Dimensions.get("window"))
|
|
31
41
|
})
|
|
32
42
|
|
|
33
43
|
useLayoutEffect(() => {
|
|
34
|
-
|
|
44
|
+
const subscription = Dimensions.addEventListener("change", onCalled)
|
|
35
45
|
|
|
36
|
-
return () =>
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}, [])
|
|
46
|
+
return () => subscription?.remove()
|
|
47
|
+
})
|
|
40
48
|
|
|
41
|
-
return
|
|
49
|
+
return s.s.breakpoint
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
export default useBreakpoint
|