tamagui 1.128.1 → 1.129.0

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
@@ -2419,6 +2419,9 @@ var require_createVariable_native = __commonJS({
2419
2419
  isVariable: function() {
2420
2420
  return isVariable2;
2421
2421
  },
2422
+ px: function() {
2423
+ return px;
2424
+ },
2422
2425
  setDidGetVariableValue: function() {
2423
2426
  return setDidGetVariableValue;
2424
2427
  },
@@ -2482,6 +2485,12 @@ var require_createVariable_native = __commonJS({
2482
2485
  var name = (0, import_helpers.simpleHash)(nameProp, 60);
2483
2486
  return includeVar ? constructCSSVariableName(name) : name;
2484
2487
  };
2488
+ function px(value) {
2489
+ return {
2490
+ val: value,
2491
+ needsPx: !0
2492
+ };
2493
+ }
2485
2494
  }
2486
2495
  });
2487
2496
 
@@ -9038,7 +9047,12 @@ If you meant to do this, you can disable this warning - either change untilMeasu
9038
9047
  return Component2.staticConfig = extendStyledConfig(extended), Component2.styleable = styleable, Component2;
9039
9048
  }
9040
9049
  function styleable(Component2, options) {
9041
- var _Component_render, isForwardedRefAlready = ((_Component_render = Component2.render) === null || _Component_render === void 0 ? void 0 : _Component_render.length) === 2, out = isForwardedRefAlready ? Component2 : /* @__PURE__ */ import_react3.default.forwardRef(Component2), extendedConfig = extendStyledConfig(options == null ? void 0 : options.staticConfig);
9050
+ var _Component_render, isForwardedRefAlready = ((_Component_render = Component2.render) === null || _Component_render === void 0 ? void 0 : _Component_render.length) === 2 || Component2.length === 2, out = isForwardedRefAlready ? Component2 : /* @__PURE__ */ import_react3.default.forwardRef(function(props, ref) {
9051
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component2, {
9052
+ ...props,
9053
+ ref
9054
+ });
9055
+ }), extendedConfig = extendStyledConfig(options == null ? void 0 : options.staticConfig);
9042
9056
  return out = options != null && options.disableTheme ? out : (0, import_themeable.themeable)(out, extendedConfig, !0), process.env.TAMAGUI_MEMOIZE_STYLEABLE && (out = /* @__PURE__ */ import_react3.default.memo(out)), out.staticConfig = extendedConfig, out.styleable = styleable, out;
9043
9057
  }
9044
9058
  return res.extractable = extractable, res.styleable = styleable, res;
@@ -9314,7 +9328,7 @@ var require_createVariables_native = __commonJS({
9314
9328
  }
9315
9329
  });
9316
9330
  module2.exports = __toCommonJS2(createVariables_exports);
9317
- var import_helpers = require_index_native7(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
9331
+ var import_constants4 = require_index_native6(), import_helpers = require_index_native7(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
9318
9332
  var parentPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", isFont = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
9319
9333
  if (cache.has(tokens)) return tokens;
9320
9334
  var res = {}, i = 0;
@@ -9326,16 +9340,25 @@ var require_createVariables_native = __commonJS({
9326
9340
  continue;
9327
9341
  }
9328
9342
  var niceKey = (0, import_helpers.simpleHash)(key, 1e3), name = parentPath && parentPath !== "t-color" ? `${parentPath}-${niceKey}` : `c-${niceKey}`;
9343
+ if (val && typeof val == "object" && "needsPx" in val && "val" in val) {
9344
+ var finalValue = (0, import_createVariable.createVariable)({
9345
+ val: val.val,
9346
+ name,
9347
+ key: keyWithPrefix
9348
+ });
9349
+ import_constants4.isWeb && (finalValue.needsPx = val.needsPx), res[key] = finalValue;
9350
+ continue;
9351
+ }
9329
9352
  if (val && typeof val == "object") {
9330
9353
  res[key] = createVariables(tokens[key], name, !1);
9331
9354
  continue;
9332
9355
  }
9333
- var finalValue = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
9356
+ var finalValue1 = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
9334
9357
  val,
9335
9358
  name,
9336
9359
  key: keyWithPrefix
9337
9360
  });
9338
- res[key] = finalValue;
9361
+ res[key] = finalValue1;
9339
9362
  }
9340
9363
  return cache.set(res, !0), res;
9341
9364
  };
@@ -9855,6 +9878,14 @@ var require_createTamagui_native = __commonJS({
9855
9878
  });
9856
9879
  module2.exports = __toCommonJS2(createTamagui_exports);
9857
9880
  var import_constants4 = require_index_native6(), import_config = require_config_native(), import_createVariables = require_createVariables_native(), import_getThemeCSSRules = require_getThemeCSSRules_native(), import_insertStyleRule = require_insertStyleRule_native(), import_proxyThemeToParents = require_proxyThemeToParents_native(), import_registerCSSVariable = require_registerCSSVariable_native(), import_themes = require_themes_native(), import_useMedia = require_useMedia_native(), import_insertFont = require_insertFont_native(), import_Tamagui = require_Tamagui_native(), createdConfigs = /* @__PURE__ */ new WeakMap();
9881
+ function shouldTokenCategoryHaveUnits(category) {
9882
+ var UNIT_CATEGORIES = /* @__PURE__ */ new Set([
9883
+ "size",
9884
+ "space",
9885
+ "radius"
9886
+ ]);
9887
+ return UNIT_CATEGORIES.has(category);
9888
+ }
9858
9889
  function createTamagui2(configIn) {
9859
9890
  var _configIn_settings;
9860
9891
  if (process.env.NODE_ENV === "test" && globalThis.__tamaguiConfig) return console.warn("Warning: You somehow have duplicate Tamagui dependencies, this can cause issues. Tamagui is working around this by loading a previously loaded config in test mode. "), globalThis.__tamaguiConfig;
@@ -9901,7 +9932,11 @@ var require_createTamagui_native = __commonJS({
9901
9932
  var variable = tokens[key2][skey];
9902
9933
  if (specificTokens[`$${key2}.${skey}`] = variable, process.env.NODE_ENV === "development" && typeof variable > "u") throw new Error(`No value for tokens.${key2}.${skey}:
9903
9934
  ${JSON.stringify(variable, null, 2)}`);
9904
- import_constants4.isWeb && ((0, import_registerCSSVariable.registerCSSVariable)(variable), declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, key2 === "zIndex")));
9935
+ if (import_constants4.isWeb) {
9936
+ (0, import_registerCSSVariable.registerCSSVariable)(variable);
9937
+ var variableNeedsPx = variable.needsPx === !0, categoryNeedsPx = shouldTokenCategoryHaveUnits(key2), shouldBeUnitless = !(variableNeedsPx || categoryNeedsPx);
9938
+ declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, shouldBeUnitless));
9939
+ }
9905
9940
  }
9906
9941
  if (0) {
9907
9942
  var declarationsToRuleSet;
@@ -23993,9 +24028,18 @@ var require_Animate_native = __commonJS({
23993
24028
  }
23994
24029
  });
23995
24030
  module2.exports = __toCommonJS2(Animate_exports);
23996
- var import_jsx_runtime6 = require("react/jsx-runtime"), import_animate_presence = require_index_native4();
24031
+ var import_jsx_runtime6 = require("react/jsx-runtime"), import_animate_presence = require_index_native4(), import_react3 = require("react");
23997
24032
  function Animate(param) {
23998
- var { children, type, ...props } = param;
24033
+ var { children, lazyMount, type, present, ...props } = param, [lazyMounted, setLazyMounted] = (0, import_react3.useState)(lazyMount ? !1 : present);
24034
+ (0, import_react3.useEffect)(function() {
24035
+ lazyMount && present && (0, import_react3.startTransition)(function() {
24036
+ setLazyMounted(present);
24037
+ });
24038
+ }, [
24039
+ lazyMount,
24040
+ present
24041
+ ]);
24042
+ var mounted = present ? lazyMount ? lazyMounted : present : !1;
23999
24043
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_animate_presence.PresenceChild, {
24000
24044
  initial: props.initial ? void 0 : !1,
24001
24045
  onExitComplete: props.onExitComplete,
@@ -24005,12 +24049,12 @@ var require_Animate_native = __commonJS({
24005
24049
  // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
24006
24050
  // but since we always re-render this component on open changes this should be fine to leave off?
24007
24051
  presenceAffectsLayout: !1,
24008
- isPresent: props.present,
24052
+ isPresent: present,
24009
24053
  custom: props.custom,
24010
24054
  children
24011
24055
  }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_animate_presence.AnimatePresence, {
24012
24056
  ...props,
24013
- children: props.present ? children : null
24057
+ children: mounted ? children : null
24014
24058
  }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, {
24015
24059
  children
24016
24060
  });
@@ -24458,21 +24502,21 @@ var require_Popper_native = __commonJS({
24458
24502
  x,
24459
24503
  y
24460
24504
  ]);
24461
- var show = !0, frameProps = {
24505
+ var hide2 = x === 0 && y === 0, frameProps = {
24462
24506
  ref: contentRefs,
24463
24507
  x: x || 0,
24464
24508
  y: y || 0,
24465
24509
  top: 0,
24466
24510
  left: 0,
24467
24511
  position: strategy,
24468
- opacity: show ? 1 : 0,
24512
+ opacity: 1,
24469
24513
  ...enableAnimationForPositionChange && {
24470
24514
  // apply animation but disable it on initial render to avoid animating from 0 to the first position
24471
24515
  animation: rest.animation,
24472
24516
  animateOnly: needsMeasure ? [] : rest.animateOnly,
24473
24517
  animatePresence: !1
24474
24518
  },
24475
- ...x === 0 && y === 0 && {
24519
+ ...hide2 && {
24476
24520
  opacity: 0,
24477
24521
  animateOnly: []
24478
24522
  }
@@ -24905,7 +24949,7 @@ var require_Popover_native = __commonJS({
24905
24949
  });
24906
24950
  }
24907
24951
  var PopoverContentImpl = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
24908
- var { trapFocus, __scopePopover, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, disableFocusScope, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, children, disableRemoveScroll, freezeContentsWhenHidden, setIsFullyHidden, ...contentProps } = props, context = usePopoverContext(__scopePopover), { open, keepChildrenMounted } = context, popperContext = (0, import_popper.usePopperContext)(__scopePopover || POPOVER_SCOPE), handleExitComplete = React4.useCallback(function() {
24952
+ var { trapFocus, __scopePopover, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, disableFocusScope, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, children, disableRemoveScroll, freezeContentsWhenHidden, setIsFullyHidden, lazyMount, ...contentProps } = props, context = usePopoverContext(__scopePopover), { open, keepChildrenMounted } = context, popperContext = (0, import_popper.usePopperContext)(__scopePopover || POPOVER_SCOPE), handleExitComplete = React4.useCallback(function() {
24909
24953
  setIsFullyHidden == null || setIsFullyHidden(!0);
24910
24954
  }, [
24911
24955
  setIsFullyHidden
@@ -24923,6 +24967,7 @@ var require_Popover_native = __commonJS({
24923
24967
  present: !!open,
24924
24968
  keepChildrenMounted,
24925
24969
  onExitComplete: handleExitComplete,
24970
+ lazyMount,
24926
24971
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_popper.PopperContent, {
24927
24972
  __scopePopper: __scopePopover || POPOVER_SCOPE,
24928
24973
  "data-state": getState(open),