@tamagui/adapt 1.74.2 → 1.74.4
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.
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isTouchable,
|
|
3
|
+
isWeb,
|
|
4
|
+
useIsomorphicLayoutEffect,
|
|
5
|
+
useMedia,
|
|
6
|
+
withStaticProperties
|
|
7
|
+
} from "@tamagui/core";
|
|
8
|
+
import { createContext, createElement, useContext, useMemo, useState } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
const AdaptParentContext = createContext(null), AdaptContents = (props) => {
|
|
11
|
+
const context = useContext(AdaptParentContext);
|
|
12
|
+
if (!context?.Contents)
|
|
13
|
+
throw new Error("Adapt not supported by this component");
|
|
14
|
+
return createElement(context.Contents, props);
|
|
15
|
+
};
|
|
16
|
+
AdaptContents.shouldForwardSpace = !0;
|
|
17
|
+
const useAdaptParent = ({
|
|
18
|
+
Contents
|
|
19
|
+
}) => {
|
|
20
|
+
const [when, setWhen] = useState(null);
|
|
21
|
+
return {
|
|
22
|
+
AdaptProvider: useMemo(() => {
|
|
23
|
+
const context = {
|
|
24
|
+
Contents,
|
|
25
|
+
setWhen
|
|
26
|
+
};
|
|
27
|
+
function AdaptProviderView(props) {
|
|
28
|
+
return /* @__PURE__ */ jsx(AdaptParentContext.Provider, { value: context, children: props.children });
|
|
29
|
+
}
|
|
30
|
+
return AdaptProviderView;
|
|
31
|
+
}, [Contents]),
|
|
32
|
+
when
|
|
33
|
+
};
|
|
34
|
+
}, Adapt = withStaticProperties(
|
|
35
|
+
function({ platform, when, children }) {
|
|
36
|
+
const context = useContext(AdaptParentContext), media = useMedia();
|
|
37
|
+
let enabled = !platform;
|
|
38
|
+
return platform === "touch" && (enabled = isTouchable), platform === "native" && (enabled = !isWeb), platform === "web" && (enabled = isWeb), when && !media[when] && (enabled = !1), useIsomorphicLayoutEffect(() => {
|
|
39
|
+
enabled && context?.setWhen(when || enabled);
|
|
40
|
+
}, [when, context, enabled]), enabled ? children : null;
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
Contents: AdaptContents
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
export {
|
|
47
|
+
Adapt,
|
|
48
|
+
AdaptContents,
|
|
49
|
+
AdaptParentContext,
|
|
50
|
+
useAdaptParent
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=Adapt.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Adapt.tsx"],
|
|
4
|
+
"mappings": "AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,eAAe,YAAY,SAAS,gBAAgB;AA8CpE;AA5BD,MAAM,qBAAqB,cAA0C,IAAI,GAGnE,gBAAgB,CAAC,UAAe;AAC3C,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uCAAuC;AAEzD,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,CAAC;AAcf,WAbI,aAAa,YAAS,UAAU,cAChC,aAAa,aAAU,UAAU,CAAC,QAClC,aAAa,UAAO,UAAU,QAE9B,QAAQ,CAAC,MAAM,IAAI,MACrB,UAAU,KAGZ,0BAA0B,MAAM;AAC9B,MAAK,WACL,SAAS,QAAS,QAAQ,OAAgB;AAAA,IAC5C,GAAG,CAAC,MAAM,SAAS,OAAO,CAAC,GAEtB,UAIE,WAHE;AAAA,EAIX;AAAA,EACA;AAAA,IACE,UAAU;AAAA,EACZ;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/adapt",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.4",
|
|
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/core": "1.74.
|
|
29
|
+
"@tamagui/core": "1.74.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.74.
|
|
32
|
+
"@tamagui/build": "1.74.4"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|