@tamagui/core 1.0.1 → 1.0.2

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 (69) hide show
  1. package/dist/cjs/config.js +3 -5
  2. package/dist/cjs/config.js.map +2 -2
  3. package/dist/cjs/constants/constants.js.map +2 -2
  4. package/dist/cjs/createFont.js.map +2 -2
  5. package/dist/cjs/helpers/ThemeManager.js +3 -15
  6. package/dist/cjs/helpers/ThemeManager.js.map +2 -2
  7. package/dist/cjs/helpers/cache.js +2 -2
  8. package/dist/cjs/helpers/cache.js.map +2 -2
  9. package/dist/cjs/helpers/getBoundingClientRect.js +3 -6
  10. package/dist/cjs/helpers/getBoundingClientRect.js.map +2 -2
  11. package/dist/cjs/helpers/getSplitStyles.js +1 -1
  12. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  13. package/dist/cjs/helpers/getStylesAtomic.js +2 -7
  14. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  15. package/dist/cjs/helpers/isTamaguiComponent.js +2 -7
  16. package/dist/cjs/helpers/isTamaguiComponent.js.map +2 -2
  17. package/dist/cjs/helpers/mergeProps.js +1 -1
  18. package/dist/cjs/helpers/mergeProps.js.map +2 -2
  19. package/dist/cjs/hooks/getThemeUnwrapped.js +1 -4
  20. package/dist/cjs/hooks/getThemeUnwrapped.js.map +2 -2
  21. package/dist/cjs/styled.js.map +2 -2
  22. package/dist/cjs/views/FontLanguage.js.map +2 -2
  23. package/dist/cjs/views/Text.js +0 -5
  24. package/dist/cjs/views/Text.js.map +2 -2
  25. package/dist/cjs/views/ThemeProvider.js +5 -6
  26. package/dist/cjs/views/ThemeProvider.js.map +2 -2
  27. package/dist/esm/config.js +3 -5
  28. package/dist/esm/config.js.map +2 -2
  29. package/dist/esm/constants/constants.js.map +2 -2
  30. package/dist/esm/createFont.js.map +2 -2
  31. package/dist/esm/helpers/ThemeManager.js +3 -15
  32. package/dist/esm/helpers/ThemeManager.js.map +2 -2
  33. package/dist/esm/helpers/cache.js +2 -2
  34. package/dist/esm/helpers/cache.js.map +2 -2
  35. package/dist/esm/helpers/getBoundingClientRect.js +3 -6
  36. package/dist/esm/helpers/getBoundingClientRect.js.map +2 -2
  37. package/dist/esm/helpers/getSplitStyles.js +1 -1
  38. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  39. package/dist/esm/helpers/getStylesAtomic.js +2 -7
  40. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  41. package/dist/esm/helpers/isTamaguiComponent.js +2 -7
  42. package/dist/esm/helpers/isTamaguiComponent.js.map +2 -2
  43. package/dist/esm/helpers/mergeProps.js +1 -1
  44. package/dist/esm/helpers/mergeProps.js.map +2 -2
  45. package/dist/esm/hooks/getThemeUnwrapped.js +1 -4
  46. package/dist/esm/hooks/getThemeUnwrapped.js.map +2 -2
  47. package/dist/esm/styled.js.map +2 -2
  48. package/dist/esm/views/FontLanguage.js.map +2 -2
  49. package/dist/esm/views/Text.js +0 -5
  50. package/dist/esm/views/Text.js.map +2 -2
  51. package/dist/esm/views/ThemeProvider.js +5 -6
  52. package/dist/esm/views/ThemeProvider.js.map +2 -2
  53. package/package.json +10 -10
  54. package/src/config.ts +4 -6
  55. package/src/constants/constants.ts +0 -2
  56. package/src/createFont.ts +0 -2
  57. package/src/helpers/ThemeManager.tsx +4 -20
  58. package/src/helpers/cache.ts +2 -5
  59. package/src/helpers/getBoundingClientRect.tsx +2 -5
  60. package/src/helpers/getSplitStyles.tsx +1 -1
  61. package/src/helpers/getStylesAtomic.ts +1 -9
  62. package/src/helpers/isTamaguiComponent.tsx +2 -6
  63. package/src/helpers/mergeProps.ts +1 -1
  64. package/src/hooks/getThemeUnwrapped.tsx +1 -3
  65. package/src/styled.tsx +1 -1
  66. package/src/views/FontLanguage.tsx +0 -2
  67. package/src/views/Text.tsx +0 -6
  68. package/src/views/ThemeProvider.tsx +8 -8
  69. package/types/helpers/cache.d.ts +2 -2
package/src/config.ts CHANGED
@@ -1,20 +1,18 @@
1
- import { ConfigListener, TamaguiInternalConfig, ThemeParsed, Tokens } from './types'
1
+ import { ConfigListener, TamaguiInternalConfig, Tokens } from './types'
2
2
 
3
3
  let conf: TamaguiInternalConfig | null
4
4
 
5
5
  export const setConfig = (next: TamaguiInternalConfig) => {
6
6
  conf = next
7
- if (configListeners.size) {
8
- configListeners.forEach((cb) => cb(next))
9
- }
7
+ configListeners.forEach((cb) => cb(next))
10
8
  }
11
9
 
12
10
  export const setConfigFont = (name: string, font: any, fontParsed: any) => {
13
11
  if (process.env.NODE_ENV === 'development') {
14
12
  if (!conf) throw new Error(`Haven't called createTamagui yet`)
15
13
  }
16
- Object.assign(conf!.fonts, { [name]: font })
17
- Object.assign(conf!.fontsParsed, { [`$${name}`]: fontParsed })
14
+ conf!.fonts[name] = font
15
+ conf!.fontsParsed[`$${name}`] = fontParsed
18
16
  }
19
17
 
20
18
  export const getConfig = () => {
@@ -1,5 +1,3 @@
1
- import { isWeb } from '@tamagui/constants'
2
-
3
1
  export const THEME_NAME_SEPARATOR = '_'
4
2
  export const THEME_CLASSNAME_PREFIX = 't_'
5
3
 
package/src/createFont.ts CHANGED
@@ -34,7 +34,6 @@ const processSection = <T>(
34
34
 
35
35
  export const createFont = <A extends GenericFont>(font: A): A => {
36
36
  const sizeKeys = Object.keys(font.size)
37
-
38
37
  const processedFont = Object.fromEntries(
39
38
  Object.entries(font).map(([key, section]) => {
40
39
  return [
@@ -47,6 +46,5 @@ export const createFont = <A extends GenericFont>(font: A): A => {
47
46
  ]
48
47
  })
49
48
  )
50
-
51
49
  return Object.freeze(processedFont) as A
52
50
  }
@@ -39,10 +39,7 @@ export class ThemeManager {
39
39
  this.updateState(props, false)
40
40
  return
41
41
  }
42
- if (!parentManager) {
43
- throw new Error('Must set up root first')
44
- }
45
-
42
+ if (!parentManager) throw `❌`
46
43
  // copy over listeners
47
44
  this.themeListeners = parentManager.themeListeners
48
45
 
@@ -205,22 +202,9 @@ function getState(
205
202
  ? max // component name only don't search upwards
206
203
  : 0
207
204
 
208
- if (process.env.NODE_ENV === 'development' && props.debug === 'verbose')
209
- [
210
- // eslint-disable-next-line no-console
211
- console.groupCollapsed('ThemeManager.getState()', props, {
212
- parentName,
213
- parentBaseTheme,
214
- base,
215
- min,
216
- max,
217
- isParentAComponentTheme,
218
- }),
219
- // eslint-disable-next-line no-console
220
- console.trace(),
221
- // eslint-disable-next-line no-console
222
- console.groupEnd(),
223
- ]
205
+ // prettier-ignore
206
+ // eslint-disable-next-line no-console
207
+ if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') [ console.groupCollapsed('ThemeManager.getState()', props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme }), console.trace(), console.groupEnd() ]
224
208
 
225
209
  for (let i = max; i >= min; i--) {
226
210
  let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR)
@@ -5,11 +5,8 @@ export type Style = { [key: string]: Value }
5
5
  const v: Record<string, any> = {}
6
6
 
7
7
  export const cache = {
8
- get(key: string, valStr: string) {
9
- return v[key]?.[valStr]
10
- },
11
-
12
- set(key: string, valStr: string, object: any) {
8
+ get: (key: string, valStr: string) => v[key]?.[valStr],
9
+ set: (key: string, valStr: string, object: any) => {
13
10
  v[key] ??= {}
14
11
  v[key][valStr] = object
15
12
  },
@@ -1,7 +1,4 @@
1
1
  export const getBoundingClientRect = (node: HTMLElement | null): void | DOMRect => {
2
- if (!node) return
3
- if (node.nodeType !== 1) return
4
- if (node.getBoundingClientRect) {
5
- return node.getBoundingClientRect()
6
- }
2
+ if (!node || node.nodeType !== 1) return
3
+ return node.getBoundingClientRect?.()
7
4
  }
@@ -643,7 +643,7 @@ export const getSplitStyles: StyleSplitter = (
643
643
  // we never animate in on server side just show the full thing
644
644
  // on client side we use CSS to hide the fully in SSR items, then
645
645
  // un-hide and replay with original animation.
646
- if (!isClient && isEnter) {
646
+ if (isWeb && !isClient && isEnter) {
647
647
  isDisabled = false
648
648
  }
649
649
 
@@ -56,16 +56,8 @@ export function getAtomicStyle(
56
56
  if (!style || typeof style !== 'object') {
57
57
  throw new Error(`Wrong style type: "${typeof style}": ${style}`)
58
58
  }
59
- } else {
60
- if (!style) {
61
- if (process.env.NODE_ENV === 'development') {
62
- // eslint-disable-next-line no-console
63
- console.warn('Invalid style')
64
- }
65
- return []
66
- }
67
59
  }
68
-
60
+ if (!style) return []
69
61
  return generateAtomicStyles(style, pseudo)
70
62
  }
71
63
 
@@ -6,10 +6,6 @@ export function isTamaguiComponent<A>(
6
6
  ): comp is A & {
7
7
  staticConfig: StaticConfig
8
8
  } {
9
- const config = comp && (comp['staticConfig'] as StaticConfigParsed | undefined)
10
- if (!config?.parsed) return false
11
- if (name) {
12
- return name === config.componentName
13
- }
14
- return true
9
+ const config = comp?.['staticConfig'] as StaticConfigParsed | undefined
10
+ return (config?.parsed && (name ? name === config.componentName : true)) || false
15
11
  }
@@ -41,7 +41,7 @@ function mergeProp(
41
41
  inverseShorthands?: AnyRecord
42
42
  ) {
43
43
  const val = a[key]
44
- const shorthand = inverseShorthands ? inverseShorthands[key] : null
44
+ const shorthand = inverseShorthands?.[key] || null
45
45
  if (b && (key in b || (shorthand && shorthand in b))) {
46
46
  return
47
47
  }
@@ -1,7 +1,5 @@
1
1
  export const getThemeUnwrapped = (theme: any) => {
2
- if (!theme) return null
3
- const first = theme[GetThemeUnwrapped]
4
- return first || theme
2
+ return theme?.[GetThemeUnwrapped] || theme
5
3
  }
6
4
 
7
5
  export const GetThemeUnwrapped = Symbol()
package/src/styled.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { stylePropsAll, validStyles } from '@tamagui/helpers'
1
+ import { stylePropsAll } from '@tamagui/helpers'
2
2
 
3
3
  import { createComponent } from './createComponent'
4
4
  import { ReactNativeStaticConfigs } from './setupReactNative'
@@ -1,5 +1,3 @@
1
- import React from 'react'
2
-
3
1
  import { FontLanguageProps } from './FontLanguage.types'
4
2
 
5
3
  export const FontLanguage = ({ children, ...props }: FontLanguageProps) => {
@@ -69,12 +69,6 @@ export const Text = createComponent<TextProps, TextView, TextPropsBase>({
69
69
  },
70
70
  },
71
71
 
72
- pressable: {
73
- true: {
74
- cursor: 'pointer',
75
- },
76
- },
77
-
78
72
  ellipse: {
79
73
  true: isWeb
80
74
  ? ellipseStyle
@@ -32,15 +32,15 @@ export const ThemeProvider = (props: ThemeProviderProps) => {
32
32
  }, [props.defaultTheme, props.disableRootThemeClass, props.themeClassNameOnRoot])
33
33
  }
34
34
 
35
- const value = useMemo(() => {
36
- return {
37
- defaultTheme: props.defaultTheme,
38
- }
39
- // NOTE DON'T CHANGE THIS ITS ONLY USED BY useThemeName for SSR safety for now...
40
- }, [])
41
-
42
35
  return (
43
- <ThemeProviderRootContext.Provider value={value}>
36
+ <ThemeProviderRootContext.Provider
37
+ value={useMemo(() => {
38
+ return {
39
+ defaultTheme: props.defaultTheme,
40
+ }
41
+ // NOTE DON'T CHANGE THIS ITS ONLY USED BY useThemeName for SSR safety for now...
42
+ }, [])}
43
+ >
44
44
  <Theme
45
45
  className={props.className}
46
46
  name={props.defaultTheme}
@@ -3,8 +3,8 @@ export type Style = {
3
3
  [key: string]: Value;
4
4
  };
5
5
  export declare const cache: {
6
- get(key: string, valStr: string): any;
7
- set(key: string, valStr: string, object: any): void;
6
+ get: (key: string, valStr: string) => any;
7
+ set: (key: string, valStr: string, object: any) => void;
8
8
  };
9
9
  export {};
10
10
  //# sourceMappingURL=cache.d.ts.map