@tamagui/core 1.138.2 → 1.138.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/native.cjs CHANGED
@@ -2662,6 +2662,10 @@ var variableToFontNameCache = /* @__PURE__ */ new WeakMap(), resolveTokensAndVar
2662
2662
  for (var _key in value) {
2663
2663
  var subKey = conf2.shorthands[_key] || _key, val = value[_key];
2664
2664
  if (!(!styleProps.noSkip && subKey in skipProps)) {
2665
+ if (staticConfig) {
2666
+ var _staticConfig_context, _staticConfig_parentStaticConfig_context, _staticConfig_parentStaticConfig, contextProps = ((_staticConfig_context = staticConfig.context) === null || _staticConfig_context === void 0 ? void 0 : _staticConfig_context.props) || ((_staticConfig_parentStaticConfig = staticConfig.parentStaticConfig) === null || _staticConfig_parentStaticConfig === void 0 || (_staticConfig_parentStaticConfig_context = _staticConfig_parentStaticConfig.context) === null || _staticConfig_parentStaticConfig_context === void 0 ? void 0 : _staticConfig_parentStaticConfig_context.props);
2667
+ contextProps && subKey in contextProps && (styleState.overriddenContextProps || (styleState.overriddenContextProps = {}), styleState.overriddenContextProps[subKey] = val);
2668
+ }
2665
2669
  if (styleProps.noExpand) res[subKey] = val;
2666
2670
  else if (variants && subKey in variants) {
2667
2671
  if (parentVariantKey && parentVariantKey === key) res[subKey] = // SYNC WITH *1
@@ -2838,6 +2842,17 @@ function _type_of$2(obj) {
2838
2842
  return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
2839
2843
  }
2840
2844
  var conf, PROP_SPLIT = "-";
2845
+ function normalizeGroupKey(key, groupContext) {
2846
+ var parts = key.split("-"), plen = parts.length;
2847
+ if (
2848
+ // check if its actually a simple group selector to avoid breaking selectors
2849
+ plen === 2 || plen === 3 && pseudoPriorities[parts[parts.length - 1]]
2850
+ ) {
2851
+ var name = parts[1];
2852
+ if (groupContext && !groupContext[name]) return key.replace("$group-", "$group-true-");
2853
+ }
2854
+ return key;
2855
+ }
2841
2856
  function isValidStyleKey(key, validStyles2, accept) {
2842
2857
  return key in validStyles2 ? true : accept && key in accept;
2843
2858
  }
@@ -2864,16 +2879,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
2864
2879
  return "continue";
2865
2880
  }
2866
2881
  var isVariant = !isValidStyleKeyInit && variants && keyInit in variants, isStyleLikeKey = isValidStyleKeyInit || isVariant, isPseudo = keyInit in validPseudoKeys, isMedia = !isStyleLikeKey && !isPseudo ? getMediaKey(keyInit) : false, isMediaOrPseudo = !!(isMedia || isPseudo);
2867
- if (isMediaOrPseudo && isMedia === "group") {
2868
- var parts = keyInit.split("-"), plen = parts.length;
2869
- if (
2870
- // check if its actually a simple group selector to avoid breaking selectors
2871
- plen === 2 || plen === 3 && pseudoPriorities[parts[parts.length - 1]]
2872
- ) {
2873
- var name2 = parts[1];
2874
- groupContext && !(groupContext == null ? void 0 : groupContext[name2]) && (keyInit = keyInit.replace("$group-", "$group-true-"));
2875
- }
2876
- }
2882
+ isMediaOrPseudo && isMedia === "group" && (keyInit = normalizeGroupKey(keyInit, groupContext));
2877
2883
  var isStyleProp = isValidStyleKeyInit || isMediaOrPseudo || isVariant && !noExpand;
2878
2884
  if (isStyleProp && (asChild === "except-style" || asChild === "except-style-web")) return "continue";
2879
2885
  var shouldPassProp = !isStyleProp && isHOC || // is in parent variants
@@ -2897,7 +2903,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
2897
2903
  mergeStyle(styleState, key4, val2, 1);
2898
2904
  return;
2899
2905
  }
2900
- if (isPseudo = key4 in validPseudoKeys, isMedia = isPseudo ? false : getMediaKey(key4), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key4 in variants, (inlineProps == null ? void 0 : inlineProps.has(key4)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened == null ? void 0 : inlineWhenUnflattened.has(key4))) {
2906
+ if (isPseudo = key4 in validPseudoKeys, isMedia = isPseudo ? false : getMediaKey(key4), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key4 in variants, isMedia === "group" && (key4 = normalizeGroupKey(key4, groupContext)), (inlineProps == null ? void 0 : inlineProps.has(key4)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened == null ? void 0 : inlineWhenUnflattened.has(key4))) {
2901
2907
  var _props_key;
2902
2908
  viewProps[key4] = (_props_key = props[key4]) !== null && _props_key !== void 0 ? _props_key : val2;
2903
2909
  }
@@ -3103,6 +3109,10 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3103
3109
  (_styleState2 = styleState).style || (_styleState2.style = {}), Object.assign(styleState.style, normalizeStyle(style));
3104
3110
  }
3105
3111
  }
3112
+ if (viewProps.tabIndex === 0) {
3113
+ var _viewProps1, _accessible1;
3114
+ (_accessible1 = (_viewProps1 = viewProps).accessible) !== null && _accessible1 !== void 0 || (_viewProps1.accessible = true);
3115
+ }
3106
3116
  var style1 = styleState.style;
3107
3117
  if (style1 == null ? void 0 : style1.fontFamily) {
3108
3118
  var _getFont, faceInfo = (_getFont = getFont(style1.fontFamily)) === null || _getFont === void 0 ? void 0 : _getFont.face;
@@ -3122,7 +3132,8 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3122
3132
  rulesToInsert,
3123
3133
  dynamicThemeAccess,
3124
3134
  pseudoGroups,
3125
- mediaGroups
3135
+ mediaGroups,
3136
+ overriddenContextProps: styleState.overriddenContextProps
3126
3137
  }, asChildExceptStyleLike = asChild === "except-style" || asChild === "except-style-web";
3127
3138
  if (!styleProps.noMergeStyle && !asChildExceptStyleLike) {
3128
3139
  var style2 = styleState.style;
@@ -3140,26 +3151,33 @@ function mergeFlatTransforms(target, flatTransforms) {
3140
3151
  });
3141
3152
  }
3142
3153
  function mergeStyle(styleState, key, val, importance) {
3143
- var {
3154
+ var _staticConfig_context, _staticConfig_parentStaticConfig_context, _staticConfig_parentStaticConfig, {
3144
3155
  viewProps,
3145
3156
  styleProps,
3146
3157
  staticConfig,
3147
3158
  usedKeys
3148
3159
  } = styleState, existingImportance = usedKeys[key] || 0;
3149
- if (!(existingImportance > importance)) if (key in stylePropsTransform) {
3150
- var _styleState;
3151
- (_styleState = styleState).flatTransforms || (_styleState.flatTransforms = {}), usedKeys[key] = importance, styleState.flatTransforms[key] = val;
3152
- } else {
3153
- var shouldNormalize = isWeb, out = shouldNormalize ? normalizeValueWithProperty(val) : val;
3154
- if (
3155
- // accept is for props not styles
3156
- staticConfig.accept && key in staticConfig.accept
3157
- ) viewProps[key] = out;
3158
- else {
3160
+ if (!(existingImportance > importance)) {
3161
+ var contextProps = ((_staticConfig_context = staticConfig.context) === null || _staticConfig_context === void 0 ? void 0 : _staticConfig_context.props) || ((_staticConfig_parentStaticConfig = staticConfig.parentStaticConfig) === null || _staticConfig_parentStaticConfig === void 0 || (_staticConfig_parentStaticConfig_context = _staticConfig_parentStaticConfig.context) === null || _staticConfig_parentStaticConfig_context === void 0 ? void 0 : _staticConfig_parentStaticConfig_context.props);
3162
+ if (contextProps && key in contextProps) {
3163
+ var _styleState;
3164
+ (_styleState = styleState).overriddenContextProps || (_styleState.overriddenContextProps = {}), styleState.overriddenContextProps[key] = val;
3165
+ }
3166
+ if (key in stylePropsTransform) {
3159
3167
  var _styleState1;
3160
- (_styleState1 = styleState).style || (_styleState1.style = {}), usedKeys[key] = importance, styleState.style[key] = // if you dont do this you'll be passing props.transform arrays directly here and then mutating them
3161
- // if theres any flatTransforms later, causing issues (mutating props is bad, in strict mode styles get borked)
3162
- key === "transform" && Array.isArray(out) ? [...out] : out;
3168
+ (_styleState1 = styleState).flatTransforms || (_styleState1.flatTransforms = {}), usedKeys[key] = importance, styleState.flatTransforms[key] = val;
3169
+ } else {
3170
+ var shouldNormalize = isWeb, out = shouldNormalize ? normalizeValueWithProperty(val) : val;
3171
+ if (
3172
+ // accept is for props not styles
3173
+ staticConfig.accept && key in staticConfig.accept
3174
+ ) viewProps[key] = out;
3175
+ else {
3176
+ var _styleState2;
3177
+ (_styleState2 = styleState).style || (_styleState2.style = {}), usedKeys[key] = importance, styleState.style[key] = // if you dont do this you'll be passing props.transform arrays directly here and then mutating them
3178
+ // if theres any flatTransforms later, causing issues (mutating props is bad, in strict mode styles get borked)
3179
+ key === "transform" && Array.isArray(out) ? [...out] : out;
3180
+ }
3163
3181
  }
3164
3182
  }
3165
3183
  }
@@ -3434,7 +3452,7 @@ function _type_of$1(obj) {
3434
3452
  return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
3435
3453
  }
3436
3454
  var useComponentState = function(props, animationDriver, staticConfig, config) {
3437
- var _animationDriver_usePresence, isHydrated = useDidFinishSSR(), needsHydration = !useIsClientOnly(), useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, {
3455
+ var _animationDriver_usePresence, isHydrated = useDidFinishSSR(), needsHydration = !useIsClientOnly(), useAnimations = (animationDriver == null ? void 0 : animationDriver.isStub) ? void 0 : animationDriver == null ? void 0 : animationDriver.useAnimations, {
3438
3456
  isHOC
3439
3457
  } = staticConfig, stateRef = React.useRef(
3440
3458
  // performance: avoid creating object every render
@@ -3591,7 +3609,7 @@ function createComponent(staticConfig) {
3591
3609
  nextProps && (props = nextProps), overriddenContextProps = overrides;
3592
3610
  }
3593
3611
  var componentName2 = props.componentName || staticConfig.componentName;
3594
- var componentContext = React.useContext(ComponentContext), groupContextParent = React.useContext(GroupContext), animationDriver = componentContext.animationDriver, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, componentState = useComponentState(props, animationDriver, staticConfig), {
3612
+ var componentContext = React.useContext(ComponentContext), groupContextParent = React.useContext(GroupContext), animationDriver = componentContext.animationDriver, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, componentState = useComponentState(props, (animationDriver == null ? void 0 : animationDriver.isStub) ? null : animationDriver, staticConfig), {
3595
3613
  disabled,
3596
3614
  groupName,
3597
3615
  hasAnimationProp,
@@ -3681,7 +3699,15 @@ function createComponent(staticConfig) {
3681
3699
  willBeAnimated,
3682
3700
  styledContext: styledContextValue
3683
3701
  }, themeName = (themeState == null ? void 0 : themeState.name) || "";
3684
- var splitStyles = useSplitStyles(props, staticConfig, theme, themeName, state, styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp), isPassthrough = !splitStyles, groupContext = groupName && (allGroupContexts == null ? void 0 : allGroupContexts[groupName]) || null;
3702
+ var splitStyles = useSplitStyles(props, staticConfig, theme, themeName, state, styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp), isPassthrough = !splitStyles, contextForOverride = staticConfig.context;
3703
+ if (splitStyles == null ? void 0 : splitStyles.overriddenContextProps) {
3704
+ var _staticConfig_parentStaticConfig, contextForProps = staticConfig.context || ((_staticConfig_parentStaticConfig = staticConfig.parentStaticConfig) === null || _staticConfig_parentStaticConfig === void 0 ? void 0 : _staticConfig_parentStaticConfig.context);
3705
+ if (contextForProps) {
3706
+ for (var key in splitStyles.overriddenContextProps) overriddenContextProps || (overriddenContextProps = {}), overriddenContextProps[key] = splitStyles.overriddenContextProps[key];
3707
+ staticConfig.context || (contextForOverride = contextForProps);
3708
+ }
3709
+ }
3710
+ var groupContext = groupName && (allGroupContexts == null ? void 0 : allGroupContexts[groupName]) || null;
3685
3711
  if (!isPassthrough && groupContext && // avoids onLayout if we don't need it
3686
3712
  props.containerType !== "normal") {
3687
3713
  var groupState = groupContext == null ? void 0 : groupContext.state;
@@ -3723,8 +3749,8 @@ function createComponent(staticConfig) {
3723
3749
  }), stateRef.current.setStateShallow = function(nextOrGetNext) {
3724
3750
  var prev = stateRef.current.nextState || state, next = typeof nextOrGetNext == "function" ? nextOrGetNext(prev) : nextOrGetNext;
3725
3751
  if (!(next === prev || isEqualShallow(prev, next))) {
3726
- var canAvoidReRender = Object.keys(next).every(function(key2) {
3727
- return avoidReRenderKeys.has(key2);
3752
+ var canAvoidReRender = Object.keys(next).every(function(key3) {
3753
+ return avoidReRenderKeys.has(key3);
3728
3754
  }), updatedState = __spreadValues(__spreadValues({}, prev), next);
3729
3755
  if (stateRef.current.nextState = updatedState, canAvoidReRender) {
3730
3756
  var _stateRef_current_updateStyleListener, _stateRef_current;
@@ -3970,9 +3996,9 @@ function createComponent(staticConfig) {
3970
3996
  }))), "group" in props && (content = /* @__PURE__ */ jsxRuntimeExports.jsx(GroupContext.Provider, {
3971
3997
  value: allGroupContexts,
3972
3998
  children: content
3973
- })), content = disableTheme || !splitStyles ? content : getThemedChildren(themeState, content, themeStateProps, false, stateRef), overriddenContextProps) {
3974
- var Provider = staticConfig.context.Provider;
3975
- for (var key in styledContextValue) key in overriddenContextProps || (overriddenContextProps[key] = styledContextValue[key]);
3999
+ })), content = disableTheme || !splitStyles ? content : getThemedChildren(themeState, content, themeStateProps, false, stateRef), overriddenContextProps && contextForOverride) {
4000
+ var Provider = contextForOverride.Provider;
4001
+ for (var key1 in styledContextValue) key1 in overriddenContextProps || (overriddenContextProps[key1] = styledContextValue[key1]);
3976
4002
  debugProp && console.info("overriddenContextProps", overriddenContextProps), content = /* @__PURE__ */ jsxRuntimeExports.jsx(Provider, __spreadProps(__spreadValues({
3977
4003
  __disableMergeDefaultValues: true
3978
4004
  }, overriddenContextProps), {
@@ -4341,6 +4367,35 @@ var cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
4341
4367
  }
4342
4368
  return cache.set(res, true), res;
4343
4369
  };
4370
+ var noAnimationDriver = function(method) {
4371
+ console.warn(`No animation driver configured. To use ${method}, you must pass \`animations\` to createTamagui. See: https://tamagui.dev/docs/core/animations`);
4372
+ }, createEmptyAnimationDriver = function() {
4373
+ return {
4374
+ isReactNative: false,
4375
+ supportsCSS: true,
4376
+ classNameAnimation: true,
4377
+ isStub: true,
4378
+ animations: {},
4379
+ useAnimations: function() {
4380
+ return noAnimationDriver("animations");
4381
+ },
4382
+ usePresence: function() {
4383
+ return noAnimationDriver("usePresence");
4384
+ },
4385
+ ResetPresence: function() {
4386
+ return noAnimationDriver("ResetPresence");
4387
+ },
4388
+ useAnimatedNumber: function() {
4389
+ return noAnimationDriver("useAnimatedNumber");
4390
+ },
4391
+ useAnimatedNumberStyle: function() {
4392
+ return noAnimationDriver("useAnimatedNumberStyle");
4393
+ },
4394
+ useAnimatedNumberReaction: function() {
4395
+ return noAnimationDriver("useAnimatedNumberReaction");
4396
+ }
4397
+ };
4398
+ }, defaultAnimationDriver = createEmptyAnimationDriver();
4344
4399
  var registerCSSVariable = function(v) {
4345
4400
  tokensValueToVariable.set(getVariableValue(v), v);
4346
4401
  }, variableToCSS = function(v) {
@@ -4450,7 +4505,7 @@ function createTamagui$1(configIn) {
4450
4505
  fonts: {},
4451
4506
  onlyAllowShorthands: false,
4452
4507
  fontLanguages: [],
4453
- animations: {},
4508
+ animations: defaultAnimationDriver,
4454
4509
  media: {}
4455
4510
  }, configIn), {
4456
4511
  unset,
@@ -4500,8 +4555,7 @@ function getThemesDeduped(themes2, colorTokens) {
4500
4555
  e2.names.push(themeName);
4501
4556
  continue;
4502
4557
  }
4503
- var theme = __spreadValues({}, rawTheme);
4504
- colorTokens && Object.assign(theme, colorTokens);
4558
+ var theme = __spreadValues(__spreadValues({}, colorTokens), rawTheme);
4505
4559
  for (var key1 in theme) ensureThemeVariable(theme, key1);
4506
4560
  var deduped = {
4507
4561
  names: [themeName],
@@ -2487,6 +2487,10 @@ var variableToFontNameCache = /* @__PURE__ */ new WeakMap(), resolveTokensAndVar
2487
2487
  for (var _key in value) {
2488
2488
  var subKey = conf2.shorthands[_key] || _key, val = value[_key];
2489
2489
  if (!(!styleProps.noSkip && subKey in skipProps)) {
2490
+ if (staticConfig) {
2491
+ var _staticConfig_context, _staticConfig_parentStaticConfig_context, _staticConfig_parentStaticConfig, contextProps = ((_staticConfig_context = staticConfig.context) === null || _staticConfig_context === void 0 ? void 0 : _staticConfig_context.props) || ((_staticConfig_parentStaticConfig = staticConfig.parentStaticConfig) === null || _staticConfig_parentStaticConfig === void 0 || (_staticConfig_parentStaticConfig_context = _staticConfig_parentStaticConfig.context) === null || _staticConfig_parentStaticConfig_context === void 0 ? void 0 : _staticConfig_parentStaticConfig_context.props);
2492
+ contextProps && subKey in contextProps && (styleState.overriddenContextProps || (styleState.overriddenContextProps = {}), styleState.overriddenContextProps[subKey] = val);
2493
+ }
2490
2494
  if (styleProps.noExpand) res[subKey] = val;
2491
2495
  else if (variants && subKey in variants) {
2492
2496
  if (parentVariantKey && parentVariantKey === key) res[subKey] = // SYNC WITH *1
@@ -2663,6 +2667,17 @@ function _type_of$2(obj) {
2663
2667
  return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
2664
2668
  }
2665
2669
  var conf, PROP_SPLIT = "-";
2670
+ function normalizeGroupKey(key, groupContext) {
2671
+ var parts = key.split("-"), plen = parts.length;
2672
+ if (
2673
+ // check if its actually a simple group selector to avoid breaking selectors
2674
+ plen === 2 || plen === 3 && pseudoPriorities[parts[parts.length - 1]]
2675
+ ) {
2676
+ var name = parts[1];
2677
+ if (groupContext && !groupContext[name]) return key.replace("$group-", "$group-true-");
2678
+ }
2679
+ return key;
2680
+ }
2666
2681
  function isValidStyleKey(key, validStyles2, accept) {
2667
2682
  return key in validStyles2 ? true : accept && key in accept;
2668
2683
  }
@@ -2690,16 +2705,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
2690
2705
  return "continue";
2691
2706
  }
2692
2707
  var isVariant = !isValidStyleKeyInit && variants && keyInit in variants, isStyleLikeKey = isValidStyleKeyInit || isVariant, isPseudo = keyInit in validPseudoKeys, isMedia = !isStyleLikeKey && !isPseudo ? getMediaKey(keyInit) : false, isMediaOrPseudo = !!(isMedia || isPseudo);
2693
- if (isMediaOrPseudo && isMedia === "group") {
2694
- var parts = keyInit.split("-"), plen = parts.length;
2695
- if (
2696
- // check if its actually a simple group selector to avoid breaking selectors
2697
- plen === 2 || plen === 3 && pseudoPriorities[parts[parts.length - 1]]
2698
- ) {
2699
- var name2 = parts[1];
2700
- groupContext && !(groupContext == null ? void 0 : groupContext[name2]) && (keyInit = keyInit.replace("$group-", "$group-true-"));
2701
- }
2702
- }
2708
+ isMediaOrPseudo && isMedia === "group" && (keyInit = normalizeGroupKey(keyInit, groupContext));
2703
2709
  var isStyleProp = isValidStyleKeyInit || isMediaOrPseudo || isVariant && !noExpand;
2704
2710
  if (isStyleProp && (asChild === "except-style" || asChild === "except-style-web")) return "continue";
2705
2711
  var shouldPassProp = !isStyleProp && isHOC || // is in parent variants
@@ -2723,7 +2729,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
2723
2729
  mergeStyle(styleState, key4, val2, 1);
2724
2730
  return;
2725
2731
  }
2726
- if (isPseudo = key4 in validPseudoKeys, isMedia = isPseudo ? false : getMediaKey(key4), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key4 in variants, (inlineProps == null ? void 0 : inlineProps.has(key4)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened == null ? void 0 : inlineWhenUnflattened.has(key4))) {
2732
+ if (isPseudo = key4 in validPseudoKeys, isMedia = isPseudo ? false : getMediaKey(key4), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key4 in variants, isMedia === "group" && (key4 = normalizeGroupKey(key4, groupContext)), (inlineProps == null ? void 0 : inlineProps.has(key4)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened == null ? void 0 : inlineWhenUnflattened.has(key4))) {
2727
2733
  var _props_key;
2728
2734
  viewProps[key4] = (_props_key = props[key4]) !== null && _props_key !== void 0 ? _props_key : val2;
2729
2735
  }
@@ -2929,6 +2935,10 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
2929
2935
  (_styleState2 = styleState).style || (_styleState2.style = {}), Object.assign(styleState.style, normalizeStyle(style));
2930
2936
  }
2931
2937
  }
2938
+ if (viewProps.tabIndex === 0) {
2939
+ var _viewProps1, _accessible1;
2940
+ (_accessible1 = (_viewProps1 = viewProps).accessible) !== null && _accessible1 !== void 0 || (_viewProps1.accessible = true);
2941
+ }
2932
2942
  var style1 = styleState.style;
2933
2943
  if (style1 == null ? void 0 : style1.fontFamily) {
2934
2944
  var _getFont, faceInfo = (_getFont = getFont(style1.fontFamily)) === null || _getFont === void 0 ? void 0 : _getFont.face;
@@ -2948,7 +2958,8 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
2948
2958
  rulesToInsert,
2949
2959
  dynamicThemeAccess,
2950
2960
  pseudoGroups,
2951
- mediaGroups
2961
+ mediaGroups,
2962
+ overriddenContextProps: styleState.overriddenContextProps
2952
2963
  }, asChildExceptStyleLike = asChild === "except-style" || asChild === "except-style-web";
2953
2964
  if (!styleProps.noMergeStyle && !asChildExceptStyleLike) {
2954
2965
  var style2 = styleState.style;
@@ -2966,26 +2977,33 @@ function mergeFlatTransforms(target, flatTransforms) {
2966
2977
  });
2967
2978
  }
2968
2979
  function mergeStyle(styleState, key, val, importance) {
2969
- var {
2980
+ var _staticConfig_context, _staticConfig_parentStaticConfig_context, _staticConfig_parentStaticConfig, {
2970
2981
  viewProps,
2971
2982
  styleProps,
2972
2983
  staticConfig,
2973
2984
  usedKeys
2974
2985
  } = styleState, existingImportance = usedKeys[key] || 0;
2975
- if (!(existingImportance > importance)) if (key in stylePropsTransform) {
2976
- var _styleState;
2977
- (_styleState = styleState).flatTransforms || (_styleState.flatTransforms = {}), usedKeys[key] = importance, styleState.flatTransforms[key] = val;
2978
- } else {
2979
- var shouldNormalize = isWeb, out = shouldNormalize ? normalizeValueWithProperty(val) : val;
2980
- if (
2981
- // accept is for props not styles
2982
- staticConfig.accept && key in staticConfig.accept
2983
- ) viewProps[key] = out;
2984
- else {
2986
+ if (!(existingImportance > importance)) {
2987
+ var contextProps = ((_staticConfig_context = staticConfig.context) === null || _staticConfig_context === void 0 ? void 0 : _staticConfig_context.props) || ((_staticConfig_parentStaticConfig = staticConfig.parentStaticConfig) === null || _staticConfig_parentStaticConfig === void 0 || (_staticConfig_parentStaticConfig_context = _staticConfig_parentStaticConfig.context) === null || _staticConfig_parentStaticConfig_context === void 0 ? void 0 : _staticConfig_parentStaticConfig_context.props);
2988
+ if (contextProps && key in contextProps) {
2989
+ var _styleState;
2990
+ (_styleState = styleState).overriddenContextProps || (_styleState.overriddenContextProps = {}), styleState.overriddenContextProps[key] = val;
2991
+ }
2992
+ if (key in stylePropsTransform) {
2985
2993
  var _styleState1;
2986
- (_styleState1 = styleState).style || (_styleState1.style = {}), usedKeys[key] = importance, styleState.style[key] = // if you dont do this you'll be passing props.transform arrays directly here and then mutating them
2987
- // if theres any flatTransforms later, causing issues (mutating props is bad, in strict mode styles get borked)
2988
- key === "transform" && Array.isArray(out) ? [...out] : out;
2994
+ (_styleState1 = styleState).flatTransforms || (_styleState1.flatTransforms = {}), usedKeys[key] = importance, styleState.flatTransforms[key] = val;
2995
+ } else {
2996
+ var shouldNormalize = isWeb, out = shouldNormalize ? normalizeValueWithProperty(val) : val;
2997
+ if (
2998
+ // accept is for props not styles
2999
+ staticConfig.accept && key in staticConfig.accept
3000
+ ) viewProps[key] = out;
3001
+ else {
3002
+ var _styleState2;
3003
+ (_styleState2 = styleState).style || (_styleState2.style = {}), usedKeys[key] = importance, styleState.style[key] = // if you dont do this you'll be passing props.transform arrays directly here and then mutating them
3004
+ // if theres any flatTransforms later, causing issues (mutating props is bad, in strict mode styles get borked)
3005
+ key === "transform" && Array.isArray(out) ? [...out] : out;
3006
+ }
2989
3007
  }
2990
3008
  }
2991
3009
  }
@@ -3260,7 +3278,7 @@ function _type_of$1(obj) {
3260
3278
  return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
3261
3279
  }
3262
3280
  var useComponentState = function(props, animationDriver, staticConfig, config) {
3263
- var _animationDriver_usePresence, isHydrated = useDidFinishSSR(), needsHydration = !useIsClientOnly(), useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, {
3281
+ var _animationDriver_usePresence, isHydrated = useDidFinishSSR(), needsHydration = !useIsClientOnly(), useAnimations = (animationDriver == null ? void 0 : animationDriver.isStub) ? void 0 : animationDriver == null ? void 0 : animationDriver.useAnimations, {
3264
3282
  isHOC
3265
3283
  } = staticConfig, stateRef = React.useRef(
3266
3284
  // performance: avoid creating object every render
@@ -3421,7 +3439,7 @@ function createComponent(staticConfig) {
3421
3439
  nextProps && (props = nextProps), overriddenContextProps = overrides;
3422
3440
  }
3423
3441
  var componentName2 = props.componentName || staticConfig.componentName;
3424
- var componentContext = React.useContext(ComponentContext), groupContextParent = React.useContext(GroupContext), animationDriver = componentContext.animationDriver, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, componentState = useComponentState(props, animationDriver, staticConfig), {
3442
+ var componentContext = React.useContext(ComponentContext), groupContextParent = React.useContext(GroupContext), animationDriver = componentContext.animationDriver, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, componentState = useComponentState(props, (animationDriver == null ? void 0 : animationDriver.isStub) ? null : animationDriver, staticConfig), {
3425
3443
  disabled,
3426
3444
  groupName,
3427
3445
  hasAnimationProp,
@@ -3511,7 +3529,15 @@ function createComponent(staticConfig) {
3511
3529
  willBeAnimated,
3512
3530
  styledContext: styledContextValue
3513
3531
  }, themeName = (themeState == null ? void 0 : themeState.name) || "";
3514
- var splitStyles = useSplitStyles(props, staticConfig, theme, themeName, state, styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp), isPassthrough = !splitStyles, groupContext = groupName && (allGroupContexts == null ? void 0 : allGroupContexts[groupName]) || null;
3532
+ var splitStyles = useSplitStyles(props, staticConfig, theme, themeName, state, styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp), isPassthrough = !splitStyles, contextForOverride = staticConfig.context;
3533
+ if (splitStyles == null ? void 0 : splitStyles.overriddenContextProps) {
3534
+ var _staticConfig_parentStaticConfig, contextForProps = staticConfig.context || ((_staticConfig_parentStaticConfig = staticConfig.parentStaticConfig) === null || _staticConfig_parentStaticConfig === void 0 ? void 0 : _staticConfig_parentStaticConfig.context);
3535
+ if (contextForProps) {
3536
+ for (var key in splitStyles.overriddenContextProps) overriddenContextProps || (overriddenContextProps = {}), overriddenContextProps[key] = splitStyles.overriddenContextProps[key];
3537
+ staticConfig.context || (contextForOverride = contextForProps);
3538
+ }
3539
+ }
3540
+ var groupContext = groupName && (allGroupContexts == null ? void 0 : allGroupContexts[groupName]) || null;
3515
3541
  if (!isPassthrough && groupContext && // avoids onLayout if we don't need it
3516
3542
  props.containerType !== "normal") {
3517
3543
  var groupState = groupContext == null ? void 0 : groupContext.state;
@@ -3553,8 +3579,8 @@ function createComponent(staticConfig) {
3553
3579
  }), stateRef.current.setStateShallow = function(nextOrGetNext) {
3554
3580
  var prev = stateRef.current.nextState || state, next = typeof nextOrGetNext == "function" ? nextOrGetNext(prev) : nextOrGetNext;
3555
3581
  if (!(next === prev || isEqualShallow(prev, next))) {
3556
- var canAvoidReRender = Object.keys(next).every(function(key2) {
3557
- return avoidReRenderKeys.has(key2);
3582
+ var canAvoidReRender = Object.keys(next).every(function(key3) {
3583
+ return avoidReRenderKeys.has(key3);
3558
3584
  }), updatedState = __spreadValues(__spreadValues({}, prev), next);
3559
3585
  if (stateRef.current.nextState = updatedState, canAvoidReRender) {
3560
3586
  var _stateRef_current_updateStyleListener, _stateRef_current;
@@ -3800,9 +3826,9 @@ function createComponent(staticConfig) {
3800
3826
  }))), "group" in props && (content = /* @__PURE__ */ jsxRuntimeExports.jsx(GroupContext.Provider, {
3801
3827
  value: allGroupContexts,
3802
3828
  children: content
3803
- })), content = disableTheme || !splitStyles ? content : getThemedChildren(themeState, content, themeStateProps, false, stateRef), overriddenContextProps) {
3804
- var Provider = staticConfig.context.Provider;
3805
- for (var key in styledContextValue) key in overriddenContextProps || (overriddenContextProps[key] = styledContextValue[key]);
3829
+ })), content = disableTheme || !splitStyles ? content : getThemedChildren(themeState, content, themeStateProps, false, stateRef), overriddenContextProps && contextForOverride) {
3830
+ var Provider = contextForOverride.Provider;
3831
+ for (var key1 in styledContextValue) key1 in overriddenContextProps || (overriddenContextProps[key1] = styledContextValue[key1]);
3806
3832
  debugProp && console.info("overriddenContextProps", overriddenContextProps), content = /* @__PURE__ */ jsxRuntimeExports.jsx(Provider, __spreadProps(__spreadValues({
3807
3833
  __disableMergeDefaultValues: true
3808
3834
  }, overriddenContextProps), {
@@ -4171,6 +4197,35 @@ var cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
4171
4197
  }
4172
4198
  return cache.set(res, true), res;
4173
4199
  };
4200
+ var noAnimationDriver = function(method) {
4201
+ console.warn(`No animation driver configured. To use ${method}, you must pass \`animations\` to createTamagui. See: https://tamagui.dev/docs/core/animations`);
4202
+ }, createEmptyAnimationDriver = function() {
4203
+ return {
4204
+ isReactNative: false,
4205
+ supportsCSS: true,
4206
+ classNameAnimation: true,
4207
+ isStub: true,
4208
+ animations: {},
4209
+ useAnimations: function() {
4210
+ return noAnimationDriver("animations");
4211
+ },
4212
+ usePresence: function() {
4213
+ return noAnimationDriver("usePresence");
4214
+ },
4215
+ ResetPresence: function() {
4216
+ return noAnimationDriver("ResetPresence");
4217
+ },
4218
+ useAnimatedNumber: function() {
4219
+ return noAnimationDriver("useAnimatedNumber");
4220
+ },
4221
+ useAnimatedNumberStyle: function() {
4222
+ return noAnimationDriver("useAnimatedNumberStyle");
4223
+ },
4224
+ useAnimatedNumberReaction: function() {
4225
+ return noAnimationDriver("useAnimatedNumberReaction");
4226
+ }
4227
+ };
4228
+ }, defaultAnimationDriver = createEmptyAnimationDriver();
4174
4229
  var registerCSSVariable = function(v) {
4175
4230
  tokensValueToVariable.set(getVariableValue(v), v);
4176
4231
  }, variableToCSS = function(v) {
@@ -4281,7 +4336,7 @@ function createTamagui$1(configIn) {
4281
4336
  fonts: {},
4282
4337
  onlyAllowShorthands: false,
4283
4338
  fontLanguages: [],
4284
- animations: {},
4339
+ animations: defaultAnimationDriver,
4285
4340
  media: {}
4286
4341
  }, configIn), {
4287
4342
  unset,
@@ -4331,8 +4386,7 @@ function getThemesDeduped(themes2, colorTokens) {
4331
4386
  e2.names.push(themeName);
4332
4387
  continue;
4333
4388
  }
4334
- var theme = __spreadValues({}, rawTheme);
4335
- colorTokens && Object.assign(theme, colorTokens);
4389
+ var theme = __spreadValues(__spreadValues({}, colorTokens), rawTheme);
4336
4390
  for (var key1 in theme) ensureThemeVariable(theme, key1);
4337
4391
  var deduped = {
4338
4392
  names: [themeName],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.138.2",
3
+ "version": "1.138.4",
4
4
  "type": "module",
5
5
  "source": "src/index.tsx",
6
6
  "main": "dist/cjs",
@@ -33,18 +33,18 @@
33
33
  "native-test.d.ts"
34
34
  ],
35
35
  "dependencies": {
36
- "@tamagui/helpers": "1.138.2",
37
- "@tamagui/react-native-media-driver": "1.138.2",
38
- "@tamagui/react-native-use-pressable": "1.138.2",
39
- "@tamagui/react-native-use-responder-events": "1.138.2",
40
- "@tamagui/use-element-layout": "1.138.2",
41
- "@tamagui/use-event": "1.138.2",
42
- "@tamagui/web": "1.138.2"
36
+ "@tamagui/helpers": "1.138.4",
37
+ "@tamagui/react-native-media-driver": "1.138.4",
38
+ "@tamagui/react-native-use-pressable": "1.138.4",
39
+ "@tamagui/react-native-use-responder-events": "1.138.4",
40
+ "@tamagui/use-element-layout": "1.138.4",
41
+ "@tamagui/use-event": "1.138.4",
42
+ "@tamagui/web": "1.138.4"
43
43
  },
44
44
  "devDependencies": {
45
- "@tamagui/build": "1.138.2",
46
- "@tamagui/native-bundle": "1.138.2",
47
- "@tamagui/react-native-web-lite": "1.138.2",
45
+ "@tamagui/build": "1.138.4",
46
+ "@tamagui/native-bundle": "1.138.4",
47
+ "@tamagui/react-native-web-lite": "1.138.4",
48
48
  "@testing-library/react": "^16.1.0",
49
49
  "csstype": "^3.0.10",
50
50
  "react": "*",