@tamagui/adapt 1.106.0 → 1.108.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/Adapt.js +4 -4
- package/dist/cjs/Adapt.js.map +2 -2
- package/dist/cjs/Adapt.native.js +9 -4
- package/dist/cjs/Adapt.native.js.map +2 -2
- package/dist/esm/Adapt.js +11 -12
- package/dist/esm/Adapt.js.map +1 -1
- package/dist/esm/Adapt.mjs +9 -5
- package/dist/esm/Adapt.mjs.map +1 -1
- package/dist/esm/Adapt.native.js +9 -5
- package/dist/esm/Adapt.native.js.map +2 -2
- package/package.json +5 -5
- package/src/Adapt.tsx +32 -21
- package/types/Adapt.d.ts +9 -4
- package/types/Adapt.d.ts.map +1 -1
package/dist/cjs/Adapt.js
CHANGED
|
@@ -20,7 +20,7 @@ __export(Adapt_exports, {
|
|
|
20
20
|
useAdaptParent: () => useAdaptParent
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(Adapt_exports);
|
|
23
|
-
var import_constants = require("@tamagui/constants"),
|
|
23
|
+
var import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_helpers = require("@tamagui/helpers"), import_react = require("react"), import_jsx_runtime = require("react/jsx-runtime");
|
|
24
24
|
const AdaptParentContext = (0, import_react.createContext)(null), AdaptContents = (props) => {
|
|
25
25
|
const context = (0, import_react.useContext)(AdaptParentContext);
|
|
26
26
|
if (!context?.Contents)
|
|
@@ -50,10 +50,10 @@ const useAdaptParent = ({
|
|
|
50
50
|
}, Adapt = (0, import_helpers.withStaticProperties)(
|
|
51
51
|
function({ platform, when, children }) {
|
|
52
52
|
const context = (0, import_react.useContext)(AdaptParentContext), media = (0, import_core.useMedia)();
|
|
53
|
-
let enabled = !
|
|
54
|
-
return platform === "touch" && (enabled =
|
|
53
|
+
let enabled = !1;
|
|
54
|
+
return typeof when == "function" ? enabled = when({ media }) : (enabled = !platform, platform === "touch" && (enabled = import_constants.isTouchable), platform === "native" && (enabled = !import_constants.isWeb), platform === "web" && (enabled = import_constants.isWeb), platform === "ios" && (enabled = import_constants.isIos), platform === "android" && (enabled = import_constants.isAndroid), when && !media[when] && (enabled = !1)), (0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
55
55
|
enabled && context?.setWhen(when || enabled);
|
|
56
|
-
}, [when, context, enabled]), enabled ? children : null;
|
|
56
|
+
}, [when, context, enabled]), enabled ? typeof children == "function" ? children({ enabled, media }) : children : null;
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
Contents: AdaptContents
|
package/dist/cjs/Adapt.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Adapt.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMO,+BAEP,cAAyB,0BACzB,iBAAqC,6BACrC,eAA4E,kBAoDpE;AAhCD,MAAM,yBAAqB,4BAA0C,IAAI,GAGnE,gBAAgB,CAAC,UAAe;AAC3C,QAAM,cAAU,yBAAW,kBAAkB;AAC7C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,QAAQ,IAAI,aAAa,eACrB,8CACA;AAAA,IACN;AAEF,aAAO,4BAAc,QAAQ,UAAU,KAAK;AAC9C;AAEA,cAAc,qBAAqB;AAE5B,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AACF,MAEM;AACJ,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAe,IAAI;AAmB3C,SAAO;AAAA,IACL,mBAlBoB,sBAAQ,MAAM;AAClC,YAAM,UAA+B;AAAA,QACnC;AAAA,QACA;AAAA,MACF;AAEA,eAAS,kBAAkB,OAA2B;AACpD,eACE,4CAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACjC,gBAAM,UACT;AAAA,MAEJ;AAEA,aAAO;AAAA,IACT,GAAG,CAAC,QAAQ,CAAC;AAAA,IAIX;AAAA,EACF;AACF,GAEa,YAAQ;AAAA,EACnB,SAAe,EAAE,UAAU,MAAM,SAAS,GAAe;AACvD,UAAM,cAAU,yBAAW,kBAAkB,GACvC,YAAQ,sBAAS;AAEvB,QAAI,UAAU;AAuBd,WArBI,OAAO,QAAS,aAClB,UAAU,KAAK,EAAE,MAAM,CAAC,KAExB,UAAU,CAAC,UAEP,aAAa,YAAS,UAAU,+BAChC,aAAa,aAAU,UAAU,CAAC,yBAClC,aAAa,UAAO,UAAU,yBAC9B,aAAa,UAAO,UAAU,yBAC9B,aAAa,cAAW,UAAU,6BAElC,QAAQ,CAAC,MAAM,IAAI,MACrB,UAAU,UAId,4CAA0B,MAAM;AAC9B,MAAK,WACL,SAAS,QAAS,QAAQ,OAAgB;AAAA,IAC5C,GAAG,CAAC,MAAM,SAAS,OAAO,CAAC,GAEtB,UAID,OAAO,YAAa,aACf,SAAS,EAAE,SAAS,MAAM,CAAC,IAG7B,WAPE;AAAA,EAQX;AAAA,EACA;AAAA,IACE,UAAU;AAAA,EACZ;AACF;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
package/dist/cjs/Adapt.native.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(Adapt_exports, {
|
|
|
21
21
|
useAdaptParent: () => useAdaptParent
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(Adapt_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime"), import_constants = require("@tamagui/constants"),
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_helpers = require("@tamagui/helpers"), import_react = require("react");
|
|
25
25
|
function _array_like_to_array(arr, len) {
|
|
26
26
|
(len == null || len > arr.length) && (len = arr.length);
|
|
27
27
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
@@ -90,14 +90,19 @@ var useAdaptParent = function(param) {
|
|
|
90
90
|
when
|
|
91
91
|
};
|
|
92
92
|
}, Adapt = (0, import_helpers.withStaticProperties)(function(param) {
|
|
93
|
-
var platform = param.platform, when = param.when, children = param.children, context = (0, import_react.useContext)(AdaptParentContext), media = (0, import_core.useMedia)(), enabled = !
|
|
94
|
-
return
|
|
93
|
+
var platform = param.platform, when = param.when, children = param.children, context = (0, import_react.useContext)(AdaptParentContext), media = (0, import_core.useMedia)(), enabled = !1;
|
|
94
|
+
return typeof when == "function" ? enabled = when({
|
|
95
|
+
media
|
|
96
|
+
}) : (enabled = !platform, platform === "touch" && (enabled = import_constants.isTouchable), platform === "native" && (enabled = !import_constants.isWeb), platform === "web" && (enabled = import_constants.isWeb), platform === "ios" && (enabled = import_constants.isIos), platform === "android" && (enabled = import_constants.isAndroid), when && !media[when] && (enabled = !1)), (0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
95
97
|
enabled && (context == null || context.setWhen(when || enabled));
|
|
96
98
|
}, [
|
|
97
99
|
when,
|
|
98
100
|
context,
|
|
99
101
|
enabled
|
|
100
|
-
]), enabled ? children
|
|
102
|
+
]), enabled ? typeof children == "function" ? children({
|
|
103
|
+
enabled,
|
|
104
|
+
media
|
|
105
|
+
}) : children : null;
|
|
101
106
|
}, {
|
|
102
107
|
Contents: AdaptContents
|
|
103
108
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/adapt/src/Adapt.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;uDAAA,
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;uDAAA,mBAMO,+BAEP,cAAyB,0BACzB,iBAAqC,6BACrC,eAA4E;;;;;;;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B,IAAKL,YACLzB,WAAAA,QAAAA,QAASY,QAASD,QAAQc,OAAAA;EAC5B,GAAG;IAACd;IAAMX;IAASyB;GAAQ,GAEtBA,UAID,OAAON,YAAa,aACfA,SAAS;IAAEM;IAASF;EAAM,CAAA,IAG5BJ,WAPE;AAQX,GACA;EACEjB,UAAUJ;AACZ,CAAA;",
|
|
5
|
+
"names": ["AdaptParentContext", "createContext", "AdaptContents", "props", "context", "useContext", "Contents", "Error", "process", "env", "NODE_ENV", "createElement", "shouldForwardSpace", "useAdaptParent", "useState", "when", "setWhen", "AdaptProvider", "useMemo", "AdaptProviderView", "_jsx", "Provider", "value", "children", "Adapt", "withStaticProperties", "platform", "media", "useMedia", "enabled", "isTouchable", "isWeb", "isIos", "isAndroid", "useIsomorphicLayoutEffect"]
|
|
6
6
|
}
|
package/dist/esm/Adapt.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
isAndroid,
|
|
3
|
+
isIos,
|
|
4
|
+
isTouchable,
|
|
5
|
+
isWeb,
|
|
6
|
+
useIsomorphicLayoutEffect
|
|
7
|
+
} from "@tamagui/constants";
|
|
3
8
|
import { useMedia } from "@tamagui/core";
|
|
4
9
|
import { withStaticProperties } from "@tamagui/helpers";
|
|
5
|
-
import {
|
|
6
|
-
createContext,
|
|
7
|
-
createElement,
|
|
8
|
-
useContext,
|
|
9
|
-
useMemo,
|
|
10
|
-
useState
|
|
11
|
-
} from "react";
|
|
10
|
+
import { createContext, createElement, useContext, useMemo, useState } from "react";
|
|
12
11
|
import { jsx } from "react/jsx-runtime";
|
|
13
12
|
const AdaptParentContext = createContext(null), AdaptContents = (props) => {
|
|
14
13
|
const context = useContext(AdaptParentContext);
|
|
@@ -39,10 +38,10 @@ const useAdaptParent = ({
|
|
|
39
38
|
}, Adapt = withStaticProperties(
|
|
40
39
|
function({ platform, when, children }) {
|
|
41
40
|
const context = useContext(AdaptParentContext), media = useMedia();
|
|
42
|
-
let enabled = !
|
|
43
|
-
return platform === "touch" && (enabled = isTouchable), platform === "native" && (enabled = !isWeb), platform === "web" && (enabled = isWeb), platform === "ios" && (enabled = isIos), platform === "android" && (enabled = isAndroid), when && !media[when] && (enabled = !1), useIsomorphicLayoutEffect(() => {
|
|
41
|
+
let enabled = !1;
|
|
42
|
+
return typeof when == "function" ? enabled = when({ media }) : (enabled = !platform, platform === "touch" && (enabled = isTouchable), platform === "native" && (enabled = !isWeb), platform === "web" && (enabled = isWeb), platform === "ios" && (enabled = isIos), platform === "android" && (enabled = isAndroid), when && !media[when] && (enabled = !1)), useIsomorphicLayoutEffect(() => {
|
|
44
43
|
enabled && context?.setWhen(when || enabled);
|
|
45
|
-
}, [when, context, enabled]), enabled ? children : null;
|
|
44
|
+
}, [when, context, enabled]), enabled ? typeof children == "function" ? children({ enabled, media }) : children : null;
|
|
46
45
|
},
|
|
47
46
|
{
|
|
48
47
|
Contents: AdaptContents
|
package/dist/esm/Adapt.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Adapt.tsx"],
|
|
4
|
-
"mappings": "AAAA,
|
|
4
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,SAAS,4BAA4B;AACrC,SAAS,eAAe,eAAe,YAAY,SAAS,gBAAgB;AAoDpE;AAhCD,MAAM,qBAAqB,cAA0C,IAAI,GAGnE,gBAAgB,CAAC,UAAe;AAC3C,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,QAAQ,IAAI,aAAa,eACrB,8CACA;AAAA,IACN;AAEF,SAAO,cAAc,QAAQ,UAAU,KAAK;AAC9C;AAEA,cAAc,qBAAqB;AAE5B,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AACF,MAEM;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAAe,IAAI;AAmB3C,SAAO;AAAA,IACL,eAlBoB,QAAQ,MAAM;AAClC,YAAM,UAA+B;AAAA,QACnC;AAAA,QACA;AAAA,MACF;AAEA,eAAS,kBAAkB,OAA2B;AACpD,eACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACjC,gBAAM,UACT;AAAA,MAEJ;AAEA,aAAO;AAAA,IACT,GAAG,CAAC,QAAQ,CAAC;AAAA,IAIX;AAAA,EACF;AACF,GAEa,QAAQ;AAAA,EACnB,SAAe,EAAE,UAAU,MAAM,SAAS,GAAe;AACvD,UAAM,UAAU,WAAW,kBAAkB,GACvC,QAAQ,SAAS;AAEvB,QAAI,UAAU;AAuBd,WArBI,OAAO,QAAS,aAClB,UAAU,KAAK,EAAE,MAAM,CAAC,KAExB,UAAU,CAAC,UAEP,aAAa,YAAS,UAAU,cAChC,aAAa,aAAU,UAAU,CAAC,QAClC,aAAa,UAAO,UAAU,QAC9B,aAAa,UAAO,UAAU,QAC9B,aAAa,cAAW,UAAU,YAElC,QAAQ,CAAC,MAAM,IAAI,MACrB,UAAU,MAId,0BAA0B,MAAM;AAC9B,MAAK,WACL,SAAS,QAAS,QAAQ,OAAgB;AAAA,IAC5C,GAAG,CAAC,MAAM,SAAS,OAAO,CAAC,GAEtB,UAID,OAAO,YAAa,aACf,SAAS,EAAE,SAAS,MAAM,CAAC,IAG7B,WAPE;AAAA,EAQX;AAAA,EACA;AAAA,IACE,UAAU;AAAA,EACZ;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/Adapt.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isAndroid, isIos, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
-
import { isTouchable } from "@tamagui/constants";
|
|
1
|
+
import { isAndroid, isIos, isTouchable, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
2
|
import { useMedia } from "@tamagui/core";
|
|
4
3
|
import { withStaticProperties } from "@tamagui/helpers";
|
|
5
4
|
import { createContext, createElement, useContext, useMemo, useState } from "react";
|
|
@@ -39,10 +38,15 @@ const useAdaptParent = ({
|
|
|
39
38
|
}) {
|
|
40
39
|
const context = useContext(AdaptParentContext),
|
|
41
40
|
media = useMedia();
|
|
42
|
-
let enabled = !
|
|
43
|
-
return
|
|
41
|
+
let enabled = !1;
|
|
42
|
+
return typeof when == "function" ? enabled = when({
|
|
43
|
+
media
|
|
44
|
+
}) : (enabled = !platform, platform === "touch" && (enabled = isTouchable), platform === "native" && (enabled = !isWeb), platform === "web" && (enabled = isWeb), platform === "ios" && (enabled = isIos), platform === "android" && (enabled = isAndroid), when && !media[when] && (enabled = !1)), useIsomorphicLayoutEffect(() => {
|
|
44
45
|
enabled && context?.setWhen(when || enabled);
|
|
45
|
-
}, [when, context, enabled]), enabled ? children
|
|
46
|
+
}, [when, context, enabled]), enabled ? typeof children == "function" ? children({
|
|
47
|
+
enabled,
|
|
48
|
+
media
|
|
49
|
+
}) : children : null;
|
|
46
50
|
}, {
|
|
47
51
|
Contents: AdaptContents
|
|
48
52
|
});
|
package/dist/esm/Adapt.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isAndroid","isIos","
|
|
1
|
+
{"version":3,"names":["isAndroid","isIos","isTouchable","isWeb","useIsomorphicLayoutEffect","useMedia","withStaticProperties","createContext","createElement","useContext","useMemo","useState","jsx","AdaptParentContext","AdaptContents","props","context","Contents","Error","process","env","NODE_ENV","shouldForwardSpace","useAdaptParent","when","setWhen","AdaptProvider","AdaptProviderView","Provider","value","children","Adapt","platform","media","enabled"],"sources":["../../src/Adapt.tsx"],"sourcesContent":[null],"mappings":"AAAA,SACEA,SAAA,EACAC,KAAA,EACAC,WAAA,EACAC,KAAA,EACAC,yBAAA,QACK;AAEP,SAASC,QAAA,QAAgB;AACzB,SAASC,oBAAA,QAA4B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ACF,QAAA,EAEPA,QAAA,KAAa,YAASE,OAAA,GAAUhC,WAAA,GAChC8B,QAAA,KAAa,aAAUE,OAAA,GAAU,CAAC/B,KAAA,GAClC6B,QAAA,KAAa,UAAOE,OAAA,GAAU/B,KAAA,GAC9B6B,QAAA,KAAa,UAAOE,OAAA,GAAUjC,KAAA,GAC9B+B,QAAA,KAAa,cAAWE,OAAA,GAAUlC,SAAA,GAElCwB,IAAA,IAAQ,CAACS,KAAA,CAAMT,IAAI,MACrBU,OAAA,GAAU,MAId9B,yBAAA,CAA0B,MAAM;MACzB8B,OAAA,IACLlB,OAAA,EAASS,OAAA,CAASD,IAAA,IAAQU,OAAgB;IAC5C,GAAG,CAACV,IAAA,EAAMR,OAAA,EAASkB,OAAO,CAAC,GAEtBA,OAAA,GAID,OAAOJ,QAAA,IAAa,aACfA,QAAA,CAAS;MAAEI,OAAA;MAASD;IAAM,CAAC,IAG7BH,QAAA,GAPE;EAQX,GACA;IACEb,QAAA,EAAUH;EACZ,CACF","ignoreList":[]}
|
package/dist/esm/Adapt.native.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isAndroid, isIos, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
|
-
import { isTouchable } from "@tamagui/constants";
|
|
2
|
+
import { isAndroid, isIos, isTouchable, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
4
3
|
import { useMedia } from "@tamagui/core";
|
|
5
4
|
import { withStaticProperties } from "@tamagui/helpers";
|
|
6
5
|
import { createContext, createElement, useContext, useMemo, useState } from "react";
|
|
@@ -72,14 +71,19 @@ var useAdaptParent = function(param) {
|
|
|
72
71
|
when
|
|
73
72
|
};
|
|
74
73
|
}, Adapt = withStaticProperties(function(param) {
|
|
75
|
-
var platform = param.platform, when = param.when, children = param.children, context = useContext(AdaptParentContext), media = useMedia(), enabled = !
|
|
76
|
-
return
|
|
74
|
+
var platform = param.platform, when = param.when, children = param.children, context = useContext(AdaptParentContext), media = useMedia(), enabled = !1;
|
|
75
|
+
return typeof when == "function" ? enabled = when({
|
|
76
|
+
media
|
|
77
|
+
}) : (enabled = !platform, platform === "touch" && (enabled = isTouchable), platform === "native" && (enabled = !isWeb), platform === "web" && (enabled = isWeb), platform === "ios" && (enabled = isIos), platform === "android" && (enabled = isAndroid), when && !media[when] && (enabled = !1)), useIsomorphicLayoutEffect(function() {
|
|
77
78
|
enabled && (context == null || context.setWhen(when || enabled));
|
|
78
79
|
}, [
|
|
79
80
|
when,
|
|
80
81
|
context,
|
|
81
82
|
enabled
|
|
82
|
-
]), enabled ? children
|
|
83
|
+
]), enabled ? typeof children == "function" ? children({
|
|
84
|
+
enabled,
|
|
85
|
+
media
|
|
86
|
+
}) : children : null;
|
|
83
87
|
}, {
|
|
84
88
|
Contents: AdaptContents
|
|
85
89
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/adapt/src/Adapt.tsx"],
|
|
4
|
-
"mappings": ";AAAA,
|
|
5
|
-
"names": ["isAndroid", "isIos", "
|
|
4
|
+
"mappings": ";AAAA,SACEA,WACAC,OACAC,aACAC,OACAC,iCACK;AAEP,SAASC,gBAAgB;AACzB,SAASC,4BAA4B;AACrC,SAASC,eAAeC,eAAeC,YAAYC,SAASC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBrE,IAAMC,qBAAqBL,8BAA0C,IAAA,GAG/DM,gBAAgB,SAACC,OAAAA;AAC5B,MAAMC,UAAUN,WAAWG,kBAAAA;AAC3B,MAAI,EAACG,WAAAA,QAAAA,QAASC;AACZ,UAAM,IAAIC,MACRC,QAAQC,IAAIC,aAAa,eACpB,8CACA,0GAAA;AAGT,SAAOZ,8BAAcO,QAAQC,UAAUF,KAAAA;AACzC;AAEAD,cAAcQ,qBAAqB;AAE5B,IAAMC,iBAAiB,SAAA,OAAA;MAC5BN,WAAAA,MAAAA,UAIwBL,YAAAA,iBAAAA,SAAe,IAAA,GAAA,CAAA,GAAhCY,OAAiBZ,UAAAA,CAAAA,GAAXa,UAAWb,UAAAA,CAAAA,GAElBc,gBAAgBf,QAAQ,WAAA;QAMnBgB,oBAAT,SAA2BZ,OAAyB;AAClD,aACE,qBAACF,mBAAmBe,UAAQ;QAACC,OAAOb;kBACjCD,MAAMe;;IAGb,GAXMd,UAA+B;MACnCC;MACAQ;IACF;AAUA,WAAOE;EACT,GAAG;IAACV;GAAS;AAEb,SAAO;IACLS;IACAF;EACF;AACF,GAEaO,QAAQxB,qBACnB,SAAe,OAAwC;MAAtCyB,WAAF,MAAEA,UAAUR,OAAZ,MAAYA,MAAMM,WAAlB,MAAkBA,UACzBd,UAAUN,WAAWG,kBAAAA,GACrBoB,QAAQ3B,SAAAA,GAEV4B,UAAU;AAuBd,SArBI,OAAOV,QAAS,aAClBU,UAAUV,KAAK;IAAES;EAAM,CAAA,KAEvBC,UAAU,CAACF,UAEPA,aAAa,YAASE,UAAU/B,cAChC6B,aAAa,aAAUE,UAAU,CAAC9B,QAClC4B,aAAa,UAAOE,UAAU9B,QAC9B4B,aAAa,UAAOE,UAAUhC,QAC9B8B,aAAa,cAAWE,UAAUjC,YAElCuB,QAAQ,CAACS,MAAMT,IAAAA,MACjBU,UAAU,MAId7B,0BAA0B,WAAA;AACxB,IAAK6B,YACLlB,WAAAA,QAAAA,QAASS,QAASD,QAAQU,OAAAA;EAC5B,GAAG;IAACV;IAAMR;IAASkB;GAAQ,GAEtBA,UAID,OAAOJ,YAAa,aACfA,SAAS;IAAEI;IAASD;EAAM,CAAA,IAG5BH,WAPE;AAQX,GACA;EACEb,UAAUH;AACZ,CAAA;",
|
|
5
|
+
"names": ["isAndroid", "isIos", "isTouchable", "isWeb", "useIsomorphicLayoutEffect", "useMedia", "withStaticProperties", "createContext", "createElement", "useContext", "useMemo", "useState", "AdaptParentContext", "AdaptContents", "props", "context", "Contents", "Error", "process", "env", "NODE_ENV", "shouldForwardSpace", "useAdaptParent", "when", "setWhen", "AdaptProvider", "AdaptProviderView", "Provider", "value", "children", "Adapt", "platform", "media", "enabled"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/adapt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.108.0",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/constants": "1.
|
|
31
|
-
"@tamagui/core": "1.
|
|
32
|
-
"@tamagui/helpers": "1.
|
|
30
|
+
"@tamagui/constants": "1.108.0",
|
|
31
|
+
"@tamagui/core": "1.108.0",
|
|
32
|
+
"@tamagui/helpers": "1.108.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tamagui/build": "1.
|
|
35
|
+
"@tamagui/build": "1.108.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
package/src/Adapt.tsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
isAndroid,
|
|
3
|
+
isIos,
|
|
4
|
+
isTouchable,
|
|
5
|
+
isWeb,
|
|
6
|
+
useIsomorphicLayoutEffect,
|
|
7
|
+
} from '@tamagui/constants'
|
|
8
|
+
import type { MediaQueryKey, UseMediaState } from '@tamagui/core'
|
|
4
9
|
import { useMedia } from '@tamagui/core'
|
|
5
10
|
import { withStaticProperties } from '@tamagui/helpers'
|
|
6
|
-
import {
|
|
7
|
-
createContext,
|
|
8
|
-
createElement,
|
|
9
|
-
useContext,
|
|
10
|
-
useMemo,
|
|
11
|
-
useState,
|
|
12
|
-
useRef,
|
|
13
|
-
} from 'react'
|
|
11
|
+
import { createContext, createElement, useContext, useMemo, useState } from 'react'
|
|
14
12
|
|
|
15
13
|
type MediaQueryKeyString = MediaQueryKey extends string ? MediaQueryKey : never
|
|
16
14
|
|
|
17
15
|
export type AdaptProps = {
|
|
18
|
-
when?: MediaQueryKeyString
|
|
16
|
+
when?: MediaQueryKeyString | ((state: { media: UseMediaState }) => boolean)
|
|
19
17
|
platform?: 'native' | 'web' | 'touch' | 'ios' | 'android'
|
|
20
|
-
children?:
|
|
18
|
+
children?:
|
|
19
|
+
| React.ReactNode
|
|
20
|
+
| ((state: { enabled: boolean; media: UseMediaState }) => React.ReactNode)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
type When = MediaQueryKeyString | boolean | null
|
|
@@ -80,15 +80,22 @@ export const Adapt = withStaticProperties(
|
|
|
80
80
|
const context = useContext(AdaptParentContext)
|
|
81
81
|
const media = useMedia()
|
|
82
82
|
|
|
83
|
-
let enabled =
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
let enabled = false
|
|
84
|
+
|
|
85
|
+
if (typeof when === 'function') {
|
|
86
|
+
enabled = when({ media })
|
|
87
|
+
} else {
|
|
88
|
+
enabled = !platform
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
enabled =
|
|
90
|
+
if (platform === 'touch') enabled = isTouchable
|
|
91
|
+
if (platform === 'native') enabled = !isWeb
|
|
92
|
+
if (platform === 'web') enabled = isWeb
|
|
93
|
+
if (platform === 'ios') enabled = isIos
|
|
94
|
+
if (platform === 'android') enabled = isAndroid
|
|
95
|
+
|
|
96
|
+
if (when && !media[when]) {
|
|
97
|
+
enabled = false
|
|
98
|
+
}
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -100,6 +107,10 @@ export const Adapt = withStaticProperties(
|
|
|
100
107
|
return null
|
|
101
108
|
}
|
|
102
109
|
|
|
110
|
+
if (typeof children === 'function') {
|
|
111
|
+
return children({ enabled, media })
|
|
112
|
+
}
|
|
113
|
+
|
|
103
114
|
return children
|
|
104
115
|
},
|
|
105
116
|
{
|
package/types/Adapt.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type { MediaQueryKey } from '@tamagui/core';
|
|
1
|
+
import type { MediaQueryKey, UseMediaState } from '@tamagui/core';
|
|
2
2
|
type MediaQueryKeyString = MediaQueryKey extends string ? MediaQueryKey : never;
|
|
3
3
|
export type AdaptProps = {
|
|
4
|
-
when?: MediaQueryKeyString
|
|
4
|
+
when?: MediaQueryKeyString | ((state: {
|
|
5
|
+
media: UseMediaState;
|
|
6
|
+
}) => boolean);
|
|
5
7
|
platform?: 'native' | 'web' | 'touch' | 'ios' | 'android';
|
|
6
|
-
children?:
|
|
8
|
+
children?: React.ReactNode | ((state: {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
media: UseMediaState;
|
|
11
|
+
}) => React.ReactNode);
|
|
7
12
|
};
|
|
8
13
|
type When = MediaQueryKeyString | boolean | null;
|
|
9
14
|
type Component = (props: any) => any;
|
|
@@ -24,7 +29,7 @@ export declare const useAdaptParent: ({ Contents, }: {
|
|
|
24
29
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
25
30
|
when: When;
|
|
26
31
|
};
|
|
27
|
-
export declare const Adapt: (({ platform, when, children }: AdaptProps) =>
|
|
32
|
+
export declare const Adapt: (({ platform, when, children }: AdaptProps) => import("react").ReactNode) & {
|
|
28
33
|
Contents: {
|
|
29
34
|
(props: any): import("react").FunctionComponentElement<any>;
|
|
30
35
|
shouldForwardSpace: boolean;
|
package/types/Adapt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapt.d.ts","sourceRoot":"","sources":["../src/Adapt.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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