@tamagui/core 1.129.4 → 1.129.5-1751184593158

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
@@ -2091,7 +2091,7 @@ var require_useMedia_native = __commonJS({
2091
2091
  };
2092
2092
  }
2093
2093
  function useMedia2(cc, debug) {
2094
- var componentState = cc ? States.get(cc) : null, internalRef = (0, import_react3.useRef)();
2094
+ var componentState = cc ? States.get(cc) : null, internalRef = (0, import_react3.useRef)(null);
2095
2095
  internalRef.current || (internalRef.current = {
2096
2096
  keys: /* @__PURE__ */ new Set()
2097
2097
  });
@@ -5580,7 +5580,7 @@ var require_getSplitStyles_native = __commonJS({
5580
5580
  conf = conf || (0, import_config.getConfig)();
5581
5581
  var animationDriver = (componentContext == null ? void 0 : componentContext.animationDriver) || conf.animations;
5582
5582
  import_constants2.isWeb && styleProps.isAnimated && animationDriver.isReactNative && !styleProps.noNormalize && (styleProps.noNormalize = "values");
5583
- var { shorthands } = conf, { isHOC, isText, isInput, variants, isReactNative, inlineProps, inlineWhenUnflattened, parentStaticConfig, acceptsClassName } = staticConfig, viewProps = {}, mediaState2 = styleProps.mediaState || import_useMedia.mediaState, usedKeys = {}, shouldDoClasses = acceptsClassName && import_constants2.isWeb && !styleProps.noClass, rulesToInsert = void 0, classNames = {}, pseudos = null, space = props.space, hasMedia = !1, dynamicThemeAccess, pseudoGroups, mediaGroups, className = props.className || "", mediaStylesSeen = 0, validStyles2 = staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? import_helpers2.stylePropsText : import_helpers2.validStyles);
5583
+ var { shorthands } = conf, { isHOC, isText, isInput, variants, isReactNative, inlineProps, inlineWhenUnflattened, parentStaticConfig, acceptsClassName } = staticConfig, viewProps = {}, mediaState2 = styleProps.mediaState || import_useMedia.mediaState, usedKeys = {}, shouldDoClasses = acceptsClassName && import_constants2.isWeb && !styleProps.noClass && !styleProps.isAnimated, rulesToInsert = void 0, classNames = {}, pseudos = null, space = props.space, hasMedia = !1, dynamicThemeAccess, pseudoGroups, mediaGroups, className = props.className || "", mediaStylesSeen = 0, validStyles2 = staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? import_helpers2.stylePropsText : import_helpers2.validStyles);
5584
5584
  process.env.NODE_ENV === "development" && debug === "profile" && time`split-styles-setup`;
5585
5585
  var styleState = {
5586
5586
  classNames,
@@ -5687,7 +5687,7 @@ var require_getSplitStyles_native = __commonJS({
5687
5687
  var style2 = styleState.style;
5688
5688
  if (0) {
5689
5689
  var _staticConfig_defaultProps, fontFamily, fontFamilyClassName, groupClassName, componentNameFinal, componentClassName, classList, finalClassName;
5690
- if (!(styleProps.isAnimated && !animationDriver.supportsCSSVars && isReactNative) && isReactNative) {
5690
+ if (!styleProps.isAnimated && isReactNative) {
5691
5691
  var cnStyles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1;
5692
5692
  try {
5693
5693
  for (var _iterator1, _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) var name;
@@ -5769,7 +5769,6 @@ var require_getSplitStyles_native = __commonJS({
5769
5769
  return styleProps.noNormalize || (0, import_expandStyles.fixStyles)(styleOut), styleOut;
5770
5770
  }, useInsertEffectCompat = import_constants2.isWeb ? import_react3.default.useInsertionEffect || import_constants2.useIsomorphicLayoutEffect : function() {
5771
5771
  }, useSplitStyles = function(a, b, c, d, e, f, g, h, i, j, k) {
5772
- conf = conf || (0, import_config.getConfig)();
5773
5772
  var res = getSplitStyles(a, b, c, d, e, f, g, h, i, j, k);
5774
5773
  return res;
5775
5774
  };
@@ -5957,9 +5956,9 @@ var require_setElementProps_native = __commonJS({
5957
5956
  }
5958
5957
  });
5959
5958
 
5960
- // ../web/dist/cjs/helpers/createShallowSetState.native.js
5961
- var require_createShallowSetState_native = __commonJS({
5962
- "../web/dist/cjs/helpers/createShallowSetState.native.js"(exports2, module2) {
5959
+ // ../web/dist/cjs/helpers/useCreateShallowSetState.native.js
5960
+ var require_useCreateShallowSetState_native = __commonJS({
5961
+ "../web/dist/cjs/helpers/useCreateShallowSetState.native.js"(exports2, module2) {
5963
5962
  "use strict";
5964
5963
  var __defProp2 = Object.defineProperty, __getOwnPropDesc2 = Object.getOwnPropertyDescriptor, __getOwnPropNames2 = Object.getOwnPropertyNames, __hasOwnProp2 = Object.prototype.hasOwnProperty, __export2 = function(target, all) {
5965
5964
  for (var name in all) __defProp2(target, name, {
@@ -5993,43 +5992,31 @@ var require_createShallowSetState_native = __commonJS({
5993
5992
  return __copyProps2(__defProp2({}, "__esModule", {
5994
5993
  value: !0
5995
5994
  }), mod);
5996
- }, createShallowSetState_exports = {};
5997
- __export2(createShallowSetState_exports, {
5998
- createShallowSetState: function() {
5999
- return createShallowSetState;
6000
- },
5995
+ }, useCreateShallowSetState_exports = {};
5996
+ __export2(useCreateShallowSetState_exports, {
6001
5997
  isEqualShallow: function() {
6002
5998
  return isEqualShallow2;
6003
5999
  },
6004
6000
  mergeIfNotShallowEqual: function() {
6005
6001
  return mergeIfNotShallowEqual;
6002
+ },
6003
+ useCreateShallowSetState: function() {
6004
+ return useCreateShallowSetState;
6006
6005
  }
6007
6006
  });
6008
- module2.exports = __toCommonJS2(createShallowSetState_exports);
6009
- var import_react3 = require("react"), callImmediate = function(cb) {
6010
- return cb();
6011
- };
6012
- function createShallowSetState(setter, onlyAllow, transition, debugIn) {
6007
+ module2.exports = __toCommonJS2(useCreateShallowSetState_exports);
6008
+ var import_react3 = require("react");
6009
+ function useCreateShallowSetState(setter, debugIn) {
6013
6010
  return (0, import_react3.useCallback)(function(next) {
6014
- var wrap = transition ? import_react3.startTransition : callImmediate;
6015
- wrap(function() {
6016
- setter(function(prev) {
6017
- return mergeIfNotShallowEqual(prev, next, onlyAllow, debugIn);
6018
- });
6011
+ setter(function(prev) {
6012
+ return mergeIfNotShallowEqual(prev, next, debugIn);
6019
6013
  });
6020
6014
  }, [
6021
6015
  setter,
6022
- onlyAllow ? onlyAllow.join("") : "",
6023
- transition,
6024
6016
  debugIn
6025
6017
  ]);
6026
6018
  }
6027
- function mergeIfNotShallowEqual(prev, next, onlyAllow, debug) {
6028
- if (onlyAllow) {
6029
- var allowed = {};
6030
- for (var key in next) onlyAllow.includes(key) && (allowed[key] = next[key]);
6031
- next = allowed;
6032
- }
6019
+ function mergeIfNotShallowEqual(prev, next, debug) {
6033
6020
  if (!prev || !next || isEqualShallow2(prev, next)) return prev || next;
6034
6021
  if (process.env.NODE_ENV === "development" && debug && (console.info("setStateShallow CHANGE", {
6035
6022
  prev,
@@ -6090,7 +6077,7 @@ var require_subscribeToContextGroup_native = __commonJS({
6090
6077
  }
6091
6078
  });
6092
6079
  module2.exports = __toCommonJS2(subscribeToContextGroup_exports);
6093
- var import_useMedia = require_useMedia_native(), import_createShallowSetState = require_createShallowSetState_native(), subscribeToContextGroup = function(param) {
6080
+ var import_useMedia = require_useMedia_native(), import_useCreateShallowSetState = require_useCreateShallowSetState_native(), subscribeToContextGroup = function(param) {
6094
6081
  var { setStateShallow, pseudoGroups, mediaGroups, componentContext, state } = param;
6095
6082
  if (pseudoGroups || mediaGroups) {
6096
6083
  var _componentContext_groups_subscribe, _componentContext_groups;
@@ -6101,7 +6088,7 @@ var require_subscribeToContextGroup_native = __commonJS({
6101
6088
  };
6102
6089
  if (pseudo && pseudoGroups != null && pseudoGroups.has(String(name))) Object.assign(current.pseudo, pseudo), persist();
6103
6090
  else if (layout && mediaGroups) {
6104
- var mediaState2 = (0, import_useMedia.getMediaState)(mediaGroups, layout), next = (0, import_createShallowSetState.mergeIfNotShallowEqual)(current.media, mediaState2);
6091
+ var mediaState2 = (0, import_useMedia.getMediaState)(mediaGroups, layout), next = (0, import_useCreateShallowSetState.mergeIfNotShallowEqual)(current.media || {}, mediaState2);
6105
6092
  next !== current.media && (Object.assign(current.media, next), persist());
6106
6093
  }
6107
6094
  function persist() {
@@ -7050,10 +7037,15 @@ var require_index_native6 = __commonJS({
7050
7037
  },
7051
7038
  useDidFinishSSR: function() {
7052
7039
  return useDidFinishSSR;
7040
+ },
7041
+ useIsClientOnly: function() {
7042
+ return useIsClientOnly;
7053
7043
  }
7054
7044
  });
7055
7045
  module2.exports = __toCommonJS2(index_exports2);
7056
- var React3 = __toESM2(require("react")), import_ClientOnly = require_ClientOnly_native(), import_ClientOnly2 = require_ClientOnly_native();
7046
+ var React3 = __toESM2(require("react")), import_ClientOnly = require_ClientOnly_native(), import_ClientOnly2 = require_ClientOnly_native(), useIsClientOnly = function() {
7047
+ return React3.useContext(import_ClientOnly.ClientOnlyContext);
7048
+ };
7057
7049
  function useDidFinishSSR(value) {
7058
7050
  var clientOnly = React3.useContext(import_ClientOnly.ClientOnlyContext);
7059
7051
  return value ?? !0;
@@ -7108,10 +7100,12 @@ var require_useComponentState_native = __commonJS({
7108
7100
  }
7109
7101
  });
7110
7102
  module2.exports = __toCommonJS2(useComponentState_exports);
7111
- var import_constants2 = require_index_native2(), import_use_did_finish_ssr = require_index_native6(), import_react3 = require("react"), import_defaultComponentState = require_defaultComponentState_native(), import_createShallowSetState = require_createShallowSetState_native(), import_isObj = require_isObj_native(), import_log = require_log_native(), useComponentState = function(props, param, staticConfig, config) {
7112
- var { animationDriver } = param, _animationDriver_usePresence, isHydrated = (0, import_use_did_finish_ssr.useDidFinishSSR)(), [startedUnhydrated] = (0, import_react3.useState)(import_constants2.IS_REACT_19 ? !isHydrated : !1), useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, stateRef = (0, import_react3.useRef)(void 0);
7103
+ var import_constants2 = require_index_native2(), import_use_did_finish_ssr = require_index_native6(), import_react3 = require("react"), import_defaultComponentState = require_defaultComponentState_native(), import_isObj = require_isObj_native(), import_log = require_log_native(), import_useCreateShallowSetState = require_useCreateShallowSetState_native(), useComponentState = function(props, param, staticConfig, config) {
7104
+ var { animationDriver } = param, _animationDriver_usePresence, isHydrated = (0, import_use_did_finish_ssr.useDidFinishSSR)(), needsHydration = !(0, import_use_did_finish_ssr.useIsClientOnly)(), [startedUnhydrated] = (0, import_react3.useState)(import_constants2.IS_REACT_19 ? !isHydrated : !1), useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, stateRef = (0, import_react3.useRef)(void 0);
7113
7105
  stateRef.current || (stateRef.current = {});
7114
- var hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver == null ? void 0 : animationDriver.supportsCSSVars, curStateRef = stateRef.current, willBeAnimatedClient = function() {
7106
+ var hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver == null ? void 0 : animationDriver.supportsCSSVars, curStateRef = stateRef.current;
7107
+ !needsHydration && hasAnimationProp && (curStateRef.hasAnimated = !0);
7108
+ var willBeAnimatedClient = function() {
7115
7109
  var next = !!(hasAnimationProp && !staticConfig.isHOC && useAnimations);
7116
7110
  return !!(next || curStateRef.hasAnimated);
7117
7111
  }(), willBeAnimated = !import_constants2.isServer && willBeAnimatedClient;
@@ -7131,16 +7125,12 @@ var require_useComponentState_native = __commonJS({
7131
7125
  ...states[0],
7132
7126
  [props.forceStyle]: !0
7133
7127
  } : states[0], setState = states[1], isAnimated = willBeAnimated;
7134
- import_constants2.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (disabled && Object.assign(state, import_defaultComponentState.defaultComponentStateMounted), state.disabled = disabled, setState({
7135
- ...state
7128
+ import_constants2.isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated && (isAnimated = !1, curStateRef.willHydrate = !0), disabled !== state.disabled && (disabled && Object.assign(state, import_defaultComponentState.defaultComponentStateMounted), state.disabled = disabled, setState(function(_) {
7129
+ return {
7130
+ ...state
7131
+ };
7136
7132
  }));
7137
- var groupName = props.group, setStateShallow = (0, import_createShallowSetState.createShallowSetState)(
7138
- setState,
7139
- void 0,
7140
- // note: allows all state updates even when disabled for the enterStyle animation to work
7141
- !1,
7142
- props.debug
7143
- );
7133
+ var groupName = props.group, setStateShallow = (0, import_useCreateShallowSetState.useCreateShallowSetState)(setState, props.debug);
7144
7134
  if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
7145
7135
  process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`has presenceState ${JSON.stringify(presenceState)}`);
7146
7136
  var { enterVariant, exitVariant, enterExitVariant, custom } = presenceState;
@@ -7148,7 +7138,7 @@ var require_useComponentState_native = __commonJS({
7148
7138
  var exv = exitVariant ?? enterExitVariant, env = enterVariant ?? enterExitVariant;
7149
7139
  state.unmounted && env && staticConfig.variants[env] ? (process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`Animating presence ENTER "${env}"`), props[env] = !0) : isExiting && exv && (process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`Animating presence EXIT "${exv}"`), props[exv] = exitVariant !== enterExitVariant);
7150
7140
  }
7151
- var noClass = !import_constants2.isWeb || !!props.forceStyle;
7141
+ var noClass = !import_constants2.isWeb || !!props.forceStyle || isAnimated && (animationDriver == null ? void 0 : animationDriver.needsWebStyles);
7152
7142
  if (import_constants2.isWeb && (!import_constants2.isServer || isHydrated)) {
7153
7143
  var isAnimatedAndHydrated = isAnimated && !supportsCSSVars, isClassNameDisabled = !staticConfig.acceptsClassName && (config.disableSSR || !state.unmounted), isDisabledManually = disableClassName && !state.unmounted;
7154
7144
  (isAnimatedAndHydrated || isDisabledManually || isClassNameDisabled) && (noClass = !0, process.env.NODE_ENV === "development" && props.debug && (0, import_log.log)("avoiding className", {
@@ -7177,6 +7167,26 @@ var require_useComponentState_native = __commonJS({
7177
7167
  }
7178
7168
  };
7179
7169
  }
7170
+ if (!curStateRef.stateEmitter && hasAnimationProp) {
7171
+ var listeners1 = /* @__PURE__ */ new Set();
7172
+ curStateRef.stateEmitter = {
7173
+ listeners: listeners1,
7174
+ emit(state2) {
7175
+ listeners1.forEach(function(l) {
7176
+ return l(state2);
7177
+ });
7178
+ },
7179
+ subscribe(cb) {
7180
+ return listeners1.add(cb), setStateShallow({
7181
+ hasDynGroupChildren: !0
7182
+ }), function() {
7183
+ listeners1.delete(cb), listeners1.size === 0 && setStateShallow({
7184
+ hasDynGroupChildren: !1
7185
+ });
7186
+ };
7187
+ }
7188
+ };
7189
+ }
7180
7190
  return {
7181
7191
  startedUnhydrated,
7182
7192
  curStateRef,
@@ -7540,10 +7550,14 @@ var require_createComponent_native = __commonJS({
7540
7550
  }, [
7541
7551
  componentName2
7542
7552
  ]);
7543
- var animationDriver = componentContext.animationDriver, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, { curStateRef, disabled, groupName, hasAnimationProp, hasEnterStyle, isAnimated, isExiting, isHydrated, presence, presenceState, setState, setStateShallow, noClass, state, stateRef, supportsCSSVars, willBeAnimated, willBeAnimatedClient, startedUnhydrated } = (0, import_useComponentState.useComponentState)(props, componentContext, staticConfig, config);
7553
+ var animationDriver = componentContext.animationDriver, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, componentState = (0, import_useComponentState.useComponentState)(props, componentContext, staticConfig, config), { curStateRef, disabled, groupName, hasAnimationProp, hasEnterStyle, isAnimated, isExiting, isHydrated, presence, presenceState, setState, noClass, state, stateRef, supportsCSSVars, willBeAnimated, willBeAnimatedClient, startedUnhydrated } = componentState, setStateShallow = componentState.setStateShallow;
7544
7554
  process.env.NODE_ENV === "development" && time2 && time2`use-state`;
7545
7555
  var hasTextAncestor = !!(import_constants2.isWeb && isText && componentContext.inText), isTaggable = !Component || typeof Component == "string", tagProp = props.tag, element = import_constants2.isWeb && isTaggable && tagProp || Component, BaseTextComponent = BaseText || element || "span", BaseViewComponent = BaseView || element || (hasTextAncestor ? "span" : "div"), elementType = isText ? BaseTextComponent : BaseViewComponent;
7546
- animationDriver && isAnimated && (elementType = animationDriver[isText ? "Text" : "View"] || elementType);
7556
+ animationDriver && isAnimated && // this should really be behind another prop as it's not really related to
7557
+ // "needsWebStyles" basically with motion we just animate a plain div, but
7558
+ // we still have animated.View/Text for Sheet which wants to control
7559
+ // things declaratively
7560
+ !animationDriver.needsWebStyles && (elementType = animationDriver[isText ? "Text" : "View"] || elementType);
7547
7561
  var disableThemeProp = !1, disableTheme = disableThemeProp || isHOC;
7548
7562
  process.env.NODE_ENV === "development" && time2 && time2`theme-props`, props.themeShallow && (curStateRef.themeShallow = !0);
7549
7563
  var themeStateProps = {
@@ -7597,10 +7611,30 @@ var require_createComponent_native = __commonJS({
7597
7611
  isExiting,
7598
7612
  isAnimated,
7599
7613
  willBeAnimated,
7600
- styledContextProps
7614
+ styledContextProps,
7615
+ noMergeStyle: isAnimated && (animationDriver == null ? void 0 : animationDriver.needsWebStyles)
7601
7616
  }, themeName = (themeState == null ? void 0 : themeState.name) || "";
7602
7617
  process.env.NODE_ENV === "development" && time2 && time2`split-styles-prepare`;
7603
7618
  var splitStyles = (0, import_getSplitStyles.useSplitStyles)(props, staticConfig, theme, themeName, state, styleProps, null, componentContext, elementType, startedUnhydrated, debugProp);
7619
+ if (hasAnimationProp && animationDriver != null && animationDriver.avoidReRenders) {
7620
+ var styleListener = stateRef.current.useStyleListener, ogSetStateShallow = setStateShallow;
7621
+ setStateShallow = function(next) {
7622
+ var avoidReRenderKeys = /* @__PURE__ */ new Set([
7623
+ "hover",
7624
+ "press",
7625
+ "pressIn"
7626
+ ]), canAvoidReRender = Object.keys(next).every(function(key3) {
7627
+ return avoidReRenderKeys.has(key3);
7628
+ });
7629
+ if (canAvoidReRender) {
7630
+ var updatedState = {
7631
+ ...state,
7632
+ ...next
7633
+ }, nextStyles = (0, import_getSplitStyles.getSplitStyles)(props, staticConfig, theme, themeName, updatedState, styleProps, null, componentContext, elementType, startedUnhydrated, debugProp);
7634
+ styleListener(nextStyles.style);
7635
+ } else ogSetStateShallow(next);
7636
+ };
7637
+ }
7604
7638
  if (process.env.NODE_ENV === "development" && time2 && time2`split-styles`, props.group && props.untilMeasured === "hide" && !curStateRef.hasMeasured) {
7605
7639
  var _splitStyles;
7606
7640
  (_splitStyles = splitStyles).style || (_splitStyles.style = {}), splitStyles.style.opacity = 0;
@@ -7639,10 +7673,15 @@ var require_createComponent_native = __commonJS({
7639
7673
  (supportsCSSVars ? willBeAnimatedClient : willBeAnimated) && useAnimations && !isHOC
7640
7674
  );
7641
7675
  if (shouldUseAnimation) {
7642
- var animations = useAnimations({
7676
+ var useStyleEmitter = animationDriver != null && animationDriver.avoidReRenders ? function(listener) {
7677
+ stateRef.current.useStyleListener = listener;
7678
+ } : void 0, animations = useAnimations({
7643
7679
  props: propsWithAnimation,
7644
7680
  // if hydrating, send empty style
7645
7681
  style: splitStylesStyle || {},
7682
+ // @ts-ignore
7683
+ styleState: splitStyles,
7684
+ useStyleEmitter,
7646
7685
  presence,
7647
7686
  componentState: state,
7648
7687
  styleProps,
@@ -10697,7 +10736,7 @@ var require_index_native8 = __commonJS({
10697
10736
  __reExport2(index_exports2, require_withStableStyle_native(), module2.exports);
10698
10737
  __reExport2(index_exports2, require_createMediaStyle_native(), module2.exports);
10699
10738
  __reExport2(index_exports2, require_getShorthandValue_native(), module2.exports);
10700
- __reExport2(index_exports2, require_createShallowSetState_native(), module2.exports);
10739
+ __reExport2(index_exports2, require_useCreateShallowSetState_native(), module2.exports);
10701
10740
  __reExport2(index_exports2, require_createStyledContext_native(), module2.exports);
10702
10741
  __reExport2(index_exports2, require_expandStyles_native(), module2.exports);
10703
10742
  __reExport2(index_exports2, require_getExpandedShorthands_native(), module2.exports);