tamagui 1.80.4 → 1.81.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
@@ -1568,7 +1568,7 @@ var require_objectIdentityKey_native = __commonJS({
1568
1568
  for (let key in obj) {
1569
1569
  k += key;
1570
1570
  let arg = obj[key], type = typeof arg;
1571
- if (!arg || type !== "object")
1571
+ if (!arg || type !== "object" && type !== "function")
1572
1572
  k += type + arg;
1573
1573
  else if (cache.has(arg))
1574
1574
  k += cache.get(arg);
@@ -1607,16 +1607,22 @@ var require_createStyledContext_native = __commonJS({
1607
1607
  scope,
1608
1608
  ...values
1609
1609
  }) => {
1610
- let value = (0, import_react2.useMemo)(() => ({
1610
+ let current;
1611
+ try {
1612
+ current = useStyledContext(scope);
1613
+ } catch {
1614
+ }
1615
+ let next = (0, import_react2.useMemo)(() => ({
1611
1616
  // this ! is a workaround for ts error
1612
1617
  ...defaultValues,
1618
+ ...current,
1613
1619
  ...values
1614
- }), [(0, import_objectIdentityKey.objectIdentityKey)(values)]), Provider2 = OGProvider2;
1620
+ }), [(0, import_objectIdentityKey.objectIdentityKey)(values), current]), Provider2 = OGProvider2;
1615
1621
  if (scope) {
1616
1622
  let ScopedContext = scopedContexts.get(scope);
1617
1623
  ScopedContext || (ScopedContext = (0, import_react2.createContext)(defaultValues), scopedContexts.set(scope, ScopedContext)), Provider2 = ScopedContext.Provider;
1618
1624
  }
1619
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Provider2, { value, children });
1625
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Provider2, { value: next, children });
1620
1626
  }, useStyledContext = (scope) => {
1621
1627
  let context = scope ? scopedContexts.get(scope) : OGContext;
1622
1628
  return (0, import_react2.useContext)(context);
@@ -3318,37 +3324,43 @@ var require_propMapper_native = __commonJS({
3318
3324
  fontSize: "size",
3319
3325
  fontWeight: "weight"
3320
3326
  }, lastFontFamilyToken = null, getTokenForKey = (key, value, resolveAs = "none", styleState) => {
3321
- var _a, _b, _c;
3327
+ var _a, _b, _c, _d;
3322
3328
  if (resolveAs === "none")
3323
3329
  return value;
3324
- let { theme, conf = (0, import_config.getConfig)(), context, fontFamily } = styleState, tokensParsed = conf.tokensParsed, valOrVar, hasSet = !1;
3330
+ let { theme, conf = (0, import_config.getConfig)(), context, fontFamily, staticConfig } = styleState, tokensParsed = conf.tokensParsed, valOrVar, hasSet = !1;
3325
3331
  if (theme && value in theme)
3326
3332
  valOrVar = theme[value], process.env.NODE_ENV === "development" && styleState.debug === "verbose" && console.info(` - resolving ${key} to theme value ${value}: ${(_a = valOrVar == null ? void 0 : valOrVar.get) == null ? void 0 : _a.call(valOrVar)}`), hasSet = !0;
3327
3333
  else if (value in conf.specificTokens)
3328
3334
  hasSet = !0, valOrVar = conf.specificTokens[value];
3329
3335
  else {
3330
- switch (key) {
3331
- case "fontFamily": {
3332
- valOrVar = ((_b = (context != null && context.language ? (0, import_getVariantExtras.getFontsForLanguage)(conf.fontsParsed, context.language) : conf.fontsParsed)[value]) == null ? void 0 : _b.family) || value, lastFontFamilyToken = value, hasSet = !0;
3333
- break;
3334
- }
3335
- case "fontSize":
3336
- case "lineHeight":
3337
- case "letterSpacing":
3338
- case "fontWeight": {
3339
- let defaultFont = conf.defaultFont || "$body", fam = fontFamily || defaultFont;
3340
- if (fam) {
3341
- let fontsParsed = context != null && context.language ? (0, import_getVariantExtras.getFontsForLanguage)(conf.fontsParsed, context.language) : conf.fontsParsed, font = fontsParsed[fam] || fontsParsed[defaultFont];
3342
- valOrVar = ((_c = font == null ? void 0 : font[fontShorthand[key] || key]) == null ? void 0 : _c[value]) || value, hasSet = !0;
3336
+ let customTokenAccept = (_b = staticConfig == null ? void 0 : staticConfig.acceptTokens) == null ? void 0 : _b[key];
3337
+ if (customTokenAccept) {
3338
+ let val = tokensParsed[customTokenAccept][value];
3339
+ val && (valOrVar = val, hasSet = !0);
3340
+ } else {
3341
+ switch (key) {
3342
+ case "fontFamily": {
3343
+ valOrVar = ((_c = (context != null && context.language ? (0, import_getVariantExtras.getFontsForLanguage)(conf.fontsParsed, context.language) : conf.fontsParsed)[value]) == null ? void 0 : _c.family) || value, lastFontFamilyToken = value, hasSet = !0;
3344
+ break;
3345
+ }
3346
+ case "fontSize":
3347
+ case "lineHeight":
3348
+ case "letterSpacing":
3349
+ case "fontWeight": {
3350
+ let defaultFont = conf.defaultFont || "$body", fam = fontFamily || defaultFont;
3351
+ if (fam) {
3352
+ let fontsParsed = context != null && context.language ? (0, import_getVariantExtras.getFontsForLanguage)(conf.fontsParsed, context.language) : conf.fontsParsed, font = fontsParsed[fam] || fontsParsed[defaultFont];
3353
+ valOrVar = ((_d = font == null ? void 0 : font[fontShorthand[key] || key]) == null ? void 0 : _d[value]) || value, hasSet = !0;
3354
+ }
3355
+ break;
3343
3356
  }
3344
- break;
3345
3357
  }
3358
+ for (let cat in import_helpers.tokenCategories)
3359
+ if (key in import_helpers.tokenCategories[cat]) {
3360
+ let res = tokensParsed[cat][value];
3361
+ res != null && (valOrVar = res, hasSet = !0);
3362
+ }
3346
3363
  }
3347
- for (let cat in import_helpers.tokenCategories)
3348
- if (key in import_helpers.tokenCategories[cat]) {
3349
- let res = tokensParsed[cat][value];
3350
- res != null && (valOrVar = res, hasSet = !0);
3351
- }
3352
3364
  if (!hasSet) {
3353
3365
  let spaceVar = tokensParsed.space[value];
3354
3366
  spaceVar != null && (valOrVar = spaceVar, hasSet = !0);
@@ -3394,7 +3406,12 @@ var require_getSplitStyles_native = __commonJS({
3394
3406
  useSplitStyles: () => useSplitStyles
3395
3407
  });
3396
3408
  module2.exports = __toCommonJS2(getSplitStyles_exports);
3397
- var import_constants4 = require_index_native(), import_helpers = require_index_native7(), import_react2 = require("react"), import_config = require_config_native(), import_accessibilityDirectMap = require_accessibilityDirectMap_native(), import_constants22 = require_constants_native2(), import_isDevTools = require_isDevTools_native(), import_useMedia = require_useMedia_native(), import_createMediaStyle = require_createMediaStyle_native(), import_expandStyles = require_expandStyles_native(), import_getGroupPropParts = require_getGroupPropParts_native(), import_getStylesAtomic = require_getStylesAtomic_native(), import_insertStyleRule = require_insertStyleRule_native(), import_log = require_log_native(), import_normalizeValueWithProperty = require_normalizeValueWithProperty_native(), import_propMapper = require_propMapper_native(), import_pseudoDescriptors = require_pseudoDescriptors_native(), IS_STATIC = process.env.IS_STATIC === "is_static", conf, PROP_SPLIT = "-", getSplitStyles = (props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, context, elementType, debug) => {
3409
+ var import_constants4 = require_index_native(), import_helpers = require_index_native7(), import_react2 = require("react"), import_config = require_config_native(), import_accessibilityDirectMap = require_accessibilityDirectMap_native(), import_constants22 = require_constants_native2(), import_isDevTools = require_isDevTools_native(), import_useMedia = require_useMedia_native(), import_createMediaStyle = require_createMediaStyle_native(), import_expandStyles = require_expandStyles_native(), import_getGroupPropParts = require_getGroupPropParts_native(), import_getStylesAtomic = require_getStylesAtomic_native(), import_insertStyleRule = require_insertStyleRule_native(), import_log = require_log_native(), import_normalizeValueWithProperty = require_normalizeValueWithProperty_native(), import_propMapper = require_propMapper_native(), import_pseudoDescriptors = require_pseudoDescriptors_native(), IS_STATIC = process.env.IS_STATIC === "is_static", conf, PROP_SPLIT = "-";
3410
+ function isValidStyleKey(key, staticConfig) {
3411
+ let validStyleProps = staticConfig.validStyles ?? (staticConfig.isText ? import_helpers.stylePropsText : import_helpers.validStyles);
3412
+ return key in validStyleProps || staticConfig.acceptTokens && key in staticConfig.acceptTokens;
3413
+ }
3414
+ var getSplitStyles = (props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, context, elementType, debug) => {
3398
3415
  var _a, _b, _c, _e, _f, _g;
3399
3416
  conf = conf || (0, import_config.getConfig)(), import_constants4.isWeb && styleProps.isAnimated && conf.animations.isReactNative && !styleProps.noNormalize && (styleProps.noNormalize = "values");
3400
3417
  let { shorthands } = conf, {
@@ -3406,7 +3423,7 @@ var require_getSplitStyles_native = __commonJS({
3406
3423
  inlineWhenUnflattened,
3407
3424
  parentStaticConfig,
3408
3425
  acceptsClassName
3409
- } = staticConfig, validStyleProps = isText ? import_helpers.stylePropsText : import_helpers.validStyles, viewProps = {}, mediaState3 = styleProps.mediaState || import_useMedia.mediaState, usedKeys = {}, shouldDoClasses = acceptsClassName && import_constants4.isWeb && !styleProps.noClassNames, rulesToInsert = [], classNames = {}, transforms = {}, pseudos = null, space = props.space, hasMedia = !1, dynamicThemeAccess, pseudoGroups, mediaGroups, style = {}, className = "", mediaStylesSeen = 0, styleState = {
3426
+ } = staticConfig, viewProps = {}, mediaState3 = styleProps.mediaState || import_useMedia.mediaState, usedKeys = {}, shouldDoClasses = acceptsClassName && import_constants4.isWeb && !styleProps.noClassNames, rulesToInsert = [], classNames = {}, transforms = {}, pseudos = null, space = props.space, hasMedia = !1, dynamicThemeAccess, pseudoGroups, mediaGroups, style = {}, className = "", mediaStylesSeen = 0, styleState = {
3410
3427
  curProps: { ...props },
3411
3428
  classNames,
3412
3429
  conf,
@@ -3434,7 +3451,7 @@ var require_getSplitStyles_native = __commonJS({
3434
3451
  let keyInit = keyOg, valInit = props[keyOg];
3435
3452
  if (styleProps.disableExpandShorthands || keyInit in shorthands && (keyInit = shorthands[keyInit]), keyInit === "className" || keyInit in usedKeys || keyInit in skipProps && !isHOC)
3436
3453
  continue;
3437
- let valInitType = typeof valInit;
3454
+ let valInitType = typeof valInit, isValidStyleKeyInit = isValidStyleKey(keyInit, staticConfig);
3438
3455
  if (styleState.curProps[keyInit] = valInit, !import_constants4.isAndroid && keyInit === "elevationAndroid")
3439
3456
  continue;
3440
3457
  if (keyInit === "userSelect")
@@ -3483,7 +3500,7 @@ var require_getSplitStyles_native = __commonJS({
3483
3500
  case "accessibilityRequired":
3484
3501
  default:
3485
3502
  }
3486
- let isValidStyleKeyInit = keyInit in validStyleProps, isShorthand = keyInit in shorthands, isVariant = !isValidStyleKeyInit && variants && keyInit in variants, isStyleLikeKey = isShorthand || isValidStyleKeyInit || isVariant, isPseudo = keyInit in import_helpers.validPseudoKeys, isMedia = !isStyleLikeKey && !isPseudo && (0, import_useMedia.isMediaKey)(keyInit), isMediaOrPseudo = !!(isMedia || isPseudo), isStyleProp = isMediaOrPseudo || isVariant && !styleProps.noExpand || isValidStyleKeyInit || isShorthand;
3503
+ let isShorthand = keyInit in shorthands, isVariant = !isValidStyleKeyInit && variants && keyInit in variants, isStyleLikeKey = isShorthand || isValidStyleKeyInit || isVariant, isPseudo = keyInit in import_helpers.validPseudoKeys, isMedia = !isStyleLikeKey && !isPseudo && (0, import_useMedia.isMediaKey)(keyInit), isMediaOrPseudo = !!(isMedia || isPseudo), isStyleProp = isMediaOrPseudo || isVariant && !styleProps.noExpand || isValidStyleKeyInit || isShorthand;
3487
3504
  if (isStyleProp && (props.asChild === "except-style" || props.asChild === "except-style-web"))
3488
3505
  continue;
3489
3506
  let shouldPassProp = !isStyleProp || // is in parent variants
@@ -3704,7 +3721,7 @@ current`, {
3704
3721
  if (
3705
3722
  // is HOC we can just pass through the styles as props
3706
3723
  // this fixes issues where style prop got merged with wrong priority
3707
- !isHOC && (key in validStyleProps || import_constants4.isAndroid && key === "elevation")
3724
+ !isHOC && (isValidStyleKey(key, staticConfig) || import_constants4.isAndroid && key === "elevation")
3708
3725
  ) {
3709
3726
  mergeStyle(styleState, key, val);
3710
3727
  continue;
@@ -6365,7 +6382,6 @@ var require_Text_native = __commonJS({
6365
6382
  }
6366
6383
  }
6367
6384
  },
6368
- deoptProps: /* @__PURE__ */ new Set(["ellipse"]),
6369
6385
  validStyles: {
6370
6386
  ...import_helpers.validStyles,
6371
6387
  ...import_helpers.stylePropsTextOnly
@@ -12216,7 +12232,7 @@ var require_Button_native = __commonJS({
12216
12232
  Icon: ButtonIcon
12217
12233
  });
12218
12234
  function useButton({ textProps, ...propsIn }, { Text: Text3 = Button2.Text } = { Text: Button2.Text }) {
12219
- let isNested = (0, import_react2.useContext)(import_stacks3.ButtonNestingContext), didFinishSSR = (0, import_web.useDidFinishSSR)(), propsActive = (0, import_web.useProps)(propsIn), {
12235
+ let isNested = (0, import_react2.useContext)(import_stacks3.ButtonNestingContext), propsActive = (0, import_web.useProps)(propsIn), {
12220
12236
  icon,
12221
12237
  iconAfter,
12222
12238
  space,
@@ -12227,6 +12243,7 @@ var require_Button_native = __commonJS({
12227
12243
  noTextWrap,
12228
12244
  fontFamily,
12229
12245
  fontSize,
12246
+ tag,
12230
12247
  ...restProps
12231
12248
  } = propsActive, size2 = propsActive.size || (propsActive.unstyled ? void 0 : "$true"), color = propsActive.color, iconSize = (typeof size2 == "number" ? size2 * 0.5 : (0, import_font_size.getFontSize)(size2)) * scaleIcon, getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
12232
12249
  size: iconSize,
@@ -12245,11 +12262,7 @@ var require_Button_native = __commonJS({
12245
12262
  separator,
12246
12263
  direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
12247
12264
  children: [themedIcon, ...contents, themedIconAfter]
12248
- }), tag = isNested ? "span" : (
12249
- // defaults to <a /> when accessibilityRole = link
12250
- // see https://github.com/tamagui/tamagui/issues/505
12251
- propsActive.accessibilityRole === "link" ? "a" : void 0
12252
- ), props = {
12265
+ }), props = {
12253
12266
  size: size2,
12254
12267
  ...propsIn.disabled && {
12255
12268
  // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
@@ -12259,13 +12272,16 @@ var require_Button_native = __commonJS({
12259
12272
  borderColor: "$background"
12260
12273
  }
12261
12274
  },
12262
- ...tag && {
12263
- tag
12264
- },
12275
+ // fixes SSR issue + DOM nesting issue of not allowing button in button
12276
+ tag: tag ?? (isNested ? "span" : (
12277
+ // defaults to <a /> when accessibilityRole = link
12278
+ // see https://github.com/tamagui/tamagui/issues/505
12279
+ propsActive.accessibilityRole === "link" ? "a" : "button"
12280
+ )),
12265
12281
  ...restProps,
12266
12282
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_stacks3.ButtonNestingContext.Provider, { value: !0, children: inner }),
12267
12283
  // forces it to be a runtime pressStyle so it passes through context text colors
12268
- disableClassName: didFinishSSR
12284
+ disableClassName: !0
12269
12285
  };
12270
12286
  return {
12271
12287
  spaceSize,