@tamagui/core 1.0.1-rc.8 → 1.0.1

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 (200) hide show
  1. package/dist/cjs/Pressability.js +32 -0
  2. package/dist/cjs/Pressability.js.map +7 -0
  3. package/dist/cjs/Pressability.native.js +32 -0
  4. package/dist/cjs/Pressability.native.js.map +7 -0
  5. package/dist/cjs/ThemeContext.js +30 -0
  6. package/dist/cjs/ThemeContext.js.map +7 -0
  7. package/dist/cjs/ThemeManager.js +211 -0
  8. package/dist/cjs/ThemeManager.js.map +7 -0
  9. package/dist/cjs/conf.js +70 -0
  10. package/dist/cjs/conf.js.map +7 -0
  11. package/dist/cjs/constants/platform.js +4 -10
  12. package/dist/cjs/constants/platform.js.map +2 -2
  13. package/dist/cjs/constants/rnw.native.js +28 -0
  14. package/dist/cjs/constants/rnw.native.js.map +7 -0
  15. package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +1 -1
  16. package/dist/cjs/createComponent.js +25 -27
  17. package/dist/cjs/createComponent.js.map +2 -2
  18. package/dist/cjs/createTamagui.js +4 -1
  19. package/dist/cjs/createTamagui.js.map +2 -2
  20. package/dist/cjs/defaultComponentState.js +2 -0
  21. package/dist/cjs/defaultComponentState.js.map +7 -0
  22. package/dist/cjs/helpers/ThemeManager.js +4 -2
  23. package/dist/cjs/helpers/ThemeManager.js.map +2 -2
  24. package/dist/cjs/helpers/Unwrap.js +29 -0
  25. package/dist/cjs/helpers/Unwrap.js.map +7 -0
  26. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +1 -1
  27. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +1 -1
  28. package/dist/cjs/helpers/cache.js +7 -11
  29. package/dist/cjs/helpers/cache.js.map +2 -2
  30. package/dist/cjs/helpers/calc.js.map +2 -2
  31. package/dist/cjs/helpers/createShallowUpdate.js +9 -12
  32. package/dist/cjs/helpers/createShallowUpdate.js.map +1 -1
  33. package/dist/cjs/helpers/createTamaguiProvider.js +65 -0
  34. package/dist/cjs/helpers/createTamaguiProvider.js.map +7 -0
  35. package/dist/cjs/helpers/cssHash.js +51 -0
  36. package/dist/cjs/helpers/cssHash.js.map +7 -0
  37. package/dist/cjs/helpers/expandStyle.js +29 -41
  38. package/dist/cjs/helpers/expandStyle.js.map +2 -2
  39. package/dist/cjs/helpers/expandStyle.test.js +10 -0
  40. package/dist/cjs/helpers/expandStyle.test.js.map +7 -0
  41. package/dist/cjs/helpers/getFont.js +2 -6
  42. package/dist/cjs/helpers/getFont.js.map +2 -2
  43. package/dist/cjs/helpers/getSplitStyles.js +22 -23
  44. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  45. package/dist/cjs/helpers/getStackSize.js.map +1 -1
  46. package/dist/cjs/helpers/getStylesAtomic.js +10 -11
  47. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  48. package/dist/cjs/helpers/insertStyleRule.js +58 -27
  49. package/dist/cjs/helpers/insertStyleRule.js.map +3 -3
  50. package/dist/cjs/helpers/nativeGestureHandler.native.js +19 -0
  51. package/dist/cjs/helpers/nativeGestureHandler.native.js.map +7 -0
  52. package/dist/cjs/helpers/normalizeValueWithProperty.js +3 -3
  53. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
  54. package/dist/cjs/helpers/startTransition.js +1 -4
  55. package/dist/cjs/helpers/startTransition.js.map +2 -2
  56. package/dist/cjs/helpers/themeable.js +2 -2
  57. package/dist/cjs/helpers/themeable.js.map +2 -2
  58. package/dist/cjs/helpers/wrapThemeManagerContext.js +37 -0
  59. package/dist/cjs/helpers/wrapThemeManagerContext.js.map +7 -0
  60. package/dist/cjs/hooks/useConstant.js +0 -3
  61. package/dist/cjs/hooks/useConstant.js.map +2 -2
  62. package/dist/cjs/hooks/useElementLayout.js +1 -1
  63. package/dist/cjs/hooks/useElementLayout.js.map +2 -2
  64. package/dist/cjs/hooks/useFeatures.js +201 -0
  65. package/dist/cjs/hooks/useFeatures.js.map +7 -0
  66. package/dist/cjs/hooks/useIsMounted.js.map +1 -1
  67. package/dist/cjs/hooks/useIsSSR.js +6 -10
  68. package/dist/cjs/hooks/useIsSSR.js.map +2 -2
  69. package/dist/cjs/hooks/useMedia.js +5 -0
  70. package/dist/cjs/hooks/useMedia.js.map +2 -2
  71. package/dist/cjs/hooks/usePressable.js.map +1 -1
  72. package/dist/cjs/hooks/usePrevious.js +1 -0
  73. package/dist/cjs/hooks/usePrevious.js.map +7 -0
  74. package/dist/cjs/hooks/useTheme.js +45 -50
  75. package/dist/cjs/hooks/useTheme.js.map +3 -3
  76. package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
  77. package/dist/cjs/styled.js +12 -0
  78. package/dist/cjs/styled.js.map +2 -2
  79. package/dist/cjs/views/TamaguiProvider.js +3 -0
  80. package/dist/cjs/views/TamaguiProvider.js.map +2 -2
  81. package/dist/cjs/views/TextAncestorContext.js +44 -0
  82. package/dist/cjs/views/TextAncestorContext.js.map +7 -0
  83. package/dist/cjs/views/Theme.js +15 -21
  84. package/dist/cjs/views/Theme.js.map +3 -3
  85. package/dist/cjs/views/ThemeInverse.js +20 -21
  86. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  87. package/dist/cjs/views/ThemeReset.js +5 -10
  88. package/dist/cjs/views/ThemeReset.js.map +3 -3
  89. package/dist/esm/Pressability.js +7 -0
  90. package/dist/esm/Pressability.js.map +7 -0
  91. package/dist/esm/Pressability.native.js +7 -0
  92. package/dist/esm/Pressability.native.js.map +7 -0
  93. package/dist/esm/ThemeContext.js +6 -0
  94. package/dist/esm/ThemeContext.js.map +7 -0
  95. package/dist/esm/ThemeManager.js +185 -0
  96. package/dist/esm/ThemeManager.js.map +7 -0
  97. package/dist/esm/conf.js +39 -0
  98. package/dist/esm/conf.js.map +7 -0
  99. package/dist/esm/constants/platform.js +3 -7
  100. package/dist/esm/constants/platform.js.map +2 -2
  101. package/dist/esm/constants/rnw.native.js +5 -0
  102. package/dist/esm/constants/rnw.native.js.map +7 -0
  103. package/dist/esm/contexts/ButtonInsideButtonContext.js.map +1 -1
  104. package/dist/esm/createComponent.js +26 -28
  105. package/dist/esm/createComponent.js.map +2 -2
  106. package/dist/esm/createTamagui.js +9 -2
  107. package/dist/esm/createTamagui.js.map +2 -2
  108. package/dist/esm/defaultComponentState.js +1 -0
  109. package/dist/esm/defaultComponentState.js.map +7 -0
  110. package/dist/esm/helpers/ThemeManager.js +4 -2
  111. package/dist/esm/helpers/ThemeManager.js.map +2 -2
  112. package/dist/esm/helpers/Unwrap.js +5 -0
  113. package/dist/esm/helpers/Unwrap.js.map +7 -0
  114. package/dist/esm/helpers/assignNativePropsToWeb.js.map +1 -1
  115. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +1 -1
  116. package/dist/esm/helpers/cache.js +7 -10
  117. package/dist/esm/helpers/cache.js.map +2 -2
  118. package/dist/esm/helpers/calc.js.map +2 -2
  119. package/dist/esm/helpers/createShallowUpdate.js +9 -12
  120. package/dist/esm/helpers/createShallowUpdate.js.map +1 -1
  121. package/dist/esm/helpers/createTamaguiProvider.js +38 -0
  122. package/dist/esm/helpers/createTamaguiProvider.js.map +7 -0
  123. package/dist/esm/helpers/cssHash.js +27 -0
  124. package/dist/esm/helpers/cssHash.js.map +7 -0
  125. package/dist/esm/helpers/expandStyle.js +26 -38
  126. package/dist/esm/helpers/expandStyle.js.map +2 -2
  127. package/dist/esm/helpers/expandStyle.test.js +9 -0
  128. package/dist/esm/helpers/expandStyle.test.js.map +7 -0
  129. package/dist/esm/helpers/getFont.js +2 -6
  130. package/dist/esm/helpers/getFont.js.map +2 -2
  131. package/dist/esm/helpers/getSplitStyles.js +24 -24
  132. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  133. package/dist/esm/helpers/getStackSize.js.map +1 -1
  134. package/dist/esm/helpers/getStylesAtomic.js +10 -11
  135. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  136. package/dist/esm/helpers/insertStyleRule.js +56 -26
  137. package/dist/esm/helpers/insertStyleRule.js.map +3 -3
  138. package/dist/esm/helpers/nativeGestureHandler.native.js +2 -0
  139. package/dist/esm/helpers/nativeGestureHandler.native.js.map +7 -0
  140. package/dist/esm/helpers/normalizeValueWithProperty.js +3 -3
  141. package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
  142. package/dist/esm/helpers/startTransition.js.map +1 -1
  143. package/dist/esm/helpers/themeable.js +2 -2
  144. package/dist/esm/helpers/themeable.js.map +2 -2
  145. package/dist/esm/helpers/wrapThemeManagerContext.js +11 -0
  146. package/dist/esm/helpers/wrapThemeManagerContext.js.map +7 -0
  147. package/dist/esm/hooks/useConstant.js +1 -4
  148. package/dist/esm/hooks/useConstant.js.map +2 -2
  149. package/dist/esm/hooks/useElementLayout.js +1 -1
  150. package/dist/esm/hooks/useElementLayout.js.map +2 -2
  151. package/dist/esm/hooks/useFeatures.js +174 -0
  152. package/dist/esm/hooks/useFeatures.js.map +7 -0
  153. package/dist/esm/hooks/useIsMounted.js.map +1 -1
  154. package/dist/esm/hooks/useIsSSR.js +8 -12
  155. package/dist/esm/hooks/useIsSSR.js.map +2 -2
  156. package/dist/esm/hooks/useMedia.js +4 -0
  157. package/dist/esm/hooks/useMedia.js.map +2 -2
  158. package/dist/esm/hooks/usePressable.js.map +1 -1
  159. package/dist/esm/hooks/usePrevious.js +1 -0
  160. package/dist/esm/hooks/usePrevious.js.map +7 -0
  161. package/dist/esm/hooks/useTheme.js +45 -50
  162. package/dist/esm/hooks/useTheme.js.map +3 -3
  163. package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
  164. package/dist/esm/styled.js +12 -0
  165. package/dist/esm/styled.js.map +2 -2
  166. package/dist/esm/views/TamaguiProvider.js +3 -0
  167. package/dist/esm/views/TamaguiProvider.js.map +2 -2
  168. package/dist/esm/views/TextAncestorContext.js +15 -0
  169. package/dist/esm/views/TextAncestorContext.js.map +7 -0
  170. package/dist/esm/views/Theme.js +14 -14
  171. package/dist/esm/views/Theme.js.map +2 -2
  172. package/dist/esm/views/ThemeInverse.js +15 -20
  173. package/dist/esm/views/ThemeInverse.js.map +2 -2
  174. package/dist/esm/views/ThemeReset.js +4 -6
  175. package/dist/esm/views/ThemeReset.js.map +2 -2
  176. package/package.json +13 -14
  177. package/src/createComponent.tsx +47 -43
  178. package/src/createTamagui.ts +10 -2
  179. package/src/helpers/ThemeManager.tsx +7 -2
  180. package/src/helpers/cache.ts +7 -9
  181. package/src/helpers/expandStyle.ts +27 -41
  182. package/src/helpers/getSplitStyles.tsx +40 -23
  183. package/src/helpers/getStylesAtomic.ts +15 -15
  184. package/src/helpers/insertStyleRule.tsx +68 -38
  185. package/src/helpers/normalizeValueWithProperty.ts +3 -3
  186. package/src/helpers/themeable.tsx +3 -3
  187. package/src/hooks/useElementLayout.tsx +1 -1
  188. package/src/hooks/useMedia.tsx +3 -0
  189. package/src/hooks/useTheme.tsx +67 -48
  190. package/src/styled.tsx +15 -0
  191. package/src/views/TamaguiProvider.tsx +6 -0
  192. package/src/views/Theme.tsx +15 -22
  193. package/types/createComponent.d.ts +1 -1
  194. package/types/helpers/ThemeManager.d.ts +1 -1
  195. package/types/helpers/cache.d.ts +2 -4
  196. package/types/helpers/insertStyleRule.d.ts +2 -1
  197. package/types/helpers/themeable.d.ts +1 -1
  198. package/types/hooks/useMedia.d.ts +1 -0
  199. package/types/hooks/useTheme.d.ts +1 -1
  200. package/types/views/Theme.d.ts +1 -1
@@ -20,7 +20,6 @@ import React, {
20
20
  createElement,
21
21
  forwardRef,
22
22
  memo,
23
- startTransition,
24
23
  useCallback,
25
24
  useContext,
26
25
  useEffect,
@@ -61,7 +60,7 @@ import {
61
60
  } from './types'
62
61
  import { usePressability } from './vendor/Pressability'
63
62
  import { Slot, mergeEvent } from './views/Slot'
64
- import { wrapThemeManagerContext } from './views/Theme'
63
+ import { useThemeManagerContext } from './views/Theme'
65
64
 
66
65
  // let t
67
66
  // import { timer } from '@tamagui/timer'
@@ -558,7 +557,8 @@ export function createComponent<
558
557
 
559
558
  if (process.env.NODE_ENV === 'development' && !isText && isWeb) {
560
559
  Children.toArray(props.children).forEach((item) => {
561
- if (typeof item === 'string') {
560
+ // allow newlines because why not its annoying with mdx
561
+ if (typeof item === 'string' && item !== '\n') {
562
562
  // eslint-disable-next-line no-console
563
563
  console.error(
564
564
  `Unexpected text node: ${item}. A text node cannot be a child of a <View>.`
@@ -585,10 +585,17 @@ export function createComponent<
585
585
  const shouldSetMounted = needsMount && state.unmounted
586
586
  useEffect(() => {
587
587
  if (!shouldSetMounted) return
588
+ if (state.unmounted === true && needsMount) {
589
+ setStateShallow({
590
+ unmounted: false,
591
+ })
592
+ return
593
+ }
594
+
588
595
  setStateShallow({
589
596
  unmounted: false,
590
597
  })
591
- }, [shouldSetMounted])
598
+ }, [shouldSetMounted, state.unmounted])
592
599
 
593
600
  let styles: Record<string, any>[]
594
601
 
@@ -618,11 +625,15 @@ export function createComponent<
618
625
  const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : ''
619
626
 
620
627
  const classList = [
628
+ hasEnterStyle && ((state.unmounted && needsMount) || !isClient)
629
+ ? 't_will-mount'
630
+ : '',
621
631
  componentName ? componentClassName : '',
622
632
  fontFamilyClassName,
623
633
  themeIsNew ? theme.className : '',
624
634
  classNames ? Object.values(classNames).join(' ') : '',
625
635
  ]
636
+
626
637
  const className = classList.join(' ')
627
638
 
628
639
  if (process.env.TAMAGUI_TARGET === 'web') {
@@ -811,23 +822,20 @@ export function createComponent<
811
822
  stateRef.current.themeShouldReset = true
812
823
  }
813
824
 
814
- const childEls =
815
- !children || asChild
816
- ? children
817
- : wrapThemeManagerContext(
818
- spacedChildren({
819
- separator,
820
- children,
821
- space,
822
- direction: props.spaceDirection || 'both',
823
- isZStack,
824
- }),
825
- // only set context if changed theme
826
- stateRef.current.hasProvidedThemeManager ? themeManager : undefined,
827
- stateRef.current.themeShouldReset
828
- )
825
+ const innerContent = useThemeManagerContext(
826
+ spacedChildren({
827
+ separator,
828
+ children,
829
+ space,
830
+ direction: props.spaceDirection || 'both',
831
+ isZStack,
832
+ }),
833
+ // only set context if changed theme
834
+ stateRef.current.hasProvidedThemeManager ? themeManager : undefined,
835
+ stateRef.current.themeShouldReset
836
+ )
829
837
 
830
- let content: any
838
+ let content = !children || asChild ? children : innerContent
831
839
 
832
840
  if (asChild) {
833
841
  elementType = Slot
@@ -865,7 +873,7 @@ export function createComponent<
865
873
  }
866
874
  }
867
875
 
868
- content = createElement(elementType, viewProps, childEls)
876
+ content = createElement(elementType, viewProps, content)
869
877
 
870
878
  if (process.env.TAMAGUI_TARGET === 'web') {
871
879
  if (events || isAnimatedReactNativeWeb) {
@@ -921,7 +929,6 @@ export function createComponent<
921
929
  styles,
922
930
  pseudos,
923
931
  content,
924
- childEls,
925
932
  shouldAvoidClasses,
926
933
  avoidClasses: avoidClassesWhileAnimating,
927
934
  animation: props.animation,
@@ -1162,41 +1169,38 @@ export type SpacedChildrenProps = {
1162
1169
  separator?: React.ReactNode
1163
1170
  }
1164
1171
 
1165
- export function spacedChildren({
1166
- isZStack,
1167
- children,
1168
- space,
1169
- direction,
1170
- spaceFlex,
1171
- separator,
1172
- }: SpacedChildrenProps) {
1172
+ export function spacedChildren(props: SpacedChildrenProps) {
1173
+ const { isZStack, children, space, direction, spaceFlex, separator } = props
1173
1174
  const hasSpace = !!(space || spaceFlex)
1174
1175
  const hasSeparator = !(separator === undefined || separator === null)
1175
1176
  if (!(hasSpace || hasSeparator || isZStack)) {
1176
1177
  return children
1177
1178
  }
1179
+
1178
1180
  const childrenList = Children.toArray(children)
1181
+
1179
1182
  const len = childrenList.length
1180
- if (len <= 1 && !isZStack) {
1181
- if (len === 1) {
1182
- // forward space! only when one component doesn't make sense to forward space to all children
1183
- const [onlyChild] = childrenList
1184
- if (React.isValidElement(onlyChild) && onlyChild.type?.['shouldForwardSpace']) {
1185
- return React.cloneElement(onlyChild, {
1186
- space,
1187
- spaceFlex,
1188
- separator,
1189
- } as any)
1190
- }
1191
- }
1183
+ if (len <= 1 && !isZStack && !childrenList[0]?.['type']?.['shouldForwardSpace']) {
1192
1184
  return childrenList
1193
1185
  }
1186
+
1194
1187
  const final: React.ReactNode[] = []
1195
- for (const [index, child] of childrenList.entries()) {
1188
+ for (let [index, child] of childrenList.entries()) {
1196
1189
  const isEmpty =
1197
1190
  child === null ||
1198
1191
  child === undefined ||
1199
1192
  (Array.isArray(child) && child.length === 0)
1193
+
1194
+ // forward space
1195
+ if (!isEmpty && React.isValidElement(child) && child.type?.['shouldForwardSpace']) {
1196
+ child = React.cloneElement(child, {
1197
+ space,
1198
+ spaceFlex,
1199
+ separator,
1200
+ key: child.key,
1201
+ } as any)
1202
+ }
1203
+
1200
1204
  // push them all, but wrap some in Fragment
1201
1205
  if (isEmpty || !child || (child['key'] && !isZStack)) {
1202
1206
  final.push(child)
@@ -3,7 +3,11 @@ import { isRSC, isWeb } from '@tamagui/constants'
3
3
  import { configListeners, setConfig } from './config'
4
4
  import { createVariables } from './createVariables'
5
5
  import { getThemeCSSRules } from './helpers/getThemeCSSRules'
6
- import { getAllRules } from './helpers/insertStyleRule'
6
+ import {
7
+ getAllRules,
8
+ listenForSheetChanges,
9
+ scanAllSheets,
10
+ } from './helpers/insertStyleRule'
7
11
  import {
8
12
  registerCSSVariable,
9
13
  tokensValueToVariable,
@@ -42,6 +46,9 @@ export function createTamagui<Conf extends CreateTamaguiProps>(
42
46
  }
43
47
  }
44
48
 
49
+ scanAllSheets()
50
+ listenForSheetChanges()
51
+
45
52
  const fontTokens = Object.fromEntries(
46
53
  Object.entries(configIn.fonts!).map(([k, v]) => {
47
54
  return [k, createVariables(v, 'f', true)]
@@ -205,7 +212,8 @@ export function createTamagui<Conf extends CreateTamaguiProps>(
205
212
  tokensParsed,
206
213
  parsed: true,
207
214
  getCSS: (separator = '\n') => {
208
- return `.is_Text .is_Text {display:inline-flex;}
215
+ return `.t_unmounted .t_will-mount {opacity:0;visibility:hidden;}
216
+ .is_Text .is_Text {display:inline-flex;}
209
217
  ._dsp_contents {display:contents;}
210
218
  ${themeConfig.cssRuleSets.join(separator)}
211
219
  ${themeConfig.themeRuleSets.join(separator)}
@@ -42,6 +42,10 @@ export class ThemeManager {
42
42
  if (!parentManager) {
43
43
  throw new Error('Must set up root first')
44
44
  }
45
+
46
+ // copy over listeners
47
+ this.themeListeners = parentManager.themeListeners
48
+
45
49
  // no change no props
46
50
  if (hasNoThemeUpdatingProps(props)) {
47
51
  return parentManager
@@ -101,9 +105,9 @@ export class ThemeManager {
101
105
  state: ThemeManagerState | null = this.state
102
106
  ) {
103
107
  if (!nextState?.theme || nextState.theme === state?.theme) {
104
- return null
108
+ return false
105
109
  }
106
- return nextState
110
+ return true
107
111
  }
108
112
 
109
113
  getState(props = this.props, parentManager = this.parentManager) {
@@ -136,6 +140,7 @@ export class ThemeManager {
136
140
  }
137
141
 
138
142
  notify() {
143
+ console.log('notify', this.themeListeners.size, this.themeListeners)
139
144
  this.themeListeners.forEach((cb) => cb(this.state.name, this))
140
145
  }
141
146
 
@@ -2,17 +2,15 @@ type Value = Object | Array<any> | string | number
2
2
 
3
3
  export type Style = { [key: string]: Value }
4
4
 
5
- class Cache {
6
- v: Record<string, any> = {}
5
+ const v: Record<string, any> = {}
7
6
 
7
+ export const cache = {
8
8
  get(key: string, valStr: string) {
9
- return this.v[key]?.[valStr]
10
- }
9
+ return v[key]?.[valStr]
10
+ },
11
11
 
12
12
  set(key: string, valStr: string, object: any) {
13
- this.v[key] ??= {}
14
- this.v[key][valStr] = object
15
- }
13
+ v[key] ??= {}
14
+ v[key][valStr] = object
15
+ },
16
16
  }
17
-
18
- export const cache = new Cache()
@@ -30,25 +30,16 @@ export function expandStyle(key: string, value: any) {
30
30
 
31
31
  // web only
32
32
  switch (key) {
33
- case 'aspectRatio': {
34
- return [[key, value.toString()]]
35
- }
36
-
37
33
  case 'textAlignVertical': {
38
34
  return [['verticalAlign', value === 'center' ? 'middle' : value]]
39
35
  }
40
-
41
- case 'textDecorationLine': {
42
- return [['textDecorationLine', value]]
43
- }
44
-
45
36
  case 'writingDirection': {
46
37
  return [['direction', value]]
47
38
  }
48
39
  }
49
40
  }
50
41
 
51
- const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]
42
+ const longKey = EXPANSIONS[key]
52
43
  if (longKey) {
53
44
  return longKey.map((key) => {
54
45
  return [key, value]
@@ -56,41 +47,36 @@ export function expandStyle(key: string, value: any) {
56
47
  }
57
48
  }
58
49
 
59
- const STYLE_SHORT_FORM_EXPANSIONS: Record<string, string[]> = {
60
- borderColor: [
61
- 'borderTopColor',
62
- 'borderRightColor',
63
- 'borderBottomColor',
64
- 'borderLeftColor',
65
- ],
50
+ const all = ['Top', 'Right', 'Bottom', 'Left']
51
+ const horiz = ['Right', 'Left']
52
+ const vert = ['Top', 'Bottom']
53
+ const xy = ['X', 'Y']
54
+
55
+ const EXPANSIONS: Record<string, string[]> = {
56
+ borderColor: ['TopColor', 'RightColor', 'BottomColor', 'LeftColor'],
66
57
  borderRadius: [
67
- 'borderTopLeftRadius',
68
- 'borderTopRightRadius',
69
- 'borderBottomRightRadius',
70
- 'borderBottomLeftRadius',
71
- ],
72
- borderWidth: [
73
- 'borderTopWidth',
74
- 'borderRightWidth',
75
- 'borderBottomWidth',
76
- 'borderLeftWidth',
58
+ 'TopLeftRadius',
59
+ 'TopRightRadius',
60
+ 'BottomRightRadius',
61
+ 'BottomLeftRadius',
77
62
  ],
78
- margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],
79
- marginHorizontal: ['marginRight', 'marginLeft'],
80
- marginVertical: ['marginTop', 'marginBottom'],
81
- overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],
82
- padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],
83
- paddingHorizontal: ['paddingRight', 'paddingLeft'],
84
- paddingVertical: ['paddingTop', 'paddingBottom'],
63
+ borderWidth: ['TopWidth', 'RightWidth', 'BottomWidth', 'LeftWidth'],
64
+ margin: all,
65
+ marginHorizontal: horiz,
66
+ marginVertical: vert,
67
+ overscrollBehavior: xy,
68
+ padding: all,
69
+ paddingHorizontal: horiz,
70
+ paddingVertical: vert,
85
71
  ...(isWeb && {
86
72
  // react-native only supports borderStyle
87
- borderStyle: [
88
- 'borderTopStyle',
89
- 'borderRightStyle',
90
- 'borderBottomStyle',
91
- 'borderLeftStyle',
92
- ],
73
+ borderStyle: ['TopStyle', 'RightStyle', 'BottomStyle', 'LeftStyle'],
93
74
  // react-native doesn't support X / Y
94
- overflow: ['overflowX', 'overflowY'],
75
+ overflow: xy,
95
76
  }),
96
77
  }
78
+
79
+ for (const parent in EXPANSIONS) {
80
+ const prefix = parent.slice(0, /[A-Z]/.exec(parent)?.index ?? parent.length)
81
+ EXPANSIONS[parent] = EXPANSIONS[parent].map((k) => `${prefix}${k}`)
82
+ }
@@ -20,6 +20,7 @@ import { isDevTools } from '../constants/isDevTools'
20
20
  import {
21
21
  getMediaImportanceIfMoreImportant,
22
22
  mediaState as globalMediaState,
23
+ mediaKeysWithAndWithout$,
23
24
  mediaQueryConfig,
24
25
  mergeMediaByImportance,
25
26
  } from '../hooks/useMedia'
@@ -45,8 +46,8 @@ import {
45
46
  RulesToInsert,
46
47
  insertStyleRules,
47
48
  insertedTransforms,
49
+ scanAllSheets,
48
50
  shouldInsertStyleRules,
49
- updateInserted,
50
51
  updateRules,
51
52
  } from './insertStyleRule'
52
53
  import { FlatTransforms, mergeTransform, mergeTransforms } from './mergeTransform'
@@ -205,7 +206,7 @@ const accessibilityRoleToWebRole = {
205
206
  // const classNames = {}
206
207
 
207
208
  const isMediaKey = (key: string) =>
208
- Boolean(key[0] === '$' && mediaQueryConfig[key.slice(1)])
209
+ Boolean(key[0] === '$' && mediaKeysWithAndWithout$.has(key))
209
210
 
210
211
  export const getSplitStyles: StyleSplitter = (
211
212
  props,
@@ -217,6 +218,10 @@ export const getSplitStyles: StyleSplitter = (
217
218
  elementType,
218
219
  debug
219
220
  ) => {
221
+ if (cache.has(props)) {
222
+ return cache.get(props)
223
+ }
224
+
220
225
  conf = conf || getConfig()
221
226
  const { shorthands } = conf
222
227
  const {
@@ -320,8 +325,7 @@ export const getSplitStyles: StyleSplitter = (
320
325
  const valInit = props[keyInit]
321
326
 
322
327
  // normalize shorthands up front
323
- const expandedKey = keyInit in shorthands
324
- if (expandedKey) {
328
+ if (keyInit in shorthands) {
325
329
  keyInit = shorthands[keyInit]
326
330
  }
327
331
 
@@ -329,8 +333,8 @@ export const getSplitStyles: StyleSplitter = (
329
333
  if (keyInit in skipProps) continue
330
334
  if (!isWeb && keyInit.startsWith('data-')) continue
331
335
 
332
- if (validStyleProps[keyInit] || keyInit.includes('-')) {
333
- if (valInit && valInit[0] === '_') {
336
+ if (typeof valInit === 'string' && valInit[0] === '_') {
337
+ if (keyInit in validStyleProps || keyInit.includes('-')) {
334
338
  if (shouldDoClasses) {
335
339
  classNames[keyInit] = valInit
336
340
  } else {
@@ -425,20 +429,12 @@ export const getSplitStyles: StyleSplitter = (
425
429
  }
426
430
  break
427
431
  }
428
- case 'accessibilityControls': {
429
- viewProps['aria-controls'] = processIDRefList(valInit)
430
- break
431
- }
432
+ case 'accessibilityLabelledBy':
433
+ case 'accessibilityFlowTo':
434
+ case 'accessibilityControls':
432
435
  case 'accessibilityDescribedBy': {
433
- viewProps['aria-describedby'] = processIDRefList(valInit)
434
- break
435
- }
436
- case 'accessibilityFlowTo': {
437
- viewProps['aria-flowto'] = processIDRefList(valInit)
438
- break
439
- }
440
- case 'accessibilityLabelledBy': {
441
- viewProps['aria-labelledby'] = processIDRefList(valInit)
436
+ viewProps[`aria-${keyInit.replace('accessibility', '').toLowerCase()}`] =
437
+ processIDRefList(valInit)
442
438
  break
443
439
  }
444
440
  case 'accessibilityKeyShortcuts': {
@@ -538,7 +534,7 @@ export const getSplitStyles: StyleSplitter = (
538
534
  )
539
535
  ) {
540
536
  // web-only, exclude all other accessibility props not handled above
541
- if (isWeb && keyInit.includes('ccessibility')) {
537
+ if (isWeb && keyInit.indexOf('ccessibility') > 0) {
542
538
  continue
543
539
  }
544
540
  usedKeys[keyInit] = 1
@@ -642,7 +638,24 @@ export const getSplitStyles: StyleSplitter = (
642
638
  }
643
639
  }
644
640
  } else {
645
- const isDisabled = !state[descriptor.stateKey || descriptor.name]
641
+ let isDisabled = !state[descriptor.stateKey || descriptor.name]
642
+
643
+ // we never animate in on server side just show the full thing
644
+ // on client side we use CSS to hide the fully in SSR items, then
645
+ // un-hide and replay with original animation.
646
+ if (!isClient && isEnter) {
647
+ isDisabled = false
648
+ }
649
+
650
+ // console.log(
651
+ // 'isDisabled',
652
+ // state,
653
+ // descriptor.stateKey,
654
+ // state[descriptor.stateKey || descriptor.name],
655
+ // isDisabled,
656
+ // descriptor
657
+ // )
658
+
646
659
  if (!isDisabled) {
647
660
  usedKeys[key] ||= 1
648
661
  }
@@ -766,7 +779,7 @@ export const getSplitStyles: StyleSplitter = (
766
779
  fontFamily = valInit[0] === '$' ? valInit : val
767
780
  }
768
781
 
769
- if (validStyleProps[key]) {
782
+ if (key in validStyleProps) {
770
783
  mergeStyle(styleState, key, val)
771
784
  continue
772
785
  }
@@ -887,6 +900,7 @@ export const getSplitStyles: StyleSplitter = (
887
900
  rulesToInsert,
888
901
  parentSplitStyles,
889
902
  flatTransforms,
903
+ result,
890
904
  }
891
905
  for (const key in { ...result, ...logs }) {
892
906
  // eslint-disable-next-line no-console
@@ -897,6 +911,8 @@ export const getSplitStyles: StyleSplitter = (
897
911
  }
898
912
  }
899
913
 
914
+ cache.set(props, result)
915
+
900
916
  return result
901
917
  }
902
918
 
@@ -916,7 +932,8 @@ function mergeClassName(
916
932
  if (isClient) {
917
933
  if (!transform) {
918
934
  // HMR or loaded a new chunk
919
- updateInserted()
935
+ console.warn(`got a new ting`)
936
+ scanAllSheets()
920
937
  transform = insertedTransforms[val]
921
938
  if (process.env.NODE_ENV === 'development') {
922
939
  if (!transform) {
@@ -82,7 +82,21 @@ const generateAtomicStyles = (
82
82
 
83
83
  // transform
84
84
  if (style.transform && Array.isArray(style.transform)) {
85
- style.transform = style.transform.map(mapTransform).join(' ')
85
+ style.transform = style.transform
86
+ .map(
87
+ // { scale: 2 } => 'scale(2)'
88
+ // { translateX: 20 } => 'translateX(20px)'
89
+ // { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'
90
+ (transform) => {
91
+ const type = Object.keys(transform)[0]
92
+ const value = transform[type]
93
+ if (type === 'matrix' || type === 'matrix3d') {
94
+ return `${type}(${value.join(',')})`
95
+ }
96
+ return `${type}(${normalizeValueWithProperty(value, type)})`
97
+ }
98
+ )
99
+ .join(' ')
86
100
  }
87
101
 
88
102
  styleToCSS(style)
@@ -160,20 +174,6 @@ export function styleToCSS(style: Record<string, any>) {
160
174
  }
161
175
  }
162
176
 
163
- // { scale: 2 } => 'scale(2)'
164
- // { translateX: 20 } => 'translateX(20px)'
165
- // { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'
166
- const mapTransform = (transform) => {
167
- const type = Object.keys(transform)[0]
168
- const value = transform[type]
169
- if (type === 'matrix' || type === 'matrix3d') {
170
- return `${type}(${value.join(',')})`
171
- } else {
172
- const normalizedValue = normalizeValueWithProperty(value, type)
173
- return `${type}(${normalizedValue})`
174
- }
175
- }
176
-
177
177
  function createDeclarationBlock(style: Style, important = false) {
178
178
  let next = ''
179
179
  for (const key in style) {