tamagui 2.5.0 → 2.5.2

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.
@@ -1,4 +1,4 @@
1
1
  $ tamagui-build
2
- built tamagui in 1581 ms
2
+ built tamagui in 1153 ms
3
3
  Running afterBuild script...
4
- afterBuild completed in 528 ms
4
+ afterBuild completed in 277 ms
package/dist/native.cjs CHANGED
@@ -15780,9 +15780,13 @@ var init_getSplitStyles_native = __esmMin((() => {
15780
15780
  }
15781
15781
  }
15782
15782
  if (keyInit in skipProps && !noSkip && !isHOC) {
15783
- var _driver_animations;
15784
15783
  if (keyInit === "group");
15785
- if (keyInit === "transition" && typeof valInit === "string" && !(driver === null || driver === void 0 ? void 0 : (_driver_animations = driver.animations) === null || _driver_animations === void 0 ? void 0 : _driver_animations[valInit])) {} else return "continue";
15784
+ if (keyInit === "transition" && typeof valInit === "string") {
15785
+ var _driver_animations;
15786
+ var animationConfig = driver === null || driver === void 0 ? void 0 : (_driver_animations = driver.animations) === null || _driver_animations === void 0 ? void 0 : _driver_animations[valInit];
15787
+ if (animationConfig && (driver === null || driver === void 0 ? void 0 : driver.outputStyle) === "css" && process.env.IS_STATIC === "is_static") valInit = `all ${animationConfig}`;
15788
+ else if (animationConfig) return "continue";
15789
+ } else return "continue";
15786
15790
  }
15787
15791
  var isValidStyleKeyInit = isValidStyleKey(keyInit, validStyles$1, accept);
15788
15792
  if (!isValidStyleKeyInit) {
@@ -17171,7 +17175,7 @@ function createComponent(staticConfig) {
17171
17175
  setMediaShouldUpdate(componentContext, didGetVariableValue() || hasRuntimeMediaKeys || noClass && (splitStyles === null || splitStyles === void 0 ? void 0 : splitStyles.hasMedia) === true, hasRuntimeMediaKeys ? splitStyles.hasMedia : null);
17172
17176
  var { viewProps: viewPropsIn, pseudos, style: splitStylesStyle, classNames, pseudoGroups, mediaGroups } = splitStyles || {};
17173
17177
  var propsWithAnimation = props;
17174
- var _ref5 = viewPropsIn || {}, { asChild, children, themeShallow, spaceDirection: _spaceDirection, onPress, onLongPress, onPressIn, onPressOut, onHoverIn, onHoverOut, onMouseUp, onMouseDown, onMouseEnter, onMouseLeave, onFocus, onBlur, separator, passThrough, forceStyle: _forceStyle, onClick, theme: _themeProp } = _ref5, nonTamaguiProps = _objectWithoutProperties(_ref5, _excluded2$29);
17178
+ var _ref5 = viewPropsIn || {}, { asChild, children, themeShallow, spaceDirection: _spaceDirection, onPress, onLongPress, onPressIn, onPressOut, onHoverIn, onHoverOut, onMouseUp, onMouseDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onDidAnimate, separator, passThrough, forceStyle: _forceStyle, onClick, theme: _themeProp } = _ref5, nonTamaguiProps = _objectWithoutProperties(_ref5, _excluded2$29);
17175
17179
  var viewProps = nonTamaguiProps;
17176
17180
  if (props.forceStyle) viewProps.forceStyle = props.forceStyle;
17177
17181
  if (isHOC) {
@@ -17201,7 +17205,8 @@ function createComponent(staticConfig) {
17201
17205
  themeName,
17202
17206
  pseudos: pseudos || null,
17203
17207
  staticConfig,
17204
- stateRef
17208
+ stateRef,
17209
+ onDidAnimate
17205
17210
  });
17206
17211
  if (animations) {
17207
17212
  if (animations.ref) animatedRef = animations.ref;
@@ -17532,6 +17537,7 @@ var init_createComponent_native = __esmMin((() => {
17532
17537
  "onMouseLeave",
17533
17538
  "onFocus",
17534
17539
  "onBlur",
17540
+ "onDidAnimate",
17535
17541
  "separator",
17536
17542
  "passThrough",
17537
17543
  "forceStyle",
@@ -20312,7 +20318,7 @@ var _excluded$48 = ["type"], _excluded2$26 = [
20312
20318
  "disabled",
20313
20319
  "dir",
20314
20320
  "orientation"
20315
- ], _excluded5$12 = ["__scopeAccordion", "value"], _excluded6$8 = ["__scopeAccordion"], _excluded7$5 = ["__scopeAccordion"], _excluded8$5 = ["__scopeAccordion"], _excluded9$5 = ["children"];
20321
+ ], _excluded5$12 = ["__scopeAccordion", "value"], _excluded6$8 = ["__scopeAccordion"], _excluded7$5 = ["__scopeAccordion"], _excluded8$5 = ["__scopeAccordion", "forceMount"], _excluded9$5 = ["children", "transition"];
20316
20322
  var ACCORDION_NAME = "Accordion";
20317
20323
  var ACCORDION_KEYS = [
20318
20324
  "Home",
@@ -20539,38 +20545,109 @@ var AccordionContentFrame = styledExport(Collapsible.Content, {
20539
20545
  } } },
20540
20546
  defaultVariants: { unstyled: process.env.TAMAGUI_HEADLESS === "1" }
20541
20547
  });
20548
+ var AccordionHeightAnimatorContext = /* @__PURE__ */ react$1.createContext(false);
20542
20549
  var AccordionContent = AccordionContentFrame.styleable(function AccordionContent2(props, forwardedRef) {
20543
- var { __scopeAccordion } = props, contentProps = _objectWithoutProperties(props, _excluded8$5);
20550
+ var { __scopeAccordion, forceMount } = props, contentProps = _objectWithoutProperties(props, _excluded8$5);
20544
20551
  var accordionContext = useAccordionContext(__scopeAccordion);
20552
+ var itemContext = useAccordionItemContext(__scopeAccordion);
20553
+ var heightAnimatorPresent = react$1.useContext(AccordionHeightAnimatorContext);
20545
20554
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccordionContentFrame, _objectSpread2(_objectSpread2({
20546
20555
  role: "region",
20547
- "aria-labelledby": useAccordionItemContext(__scopeAccordion).triggerId,
20556
+ "aria-labelledby": itemContext.triggerId,
20548
20557
  "data-orientation": accordionContext.orientation,
20549
20558
  __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT
20550
- }, contentProps), {}, { ref: forwardedRef }));
20559
+ }, contentProps), {}, {
20560
+ forceMount: forceMount || heightAnimatorPresent,
20561
+ ref: forwardedRef
20562
+ }));
20551
20563
  });
20552
20564
  var HeightAnimator = View.styleable(function(props, ref) {
20553
20565
  var itemContext = useAccordionItemContext();
20554
- var { children } = props, rest = _objectWithoutProperties(props, _excluded9$5);
20555
- var [measuredHeight, setMeasuredHeight] = react$1.useState(0);
20556
- var hasMeasured = measuredHeight > 0;
20557
- var height = itemContext.open ? hasMeasured ? measuredHeight : "auto" : 0;
20558
- var shouldAbsolutePosition = hasMeasured || !itemContext.open;
20566
+ var { children, transition } = props, rest = _objectWithoutProperties(props, _excluded9$5);
20567
+ var open = !!itemContext.open;
20568
+ var [fixed, setFixed] = react$1.useState(!open);
20569
+ var [pinned, setPinned] = react$1.useState(false);
20570
+ var [contentPresent, setContentPresent] = react$1.useState(open);
20571
+ var [contentHeight, setContentHeight] = react$1.useState(0);
20572
+ var outerRef = react$1.useRef(null);
20573
+ var innerRef = react$1.useRef(null);
20574
+ var composedRef = useComposedRefs(outerRef, ref);
20575
+ var lastOuterHeightRef = react$1.useRef(0);
20576
+ var pinnedHeightRef = react$1.useRef(0);
20577
+ var settleTimerRef = react$1.useRef(void 0);
20578
+ var prevOpenRef = react$1.useRef(open);
20579
+ if (prevOpenRef.current !== open) {
20580
+ prevOpenRef.current = open;
20581
+ clearTimeout(settleTimerRef.current);
20582
+ if (open) setContentPresent(true);
20583
+ else if (lastOuterHeightRef.current < 1) setContentPresent(false);
20584
+ if (!fixed) {
20585
+ pinnedHeightRef.current = lastOuterHeightRef.current;
20586
+ setFixed(true);
20587
+ setPinned(true);
20588
+ }
20589
+ }
20590
+ useIsomorphicLayoutEffect(function() {
20591
+ if (!pinned) return;
20592
+ var frame = requestAnimationFrame(function() {
20593
+ return setPinned(false);
20594
+ });
20595
+ return function() {
20596
+ return cancelAnimationFrame(frame);
20597
+ };
20598
+ }, [pinned]);
20599
+ react$1.useEffect(function() {
20600
+ return function() {
20601
+ return clearTimeout(settleTimerRef.current);
20602
+ };
20603
+ }, []);
20604
+ useIsomorphicLayoutEffect(function() {
20605
+ var _el_getBoundingClientRect;
20606
+ if (!fixed || !open) return;
20607
+ var el = innerRef.current;
20608
+ var naturalHeight = el === null || el === void 0 ? void 0 : (_el_getBoundingClientRect = el.getBoundingClientRect) === null || _el_getBoundingClientRect === void 0 ? void 0 : _el_getBoundingClientRect.call(el).height;
20609
+ if (naturalHeight && naturalHeight > 0 && naturalHeight !== contentHeight) setContentHeight(naturalHeight);
20610
+ });
20611
+ var minHeight = pinned ? pinnedHeightRef.current : open ? contentHeight : 0;
20559
20612
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, _objectSpread2(_objectSpread2({
20560
- ref,
20561
- height,
20613
+ ref: composedRef,
20562
20614
  position: "relative"
20563
- }, rest), {}, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
20564
- position: shouldAbsolutePosition ? "absolute" : "relative",
20565
- top: shouldAbsolutePosition ? 0 : void 0,
20566
- left: shouldAbsolutePosition ? 0 : void 0,
20567
- right: shouldAbsolutePosition ? 0 : void 0,
20615
+ }, rest), {}, {
20616
+ transition: fixed ? transition : void 0,
20617
+ height: "auto",
20618
+ minHeight,
20619
+ overflow: "hidden",
20568
20620
  onLayout: function(param) {
20569
20621
  var { nativeEvent } = param;
20570
- if (nativeEvent.layout.height && nativeEvent.layout.height !== measuredHeight) setMeasuredHeight(nativeEvent.layout.height);
20622
+ var outerHeight = nativeEvent.layout.height;
20623
+ lastOuterHeightRef.current = outerHeight;
20624
+ clearTimeout(settleTimerRef.current);
20625
+ if (fixed && !pinned && open && contentHeight > 0) {
20626
+ if (Math.abs(outerHeight - contentHeight) < 1) settleTimerRef.current = setTimeout(function() {
20627
+ return setFixed(false);
20628
+ }, 100);
20629
+ }
20571
20630
  },
20572
- children
20573
- }) }));
20631
+ onDidAnimate: function() {
20632
+ if (!prevOpenRef.current && !pinned) setContentPresent(false);
20633
+ },
20634
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
20635
+ ref: innerRef,
20636
+ position: fixed ? "absolute" : "relative",
20637
+ top: fixed ? 0 : void 0,
20638
+ left: fixed ? 0 : void 0,
20639
+ right: fixed ? 0 : void 0,
20640
+ onLayout: function(param) {
20641
+ var { nativeEvent } = param;
20642
+ var naturalHeight = nativeEvent.layout.height;
20643
+ if (open && naturalHeight !== contentHeight) setContentHeight(naturalHeight);
20644
+ },
20645
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccordionHeightAnimatorContext.Provider, {
20646
+ value: contentPresent,
20647
+ children
20648
+ })
20649
+ })
20650
+ }));
20574
20651
  });
20575
20652
  function getState$4(open) {
20576
20653
  return open ? "open" : "closed";
@@ -21985,6 +22062,7 @@ init_objectWithoutProperties();
21985
22062
  init_objectSpread2();
21986
22063
  var _excluded$41 = [
21987
22064
  "src",
22065
+ "source",
21988
22066
  "width",
21989
22067
  "height",
21990
22068
  "borderRadius",
@@ -22011,8 +22089,13 @@ var defaultObjectFitMap = function(objectFit) {
22011
22089
  };
22012
22090
  var defaultTransformSource = function(props) {
22013
22091
  var { src, source, width, height } = props;
22014
- if (source) return source;
22015
- if (src && typeof src !== "string") return src;
22092
+ if (typeof src === "string") return {
22093
+ uri: src,
22094
+ width,
22095
+ height
22096
+ };
22097
+ if (source !== void 0 && source !== null) return source;
22098
+ if (src !== void 0 && src !== null) return src;
22016
22099
  return {
22017
22100
  uri: src,
22018
22101
  width,
@@ -22021,7 +22104,7 @@ var defaultTransformSource = function(props) {
22021
22104
  };
22022
22105
  function createImage(options) {
22023
22106
  var { Component, mapObjectFitToResizeMode = defaultObjectFitMap, resizeModePropName = "resizeMode", objectPositionPropName, transformSource = defaultTransformSource } = options;
22024
- var ImageComponent = styledExport(Component, { name: "Image" }, { inlineProps: /* @__PURE__ */ new Set([
22107
+ var StyledImage = styledExport(Component, { name: "Image" }, { inlineProps: /* @__PURE__ */ new Set([
22025
22108
  "source",
22026
22109
  "placeholder",
22027
22110
  "transition",
@@ -22038,13 +22121,15 @@ function createImage(options) {
22038
22121
  "onLoadStart",
22039
22122
  "onProgress",
22040
22123
  "onLoadEnd"
22041
- ]) }).styleable(function(incomingProps, ref) {
22124
+ ]) });
22125
+ var ImageComponent = StyledImage.styleable(function(incomingProps, ref) {
22042
22126
  var props = incomingProps;
22043
- var { src, width, height, borderRadius, objectFit, objectPosition, decoding, elementTiming, fetchpriority, isMap, loading, sizes, useMap, onLoad, onError } = props, rest = _objectWithoutProperties(props, _excluded$41);
22127
+ var { src, source, width, height, borderRadius, objectFit, objectPosition, decoding, elementTiming, fetchpriority, isMap, loading, sizes, useMap, onLoad, onError } = props, rest = _objectWithoutProperties(props, _excluded$41);
22044
22128
  var resolvedWidth = typeof width === "string" && width[0] === "$" ? getTokenValue(width, "size") : width;
22045
22129
  var resolvedHeight = typeof height === "string" && height[0] === "$" ? getTokenValue(height, "size") : height;
22046
22130
  var finalSource = transformSource({
22047
22131
  src,
22132
+ source,
22048
22133
  width: resolvedWidth,
22049
22134
  height: resolvedHeight
22050
22135
  });
@@ -22058,11 +22143,11 @@ function createImage(options) {
22058
22143
  if (objectPositionPropName && objectPosition) finalProps[objectPositionPropName] = objectPosition;
22059
22144
  if (onLoad) finalProps.onLoad = function(e) {
22060
22145
  var _e_nativeEvent;
22061
- var source = (e === null || e === void 0 ? void 0 : (_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.source) || (e === null || e === void 0 ? void 0 : e.source) || {};
22146
+ var source2 = (e === null || e === void 0 ? void 0 : (_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.source) || (e === null || e === void 0 ? void 0 : e.source) || {};
22062
22147
  onLoad({
22063
22148
  target: {
22064
- naturalHeight: source === null || source === void 0 ? void 0 : source.height,
22065
- naturalWidth: source === null || source === void 0 ? void 0 : source.width
22149
+ naturalHeight: source2 === null || source2 === void 0 ? void 0 : source2.height,
22150
+ naturalWidth: source2 === null || source2 === void 0 ? void 0 : source2.width
22066
22151
  },
22067
22152
  type: "load"
22068
22153
  });
@@ -22070,7 +22155,7 @@ function createImage(options) {
22070
22155
  if (onError) finalProps.onError = function() {
22071
22156
  onError({ type: "error" });
22072
22157
  };
22073
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, _objectSpread2({ ref }, finalProps));
22158
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledImage, _objectSpread2({ ref }, finalProps));
22074
22159
  });
22075
22160
  var comp = Component;
22076
22161
  ImageComponent.getSize = comp.getSize || function() {};
@@ -32319,10 +32404,10 @@ var Toggle = /* @__PURE__ */ react$1.forwardRef(function Toggle2(props, forwarde
32319
32404
  "data-state": active ? "on" : "off",
32320
32405
  "data-disabled": props.disabled ? "" : void 0,
32321
32406
  unstyled
32322
- }, active && !activeStyle && !unstyled && { defaultActiveStyle: true }), active && activeStyle && _objectSpread2(_objectSpread2({}, activeStyle), {}, {
32407
+ }, active && !activeStyle && !unstyled && { defaultActiveStyle: true }), buttonProps), active && activeStyle && _objectSpread2(_objectSpread2({}, activeStyle), {}, {
32323
32408
  hoverStyle: activeStyle,
32324
32409
  focusStyle: activeStyle
32325
- })), buttonProps), {}, {
32410
+ })), {}, {
32326
32411
  ref: forwardedRef,
32327
32412
  onPress: composeEventHandlers((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function() {
32328
32413
  if (!props.disabled) setActive(function(prev) {
package/dist/test.cjs CHANGED
@@ -15960,9 +15960,13 @@ var init_getSplitStyles_native = __esmMin((() => {
15960
15960
  }
15961
15961
  }
15962
15962
  if (keyInit in skipProps && !noSkip && !isHOC) {
15963
- var _driver_animations;
15964
15963
  if (keyInit === "group");
15965
- if (keyInit === "transition" && typeof valInit === "string" && !(driver === null || driver === void 0 ? void 0 : (_driver_animations = driver.animations) === null || _driver_animations === void 0 ? void 0 : _driver_animations[valInit])) {} else return "continue";
15964
+ if (keyInit === "transition" && typeof valInit === "string") {
15965
+ var _driver_animations;
15966
+ var animationConfig = driver === null || driver === void 0 ? void 0 : (_driver_animations = driver.animations) === null || _driver_animations === void 0 ? void 0 : _driver_animations[valInit];
15967
+ if (animationConfig && (driver === null || driver === void 0 ? void 0 : driver.outputStyle) === "css" && process.env.IS_STATIC === "is_static") valInit = `all ${animationConfig}`;
15968
+ else if (animationConfig) return "continue";
15969
+ } else return "continue";
15966
15970
  }
15967
15971
  var isValidStyleKeyInit = isValidStyleKey(keyInit, validStyles$1, accept);
15968
15972
  if (!isValidStyleKeyInit) {
@@ -17357,7 +17361,7 @@ function createComponent(staticConfig) {
17357
17361
  setMediaShouldUpdate(componentContext, didGetVariableValue() || hasRuntimeMediaKeys || noClass && (splitStyles === null || splitStyles === void 0 ? void 0 : splitStyles.hasMedia) === true, hasRuntimeMediaKeys ? splitStyles.hasMedia : null);
17358
17362
  var { viewProps: viewPropsIn, pseudos, style: splitStylesStyle, classNames, pseudoGroups, mediaGroups } = splitStyles || {};
17359
17363
  var propsWithAnimation = props;
17360
- var _ref5 = viewPropsIn || {}, { asChild, children, themeShallow, spaceDirection: _spaceDirection, onPress, onLongPress, onPressIn, onPressOut, onHoverIn, onHoverOut, onMouseUp, onMouseDown, onMouseEnter, onMouseLeave, onFocus, onBlur, separator, passThrough, forceStyle: _forceStyle, onClick, theme: _themeProp } = _ref5, nonTamaguiProps = _objectWithoutProperties(_ref5, _excluded2$29);
17364
+ var _ref5 = viewPropsIn || {}, { asChild, children, themeShallow, spaceDirection: _spaceDirection, onPress, onLongPress, onPressIn, onPressOut, onHoverIn, onHoverOut, onMouseUp, onMouseDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onDidAnimate, separator, passThrough, forceStyle: _forceStyle, onClick, theme: _themeProp } = _ref5, nonTamaguiProps = _objectWithoutProperties(_ref5, _excluded2$29);
17361
17365
  var viewProps = nonTamaguiProps;
17362
17366
  if (props.forceStyle) viewProps.forceStyle = props.forceStyle;
17363
17367
  if (isHOC) {
@@ -17387,7 +17391,8 @@ function createComponent(staticConfig) {
17387
17391
  themeName,
17388
17392
  pseudos: pseudos || null,
17389
17393
  staticConfig,
17390
- stateRef
17394
+ stateRef,
17395
+ onDidAnimate
17391
17396
  });
17392
17397
  if (animations) {
17393
17398
  if (animations.ref) animatedRef = animations.ref;
@@ -17718,6 +17723,7 @@ var init_createComponent_native = __esmMin((() => {
17718
17723
  "onMouseLeave",
17719
17724
  "onFocus",
17720
17725
  "onBlur",
17726
+ "onDidAnimate",
17721
17727
  "separator",
17722
17728
  "passThrough",
17723
17729
  "forceStyle",
@@ -20379,7 +20385,7 @@ var _excluded$48 = ["type"], _excluded2$26 = [
20379
20385
  "disabled",
20380
20386
  "dir",
20381
20387
  "orientation"
20382
- ], _excluded5$12 = ["__scopeAccordion", "value"], _excluded6$8 = ["__scopeAccordion"], _excluded7$5 = ["__scopeAccordion"], _excluded8$5 = ["__scopeAccordion"], _excluded9$5 = ["children"];
20388
+ ], _excluded5$12 = ["__scopeAccordion", "value"], _excluded6$8 = ["__scopeAccordion"], _excluded7$5 = ["__scopeAccordion"], _excluded8$5 = ["__scopeAccordion", "forceMount"], _excluded9$5 = ["children", "transition"];
20383
20389
  var ACCORDION_NAME = "Accordion";
20384
20390
  var ACCORDION_KEYS = [
20385
20391
  "Home",
@@ -20606,38 +20612,109 @@ var AccordionContentFrame = styledExport(Collapsible.Content, {
20606
20612
  } } },
20607
20613
  defaultVariants: { unstyled: process.env.TAMAGUI_HEADLESS === "1" }
20608
20614
  });
20615
+ var AccordionHeightAnimatorContext = /* @__PURE__ */ react$1.createContext(false);
20609
20616
  var AccordionContent = AccordionContentFrame.styleable(function AccordionContent2(props, forwardedRef) {
20610
- var { __scopeAccordion } = props, contentProps = _objectWithoutProperties(props, _excluded8$5);
20617
+ var { __scopeAccordion, forceMount } = props, contentProps = _objectWithoutProperties(props, _excluded8$5);
20611
20618
  var accordionContext = useAccordionContext(__scopeAccordion);
20619
+ var itemContext = useAccordionItemContext(__scopeAccordion);
20620
+ var heightAnimatorPresent = react$1.useContext(AccordionHeightAnimatorContext);
20612
20621
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccordionContentFrame, _objectSpread2(_objectSpread2({
20613
20622
  role: "region",
20614
- "aria-labelledby": useAccordionItemContext(__scopeAccordion).triggerId,
20623
+ "aria-labelledby": itemContext.triggerId,
20615
20624
  "data-orientation": accordionContext.orientation,
20616
20625
  __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT
20617
- }, contentProps), {}, { ref: forwardedRef }));
20626
+ }, contentProps), {}, {
20627
+ forceMount: forceMount || heightAnimatorPresent,
20628
+ ref: forwardedRef
20629
+ }));
20618
20630
  });
20619
20631
  var HeightAnimator = View.styleable(function(props, ref) {
20620
20632
  var itemContext = useAccordionItemContext();
20621
- var { children } = props, rest = _objectWithoutProperties(props, _excluded9$5);
20622
- var [measuredHeight, setMeasuredHeight] = react$1.useState(0);
20623
- var hasMeasured = measuredHeight > 0;
20624
- var height = itemContext.open ? hasMeasured ? measuredHeight : "auto" : 0;
20625
- var shouldAbsolutePosition = hasMeasured || !itemContext.open;
20633
+ var { children, transition } = props, rest = _objectWithoutProperties(props, _excluded9$5);
20634
+ var open = !!itemContext.open;
20635
+ var [fixed, setFixed] = react$1.useState(!open);
20636
+ var [pinned, setPinned] = react$1.useState(false);
20637
+ var [contentPresent, setContentPresent] = react$1.useState(open);
20638
+ var [contentHeight, setContentHeight] = react$1.useState(0);
20639
+ var outerRef = react$1.useRef(null);
20640
+ var innerRef = react$1.useRef(null);
20641
+ var composedRef = useComposedRefs(outerRef, ref);
20642
+ var lastOuterHeightRef = react$1.useRef(0);
20643
+ var pinnedHeightRef = react$1.useRef(0);
20644
+ var settleTimerRef = react$1.useRef(void 0);
20645
+ var prevOpenRef = react$1.useRef(open);
20646
+ if (prevOpenRef.current !== open) {
20647
+ prevOpenRef.current = open;
20648
+ clearTimeout(settleTimerRef.current);
20649
+ if (open) setContentPresent(true);
20650
+ else if (lastOuterHeightRef.current < 1) setContentPresent(false);
20651
+ if (!fixed) {
20652
+ pinnedHeightRef.current = lastOuterHeightRef.current;
20653
+ setFixed(true);
20654
+ setPinned(true);
20655
+ }
20656
+ }
20657
+ useIsomorphicLayoutEffect(function() {
20658
+ if (!pinned) return;
20659
+ var frame = requestAnimationFrame(function() {
20660
+ return setPinned(false);
20661
+ });
20662
+ return function() {
20663
+ return cancelAnimationFrame(frame);
20664
+ };
20665
+ }, [pinned]);
20666
+ react$1.useEffect(function() {
20667
+ return function() {
20668
+ return clearTimeout(settleTimerRef.current);
20669
+ };
20670
+ }, []);
20671
+ useIsomorphicLayoutEffect(function() {
20672
+ var _el_getBoundingClientRect;
20673
+ if (!fixed || !open) return;
20674
+ var el = innerRef.current;
20675
+ var naturalHeight = el === null || el === void 0 ? void 0 : (_el_getBoundingClientRect = el.getBoundingClientRect) === null || _el_getBoundingClientRect === void 0 ? void 0 : _el_getBoundingClientRect.call(el).height;
20676
+ if (naturalHeight && naturalHeight > 0 && naturalHeight !== contentHeight) setContentHeight(naturalHeight);
20677
+ });
20678
+ var minHeight = pinned ? pinnedHeightRef.current : open ? contentHeight : 0;
20626
20679
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, _objectSpread2(_objectSpread2({
20627
- ref,
20628
- height,
20680
+ ref: composedRef,
20629
20681
  position: "relative"
20630
- }, rest), {}, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
20631
- position: shouldAbsolutePosition ? "absolute" : "relative",
20632
- top: shouldAbsolutePosition ? 0 : void 0,
20633
- left: shouldAbsolutePosition ? 0 : void 0,
20634
- right: shouldAbsolutePosition ? 0 : void 0,
20682
+ }, rest), {}, {
20683
+ transition: fixed ? transition : void 0,
20684
+ height: "auto",
20685
+ minHeight,
20686
+ overflow: "hidden",
20635
20687
  onLayout: function(param) {
20636
20688
  var { nativeEvent } = param;
20637
- if (nativeEvent.layout.height && nativeEvent.layout.height !== measuredHeight) setMeasuredHeight(nativeEvent.layout.height);
20689
+ var outerHeight = nativeEvent.layout.height;
20690
+ lastOuterHeightRef.current = outerHeight;
20691
+ clearTimeout(settleTimerRef.current);
20692
+ if (fixed && !pinned && open && contentHeight > 0) {
20693
+ if (Math.abs(outerHeight - contentHeight) < 1) settleTimerRef.current = setTimeout(function() {
20694
+ return setFixed(false);
20695
+ }, 100);
20696
+ }
20638
20697
  },
20639
- children
20640
- }) }));
20698
+ onDidAnimate: function() {
20699
+ if (!prevOpenRef.current && !pinned) setContentPresent(false);
20700
+ },
20701
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
20702
+ ref: innerRef,
20703
+ position: fixed ? "absolute" : "relative",
20704
+ top: fixed ? 0 : void 0,
20705
+ left: fixed ? 0 : void 0,
20706
+ right: fixed ? 0 : void 0,
20707
+ onLayout: function(param) {
20708
+ var { nativeEvent } = param;
20709
+ var naturalHeight = nativeEvent.layout.height;
20710
+ if (open && naturalHeight !== contentHeight) setContentHeight(naturalHeight);
20711
+ },
20712
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccordionHeightAnimatorContext.Provider, {
20713
+ value: contentPresent,
20714
+ children
20715
+ })
20716
+ })
20717
+ }));
20641
20718
  });
20642
20719
  function getState$4(open) {
20643
20720
  return open ? "open" : "closed";
@@ -22052,6 +22129,7 @@ init_objectWithoutProperties();
22052
22129
  init_objectSpread2();
22053
22130
  var _excluded$41 = [
22054
22131
  "src",
22132
+ "source",
22055
22133
  "width",
22056
22134
  "height",
22057
22135
  "borderRadius",
@@ -22078,8 +22156,13 @@ var defaultObjectFitMap = function(objectFit) {
22078
22156
  };
22079
22157
  var defaultTransformSource = function(props) {
22080
22158
  var { src, source, width, height } = props;
22081
- if (source) return source;
22082
- if (src && typeof src !== "string") return src;
22159
+ if (typeof src === "string") return {
22160
+ uri: src,
22161
+ width,
22162
+ height
22163
+ };
22164
+ if (source !== void 0 && source !== null) return source;
22165
+ if (src !== void 0 && src !== null) return src;
22083
22166
  return {
22084
22167
  uri: src,
22085
22168
  width,
@@ -22088,7 +22171,7 @@ var defaultTransformSource = function(props) {
22088
22171
  };
22089
22172
  function createImage(options) {
22090
22173
  var { Component, mapObjectFitToResizeMode = defaultObjectFitMap, resizeModePropName = "resizeMode", objectPositionPropName, transformSource = defaultTransformSource } = options;
22091
- var ImageComponent = styledExport(Component, { name: "Image" }, { inlineProps: /* @__PURE__ */ new Set([
22174
+ var StyledImage = styledExport(Component, { name: "Image" }, { inlineProps: /* @__PURE__ */ new Set([
22092
22175
  "source",
22093
22176
  "placeholder",
22094
22177
  "transition",
@@ -22105,13 +22188,15 @@ function createImage(options) {
22105
22188
  "onLoadStart",
22106
22189
  "onProgress",
22107
22190
  "onLoadEnd"
22108
- ]) }).styleable(function(incomingProps, ref) {
22191
+ ]) });
22192
+ var ImageComponent = StyledImage.styleable(function(incomingProps, ref) {
22109
22193
  var props = incomingProps;
22110
- var { src, width, height, borderRadius, objectFit, objectPosition, decoding, elementTiming, fetchpriority, isMap, loading, sizes, useMap, onLoad, onError } = props, rest = _objectWithoutProperties(props, _excluded$41);
22194
+ var { src, source, width, height, borderRadius, objectFit, objectPosition, decoding, elementTiming, fetchpriority, isMap, loading, sizes, useMap, onLoad, onError } = props, rest = _objectWithoutProperties(props, _excluded$41);
22111
22195
  var resolvedWidth = typeof width === "string" && width[0] === "$" ? getTokenValue(width, "size") : width;
22112
22196
  var resolvedHeight = typeof height === "string" && height[0] === "$" ? getTokenValue(height, "size") : height;
22113
22197
  var finalSource = transformSource({
22114
22198
  src,
22199
+ source,
22115
22200
  width: resolvedWidth,
22116
22201
  height: resolvedHeight
22117
22202
  });
@@ -22125,11 +22210,11 @@ function createImage(options) {
22125
22210
  if (objectPositionPropName && objectPosition) finalProps[objectPositionPropName] = objectPosition;
22126
22211
  if (onLoad) finalProps.onLoad = function(e) {
22127
22212
  var _e_nativeEvent;
22128
- var source = (e === null || e === void 0 ? void 0 : (_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.source) || (e === null || e === void 0 ? void 0 : e.source) || {};
22213
+ var source2 = (e === null || e === void 0 ? void 0 : (_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.source) || (e === null || e === void 0 ? void 0 : e.source) || {};
22129
22214
  onLoad({
22130
22215
  target: {
22131
- naturalHeight: source === null || source === void 0 ? void 0 : source.height,
22132
- naturalWidth: source === null || source === void 0 ? void 0 : source.width
22216
+ naturalHeight: source2 === null || source2 === void 0 ? void 0 : source2.height,
22217
+ naturalWidth: source2 === null || source2 === void 0 ? void 0 : source2.width
22133
22218
  },
22134
22219
  type: "load"
22135
22220
  });
@@ -22137,7 +22222,7 @@ function createImage(options) {
22137
22222
  if (onError) finalProps.onError = function() {
22138
22223
  onError({ type: "error" });
22139
22224
  };
22140
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, _objectSpread2({ ref }, finalProps));
22225
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledImage, _objectSpread2({ ref }, finalProps));
22141
22226
  });
22142
22227
  var comp = Component;
22143
22228
  ImageComponent.getSize = comp.getSize || function() {};
@@ -32386,10 +32471,10 @@ var Toggle = /* @__PURE__ */ react$1.forwardRef(function Toggle2(props, forwarde
32386
32471
  "data-state": active ? "on" : "off",
32387
32472
  "data-disabled": props.disabled ? "" : void 0,
32388
32473
  unstyled
32389
- }, active && !activeStyle && !unstyled && { defaultActiveStyle: true }), active && activeStyle && _objectSpread2(_objectSpread2({}, activeStyle), {}, {
32474
+ }, active && !activeStyle && !unstyled && { defaultActiveStyle: true }), buttonProps), active && activeStyle && _objectSpread2(_objectSpread2({}, activeStyle), {}, {
32390
32475
  hoverStyle: activeStyle,
32391
32476
  focusStyle: activeStyle
32392
- })), buttonProps), {}, {
32477
+ })), {}, {
32393
32478
  ref: forwardedRef,
32394
32479
  onPress: composeEventHandlers((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function() {
32395
32480
  if (!props.disabled) setActive(function(prev) {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tamagui",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "description": "Style and UI for React (web and native) meet an optimizing compiler",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/tamagui/tamagui.git",
8
+ "url": "git+https://github.com/tamagui/tamagui.git",
9
9
  "directory": "code/ui/tamagui"
10
10
  },
11
11
  "source": "src/index.ts",
@@ -77,72 +77,72 @@
77
77
  "check-circular-deps": "npx madge --circular ./src/index.ts"
78
78
  },
79
79
  "dependencies": {
80
- "@tamagui/accordion": "2.5.0",
81
- "@tamagui/adapt": "2.5.0",
82
- "@tamagui/alert-dialog": "2.5.0",
83
- "@tamagui/animate": "2.5.0",
84
- "@tamagui/animate-presence": "2.5.0",
85
- "@tamagui/avatar": "2.5.0",
86
- "@tamagui/button": "2.5.0",
87
- "@tamagui/card": "2.5.0",
88
- "@tamagui/checkbox": "2.5.0",
89
- "@tamagui/collapsible": "2.5.0",
90
- "@tamagui/compose-refs": "2.5.0",
91
- "@tamagui/constants": "2.5.0",
92
- "@tamagui/context-menu": "2.5.0",
93
- "@tamagui/core": "2.5.0",
94
- "@tamagui/create-context": "2.5.0",
95
- "@tamagui/create-menu": "2.5.0",
96
- "@tamagui/dialog": "2.5.0",
97
- "@tamagui/element": "2.5.0",
98
- "@tamagui/elements": "2.5.0",
99
- "@tamagui/fake-react-native": "2.5.0",
100
- "@tamagui/focusable": "2.5.0",
101
- "@tamagui/form": "2.5.0",
102
- "@tamagui/get-button-sized": "2.5.0",
103
- "@tamagui/get-font-sized": "2.5.0",
104
- "@tamagui/get-token": "2.5.0",
105
- "@tamagui/group": "2.5.0",
106
- "@tamagui/helpers-tamagui": "2.5.0",
107
- "@tamagui/image": "2.5.0",
108
- "@tamagui/input": "2.5.0",
109
- "@tamagui/label": "2.5.0",
110
- "@tamagui/linear-gradient": "2.5.0",
111
- "@tamagui/list-item": "2.5.0",
112
- "@tamagui/menu": "2.5.0",
113
- "@tamagui/polyfill-dev": "2.5.0",
114
- "@tamagui/popover": "2.5.0",
115
- "@tamagui/popper": "2.5.0",
116
- "@tamagui/portal": "2.5.0",
117
- "@tamagui/progress": "2.5.0",
118
- "@tamagui/radio-group": "2.5.0",
119
- "@tamagui/react-native-media-driver": "2.5.0",
120
- "@tamagui/scroll-view": "2.5.0",
121
- "@tamagui/select": "2.5.0",
122
- "@tamagui/separator": "2.5.0",
123
- "@tamagui/shapes": "2.5.0",
124
- "@tamagui/sheet": "2.5.0",
125
- "@tamagui/slider": "2.5.0",
126
- "@tamagui/spacer": "2.5.0",
127
- "@tamagui/spinner": "2.5.0",
128
- "@tamagui/stacks": "2.5.0",
129
- "@tamagui/switch": "2.5.0",
130
- "@tamagui/tabs": "2.5.0",
131
- "@tamagui/text": "2.5.0",
132
- "@tamagui/theme": "2.5.0",
133
- "@tamagui/toast": "2.5.0",
134
- "@tamagui/toggle-group": "2.5.0",
135
- "@tamagui/tooltip": "2.5.0",
136
- "@tamagui/use-controllable-state": "2.5.0",
137
- "@tamagui/use-debounce": "2.5.0",
138
- "@tamagui/use-force-update": "2.5.0",
139
- "@tamagui/use-window-dimensions": "2.5.0",
140
- "@tamagui/visually-hidden": "2.5.0",
141
- "@tamagui/font-size": "2.5.0",
142
- "@tamagui/z-index-stack": "2.5.0"
80
+ "@tamagui/accordion": "2.5.2",
81
+ "@tamagui/adapt": "2.5.2",
82
+ "@tamagui/alert-dialog": "2.5.2",
83
+ "@tamagui/animate": "2.5.2",
84
+ "@tamagui/animate-presence": "2.5.2",
85
+ "@tamagui/avatar": "2.5.2",
86
+ "@tamagui/button": "2.5.2",
87
+ "@tamagui/card": "2.5.2",
88
+ "@tamagui/checkbox": "2.5.2",
89
+ "@tamagui/collapsible": "2.5.2",
90
+ "@tamagui/compose-refs": "2.5.2",
91
+ "@tamagui/constants": "2.5.2",
92
+ "@tamagui/context-menu": "2.5.2",
93
+ "@tamagui/core": "2.5.2",
94
+ "@tamagui/create-context": "2.5.2",
95
+ "@tamagui/create-menu": "2.5.2",
96
+ "@tamagui/dialog": "2.5.2",
97
+ "@tamagui/element": "2.5.2",
98
+ "@tamagui/elements": "2.5.2",
99
+ "@tamagui/fake-react-native": "2.5.2",
100
+ "@tamagui/focusable": "2.5.2",
101
+ "@tamagui/form": "2.5.2",
102
+ "@tamagui/get-button-sized": "2.5.2",
103
+ "@tamagui/get-font-sized": "2.5.2",
104
+ "@tamagui/get-token": "2.5.2",
105
+ "@tamagui/group": "2.5.2",
106
+ "@tamagui/helpers-tamagui": "2.5.2",
107
+ "@tamagui/image": "2.5.2",
108
+ "@tamagui/input": "2.5.2",
109
+ "@tamagui/label": "2.5.2",
110
+ "@tamagui/linear-gradient": "2.5.2",
111
+ "@tamagui/list-item": "2.5.2",
112
+ "@tamagui/menu": "2.5.2",
113
+ "@tamagui/polyfill-dev": "2.5.2",
114
+ "@tamagui/popover": "2.5.2",
115
+ "@tamagui/popper": "2.5.2",
116
+ "@tamagui/portal": "2.5.2",
117
+ "@tamagui/progress": "2.5.2",
118
+ "@tamagui/radio-group": "2.5.2",
119
+ "@tamagui/react-native-media-driver": "2.5.2",
120
+ "@tamagui/scroll-view": "2.5.2",
121
+ "@tamagui/select": "2.5.2",
122
+ "@tamagui/separator": "2.5.2",
123
+ "@tamagui/shapes": "2.5.2",
124
+ "@tamagui/sheet": "2.5.2",
125
+ "@tamagui/slider": "2.5.2",
126
+ "@tamagui/spacer": "2.5.2",
127
+ "@tamagui/spinner": "2.5.2",
128
+ "@tamagui/stacks": "2.5.2",
129
+ "@tamagui/switch": "2.5.2",
130
+ "@tamagui/tabs": "2.5.2",
131
+ "@tamagui/text": "2.5.2",
132
+ "@tamagui/theme": "2.5.2",
133
+ "@tamagui/toast": "2.5.2",
134
+ "@tamagui/toggle-group": "2.5.2",
135
+ "@tamagui/tooltip": "2.5.2",
136
+ "@tamagui/use-controllable-state": "2.5.2",
137
+ "@tamagui/use-debounce": "2.5.2",
138
+ "@tamagui/use-force-update": "2.5.2",
139
+ "@tamagui/use-window-dimensions": "2.5.2",
140
+ "@tamagui/visually-hidden": "2.5.2",
141
+ "@tamagui/font-size": "2.5.2",
142
+ "@tamagui/z-index-stack": "2.5.2"
143
143
  },
144
144
  "devDependencies": {
145
- "@tamagui/build": "2.5.0",
145
+ "@tamagui/build": "2.5.2",
146
146
  "react": ">=19",
147
147
  "react-native": "0.83.2",
148
148
  "react-native-web": "^0.21.0"