@tamagui/core 1.113.2 → 1.114.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.
package/dist/native.js CHANGED
@@ -2977,10 +2977,12 @@ var require_useMedia_native = __commonJS({
2977
2977
  }));
2978
2978
  }
2979
2979
  var States = /* @__PURE__ */ new WeakMap();
2980
- function setMediaShouldUpdate(ref, props) {
2981
- return States.set(ref, {
2982
- ...States.get(ref),
2983
- ...props
2980
+ function setMediaShouldUpdate(ref, enabled, keys) {
2981
+ var cur = States.get(ref);
2982
+ (!cur || cur.enabled !== enabled || keys) && States.set(ref, {
2983
+ ...cur,
2984
+ enabled,
2985
+ keys
2984
2986
  });
2985
2987
  }
2986
2988
  function subscribe(subscriber) {
@@ -3668,7 +3670,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
3668
3670
  props.deopt,
3669
3671
  props.debug
3670
3672
  ]);
3671
- return process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupCollapsed(` \u{1F539} [${themeManager == null ? void 0 : themeManager.id}] useTheme =>`, state == null ? void 0 : state.name), console.info("returning state", changedThemeState, "from props", props), console.groupEnd()), [
3673
+ return process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupCollapsed(` \u{1F539} [${themeManager == null ? void 0 : themeManager.id}] useTheme =>`, state == null ? void 0 : state.name), console.info("returning state", changedThemeState.state, changedThemeState.isNewTheme, "from props", props), console.groupEnd()), [
3672
3674
  changedThemeState,
3673
3675
  themeProxied
3674
3676
  ];
@@ -3812,12 +3814,12 @@ If this is intended and you are using Tamagui without any themes, you can disabl
3812
3814
  });
3813
3815
  }, !0), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(function(name, manager, forced) {
3814
3816
  var force = forced || (shouldUpdate == null ? void 0 : shouldUpdate()) || props.deopt || props["disable-child-theme"], shouldTryUpdate = force ?? !!(keys != null && keys.length || isNewTheme);
3815
- process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info(" \u{1F538} onChange", themeManager.id, {
3817
+ process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info(" \u{1F538} onChange", {
3818
+ id: themeManager.id,
3816
3819
  force,
3817
3820
  shouldTryUpdate,
3818
3821
  props,
3819
3822
  name,
3820
- manager,
3821
3823
  keys
3822
3824
  }), shouldTryUpdate && setThemeState(function(prev) {
3823
3825
  return createState(prev, force);
@@ -7134,7 +7136,7 @@ var require_getSplitStyles_native = __commonJS({
7134
7136
  }
7135
7137
  var isStyleProp = isValidStyleKeyInit || isMediaOrPseudo1 || isVariant && !noExpand || isShorthand;
7136
7138
  if (!(isStyleProp && (asChild === "except-style" || asChild === "except-style-web"))) {
7137
- var shouldPassProp = !isStyleProp || // is in parent variants
7139
+ var shouldPassProp = !isStyleProp && isHOC || // is in parent variants
7138
7140
  isHOC && parentVariants && keyInit in parentVariants || (inlineProps == null ? void 0 : inlineProps.has(keyInit)), parentVariant = parentVariants == null ? void 0 : parentVariants[keyInit], isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo1 || parentVariant || keyInit in import_skipProps.skipProps)), shouldPassThrough = shouldPassProp || isHOCShouldPassThrough;
7139
7141
  if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), consoleGroupCollapsed(` \u{1F511} ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ""} ${shouldPassThrough ? "(pass)" : ""}`), (0, import_log.log)({
7140
7142
  isVariant,
@@ -7875,7 +7877,12 @@ var require_themeable_native = __commonJS({
7875
7877
  var import_jsx_runtime = require("react/jsx-runtime"), import_react3 = __toESM2(require("react")), import_Theme = require_Theme_native();
7876
7878
  function themeable(Component, staticConfig) {
7877
7879
  var withThemeComponent = /* @__PURE__ */ import_react3.default.forwardRef(function(props, ref) {
7878
- var { themeInverse, theme, componentName, themeReset, ...rest } = props, element = (
7880
+ var { themeInverse, theme, componentName, themeReset, ...rest } = props, overriddenContextProps, context = staticConfig == null ? void 0 : staticConfig.context;
7881
+ if (context) for (var key in context.props) {
7882
+ var val = props[key];
7883
+ val !== void 0 && (overriddenContextProps || (overriddenContextProps = {}), overriddenContextProps[key] = val);
7884
+ }
7885
+ var element = (
7879
7886
  // @ts-expect-error its ok
7880
7887
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
7881
7888
  ref,
@@ -7891,6 +7898,14 @@ var require_themeable_native = __commonJS({
7891
7898
  reset: themeReset,
7892
7899
  children: element
7893
7900
  });
7901
+ if (context) {
7902
+ var Provider = context.Provider, contextValue = import_react3.default.useContext(context);
7903
+ contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider, {
7904
+ ...contextValue,
7905
+ ...overriddenContextProps,
7906
+ children: contents
7907
+ });
7908
+ }
7894
7909
  return contents;
7895
7910
  }), withTheme = withThemeComponent;
7896
7911
  return withTheme.displayName = `Themed(${(Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "Anonymous"})`, withTheme;
@@ -8406,15 +8421,16 @@ var require_createComponent_native = __commonJS({
8406
8421
  (_ = (_propsIn_datatestrenders = propsIn["data-test-renders"])[_current = "current"]) !== null && _ !== void 0 || (_propsIn_datatestrenders[_current] = 0), propsIn["data-test-renders"].current += 1;
8407
8422
  }
8408
8423
  var componentContext = import_react3.default.useContext(import_ComponentContext.ComponentContext), styledContextProps, overriddenContextProps, contextValue, { context, isReactNative } = staticConfig;
8409
- if (context) {
8410
- contextValue = import_react3.default.useContext(context);
8411
- var { inverseShorthands } = (0, import_config.getConfig)();
8424
+ if (context && (contextValue = import_react3.default.useContext(context), contextValue)) {
8425
+ process.env.NODE_ENV === "development" && (propsIn.debug || defaultProps != null && defaultProps.debug) && (0, import_log.log)(" \u{1F447} contextValue", contextValue);
8412
8426
  for (var key in context.props) {
8413
- var _propsIn_key, _ref, _ref1, propVal = (_ref1 = (_ref = (_propsIn_key = propsIn[key]) !== null && _propsIn_key !== void 0 ? _propsIn_key : propsIn[inverseShorthands[key]]) !== null && _ref !== void 0 ? _ref : defaultProps == null ? void 0 : defaultProps[key]) !== null && _ref1 !== void 0 ? _ref1 : defaultProps == null ? void 0 : defaultProps[inverseShorthands[key]];
8427
+ var propVal = propsIn[key];
8414
8428
  if (propVal === void 0) {
8415
8429
  var val = contextValue == null ? void 0 : contextValue[key];
8416
8430
  val !== void 0 && (styledContextProps || (styledContextProps = {}), styledContextProps[key] = val);
8417
- } else overriddenContextProps || (overriddenContextProps = {}), overriddenContextProps[key] = propVal;
8431
+ }
8432
+ var finalVal = propVal ?? (defaultProps == null ? void 0 : defaultProps[key]);
8433
+ finalVal !== void 0 && (overriddenContextProps || (overriddenContextProps = {}), overriddenContextProps[key] = finalVal);
8418
8434
  }
8419
8435
  }
8420
8436
  var curDefaultProps = styledContextProps ? {
@@ -8510,10 +8526,7 @@ var require_createComponent_native = __commonJS({
8510
8526
  }
8511
8527
  process.env.NODE_ENV === "development" && time && time`split-styles`, curStateRef.isListeningToTheme = splitStyles.dynamicThemeAccess;
8512
8528
  var hasRuntimeMediaKeys = splitStyles.hasMedia && splitStyles.hasMedia !== !0, shouldListenForMedia = (0, import_createVariable.didGetVariableValue)() || hasRuntimeMediaKeys || noClassNames && splitStyles.hasMedia === !0, mediaListeningKeys = hasRuntimeMediaKeys ? splitStyles.hasMedia : null;
8513
- process.env.NODE_ENV === "development" && debugProp === "verbose" && console.info("useMedia() createComponent", shouldListenForMedia, mediaListeningKeys), (0, import_useMedia.setMediaShouldUpdate)(stateRef, {
8514
- enabled: shouldListenForMedia,
8515
- keys: mediaListeningKeys
8516
- });
8529
+ process.env.NODE_ENV === "development" && debugProp === "verbose" && console.info("useMedia() createComponent", shouldListenForMedia, mediaListeningKeys), (0, import_useMedia.setMediaShouldUpdate)(stateRef, shouldListenForMedia, mediaListeningKeys);
8517
8530
  var { viewProps: viewPropsIn, pseudos, style: splitStylesStyle, classNames, space } = splitStyles, propsWithAnimation = props, {
8518
8531
  asChild,
8519
8532
  children,
@@ -8539,7 +8552,7 @@ var require_createComponent_native = __commonJS({
8539
8552
  theme: _themeProp,
8540
8553
  ...nonTamaguiProps
8541
8554
  } = viewPropsIn, viewProps = nonTamaguiProps;
8542
- !isTaggable && props.forceStyle && (viewProps.forceStyle = props.forceStyle), isHOC && _themeProp && (viewProps.theme = _themeProp), elementType.acceptTagProp && (viewProps.tag = tagProp);
8555
+ !isTaggable && props.forceStyle && (viewProps.forceStyle = props.forceStyle), isHOC && _themeProp && (viewProps.theme = _themeProp), tagProp && elementType.acceptTagProp && (viewProps.tag = tagProp);
8543
8556
  var animationStyles, shouldUseAnimation = (
8544
8557
  // if it supports css vars we run it on server too to get matching initial style
8545
8558
  (supportsCSSVars ? willBeAnimatedClient : willBeAnimated) && useAnimations && !isHOC
@@ -9787,20 +9800,20 @@ ${runtimeStyles}`;
9787
9800
  sinceLastCall: !0
9788
9801
  });
9789
9802
  }, _configIn_settings_defaultFont, defaultFontSetting = (_configIn_settings_defaultFont = (_configIn_settings = configIn.settings) === null || _configIn_settings === void 0 ? void 0 : _configIn_settings.defaultFont) !== null && _configIn_settings_defaultFont !== void 0 ? _configIn_settings_defaultFont : configIn.defaultFont, defaultFont = function() {
9790
- var val2 = defaultFontSetting || // uses font named "body" if present for compat
9791
- configIn.fonts && ("body" in configIn.fonts ? "body" : "");
9792
- return !val2 && configIn.fonts && (val2 = Object.keys(configIn.fonts)[0]), (val2 == null ? void 0 : val2[0]) === "$" && (val2 = val2.slice(1)), val2;
9793
- }(), defaultFontToken = `$${defaultFont}`, config = {
9803
+ var val2 = defaultFontSetting;
9804
+ return (val2 == null ? void 0 : val2[0]) === "$" && (val2 = val2.slice(1)), val2;
9805
+ }(), defaultFontToken = defaultFont ? `$${defaultFont}` : "", unset = {
9806
+ ...configIn.unset
9807
+ };
9808
+ !unset.fontFamily && defaultFont && (unset.fontFamily = defaultFontToken);
9809
+ var config = {
9794
9810
  fonts: {},
9795
9811
  onlyAllowShorthands: !1,
9796
9812
  fontLanguages: [],
9797
9813
  animations: {},
9798
9814
  media: {},
9799
9815
  ...configIn,
9800
- unset: {
9801
- fontFamily: defaultFont ? defaultFontToken : void 0,
9802
- ...configIn.unset
9803
- },
9816
+ unset,
9804
9817
  settings: {
9805
9818
  // move deprecated settings here so we can reference them all using `getSetting`
9806
9819
  // TODO remove this on v2