@tamagui/web 1.88.6 → 1.88.8

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/src/types.tsx CHANGED
@@ -21,13 +21,13 @@ import type {
21
21
  import type { Variable } from './createVariable'
22
22
  import { StyledContext } from './helpers/createStyledContext'
23
23
  import { CSSColorNames } from './interfaces/CSSColorNames'
24
+ import { ColorKeys, SizeKeys, SpaceKeys } from './interfaces/KeyTypes'
24
25
  import { RNOnlyProps } from './interfaces/RNExclusiveTypes'
25
- import type { LanguageContextType } from './views/FontLanguage.types'
26
- import type { ThemeProviderProps } from './views/ThemeProvider'
26
+ import { TamaguiComponentPropsBaseBase } from './interfaces/TamaguiComponentPropsBaseBase'
27
27
  import { TamaguiComponentState } from './interfaces/TamaguiComponentState'
28
28
  import { WebOnlyPressEvents } from './interfaces/WebOnlyPressEvents'
29
- import { TamaguiComponentPropsBaseBase } from './interfaces/TamaguiComponentPropsBaseBase'
30
- import { SizeKeys, SpaceKeys, ColorKeys } from './interfaces/KeyTypes'
29
+ import type { LanguageContextType } from './views/FontLanguage.types'
30
+ import type { ThemeProviderProps } from './views/ThemeProvider'
31
31
 
32
32
  export * from './interfaces/KeyTypes'
33
33
  export * from './interfaces/TamaguiComponentState'
@@ -453,7 +453,7 @@ export interface SpacerStyleProps
453
453
  extends Omit<StackStyleBase, keyof SpacerUniqueProps>,
454
454
  SpacerUniqueProps {}
455
455
 
456
- export type SpacerProps = WithThemeShorthandsPseudosMedia<SpacerStyleProps>
456
+ export type SpacerProps = WithThemeShorthandsPseudosMedia<SpacerStyleProps, {}>
457
457
 
458
458
  type AllowedValueSettingBase =
459
459
  | boolean
@@ -1112,10 +1112,23 @@ export type GetThemeValueForKey<K extends string | symbol | number> =
1112
1112
  : never
1113
1113
  : never)
1114
1114
 
1115
- export type WithThemeValues<T extends object> = {
1116
- [K in keyof T]: ThemeValueGet<K> extends never
1117
- ? T[K] | 'unset'
1118
- : GetThemeValueForKey<K> | Exclude<T[K], string> | 'unset'
1115
+ export type GetThemeValuesFor<
1116
+ T extends Object,
1117
+ K extends keyof T,
1118
+ AddUnset,
1119
+ > = ThemeValueGet<K> extends never
1120
+ ? T[K] | (AddUnset extends true ? 'unset' : never)
1121
+ :
1122
+ | GetThemeValueForKey<K>
1123
+ | Exclude<T[K], string>
1124
+ | (AddUnset extends true ? 'unset' : never)
1125
+
1126
+ export type WithThemeValues<T extends Object, Variants extends Object> = {
1127
+ [K in keyof T | keyof Variants]?: K extends keyof Variants
1128
+ ? GetThemeValuesFor<Variants, K, false>
1129
+ : K extends keyof T
1130
+ ? GetThemeValuesFor<T, K, true>
1131
+ : never
1119
1132
  }
1120
1133
 
1121
1134
  export type NarrowShorthands = Narrow<Shorthands>
@@ -1156,21 +1169,31 @@ export type AllPlatforms = 'web' | 'native' | 'android' | 'ios'
1156
1169
  //
1157
1170
  // add both theme and shorthands
1158
1171
  //
1159
- export type WithThemeAndShorthands<A extends Object> = OnlyAllowShorthands extends true
1160
- ? WithThemeValues<Omit<A, Longhands>> & WithShorthands<WithThemeValues<A>>
1161
- : WithThemeValues<A> & WithShorthands<WithThemeValues<A>>
1172
+ export type WithThemeAndShorthands<
1173
+ A extends Object,
1174
+ Variants extends Object,
1175
+ > = OnlyAllowShorthands extends true
1176
+ ? WithThemeValues<Omit<A, Longhands>, Variants> &
1177
+ WithShorthands<WithThemeValues<A, Variants>>
1178
+ : WithThemeValues<A, Variants> & WithShorthands<WithThemeValues<A, Variants>>
1162
1179
 
1163
1180
  //
1164
1181
  // combines all of theme, shorthands, pseudos...
1165
1182
  //
1166
- export type WithThemeShorthandsAndPseudos<A extends Object> = WithThemeAndShorthands<A> &
1167
- WithPseudoProps<WithThemeAndShorthands<A>>
1183
+ export type WithThemeShorthandsAndPseudos<
1184
+ A extends Object,
1185
+ Variants extends Object,
1186
+ > = WithThemeAndShorthands<A, Variants> &
1187
+ WithPseudoProps<WithThemeAndShorthands<A, Variants>>
1168
1188
 
1169
1189
  //
1170
1190
  // ... media queries and animations
1171
1191
  //
1172
- export type WithThemeShorthandsPseudosMedia<A extends Object> =
1173
- WithThemeShorthandsAndPseudos<A> & WithMediaProps<WithThemeShorthandsAndPseudos<A>>
1192
+ export type WithThemeShorthandsPseudosMedia<
1193
+ A extends Object,
1194
+ Variants extends Object,
1195
+ > = WithThemeShorthandsAndPseudos<A, Variants> &
1196
+ WithMediaProps<WithThemeShorthandsAndPseudos<A, Variants>>
1174
1197
 
1175
1198
  /**
1176
1199
  * Base style-only props (no media, pseudo):
@@ -1289,7 +1312,7 @@ export interface StackNonStyleProps
1289
1312
  style?: StyleProp<LooseCombinedObjects<React.CSSProperties, ViewStyle>>
1290
1313
  }
1291
1314
 
1292
- export type StackStyle = WithThemeShorthandsPseudosMedia<StackStyleBase>
1315
+ export type StackStyle = WithThemeShorthandsPseudosMedia<StackStyleBase, {}>
1293
1316
 
1294
1317
  export type StackProps = StackNonStyleProps & StackStyle
1295
1318
 
@@ -1313,7 +1336,7 @@ export interface TextNonStyleProps
1313
1336
  style?: StyleProp<LooseCombinedObjects<React.CSSProperties, TextStyle>>
1314
1337
  }
1315
1338
 
1316
- export type TextStyleProps = WithThemeShorthandsPseudosMedia<TextStylePropsBase>
1339
+ export type TextStyleProps = WithThemeShorthandsPseudosMedia<TextStylePropsBase, {}>
1317
1340
 
1318
1341
  export type TextProps = TextNonStyleProps & TextStyleProps
1319
1342
 
@@ -1335,42 +1358,48 @@ export type Styleable<
1335
1358
  Ref,
1336
1359
  NonStyledProps,
1337
1360
  BaseStyles extends Object,
1338
- VariantProps,
1361
+ VariantProps extends Object,
1339
1362
  ParentStaticProperties,
1340
1363
  > = <
1341
- CustomProps extends Object | void = void,
1342
- MergedProps = CustomProps extends void
1343
- ? Props
1344
- : Omit<Props, keyof CustomProps> & CustomProps,
1345
- FunctionDef extends FunctionComponent<MergedProps> = FunctionComponent<MergedProps>,
1364
+ CustomProps extends Object | void,
1365
+ FunctionDef extends FunctionComponent<any> = FunctionComponent<
1366
+ GetFinalProps<
1367
+ NonStyledProps & CustomProps,
1368
+ Omit<BaseStyles, keyof CustomProps>,
1369
+ VariantProps
1370
+ >
1371
+ >,
1346
1372
  >(
1347
1373
  a: FunctionDef,
1348
1374
  options?: StyleableOptions
1349
1375
  ) => TamaguiComponent<
1350
- MergedProps,
1376
+ Props,
1351
1377
  Ref,
1352
1378
  NonStyledProps & CustomProps,
1353
- BaseStyles,
1379
+ Omit<BaseStyles, keyof CustomProps>,
1354
1380
  VariantProps,
1355
1381
  ParentStaticProperties
1356
1382
  >
1357
1383
 
1358
- export type GetFinalProps<NonStyleProps, StylePropsBase> = Omit<
1384
+ export type GetFinalProps<
1359
1385
  NonStyleProps,
1360
- keyof StylePropsBase
1361
- > &
1362
- (StylePropsBase extends Object ? WithThemeShorthandsPseudosMedia<StylePropsBase> : {})
1386
+ StylePropsBase,
1387
+ VariantProps extends Object,
1388
+ > = StylePropsBase extends Object
1389
+ ? Omit<NonStyleProps, keyof StylePropsBase> &
1390
+ WithThemeShorthandsPseudosMedia<StylePropsBase, VariantProps>
1391
+ : NonStyleProps
1363
1392
 
1364
1393
  export type TamaguiComponent<
1365
1394
  Props = any,
1366
1395
  Ref = any,
1367
1396
  NonStyledProps = {},
1368
1397
  BaseStyles extends Object = {},
1369
- VariantProps = {},
1398
+ VariantProps extends Object = {},
1370
1399
  ParentStaticProperties = {},
1371
1400
  > = ForwardRefExoticComponent<
1372
1401
  (Props extends TamaDefer
1373
- ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps>
1402
+ ? GetFinalProps<NonStyledProps, BaseStyles, VariantProps>
1374
1403
  : Props) &
1375
1404
  RefAttributes<Ref>
1376
1405
  > &
@@ -1388,20 +1417,25 @@ export type TamaguiComponent<
1388
1417
 
1389
1418
  export type InferGenericComponentProps<A> = A extends ComponentType<infer Props>
1390
1419
  ? Props
1391
- : A extends new (
1392
- props: infer Props
1393
- ) => any
1394
- ? Props
1395
- : {}
1396
-
1397
- export type InferStyledProps<
1398
- A extends StylableComponent,
1399
- B extends StaticConfigPublic,
1400
- > = A extends {
1420
+ : A extends ReactComponentWithRef<infer P, any>
1421
+ ? P
1422
+ : A extends ForwardRefExoticComponent<infer P>
1423
+ ? P
1424
+ : A extends new (
1425
+ props: infer Props
1426
+ ) => any
1427
+ ? Props
1428
+ : {}
1429
+
1430
+ export type InferStyledProps<A extends StylableComponent, B extends Object> = A extends {
1401
1431
  __tama: any
1402
1432
  }
1403
1433
  ? GetProps<A>
1404
- : GetFinalProps<InferGenericComponentProps<A>, GetBaseStyles<{}, B>>
1434
+ : GetFinalProps<
1435
+ InferGenericComponentProps<A>,
1436
+ GetBaseStyles<A, B>,
1437
+ GetVariantProps<A, B>
1438
+ >
1405
1439
 
1406
1440
  export type GetProps<A extends StylableComponent> = A extends {
1407
1441
  __tama: [
@@ -1414,7 +1448,9 @@ export type GetProps<A extends StylableComponent> = A extends {
1414
1448
  ]
1415
1449
  }
1416
1450
  ? Props extends TamaDefer
1417
- ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps>
1451
+ ? VariantProps extends Object
1452
+ ? GetFinalProps<NonStyledProps, BaseStyles, VariantProps>
1453
+ : never
1418
1454
  : Props
1419
1455
  : InferGenericComponentProps<A>
1420
1456
 
@@ -1424,14 +1460,20 @@ export type GetNonStyledProps<A extends StylableComponent> = A extends {
1424
1460
  ? B
1425
1461
  : TamaguiComponentPropsBaseBase & GetProps<A>
1426
1462
 
1427
- export type GetBaseStyles<A, B> = A extends {
1463
+ export type GetBaseStyles<A, B extends StaticConfig> = A extends {
1428
1464
  __tama: [any, any, any, infer C, any, any]
1429
1465
  }
1430
1466
  ? C
1431
- : B extends { isText: true }
1467
+ : ShouldHaveTextBaseStyles<B> extends true
1432
1468
  ? TextStylePropsBase
1433
1469
  : StackStyleBase
1434
1470
 
1471
+ type ShouldHaveTextBaseStyles<SC extends StaticConfig> = SC extends { isText: true }
1472
+ ? true
1473
+ : SC extends { isInput: true }
1474
+ ? true
1475
+ : false
1476
+
1435
1477
  export type GetStyledVariants<A> = A extends {
1436
1478
  __tama: [any, any, any, any, infer B, any]
1437
1479
  }
@@ -1449,7 +1491,7 @@ export type StaticComponentObject<
1449
1491
  Ref,
1450
1492
  NonStyledProps,
1451
1493
  BaseStyles extends Object,
1452
- VariantProps,
1494
+ VariantProps extends Object,
1453
1495
  ParentStaticProperties,
1454
1496
  > = {
1455
1497
  staticConfig: StaticConfig
@@ -1460,9 +1502,7 @@ export type StaticComponentObject<
1460
1502
  * If you want your HOC of a styled() component to also be able to be styled(), you need this to wrap it.
1461
1503
  */
1462
1504
  styleable: Styleable<
1463
- Props extends TamaDefer
1464
- ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps>
1465
- : Props,
1505
+ Props,
1466
1506
  Ref,
1467
1507
  NonStyledProps,
1468
1508
  BaseStyles,
@@ -1541,10 +1581,15 @@ export type StaticConfigPublic = {
1541
1581
  neverFlatten?: boolean | 'jsx'
1542
1582
 
1543
1583
  /**
1544
- * Determines ultimate output tag (Text vs View)
1584
+ * Determines ultimate output tag (Text vs View) and accepted props (text props vs view)
1545
1585
  */
1546
1586
  isText?: boolean
1547
1587
 
1588
+ /**
1589
+ * Adds support for text props and handles focus properly
1590
+ */
1591
+ isInput?: boolean
1592
+
1548
1593
  /**
1549
1594
  * Which style keys are allowed to be extracted.
1550
1595
  */
@@ -1608,11 +1653,6 @@ type StaticConfigBase = StaticConfigPublic & {
1608
1653
  */
1609
1654
  memo?: boolean
1610
1655
 
1611
- /**
1612
- * Used internally for handling focus
1613
- */
1614
- isInput?: boolean
1615
-
1616
1656
  /**
1617
1657
  * Used internally for knowing how to handle when a HOC is in-between styled()
1618
1658
  */
@@ -1664,8 +1704,8 @@ export type SpreadKeys =
1664
1704
 
1665
1705
  export type VariantDefinitions<
1666
1706
  Parent extends StylableComponent = TamaguiComponent,
1667
- StaticConfig extends StaticConfigPublic = {},
1668
- MyProps extends Object = Partial<GetVariantProps<Parent, StaticConfig['isText']>>,
1707
+ SC extends StaticConfig = {},
1708
+ MyProps extends Object = Partial<GetVariantProps<Parent, SC>>,
1669
1709
  Val = any,
1670
1710
  > = VariantDefinitionFromProps<MyProps, Val> & {
1671
1711
  _isEmpty?: 1
@@ -1673,7 +1713,7 @@ export type VariantDefinitions<
1673
1713
 
1674
1714
  export type GetVariantProps<
1675
1715
  A extends StylableComponent,
1676
- IsText extends boolean | undefined,
1716
+ B extends StaticConfigPublic,
1677
1717
  > = A extends {
1678
1718
  __tama: [
1679
1719
  infer Props,
@@ -1685,11 +1725,11 @@ export type GetVariantProps<
1685
1725
  ]
1686
1726
  }
1687
1727
  ? Props extends TamaDefer
1688
- ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps>
1728
+ ? VariantProps extends Object
1729
+ ? GetFinalProps<NonStyledProps, BaseStyles, VariantProps>
1730
+ : never
1689
1731
  : Props
1690
- : WithThemeShorthandsPseudosMedia<
1691
- IsText extends true ? TextStylePropsBase : StackStyleBase
1692
- >
1732
+ : {}
1693
1733
 
1694
1734
  export type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object
1695
1735
  ? {
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
2
  import { DebugProp, SpaceDirection, SpaceValue, SpacerProps, SpacerStyleProps, StackNonStyleProps, StaticConfig, TamaguiComponent, TamaguiElement } from './types';
3
3
  export declare const mouseUps: Set<Function>;
4
- export declare function createComponent<ComponentPropTypes extends Record<string, any> = {}, Ref extends TamaguiElement = TamaguiElement, BaseProps = never, BaseStyles extends Object = never>(staticConfig: StaticConfig): TamaguiComponent<ComponentPropTypes, Ref, BaseProps, BaseStyles, void>;
4
+ export declare function createComponent<ComponentPropTypes extends Record<string, any> = {}, Ref extends TamaguiElement = TamaguiElement, BaseProps = never, BaseStyles extends Object = never>(staticConfig: StaticConfig): TamaguiComponent<ComponentPropTypes, Ref, BaseProps, BaseStyles, {}>;
5
5
  export declare function Unspaced(props: {
6
6
  children?: any;
7
7
  }): any;
8
8
  export declare namespace Unspaced {
9
9
  var isUnspaced: boolean;
10
10
  }
11
- export declare const Spacer: TamaguiComponent<SpacerProps, TamaguiElement, StackNonStyleProps, SpacerStyleProps, void>;
11
+ export declare const Spacer: TamaguiComponent<SpacerProps, TamaguiElement, StackNonStyleProps, SpacerStyleProps, {}>;
12
12
  export type SpacedChildrenProps = {
13
13
  isZStack?: boolean;
14
14
  children?: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAIA,OAAO,KAYN,MAAM,OAAO,CAAA;AAuBd,OAAO,EAEL,SAAS,EAMT,cAAc,EACd,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAElB,YAAY,EAEZ,gBAAgB,EAEhB,cAAc,EAMf,MAAM,SAAS,CAAA;AAiBhB,eAAO,MAAM,QAAQ,eAAsB,CAAA;AA6D3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACnD,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,SAAS,GAAG,KAAK,EACjB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,YAAY,EAAE,YAAY,0EAirC3B;AAsBD,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,OAEjD;yBAFe,QAAQ;;;AAkBxB,eAAO,MAAM,MAAM,2FA0CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,GAAG,OAAO,CAAA;IACpC,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAiGxD"}
1
+ {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAIA,OAAO,KAYN,MAAM,OAAO,CAAA;AAuBd,OAAO,EAEL,SAAS,EAMT,cAAc,EACd,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAElB,YAAY,EAEZ,gBAAgB,EAEhB,cAAc,EAMf,MAAM,SAAS,CAAA;AAiBhB,eAAO,MAAM,QAAQ,eAAsB,CAAA;AA6D3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACnD,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,SAAS,GAAG,KAAK,EACjB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,YAAY,EAAE,YAAY,wEAmrC3B;AAsBD,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,OAEjD;yBAFe,QAAQ;;;AAkBxB,eAAO,MAAM,MAAM,yFA0CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,GAAG,OAAO,CAAA;IACpC,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAiGxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAEV,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,aAAa,EAOb,eAAe,EACf,YAAY,EAGZ,cAAc,EACd,WAAW,EAEZ,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AA4BhF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAMhE,KAAK,aAAa,GAAG,CACnB,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC7B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,qBAAqB,EACrC,UAAU,EAAE,eAAe,EAC3B,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,EACzC,OAAO,CAAC,EAAE,iBAAiB,EAE3B,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,SAAS,KACd,cAAc,CAAA;AAEnB,eAAO,MAAM,UAAU,MAAM,CAAA;AA+B7B,eAAO,MAAM,cAAc,EAAE,aAooC5B,CAAA;AA2DD,eAAO,MAAM,WAAW,eACV,aAAa,UACjB,MAAM,WACL,MAAM,wBACO,OAAO,KAC5B,cA2BF,CAAA;AAqBD,eAAO,MAAM,cAAc,EAAE,aAQ5B,CAAA"}
1
+ {"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAEV,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,aAAa,EAOb,eAAe,EACf,YAAY,EAGZ,cAAc,EACd,WAAW,EAEZ,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AA4BhF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAMhE,KAAK,aAAa,GAAG,CACnB,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC7B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,qBAAqB,EACrC,UAAU,EAAE,eAAe,EAC3B,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,EACzC,OAAO,CAAC,EAAE,iBAAiB,EAE3B,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,SAAS,KACd,cAAc,CAAA;AAEnB,eAAO,MAAM,UAAU,MAAM,CAAA;AAgC7B,eAAO,MAAM,cAAc,EAAE,aAqoC5B,CAAA;AA2DD,eAAO,MAAM,WAAW,eACV,aAAa,UACjB,MAAM,WACL,MAAM,wBACO,OAAO,KAC5B,cA2BF,CAAA;AAqBD,eAAO,MAAM,cAAc,EAAE,aAQ5B,CAAA"}
package/types/types.d.ts CHANGED
@@ -5,13 +5,13 @@ import type { Text as RNText, TextProps as ReactTextProps, TextStyle, View, View
5
5
  import type { Variable } from './createVariable';
6
6
  import { StyledContext } from './helpers/createStyledContext';
7
7
  import { CSSColorNames } from './interfaces/CSSColorNames';
8
+ import { ColorKeys, SizeKeys, SpaceKeys } from './interfaces/KeyTypes';
8
9
  import { RNOnlyProps } from './interfaces/RNExclusiveTypes';
9
- import type { LanguageContextType } from './views/FontLanguage.types';
10
- import type { ThemeProviderProps } from './views/ThemeProvider';
10
+ import { TamaguiComponentPropsBaseBase } from './interfaces/TamaguiComponentPropsBaseBase';
11
11
  import { TamaguiComponentState } from './interfaces/TamaguiComponentState';
12
12
  import { WebOnlyPressEvents } from './interfaces/WebOnlyPressEvents';
13
- import { TamaguiComponentPropsBaseBase } from './interfaces/TamaguiComponentPropsBaseBase';
14
- import { SizeKeys, SpaceKeys, ColorKeys } from './interfaces/KeyTypes';
13
+ import type { LanguageContextType } from './views/FontLanguage.types';
14
+ import type { ThemeProviderProps } from './views/ThemeProvider';
15
15
  export * from './interfaces/KeyTypes';
16
16
  export * from './interfaces/TamaguiComponentState';
17
17
  export type { MediaStyleObject, StyleObject } from '@tamagui/helpers';
@@ -270,7 +270,7 @@ export type SpacerUniqueProps = {
270
270
  };
271
271
  export interface SpacerStyleProps extends Omit<StackStyleBase, keyof SpacerUniqueProps>, SpacerUniqueProps {
272
272
  }
273
- export type SpacerProps = WithThemeShorthandsPseudosMedia<SpacerStyleProps>;
273
+ export type SpacerProps = WithThemeShorthandsPseudosMedia<SpacerStyleProps, {}>;
274
274
  type AllowedValueSettingBase = boolean | 'strict' | 'somewhat-strict' | 'strict-web' | 'somewhat-strict-web';
275
275
  type AllowedStyleValuesSettingSize = AllowedValueSettingBase | 'number' | 'percent';
276
276
  type AllowedStyleValuesSettingZIndex = AllowedValueSettingBase | 'number';
@@ -600,8 +600,9 @@ export type ThemeValueGet<K extends string | number | symbol> = K extends 'theme
600
600
  export type GetThemeValueForKey<K extends string | symbol | number> = ThemeValueGet<K> | ThemeValueFallback | (TamaguiSettings extends {
601
601
  autocompleteSpecificTokens: infer Val;
602
602
  } ? Val extends true | undefined ? SpecificTokens : never : never);
603
- export type WithThemeValues<T extends object> = {
604
- [K in keyof T]: ThemeValueGet<K> extends never ? T[K] | 'unset' : GetThemeValueForKey<K> | Exclude<T[K], string> | 'unset';
603
+ export type GetThemeValuesFor<T extends Object, K extends keyof T, AddUnset> = ThemeValueGet<K> extends never ? T[K] | (AddUnset extends true ? 'unset' : never) : GetThemeValueForKey<K> | Exclude<T[K], string> | (AddUnset extends true ? 'unset' : never);
604
+ export type WithThemeValues<T extends Object, Variants extends Object> = {
605
+ [K in keyof T | keyof Variants]?: K extends keyof Variants ? GetThemeValuesFor<Variants, K, false> : K extends keyof T ? GetThemeValuesFor<T, K, true> : never;
605
606
  };
606
607
  export type NarrowShorthands = Narrow<Shorthands>;
607
608
  export type Longhands = NarrowShorthands[keyof NarrowShorthands];
@@ -625,9 +626,9 @@ export type PseudoStyles = {
625
626
  exitStyle?: ViewStyle;
626
627
  };
627
628
  export type AllPlatforms = 'web' | 'native' | 'android' | 'ios';
628
- export type WithThemeAndShorthands<A extends Object> = OnlyAllowShorthands extends true ? WithThemeValues<Omit<A, Longhands>> & WithShorthands<WithThemeValues<A>> : WithThemeValues<A> & WithShorthands<WithThemeValues<A>>;
629
- export type WithThemeShorthandsAndPseudos<A extends Object> = WithThemeAndShorthands<A> & WithPseudoProps<WithThemeAndShorthands<A>>;
630
- export type WithThemeShorthandsPseudosMedia<A extends Object> = WithThemeShorthandsAndPseudos<A> & WithMediaProps<WithThemeShorthandsAndPseudos<A>>;
629
+ export type WithThemeAndShorthands<A extends Object, Variants extends Object> = OnlyAllowShorthands extends true ? WithThemeValues<Omit<A, Longhands>, Variants> & WithShorthands<WithThemeValues<A, Variants>> : WithThemeValues<A, Variants> & WithShorthands<WithThemeValues<A, Variants>>;
630
+ export type WithThemeShorthandsAndPseudos<A extends Object, Variants extends Object> = WithThemeAndShorthands<A, Variants> & WithPseudoProps<WithThemeAndShorthands<A, Variants>>;
631
+ export type WithThemeShorthandsPseudosMedia<A extends Object, Variants extends Object> = WithThemeShorthandsAndPseudos<A, Variants> & WithMediaProps<WithThemeShorthandsAndPseudos<A, Variants>>;
631
632
  /**
632
633
  * Base style-only props (no media, pseudo):
633
634
  */
@@ -696,12 +697,12 @@ type LooseCombinedObjects<A extends Object, B extends Object> = A | B | (A & B);
696
697
  export interface StackNonStyleProps extends Omit<ViewProps, 'pointerEvents' | 'display' | 'children' | RNOnlyProps | keyof ExtendBaseStackProps | 'style'>, ExtendBaseStackProps, TamaguiComponentPropsBase {
697
698
  style?: StyleProp<LooseCombinedObjects<React.CSSProperties, ViewStyle>>;
698
699
  }
699
- export type StackStyle = WithThemeShorthandsPseudosMedia<StackStyleBase>;
700
+ export type StackStyle = WithThemeShorthandsPseudosMedia<StackStyleBase, {}>;
700
701
  export type StackProps = StackNonStyleProps & StackStyle;
701
702
  export interface TextNonStyleProps extends Omit<ReactTextProps, 'children' | keyof WebOnlyPressEvents | RNOnlyProps | keyof ExtendBaseTextProps | 'style'>, ExtendBaseTextProps, TamaguiComponentPropsBase {
702
703
  style?: StyleProp<LooseCombinedObjects<React.CSSProperties, TextStyle>>;
703
704
  }
704
- export type TextStyleProps = WithThemeShorthandsPseudosMedia<TextStylePropsBase>;
705
+ export type TextStyleProps = WithThemeShorthandsPseudosMedia<TextStylePropsBase, {}>;
705
706
  export type TextProps = TextNonStyleProps & TextStyleProps;
706
707
  export interface ThemeableProps {
707
708
  theme?: ThemeName | null;
@@ -714,15 +715,15 @@ export type StyleableOptions = {
714
715
  disableTheme?: boolean;
715
716
  staticConfig?: Partial<StaticConfig>;
716
717
  };
717
- export type Styleable<Props, Ref, NonStyledProps, BaseStyles extends Object, VariantProps, ParentStaticProperties> = <CustomProps extends Object | void = void, MergedProps = CustomProps extends void ? Props : Omit<Props, keyof CustomProps> & CustomProps, FunctionDef extends FunctionComponent<MergedProps> = FunctionComponent<MergedProps>>(a: FunctionDef, options?: StyleableOptions) => TamaguiComponent<MergedProps, Ref, NonStyledProps & CustomProps, BaseStyles, VariantProps, ParentStaticProperties>;
718
- export type GetFinalProps<NonStyleProps, StylePropsBase> = Omit<NonStyleProps, keyof StylePropsBase> & (StylePropsBase extends Object ? WithThemeShorthandsPseudosMedia<StylePropsBase> : {});
719
- export type TamaguiComponent<Props = any, Ref = any, NonStyledProps = {}, BaseStyles extends Object = {}, VariantProps = {}, ParentStaticProperties = {}> = ForwardRefExoticComponent<(Props extends TamaDefer ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps> : Props) & RefAttributes<Ref>> & StaticComponentObject<Props, Ref, NonStyledProps, BaseStyles, VariantProps, ParentStaticProperties> & Omit<ParentStaticProperties, 'staticConfig' | 'extractable' | 'styleable'> & {
718
+ export type Styleable<Props, Ref, NonStyledProps, BaseStyles extends Object, VariantProps extends Object, ParentStaticProperties> = <CustomProps extends Object | void, FunctionDef extends FunctionComponent<any> = FunctionComponent<GetFinalProps<NonStyledProps & CustomProps, Omit<BaseStyles, keyof CustomProps>, VariantProps>>>(a: FunctionDef, options?: StyleableOptions) => TamaguiComponent<Props, Ref, NonStyledProps & CustomProps, Omit<BaseStyles, keyof CustomProps>, VariantProps, ParentStaticProperties>;
719
+ export type GetFinalProps<NonStyleProps, StylePropsBase, VariantProps extends Object> = StylePropsBase extends Object ? Omit<NonStyleProps, keyof StylePropsBase> & WithThemeShorthandsPseudosMedia<StylePropsBase, VariantProps> : NonStyleProps;
720
+ export type TamaguiComponent<Props = any, Ref = any, NonStyledProps = {}, BaseStyles extends Object = {}, VariantProps extends Object = {}, ParentStaticProperties = {}> = ForwardRefExoticComponent<(Props extends TamaDefer ? GetFinalProps<NonStyledProps, BaseStyles, VariantProps> : Props) & RefAttributes<Ref>> & StaticComponentObject<Props, Ref, NonStyledProps, BaseStyles, VariantProps, ParentStaticProperties> & Omit<ParentStaticProperties, 'staticConfig' | 'extractable' | 'styleable'> & {
720
721
  __tama: [Props, Ref, NonStyledProps, BaseStyles, VariantProps, ParentStaticProperties];
721
722
  };
722
- export type InferGenericComponentProps<A> = A extends ComponentType<infer Props> ? Props : A extends new (props: infer Props) => any ? Props : {};
723
- export type InferStyledProps<A extends StylableComponent, B extends StaticConfigPublic> = A extends {
723
+ export type InferGenericComponentProps<A> = A extends ComponentType<infer Props> ? Props : A extends ReactComponentWithRef<infer P, any> ? P : A extends ForwardRefExoticComponent<infer P> ? P : A extends new (props: infer Props) => any ? Props : {};
724
+ export type InferStyledProps<A extends StylableComponent, B extends Object> = A extends {
724
725
  __tama: any;
725
- } ? GetProps<A> : GetFinalProps<InferGenericComponentProps<A>, GetBaseStyles<{}, B>>;
726
+ } ? GetProps<A> : GetFinalProps<InferGenericComponentProps<A>, GetBaseStyles<A, B>, GetVariantProps<A, B>>;
726
727
  export type GetProps<A extends StylableComponent> = A extends {
727
728
  __tama: [
728
729
  infer Props,
@@ -732,26 +733,29 @@ export type GetProps<A extends StylableComponent> = A extends {
732
733
  infer VariantProps,
733
734
  any
734
735
  ];
735
- } ? Props extends TamaDefer ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps> : Props : InferGenericComponentProps<A>;
736
+ } ? Props extends TamaDefer ? VariantProps extends Object ? GetFinalProps<NonStyledProps, BaseStyles, VariantProps> : never : Props : InferGenericComponentProps<A>;
736
737
  export type GetNonStyledProps<A extends StylableComponent> = A extends {
737
738
  __tama: [any, any, infer B, any, any, any];
738
739
  } ? B : TamaguiComponentPropsBaseBase & GetProps<A>;
739
- export type GetBaseStyles<A, B> = A extends {
740
+ export type GetBaseStyles<A, B extends StaticConfig> = A extends {
740
741
  __tama: [any, any, any, infer C, any, any];
741
- } ? C : B extends {
742
+ } ? C : ShouldHaveTextBaseStyles<B> extends true ? TextStylePropsBase : StackStyleBase;
743
+ type ShouldHaveTextBaseStyles<SC extends StaticConfig> = SC extends {
742
744
  isText: true;
743
- } ? TextStylePropsBase : StackStyleBase;
745
+ } ? true : SC extends {
746
+ isInput: true;
747
+ } ? true : false;
744
748
  export type GetStyledVariants<A> = A extends {
745
749
  __tama: [any, any, any, any, infer B, any];
746
750
  } ? B : {};
747
751
  export type GetStaticConfig<A> = A extends {
748
752
  __tama: [any, any, any, any, any, infer B];
749
753
  } ? B : A;
750
- export type StaticComponentObject<Props, Ref, NonStyledProps, BaseStyles extends Object, VariantProps, ParentStaticProperties> = {
754
+ export type StaticComponentObject<Props, Ref, NonStyledProps, BaseStyles extends Object, VariantProps extends Object, ParentStaticProperties> = {
751
755
  staticConfig: StaticConfig;
752
756
  /** @deprecated use `styleable` instead (same functionality, better name) */
753
757
  extractable: <X>(a: X, staticConfig?: Partial<StaticConfig>) => X;
754
- styleable: Styleable<Props extends TamaDefer ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps> : Props, Ref, NonStyledProps, BaseStyles, VariantProps, ParentStaticProperties>;
758
+ styleable: Styleable<Props, Ref, NonStyledProps, BaseStyles, VariantProps, ParentStaticProperties>;
755
759
  };
756
760
  export type TamaguiComponentExpectingVariants<Props = {}, Variants extends Object = {}> = TamaguiComponent<Props, any, any, any, Variants>;
757
761
  export type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {
@@ -797,9 +801,13 @@ export type StaticConfigPublic = {
797
801
  */
798
802
  neverFlatten?: boolean | 'jsx';
799
803
  /**
800
- * Determines ultimate output tag (Text vs View)
804
+ * Determines ultimate output tag (Text vs View) and accepted props (text props vs view)
801
805
  */
802
806
  isText?: boolean;
807
+ /**
808
+ * Adds support for text props and handles focus properly
809
+ */
810
+ isInput?: boolean;
803
811
  /**
804
812
  * Which style keys are allowed to be extracted.
805
813
  */
@@ -854,10 +862,6 @@ type StaticConfigBase = StaticConfigPublic & {
854
862
  * Memoize the component
855
863
  */
856
864
  memo?: boolean;
857
- /**
858
- * Used internally for handling focus
859
- */
860
- isInput?: boolean;
861
865
  /**
862
866
  * Used internally for knowing how to handle when a HOC is in-between styled()
863
867
  */
@@ -879,10 +883,10 @@ export type ViewStyleWithPseudos = TextStyleProps | (TextStyleProps & {
879
883
  */
880
884
  export type StylableComponent = TamaguiComponent | ComponentType<any> | ForwardRefExoticComponent<any> | ReactComponentWithRef<any, any> | (new (props: any) => any);
881
885
  export type SpreadKeys = '...fontSize' | '...fontStyle' | '...fontTransform' | '...lineHeight' | '...letterSpacing' | '...size' | '...space' | '...color' | '...zIndex' | '...theme' | '...radius';
882
- export type VariantDefinitions<Parent extends StylableComponent = TamaguiComponent, StaticConfig extends StaticConfigPublic = {}, MyProps extends Object = Partial<GetVariantProps<Parent, StaticConfig['isText']>>, Val = any> = VariantDefinitionFromProps<MyProps, Val> & {
886
+ export type VariantDefinitions<Parent extends StylableComponent = TamaguiComponent, SC extends StaticConfig = {}, MyProps extends Object = Partial<GetVariantProps<Parent, SC>>, Val = any> = VariantDefinitionFromProps<MyProps, Val> & {
883
887
  _isEmpty?: 1;
884
888
  };
885
- export type GetVariantProps<A extends StylableComponent, IsText extends boolean | undefined> = A extends {
889
+ export type GetVariantProps<A extends StylableComponent, B extends StaticConfigPublic> = A extends {
886
890
  __tama: [
887
891
  infer Props,
888
892
  any,
@@ -891,7 +895,7 @@ export type GetVariantProps<A extends StylableComponent, IsText extends boolean
891
895
  infer VariantProps,
892
896
  any
893
897
  ];
894
- } ? Props extends TamaDefer ? GetFinalProps<NonStyledProps, BaseStyles & VariantProps> : Props : WithThemeShorthandsPseudosMedia<IsText extends true ? TextStylePropsBase : StackStyleBase>;
898
+ } ? Props extends TamaDefer ? VariantProps extends Object ? GetFinalProps<NonStyledProps, BaseStyles, VariantProps> : never : Props : {};
895
899
  export type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object ? {
896
900
  [propName: string]: VariantSpreadFunction<MyProps, Val> | ({
897
901
  [Key in SpreadKeys]?: Key extends '...fontSize' ? FontSizeVariantSpreadFunction<MyProps> : Key extends '...size' ? SizeVariantSpreadFunction<MyProps> : Key extends '...space' ? SpaceVariantSpreadFunction<MyProps> : Key extends '...color' ? ColorVariantSpreadFunction<MyProps> : Key extends '...lineHeight' ? FontLineHeightVariantSpreadFunction<MyProps> : Key extends '...fontTransform' ? FontTransformVariantSpreadFunction<MyProps> : Key extends '...fontStyle' ? FontStyleVariantSpreadFunction<MyProps> : Key extends '...letterSpacing' ? FontLetterSpacingVariantSpreadFunction<MyProps> : Key extends '...zIndex' ? ZIndexVariantSpreadFunction<MyProps> : Key extends '...radius' ? RadiusVariantSpreadFunction<MyProps> : Key extends '...theme' ? ThemeVariantSpreadFunction<MyProps> : never;