@tamagui/web 2.0.0-1768427228811 → 2.0.0-1768530912818
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/_withStableStyle.cjs +5 -2
- package/dist/cjs/_withStableStyle.js +3 -3
- package/dist/cjs/_withStableStyle.js.map +1 -1
- package/dist/cjs/_withStableStyle.native.js +10 -2
- package/dist/cjs/_withStableStyle.native.js.map +1 -1
- package/dist/cjs/helpers/getDynamicVal.cjs +22 -1
- package/dist/cjs/helpers/getDynamicVal.js +22 -1
- package/dist/cjs/helpers/getDynamicVal.js.map +1 -1
- package/dist/cjs/helpers/getDynamicVal.native.js +22 -1
- package/dist/cjs/helpers/getDynamicVal.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.cjs +1 -19
- package/dist/cjs/helpers/getSplitStyles.js +2 -25
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.native.js +8 -4
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/_withStableStyle.js +3 -2
- package/dist/esm/_withStableStyle.js.map +1 -1
- package/dist/esm/_withStableStyle.mjs +5 -2
- package/dist/esm/_withStableStyle.mjs.map +1 -1
- package/dist/esm/_withStableStyle.native.js +10 -2
- package/dist/esm/_withStableStyle.native.js.map +1 -1
- package/dist/esm/helpers/getDynamicVal.js +22 -1
- package/dist/esm/helpers/getDynamicVal.js.map +1 -1
- package/dist/esm/helpers/getDynamicVal.mjs +21 -1
- package/dist/esm/helpers/getDynamicVal.mjs.map +1 -1
- package/dist/esm/helpers/getDynamicVal.native.js +21 -1
- package/dist/esm/helpers/getDynamicVal.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +4 -32
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +4 -22
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +9 -5
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/package.json +12 -12
- package/src/_withStableStyle.tsx +14 -1
- package/src/helpers/getDynamicVal.ts +35 -0
- package/src/helpers/getSplitStyles.tsx +34 -13
- package/types/_withStableStyle.d.ts.map +1 -1
- package/types/helpers/getDynamicVal.d.ts +4 -0
- package/types/helpers/getDynamicVal.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
|
@@ -37,7 +37,6 @@ import type {
|
|
|
37
37
|
GetStyleState,
|
|
38
38
|
PseudoStyles,
|
|
39
39
|
RulesToInsert,
|
|
40
|
-
SpaceTokens,
|
|
41
40
|
SplitStyleProps,
|
|
42
41
|
StaticConfig,
|
|
43
42
|
StyleObject,
|
|
@@ -54,6 +53,7 @@ import {
|
|
|
54
53
|
extractValueFromDynamic,
|
|
55
54
|
getDynamicVal,
|
|
56
55
|
getOppositeScheme,
|
|
56
|
+
isColorStyleKey,
|
|
57
57
|
} from './getDynamicVal'
|
|
58
58
|
import { getGroupPropParts } from './getGroupPropParts'
|
|
59
59
|
import { insertStyleRules, shouldInsertStyleRules, updateRules } from './insertStyleRule'
|
|
@@ -204,7 +204,6 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
204
204
|
const classNames: ClassNamesObject = {}
|
|
205
205
|
|
|
206
206
|
let pseudos: PseudoStyles | null = null
|
|
207
|
-
let space: SpaceTokens | null = props.space
|
|
208
207
|
let hasMedia: boolean | Set<string> = false
|
|
209
208
|
let dynamicThemeAccess: boolean | undefined
|
|
210
209
|
let pseudoGroups: Set<string> | undefined
|
|
@@ -896,24 +895,44 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
896
895
|
let importanceBump = 0
|
|
897
896
|
|
|
898
897
|
if (isThemeMedia) {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
898
|
+
if (
|
|
899
|
+
process.env.TAMAGUI_TARGET === 'native' &&
|
|
900
|
+
isIos &&
|
|
901
|
+
getSetting('fastSchemeChange')
|
|
902
|
+
) {
|
|
903
903
|
// iOS will use https://reactnative.dev/docs/dynamiccolorios
|
|
904
|
-
//
|
|
905
|
-
//
|
|
904
|
+
// so need to predefine the dynamic color before merging the styles
|
|
905
|
+
// for example: <StyledYStack $theme-dark={{borderColor: '$red10'}} $theme-light={{borderColor: '$green10'}}> => {borderColor: {dynamic: {dark: '$red10', light: '$green10'}}}
|
|
906
906
|
|
|
907
907
|
styleState.style ||= {}
|
|
908
908
|
const scheme = mediaKeyShort
|
|
909
909
|
const oppositeScheme = getOppositeScheme(mediaKeyShort)
|
|
910
910
|
const themeOriginalValues = styleOriginalValues.get(mediaStyle)
|
|
911
|
+
const isCurrentScheme = themeName === scheme || themeName.startsWith(scheme)
|
|
911
912
|
|
|
912
913
|
for (const subKey in mediaStyle) {
|
|
913
914
|
const val = extractValueFromDynamic(mediaStyle[subKey], scheme)
|
|
914
915
|
const existing = styleState.style[subKey]
|
|
915
916
|
|
|
916
|
-
//
|
|
917
|
+
// Only color properties support DynamicColorIOS - non-color properties
|
|
918
|
+
// like opacity, dimensions, etc. will crash if wrapped with {dynamic: {...}}
|
|
919
|
+
// See: https://github.com/tamagui/tamagui/issues/3096
|
|
920
|
+
// See: https://github.com/tamagui/tamagui/issues/2980
|
|
921
|
+
if (!isColorStyleKey(subKey)) {
|
|
922
|
+
// non-color properties require re-render to update
|
|
923
|
+
dynamicThemeAccess = true
|
|
924
|
+
// only apply if this is the current theme
|
|
925
|
+
if (isCurrentScheme) {
|
|
926
|
+
// update mediastyle so the later merge loop uses correct value
|
|
927
|
+
mediaStyle[subKey] = val
|
|
928
|
+
} else {
|
|
929
|
+
// Remove from mediaStyle so it doesn't get merged with wrong theme's value
|
|
930
|
+
delete mediaStyle[subKey]
|
|
931
|
+
}
|
|
932
|
+
continue
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// if there's already a dynamic object from the other theme pseudo prop,
|
|
917
936
|
// merge directly to avoid importance conflicts between $theme-dark and $theme-light
|
|
918
937
|
if (existing?.dynamic) {
|
|
919
938
|
existing.dynamic[scheme] = val
|
|
@@ -935,10 +954,12 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
935
954
|
)
|
|
936
955
|
}
|
|
937
956
|
}
|
|
938
|
-
} else
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
957
|
+
} else {
|
|
958
|
+
// non-ios or no fastschemechange - need re-renders for theme changes
|
|
959
|
+
dynamicThemeAccess = true
|
|
960
|
+
if (!(themeName === mediaKeyShort || themeName.startsWith(mediaKeyShort))) {
|
|
961
|
+
return
|
|
962
|
+
}
|
|
942
963
|
}
|
|
943
964
|
} else if (isGroupMedia) {
|
|
944
965
|
const groupInfo = getGroupPropParts(mediaKeyShort)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_withStableStyle.d.ts","sourceRoot":"","sources":["../src/_withStableStyle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"_withStableStyle.d.ts","sourceRoot":"","sources":["../src/_withStableStyle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,4DAA4D;AAE5D,eAAO,MAAM,gBAAgB,GAC3B,WAAW,GAAG,EACd,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,MAAM,qFAkBvD,CAAA"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare function getOppositeScheme(scheme: string): "light" | "dark";
|
|
2
|
+
/**
|
|
3
|
+
* Check if a style key is a color property that supports DynamicColorIOS.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isColorStyleKey(key: string): boolean;
|
|
2
6
|
export declare function getDynamicVal({ scheme, val, oppositeVal, }: {
|
|
3
7
|
scheme: string;
|
|
4
8
|
val: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDynamicVal.d.ts","sourceRoot":"","sources":["../../src/helpers/getDynamicVal.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,oBAE/C;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,WAAW,GACZ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;;;;EAQtD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAK/D"}
|
|
1
|
+
{"version":3,"file":"getDynamicVal.d.ts","sourceRoot":"","sources":["../../src/helpers/getDynamicVal.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,oBAE/C;AA8BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,WAAW,GACZ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;;;;EAQtD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAK/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,aAAa,
|
|
1
|
+
{"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,aAAa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