@tamagui/adapt 1.13.2 → 1.13.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.
package/dist/cjs/Adapt.js CHANGED
@@ -1,89 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var Adapt_exports = {};
20
- __export(Adapt_exports, {
21
- Adapt: () => Adapt,
22
- AdaptContents: () => AdaptContents,
23
- AdaptParentContext: () => AdaptParentContext,
24
- useAdaptParent: () => useAdaptParent
25
- });
26
- module.exports = __toCommonJS(Adapt_exports);
27
- var import_jsx_runtime = require("react/jsx-runtime");
28
- var import_core = require("@tamagui/core");
29
- var import_react = require("react");
30
- const AdaptParentContext = (0, import_react.createContext)(null);
31
- const AdaptContents = (props) => {
32
- const context = (0, import_react.useContext)(AdaptParentContext);
33
- if (!(context == null ? void 0 : context.Contents)) {
34
- throw new Error("Adapt not supported by this component");
35
- }
36
- return (0, import_react.createElement)(context.Contents, props);
37
- };
38
- AdaptContents["shouldForwardSpace"] = true;
39
- const useAdaptParent = ({
40
- Contents
41
- }) => {
42
- const [when, setWhen] = (0, import_react.useState)(null);
43
- const AdaptProvider = (0, import_react.useMemo)(() => {
44
- const context = {
45
- Contents,
46
- setWhen
47
- };
48
- function AdaptProviderView(props) {
49
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptParentContext.Provider, { value: context, children: props.children });
50
- }
51
- return AdaptProviderView;
52
- }, [Contents]);
53
- return {
54
- AdaptProvider,
55
- when
56
- };
57
- };
58
- const Adapt = (0, import_core.withStaticProperties)(
59
- function Adapt2({ platform, when, children }) {
60
- const context = (0, import_react.useContext)(AdaptParentContext);
61
- let enabled = !platform;
62
- if (platform === "touch")
63
- enabled = import_core.isTouchable;
64
- if (platform === "native")
65
- enabled = !import_core.isWeb;
66
- if (platform === "web")
67
- enabled = import_core.isWeb;
68
- (0, import_core.useIsomorphicLayoutEffect)(() => {
69
- if (!enabled)
70
- return;
71
- context == null ? void 0 : context.setWhen(when || enabled);
72
- }, [when, context, enabled]);
73
- if (!enabled) {
74
- return null;
75
- }
76
- return children;
77
- },
78
- {
79
- Contents: AdaptContents
80
- }
81
- );
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
84
- Adapt,
85
- AdaptContents,
86
- AdaptParentContext,
87
- useAdaptParent
88
- });
1
+ "use strict";var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},P=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!A.call(t,n)&&n!==o&&s(t,n,{get:()=>e[n],enumerable:!(i=h(e,n))||i.enumerable});return t};var x=t=>P(s({},"__esModule",{value:!0}),t);var w={};C(w,{Adapt:()=>v,AdaptContents:()=>u,AdaptParentContext:()=>d,useAdaptParent:()=>f});module.exports=x(w);var y=require("react/jsx-runtime"),p=require("@tamagui/core"),r=require("react");const d=(0,r.createContext)(null),u=t=>{const e=(0,r.useContext)(d);if(!(e!=null&&e.Contents))throw new Error("Adapt not supported by this component");return(0,r.createElement)(e.Contents,t)};u.shouldForwardSpace=!0;const f=({Contents:t})=>{const[e,o]=(0,r.useState)(null);return{AdaptProvider:(0,r.useMemo)(()=>{const n={Contents:t,setWhen:o};function a(c){return(0,y.jsx)(d.Provider,{value:n,children:c.children})}return a},[t]),when:e}},v=(0,p.withStaticProperties)(function({platform:e,when:o,children:i}){const n=(0,r.useContext)(d);let a=!e;return e==="touch"&&(a=p.isTouchable),e==="native"&&(a=!p.isWeb),e==="web"&&(a=p.isWeb),(0,p.useIsomorphicLayoutEffect)(()=>{a&&(n==null||n.setWhen(o||a))},[o,n,a]),a?i:null},{Contents:u});0&&(module.exports={Adapt,AdaptContents,AdaptParentContext,useAdaptParent});
89
2
  //# sourceMappingURL=Adapt.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/Adapt.tsx"],
4
4
  "sourcesContent": ["import {\n MediaQueryKey,\n isTouchable,\n isWeb,\n useIsomorphicLayoutEffect,\n withStaticProperties,\n} from '@tamagui/core'\nimport { createContext, createElement, useContext, useMemo, useState } from 'react'\n\ntype MediaQueryKeyString = MediaQueryKey extends string ? MediaQueryKey : never\n\nexport type AdaptProps = {\n when?: MediaQueryKeyString\n platform?: 'native' | 'web' | 'touch'\n children?: any\n}\n\ntype When = MediaQueryKeyString | boolean | null\n\ntype Component = (props: any) => any\ntype AdaptParentContextI = {\n Contents: Component\n setWhen: (when: When) => any\n}\n\nexport const AdaptParentContext = createContext<AdaptParentContextI | null>(null)\n\n// forward props\nexport const AdaptContents = (props: any) => {\n const context = useContext(AdaptParentContext)\n if (!context?.Contents) {\n throw new Error('Adapt not supported by this component')\n }\n return createElement(context.Contents, props)\n}\n\nAdaptContents['shouldForwardSpace'] = true\n\nexport const useAdaptParent = ({\n Contents,\n}: {\n Contents: AdaptParentContextI['Contents']\n}) => {\n const [when, setWhen] = useState<When>(null)\n\n const AdaptProvider = useMemo(() => {\n const context: AdaptParentContextI = {\n Contents,\n setWhen,\n }\n\n function AdaptProviderView(props: { children?: any }) {\n return (\n <AdaptParentContext.Provider value={context}>\n {props.children}\n </AdaptParentContext.Provider>\n )\n }\n\n return AdaptProviderView\n }, [Contents])\n\n return {\n AdaptProvider,\n when,\n }\n}\n\nexport const Adapt = withStaticProperties(\n function Adapt({ platform, when, children }: AdaptProps) {\n const context = useContext(AdaptParentContext)\n\n let enabled = !platform\n if (platform === 'touch') enabled = isTouchable\n if (platform === 'native') enabled = !isWeb\n if (platform === 'web') enabled = isWeb\n\n useIsomorphicLayoutEffect(() => {\n if (!enabled) return\n context?.setWhen((when || enabled) as When)\n }, [when, context, enabled])\n\n if (!enabled) {\n return null\n }\n\n return children\n },\n {\n Contents: AdaptContents,\n }\n)\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDQ;AArDR,kBAMO;AACP,mBAA4E;AAkBrE,MAAM,yBAAqB,4BAA0C,IAAI;AAGzE,MAAM,gBAAgB,CAAC,UAAe;AAC3C,QAAM,cAAU,yBAAW,kBAAkB;AAC7C,MAAI,EAAC,mCAAS,WAAU;AACtB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACA,aAAO,4BAAc,QAAQ,UAAU,KAAK;AAC9C;AAEA,cAAc,oBAAoB,IAAI;AAE/B,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AACF,MAEM;AACJ,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAe,IAAI;AAE3C,QAAM,oBAAgB,sBAAQ,MAAM;AAClC,UAAM,UAA+B;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,aAAS,kBAAkB,OAA2B;AACpD,aACE,4CAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACjC,gBAAM,UACT;AAAA,IAEJ;AAEA,WAAO;AAAA,EACT,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAQ;AAAA,EACnB,SAASA,OAAM,EAAE,UAAU,MAAM,SAAS,GAAe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AAU,KAAAH,EAAM,SAAAI,CAAS,EAAe,CACvD,MAAMN,KAAU,cAAWP,CAAkB,EAE7C,IAAIc,EAAU,CAACF,EAUf,OATIA,IAAa,UAASE,EAAU,eAChCF,IAAa,WAAUE,EAAU,CAAC,SAClCF,IAAa,QAAOE,EAAU,YAElC,6BAA0B,IAAM,CACzBA,IACLP,GAAA,MAAAA,EAAS,QAASE,GAAQK,GAC5B,EAAG,CAACL,EAAMF,EAASO,CAAO,CAAC,EAEtBA,EAIED,EAHE,IAIX,EACA,CACE,SAAUd,CACZ,CACF",
6
+ "names": ["Adapt_exports", "__export", "Adapt", "AdaptContents", "AdaptParentContext", "useAdaptParent", "__toCommonJS", "import_jsx_runtime", "import_core", "import_react", "props", "context", "Contents", "when", "setWhen", "AdaptProviderView", "platform", "children", "enabled"]
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -1,19 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var src_exports = {};
17
- module.exports = __toCommonJS(src_exports);
18
- __reExport(src_exports, require("./Adapt"), module.exports);
1
+ "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./Adapt"),module.exports);
19
2
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx"],
4
4
  "sourcesContent": ["export * from './Adapt'\n"],
5
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,oBAAd;",
6
- "names": []
5
+ "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,mBAAd",
6
+ "names": ["src_exports", "__toCommonJS", "__reExport"]
7
7
  }
package/dist/esm/Adapt.js CHANGED
@@ -1,67 +1,2 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import {
3
- isTouchable,
4
- isWeb,
5
- useIsomorphicLayoutEffect,
6
- withStaticProperties
7
- } from "@tamagui/core";
8
- import { createContext, createElement, useContext, useMemo, useState } from "react";
9
- const AdaptParentContext = createContext(null);
10
- const AdaptContents = (props) => {
11
- const context = useContext(AdaptParentContext);
12
- if (!(context == null ? void 0 : context.Contents)) {
13
- throw new Error("Adapt not supported by this component");
14
- }
15
- return createElement(context.Contents, props);
16
- };
17
- AdaptContents["shouldForwardSpace"] = true;
18
- const useAdaptParent = ({
19
- Contents
20
- }) => {
21
- const [when, setWhen] = useState(null);
22
- const 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
- return {
33
- AdaptProvider,
34
- when
35
- };
36
- };
37
- const Adapt = withStaticProperties(
38
- function Adapt2({ platform, when, children }) {
39
- const context = useContext(AdaptParentContext);
40
- let enabled = !platform;
41
- if (platform === "touch")
42
- enabled = isTouchable;
43
- if (platform === "native")
44
- enabled = !isWeb;
45
- if (platform === "web")
46
- enabled = isWeb;
47
- useIsomorphicLayoutEffect(() => {
48
- if (!enabled)
49
- return;
50
- context == null ? void 0 : context.setWhen(when || enabled);
51
- }, [when, context, enabled]);
52
- if (!enabled) {
53
- return null;
54
- }
55
- return children;
56
- },
57
- {
58
- Contents: AdaptContents
59
- }
60
- );
61
- export {
62
- Adapt,
63
- AdaptContents,
64
- AdaptParentContext,
65
- useAdaptParent
66
- };
1
+ import{jsx as x}from"react/jsx-runtime";import{isTouchable as y,isWeb as i,useIsomorphicLayoutEffect as c,withStaticProperties as h}from"@tamagui/core";import{createContext as l,createElement as A,useContext as d,useMemo as C,useState as P}from"react";const a=l(null),s=r=>{const e=d(a);if(!(e!=null&&e.Contents))throw new Error("Adapt not supported by this component");return A(e.Contents,r)};s.shouldForwardSpace=!0;const W=({Contents:r})=>{const[e,o]=P(null);return{AdaptProvider:C(()=>{const n={Contents:r,setWhen:o};function t(u){return x(a.Provider,{value:n,children:u.children})}return t},[r]),when:e}},b=h(function({platform:e,when:o,children:p}){const n=d(a);let t=!e;return e==="touch"&&(t=y),e==="native"&&(t=!i),e==="web"&&(t=i),c(()=>{t&&(n==null||n.setWhen(o||t))},[o,n,t]),t?p:null},{Contents:s});export{b as Adapt,s as AdaptContents,a as AdaptParentContext,W as useAdaptParent};
67
2
  //# sourceMappingURL=Adapt.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/Adapt.tsx"],
4
4
  "sourcesContent": ["import {\n MediaQueryKey,\n isTouchable,\n isWeb,\n useIsomorphicLayoutEffect,\n withStaticProperties,\n} from '@tamagui/core'\nimport { createContext, createElement, useContext, useMemo, useState } from 'react'\n\ntype MediaQueryKeyString = MediaQueryKey extends string ? MediaQueryKey : never\n\nexport type AdaptProps = {\n when?: MediaQueryKeyString\n platform?: 'native' | 'web' | 'touch'\n children?: any\n}\n\ntype When = MediaQueryKeyString | boolean | null\n\ntype Component = (props: any) => any\ntype AdaptParentContextI = {\n Contents: Component\n setWhen: (when: When) => any\n}\n\nexport const AdaptParentContext = createContext<AdaptParentContextI | null>(null)\n\n// forward props\nexport const AdaptContents = (props: any) => {\n const context = useContext(AdaptParentContext)\n if (!context?.Contents) {\n throw new Error('Adapt not supported by this component')\n }\n return createElement(context.Contents, props)\n}\n\nAdaptContents['shouldForwardSpace'] = true\n\nexport const useAdaptParent = ({\n Contents,\n}: {\n Contents: AdaptParentContextI['Contents']\n}) => {\n const [when, setWhen] = useState<When>(null)\n\n const AdaptProvider = useMemo(() => {\n const context: AdaptParentContextI = {\n Contents,\n setWhen,\n }\n\n function AdaptProviderView(props: { children?: any }) {\n return (\n <AdaptParentContext.Provider value={context}>\n {props.children}\n </AdaptParentContext.Provider>\n )\n }\n\n return AdaptProviderView\n }, [Contents])\n\n return {\n AdaptProvider,\n when,\n }\n}\n\nexport const Adapt = withStaticProperties(\n function Adapt({ platform, when, children }: AdaptProps) {\n const context = useContext(AdaptParentContext)\n\n let enabled = !platform\n if (platform === 'touch') enabled = isTouchable\n if (platform === 'native') enabled = !isWeb\n if (platform === 'web') enabled = isWeb\n\n useIsomorphicLayoutEffect(() => {\n if (!enabled) return\n context?.setWhen((when || enabled) as When)\n }, [when, context, enabled])\n\n if (!enabled) {\n return null\n }\n\n return children\n },\n {\n Contents: AdaptContents,\n }\n)\n"],
5
- "mappings": "AAqDQ;AArDR;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,eAAe,YAAY,SAAS,gBAAgB;AAkBrE,MAAM,qBAAqB,cAA0C,IAAI;AAGzE,MAAM,gBAAgB,CAAC,UAAe;AAC3C,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,EAAC,mCAAS,WAAU;AACtB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACA,S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ACG,GAAA,MAAAA,EAAS,UACZ,MAAM,IAAI,MAAM,uCAAuC,EAEzD,OAAOP,EAAcO,EAAQ,SAAUD,CAAK,CAC9C,EAEAD,EAAc,mBAAwB,GAE/B,MAAMG,EAAiB,CAAC,CAC7B,SAAAC,CACF,IAEM,CACJ,KAAM,CAACC,EAAMC,CAAO,EAAIR,EAAe,IAAI,EAmB3C,MAAO,CACL,cAlBoBD,EAAQ,IAAM,CAClC,MAAMK,EAA+B,CACnC,SAAAE,EACA,QAAAE,CACF,EAEA,SAASC,EAAkBN,EAA2B,CACpD,OACEZ,EAACU,EAAmB,SAAnB,CAA4B,MAAOG,EACjC,SAAAD,EAAM,SACT,CAEJ,CAEA,OAAOM,CACT,EAAG,CAACH,CAAQ,CAAC,EAIX,KAAAC,CACF,CACF,EAEaG,EAAQf,EACnB,SAAe,CAAE,SAAAgB,EAAU,KAAAJ,EAAM,SAAAK,CAAS,EAAe,CACvD,MAAMR,EAAUN,EAAWG,CAAkB,EAE7C,IAAIY,EAAU,CAACF,EAUf,OATIA,IAAa,UAASE,EAAUrB,GAChCmB,IAAa,WAAUE,EAAU,CAACpB,GAClCkB,IAAa,QAAOE,EAAUpB,GAElCC,EAA0B,IAAM,CACzBmB,IACLT,GAAA,MAAAA,EAAS,QAASG,GAAQM,GAC5B,EAAG,CAACN,EAAMH,EAASS,CAAO,CAAC,EAEtBA,EAIED,EAHE,IAIX,EACA,CACE,SAAUV,CACZ,CACF",
6
+ "names": ["jsx", "isTouchable", "isWeb", "useIsomorphicLayoutEffect", "withStaticProperties", "createContext", "createElement", "useContext", "useMemo", "useState", "AdaptParentContext", "AdaptContents", "props", "context", "useAdaptParent", "Contents", "when", "setWhen", "AdaptProviderView", "Adapt", "platform", "children", "enabled"]
7
7
  }
@@ -1,67 +1,2 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import {
3
- isTouchable,
4
- isWeb,
5
- useIsomorphicLayoutEffect,
6
- withStaticProperties
7
- } from "@tamagui/core";
8
- import { createContext, createElement, useContext, useMemo, useState } from "react";
9
- const AdaptParentContext = createContext(null);
10
- const AdaptContents = (props) => {
11
- const context = useContext(AdaptParentContext);
12
- if (!(context == null ? void 0 : context.Contents)) {
13
- throw new Error("Adapt not supported by this component");
14
- }
15
- return createElement(context.Contents, props);
16
- };
17
- AdaptContents["shouldForwardSpace"] = true;
18
- const useAdaptParent = ({
19
- Contents
20
- }) => {
21
- const [when, setWhen] = useState(null);
22
- const 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
- return {
33
- AdaptProvider,
34
- when
35
- };
36
- };
37
- const Adapt = withStaticProperties(
38
- function Adapt2({ platform, when, children }) {
39
- const context = useContext(AdaptParentContext);
40
- let enabled = !platform;
41
- if (platform === "touch")
42
- enabled = isTouchable;
43
- if (platform === "native")
44
- enabled = !isWeb;
45
- if (platform === "web")
46
- enabled = isWeb;
47
- useIsomorphicLayoutEffect(() => {
48
- if (!enabled)
49
- return;
50
- context == null ? void 0 : context.setWhen(when || enabled);
51
- }, [when, context, enabled]);
52
- if (!enabled) {
53
- return null;
54
- }
55
- return children;
56
- },
57
- {
58
- Contents: AdaptContents
59
- }
60
- );
61
- export {
62
- Adapt,
63
- AdaptContents,
64
- AdaptParentContext,
65
- useAdaptParent
66
- };
1
+ import{jsx as x}from"react/jsx-runtime";import{isTouchable as y,isWeb as i,useIsomorphicLayoutEffect as c,withStaticProperties as h}from"@tamagui/core";import{createContext as l,createElement as A,useContext as d,useMemo as C,useState as P}from"react";const a=l(null),s=r=>{const e=d(a);if(!(e!=null&&e.Contents))throw new Error("Adapt not supported by this component");return A(e.Contents,r)};s.shouldForwardSpace=!0;const W=({Contents:r})=>{const[e,o]=P(null);return{AdaptProvider:C(()=>{const n={Contents:r,setWhen:o};function t(u){return x(a.Provider,{value:n,children:u.children})}return t},[r]),when:e}},b=h(function({platform:e,when:o,children:p}){const n=d(a);let t=!e;return e==="touch"&&(t=y),e==="native"&&(t=!i),e==="web"&&(t=i),c(()=>{t&&(n==null||n.setWhen(o||t))},[o,n,t]),t?p:null},{Contents:s});export{b as Adapt,s as AdaptContents,a as AdaptParentContext,W as useAdaptParent};
67
2
  //# sourceMappingURL=Adapt.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/Adapt.tsx"],
4
4
  "sourcesContent": ["import {\n MediaQueryKey,\n isTouchable,\n isWeb,\n useIsomorphicLayoutEffect,\n withStaticProperties,\n} from '@tamagui/core'\nimport { createContext, createElement, useContext, useMemo, useState } from 'react'\n\ntype MediaQueryKeyString = MediaQueryKey extends string ? MediaQueryKey : never\n\nexport type AdaptProps = {\n when?: MediaQueryKeyString\n platform?: 'native' | 'web' | 'touch'\n children?: any\n}\n\ntype When = MediaQueryKeyString | boolean | null\n\ntype Component = (props: any) => any\ntype AdaptParentContextI = {\n Contents: Component\n setWhen: (when: When) => any\n}\n\nexport const AdaptParentContext = createContext<AdaptParentContextI | null>(null)\n\n// forward props\nexport const AdaptContents = (props: any) => {\n const context = useContext(AdaptParentContext)\n if (!context?.Contents) {\n throw new Error('Adapt not supported by this component')\n }\n return createElement(context.Contents, props)\n}\n\nAdaptContents['shouldForwardSpace'] = true\n\nexport const useAdaptParent = ({\n Contents,\n}: {\n Contents: AdaptParentContextI['Contents']\n}) => {\n const [when, setWhen] = useState<When>(null)\n\n const AdaptProvider = useMemo(() => {\n const context: AdaptParentContextI = {\n Contents,\n setWhen,\n }\n\n function AdaptProviderView(props: { children?: any }) {\n return (\n <AdaptParentContext.Provider value={context}>\n {props.children}\n </AdaptParentContext.Provider>\n )\n }\n\n return AdaptProviderView\n }, [Contents])\n\n return {\n AdaptProvider,\n when,\n }\n}\n\nexport const Adapt = withStaticProperties(\n function Adapt({ platform, when, children }: AdaptProps) {\n const context = useContext(AdaptParentContext)\n\n let enabled = !platform\n if (platform === 'touch') enabled = isTouchable\n if (platform === 'native') enabled = !isWeb\n if (platform === 'web') enabled = isWeb\n\n useIsomorphicLayoutEffect(() => {\n if (!enabled) return\n context?.setWhen((when || enabled) as When)\n }, [when, context, enabled])\n\n if (!enabled) {\n return null\n }\n\n return children\n },\n {\n Contents: AdaptContents,\n }\n)\n"],
5
- "mappings": "AAqDQ;AArDR;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,eAAe,YAAY,SAAS,gBAAgB;AAkBrE,MAAM,qBAAqB,cAA0C,IAAI;AAGzE,MAAM,gBAAgB,CAAC,UAAe;AAC3C,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,EAAC,mCAAS,WAAU;AACtB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACA,SAAO,cAAc,QAAQ,UAAU,KAAK;AAC9C;AAEA,cAAc,oBAAoB,IAAI;AAE/B,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AACF,MAEM;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAAe,IAAI;AAE3C,QAAM,gBAAgB,QAAQ,MAAM;AAClC,UAAM,UAA+B;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,aAAS,kBAAkB,OAA2B;AACpD,aACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACjC,gBAAM,UACT;AAAA,IAEJ;AAEA,WAAO;AAAA,EACT,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,QAAQ;AAAA,EACnB,SAASA,OAAM,EAAE,UAAU,MAAM,SAAS,GAAe;AACvD,UAAM,UAAU,WAAW,kBAAkB;AAE7C,QAAI,UAAU,CAAC;AACf,QAAI,aAAa;AAAS,gBAAU;AACpC,QAAI,aAAa;AAAU,gBAAU,CAAC;AACtC,QAAI,aAAa;AAAO,gBAAU;AAElC,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,EAAU,CAACpB,GAClCkB,IAAa,QAAOE,EAAUpB,GAElCC,EAA0B,IAAM,CACzBmB,IACLT,GAAA,MAAAA,EAAS,QAASG,GAAQM,GAC5B,EAAG,CAACN,EAAMH,EAASS,CAAO,CAAC,EAEtBA,EAIED,EAHE,IAIX,EACA,CACE,SAAUV,CACZ,CACF",
6
+ "names": ["jsx", "isTouchable", "isWeb", "useIsomorphicLayoutEffect", "withStaticProperties", "createContext", "createElement", "useContext", "useMemo", "useState", "AdaptParentContext", "AdaptContents", "props", "context", "useAdaptParent", "Contents", "when", "setWhen", "AdaptProviderView", "Adapt", "platform", "children", "enabled"]
7
7
  }
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./Adapt";
1
+ export*from"./Adapt";
2
2
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx"],
4
4
  "sourcesContent": ["export * from './Adapt'\n"],
5
- "mappings": "AAAA,cAAc;",
5
+ "mappings": "AAAA,WAAc",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- export * from "./Adapt";
1
+ export*from"./Adapt";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx"],
4
4
  "sourcesContent": ["export * from './Adapt'\n"],
5
- "mappings": "AAAA,cAAc;",
5
+ "mappings": "AAAA,WAAc",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/adapt",
3
- "version": "1.13.2",
3
+ "version": "1.13.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.13.2"
29
+ "@tamagui/core": "1.13.4"
30
30
  },
31
31
  "devDependencies": {
32
- "@tamagui/build": "1.13.2"
32
+ "@tamagui/build": "1.13.4"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"