@tamagui/adapt 1.0.1-rc.5 → 1.0.1-rc.6

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
@@ -29,13 +29,15 @@ var import_react = require("react");
29
29
  const AdaptParentContext = (0, import_react.createContext)(null);
30
30
  const AdaptContents = (props) => {
31
31
  const context = (0, import_react.useContext)(AdaptParentContext);
32
- if (!context || !context.Contents) {
33
- throw new Error(`Adapt not supported by this component`);
32
+ if (!(context == null ? void 0 : context.Contents)) {
33
+ throw new Error("Adapt not supported by this component");
34
34
  }
35
35
  return (0, import_react.createElement)(context.Contents, props);
36
36
  };
37
37
  AdaptContents["shouldForwardSpace"] = true;
38
- const useAdaptParent = ({ Contents }) => {
38
+ const useAdaptParent = ({
39
+ Contents
40
+ }) => {
39
41
  const [when, setWhen] = (0, import_react.useState)(null);
40
42
  const AdaptProvider = (0, import_react.useMemo)(() => {
41
43
  const context = {
@@ -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\nconst AdaptParentContext = createContext<AdaptParentContextI | null>(null)\n\n// forward props\nexport const AdaptContents = (props: any) => {\n const context = useContext(AdaptParentContext)\n if (!context || !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 = ({ Contents }: { Contents: AdaptParentContextI['Contents'] }) => {\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}>{props.children}</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;AA6CQ;AA7CR,kBAMO;AACP,mBAA4E;AAc5E,MAAM,yBAAqB,4BAA0C,IAAI;AAGlE,MAAM,gBAAgB,CAAC,UAAe;AAC3C,QAAM,cAAU,yBAAW,kBAAkB;AAC7C,MAAI,CAAC,WAAW,CAAC,QAAQ,UAAU;AACjC,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACA,aAAO,4BAAc,QAAQ,UAAU,KAAK;AAC9C;AAEA,cAAc,wBAAwB;AAE/B,MAAM,iBAAiB,CAAC,EAAE,SAAS,MAAqD;AAC7F,QAAM,CAAC,MAAM,OAAO,QAAI,uBAA+B,IAAI;AAE3D,QAAM,oBAAgB,sBAAQ,MAAM;AAClC,UAAM,UAA+B;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,WAAO,CAAC,UAA8B;AACpC,aACE,4CAAC,mBAAmB,UAAnB;AAAA,QAA4B,OAAO;AAAA,QAAU,gBAAM;AAAA,OAAS;AAAA,IAEjE;AAAA,EACF,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;AACvD,UAAM,cAAU,yBAAW,kBAAkB;AAE7C,QAAI,UAAU,CAAC;AACf,QAAI,aAAa;AAAS,gBAAU;AACpC,QAAI,aAAa;AAAU,gBAAU,CAAC;AACtC,QAAI,aAAa;AAAO,gBAAU;AAElC,+CAA0B,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;",
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\nconst 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}: { Contents: AdaptParentContextI['Contents'] }) => {\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;AA+CQ;AA/CR,kBAMO;AACP,mBAA4E;AAc5E,MAAM,yBAAqB,4BAA0C,IAAI;AAGlE,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,wBAAwB;AAE/B,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AACF,MAAqD;AACnD,QAAM,CAAC,MAAM,OAAO,QAAI,uBAA+B,IAAI;AAE3D,QAAM,oBAAgB,sBAAQ,MAAM;AAClC,UAAM,UAA+B;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,WAAO,CAAC,UAA8B;AACpC,aACE,4CAAC,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,YAAQ;AAAA,EACnB,SAASA,OAAM,EAAE,UAAU,MAAM,SAAS,GAAe;AACvD,UAAM,cAAU,yBAAW,kBAAkB;AAE7C,QAAI,UAAU,CAAC;AACf,QAAI,aAAa;AAAS,gBAAU;AACpC,QAAI,aAAa;AAAU,gBAAU,CAAC;AACtC,QAAI,aAAa;AAAO,gBAAU;AAElC,+CAA0B,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/dist/esm/Adapt.js CHANGED
@@ -9,13 +9,15 @@ import { createContext, createElement, useContext, useMemo, useState } from "rea
9
9
  const AdaptParentContext = createContext(null);
10
10
  const AdaptContents = (props) => {
11
11
  const context = useContext(AdaptParentContext);
12
- if (!context || !context.Contents) {
13
- throw new Error(`Adapt not supported by this component`);
12
+ if (!(context == null ? void 0 : context.Contents)) {
13
+ throw new Error("Adapt not supported by this component");
14
14
  }
15
15
  return createElement(context.Contents, props);
16
16
  };
17
17
  AdaptContents["shouldForwardSpace"] = true;
18
- const useAdaptParent = ({ Contents }) => {
18
+ const useAdaptParent = ({
19
+ Contents
20
+ }) => {
19
21
  const [when, setWhen] = useState(null);
20
22
  const AdaptProvider = useMemo(() => {
21
23
  const context = {
@@ -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\nconst AdaptParentContext = createContext<AdaptParentContextI | null>(null)\n\n// forward props\nexport const AdaptContents = (props: any) => {\n const context = useContext(AdaptParentContext)\n if (!context || !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 = ({ Contents }: { Contents: AdaptParentContextI['Contents'] }) => {\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}>{props.children}</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": "AA6CQ;AA7CR;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,eAAe,YAAY,SAAS,gBAAgB;AAc5E,MAAM,qBAAqB,cAA0C,IAAI;AAGlE,MAAM,gBAAgB,CAAC,UAAe;AAC3C,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,CAAC,WAAW,CAAC,QAAQ,UAAU;AACjC,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACA,SAAO,cAAc,QAAQ,UAAU,KAAK;AAC9C;AAEA,cAAc,wBAAwB;AAE/B,MAAM,iBAAiB,CAAC,EAAE,SAAS,MAAqD;AAC7F,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,QAAU,gBAAM;AAAA,OAAS;AAAA,IAEjE;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;",
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\nconst 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}: { Contents: AdaptParentContextI['Contents'] }) => {\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": "AA+CQ;AA/CR;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,eAAe,YAAY,SAAS,gBAAgB;AAc5E,MAAM,qBAAqB,cAA0C,IAAI;AAGlE,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,MAAqD;AACnD,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.5",
3
+ "version": "1.0.1-rc.6",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -12,16 +12,16 @@
12
12
  "scripts": {
13
13
  "build": "tamagui-build",
14
14
  "watch": "tamagui-build --watch",
15
- "lint": "eslint src",
16
- "lint:fix": "yarn lint --fix",
15
+ "lint": "../../node_modules/.bin/rome check src",
16
+ "lint:fix": "../../node_modules/.bin/rome check --apply-suggested src",
17
17
  "clean": "tamagui-build clean",
18
18
  "clean:build": "tamagui-build clean:build"
19
19
  },
20
20
  "dependencies": {
21
- "@tamagui/core": "^1.0.1-rc.5"
21
+ "@tamagui/core": "^1.0.1-rc.6"
22
22
  },
23
23
  "devDependencies": {
24
- "@tamagui/build": "^1.0.1-rc.5"
24
+ "@tamagui/build": "^1.0.1-rc.6"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
package/src/Adapt.tsx CHANGED
@@ -24,15 +24,17 @@ const AdaptParentContext = createContext<AdaptParentContextI | null>(null)
24
24
  // forward props
25
25
  export const AdaptContents = (props: any) => {
26
26
  const context = useContext(AdaptParentContext)
27
- if (!context || !context.Contents) {
28
- throw new Error(`Adapt not supported by this component`)
27
+ if (!context?.Contents) {
28
+ throw new Error('Adapt not supported by this component')
29
29
  }
30
30
  return createElement(context.Contents, props)
31
31
  }
32
32
 
33
33
  AdaptContents['shouldForwardSpace'] = true
34
34
 
35
- export const useAdaptParent = ({ Contents }: { Contents: AdaptParentContextI['Contents'] }) => {
35
+ export const useAdaptParent = ({
36
+ Contents,
37
+ }: { Contents: AdaptParentContextI['Contents'] }) => {
36
38
  const [when, setWhen] = useState<MediaQueryKey | null>(null)
37
39
 
38
40
  const AdaptProvider = useMemo(() => {
@@ -43,7 +45,9 @@ export const useAdaptParent = ({ Contents }: { Contents: AdaptParentContextI['Co
43
45
 
44
46
  return (props: { children?: any }) => {
45
47
  return (
46
- <AdaptParentContext.Provider value={context}>{props.children}</AdaptParentContext.Provider>
48
+ <AdaptParentContext.Provider value={context}>
49
+ {props.children}
50
+ </AdaptParentContext.Provider>
47
51
  )
48
52
  }
49
53
  }, [Contents])
@@ -76,5 +80,5 @@ export const Adapt = withStaticProperties(
76
80
  },
77
81
  {
78
82
  Contents: AdaptContents,
79
- }
83
+ },
80
84
  )
package/types/Adapt.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare const AdaptContents: {
14
14
  (props: any): import("react").FunctionComponentElement<any>;
15
15
  shouldForwardSpace: boolean;
16
16
  };
17
- export declare const useAdaptParent: ({ Contents }: {
17
+ export declare const useAdaptParent: ({ Contents, }: {
18
18
  Contents: AdaptParentContextI['Contents'];
19
19
  }) => {
20
20
  AdaptProvider: (props: {