@tamagui/web 2.4.3 → 2.4.5-1784066510418
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/.turbo/turbo-build.log +1 -1
- package/dist/cjs/helpers/getSplitStyles.cjs +27 -1
- package/dist/cjs/helpers/getSplitStyles.native.js +77 -46
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/styleProvenance.cjs +43 -0
- package/dist/cjs/helpers/styleProvenance.native.js +46 -0
- package/dist/cjs/helpers/styleProvenance.native.js.map +1 -0
- package/dist/cjs/hooks/useThemeState.cjs +4 -0
- package/dist/cjs/hooks/useThemeState.native.js +4 -0
- package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +25 -2
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +76 -48
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/styleProvenance.mjs +16 -0
- package/dist/esm/helpers/styleProvenance.mjs.map +1 -0
- package/dist/esm/helpers/styleProvenance.native.js +16 -0
- package/dist/esm/helpers/styleProvenance.native.js.map +1 -0
- package/dist/esm/hooks/useThemeState.mjs +4 -0
- package/dist/esm/hooks/useThemeState.mjs.map +1 -1
- package/dist/esm/hooks/useThemeState.native.js +4 -0
- package/dist/esm/hooks/useThemeState.native.js.map +1 -1
- package/package.json +13 -13
- package/src/helpers/getSplitStyles.tsx +59 -1
- package/src/helpers/styleProvenance.ts +49 -0
- package/src/hooks/useThemeState.ts +14 -0
- package/src/types.tsx +4 -0
- package/types/helpers/getSplitStyles.d.ts +2 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/styleProvenance.d.ts +11 -0
- package/types/helpers/styleProvenance.d.ts.map +1 -0
- package/types/hooks/useThemeState.d.ts.map +1 -1
- package/types/types.d.ts +1 -0
- package/types/types.d.ts.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAndroid, isClient, isWeb, supportsDynamicColorIOS } from "@tamagui/constants";
|
|
1
|
+
import { getPlatformDriver, isAndroid, isClient, isWeb, supportsDynamicColorIOS } from "@tamagui/constants";
|
|
2
2
|
import { StyleObjectIdentifier, StyleObjectProperty, StyleObjectPseudo, stylePropsText, stylePropsTransform, tokenCategories, validPseudoKeys, validStyles } from "@tamagui/helpers";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { getConfig, getFont, getSetting } from "../config.native.js";
|
|
@@ -20,12 +20,14 @@ import { defaultMediaImportance, pseudoDescriptors, pseudoPriorities } from "./p
|
|
|
20
20
|
import { skipProps } from "./skipProps.native.js";
|
|
21
21
|
import { sortString } from "./sortString.native.js";
|
|
22
22
|
import { styleOriginalValues } from "./styleOriginalValues.native.js";
|
|
23
|
+
import { STYLE_TOKEN_PROVENANCE_KEY, getStyleTokenProvenance, setStyleTokenProvenance } from "./styleProvenance.native.js";
|
|
23
24
|
import { transformsToString } from "./transformsToString.native.js";
|
|
24
25
|
function _type_of(obj) {
|
|
25
26
|
"@swc/helpers - typeof";
|
|
26
27
|
|
|
27
28
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
28
29
|
}
|
|
30
|
+
var shouldTrackStyleTokenProvenance = process.env.NODE_ENV === "development" && process.env.TAMAGUI_ENABLE_STYLE_TOKEN_PROVENANCE === "1";
|
|
29
31
|
var conf;
|
|
30
32
|
var PROP_SPLIT = "-";
|
|
31
33
|
function normalizeGroupKey(key, groupContext) {
|
|
@@ -41,6 +43,8 @@ function isValidStyleKey(key, validStyles, accept) {
|
|
|
41
43
|
return key in validStyles ? true : accept && key in accept;
|
|
42
44
|
}
|
|
43
45
|
function shouldSkipNativeHoverProp(key, isMedia) {
|
|
46
|
+
var _getPlatformDriver;
|
|
47
|
+
if ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) return false;
|
|
44
48
|
if (key === "hoverStyle") return true;
|
|
45
49
|
if (isMedia === "group") return getGroupPropParts(key.slice(1)).pseudo === "hover";
|
|
46
50
|
return false;
|
|
@@ -137,45 +141,45 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
137
141
|
if (valInit && (keyInit === "fontFamily" || keyInit === shorthands["fontFamily"]) && valInit in conf.fontsParsed) styleState.fontFamily = valInit;
|
|
138
142
|
}
|
|
139
143
|
var disablePropMap = isMediaOrPseudo || !isStyleLikeKey;
|
|
140
|
-
propMapper(keyInit, valInit, styleState, disablePropMap, function (
|
|
144
|
+
propMapper(keyInit, valInit, styleState, disablePropMap, function (key6, val2, originalVal) {
|
|
141
145
|
var _parentStaticConfig_variants;
|
|
142
|
-
var isStyledContextProp = styledContext &&
|
|
146
|
+
var isStyledContextProp = styledContext && key6 in styledContext;
|
|
143
147
|
if (!isHOC && disablePropMap && !isStyledContextProp && !isMediaOrPseudo) {
|
|
144
|
-
viewProps[
|
|
148
|
+
viewProps[key6] = val2;
|
|
145
149
|
return;
|
|
146
150
|
}
|
|
147
151
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
148
|
-
console.groupCollapsed(" 💠 expanded", keyInit, "=>",
|
|
152
|
+
console.groupCollapsed(" 💠 expanded", keyInit, "=>", key6);
|
|
149
153
|
log(val2);
|
|
150
154
|
console.groupEnd();
|
|
151
155
|
}
|
|
152
156
|
if (val2 == null) return;
|
|
153
|
-
if (
|
|
154
|
-
viewProps[
|
|
157
|
+
if (key6 === "pointerEvents") {
|
|
158
|
+
viewProps[key6] = val2;
|
|
155
159
|
return;
|
|
156
160
|
}
|
|
157
|
-
if (!isHOC && isValidStyleKey(
|
|
158
|
-
mergeStyle(styleState,
|
|
161
|
+
if (!isHOC && isValidStyleKey(key6, validStyles$1, accept) || isAndroid && key6 === "elevation") {
|
|
162
|
+
mergeStyle(styleState, key6, val2, 1, false, originalVal);
|
|
159
163
|
return;
|
|
160
164
|
}
|
|
161
|
-
isPseudo =
|
|
162
|
-
isMedia = isPseudo ? false : getMediaKey(
|
|
165
|
+
isPseudo = key6 in validPseudoKeys;
|
|
166
|
+
isMedia = isPseudo ? false : getMediaKey(key6);
|
|
163
167
|
isMediaOrPseudo = Boolean(isMedia || isPseudo);
|
|
164
|
-
isVariant = variants &&
|
|
165
|
-
if (isMedia === "group")
|
|
166
|
-
if (shouldSkipNativeHoverProp(
|
|
167
|
-
if ((inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(
|
|
168
|
+
isVariant = variants && key6 in variants;
|
|
169
|
+
if (isMedia === "group") key6 = normalizeGroupKey(key6, groupContext);
|
|
170
|
+
if (shouldSkipNativeHoverProp(key6, isMedia)) return;
|
|
171
|
+
if ((inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(key6)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened === null || inlineWhenUnflattened === void 0 ? void 0 : inlineWhenUnflattened.has(key6))) {
|
|
168
172
|
var _props_key;
|
|
169
|
-
viewProps[
|
|
173
|
+
viewProps[key6] = (_props_key = props[key6]) !== null && _props_key !== void 0 ? _props_key : val2;
|
|
170
174
|
}
|
|
171
175
|
if (styleProps.noExpand && isPseudo || isHOC && (isMediaOrPseudo || (parentStaticConfig === null || parentStaticConfig === void 0 ? void 0 : (_parentStaticConfig_variants = parentStaticConfig.variants) === null || _parentStaticConfig_variants === void 0 ? void 0 : _parentStaticConfig_variants[keyInit]))) {
|
|
172
|
-
passDownProp(viewProps,
|
|
176
|
+
passDownProp(viewProps, key6, val2, isMediaOrPseudo);
|
|
173
177
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
174
|
-
console.groupCollapsed(` - passing down prop ${
|
|
178
|
+
console.groupCollapsed(` - passing down prop ${key6}`);
|
|
175
179
|
log({
|
|
176
180
|
val: val2,
|
|
177
181
|
after: {
|
|
178
|
-
...viewProps[
|
|
182
|
+
...viewProps[key6]
|
|
179
183
|
}
|
|
180
184
|
});
|
|
181
185
|
console.groupEnd();
|
|
@@ -184,23 +188,23 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
184
188
|
}
|
|
185
189
|
if (isPseudo) {
|
|
186
190
|
if (!val2) return;
|
|
187
|
-
var pseudoStyleObject = getSubStyle(styleState,
|
|
191
|
+
var pseudoStyleObject = getSubStyle(styleState, key6, val2, styleProps.noClass && !(process.env.IS_STATIC === "is_static"));
|
|
188
192
|
if (!shouldDoClasses || process.env.IS_STATIC === "is_static") {
|
|
189
193
|
var _pseudos, _key;
|
|
190
194
|
pseudos || (pseudos = {});
|
|
191
|
-
(_pseudos = pseudos)[_key =
|
|
195
|
+
(_pseudos = pseudos)[_key = key6] || (_pseudos[_key] = {});
|
|
192
196
|
if (process.env.IS_STATIC === "is_static") {
|
|
193
|
-
Object.assign(pseudos[
|
|
197
|
+
Object.assign(pseudos[key6], pseudoStyleObject);
|
|
194
198
|
return;
|
|
195
199
|
}
|
|
196
200
|
}
|
|
197
|
-
var descriptor = pseudoDescriptors[
|
|
198
|
-
var isEnter =
|
|
199
|
-
var isExit =
|
|
201
|
+
var descriptor = pseudoDescriptors[key6];
|
|
202
|
+
var isEnter = key6 === "enterStyle";
|
|
203
|
+
var isExit = key6 === "exitStyle";
|
|
200
204
|
if (!descriptor) return;
|
|
201
205
|
if (shouldDoClasses && !isExit) {
|
|
202
206
|
var pseudoStyles = getStyleAtomic(pseudoStyleObject, descriptor);
|
|
203
|
-
if (process.env.NODE_ENV === "development" && debug === "verbose") console.info("pseudo:",
|
|
207
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") console.info("pseudo:", key6, pseudoStyleObject, pseudoStyles);
|
|
204
208
|
var _iteratorNormalCompletion3 = true,
|
|
205
209
|
_didIteratorError3 = false,
|
|
206
210
|
_iteratorError3 = void 0;
|
|
@@ -226,7 +230,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
226
230
|
if (isExit) isDisabled = !styleProps.isExiting;
|
|
227
231
|
if (isEnter && componentState.unmounted === false) isDisabled = true;
|
|
228
232
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
229
|
-
console.groupCollapsed("pseudo",
|
|
233
|
+
console.groupCollapsed("pseudo", key6, {
|
|
230
234
|
isDisabled
|
|
231
235
|
});
|
|
232
236
|
log({
|
|
@@ -248,8 +252,8 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
248
252
|
if (process.env.IS_STATIC === "is_static") {
|
|
249
253
|
var _pseudos1, _key1;
|
|
250
254
|
pseudos || (pseudos = {});
|
|
251
|
-
(_pseudos1 = pseudos)[_key1 =
|
|
252
|
-
pseudos[
|
|
255
|
+
(_pseudos1 = pseudos)[_key1 = key6] || (_pseudos1[_key1] = {});
|
|
256
|
+
pseudos[key6][pkey] = _$val;
|
|
253
257
|
}
|
|
254
258
|
mergeStyle(styleState, pkey, _$val, importance, false, pseudoOriginalValues === null || pseudoOriginalValues === void 0 ? void 0 : pseudoOriginalValues[pkey]);
|
|
255
259
|
}
|
|
@@ -262,25 +266,25 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
262
266
|
}
|
|
263
267
|
}
|
|
264
268
|
if (!isDisabled) for (var _$key in val2) {
|
|
265
|
-
var
|
|
266
|
-
styleState.usedKeys[
|
|
269
|
+
var k2 = shorthands[_$key] || _$key;
|
|
270
|
+
styleState.usedKeys[k2] = Math.max(importance, styleState.usedKeys[k2] || 0);
|
|
267
271
|
}
|
|
268
272
|
}
|
|
269
273
|
return;
|
|
270
274
|
}
|
|
271
275
|
if (isMedia) {
|
|
272
276
|
if (!val2) return;
|
|
273
|
-
var mediaKeyShort =
|
|
277
|
+
var mediaKeyShort = key6.slice(isMedia == "theme" ? 7 : 1);
|
|
274
278
|
hasMedia || (hasMedia = true);
|
|
275
279
|
if (val2["space"] || !shouldDoClasses || styleProps.willBeAnimated) {
|
|
276
280
|
if (!hasMedia || typeof hasMedia === "boolean") hasMedia = /* @__PURE__ */new Set();
|
|
277
281
|
hasMedia.add(mediaKeyShort);
|
|
278
282
|
}
|
|
279
283
|
if (isMedia === "platform") {
|
|
280
|
-
if (!isActivePlatform(
|
|
284
|
+
if (!isActivePlatform(key6)) return;
|
|
281
285
|
}
|
|
282
|
-
if (process.env.NODE_ENV === "development" && debug === "verbose") log(` \u{1F4FA} ${
|
|
283
|
-
key:
|
|
286
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") log(` \u{1F4FA} ${key6}`, {
|
|
287
|
+
key: key6,
|
|
284
288
|
val: val2,
|
|
285
289
|
props,
|
|
286
290
|
shouldDoClasses,
|
|
@@ -291,7 +295,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
291
295
|
var priority = mediaStylesSeen;
|
|
292
296
|
mediaStylesSeen += 1;
|
|
293
297
|
if (shouldDoClasses) {
|
|
294
|
-
var mediaStyles = getCSSStylesAtomic(getSubStyle(styleState,
|
|
298
|
+
var mediaStyles = getCSSStylesAtomic(getSubStyle(styleState, key6, val2, false));
|
|
295
299
|
var _iteratorNormalCompletion12 = true,
|
|
296
300
|
_didIteratorError12 = false,
|
|
297
301
|
_iteratorError12 = void 0;
|
|
@@ -318,14 +322,14 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
318
322
|
}
|
|
319
323
|
}
|
|
320
324
|
} else {
|
|
321
|
-
let mergeMediaStyle2 = function (
|
|
325
|
+
let mergeMediaStyle2 = function (key7, val3, originalVal2) {
|
|
322
326
|
var _styleState4;
|
|
323
|
-
if (!isValidStyleKey(
|
|
324
|
-
viewProps[
|
|
327
|
+
if (!isValidStyleKey(key7, validStyles$1, accept)) {
|
|
328
|
+
viewProps[key7] = val3;
|
|
325
329
|
return;
|
|
326
330
|
}
|
|
327
331
|
(_styleState4 = styleState).style || (_styleState4.style = {});
|
|
328
|
-
if (mergeMediaByImportance(styleState, mediaKeyShort,
|
|
332
|
+
if (mergeMediaByImportance(styleState, mediaKeyShort, key7, val3, mediaState$1[mediaKeyShort], importanceBump, debug, originalVal2) && key7 === "fontFamily") styleState.fontFamily = mediaStyle1.fontFamily;
|
|
329
333
|
};
|
|
330
334
|
var isThemeMedia = isMedia === "theme";
|
|
331
335
|
var isGroupMedia = isMedia === "group";
|
|
@@ -337,7 +341,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
337
341
|
}
|
|
338
342
|
if (process.env.NODE_ENV === "development" && debug === "verbose") log(` \u{1F4FA} \u2705 ENABLED ${mediaKeyShort}`);
|
|
339
343
|
}
|
|
340
|
-
var mediaStyle1 = getSubStyle(styleState,
|
|
344
|
+
var mediaStyle1 = getSubStyle(styleState, key6, val2, true);
|
|
341
345
|
var importanceBump = 0;
|
|
342
346
|
if (isThemeMedia) {
|
|
343
347
|
if (supportsDynamicColorIOS && getSetting("fastSchemeChange")) {
|
|
@@ -466,7 +470,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
466
470
|
}
|
|
467
471
|
if (!isVariant) {
|
|
468
472
|
if (isStyledContextProp) return;
|
|
469
|
-
viewProps[
|
|
473
|
+
viewProps[key6] = val2;
|
|
470
474
|
}
|
|
471
475
|
});
|
|
472
476
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
@@ -538,9 +542,9 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
538
542
|
fallbackProps
|
|
539
543
|
} = styleProps;
|
|
540
544
|
if (fallbackProps) styleState.props = new Proxy(props, {
|
|
541
|
-
get(_,
|
|
542
|
-
if (!Reflect.has(props,
|
|
543
|
-
return Reflect.get(props,
|
|
545
|
+
get(_, key6, val2) {
|
|
546
|
+
if (!Reflect.has(props, key6)) return Reflect.get(fallbackProps, key6);
|
|
547
|
+
return Reflect.get(props, key6);
|
|
544
548
|
}
|
|
545
549
|
});
|
|
546
550
|
}
|
|
@@ -610,7 +614,12 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
610
614
|
if (style) if (style["$$css"]) Object.assign(styleState.classNames, style);else {
|
|
611
615
|
var _styleState2;
|
|
612
616
|
(_styleState2 = styleState).style || (_styleState2.style = {});
|
|
613
|
-
|
|
617
|
+
var normalized = normalizeStyle(style);
|
|
618
|
+
Object.assign(styleState.style, normalized);
|
|
619
|
+
if (shouldTrackStyleTokenProvenance) {
|
|
620
|
+
var styleOriginals = styleOriginalValues.get(normalized);
|
|
621
|
+
for (var k in normalized) recordStyleTokenProvenance(styleState, k, styleOriginals === null || styleOriginals === void 0 ? void 0 : styleOriginals[k]);
|
|
622
|
+
}
|
|
614
623
|
}
|
|
615
624
|
}
|
|
616
625
|
}
|
|
@@ -636,6 +645,18 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
636
645
|
if (process.env.NODE_ENV === "development" && debug && debug !== "profile") log(`Found fontFamily native: ${style1.fontFamily}`, faceInfo);
|
|
637
646
|
}
|
|
638
647
|
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-pre-result`;
|
|
648
|
+
if (shouldTrackStyleTokenProvenance && styleState.style && styleState.tokenProvenance) {
|
|
649
|
+
var provenance = {};
|
|
650
|
+
var hasProvenance = false;
|
|
651
|
+
for (var key4 in styleState.tokenProvenance) {
|
|
652
|
+
provenance[key4] = {
|
|
653
|
+
token: styleState.tokenProvenance[key4],
|
|
654
|
+
theme: themeName
|
|
655
|
+
};
|
|
656
|
+
hasProvenance = true;
|
|
657
|
+
}
|
|
658
|
+
if (hasProvenance) setStyleTokenProvenance(styleState.style, provenance);
|
|
659
|
+
}
|
|
639
660
|
var result = {
|
|
640
661
|
hasMedia,
|
|
641
662
|
fontFamily: styleState.fontFamily,
|
|
@@ -670,7 +691,7 @@ var getSplitStyles = function (props, staticConfig, theme, themeName, componentS
|
|
|
670
691
|
rulesToInsert,
|
|
671
692
|
parentSplitStyles
|
|
672
693
|
};
|
|
673
|
-
for (var
|
|
694
|
+
for (var key5 in logs) log(key5, logs[key5]);
|
|
674
695
|
} catch (e) {}
|
|
675
696
|
console.groupEnd();
|
|
676
697
|
}
|
|
@@ -720,9 +741,16 @@ function mergeStyle(styleState, key, val, importance) {
|
|
|
720
741
|
(_styleState2 = styleState).style || (_styleState2.style = {});
|
|
721
742
|
usedKeys[key] = importance;
|
|
722
743
|
styleState.style[key] = key === "transform" && Array.isArray(out) ? [...out] : out;
|
|
744
|
+
if (shouldTrackStyleTokenProvenance) recordStyleTokenProvenance(styleState, key, originalVal);
|
|
723
745
|
}
|
|
724
746
|
}
|
|
725
747
|
}
|
|
748
|
+
function recordStyleTokenProvenance(styleState, key, originalVal) {
|
|
749
|
+
if (typeof originalVal === "string" && originalVal[0] === "$") {
|
|
750
|
+
var _styleState;
|
|
751
|
+
((_styleState = styleState).tokenProvenance || (_styleState.tokenProvenance = {}))[key] = originalVal;
|
|
752
|
+
} else if (styleState.tokenProvenance && key in styleState.tokenProvenance) delete styleState.tokenProvenance[key];
|
|
753
|
+
}
|
|
726
754
|
var getSubStyle = function (styleState, subKey, styleIn, avoidMergeTransform) {
|
|
727
755
|
var {
|
|
728
756
|
staticConfig,
|
|
@@ -890,5 +918,5 @@ function applyDefaultStyle(pkey, styleState) {
|
|
|
890
918
|
var defaultValues = animatableDefaults[pkey];
|
|
891
919
|
if (defaultValues != null && !(pkey in styleState.usedKeys) && (!styleState.style || !(pkey in styleState.style))) mergeStyle(styleState, pkey, defaultValues, 1);
|
|
892
920
|
}
|
|
893
|
-
export { PROP_SPLIT, getSplitStyles, getSubStyle, styleOriginalValues, useSplitStyles };
|
|
921
|
+
export { PROP_SPLIT, STYLE_TOKEN_PROVENANCE_KEY, getSplitStyles, getStyleTokenProvenance, getSubStyle, styleOriginalValues, useSplitStyles };
|
|
894
922
|
//# sourceMappingURL=getSplitStyles.native.js.map
|