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.
@@ -2404,6 +2404,9 @@ var require_createVariable_native = __commonJS({
2404
2404
  isVariable: function() {
2405
2405
  return isVariable2;
2406
2406
  },
2407
+ px: function() {
2408
+ return px;
2409
+ },
2407
2410
  setDidGetVariableValue: function() {
2408
2411
  return setDidGetVariableValue;
2409
2412
  },
@@ -2465,6 +2468,12 @@ var require_createVariable_native = __commonJS({
2465
2468
  var includeVar = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, name = (0, import_helpers.simpleHash)(nameProp, 60);
2466
2469
  return includeVar ? constructCSSVariableName(name) : name;
2467
2470
  };
2471
+ function px(value) {
2472
+ return {
2473
+ val: value,
2474
+ needsPx: !0
2475
+ };
2476
+ }
2468
2477
  }
2469
2478
  });
2470
2479
 
@@ -8469,7 +8478,12 @@ var require_createComponent_native = __commonJS({
8469
8478
  return Component2.staticConfig = extendStyledConfig(extended), Component2.styleable = styleable, Component2;
8470
8479
  }
8471
8480
  function styleable(Component2, options) {
8472
- 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);
8481
+ 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) {
8482
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component2, {
8483
+ ...props,
8484
+ ref
8485
+ });
8486
+ }), extendedConfig = extendStyledConfig(options == null ? void 0 : options.staticConfig);
8473
8487
  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;
8474
8488
  }
8475
8489
  return res.extractable = extractable, res.styleable = styleable, res;
@@ -8745,7 +8759,7 @@ var require_createVariables_native = __commonJS({
8745
8759
  }
8746
8760
  });
8747
8761
  module2.exports = __toCommonJS2(createVariables_exports);
8748
- var import_helpers = require_index_native7(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
8762
+ var import_constants4 = require_index_native6(), import_helpers = require_index_native7(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
8749
8763
  var parentPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", isFont = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
8750
8764
  if (cache.has(tokens)) return tokens;
8751
8765
  var res = {}, i = 0;
@@ -8757,16 +8771,25 @@ var require_createVariables_native = __commonJS({
8757
8771
  continue;
8758
8772
  }
8759
8773
  var niceKey = (0, import_helpers.simpleHash)(key, 1e3), name = parentPath && parentPath !== "t-color" ? `${parentPath}-${niceKey}` : `c-${niceKey}`;
8774
+ if (val && typeof val == "object" && "needsPx" in val && "val" in val) {
8775
+ var finalValue = (0, import_createVariable.createVariable)({
8776
+ val: val.val,
8777
+ name,
8778
+ key: keyWithPrefix
8779
+ });
8780
+ import_constants4.isWeb && (finalValue.needsPx = val.needsPx), res[key] = finalValue;
8781
+ continue;
8782
+ }
8760
8783
  if (val && typeof val == "object") {
8761
8784
  res[key] = createVariables(tokens[key], name, !1);
8762
8785
  continue;
8763
8786
  }
8764
- var finalValue = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
8787
+ var finalValue1 = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
8765
8788
  val,
8766
8789
  name,
8767
8790
  key: keyWithPrefix
8768
8791
  });
8769
- res[key] = finalValue;
8792
+ res[key] = finalValue1;
8770
8793
  }
8771
8794
  return cache.set(res, !0), res;
8772
8795
  };
@@ -9286,6 +9309,14 @@ var require_createTamagui_native = __commonJS({
9286
9309
  });
9287
9310
  module2.exports = __toCommonJS2(createTamagui_exports);
9288
9311
  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();
9312
+ function shouldTokenCategoryHaveUnits(category) {
9313
+ var UNIT_CATEGORIES = /* @__PURE__ */ new Set([
9314
+ "size",
9315
+ "space",
9316
+ "radius"
9317
+ ]);
9318
+ return UNIT_CATEGORIES.has(category);
9319
+ }
9289
9320
  function createTamagui2(configIn) {
9290
9321
  var _configIn_settings;
9291
9322
  if (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;
@@ -9330,7 +9361,11 @@ var require_createTamagui_native = __commonJS({
9330
9361
  var cssRuleSets = [], declarations = [], fontDeclarations = {};
9331
9362
  for (var key2 in tokens) for (var skey in tokens[key2]) {
9332
9363
  var variable = tokens[key2][skey];
9333
- specificTokens[`$${key2}.${skey}`] = variable, import_constants4.isWeb && ((0, import_registerCSSVariable.registerCSSVariable)(variable), declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, key2 === "zIndex")));
9364
+ if (specificTokens[`$${key2}.${skey}`] = variable, import_constants4.isWeb) {
9365
+ (0, import_registerCSSVariable.registerCSSVariable)(variable);
9366
+ var variableNeedsPx = variable.needsPx === !0, categoryNeedsPx = shouldTokenCategoryHaveUnits(key2), shouldBeUnitless = !(variableNeedsPx || categoryNeedsPx);
9367
+ declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, shouldBeUnitless));
9368
+ }
9334
9369
  }
9335
9370
  if (0) {
9336
9371
  var declarationsToRuleSet;
@@ -23299,9 +23334,18 @@ var require_Animate_native = __commonJS({
23299
23334
  }
23300
23335
  });
23301
23336
  module2.exports = __toCommonJS2(Animate_exports);
23302
- var import_jsx_runtime6 = require("react/jsx-runtime"), import_animate_presence = require_index_native4();
23337
+ var import_jsx_runtime6 = require("react/jsx-runtime"), import_animate_presence = require_index_native4(), import_react3 = require("react");
23303
23338
  function Animate(param) {
23304
- var { children, type, ...props } = param;
23339
+ var { children, lazyMount, type, present, ...props } = param, [lazyMounted, setLazyMounted] = (0, import_react3.useState)(lazyMount ? !1 : present);
23340
+ (0, import_react3.useEffect)(function() {
23341
+ lazyMount && present && (0, import_react3.startTransition)(function() {
23342
+ setLazyMounted(present);
23343
+ });
23344
+ }, [
23345
+ lazyMount,
23346
+ present
23347
+ ]);
23348
+ var mounted = present ? lazyMount ? lazyMounted : present : !1;
23305
23349
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_animate_presence.PresenceChild, {
23306
23350
  initial: props.initial ? void 0 : !1,
23307
23351
  onExitComplete: props.onExitComplete,
@@ -23311,12 +23355,12 @@ var require_Animate_native = __commonJS({
23311
23355
  // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
23312
23356
  // but since we always re-render this component on open changes this should be fine to leave off?
23313
23357
  presenceAffectsLayout: !1,
23314
- isPresent: props.present,
23358
+ isPresent: present,
23315
23359
  custom: props.custom,
23316
23360
  children
23317
23361
  }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_animate_presence.AnimatePresence, {
23318
23362
  ...props,
23319
- children: props.present ? children : null
23363
+ children: mounted ? children : null
23320
23364
  }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, {
23321
23365
  children
23322
23366
  });
@@ -23764,21 +23808,21 @@ var require_Popper_native = __commonJS({
23764
23808
  x,
23765
23809
  y
23766
23810
  ]);
23767
- var show = !0, frameProps = {
23811
+ var hide2 = x === 0 && y === 0, frameProps = {
23768
23812
  ref: contentRefs,
23769
23813
  x: x || 0,
23770
23814
  y: y || 0,
23771
23815
  top: 0,
23772
23816
  left: 0,
23773
23817
  position: strategy,
23774
- opacity: show ? 1 : 0,
23818
+ opacity: 1,
23775
23819
  ...enableAnimationForPositionChange && {
23776
23820
  // apply animation but disable it on initial render to avoid animating from 0 to the first position
23777
23821
  animation: rest.animation,
23778
23822
  animateOnly: needsMeasure ? [] : rest.animateOnly,
23779
23823
  animatePresence: !1
23780
23824
  },
23781
- ...x === 0 && y === 0 && {
23825
+ ...hide2 && {
23782
23826
  opacity: 0,
23783
23827
  animateOnly: []
23784
23828
  }
@@ -24211,7 +24255,7 @@ var require_Popover_native = __commonJS({
24211
24255
  });
24212
24256
  }
24213
24257
  var PopoverContentImpl = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
24214
- 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() {
24258
+ 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() {
24215
24259
  setIsFullyHidden == null || setIsFullyHidden(!0);
24216
24260
  }, [
24217
24261
  setIsFullyHidden
@@ -24229,6 +24273,7 @@ var require_Popover_native = __commonJS({
24229
24273
  present: !!open,
24230
24274
  keepChildrenMounted,
24231
24275
  onExitComplete: handleExitComplete,
24276
+ lazyMount,
24232
24277
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_popper.PopperContent, {
24233
24278
  __scopePopper: __scopePopover || POPOVER_SCOPE,
24234
24279
  "data-state": getState(open),