@tamagui/core 1.73.2 → 1.74.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.
package/dist/native.js CHANGED
@@ -3371,10 +3371,22 @@ var require_propMapper_native = __commonJS({
3371
3371
  spaceVar != null && (valOrVar = spaceVar, hasSet = !0);
3372
3372
  }
3373
3373
  }
3374
- return hasSet ? resolveVariableValue(valOrVar, resolveAs) : (process.env.NODE_ENV === "development" && import_isDevTools.isDevTools && styleState.debug === "verbose" && (console.groupCollapsed(" \uFE52 propMap (val)", key, value), console.log({ valOrVar, theme, hasSet }, theme ? theme[key] : ""), console.groupEnd()), value);
3374
+ if (hasSet) {
3375
+ let out = resolveVariableValue(valOrVar, resolveAs);
3376
+ return process.env.NODE_ENV === "development" && styleState.debug === "verbose" && console.log("resolved", resolveAs, valOrVar.get, out), out;
3377
+ }
3378
+ return process.env.NODE_ENV === "development" && import_isDevTools.isDevTools && styleState.debug === "verbose" && (console.groupCollapsed(" \uFE52 propMap (val)", key, value), console.log({ valOrVar, theme, hasSet }, theme ? theme[key] : ""), console.groupEnd()), value;
3375
3379
  };
3376
3380
  function resolveVariableValue(valOrVar, resolveValues) {
3377
- return resolveValues === "none" ? valOrVar : (0, import_createVariable.isVariable)(valOrVar) ? !import_constants2.isWeb || resolveValues === "value" ? valOrVar.val : valOrVar.variable : valOrVar;
3381
+ if (resolveValues === "none")
3382
+ return valOrVar;
3383
+ if ((0, import_createVariable.isVariable)(valOrVar)) {
3384
+ if (resolveValues === "value")
3385
+ return valOrVar.val;
3386
+ let get = valOrVar.get;
3387
+ return typeof get == "function" ? get() : valOrVar.val;
3388
+ }
3389
+ return valOrVar;
3378
3390
  }
3379
3391
  }
3380
3392
  });
@@ -3581,7 +3593,7 @@ current`, {
3581
3593
  }
3582
3594
  } else {
3583
3595
  let curImportance = usedKeys[pkey] || 0, shouldMerge = importance >= curImportance;
3584
- shouldMerge && (pseudos ||= {}, pseudos[key] ||= {}, pseudos[key][pkey] = val2, mergeStyle(styleState, pkey, val2), usedKeys[pkey] = Math.max(usedKeys[pkey], importance)), process.env.NODE_ENV === "development" && debug === "verbose" && console.log(" subKey", pkey, shouldMerge, {
3596
+ shouldMerge && (pseudos ||= {}, pseudos[key] ||= {}, pseudos[key][pkey] = val2, mergeStyle(styleState, pkey, val2)), process.env.NODE_ENV === "development" && debug === "verbose" && console.log(" subKey", pkey, shouldMerge, {
3585
3597
  importance,
3586
3598
  curImportance,
3587
3599
  pkey,
@@ -4177,8 +4189,8 @@ var require_useTheme_native = __commonJS({
4177
4189
  function getDefaultThemeProxied() {
4178
4190
  if (cached)
4179
4191
  return cached;
4180
- let config = (0, import_config.getConfig)(), defaultTheme = config.themes.light ?? config.themes[Object.keys(config.themes)[0]];
4181
- return cached = getThemeProxied(defaultTheme), cached;
4192
+ let config = (0, import_config.getConfig)(), name = config.themes.light ? "light" : Object.keys(config.themes)[0], defaultTheme = config.themes[name];
4193
+ return cached = getThemeProxied({ theme: defaultTheme, name }), cached;
4182
4194
  }
4183
4195
  var useTheme = (props = emptyProps) => {
4184
4196
  let [_, theme] = useThemeWithState(props);
@@ -4204,10 +4216,15 @@ var require_useTheme_native = __commonJS({
4204
4216
 
4205
4217
  If this is intended and you are using Tamagui without any themes, you can disable this warning by setting the environment variable TAMAGUI_DISABLE_NO_THEME_WARNING=1`
4206
4218
  );
4207
- let themeProxied = (0, import_react.useMemo)(() => !themeManager || !(state != null && state.theme) ? {} : getThemeProxied(state.theme, themeManager, keys.current, props.debug), [state, themeManager]);
4219
+ 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]);
4208
4220
  return process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupCollapsed(" \u{1F539} useTheme =>", state == null ? void 0 : state.name), console.log("returning state", changedThemeState, "from props", props), console.groupEnd()), [changedThemeState, themeProxied];
4209
4221
  };
4210
- function getThemeProxied(theme, themeManager, keys, debug) {
4222
+ function getThemeProxied({ theme, name }, deopt = !1, themeManager, keys, debug) {
4223
+ if (!theme)
4224
+ return {};
4225
+ function track(key) {
4226
+ keys && !keys.includes(key) && (keys.push(key), process.env.NODE_ENV === "development" && debug && console.log(` \u{1F3A8} useTheme() tracking new key: ${key}`));
4227
+ }
4211
4228
  return (0, import_createProxy.createProxy)(theme, {
4212
4229
  has(_, key) {
4213
4230
  if (Reflect.has(theme, key))
@@ -4229,7 +4246,30 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4229
4246
  // when they touch the actual value we only track it
4230
4247
  // if its a variable (web), its ignored!
4231
4248
  get(_2, subkey) {
4232
- return keys && (subkey === "val" || subkey === "get" && !import_constants2.isWeb) && !keys.includes(keyString) && (keys.push(keyString), process.env.NODE_ENV === "development" && debug && console.log(` \u{1F3A8} useTheme() tracking new key: ${keyString}`)), subkey === "get" ? () => (0, import_createVariable.getVariable)(val) : Reflect.get(val, subkey);
4249
+ if (subkey === "val")
4250
+ track(keyString);
4251
+ else if (subkey === "get")
4252
+ return () => {
4253
+ let outVal = (0, import_createVariable.getVariable)(val);
4254
+ if (import_constants2.isIos && !deopt) {
4255
+ let isDark = name.startsWith("dark"), isLight = !isDark && name.startsWith("light");
4256
+ if (isDark || isLight) {
4257
+ let oppositeThemeName = name.replace(
4258
+ isDark ? "dark" : "light",
4259
+ isDark ? "light" : "dark"
4260
+ ), oppositeTheme = (0, import_config.getConfig)().themes[oppositeThemeName], oppositeVal = (0, import_createVariable.getVariable)(oppositeTheme == null ? void 0 : oppositeTheme[keyString]);
4261
+ if (oppositeVal)
4262
+ return {
4263
+ dynamic: {
4264
+ dark: isDark ? outVal : oppositeVal,
4265
+ light: isLight ? outVal : oppositeVal
4266
+ }
4267
+ };
4268
+ }
4269
+ }
4270
+ return track(keyString), outVal;
4271
+ };
4272
+ return Reflect.get(val, subkey);
4233
4273
  }
4234
4274
  });
4235
4275
  }
@@ -4238,10 +4278,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4238
4278
  });
4239
4279
  }
4240
4280
  var activeThemeManagers = /* @__PURE__ */ new Set(), useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => {
4241
- let {
4242
- // @ts-expect-error internal use only
4243
- disable
4244
- } = props, parentManager = (0, import_react.useContext)(import_ThemeManagerContext.ThemeManagerContext);
4281
+ let { disable } = props, parentManager = (0, import_react.useContext)(import_ThemeManagerContext.ThemeManagerContext);
4245
4282
  if (!isRoot && !parentManager || disable)
4246
4283
  return {
4247
4284
  isNewTheme: !1,
@@ -4268,7 +4305,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4268
4305
  let selfListenerDispose = themeManager.onChangeTheme((_a, _b, forced) => {
4269
4306
  forced && setThemeState((prev) => createState(prev, !0));
4270
4307
  }), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme((name, manager) => {
4271
- let force = shouldUpdate == null ? void 0 : shouldUpdate(), doUpdate = force ?? !!(keys != null && keys.length || isNewTheme);
4308
+ let force = (shouldUpdate == null ? void 0 : shouldUpdate()) || props.deopt || props["disable-child-theme"], doUpdate = force ?? !!(keys != null && keys.length || isNewTheme);
4272
4309
  process.env.NODE_ENV === "development" && props.debug && console.log(" \u{1F538} onChange", themeManager.id, {
4273
4310
  force,
4274
4311
  doUpdate,
@@ -4322,7 +4359,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4322
4359
  prev.state,
4323
4360
  forceChange
4324
4361
  );
4325
- nextState ? (state2 = nextState, !prev.isNewTheme || !import_constants2.isWeb ? themeManager2 = getNewThemeManager() : themeManager2.updateState(nextState)) : prev.isNewTheme && parentManager && !next && (themeManager2 = parentManager);
4362
+ nextState ? (state2 = nextState, prev.isNewTheme ? themeManager2.updateState(nextState) : themeManager2 = getNewThemeManager()) : prev.isNewTheme && parentManager && !next && (themeManager2 = parentManager);
4326
4363
  } else
4327
4364
  themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
4328
4365
  }
@@ -4759,17 +4796,22 @@ var require_createComponent_native = __commonJS({
4759
4796
  isEntering && enterVariant ? (process.env.NODE_ENV === "development" && debugProp === "verbose" && console.warn(`Animating presence ENTER "${enterVariant}"`), props[enterVariant] = !0) : isExiting2 && exitVariant && (process.env.NODE_ENV === "development" && debugProp === "verbose" && console.warn(`Animating presence EXIT "${enterVariant}"`), props[exitVariant] = !enterExitVariant);
4760
4797
  }
4761
4798
  }
4762
- 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;
4799
+ 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;
4763
4800
  process.env.NODE_ENV === "development" && time && time`theme-props`, props.themeShallow && (stateRef.current.themeShallow = !0);
4764
4801
  let themeStateProps = {
4765
4802
  name: props.theme,
4766
4803
  componentName,
4767
- // @ts-ignore this is internal use only
4768
4804
  disable: disableTheme,
4769
4805
  shallow: stateRef.current.themeShallow,
4770
- shouldUpdate: () => stateRef.current.isListeningToTheme,
4806
+ // if this returns undefined it defers to the keys tracking, so its only used to force either updates or no updates
4807
+ shouldUpdate: () => (
4808
+ // when we use $theme- styles we need to force it to re-render on theme changes (this can be optimized likely)
4809
+ stateRef.current.isListeningToTheme
4810
+ ),
4771
4811
  debug: debugProp
4772
- }, isExiting = !state.unmounted && (presence == null ? void 0 : presence[0]) === !1;
4812
+ };
4813
+ themeStateProps.deopt = config != null && config.settings.fastSchemeChange ? willBeAnimated : !0;
4814
+ let isExiting = !state.unmounted && (presence == null ? void 0 : presence[0]) === !1;
4773
4815
  if (process.env.NODE_ENV === "development") {
4774
4816
  let id = (0, import_react.useId)();
4775
4817
  if (debugProp && debugProp !== "profile") {
@@ -5091,7 +5133,7 @@ If you meant to do this, you can disable this warning - either change untilMeasu
5091
5133
  });
5092
5134
  staticConfig.componentName && (component.displayName = staticConfig.componentName);
5093
5135
  let res = component;
5094
- (process.env.TAMAGUI_MEMO_ALL || staticConfig.memo) && (res = (0, import_react.memo)(res)), res.staticConfig = staticConfig;
5136
+ process.env.TAMAGUI_DISABLE_MEMO || (res = (0, import_react.memo)(res)), res.staticConfig = staticConfig;
5095
5137
  function extendStyledConfig(extended) {
5096
5138
  return {
5097
5139
  ...staticConfig,
@@ -5866,22 +5908,30 @@ var require_setupReactNative_native = __commonJS({
5866
5908
  setupReactNative: () => setupReactNative
5867
5909
  });
5868
5910
  module2.exports = __toCommonJS2(setupReactNative_exports);
5869
- var ReactNativeStaticConfigs = /* @__PURE__ */ new WeakMap();
5870
5911
  function getReactNativeConfig(Component) {
5871
- return ReactNativeStaticConfigs.get(Component);
5912
+ var _a, _b;
5913
+ if (Component)
5914
+ return Component.getSizeWithHeaders ? RNConfigs.Image : (_a = Component.propTypes) != null && _a.textBreakStrategy ? RNConfigs.Text : (_b = Component.propTypes) != null && _b.onTextInput ? void 0 : RNConfigs.default;
5872
5915
  }
5873
- function setupReactNative(rnExports) {
5874
- for (let key in rnExports) {
5875
- if (key[0].toLowerCase() === key[0])
5876
- continue;
5877
- let val = rnExports[key];
5878
- val && typeof val == "object" && ReactNativeStaticConfigs.set(val, {
5879
- isReactNative: !0,
5880
- isText: key === "Text" || key === "TextInput",
5881
- isInput: key === "TextInput" || key === "TextArea",
5882
- inlineProps: key === "Image" ? /* @__PURE__ */ new Set(["src", "width", "height"]) : void 0
5883
- });
5916
+ var RNConfigs = {
5917
+ Image: {
5918
+ isReactNative: !0,
5919
+ inlineProps: /* @__PURE__ */ new Set(["src", "width", "height"])
5920
+ },
5921
+ Text: {
5922
+ isReactNative: !0,
5923
+ isText: !0
5924
+ },
5925
+ TextInput: {
5926
+ isReactNative: !0,
5927
+ isInput: !0,
5928
+ isText: !0
5929
+ },
5930
+ default: {
5931
+ isReactNative: !0
5884
5932
  }
5933
+ };
5934
+ function setupReactNative(rnExports) {
5885
5935
  }
5886
5936
  }
5887
5937
  });
@@ -5907,7 +5957,7 @@ var require_styled_native = __commonJS({
5907
5957
  function styled(ComponentIn, options, staticExtractionOptions) {
5908
5958
  if (process.env.NODE_ENV !== "production" && !ComponentIn)
5909
5959
  throw new Error("No component given to styled()");
5910
- 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 = (() => {
5960
+ 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 = (() => {
5911
5961
  if (options) {
5912
5962
  let {
5913
5963
  variants,