@tamagui/core 1.129.4 → 1.129.5-1751174117974

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.
@@ -1895,7 +1895,7 @@ var require_useMedia_native = __commonJS({
1895
1895
  };
1896
1896
  }
1897
1897
  function useMedia2(cc, debug) {
1898
- var componentState = cc ? States.get(cc) : null, internalRef = (0, import_react3.useRef)();
1898
+ var componentState = cc ? States.get(cc) : null, internalRef = (0, import_react3.useRef)(null);
1899
1899
  internalRef.current || (internalRef.current = {
1900
1900
  keys: /* @__PURE__ */ new Set()
1901
1901
  });
@@ -5240,7 +5240,7 @@ var require_getSplitStyles_native = __commonJS({
5240
5240
  conf = conf || (0, import_config.getConfig)();
5241
5241
  var animationDriver = (componentContext == null ? void 0 : componentContext.animationDriver) || conf.animations;
5242
5242
  import_constants2.isWeb && styleProps.isAnimated && animationDriver.isReactNative && !styleProps.noNormalize && (styleProps.noNormalize = "values");
5243
- 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), styleState = {
5243
+ 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), styleState = {
5244
5244
  classNames,
5245
5245
  conf,
5246
5246
  props,
@@ -5330,7 +5330,7 @@ var require_getSplitStyles_native = __commonJS({
5330
5330
  var style2 = styleState.style;
5331
5331
  if (0) {
5332
5332
  var _staticConfig_defaultProps, fontFamily, fontFamilyClassName, groupClassName, componentNameFinal, componentClassName, classList, finalClassName;
5333
- if (!(styleProps.isAnimated && !animationDriver.supportsCSSVars && isReactNative) && isReactNative) {
5333
+ if (!styleProps.isAnimated && isReactNative) {
5334
5334
  var cnStyles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1;
5335
5335
  try {
5336
5336
  for (var _iterator1, _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) var name;
@@ -5402,7 +5402,6 @@ var require_getSplitStyles_native = __commonJS({
5402
5402
  return styleProps.noNormalize || (0, import_expandStyles.fixStyles)(styleOut), styleOut;
5403
5403
  }, useInsertEffectCompat = import_constants2.isWeb ? import_react3.default.useInsertionEffect || import_constants2.useIsomorphicLayoutEffect : function() {
5404
5404
  }, useSplitStyles = function(a, b, c, d, e, f, g, h, i, j, k) {
5405
- conf = conf || (0, import_config.getConfig)();
5406
5405
  var res = getSplitStyles(a, b, c, d, e, f, g, h, i, j, k);
5407
5406
  return res;
5408
5407
  };
@@ -5590,9 +5589,9 @@ var require_setElementProps_native = __commonJS({
5590
5589
  }
5591
5590
  });
5592
5591
 
5593
- // ../web/dist/cjs/helpers/createShallowSetState.native.js
5594
- var require_createShallowSetState_native = __commonJS({
5595
- "../web/dist/cjs/helpers/createShallowSetState.native.js"(exports2, module2) {
5592
+ // ../web/dist/cjs/helpers/useCreateShallowSetState.native.js
5593
+ var require_useCreateShallowSetState_native = __commonJS({
5594
+ "../web/dist/cjs/helpers/useCreateShallowSetState.native.js"(exports2, module2) {
5596
5595
  "use strict";
5597
5596
  var __defProp2 = Object.defineProperty, __getOwnPropDesc2 = Object.getOwnPropertyDescriptor, __getOwnPropNames2 = Object.getOwnPropertyNames, __hasOwnProp2 = Object.prototype.hasOwnProperty, __export2 = function(target, all) {
5598
5597
  for (var name in all) __defProp2(target, name, {
@@ -5626,43 +5625,31 @@ var require_createShallowSetState_native = __commonJS({
5626
5625
  return __copyProps2(__defProp2({}, "__esModule", {
5627
5626
  value: !0
5628
5627
  }), mod);
5629
- }, createShallowSetState_exports = {};
5630
- __export2(createShallowSetState_exports, {
5631
- createShallowSetState: function() {
5632
- return createShallowSetState;
5633
- },
5628
+ }, useCreateShallowSetState_exports = {};
5629
+ __export2(useCreateShallowSetState_exports, {
5634
5630
  isEqualShallow: function() {
5635
5631
  return isEqualShallow2;
5636
5632
  },
5637
5633
  mergeIfNotShallowEqual: function() {
5638
5634
  return mergeIfNotShallowEqual;
5635
+ },
5636
+ useCreateShallowSetState: function() {
5637
+ return useCreateShallowSetState;
5639
5638
  }
5640
5639
  });
5641
- module2.exports = __toCommonJS2(createShallowSetState_exports);
5642
- var import_react3 = require("react"), callImmediate = function(cb) {
5643
- return cb();
5644
- };
5645
- function createShallowSetState(setter, onlyAllow, transition, debugIn) {
5640
+ module2.exports = __toCommonJS2(useCreateShallowSetState_exports);
5641
+ var import_react3 = require("react");
5642
+ function useCreateShallowSetState(setter, debugIn) {
5646
5643
  return (0, import_react3.useCallback)(function(next) {
5647
- var wrap = transition ? import_react3.startTransition : callImmediate;
5648
- wrap(function() {
5649
- setter(function(prev) {
5650
- return mergeIfNotShallowEqual(prev, next, onlyAllow, debugIn);
5651
- });
5644
+ setter(function(prev) {
5645
+ return mergeIfNotShallowEqual(prev, next, debugIn);
5652
5646
  });
5653
5647
  }, [
5654
5648
  setter,
5655
- onlyAllow ? onlyAllow.join("") : "",
5656
- transition,
5657
5649
  debugIn
5658
5650
  ]);
5659
5651
  }
5660
- function mergeIfNotShallowEqual(prev, next, onlyAllow, debug) {
5661
- if (onlyAllow) {
5662
- var allowed = {};
5663
- for (var key in next) onlyAllow.includes(key) && (allowed[key] = next[key]);
5664
- next = allowed;
5665
- }
5652
+ function mergeIfNotShallowEqual(prev, next, debug) {
5666
5653
  return !prev || !next || isEqualShallow2(prev, next) ? prev || next : {
5667
5654
  ...prev,
5668
5655
  ...next
@@ -5718,7 +5705,7 @@ var require_subscribeToContextGroup_native = __commonJS({
5718
5705
  }
5719
5706
  });
5720
5707
  module2.exports = __toCommonJS2(subscribeToContextGroup_exports);
5721
- var import_useMedia = require_useMedia_native(), import_createShallowSetState = require_createShallowSetState_native(), subscribeToContextGroup = function(param) {
5708
+ var import_useMedia = require_useMedia_native(), import_useCreateShallowSetState = require_useCreateShallowSetState_native(), subscribeToContextGroup = function(param) {
5722
5709
  var { setStateShallow, pseudoGroups, mediaGroups, componentContext, state } = param;
5723
5710
  if (pseudoGroups || mediaGroups) {
5724
5711
  var _componentContext_groups_subscribe, _componentContext_groups;
@@ -5729,7 +5716,7 @@ var require_subscribeToContextGroup_native = __commonJS({
5729
5716
  };
5730
5717
  if (pseudo && pseudoGroups != null && pseudoGroups.has(String(name))) Object.assign(current.pseudo, pseudo), persist();
5731
5718
  else if (layout && mediaGroups) {
5732
- var mediaState2 = (0, import_useMedia.getMediaState)(mediaGroups, layout), next = (0, import_createShallowSetState.mergeIfNotShallowEqual)(current.media, mediaState2);
5719
+ var mediaState2 = (0, import_useMedia.getMediaState)(mediaGroups, layout), next = (0, import_useCreateShallowSetState.mergeIfNotShallowEqual)(current.media || {}, mediaState2);
5733
5720
  next !== current.media && (Object.assign(current.media, next), persist());
5734
5721
  }
5735
5722
  function persist() {
@@ -6640,10 +6627,15 @@ var require_index_native6 = __commonJS({
6640
6627
  },
6641
6628
  useDidFinishSSR: function() {
6642
6629
  return useDidFinishSSR;
6630
+ },
6631
+ useIsClientOnly: function() {
6632
+ return useIsClientOnly;
6643
6633
  }
6644
6634
  });
6645
6635
  module2.exports = __toCommonJS2(index_exports2);
6646
- var React3 = __toESM2(require("react")), import_ClientOnly = require_ClientOnly_native(), import_ClientOnly2 = require_ClientOnly_native();
6636
+ var React3 = __toESM2(require("react")), import_ClientOnly = require_ClientOnly_native(), import_ClientOnly2 = require_ClientOnly_native(), useIsClientOnly = function() {
6637
+ return React3.useContext(import_ClientOnly.ClientOnlyContext);
6638
+ };
6647
6639
  function useDidFinishSSR(value) {
6648
6640
  var clientOnly = React3.useContext(import_ClientOnly.ClientOnlyContext);
6649
6641
  return value ?? !0;
@@ -6698,10 +6690,12 @@ var require_useComponentState_native = __commonJS({
6698
6690
  }
6699
6691
  });
6700
6692
  module2.exports = __toCommonJS2(useComponentState_exports);
6701
- 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) {
6702
- 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);
6693
+ 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) {
6694
+ 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);
6703
6695
  stateRef.current || (stateRef.current = {});
6704
- var hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver == null ? void 0 : animationDriver.supportsCSSVars, curStateRef = stateRef.current, willBeAnimatedClient = function() {
6696
+ var hasAnimationProp = !!("animation" in props || props.style && hasAnimatedStyleValue(props.style)), supportsCSSVars = animationDriver == null ? void 0 : animationDriver.supportsCSSVars, curStateRef = stateRef.current;
6697
+ !needsHydration && hasAnimationProp && (curStateRef.hasAnimated = !0);
6698
+ var willBeAnimatedClient = function() {
6705
6699
  var next = !!(hasAnimationProp && !staticConfig.isHOC && useAnimations);
6706
6700
  return !!(next || curStateRef.hasAnimated);
6707
6701
  }(), willBeAnimated = !import_constants2.isServer && willBeAnimatedClient;
@@ -6721,23 +6715,19 @@ var require_useComponentState_native = __commonJS({
6721
6715
  ...states[0],
6722
6716
  [props.forceStyle]: !0
6723
6717
  } : states[0], setState = states[1], isAnimated = willBeAnimated;
6724
- 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({
6725
- ...state
6718
+ 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(_) {
6719
+ return {
6720
+ ...state
6721
+ };
6726
6722
  }));
6727
- var groupName = props.group, setStateShallow = (0, import_createShallowSetState.createShallowSetState)(
6728
- setState,
6729
- void 0,
6730
- // note: allows all state updates even when disabled for the enterStyle animation to work
6731
- !1,
6732
- props.debug
6733
- );
6723
+ var groupName = props.group, setStateShallow = (0, import_useCreateShallowSetState.useCreateShallowSetState)(setState, props.debug);
6734
6724
  if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
6735
6725
  var { enterVariant, exitVariant, enterExitVariant, custom } = presenceState;
6736
6726
  (0, import_isObj.isObj)(custom) && Object.assign(props, custom);
6737
6727
  var exv = exitVariant ?? enterExitVariant, env = enterVariant ?? enterExitVariant;
6738
6728
  state.unmounted && env && staticConfig.variants[env] ? props[env] = !0 : isExiting && exv && (props[exv] = exitVariant !== enterExitVariant);
6739
6729
  }
6740
- var noClass = !import_constants2.isWeb || !!props.forceStyle;
6730
+ var noClass = !import_constants2.isWeb || !!props.forceStyle || isAnimated && (animationDriver == null ? void 0 : animationDriver.needsWebStyles);
6741
6731
  if (import_constants2.isWeb && (!import_constants2.isServer || isHydrated)) {
6742
6732
  var isAnimatedAndHydrated = isAnimated && !supportsCSSVars, isClassNameDisabled = !staticConfig.acceptsClassName && (config.disableSSR || !state.unmounted), isDisabledManually = disableClassName && !state.unmounted;
6743
6733
  (isAnimatedAndHydrated || isDisabledManually || isClassNameDisabled) && (noClass = !0);
@@ -6762,6 +6752,26 @@ var require_useComponentState_native = __commonJS({
6762
6752
  }
6763
6753
  };
6764
6754
  }
6755
+ if (!curStateRef.stateEmitter && hasAnimationProp) {
6756
+ var listeners1 = /* @__PURE__ */ new Set();
6757
+ curStateRef.stateEmitter = {
6758
+ listeners: listeners1,
6759
+ emit(state2) {
6760
+ listeners1.forEach(function(l) {
6761
+ return l(state2);
6762
+ });
6763
+ },
6764
+ subscribe(cb) {
6765
+ return listeners1.add(cb), setStateShallow({
6766
+ hasDynGroupChildren: !0
6767
+ }), function() {
6768
+ listeners1.delete(cb), listeners1.size === 0 && setStateShallow({
6769
+ hasDynGroupChildren: !1
6770
+ });
6771
+ };
6772
+ }
6773
+ };
6774
+ }
6765
6775
  return {
6766
6776
  startedUnhydrated,
6767
6777
  curStateRef,
@@ -7075,8 +7085,12 @@ var require_createComponent_native = __commonJS({
7075
7085
  ...styledContextProps
7076
7086
  } : defaultProps, props = propsIn;
7077
7087
  curDefaultProps && (props = (0, import_mergeProps.mergeProps)(curDefaultProps, propsIn));
7078
- var componentName2 = props.componentName || staticConfig.componentName, 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), 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;
7079
- animationDriver && isAnimated && (elementType = animationDriver[isText ? "Text" : "View"] || elementType);
7088
+ var componentName2 = props.componentName || staticConfig.componentName, 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, 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;
7089
+ animationDriver && isAnimated && // this should really be behind another prop as it's not really related to
7090
+ // "needsWebStyles" basically with motion we just animate a plain div, but
7091
+ // we still have animated.View/Text for Sheet which wants to control
7092
+ // things declaratively
7093
+ !animationDriver.needsWebStyles && (elementType = animationDriver[isText ? "Text" : "View"] || elementType);
7080
7094
  var disableThemeProp = !1, disableTheme = disableThemeProp || isHOC;
7081
7095
  props.themeShallow && (curStateRef.themeShallow = !0);
7082
7096
  var themeStateProps = {
@@ -7105,8 +7119,28 @@ var require_createComponent_native = __commonJS({
7105
7119
  isExiting,
7106
7120
  isAnimated,
7107
7121
  willBeAnimated,
7108
- styledContextProps
7122
+ styledContextProps,
7123
+ noMergeStyle: isAnimated && (animationDriver == null ? void 0 : animationDriver.needsWebStyles)
7109
7124
  }, themeName = (themeState == null ? void 0 : themeState.name) || "", splitStyles = (0, import_getSplitStyles.useSplitStyles)(props, staticConfig, theme, themeName, state, styleProps, null, componentContext, elementType, startedUnhydrated, debugProp);
7125
+ if (hasAnimationProp && animationDriver != null && animationDriver.avoidReRenders) {
7126
+ var styleListener = stateRef.current.useStyleListener, ogSetStateShallow = setStateShallow;
7127
+ setStateShallow = function(next) {
7128
+ var avoidReRenderKeys = /* @__PURE__ */ new Set([
7129
+ "hover",
7130
+ "press",
7131
+ "pressIn"
7132
+ ]), canAvoidReRender = Object.keys(next).every(function(key3) {
7133
+ return avoidReRenderKeys.has(key3);
7134
+ });
7135
+ if (canAvoidReRender) {
7136
+ var updatedState = {
7137
+ ...state,
7138
+ ...next
7139
+ }, nextStyles = (0, import_getSplitStyles.getSplitStyles)(props, staticConfig, theme, themeName, updatedState, styleProps, null, componentContext, elementType, startedUnhydrated, debugProp);
7140
+ styleListener(nextStyles.style);
7141
+ } else ogSetStateShallow(next);
7142
+ };
7143
+ }
7110
7144
  if (props.group && props.untilMeasured === "hide" && !curStateRef.hasMeasured) {
7111
7145
  var _splitStyles;
7112
7146
  (_splitStyles = splitStyles).style || (_splitStyles.style = {}), splitStyles.style.opacity = 0;
@@ -7145,10 +7179,15 @@ var require_createComponent_native = __commonJS({
7145
7179
  (supportsCSSVars ? willBeAnimatedClient : willBeAnimated) && useAnimations && !isHOC
7146
7180
  );
7147
7181
  if (shouldUseAnimation) {
7148
- var animations = useAnimations({
7182
+ var useStyleEmitter = animationDriver != null && animationDriver.avoidReRenders ? function(listener) {
7183
+ stateRef.current.useStyleListener = listener;
7184
+ } : void 0, animations = useAnimations({
7149
7185
  props: propsWithAnimation,
7150
7186
  // if hydrating, send empty style
7151
7187
  style: splitStylesStyle || {},
7188
+ // @ts-ignore
7189
+ styleState: splitStyles,
7190
+ useStyleEmitter,
7152
7191
  presence,
7153
7192
  componentState: state,
7154
7193
  styleProps,
@@ -10124,7 +10163,7 @@ var require_index_native8 = __commonJS({
10124
10163
  __reExport2(index_exports2, require_withStableStyle_native(), module2.exports);
10125
10164
  __reExport2(index_exports2, require_createMediaStyle_native(), module2.exports);
10126
10165
  __reExport2(index_exports2, require_getShorthandValue_native(), module2.exports);
10127
- __reExport2(index_exports2, require_createShallowSetState_native(), module2.exports);
10166
+ __reExport2(index_exports2, require_useCreateShallowSetState_native(), module2.exports);
10128
10167
  __reExport2(index_exports2, require_createStyledContext_native(), module2.exports);
10129
10168
  __reExport2(index_exports2, require_expandStyles_native(), module2.exports);
10130
10169
  __reExport2(index_exports2, require_getExpandedShorthands_native(), module2.exports);