@tamagui/adapt 2.0.0-rc.26 → 2.0.0-rc.26-1773452370596
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/package.json +7 -7
- package/dist/cjs/Adapt.js +0 -184
- package/dist/cjs/Adapt.js.map +0 -6
- package/dist/esm/Adapt.js +0 -173
- package/dist/esm/Adapt.js.map +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/adapt",
|
|
3
|
-
"version": "2.0.0-rc.26",
|
|
3
|
+
"version": "2.0.0-rc.26-1773452370596",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"types",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"clean:build": "tamagui-build clean:build"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@tamagui/constants": "2.0.0-rc.26",
|
|
39
|
-
"@tamagui/core": "2.0.0-rc.26",
|
|
40
|
-
"@tamagui/helpers": "2.0.0-rc.26",
|
|
41
|
-
"@tamagui/portal": "2.0.0-rc.26",
|
|
42
|
-
"@tamagui/z-index-stack": "2.0.0-rc.26"
|
|
38
|
+
"@tamagui/constants": "2.0.0-rc.26-1773452370596",
|
|
39
|
+
"@tamagui/core": "2.0.0-rc.26-1773452370596",
|
|
40
|
+
"@tamagui/helpers": "2.0.0-rc.26-1773452370596",
|
|
41
|
+
"@tamagui/portal": "2.0.0-rc.26-1773452370596",
|
|
42
|
+
"@tamagui/z-index-stack": "2.0.0-rc.26-1773452370596"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tamagui/build": "2.0.0-rc.26",
|
|
45
|
+
"@tamagui/build": "2.0.0-rc.26-1773452370596",
|
|
46
46
|
"react": ">=19"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
package/dist/cjs/Adapt.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var Adapt_exports = {};
|
|
24
|
-
__export(Adapt_exports, {
|
|
25
|
-
Adapt: () => Adapt,
|
|
26
|
-
AdaptContents: () => AdaptContents,
|
|
27
|
-
AdaptContext: () => AdaptContext,
|
|
28
|
-
AdaptParent: () => AdaptParent,
|
|
29
|
-
AdaptPortalContents: () => AdaptPortalContents,
|
|
30
|
-
ProvideAdaptContext: () => ProvideAdaptContext,
|
|
31
|
-
useAdaptContext: () => useAdaptContext,
|
|
32
|
-
useAdaptIsActive: () => useAdaptIsActive
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(Adapt_exports);
|
|
35
|
-
var import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_helpers = require("@tamagui/helpers"), import_native = require("@tamagui/native"), import_portal = require("@tamagui/portal"), import_z_index_stack = require("@tamagui/z-index-stack"), import_react = __toESM(require("react"), 1), import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
function createAdaptChildrenStore() {
|
|
37
|
-
let children = null;
|
|
38
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
39
|
-
return {
|
|
40
|
-
set(c) {
|
|
41
|
-
children = c;
|
|
42
|
-
for (const l of listeners) l();
|
|
43
|
-
},
|
|
44
|
-
get: () => children,
|
|
45
|
-
subscribe(callback) {
|
|
46
|
-
return listeners.add(callback), () => listeners.delete(callback);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const AdaptChildrenStoreContext = (0, import_react.createContext)(null), emptySubscribe = () => () => {
|
|
51
|
-
}, emptyGet = () => null;
|
|
52
|
-
function TeleportAdaptContents() {
|
|
53
|
-
const store = (0, import_react.useContext)(AdaptChildrenStoreContext), children = import_react.default.useSyncExternalStore(
|
|
54
|
-
store?.subscribe ?? emptySubscribe,
|
|
55
|
-
store?.get ?? emptyGet,
|
|
56
|
-
store?.get ?? emptyGet
|
|
57
|
-
);
|
|
58
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
59
|
-
}
|
|
60
|
-
const AdaptContext = (0, import_core.createStyledContext)({
|
|
61
|
-
Contents: null,
|
|
62
|
-
scopeName: "",
|
|
63
|
-
portalName: "",
|
|
64
|
-
platform: null,
|
|
65
|
-
setPlatform: (x) => {
|
|
66
|
-
},
|
|
67
|
-
when: null,
|
|
68
|
-
setWhen: () => {
|
|
69
|
-
}
|
|
70
|
-
}), LastAdaptContextScope = (0, import_react.createContext)(""), ProvideAdaptContext = ({
|
|
71
|
-
children,
|
|
72
|
-
...context
|
|
73
|
-
}) => {
|
|
74
|
-
const scope = context.scopeName || "", lastScope = (0, import_react.useContext)(LastAdaptContextScope);
|
|
75
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LastAdaptContextScope.Provider, { value: lastScope || context.lastScope || "", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
|
-
AdaptContext.Provider,
|
|
77
|
-
{
|
|
78
|
-
scope,
|
|
79
|
-
lastScope: lastScope || context.lastScope,
|
|
80
|
-
...context,
|
|
81
|
-
children
|
|
82
|
-
}
|
|
83
|
-
) });
|
|
84
|
-
}, useAdaptContext = (scope) => {
|
|
85
|
-
const lastScope = (0, import_react.useContext)(LastAdaptContextScope), adaptScope = scope ?? lastScope;
|
|
86
|
-
return AdaptContext.useStyledContext(adaptScope);
|
|
87
|
-
}, AdaptPortals = /* @__PURE__ */ new Map(), AdaptParent = ({ children, Contents, scope, portal }) => {
|
|
88
|
-
const id = (0, import_react.useId)(), portalName = `AdaptPortal${scope}${id}`, childrenStoreRef = import_react.default.useRef(null);
|
|
89
|
-
childrenStoreRef.current || (childrenStoreRef.current = createAdaptChildrenStore());
|
|
90
|
-
const isTeleport = !1, FinalContents = (0, import_react.useMemo)(() => {
|
|
91
|
-
if (Contents)
|
|
92
|
-
return Contents;
|
|
93
|
-
if (isTeleport)
|
|
94
|
-
return TeleportAdaptContents;
|
|
95
|
-
if (AdaptPortals.has(portalName))
|
|
96
|
-
return AdaptPortals.get(portalName);
|
|
97
|
-
const element = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
-
import_portal.PortalHost,
|
|
99
|
-
{
|
|
100
|
-
name: portalName,
|
|
101
|
-
forwardProps: typeof portal == "boolean" ? void 0 : portal?.forwardProps
|
|
102
|
-
},
|
|
103
|
-
id
|
|
104
|
-
);
|
|
105
|
-
return AdaptPortals.set(portalName, element), element;
|
|
106
|
-
}, [portalName, Contents, isTeleport]);
|
|
107
|
-
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
108
|
-
if (!isTeleport)
|
|
109
|
-
return AdaptPortals.set(portalName, FinalContents), () => {
|
|
110
|
-
AdaptPortals.delete(portalName);
|
|
111
|
-
};
|
|
112
|
-
}, [portalName, isTeleport]);
|
|
113
|
-
const [when, setWhen] = import_react.default.useState(null), [platform, setPlatform] = import_react.default.useState(null);
|
|
114
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptChildrenStoreContext.Provider, { value: childrenStoreRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LastAdaptContextScope.Provider, { value: scope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
-
ProvideAdaptContext,
|
|
116
|
-
{
|
|
117
|
-
Contents: FinalContents,
|
|
118
|
-
when,
|
|
119
|
-
platform,
|
|
120
|
-
setPlatform,
|
|
121
|
-
setWhen,
|
|
122
|
-
portalName,
|
|
123
|
-
scopeName: scope,
|
|
124
|
-
children
|
|
125
|
-
}
|
|
126
|
-
) }) });
|
|
127
|
-
}, AdaptContents = ({ scope, ...rest }) => {
|
|
128
|
-
const context = useAdaptContext(scope);
|
|
129
|
-
if (!context?.Contents)
|
|
130
|
-
throw new Error(
|
|
131
|
-
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."
|
|
132
|
-
);
|
|
133
|
-
return import_react.default.createElement(context.Contents, { ...rest, key: "stable" });
|
|
134
|
-
};
|
|
135
|
-
AdaptContents.shouldForwardSpace = !0;
|
|
136
|
-
const Adapt = (0, import_helpers.withStaticProperties)(
|
|
137
|
-
function(props) {
|
|
138
|
-
const { platform, when, children, scope } = props, context = useAdaptContext(scope), enabled = useAdaptIsActiveGiven(props);
|
|
139
|
-
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
140
|
-
context?.setWhen?.(when || enabled), context?.setPlatform?.(platform || null);
|
|
141
|
-
}, [when, platform, enabled, context.setWhen, context.setPlatform]), (0, import_constants.useIsomorphicLayoutEffect)(() => () => {
|
|
142
|
-
context?.setWhen?.(null), context?.setPlatform?.(null);
|
|
143
|
-
}, []);
|
|
144
|
-
let output;
|
|
145
|
-
if (typeof children == "function") {
|
|
146
|
-
const Component = context?.Contents;
|
|
147
|
-
output = children(Component ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) : null);
|
|
148
|
-
} else
|
|
149
|
-
output = children;
|
|
150
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_z_index_stack.StackZIndexContext, { children: enabled ? output : null });
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
Contents: AdaptContents
|
|
154
|
-
}
|
|
155
|
-
), AdaptPortalContents = (props) => {
|
|
156
|
-
const isActive = useAdaptIsActive(props.scope), { portalName } = useAdaptContext(props.scope), childrenStore = (0, import_react.useContext)(AdaptChildrenStoreContext);
|
|
157
|
-
return !import_constants.isWeb && (0, import_native.getPortal)().state.type === "teleport" && childrenStore ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptPortalTeleport, { isActive, store: childrenStore, children: props.children }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { passThrough: !isActive, hostName: portalName, children: props.children });
|
|
158
|
-
};
|
|
159
|
-
function AdaptPortalTeleport({
|
|
160
|
-
isActive,
|
|
161
|
-
store,
|
|
162
|
-
children
|
|
163
|
-
}) {
|
|
164
|
-
return (0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
165
|
-
if (isActive)
|
|
166
|
-
return store.set(children), () => store.set(null);
|
|
167
|
-
}), isActive ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
168
|
-
}
|
|
169
|
-
const useAdaptIsActiveGiven = ({
|
|
170
|
-
when,
|
|
171
|
-
platform
|
|
172
|
-
}) => {
|
|
173
|
-
const media = (0, import_core.useMedia)();
|
|
174
|
-
if (when == null && platform == null)
|
|
175
|
-
return !1;
|
|
176
|
-
if (when === !0)
|
|
177
|
-
return !0;
|
|
178
|
-
let enabled = !1;
|
|
179
|
-
return platform === "touch" ? enabled = import_constants.isTouchable : platform === "native" ? enabled = !import_constants.isWeb : platform === "web" ? enabled = import_constants.isWeb : platform === "ios" ? enabled = import_constants.isIos : platform === "android" && (enabled = import_constants.isAndroid), platform && enabled == !1 ? !1 : (when && typeof when == "string" && (enabled = media[when]), enabled);
|
|
180
|
-
}, useAdaptIsActive = (scope) => {
|
|
181
|
-
const props = useAdaptContext(scope);
|
|
182
|
-
return useAdaptIsActiveGiven(props);
|
|
183
|
-
};
|
|
184
|
-
//# sourceMappingURL=Adapt.js.map
|
package/dist/cjs/Adapt.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Adapt.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMO,+BAEP,cAA8C,0BAC9C,iBAAqC,6BACrC,gBAA0B,4BAC1B,gBAAuC,4BACvC,uBAAmC,mCACnC,eAAiE,8BA2CxD;AA7BT,SAAS,2BAA+C;AACtD,MAAI,WAA4B;AAChC,QAAM,YAAY,oBAAI,IAAgB;AACtC,SAAO;AAAA,IACL,IAAI,GAAG;AACL,iBAAW;AACX,iBAAW,KAAK,UAAW,GAAE;AAAA,IAC/B;AAAA,IACA,KAAK,MAAM;AAAA,IACX,UAAU,UAAU;AAClB,uBAAU,IAAI,QAAQ,GACf,MAAM,UAAU,OAAO,QAAQ;AAAA,IACxC;AAAA,EACF;AACF;AAEA,MAAM,gCAA4B,4BAAyC,IAAI,GAEzE,iBAAiB,MAAM,MAAM;AAAC,GAC9B,WAAW,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GT,MAAI,UAAU;AAQd,SANI,aAAa,UAAS,UAAU,+BAC3B,aAAa,WAAU,UAAU,CAAC,yBAClC,aAAa,QAAO,UAAU,yBAC9B,aAAa,QAAO,UAAU,yBAC9B,aAAa,cAAW,UAAU,6BAEvC,YAAY,WAAW,KAClB,MAGL,QAAQ,OAAO,QAAS,aAC1B,UAAU,MAAM,IAAI,IAGf;AACT,GAEa,mBAAmB,CAAC,UAAmB;AAClD,QAAM,QAAQ,gBAAgB,KAAK;AACnC,SAAO,sBAAsB,KAAK;AACpC;",
|
|
5
|
-
"names": ["React"]
|
|
6
|
-
}
|
package/dist/esm/Adapt.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isAndroid,
|
|
3
|
-
isIos,
|
|
4
|
-
isTouchable,
|
|
5
|
-
isWeb,
|
|
6
|
-
useIsomorphicLayoutEffect
|
|
7
|
-
} from "@tamagui/constants";
|
|
8
|
-
import { createStyledContext, useMedia } from "@tamagui/core";
|
|
9
|
-
import { withStaticProperties } from "@tamagui/helpers";
|
|
10
|
-
import { getPortal } from "@tamagui/native";
|
|
11
|
-
import { PortalHost, PortalItem } from "@tamagui/portal";
|
|
12
|
-
import { StackZIndexContext } from "@tamagui/z-index-stack";
|
|
13
|
-
import React, { createContext, useContext, useId, useMemo } from "react";
|
|
14
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
15
|
-
function createAdaptChildrenStore() {
|
|
16
|
-
let children = null;
|
|
17
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
18
|
-
return {
|
|
19
|
-
set(c) {
|
|
20
|
-
children = c;
|
|
21
|
-
for (const l of listeners) l();
|
|
22
|
-
},
|
|
23
|
-
get: () => children,
|
|
24
|
-
subscribe(callback) {
|
|
25
|
-
return listeners.add(callback), () => listeners.delete(callback);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const AdaptChildrenStoreContext = createContext(null), emptySubscribe = () => () => {
|
|
30
|
-
}, emptyGet = () => null;
|
|
31
|
-
function TeleportAdaptContents() {
|
|
32
|
-
const store = useContext(AdaptChildrenStoreContext), children = React.useSyncExternalStore(
|
|
33
|
-
store?.subscribe ?? emptySubscribe,
|
|
34
|
-
store?.get ?? emptyGet,
|
|
35
|
-
store?.get ?? emptyGet
|
|
36
|
-
);
|
|
37
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
38
|
-
}
|
|
39
|
-
const AdaptContext = createStyledContext({
|
|
40
|
-
Contents: null,
|
|
41
|
-
scopeName: "",
|
|
42
|
-
portalName: "",
|
|
43
|
-
platform: null,
|
|
44
|
-
setPlatform: (x) => {
|
|
45
|
-
},
|
|
46
|
-
when: null,
|
|
47
|
-
setWhen: () => {
|
|
48
|
-
}
|
|
49
|
-
}), LastAdaptContextScope = createContext(""), ProvideAdaptContext = ({
|
|
50
|
-
children,
|
|
51
|
-
...context
|
|
52
|
-
}) => {
|
|
53
|
-
const scope = context.scopeName || "", lastScope = useContext(LastAdaptContextScope);
|
|
54
|
-
return /* @__PURE__ */ jsx(LastAdaptContextScope.Provider, { value: lastScope || context.lastScope || "", children: /* @__PURE__ */ jsx(
|
|
55
|
-
AdaptContext.Provider,
|
|
56
|
-
{
|
|
57
|
-
scope,
|
|
58
|
-
lastScope: lastScope || context.lastScope,
|
|
59
|
-
...context,
|
|
60
|
-
children
|
|
61
|
-
}
|
|
62
|
-
) });
|
|
63
|
-
}, useAdaptContext = (scope) => {
|
|
64
|
-
const lastScope = useContext(LastAdaptContextScope), adaptScope = scope ?? lastScope;
|
|
65
|
-
return AdaptContext.useStyledContext(adaptScope);
|
|
66
|
-
}, AdaptPortals = /* @__PURE__ */ new Map(), AdaptParent = ({ children, Contents, scope, portal }) => {
|
|
67
|
-
const id = useId(), portalName = `AdaptPortal${scope}${id}`, childrenStoreRef = React.useRef(null);
|
|
68
|
-
childrenStoreRef.current || (childrenStoreRef.current = createAdaptChildrenStore());
|
|
69
|
-
const isTeleport = !1, FinalContents = useMemo(() => {
|
|
70
|
-
if (Contents)
|
|
71
|
-
return Contents;
|
|
72
|
-
if (isTeleport)
|
|
73
|
-
return TeleportAdaptContents;
|
|
74
|
-
if (AdaptPortals.has(portalName))
|
|
75
|
-
return AdaptPortals.get(portalName);
|
|
76
|
-
const element = () => /* @__PURE__ */ jsx(
|
|
77
|
-
PortalHost,
|
|
78
|
-
{
|
|
79
|
-
name: portalName,
|
|
80
|
-
forwardProps: typeof portal == "boolean" ? void 0 : portal?.forwardProps
|
|
81
|
-
},
|
|
82
|
-
id
|
|
83
|
-
);
|
|
84
|
-
return AdaptPortals.set(portalName, element), element;
|
|
85
|
-
}, [portalName, Contents, isTeleport]);
|
|
86
|
-
useIsomorphicLayoutEffect(() => {
|
|
87
|
-
if (!isTeleport)
|
|
88
|
-
return AdaptPortals.set(portalName, FinalContents), () => {
|
|
89
|
-
AdaptPortals.delete(portalName);
|
|
90
|
-
};
|
|
91
|
-
}, [portalName, isTeleport]);
|
|
92
|
-
const [when, setWhen] = React.useState(null), [platform, setPlatform] = React.useState(null);
|
|
93
|
-
return /* @__PURE__ */ jsx(AdaptChildrenStoreContext.Provider, { value: childrenStoreRef.current, children: /* @__PURE__ */ jsx(LastAdaptContextScope.Provider, { value: scope, children: /* @__PURE__ */ jsx(
|
|
94
|
-
ProvideAdaptContext,
|
|
95
|
-
{
|
|
96
|
-
Contents: FinalContents,
|
|
97
|
-
when,
|
|
98
|
-
platform,
|
|
99
|
-
setPlatform,
|
|
100
|
-
setWhen,
|
|
101
|
-
portalName,
|
|
102
|
-
scopeName: scope,
|
|
103
|
-
children
|
|
104
|
-
}
|
|
105
|
-
) }) });
|
|
106
|
-
}, AdaptContents = ({ scope, ...rest }) => {
|
|
107
|
-
const context = useAdaptContext(scope);
|
|
108
|
-
if (!context?.Contents)
|
|
109
|
-
throw new Error(
|
|
110
|
-
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."
|
|
111
|
-
);
|
|
112
|
-
return React.createElement(context.Contents, { ...rest, key: "stable" });
|
|
113
|
-
};
|
|
114
|
-
AdaptContents.shouldForwardSpace = !0;
|
|
115
|
-
const Adapt = withStaticProperties(
|
|
116
|
-
function(props) {
|
|
117
|
-
const { platform, when, children, scope } = props, context = useAdaptContext(scope), enabled = useAdaptIsActiveGiven(props);
|
|
118
|
-
useIsomorphicLayoutEffect(() => {
|
|
119
|
-
context?.setWhen?.(when || enabled), context?.setPlatform?.(platform || null);
|
|
120
|
-
}, [when, platform, enabled, context.setWhen, context.setPlatform]), useIsomorphicLayoutEffect(() => () => {
|
|
121
|
-
context?.setWhen?.(null), context?.setPlatform?.(null);
|
|
122
|
-
}, []);
|
|
123
|
-
let output;
|
|
124
|
-
if (typeof children == "function") {
|
|
125
|
-
const Component = context?.Contents;
|
|
126
|
-
output = children(Component ? /* @__PURE__ */ jsx(Component, {}) : null);
|
|
127
|
-
} else
|
|
128
|
-
output = children;
|
|
129
|
-
return /* @__PURE__ */ jsx(StackZIndexContext, { children: enabled ? output : null });
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
Contents: AdaptContents
|
|
133
|
-
}
|
|
134
|
-
), AdaptPortalContents = (props) => {
|
|
135
|
-
const isActive = useAdaptIsActive(props.scope), { portalName } = useAdaptContext(props.scope), childrenStore = useContext(AdaptChildrenStoreContext);
|
|
136
|
-
return !isWeb && getPortal().state.type === "teleport" && childrenStore ? /* @__PURE__ */ jsx(AdaptPortalTeleport, { isActive, store: childrenStore, children: props.children }) : /* @__PURE__ */ jsx(PortalItem, { passThrough: !isActive, hostName: portalName, children: props.children });
|
|
137
|
-
};
|
|
138
|
-
function AdaptPortalTeleport({
|
|
139
|
-
isActive,
|
|
140
|
-
store,
|
|
141
|
-
children
|
|
142
|
-
}) {
|
|
143
|
-
return useIsomorphicLayoutEffect(() => {
|
|
144
|
-
if (isActive)
|
|
145
|
-
return store.set(children), () => store.set(null);
|
|
146
|
-
}), isActive ? null : /* @__PURE__ */ jsx(Fragment, { children });
|
|
147
|
-
}
|
|
148
|
-
const useAdaptIsActiveGiven = ({
|
|
149
|
-
when,
|
|
150
|
-
platform
|
|
151
|
-
}) => {
|
|
152
|
-
const media = useMedia();
|
|
153
|
-
if (when == null && platform == null)
|
|
154
|
-
return !1;
|
|
155
|
-
if (when === !0)
|
|
156
|
-
return !0;
|
|
157
|
-
let enabled = !1;
|
|
158
|
-
return platform === "touch" ? enabled = isTouchable : platform === "native" ? enabled = !isWeb : platform === "web" ? enabled = isWeb : platform === "ios" ? enabled = isIos : platform === "android" && (enabled = isAndroid), platform && enabled == !1 ? !1 : (when && typeof when == "string" && (enabled = media[when]), enabled);
|
|
159
|
-
}, useAdaptIsActive = (scope) => {
|
|
160
|
-
const props = useAdaptContext(scope);
|
|
161
|
-
return useAdaptIsActiveGiven(props);
|
|
162
|
-
};
|
|
163
|
-
export {
|
|
164
|
-
Adapt,
|
|
165
|
-
AdaptContents,
|
|
166
|
-
AdaptContext,
|
|
167
|
-
AdaptParent,
|
|
168
|
-
AdaptPortalContents,
|
|
169
|
-
ProvideAdaptContext,
|
|
170
|
-
useAdaptContext,
|
|
171
|
-
useAdaptIsActive
|
|
172
|
-
};
|
|
173
|
-
//# sourceMappingURL=Adapt.js.map
|
package/dist/esm/Adapt.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Adapt.tsx"],
|
|
4
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,qBAAqB,gBAAgB;AAC9C,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAC1B,SAAS,YAAY,kBAAkB;AACvC,SAAS,0BAA0B;AACnC,OAAO,SAAS,eAAe,YAAY,OAAO,eAAe;AA2CxD;AA7BT,SAAS,2BAA+C;AACtD,MAAI,WAA4B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