tamagui 1.128.1 → 1.129.1

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
 
@@ -9314,7 +9323,7 @@ var require_createVariables_native = __commonJS({
9314
9323
  }
9315
9324
  });
9316
9325
  module2.exports = __toCommonJS2(createVariables_exports);
9317
- var import_helpers = require_index_native7(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
9326
+ var import_constants4 = require_index_native6(), import_helpers = require_index_native7(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
9318
9327
  var parentPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", isFont = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
9319
9328
  if (cache.has(tokens)) return tokens;
9320
9329
  var res = {}, i = 0;
@@ -9326,16 +9335,25 @@ var require_createVariables_native = __commonJS({
9326
9335
  continue;
9327
9336
  }
9328
9337
  var niceKey = (0, import_helpers.simpleHash)(key, 1e3), name = parentPath && parentPath !== "t-color" ? `${parentPath}-${niceKey}` : `c-${niceKey}`;
9338
+ if (val && typeof val == "object" && "needsPx" in val && "val" in val) {
9339
+ var finalValue = (0, import_createVariable.createVariable)({
9340
+ val: val.val,
9341
+ name,
9342
+ key: keyWithPrefix
9343
+ });
9344
+ import_constants4.isWeb && (finalValue.needsPx = val.needsPx), res[key] = finalValue;
9345
+ continue;
9346
+ }
9329
9347
  if (val && typeof val == "object") {
9330
9348
  res[key] = createVariables(tokens[key], name, !1);
9331
9349
  continue;
9332
9350
  }
9333
- var finalValue = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
9351
+ var finalValue1 = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
9334
9352
  val,
9335
9353
  name,
9336
9354
  key: keyWithPrefix
9337
9355
  });
9338
- res[key] = finalValue;
9356
+ res[key] = finalValue1;
9339
9357
  }
9340
9358
  return cache.set(res, !0), res;
9341
9359
  };
@@ -9855,6 +9873,14 @@ var require_createTamagui_native = __commonJS({
9855
9873
  });
9856
9874
  module2.exports = __toCommonJS2(createTamagui_exports);
9857
9875
  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();
9876
+ function shouldTokenCategoryHaveUnits(category) {
9877
+ var UNIT_CATEGORIES = /* @__PURE__ */ new Set([
9878
+ "size",
9879
+ "space",
9880
+ "radius"
9881
+ ]);
9882
+ return UNIT_CATEGORIES.has(category);
9883
+ }
9858
9884
  function createTamagui2(configIn) {
9859
9885
  var _configIn_settings;
9860
9886
  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 +9927,11 @@ var require_createTamagui_native = __commonJS({
9901
9927
  var variable = tokens[key2][skey];
9902
9928
  if (specificTokens[`$${key2}.${skey}`] = variable, process.env.NODE_ENV === "development" && typeof variable > "u") throw new Error(`No value for tokens.${key2}.${skey}:
9903
9929
  ${JSON.stringify(variable, null, 2)}`);
9904
- import_constants4.isWeb && ((0, import_registerCSSVariable.registerCSSVariable)(variable), declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, key2 === "zIndex")));
9930
+ if (import_constants4.isWeb) {
9931
+ (0, import_registerCSSVariable.registerCSSVariable)(variable);
9932
+ var variableNeedsPx = variable.needsPx === !0, categoryNeedsPx = shouldTokenCategoryHaveUnits(key2), shouldBeUnitless = !(variableNeedsPx || categoryNeedsPx);
9933
+ declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, shouldBeUnitless));
9934
+ }
9905
9935
  }
9906
9936
  if (0) {
9907
9937
  var declarationsToRuleSet;
@@ -23993,9 +24023,18 @@ var require_Animate_native = __commonJS({
23993
24023
  }
23994
24024
  });
23995
24025
  module2.exports = __toCommonJS2(Animate_exports);
23996
- var import_jsx_runtime6 = require("react/jsx-runtime"), import_animate_presence = require_index_native4();
24026
+ var import_jsx_runtime6 = require("react/jsx-runtime"), import_animate_presence = require_index_native4(), import_react3 = require("react");
23997
24027
  function Animate(param) {
23998
- var { children, type, ...props } = param;
24028
+ var { children, lazyMount, type, present, ...props } = param, [lazyMounted, setLazyMounted] = (0, import_react3.useState)(lazyMount ? !1 : present);
24029
+ (0, import_react3.useEffect)(function() {
24030
+ lazyMount && present && (0, import_react3.startTransition)(function() {
24031
+ setLazyMounted(present);
24032
+ });
24033
+ }, [
24034
+ lazyMount,
24035
+ present
24036
+ ]);
24037
+ var mounted = present ? lazyMount ? lazyMounted : present : !1;
23999
24038
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_animate_presence.PresenceChild, {
24000
24039
  initial: props.initial ? void 0 : !1,
24001
24040
  onExitComplete: props.onExitComplete,
@@ -24005,12 +24044,12 @@ var require_Animate_native = __commonJS({
24005
24044
  // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
24006
24045
  // but since we always re-render this component on open changes this should be fine to leave off?
24007
24046
  presenceAffectsLayout: !1,
24008
- isPresent: props.present,
24047
+ isPresent: present,
24009
24048
  custom: props.custom,
24010
24049
  children
24011
24050
  }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_animate_presence.AnimatePresence, {
24012
24051
  ...props,
24013
- children: props.present ? children : null
24052
+ children: mounted ? children : null
24014
24053
  }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, {
24015
24054
  children
24016
24055
  });
@@ -24458,21 +24497,21 @@ var require_Popper_native = __commonJS({
24458
24497
  x,
24459
24498
  y
24460
24499
  ]);
24461
- var show = !0, frameProps = {
24500
+ var hide2 = x === 0 && y === 0, frameProps = {
24462
24501
  ref: contentRefs,
24463
24502
  x: x || 0,
24464
24503
  y: y || 0,
24465
24504
  top: 0,
24466
24505
  left: 0,
24467
24506
  position: strategy,
24468
- opacity: show ? 1 : 0,
24507
+ opacity: 1,
24469
24508
  ...enableAnimationForPositionChange && {
24470
24509
  // apply animation but disable it on initial render to avoid animating from 0 to the first position
24471
24510
  animation: rest.animation,
24472
24511
  animateOnly: needsMeasure ? [] : rest.animateOnly,
24473
24512
  animatePresence: !1
24474
24513
  },
24475
- ...x === 0 && y === 0 && {
24514
+ ...hide2 && {
24476
24515
  opacity: 0,
24477
24516
  animateOnly: []
24478
24517
  }
@@ -24905,7 +24944,7 @@ var require_Popover_native = __commonJS({
24905
24944
  });
24906
24945
  }
24907
24946
  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() {
24947
+ 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
24948
  setIsFullyHidden == null || setIsFullyHidden(!0);
24910
24949
  }, [
24911
24950
  setIsFullyHidden
@@ -24923,6 +24962,7 @@ var require_Popover_native = __commonJS({
24923
24962
  present: !!open,
24924
24963
  keepChildrenMounted,
24925
24964
  onExitComplete: handleExitComplete,
24965
+ lazyMount,
24926
24966
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_popper.PopperContent, {
24927
24967
  __scopePopper: __scopePopover || POPOVER_SCOPE,
24928
24968
  "data-state": getState(open),