tamagui 1.123.16 → 1.123.17-1738816646757

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
@@ -4767,6 +4767,57 @@ var require_defaultComponentState_native = __commonJS({
4767
4767
  }
4768
4768
  });
4769
4769
 
4770
+ // ../../core/web/dist/cjs/helpers/getShorthandValue.native.js
4771
+ var require_getShorthandValue_native = __commonJS({
4772
+ "../../core/web/dist/cjs/helpers/getShorthandValue.native.js"(exports2, module2) {
4773
+ "use strict";
4774
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc2 = Object.getOwnPropertyDescriptor, __getOwnPropNames2 = Object.getOwnPropertyNames, __hasOwnProp2 = Object.prototype.hasOwnProperty, __export2 = function(target, all) {
4775
+ for (var name in all) __defProp2(target, name, {
4776
+ get: all[name],
4777
+ enumerable: !0
4778
+ });
4779
+ }, __copyProps2 = function(to, from, except, desc) {
4780
+ var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
4781
+ if (from && typeof from == "object" || typeof from == "function") try {
4782
+ for (var _loop = function() {
4783
+ var key = _step.value;
4784
+ !__hasOwnProp2.call(to, key) && key !== except && __defProp2(to, key, {
4785
+ get: function() {
4786
+ return from[key];
4787
+ },
4788
+ enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
4789
+ });
4790
+ }, _iterator = __getOwnPropNames2(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) _loop();
4791
+ } catch (err) {
4792
+ _didIteratorError = !0, _iteratorError = err;
4793
+ } finally {
4794
+ try {
4795
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
4796
+ } finally {
4797
+ if (_didIteratorError)
4798
+ throw _iteratorError;
4799
+ }
4800
+ }
4801
+ return to;
4802
+ }, __toCommonJS2 = function(mod) {
4803
+ return __copyProps2(__defProp2({}, "__esModule", {
4804
+ value: !0
4805
+ }), mod);
4806
+ }, getShorthandValue_exports = {};
4807
+ __export2(getShorthandValue_exports, {
4808
+ getShorthandValue: function() {
4809
+ return getShorthandValue;
4810
+ }
4811
+ });
4812
+ module2.exports = __toCommonJS2(getShorthandValue_exports);
4813
+ var import_config = require_config_native(), inverseShorthands = null, getShorthandValue = function(props, key) {
4814
+ inverseShorthands || (inverseShorthands = (0, import_config.getConfig)().inverseShorthands);
4815
+ var _props_key;
4816
+ return (_props_key = props[key]) !== null && _props_key !== void 0 ? _props_key : inverseShorthands ? props[inverseShorthands[key]] : void 0;
4817
+ };
4818
+ }
4819
+ });
4820
+
4770
4821
  // ../../core/web/dist/cjs/constants/accessibilityDirectMap.native.js
4771
4822
  var require_accessibilityDirectMap_native = __commonJS({
4772
4823
  "../../core/web/dist/cjs/constants/accessibilityDirectMap.native.js"(exports2, module2) {
@@ -8623,7 +8674,7 @@ var require_createComponent_native = __commonJS({
8623
8674
  }
8624
8675
  });
8625
8676
  module2.exports = __toCommonJS2(createComponent_exports);
8626
- var import_jsx_runtime6 = require("react/jsx-runtime"), import_compose_refs = require_index_native12(), import_constants4 = require_index_native6(), import_helpers = require_index_native7(), import_react3 = __toESM2(require("react")), import_config = require_config_native(), import_constants22 = require_constants_native2(), import_isDevTools = require_isDevTools_native(), import_ComponentContext = require_ComponentContext_native(), import_createVariable = require_createVariable_native(), import_defaultComponentState = require_defaultComponentState_native(), import_getSplitStyles = require_getSplitStyles_native(), import_log = require_log_native(), import_mergeProps = require_mergeProps_native(), import_setElementProps = require_setElementProps_native(), import_subscribeToContextGroup = require_subscribeToContextGroup_native(), import_themeable = require_themeable_native(), import_wrapStyleTags = require_wrapStyleTags_native(), import_useComponentState = require_useComponentState_native(), import_useMedia = require_useMedia_native(), import_useTheme = require_useTheme_native(), import_setupHooks = require_setupHooks_native(), import_Slot = require_Slot_native(), import_Theme = require_Theme_native(), import_ThemeDebug = require_ThemeDebug_native(), time2, debugKeyListeners, startVisualizer, componentSetStates = /* @__PURE__ */ new Set();
8677
+ var import_jsx_runtime6 = require("react/jsx-runtime"), import_compose_refs = require_index_native12(), import_constants4 = require_index_native6(), import_helpers = require_index_native7(), import_react3 = __toESM2(require("react")), import_config = require_config_native(), import_constants22 = require_constants_native2(), import_isDevTools = require_isDevTools_native(), import_ComponentContext = require_ComponentContext_native(), import_createVariable = require_createVariable_native(), import_defaultComponentState = require_defaultComponentState_native(), import_getShorthandValue = require_getShorthandValue_native(), import_getSplitStyles = require_getSplitStyles_native(), import_log = require_log_native(), import_mergeProps = require_mergeProps_native(), import_setElementProps = require_setElementProps_native(), import_subscribeToContextGroup = require_subscribeToContextGroup_native(), import_themeable = require_themeable_native(), import_wrapStyleTags = require_wrapStyleTags_native(), import_useComponentState = require_useComponentState_native(), import_useMedia = require_useMedia_native(), import_useTheme = require_useTheme_native(), import_setupHooks = require_setupHooks_native(), import_Slot = require_Slot_native(), import_Theme = require_Theme_native(), import_ThemeDebug = require_ThemeDebug_native(), time2, debugKeyListeners, startVisualizer, componentSetStates = /* @__PURE__ */ new Set();
8627
8678
  typeof document < "u" && (cancelTouches = function() {
8628
8679
  componentSetStates.forEach(function(setState) {
8629
8680
  return setState(function(prev) {
@@ -8702,9 +8753,8 @@ var require_createComponent_native = __commonJS({
8702
8753
  var componentContext = import_react3.default.useContext(import_ComponentContext.ComponentContext), styledContextProps, overriddenContextProps, contextValue, { context, isReactNative } = staticConfig;
8703
8754
  if (context && (contextValue = import_react3.default.useContext(context), contextValue)) {
8704
8755
  process.env.NODE_ENV === "development" && (defaultProps == null ? void 0 : defaultProps.debug) === "verbose" && (0, import_log.log)(" \u{1F447} contextValue", contextValue);
8705
- var shorthands = config == null ? void 0 : config.shorthands;
8706
8756
  for (var key in context.props) {
8707
- var propVal = propsIn[key] || propsIn[shorthands == null ? void 0 : shorthands[propsIn]];
8757
+ var propVal = (0, import_getShorthandValue.getShorthandValue)(propsIn, key);
8708
8758
  if (propVal === void 0) {
8709
8759
  var val = contextValue == null ? void 0 : contextValue[key];
8710
8760
  val !== void 0 && (styledContextProps || (styledContextProps = {}), styledContextProps[key] = val);
@@ -11067,9 +11117,12 @@ var require_useProps_native = __commonJS({
11067
11117
  componentName: staticConfig.componentName,
11068
11118
  name: "theme" in props ? props.theme : void 0,
11069
11119
  inverse: "themeInverse" in props ? props.themeInverse : void 0
11070
- }), componentContext = import_react3.default.useContext(import_ComponentContext.ComponentContext), { state, disabled, setStateShallow } = (0, import_useComponentState.useComponentState)(props, componentContext, staticConfig, (0, import_config.getConfig)()), mediaState3 = (0, import_useMedia.useMedia)(), splitStyles = (0, import_getSplitStyles.useSplitStyles)(props, staticConfig, theme, ((_themeState_state = themeState.state) === null || _themeState_state === void 0 ? void 0 : _themeState_state.name) || "", state, {
11120
+ }), componentContext = import_react3.default.useContext(import_ComponentContext.ComponentContext), { state, disabled, setStateShallow } = (0, import_useComponentState.useComponentState)(props, componentContext, staticConfig, (0, import_config.getConfig)()), mediaStateNow = opts != null && opts.noMedia ? (
11121
+ // not safe to use mediaState but really marginal to hit this
11122
+ import_useMedia.mediaState
11123
+ ) : (0, import_useMedia.useMedia)(), splitStyles = (0, import_getSplitStyles.useSplitStyles)(props, staticConfig, theme, ((_themeState_state = themeState.state) === null || _themeState_state === void 0 ? void 0 : _themeState_state.name) || "", state, {
11071
11124
  isAnimated: !1,
11072
- mediaState: mediaState3,
11125
+ mediaState: mediaStateNow,
11073
11126
  noSkip: !0,
11074
11127
  noMergeStyle: !0,
11075
11128
  noClass: !0,
@@ -11105,7 +11158,7 @@ var require_useProps_native = __commonJS({
11105
11158
  splitStyles.viewProps,
11106
11159
  splitStyles.style || {},
11107
11160
  theme,
11108
- mediaState3
11161
+ import_useMedia.mediaState
11109
11162
  ];
11110
11163
  }
11111
11164
  }
@@ -11672,6 +11725,7 @@ var require_index_native14 = __commonJS({
11672
11725
  __reExport2(index_exports2, require_ComponentContext_native(), module2.exports);
11673
11726
  __reExport2(index_exports2, require_withStableStyle_native(), module2.exports);
11674
11727
  __reExport2(index_exports2, require_createMediaStyle_native(), module2.exports);
11728
+ __reExport2(index_exports2, require_getShorthandValue_native(), module2.exports);
11675
11729
  __reExport2(index_exports2, require_createShallowSetState_native(), module2.exports);
11676
11730
  __reExport2(index_exports2, require_createStyledContext_native(), module2.exports);
11677
11731
  __reExport2(index_exports2, require_expandStyles_native(), module2.exports);
@@ -29673,7 +29727,7 @@ var require_createSwitch_native = __commonJS({
29673
29727
  var { disableActiveTheme, Frame = import_Switch.SwitchFrame, Thumb = import_Switch.SwitchThumb } = createProps;
29674
29728
  process.env.NODE_ENV === "development" && (Frame !== import_Switch.SwitchFrame && Frame.staticConfig.context && Frame.staticConfig.context !== import_StyledContext.SwitchStyledContext || Thumb !== import_Switch.SwitchThumb && Thumb.staticConfig.context && Thumb.staticConfig.context !== import_StyledContext.SwitchStyledContext) && console.warn("Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden."), Frame.staticConfig.context = import_StyledContext.SwitchStyledContext, Thumb.staticConfig.context = import_StyledContext.SwitchStyledContext;
29675
29729
  var SwitchThumbComponent = Thumb.styleable(function(props, forwardedRef) {
29676
- var { size: sizeProp, unstyled: unstyledProp, nativeID, ...thumbProps } = props, context = React4.useContext(SwitchContext), { checked, disabled, frameWidth } = context, styledContext = import_StyledContext.SwitchStyledContext.useStyledContext(), { unstyled: unstyledContext, size: sizeContext } = styledContext, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size4 = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React4.useRef(checked).current, [thumbWidth, setThumbWidth] = React4.useState(0), distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
29730
+ var { size: sizeProp, unstyled: unstyledProp, nativeID, ...thumbProps } = props, context = React4.useContext(SwitchContext), { checked, disabled, frameWidth } = context, styledContext = import_StyledContext.SwitchStyledContext.useStyledContext(), { unstyled: unstyledContext, size: sizeContext } = styledContext, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size4 = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React4.useRef(checked).current, initialWidth = (0, import_core12.getVariableValue)(props.width, "size"), [thumbWidth, setThumbWidth] = React4.useState(typeof initialWidth == "number" ? initialWidth : 0), distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
29677
29731
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Thumb, {
29678
29732
  ref: forwardedRef,
29679
29733
  unstyled,
@@ -29686,7 +29740,8 @@ var require_createSwitch_native = __commonJS({
29686
29740
  alignSelf: initialChecked ? "flex-end" : "flex-start",
29687
29741
  x,
29688
29742
  onLayout: (0, import_core12.composeEventHandlers)(props.onLayout, function(e) {
29689
- return setThumbWidth(e.nativeEvent.layout.width);
29743
+ var next = e.nativeEvent.layout.width;
29744
+ next !== thumbWidth && setThumbWidth(next);
29690
29745
  }),
29691
29746
  // expected variants
29692
29747
  checked,
@@ -29699,7 +29754,12 @@ var require_createSwitch_native = __commonJS({
29699
29754
  defaultProp: defaultChecked || !1,
29700
29755
  onChange: onCheckedChange,
29701
29756
  transition: !0
29702
- }), styledContext = React4.useContext(import_StyledContext.SwitchStyledContext.context), [frameWidth, setFrameWidth] = React4.useState(0), { switchProps, bubbleInput, switchRef } = (0, import_switch_headless.useSwitch)(
29757
+ }), styledContext = React4.useContext(import_StyledContext.SwitchStyledContext.context), estimatedInitialWidth = 0, estWidth = (0, import_core12.getVariableValue)((0, import_core12.getShorthandValue)(props, "width"), "size");
29758
+ if (estWidth) {
29759
+ var _getShorthandValue, _ref, estPad = (_ref = (_getShorthandValue = (0, import_core12.getShorthandValue)(props, "paddingHorizontal")) !== null && _getShorthandValue !== void 0 ? _getShorthandValue : (0, import_core12.getShorthandValue)(props, "padding")) !== null && _ref !== void 0 ? _ref : 0, _getShorthandValue1, _ref1, estLeftPad = (_ref1 = (_getShorthandValue1 = (0, import_core12.getShorthandValue)(props, "paddingLeft")) !== null && _getShorthandValue1 !== void 0 ? _getShorthandValue1 : estPad) !== null && _ref1 !== void 0 ? _ref1 : 0, _getShorthandValue2, _ref2, estRightPad = (_ref2 = (_getShorthandValue2 = (0, import_core12.getShorthandValue)(props, "paddingRight")) !== null && _getShorthandValue2 !== void 0 ? _getShorthandValue2 : estPad) !== null && _ref2 !== void 0 ? _ref2 : 0;
29760
+ estimatedInitialWidth = estWidth - (estLeftPad ? (0, import_core12.getVariableValue)(estLeftPad, "size") : 0) - (estRightPad ? (0, import_core12.getVariableValue)(estRightPad, "size") : 0);
29761
+ }
29762
+ var [frameWidth, setFrameInnerWidth] = React4.useState(estimatedInitialWidth), { switchProps, bubbleInput, switchRef } = (0, import_switch_headless.useSwitch)(
29703
29763
  // @ts-ignore
29704
29764
  props,
29705
29765
  [
@@ -29738,11 +29798,10 @@ var require_createSwitch_native = __commonJS({
29738
29798
  checked,
29739
29799
  disabled,
29740
29800
  frameWidth
29741
- ]), handleLayout = React4.useCallback(function(e) {
29742
- setFrameWidth(e.nativeEvent.layout.width);
29743
- }, [
29744
- setFrameWidth
29745
- ]), _styledContext_unstyled, _ref, unstyled = (_ref = (_styledContext_unstyled = styledContext.unstyled) !== null && _styledContext_unstyled !== void 0 ? _styledContext_unstyled : props.unstyled) !== null && _ref !== void 0 ? _ref : !1, _styledContext_size, _ref1;
29801
+ ]), handleLayout = function(e) {
29802
+ var next = e.nativeEvent.layout.width;
29803
+ next !== frameWidth && setFrameInnerWidth(next);
29804
+ }, _styledContext_unstyled, _ref3, unstyled = (_ref3 = (_styledContext_unstyled = styledContext.unstyled) !== null && _styledContext_unstyled !== void 0 ? _styledContext_unstyled : props.unstyled) !== null && _ref3 !== void 0 ? _ref3 : !1, _styledContext_size, _ref4;
29746
29805
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(SwitchContext.Provider, {
29747
29806
  value,
29748
29807
  children: [
@@ -29753,7 +29812,7 @@ var require_createSwitch_native = __commonJS({
29753
29812
  type: "button"
29754
29813
  },
29755
29814
  ...!unstyled && {
29756
- size: (_ref1 = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref1 !== void 0 ? _ref1 : "$true"
29815
+ size: (_ref4 = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref4 !== void 0 ? _ref4 : "$true"
29757
29816
  },
29758
29817
  unstyled,
29759
29818
  ...props,
@@ -29768,7 +29827,7 @@ var require_createSwitch_native = __commonJS({
29768
29827
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native4.View, {
29769
29828
  style: measureContainerStyle,
29770
29829
  onLayout: handleLayout,
29771
- children: props.children
29830
+ children: frameWidth ? props.children : null
29772
29831
  })
29773
29832
  }),
29774
29833
  bubbleInput