tamagui 1.79.6 → 1.79.8

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
@@ -1261,7 +1261,7 @@ var require_useMedia_native = __commonJS({
1261
1261
  return listeners.add(subscriber), () => listeners.delete(subscriber);
1262
1262
  }
1263
1263
  function useMedia3(uid, componentContext) {
1264
- let internal = (0, import_react2.useRef)(), initialState = ((componentContext ? (0, import_useDisableSSR.getDisableSSR)(componentContext) : (0, import_useDisableSSR.useDisableSSR)()) ? mediaState3 : initState) || {}, state = (0, import_react2.useSyncExternalStore)(
1264
+ let internal = (0, import_react2.useRef)(), initialState = ((componentContext ? (0, import_useDisableSSR.getDisableSSR)(componentContext) : (0, import_useDisableSSR.useDisableSSR)()) || !import_constants.isWeb ? mediaState3 : initState) || {}, state = (0, import_react2.useSyncExternalStore)(
1265
1265
  subscribe,
1266
1266
  () => {
1267
1267
  if (!internal.current)
@@ -3761,7 +3761,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
3761
3761
  if (forceShouldChange || next && !(forceUpdate !== !0 && !manager.getStateShouldChange(next, prevState)))
3762
3762
  return next;
3763
3763
  }
3764
- if (import_constants.isServer || ((0, import_react2.useLayoutEffect)(() => {
3764
+ if (import_constants.isServer || ((0, import_react2.useEffect)(() => {
3765
3765
  if (!themeManager)
3766
3766
  return;
3767
3767
  if (props.inverse && !mounted) {
@@ -3777,7 +3777,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
3777
3777
  }), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(
3778
3778
  (name, manager, forced) => {
3779
3779
  let force = forced || (shouldUpdate == null ? void 0 : shouldUpdate()) || props.deopt || props["disable-child-theme"], shouldTryUpdate = force ?? !!(keys != null && keys.length || isNewTheme);
3780
- process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info(" \u{1F538} onChange", themeManager.id, { force, shouldTryUpdate, props, name, manager, keys }), shouldTryUpdate && setThemeState(createState);
3780
+ process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info(" \u{1F538} onChange", themeManager.id, { force, shouldTryUpdate, props, name, manager, keys }), shouldTryUpdate && setThemeState((prev) => createState(prev, force));
3781
3781
  },
3782
3782
  themeManager.id
3783
3783
  );
@@ -10407,7 +10407,7 @@ var require_SheetScrollView_native = __commonJS({
10407
10407
  });
10408
10408
  module2.exports = __toCommonJS2(SheetScrollView_exports);
10409
10409
  var import_core13 = require_index_native15(), import_scroll_view = require_index_native33(), import_react2 = require("react"), import_SheetContext = require_SheetContext_native(), import_jsx_runtime6 = require("react/jsx-runtime"), SHEET_SCROLL_VIEW_NAME = "SheetScrollView", SheetScrollView = (0, import_react2.forwardRef)(
10410
- ({ __scopeSheet, children, ...props }, ref) => {
10410
+ ({ __scopeSheet, children, onScroll, ...props }, ref) => {
10411
10411
  let context = (0, import_SheetContext.useSheetContext)(SHEET_SCROLL_VIEW_NAME, __scopeSheet), { scrollBridge } = context, scrollRef = (0, import_react2.useRef)(null), state = (0, import_react2.useRef)({
10412
10412
  lastPageY: 0,
10413
10413
  dragAt: 0,
@@ -10437,7 +10437,7 @@ var require_SheetScrollView_native = __commonJS({
10437
10437
  scrollEventThrottle: 8,
10438
10438
  onScroll: (e) => {
10439
10439
  let { y } = e.nativeEvent.contentOffset;
10440
- scrollBridge.y = y, y > 0 && (scrollBridge.scrollStartY = -1);
10440
+ scrollBridge.y = y, y > 0 && (scrollBridge.scrollStartY = -1), onScroll == null || onScroll(e);
10441
10441
  },
10442
10442
  onStartShouldSetResponder: () => (scrollBridge.scrollStartY = -1, state.current.isDragging = !0, !0),
10443
10443
  onMoveShouldSetResponder: () => !1,
@@ -17230,8 +17230,8 @@ var require_SliderImpl_native = __commonJS({
17230
17230
  onStartShouldSetResponder: () => !0,
17231
17231
  onResponderTerminationRequest: () => !1,
17232
17232
  onResponderGrant: (0, import_core13.composeEventHandlers)(props.onResponderGrant, (event) => {
17233
- let target = event.target, isStartingOnThumb = context.thumbs.has(target);
17234
- import_core13.isWeb && target instanceof HTMLElement && context.thumbs.has(target) && target.focus(), onSlideStart(event, isStartingOnThumb ? "thumb" : "track");
17233
+ let target = event.target, thumbIndex = context.thumbs.get(target), isStartingOnThumb = thumbIndex !== void 0;
17234
+ import_core13.isWeb && target instanceof HTMLElement && context.thumbs.has(target) && target.focus(), !import_core13.isWeb && isStartingOnThumb && (context.valueIndexToChangeRef.current = thumbIndex), onSlideStart(event, isStartingOnThumb ? "thumb" : "track");
17235
17235
  }),
17236
17236
  onResponderMove: (0, import_core13.composeEventHandlers)(props.onResponderMove, (event) => {
17237
17237
  event.stopPropagation(), onSlideMove(event);
@@ -17518,10 +17518,10 @@ var require_Slider_native = __commonJS({
17518
17518
  ), value = context.values[index], percent = value === void 0 ? 0 : (0, import_helpers2.convertValueToPercentage)(value, context.min, context.max), label = (0, import_helpers2.getLabel)(index, context.values.length), sizeIn = sizeProp ?? context.size ?? "$true", [size2, setSize] = React2.useState(() => (0, import_core13.getVariableValue)(getThumbSize(sizeIn).width)), thumbInBoundsOffset = size2 ? (0, import_helpers2.getThumbInBoundsOffset)(size2, percent, orientation.direction) : 0;
17519
17519
  React2.useEffect(() => {
17520
17520
  if (thumb)
17521
- return context.thumbs.add(thumb), () => {
17521
+ return context.thumbs.set(thumb, index), () => {
17522
17522
  context.thumbs.delete(thumb);
17523
17523
  };
17524
- }, [thumb, context.thumbs]);
17524
+ }, [thumb, context.thumbs, index]);
17525
17525
  let positionalStyles = context.orientation === "horizontal" ? {
17526
17526
  x: thumbInBoundsOffset - size2 / 2,
17527
17527
  y: -size2 / 2,
@@ -17584,13 +17584,12 @@ var require_Slider_native = __commonJS({
17584
17584
  onSlideMove,
17585
17585
  onSlideStart,
17586
17586
  ...sliderProps
17587
- } = props, sliderRef = React2.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(sliderRef, forwardedRef), thumbRefs = React2.useRef(/* @__PURE__ */ new Set()), valueIndexToChangeRef = React2.useRef(0), isHorizontal = orientation === "horizontal", [values = [], setValues] = (0, import_use_controllable_state.useControllableState)({
17587
+ } = props, sliderRef = React2.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(sliderRef, forwardedRef), thumbRefs = React2.useRef(/* @__PURE__ */ new Map()), valueIndexToChangeRef = React2.useRef(0), isHorizontal = orientation === "horizontal", [values = [], setValues] = (0, import_use_controllable_state.useControllableState)({
17588
17588
  prop: value,
17589
17589
  defaultProp: defaultValue,
17590
17590
  transition: !0,
17591
17591
  onChange: (value2) => {
17592
- var _a;
17593
- import_core13.isWeb && ((_a = [...thumbRefs.current][valueIndexToChangeRef.current]) == null || _a.focus()), onValueChange(value2);
17592
+ updateThumbFocus(valueIndexToChangeRef.current), onValueChange(value2);
17594
17593
  }
17595
17594
  });
17596
17595
  import_core13.isWeb && React2.useEffect(() => {
@@ -17604,6 +17603,15 @@ var require_Slider_native = __commonJS({
17604
17603
  node.removeEventListener("touchstart", preventDefault);
17605
17604
  };
17606
17605
  }, []);
17606
+ function updateThumbFocus(focusIndex) {
17607
+ if (import_core13.isWeb) {
17608
+ for (let [node, index] of thumbRefs.current.entries())
17609
+ if (index === focusIndex) {
17610
+ node.focus();
17611
+ return;
17612
+ }
17613
+ }
17614
+ }
17607
17615
  function handleSlideMove(value2, event) {
17608
17616
  updateValues(value2, valueIndexToChangeRef.current), onSlideMove == null || onSlideMove(event, value2);
17609
17617
  }
@@ -17879,109 +17887,103 @@ var require_createSwitch_native = __commonJS({
17879
17887
  ref: forwardedRef
17880
17888
  }
17881
17889
  );
17882
- }), SwitchComponent = Frame.extractable(
17883
- React2.forwardRef(function(propsIn, forwardedRef) {
17884
- let styledContext = React2.useContext(import_SwitchContext.SwitchContext), props = (0, import_core13.useProps)(propsIn, {
17885
- noNormalize: !0,
17886
- noExpand: !0,
17887
- resolveValues: "none",
17888
- forComponent: Frame
17889
- }), {
17890
- labeledBy: ariaLabelledby,
17891
- name,
17892
- checked: checkedProp,
17893
- defaultChecked,
17894
- required,
17895
- disabled,
17896
- value = "on",
17897
- onCheckedChange,
17898
- size: size2 = styledContext.size ?? "$true",
17899
- unstyled = styledContext.unstyled ?? !1,
17900
- native: nativeProp,
17901
- nativeProps,
17902
- children,
17903
- ...switchProps
17904
- } = props, native = Array.isArray(nativeProp) ? nativeProp : [nativeProp], shouldRenderMobileNative = !import_core13.isWeb && nativeProp === !0 || !import_core13.isWeb && native.includes("mobile") || native.includes("android") && import_react_native4.Platform.OS === "android" || native.includes("ios") && import_react_native4.Platform.OS === "ios", [button, setButton] = React2.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(
17905
- forwardedRef,
17906
- // @ts-expect-error
17907
- setButton
17908
- ), labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId, hasConsumerStoppedPropagationRef = React2.useRef(!1), isFormControl = import_core13.isWeb ? button ? !!button.closest("form") : !0 : !1, [frameWidth, setFrameWidth] = React2.useState(0), [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
17909
- prop: checkedProp,
17910
- defaultProp: defaultChecked || !1,
17911
- onChange: onCheckedChange,
17912
- transition: !0
17913
- });
17914
- return shouldRenderMobileNative ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17915
- import_react_native4.Switch,
17890
+ }), SwitchComponent = Frame.styleable(function(propsIn, forwardedRef) {
17891
+ let styledContext = React2.useContext(import_SwitchContext.SwitchContext), props = (0, import_core13.useProps)(propsIn, {
17892
+ noNormalize: !0,
17893
+ noExpand: !0,
17894
+ resolveValues: "none",
17895
+ forComponent: Frame
17896
+ }), {
17897
+ labeledBy: ariaLabelledby,
17898
+ name,
17899
+ checked: checkedProp,
17900
+ defaultChecked,
17901
+ required,
17902
+ disabled,
17903
+ value = "on",
17904
+ onCheckedChange,
17905
+ size: size2 = styledContext.size ?? "$true",
17906
+ unstyled = styledContext.unstyled ?? !1,
17907
+ native: nativeProp,
17908
+ nativeProps,
17909
+ children,
17910
+ ...switchProps
17911
+ } = props, native = Array.isArray(nativeProp) ? nativeProp : [nativeProp], shouldRenderMobileNative = !import_core13.isWeb && nativeProp === !0 || !import_core13.isWeb && native.includes("mobile") || native.includes("android") && import_react_native4.Platform.OS === "android" || native.includes("ios") && import_react_native4.Platform.OS === "ios", [button, setButton] = React2.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, setButton), labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId, hasConsumerStoppedPropagationRef = React2.useRef(!1), isFormControl = import_core13.isWeb ? button ? !!button.closest("form") : !0 : !1, [frameWidth, setFrameWidth] = React2.useState(0), [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
17912
+ prop: checkedProp,
17913
+ defaultProp: defaultChecked || !1,
17914
+ onChange: onCheckedChange,
17915
+ transition: !0
17916
+ });
17917
+ return shouldRenderMobileNative ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17918
+ import_react_native4.Switch,
17919
+ {
17920
+ value: checkedProp,
17921
+ onValueChange: onCheckedChange,
17922
+ ...nativeProps
17923
+ }
17924
+ ) : (import_core13.isWeb || React2.useEffect(() => {
17925
+ if (props.id)
17926
+ return (0, import_focusable2.registerFocusable)(props.id, {
17927
+ focus: () => {
17928
+ setChecked((x) => !x);
17929
+ }
17930
+ });
17931
+ }, [props.id, setChecked]), /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
17932
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17933
+ Frame,
17916
17934
  {
17917
- value: checkedProp,
17918
- onValueChange: onCheckedChange,
17919
- ...nativeProps
17920
- }
17921
- ) : (import_core13.isWeb || React2.useEffect(() => {
17922
- if (props.id)
17923
- return (0, import_focusable2.registerFocusable)(props.id, {
17924
- focus: () => {
17925
- setChecked((x) => !x);
17935
+ tag: "button",
17936
+ unstyled,
17937
+ size: size2,
17938
+ checked,
17939
+ disabled,
17940
+ frameWidth,
17941
+ themeShallow: !0,
17942
+ ...!disableActiveTheme && {
17943
+ theme: checked ? "active" : null,
17944
+ themeShallow: !0
17945
+ },
17946
+ role: "switch",
17947
+ "aria-checked": checked,
17948
+ "aria-labelledby": labelledBy,
17949
+ "aria-required": required,
17950
+ "data-state": getState(checked),
17951
+ "data-disabled": disabled ? "" : void 0,
17952
+ tabIndex: disabled ? void 0 : 0,
17953
+ value,
17954
+ ...switchProps,
17955
+ ref: composedRefs,
17956
+ onPress: (0, import_core13.composeEventHandlers)(props.onPress, (event) => {
17957
+ setChecked((prevChecked) => !prevChecked), import_core13.isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
17958
+ }),
17959
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17960
+ import_stacks3.YStack,
17961
+ {
17962
+ alignSelf: "stretch",
17963
+ flex: 1,
17964
+ onLayout: (e) => {
17965
+ setFrameWidth(e.nativeEvent.layout.width);
17966
+ },
17967
+ children: typeof children == "function" ? children(checked) : children
17926
17968
  }
17927
- });
17928
- }, [props.id, setChecked]), /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
17929
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17930
- Frame,
17931
- {
17932
- tag: "button",
17933
- unstyled,
17934
- size: size2,
17935
- checked,
17936
- disabled,
17937
- frameWidth,
17938
- themeShallow: !0,
17939
- ...!disableActiveTheme && {
17940
- theme: checked ? "active" : null,
17941
- themeShallow: !0
17942
- },
17943
- role: "switch",
17944
- "aria-checked": checked,
17945
- "aria-labelledby": labelledBy,
17946
- "aria-required": required,
17947
- "data-state": getState(checked),
17948
- "data-disabled": disabled ? "" : void 0,
17949
- tabIndex: disabled ? void 0 : 0,
17950
- value,
17951
- ...switchProps,
17952
- ref: composedRefs,
17953
- onPress: (0, import_core13.composeEventHandlers)(props.onPress, (event) => {
17954
- setChecked((prevChecked) => !prevChecked), import_core13.isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
17955
- }),
17956
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17957
- import_stacks3.YStack,
17958
- {
17959
- alignSelf: "stretch",
17960
- flex: 1,
17961
- onLayout: (e) => {
17962
- setFrameWidth(e.nativeEvent.layout.width);
17963
- },
17964
- children: typeof children == "function" ? children(checked) : children
17965
- }
17966
- )
17967
- }
17968
- ),
17969
- import_core13.isWeb && isFormControl && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17970
- BubbleInput,
17971
- {
17972
- control: button,
17973
- bubbles: !hasConsumerStoppedPropagationRef.current,
17974
- name,
17975
- value,
17976
- checked,
17977
- required,
17978
- disabled,
17979
- style: { transform: "translateX(-100%)" }
17980
- }
17981
- )
17982
- ] }));
17983
- })
17984
- ), BubbleInput = (props) => {
17969
+ )
17970
+ }
17971
+ ),
17972
+ import_core13.isWeb && isFormControl && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17973
+ BubbleInput,
17974
+ {
17975
+ control: button,
17976
+ bubbles: !hasConsumerStoppedPropagationRef.current,
17977
+ name,
17978
+ value,
17979
+ checked,
17980
+ required,
17981
+ disabled,
17982
+ style: { transform: "translateX(-100%)" }
17983
+ }
17984
+ )
17985
+ ] }));
17986
+ }), BubbleInput = (props) => {
17985
17987
  let { control, checked, bubbles = !0, ...inputProps } = props, ref = React2.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
17986
17988
  return React2.useEffect(() => {
17987
17989
  let input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(