@tamagui/core 1.0.0-alpha.5 → 1.0.0-alpha.6
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/createComponent.js +42 -28
- package/dist/createComponent.js.map +2 -2
- package/dist/createVariable.js +3 -0
- package/dist/createVariable.js.map +2 -2
- package/dist/helpers/getSplitStyles.js +1 -13
- package/dist/helpers/getSplitStyles.js.map +2 -2
- package/dist/helpers/isComponent.js +10 -0
- package/dist/helpers/isComponent.js.map +7 -0
- package/dist/helpers/isTamaguiComponent.js +10 -0
- package/dist/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/helpers/isTamaguiElement.js +10 -0
- package/dist/helpers/isTamaguiElement.js.map +7 -0
- package/dist/index.cjs +105 -71
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/views/Theme.js +11 -4
- package/dist/views/Theme.js.map +2 -2
- package/dist/views/ThemeInverse.js +0 -1
- package/dist/views/ThemeInverse.js.map +2 -2
- package/package.json +4 -5
- package/src/createComponent.tsx +48 -37
- package/src/createVariable.ts +4 -0
- package/src/helpers/getSplitStyles.tsx +3 -16
- package/src/helpers/isTamaguiElement.tsx +5 -0
- package/src/index.ts +1 -1
- package/src/views/Theme.tsx +12 -5
- package/src/views/ThemeInverse.tsx +0 -1
- package/types.d.ts +2 -4
- package/src/views/SafeAreaProvider.tsx +0 -33
package/dist/createComponent.js
CHANGED
|
@@ -47,6 +47,38 @@ function createComponent(configIn) {
|
|
|
47
47
|
let defaultsClassName = "";
|
|
48
48
|
let initialTheme;
|
|
49
49
|
const component = forwardRef((props, forwardedRef) => {
|
|
50
|
+
const forceUpdate = useForceUpdate();
|
|
51
|
+
const features = useFeatures(props, { forceUpdate });
|
|
52
|
+
const manager = useContext(ThemeManagerContext);
|
|
53
|
+
const [state, set_] = useState(() => ({
|
|
54
|
+
hover: false,
|
|
55
|
+
press: false,
|
|
56
|
+
pressIn: false,
|
|
57
|
+
theme: manager.name
|
|
58
|
+
}));
|
|
59
|
+
const set = /* @__PURE__ */ __name((next) => set_((prev) => {
|
|
60
|
+
for (const key in next) {
|
|
61
|
+
if (prev[key] !== next[key]) {
|
|
62
|
+
return { ...prev, ...next };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return prev;
|
|
66
|
+
}), "set");
|
|
67
|
+
if (process.env.NODE_ENV === "development" && !isText && isWeb) {
|
|
68
|
+
Children.toArray(props.children).forEach((item) => {
|
|
69
|
+
if (typeof item === "string") {
|
|
70
|
+
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
75
|
+
const hostRef = useRef(null);
|
|
76
|
+
const {
|
|
77
|
+
viewProps: viewPropsIn,
|
|
78
|
+
pseudos,
|
|
79
|
+
style,
|
|
80
|
+
classNames
|
|
81
|
+
} = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
|
|
50
82
|
const {
|
|
51
83
|
tag,
|
|
52
84
|
hitSlop,
|
|
@@ -80,34 +112,17 @@ function createComponent(configIn) {
|
|
|
80
112
|
onStartShouldSetResponderCapture,
|
|
81
113
|
onMouseDown,
|
|
82
114
|
onClick,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}));
|
|
94
|
-
const set = /* @__PURE__ */ __name((next) => set_((prev) => {
|
|
95
|
-
for (const key in next) {
|
|
96
|
-
if (prev[key] !== next[key]) {
|
|
97
|
-
return { ...prev, ...next };
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return prev;
|
|
101
|
-
}), "set");
|
|
102
|
-
if (process.env.NODE_ENV === "development" && !isText && isWeb) {
|
|
103
|
-
Children.toArray(props.children).forEach((item) => {
|
|
104
|
-
if (typeof item === "string") {
|
|
105
|
-
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
115
|
+
accessible,
|
|
116
|
+
accessibilityRole,
|
|
117
|
+
onLayout,
|
|
118
|
+
...viewProps
|
|
119
|
+
} = viewPropsIn;
|
|
120
|
+
if (!isWeb) {
|
|
121
|
+
if (accessible)
|
|
122
|
+
viewProps.accessible = accessible;
|
|
123
|
+
if (accessibilityRole)
|
|
124
|
+
viewProps.accessibilityRole = accessibilityRole;
|
|
108
125
|
}
|
|
109
|
-
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
110
|
-
const hostRef = useRef(null);
|
|
111
126
|
if (isWeb) {
|
|
112
127
|
rnw.useResponderEvents(hostRef, {
|
|
113
128
|
onMoveShouldSetResponder,
|
|
@@ -129,7 +144,6 @@ function createComponent(configIn) {
|
|
|
129
144
|
});
|
|
130
145
|
}
|
|
131
146
|
const isTracking = useRef(false);
|
|
132
|
-
const { viewProps, pseudos, style, classNames } = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
|
|
133
147
|
const internal = useRef();
|
|
134
148
|
if (!internal.current) {
|
|
135
149
|
internal.current = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/createComponent.tsx"],
|
|
4
|
-
"sourcesContent": ["import { concatClassName, stylePropsView } from '@tamagui/helpers'\nimport { useForceUpdate } from '@tamagui/use-force-update'\nimport React, {\n Children,\n Fragment,\n createElement,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport { StyleSheet, Text, View, ViewStyle } from 'react-native'\n\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\nimport { onConfiguredOnce } from './createTamagui'\nimport { addStylesUsingClassname, useStylesAsClassname } from './helpers/addStylesUsingClassname'\nimport { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'\nimport { getSplitStyles } from './helpers/getSplitStyles'\nimport { useFeatures } from './hooks/useFeatures'\nimport { usePressable } from './hooks/usePressable'\nimport {\n SpaceTokens,\n StaticComponent,\n StaticConfig,\n StaticConfigParsed,\n TamaguiInternalConfig,\n} from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\nimport { ThemeManagerContext } from './views/ThemeManagerContext'\n\nexport const mouseUps = new Set<Function>()\n\nif (typeof document !== 'undefined') {\n document.addEventListener('mouseup', () => {\n mouseUps.forEach((x) => x())\n mouseUps.clear()\n })\n}\n\ntype DefaultProps = {}\n\nexport function createComponent<A extends Object = DefaultProps>(\n configIn: Partial<StaticConfig> | StaticConfigParsed\n) {\n let staticConfig: StaticConfigParsed\n if ('parsed' in configIn) {\n staticConfig = configIn\n } else {\n staticConfig = parseStaticConfig(configIn)\n }\n\n const { Component, validStyles, isText, isZStack } = staticConfig\n const validStyleProps = validStyles ?? stylePropsView\n\n // split out default styles vs props so we can assign it to component.defaultProps\n let defaultProps = null as any\n let tamaguiConfig: TamaguiInternalConfig\n\n // web uses className, native uses style\n let defaultsStyle: any\n let defaultsClassName = ''\n let initialTheme: any\n\n // see onConfiguredOnce below which attaches a name then to this component\n\n const component = forwardRef<View, A>((props: any, forwardedRef) => {\n const {\n tag,\n hitSlop,\n children,\n pointerEvents,\n onPress,\n onPressIn,\n onPressOut,\n onHoverIn,\n onHoverOut,\n space,\n disabled,\n onMouseEnter,\n onMouseLeave,\n hrefAttrs,\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n onMouseDown,\n onClick,\n // TODO feature load layou hook\n onLayout,\n } = props\n\n const forceUpdate = useForceUpdate()\n const features = useFeatures(props, { forceUpdate })\n const manager = useContext(ThemeManagerContext)\n const [state, set_] = useState(() => ({\n hover: false,\n press: false,\n pressIn: false,\n theme: manager.name,\n }))\n const set = (next: Partial<typeof state>) =>\n set_((prev) => {\n for (const key in next) {\n if (prev[key] !== next[key]) {\n return { ...prev, ...next }\n }\n }\n return prev\n })\n\n // from react-native-web\n if (process.env.NODE_ENV === 'development' && !isText && isWeb) {\n Children.toArray(props.children).forEach((item) => {\n if (typeof item === 'string') {\n console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`)\n }\n })\n }\n\n const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false\n const hostRef = useRef(null)\n\n if (isWeb) {\n // from react-native-web\n rnw.useResponderEvents(hostRef, {\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n })\n }\n\n const isTracking = useRef(false)\n\n const { viewProps, pseudos, style, classNames } = getSplitStyles(\n props,\n staticConfig,\n (manager.theme as any) || initialTheme\n )\n\n // hasEverHadEvents prevents repareting if you remove onPress or similar...\n const internal = useRef<{ isMounted: boolean; hasEverHadEvents?: boolean }>()\n if (!internal.current) {\n internal.current = {\n isMounted: true,\n }\n }\n\n useEffect(() => {\n internal.current!.isMounted = true\n const dispose = manager?.onChangeTheme((name) => {\n if (isTracking.current) {\n set({ theme: name })\n }\n })\n return () => {\n dispose()\n mouseUps.delete(unPress)\n isTracking.current = false\n internal.current!.isMounted = false\n }\n }, [manager])\n\n // element\n const element = isWeb\n ? !Component || typeof Component === 'string'\n ? // default to tag, fallback to component (when both strings)\n tag || Component\n : Component\n : Component\n const ReactView = !isWeb ? View : element || (hasTextAncestor ? 'span' : 'div')\n const ReactText = !isWeb ? Text : element || 'span'\n const ViewComponent = isText ? ReactText : ReactView\n\n // styles\n const isHovering = !isTouchDevice && !disabled && pseudos && state.hover\n const isPressing = !disabled && pseudos && state.press\n\n const styles = [\n // parity w react-native-web, only for text in text\n // TODO this should be able to be done w css to replicate after extraction:\n // (.text .text { display: inline-flex; }) (but if they set display we'd need stronger precendence)\n // isText && hasTextAncestor && isWeb ? { display: 'inline-flex' } : null,\n style,\n isHovering ? pseudos.hoverStyle || null : null,\n isPressing ? pseudos.pressStyle || null : null,\n ]\n\n if (isWeb) {\n const stylesClassNames = useStylesAsClassname(styles)\n const classList = isText\n ? [\n defaultsClassName,\n // hasTextAncestor === true && cssText.textHasAncestor,\n // TODO MOVE TO VARIANTS [number] [any]\n // numberOfLines != null && numberOfLines > 1 && cssText.textMultiLine,\n classNames,\n stylesClassNames,\n props.className,\n ]\n : [defaultsClassName, props.className, classNames, stylesClassNames]\n\n // @ts-expect-error\n const className = concatClassName(...classList)\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // prettier-ignore\n console.log('\uD83E\uDD5A className', { style, styles, classList, stylesClassNames, className })\n }\n }\n viewProps.className = className\n } else {\n viewProps.style = styles\n }\n\n if (pointerEvents) {\n viewProps.pointerEvents = pointerEvents\n }\n\n if (isWeb) {\n // from react-native-web\n const platformMethodsRef = rnw.usePlatformMethods(viewProps)\n const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef)\n viewProps.ref = setRef\n if (props.href != null && hrefAttrs != null) {\n const { download, rel, target } = hrefAttrs\n if (download != null) {\n viewProps.download = download\n }\n if (rel != null) {\n viewProps.rel = rel\n }\n if (typeof target === 'string') {\n viewProps.target = target.charAt(0) !== '_' ? '_' + target : target\n }\n }\n } else {\n if (forwardedRef) {\n viewProps.ref = forwardedRef\n }\n }\n\n const attachPress = !!(\n (pseudos && pseudos.pressStyle) ||\n onPress ||\n onPressOut ||\n onPressIn ||\n onClick\n )\n const attachHover =\n isWeb &&\n !isTouchDevice &&\n !!((pseudos && pseudos.hoverStyle) || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)\n\n // check presence to prevent reparenting bugs, allows for onPress={x ? function : undefined} usage\n // while avoiding reparenting...\n // once proper reparenting is supported, we can remove this and use that...\n const shouldAttach =\n internal.current.hasEverHadEvents ||\n attachPress ||\n attachHover ||\n 'pressStyle' in props ||\n 'onPress' in props ||\n 'onPressIn' in props ||\n 'onPressOut' in props ||\n (isWeb &&\n ('hoverStyle' in props ||\n 'onClick' in props ||\n 'onHoverIn' in props ||\n 'onHoverOut' in props ||\n 'onMouseEnter' in props ||\n 'onMouseLeave' in props))\n\n // never remove events as we wrap in a div (for now, may be able to remove..)\n if (shouldAttach) {\n internal.current.hasEverHadEvents = true\n }\n\n const unPress = useCallback(() => {\n if (!internal.current!.isMounted) return\n set({\n press: false,\n pressIn: false,\n })\n }, [])\n\n const events = shouldAttach\n ? {\n ...(!isWeb && {\n // non web\n onPressOut: (e) => {\n unPress()\n onPressOut?.(e)\n },\n }),\n ...(isWeb &&\n !isTouchDevice && {\n onMouseEnter:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n if (attachHover) {\n next.hover = true\n }\n if (state.pressIn) {\n next.press = true\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverIn?.(e)\n onMouseEnter?.(e)\n }\n : undefined,\n onMouseLeave:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n mouseUps.add(unPress)\n if (attachHover) {\n next.hover = false\n }\n if (state.pressIn) {\n next.press = false\n next.pressIn = false\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverOut?.(e)\n onMouseLeave?.(e)\n }\n : undefined,\n }),\n onMouseDown: attachPress\n ? (e) => {\n set({\n press: true,\n pressIn: true,\n })\n onPressIn?.(e)\n onMouseDown?.(e)\n }\n : (onPressIn as any),\n onClick: attachPress\n ? (e) => {\n // this caused issue with next.js passing href\n // e.preventDefault()\n onPress?.(e)\n onClick?.(e)\n unPress()\n onPressOut?.(e)\n }\n : (onPressOut as any),\n }\n : null\n\n if (events) {\n if (typeof ViewComponent !== 'string') {\n // TODO once we do the above we can then rely entirely on pressStyle returned here isntead of above pressStyle logic\n const [pressProps] = usePressable({\n disabled,\n hitSlop,\n onPressIn: events.onMouseDown,\n onPressOut: events.onPressOut,\n onPress: events.onClick,\n })\n Object.assign(viewProps, pressProps)\n } else {\n Object.assign(viewProps, events)\n }\n }\n\n const childEls = spacedChildren({\n children,\n space,\n flexDirection: props.flexDirection || defaultProps?.flexDirection,\n isZStack: isZStack,\n })\n\n let content: any\n\n // replicate react-native-web's `createElement`\n if (isWeb && rnw) {\n const domProps = rnw.createDOMProps(viewProps)\n const className =\n domProps.className && domProps.className !== viewProps.className\n ? `${domProps.className} ${viewProps.className}`\n : viewProps.className\n Object.assign(viewProps, domProps)\n viewProps.className = className\n content = createElement(ViewComponent, viewProps, childEls)\n } else {\n content = createElement(ViewComponent, viewProps, childEls)\n }\n\n const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor\n if (shouldWrapTextAncestor) {\n // from react-native-web\n // @ts-ignore\n content = createElement(TextAncestorContext.Provider, { value: true }, content)\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n viewProps['debug'] = true\n console.log('\uD83E\uDD5A props in:', props)\n console.log('\uD83E\uDD5A props out:', viewProps)\n console.log(props.onClick?.toString())\n // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls })\n // only on browser because node expands it huge\n if (isWeb) {\n console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\n }\n }\n }\n\n return (\n <>\n {features}\n {content}\n </>\n )\n })\n\n // Once configuration is run and all components are registered\n // get default props + className and analyze styles\n onConfiguredOnce((conf) => {\n tamaguiConfig = conf\n initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]\n const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true)\n if (isWeb) {\n if (next.classNames) {\n defaultsClassName += next.classNames + ' '\n }\n defaultsClassName += addStylesUsingClassname([next.style, next.pseudos])\n } else {\n if (!hasWarnedOnce) {\n hasWarnedOnce = true\n console.log('\u26A0\uFE0F we need to account for default styles for media queries')\n }\n }\n // @ts-ignore\n component.defaultProps = {\n ...next.viewProps,\n ...component.defaultProps,\n }\n if (process.env.NODE_ENV === 'development') {\n if (staticConfig.defaultProps?.debug) {\n console.log('tamagui debug component:', next, defaultsClassName, component.defaultProps)\n }\n }\n })\n\n component['staticConfig'] = {\n validStyles: validStyleProps,\n ...staticConfig,\n }\n\n const res = component as any as StaticComponent<A, void>\n\n // add extractable HoC\n res['extractable'] = (Component: any) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n neverFlatten: true,\n defaultProps: Component.defaultProps,\n })\n return Component\n }\n\n return res\n}\n\nlet hasWarnedOnce = false\n\n// dont used styled() here to avoid circular deps\n// keep inline to avoid circular deps\n\nexport const Spacer = createComponent<{ size?: number | SpaceTokens; flex?: boolean | number }>({\n defaultProps: {\n ...stackDefaultStyles,\n size: true,\n },\n variants: {\n size: {\n '...size': (size, { tokens }) => {\n size = size == true ? '$true' : size\n return {\n width: tokens.size[size] ?? size,\n height: tokens.size[size] ?? size,\n }\n },\n },\n\n direction: {\n horizontal: {\n height: 0,\n },\n vertical: {\n width: 0,\n },\n },\n },\n})\n\nexport function spacedChildren({\n isZStack,\n children,\n space,\n flexDirection,\n}: {\n isZStack?: boolean\n children: any\n space?: any\n flexDirection?: ViewStyle['flexDirection']\n}) {\n if (!space && !isZStack) {\n return children\n }\n const childrenList = Children.toArray(children)\n const len = childrenList.length\n if (len === 1) {\n return children\n }\n const next: any[] = []\n for (const [index, child] of childrenList.entries()) {\n if (child === null || child === undefined) {\n continue\n }\n\n const key = `${child?.['key'] ?? index}`\n\n next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>)\n\n // allows for custom visually hidden components that dont insert spacing\n if (child?.['type']?.['isVisuallyHidden']) {\n continue\n }\n\n if (index !== len - 1) {\n if (space) {\n next.push(\n <Spacer\n key={`${key}_spacer`}\n // @ts-ignore TODO\n direction={\n flexDirection === 'row' || flexDirection === 'row-reverse' ? 'horizontal' : 'vertical'\n }\n size={space}\n />\n )\n }\n }\n }\n return next\n}\n\n// for now not so \"tamagui-y\"\nconst Absolute = ({ children }) => <View style={sheet.fullscreen}>{children}</View>\nconst sheet = StyleSheet.create({\n fullscreen: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n },\n})\n"],
|
|
5
|
-
"mappings": ";;AAAA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AAEO,MAAM,WAAW,IAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAAiB,WAAW,MAAM;AACzC,aAAS,QAAQ,CAAC,MAAM;AACxB,aAAS;AAAA;AAAA;AAMN,yBACL,UACA;AACA,MAAI;AACJ,MAAI,YAAY,UAAU;AACxB,mBAAe;AAAA,SACV;AACL,mBAAe,kBAAkB;AAAA;AAGnC,QAAM,EAAE,WAAW,aAAa,QAAQ,aAAa;AACrD,QAAM,kBAAkB,eAAe;AAGvC,MAAI,eAAe;AACnB,MAAI;AAGJ,MAAI;AACJ,MAAI,oBAAoB;AACxB,MAAI;AAIJ,QAAM,YAAY,WAAoB,CAAC,OAAY,iBAAiB;AAClE,UAAM
|
|
4
|
+
"sourcesContent": ["import { concatClassName, stylePropsView } from '@tamagui/helpers'\nimport { useForceUpdate } from '@tamagui/use-force-update'\nimport React, {\n Children,\n Fragment,\n createElement,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport { StyleSheet, Text, View, ViewStyle } from 'react-native'\n\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\nimport { onConfiguredOnce } from './createTamagui'\nimport { addStylesUsingClassname, useStylesAsClassname } from './helpers/addStylesUsingClassname'\nimport { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'\nimport { getSplitStyles } from './helpers/getSplitStyles'\nimport { useFeatures } from './hooks/useFeatures'\nimport { usePressable } from './hooks/usePressable'\nimport {\n SpaceTokens,\n StaticComponent,\n StaticConfig,\n StaticConfigParsed,\n TamaguiInternalConfig,\n} from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\nimport { ThemeManagerContext } from './views/ThemeManagerContext'\n\nexport const mouseUps = new Set<Function>()\n\nif (typeof document !== 'undefined') {\n document.addEventListener('mouseup', () => {\n mouseUps.forEach((x) => x())\n mouseUps.clear()\n })\n}\n\ntype DefaultProps = {}\n\nexport function createComponent<A extends Object = DefaultProps>(\n configIn: Partial<StaticConfig> | StaticConfigParsed\n) {\n let staticConfig: StaticConfigParsed\n if ('parsed' in configIn) {\n staticConfig = configIn\n } else {\n staticConfig = parseStaticConfig(configIn)\n }\n\n const { Component, validStyles, isText, isZStack } = staticConfig\n const validStyleProps = validStyles ?? stylePropsView\n\n // split out default styles vs props so we can assign it to component.defaultProps\n let defaultProps = null as any\n let tamaguiConfig: TamaguiInternalConfig\n\n // web uses className, native uses style\n let defaultsStyle: any\n let defaultsClassName = ''\n let initialTheme: any\n\n // see onConfiguredOnce below which attaches a name then to this component\n\n const component = forwardRef<View, A>((props: any, forwardedRef) => {\n const forceUpdate = useForceUpdate()\n const features = useFeatures(props, { forceUpdate })\n const manager = useContext(ThemeManagerContext)\n const [state, set_] = useState(() => ({\n hover: false,\n press: false,\n pressIn: false,\n theme: manager.name,\n }))\n const set = (next: Partial<typeof state>) =>\n set_((prev) => {\n for (const key in next) {\n if (prev[key] !== next[key]) {\n return { ...prev, ...next }\n }\n }\n return prev\n })\n\n // from react-native-web\n if (process.env.NODE_ENV === 'development' && !isText && isWeb) {\n Children.toArray(props.children).forEach((item) => {\n if (typeof item === 'string') {\n console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`)\n }\n })\n }\n\n const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false\n const hostRef = useRef(null)\n\n const {\n viewProps: viewPropsIn,\n pseudos,\n style,\n classNames,\n } = getSplitStyles(props, staticConfig, (manager.theme as any) || initialTheme)\n\n const {\n tag,\n hitSlop,\n children,\n pointerEvents,\n onPress,\n onPressIn,\n onPressOut,\n onHoverIn,\n onHoverOut,\n space,\n disabled,\n onMouseEnter,\n onMouseLeave,\n hrefAttrs,\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n onMouseDown,\n onClick,\n\n accessible,\n accessibilityRole,\n\n // TODO feature load layout hook\n onLayout,\n ...viewProps\n } = viewPropsIn\n\n if (!isWeb) {\n if (accessible) viewProps.accessible = accessible\n if (accessibilityRole) viewProps.accessibilityRole = accessibilityRole\n }\n\n if (isWeb) {\n // from react-native-web\n rnw.useResponderEvents(hostRef, {\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n })\n }\n\n const isTracking = useRef(false)\n\n // hasEverHadEvents prevents repareting if you remove onPress or similar...\n const internal = useRef<{ isMounted: boolean; hasEverHadEvents?: boolean }>()\n if (!internal.current) {\n internal.current = {\n isMounted: true,\n }\n }\n\n useEffect(() => {\n internal.current!.isMounted = true\n const dispose = manager?.onChangeTheme((name) => {\n if (isTracking.current) {\n set({ theme: name })\n }\n })\n return () => {\n dispose()\n mouseUps.delete(unPress)\n isTracking.current = false\n internal.current!.isMounted = false\n }\n }, [manager])\n\n // element\n const element = isWeb\n ? !Component || typeof Component === 'string'\n ? // default to tag, fallback to component (when both strings)\n tag || Component\n : Component\n : Component\n const ReactView = !isWeb ? View : element || (hasTextAncestor ? 'span' : 'div')\n const ReactText = !isWeb ? Text : element || 'span'\n const ViewComponent = isText ? ReactText : ReactView\n\n // styles\n const isHovering = !isTouchDevice && !disabled && pseudos && state.hover\n const isPressing = !disabled && pseudos && state.press\n\n const styles = [\n // parity w react-native-web, only for text in text\n // TODO this should be able to be done w css to replicate after extraction:\n // (.text .text { display: inline-flex; }) (but if they set display we'd need stronger precendence)\n // isText && hasTextAncestor && isWeb ? { display: 'inline-flex' } : null,\n style,\n isHovering ? pseudos.hoverStyle || null : null,\n isPressing ? pseudos.pressStyle || null : null,\n ]\n\n if (isWeb) {\n const stylesClassNames = useStylesAsClassname(styles)\n const classList = isText\n ? [\n defaultsClassName,\n // hasTextAncestor === true && cssText.textHasAncestor,\n // TODO MOVE TO VARIANTS [number] [any]\n // numberOfLines != null && numberOfLines > 1 && cssText.textMultiLine,\n classNames,\n stylesClassNames,\n props.className,\n ]\n : [defaultsClassName, props.className, classNames, stylesClassNames]\n\n // @ts-expect-error\n const className = concatClassName(...classList)\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // prettier-ignore\n console.log('\uD83E\uDD5A className', { style, styles, classList, stylesClassNames, className })\n }\n }\n viewProps.className = className\n } else {\n viewProps.style = styles\n }\n\n if (pointerEvents) {\n viewProps.pointerEvents = pointerEvents\n }\n\n if (isWeb) {\n // from react-native-web\n const platformMethodsRef = rnw.usePlatformMethods(viewProps)\n const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef)\n viewProps.ref = setRef\n if (props.href != null && hrefAttrs != null) {\n const { download, rel, target } = hrefAttrs\n if (download != null) {\n viewProps.download = download\n }\n if (rel != null) {\n viewProps.rel = rel\n }\n if (typeof target === 'string') {\n viewProps.target = target.charAt(0) !== '_' ? '_' + target : target\n }\n }\n } else {\n if (forwardedRef) {\n viewProps.ref = forwardedRef\n }\n }\n\n const attachPress = !!(\n (pseudos && pseudos.pressStyle) ||\n onPress ||\n onPressOut ||\n onPressIn ||\n onClick\n )\n const attachHover =\n isWeb &&\n !isTouchDevice &&\n !!((pseudos && pseudos.hoverStyle) || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)\n\n // check presence to prevent reparenting bugs, allows for onPress={x ? function : undefined} usage\n // while avoiding reparenting...\n // once proper reparenting is supported, we can remove this and use that...\n const shouldAttach =\n internal.current.hasEverHadEvents ||\n attachPress ||\n attachHover ||\n 'pressStyle' in props ||\n 'onPress' in props ||\n 'onPressIn' in props ||\n 'onPressOut' in props ||\n (isWeb &&\n ('hoverStyle' in props ||\n 'onClick' in props ||\n 'onHoverIn' in props ||\n 'onHoverOut' in props ||\n 'onMouseEnter' in props ||\n 'onMouseLeave' in props))\n\n // never remove events as we wrap in a div (for now, may be able to remove..)\n if (shouldAttach) {\n internal.current.hasEverHadEvents = true\n }\n\n const unPress = useCallback(() => {\n if (!internal.current!.isMounted) return\n set({\n press: false,\n pressIn: false,\n })\n }, [])\n\n const events = shouldAttach\n ? {\n ...(!isWeb && {\n // non web\n onPressOut: (e) => {\n unPress()\n onPressOut?.(e)\n },\n }),\n ...(isWeb &&\n !isTouchDevice && {\n onMouseEnter:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n if (attachHover) {\n next.hover = true\n }\n if (state.pressIn) {\n next.press = true\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverIn?.(e)\n onMouseEnter?.(e)\n }\n : undefined,\n onMouseLeave:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n mouseUps.add(unPress)\n if (attachHover) {\n next.hover = false\n }\n if (state.pressIn) {\n next.press = false\n next.pressIn = false\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverOut?.(e)\n onMouseLeave?.(e)\n }\n : undefined,\n }),\n onMouseDown: attachPress\n ? (e) => {\n set({\n press: true,\n pressIn: true,\n })\n onPressIn?.(e)\n onMouseDown?.(e)\n }\n : (onPressIn as any),\n onClick: attachPress\n ? (e) => {\n // this caused issue with next.js passing href\n // e.preventDefault()\n onPress?.(e)\n onClick?.(e)\n unPress()\n onPressOut?.(e)\n }\n : (onPressOut as any),\n }\n : null\n\n if (events) {\n if (typeof ViewComponent !== 'string') {\n // TODO once we do the above we can then rely entirely on pressStyle returned here isntead of above pressStyle logic\n const [pressProps] = usePressable({\n disabled,\n hitSlop,\n onPressIn: events.onMouseDown,\n onPressOut: events.onPressOut,\n onPress: events.onClick,\n })\n Object.assign(viewProps, pressProps)\n } else {\n Object.assign(viewProps, events)\n }\n }\n\n const childEls = spacedChildren({\n children,\n space,\n flexDirection: props.flexDirection || defaultProps?.flexDirection,\n isZStack: isZStack,\n })\n\n let content: any\n\n // replicate react-native-web's `createElement`\n if (isWeb && rnw) {\n const domProps = rnw.createDOMProps(viewProps)\n const className =\n domProps.className && domProps.className !== viewProps.className\n ? `${domProps.className} ${viewProps.className}`\n : viewProps.className\n Object.assign(viewProps, domProps)\n viewProps.className = className\n content = createElement(ViewComponent, viewProps, childEls)\n } else {\n content = createElement(ViewComponent, viewProps, childEls)\n }\n\n const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor\n if (shouldWrapTextAncestor) {\n // from react-native-web\n // @ts-ignore\n content = createElement(TextAncestorContext.Provider, { value: true }, content)\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n viewProps['debug'] = true\n console.log('\uD83E\uDD5A props in:', props)\n console.log('\uD83E\uDD5A props out:', viewProps)\n console.log(props.onClick?.toString())\n // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls })\n // only on browser because node expands it huge\n if (isWeb) {\n console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\n }\n }\n }\n\n return (\n <>\n {features}\n {content}\n </>\n )\n })\n\n // Once configuration is run and all components are registered\n // get default props + className and analyze styles\n onConfiguredOnce((conf) => {\n tamaguiConfig = conf\n initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]\n const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true)\n if (isWeb) {\n if (next.classNames) {\n defaultsClassName += next.classNames + ' '\n }\n defaultsClassName += addStylesUsingClassname([next.style, next.pseudos])\n } else {\n if (!hasWarnedOnce) {\n hasWarnedOnce = true\n console.log('\u26A0\uFE0F we need to account for default styles for media queries')\n }\n }\n // @ts-ignore\n component.defaultProps = {\n ...next.viewProps,\n ...component.defaultProps,\n }\n if (process.env.NODE_ENV === 'development') {\n if (staticConfig.defaultProps?.debug) {\n console.log('tamagui debug component:', next, defaultsClassName, component.defaultProps)\n }\n }\n })\n\n component['staticConfig'] = {\n validStyles: validStyleProps,\n ...staticConfig,\n }\n\n const res = component as any as StaticComponent<A, void>\n\n // add extractable HoC\n res['extractable'] = (Component: any) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n neverFlatten: true,\n defaultProps: Component.defaultProps,\n })\n return Component\n }\n\n return res\n}\n\nlet hasWarnedOnce = false\n\n// dont used styled() here to avoid circular deps\n// keep inline to avoid circular deps\n\nexport const Spacer = createComponent<{ size?: number | SpaceTokens; flex?: boolean | number }>({\n defaultProps: {\n ...stackDefaultStyles,\n size: true,\n },\n variants: {\n size: {\n '...size': (size, { tokens }) => {\n size = size == true ? '$true' : size\n return {\n width: tokens.size[size] ?? size,\n height: tokens.size[size] ?? size,\n }\n },\n },\n\n direction: {\n horizontal: {\n height: 0,\n },\n vertical: {\n width: 0,\n },\n },\n },\n})\n\nexport function spacedChildren({\n isZStack,\n children,\n space,\n flexDirection,\n}: {\n isZStack?: boolean\n children: any\n space?: any\n flexDirection?: ViewStyle['flexDirection']\n}) {\n if (!space && !isZStack) {\n return children\n }\n const childrenList = Children.toArray(children)\n const len = childrenList.length\n if (len === 1) {\n return children\n }\n const next: any[] = []\n for (const [index, child] of childrenList.entries()) {\n if (child === null || child === undefined) {\n continue\n }\n\n const key = `${child?.['key'] ?? index}`\n\n next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>)\n\n // allows for custom visually hidden components that dont insert spacing\n if (child?.['type']?.['isVisuallyHidden']) {\n continue\n }\n\n if (index !== len - 1) {\n if (space) {\n next.push(\n <Spacer\n key={`${key}_spacer`}\n // @ts-ignore TODO\n direction={\n flexDirection === 'row' || flexDirection === 'row-reverse' ? 'horizontal' : 'vertical'\n }\n size={space}\n />\n )\n }\n }\n }\n return next\n}\n\n// for now not so \"tamagui-y\"\nconst Absolute = ({ children }) => <View style={sheet.fullscreen}>{children}</View>\nconst sheet = StyleSheet.create({\n fullscreen: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n },\n})\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AAEO,MAAM,WAAW,IAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAAiB,WAAW,MAAM;AACzC,aAAS,QAAQ,CAAC,MAAM;AACxB,aAAS;AAAA;AAAA;AAMN,yBACL,UACA;AACA,MAAI;AACJ,MAAI,YAAY,UAAU;AACxB,mBAAe;AAAA,SACV;AACL,mBAAe,k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AAC,OAAO,UAAU,aAAa,WAAW;AACnD,QAAI,UAAU,QAAQ,UAAU,QAAW;AACzC;AAAA;AAGF,UAAM,MAAM,GAAG,QAAQ,UAAU;AAEjC,SAAK,KAAK,oCAAC,UAAD;AAAA,MAAU;AAAA,OAAW,WAAW,oCAAC,UAAD,MAAW,SAAoB;AAGzE,QAAI,QAAQ,UAAU,qBAAqB;AACzC;AAAA;AAGF,QAAI,UAAU,MAAM,GAAG;AACrB,UAAI,OAAO;AACT,aAAK,KACH,oCAAC,QAAD;AAAA,UACE,KAAK,GAAG;AAAA,UAER,WACE,kBAAkB,SAAS,kBAAkB,gBAAgB,eAAe;AAAA,UAE9E,MAAM;AAAA;AAAA;AAAA;AAAA;AAMhB,SAAO;AAAA;AAjDO;AAqDhB,MAAM,WAAW,wBAAC,EAAE,eAAe,oCAAC,MAAD;AAAA,EAAM,OAAO,MAAM;AAAA,GAAa,WAAlD;AACjB,MAAM,QAAQ,WAAW,OAAO;AAAA,EAC9B,YAAY;AAAA,IACV,UAAU;AAAA,IACV,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/createVariable.js
CHANGED
|
@@ -7,6 +7,9 @@ class Variable {
|
|
|
7
7
|
this.name = name;
|
|
8
8
|
this.variable = isWeb ? `var(--${name})` : this.val;
|
|
9
9
|
}
|
|
10
|
+
toString() {
|
|
11
|
+
return isWeb ? this.variable : this.val;
|
|
12
|
+
}
|
|
10
13
|
}
|
|
11
14
|
__name(Variable, "Variable");
|
|
12
15
|
const createVariable = /* @__PURE__ */ __name((props) => new Variable(props), "createVariable");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/createVariable.ts"],
|
|
4
|
-
"sourcesContent": ["import { isWeb } from './constants/platform'\n\nexport class Variable {\n name: string\n val: string | number\n variable: string | number\n\n constructor({ val, name }: VariableIn) {\n // converting to px breaks rn\n this.val = val //typeof val === 'string' ? val : `${val}px`\n this.name = name\n this.variable = isWeb ? `var(--${name})` : this.val\n }\n}\n\ntype VariableIn = { val: string | number; name: string }\n\nexport const createVariable = (props: VariableIn) => new Variable(props)\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v instanceof Variable\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEO,eAAe;AAAA,EAKpB,YAAY,EAAE,KAAK,QAAoB;AAErC,SAAK,MAAM;AACX,SAAK,OAAO;AACZ,SAAK,WAAW,QAAQ,SAAS,UAAU,KAAK;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { isWeb } from './constants/platform'\n\nexport class Variable {\n name: string\n val: string | number\n variable: string | number\n\n constructor({ val, name }: VariableIn) {\n // converting to px breaks rn\n this.val = val //typeof val === 'string' ? val : `${val}px`\n this.name = name\n this.variable = isWeb ? `var(--${name})` : this.val\n }\n\n toString() {\n return isWeb ? this.variable : this.val\n }\n}\n\ntype VariableIn = { val: string | number; name: string }\n\nexport const createVariable = (props: VariableIn) => new Variable(props)\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v instanceof Variable\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEO,eAAe;AAAA,EAKpB,YAAY,EAAE,KAAK,QAAoB;AAErC,SAAK,MAAM;AACX,SAAK,OAAO;AACZ,SAAK,WAAW,QAAQ,SAAS,UAAU,KAAK;AAAA;AAAA,EAGlD,WAAW;AACT,WAAO,QAAQ,KAAK,WAAW,KAAK;AAAA;AAAA;AAbjC;AAmBA,MAAM,iBAAiB,wBAAC,UAAsB,IAAI,SAAS,QAApC;AAEvB,oBAAoB,GAAkC;AAC3D,SAAO,aAAa;AAAA;AADN;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,6 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, isSpl
|
|
|
17
17
|
const validStyleProps = staticConfig.isText ? stylePropsText : validStyles;
|
|
18
18
|
const viewProps = {};
|
|
19
19
|
const style = [];
|
|
20
|
-
const blacklistProps = isSplittingDefaultProps ? blacklistDefaultProps : blacklistFinalProps;
|
|
21
20
|
let pseudos = null;
|
|
22
21
|
let cur = null;
|
|
23
22
|
let classNames = null;
|
|
@@ -96,7 +95,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, isSpl
|
|
|
96
95
|
cur[key] = val;
|
|
97
96
|
continue;
|
|
98
97
|
}
|
|
99
|
-
if (!
|
|
98
|
+
if (!staticConfig.variants || !(key in staticConfig.variants)) {
|
|
100
99
|
viewProps[key] = val;
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -134,17 +133,6 @@ const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props)
|
|
|
134
133
|
fixNativeShadow(styleOut);
|
|
135
134
|
return styleOut;
|
|
136
135
|
}, "getSubStyle");
|
|
137
|
-
const blacklistDefaultProps = {
|
|
138
|
-
...validStyles,
|
|
139
|
-
...stylePropsText
|
|
140
|
-
};
|
|
141
|
-
const blacklistFinalProps = {
|
|
142
|
-
...blacklistDefaultProps,
|
|
143
|
-
tag: true,
|
|
144
|
-
debug: true,
|
|
145
|
-
space: true,
|
|
146
|
-
hitSlop: true
|
|
147
|
-
};
|
|
148
136
|
const mapTransformKeys = {
|
|
149
137
|
x: "translateX",
|
|
150
138
|
y: "translateY"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/getSplitStyles.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n AllRules,\n stylePropsText,\n stylePropsTransform,\n validStyles,\n validStylesPseudo,\n} from '@tamagui/helpers'\nimport { ViewStyle } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { mediaQueryConfig } from '../hooks/useMedia'\nimport { StaticConfigParsed, ThemeObject } from '../types'\nimport { createMediaStyle } from './createMediaStyle'\nimport { fixNativeShadow } from './fixNativeShadow'\nimport { getStylesAtomic } from './getStylesAtomic'\nimport { insertStyleRule } from './insertStyleRule'\n\nexport type SplitStyles = ReturnType<typeof getSplitStyles>\n\n// TODO run over this, should be able to cut it down quite a bit\n\nexport const getSplitStyles = (\n props: { [key: string]: any },\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n isSplittingDefaultProps?: boolean\n) => {\n const validStyleProps = staticConfig.isText ? stylePropsText : validStyles\n const viewProps: Record<string, any> = {}\n const style: any[] = []\n
|
|
5
|
-
"mappings": ";;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA;AACA;AAEA;AACA;AACA;AACA;AAMO,MAAM,iBAAiB,wBAC5B,OACA,cACA,OACA,4BACG;AACH,QAAM,kBAAkB,aAAa,SAAS,iBAAiB;AAC/D,QAAM,YAAiC;AACvC,QAAM,QAAe;
|
|
4
|
+
"sourcesContent": ["import {\n AllRules,\n stylePropsText,\n stylePropsTransform,\n validStyles,\n validStylesPseudo,\n} from '@tamagui/helpers'\nimport { ViewStyle } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { mediaQueryConfig } from '../hooks/useMedia'\nimport { StaticConfigParsed, ThemeObject } from '../types'\nimport { createMediaStyle } from './createMediaStyle'\nimport { fixNativeShadow } from './fixNativeShadow'\nimport { getStylesAtomic } from './getStylesAtomic'\nimport { insertStyleRule } from './insertStyleRule'\n\nexport type SplitStyles = ReturnType<typeof getSplitStyles>\n\n// TODO run over this, should be able to cut it down quite a bit\n\nexport const getSplitStyles = (\n props: { [key: string]: any },\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n isSplittingDefaultProps?: boolean\n) => {\n const validStyleProps = staticConfig.isText ? stylePropsText : validStyles\n const viewProps: Record<string, any> = {}\n const style: any[] = []\n\n let pseudos: { hoverStyle?: ViewStyle; pressStyle?: ViewStyle } | null = null\n let cur: ViewStyle | null = null\n let classNames: string[] | null = null\n\n for (const keyInit in props) {\n // be sure to sync next few lines below to getSubStyle (*1)\n const valInit = props[keyInit]\n\n // media\n if (keyInit[0] === '$') {\n const mediaKey = keyInit.slice(1)\n\n if (!mediaQueryConfig[mediaKey]) {\n // this isn't a media key, pass through\n viewProps[keyInit] = valInit\n continue\n }\n\n // dont check if media is active, we just apply *all* media styles\n // we combine the media props on top regular props, could proxy this\n // TODO test proxy here instead of merge\n const mediaProps = { ...props, ...valInit }\n // TODO media + hover\n const mediaStyle = getSubStyle(valInit, staticConfig, theme, props)\n const mediaStyles = getStylesAtomic(mediaStyle)\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n console.log('mediaStyles', keyInit, { mediaProps, mediaStyle, mediaStyles })\n }\n }\n for (const style of mediaStyles) {\n if (isWeb) {\n const out = createMediaStyle(style, mediaKey, mediaQueryConfig)\n classNames = classNames || []\n classNames.push(out.identifier)\n AllRules.add(out.styleRule)\n insertStyleRule(out.styleRule)\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log('mediaProp', style.identifier, out, mediaProps, mediaStyle, mediaStyles)\n }\n } else {\n console.log('TODO native media style logic')\n }\n }\n continue\n }\n\n // pseudo\n if (validStylesPseudo[keyInit]) {\n if (!valInit) continue\n pseudos = pseudos || {}\n pseudos[keyInit] = getSubStyle(valInit, staticConfig, theme, props)\n continue\n }\n\n const out = staticConfig.propMapper(keyInit, valInit, theme, props)\n\n const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out)\n\n for (const [key, val] of expanded) {\n // const val = valueMap(valInit) ?? valInit\n const keyFirstChar = key[0]\n if (key === 'style' || (keyFirstChar === '_' && key.startsWith('_style'))) {\n if (cur) {\n // process last\n fixNativeShadow(cur)\n style.push(cur)\n cur = null\n }\n fixNativeShadow(val)\n style.push(val)\n continue\n }\n // expand flex so it merged with flexShrink etc properly\n // TODO this shouldn't be here...\n if (key === 'flex') {\n cur = cur || {}\n // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex\n // TODO this fixed a behavior but need to find / document / test\n Object.assign(cur, {\n flexGrow: val,\n flexShrink: 1,\n })\n continue\n }\n if (!isWeb && key === 'pointerEvents') {\n viewProps[key] = val\n continue\n }\n if (validStyleProps[key]) {\n // transforms\n if (key in stylePropsTransform) {\n cur = cur || {}\n mergeTransform(cur, key, val)\n continue\n }\n cur = cur || {}\n cur[key] = val\n continue\n }\n\n // pass to view props\n if (!staticConfig.variants || !(key in staticConfig.variants)) {\n viewProps[key] = val\n }\n }\n }\n // push last style\n if (cur) {\n fixNativeShadow(cur)\n style.push(cur)\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n console.log(' \uD83E\uDD5A splitProps:', { props, viewProps, style })\n }\n }\n\n return {\n viewProps,\n style,\n pseudos,\n classNames,\n }\n}\n\nconst getSubStyle = (\n styleIn: Object,\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n props: any\n): ViewStyle => {\n const styleOut: ViewStyle = {}\n for (const key in styleIn) {\n // be sure to sync next few lines below to loop above (*1)\n const val = styleIn[key]\n const out = staticConfig.propMapper(key, val, theme, props)\n const expanded = out === true || !out ? [[key, val]] : Object.entries(out)\n for (const [skey, sval] of expanded) {\n // const sval = valueMap(valInit)\n if (skey in stylePropsTransform) {\n mergeTransform(styleOut, skey, sval)\n } else {\n styleOut[skey] = sval\n }\n }\n }\n fixNativeShadow(styleOut)\n return styleOut\n}\n\nconst mapTransformKeys = {\n x: 'translateX',\n y: 'translateY',\n}\n\nconst mergeTransform = (obj: ViewStyle, key: string, val: any) => {\n const transform: any[] = obj.transform\n ? Array.isArray(obj.transform)\n ? obj.transform\n : [obj.transform]\n : []\n transform.push({ [mapTransformKeys[key] || key]: val })\n obj.transform = transform\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA;AACA;AAEA;AACA;AACA;AACA;AAMO,MAAM,iBAAiB,wBAC5B,OACA,cACA,OACA,4BACG;AACH,QAAM,kBAAkB,aAAa,SAAS,iBAAi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BW;AAyBpB,MAAM,mBAAmB;AAAA,EACvB,GAAG;AAAA,EACH,GAAG;AAAA;AAGL,MAAM,iBAAiB,wBAAC,KAAgB,KAAa,QAAa;AAChE,QAAM,YAAmB,IAAI,YACzB,MAAM,QAAQ,IAAI,aAChB,IAAI,YACJ,CAAC,IAAI,aACP;AACJ,YAAU,KAAK,GAAG,iBAAiB,QAAQ,MAAM;AACjD,MAAI,YAAY;AAAA,GAPK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { isValidElement } from "react";
|
|
4
|
+
const isTamaguiComponent = /* @__PURE__ */ __name((child) => {
|
|
5
|
+
return isValidElement(child) && child.type["staticConfig"]?.parsed;
|
|
6
|
+
}, "isTamaguiComponent");
|
|
7
|
+
export {
|
|
8
|
+
isTamaguiComponent
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=isComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/isComponent.tsx"],
|
|
4
|
+
"sourcesContent": ["import { isValidElement } from 'react'\n\nexport const isTamaguiComponent = (child: any) => {\n return isValidElement(child) && child.type['staticConfig']?.parsed\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEO,MAAM,qBAAqB,wBAAC,UAAe;AAChD,SAAO,eAAe,UAAU,MAAM,KAAK,iBAAiB;AAAA,GAD5B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { isValidElement } from "react";
|
|
4
|
+
const isTamaguiComponent = /* @__PURE__ */ __name((child) => {
|
|
5
|
+
return isValidElement(child) && !!child.type["staticConfig"]?.parsed;
|
|
6
|
+
}, "isTamaguiComponent");
|
|
7
|
+
export {
|
|
8
|
+
isTamaguiComponent
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=isTamaguiComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/isTamaguiComponent.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { isValidElement } from 'react'\n\nexport const isTamaguiComponent = (child: any): child is React.ReactElement => {\n return isValidElement(child) && !!child.type['staticConfig']?.parsed\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEO,MAAM,qBAAqB,wBAAC,UAA4C;AAC7E,SAAO,eAAe,UAAU,CAAC,CAAC,MAAM,KAAK,iBAAiB;AAAA,GAD9B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { isValidElement } from "react";
|
|
4
|
+
const isTamaguiElement = /* @__PURE__ */ __name((child) => {
|
|
5
|
+
return isValidElement(child) && !!child.type["staticConfig"]?.parsed;
|
|
6
|
+
}, "isTamaguiElement");
|
|
7
|
+
export {
|
|
8
|
+
isTamaguiElement
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=isTamaguiElement.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/isTamaguiElement.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { isValidElement } from 'react'\n\nexport const isTamaguiElement = (child: any): child is React.ReactElement => {\n return isValidElement(child) && !!child.type['staticConfig']?.parsed\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEO,MAAM,mBAAmB,wBAAC,UAA4C;AAC3E,SAAO,eAAe,UAAU,CAAC,CAAC,MAAM,KAAK,iBAAiB;AAAA,GADhC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|