@tamagui/core 1.0.1-beta.166 → 1.0.1-beta.168

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.
Files changed (103) hide show
  1. package/dist/cjs/addTheme.js.map +1 -1
  2. package/dist/cjs/config.js.map +1 -1
  3. package/dist/cjs/constants/platform.js +4 -4
  4. package/dist/cjs/constants/platform.js.map +2 -2
  5. package/dist/cjs/constants/platform.native.js +3 -3
  6. package/dist/cjs/constants/platform.native.js.map +2 -2
  7. package/dist/cjs/createComponent.js +4 -2
  8. package/dist/cjs/createComponent.js.map +2 -2
  9. package/dist/cjs/createTamagui.js +1 -4
  10. package/dist/cjs/createTamagui.js.map +2 -2
  11. package/dist/cjs/createVariable.js +9 -0
  12. package/dist/cjs/createVariable.js.map +2 -2
  13. package/dist/cjs/helpers/ThemeManager.js.map +1 -1
  14. package/dist/cjs/helpers/getSplitStyles.js +16 -9
  15. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  16. package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
  17. package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
  18. package/dist/cjs/hooks/useIsSSR.js +8 -4
  19. package/dist/cjs/hooks/useIsSSR.js.map +2 -2
  20. package/dist/cjs/hooks/useIsTouchDevice.js +1 -1
  21. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  22. package/dist/cjs/hooks/useMedia.js +48 -29
  23. package/dist/cjs/hooks/useMedia.js.map +2 -2
  24. package/dist/cjs/hooks/useTheme.js +1 -1
  25. package/dist/cjs/hooks/useTheme.js.map +2 -2
  26. package/dist/cjs/styled.js +11 -8
  27. package/dist/cjs/styled.js.map +2 -2
  28. package/dist/cjs/types.js.map +1 -1
  29. package/dist/cjs/updateTheme.js.map +2 -2
  30. package/dist/cjs/views/TamaguiProvider.js +2 -2
  31. package/dist/cjs/views/TamaguiProvider.js.map +2 -2
  32. package/dist/esm/addTheme.js.map +1 -1
  33. package/dist/esm/config.js.map +1 -1
  34. package/dist/esm/constants/platform.js +3 -3
  35. package/dist/esm/constants/platform.js.map +2 -2
  36. package/dist/esm/constants/platform.native.js +2 -2
  37. package/dist/esm/constants/platform.native.js.map +2 -2
  38. package/dist/esm/createComponent.js +4 -2
  39. package/dist/esm/createComponent.js.map +2 -2
  40. package/dist/esm/createTamagui.js +1 -4
  41. package/dist/esm/createTamagui.js.map +2 -2
  42. package/dist/esm/createVariable.js +8 -0
  43. package/dist/esm/createVariable.js.map +2 -2
  44. package/dist/esm/helpers/ThemeManager.js.map +1 -1
  45. package/dist/esm/helpers/getSplitStyles.js +16 -9
  46. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  47. package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
  48. package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
  49. package/dist/esm/hooks/useIsSSR.js +9 -5
  50. package/dist/esm/hooks/useIsSSR.js.map +2 -2
  51. package/dist/esm/hooks/useIsTouchDevice.js +2 -2
  52. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  53. package/dist/esm/hooks/useMedia.js +49 -30
  54. package/dist/esm/hooks/useMedia.js.map +2 -2
  55. package/dist/esm/hooks/useTheme.js +2 -2
  56. package/dist/esm/hooks/useTheme.js.map +2 -2
  57. package/dist/esm/styled.js +11 -8
  58. package/dist/esm/styled.js.map +2 -2
  59. package/dist/esm/updateTheme.js.map +2 -2
  60. package/dist/esm/views/TamaguiProvider.js +3 -3
  61. package/dist/esm/views/TamaguiProvider.js.map +2 -2
  62. package/package.json +10 -10
  63. package/src/addTheme.ts +3 -3
  64. package/src/config.ts +1 -1
  65. package/src/constants/platform.native.ts +1 -1
  66. package/src/constants/platform.ts +2 -2
  67. package/src/createComponent.tsx +10 -2
  68. package/src/createTamagui.ts +7 -10
  69. package/src/createVariable.ts +8 -1
  70. package/src/helpers/ThemeManager.tsx +4 -4
  71. package/src/helpers/getSplitStyles.tsx +25 -12
  72. package/src/helpers/getThemeCSSRules.ts +2 -2
  73. package/src/helpers/isTamaguiElement.tsx +3 -5
  74. package/src/hooks/useIsSSR.tsx +10 -5
  75. package/src/hooks/useIsTouchDevice.tsx +2 -2
  76. package/src/hooks/useMedia.tsx +65 -36
  77. package/src/hooks/useTheme.tsx +6 -6
  78. package/src/styled.tsx +40 -12
  79. package/src/types.tsx +45 -12
  80. package/src/updateTheme.ts +2 -2
  81. package/src/views/TamaguiProvider.tsx +3 -4
  82. package/types/addTheme.d.ts +2 -2
  83. package/types/config.d.ts +18 -2
  84. package/types/constants/platform.d.ts +1 -1
  85. package/types/constants/platform.native.d.ts +1 -1
  86. package/types/createVariable.d.ts +5 -0
  87. package/types/helpers/ThemeManager.d.ts +5 -5
  88. package/types/helpers/calc.d.ts +5 -0
  89. package/types/helpers/expandStyle.d.ts +4 -0
  90. package/types/helpers/expandStyles.d.ts +7 -0
  91. package/types/helpers/getSplitStyles.d.ts +3 -3
  92. package/types/helpers/getStylesAtomic.d.ts +4 -0
  93. package/types/helpers/getThemeCSSRules.d.ts +2 -2
  94. package/types/helpers/isTamaguiElement.d.ts +4 -6
  95. package/types/helpers/mergeProps.d.ts +13 -0
  96. package/types/helpers/normalizeValueWithProperty.d.ts +4 -0
  97. package/types/hooks/useIsSSR.d.ts +3 -1
  98. package/types/hooks/useMedia.d.ts +3 -3
  99. package/types/hooks/useTheme.d.ts +4 -4
  100. package/types/insertFont.d.ts +3 -0
  101. package/types/styled.d.ts +5 -1
  102. package/types/types.d.ts +112 -12
  103. package/types/updateTheme.d.ts +2 -2
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ThemeObject, Themes } from '../types';
2
+ import { ThemeParsed, Themes } from '../types';
3
3
  declare type ThemeListener = (name: string | null, themeManager: ThemeManager) => void;
4
4
  export declare type SetActiveThemeProps = {
5
5
  className?: string;
@@ -16,22 +16,22 @@ export declare type GetNextThemeProps = {
16
16
  export declare class ThemeManager {
17
17
  name: string;
18
18
  className: string;
19
- theme: ThemeObject | null;
19
+ theme: ThemeParsed | null;
20
20
  parentManager: ThemeManager | null;
21
21
  reset: boolean;
22
22
  keys: Map<any, Set<string>>;
23
23
  listeners: Map<any, Function>;
24
24
  themeListeners: Set<ThemeListener>;
25
- constructor(name?: string, className?: string, theme?: ThemeObject | null, parentManager?: ThemeManager | null, reset?: boolean);
25
+ constructor(name?: string, className?: string, theme?: ThemeParsed | null, parentManager?: ThemeManager | null, reset?: boolean);
26
26
  get didChangeTheme(): boolean | null;
27
27
  get parentName(): string | null;
28
28
  get fullName(): string;
29
- getValue(key: string): import("../types").VariableVal | undefined;
29
+ getValue(key: string): import("..").Variable<import("..").VariableValue> | undefined;
30
30
  isTracking(uuid: Object): boolean;
31
31
  update({ name, theme, className }?: SetActiveThemeProps, force?: boolean): boolean;
32
32
  getNextTheme(props?: GetNextThemeProps, debug?: any): {
33
33
  name: string;
34
- theme: ThemeObject | null;
34
+ theme: ThemeParsed | null;
35
35
  className: string | undefined;
36
36
  };
37
37
  getClassName(name: string): string;
@@ -1,4 +1,9 @@
1
1
  import { FontLineHeightTokens, FontSizeTokens, SizeTokens, SpaceTokens } from '../types';
2
+ /**
3
+ * Simple calc() that handles native + web
4
+ * on web: outputs a calc() string
5
+ * on native: outputs a plain number
6
+ */
2
7
  export declare type CalcVal = string | number | SizeTokens | SpaceTokens | FontSizeTokens | FontLineHeightTokens;
3
8
  declare const operators: {
4
9
  '+': (a: number, b: number) => number;
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Some parts adapted from react-native-web
3
+ * Copyright (c) Nicolas Gallagher licensed under the MIT license.
4
+ */
1
5
  export declare function expandStyle(key: string, value: any): any[][] | undefined;
2
6
  //# sourceMappingURL=expandStyle.d.ts.map
@@ -2,6 +2,13 @@ export declare const defaultOffset: {
2
2
  height: number;
3
3
  width: number;
4
4
  };
5
+ /**
6
+ * This is what you want to run before Object.assign() a style onto another.
7
+ * It does the following:
8
+ * 1. Turns user shorthands into longhands, ie px = paddingHorizontal
9
+ * 2. Normalizes various inconsistent styles to be more consistent
10
+ * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight
11
+ */
5
12
  export declare function expandStyles(style: Record<string, any>, config?: import("..").TamaguiInternalConfig<import("..").CreateTokens<import("..").VariableVal>, {
6
13
  [key: string]: Partial<import("..").TamaguiBaseTheme> & {
7
14
  [key: string]: import("..").VariableVal;
@@ -1,5 +1,5 @@
1
1
  import type { ViewStyle } from 'react-native';
2
- import type { DebugProp, MediaQueryKey, PseudoStyles, SplitStyleState, StackProps, StaticConfigParsed, TamaguiInternalConfig, ThemeObject } from '../types';
2
+ import type { DebugProp, MediaQueryKey, PseudoStyles, SplitStyleState, StackProps, StaticConfigParsed, TamaguiInternalConfig, ThemeParsed } from '../types';
3
3
  import { FontLanguageProps, LanguageContextType } from '../views/FontLanguage.types';
4
4
  import { RulesToInsert } from './insertStyleRule';
5
5
  export declare type SplitStyles = ReturnType<typeof getSplitStyles>;
@@ -7,7 +7,7 @@ export declare type ClassNamesObject = Record<string, string>;
7
7
  export declare type SplitStyleResult = ReturnType<typeof getSplitStyles>;
8
8
  declare type StyleSplitter = (props: {
9
9
  [key: string]: any;
10
- }, staticConfig: StaticConfigParsed, theme: ThemeObject, state: SplitStyleState, defaultClassNames?: any, languageContext?: LanguageContextType, debug?: DebugProp) => {
10
+ }, staticConfig: StaticConfigParsed, theme: ThemeParsed, state: SplitStyleState, defaultClassNames?: any, languageContext?: LanguageContextType, debug?: DebugProp) => {
11
11
  pseudos: PseudoStyles;
12
12
  medias: Record<MediaQueryKey, ViewStyle>;
13
13
  style: ViewStyle;
@@ -24,7 +24,7 @@ export declare const pseudoCNInverse: {
24
24
  press: string;
25
25
  };
26
26
  export declare const getSplitStyles: StyleSplitter;
27
- export declare const getSubStyle: (subKey: string, styleIn: Object, staticConfig: StaticConfigParsed, theme: ThemeObject, props: any, state: SplitStyleState, conf: TamaguiInternalConfig, languageContext?: FontLanguageProps, avoidDefaultProps?: boolean) => ViewStyle;
27
+ export declare const getSubStyle: (subKey: string, styleIn: Object, staticConfig: StaticConfigParsed, theme: ThemeParsed, props: any, state: SplitStyleState, conf: TamaguiInternalConfig, languageContext?: FontLanguageProps, avoidDefaultProps?: boolean) => ViewStyle;
28
28
  export declare const insertSplitStyles: StyleSplitter;
29
29
  export declare const useSplitStyles: StyleSplitter;
30
30
  export {};
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Some parts adapted from react-native-web
3
+ * Copyright (c) Nicolas Gallagher licensed under the MIT license.
4
+ */
1
5
  import { StyleObject } from '@tamagui/helpers';
2
6
  import type { TextStyle, ViewStyle } from 'react-native';
3
7
  import { PseudoDescriptor } from './pseudoDescriptors';
@@ -1,8 +1,8 @@
1
- import { CreateTamaguiProps, ThemeObject } from '../types';
1
+ import { CreateTamaguiProps, ThemeParsed } from '../types';
2
2
  export declare function getThemeCSSRules({ config, themeName, theme, names, }: {
3
3
  config: CreateTamaguiProps;
4
4
  themeName: string;
5
- theme: ThemeObject;
5
+ theme: ThemeParsed;
6
6
  names: string[];
7
7
  }): string[];
8
8
  //# sourceMappingURL=getThemeCSSRules.d.ts.map
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
- import { StaticConfig } from '../types';
3
- export declare type TamaguiReactElement = React.ReactElement & {
4
- type: {
5
- staticConfig: StaticConfig;
6
- };
2
+ import { TamaguiComponent } from '../types';
3
+ export declare type TamaguiReactElement<P = any> = React.ReactElement<P> & {
4
+ type: TamaguiComponent;
7
5
  };
8
- export declare const isTamaguiElement: (child: any, name?: string) => child is TamaguiReactElement;
6
+ export declare const isTamaguiElement: (child: any, name?: string) => child is TamaguiReactElement<any>;
9
7
  //# sourceMappingURL=isTamaguiElement.d.ts.map
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Preserves prop ordering, so that the order most closely matches the last spread objects
3
+ * Useful for having { ...defaultProps, ...props } that ensure props ordering is always kept
4
+ *
5
+ * Given:
6
+ * mergeProps({ a: 1, b: 2 }, { b: 1, a: 2 })
7
+ * The final key order will be:
8
+ * b, a
9
+ *
10
+ * Handles a couple special tamagui cases
11
+ * - classNames can be extracted out separately
12
+ * - shorthands can be expanded before merging
13
+ */
1
14
  declare type StringRecord = Record<string, string>;
2
15
  export declare const mergeProps: (a: Object, b: Object, leaveOutClassNames?: boolean, inverseShorthands?: StringRecord) => readonly [StringRecord, StringRecord];
3
16
  export {};
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Some parts adapted from react-native-web
3
+ * Copyright (c) Nicolas Gallagher licensed under the MIT license.
4
+ */
1
5
  export declare function normalizeValueWithProperty(value: any, property?: string): any;
2
6
  //# sourceMappingURL=normalizeValueWithProperty.d.ts.map
@@ -1,2 +1,4 @@
1
- export declare const useIsSSR: () => boolean;
1
+ export declare const useIsSSR: (props?: {
2
+ immediate?: boolean;
3
+ }) => boolean;
2
4
  //# sourceMappingURL=useIsSSR.d.ts.map
@@ -1,11 +1,11 @@
1
- import { ConfigureMediaQueryOptions, MediaQueries, MediaQueryKey, MediaQueryObject, MediaQueryState } from '../types';
1
+ import { MediaQueries, MediaQueryKey, MediaQueryObject, MediaQueryState, TamaguiInternalConfig } from '../types';
2
2
  export declare const mediaState: MediaQueryState;
3
3
  export declare function addMediaQueryListener(key: MediaQueryKey, cb: any): () => void;
4
4
  export declare function removeMediaQueryListener(key: MediaQueryKey, cb: any): void;
5
5
  export declare const mediaQueryConfig: MediaQueries;
6
6
  export declare const getMedia: () => MediaQueryState;
7
- export declare const configureMedia: ({ queries, defaultActive, }?: ConfigureMediaQueryOptions) => void;
8
- export declare function useMediaQueryListeners(): void;
7
+ export declare const configureMedia: (config: TamaguiInternalConfig) => void;
8
+ export declare function useMediaQueryListeners(config: TamaguiInternalConfig): void;
9
9
  export declare function useMedia(): {
10
10
  [key in MediaQueryKey]: boolean;
11
11
  };
@@ -1,5 +1,5 @@
1
1
  import { ThemeManager } from '../helpers/ThemeManager';
2
- import { ThemeName, ThemeObject } from '../types';
2
+ import { ThemeName, ThemeParsed } from '../types';
3
3
  export interface ThemeProps {
4
4
  className?: string;
5
5
  disableThemeClass?: boolean;
@@ -9,7 +9,7 @@ export interface ThemeProps {
9
9
  reset?: boolean;
10
10
  debug?: boolean | 'verbose';
11
11
  }
12
- export declare const useTheme: (themeName?: string | null, componentName?: string, props?: ThemeProps, forceUpdate?: any) => ThemeObject;
12
+ export declare const useTheme: (themeName?: string | null, componentName?: string, props?: ThemeProps, forceUpdate?: any) => ThemeParsed;
13
13
  export declare const getThemeManager: (theme: any) => ThemeManager | undefined;
14
14
  export declare const useThemeName: (opts?: {
15
15
  parent?: true;
@@ -17,10 +17,10 @@ export declare const useThemeName: (opts?: {
17
17
  export declare const useDefaultThemeName: () => ThemeName | undefined;
18
18
  export declare const activeThemeManagers: Set<ThemeManager>;
19
19
  export declare const useChangeThemeEffect: (name?: string | null, componentName?: string, props?: ThemeProps, forceUpdateProp?: any, uuid?: Object) => {
20
- themes: Record<string, ThemeObject>;
20
+ themes: Record<string, ThemeParsed>;
21
21
  themeManager: ThemeManager | null;
22
22
  name: string;
23
- theme: ThemeObject | null;
23
+ theme: ThemeParsed | null;
24
24
  className?: string | undefined;
25
25
  };
26
26
  //# sourceMappingURL=useTheme.d.ts.map
@@ -1,5 +1,8 @@
1
1
  import { DeepVariableObject } from './createVariables';
2
2
  import { GenericFont } from './types';
3
+ /**
4
+ * Runtime dynamic insert font
5
+ */
3
6
  export declare function insertFont<A extends GenericFont>(name: string, fontIn: A): DeepVariableObject<A>;
4
7
  export declare function parseFont<A extends GenericFont>(definition: A): DeepVariableObject<A>;
5
8
  export declare function registerFontVariables(parsedFont: any): string[];
package/types/styled.d.ts CHANGED
@@ -6,11 +6,15 @@ export declare type StyledOptions<ParentComponent extends StylableComponent> = G
6
6
  [key: string]: any;
7
7
  };
8
8
  };
9
+ declare type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<any, any, infer P> ? P : GetProps<A>;
10
+ declare type GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<any, any, any, infer V> ? V : {};
9
11
  export declare function styled<ParentComponent extends StylableComponent, Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void>(Component: ParentComponent, options?: GetProps<ParentComponent> & {
10
12
  name?: string;
11
13
  variants?: Variants | undefined;
12
14
  defaultVariants?: {
13
15
  [key: string]: any;
14
16
  };
15
- }, staticExtractionOptions?: Partial<StaticConfig>): TamaguiComponent<Variants extends void ? GetProps<ParentComponent> : (ParentComponent extends TamaguiComponent<any, any, infer P, {}> ? P : GetProps<ParentComponent>) & Omit<ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; }) & MediaProps<Partial<(ParentComponent extends TamaguiComponent<any, any, infer P, {}> ? P : GetProps<ParentComponent>) & Omit<ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>> & PseudoProps<Partial<(ParentComponent extends TamaguiComponent<any, any, infer P, {}> ? P : GetProps<ParentComponent>) & Omit<ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>>, TamaguiElement, ParentComponent extends TamaguiComponent<any, any, infer P, {}> ? P : GetProps<ParentComponent>, (ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}) & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>;
17
+ acceptsClassName?: boolean;
18
+ }, staticExtractionOptions?: Partial<StaticConfig>): TamaguiComponent<Variants extends void ? GetProps<ParentComponent> : GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; }) & MediaProps<Partial<GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>> & PseudoProps<Partial<GetBaseProps<ParentComponent> & Omit<GetVariantProps<ParentComponent>, keyof (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>>, TamaguiElement, GetBaseProps<ParentComponent>, GetVariantProps<ParentComponent> & (Variants extends void ? {} : { [Key in keyof Variants]?: (Variants[Key] extends VariantSpreadFunction<any, infer Val> ? Val : GetVariantValues<keyof Variants[Key]>) | undefined; })>;
19
+ export {};
16
20
  //# sourceMappingURL=styled.d.ts.map
package/types/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import React, { RefObject } from 'react';
3
3
  import { GestureResponderEvent, Image, PressableProps, TextProps as ReactTextProps, Text, TextInput, TextStyle, View, ViewProps, ViewStyle } from 'react-native';
4
4
  import { Variable } from './createVariable';
5
5
  import { ResolveVariableTypes } from './helpers/createPropMapper';
6
+ import { TamaguiReactElement } from './static';
6
7
  import { RNWTextProps, RNWViewProps } from './types-rnw';
7
8
  import { FontLanguageProps } from './views/FontLanguage.types';
8
9
  import { ThemeProviderProps } from './views/ThemeProvider';
@@ -107,7 +108,11 @@ export declare type CreateTamaguiConfig<A extends GenericTokens, B extends Gener
107
108
  fonts: RemoveLanguagePostfixes<F>;
108
109
  fontLanguages: GetLanguagePostfixes<F> extends never ? string[] : GetLanguagePostfixes<F>[];
109
110
  tokens: A;
110
- themes: B;
111
+ themes: {
112
+ [Name in keyof B]: {
113
+ [Key in keyof B[Name]]: Variable;
114
+ };
115
+ };
111
116
  shorthands: C;
112
117
  media: D;
113
118
  animations: AnimationDriver<E>;
@@ -128,13 +133,16 @@ declare type ConfProps<A extends GenericTokens, B extends GenericThemes, C exten
128
133
  };
129
134
  export declare type InferTamaguiConfig<Conf> = Conf extends ConfProps<infer A, infer B, infer C, infer D, infer E, infer F> ? TamaguiInternalConfig<A, B, C, D, E, F> : unknown;
130
135
  export declare type GenericTamaguiConfig = CreateTamaguiConfig<GenericTokens, GenericThemes, GenericShorthands, GenericMedia, GenericAnimations, GenericFonts>;
131
- export declare type ThemeObject = TamaguiConfig['themes'][keyof TamaguiConfig['themes']];
136
+ export declare type ThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['themes']];
137
+ export declare type ThemeKeys = keyof ThemeDefinition;
138
+ export declare type ThemeParsed = {
139
+ [key in ThemeKeys]: Variable;
140
+ };
132
141
  export declare type Tokens = TamaguiConfig['tokens'];
133
142
  export declare type Shorthands = TamaguiConfig['shorthands'];
134
143
  export declare type Media = TamaguiConfig['media'];
135
144
  export declare type Themes = TamaguiConfig['themes'];
136
145
  export declare type ThemeName = GetAltThemeNames<keyof Themes>;
137
- export declare type ThemeKeys = keyof ThemeObject;
138
146
  export declare type ThemeTokens = `$${ThemeKeys}`;
139
147
  export declare type AnimationKeys = Omit<GetAnimationKeys<TamaguiConfig>, number>;
140
148
  export declare type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>;
@@ -157,6 +165,24 @@ export declare type CreateTamaguiProps = {
157
165
  };
158
166
  };
159
167
  defaultTheme?: string;
168
+ /**
169
+ * *Advanced use case* For all CSS extracted views, this has no effect.
170
+ *
171
+ * For SSR compatibility on the web, Tamagui will render once with the settings
172
+ * from `mediaQueryDefaultActive` set for all media queries. Then, it will render
173
+ * again after the initial render using the proper media query values. This is so that
174
+ * hydration will match perfectly with the server.
175
+ *
176
+ * Setting disableSSR will avoid this second render by setting the media query state
177
+ * to the actual browser dimensions on initial load. This is only useful for client-only
178
+ * apps.
179
+ *
180
+ */
181
+ disableSSR?: boolean;
182
+ /**
183
+ * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.
184
+ * For custom use cases like integration with next-theme.
185
+ */
160
186
  disableRootThemeClass?: boolean;
161
187
  defaultProps?: Record<string, any> & {
162
188
  Stack?: StackProps;
@@ -176,7 +202,6 @@ export declare type TamaguiInternalConfig<A extends GenericTokens = GenericToken
176
202
  getCSS: () => string;
177
203
  parsed: boolean;
178
204
  inverseShorthands: Record<string, string>;
179
- themeClassNameOnRoot?: boolean;
180
205
  };
181
206
  export declare type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']['animations'];
182
207
  export declare type UnionableString = string & {};
@@ -226,10 +251,6 @@ export declare type MediaProps<A> = {
226
251
  export declare type MediaQueries = {
227
252
  [key in MediaQueryKey]: MediaQueryObject;
228
253
  };
229
- export declare type ConfigureMediaQueryOptions = {
230
- queries?: MediaQueries;
231
- defaultActive?: Record<MediaQueryKey, boolean>;
232
- };
233
254
  export declare type TransformStyleProps = {
234
255
  x?: number;
235
256
  y?: number;
@@ -264,7 +285,7 @@ declare type GetTokenFontKeysFor<A extends 'size' | 'weight' | 'letterSpacing' |
264
285
  declare type GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`;
265
286
  export declare type SizeTokens = GetTokenString<keyof Tokens['size']> | number;
266
287
  export declare type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean;
267
- export declare type ColorTokens = GetTokenString<keyof Tokens['color']> | GetTokenString<keyof ThemeObject> | CSSColorNames;
288
+ export declare type ColorTokens = GetTokenString<keyof Tokens['color']> | GetTokenString<keyof ThemeParsed> | CSSColorNames;
268
289
  export declare type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number;
269
290
  export declare type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number;
270
291
  export declare type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>;
@@ -347,7 +368,7 @@ export declare type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'chi
347
368
  disableInjectCSS?: boolean;
348
369
  children?: React.ReactNode;
349
370
  };
350
- export declare type PropMapper = (key: string, value: any, theme: ThemeObject, props: Record<string, any>, state: Partial<SplitStyleState>, languageContext?: FontLanguageProps, avoidDefaultProps?: boolean, debug?: DebugProp) => undefined | [string, any][];
371
+ export declare type PropMapper = (key: string, value: any, theme: ThemeParsed, props: Record<string, any>, state: Partial<SplitStyleState>, languageContext?: FontLanguageProps, avoidDefaultProps?: boolean, debug?: DebugProp) => undefined | [string, any][];
351
372
  export declare type StaticConfigParsed = StaticConfig & {
352
373
  parsed: true;
353
374
  propMapper: PropMapper;
@@ -367,36 +388,110 @@ export declare type GenericVariantDefinitions = {
367
388
  export declare type StaticConfig = {
368
389
  Component?: React.FunctionComponent<any> & StaticComponentObject;
369
390
  variants?: GenericVariantDefinitions;
391
+ /**
392
+ * Used for applying sub theme style
393
+ */
370
394
  componentName?: string;
395
+ /**
396
+ * (compiler) If you need to pass context or something, prevents from ever
397
+ * flattening. The 'jsx' option means it will never flatten. if you
398
+ * pass JSX as a children (if its purely string, it will still flatten).
399
+ */
371
400
  neverFlatten?: boolean | 'jsx';
401
+ /**
402
+ * Determines ultimate output tag (Text vs View)
403
+ */
372
404
  isText?: boolean;
405
+ /**
406
+ * Attempts to attach focus styles at runtime (useful for native)
407
+ */
373
408
  isInput?: boolean;
409
+ /**
410
+ * React native web images need special handling for className support
411
+ */
374
412
  isImage?: boolean;
413
+ /**
414
+ * Which style keys are allowed to be extracted.
415
+ */
375
416
  validStyles?: {
376
417
  [key: string]: boolean;
377
418
  };
419
+ /**
420
+ * Same as React.defaultProps, be sure to sync
421
+ */
378
422
  defaultProps: Record<string, any>;
423
+ /**
424
+ * (compiler) If these props are encountered, bail on all optimization.
425
+ */
379
426
  deoptProps?: Set<string>;
427
+ /**
428
+ * (compiler) If these props are encountered, leave them un-extracted.
429
+ */
380
430
  inlineProps?: Set<string>;
431
+ /**
432
+ * (compiler) If not flattening, leave this prop as original value.
433
+ * Only applies to style attributes
434
+ */
381
435
  inlineWhenUnflattened?: Set<string>;
436
+ /**
437
+ * (compiler) A bit odd, only for more advanced heirarchies.
438
+ * Indicates that the component will set this prop so the
439
+ * static extraction can ensure it sets them to ={undefined}
440
+ * so they get overriddent. In the future, this can be smarter.
441
+ */
382
442
  ensureOverriddenProp?: {
383
443
  [key: string]: boolean;
384
444
  };
445
+ /**
446
+ * Auto-detected, but can ovverride. Wraps children to space them on top
447
+ */
385
448
  isZStack?: boolean;
449
+ /**
450
+ * Merges into defaultProps later on, used internally yonly
451
+ */
386
452
  defaultVariants?: {
387
453
  [key: string]: any;
388
454
  };
455
+ /**
456
+ * Auto-detect, but can ovverride, passes styles properly to react-native-web
457
+ */
389
458
  isReactNativeWeb?: boolean;
459
+ /**
460
+ * Used internally to keep reference to the original rnw component
461
+ */
390
462
  reactNativeWebComponent?: any;
463
+ /**
464
+ * Memoize the component
465
+ */
391
466
  memo?: boolean;
467
+ /**
468
+ * Auto-detect, but can ovverride, passes styles properly to react-native-web
469
+ */
392
470
  isTamagui?: boolean;
471
+ /**
472
+ * Used internally to handle extractable HoC separate
473
+ */
393
474
  isHOC?: boolean;
475
+ /**
476
+ * Used insternally to attach default props to names
477
+ */
394
478
  parentNames?: string[];
395
- };
479
+ /**
480
+ * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,
481
+ * it will assume the passed in component only accepts style={} for react-native compatibility.
482
+ * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.
483
+ */
484
+ acceptsClassName?: boolean;
485
+ };
486
+ /**
487
+ * --------------------------------------------
488
+ * variants
489
+ * --------------------------------------------
490
+ */
396
491
  export declare type StylableComponent = TamaguiComponent | React.Component | React.ForwardRefExoticComponent<any> | ReactComponentWithRef<any, any> | (new (props: any) => any) | typeof View | typeof Text | typeof TextInput | typeof Image;
397
492
  export declare type GetStyledVariants<A extends TamaguiComponent> = A extends TamaguiComponent<any, any, any, infer Variants> ? Variants : never;
398
493
  export declare type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<any, any, infer BaseProps> ? BaseProps : never;
399
- export declare type GetProps<A extends StylableComponent> = A extends TamaguiComponent<infer Props> ? Props : A extends React.Component<infer Props> ? GetGenericComponentTamaguiProps<Props> : A extends new (props: infer Props) => any ? GetGenericComponentTamaguiProps<Props> : {};
494
+ export declare type GetProps<A extends StylableComponent> = A extends TamaguiComponent<infer Props> ? Props : A extends TamaguiReactElement<infer Props> ? Props : A extends React.Component<infer Props> ? GetGenericComponentTamaguiProps<Props> : A extends new (props: infer Props) => any ? GetGenericComponentTamaguiProps<Props> : {};
400
495
  declare type GetGenericComponentTamaguiProps<P> = P & Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>;
401
496
  export declare type SpreadKeys = '...fontSize' | '...fontStyle' | '...fontTransform' | '...lineHeight' | '...letterSpacing' | '...size' | '...space' | '...color' | '...zIndex' | '...theme' | '...radius';
402
497
  export declare type VariantDefinitions<Parent extends StylableComponent = TamaguiComponent, MyProps extends Object = GetProps<Parent>, Val = any> = VariantDefinitionFromProps<MyProps, Val>;
@@ -441,6 +536,11 @@ export declare type FontTransformVariantSpreadFunction<A extends PropLike> = Var
441
536
  export declare type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ZIndexTokens>;
442
537
  export declare type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, RadiusTokens>;
443
538
  export declare type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ThemeTokens>;
539
+ /**
540
+ * --------------------------------------------
541
+ * end variants
542
+ * --------------------------------------------
543
+ */
444
544
  declare type SizeKeys = 'width' | 'height' | 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'shadowRadius';
445
545
  declare type ColorKeys = 'color' | 'backgroundColor' | 'borderColor' | 'borderBottomColor' | 'borderTopColor' | 'borderLeftColor' | 'borderRightColor' | 'shadowColor' | 'textShadowColor';
446
546
  declare type SpaceKeys = 'space' | 'padding' | 'paddingHorizontal' | 'paddingVertical' | 'paddingLeft' | 'paddingTop' | 'paddingBottom' | 'paddingLeft' | 'paddingRight' | 'paddingEnd' | 'paddingStart' | 'margin' | 'marginHorizontal' | 'marginVertical' | 'marginLeft' | 'marginTop' | 'marginBottom' | 'marginLeft' | 'marginRight' | 'marginEnd' | 'marginStart' | 'x' | 'y' | 'scale' | 'scaleX' | 'scaleY' | 'borderTopEndRadius' | 'borderTopLeftRadius' | 'borderTopRightRadius' | 'borderTopStartRadius' | 'borderBottomEndRadius' | 'borderBottomLeftRadius' | 'borderBottomRightRadius' | 'borderBottomStartRadius' | 'borderBottomWidth' | 'borderLeftWidth' | 'borderRadius' | 'borderRightWidth' | 'borderTopEndRadius' | 'borderTopLeftRadius' | 'borderTopRightRadius' | 'borderEndWidth' | 'borderStartWidth' | 'borderTopStartRadius' | 'borderTopWidth' | 'borderWidth' | 'left' | 'top' | 'right' | 'bottom' | 'shadowOffset';
@@ -1,7 +1,7 @@
1
- import { ThemeObject } from './types';
1
+ import { ThemeDefinition } from './types';
2
2
  export declare function updateTheme({ name, theme }: {
3
3
  name: string;
4
- theme: ThemeObject;
4
+ theme: ThemeDefinition;
5
5
  }): {
6
6
  theme: any;
7
7
  cssRules: string[];