@tamagui/web 1.48.10 → 1.49.0
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.
- package/dist/cjs/Tamagui.js.map +1 -1
- package/dist/cjs/createComponent.js +92 -8
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.js +3 -2
- package/dist/cjs/helpers/ThemeManager.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +55 -10
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js +33 -34
- package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.js +2 -0
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/cjs/helpers/propMapper.js +5 -1
- package/dist/cjs/helpers/propMapper.js.map +1 -1
- package/dist/cjs/helpers/pseudoDescriptors.js +10 -4
- package/dist/cjs/helpers/pseudoDescriptors.js.map +1 -1
- package/dist/cjs/hooks/useMedia.js +14 -13
- package/dist/cjs/hooks/useMedia.js.map +1 -1
- package/dist/cjs/hooks/useTheme.js +12 -5
- package/dist/cjs/hooks/useTheme.js.map +1 -1
- package/dist/cjs/views/Theme.js +3 -6
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/esm/Tamagui.js +1 -5
- package/dist/esm/Tamagui.js.map +1 -1
- package/dist/esm/createComponent.js +92 -8
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.js +3 -2
- package/dist/esm/helpers/ThemeManager.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +55 -10
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +37 -35
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js +2 -0
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/esm/helpers/propMapper.js +5 -1
- package/dist/esm/helpers/propMapper.js.map +1 -1
- package/dist/esm/helpers/pseudoDescriptors.js +8 -3
- package/dist/esm/helpers/pseudoDescriptors.js.map +1 -1
- package/dist/esm/hooks/useMedia.js +13 -12
- package/dist/esm/hooks/useMedia.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +12 -5
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/views/Theme.js +10 -7
- package/dist/esm/views/Theme.js.map +2 -2
- package/package.json +9 -9
- package/src/Tamagui.ts +1 -5
- package/src/createComponent.tsx +81 -42
- package/src/helpers/ThemeManager.tsx +4 -3
- package/src/helpers/getSplitStyles.tsx +63 -13
- package/src/helpers/getStylesAtomic.ts +45 -48
- package/src/helpers/normalizeValueWithProperty.ts +2 -0
- package/src/helpers/propMapper.ts +11 -2
- package/src/helpers/pseudoDescriptors.ts +9 -4
- package/src/hooks/useMedia.tsx +14 -12
- package/src/hooks/useTheme.tsx +13 -6
- package/src/types.tsx +3 -5
- package/src/views/Theme.tsx +16 -6
- package/types/Tamagui.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/ThemeManager.d.ts +1 -0
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +3 -3
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -1
- package/types/helpers/propMapper.d.ts.map +1 -1
- package/types/helpers/pseudoDescriptors.d.ts +15 -0
- package/types/helpers/pseudoDescriptors.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/types.d.ts +3 -3
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
package/src/createComponent.tsx
CHANGED
|
@@ -48,8 +48,6 @@ import { Slot } from './views/Slot'
|
|
|
48
48
|
import { useThemedChildren } from './views/Theme'
|
|
49
49
|
import { ThemeDebug } from './views/ThemeDebug'
|
|
50
50
|
|
|
51
|
-
// const timer = require('@tamagui/timer').timer()
|
|
52
|
-
|
|
53
51
|
// this appears to fix expo / babel not picking this up sometimes? really odd
|
|
54
52
|
process.env.TAMAGUI_TARGET
|
|
55
53
|
|
|
@@ -71,10 +69,6 @@ const defaultComponentStateShouldEnter: TamaguiComponentState = {
|
|
|
71
69
|
unmounted: 'should-enter',
|
|
72
70
|
}
|
|
73
71
|
|
|
74
|
-
const HYDRATION_CUTOFF = process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF
|
|
75
|
-
? +process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF
|
|
76
|
-
: 5
|
|
77
|
-
|
|
78
72
|
/**
|
|
79
73
|
* All things that need one-time setup after createTamagui is called
|
|
80
74
|
*/
|
|
@@ -149,10 +143,6 @@ export function createComponent<
|
|
|
149
143
|
}
|
|
150
144
|
|
|
151
145
|
const component = forwardRef<Ref, ComponentPropTypes>((propsIn: any, forwardedRef) => {
|
|
152
|
-
// const shouldTime = staticConfig.defaultProps?.padding === 5
|
|
153
|
-
// let time: any
|
|
154
|
-
// if (shouldTime) time = timer.start()
|
|
155
|
-
|
|
156
146
|
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
157
147
|
// todo this could be moved to a cleaner location
|
|
158
148
|
if (!hasSetupBaseViews) {
|
|
@@ -223,6 +213,12 @@ export function createComponent<
|
|
|
223
213
|
const debugProp = props['debug'] as DebugProp
|
|
224
214
|
const componentName = props.componentName || staticConfig.componentName
|
|
225
215
|
|
|
216
|
+
let time: any
|
|
217
|
+
if (process.env.NODE_ENV === 'development' && debugProp === 'profile') {
|
|
218
|
+
const timer = require('@tamagui/timer').timer()
|
|
219
|
+
time = timer.start()
|
|
220
|
+
}
|
|
221
|
+
|
|
226
222
|
const isHydrated = useDidFinishSSR()
|
|
227
223
|
|
|
228
224
|
// conditional but if ever true stays true
|
|
@@ -236,7 +232,7 @@ export function createComponent<
|
|
|
236
232
|
)
|
|
237
233
|
stateRef.current ||= {}
|
|
238
234
|
|
|
239
|
-
|
|
235
|
+
if (process.env.NODE_ENV === 'development' && time) time`stateref`
|
|
240
236
|
|
|
241
237
|
const hostRef = useRef<TamaguiElement>(null)
|
|
242
238
|
|
|
@@ -267,7 +263,7 @@ export function createComponent<
|
|
|
267
263
|
const hasEnterStyle = !!props.enterStyle
|
|
268
264
|
const needsMount = Boolean((isWeb ? isClient : true) && willBeAnimated)
|
|
269
265
|
|
|
270
|
-
|
|
266
|
+
if (process.env.NODE_ENV === 'development' && time) time`pre-use-state`
|
|
271
267
|
|
|
272
268
|
const initialState = willBeAnimated
|
|
273
269
|
? supportsCSSVars
|
|
@@ -285,7 +281,7 @@ export function createComponent<
|
|
|
285
281
|
// TODO performance optimization could avoid useCallback and just have this be setStateShallow(setState, state) at call-sites
|
|
286
282
|
const setStateShallow = useShallowSetState(setState, debugProp, componentName)
|
|
287
283
|
|
|
288
|
-
|
|
284
|
+
if (process.env.NODE_ENV === 'development' && time) time`use-state`
|
|
289
285
|
|
|
290
286
|
let isAnimated = willBeAnimated
|
|
291
287
|
|
|
@@ -311,7 +307,7 @@ export function createComponent<
|
|
|
311
307
|
const languageContext = useContext(FontLanguageContext)
|
|
312
308
|
const isDisabled = props.disabled ?? props.accessibilityState?.disabled
|
|
313
309
|
|
|
314
|
-
|
|
310
|
+
if (process.env.NODE_ENV === 'development' && time) time`use-context`
|
|
315
311
|
|
|
316
312
|
const isTaggable = !Component || typeof Component === 'string'
|
|
317
313
|
// default to tag, fallback to component (when both strings)
|
|
@@ -353,7 +349,7 @@ export function createComponent<
|
|
|
353
349
|
const disableThemeProp = props['data-disable-theme']
|
|
354
350
|
const disableTheme = (disableThemeProp && !willBeAnimated) || isHOC
|
|
355
351
|
|
|
356
|
-
|
|
352
|
+
if (process.env.NODE_ENV === 'development' && time) time`theme-props`
|
|
357
353
|
|
|
358
354
|
const themeStateProps = {
|
|
359
355
|
name: props.theme,
|
|
@@ -374,9 +370,11 @@ export function createComponent<
|
|
|
374
370
|
if (process.env.NODE_ENV === 'development') {
|
|
375
371
|
const id = useId()
|
|
376
372
|
|
|
377
|
-
if (debugProp) {
|
|
373
|
+
if (debugProp && debugProp !== 'profile') {
|
|
378
374
|
// prettier-ignore
|
|
379
|
-
const name = `${
|
|
375
|
+
const name = `${
|
|
376
|
+
componentName || Component?.displayName || Component?.name || "[Unnamed Component]"
|
|
377
|
+
}`;
|
|
380
378
|
const type = isAnimatedReactNative ? '(animated)' : isReactNative ? '(rnw)' : ''
|
|
381
379
|
const dataIs = propsIn['data-is'] || ''
|
|
382
380
|
const banner = `${name}${dataIs ? ` ${dataIs}` : ''} ${type} id ${id}`
|
|
@@ -394,20 +392,35 @@ export function createComponent<
|
|
|
394
392
|
)
|
|
395
393
|
// prettier-ignore
|
|
396
394
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
397
|
-
console.log({
|
|
395
|
+
console.log({
|
|
396
|
+
propsIn,
|
|
397
|
+
props,
|
|
398
|
+
state,
|
|
399
|
+
staticConfig,
|
|
400
|
+
elementType,
|
|
401
|
+
themeStateProps,
|
|
402
|
+
styledContext: { contextProps: styledContextProps, overriddenContextProps },
|
|
403
|
+
presence,
|
|
404
|
+
isAnimated,
|
|
405
|
+
isHOC,
|
|
406
|
+
hasAnimationProp,
|
|
407
|
+
useAnimations,
|
|
408
|
+
propsInOrder: Object.keys(propsIn),
|
|
409
|
+
propsOrder: Object.keys(props),
|
|
410
|
+
});
|
|
398
411
|
console.groupEnd()
|
|
399
412
|
}
|
|
400
413
|
}
|
|
401
414
|
}
|
|
402
415
|
|
|
403
|
-
|
|
416
|
+
if (process.env.NODE_ENV === 'development' && time) time`pre-theme-media`
|
|
404
417
|
|
|
405
418
|
const [themeState, theme] = useThemeWithState(themeStateProps)
|
|
406
419
|
|
|
407
420
|
elementType = Component || elementType
|
|
408
421
|
const isStringElement = typeof elementType === 'string'
|
|
409
422
|
|
|
410
|
-
|
|
423
|
+
if (process.env.NODE_ENV === 'development' && time) time`theme`
|
|
411
424
|
|
|
412
425
|
const mediaState = useMedia(
|
|
413
426
|
// @ts-ignore, we just pass a stable object so we can get it later with
|
|
@@ -415,7 +428,7 @@ export function createComponent<
|
|
|
415
428
|
stateRef
|
|
416
429
|
)
|
|
417
430
|
|
|
418
|
-
|
|
431
|
+
if (process.env.NODE_ENV === 'development' && time) time`media`
|
|
419
432
|
|
|
420
433
|
setDidGetVariableValue(false)
|
|
421
434
|
|
|
@@ -452,13 +465,13 @@ export function createComponent<
|
|
|
452
465
|
debugProp
|
|
453
466
|
)
|
|
454
467
|
|
|
455
|
-
|
|
468
|
+
if (process.env.NODE_ENV === 'development' && time) time`split-styles`
|
|
456
469
|
|
|
457
470
|
stateRef.current.isListeningToTheme = splitStyles.dynamicThemeAccess
|
|
458
471
|
|
|
459
472
|
// only listen for changes if we are using raw theme values or media space, or dynamic media (native)
|
|
460
473
|
// array = space media breakpoints
|
|
461
|
-
const isMediaArray = Array.isArray(splitStyles.hasMedia)
|
|
474
|
+
const isMediaArray = splitStyles.hasMedia && Array.isArray(splitStyles.hasMedia)
|
|
462
475
|
const shouldListenForMedia =
|
|
463
476
|
didGetVariableValue() ||
|
|
464
477
|
isMediaArray ||
|
|
@@ -480,11 +493,11 @@ export function createComponent<
|
|
|
480
493
|
)
|
|
481
494
|
}
|
|
482
495
|
|
|
483
|
-
if (debugProp) {
|
|
496
|
+
if (debugProp && debugProp !== 'profile') {
|
|
484
497
|
console.groupCollapsed('>>>')
|
|
485
498
|
// prettier-ignore
|
|
486
499
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
487
|
-
console.log(
|
|
500
|
+
console.log("props in", propsIn, "mapped to", props, "in order", Object.keys(props));
|
|
488
501
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
489
502
|
console.log('splitStyles', splitStyles)
|
|
490
503
|
// rome-ignore lint/nursery/noConsoleLog: ok
|
|
@@ -535,6 +548,8 @@ export function createComponent<
|
|
|
535
548
|
if (isAnimated && animations) {
|
|
536
549
|
animationStyles = animations.style
|
|
537
550
|
}
|
|
551
|
+
|
|
552
|
+
if (process.env.NODE_ENV === 'development' && time) time`animations`
|
|
538
553
|
}
|
|
539
554
|
|
|
540
555
|
const {
|
|
@@ -565,7 +580,7 @@ export function createComponent<
|
|
|
565
580
|
...nonTamaguiProps
|
|
566
581
|
} = viewPropsIn
|
|
567
582
|
|
|
568
|
-
|
|
583
|
+
if (process.env.NODE_ENV === 'development' && time) time`destructure`
|
|
569
584
|
|
|
570
585
|
const disabled = props.accessibilityState?.disabled || props.accessibilityDisabled
|
|
571
586
|
|
|
@@ -604,7 +619,7 @@ export function createComponent<
|
|
|
604
619
|
}
|
|
605
620
|
}
|
|
606
621
|
|
|
607
|
-
|
|
622
|
+
if (process.env.NODE_ENV === 'development' && time) time`events-hooks`
|
|
608
623
|
|
|
609
624
|
const unPress = useCallback(() => {
|
|
610
625
|
setStateShallow({
|
|
@@ -707,7 +722,7 @@ export function createComponent<
|
|
|
707
722
|
(isWeb && noClassNames && 'hoverStyle' in props)
|
|
708
723
|
)
|
|
709
724
|
|
|
710
|
-
|
|
725
|
+
if (process.env.NODE_ENV === 'development' && time) time`events-setup`
|
|
711
726
|
|
|
712
727
|
const events: TamaguiComponentEvents | null =
|
|
713
728
|
shouldAttach && !isDisabled && !asChild
|
|
@@ -789,7 +804,7 @@ export function createComponent<
|
|
|
789
804
|
})
|
|
790
805
|
}
|
|
791
806
|
|
|
792
|
-
|
|
807
|
+
if (process.env.NODE_ENV === 'development' && time) time`events`
|
|
793
808
|
|
|
794
809
|
if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {
|
|
795
810
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
@@ -806,7 +821,7 @@ export function createComponent<
|
|
|
806
821
|
|
|
807
822
|
const direction = props.spaceDirection || 'both'
|
|
808
823
|
|
|
809
|
-
|
|
824
|
+
if (process.env.NODE_ENV === 'development' && time) time`hooks`
|
|
810
825
|
|
|
811
826
|
// since we re-render without changing children often for animations or on mount
|
|
812
827
|
// we memo children here. tested this on the site homepage which has hundreds of components
|
|
@@ -878,7 +893,7 @@ export function createComponent<
|
|
|
878
893
|
}
|
|
879
894
|
|
|
880
895
|
if (process.env.NODE_ENV === 'development') {
|
|
881
|
-
if (debugProp) {
|
|
896
|
+
if (debugProp && debugProp !== 'profile') {
|
|
882
897
|
const element = typeof elementType === 'string' ? elementType : 'Component'
|
|
883
898
|
console.groupCollapsed(`render <${element} /> with props`)
|
|
884
899
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
@@ -894,22 +909,45 @@ export function createComponent<
|
|
|
894
909
|
if (typeof window !== 'undefined') {
|
|
895
910
|
// prettier-ignore
|
|
896
911
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
897
|
-
console.log({
|
|
912
|
+
console.log({
|
|
913
|
+
state,
|
|
914
|
+
styleProps,
|
|
915
|
+
themeState,
|
|
916
|
+
isAnimated,
|
|
917
|
+
isAnimatedReactNativeWeb,
|
|
918
|
+
defaultProps,
|
|
919
|
+
viewProps,
|
|
920
|
+
splitStyles,
|
|
921
|
+
animationStyles,
|
|
922
|
+
handlesPressEvents,
|
|
923
|
+
willBeAnimated,
|
|
924
|
+
isStringElement,
|
|
925
|
+
classNamesIn: props.className?.split(" "),
|
|
926
|
+
classNamesOut: viewProps.className?.split(" "),
|
|
927
|
+
events,
|
|
928
|
+
shouldAttach,
|
|
929
|
+
pseudos,
|
|
930
|
+
content,
|
|
931
|
+
shouldAvoidClasses,
|
|
932
|
+
animation: props.animation,
|
|
933
|
+
style: splitStylesStyle,
|
|
934
|
+
staticConfig,
|
|
935
|
+
tamaguiConfig,
|
|
936
|
+
shouldForcePseudo,
|
|
937
|
+
elementType,
|
|
938
|
+
initialState,
|
|
939
|
+
classNames,
|
|
940
|
+
});
|
|
898
941
|
}
|
|
899
942
|
console.groupEnd()
|
|
900
943
|
console.groupEnd()
|
|
901
944
|
}
|
|
902
945
|
}
|
|
903
946
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
// timer.print()
|
|
909
|
-
// }
|
|
910
|
-
// hasLogged = true
|
|
911
|
-
// }, 1000)
|
|
912
|
-
// }
|
|
947
|
+
if (process.env.NODE_ENV === 'development' && time) {
|
|
948
|
+
time`rest`
|
|
949
|
+
time.print()
|
|
950
|
+
}
|
|
913
951
|
|
|
914
952
|
return content
|
|
915
953
|
})
|
|
@@ -948,7 +986,8 @@ export function createComponent<
|
|
|
948
986
|
const isForwardedRefAlready = Component.render?.length === 2
|
|
949
987
|
const ComponentForwardedRef = isForwardedRefAlready
|
|
950
988
|
? (Component as any)
|
|
951
|
-
:
|
|
989
|
+
: // memo because theme changes otherwise would always re-render
|
|
990
|
+
memo(forwardRef(Component as any))
|
|
952
991
|
|
|
953
992
|
const extendedConfig = extendStyledConfig()
|
|
954
993
|
const out = themeable(ComponentForwardedRef, extendedConfig) as any
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { getThemes
|
|
1
|
+
import { getThemes } from '../config'
|
|
2
2
|
import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from '../constants/constants'
|
|
3
|
-
import { getThemeUnwrapped } from '../hooks/getThemeUnwrapped'
|
|
4
3
|
import { ThemeParsed, ThemeProps } from '../types'
|
|
5
4
|
|
|
6
5
|
type ThemeListener = (
|
|
@@ -23,6 +22,7 @@ export type ThemeManagerState = {
|
|
|
23
22
|
className?: string
|
|
24
23
|
parentName?: string
|
|
25
24
|
componentName?: string
|
|
25
|
+
inverse?: boolean
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const emptyState: ThemeManagerState = { name: '' }
|
|
@@ -56,7 +56,7 @@ export class ThemeManager {
|
|
|
56
56
|
`No parent manager given, this is likely due to duplicated Tamagui dependencies. Check your lockfile for mis-matched versions.`
|
|
57
57
|
)
|
|
58
58
|
}
|
|
59
|
-
throw
|
|
59
|
+
throw `❌ 0`
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// no change no props
|
|
@@ -311,6 +311,7 @@ function getState(
|
|
|
311
311
|
className: getNextThemeClassName(found),
|
|
312
312
|
parentName,
|
|
313
313
|
componentName,
|
|
314
|
+
inverse: props.inverse,
|
|
314
315
|
}
|
|
315
316
|
break
|
|
316
317
|
}
|
|
@@ -181,11 +181,24 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
181
181
|
debug,
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
if (
|
|
184
|
+
if (
|
|
185
|
+
process.env.NODE_ENV === 'development' &&
|
|
186
|
+
debug &&
|
|
187
|
+
debug !== 'profile' &&
|
|
188
|
+
isClient
|
|
189
|
+
) {
|
|
185
190
|
console.groupCollapsed('getSplitStyles (collapsed)')
|
|
186
191
|
// prettier-ignore
|
|
187
192
|
// rome-ignore lint/nursery/noConsoleLog: ok
|
|
188
|
-
console.log({
|
|
193
|
+
console.log({
|
|
194
|
+
props,
|
|
195
|
+
staticConfig,
|
|
196
|
+
shouldDoClasses,
|
|
197
|
+
styleProps,
|
|
198
|
+
componentState,
|
|
199
|
+
styleState,
|
|
200
|
+
theme: { ...theme },
|
|
201
|
+
});
|
|
189
202
|
console.groupEnd()
|
|
190
203
|
}
|
|
191
204
|
|
|
@@ -526,7 +539,14 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
526
539
|
if (isClient) {
|
|
527
540
|
// prettier-ignore
|
|
528
541
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
529
|
-
console.log({
|
|
542
|
+
console.log({
|
|
543
|
+
variants,
|
|
544
|
+
variant: variants?.[keyInit],
|
|
545
|
+
isVariant,
|
|
546
|
+
isHOCShouldPassThrough,
|
|
547
|
+
curProps: { ...styleState.curProps },
|
|
548
|
+
parentStaticConfig,
|
|
549
|
+
});
|
|
530
550
|
}
|
|
531
551
|
console.groupEnd()
|
|
532
552
|
}
|
|
@@ -598,7 +618,18 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
598
618
|
if (!isServer && isDevTools) {
|
|
599
619
|
// prettier-ignore
|
|
600
620
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
601
|
-
console.log({
|
|
621
|
+
console.log({
|
|
622
|
+
expanded,
|
|
623
|
+
styleProps,
|
|
624
|
+
componentState,
|
|
625
|
+
isVariant,
|
|
626
|
+
variant: variants?.[keyInit],
|
|
627
|
+
shouldPassProp,
|
|
628
|
+
isHOCShouldPassThrough,
|
|
629
|
+
theme,
|
|
630
|
+
usedKeys: { ...usedKeys },
|
|
631
|
+
curProps: { ...styleState.curProps },
|
|
632
|
+
});
|
|
602
633
|
// rome-ignore lint/nursery/noConsoleLog: ok
|
|
603
634
|
console.log('expanded', expanded, '\nusedKeys', { ...usedKeys }, '\ncurrent', {
|
|
604
635
|
...style,
|
|
@@ -687,10 +718,10 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
687
718
|
|
|
688
719
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
689
720
|
// prettier-ignore
|
|
690
|
-
console.groupCollapsed(
|
|
721
|
+
console.groupCollapsed("pseudo (classes)", key);
|
|
691
722
|
// prettier-ignore
|
|
692
723
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
693
|
-
console.log({ pseudoStyleObject, pseudoStyles })
|
|
724
|
+
console.log({ pseudoStyleObject, pseudoStyles });
|
|
694
725
|
console.groupEnd()
|
|
695
726
|
}
|
|
696
727
|
|
|
@@ -727,10 +758,16 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
727
758
|
|
|
728
759
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
729
760
|
// prettier-ignore
|
|
730
|
-
console.groupCollapsed(
|
|
761
|
+
console.groupCollapsed("pseudo", key, { isDisabled });
|
|
731
762
|
// prettier-ignore
|
|
732
763
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
733
|
-
console.log(pseudoStyleObject, {
|
|
764
|
+
console.log(pseudoStyleObject, {
|
|
765
|
+
isDisabled,
|
|
766
|
+
descriptorKey,
|
|
767
|
+
descriptor,
|
|
768
|
+
pseudoState,
|
|
769
|
+
state: { ...componentState },
|
|
770
|
+
});
|
|
734
771
|
console.groupEnd()
|
|
735
772
|
}
|
|
736
773
|
|
|
@@ -759,7 +796,12 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
759
796
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
760
797
|
// prettier-ignore
|
|
761
798
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
762
|
-
console.log(
|
|
799
|
+
console.log(" subKey", pkey, shouldMerge, {
|
|
800
|
+
importance,
|
|
801
|
+
curImportance,
|
|
802
|
+
pkey,
|
|
803
|
+
val,
|
|
804
|
+
});
|
|
763
805
|
}
|
|
764
806
|
}
|
|
765
807
|
}
|
|
@@ -806,7 +848,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
806
848
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
807
849
|
// prettier-ignore
|
|
808
850
|
// rome-ignore lint/nursery/noConsoleLog: ok
|
|
809
|
-
console.log(` 📺 ${key}`, { key, mediaStyle, props, shouldDoClasses })
|
|
851
|
+
console.log(` 📺 ${key}`, { key, val, mediaStyle, props, shouldDoClasses });
|
|
810
852
|
}
|
|
811
853
|
|
|
812
854
|
// for some reason 'space' in val upsetting next ssr during prod build
|
|
@@ -842,7 +884,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
842
884
|
}
|
|
843
885
|
}
|
|
844
886
|
|
|
845
|
-
const mediaStyles = getStylesAtomic(mediaStyle)
|
|
887
|
+
const mediaStyles = getStylesAtomic(mediaStyle, debug)
|
|
846
888
|
const priority = mediaStylesSeen
|
|
847
889
|
mediaStylesSeen += 1
|
|
848
890
|
|
|
@@ -1123,7 +1165,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
1123
1165
|
styleState.fontFamily = overrideFace
|
|
1124
1166
|
}
|
|
1125
1167
|
}
|
|
1126
|
-
if (process.env.NODE_ENV === 'development' && debug) {
|
|
1168
|
+
if (process.env.NODE_ENV === 'development' && debug && debug !== 'profile') {
|
|
1127
1169
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
1128
1170
|
console.log(`Found fontFamily native: ${style.fontFamily}`, faceInfo)
|
|
1129
1171
|
}
|
|
@@ -1138,7 +1180,15 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
1138
1180
|
if (isDevTools) {
|
|
1139
1181
|
console.groupCollapsed(' 🔹 ===>')
|
|
1140
1182
|
// prettier-ignore
|
|
1141
|
-
const logs = {
|
|
1183
|
+
const logs = {
|
|
1184
|
+
...result,
|
|
1185
|
+
componentState,
|
|
1186
|
+
transforms,
|
|
1187
|
+
viewProps,
|
|
1188
|
+
viewPropsOrder: Object.keys(viewProps),
|
|
1189
|
+
rulesToInsert,
|
|
1190
|
+
parentSplitStyles,
|
|
1191
|
+
};
|
|
1142
1192
|
for (const key in logs) {
|
|
1143
1193
|
// rome-ignore lint/nursery/noConsoleLog: ok
|
|
1144
1194
|
console.log(key, logs[key])
|
|
@@ -6,77 +6,55 @@
|
|
|
6
6
|
import { StyleObject, simpleHash } from '@tamagui/helpers'
|
|
7
7
|
|
|
8
8
|
import { getConfig } from '../config'
|
|
9
|
-
import type { TamaguiInternalConfig, ViewStyleWithPseudos } from '../types'
|
|
9
|
+
import type { DebugProp, TamaguiInternalConfig, ViewStyleWithPseudos } from '../types'
|
|
10
10
|
import { defaultOffset } from './defaultOffset'
|
|
11
11
|
import { normalizeValueWithProperty } from './normalizeValueWithProperty'
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
PseudoDescriptor,
|
|
14
|
+
pseudoDescriptors,
|
|
15
|
+
pseudoDescriptorsBase,
|
|
16
|
+
} from './pseudoDescriptors'
|
|
13
17
|
|
|
14
18
|
// refactor this file away next...
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
const pseudosOrdered = [
|
|
18
|
-
pseudoDescriptors.hoverStyle,
|
|
19
|
-
pseudoDescriptors.pressStyle,
|
|
20
|
-
pseudoDescriptors.focusStyle,
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
export function getStylesAtomic(stylesIn: ViewStyleWithPseudos) {
|
|
24
|
-
// performance optimization
|
|
25
|
-
if (!(stylesIn.hoverStyle || stylesIn.pressStyle || stylesIn.focusStyle)) {
|
|
26
|
-
return generateAtomicStyles(stylesIn)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// only for pseudos
|
|
30
|
-
const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn
|
|
20
|
+
export function getStylesAtomic(stylesIn: ViewStyleWithPseudos, debug?: DebugProp) {
|
|
31
21
|
let res: StyleObject[] = []
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
for (const pseudoName in pseudoDescriptorsBase) {
|
|
23
|
+
const pseudoStyle = stylesIn[pseudoName]
|
|
24
|
+
if (pseudoStyle) {
|
|
25
|
+
res = [
|
|
26
|
+
...res,
|
|
27
|
+
...generateAtomicStyles(pseudoStyle, pseudoDescriptorsBase[pseudoName]),
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
res = [...res, ...generateAtomicStyles(stylesIn)]
|
|
32
|
+
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
33
|
+
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
34
|
+
console.log(` 🪮 getStylesAtomic`, { stylesIn, res })
|
|
37
35
|
}
|
|
38
36
|
return res
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
let conf: TamaguiInternalConfig
|
|
42
40
|
|
|
41
|
+
// mutates...
|
|
42
|
+
|
|
43
43
|
export const generateAtomicStyles = (
|
|
44
|
-
|
|
44
|
+
style: ViewStyleWithPseudos,
|
|
45
45
|
pseudo?: PseudoDescriptor
|
|
46
46
|
): StyleObject[] => {
|
|
47
|
-
if (!
|
|
47
|
+
if (!style) return []
|
|
48
48
|
|
|
49
49
|
conf = conf || getConfig()
|
|
50
50
|
|
|
51
|
-
// were converting to css styles
|
|
52
|
-
const style = { ...styleIn } as Record<string, string | null | undefined>
|
|
53
|
-
|
|
54
|
-
// transform
|
|
55
|
-
if ('transform' in style && Array.isArray(style.transform)) {
|
|
56
|
-
style.transform = style.transform
|
|
57
|
-
.map(
|
|
58
|
-
// { scale: 2 } => 'scale(2)'
|
|
59
|
-
// { translateX: 20 } => 'translateX(20px)'
|
|
60
|
-
// { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'
|
|
61
|
-
(transform) => {
|
|
62
|
-
const type = Object.keys(transform)[0]
|
|
63
|
-
const value = transform[type]
|
|
64
|
-
if (type === 'matrix' || type === 'matrix3d') {
|
|
65
|
-
return `${type}(${value.join(',')})`
|
|
66
|
-
}
|
|
67
|
-
return `${type}(${normalizeValueWithProperty(value, type)})`
|
|
68
|
-
}
|
|
69
|
-
)
|
|
70
|
-
.join(' ')
|
|
71
|
-
}
|
|
72
|
-
|
|
73
51
|
styleToCSS(style)
|
|
74
52
|
|
|
75
53
|
const out: StyleObject[] = []
|
|
76
54
|
for (const key in style) {
|
|
77
55
|
const value = normalizeValueWithProperty(style[key], key)
|
|
78
|
-
if (
|
|
79
|
-
|
|
56
|
+
if (key in pseudoDescriptors) continue
|
|
57
|
+
if (value == null) continue
|
|
80
58
|
const hash = simpleHash(`${value}`)
|
|
81
59
|
const pseudoPrefix = pseudo ? `0${pseudo.name}-` : ''
|
|
82
60
|
const shortProp = conf.inverseShorthands[key] || key
|
|
@@ -96,6 +74,25 @@ export const generateAtomicStyles = (
|
|
|
96
74
|
}
|
|
97
75
|
|
|
98
76
|
export function styleToCSS(style: Record<string, any>) {
|
|
77
|
+
// transform
|
|
78
|
+
if ('transform' in style && Array.isArray(style.transform)) {
|
|
79
|
+
style.transform = style.transform
|
|
80
|
+
.map(
|
|
81
|
+
// { scale: 2 } => 'scale(2)'
|
|
82
|
+
// { translateX: 20 } => 'translateX(20px)'
|
|
83
|
+
// { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'
|
|
84
|
+
(transform) => {
|
|
85
|
+
const type = Object.keys(transform)[0]
|
|
86
|
+
const value = transform[type]
|
|
87
|
+
if (type === 'matrix' || type === 'matrix3d') {
|
|
88
|
+
return `${type}(${value.join(',')})`
|
|
89
|
+
}
|
|
90
|
+
return `${type}(${normalizeValueWithProperty(value, type)})`
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
.join(' ')
|
|
94
|
+
}
|
|
95
|
+
|
|
99
96
|
// box-shadow
|
|
100
97
|
const { shadowOffset, shadowRadius, shadowColor } = style
|
|
101
98
|
if (style.shadowRadius) {
|
|
@@ -16,6 +16,8 @@ export function normalizeValueWithProperty(value: any, property?: string): any {
|
|
|
16
16
|
return value
|
|
17
17
|
}
|
|
18
18
|
let res = value
|
|
19
|
+
// shadowOffset etc
|
|
20
|
+
if (value && typeof value === 'object') return value
|
|
19
21
|
if (typeof value === 'number') {
|
|
20
22
|
res = `${value}px`
|
|
21
23
|
} else if (property) {
|
|
@@ -42,9 +42,18 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
|
|
|
42
42
|
const { variants } = staticConfig
|
|
43
43
|
|
|
44
44
|
// prettier-ignore
|
|
45
|
-
if (
|
|
45
|
+
if (
|
|
46
|
+
process.env.NODE_ENV === "development" &&
|
|
47
|
+
fontFamily &&
|
|
48
|
+
fontFamily[0] === "$" &&
|
|
49
|
+
!(fontFamily in conf.fontsParsed)
|
|
50
|
+
) {
|
|
46
51
|
// prettier-ignore
|
|
47
|
-
console.warn(
|
|
52
|
+
console.warn(
|
|
53
|
+
`Warning: no fontFamily "${fontFamily}" found in config: ${Object.keys(conf.fontsParsed).join(
|
|
54
|
+
", ",
|
|
55
|
+
)}`,
|
|
56
|
+
);
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
if (variants && key in variants && value != null) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// *0 order matches to *1
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
PseudoDescriptor
|
|
6
|
-
> = {
|
|
3
|
+
export const pseudoDescriptorsBase = {
|
|
4
|
+
// order of keys here important! in priority order
|
|
7
5
|
hoverStyle: {
|
|
8
6
|
name: 'hover',
|
|
9
7
|
priority: 1,
|
|
@@ -17,6 +15,13 @@ export const pseudoDescriptors: Record<
|
|
|
17
15
|
name: 'focus',
|
|
18
16
|
priority: 3,
|
|
19
17
|
},
|
|
18
|
+
} as const
|
|
19
|
+
|
|
20
|
+
export const pseudoDescriptors: Record<
|
|
21
|
+
'hoverStyle' | 'pressStyle' | 'focusStyle' | 'enterStyle' | 'exitStyle',
|
|
22
|
+
PseudoDescriptor
|
|
23
|
+
> = {
|
|
24
|
+
...pseudoDescriptorsBase,
|
|
20
25
|
enterStyle: {
|
|
21
26
|
name: 'enter',
|
|
22
27
|
stateKey: 'unmounted',
|