@tamagui/core 1.0.1-beta.167 → 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 (94) 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/helpers/ThemeManager.js.map +1 -1
  12. package/dist/cjs/helpers/getSplitStyles.js +16 -9
  13. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  14. package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
  15. package/dist/cjs/hooks/useIsSSR.js +8 -4
  16. package/dist/cjs/hooks/useIsSSR.js.map +2 -2
  17. package/dist/cjs/hooks/useIsTouchDevice.js +1 -1
  18. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  19. package/dist/cjs/hooks/useMedia.js +48 -29
  20. package/dist/cjs/hooks/useMedia.js.map +2 -2
  21. package/dist/cjs/hooks/useTheme.js +1 -1
  22. package/dist/cjs/hooks/useTheme.js.map +2 -2
  23. package/dist/cjs/styled.js +11 -8
  24. package/dist/cjs/styled.js.map +2 -2
  25. package/dist/cjs/types.js.map +1 -1
  26. package/dist/cjs/updateTheme.js.map +2 -2
  27. package/dist/cjs/views/TamaguiProvider.js +2 -2
  28. package/dist/cjs/views/TamaguiProvider.js.map +2 -2
  29. package/dist/esm/addTheme.js.map +1 -1
  30. package/dist/esm/config.js.map +1 -1
  31. package/dist/esm/constants/platform.js +3 -3
  32. package/dist/esm/constants/platform.js.map +2 -2
  33. package/dist/esm/constants/platform.native.js +2 -2
  34. package/dist/esm/constants/platform.native.js.map +2 -2
  35. package/dist/esm/createComponent.js +4 -2
  36. package/dist/esm/createComponent.js.map +2 -2
  37. package/dist/esm/createTamagui.js +1 -4
  38. package/dist/esm/createTamagui.js.map +2 -2
  39. package/dist/esm/helpers/ThemeManager.js.map +1 -1
  40. package/dist/esm/helpers/getSplitStyles.js +16 -9
  41. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  42. package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
  43. package/dist/esm/hooks/useIsSSR.js +9 -5
  44. package/dist/esm/hooks/useIsSSR.js.map +2 -2
  45. package/dist/esm/hooks/useIsTouchDevice.js +2 -2
  46. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  47. package/dist/esm/hooks/useMedia.js +49 -30
  48. package/dist/esm/hooks/useMedia.js.map +2 -2
  49. package/dist/esm/hooks/useTheme.js +2 -2
  50. package/dist/esm/hooks/useTheme.js.map +2 -2
  51. package/dist/esm/styled.js +11 -8
  52. package/dist/esm/styled.js.map +2 -2
  53. package/dist/esm/updateTheme.js.map +2 -2
  54. package/dist/esm/views/TamaguiProvider.js +3 -3
  55. package/dist/esm/views/TamaguiProvider.js.map +2 -2
  56. package/package.json +10 -10
  57. package/src/addTheme.ts +3 -3
  58. package/src/config.ts +1 -1
  59. package/src/constants/platform.native.ts +1 -1
  60. package/src/constants/platform.ts +2 -2
  61. package/src/createComponent.tsx +10 -2
  62. package/src/createTamagui.ts +7 -10
  63. package/src/helpers/ThemeManager.tsx +4 -4
  64. package/src/helpers/getSplitStyles.tsx +25 -12
  65. package/src/helpers/getThemeCSSRules.ts +2 -2
  66. package/src/hooks/useIsSSR.tsx +10 -5
  67. package/src/hooks/useIsTouchDevice.tsx +2 -2
  68. package/src/hooks/useMedia.tsx +65 -36
  69. package/src/hooks/useTheme.tsx +6 -6
  70. package/src/styled.tsx +14 -8
  71. package/src/types.tsx +40 -12
  72. package/src/updateTheme.ts +2 -2
  73. package/src/views/TamaguiProvider.tsx +3 -4
  74. package/types/addTheme.d.ts +2 -2
  75. package/types/config.d.ts +18 -2
  76. package/types/constants/platform.d.ts +1 -1
  77. package/types/constants/platform.native.d.ts +1 -1
  78. package/types/createVariable.d.ts +4 -0
  79. package/types/helpers/ThemeManager.d.ts +5 -5
  80. package/types/helpers/calc.d.ts +5 -0
  81. package/types/helpers/expandStyle.d.ts +4 -0
  82. package/types/helpers/expandStyles.d.ts +7 -0
  83. package/types/helpers/getSplitStyles.d.ts +3 -3
  84. package/types/helpers/getStylesAtomic.d.ts +4 -0
  85. package/types/helpers/getThemeCSSRules.d.ts +2 -2
  86. package/types/helpers/mergeProps.d.ts +13 -0
  87. package/types/helpers/normalizeValueWithProperty.d.ts +4 -0
  88. package/types/hooks/useIsSSR.d.ts +3 -1
  89. package/types/hooks/useMedia.d.ts +3 -3
  90. package/types/hooks/useTheme.d.ts +4 -4
  91. package/types/insertFont.d.ts +3 -0
  92. package/types/styled.d.ts +1 -0
  93. package/types/types.d.ts +110 -11
  94. package/types/updateTheme.d.ts +2 -2
@@ -1,20 +1,39 @@
1
- import { useMemo, useState } from 'react'
1
+ import { useEffect, useMemo, useState } from 'react'
2
2
 
3
3
  import { useIsomorphicLayoutEffect } from '../constants/platform'
4
4
  import { matchMedia } from '../helpers/matchMedia'
5
5
  import {
6
- ConfigureMediaQueryOptions,
7
6
  MediaQueries,
8
7
  MediaQueryKey,
9
8
  MediaQueryObject,
10
9
  MediaQueryState,
10
+ TamaguiInternalConfig,
11
11
  } from '../types'
12
12
  import { useSafeRef } from './useSafeRef'
13
13
 
14
- export const mediaState: MediaQueryState = {} as any
14
+ export const mediaState: MediaQueryState =
15
+ // development time safeguard
16
+ process.env.NODE_ENV === 'development'
17
+ ? new Proxy(
18
+ {},
19
+ {
20
+ get(target, key) {
21
+ if (typeof key === 'string' && key[0] === '$') {
22
+ throw new Error(`Access of mediaState should never include $`)
23
+ }
24
+ return Reflect.get(target, key)
25
+ },
26
+ }
27
+ )
28
+ : ({} as any)
29
+
15
30
  const mediaQueryListeners: { [key: string]: Set<Function> } = {}
16
31
 
17
32
  export function addMediaQueryListener(key: MediaQueryKey, cb: any) {
33
+ if (process.env.NODE_ENV === 'development' && key[0] === '$') {
34
+ // eslint-disable-next-line no-console
35
+ console.warn(`Warning, listening to media queries shouldn't use the "$" prefix`)
36
+ }
18
37
  mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()
19
38
  mediaQueryListeners[key].add(cb)
20
39
  return () => removeMediaQueryListener(key, cb)
@@ -35,29 +54,17 @@ const dispose = new Set<Function>()
35
54
  // for SSR capture it at time of startup
36
55
  let initialMediaState: MediaQueryState | null
37
56
 
38
- export const configureMedia = ({
39
- queries,
40
- defaultActive = {},
41
- }: ConfigureMediaQueryOptions = {}) => {
42
- if (!queries) return
43
-
44
- // support hot reload
45
- if (initialMediaState) {
46
- if (process.env.NODE_ENV === 'development') {
47
- if (JSON.stringify(queries) === JSON.stringify(mediaQueryConfig)) {
48
- // hmr avoid update
49
- return
50
- }
51
- }
52
- setupMediaListeners()
53
- }
54
-
55
- Object.assign(mediaQueryConfig, queries)
56
- // start in the initial state
57
- for (const key in queries) {
58
- mediaState[key] = defaultActive[key] || false
57
+ export const configureMedia = (config: TamaguiInternalConfig) => {
58
+ const { media, mediaQueryDefaultActive } = config
59
+ if (!media) return
60
+ for (const key in media) {
61
+ mediaState[key] = mediaQueryDefaultActive?.[key] || false
59
62
  }
63
+ Object.assign(mediaQueryConfig, media)
60
64
  initialMediaState = { ...mediaState }
65
+ if (config.disableSSR) {
66
+ setupMediaListeners()
67
+ }
61
68
  }
62
69
 
63
70
  function unlisten() {
@@ -65,7 +72,20 @@ function unlisten() {
65
72
  dispose.clear()
66
73
  }
67
74
 
75
+ /**
76
+ * Note: This should *not* set the state on the first render!
77
+ * Because to avoid hydration issues SSR must match the server
78
+ * *and then* re-render with the actual media query state.
79
+ */
80
+ let configuredKey = ''
68
81
  function setupMediaListeners() {
82
+ // avoid setting up more than once per config
83
+ const nextKey = JSON.stringify(mediaQueryConfig)
84
+ if (nextKey === configuredKey) {
85
+ return
86
+ }
87
+ configuredKey = nextKey
88
+
69
89
  // hmr, undo existing before re-binding
70
90
  unlisten()
71
91
 
@@ -79,6 +99,7 @@ function setupMediaListeners() {
79
99
  // react native needs these deprecated apis for now
80
100
  match.addListener(update)
81
101
  dispose.add(() => match.removeListener(update))
102
+
82
103
  update()
83
104
 
84
105
  function update() {
@@ -87,16 +108,18 @@ function setupMediaListeners() {
87
108
  mediaState[key] = next
88
109
  const listeners = mediaQueryListeners[key]
89
110
  if (listeners?.size) {
90
- for (const cb of [...listeners]) {
91
- cb()
92
- }
111
+ listeners.forEach((cb) => cb())
93
112
  }
94
113
  }
95
114
  }
96
115
  }
97
116
 
98
- export function useMediaQueryListeners() {
99
- useIsomorphicLayoutEffect(() => {
117
+ export function useMediaQueryListeners(config: TamaguiInternalConfig) {
118
+ if (config.disableSSR) {
119
+ return
120
+ }
121
+
122
+ useEffect(() => {
100
123
  setupMediaListeners()
101
124
  return unlisten
102
125
  }, [])
@@ -105,7 +128,7 @@ export function useMediaQueryListeners() {
105
128
  export function useMedia(): {
106
129
  [key in MediaQueryKey]: boolean
107
130
  } {
108
- const [state, setState] = useState(initialMediaState!)
131
+ const [state, setState] = useState(initialMediaState || {})
109
132
  const keys = useSafeRef({} as Record<string, boolean>)
110
133
 
111
134
  function updateState() {
@@ -120,13 +143,12 @@ export function useMedia(): {
120
143
  }
121
144
 
122
145
  useIsomorphicLayoutEffect(() => {
123
- const listeners: Function[] = []
124
- for (const key in keys.current) {
125
- listeners.push(addMediaQueryListener(key, updateState))
126
- }
146
+ const disposes: Function[] = Object.keys(keys.current).map((key) =>
147
+ addMediaQueryListener(key, updateState)
148
+ )
127
149
  updateState()
128
150
  return () => {
129
- listeners.forEach((cb) => cb())
151
+ disposes.forEach((cb) => cb())
130
152
  }
131
153
  })
132
154
 
@@ -134,8 +156,15 @@ export function useMedia(): {
134
156
  () =>
135
157
  new Proxy(state, {
136
158
  get(_, key: string) {
159
+ if (process.env.NODE_ENV === 'development') {
160
+ if (!initialMediaState) {
161
+ throw new Error(
162
+ `To use useMedia() you must pass in media configuration to createTamagui, none was found.`
163
+ )
164
+ }
165
+ }
137
166
  if (!keys.current[key]) {
138
- keys.current = { ...keys.current, [key]: true }
167
+ keys.current[key] = true
139
168
  }
140
169
  return Reflect.get(state, key)
141
170
  },
@@ -3,7 +3,7 @@ import React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'r
3
3
 
4
4
  import { getConfig } from '../config'
5
5
  import { isDevTools } from '../constants/isDevTools'
6
- import { isRSC, isSSR, useIsomorphicLayoutEffect } from '../constants/platform'
6
+ import { isRSC, isServer, useIsomorphicLayoutEffect } from '../constants/platform'
7
7
  import { ThemeContext } from '../contexts/ThemeContext'
8
8
  import { areEqualSets } from '../helpers/areEqualSets'
9
9
  import {
@@ -12,7 +12,7 @@ import {
12
12
  ThemeManagerContext,
13
13
  emptyManager,
14
14
  } from '../helpers/ThemeManager'
15
- import { ThemeName, ThemeObject } from '../types'
15
+ import { ThemeName, ThemeParsed } from '../types'
16
16
  import { GetThemeUnwrapped } from './getThemeUnwrapped'
17
17
  import { useConstant } from './useConstant'
18
18
  import { useServerRef } from './useServerHooks'
@@ -38,7 +38,7 @@ export const useTheme = (
38
38
  componentName?: string,
39
39
  props?: ThemeProps,
40
40
  forceUpdate?: any
41
- ): ThemeObject => {
41
+ ): ThemeParsed => {
42
42
  // TODO this can use useChangeThemeEffect almost ready
43
43
  if (isRSC) {
44
44
  const config = getConfig()
@@ -195,10 +195,10 @@ export const useChangeThemeEffect = (
195
195
  forceUpdateProp?: any,
196
196
  uuid?: Object
197
197
  ): {
198
- themes: Record<string, ThemeObject>
198
+ themes: Record<string, ThemeParsed>
199
199
  themeManager: ThemeManager | null
200
200
  name: string
201
- theme: ThemeObject | null
201
+ theme: ThemeParsed | null
202
202
  className?: string
203
203
  } => {
204
204
  const { themes } = getConfig()
@@ -236,7 +236,7 @@ export const useChangeThemeEffect = (
236
236
  return new ThemeManager(next.name, next.className, next.theme, parentManager, reset)
237
237
  })
238
238
 
239
- if (!isSSR) {
239
+ if (!isServer) {
240
240
  useLayoutEffect(() => {
241
241
  themeManager.update(next)
242
242
 
package/src/styled.tsx CHANGED
@@ -48,6 +48,7 @@ export function styled<
48
48
  variants?: Variants | undefined
49
49
  // thought i had this typed, but can't get it linked
50
50
  defaultVariants?: { [key: string]: any }
51
+ acceptsClassName?: boolean
51
52
  },
52
53
  staticExtractionOptions?: Partial<StaticConfig>
53
54
  ) {
@@ -73,7 +74,13 @@ export function styled<
73
74
  }
74
75
 
75
76
  if (options) {
76
- const { variants, name, defaultVariants, ...defaultProps } = options
77
+ const {
78
+ variants,
79
+ name,
80
+ defaultVariants,
81
+ acceptsClassName: acceptsClassNameProp,
82
+ ...defaultProps
83
+ } = options
77
84
  if (defaultVariants) {
78
85
  Object.assign(defaultProps, defaultVariants)
79
86
  }
@@ -84,12 +91,7 @@ export function styled<
84
91
  RNComponents.add(Component)
85
92
  isReactNativeWeb = true
86
93
  } else {
87
- if (process.env.NODE_ENV === 'development') {
88
- // eslint-disable-next-line no-console
89
- console.warn(
90
- `Invalid styled() component: Tamagui only accepts react-native Text, View, Image, TextInput, or another styled Tamagui view`
91
- )
92
- }
94
+ // assuming some sort of non-tamagui non-rn view, will always use style={}
93
95
  }
94
96
  }
95
97
  const reactNativeWebComponent = isReactNativeWeb
@@ -107,6 +109,8 @@ export function styled<
107
109
  isInput || staticExtractionOptions?.isText || parentStaticConfig?.isText || Comp === Text
108
110
  )
109
111
 
112
+ const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNativeWeb)
113
+
110
114
  const conf: Partial<StaticConfig> = {
111
115
  ...staticExtractionOptions,
112
116
  ...(!isTamagui && {
@@ -125,10 +129,12 @@ export function styled<
125
129
  isInput,
126
130
  isText,
127
131
  isImage,
132
+ acceptsClassName,
128
133
  }
129
134
 
130
135
  // TODO compiler doesn't have logic to include children, de-opt (see EnsureFlexed for test usage)
131
- if (defaultProps.children) {
136
+ // bail on non className views as well
137
+ if (defaultProps.children || !acceptsClassName) {
132
138
  conf.neverFlatten = true
133
139
  }
134
140
 
package/src/types.tsx CHANGED
@@ -162,7 +162,12 @@ export type CreateTamaguiConfig<
162
162
  fonts: RemoveLanguagePostfixes<F>
163
163
  fontLanguages: GetLanguagePostfixes<F> extends never ? string[] : GetLanguagePostfixes<F>[]
164
164
  tokens: A
165
- themes: B
165
+ // parsed
166
+ themes: {
167
+ [Name in keyof B]: {
168
+ [Key in keyof B[Name]]: Variable
169
+ }
170
+ }
166
171
  shorthands: C
167
172
  media: D
168
173
  animations: AnimationDriver<E>
@@ -230,13 +235,16 @@ export type GenericTamaguiConfig = CreateTamaguiConfig<
230
235
  >
231
236
 
232
237
  // since TamaguiConfig will be re-declared, these will all be typed globally
233
- export type ThemeObject = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]
238
+ export type ThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]
239
+ export type ThemeKeys = keyof ThemeDefinition
240
+ export type ThemeParsed = {
241
+ [key in ThemeKeys]: Variable
242
+ }
234
243
  export type Tokens = TamaguiConfig['tokens']
235
244
  export type Shorthands = TamaguiConfig['shorthands']
236
245
  export type Media = TamaguiConfig['media']
237
246
  export type Themes = TamaguiConfig['themes']
238
247
  export type ThemeName = GetAltThemeNames<keyof Themes>
239
- export type ThemeKeys = keyof ThemeObject
240
248
  export type ThemeTokens = `$${ThemeKeys}`
241
249
  export type AnimationKeys = Omit<GetAnimationKeys<TamaguiConfig>, number>
242
250
  export type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>
@@ -264,6 +272,26 @@ export type CreateTamaguiProps = {
264
272
  }
265
273
 
266
274
  defaultTheme?: string
275
+
276
+ /**
277
+ * *Advanced use case* For all CSS extracted views, this has no effect.
278
+ *
279
+ * For SSR compatibility on the web, Tamagui will render once with the settings
280
+ * from `mediaQueryDefaultActive` set for all media queries. Then, it will render
281
+ * again after the initial render using the proper media query values. This is so that
282
+ * hydration will match perfectly with the server.
283
+ *
284
+ * Setting disableSSR will avoid this second render by setting the media query state
285
+ * to the actual browser dimensions on initial load. This is only useful for client-only
286
+ * apps.
287
+ *
288
+ */
289
+ disableSSR?: boolean
290
+
291
+ /**
292
+ * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.
293
+ * For custom use cases like integration with next-theme.
294
+ */
267
295
  disableRootThemeClass?: boolean
268
296
 
269
297
  defaultProps?: Record<string, any> & {
@@ -314,9 +342,6 @@ export type TamaguiInternalConfig<
314
342
  getCSS: () => string
315
343
  parsed: boolean
316
344
  inverseShorthands: Record<string, string>
317
-
318
- // just passed in from CreateTamaguiProps
319
- themeClassNameOnRoot?: boolean
320
345
  }
321
346
 
322
347
  export type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']['animations']
@@ -352,10 +377,6 @@ export type MediaProps<A> = {
352
377
  export type MediaQueries = {
353
378
  [key in MediaQueryKey]: MediaQueryObject
354
379
  }
355
- export type ConfigureMediaQueryOptions = {
356
- queries?: MediaQueries
357
- defaultActive?: Record<MediaQueryKey, boolean>
358
- }
359
380
 
360
381
  export type TransformStyleProps = {
361
382
  x?: number
@@ -423,7 +444,7 @@ export type SizeTokens = GetTokenString<keyof Tokens['size']> | number
423
444
  export type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean
424
445
  export type ColorTokens =
425
446
  | GetTokenString<keyof Tokens['color']>
426
- | GetTokenString<keyof ThemeObject>
447
+ | GetTokenString<keyof ThemeParsed>
427
448
  | CSSColorNames
428
449
  export type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number
429
450
  export type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number
@@ -640,7 +661,7 @@ export type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>>
640
661
  export type PropMapper = (
641
662
  key: string,
642
663
  value: any,
643
- theme: ThemeObject,
664
+ theme: ThemeParsed,
644
665
  props: Record<string, any>,
645
666
  state: Partial<SplitStyleState>,
646
667
  languageContext?: FontLanguageProps,
@@ -773,6 +794,13 @@ export type StaticConfig = {
773
794
  * Used insternally to attach default props to names
774
795
  */
775
796
  parentNames?: string[]
797
+
798
+ /**
799
+ * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,
800
+ * it will assume the passed in component only accepts style={} for react-native compatibility.
801
+ * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.
802
+ */
803
+ acceptsClassName?: boolean
776
804
  }
777
805
 
778
806
  /**
@@ -1,8 +1,8 @@
1
1
  import { addTheme } from './addTheme'
2
2
  import { activeThemeManagers } from './hooks/useTheme'
3
- import { ThemeObject } from './types'
3
+ import { ThemeDefinition } from './types'
4
4
 
5
- export function updateTheme({ name, theme }: { name: string; theme: ThemeObject }) {
5
+ export function updateTheme({ name, theme }: { name: string; theme: ThemeDefinition }) {
6
6
  const next = addTheme({ name, theme, insertCSS: true, update: true })
7
7
 
8
8
  if (process.env.TAMAGUI_TARGET === 'native') {
@@ -1,7 +1,6 @@
1
- import { useForceUpdate } from '@tamagui/use-force-update'
2
1
  import * as React from 'react'
3
2
 
4
- import { isClient, isRSC, isSSR } from '../constants/platform'
3
+ import { isClient, isRSC, isServer } from '../constants/platform'
5
4
  import { ButtonInsideButtonContext } from '../contexts/ButtonInsideButtonContext'
6
5
  import { TextAncestorProvider } from '../contexts/TextAncestorContext'
7
6
  import { useMediaQueryListeners } from '../hooks/useMedia'
@@ -22,8 +21,8 @@ export function TamaguiProvider({
22
21
  )
23
22
  }
24
23
 
25
- if (!isSSR) {
26
- useMediaQueryListeners()
24
+ if (!isServer) {
25
+ useMediaQueryListeners(config)
27
26
  }
28
27
 
29
28
  if (isClient) {
@@ -1,7 +1,7 @@
1
- import { ThemeObject } from './types';
1
+ import { ThemeDefinition } from './types';
2
2
  export declare function addTheme({ name: themeName, theme: themeIn, insertCSS, update, }: {
3
3
  name: string;
4
- theme: ThemeObject;
4
+ theme: ThemeDefinition;
5
5
  insertCSS?: boolean;
6
6
  update?: boolean;
7
7
  }): {
package/types/config.d.ts CHANGED
@@ -17,8 +17,24 @@ export declare const getConfig: () => TamaguiInternalConfig<import("./types").Cr
17
17
  }, import("./types").GenericFonts>;
18
18
  export declare const getTokens: () => import("./types").CreateTokens<import("./createVariable").Variable<import("./createVariable").VariableValue>>;
19
19
  export declare const getThemes: () => {
20
- [key: string]: Partial<import("./types").TamaguiBaseTheme> & {
21
- [key: string]: import("./types").VariableVal;
20
+ [x: string]: {
21
+ [x: string]: import("./createVariable").Variable<import("./createVariable").VariableValue>;
22
+ background?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
23
+ backgroundHover?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
24
+ backgroundPress?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
25
+ backgroundFocus?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
26
+ color?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
27
+ colorHover?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
28
+ colorPress?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
29
+ colorFocus?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
30
+ borderColor?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
31
+ borderColorHover?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
32
+ borderColorPress?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
33
+ borderColorFocus?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
34
+ shadowColor?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
35
+ shadowColorHover?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
36
+ shadowColorPress?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
37
+ shadowColorFocus?: import("./createVariable").Variable<import("./createVariable").VariableValue> | undefined;
22
38
  };
23
39
  };
24
40
  export declare const configListeners: Set<ConfigListener>;
@@ -3,7 +3,7 @@ export declare const isAndroid: boolean;
3
3
  export declare const isIOS: boolean;
4
4
  export declare const isWeb: boolean;
5
5
  export declare const isWindowDefined: boolean;
6
- export declare const isSSR: boolean;
6
+ export declare const isServer: boolean;
7
7
  export declare const isClient: boolean;
8
8
  export declare const isRSC: any;
9
9
  export declare const useIsomorphicLayoutEffect: typeof useEffect;
@@ -3,7 +3,7 @@ export declare const isAndroid: boolean;
3
3
  export declare const isIOS: boolean;
4
4
  export declare const isWeb = false;
5
5
  export declare const isWindowDefined = false;
6
- export declare const isSSR = false;
6
+ export declare const isServer = false;
7
7
  export declare const isClient = false;
8
8
  export declare const isRSC = false;
9
9
  export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Should rename this to Token
3
+ * Moving to objects for React Server Components support
4
+ */
1
5
  declare const IS_VAR = "__isVar__";
2
6
  export declare type VariableValue = string | number;
3
7
  declare type VariableIn<A extends VariableValue = VariableValue> = {
@@ -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,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
  };