@tamagui/web 3.0.0-beta.745.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.
Files changed (55) hide show
  1. package/dist/cjs/helpers/directStyle.cjs +7 -3
  2. package/dist/cjs/helpers/directStyle.native.cjs +7 -3
  3. package/dist/cjs/helpers/directStyle.native.js +7 -3
  4. package/dist/cjs/helpers/directStyle.native.js.map +1 -1
  5. package/dist/cjs/helpers/getCSSStylesAtomic.cjs +6 -7
  6. package/dist/cjs/helpers/getSplitStyles.cjs +106 -10
  7. package/dist/cjs/helpers/getSplitStyles.native.cjs +168 -10
  8. package/dist/cjs/helpers/getSplitStyles.native.js +168 -10
  9. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  10. package/dist/cjs/helpers/propMapper.cjs +32 -6
  11. package/dist/cjs/helpers/propMapper.native.cjs +45 -6
  12. package/dist/cjs/helpers/propMapper.native.js +45 -6
  13. package/dist/cjs/helpers/propMapper.native.js.map +1 -1
  14. package/dist/cjs/hooks/useComponentState.cjs +6 -4
  15. package/dist/cjs/hooks/useComponentState.native.cjs +6 -4
  16. package/dist/cjs/hooks/useComponentState.native.js +6 -4
  17. package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
  18. package/dist/esm/helpers/directStyle.mjs +7 -4
  19. package/dist/esm/helpers/directStyle.mjs.map +1 -1
  20. package/dist/esm/helpers/directStyle.native.js +7 -4
  21. package/dist/esm/helpers/directStyle.native.js.map +1 -1
  22. package/dist/esm/helpers/getCSSStylesAtomic.mjs +6 -7
  23. package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
  24. package/dist/esm/helpers/getSplitStyles.mjs +107 -11
  25. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  26. package/dist/esm/helpers/getSplitStyles.native.js +169 -11
  27. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  28. package/dist/esm/helpers/propMapper.mjs +33 -7
  29. package/dist/esm/helpers/propMapper.mjs.map +1 -1
  30. package/dist/esm/helpers/propMapper.native.js +46 -7
  31. package/dist/esm/helpers/propMapper.native.js.map +1 -1
  32. package/dist/esm/hooks/useComponentState.mjs +6 -4
  33. package/dist/esm/hooks/useComponentState.mjs.map +1 -1
  34. package/dist/esm/hooks/useComponentState.native.js +6 -4
  35. package/dist/esm/hooks/useComponentState.native.js.map +1 -1
  36. package/package.json +15 -15
  37. package/src/helpers/directStyle.ts +10 -4
  38. package/src/helpers/getCSSStylesAtomic.ts +16 -10
  39. package/src/helpers/getSplitStyles.tsx +183 -17
  40. package/src/helpers/propMapper.ts +64 -13
  41. package/src/hooks/useComponentState.ts +15 -4
  42. package/src/styled.tsx +4 -0
  43. package/src/types.tsx +13 -2
  44. package/types/dom/html.d.ts +49 -49
  45. package/types/dom/html.native.d.ts +46 -46
  46. package/types/helpers/directStyle.d.ts +1 -0
  47. package/types/helpers/directStyle.d.ts.map +1 -1
  48. package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
  49. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  50. package/types/helpers/propMapper.d.ts +2 -2
  51. package/types/helpers/propMapper.d.ts.map +1 -1
  52. package/types/hooks/useComponentState.d.ts.map +1 -1
  53. package/types/styled.d.ts.map +1 -1
  54. package/types/types.d.ts +4 -1
  55. package/types/types.d.ts.map +1 -1
@@ -41,7 +41,7 @@ var lifecycleHandler = {
41
41
  return true;
42
42
  }
43
43
  };
44
- function hasFlatModifier(props, config, modifiers, ctx) {
44
+ function hasFlatModifier(props, config, modifiers, ctx, variants) {
45
45
  var _ctx;
46
46
  var scan = (_ctx = ctx).flatScan || (_ctx.flatScan = [
47
47
  "",
@@ -56,7 +56,9 @@ function hasFlatModifier(props, config, modifiers, ctx) {
56
56
  continue;
57
57
  }
58
58
  var property = config.shorthands[key] || key;
59
- if (!(property in stylePropsAll) && property !== "transition") continue;
59
+ if (!(property in stylePropsAll) && property !== "transition" && !(variants && key in variants)) {
60
+ continue;
61
+ }
60
62
  if (!isString) {
61
63
  if (property === "transition") continue;
62
64
  for (var chain in value) {
@@ -104,7 +106,7 @@ var useComponentState = function(props, animationDriver, staticConfig, config) {
104
106
  if (!needsHydration && hasAnimationProp) {
105
107
  curStateRef.hasAnimated = true;
106
108
  }
107
- var platformPseudo = Boolean(!isHOC && useAnimations && (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.avoidReRenders) && ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) && hasFlatModifier(props, config, platformPseudoModifiers, curStateRef));
109
+ var platformPseudo = Boolean(!isHOC && useAnimations && (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.avoidReRenders) && ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) && hasFlatModifier(props, config, platformPseudoModifiers, curStateRef, staticConfig.variants));
108
110
  var willBeAnimatedClient = (function() {
109
111
  var next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);
110
112
  return Boolean(next || curStateRef.hasAnimated);
@@ -118,7 +120,7 @@ var useComponentState = function(props, animationDriver, staticConfig, config) {
118
120
  var presenceState = presence === null || presence === void 0 ? void 0 : presence[2];
119
121
  var isExiting = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === false;
120
122
  var isEntering = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === true && presenceState.initial !== false;
121
- var hasEnterStyle = hasFlatModifier(props, config, enterModifier, curStateRef);
123
+ var hasEnterStyle = hasFlatModifier(props, config, enterModifier, curStateRef, staticConfig.variants);
122
124
  var hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && ((animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isReactNative) || inputStyle !== "css");
123
125
  var canImmediatelyEnter = hasEnterStyle || isEntering;
124
126
  var shouldEnter = !isHOC && (hasEnterStyle || isEntering || hasAnimationThatNeedsHydrate || disableClassName);
@@ -1 +1 @@
1
- {"version":3,"file":"useComponentState.native.js","names":[],"sources":["esm/hooks/useComponentState.native.js"],"sourcesContent":["import { getPlatformDriver, isServer, isWeb } from \"@tamagui/constants\";\nimport { stylePropsAll } from \"@tamagui/helpers\";\nimport { canonicalClauseModifier, scanFlatValue } from \"@tamagui/style-grammar/runtime\";\nimport { mergeIfNotShallowEqual } from \"@tamagui/is-equal-shallow\";\nimport { useDidFinishSSR, useIsClientOnly } from \"@tamagui/use-did-finish-ssr\";\nimport { useRef, useState } from \"react\";\nimport { getSetting } from \"../config\";\nimport { formatDiagnostic } from \"../helpers/formatDiagnostic\";\nimport { isOptimizedForFirstRender } from \"./isOptimizedForFirstRender\";\nimport { defaultComponentState, defaultComponentStateMounted, defaultComponentStateShouldEnter } from \"../defaultComponentState\";\nimport { isObj } from \"../helpers/isObj\";\nimport { log } from \"../helpers/log\";\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nvar platformPseudoModifiers = /* @__PURE__ */ new Set([\n \"hover\",\n \"press\",\n \"focus\"\n]);\nvar enterModifier = /* @__PURE__ */ new Set([\n \"enter\"\n]);\nvar lifecycleHandler = {\n segment(ctx, start, end, isBase, valid) {\n var scan = ctx.flatScan;\n if (!isBase && valid && start < end && scan[3]) scan[2] = true;\n scan[3] = false;\n },\n chain(ctx, start, end, valid) {\n var scan = ctx.flatScan;\n scan[3] = false;\n if (!valid) return true;\n for (var index = start; index <= end; index++) {\n if (index !== end && scan[0].charCodeAt(index) !== 58) continue;\n if (scan[1].has(canonicalClauseModifier(scan[0].slice(start, index)))) {\n scan[3] = true;\n }\n start = index + 1;\n }\n return true;\n }\n};\nfunction hasFlatModifier(props, config, modifiers, ctx) {\n var _ctx;\n var scan = (_ctx = ctx).flatScan || (_ctx.flatScan = [\n \"\",\n enterModifier,\n false,\n false\n ]);\n for (var key in props) {\n var value = props[key];\n var isString = typeof value === \"string\";\n if (isString ? value.indexOf(\":\") === -1 : !value || (typeof value === \"undefined\" ? \"undefined\" : _type_of(value)) !== \"object\") {\n continue;\n }\n var property = config.shorthands[key] || key;\n if (!(property in stylePropsAll) && property !== \"transition\") continue;\n if (!isString) {\n if (property === \"transition\") continue;\n for (var chain in value) {\n if (chain === \"default\" || value[chain] == null) continue;\n var start = 0;\n for (var index = 0; index <= chain.length; index++) {\n if (index !== chain.length && chain.charCodeAt(index) !== 58) continue;\n if (modifiers.has(canonicalClauseModifier(chain.slice(start, index)))) {\n return true;\n }\n start = index + 1;\n }\n }\n continue;\n }\n scan[0] = value;\n scan[1] = modifiers;\n scan[2] = false;\n scan[3] = false;\n scanFlatValue(value, lifecycleHandler, ctx);\n if (scan[2]) return true;\n }\n return false;\n}\nvar useComponentState = function(props, animationDriver, staticConfig, config) {\n \"use no memo\";\n var _getPlatformDriver, _animationDriver_usePresence;\n var isHydrated = useDidFinishSSR();\n var needsHydration = !useIsClientOnly();\n var useAnimations = (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isStub) ? void 0 : animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.useAnimations;\n var { isHOC } = staticConfig;\n var stateRef = useRef(\n // performance: avoid creating object every render\n void 0\n );\n if (!stateRef.current) {\n stateRef.current = {\n startedUnhydrated: needsHydration && !isHydrated,\n optimizeForFirstRender: isOptimizedForFirstRender()\n };\n }\n var hasAnimationProp = Boolean(!isHOC && \"transition\" in props || props.style && hasAnimatedStyleValue(props.style));\n var _animationDriver_inputStyle;\n var inputStyle = (_animationDriver_inputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.inputStyle) !== null && _animationDriver_inputStyle !== void 0 ? _animationDriver_inputStyle : \"css\";\n var _animationDriver_outputStyle;\n var outputStyle = (_animationDriver_outputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.outputStyle) !== null && _animationDriver_outputStyle !== void 0 ? _animationDriver_outputStyle : \"css\";\n var curStateRef = stateRef.current;\n if (!needsHydration && hasAnimationProp) {\n curStateRef.hasAnimated = true;\n }\n var platformPseudo = Boolean(!isHOC && useAnimations && (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.avoidReRenders) && ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) && hasFlatModifier(props, config, platformPseudoModifiers, curStateRef));\n var willBeAnimatedClient = (function() {\n var next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);\n return Boolean(next || curStateRef.hasAnimated);\n })();\n var willBeAnimated = !isServer && willBeAnimatedClient;\n if (willBeAnimated && !curStateRef.hasAnimated) {\n curStateRef.hasAnimated = true;\n }\n var { disableClassName } = props;\n var presence = !isHOC && willBeAnimated && props[\"animatePresence\"] !== false && (animationDriver === null || animationDriver === void 0 ? void 0 : (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null;\n var presenceState = presence === null || presence === void 0 ? void 0 : presence[2];\n var isExiting = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === false;\n var isEntering = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === true && presenceState.initial !== false;\n var hasEnterStyle = hasFlatModifier(props, config, enterModifier, curStateRef);\n var hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && ((animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isReactNative) || inputStyle !== \"css\");\n var canImmediatelyEnter = hasEnterStyle || isEntering;\n var shouldEnter = !isHOC && (hasEnterStyle || isEntering || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate\n // this is just for a better ux, supports css variables for light/dark, media queries, etc\n disableClassName);\n var initialState = shouldEnter ? (\n // on the very first render we switch all spring animation drivers to css rendering\n // this is because we need to use css variables, which they don't support to do proper SSR\n // without flickers of the wrong colors.\n // but once we do that initial hydration and we are in client side rendering mode,\n // we can avoid the extra re-render on mount\n canImmediatelyEnter ? defaultComponentStateShouldEnter : defaultComponentState\n ) : defaultComponentStateMounted;\n var disabled = isDisabled(props);\n if (disabled != null) {\n initialState.disabled = disabled;\n }\n var states = useState(initialState);\n var state = props.forceStyle ? {\n ...states[0],\n [props.forceStyle]: true\n } : states[0];\n var setState = states[1];\n var isAnimated = willBeAnimated;\n if (isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated) {\n isAnimated = false;\n curStateRef.willHydrate = true;\n }\n if (disabled !== state.disabled) {\n if (disabled) {\n Object.assign(state, defaultComponentStateMounted);\n }\n state.disabled = disabled;\n setState(function(_) {\n return {\n ...state\n };\n });\n }\n var groupName = props.group;\n if (!stateRef.current.baseSetStateShallow) {\n var r = stateRef.current;\n r.baseSetStateShallow = function(stateOrGetState) {\n setState(function(prev) {\n var next = typeof stateOrGetState === \"function\" ? stateOrGetState(prev) : stateOrGetState;\n var update = mergeIfNotShallowEqual(prev, next);\n if (process.env.NODE_ENV === \"development\") {\n var dbg = r.__debug;\n if (dbg && update !== prev) {\n console.groupCollapsed(`setStateShallow CHANGE`, \"=>\", update);\n console.info(`previously`, prev);\n console.trace();\n console.groupEnd();\n }\n }\n return update;\n });\n };\n }\n if (process.env.NODE_ENV === \"development\") {\n ;\n stateRef.current.__debug = props.debug;\n }\n var setStateShallow = stateRef.current.baseSetStateShallow;\n if (process.env.NODE_ENV === \"development\" && globalThis.time) globalThis.time`state-useCreateShallowSetState`;\n var outProps = props;\n if (presenceState && isAnimated && isHydrated && staticConfig.variants) {\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n var _staticConfig_Component, _staticConfig_Component1;\n console.warn(formatDiagnostic(\"TAMAGUI_PRESENCE_STATE\", ((_staticConfig_Component = staticConfig.Component) === null || _staticConfig_Component === void 0 ? void 0 : _staticConfig_Component.displayName) || ((_staticConfig_Component1 = staticConfig.Component) === null || _staticConfig_Component1 === void 0 ? void 0 : _staticConfig_Component1.name) || \"TamaguiComponent\", \"AnimatePresence supplied lifecycle state to an animated component\", 'Remove debug=\"verbose\" after inspecting the animation state', \"presenceState\", presenceState));\n }\n var { custom } = presenceState;\n if (isObj(custom)) {\n outProps = {\n ...props,\n ...custom\n };\n }\n }\n var noClass = !isWeb || !!props.forceStyle;\n if (!isHydrated) {\n noClass = false;\n } else {\n if (isWeb && isHydrated) {\n var isAnimatedAndHydrated = isAnimated && isHydrated;\n var isClassNameDisabled = !staticConfig.acceptsClassName && (getSetting(\"disableSSR\") || !state.unmounted);\n var isDisabledManually = disableClassName && !state.unmounted;\n if (\n // Only disable className for animation drivers that output inline styles (not css)\n isAnimatedAndHydrated && outputStyle !== \"css\" || isDisabledManually || isClassNameDisabled\n ) {\n noClass = true;\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n log(`avoiding className`, {\n isAnimatedAndHydrated,\n isDisabledManually,\n isClassNameDisabled\n });\n }\n }\n }\n }\n return {\n props: outProps,\n startedUnhydrated: curStateRef.startedUnhydrated,\n curStateRef,\n disabled,\n groupName,\n hasAnimationProp,\n hasEnterStyle,\n isAnimated,\n isExiting,\n isHydrated,\n presence,\n presenceState,\n setState,\n setStateShallow,\n noClass,\n state,\n stateRef,\n inputStyle,\n outputStyle,\n willBeAnimated,\n willBeAnimatedClient,\n platformPseudo\n };\n};\nfunction hasAnimatedStyleValue(style) {\n for (var k in style) {\n var val = style[k];\n if (val && (typeof val === \"undefined\" ? \"undefined\" : _type_of(val)) === \"object\" && \"_animation\" in val) {\n return true;\n }\n }\n return false;\n}\nvar isDisabled = function(props) {\n var _props_accessibilityState;\n return props.disabled || props.passThrough || ((_props_accessibilityState = props.accessibilityState) === null || _props_accessibilityState === void 0 ? void 0 : _props_accessibilityState.disabled) || props[\"aria-disabled\"] || props.accessibilityDisabled || false;\n};\nexport {\n useComponentState\n};\n//# sourceMappingURL=useComponentState.js.map\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAS,SAAS,KAAK;CACrB;CACA,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I,KAAK,OAAO;EACnB,IAAI,MAAM,MAAM;EAChB,IAAI,QAAQ,OAAO,QAAQ,cAAc,cAAc,SAAS,GAAG,OAAO,YAAY,gBAAgB,KAAK;GACzG,OAAO;EACT;CACF;CACA,OAAO;AACT;AACA,IAAI,aAAa,SAAS,OAAO;CAC/B,IAAI;CACJ,OAAO,MAAM,YAAY,MAAM,iBAAiB,4BAA4B,MAAM,wBAAwB,QAAQ,8BAA8B,KAAK,IAAI,KAAK,IAAI,0BAA0B,aAAa,MAAM,oBAAoB,MAAM,yBAAyB;AACpQ"}
1
+ {"version":3,"file":"useComponentState.native.js","names":[],"sources":["esm/hooks/useComponentState.native.js"],"sourcesContent":["import { getPlatformDriver, isServer, isWeb } from \"@tamagui/constants\";\nimport { stylePropsAll } from \"@tamagui/helpers\";\nimport { canonicalClauseModifier, scanFlatValue } from \"@tamagui/style-grammar/runtime\";\nimport { mergeIfNotShallowEqual } from \"@tamagui/is-equal-shallow\";\nimport { useDidFinishSSR, useIsClientOnly } from \"@tamagui/use-did-finish-ssr\";\nimport { useRef, useState } from \"react\";\nimport { getSetting } from \"../config\";\nimport { formatDiagnostic } from \"../helpers/formatDiagnostic\";\nimport { isOptimizedForFirstRender } from \"./isOptimizedForFirstRender\";\nimport { defaultComponentState, defaultComponentStateMounted, defaultComponentStateShouldEnter } from \"../defaultComponentState\";\nimport { isObj } from \"../helpers/isObj\";\nimport { log } from \"../helpers/log\";\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nvar platformPseudoModifiers = /* @__PURE__ */ new Set([\n \"hover\",\n \"press\",\n \"focus\"\n]);\nvar enterModifier = /* @__PURE__ */ new Set([\n \"enter\"\n]);\nvar lifecycleHandler = {\n segment(ctx, start, end, isBase, valid) {\n var scan = ctx.flatScan;\n if (!isBase && valid && start < end && scan[3]) scan[2] = true;\n scan[3] = false;\n },\n chain(ctx, start, end, valid) {\n var scan = ctx.flatScan;\n scan[3] = false;\n if (!valid) return true;\n for (var index = start; index <= end; index++) {\n if (index !== end && scan[0].charCodeAt(index) !== 58) continue;\n if (scan[1].has(canonicalClauseModifier(scan[0].slice(start, index)))) {\n scan[3] = true;\n }\n start = index + 1;\n }\n return true;\n }\n};\nfunction hasFlatModifier(props, config, modifiers, ctx, variants) {\n var _ctx;\n var scan = (_ctx = ctx).flatScan || (_ctx.flatScan = [\n \"\",\n enterModifier,\n false,\n false\n ]);\n for (var key in props) {\n var value = props[key];\n var isString = typeof value === \"string\";\n if (isString ? value.indexOf(\":\") === -1 : !value || (typeof value === \"undefined\" ? \"undefined\" : _type_of(value)) !== \"object\") {\n continue;\n }\n var property = config.shorthands[key] || key;\n if (!(property in stylePropsAll) && property !== \"transition\" && // conditional variant props resolve style branches too, so their\n // lifecycle clauses drive the same decision\n !(variants && key in variants)) {\n continue;\n }\n if (!isString) {\n if (property === \"transition\") continue;\n for (var chain in value) {\n if (chain === \"default\" || value[chain] == null) continue;\n var start = 0;\n for (var index = 0; index <= chain.length; index++) {\n if (index !== chain.length && chain.charCodeAt(index) !== 58) continue;\n if (modifiers.has(canonicalClauseModifier(chain.slice(start, index)))) {\n return true;\n }\n start = index + 1;\n }\n }\n continue;\n }\n scan[0] = value;\n scan[1] = modifiers;\n scan[2] = false;\n scan[3] = false;\n scanFlatValue(value, lifecycleHandler, ctx);\n if (scan[2]) return true;\n }\n return false;\n}\nvar useComponentState = function(props, animationDriver, staticConfig, config) {\n \"use no memo\";\n var _getPlatformDriver, _animationDriver_usePresence;\n var isHydrated = useDidFinishSSR();\n var needsHydration = !useIsClientOnly();\n var useAnimations = (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isStub) ? void 0 : animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.useAnimations;\n var { isHOC } = staticConfig;\n var stateRef = useRef(\n // performance: avoid creating object every render\n void 0\n );\n if (!stateRef.current) {\n stateRef.current = {\n startedUnhydrated: needsHydration && !isHydrated,\n optimizeForFirstRender: isOptimizedForFirstRender()\n };\n }\n var hasAnimationProp = Boolean(!isHOC && \"transition\" in props || props.style && hasAnimatedStyleValue(props.style));\n var _animationDriver_inputStyle;\n var inputStyle = (_animationDriver_inputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.inputStyle) !== null && _animationDriver_inputStyle !== void 0 ? _animationDriver_inputStyle : \"css\";\n var _animationDriver_outputStyle;\n var outputStyle = (_animationDriver_outputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.outputStyle) !== null && _animationDriver_outputStyle !== void 0 ? _animationDriver_outputStyle : \"css\";\n var curStateRef = stateRef.current;\n if (!needsHydration && hasAnimationProp) {\n curStateRef.hasAnimated = true;\n }\n var platformPseudo = Boolean(!isHOC && useAnimations && (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.avoidReRenders) && ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) && hasFlatModifier(props, config, platformPseudoModifiers, curStateRef, staticConfig.variants));\n var willBeAnimatedClient = (function() {\n var next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);\n return Boolean(next || curStateRef.hasAnimated);\n })();\n var willBeAnimated = !isServer && willBeAnimatedClient;\n if (willBeAnimated && !curStateRef.hasAnimated) {\n curStateRef.hasAnimated = true;\n }\n var { disableClassName } = props;\n var presence = !isHOC && willBeAnimated && props[\"animatePresence\"] !== false && (animationDriver === null || animationDriver === void 0 ? void 0 : (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null;\n var presenceState = presence === null || presence === void 0 ? void 0 : presence[2];\n var isExiting = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === false;\n var isEntering = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === true && presenceState.initial !== false;\n var hasEnterStyle = hasFlatModifier(props, config, enterModifier, curStateRef, staticConfig.variants);\n var hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && ((animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isReactNative) || inputStyle !== \"css\");\n var canImmediatelyEnter = hasEnterStyle || isEntering;\n var shouldEnter = !isHOC && (hasEnterStyle || isEntering || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate\n // this is just for a better ux, supports css variables for light/dark, media queries, etc\n disableClassName);\n var initialState = shouldEnter ? (\n // on the very first render we switch all spring animation drivers to css rendering\n // this is because we need to use css variables, which they don't support to do proper SSR\n // without flickers of the wrong colors.\n // but once we do that initial hydration and we are in client side rendering mode,\n // we can avoid the extra re-render on mount\n canImmediatelyEnter ? defaultComponentStateShouldEnter : defaultComponentState\n ) : defaultComponentStateMounted;\n var disabled = isDisabled(props);\n if (disabled != null) {\n initialState.disabled = disabled;\n }\n var states = useState(initialState);\n var state = props.forceStyle ? {\n ...states[0],\n [props.forceStyle]: true\n } : states[0];\n var setState = states[1];\n var isAnimated = willBeAnimated;\n if (isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated) {\n isAnimated = false;\n curStateRef.willHydrate = true;\n }\n if (disabled !== state.disabled) {\n if (disabled) {\n Object.assign(state, defaultComponentStateMounted);\n }\n state.disabled = disabled;\n setState(function(_) {\n return {\n ...state\n };\n });\n }\n var groupName = props.group;\n if (!stateRef.current.baseSetStateShallow) {\n var r = stateRef.current;\n r.baseSetStateShallow = function(stateOrGetState) {\n setState(function(prev) {\n var next = typeof stateOrGetState === \"function\" ? stateOrGetState(prev) : stateOrGetState;\n var update = mergeIfNotShallowEqual(prev, next);\n if (process.env.NODE_ENV === \"development\") {\n var dbg = r.__debug;\n if (dbg && update !== prev) {\n console.groupCollapsed(`setStateShallow CHANGE`, \"=>\", update);\n console.info(`previously`, prev);\n console.trace();\n console.groupEnd();\n }\n }\n return update;\n });\n };\n }\n if (process.env.NODE_ENV === \"development\") {\n ;\n stateRef.current.__debug = props.debug;\n }\n var setStateShallow = stateRef.current.baseSetStateShallow;\n if (process.env.NODE_ENV === \"development\" && globalThis.time) globalThis.time`state-useCreateShallowSetState`;\n var outProps = props;\n if (presenceState && isAnimated && isHydrated && staticConfig.variants) {\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n var _staticConfig_Component, _staticConfig_Component1;\n console.warn(formatDiagnostic(\"TAMAGUI_PRESENCE_STATE\", ((_staticConfig_Component = staticConfig.Component) === null || _staticConfig_Component === void 0 ? void 0 : _staticConfig_Component.displayName) || ((_staticConfig_Component1 = staticConfig.Component) === null || _staticConfig_Component1 === void 0 ? void 0 : _staticConfig_Component1.name) || \"TamaguiComponent\", \"AnimatePresence supplied lifecycle state to an animated component\", 'Remove debug=\"verbose\" after inspecting the animation state', \"presenceState\", presenceState));\n }\n var { custom } = presenceState;\n if (isObj(custom)) {\n outProps = {\n ...props,\n ...custom\n };\n }\n }\n var noClass = !isWeb || !!props.forceStyle;\n if (!isHydrated) {\n noClass = false;\n } else {\n if (isWeb && isHydrated) {\n var isAnimatedAndHydrated = isAnimated && isHydrated;\n var isClassNameDisabled = !staticConfig.acceptsClassName && (getSetting(\"disableSSR\") || !state.unmounted);\n var isDisabledManually = disableClassName && !state.unmounted;\n if (\n // Only disable className for animation drivers that output inline styles (not css)\n isAnimatedAndHydrated && outputStyle !== \"css\" || isDisabledManually || isClassNameDisabled\n ) {\n noClass = true;\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n log(`avoiding className`, {\n isAnimatedAndHydrated,\n isDisabledManually,\n isClassNameDisabled\n });\n }\n }\n }\n }\n return {\n props: outProps,\n startedUnhydrated: curStateRef.startedUnhydrated,\n curStateRef,\n disabled,\n groupName,\n hasAnimationProp,\n hasEnterStyle,\n isAnimated,\n isExiting,\n isHydrated,\n presence,\n presenceState,\n setState,\n setStateShallow,\n noClass,\n state,\n stateRef,\n inputStyle,\n outputStyle,\n willBeAnimated,\n willBeAnimatedClient,\n platformPseudo\n };\n};\nfunction hasAnimatedStyleValue(style) {\n for (var k in style) {\n var val = style[k];\n if (val && (typeof val === \"undefined\" ? \"undefined\" : _type_of(val)) === \"object\" && \"_animation\" in val) {\n return true;\n }\n }\n return false;\n}\nvar isDisabled = function(props) {\n var _props_accessibilityState;\n return props.disabled || props.passThrough || ((_props_accessibilityState = props.accessibilityState) === null || _props_accessibilityState === void 0 ? void 0 : _props_accessibilityState.disabled) || props[\"aria-disabled\"] || props.accessibilityDisabled || false;\n};\nexport {\n useComponentState\n};\n//# sourceMappingURL=useComponentState.js.map\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAS,SAAS,KAAK;CACrB;CACA,OAAO,OAAO,OAAO,WAAW,eAAe,IAAI,gBAAgB,SAAS,WAAW,OAAO;AAChG;AACA,IAAI,0CAA0C,IAAI,IAAI;CACpD;CACA;CACA;AACF,CAAC;AACD,IAAI,gCAAgC,IAAI,IAAI,CAC1C,OACF,CAAC;AACD,IAAI,mBAAmB;CACrB,QAAQ,KAAK,OAAO,KAAK,QAAQ,OAAO;EACtC,IAAI,OAAO,IAAI;EACf,IAAI,CAAC,UAAU,SAAS,QAAQ,OAAO,KAAK,IAAI,KAAK,KAAK;EAC1D,KAAK,KAAK;CACZ;CACA,MAAM,KAAK,OAAO,KAAK,OAAO;EAC5B,IAAI,OAAO,IAAI;EACf,KAAK,KAAK;EACV,IAAI,CAAC,OAAO,OAAO;EACnB,KAAK,IAAI,QAAQ,OAAO,SAAS,KAAK,SAAS;GAC7C,IAAI,UAAU,OAAO,KAAK,EAAE,CAAC,WAAW,KAAK,MAAM,IAAI;GACvD,IAAI,KAAK,EAAE,CAAC,IAAI,wBAAwB,KAAK,EAAE,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC,GAAG;IACrE,KAAK,KAAK;GACZ;GACA,QAAQ,QAAQ;EAClB;EACA,OAAO;CACT;AACF;AACA,SAAS,gBAAgB,OAAO,QAAQ,WAAW,KAAK,UAAU;CAChE,IAAI;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Ac;GAC1C,IAAI,sBAAsB,CAAC,aAAa,qBAAqB,WAAW,YAAY,KAAK,CAAC,MAAM;GAChG,IAAI,qBAAqB,oBAAoB,CAAC,MAAM;GACpD,IAEE,yBAAyB,gBAAgB,SAAS,sBAAsB,qBACxE;IACA,UAAU;IACV,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAU,WAAW;KACvE,IAAI,sBAAsB;MACxB;MACA;MACA;KACF,CAAC;IACH;GACF;EACF;CACF;CACA,OAAO;EACL,OAAO;EACP,mBAAmB,YAAY;EAC/B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AACA,SAAS,sBAAsB,OAAO;CACpC,KAAK,IAAI,KAAK,OAAO;EACnB,IAAI,MAAM,MAAM;EAChB,IAAI,QAAQ,OAAO,QAAQ,cAAc,cAAc,SAAS,GAAG,OAAO,YAAY,gBAAgB,KAAK;GACzG,OAAO;EACT;CACF;CACA,OAAO;AACT;AACA,IAAI,aAAa,SAAS,OAAO;CAC/B,IAAI;CACJ,OAAO,MAAM,YAAY,MAAM,iBAAiB,4BAA4B,MAAM,wBAAwB,QAAQ,8BAA8B,KAAK,IAAI,KAAK,IAAI,0BAA0B,aAAa,MAAM,oBAAoB,MAAM,yBAAyB;AACpQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "3.0.0-beta.745.1",
3
+ "version": "3.0.0-beta.752.1",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Nate Wienert"
@@ -90,22 +90,22 @@
90
90
  "test:web": "vitest --typecheck --run"
91
91
  },
92
92
  "dependencies": {
93
- "@tamagui/compose-refs": "3.0.0-beta.745.1",
94
- "@tamagui/constants": "3.0.0-beta.745.1",
95
- "@tamagui/dom": "3.0.0-beta.745.1",
96
- "@tamagui/helpers": "3.0.0-beta.745.1",
97
- "@tamagui/is-equal-shallow": "3.0.0-beta.745.1",
98
- "@tamagui/native": "3.0.0-beta.745.1",
99
- "@tamagui/normalize-css-color": "3.0.0-beta.745.1",
100
- "@tamagui/style-grammar": "3.0.0-beta.745.1",
101
- "@tamagui/timer": "3.0.0-beta.745.1",
102
- "@tamagui/types": "3.0.0-beta.745.1",
103
- "@tamagui/use-did-finish-ssr": "3.0.0-beta.745.1",
104
- "@tamagui/use-event": "3.0.0-beta.745.1",
105
- "@tamagui/use-force-update": "3.0.0-beta.745.1"
93
+ "@tamagui/compose-refs": "3.0.0-beta.752.1",
94
+ "@tamagui/constants": "3.0.0-beta.752.1",
95
+ "@tamagui/dom": "3.0.0-beta.752.1",
96
+ "@tamagui/helpers": "3.0.0-beta.752.1",
97
+ "@tamagui/is-equal-shallow": "3.0.0-beta.752.1",
98
+ "@tamagui/native": "3.0.0-beta.752.1",
99
+ "@tamagui/normalize-css-color": "3.0.0-beta.752.1",
100
+ "@tamagui/style-grammar": "3.0.0-beta.752.1",
101
+ "@tamagui/timer": "3.0.0-beta.752.1",
102
+ "@tamagui/types": "3.0.0-beta.752.1",
103
+ "@tamagui/use-did-finish-ssr": "3.0.0-beta.752.1",
104
+ "@tamagui/use-event": "3.0.0-beta.752.1",
105
+ "@tamagui/use-force-update": "3.0.0-beta.752.1"
106
106
  },
107
107
  "devDependencies": {
108
- "@tamagui/build": "3.0.0-beta.745.1",
108
+ "@tamagui/build": "3.0.0-beta.752.1",
109
109
  "@testing-library/react": "^16.1.0",
110
110
  "csstype": "^3.0.10",
111
111
  "react": "19.2.3",
@@ -909,7 +909,7 @@ function directAtomic(
909
909
  conditionSelector,
910
910
  conditionWrappers,
911
911
  signature,
912
- true,
912
+ 2 as any,
913
913
  atomicKey,
914
914
  condition
915
915
  ? 1 +
@@ -947,7 +947,10 @@ function directAtomic(
947
947
  atomics[atomicKey] = atomic
948
948
  } else {
949
949
  const previousIdentifier = existing.styleObject[StyleObjectIdentifier]
950
- const rules = existing.styleObject[StyleObjectRules]
950
+ // cached rules stay immutable until a same-property contribution needs to
951
+ // splice or rewrite them.
952
+ const rules = existing.styleObject[StyleObjectRules].slice()
953
+ existing.styleObject[StyleObjectRules] = rules
951
954
  if (!condition && !isDefault && existing.conditions) {
952
955
  for (const key in existing.conditions) {
953
956
  const entry = existing.conditions[key]
@@ -1061,7 +1064,10 @@ export function flushDirectStyles(state: GetStyleState, clear = false) {
1061
1064
  const styleObject = atomics[property].styleObject
1062
1065
  const identifier = styleObject[StyleObjectIdentifier]
1063
1066
  if (shouldInsertStyleRules(identifier)) {
1064
- updateRules(identifier, styleObject[StyleObjectRules])
1067
+ // rulesToInsert owns its array; never expose the cache's borrowed copy.
1068
+ const rules = styleObject[StyleObjectRules].slice()
1069
+ styleObject[StyleObjectRules] = rules
1070
+ updateRules(identifier, rules)
1065
1071
  state.flatRulesToInsert![identifier] = styleObject
1066
1072
  }
1067
1073
  }
@@ -2075,7 +2081,7 @@ export function contributeFrontendValue(
2075
2081
  // resolvable modifier chain; anything else is a structured leaf value
2076
2082
  // (shadowOffset) and stays whole. only the first key is probed, the same way
2077
2083
  // the string scanner commits at its first clause
2078
- function isConditionalStyleObject(
2084
+ export function isConditionalStyleObject(
2079
2085
  state: GetStyleState,
2080
2086
  value: Record<string, any>
2081
2087
  ): boolean {
@@ -21,7 +21,7 @@ export function getCSSStylesAtomic(style: ViewStyleObject) {
21
21
  for (const key in style) {
22
22
  if (key === '$$css') continue
23
23
  const val = style[key]
24
- const so = getStyleObject(style, key)
24
+ const so = getStyleObject(val, key)
25
25
  if (so) {
26
26
  out.push(so)
27
27
  }
@@ -40,7 +40,7 @@ export function getCSSStyleAtomic(
40
40
  classRepetitions = 1
41
41
  ): StyleObject | undefined {
42
42
  return getStyleObject(
43
- { [key]: val } as ViewStyleObject,
43
+ val,
44
44
  key,
45
45
  condition,
46
46
  wrappers,
@@ -56,7 +56,7 @@ let confRevision = 0
56
56
 
57
57
  // the direct path rebuilds the same identifier and the same rule strings on
58
58
  // every render of every component, and insertStyleRules only ever inserts the
59
- // FIRST set it sees for an identifier and discards the rest. the accumulated
59
+ // first set it sees for an identifier and discards the rest. the accumulated
60
60
  // identity is the whole input to both, so one lookup replaces the hash, the
61
61
  // identifier build and every rule string. two levels so a lookup allocates
62
62
  // nothing. bounded and cleared the same way simpleHash's cache is.
@@ -66,19 +66,18 @@ let directIdentitiesSize = 0
66
66
  type DirectIdentity = { identifier: string; rules: string[] }
67
67
 
68
68
  const getStyleObject = (
69
- style: ViewStyleObject,
69
+ val: any,
70
70
  key: string,
71
71
  condition = '',
72
72
  wrappers?: readonly string[],
73
73
  identity?: string,
74
- direct = false,
74
+ direct: boolean | 2 = false,
75
75
  identityKey = key,
76
76
  classRepetitions = 1
77
77
  ): StyleObject | undefined => {
78
- let val = style[key]
79
78
  if (val == null) return
80
79
  // transform
81
- if (key === 'transform' && Array.isArray(style.transform)) {
80
+ if (key === 'transform' && Array.isArray(val)) {
82
81
  val = transformsToString(val)
83
82
  }
84
83
  const value = normalizeValueWithProperty(val, key)
@@ -99,7 +98,14 @@ const getStyleObject = (
99
98
  byKey = directIdentities.get(identityKey)
100
99
  const known = byKey?.get(identity)
101
100
  if (known) {
102
- return [key, value, known.identifier, undefined, known.rules.slice()]
101
+ // directStyle takes ownership before mutation or public exposure.
102
+ return [
103
+ key,
104
+ value,
105
+ known.identifier,
106
+ undefined,
107
+ direct === 2 ? known.rules : known.rules.slice(),
108
+ ]
103
109
  }
104
110
  }
105
111
  const rawValue = typeof value === 'string' ? value : `${value}`
@@ -148,7 +154,7 @@ const getStyleObject = (
148
154
  byKey = new Map()
149
155
  directIdentities.set(identityKey, byKey)
150
156
  }
151
- byKey.set(identity, { identifier, rules: rules.slice() })
157
+ byKey.set(identity, { identifier, rules: direct === 2 ? rules : rules.slice() })
152
158
  directIdentitiesSize++
153
159
  }
154
160
  return [
@@ -233,7 +239,7 @@ function createAtomicRules(
233
239
  value: any,
234
240
  condition = '',
235
241
  wrappers?: readonly string[],
236
- direct = false,
242
+ direct: boolean | 2 = false,
237
243
  classRepetitions = 1
238
244
  ): string[] {
239
245
  // longhands get .cls.cls for higher specificity over shorthands
@@ -14,6 +14,7 @@ import {
14
14
  STYLE_FRONTEND_PREPROCESSED,
15
15
  } from './styleFrontend'
16
16
  import { getConfig, getFont } from '../config'
17
+ import { isVariable } from '../createVariable'
17
18
  import { isDevTools } from '../constants/isDevTools'
18
19
  import { mediaState as globalMediaState } from './mediaState'
19
20
  import type {
@@ -38,6 +39,7 @@ import type {
38
39
  TransitionProp,
39
40
  ViewStyleObject,
40
41
  } from '../types'
42
+ import { scanFlatValue, type FlatValueHandler } from '@tamagui/style-grammar/runtime'
41
43
  import { fixStyles } from './expandStyles'
42
44
  import { styleToCSS } from './getCSSStylesAtomic'
43
45
  import { getDefaultProps } from './getDefaultProps'
@@ -53,6 +55,7 @@ import {
53
55
  contributeVariantClauseValue,
54
56
  flushDirectStyles,
55
57
  getDirectDynamicThemeAccess,
58
+ resolveClauseChain,
56
59
  } from './directStyle'
57
60
  import { contributeFrontendProgram, isFrontendProgram } from './frontendProgram'
58
61
  import { skipProps } from './skipProps'
@@ -112,17 +115,128 @@ function compoundMatcherMatches(expected: any, actual: any) {
112
115
  return Object.is(expected, actual)
113
116
  }
114
117
 
115
- function compoundVariantMatches(
118
+ // clause-string payloads arrive as slices, so booleans and numbers in the
119
+ // matcher compare by their string spelling
120
+ function compoundMatcherMatchesPayload(expected: any, payload: string) {
121
+ if (Array.isArray(expected)) {
122
+ return expected.some((value) => compoundMatcherMatchesPayload(value, payload))
123
+ }
124
+ return typeof expected === 'string'
125
+ ? expected === payload
126
+ : String(expected) === payload
127
+ }
128
+
129
+ // [source, expected, isChain, chains, matchedBase]
130
+ type CompoundScanContext = [string, any, (chain: string) => boolean, string[], boolean]
131
+
132
+ const compoundScanHandler: FlatValueHandler<CompoundScanContext> = {
133
+ segment(ctx, start, end, isBase, valid, source, chainStart, chainEnd, chainValid) {
134
+ if (!valid || start >= end) return
135
+ if (!compoundMatcherMatchesPayload(ctx[1], source.slice(start, end))) return
136
+ if (isBase) {
137
+ ctx[4] = true
138
+ return
139
+ }
140
+ if (!chainValid) return
141
+ const chain = source.slice(chainStart, chainEnd)
142
+ if (ctx[2](chain)) ctx[3].push(chain)
143
+ },
144
+ chain() {
145
+ return true
146
+ },
147
+ error() {},
148
+ }
149
+
150
+ /**
151
+ * Which condition chains a compound matcher key matches on a prop value.
152
+ * `['']` means unconditional: an exact value, or a conditional value whose
153
+ * base/default branch matches (the clause system has no negative conditions,
154
+ * so a matching base applies the compound in every state, exactly like an
155
+ * exact value). `null` means no branch matches. Non-empty chains mean the
156
+ * compound's style applies only under those conditions; the caller rewrites
157
+ * it into the flat object form so the ordinary pipeline carries it.
158
+ */
159
+ function matcherChains(
160
+ expected: any,
161
+ actual: any,
162
+ isChain: (chain: string) => boolean
163
+ ): string[] | null {
164
+ if (typeof actual === 'string' && actual.indexOf(':') !== -1) {
165
+ const scan: CompoundScanContext = [actual, expected, isChain, [], false]
166
+ scanFlatValue(actual, compoundScanHandler, scan)
167
+ if (scan[4]) return ['']
168
+ return scan[3].length ? scan[3] : null
169
+ }
170
+ if (
171
+ actual &&
172
+ typeof actual === 'object' &&
173
+ !Array.isArray(actual) &&
174
+ !isVariable(actual)
175
+ ) {
176
+ let conditional = Object.prototype.hasOwnProperty.call(actual, 'default')
177
+ if (!conditional) {
178
+ for (const key in actual) {
179
+ conditional = key.length > 0 && isChain(key)
180
+ break
181
+ }
182
+ }
183
+ if (conditional) {
184
+ const chains: string[] = []
185
+ for (const key in actual) {
186
+ const payload = actual[key]
187
+ if (payload == null || !compoundMatcherMatches(expected, payload)) continue
188
+ if (key === 'default') return ['']
189
+ if (isChain(key)) chains.push(key)
190
+ }
191
+ return chains.length ? chains : null
192
+ }
193
+ }
194
+ return compoundMatcherMatches(expected, actual) ? [''] : null
195
+ }
196
+
197
+ // the runtime discrimination rule, phrased over an isChain callback: a
198
+ // conditional object names a `default` or opens with a resolvable chain
199
+ function isConditionalObjectValue(
200
+ value: Record<string, any>,
201
+ isChain: (chain: string) => boolean
202
+ ): boolean {
203
+ if (Object.prototype.hasOwnProperty.call(value, 'default')) return true
204
+ for (const key in value) {
205
+ return key.length > 0 && isChain(key)
206
+ }
207
+ return false
208
+ }
209
+
210
+ const joinChains = (a: string, b: string): string => {
211
+ if (!a) return b
212
+ if (!b) return a
213
+ const segments = a.split(':')
214
+ for (const segment of b.split(':')) {
215
+ if (!segments.includes(segment)) segments.push(segment)
216
+ }
217
+ return segments.join(':')
218
+ }
219
+
220
+ function compoundVariantMatchChains(
116
221
  compoundVariant: GenericCompoundVariant,
117
- props: Record<string, any>
118
- ) {
222
+ props: Record<string, any>,
223
+ isChain: (chain: string) => boolean
224
+ ): string[] | null {
225
+ let chains: string[] = ['']
119
226
  for (const key in compoundVariant) {
120
227
  if (key === 'style') continue
121
- if (!compoundMatcherMatches(compoundVariant[key], props[key])) {
122
- return false
228
+ const keyChains = matcherChains(compoundVariant[key], props[key], isChain)
229
+ if (!keyChains) return null
230
+ const next: string[] = []
231
+ for (const a of chains) {
232
+ for (const b of keyChains) {
233
+ const joined = joinChains(a, b)
234
+ if (!next.includes(joined)) next.push(joined)
235
+ }
123
236
  }
237
+ chains = next
124
238
  }
125
- return true
239
+ return chains
126
240
  }
127
241
 
128
242
  type OrderedPropEntry = readonly [string, any]
@@ -149,6 +263,11 @@ function getStyledDefaults(staticConfig: StaticConfig): OrderedPropEntry[] | nul
149
263
  return entries
150
264
  }
151
265
 
266
+ const maybeStyleProgram = (value: any): boolean =>
267
+ typeof value === 'string'
268
+ ? value.includes(':')
269
+ : !!value && typeof value === 'object' && !Array.isArray(value) && !isVariable(value)
270
+
152
271
  function contributeDisplacedStyledDefaults(
153
272
  styledDefaults: OrderedPropEntry[] | null,
154
273
  processedProps: Record<string, any>,
@@ -164,12 +283,14 @@ function contributeDisplacedStyledDefaults(
164
283
  // equal means the default flowed through the merge untouched and will be
165
284
  // processed as an ordinary prop entry; different means a call-site value
166
285
  // displaced it. Re-injection is only needed when either contribution is a
167
- // program; ordinary values retain the prop-level fast path.
286
+ // program; ordinary values retain the prop-level fast path. an object is
287
+ // potentially a conditional program (its clause slots must survive a
288
+ // caller base); re-injecting a displaced structured leaf is a harmless
289
+ // whole-value overwrite by the later prop entry.
168
290
  if (
169
291
  propValue !== undefined &&
170
292
  propValue !== styledValue &&
171
- ((typeof styledValue === 'string' && styledValue.includes(':')) ||
172
- (typeof propValue === 'string' && propValue.includes(':')))
293
+ (maybeStyleProgram(styledValue) || maybeStyleProgram(propValue))
173
294
  ) {
174
295
  contribute(key, styledValue)
175
296
  }
@@ -193,7 +314,8 @@ function forEachPropInForwardOrder(
193
314
  processedProps: Record<string, any>,
194
315
  staticConfig: StaticConfig,
195
316
  shorthands: Record<string, string>,
196
- contribute: (key: string, value: any) => void
317
+ contribute: (key: string, value: any) => void,
318
+ isChain: (chain: string) => boolean
197
319
  ) {
198
320
  const processedBaseStyle = staticConfig.baseStyle
199
321
  const compoundVariants = staticConfig.compoundVariants
@@ -228,7 +350,8 @@ function forEachPropInForwardOrder(
228
350
  // compounds, or caller values into precedence tiers.
229
351
  const compoundsByAnchor = new Map<number, OrderedPropEntry[]>()
230
352
  for (const compoundVariant of compoundVariants) {
231
- if (!compoundVariantMatches(compoundVariant, processedProps)) {
353
+ const chains = compoundVariantMatchChains(compoundVariant, processedProps, isChain)
354
+ if (!chains) {
232
355
  continue
233
356
  }
234
357
  const { style } = compoundVariant
@@ -249,7 +372,38 @@ function forEachPropInForwardOrder(
249
372
 
250
373
  const entries = compoundsByAnchor.get(anchor) || []
251
374
  for (const key in style) {
252
- entries.push([key, style[key]])
375
+ const value = style[key]
376
+ for (const chain of chains) {
377
+ if (!chain) {
378
+ entries.push([key, value])
379
+ continue
380
+ }
381
+ // a conditional match rewrites the compound's style into the flat
382
+ // object form so the ordinary pipeline scopes it to the chain
383
+ if (
384
+ value &&
385
+ typeof value === 'object' &&
386
+ !Array.isArray(value) &&
387
+ !isVariable(value) &&
388
+ isConditionalObjectValue(value, isChain)
389
+ ) {
390
+ const composed: Record<string, any> = {}
391
+ for (const inner in value) {
392
+ composed[inner === 'default' ? chain : `${chain}:${inner}`] = value[inner]
393
+ }
394
+ entries.push([key, composed])
395
+ continue
396
+ }
397
+ if (typeof value === 'string' && value.includes(':')) {
398
+ if (process.env.NODE_ENV === 'development') {
399
+ console.warn(
400
+ `[tamagui] compound variant "${key}" carries a clause string and matched conditionally; dropping it. use the object form in the compound style`
401
+ )
402
+ }
403
+ continue
404
+ }
405
+ entries.push([key, { [chain]: value }])
406
+ }
253
407
  }
254
408
  compoundsByAnchor.set(anchor, entries)
255
409
  }
@@ -934,14 +1088,20 @@ export const getSplitStyles: StyleSplitter = (
934
1088
  !isHostStyleKey
935
1089
  )
936
1090
  } else if (isHOC) {
937
- // reduce the clause back to flat-value string form so the wrapped
938
- // component's own string parser applies the condition
939
- const appended = appendFlatClause(viewProps[key], conditionSource, val)
1091
+ // reduce the clause back to a flat value (string, or the object
1092
+ // form for structured payloads) so the wrapped component's own
1093
+ // parser applies the condition
1094
+ const appended = appendFlatClause(
1095
+ styleState,
1096
+ viewProps[key],
1097
+ conditionSource,
1098
+ val
1099
+ )
940
1100
  if (appended !== undefined) {
941
1101
  viewProps[key] = appended
942
1102
  } else if (process.env.NODE_ENV === 'development') {
943
1103
  console.warn(
944
- `[tamagui] conditional variant value for "${key}" is not string-representable; dropping the clause`
1104
+ `[tamagui] conditional variant value for "${key}" cannot join the existing clause string; dropping the clause`
945
1105
  )
946
1106
  }
947
1107
  } else if (process.env.NODE_ENV === 'development') {
@@ -1020,7 +1180,13 @@ export const getSplitStyles: StyleSplitter = (
1020
1180
  }
1021
1181
  } // end prop contribution
1022
1182
 
1023
- forEachPropInForwardOrder(processedProps, staticConfig, shorthands, contributeProp)
1183
+ forEachPropInForwardOrder(
1184
+ processedProps,
1185
+ staticConfig,
1186
+ shorthands,
1187
+ contributeProp,
1188
+ (chain) => !!resolveClauseChain(styleState, chain, 0, chain.length)
1189
+ )
1024
1190
 
1025
1191
  if (
1026
1192
  process.env.NODE_ENV === 'development' &&