@tamagui/core 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
@@ -1704,7 +1704,7 @@ var require_objectIdentityKey_native = __commonJS({
1704
1704
  for (let key in obj) {
1705
1705
  k += key;
1706
1706
  let arg = obj[key], type = typeof arg;
1707
- if (!arg || type !== "object")
1707
+ if (!arg || type !== "object" && type !== "function")
1708
1708
  k += type + arg;
1709
1709
  else if (cache.has(arg))
1710
1710
  k += cache.get(arg);
@@ -1743,16 +1743,22 @@ var require_createStyledContext_native = __commonJS({
1743
1743
  scope,
1744
1744
  ...values
1745
1745
  }) => {
1746
- let value = (0, import_react3.useMemo)(() => ({
1746
+ let current;
1747
+ try {
1748
+ current = useStyledContext(scope);
1749
+ } catch {
1750
+ }
1751
+ let next = (0, import_react3.useMemo)(() => ({
1747
1752
  // this ! is a workaround for ts error
1748
1753
  ...defaultValues,
1754
+ ...current,
1749
1755
  ...values
1750
- }), [(0, import_objectIdentityKey.objectIdentityKey)(values)]), Provider2 = OGProvider;
1756
+ }), [(0, import_objectIdentityKey.objectIdentityKey)(values), current]), Provider2 = OGProvider;
1751
1757
  if (scope) {
1752
1758
  let ScopedContext = scopedContexts.get(scope);
1753
1759
  ScopedContext || (ScopedContext = (0, import_react3.createContext)(defaultValues), scopedContexts.set(scope, ScopedContext)), Provider2 = ScopedContext.Provider;
1754
1760
  }
1755
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider2, { value, children });
1761
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider2, { value: next, children });
1756
1762
  }, useStyledContext = (scope) => {
1757
1763
  let context = scope ? scopedContexts.get(scope) : OGContext;
1758
1764
  return (0, import_react3.useContext)(context);
@@ -3482,37 +3488,43 @@ var require_propMapper_native = __commonJS({
3482
3488
  fontSize: "size",
3483
3489
  fontWeight: "weight"
3484
3490
  }, lastFontFamilyToken = null, getTokenForKey = (key, value, resolveAs = "none", styleState) => {
3485
- var _a, _b, _c;
3491
+ var _a, _b, _c, _d;
3486
3492
  if (resolveAs === "none")
3487
3493
  return value;
3488
- let { theme, conf = (0, import_config.getConfig)(), context, fontFamily } = styleState, tokensParsed = conf.tokensParsed, valOrVar, hasSet = !1;
3494
+ let { theme, conf = (0, import_config.getConfig)(), context, fontFamily, staticConfig } = styleState, tokensParsed = conf.tokensParsed, valOrVar, hasSet = !1;
3489
3495
  if (theme && value in theme)
3490
3496
  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;
3491
3497
  else if (value in conf.specificTokens)
3492
3498
  hasSet = !0, valOrVar = conf.specificTokens[value];
3493
3499
  else {
3494
- switch (key) {
3495
- case "fontFamily": {
3496
- 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;
3497
- break;
3498
- }
3499
- case "fontSize":
3500
- case "lineHeight":
3501
- case "letterSpacing":
3502
- case "fontWeight": {
3503
- let defaultFont = conf.defaultFont || "$body", fam = fontFamily || defaultFont;
3504
- if (fam) {
3505
- let fontsParsed = context != null && context.language ? (0, import_getVariantExtras.getFontsForLanguage)(conf.fontsParsed, context.language) : conf.fontsParsed, font = fontsParsed[fam] || fontsParsed[defaultFont];
3506
- valOrVar = ((_c = font == null ? void 0 : font[fontShorthand[key] || key]) == null ? void 0 : _c[value]) || value, hasSet = !0;
3500
+ let customTokenAccept = (_b = staticConfig == null ? void 0 : staticConfig.acceptTokens) == null ? void 0 : _b[key];
3501
+ if (customTokenAccept) {
3502
+ let val = tokensParsed[customTokenAccept][value];
3503
+ val && (valOrVar = val, hasSet = !0);
3504
+ } else {
3505
+ switch (key) {
3506
+ case "fontFamily": {
3507
+ 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;
3508
+ break;
3509
+ }
3510
+ case "fontSize":
3511
+ case "lineHeight":
3512
+ case "letterSpacing":
3513
+ case "fontWeight": {
3514
+ let defaultFont = conf.defaultFont || "$body", fam = fontFamily || defaultFont;
3515
+ if (fam) {
3516
+ let fontsParsed = context != null && context.language ? (0, import_getVariantExtras.getFontsForLanguage)(conf.fontsParsed, context.language) : conf.fontsParsed, font = fontsParsed[fam] || fontsParsed[defaultFont];
3517
+ valOrVar = ((_d = font == null ? void 0 : font[fontShorthand[key] || key]) == null ? void 0 : _d[value]) || value, hasSet = !0;
3518
+ }
3519
+ break;
3507
3520
  }
3508
- break;
3509
3521
  }
3522
+ for (let cat in import_helpers.tokenCategories)
3523
+ if (key in import_helpers.tokenCategories[cat]) {
3524
+ let res = tokensParsed[cat][value];
3525
+ res != null && (valOrVar = res, hasSet = !0);
3526
+ }
3510
3527
  }
3511
- for (let cat in import_helpers.tokenCategories)
3512
- if (key in import_helpers.tokenCategories[cat]) {
3513
- let res = tokensParsed[cat][value];
3514
- res != null && (valOrVar = res, hasSet = !0);
3515
- }
3516
3528
  if (!hasSet) {
3517
3529
  let spaceVar = tokensParsed.space[value];
3518
3530
  spaceVar != null && (valOrVar = spaceVar, hasSet = !0);
@@ -3558,7 +3570,12 @@ var require_getSplitStyles_native = __commonJS({
3558
3570
  useSplitStyles: () => useSplitStyles
3559
3571
  });
3560
3572
  module2.exports = __toCommonJS2(getSplitStyles_exports);
3561
- var import_constants3 = require_index_native3(), import_helpers = require_index_native4(), import_react3 = 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) => {
3573
+ var import_constants3 = require_index_native3(), import_helpers = require_index_native4(), import_react3 = 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 = "-";
3574
+ function isValidStyleKey(key, staticConfig) {
3575
+ let validStyleProps = staticConfig.validStyles ?? (staticConfig.isText ? import_helpers.stylePropsText : import_helpers.validStyles);
3576
+ return key in validStyleProps || staticConfig.acceptTokens && key in staticConfig.acceptTokens;
3577
+ }
3578
+ var getSplitStyles = (props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, context, elementType, debug) => {
3562
3579
  var _a, _b, _c, _e, _f, _g;
3563
3580
  conf = conf || (0, import_config.getConfig)(), import_constants3.isWeb && styleProps.isAnimated && conf.animations.isReactNative && !styleProps.noNormalize && (styleProps.noNormalize = "values");
3564
3581
  let { shorthands } = conf, {
@@ -3570,7 +3587,7 @@ var require_getSplitStyles_native = __commonJS({
3570
3587
  inlineWhenUnflattened,
3571
3588
  parentStaticConfig,
3572
3589
  acceptsClassName
3573
- } = staticConfig, validStyleProps = isText ? import_helpers.stylePropsText : import_helpers.validStyles, viewProps = {}, mediaState2 = styleProps.mediaState || import_useMedia.mediaState, usedKeys = {}, shouldDoClasses = acceptsClassName && import_constants3.isWeb && !styleProps.noClassNames, rulesToInsert = [], classNames = {}, transforms = {}, pseudos = null, space = props.space, hasMedia = !1, dynamicThemeAccess, pseudoGroups, mediaGroups, style = {}, className = "", mediaStylesSeen = 0, styleState = {
3590
+ } = staticConfig, viewProps = {}, mediaState2 = styleProps.mediaState || import_useMedia.mediaState, usedKeys = {}, shouldDoClasses = acceptsClassName && import_constants3.isWeb && !styleProps.noClassNames, rulesToInsert = [], classNames = {}, transforms = {}, pseudos = null, space = props.space, hasMedia = !1, dynamicThemeAccess, pseudoGroups, mediaGroups, style = {}, className = "", mediaStylesSeen = 0, styleState = {
3574
3591
  curProps: { ...props },
3575
3592
  classNames,
3576
3593
  conf,
@@ -3598,7 +3615,7 @@ var require_getSplitStyles_native = __commonJS({
3598
3615
  let keyInit = keyOg, valInit = props[keyOg];
3599
3616
  if (styleProps.disableExpandShorthands || keyInit in shorthands && (keyInit = shorthands[keyInit]), keyInit === "className" || keyInit in usedKeys || keyInit in skipProps && !isHOC)
3600
3617
  continue;
3601
- let valInitType = typeof valInit;
3618
+ let valInitType = typeof valInit, isValidStyleKeyInit = isValidStyleKey(keyInit, staticConfig);
3602
3619
  if (styleState.curProps[keyInit] = valInit, !import_constants3.isAndroid && keyInit === "elevationAndroid")
3603
3620
  continue;
3604
3621
  if (keyInit === "userSelect")
@@ -3647,7 +3664,7 @@ var require_getSplitStyles_native = __commonJS({
3647
3664
  case "accessibilityRequired":
3648
3665
  default:
3649
3666
  }
3650
- 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;
3667
+ 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;
3651
3668
  if (isStyleProp && (props.asChild === "except-style" || props.asChild === "except-style-web"))
3652
3669
  continue;
3653
3670
  let shouldPassProp = !isStyleProp || // is in parent variants
@@ -3868,7 +3885,7 @@ current`, {
3868
3885
  if (
3869
3886
  // is HOC we can just pass through the styles as props
3870
3887
  // this fixes issues where style prop got merged with wrong priority
3871
- !isHOC && (key in validStyleProps || import_constants3.isAndroid && key === "elevation")
3888
+ !isHOC && (isValidStyleKey(key, staticConfig) || import_constants3.isAndroid && key === "elevation")
3872
3889
  ) {
3873
3890
  mergeStyle(styleState, key, val);
3874
3891
  continue;
@@ -6529,7 +6546,6 @@ var require_Text_native = __commonJS({
6529
6546
  }
6530
6547
  }
6531
6548
  },
6532
- deoptProps: /* @__PURE__ */ new Set(["ellipse"]),
6533
6549
  validStyles: {
6534
6550
  ...import_helpers.validStyles,
6535
6551
  ...import_helpers.stylePropsTextOnly