@tamagui/core 1.0.1-beta.191 → 1.0.1-beta.193

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 (38) hide show
  1. package/dist/cjs/createComponent.js +15 -7
  2. package/dist/cjs/createComponent.js.map +2 -2
  3. package/dist/cjs/helpers/createProxy.js +43 -0
  4. package/dist/cjs/helpers/createProxy.js.map +7 -0
  5. package/dist/cjs/helpers/getSplitStyles.js +13 -12
  6. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  7. package/dist/cjs/helpers/getVariantExtras.js +2 -1
  8. package/dist/cjs/helpers/getVariantExtras.js.map +2 -2
  9. package/dist/cjs/helpers/proxyThemeVariables.js +2 -5
  10. package/dist/cjs/helpers/proxyThemeVariables.js.map +2 -2
  11. package/dist/cjs/hooks/useMedia.js +2 -1
  12. package/dist/cjs/hooks/useMedia.js.map +2 -2
  13. package/dist/cjs/hooks/useTheme.js +2 -1
  14. package/dist/cjs/hooks/useTheme.js.map +2 -2
  15. package/dist/esm/createComponent.js +15 -7
  16. package/dist/esm/createComponent.js.map +2 -2
  17. package/dist/esm/helpers/createProxy.js +19 -0
  18. package/dist/esm/helpers/createProxy.js.map +7 -0
  19. package/dist/esm/helpers/getSplitStyles.js +13 -12
  20. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  21. package/dist/esm/helpers/getVariantExtras.js +2 -1
  22. package/dist/esm/helpers/getVariantExtras.js.map +2 -2
  23. package/dist/esm/helpers/proxyThemeVariables.js +2 -5
  24. package/dist/esm/helpers/proxyThemeVariables.js.map +2 -2
  25. package/dist/esm/hooks/useMedia.js +2 -1
  26. package/dist/esm/hooks/useMedia.js.map +2 -2
  27. package/dist/esm/hooks/useTheme.js +2 -1
  28. package/dist/esm/hooks/useTheme.js.map +2 -2
  29. package/package.json +11 -11
  30. package/src/createComponent.tsx +17 -8
  31. package/src/helpers/createProxy.ts +16 -0
  32. package/src/helpers/getSplitStyles.tsx +12 -12
  33. package/src/helpers/getVariantExtras.tsx +2 -1
  34. package/src/helpers/proxyThemeVariables.tsx +3 -6
  35. package/src/hooks/useMedia.tsx +2 -1
  36. package/src/hooks/useTheme.tsx +2 -1
  37. package/types/helpers/createProxy.d.ts +2 -0
  38. package/src/helpers/validate.ts +0 -80
@@ -20,6 +20,7 @@ import type {
20
20
  import { FontLanguageProps, LanguageContextType } from '../views/FontLanguage.types'
21
21
  import { createMediaStyle } from './createMediaStyle'
22
22
  import { getPropMappedFontFamily } from './createPropMapper'
23
+ import { createProxy } from './createProxy'
23
24
  import { fixStyles } from './expandStyles'
24
25
  import { getAtomicStyle, getStylesAtomic, styleToCSS } from './getStylesAtomic'
25
26
  import {
@@ -45,8 +46,11 @@ const skipProps = {
45
46
  animateOnly: true,
46
47
  debug: true,
47
48
  componentName: true,
49
+ }
48
50
 
49
- ...(!isWeb && {
51
+ // native only skips
52
+ if (process.env.TAMAGUI_TARGET === 'native') {
53
+ Object.assign(skipProps, {
50
54
  tag: true,
51
55
  whiteSpace: true,
52
56
  wordWrap: true,
@@ -58,7 +62,7 @@ const skipProps = {
58
62
  contain: true,
59
63
  boxSizing: true,
60
64
  boxShadow: true,
61
- }),
65
+ })
62
66
  }
63
67
 
64
68
  type TransformNamespaceKey = 'transform' | PseudoPropKeys | MediaQueryKey
@@ -478,17 +482,13 @@ export const getSplitStyles: StyleSplitter = (
478
482
  }
479
483
  }
480
484
 
481
- if (shouldDoClasses) {
482
- const atomic = getStylesAtomic(style)
483
- for (const atomicStyle of atomic) {
484
- const key = atomicStyle.property
485
- // pointerEvents box-none must be CSS-ified
486
- // should probably have a few more exceptions here!
487
- if (key === 'pointerEvents' || !state.dynamicStylesInline) {
485
+ if (process.env.TAMAGUI_TARGET === 'web') {
486
+ if (shouldDoClasses) {
487
+ const atomic = getStylesAtomic(style)
488
+ for (const atomicStyle of atomic) {
489
+ const key = atomicStyle.property
488
490
  addStyleToInsertRules(rulesToInsert, atomicStyle)
489
491
  mergeClassName(transforms, classNames, key, atomicStyle.identifier)
490
- } else {
491
- style[key] = atomicStyle.value
492
492
  }
493
493
  }
494
494
  }
@@ -655,7 +655,7 @@ function getSubStyleProxiedProps(defaultProps: Object, baseProps: Object, specif
655
655
  if (propProxies.has(specificProps)) {
656
656
  return propProxies.get(specificProps)
657
657
  }
658
- const next = new Proxy(specificProps, {
658
+ const next = createProxy(specificProps, {
659
659
  has(_, key) {
660
660
  return key in defaultProps || key in specificProps || key in baseProps
661
661
  },
@@ -1,6 +1,7 @@
1
1
  import { getConfig } from '../config'
2
2
  import { GenericFonts } from '../types'
3
3
  import { LanguageContextType } from '../views/FontLanguage.types'
4
+ import { createProxy } from './createProxy'
4
5
 
5
6
  const extrasCache = new WeakMap()
6
7
 
@@ -30,7 +31,7 @@ export function getVariantExtras(
30
31
  // we avoid passing in default props for media queries because that would confuse things like SizableText.size:
31
32
  props: avoidDefaultProps
32
33
  ? props
33
- : new Proxy(props, {
34
+ : createProxy(props, {
34
35
  // handles shorthands
35
36
  get(target, key) {
36
37
  const shorthand = conf.inverseShorthands[key as any]
@@ -1,10 +1,7 @@
1
+ import { createProxy } from './createProxy'
2
+
1
3
  export function proxyThemeVariables<A extends Object>(obj: A): A {
2
- if (process.env.NODE_ENV === 'development' && !obj) {
3
- // eslint-disable-next-line no-console
4
- console.trace(`empty value for proxyThemeVariables`, obj)
5
- return obj
6
- }
7
- return new Proxy<A>(obj || {}, {
4
+ return createProxy<A>(obj || {}, {
8
5
  has(target, key) {
9
6
  return Reflect.has(target, removeStarting$(key))
10
7
  },
@@ -2,6 +2,7 @@ import { useIsomorphicLayoutEffect } from '@tamagui/constants'
2
2
  import { startTransition, useEffect, useMemo, useState } from 'react'
3
3
 
4
4
  import { getConfig } from '../config'
5
+ import { createProxy } from '../helpers/createProxy'
5
6
  import { matchMedia } from '../helpers/matchMedia'
6
7
  import {
7
8
  MediaQueries,
@@ -15,7 +16,7 @@ import { useSafeRef } from './useSafeRef'
15
16
  export const mediaState: MediaQueryState =
16
17
  // development time safeguard
17
18
  process.env.NODE_ENV === 'development'
18
- ? new Proxy(
19
+ ? createProxy(
19
20
  {},
20
21
  {
21
22
  get(target, key) {
@@ -6,6 +6,7 @@ import { getConfig } from '../config'
6
6
  import { isDevTools } from '../constants/isDevTools'
7
7
  import { ThemeContext } from '../contexts/ThemeContext'
8
8
  import { areEqualSets } from '../helpers/areEqualSets'
9
+ import { createProxy } from '../helpers/createProxy'
9
10
  import {
10
11
  GetNextThemeProps,
11
12
  ThemeManager,
@@ -111,7 +112,7 @@ function getThemeProxied(
111
112
  state?: React.MutableRefObject<UseThemeState>,
112
113
  debugProp?: boolean | 'verbose'
113
114
  ) {
114
- return new Proxy(theme, {
115
+ return createProxy(theme, {
115
116
  has(_, key) {
116
117
  if (typeof key === 'string' && key[0] === '$') {
117
118
  key = key.slice(1)
@@ -0,0 +1,2 @@
1
+ export declare function createProxy<A extends object>(target: A, handler: ProxyHandler<A>): A;
2
+ //# sourceMappingURL=createProxy.d.ts.map
@@ -1,80 +0,0 @@
1
- // // published a patched version that works on native
2
- // // @ts-ignore
3
- // import { default as ow } from '@tamagui/ow/dev-only'
4
-
5
- // let Config: any
6
- // let Tokens: any
7
- // let FontRequired: any
8
- // let FontOptional: any
9
-
10
- // export const validateConfig = (conf: any) => {
11
- // if (!conf) {
12
- // console.warn('no conf?')
13
- // return
14
- // }
15
- // try {
16
- // ow(conf, Config)
17
- // } catch (err: any) {
18
- // console.warn('Given config:\n', JSON.stringify(conf, null, 2), err)
19
- // }
20
- // }
21
-
22
- // export const validateTokens = (tokens: any) => {
23
- // try {
24
- // ow(tokens, Tokens)
25
- // } catch (err: any) {
26
- // console.warn('Given tokens:\n', JSON.stringify(tokens, null, 2), err)
27
- // }
28
- // }
29
-
30
- // export const validateFont = (font: any) => {
31
- // try {
32
- // const { style, transform, color, ...required } = font
33
- // ow(required, FontRequired)
34
- // ow({ style, transform, color }, FontOptional)
35
- // } catch (err: any) {
36
- // console.warn('Given font:\n', JSON.stringify(font, null, 2), err)
37
- // }
38
- // }
39
-
40
- // if (process.env.NODE_ENV === 'development') {
41
- // const fontReq = {
42
- // family: ow.string,
43
- // size: ow.object.nonEmpty.valuesOfType(ow.number),
44
- // lineHeight: ow.object.nonEmpty.valuesOfType(ow.number),
45
- // weight: ow.object.nonEmpty.valuesOfType(ow.string),
46
- // letterSpacing: ow.object.nonEmpty.valuesOfType(ow.number),
47
- // }
48
- // const fontOpt = {
49
- // style: ow.optional.object.valuesOfType(ow.string),
50
- // transform: ow.optional.object.valuesOfType(ow.string),
51
- // color: ow.optional.object.valuesOfType(ow.any(ow.string, ow.object)),
52
- // }
53
-
54
- // Config = ow.object.exactShape({
55
- // defaultTheme: ow.optional.string,
56
- // disableRootThemeClass: ow.optional.boolean,
57
- // shorthands: ow.optional.object.valuesOfType(ow.string),
58
- // themes: ow.object.valuesOfType(ow.object),
59
- // tokens: ow.object.valuesOfType(ow.object),
60
- // media: ow.object.valuesOfType(ow.object),
61
- // animations: ow.object.valuesOfType(ow.object),
62
- // fonts: ow.object.valuesOfType(
63
- // ow.object.partialShape({
64
- // ...fontReq,
65
- // ...fontOpt,
66
- // })
67
- // ),
68
- // })
69
-
70
- // FontRequired = ow.object.exactShape(fontReq)
71
- // FontOptional = ow.object.partialShape(fontOpt)
72
-
73
- // Tokens = ow.object.exactShape({
74
- // size: ow.object.nonEmpty.valuesOfType(ow.any(ow.number, ow.object)),
75
- // space: ow.object.nonEmpty.valuesOfType(ow.any(ow.number, ow.object)),
76
- // zIndex: ow.object.nonEmpty.valuesOfType(ow.any(ow.number, ow.object)),
77
- // radius: ow.object.nonEmpty.valuesOfType(ow.any(ow.number, ow.object)),
78
- // color: ow.object.nonEmpty.valuesOfType(ow.any(ow.string, ow.object)),
79
- // })
80
- // }