tamagui 1.82.1 → 1.82.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.
@@ -3319,7 +3319,7 @@ var require_getSplitStyles_native = __commonJS({
3319
3319
  };
3320
3320
  for (let keyOg in props) {
3321
3321
  let keyInit = keyOg, valInit = props[keyOg];
3322
- if (styleProps.disableExpandShorthands || keyInit in shorthands && (keyInit = shorthands[keyInit]), keyInit === "className" || keyInit in usedKeys || keyInit in skipProps && !isHOC)
3322
+ if (styleProps.disableExpandShorthands || keyInit in shorthands && (keyInit = shorthands[keyInit]), keyInit === "className" || keyInit in usedKeys || keyInit in skipProps && !styleProps.noSkip && !isHOC)
3323
3323
  continue;
3324
3324
  let valInitType = typeof valInit, isValidStyleKeyInit = isValidStyleKey(keyInit, staticConfig);
3325
3325
  if (styleState.curProps[keyInit] = valInit, !import_constants4.isAndroid && keyInit === "elevationAndroid")
@@ -3789,7 +3789,7 @@ var require_ThemeManager_native = __commonJS({
3789
3789
  module2.exports = __toCommonJS2(ThemeManager_exports);
3790
3790
  var import_constants4 = require_index_native(), import_config = require_config_native(), import_constants22 = require_constants_native2(), emptyState = { name: "" };
3791
3791
  function getHasThemeUpdatingProps(props) {
3792
- return props.name || props.componentName || props.inverse || props.reset;
3792
+ return !!(props.name || props.componentName || props.inverse || props.reset);
3793
3793
  }
3794
3794
  var uid = 0, ThemeManager = class {
3795
3795
  constructor(props = {}, parentManager) {
@@ -3859,7 +3859,7 @@ var require_ThemeManager_native = __commonJS({
3859
3859
  let nextName = props.reset ? baseName : props.name || "", allComponentThemes = componentManagers.map((x) => (x == null ? void 0 : x.state.name) || "");
3860
3860
  isDirectParentAComponentTheme && allComponentThemes.shift();
3861
3861
  let base = baseName.split(import_constants22.THEME_NAME_SEPARATOR), max2 = base.length, min2 = props.componentName && !nextName ? max2 : 0;
3862
- typeof props.debug == "string" && typeof window < "u" && (console.groupCollapsed("ThemeManager.getState()"), console.info({ props, baseName, base, min: min2, max: max2 }));
3862
+ props.debug && typeof window < "u" && (console.groupCollapsed("ThemeManager.getState()"), console.info({ props, baseName, base, min: min2, max: max2 }));
3863
3863
  for (let i = max2; i >= min2; i--) {
3864
3864
  let prefix = base.slice(0, i).join(import_constants22.THEME_NAME_SEPARATOR);
3865
3865
  props.inverse && (prefix = inverseThemeName(prefix));
@@ -3869,16 +3869,18 @@ var require_ThemeManager_native = __commonJS({
3869
3869
  lastSegment > 0 && potentials.splice(lastSegment, 0, nextName);
3870
3870
  }
3871
3871
  if (componentName && !props.reset) {
3872
- let componentPotentials = [];
3873
- if (nextName) {
3874
- let beforeSeparator = prefix.slice(0, prefix.indexOf(import_constants22.THEME_NAME_SEPARATOR));
3872
+ let baseLen = base.length, componentPotentials = [];
3873
+ if (nextName && baseLen > 1) {
3874
+ let beforeSeparator = base[0];
3875
3875
  componentPotentials.push(`${beforeSeparator}_${nextName}_${componentName}`);
3876
3876
  }
3877
3877
  if (componentPotentials.push(`${prefix}_${componentName}`), nextName) {
3878
- let prefixLessOne = base.slice(0, i - 1).join(import_constants22.THEME_NAME_SEPARATOR);
3879
- if (prefixLessOne) {
3880
- let lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`;
3881
- componentPotentials.unshift(lessSpecific);
3878
+ if (i > baseLen) {
3879
+ let prefixLessOne = base.slice(0, i - 1).join(import_constants22.THEME_NAME_SEPARATOR);
3880
+ if (prefixLessOne) {
3881
+ let lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`;
3882
+ componentPotentials.unshift(lessSpecific);
3883
+ }
3882
3884
  }
3883
3885
  let moreSpecific = `${prefix}_${nextName}_${componentName}`;
3884
3886
  componentPotentials.unshift(moreSpecific);
@@ -3887,6 +3889,7 @@ var require_ThemeManager_native = __commonJS({
3887
3889
  }
3888
3890
  let found = potentials.find((t) => t in themes);
3889
3891
  if (typeof props.debug == "string" && console.info(" getState ", {
3892
+ props,
3890
3893
  found,
3891
3894
  potentials,
3892
3895
  baseManager,
@@ -4116,7 +4119,7 @@ var require_useTheme_native = __commonJS({
4116
4119
  }
4117
4120
  let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse), mounted2 = props.inverse ? isRoot || (prev == null ? void 0 : prev.mounted) : !0;
4118
4121
  state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager));
4119
- let wasInversed = prev == null ? void 0 : prev.inversed, inversed2 = isNewTheme2 && state2.scheme !== (parentManager == null ? void 0 : parentManager.state.scheme) ? !0 : wasInversed ? !1 : null, response = {
4122
+ let wasInversed = prev == null ? void 0 : prev.inversed, inversed2 = isNewTheme2 && state2.scheme !== (parentManager == null ? void 0 : parentManager.state.scheme) ? !0 : wasInversed != null ? !1 : null, response = {
4120
4123
  themeManager: themeManager2,
4121
4124
  isNewTheme: isNewTheme2,
4122
4125
  mounted: mounted2,
@@ -4180,40 +4183,40 @@ var require_Theme_native = __commonJS({
4180
4183
  )), __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), Theme_exports = {};
4181
4184
  __export2(Theme_exports, {
4182
4185
  Theme: () => Theme2,
4183
- useThemedChildren: () => useThemedChildren
4186
+ getThemedChildren: () => getThemedChildren
4184
4187
  });
4185
4188
  module2.exports = __toCommonJS2(Theme_exports);
4186
- var import_constants4 = require_index_native(), import_react2 = __toESM2(require("react")), import_createVariable = require_createVariable_native(), import_ThemeManagerContext = require_ThemeManagerContext_native(), import_useTheme = require_useTheme_native(), import_ThemeDebug = require_ThemeDebug_native(), import_jsx_runtime6 = require("react/jsx-runtime"), Theme2 = (0, import_react2.forwardRef)(function(props, ref) {
4189
+ var import_constants4 = require_index_native(), import_react2 = __toESM2(require("react")), import_createVariable = require_createVariable_native(), import_ThemeManagerContext = require_ThemeManagerContext_native(), import_useTheme = require_useTheme_native(), import_ThemeDebug = require_ThemeDebug_native(), import_jsx_runtime6 = require("react/jsx-runtime"), Theme2 = (0, import_react2.forwardRef)(function({ children, ...props }, ref) {
4187
4190
  if (props.disable)
4188
- return props.children;
4189
- let isRoot = !!props._isRoot, disableDirectChildTheme = props["disable-child-theme"], themeState = (0, import_useTheme.useChangeThemeEffect)(props, isRoot), children = (0, import_react2.useMemo)(() => {
4190
- let children2 = disableDirectChildTheme ? import_react2.Children.map(
4191
- props.children,
4192
- (child) => (0, import_react2.cloneElement)(child, { "data-disable-theme": !0 })
4193
- ) : props.children;
4194
- if (ref)
4195
- try {
4196
- import_react2.default.Children.only(children2), children2 = (0, import_react2.cloneElement)(children2, { ref });
4197
- } catch {
4198
- }
4199
- return children2;
4200
- }, [props.children, disableDirectChildTheme]);
4201
- return useThemedChildren(themeState, children, props, isRoot);
4191
+ return children;
4192
+ let isRoot = !!props._isRoot, themeState = (0, import_useTheme.useChangeThemeEffect)(props, isRoot), finalChildren = props["disable-child-theme"] ? import_react2.Children.map(
4193
+ children,
4194
+ (child) => (0, import_react2.cloneElement)(child, { "data-disable-theme": !0 })
4195
+ ) : children;
4196
+ if (ref)
4197
+ try {
4198
+ import_react2.default.Children.only(finalChildren), finalChildren = (0, import_react2.cloneElement)(finalChildren, { ref });
4199
+ } catch {
4200
+ }
4201
+ return getThemedChildren(themeState, finalChildren, props, isRoot);
4202
4202
  });
4203
4203
  Theme2.displayName = "Theme";
4204
4204
  Theme2.avoidForwardRef = !0;
4205
- function useThemedChildren(themeState, children, props, isRoot = !1, avoidWrap = !1) {
4206
- let { themeManager, isNewTheme } = themeState, { shallow, forceClassName } = props, hasEverThemed = (0, import_react2.useRef)(!1);
4207
- if (isNewTheme && (hasEverThemed.current = !0), !(isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot))
4205
+ function getThemedChildren(themeState, children, props, isRoot = !1) {
4206
+ let { themeManager, isNewTheme } = themeState;
4207
+ if (!themeManager)
4208
+ throw "\u274C";
4209
+ let { shallow, forceClassName } = props, hasEverThemed = (0, import_react2.useRef)(!1), shouldRenderChildrenWithTheme = isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot;
4210
+ if (shouldRenderChildrenWithTheme && (hasEverThemed.current = !0), !shouldRenderChildrenWithTheme)
4208
4211
  return children;
4209
4212
  let next = children;
4210
- shallow && themeManager && (next = import_react2.Children.toArray(children).map((child) => (0, import_react2.isValidElement)(child) ? (0, import_react2.cloneElement)(
4213
+ shallow && (next = import_react2.Children.toArray(children).map((child) => (0, import_react2.isValidElement)(child) ? (0, import_react2.cloneElement)(
4211
4214
  child,
4212
4215
  void 0,
4213
4216
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Theme2, { name: themeManager.state.parentName, children: child.props.children })
4214
4217
  ) : child));
4215
- let elementsWithContext = themeManager ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ThemeManagerContext.ThemeManagerContext.Provider, { value: themeManager, children: next }) : next;
4216
- return forceClassName === !1 ? elementsWithContext : import_constants4.isWeb && !avoidWrap ? wrapThemeElements({
4218
+ let elementsWithContext = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ThemeManagerContext.ThemeManagerContext.Provider, { value: themeManager, children: next });
4219
+ return forceClassName === !1 ? elementsWithContext : import_constants4.isWeb ? wrapThemeElements({
4217
4220
  children: elementsWithContext,
4218
4221
  themeState,
4219
4222
  forceClassName,
@@ -4229,18 +4232,18 @@ var require_Theme_native = __commonJS({
4229
4232
  var _a;
4230
4233
  if (isRoot && forceClassName === !1)
4231
4234
  return children;
4232
- let inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
4233
- if (!themeState.isNewTheme && !requiresExtraWrapper)
4234
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "_dsp_contents is_Theme", children });
4235
- let { className, style } = getThemeClassNameAndStyle(themeState, isRoot), themedChildren = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `${className} _dsp_contents is_Theme`, style, children });
4235
+ let inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName, { className, style } = getThemeClassNameAndStyle(themeState, isRoot), themedChildren = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `${className} _dsp_contents is_Theme`, style, children });
4236
4236
  if (requiresExtraWrapper) {
4237
4237
  let name = ((_a = themeState.state) == null ? void 0 : _a.name) || "", inverseClassName = name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "";
4238
4238
  themedChildren = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `${inverse ? inverseClassName : ""} _dsp_contents`, children: themedChildren });
4239
4239
  }
4240
4240
  return themedChildren;
4241
4241
  }
4242
+ var emptyObj = {};
4242
4243
  function getThemeClassNameAndStyle(themeState, isRoot = !1) {
4243
4244
  var _a, _b;
4245
+ if (!themeState.isNewTheme)
4246
+ return { className: "", style: emptyObj };
4244
4247
  let themeColor = (_a = themeState.state) != null && _a.theme && themeState.isNewTheme ? (0, import_createVariable.variableToString)(themeState.state.theme.color) : "", style = themeColor ? {
4245
4248
  color: themeColor
4246
4249
  } : void 0, className = ((_b = themeState.state) == null ? void 0 : _b.className) || "";
@@ -4266,7 +4269,10 @@ var require_themeable_native = __commonJS({
4266
4269
  themeable: () => themeable3
4267
4270
  });
4268
4271
  module2.exports = __toCommonJS2(themeable_exports);
4269
- var import_react2 = require("react"), import_Theme = require_Theme_native(), import_jsx_runtime6 = require("react/jsx-runtime");
4272
+ var import_react2 = require("react"), import_Theme = require_Theme_native(), import_jsx_runtime6 = (
4273
+ // @ts-expect-error its ok
4274
+ require("react/jsx-runtime")
4275
+ );
4270
4276
  function themeable3(Component, staticConfig) {
4271
4277
  let withTheme = (0, import_react2.forwardRef)(function(props, ref) {
4272
4278
  let { themeInverse, theme, componentName, themeReset, ...rest } = props, element = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component, { ref, ...rest, "data-disable-theme": !0 });
@@ -4493,7 +4499,7 @@ var require_createComponent_native = __commonJS({
4493
4499
  isEntering && enterVariant ? props[enterVariant] = !0 : isExiting2 && exitVariant && (props[exitVariant] = !enterExitVariant);
4494
4500
  }
4495
4501
  }
4496
- let isAnimatedReactNative = hasAnimationProp && (animationsConfig == null ? void 0 : animationsConfig.isReactNative), isReactNative = !!(staticConfig.isReactNative || isAnimatedReactNative), shouldAvoidClasses = !!(!import_constants4.isWeb || isAnimated || !staticConfig.acceptsClassName || propsIn.disableClassName), shouldForcePseudo = !!propsIn.forceStyle, noClassNames = shouldAvoidClasses || shouldForcePseudo, disableThemeProp = !1, disableTheme = disableThemeProp && !willBeAnimated || isHOC;
4502
+ let isAnimatedReactNative = hasAnimationProp && (animationsConfig == null ? void 0 : animationsConfig.isReactNative), isReactNative = !!(staticConfig.isReactNative || isAnimatedReactNative), shouldAvoidClasses = !!(!import_constants4.isWeb || isAnimated || !staticConfig.acceptsClassName || propsIn.disableClassName), shouldForcePseudo = !!propsIn.forceStyle, noClassNames = shouldAvoidClasses || shouldForcePseudo, disableTheme = isHOC;
4497
4503
  props.themeShallow && (stateRef.current.themeShallow = !0);
4498
4504
  let themeStateProps = {
4499
4505
  name: props.theme,
@@ -4740,7 +4746,7 @@ var require_createComponent_native = __commonJS({
4740
4746
  subscribe: groupState.subscribe
4741
4747
  };
4742
4748
  }, [groupName]);
4743
- if (groupName && subGroupContext && (content = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ComponentContext.ComponentContext.Provider, { ...componentContext, groups: subGroupContext, children: content })), content = disableThemeProp ? content : (0, import_Theme.useThemedChildren)(themeState, content, themeStateProps, !1), staticConfig.context) {
4749
+ if (groupName && subGroupContext && (content = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ComponentContext.ComponentContext.Provider, { ...componentContext, groups: subGroupContext, children: content })), content = disableTheme ? content : (0, import_Theme.getThemedChildren)(themeState, content, themeStateProps, !1), staticConfig.context) {
4744
4750
  let contextProps = staticConfig.context.props;
4745
4751
  for (let key in contextProps)
4746
4752
  (key in style || key in viewProps) && (overriddenContextProps ||= {}, overriddenContextProps[key] = style[key] ?? viewProps[key]);
@@ -14993,7 +14999,7 @@ var require_Popover_native = __commonJS({
14993
14999
  context,
14994
15000
  children: props.children
14995
15001
  }
14996
- )), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_portal2.Portal, { zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_core13.Theme, { name: themeName, children: [
15002
+ )), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_portal2.Portal, { zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_core13.Theme, { forceClassName: !0, name: themeName, children: [
14997
15003
  !!context.open && !context.breakpointActive && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
14998
15004
  import_stacks3.YStack,
14999
15005
  {
@@ -17474,107 +17480,112 @@ var require_createSwitch_native = __commonJS({
17474
17480
  ref: forwardedRef
17475
17481
  }
17476
17482
  );
17477
- }), SwitchComponent = Frame.styleable(function(propsIn, forwardedRef) {
17478
- let styledContext = React2.useContext(import_SwitchContext.SwitchContext), props = (0, import_core13.useProps)(propsIn, {
17479
- noNormalize: !0,
17480
- noExpand: !0,
17481
- resolveValues: "none",
17482
- forComponent: Frame
17483
- }), {
17484
- labeledBy: ariaLabelledby,
17485
- name,
17486
- checked: checkedProp,
17487
- defaultChecked,
17488
- required,
17489
- disabled,
17490
- value = "on",
17491
- onCheckedChange,
17492
- size: size2 = styledContext.size ?? "$true",
17493
- unstyled = styledContext.unstyled ?? !1,
17494
- native: nativeProp,
17495
- nativeProps,
17496
- children,
17497
- ...switchProps
17498
- } = props, native = Array.isArray(nativeProp) ? nativeProp : [nativeProp], shouldRenderMobileNative = !import_constants4.isWeb && nativeProp === !0 || !import_constants4.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_constants4.isWeb ? button ? !!button.closest("form") : !0 : !1, [frameWidth, setFrameWidth] = React2.useState(0), [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
17499
- prop: checkedProp,
17500
- defaultProp: defaultChecked || !1,
17501
- onChange: onCheckedChange,
17502
- transition: !0
17503
- });
17504
- if (shouldRenderMobileNative)
17505
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17506
- import_react_native4.Switch,
17507
- {
17508
- value: checkedProp,
17509
- onValueChange: onCheckedChange,
17510
- ...nativeProps
17511
- }
17512
- );
17513
- import_constants4.isWeb || React2.useEffect(() => {
17514
- if (props.id)
17515
- return (0, import_focusable2.registerFocusable)(props.id, {
17516
- focus: () => {
17517
- setChecked((x) => !x);
17483
+ }), SwitchComponent = Frame.styleable(
17484
+ function(propsIn, forwardedRef) {
17485
+ let styledContext = React2.useContext(import_SwitchContext.SwitchContext), props = (0, import_core13.useProps)(propsIn, {
17486
+ noNormalize: !0,
17487
+ noExpand: !0,
17488
+ resolveValues: "none",
17489
+ forComponent: Frame
17490
+ }), {
17491
+ labeledBy: ariaLabelledby,
17492
+ name,
17493
+ checked: checkedProp,
17494
+ defaultChecked,
17495
+ required,
17496
+ disabled,
17497
+ value = "on",
17498
+ onCheckedChange,
17499
+ size: size2 = styledContext.size ?? "$true",
17500
+ unstyled = styledContext.unstyled ?? !1,
17501
+ native: nativeProp,
17502
+ nativeProps,
17503
+ children,
17504
+ ...switchProps
17505
+ } = props, native = Array.isArray(nativeProp) ? nativeProp : [nativeProp], shouldRenderMobileNative = !import_constants4.isWeb && nativeProp === !0 || !import_constants4.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_constants4.isWeb ? button ? !!button.closest("form") : !0 : !1, [frameWidth, setFrameWidth] = React2.useState(0), [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
17506
+ prop: checkedProp,
17507
+ defaultProp: defaultChecked || !1,
17508
+ onChange: onCheckedChange,
17509
+ transition: !0
17510
+ });
17511
+ if (shouldRenderMobileNative)
17512
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17513
+ import_react_native4.Switch,
17514
+ {
17515
+ value: checkedProp,
17516
+ onValueChange: onCheckedChange,
17517
+ ...nativeProps
17518
17518
  }
17519
- });
17520
- }, [props.id, setChecked]);
17521
- let isInsideButton = React2.useContext(import_stacks3.ButtonNestingContext);
17522
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
17523
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_stacks3.ButtonNestingContext.Provider, { value: !0, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17524
- Frame,
17525
- {
17526
- tag: isInsideButton ? "span" : "button",
17527
- unstyled,
17528
- size: size2,
17529
- checked,
17530
- disabled,
17531
- frameWidth,
17532
- themeShallow: !0,
17533
- ...!disableActiveTheme && {
17534
- theme: checked ? "active" : null,
17535
- themeShallow: !0
17536
- },
17537
- role: "switch",
17538
- "aria-checked": checked,
17539
- "aria-labelledby": labelledBy,
17540
- "aria-required": required,
17541
- "data-state": getState(checked),
17542
- "data-disabled": disabled ? "" : void 0,
17543
- tabIndex: disabled ? void 0 : 0,
17544
- value,
17545
- ...switchProps,
17546
- ref: composedRefs,
17547
- onPress: (0, import_helpers.composeEventHandlers)(props.onPress, (event) => {
17548
- setChecked((prevChecked) => !prevChecked), import_constants4.isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
17549
- }),
17550
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17551
- import_stacks3.YStack,
17552
- {
17553
- alignSelf: "stretch",
17554
- flex: 1,
17555
- onLayout: (e) => {
17556
- setFrameWidth(e.nativeEvent.layout.width);
17557
- },
17558
- children: typeof children == "function" ? children(checked) : children
17519
+ );
17520
+ import_constants4.isWeb || React2.useEffect(() => {
17521
+ if (props.id)
17522
+ return (0, import_focusable2.registerFocusable)(props.id, {
17523
+ focus: () => {
17524
+ setChecked((x) => !x);
17559
17525
  }
17560
- )
17561
- }
17562
- ) }),
17563
- import_constants4.isWeb && isFormControl && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17564
- BubbleInput,
17565
- {
17566
- control: button,
17567
- bubbles: !hasConsumerStoppedPropagationRef.current,
17568
- name,
17569
- value,
17570
- checked,
17571
- required,
17572
- disabled,
17573
- style: { transform: "translateX(-100%)" }
17574
- }
17575
- )
17576
- ] });
17577
- }), BubbleInput = (props) => {
17526
+ });
17527
+ }, [props.id, setChecked]);
17528
+ let isInsideButton = React2.useContext(import_stacks3.ButtonNestingContext);
17529
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
17530
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_stacks3.ButtonNestingContext.Provider, { value: !0, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17531
+ Frame,
17532
+ {
17533
+ tag: isInsideButton ? "span" : "button",
17534
+ unstyled,
17535
+ size: size2,
17536
+ checked,
17537
+ disabled,
17538
+ frameWidth,
17539
+ themeShallow: !0,
17540
+ ...!disableActiveTheme && {
17541
+ theme: checked ? "active" : null,
17542
+ themeShallow: !0
17543
+ },
17544
+ role: "switch",
17545
+ "aria-checked": checked,
17546
+ "aria-labelledby": labelledBy,
17547
+ "aria-required": required,
17548
+ "data-state": getState(checked),
17549
+ "data-disabled": disabled ? "" : void 0,
17550
+ tabIndex: disabled ? void 0 : 0,
17551
+ value,
17552
+ ...switchProps,
17553
+ ref: composedRefs,
17554
+ onPress: (0, import_helpers.composeEventHandlers)(props.onPress, (event) => {
17555
+ setChecked((prevChecked) => !prevChecked), import_constants4.isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
17556
+ }),
17557
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17558
+ import_stacks3.YStack,
17559
+ {
17560
+ alignSelf: "stretch",
17561
+ flex: 1,
17562
+ onLayout: (e) => {
17563
+ setFrameWidth(e.nativeEvent.layout.width);
17564
+ },
17565
+ children: typeof children == "function" ? children(checked) : children
17566
+ }
17567
+ )
17568
+ }
17569
+ ) }),
17570
+ import_constants4.isWeb && isFormControl && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17571
+ BubbleInput,
17572
+ {
17573
+ control: button,
17574
+ bubbles: !hasConsumerStoppedPropagationRef.current,
17575
+ name,
17576
+ value,
17577
+ checked,
17578
+ required,
17579
+ disabled,
17580
+ style: { transform: "translateX(-100%)" }
17581
+ }
17582
+ )
17583
+ ] });
17584
+ },
17585
+ {
17586
+ disableTheme: !0
17587
+ }
17588
+ ), BubbleInput = (props) => {
17578
17589
  let { control, checked, bubbles = !0, ...inputProps } = props, ref = React2.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
17579
17590
  return React2.useEffect(() => {
17580
17591
  let input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(