@tamagui/adapt 1.115.4 → 1.116.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.cjs +124 -47
- package/dist/cjs/Adapt.cjs.map +1 -1
- package/dist/cjs/Adapt.native.js +100 -41
- package/dist/cjs/Adapt.native.js.map +2 -2
- package/dist/esm/Adapt.js +95 -35
- package/dist/esm/Adapt.js.map +1 -1
- package/dist/esm/Adapt.mjs +120 -46
- package/dist/esm/Adapt.mjs.map +1 -1
- package/dist/esm/Adapt.native.js +98 -41
- package/dist/esm/Adapt.native.js.map +2 -2
- package/package.json +6 -5
- package/src/Adapt.tsx +206 -71
- package/types/Adapt.d.ts +48 -25
- package/types/Adapt.d.ts.map +1 -1
package/dist/esm/Adapt.mjs
CHANGED
|
@@ -1,56 +1,130 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { isAndroid, isIos, isTouchable, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
|
-
import { useMedia } from "@tamagui/core";
|
|
2
|
+
import { createStyledContext, useMedia } from "@tamagui/core";
|
|
4
3
|
import { withStaticProperties } from "@tamagui/helpers";
|
|
4
|
+
import { PortalHost, PortalItem } from "@tamagui/portal";
|
|
5
|
+
import React, { createContext, useContext, useEffect, useId } from "react";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const CurrentAdaptContextScope = createContext(""),
|
|
8
|
+
AdaptContext = createStyledContext({
|
|
9
|
+
Contents: null,
|
|
10
|
+
scopeName: "",
|
|
11
|
+
portalName: "",
|
|
12
|
+
platform: null,
|
|
13
|
+
setPlatform: null,
|
|
14
|
+
when: null,
|
|
15
|
+
setChildren: null,
|
|
16
|
+
setWhen: null
|
|
17
|
+
}),
|
|
18
|
+
ProvideAdaptContext = ({
|
|
19
|
+
children,
|
|
20
|
+
...context
|
|
21
|
+
}) => {
|
|
22
|
+
const scope = context.scopeName || "";
|
|
23
|
+
return /* @__PURE__ */jsx(CurrentAdaptContextScope.Provider, {
|
|
24
|
+
value: scope,
|
|
25
|
+
children: /* @__PURE__ */jsx(AdaptContext.Provider, {
|
|
26
|
+
scope,
|
|
27
|
+
...context,
|
|
28
|
+
children
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
useAdaptContext = (scope = "") => {
|
|
33
|
+
const contextScope = useContext(CurrentAdaptContextScope);
|
|
34
|
+
return AdaptContext.useStyledContext(scope === "" && contextScope || scope);
|
|
35
|
+
},
|
|
36
|
+
AdaptPortals = /* @__PURE__ */new Map(),
|
|
37
|
+
AdaptParent = ({
|
|
38
|
+
children,
|
|
39
|
+
Contents,
|
|
40
|
+
scope,
|
|
41
|
+
portal
|
|
42
|
+
}) => {
|
|
43
|
+
const portalName = `AdaptPortal${scope}`,
|
|
44
|
+
id = useId();
|
|
45
|
+
let FinalContents = Contents || AdaptPortals.get(id);
|
|
46
|
+
FinalContents || (FinalContents = () => /* @__PURE__ */jsx(PortalHost, {
|
|
47
|
+
name: portalName,
|
|
48
|
+
forwardProps: typeof portal == "boolean" ? void 0 : portal?.forwardProps
|
|
49
|
+
}), AdaptPortals.set(id, FinalContents)), useEffect(() => () => {
|
|
50
|
+
AdaptPortals.delete(id);
|
|
51
|
+
}, []);
|
|
52
|
+
const [when, setWhen] = React.useState(null),
|
|
53
|
+
[platform, setPlatform] = React.useState(null),
|
|
54
|
+
[children2, setChildren] = React.useState(null);
|
|
55
|
+
return /* @__PURE__ */jsx(ProvideAdaptContext, {
|
|
56
|
+
Contents: FinalContents,
|
|
57
|
+
when,
|
|
58
|
+
platform,
|
|
59
|
+
setPlatform,
|
|
60
|
+
setWhen,
|
|
61
|
+
setChildren,
|
|
62
|
+
portalName,
|
|
63
|
+
scopeName: scope,
|
|
64
|
+
children
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
AdaptContents = ({
|
|
68
|
+
scope,
|
|
69
|
+
...rest
|
|
70
|
+
}) => {
|
|
71
|
+
const context = useAdaptContext(scope);
|
|
9
72
|
if (!context?.Contents) throw new Error(process.env.NODE_ENV === "production" ? "tamagui.dev/docs/intro/errors#warning-002" : "You're rendering a Tamagui <Adapt /> component without nesting it inside a parent that is able to adapt.");
|
|
10
|
-
return React.createElement(context.Contents,
|
|
73
|
+
return React.createElement(context.Contents, {
|
|
74
|
+
...rest,
|
|
75
|
+
key: "stable"
|
|
76
|
+
});
|
|
11
77
|
};
|
|
12
78
|
AdaptContents.shouldForwardSpace = !0;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
79
|
+
const Adapt = withStaticProperties(function (props) {
|
|
80
|
+
const {
|
|
81
|
+
platform,
|
|
82
|
+
when,
|
|
83
|
+
children,
|
|
84
|
+
scope
|
|
85
|
+
} = props,
|
|
86
|
+
context = useAdaptContext(scope),
|
|
87
|
+
scopeName = scope ?? context.scopeName,
|
|
88
|
+
enabled = useAdaptIsActiveGiven(props);
|
|
89
|
+
useIsomorphicLayoutEffect(() => {
|
|
90
|
+
context?.setWhen(when || enabled), context?.setPlatform(platform || null);
|
|
91
|
+
}, [when, platform, context, enabled]), useIsomorphicLayoutEffect(() => () => {
|
|
92
|
+
context?.setWhen(null);
|
|
93
|
+
}, []);
|
|
94
|
+
let output;
|
|
95
|
+
if (typeof children == "function") {
|
|
96
|
+
const Component = context?.Contents;
|
|
97
|
+
output = children(Component ? /* @__PURE__ */jsx(Component, {}) : null);
|
|
98
|
+
} else output = children;
|
|
99
|
+
return useEffect(() => {
|
|
100
|
+
typeof children == "function" && output !== void 0 && context?.setChildren(output);
|
|
101
|
+
}, [output]), /* @__PURE__ */jsx(CurrentAdaptContextScope.Provider, {
|
|
102
|
+
value: scopeName,
|
|
103
|
+
children: enabled ? output : null
|
|
104
|
+
});
|
|
105
|
+
}, {
|
|
106
|
+
Contents: AdaptContents
|
|
107
|
+
}),
|
|
108
|
+
AdaptPortalContents = props => {
|
|
109
|
+
const {
|
|
110
|
+
portalName
|
|
111
|
+
} = useAdaptContext(props.scope);
|
|
112
|
+
return /* @__PURE__ */jsx(PortalItem, {
|
|
113
|
+
hostName: portalName,
|
|
114
|
+
children: props.children
|
|
115
|
+
});
|
|
33
116
|
},
|
|
34
|
-
|
|
35
|
-
platform,
|
|
117
|
+
useAdaptIsActiveGiven = ({
|
|
36
118
|
when,
|
|
37
|
-
|
|
38
|
-
}) {
|
|
39
|
-
const
|
|
40
|
-
media = useMedia();
|
|
119
|
+
platform
|
|
120
|
+
}) => {
|
|
121
|
+
const media = useMedia();
|
|
41
122
|
let enabled = !1;
|
|
42
|
-
return typeof when == "
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
enabled,
|
|
50
|
-
media
|
|
51
|
-
}) : children : null;
|
|
52
|
-
}, {
|
|
53
|
-
Contents: AdaptContents
|
|
54
|
-
});
|
|
55
|
-
export { Adapt, AdaptContents, AdaptParentContext, useAdaptParent };
|
|
123
|
+
return platform === "touch" && (enabled = isTouchable), platform === "native" && (enabled = !isWeb), platform === "web" && (enabled = isWeb), platform === "ios" && (enabled = isIos), platform === "android" && (enabled = isAndroid), when && typeof when == "string" && !media[when] && (enabled = !1), enabled;
|
|
124
|
+
},
|
|
125
|
+
useAdaptIsActive = scope => {
|
|
126
|
+
const props = useAdaptContext(scope);
|
|
127
|
+
return useAdaptIsActiveGiven(props);
|
|
128
|
+
};
|
|
129
|
+
export { Adapt, AdaptContents, AdaptContext, AdaptParent, AdaptPortalContents, useAdaptContext, useAdaptIsActive };
|
|
56
130
|
//# sourceMappingURL=Adapt.mjs.map
|
package/dist/esm/Adapt.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isAndroid","isIos","isTouchable","isWeb","useIsomorphicLayoutEffect","createStyledContext","useMedia","withStaticProperties","PortalHost","PortalItem","React","createContext","useContext","useEffect","useId","jsx","CurrentAdaptContextScope","AdaptContext","Contents","scopeName","portalName","platform","setPlatform","when","setChildren","setWhen","ProvideAdaptContext","children","context","scope","Provider","value","useAdaptContext","contextScope","useStyledContext","AdaptPortals","Map","AdaptParent","portal","id","FinalContents","get","name","forwardProps","set","delete","useState","children2","AdaptContents","rest","Error","process","env","NODE_ENV","createElement","key","shouldForwardSpace","Adapt","props","enabled","useAdaptIsActiveGiven","output","Component","AdaptPortalContents","hostName","media","useAdaptIsActive"],"sources":["../../src/Adapt.tsx"],"sourcesContent":[null],"mappings":"AAAA,SACEA,SAAA,EACAC,KAAA,EACAC,WAAA,EACAC,KAAA,EACAC,yBAAA,QACK;AAEP,SAASC,mBAAA,EAAqBC,QAAA,QAAgB;AAC9C,SAASC,oBAAA,QAA4B;AACrC,SAASC,UAAA,EAAYC,UAAA,QAAkB;AACvC,OAAOC,KAAA,IAASC,aAAA,EAAeC,UAAA,EAAYC,SAAA,EAAWC,KAAA,QAAa;AAwD7D,SAAAC,GAAA;AArBN,MAAMC,wBAAA,GAA2BL,aAAA,CAAc,EAAE;EAEpCM,YAAA,GAAeZ,mBAAA,CAAyC;IACnEa,QAAA,EAAU;IACVC,SAAA,EAAW;IACXC,UAAA,EAAY;IACZC,QAAA,EAAU;IACVC,WAAA,EAAa;IACbC,IAAA,EAAM;IACNC,WAAA,EAAa;IACbC,OAAA,EAAS;EACX,CAAC;EAEKC,mBAAA,GAAsBA,CAAC;IAC3BC,QAAA;IACA,GAAGC;EACL,MAA+C;IAC7C,MAAMC,KAAA,GAAQD,OAAA,CAAQT,SAAA,IAAa;IAEnC,OACE,eAAAJ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EaO,gBAAA,GAAoBrC,KAAA,IAAmB;IAClD,MAAM6B,KAAA,GAAQ1B,eAAA,CAAgBH,KAAK;IACnC,OAAO+B,qBAAA,CAAsBF,KAAK;EACpC","ignoreList":[]}
|
package/dist/esm/Adapt.native.js
CHANGED
|
@@ -1,59 +1,116 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
2
|
import { isAndroid, isIos, isTouchable, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
4
|
-
import { useMedia } from "@tamagui/core";
|
|
3
|
+
import { createStyledContext, useMedia } from "@tamagui/core";
|
|
5
4
|
import { withStaticProperties } from "@tamagui/helpers";
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { PortalHost, PortalItem } from "@tamagui/portal";
|
|
6
|
+
import React, { createContext, useContext, useEffect, useId } from "react";
|
|
7
|
+
var CurrentAdaptContextScope = /* @__PURE__ */ createContext(""), AdaptContext = createStyledContext({
|
|
8
|
+
Contents: null,
|
|
9
|
+
scopeName: "",
|
|
10
|
+
portalName: "",
|
|
11
|
+
platform: null,
|
|
12
|
+
setPlatform: null,
|
|
13
|
+
when: null,
|
|
14
|
+
setChildren: null,
|
|
15
|
+
setWhen: null
|
|
16
|
+
}), ProvideAdaptContext = function(param) {
|
|
17
|
+
var { children, ...context } = param, scope = context.scopeName || "";
|
|
18
|
+
return /* @__PURE__ */ _jsx(CurrentAdaptContextScope.Provider, {
|
|
19
|
+
value: scope,
|
|
20
|
+
children: /* @__PURE__ */ _jsx(AdaptContext.Provider, {
|
|
21
|
+
scope,
|
|
22
|
+
...context,
|
|
23
|
+
children
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}, useAdaptContext = function() {
|
|
27
|
+
var scope = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", contextScope = useContext(CurrentAdaptContextScope), context = AdaptContext.useStyledContext(scope === "" && contextScope || scope);
|
|
28
|
+
return context;
|
|
29
|
+
}, AdaptPortals = /* @__PURE__ */ new Map(), AdaptParent = function(param) {
|
|
30
|
+
var { children, Contents, scope, portal } = param, portalName = `AdaptPortal${scope}`, id = useId(), FinalContents = Contents || AdaptPortals.get(id);
|
|
31
|
+
FinalContents || (FinalContents = function() {
|
|
32
|
+
return /* @__PURE__ */ _jsx(PortalHost, {
|
|
33
|
+
name: portalName,
|
|
34
|
+
forwardProps: typeof portal == "boolean" ? void 0 : portal?.forwardProps
|
|
35
|
+
});
|
|
36
|
+
}, AdaptPortals.set(id, FinalContents)), useEffect(function() {
|
|
37
|
+
return function() {
|
|
38
|
+
AdaptPortals.delete(id);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
var [when, setWhen] = React.useState(null), [platform, setPlatform] = React.useState(null), [children2, setChildren] = React.useState(null);
|
|
42
|
+
return /* @__PURE__ */ _jsx(ProvideAdaptContext, {
|
|
43
|
+
Contents: FinalContents,
|
|
44
|
+
when,
|
|
45
|
+
platform,
|
|
46
|
+
setPlatform,
|
|
47
|
+
setWhen,
|
|
48
|
+
setChildren,
|
|
49
|
+
portalName,
|
|
50
|
+
scopeName: scope,
|
|
51
|
+
children
|
|
52
|
+
});
|
|
53
|
+
}, AdaptContents = function(param) {
|
|
54
|
+
var { scope, ...rest } = param, context = useAdaptContext(scope);
|
|
8
55
|
if (!context?.Contents)
|
|
9
56
|
throw new Error(process.env.NODE_ENV === "production" ? "tamagui.dev/docs/intro/errors#warning-002" : "You're rendering a Tamagui <Adapt /> component without nesting it inside a parent that is able to adapt.");
|
|
10
|
-
return /* @__PURE__ */ React.createElement(context.Contents,
|
|
57
|
+
return /* @__PURE__ */ React.createElement(context.Contents, {
|
|
58
|
+
...rest,
|
|
59
|
+
key: "stable"
|
|
60
|
+
});
|
|
11
61
|
};
|
|
12
62
|
AdaptContents.shouldForwardSpace = !0;
|
|
13
|
-
var
|
|
14
|
-
var {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
setWhen
|
|
18
|
-
};
|
|
19
|
-
function AdaptProviderView(props) {
|
|
20
|
-
return /* @__PURE__ */ _jsx(AdaptParentContext.Provider, {
|
|
21
|
-
value: context,
|
|
22
|
-
children: props.children
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return AdaptProviderView;
|
|
26
|
-
}, [
|
|
27
|
-
Contents
|
|
28
|
-
]);
|
|
29
|
-
return {
|
|
30
|
-
AdaptProvider,
|
|
31
|
-
when
|
|
32
|
-
};
|
|
33
|
-
}, Adapt = withStaticProperties(function(param) {
|
|
34
|
-
var { platform, when, children } = param, context = React.useContext(AdaptParentContext), media = useMedia(), enabled = !1;
|
|
35
|
-
return typeof when == "function" ? enabled = when({
|
|
36
|
-
media
|
|
37
|
-
}) : (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() {
|
|
38
|
-
if (enabled)
|
|
39
|
-
return context?.setWhen(when || enabled), function() {
|
|
40
|
-
context?.setWhen(null);
|
|
41
|
-
};
|
|
63
|
+
var Adapt = withStaticProperties(function(props) {
|
|
64
|
+
var { platform, when, children, scope } = props, context = useAdaptContext(scope), scopeName = scope ?? context.scopeName, enabled = useAdaptIsActiveGiven(props);
|
|
65
|
+
useIsomorphicLayoutEffect(function() {
|
|
66
|
+
context?.setWhen(when || enabled), context?.setPlatform(platform || null);
|
|
42
67
|
}, [
|
|
43
68
|
when,
|
|
69
|
+
platform,
|
|
44
70
|
context,
|
|
45
71
|
enabled
|
|
46
|
-
]),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
]), useIsomorphicLayoutEffect(function() {
|
|
73
|
+
return function() {
|
|
74
|
+
context?.setWhen(null);
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
77
|
+
var output;
|
|
78
|
+
if (typeof children == "function") {
|
|
79
|
+
var Component = context?.Contents;
|
|
80
|
+
output = children(Component ? /* @__PURE__ */ _jsx(Component, {}) : null);
|
|
81
|
+
} else
|
|
82
|
+
output = children;
|
|
83
|
+
return useEffect(function() {
|
|
84
|
+
typeof children == "function" && output !== void 0 && context?.setChildren(output);
|
|
85
|
+
}, [
|
|
86
|
+
output
|
|
87
|
+
]), /* @__PURE__ */ _jsx(CurrentAdaptContextScope.Provider, {
|
|
88
|
+
value: scopeName,
|
|
89
|
+
children: enabled ? output : null
|
|
90
|
+
});
|
|
50
91
|
}, {
|
|
51
92
|
Contents: AdaptContents
|
|
52
|
-
})
|
|
93
|
+
}), AdaptPortalContents = function(props) {
|
|
94
|
+
var { portalName } = useAdaptContext(props.scope);
|
|
95
|
+
return /* @__PURE__ */ _jsx(PortalItem, {
|
|
96
|
+
// passthrough={!isWeb && !isActive}
|
|
97
|
+
hostName: portalName,
|
|
98
|
+
children: props.children
|
|
99
|
+
});
|
|
100
|
+
}, useAdaptIsActiveGiven = function(param) {
|
|
101
|
+
var { when, platform } = param, media = useMedia(), enabled = !1;
|
|
102
|
+
return platform === "touch" && (enabled = isTouchable), platform === "native" && (enabled = !isWeb), platform === "web" && (enabled = isWeb), platform === "ios" && (enabled = isIos), platform === "android" && (enabled = isAndroid), when && typeof when == "string" && !media[when] && (enabled = !1), enabled;
|
|
103
|
+
}, useAdaptIsActive = function(scope) {
|
|
104
|
+
var props = useAdaptContext(scope);
|
|
105
|
+
return useAdaptIsActiveGiven(props);
|
|
106
|
+
};
|
|
53
107
|
export {
|
|
54
108
|
Adapt,
|
|
55
109
|
AdaptContents,
|
|
56
|
-
|
|
57
|
-
|
|
110
|
+
AdaptContext,
|
|
111
|
+
AdaptParent,
|
|
112
|
+
AdaptPortalContents,
|
|
113
|
+
useAdaptContext,
|
|
114
|
+
useAdaptIsActive
|
|
58
115
|
};
|
|
59
116
|
//# sourceMappingURL=Adapt.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3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;AAClC,QAAMoC,YAAYnC,SAASV;AAC3B4C,aAASnC,SAASoC,YAAY,qBAACA,WAAAA,CAAAA,CAAAA,IAAe,IAAA;EAChD;AACED,aAASnC;AAKXb,mBAAU,WAAA;AACR,IAAI,OAAOa,YAAa,cAAcmC,WAAWlB,UAC/ChB,SAASJ,YAAYsC,MAAAA;EAEzB,GAAG;IAACA;GAAO,GAGT,qBAAC9C,yBAAyBc,UAAQ;IAACC,OAAOZ;cACtCyC,UAAiBE,SAAP;;AAGlB,GACA;EACE5C,UAAU+B;AACZ,CAAA,GAGWe,sBAAsB,SAACL,OAAAA;AAKlC,MAAM,EAAEvC,WAAU,IAAKY,gBAAgB2B,MAAM9B,KAAK;AAMlD,SACE,qBAACnB,YAAAA;;IAECuD,UAAU7C;cAETuC,MAAMhC;;AAGb,GAEMkC,wBAAwB,SAAA,OAAA;MAAC,EAC7BtC,MACAF,SAAQ,IAC8B,OAChC6C,QAAQ3D,SAAAA,GAEVqD,UAAU;AAEd,SAAIvC,aAAa,YAASuC,UAAUzD,cAChCkB,aAAa,aAAUuC,UAAU,CAACxD,QAClCiB,aAAa,UAAOuC,UAAUxD,QAC9BiB,aAAa,UAAOuC,UAAU1D,QAC9BmB,aAAa,cAAWuC,UAAU3D,YAElCsB,QAAQ,OAAOA,QAAS,YAAY,CAAC2C,MAAM3C,IAAAA,MAC7CqC,UAAU,KAGLA;AACT,GAEaO,mBAAmB,SAACtC,OAAAA;AAC/B,MAAM8B,QAAQ3B,gBAAgBH,KAAAA;AAC9B,SAAOgC,sBAAsBF,KAAAA;AAC/B;",
|
|
5
|
+
"names": ["isAndroid", "isIos", "isTouchable", "isWeb", "useIsomorphicLayoutEffect", "createStyledContext", "useMedia", "withStaticProperties", "PortalHost", "PortalItem", "React", "createContext", "useContext", "useEffect", "useId", "CurrentAdaptContextScope", "AdaptContext", "Contents", "scopeName", "portalName", "platform", "setPlatform", "when", "setChildren", "setWhen", "ProvideAdaptContext", "children", "context", "scope", "Provider", "value", "useAdaptContext", "contextScope", "useStyledContext", "AdaptPortals", "Map", "AdaptParent", "portal", "id", "FinalContents", "get", "name", "forwardProps", "undefined", "set", "delete", "useState", "children2", "AdaptContents", "rest", "Error", "process", "env", "NODE_ENV", "createElement", "key", "shouldForwardSpace", "Adapt", "props", "enabled", "useAdaptIsActiveGiven", "output", "Component", "AdaptPortalContents", "hostName", "media", "useAdaptIsActive"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/adapt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.116.0",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -29,12 +29,13 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tamagui/constants": "1.
|
|
33
|
-
"@tamagui/core": "1.
|
|
34
|
-
"@tamagui/helpers": "1.
|
|
32
|
+
"@tamagui/constants": "1.116.0",
|
|
33
|
+
"@tamagui/core": "1.116.0",
|
|
34
|
+
"@tamagui/helpers": "1.116.0",
|
|
35
|
+
"@tamagui/portal": "1.116.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@tamagui/build": "1.
|
|
38
|
+
"@tamagui/build": "1.116.0"
|
|
38
39
|
},
|
|
39
40
|
"publishConfig": {
|
|
40
41
|
"access": "public"
|