@tamagui/web 3.0.3 → 3.0.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/_withNativeStyle.cjs +85 -46
- package/dist/cjs/_withNativeStyle.native.cjs +91 -41
- package/dist/cjs/_withNativeStyle.native.js +91 -41
- package/dist/cjs/_withNativeStyle.native.js.map +1 -1
- package/dist/cjs/helpers/nativeStyleEngine.cjs +140 -69
- package/dist/cjs/helpers/nativeStyleEngine.native.cjs +177 -118
- package/dist/cjs/helpers/nativeStyleEngine.native.js +177 -118
- package/dist/cjs/helpers/nativeStyleEngine.native.js.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.native.cjs +1 -0
- package/dist/cjs/index.native.js +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/_withNativeStyle.mjs +85 -40
- package/dist/esm/_withNativeStyle.mjs.map +1 -1
- package/dist/esm/_withNativeStyle.native.js +92 -42
- package/dist/esm/_withNativeStyle.native.js.map +1 -1
- package/dist/esm/helpers/nativeStyleEngine.mjs +141 -71
- package/dist/esm/helpers/nativeStyleEngine.mjs.map +1 -1
- package/dist/esm/helpers/nativeStyleEngine.native.js +177 -119
- package/dist/esm/helpers/nativeStyleEngine.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.native.js +2 -2
- package/package.json +17 -17
- package/src/_withNativeStyle.tsx +141 -55
- package/src/helpers/nativeStyleEngine.ts +230 -101
- package/src/index.ts +1 -0
- package/src/setupHooks.ts +1 -0
- package/types/_withNativeStyle.d.ts +22 -2
- package/types/_withNativeStyle.d.ts.map +1 -1
- package/types/helpers/nativeStyleEngine.d.ts +24 -9
- package/types/helpers/nativeStyleEngine.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/setupHooks.d.ts +1 -0
- package/types/setupHooks.d.ts.map +1 -1
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { setRef } from "@tamagui/compose-refs";
|
|
2
|
-
import
|
|
2
|
+
import { isAndroid, isIos } from "@tamagui/constants";
|
|
3
|
+
import { use } from "react";
|
|
3
4
|
import { _withStableStyle } from "./_withStableStyle.mjs";
|
|
4
5
|
import { getNativeStyleEngine, linkNativeStyleMapping, resolveNativeStyleMapping } from "./helpers/nativeStyleEngine.mjs";
|
|
5
6
|
import { ThemeStateContext, getThemeState } from "./hooks/useThemeState.mjs";
|
|
7
|
+
import { hooks } from "./setupHooks.mjs";
|
|
6
8
|
import { jsx } from "react/jsx-runtime";
|
|
7
9
|
|
|
8
|
-
const
|
|
10
|
+
const hostTextProps = {
|
|
11
|
+
accessible: isAndroid ? false : isIos ? true : void 0,
|
|
12
|
+
allowFontScaling: true,
|
|
13
|
+
ellipsizeMode: "tail"
|
|
14
|
+
};
|
|
15
|
+
const _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {
|
|
9
16
|
const Fallback = _withStableStyle(Component, (theme) => {
|
|
10
17
|
const themedStyle = {};
|
|
11
18
|
for (const styleKey in themeStyleKeys) {
|
|
@@ -13,46 +20,84 @@ const _withNativeStyle = (Component, baseStyle, themeStyleKeys) => {
|
|
|
13
20
|
}
|
|
14
21
|
return [baseStyle, themedStyle];
|
|
15
22
|
}, true, false);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
const baseViews = host ? hooks.getBaseViews?.() : void 0;
|
|
24
|
+
const TextAncestor = baseViews?.TextAncestor;
|
|
25
|
+
const TextAncestorProvider = TextAncestor?.Provider;
|
|
26
|
+
const HostText = host === "text" && !("userSelect" in baseStyle) && !("verticalAlign" in baseStyle) ? baseViews?.NativeText : void 0;
|
|
27
|
+
const hostTextBase = HostText ? {
|
|
28
|
+
overflow: "hidden",
|
|
29
|
+
...baseStyle,
|
|
30
|
+
...typeof baseStyle.fontWeight === "number" && { fontWeight: String(baseStyle.fontWeight) }
|
|
31
|
+
} : baseStyle;
|
|
32
|
+
const styles = /* @__PURE__ */ new Map();
|
|
33
|
+
const hostTextStyles = /* @__PURE__ */ new Map();
|
|
34
|
+
const ScopeContext = ThemeStateContext;
|
|
35
|
+
const engineOf = getNativeStyleEngine;
|
|
36
|
+
const scopeState = getThemeState;
|
|
37
|
+
const resolve = resolveNativeStyleMapping;
|
|
38
|
+
const linkMapping = linkNativeStyleMapping;
|
|
39
|
+
const assignRef = setRef;
|
|
40
|
+
const render = (props, key) => {
|
|
41
|
+
const scopeId = use(ScopeContext);
|
|
42
|
+
const inText = TextAncestor ? use(TextAncestor) : false;
|
|
43
|
+
const themeState = scopeId && engineOf() ? scopeState(scopeId) : void 0;
|
|
44
|
+
const resetsText = inText && host === "view";
|
|
45
|
+
if (!themeState) {
|
|
46
|
+
return resetsText ? /* @__PURE__ */ jsx(TextAncestorProvider, {
|
|
47
|
+
value: false,
|
|
48
|
+
children: /* @__PURE__ */ jsx(Fallback, { ...props })
|
|
49
|
+
}, key) : /* @__PURE__ */ jsx(Fallback, { ...props }, key);
|
|
50
|
+
}
|
|
51
|
+
let rest = props;
|
|
52
|
+
if (props._expressions !== void 0) {
|
|
53
|
+
const { _expressions: _ignoredExpressions, ...withoutExpressions } = props;
|
|
54
|
+
rest = withoutExpressions;
|
|
55
|
+
}
|
|
56
|
+
const ref = props.ref;
|
|
57
|
+
const { name, theme } = themeState;
|
|
58
|
+
const asHostText = HostText && !inText;
|
|
59
|
+
const Rendered = asHostText ? HostText : Component;
|
|
60
|
+
const cache = asHostText ? hostTextStyles : styles;
|
|
61
|
+
let style = cache.get(scopeId);
|
|
62
|
+
if (!style) {
|
|
63
|
+
style = [asHostText ? hostTextBase : baseStyle, null];
|
|
64
|
+
cache.set(scopeId, style);
|
|
41
65
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
style[1] = resolve(themeStyleKeys, name, theme);
|
|
67
|
+
const wrapped = resetsText || asHostText && mayRenderText(rest.children);
|
|
68
|
+
const element = /* @__PURE__ */ jsx(Rendered, {
|
|
69
|
+
...asHostText && hostTextProps,
|
|
70
|
+
...rest,
|
|
71
|
+
ref: (node) => {
|
|
72
|
+
let refCleanup;
|
|
73
|
+
if (typeof ref === "function") refCleanup = ref(node);
|
|
74
|
+
else assignRef(ref, node);
|
|
75
|
+
const link = linkMapping(node, themeStyleKeys, scopeId, name, theme);
|
|
76
|
+
return () => {
|
|
77
|
+
link?.unlink();
|
|
78
|
+
if (typeof refCleanup === "function") refCleanup();
|
|
79
|
+
else assignRef(ref, null);
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
style
|
|
83
|
+
}, wrapped ? void 0 : key);
|
|
84
|
+
if (!wrapped) return element;
|
|
85
|
+
return /* @__PURE__ */ jsx(TextAncestorProvider, {
|
|
86
|
+
value: !resetsText,
|
|
87
|
+
children: element
|
|
88
|
+
}, key);
|
|
89
|
+
};
|
|
90
|
+
const NativeStyleView = (props) => render(props);
|
|
91
|
+
NativeStyleView.inline = (element) => render(element.props, element.key);
|
|
92
|
+
return NativeStyleView;
|
|
55
93
|
};
|
|
94
|
+
function mayRenderText(children) {
|
|
95
|
+
if (children == null) return false;
|
|
96
|
+
if (Array.isArray(children) && children.length <= 3) {
|
|
97
|
+
return children.some((child) => child != null && typeof child === "object");
|
|
98
|
+
}
|
|
99
|
+
return typeof children === "object";
|
|
100
|
+
}
|
|
56
101
|
|
|
57
102
|
export { _withNativeStyle };
|
|
58
103
|
//# sourceMappingURL=_withNativeStyle.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_withNativeStyle.js","names":[],"sources":["esm/_withNativeStyle.js"],"sourcesContent":["import { setRef } from \"@tamagui/compose-refs\";\nimport
|
|
1
|
+
{"version":3,"file":"_withNativeStyle.js","names":[],"sources":["esm/_withNativeStyle.js"],"sourcesContent":["import { setRef } from \"@tamagui/compose-refs\";\nimport { isAndroid, isIos } from \"@tamagui/constants\";\nimport { use } from \"react\";\nimport { _withStableStyle } from \"./_withStableStyle\";\nimport {\n getNativeStyleEngine,\n linkNativeStyleMapping,\n resolveNativeStyleMapping\n} from \"./helpers/nativeStyleEngine\";\nimport { getThemeState, ThemeStateContext } from \"./hooks/useThemeState\";\nimport { hooks } from \"./setupHooks\";\nimport { jsx } from \"react/jsx-runtime\";\nconst hostTextProps = {\n accessible: isAndroid ? false : isIos ? true : void 0,\n allowFontScaling: true,\n ellipsizeMode: \"tail\"\n};\nconst _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {\n const Fallback = _withStableStyle(\n Component,\n (theme) => {\n const themedStyle = {};\n for (const styleKey in themeStyleKeys) {\n themedStyle[styleKey] = theme[themeStyleKeys[styleKey]]?.get();\n }\n return [baseStyle, themedStyle];\n },\n true,\n false\n );\n const baseViews = host ? hooks.getBaseViews?.() : void 0;\n const TextAncestor = baseViews?.TextAncestor;\n const TextAncestorProvider = TextAncestor?.Provider;\n const HostText = host === \"text\" && !(\"userSelect\" in baseStyle) && !(\"verticalAlign\" in baseStyle) ? baseViews?.NativeText : void 0;\n const hostTextBase = HostText ? {\n overflow: \"hidden\",\n ...baseStyle,\n ...typeof baseStyle.fontWeight === \"number\" && {\n fontWeight: String(baseStyle.fontWeight)\n }\n } : baseStyle;\n const styles = /* @__PURE__ */ new Map();\n const hostTextStyles = /* @__PURE__ */ new Map();\n const ScopeContext = ThemeStateContext;\n const engineOf = getNativeStyleEngine;\n const scopeState = getThemeState;\n const resolve = resolveNativeStyleMapping;\n const linkMapping = linkNativeStyleMapping;\n const assignRef = setRef;\n const render = (props, key) => {\n const scopeId = use(ScopeContext);\n const inText = TextAncestor ? use(TextAncestor) : false;\n const themeState = scopeId && engineOf() ? scopeState(scopeId) : void 0;\n const resetsText = inText && host === \"view\";\n if (!themeState) {\n return resetsText ? /* @__PURE__ */ jsx(TextAncestorProvider, { value: false, children: /* @__PURE__ */ jsx(Fallback, { ...props }) }, key) : /* @__PURE__ */ jsx(Fallback, { ...props }, key);\n }\n let rest = props;\n if (props._expressions !== void 0) {\n const { _expressions: _ignoredExpressions, ...withoutExpressions } = props;\n rest = withoutExpressions;\n }\n const ref = props.ref;\n const { name, theme } = themeState;\n const asHostText = HostText && !inText;\n const Rendered = asHostText ? HostText : Component;\n const cache = asHostText ? hostTextStyles : styles;\n let style = cache.get(scopeId);\n if (!style) {\n style = [asHostText ? hostTextBase : baseStyle, null];\n cache.set(scopeId, style);\n }\n style[1] = resolve(themeStyleKeys, name, theme);\n const wrapped = resetsText || asHostText && mayRenderText(rest.children);\n const element = /* @__PURE__ */ jsx(\n Rendered,\n {\n ...asHostText && hostTextProps,\n ...rest,\n ref: (node) => {\n let refCleanup;\n if (typeof ref === \"function\") refCleanup = ref(node);\n else assignRef(ref, node);\n const link = linkMapping(node, themeStyleKeys, scopeId, name, theme);\n return () => {\n link?.unlink();\n if (typeof refCleanup === \"function\") refCleanup();\n else assignRef(ref, null);\n };\n },\n style\n },\n wrapped ? void 0 : key\n );\n if (!wrapped) return element;\n return /* @__PURE__ */ jsx(TextAncestorProvider, { value: !resetsText, children: element }, key);\n };\n const NativeStyleView = (props) => render(props);\n NativeStyleView.inline = (element) => render(element.props, element.key);\n return NativeStyleView;\n};\nfunction mayRenderText(children) {\n if (children == null) return false;\n if (Array.isArray(children) && children.length <= 3) {\n return children.some((child) => child != null && typeof child === \"object\");\n }\n return typeof children === \"object\";\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AAQ,QAAQ,KAAK,SAAS,UAAU,GAAG;EACnD,OAAO,SAAS,MAAM,UAAU,SAAS,QAAQ,OAAO,UAAU,QAAQ;CAC5E;CACA,OAAO,OAAO,aAAa;AAC7B"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { setRef } from "@tamagui/compose-refs";
|
|
3
|
-
import
|
|
3
|
+
import { isAndroid, isIos } from "@tamagui/constants";
|
|
4
|
+
import { use } from "react";
|
|
4
5
|
import { _withStableStyle } from "./_withStableStyle.native.js";
|
|
5
6
|
import { getNativeStyleEngine, linkNativeStyleMapping, resolveNativeStyleMapping } from "./helpers/nativeStyleEngine.native.js";
|
|
6
7
|
import { ThemeStateContext, getThemeState } from "./hooks/useThemeState.native.js";
|
|
8
|
+
import { hooks } from "./setupHooks.native.js";
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var hostTextProps = {
|
|
11
|
+
accessible: isAndroid ? false : isIos ? true : void 0,
|
|
12
|
+
allowFontScaling: true,
|
|
13
|
+
ellipsizeMode: "tail"
|
|
14
|
+
};
|
|
15
|
+
var _withNativeStyle = function(Component, baseStyle, themeStyleKeys, host) {
|
|
16
|
+
var _hooks_getBaseViews;
|
|
9
17
|
var Fallback = _withStableStyle(Component, function(theme) {
|
|
10
18
|
var themedStyle = {};
|
|
11
19
|
for (var styleKey in themeStyleKeys) {
|
|
@@ -14,48 +22,90 @@ var _withNativeStyle = function(Component, baseStyle, themeStyleKeys) {
|
|
|
14
22
|
}
|
|
15
23
|
return [baseStyle, themedStyle];
|
|
16
24
|
}, true, false);
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
var baseViews = host ? (_hooks_getBaseViews = hooks.getBaseViews) === null || _hooks_getBaseViews === void 0 ? void 0 : _hooks_getBaseViews.call(hooks) : void 0;
|
|
26
|
+
var TextAncestor = baseViews === null || baseViews === void 0 ? void 0 : baseViews.TextAncestor;
|
|
27
|
+
var TextAncestorProvider = TextAncestor === null || TextAncestor === void 0 ? void 0 : TextAncestor.Provider;
|
|
28
|
+
var HostText = host === "text" && !("userSelect" in baseStyle) && !("verticalAlign" in baseStyle) ? baseViews === null || baseViews === void 0 ? void 0 : baseViews.NativeText : void 0;
|
|
29
|
+
var hostTextBase = HostText ? {
|
|
30
|
+
overflow: "hidden",
|
|
31
|
+
...baseStyle,
|
|
32
|
+
...typeof baseStyle.fontWeight === "number" && { fontWeight: String(baseStyle.fontWeight) }
|
|
33
|
+
} : baseStyle;
|
|
34
|
+
var styles = /* @__PURE__ */ new Map();
|
|
35
|
+
var hostTextStyles = /* @__PURE__ */ new Map();
|
|
36
|
+
var ScopeContext = ThemeStateContext;
|
|
37
|
+
var engineOf = getNativeStyleEngine;
|
|
38
|
+
var scopeState = getThemeState;
|
|
39
|
+
var resolve = resolveNativeStyleMapping;
|
|
40
|
+
var linkMapping = linkNativeStyleMapping;
|
|
41
|
+
var assignRef = setRef;
|
|
42
|
+
var render = function(props, key) {
|
|
43
|
+
var scopeId = use(ScopeContext);
|
|
44
|
+
var inText = TextAncestor ? use(TextAncestor) : false;
|
|
45
|
+
var themeState = scopeId && engineOf() ? scopeState(scopeId) : void 0;
|
|
46
|
+
var resetsText = inText && host === "view";
|
|
47
|
+
if (!themeState) {
|
|
48
|
+
return resetsText ? /* @__PURE__ */ jsx(TextAncestorProvider, {
|
|
49
|
+
value: false,
|
|
50
|
+
children: /* @__PURE__ */ jsx(Fallback, { ...props })
|
|
51
|
+
}, key) : /* @__PURE__ */ jsx(Fallback, { ...props }, key);
|
|
44
52
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
var rest = props;
|
|
54
|
+
if (props._expressions !== void 0) {
|
|
55
|
+
var { _expressions: _ignoredExpressions, ...withoutExpressions } = props;
|
|
56
|
+
rest = withoutExpressions;
|
|
57
|
+
}
|
|
58
|
+
var ref = props.ref;
|
|
59
|
+
var { name, theme } = themeState;
|
|
60
|
+
var asHostText = HostText && !inText;
|
|
61
|
+
var Rendered = asHostText ? HostText : Component;
|
|
62
|
+
var cache = asHostText ? hostTextStyles : styles;
|
|
63
|
+
var style = cache.get(scopeId);
|
|
64
|
+
if (!style) {
|
|
65
|
+
style = [asHostText ? hostTextBase : baseStyle, null];
|
|
66
|
+
cache.set(scopeId, style);
|
|
67
|
+
}
|
|
68
|
+
style[1] = resolve(themeStyleKeys, name, theme);
|
|
69
|
+
var wrapped = resetsText || asHostText && mayRenderText(rest.children);
|
|
70
|
+
var element = /* @__PURE__ */ jsx(Rendered, {
|
|
71
|
+
...asHostText && hostTextProps,
|
|
72
|
+
...rest,
|
|
73
|
+
ref: function(node) {
|
|
74
|
+
var refCleanup;
|
|
75
|
+
if (typeof ref === "function") refCleanup = ref(node);
|
|
76
|
+
else assignRef(ref, node);
|
|
77
|
+
var link = linkMapping(node, themeStyleKeys, scopeId, name, theme);
|
|
78
|
+
return function() {
|
|
79
|
+
link === null || link === void 0 ? void 0 : link.unlink();
|
|
80
|
+
if (typeof refCleanup === "function") refCleanup();
|
|
81
|
+
else assignRef(ref, null);
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
style
|
|
85
|
+
}, wrapped ? void 0 : key);
|
|
86
|
+
if (!wrapped) return element;
|
|
87
|
+
return /* @__PURE__ */ jsx(TextAncestorProvider, {
|
|
88
|
+
value: !resetsText,
|
|
89
|
+
children: element
|
|
90
|
+
}, key);
|
|
91
|
+
};
|
|
92
|
+
var NativeStyleView = function(props) {
|
|
93
|
+
return render(props);
|
|
94
|
+
};
|
|
95
|
+
NativeStyleView.inline = function(element) {
|
|
96
|
+
return render(element.props, element.key);
|
|
97
|
+
};
|
|
98
|
+
return NativeStyleView;
|
|
58
99
|
};
|
|
100
|
+
function mayRenderText(children) {
|
|
101
|
+
if (children == null) return false;
|
|
102
|
+
if (Array.isArray(children) && children.length <= 3) {
|
|
103
|
+
return children.some(function(child) {
|
|
104
|
+
return child != null && typeof child === "object";
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return typeof children === "object";
|
|
108
|
+
}
|
|
59
109
|
|
|
60
110
|
export { _withNativeStyle };
|
|
61
111
|
//# sourceMappingURL=_withNativeStyle.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_withNativeStyle.native.js","names":[],"sources":["esm/_withNativeStyle.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { setRef } from \"@tamagui/compose-refs\";\nimport
|
|
1
|
+
{"version":3,"file":"_withNativeStyle.native.js","names":[],"sources":["esm/_withNativeStyle.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { setRef } from \"@tamagui/compose-refs\";\nimport { isAndroid, isIos } from \"@tamagui/constants\";\nimport React, { use } from \"react\";\nimport { _withStableStyle } from \"./_withStableStyle\";\nimport { getNativeStyleEngine, linkNativeStyleMapping, resolveNativeStyleMapping } from \"./helpers/nativeStyleEngine\";\nimport { getThemeState, ThemeStateContext } from \"./hooks/useThemeState\";\nimport { hooks } from \"./setupHooks\";\nvar hostTextProps = {\n accessible: isAndroid ? false : isIos ? true : void 0,\n allowFontScaling: true,\n ellipsizeMode: \"tail\"\n};\nvar _withNativeStyle = function(Component, baseStyle, themeStyleKeys, host) {\n var _hooks_getBaseViews;\n var Fallback = _withStableStyle(Component, function(theme) {\n var themedStyle = {};\n for (var styleKey in themeStyleKeys) {\n var _theme_themeStyleKeys_styleKey;\n themedStyle[styleKey] = (_theme_themeStyleKeys_styleKey = theme[themeStyleKeys[styleKey]]) === null || _theme_themeStyleKeys_styleKey === void 0 ? void 0 : _theme_themeStyleKeys_styleKey.get();\n }\n return [\n baseStyle,\n themedStyle\n ];\n }, true, false);\n var baseViews = host ? (_hooks_getBaseViews = hooks.getBaseViews) === null || _hooks_getBaseViews === void 0 ? void 0 : _hooks_getBaseViews.call(hooks) : void 0;\n var TextAncestor = baseViews === null || baseViews === void 0 ? void 0 : baseViews.TextAncestor;\n var TextAncestorProvider = TextAncestor === null || TextAncestor === void 0 ? void 0 : TextAncestor.Provider;\n var HostText = host === \"text\" && !(\"userSelect\" in baseStyle) && !(\"verticalAlign\" in baseStyle) ? baseViews === null || baseViews === void 0 ? void 0 : baseViews.NativeText : void 0;\n var hostTextBase = HostText ? {\n overflow: \"hidden\",\n ...baseStyle,\n ...typeof baseStyle.fontWeight === \"number\" && {\n fontWeight: String(baseStyle.fontWeight)\n }\n } : baseStyle;\n var styles = /* @__PURE__ */ new Map();\n var hostTextStyles = /* @__PURE__ */ new Map();\n var ScopeContext = ThemeStateContext;\n var engineOf = getNativeStyleEngine;\n var scopeState = getThemeState;\n var resolve = resolveNativeStyleMapping;\n var linkMapping = linkNativeStyleMapping;\n var assignRef = setRef;\n var render = function(props, key) {\n var scopeId = use(ScopeContext);\n var inText = TextAncestor ? use(TextAncestor) : false;\n var themeState = scopeId && engineOf() ? scopeState(scopeId) : void 0;\n var resetsText = inText && host === \"view\";\n if (!themeState) {\n return resetsText ? /* @__PURE__ */ _jsx(TextAncestorProvider, {\n value: false,\n children: /* @__PURE__ */ _jsx(Fallback, {\n ...props\n })\n }, key) : /* @__PURE__ */ _jsx(Fallback, {\n ...props\n }, key);\n }\n var rest = props;\n if (props._expressions !== void 0) {\n var { _expressions: _ignoredExpressions, ...withoutExpressions } = props;\n rest = withoutExpressions;\n }\n var ref = props.ref;\n var { name, theme } = themeState;\n var asHostText = HostText && !inText;\n var Rendered = asHostText ? HostText : Component;\n var cache = asHostText ? hostTextStyles : styles;\n var style = cache.get(scopeId);\n if (!style) {\n style = [\n asHostText ? hostTextBase : baseStyle,\n null\n ];\n cache.set(scopeId, style);\n }\n style[1] = resolve(themeStyleKeys, name, theme);\n var wrapped = resetsText || asHostText && mayRenderText(rest.children);\n var element = /* @__PURE__ */ _jsx(Rendered, {\n ...asHostText && hostTextProps,\n ...rest,\n ref: function(node) {\n var refCleanup;\n if (typeof ref === \"function\") refCleanup = ref(node);\n else assignRef(ref, node);\n var link = linkMapping(node, themeStyleKeys, scopeId, name, theme);\n return function() {\n link === null || link === void 0 ? void 0 : link.unlink();\n if (typeof refCleanup === \"function\") refCleanup();\n else assignRef(ref, null);\n };\n },\n style\n }, wrapped ? void 0 : key);\n if (!wrapped) return element;\n return /* @__PURE__ */ _jsx(TextAncestorProvider, {\n value: !resetsText,\n children: element\n }, key);\n };\n var NativeStyleView = function(props) {\n return render(props);\n };\n NativeStyleView.inline = function(element) {\n return render(element.props, element.key);\n };\n return NativeStyleView;\n};\nfunction mayRenderText(children) {\n if (children == null) return false;\n if (Array.isArray(children) && children.length <= 3) {\n return children.some(function(child) {\n return child != null && typeof child === \"object\";\n });\n }\n return typeof children === \"object\";\n}\nexport {\n _withNativeStyle\n};\n//# sourceMappingURL=_withNativeStyle.js.map\n"],"mappings":";;;;;;;;;;AAQA,IAAI,gBAAgB;CAClB,YAAY,YAAY,QAAQ,QAAQ,OAAO,KAAK;CACpD,kBAAkB;CAClB,eAAe;AACjB;AACA,IAAI,mBAAmB,SAAS,WAAW,WAAW,gBAAgB,MAAM;CAC1E,IAAI;CACJ,IAAI,WAAW,iBAAiB,WAAW,SAAS,OAAO;EACzD,IAAI,cAAc,CAAC;EACnB,KAAK,IAAI,YAAY,gBAAgB;GACnC,IAAI;GACJ,YAAY,aAAa,iCAAiC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