@tamagui/use-window-dimensions 1.21.4 → 1.22.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/dist/cjs/index.js +12 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +12 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +12 -7
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +15 -11
- package/types/index.d.ts +4 -1
- package/types/index.d.ts.map +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var src_exports = {};
|
|
20
20
|
__export(src_exports, {
|
|
21
|
+
configureInitialWindowDimensions: () => configureInitialWindowDimensions,
|
|
21
22
|
useWindowDimensions: () => useWindowDimensions
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -30,18 +31,25 @@ const initialValue = {
|
|
|
30
31
|
width: 600,
|
|
31
32
|
scale: 1
|
|
32
33
|
};
|
|
33
|
-
function
|
|
34
|
+
function configureInitialWindowDimensions(next) {
|
|
35
|
+
Object.assign(initialValue, next);
|
|
36
|
+
}
|
|
37
|
+
function useWindowDimensions({ initial }) {
|
|
34
38
|
const current = (0, import_react_native.useWindowDimensions)();
|
|
35
|
-
if (process.env.TAMAGUI_TARGET != "web")
|
|
39
|
+
if (process.env.TAMAGUI_TARGET != "web") {
|
|
36
40
|
return current;
|
|
37
|
-
|
|
41
|
+
}
|
|
42
|
+
const [state, setState] = (0, import_react.useState)(
|
|
43
|
+
initial ? { ...initialValue, ...initial } : initialValue
|
|
44
|
+
);
|
|
38
45
|
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
39
46
|
setState(current);
|
|
40
|
-
},
|
|
47
|
+
}, Object.values(current));
|
|
41
48
|
return state;
|
|
42
49
|
}
|
|
43
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
51
|
0 && (module.exports = {
|
|
52
|
+
configureInitialWindowDimensions,
|
|
45
53
|
useWindowDimensions
|
|
46
54
|
});
|
|
47
55
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAyB;AACzB,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAyB;AACzB,0BAAyE;AAMzE,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,iCAAiC,MAA2B;AAC1E,SAAO,OAAO,cAAc,IAAI;AAClC;AAEO,SAAS,oBAAoB,EAAE,QAAQ,GAAsC;AAClF,QAAM,cAAU,oBAAAA,qBAAsB;AAEtC,MAAI,QAAQ,IAAI,kBAAkB,OAAO;AACvC,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,QAAQ,QAAI;AAAA,IACxB,UAAU,EAAE,GAAG,cAAc,GAAG,QAAQ,IAAI;AAAA,EAC9C;AAEA,kDAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAClB,GAAG,OAAO,OAAO,OAAO,CAAC;AAEzB,SAAO;AACT;",
|
|
5
5
|
"names": ["useWindowDimensionsRN"]
|
|
6
6
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
useWindowDimensions as useWindowDimensionsRN
|
|
5
|
-
} from "react-native";
|
|
3
|
+
import { useWindowDimensions as useWindowDimensionsRN } from "react-native";
|
|
6
4
|
const initialValue = {
|
|
7
5
|
fontScale: 1,
|
|
8
6
|
height: 800,
|
|
9
7
|
width: 600,
|
|
10
8
|
scale: 1
|
|
11
9
|
};
|
|
12
|
-
function
|
|
10
|
+
function configureInitialWindowDimensions(next) {
|
|
11
|
+
Object.assign(initialValue, next);
|
|
12
|
+
}
|
|
13
|
+
function useWindowDimensions({ initial }) {
|
|
13
14
|
const current = useWindowDimensionsRN();
|
|
14
|
-
if (process.env.TAMAGUI_TARGET != "web")
|
|
15
|
+
if (process.env.TAMAGUI_TARGET != "web") {
|
|
15
16
|
return current;
|
|
16
|
-
|
|
17
|
+
}
|
|
18
|
+
const [state, setState] = useState(
|
|
19
|
+
initial ? { ...initialValue, ...initial } : initialValue
|
|
20
|
+
);
|
|
17
21
|
useIsomorphicLayoutEffect(() => {
|
|
18
22
|
setState(current);
|
|
19
|
-
},
|
|
23
|
+
}, Object.values(current));
|
|
20
24
|
return state;
|
|
21
25
|
}
|
|
22
26
|
export {
|
|
27
|
+
configureInitialWindowDimensions,
|
|
23
28
|
useWindowDimensions
|
|
24
29
|
};
|
|
25
30
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB
|
|
4
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,SAAqB,uBAAuB,6BAA6B;AAMzE,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,iCAAiC,MAA2B;AAC1E,SAAO,OAAO,cAAc,IAAI;AAClC;AAEO,SAAS,oBAAoB,EAAE,QAAQ,GAAsC;AAClF,QAAM,UAAU,sBAAsB;AAEtC,MAAI,QAAQ,IAAI,kBAAkB,OAAO;AACvC,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,QAAQ,IAAI;AAAA,IACxB,UAAU,EAAE,GAAG,cAAc,GAAG,QAAQ,IAAI;AAAA,EAC9C;AAEA,4BAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAClB,GAAG,OAAO,OAAO,OAAO,CAAC;AAEzB,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
useWindowDimensions as useWindowDimensionsRN
|
|
5
|
-
} from "react-native";
|
|
3
|
+
import { useWindowDimensions as useWindowDimensionsRN } from "react-native";
|
|
6
4
|
const initialValue = {
|
|
7
5
|
fontScale: 1,
|
|
8
6
|
height: 800,
|
|
9
7
|
width: 600,
|
|
10
8
|
scale: 1
|
|
11
9
|
};
|
|
12
|
-
function
|
|
10
|
+
function configureInitialWindowDimensions(next) {
|
|
11
|
+
Object.assign(initialValue, next);
|
|
12
|
+
}
|
|
13
|
+
function useWindowDimensions({ initial }) {
|
|
13
14
|
const current = useWindowDimensionsRN();
|
|
14
|
-
if (process.env.TAMAGUI_TARGET != "web")
|
|
15
|
+
if (process.env.TAMAGUI_TARGET != "web") {
|
|
15
16
|
return current;
|
|
16
|
-
|
|
17
|
+
}
|
|
18
|
+
const [state, setState] = useState(
|
|
19
|
+
initial ? { ...initialValue, ...initial } : initialValue
|
|
20
|
+
);
|
|
17
21
|
useIsomorphicLayoutEffect(() => {
|
|
18
22
|
setState(current);
|
|
19
|
-
},
|
|
23
|
+
}, Object.values(current));
|
|
20
24
|
return state;
|
|
21
25
|
}
|
|
22
26
|
export {
|
|
27
|
+
configureInitialWindowDimensions,
|
|
23
28
|
useWindowDimensions
|
|
24
29
|
};
|
|
25
30
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB
|
|
4
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,SAAqB,uBAAuB,6BAA6B;AAMzE,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,iCAAiC,MAA2B;AAC1E,SAAO,OAAO,cAAc,IAAI;AAClC;AAEO,SAAS,oBAAoB,EAAE,QAAQ,GAAsC;AAClF,QAAM,UAAU,sBAAsB;AAEtC,MAAI,QAAQ,IAAI,kBAAkB,OAAO;AACvC,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,QAAQ,IAAI;AAAA,IACxB,UAAU,EAAE,GAAG,cAAc,GAAG,QAAQ,IAAI;AAAA,EAC9C;AAEA,4BAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAClB,GAAG,OAAO,OAAO,OAAO,CAAC;AAEzB,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-window-dimensions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@tamagui/constants": "1.
|
|
29
|
+
"@tamagui/constants": "1.22.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.
|
|
32
|
+
"@tamagui/build": "1.22.0",
|
|
33
33
|
"@types/react": "^18.0.15",
|
|
34
34
|
"react": "^18.2.0",
|
|
35
35
|
"react-native": "^0.71.7"
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
2
|
import { useState } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
ScaledSize,
|
|
5
|
-
useWindowDimensions as useWindowDimensionsRN
|
|
6
|
-
} from 'react-native'
|
|
3
|
+
import { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* SSR safe useWindowDimensions
|
|
@@ -16,17 +13,24 @@ const initialValue: ScaledSize = {
|
|
|
16
13
|
scale: 1,
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
export function
|
|
16
|
+
export function configureInitialWindowDimensions(next: Partial<ScaledSize>) {
|
|
17
|
+
Object.assign(initialValue, next)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function useWindowDimensions({ initial }: { initial?: Partial<ScaledSize> }) {
|
|
20
21
|
const current = useWindowDimensionsRN()
|
|
21
|
-
|
|
22
|
-
if (process.env.TAMAGUI_TARGET != 'web')
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
|
|
23
|
+
if (process.env.TAMAGUI_TARGET != 'web') {
|
|
24
|
+
return current
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const [state, setState] = useState(
|
|
28
|
+
initial ? { ...initialValue, ...initial } : initialValue
|
|
29
|
+
)
|
|
25
30
|
|
|
26
31
|
useIsomorphicLayoutEffect(() => {
|
|
27
32
|
setState(current)
|
|
28
|
-
|
|
29
|
-
}, [current.height, current.width, current.fontScale, current.scale])
|
|
33
|
+
}, Object.values(current))
|
|
30
34
|
|
|
31
35
|
return state
|
|
32
36
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { ScaledSize } from 'react-native';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function configureInitialWindowDimensions(next: Partial<ScaledSize>): void;
|
|
3
|
+
export declare function useWindowDimensions({ initial }: {
|
|
4
|
+
initial?: Partial<ScaledSize>;
|
|
5
|
+
}): ScaledSize;
|
|
3
6
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAA;AAavF,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,QAEzE;AAED,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;CAAE,cAgBjF"}
|