@tamagui/adapt 1.0.1-rc.6 → 1.0.1-rc.7
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 +2 -0
- package/dist/cjs/Adapt.js.map +2 -2
- package/dist/esm/Adapt.js +1 -0
- package/dist/esm/Adapt.js.map +2 -2
- package/package.json +3 -3
- package/src/Adapt.tsx +5 -3
- package/types/Adapt.d.ts +1 -0
package/dist/cjs/Adapt.js
CHANGED
|
@@ -20,6 +20,7 @@ var Adapt_exports = {};
|
|
|
20
20
|
__export(Adapt_exports, {
|
|
21
21
|
Adapt: () => Adapt,
|
|
22
22
|
AdaptContents: () => AdaptContents,
|
|
23
|
+
AdaptParentContext: () => AdaptParentContext,
|
|
23
24
|
useAdaptParent: () => useAdaptParent
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(Adapt_exports);
|
|
@@ -84,6 +85,7 @@ const Adapt = (0, import_core.withStaticProperties)(
|
|
|
84
85
|
0 && (module.exports = {
|
|
85
86
|
Adapt,
|
|
86
87
|
AdaptContents,
|
|
88
|
+
AdaptParentContext,
|
|
87
89
|
useAdaptParent
|
|
88
90
|
});
|
|
89
91
|
//# sourceMappingURL=Adapt.js.map
|
package/dist/cjs/Adapt.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Adapt.tsx"],
|
|
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\nexport type AdaptProps = {\n when?: MediaQueryKey\n platform?: 'native' | 'web' | 'touch'\n children?: any\n}\n\ntype Component = (props: any) => any\ntype AdaptParentContextI = {\n Contents: Component\n setWhen: (when: MediaQueryKey) => any\n}\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
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\nexport type AdaptProps = {\n when?: MediaQueryKey\n platform?: 'native' | 'web' | 'touch'\n children?: any\n}\n\ntype Component = (props: any) => any\ntype AdaptParentContextI = {\n Contents: Component\n setWhen: (when: MediaQueryKey) => 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<MediaQueryKey | null>(null)\n\n const AdaptProvider = useMemo(() => {\n const context: AdaptParentContextI = {\n Contents,\n setWhen,\n }\n\n return (props: { children?: any }) => {\n return (\n <AdaptParentContext.Provider value={context}>\n {props.children}\n </AdaptParentContext.Provider>\n )\n }\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 as MediaQueryKey)\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;AAiDQ;A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@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Adapt.tsx"],
|
|
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\nexport type AdaptProps = {\n when?: MediaQueryKey\n platform?: 'native' | 'web' | 'touch'\n children?: any\n}\n\ntype Component = (props: any) => any\ntype AdaptParentContextI = {\n Contents: Component\n setWhen: (when: MediaQueryKey) => any\n}\n\
|
|
5
|
-
"mappings": "
|
|
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\nexport type AdaptProps = {\n when?: MediaQueryKey\n platform?: 'native' | 'web' | 'touch'\n children?: any\n}\n\ntype Component = (props: any) => any\ntype AdaptParentContextI = {\n Contents: Component\n setWhen: (when: MediaQueryKey) => 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<MediaQueryKey | null>(null)\n\n const AdaptProvider = useMemo(() => {\n const context: AdaptParentContextI = {\n Contents,\n setWhen,\n }\n\n return (props: { children?: any }) => {\n return (\n <AdaptParentContext.Provider value={context}>\n {props.children}\n </AdaptParentContext.Provider>\n )\n }\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 as MediaQueryKey)\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": "AAiDQ;AAjDR;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,eAAe,YAAY,SAAS,gBAAgB;AAcrE,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,wBAAwB;AAE/B,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AACF,MAEM;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAA+B,IAAI;AAE3D,QAAM,gBAAgB,QAAQ,MAAM;AAClC,UAAM,UAA+B;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,WAAO,CAAC,UAA8B;AACpC,aACE,oBAAC,mBAAmB,UAAnB;AAAA,QAA4B,OAAO;AAAA,QACjC,gBAAM;AAAA,OACT;AAAA,IAEJ;AAAA,EACF,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,8BAA0B,MAAM;AAC9B,UAAI,CAAC;AAAS;AACd,yCAAS,QAAQ;AAAA,IACnB,GAAG,CAAC,MAAM,SAAS,OAAO,CAAC;AAE3B,QAAI,CAAC,SAAS;AACZ,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,UAAU;AAAA,EACZ;AACF;",
|
|
6
6
|
"names": ["Adapt"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/adapt",
|
|
3
|
-
"version": "1.0.1-rc.
|
|
3
|
+
"version": "1.0.1-rc.7",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tamagui/core": "^1.0.1-rc.
|
|
21
|
+
"@tamagui/core": "^1.0.1-rc.7"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tamagui/build": "^1.0.1-rc.
|
|
24
|
+
"@tamagui/build": "^1.0.1-rc.7"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
package/src/Adapt.tsx
CHANGED
|
@@ -19,7 +19,7 @@ type AdaptParentContextI = {
|
|
|
19
19
|
setWhen: (when: MediaQueryKey) => any
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const AdaptParentContext = createContext<AdaptParentContextI | null>(null)
|
|
22
|
+
export const AdaptParentContext = createContext<AdaptParentContextI | null>(null)
|
|
23
23
|
|
|
24
24
|
// forward props
|
|
25
25
|
export const AdaptContents = (props: any) => {
|
|
@@ -34,7 +34,9 @@ AdaptContents['shouldForwardSpace'] = true
|
|
|
34
34
|
|
|
35
35
|
export const useAdaptParent = ({
|
|
36
36
|
Contents,
|
|
37
|
-
}: {
|
|
37
|
+
}: {
|
|
38
|
+
Contents: AdaptParentContextI['Contents']
|
|
39
|
+
}) => {
|
|
38
40
|
const [when, setWhen] = useState<MediaQueryKey | null>(null)
|
|
39
41
|
|
|
40
42
|
const AdaptProvider = useMemo(() => {
|
|
@@ -80,5 +82,5 @@ export const Adapt = withStaticProperties(
|
|
|
80
82
|
},
|
|
81
83
|
{
|
|
82
84
|
Contents: AdaptContents,
|
|
83
|
-
}
|
|
85
|
+
}
|
|
84
86
|
)
|
package/types/Adapt.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type AdaptParentContextI = {
|
|
|
10
10
|
Contents: Component;
|
|
11
11
|
setWhen: (when: MediaQueryKey) => any;
|
|
12
12
|
};
|
|
13
|
+
export declare const AdaptParentContext: import("react").Context<AdaptParentContextI | null>;
|
|
13
14
|
export declare const AdaptContents: {
|
|
14
15
|
(props: any): import("react").FunctionComponentElement<any>;
|
|
15
16
|
shouldForwardSpace: boolean;
|