@tamagui/core 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
@@ -1320,6 +1320,9 @@ var require_createVariable_native = __commonJS({
1320
1320
  isVariable: function() {
1321
1321
  return isVariable;
1322
1322
  },
1323
+ px: function() {
1324
+ return px;
1325
+ },
1323
1326
  setDidGetVariableValue: function() {
1324
1327
  return setDidGetVariableValue;
1325
1328
  },
@@ -1383,6 +1386,12 @@ var require_createVariable_native = __commonJS({
1383
1386
  var name = (0, import_helpers2.simpleHash)(nameProp, 60);
1384
1387
  return includeVar ? constructCSSVariableName(name) : name;
1385
1388
  };
1389
+ function px(value) {
1390
+ return {
1391
+ val: value,
1392
+ needsPx: !0
1393
+ };
1394
+ }
1386
1395
  }
1387
1396
  });
1388
1397
 
@@ -8215,7 +8224,7 @@ var require_createVariables_native = __commonJS({
8215
8224
  }
8216
8225
  });
8217
8226
  module2.exports = __toCommonJS2(createVariables_exports);
8218
- var import_helpers2 = require_index_native3(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
8227
+ var import_constants2 = require_index_native2(), import_helpers2 = require_index_native3(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
8219
8228
  var parentPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", isFont = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
8220
8229
  if (cache.has(tokens)) return tokens;
8221
8230
  var res = {}, i = 0;
@@ -8227,16 +8236,25 @@ var require_createVariables_native = __commonJS({
8227
8236
  continue;
8228
8237
  }
8229
8238
  var niceKey = (0, import_helpers2.simpleHash)(key, 1e3), name = parentPath && parentPath !== "t-color" ? `${parentPath}-${niceKey}` : `c-${niceKey}`;
8239
+ if (val && typeof val == "object" && "needsPx" in val && "val" in val) {
8240
+ var finalValue = (0, import_createVariable.createVariable)({
8241
+ val: val.val,
8242
+ name,
8243
+ key: keyWithPrefix
8244
+ });
8245
+ import_constants2.isWeb && (finalValue.needsPx = val.needsPx), res[key] = finalValue;
8246
+ continue;
8247
+ }
8230
8248
  if (val && typeof val == "object") {
8231
8249
  res[key] = createVariables(tokens[key], name, !1);
8232
8250
  continue;
8233
8251
  }
8234
- var finalValue = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
8252
+ var finalValue1 = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({
8235
8253
  val,
8236
8254
  name,
8237
8255
  key: keyWithPrefix
8238
8256
  });
8239
- res[key] = finalValue;
8257
+ res[key] = finalValue1;
8240
8258
  }
8241
8259
  return cache.set(res, !0), res;
8242
8260
  };
@@ -8756,6 +8774,14 @@ var require_createTamagui_native = __commonJS({
8756
8774
  });
8757
8775
  module2.exports = __toCommonJS2(createTamagui_exports);
8758
8776
  var import_constants2 = require_index_native2(), 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();
8777
+ function shouldTokenCategoryHaveUnits(category) {
8778
+ var UNIT_CATEGORIES = /* @__PURE__ */ new Set([
8779
+ "size",
8780
+ "space",
8781
+ "radius"
8782
+ ]);
8783
+ return UNIT_CATEGORIES.has(category);
8784
+ }
8759
8785
  function createTamagui2(configIn) {
8760
8786
  var _configIn_settings;
8761
8787
  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;
@@ -8802,7 +8828,11 @@ var require_createTamagui_native = __commonJS({
8802
8828
  var variable = tokens[key2][skey];
8803
8829
  if (specificTokens[`$${key2}.${skey}`] = variable, process.env.NODE_ENV === "development" && typeof variable > "u") throw new Error(`No value for tokens.${key2}.${skey}:
8804
8830
  ${JSON.stringify(variable, null, 2)}`);
8805
- import_constants2.isWeb && ((0, import_registerCSSVariable.registerCSSVariable)(variable), declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, key2 === "zIndex")));
8831
+ if (import_constants2.isWeb) {
8832
+ (0, import_registerCSSVariable.registerCSSVariable)(variable);
8833
+ var variableNeedsPx = variable.needsPx === !0, categoryNeedsPx = shouldTokenCategoryHaveUnits(key2), shouldBeUnitless = !(variableNeedsPx || categoryNeedsPx);
8834
+ declarations.push((0, import_registerCSSVariable.variableToCSS)(variable, shouldBeUnitless));
8835
+ }
8806
8836
  }
8807
8837
  if (0) {
8808
8838
  var declarationsToRuleSet;