@tamagui/web 3.0.0-beta.748.1 → 3.0.0-beta.752.1
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/helpers/directStyle.cjs +6 -3
- package/dist/cjs/helpers/directStyle.native.cjs +6 -3
- package/dist/cjs/helpers/directStyle.native.js +6 -3
- package/dist/cjs/helpers/directStyle.native.js.map +1 -1
- package/dist/cjs/helpers/getCSSStylesAtomic.cjs +6 -7
- package/dist/cjs/helpers/getSplitStyles.cjs +106 -10
- package/dist/cjs/helpers/getSplitStyles.native.cjs +168 -10
- package/dist/cjs/helpers/getSplitStyles.native.js +168 -10
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/propMapper.cjs +17 -6
- package/dist/cjs/helpers/propMapper.native.cjs +17 -6
- package/dist/cjs/helpers/propMapper.native.js +17 -6
- package/dist/cjs/helpers/propMapper.native.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.cjs +6 -4
- package/dist/cjs/hooks/useComponentState.native.cjs +6 -4
- package/dist/cjs/hooks/useComponentState.native.js +6 -4
- package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
- package/dist/esm/helpers/directStyle.mjs +6 -3
- package/dist/esm/helpers/directStyle.mjs.map +1 -1
- package/dist/esm/helpers/directStyle.native.js +6 -3
- package/dist/esm/helpers/directStyle.native.js.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomic.mjs +6 -7
- package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +107 -11
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +169 -11
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/propMapper.mjs +17 -6
- package/dist/esm/helpers/propMapper.mjs.map +1 -1
- package/dist/esm/helpers/propMapper.native.js +17 -6
- package/dist/esm/helpers/propMapper.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +6 -4
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +6 -4
- package/dist/esm/hooks/useComponentState.native.js.map +1 -1
- package/package.json +15 -15
- package/src/helpers/directStyle.ts +9 -3
- package/src/helpers/getCSSStylesAtomic.ts +16 -10
- package/src/helpers/getSplitStyles.tsx +183 -17
- package/src/helpers/propMapper.ts +31 -12
- package/src/hooks/useComponentState.ts +15 -4
- package/types/helpers/directStyle.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/propMapper.d.ts +2 -2
- package/types/helpers/propMapper.d.ts.map +1 -1
- package/types/hooks/useComponentState.d.ts.map +1 -1
|
@@ -38,7 +38,7 @@ function getCSSStylesAtomic(style) {
|
|
|
38
38
|
for (const key in style) {
|
|
39
39
|
if (key === "$$css") continue;
|
|
40
40
|
const val = style[key];
|
|
41
|
-
const so = getStyleObject(
|
|
41
|
+
const so = getStyleObject(val, key);
|
|
42
42
|
if (so) {
|
|
43
43
|
out.push(so);
|
|
44
44
|
}
|
|
@@ -46,16 +46,15 @@ function getCSSStylesAtomic(style) {
|
|
|
46
46
|
return out;
|
|
47
47
|
}
|
|
48
48
|
function getCSSStyleAtomic(key, val, condition = "", wrappers, identity, direct = false, identityKey = key, classRepetitions = 1) {
|
|
49
|
-
return getStyleObject(
|
|
49
|
+
return getStyleObject(val, key, condition, wrappers, identity, direct, identityKey, classRepetitions);
|
|
50
50
|
}
|
|
51
51
|
let conf = null;
|
|
52
52
|
let confRevision = 0;
|
|
53
53
|
const directIdentities = /* @__PURE__ */ new Map();
|
|
54
54
|
let directIdentitiesSize = 0;
|
|
55
|
-
const getStyleObject = (
|
|
56
|
-
let val = style[key];
|
|
55
|
+
const getStyleObject = (val, key, condition = "", wrappers, identity, direct = false, identityKey = key, classRepetitions = 1) => {
|
|
57
56
|
if (val == null) return;
|
|
58
|
-
if (key === "transform" && Array.isArray(
|
|
57
|
+
if (key === "transform" && Array.isArray(val)) {
|
|
59
58
|
val = (0, import_transformsToString.transformsToString)(val);
|
|
60
59
|
}
|
|
61
60
|
const value = (0, import_normalizeValueWithProperty.normalizeValueWithProperty)(val, key);
|
|
@@ -77,7 +76,7 @@ const getStyleObject = (style, key, condition = "", wrappers, identity, direct =
|
|
|
77
76
|
value,
|
|
78
77
|
known.identifier,
|
|
79
78
|
void 0,
|
|
80
|
-
known.rules.slice()
|
|
79
|
+
direct === 2 ? known.rules : known.rules.slice()
|
|
81
80
|
];
|
|
82
81
|
}
|
|
83
82
|
}
|
|
@@ -114,7 +113,7 @@ const getStyleObject = (style, key, condition = "", wrappers, identity, direct =
|
|
|
114
113
|
}
|
|
115
114
|
byKey.set(identity, {
|
|
116
115
|
identifier,
|
|
117
|
-
rules: rules.slice()
|
|
116
|
+
rules: direct === 2 ? rules : rules.slice()
|
|
118
117
|
});
|
|
119
118
|
directIdentitiesSize++;
|
|
120
119
|
}
|
|
@@ -40,8 +40,10 @@ var import_helpers = require("@tamagui/helpers");
|
|
|
40
40
|
var import_react = __toESM(require("react"), 1);
|
|
41
41
|
var import_styleFrontend = require("./styleFrontend.cjs");
|
|
42
42
|
var import_config = require("../config.cjs");
|
|
43
|
+
var import_createVariable = require("../createVariable.cjs");
|
|
43
44
|
var import_isDevTools = require("../constants/isDevTools.cjs");
|
|
44
45
|
var import_mediaState = require("./mediaState.cjs");
|
|
46
|
+
var import_runtime = require("@tamagui/style-grammar/runtime");
|
|
45
47
|
var import_expandStyles = require("./expandStyles.cjs");
|
|
46
48
|
var import_getCSSStylesAtomic = require("./getCSSStylesAtomic.cjs");
|
|
47
49
|
var import_getDefaultProps = require("./getDefaultProps.cjs");
|
|
@@ -64,12 +66,85 @@ function compoundMatcherMatches(expected, actual) {
|
|
|
64
66
|
if (Array.isArray(expected)) return expected.some((value) => Object.is(value, actual));
|
|
65
67
|
return Object.is(expected, actual);
|
|
66
68
|
}
|
|
67
|
-
function
|
|
69
|
+
function compoundMatcherMatchesPayload(expected, payload) {
|
|
70
|
+
if (Array.isArray(expected)) return expected.some((value) => compoundMatcherMatchesPayload(value, payload));
|
|
71
|
+
return typeof expected === "string" ? expected === payload : String(expected) === payload;
|
|
72
|
+
}
|
|
73
|
+
const compoundScanHandler = {
|
|
74
|
+
segment(ctx, start, end, isBase, valid, source, chainStart, chainEnd, chainValid) {
|
|
75
|
+
if (!valid || start >= end) return;
|
|
76
|
+
if (!compoundMatcherMatchesPayload(ctx[1], source.slice(start, end))) return;
|
|
77
|
+
if (isBase) {
|
|
78
|
+
ctx[4] = true;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!chainValid) return;
|
|
82
|
+
const chain = source.slice(chainStart, chainEnd);
|
|
83
|
+
if (ctx[2](chain)) ctx[3].push(chain);
|
|
84
|
+
},
|
|
85
|
+
chain() {
|
|
86
|
+
return true;
|
|
87
|
+
},
|
|
88
|
+
error() {}
|
|
89
|
+
};
|
|
90
|
+
function matcherChains(expected, actual, isChain) {
|
|
91
|
+
if (typeof actual === "string" && actual.indexOf(":") !== -1) {
|
|
92
|
+
const scan = [
|
|
93
|
+
actual,
|
|
94
|
+
expected,
|
|
95
|
+
isChain,
|
|
96
|
+
[],
|
|
97
|
+
false
|
|
98
|
+
];
|
|
99
|
+
(0, import_runtime.scanFlatValue)(actual, compoundScanHandler, scan);
|
|
100
|
+
if (scan[4]) return [""];
|
|
101
|
+
return scan[3].length ? scan[3] : null;
|
|
102
|
+
}
|
|
103
|
+
if (actual && typeof actual === "object" && !Array.isArray(actual) && !(0, import_createVariable.isVariable)(actual)) {
|
|
104
|
+
let conditional = Object.prototype.hasOwnProperty.call(actual, "default");
|
|
105
|
+
if (!conditional) for (const key in actual) {
|
|
106
|
+
conditional = key.length > 0 && isChain(key);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (conditional) {
|
|
110
|
+
const chains = [];
|
|
111
|
+
for (const key in actual) {
|
|
112
|
+
const payload = actual[key];
|
|
113
|
+
if (payload == null || !compoundMatcherMatches(expected, payload)) continue;
|
|
114
|
+
if (key === "default") return [""];
|
|
115
|
+
if (isChain(key)) chains.push(key);
|
|
116
|
+
}
|
|
117
|
+
return chains.length ? chains : null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return compoundMatcherMatches(expected, actual) ? [""] : null;
|
|
121
|
+
}
|
|
122
|
+
function isConditionalObjectValue(value, isChain) {
|
|
123
|
+
if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
|
|
124
|
+
for (const key in value) return key.length > 0 && isChain(key);
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
const joinChains = (a, b) => {
|
|
128
|
+
if (!a) return b;
|
|
129
|
+
if (!b) return a;
|
|
130
|
+
const segments = a.split(":");
|
|
131
|
+
for (const segment of b.split(":")) if (!segments.includes(segment)) segments.push(segment);
|
|
132
|
+
return segments.join(":");
|
|
133
|
+
};
|
|
134
|
+
function compoundVariantMatchChains(compoundVariant, props, isChain) {
|
|
135
|
+
let chains = [""];
|
|
68
136
|
for (const key in compoundVariant) {
|
|
69
137
|
if (key === "style") continue;
|
|
70
|
-
|
|
138
|
+
const keyChains = matcherChains(compoundVariant[key], props[key], isChain);
|
|
139
|
+
if (!keyChains) return null;
|
|
140
|
+
const next = [];
|
|
141
|
+
for (const a of chains) for (const b of keyChains) {
|
|
142
|
+
const joined = joinChains(a, b);
|
|
143
|
+
if (!next.includes(joined)) next.push(joined);
|
|
144
|
+
}
|
|
145
|
+
chains = next;
|
|
71
146
|
}
|
|
72
|
-
return
|
|
147
|
+
return chains;
|
|
73
148
|
}
|
|
74
149
|
const styledDefaultsCache = /* @__PURE__ */ new WeakMap();
|
|
75
150
|
function getStyledDefaults(staticConfig) {
|
|
@@ -82,6 +157,7 @@ function getStyledDefaults(staticConfig) {
|
|
|
82
157
|
}
|
|
83
158
|
return entries;
|
|
84
159
|
}
|
|
160
|
+
const maybeStyleProgram = (value) => typeof value === "string" ? value.includes(":") : !!value && typeof value === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value);
|
|
85
161
|
function contributeDisplacedStyledDefaults(styledDefaults, processedProps, shorthands, contribute) {
|
|
86
162
|
if (!styledDefaults) return;
|
|
87
163
|
for (let index = 0; index < styledDefaults.length; index++) {
|
|
@@ -89,10 +165,10 @@ function contributeDisplacedStyledDefaults(styledDefaults, processedProps, short
|
|
|
89
165
|
const styledValue = styledDefaults[index][1];
|
|
90
166
|
const propValue = processedProps[key];
|
|
91
167
|
if (!(key in import_helpers.stylePropsAll) && !(key in shorthands)) continue;
|
|
92
|
-
if (propValue !== void 0 && propValue !== styledValue && (
|
|
168
|
+
if (propValue !== void 0 && propValue !== styledValue && (maybeStyleProgram(styledValue) || maybeStyleProgram(propValue))) contribute(key, styledValue);
|
|
93
169
|
}
|
|
94
170
|
}
|
|
95
|
-
function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contribute) {
|
|
171
|
+
function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contribute, isChain) {
|
|
96
172
|
const processedBaseStyle = staticConfig.baseStyle;
|
|
97
173
|
const compoundVariants = staticConfig.compoundVariants;
|
|
98
174
|
const styledDefaults = getStyledDefaults(staticConfig);
|
|
@@ -107,7 +183,8 @@ function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, con
|
|
|
107
183
|
contributeDisplacedStyledDefaults(styledDefaults, processedProps, shorthands, (k, v) => orderedEntries.push([k, v]));
|
|
108
184
|
const compoundsByAnchor = /* @__PURE__ */ new Map();
|
|
109
185
|
for (const compoundVariant of compoundVariants) {
|
|
110
|
-
|
|
186
|
+
const chains = compoundVariantMatchChains(compoundVariant, processedProps, isChain);
|
|
187
|
+
if (!chains) continue;
|
|
111
188
|
const { style } = compoundVariant;
|
|
112
189
|
if (!(0, import_isObj.isPlainObject)(style)) continue;
|
|
113
190
|
let anchor = -1;
|
|
@@ -119,7 +196,26 @@ function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, con
|
|
|
119
196
|
}
|
|
120
197
|
}
|
|
121
198
|
const entries = compoundsByAnchor.get(anchor) || [];
|
|
122
|
-
for (const key in style)
|
|
199
|
+
for (const key in style) {
|
|
200
|
+
const value = style[key];
|
|
201
|
+
for (const chain of chains) {
|
|
202
|
+
if (!chain) {
|
|
203
|
+
entries.push([key, value]);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalObjectValue(value, isChain)) {
|
|
207
|
+
const composed = {};
|
|
208
|
+
for (const inner in value) composed[inner === "default" ? chain : `${chain}:${inner}`] = value[inner];
|
|
209
|
+
entries.push([key, composed]);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (typeof value === "string" && value.includes(":")) {
|
|
213
|
+
if (process.env.NODE_ENV === "development") console.warn(`[tamagui] compound variant "${key}" carries a clause string and matched conditionally; dropping it. use the object form in the compound style`);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
entries.push([key, { [chain]: value }]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
123
219
|
compoundsByAnchor.set(anchor, entries);
|
|
124
220
|
}
|
|
125
221
|
for (let index = 0; index < orderedEntries.length; index++) contribute(orderedEntries[index][0], orderedEntries[index][1]);
|
|
@@ -403,9 +499,9 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
403
499
|
if (conditionSource !== void 0) {
|
|
404
500
|
if (isHostStyleKey || isContextProgramKey) (0, import_directStyle.contributeVariantClauseValue)(styleState, key, val, conditionSource, mergeStyle, originalVal, !isHostStyleKey);
|
|
405
501
|
else if (isHOC) {
|
|
406
|
-
const appended = (0, import_propMapper.appendFlatClause)(viewProps[key], conditionSource, val);
|
|
502
|
+
const appended = (0, import_propMapper.appendFlatClause)(styleState, viewProps[key], conditionSource, val);
|
|
407
503
|
if (appended !== void 0) viewProps[key] = appended;
|
|
408
|
-
else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] conditional variant value for "${key}"
|
|
504
|
+
else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] conditional variant value for "${key}" cannot join the existing clause string; dropping the clause`);
|
|
409
505
|
} else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key}" is not a valid style on this component; the conditional variant value is dropped.`);
|
|
410
506
|
return;
|
|
411
507
|
}
|
|
@@ -446,7 +542,7 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
446
542
|
console.groupEnd();
|
|
447
543
|
}
|
|
448
544
|
};
|
|
449
|
-
forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contributeProp);
|
|
545
|
+
forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contributeProp, (chain) => !!(0, import_directStyle.resolveClauseChain)(styleState, chain, 0, chain.length));
|
|
450
546
|
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-propsend`;
|
|
451
547
|
const conditionalStates = styleState.flatStateKeys || null;
|
|
452
548
|
const usesSafeArea = !!styleState.flatUsesSafeArea;
|
|
@@ -42,8 +42,10 @@ var import_helpers = require("@tamagui/helpers");
|
|
|
42
42
|
var import_react = __toESM(require("react"), 1);
|
|
43
43
|
var import_styleFrontend = require("./styleFrontend.native.js");
|
|
44
44
|
var import_config = require("../config.native.js");
|
|
45
|
+
var import_createVariable = require("../createVariable.native.js");
|
|
45
46
|
var import_isDevTools = require("../constants/isDevTools.native.js");
|
|
46
47
|
var import_mediaState = require("./mediaState.native.js");
|
|
48
|
+
var import_runtime = require("@tamagui/style-grammar/runtime");
|
|
47
49
|
var import_expandStyles = require("./expandStyles.native.js");
|
|
48
50
|
var import_getCSSStylesAtomic = require("./getCSSStylesAtomic.native.js");
|
|
49
51
|
var import_getDefaultProps = require("./getDefaultProps.native.js");
|
|
@@ -71,12 +73,130 @@ function compoundMatcherMatches(expected, actual) {
|
|
|
71
73
|
});
|
|
72
74
|
return Object.is(expected, actual);
|
|
73
75
|
}
|
|
74
|
-
function
|
|
76
|
+
function compoundMatcherMatchesPayload(expected, payload) {
|
|
77
|
+
if (Array.isArray(expected)) return expected.some(function(value) {
|
|
78
|
+
return compoundMatcherMatchesPayload(value, payload);
|
|
79
|
+
});
|
|
80
|
+
return typeof expected === "string" ? expected === payload : String(expected) === payload;
|
|
81
|
+
}
|
|
82
|
+
var compoundScanHandler = {
|
|
83
|
+
segment(ctx, start, end, isBase, valid, source, chainStart, chainEnd, chainValid) {
|
|
84
|
+
if (!valid || start >= end) return;
|
|
85
|
+
if (!compoundMatcherMatchesPayload(ctx[1], source.slice(start, end))) return;
|
|
86
|
+
if (isBase) {
|
|
87
|
+
ctx[4] = true;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!chainValid) return;
|
|
91
|
+
var chain = source.slice(chainStart, chainEnd);
|
|
92
|
+
if (ctx[2](chain)) ctx[3].push(chain);
|
|
93
|
+
},
|
|
94
|
+
chain() {
|
|
95
|
+
return true;
|
|
96
|
+
},
|
|
97
|
+
error() {}
|
|
98
|
+
};
|
|
99
|
+
function matcherChains(expected, actual, isChain) {
|
|
100
|
+
if (typeof actual === "string" && actual.indexOf(":") !== -1) {
|
|
101
|
+
var scan = [
|
|
102
|
+
actual,
|
|
103
|
+
expected,
|
|
104
|
+
isChain,
|
|
105
|
+
[],
|
|
106
|
+
false
|
|
107
|
+
];
|
|
108
|
+
(0, import_runtime.scanFlatValue)(actual, compoundScanHandler, scan);
|
|
109
|
+
if (scan[4]) return [""];
|
|
110
|
+
return scan[3].length ? scan[3] : null;
|
|
111
|
+
}
|
|
112
|
+
if (actual && (typeof actual === "undefined" ? "undefined" : _type_of(actual)) === "object" && !Array.isArray(actual) && !(0, import_createVariable.isVariable)(actual)) {
|
|
113
|
+
var conditional = Object.prototype.hasOwnProperty.call(actual, "default");
|
|
114
|
+
if (!conditional) for (var key in actual) {
|
|
115
|
+
conditional = key.length > 0 && isChain(key);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (conditional) {
|
|
119
|
+
var chains = [];
|
|
120
|
+
for (var key1 in actual) {
|
|
121
|
+
var payload = actual[key1];
|
|
122
|
+
if (payload == null || !compoundMatcherMatches(expected, payload)) continue;
|
|
123
|
+
if (key1 === "default") return [""];
|
|
124
|
+
if (isChain(key1)) chains.push(key1);
|
|
125
|
+
}
|
|
126
|
+
return chains.length ? chains : null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return compoundMatcherMatches(expected, actual) ? [""] : null;
|
|
130
|
+
}
|
|
131
|
+
function isConditionalObjectValue(value, isChain) {
|
|
132
|
+
if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
|
|
133
|
+
for (var key in value) return key.length > 0 && isChain(key);
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
var joinChains = function(a, b) {
|
|
137
|
+
if (!a) return b;
|
|
138
|
+
if (!b) return a;
|
|
139
|
+
var segments = a.split(":");
|
|
140
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
141
|
+
try {
|
|
142
|
+
for (var _iterator = b.split(":")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
143
|
+
var segment = _step.value;
|
|
144
|
+
if (!segments.includes(segment)) segments.push(segment);
|
|
145
|
+
}
|
|
146
|
+
} catch (err) {
|
|
147
|
+
_didIteratorError = true;
|
|
148
|
+
_iteratorError = err;
|
|
149
|
+
} finally {
|
|
150
|
+
try {
|
|
151
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
|
|
152
|
+
} finally {
|
|
153
|
+
if (_didIteratorError) throw _iteratorError;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return segments.join(":");
|
|
157
|
+
};
|
|
158
|
+
function compoundVariantMatchChains(compoundVariant, props, isChain) {
|
|
159
|
+
var chains = [""];
|
|
75
160
|
for (var key in compoundVariant) {
|
|
76
161
|
if (key === "style") continue;
|
|
77
|
-
|
|
162
|
+
var keyChains = matcherChains(compoundVariant[key], props[key], isChain);
|
|
163
|
+
if (!keyChains) return null;
|
|
164
|
+
var next = [];
|
|
165
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
166
|
+
try {
|
|
167
|
+
for (var _iterator = chains[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
168
|
+
var a = _step.value;
|
|
169
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
170
|
+
try {
|
|
171
|
+
for (var _iterator1 = keyChains[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
172
|
+
var b = _step1.value;
|
|
173
|
+
var joined = joinChains(a, b);
|
|
174
|
+
if (!next.includes(joined)) next.push(joined);
|
|
175
|
+
}
|
|
176
|
+
} catch (err) {
|
|
177
|
+
_didIteratorError1 = true;
|
|
178
|
+
_iteratorError1 = err;
|
|
179
|
+
} finally {
|
|
180
|
+
try {
|
|
181
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();
|
|
182
|
+
} finally {
|
|
183
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} catch (err) {
|
|
188
|
+
_didIteratorError = true;
|
|
189
|
+
_iteratorError = err;
|
|
190
|
+
} finally {
|
|
191
|
+
try {
|
|
192
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
|
|
193
|
+
} finally {
|
|
194
|
+
if (_didIteratorError) throw _iteratorError;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
chains = next;
|
|
78
198
|
}
|
|
79
|
-
return
|
|
199
|
+
return chains;
|
|
80
200
|
}
|
|
81
201
|
var styledDefaultsCache = /* @__PURE__ */ new WeakMap();
|
|
82
202
|
function getStyledDefaults(staticConfig) {
|
|
@@ -89,6 +209,9 @@ function getStyledDefaults(staticConfig) {
|
|
|
89
209
|
}
|
|
90
210
|
return entries;
|
|
91
211
|
}
|
|
212
|
+
var maybeStyleProgram = function(value) {
|
|
213
|
+
return typeof value === "string" ? value.includes(":") : !!value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value);
|
|
214
|
+
};
|
|
92
215
|
function contributeDisplacedStyledDefaults(styledDefaults, processedProps, shorthands, contribute) {
|
|
93
216
|
if (!styledDefaults) return;
|
|
94
217
|
for (var index = 0; index < styledDefaults.length; index++) {
|
|
@@ -96,10 +219,10 @@ function contributeDisplacedStyledDefaults(styledDefaults, processedProps, short
|
|
|
96
219
|
var styledValue = styledDefaults[index][1];
|
|
97
220
|
var propValue = processedProps[key];
|
|
98
221
|
if (!(key in import_helpers.stylePropsAll) && !(key in shorthands)) continue;
|
|
99
|
-
if (propValue !== void 0 && propValue !== styledValue && (
|
|
222
|
+
if (propValue !== void 0 && propValue !== styledValue && (maybeStyleProgram(styledValue) || maybeStyleProgram(propValue))) contribute(key, styledValue);
|
|
100
223
|
}
|
|
101
224
|
}
|
|
102
|
-
function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contribute) {
|
|
225
|
+
function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contribute, isChain) {
|
|
103
226
|
var processedBaseStyle = staticConfig.baseStyle;
|
|
104
227
|
var compoundVariants = staticConfig.compoundVariants;
|
|
105
228
|
var styledDefaults = getStyledDefaults(staticConfig);
|
|
@@ -119,7 +242,8 @@ function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, con
|
|
|
119
242
|
try {
|
|
120
243
|
for (var _iterator = compoundVariants[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
121
244
|
var compoundVariant = _step.value;
|
|
122
|
-
|
|
245
|
+
var chains = compoundVariantMatchChains(compoundVariant, processedProps, isChain);
|
|
246
|
+
if (!chains) continue;
|
|
123
247
|
var { style } = compoundVariant;
|
|
124
248
|
if (!(0, import_isObj.isPlainObject)(style)) continue;
|
|
125
249
|
var anchor = -1;
|
|
@@ -131,7 +255,39 @@ function forEachPropInForwardOrder(processedProps, staticConfig, shorthands, con
|
|
|
131
255
|
}
|
|
132
256
|
}
|
|
133
257
|
var entries = compoundsByAnchor.get(anchor) || [];
|
|
134
|
-
for (var key2 in style)
|
|
258
|
+
for (var key2 in style) {
|
|
259
|
+
var value = style[key2];
|
|
260
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
261
|
+
try {
|
|
262
|
+
for (var _iterator1 = chains[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
263
|
+
var chain = _step1.value;
|
|
264
|
+
if (!chain) {
|
|
265
|
+
entries.push([key2, value]);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalObjectValue(value, isChain)) {
|
|
269
|
+
var composed = {};
|
|
270
|
+
for (var inner in value) composed[inner === "default" ? chain : `${chain}:${inner}`] = value[inner];
|
|
271
|
+
entries.push([key2, composed]);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (typeof value === "string" && value.includes(":")) {
|
|
275
|
+
if (process.env.NODE_ENV === "development") console.warn(`[tamagui] compound variant "${key2}" carries a clause string and matched conditionally; dropping it. use the object form in the compound style`);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
entries.push([key2, { [chain]: value }]);
|
|
279
|
+
}
|
|
280
|
+
} catch (err) {
|
|
281
|
+
_didIteratorError1 = true;
|
|
282
|
+
_iteratorError1 = err;
|
|
283
|
+
} finally {
|
|
284
|
+
try {
|
|
285
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();
|
|
286
|
+
} finally {
|
|
287
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
135
291
|
compoundsByAnchor.set(anchor, entries);
|
|
136
292
|
}
|
|
137
293
|
} catch (err) {
|
|
@@ -418,9 +574,9 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
|
|
|
418
574
|
if (conditionSource !== void 0) {
|
|
419
575
|
if (isHostStyleKey || isContextProgramKey) (0, import_directStyle.contributeVariantClauseValue)(styleState, key8, val2, conditionSource, mergeStyle, originalVal, !isHostStyleKey);
|
|
420
576
|
else if (isHOC) {
|
|
421
|
-
var appended = (0, import_propMapper.appendFlatClause)(viewProps[key8], conditionSource, val2);
|
|
577
|
+
var appended = (0, import_propMapper.appendFlatClause)(styleState, viewProps[key8], conditionSource, val2);
|
|
422
578
|
if (appended !== void 0) viewProps[key8] = appended;
|
|
423
|
-
else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] conditional variant value for "${key8}"
|
|
579
|
+
else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] conditional variant value for "${key8}" cannot join the existing clause string; dropping the clause`);
|
|
424
580
|
} else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key8}" is not a valid style on this component; the conditional variant value is dropped.`);
|
|
425
581
|
return;
|
|
426
582
|
}
|
|
@@ -464,7 +620,9 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
|
|
|
464
620
|
console.groupEnd();
|
|
465
621
|
}
|
|
466
622
|
};
|
|
467
|
-
forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contributeProp)
|
|
623
|
+
forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contributeProp, function(chain) {
|
|
624
|
+
return !!(0, import_directStyle.resolveClauseChain)(styleState, chain, 0, chain.length);
|
|
625
|
+
});
|
|
468
626
|
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-propsend`;
|
|
469
627
|
var conditionalStates = styleState.flatStateKeys || null;
|
|
470
628
|
var usesSafeArea = !!styleState.flatUsesSafeArea;
|