@tamagui/core 1.73.2 → 1.74.0

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.
@@ -3286,7 +3286,15 @@ var require_propMapper_native = __commonJS({
3286
3286
  return hasSet ? resolveVariableValue(valOrVar, resolveAs) : value;
3287
3287
  };
3288
3288
  function resolveVariableValue(valOrVar, resolveValues) {
3289
- return resolveValues === "none" ? valOrVar : (0, import_createVariable.isVariable)(valOrVar) ? !import_constants2.isWeb || resolveValues === "value" ? valOrVar.val : valOrVar.variable : valOrVar;
3289
+ if (resolveValues === "none")
3290
+ return valOrVar;
3291
+ if ((0, import_createVariable.isVariable)(valOrVar)) {
3292
+ if (resolveValues === "value")
3293
+ return valOrVar.val;
3294
+ let get = valOrVar.get;
3295
+ return typeof get == "function" ? get() : valOrVar.val;
3296
+ }
3297
+ return valOrVar;
3290
3298
  }
3291
3299
  }
3292
3300
  });
@@ -3446,7 +3454,7 @@ var require_getSplitStyles_native = __commonJS({
3446
3454
  }
3447
3455
  } else {
3448
3456
  let curImportance = usedKeys[pkey] || 0;
3449
- importance >= curImportance && (pseudos ||= {}, pseudos[key] ||= {}, pseudos[key][pkey] = val2, mergeStyle(styleState, pkey, val2), usedKeys[pkey] = Math.max(usedKeys[pkey], importance));
3457
+ importance >= curImportance && (pseudos ||= {}, pseudos[key] ||= {}, pseudos[key][pkey] = val2, mergeStyle(styleState, pkey, val2));
3450
3458
  }
3451
3459
  }
3452
3460
  if (!isDisabled)
@@ -3991,8 +3999,8 @@ var require_useTheme_native = __commonJS({
3991
3999
  function getDefaultThemeProxied() {
3992
4000
  if (cached)
3993
4001
  return cached;
3994
- let config = (0, import_config.getConfig)(), defaultTheme = config.themes.light ?? config.themes[Object.keys(config.themes)[0]];
3995
- return cached = getThemeProxied(defaultTheme), cached;
4002
+ let config = (0, import_config.getConfig)(), name = config.themes.light ? "light" : Object.keys(config.themes)[0], defaultTheme = config.themes[name];
4003
+ return cached = getThemeProxied({ theme: defaultTheme, name }), cached;
3996
4004
  }
3997
4005
  var useTheme = (props = emptyProps) => {
3998
4006
  let [_, theme] = useThemeWithState(props);
@@ -4008,10 +4016,15 @@ var require_useTheme_native = __commonJS({
4008
4016
  }
4009
4017
  ), { themeManager, state } = changedThemeState;
4010
4018
  state != null && state.theme;
4011
- let themeProxied = (0, import_react.useMemo)(() => !themeManager || !(state != null && state.theme) ? {} : getThemeProxied(state.theme, themeManager, keys.current, props.debug), [state, themeManager]);
4019
+ let themeProxied = (0, import_react.useMemo)(() => !themeManager || !(state != null && state.theme) ? {} : getThemeProxied(state, props.deopt, themeManager, keys.current, props.debug), [state, themeManager, props.deopt, props.debug]);
4012
4020
  return [changedThemeState, themeProxied];
4013
4021
  };
4014
- function getThemeProxied(theme, themeManager, keys, debug) {
4022
+ function getThemeProxied({ theme, name }, deopt = !1, themeManager, keys, debug) {
4023
+ if (!theme)
4024
+ return {};
4025
+ function track(key) {
4026
+ keys && !keys.includes(key) && keys.push(key);
4027
+ }
4015
4028
  return (0, import_createProxy.createProxy)(theme, {
4016
4029
  has(_, key) {
4017
4030
  if (Reflect.has(theme, key))
@@ -4033,7 +4046,30 @@ var require_useTheme_native = __commonJS({
4033
4046
  // when they touch the actual value we only track it
4034
4047
  // if its a variable (web), its ignored!
4035
4048
  get(_2, subkey) {
4036
- return keys && (subkey === "val" || subkey === "get" && !import_constants2.isWeb) && !keys.includes(keyString) && keys.push(keyString), subkey === "get" ? () => (0, import_createVariable.getVariable)(val) : Reflect.get(val, subkey);
4049
+ if (subkey === "val")
4050
+ track(keyString);
4051
+ else if (subkey === "get")
4052
+ return () => {
4053
+ let outVal = (0, import_createVariable.getVariable)(val);
4054
+ if (import_constants2.isIos && !deopt) {
4055
+ let isDark = name.startsWith("dark"), isLight = !isDark && name.startsWith("light");
4056
+ if (isDark || isLight) {
4057
+ let oppositeThemeName = name.replace(
4058
+ isDark ? "dark" : "light",
4059
+ isDark ? "light" : "dark"
4060
+ ), oppositeTheme = (0, import_config.getConfig)().themes[oppositeThemeName], oppositeVal = (0, import_createVariable.getVariable)(oppositeTheme == null ? void 0 : oppositeTheme[keyString]);
4061
+ if (oppositeVal)
4062
+ return {
4063
+ dynamic: {
4064
+ dark: isDark ? outVal : oppositeVal,
4065
+ light: isLight ? outVal : oppositeVal
4066
+ }
4067
+ };
4068
+ }
4069
+ }
4070
+ return track(keyString), outVal;
4071
+ };
4072
+ return Reflect.get(val, subkey);
4037
4073
  }
4038
4074
  });
4039
4075
  }
@@ -4042,10 +4078,7 @@ var require_useTheme_native = __commonJS({
4042
4078
  });
4043
4079
  }
4044
4080
  var activeThemeManagers = /* @__PURE__ */ new Set(), useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => {
4045
- let {
4046
- // @ts-expect-error internal use only
4047
- disable
4048
- } = props, parentManager = (0, import_react.useContext)(import_ThemeManagerContext.ThemeManagerContext);
4081
+ let { disable } = props, parentManager = (0, import_react.useContext)(import_ThemeManagerContext.ThemeManagerContext);
4049
4082
  if (!isRoot && !parentManager || disable)
4050
4083
  return {
4051
4084
  isNewTheme: !1,
@@ -4072,7 +4105,7 @@ var require_useTheme_native = __commonJS({
4072
4105
  let selfListenerDispose = themeManager.onChangeTheme((_a, _b, forced) => {
4073
4106
  forced && setThemeState((prev) => createState(prev, !0));
4074
4107
  }), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme((name, manager) => {
4075
- ((shouldUpdate == null ? void 0 : shouldUpdate()) ?? !!(keys != null && keys.length || isNewTheme)) && setThemeState(createState);
4108
+ (((shouldUpdate == null ? void 0 : shouldUpdate()) || props.deopt || props["disable-child-theme"]) ?? !!(keys != null && keys.length)) && setThemeState(createState);
4076
4109
  }, themeManager.id);
4077
4110
  return () => {
4078
4111
  selfListenerDispose(), disposeChangeListener == null || disposeChangeListener(), activeThemeManagers.delete(themeManager);
@@ -4116,7 +4149,7 @@ var require_useTheme_native = __commonJS({
4116
4149
  prev.state,
4117
4150
  forceChange
4118
4151
  );
4119
- nextState ? (state2 = nextState, !prev.isNewTheme || !import_constants2.isWeb ? themeManager2 = getNewThemeManager() : themeManager2.updateState(nextState)) : prev.isNewTheme && parentManager && !next && (themeManager2 = parentManager);
4152
+ nextState ? (state2 = nextState, prev.isNewTheme ? themeManager2.updateState(nextState) : themeManager2 = getNewThemeManager()) : prev.isNewTheme && parentManager && !next && (themeManager2 = parentManager);
4120
4153
  } else
4121
4154
  themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
4122
4155
  }
@@ -4488,17 +4521,22 @@ var require_createComponent_native = __commonJS({
4488
4521
  isEntering && enterVariant ? props[enterVariant] = !0 : isExiting2 && exitVariant && (props[exitVariant] = !enterExitVariant);
4489
4522
  }
4490
4523
  }
4491
- let isAnimatedReactNative = hasAnimationProp && (animationsConfig == null ? void 0 : animationsConfig.isReactNative), isReactNative = !!(staticConfig.isReactNative || isAnimatedReactNative), shouldAvoidClasses = !!(!import_constants2.isWeb || isAnimated || !staticConfig.acceptsClassName || propsIn.disableClassName), shouldForcePseudo = !!propsIn.forceStyle, noClassNames = shouldAvoidClasses || shouldForcePseudo, disableThemeProp = props["data-disable-theme"], disableTheme = disableThemeProp && !willBeAnimated || isHOC;
4524
+ let isAnimatedReactNative = hasAnimationProp && (animationsConfig == null ? void 0 : animationsConfig.isReactNative), isReactNative = !!(staticConfig.isReactNative || isAnimatedReactNative), shouldAvoidClasses = !!(!import_constants2.isWeb || isAnimated || !staticConfig.acceptsClassName || propsIn.disableClassName), shouldForcePseudo = !!propsIn.forceStyle, noClassNames = shouldAvoidClasses || shouldForcePseudo, disableThemeProp = !1, disableTheme = disableThemeProp && !willBeAnimated || isHOC;
4492
4525
  props.themeShallow && (stateRef.current.themeShallow = !0);
4493
4526
  let themeStateProps = {
4494
4527
  name: props.theme,
4495
4528
  componentName,
4496
- // @ts-ignore this is internal use only
4497
4529
  disable: disableTheme,
4498
4530
  shallow: stateRef.current.themeShallow,
4499
- shouldUpdate: () => stateRef.current.isListeningToTheme,
4531
+ // if this returns undefined it defers to the keys tracking, so its only used to force either updates or no updates
4532
+ shouldUpdate: () => (
4533
+ // when we use $theme- styles we need to force it to re-render on theme changes (this can be optimized likely)
4534
+ stateRef.current.isListeningToTheme
4535
+ ),
4500
4536
  debug: debugProp
4501
- }, isExiting = !state.unmounted && (presence == null ? void 0 : presence[0]) === !1, [themeState, theme] = (0, import_useTheme.useThemeWithState)(themeStateProps);
4537
+ };
4538
+ themeStateProps.deopt = config != null && config.settings.fastSchemeChange ? willBeAnimated : !0;
4539
+ let isExiting = !state.unmounted && (presence == null ? void 0 : presence[0]) === !1, [themeState, theme] = (0, import_useTheme.useThemeWithState)(themeStateProps);
4502
4540
  elementType = Component || elementType;
4503
4541
  let isStringElement = typeof elementType == "string", mediaState2 = (0, import_useMedia.useMedia)(stateRef, componentContext);
4504
4542
  (0, import_createVariable.setDidGetVariableValue)(!1);
@@ -4723,7 +4761,7 @@ var require_createComponent_native = __commonJS({
4723
4761
  });
4724
4762
  staticConfig.componentName && (component.displayName = staticConfig.componentName);
4725
4763
  let res = component;
4726
- (process.env.TAMAGUI_MEMO_ALL || staticConfig.memo) && (res = (0, import_react.memo)(res)), res.staticConfig = staticConfig;
4764
+ process.env.TAMAGUI_DISABLE_MEMO || (res = (0, import_react.memo)(res)), res.staticConfig = staticConfig;
4727
4765
  function extendStyledConfig(extended) {
4728
4766
  return {
4729
4767
  ...staticConfig,
@@ -5489,22 +5527,30 @@ var require_setupReactNative_native = __commonJS({
5489
5527
  setupReactNative: () => setupReactNative
5490
5528
  });
5491
5529
  module2.exports = __toCommonJS2(setupReactNative_exports);
5492
- var ReactNativeStaticConfigs = /* @__PURE__ */ new WeakMap();
5493
5530
  function getReactNativeConfig(Component) {
5494
- return ReactNativeStaticConfigs.get(Component);
5531
+ var _a, _b;
5532
+ if (Component)
5533
+ return Component.getSizeWithHeaders ? RNConfigs.Image : (_a = Component.propTypes) != null && _a.textBreakStrategy ? RNConfigs.Text : (_b = Component.propTypes) != null && _b.onTextInput ? void 0 : RNConfigs.default;
5495
5534
  }
5496
- function setupReactNative(rnExports) {
5497
- for (let key in rnExports) {
5498
- if (key[0].toLowerCase() === key[0])
5499
- continue;
5500
- let val = rnExports[key];
5501
- val && typeof val == "object" && ReactNativeStaticConfigs.set(val, {
5502
- isReactNative: !0,
5503
- isText: key === "Text" || key === "TextInput",
5504
- isInput: key === "TextInput" || key === "TextArea",
5505
- inlineProps: key === "Image" ? /* @__PURE__ */ new Set(["src", "width", "height"]) : void 0
5506
- });
5535
+ var RNConfigs = {
5536
+ Image: {
5537
+ isReactNative: !0,
5538
+ inlineProps: /* @__PURE__ */ new Set(["src", "width", "height"])
5539
+ },
5540
+ Text: {
5541
+ isReactNative: !0,
5542
+ isText: !0
5543
+ },
5544
+ TextInput: {
5545
+ isReactNative: !0,
5546
+ isInput: !0,
5547
+ isText: !0
5548
+ },
5549
+ default: {
5550
+ isReactNative: !0
5507
5551
  }
5552
+ };
5553
+ function setupReactNative(rnExports) {
5508
5554
  }
5509
5555
  }
5510
5556
  });
@@ -5530,7 +5576,7 @@ var require_styled_native = __commonJS({
5530
5576
  function styled(ComponentIn, options, staticExtractionOptions) {
5531
5577
  if (!ComponentIn)
5532
5578
  throw new Error("No component given to styled()");
5533
- let parentStaticConfig = ComponentIn.staticConfig, isPlainStyledComponent = !!parentStaticConfig && !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC), Component = parentStaticConfig != null && parentStaticConfig.isHOC && !(parentStaticConfig != null && parentStaticConfig.isStyledHOC) || isPlainStyledComponent ? ComponentIn : (parentStaticConfig == null ? void 0 : parentStaticConfig.Component) || ComponentIn, reactNativeConfig = (0, import_setupReactNative.getReactNativeConfig)(Component), isReactNative = !!(reactNativeConfig || staticExtractionOptions != null && staticExtractionOptions.isReactNative || parentStaticConfig != null && parentStaticConfig.isReactNative || (0, import_setupReactNative.getReactNativeConfig)(parentStaticConfig == null ? void 0 : parentStaticConfig.Component)), staticConfigProps = (() => {
5579
+ let parentStaticConfig = ComponentIn.staticConfig, isPlainStyledComponent = !!parentStaticConfig && !(parentStaticConfig.isReactNative || parentStaticConfig.isHOC), Component = parentStaticConfig != null && parentStaticConfig.isHOC && !(parentStaticConfig != null && parentStaticConfig.isStyledHOC) || isPlainStyledComponent ? ComponentIn : (parentStaticConfig == null ? void 0 : parentStaticConfig.Component) || ComponentIn, reactNativeConfig = parentStaticConfig ? void 0 : (0, import_setupReactNative.getReactNativeConfig)(Component), isReactNative = !!(reactNativeConfig || staticExtractionOptions != null && staticExtractionOptions.isReactNative || parentStaticConfig != null && parentStaticConfig.isReactNative), staticConfigProps = (() => {
5534
5580
  if (options) {
5535
5581
  let {
5536
5582
  variants,