@tamagui/core 1.0.0-alpha.47 → 1.0.0-alpha.48
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/createComponent.js +3 -2
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/esm/createComponent.js +3 -2
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/jsx/createComponent.js +3 -2
- package/package.json +3 -3
- package/types/createComponent.d.ts +1 -1
- package/types/createComponent.d.ts.map +1 -1
|
@@ -117,6 +117,7 @@ function createComponent(configIn) {
|
|
|
117
117
|
let defaultsClassName = "";
|
|
118
118
|
let initialTheme;
|
|
119
119
|
const component = (0, import_react.forwardRef)((props, forwardedRef) => {
|
|
120
|
+
var _b;
|
|
120
121
|
const forceUpdate = (0, import_use_force_update.useForceUpdate)();
|
|
121
122
|
const features = (0, import_useFeatures.useFeatures)(props, { forceUpdate });
|
|
122
123
|
const theme = (0, import_useTheme.useTheme)();
|
|
@@ -273,7 +274,7 @@ function createComponent(configIn) {
|
|
|
273
274
|
const className = (0, import_helpers.concatClassName)(...classList);
|
|
274
275
|
if (process.env.NODE_ENV === "development") {
|
|
275
276
|
if (props["debug"]) {
|
|
276
|
-
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className });
|
|
277
|
+
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className: className.trim().split(" ") });
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
280
|
viewProps.className = className;
|
|
@@ -413,7 +414,7 @@ function createComponent(configIn) {
|
|
|
413
414
|
if (props["debug"]) {
|
|
414
415
|
viewProps["debug"] = true;
|
|
415
416
|
console.log("\u{1F95A} props in:", props);
|
|
416
|
-
console.log("\u{1F95A} props out:", viewProps);
|
|
417
|
+
console.log("\u{1F95A} props out:", viewProps, (_b = viewProps.className) == null ? void 0 : _b.split(" "));
|
|
417
418
|
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, configIn });
|
|
418
419
|
if (import_platform.isWeb)
|
|
419
420
|
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
@@ -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 { onConfiguredOnce } from './conf'\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\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 { useTheme } from './hooks/useTheme'\nimport {\n SpaceTokens,\n StaticComponent,\n StaticConfig,\n StaticConfigParsed,\n TamaguiInternalConfig,\n} from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\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\nconst defaultComponentState = {\n hover: false,\n press: false,\n pressIn: false,\n}\n\ntype ComponentState = typeof defaultComponentState\n\nfunction createShallowUpdate(setter: React.Dispatch<React.SetStateAction<ComponentState>>) {\n return (next: Partial<ComponentState>) => {\n setter((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}\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 defaultNativeStyle: StyleSheet.NamedStyles<{ base: {} }> | null = null\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 theme = useTheme()\n const [state, set_] = useState<ComponentState>(defaultComponentState)\n const set = createShallowUpdate(set_)\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, theme)\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 // 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 return () => {\n mouseUps.delete(unPress)\n internal.current!.isMounted = false\n }\n }, [])\n\n // element\n const isInternalComponent = !Component || typeof Component === 'string'\n // default to tag, fallback to component (when both strings)\n const element = isWeb ? (isInternalComponent ? tag || Component : Component) : 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 defaultNativeStyle ? defaultNativeStyle.base : null,\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-ignore we are optimizing using arguments\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\n if (staticConfig.isReactNativeWeb) {\n viewProps.dataSet = viewProps.dataSet || {}\n Object.assign(viewProps.dataSet, { __className: className })\n } else {\n // we already handle Text/View properly\n viewProps.className = className\n }\n\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 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 // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, configIn })\n // only on browser because node expands it huge\n if (isWeb) console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\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 // native, create a default StyleSheet\n // TODO handle next.pseudos\n const sheetStyles = {}\n for (const style of next.style) {\n Object.assign(sheetStyles, style)\n }\n defaultNativeStyle = StyleSheet.create({\n base: sheetStyles,\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, conf?: StaticConfig) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n ...conf,\n neverFlatten: true,\n defaultProps: {\n ...Component.defaultProps,\n ...conf?.defaultProps,\n },\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAgD;AAChD,8BAA+B;AAC/B,mBAUO;AACP,0BAAkD;AAElD,kBAAiC;AACjC,uBAAmC;AACnC,sBAAqC;AACrC,iBAAoB;AACpB,qCAA8D;AAC9D,gCAAsD;AACtD,4BAA+B;AAC/B,yBAA4B;AAC5B,0BAA6B;AAC7B,sBAAyB;AAQzB,iCAAoC;AAE7B,MAAM,WAAW,oBAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAAiB,WAAW,MAAM;AACzC,aAAS,QAAQ,CAAC,MAAM;AACxB,aAAS;AAAA;AAAA;AAMb,MAAM,wBAAwB;AAAA,EAC5B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA;AAKX,6BAA6B,QAA8D;AACzF,SAAO,CAAC,SAAkC;AACxC,WAAO,CAAC,SAAS;AACf,iBAAW,OAAO,MAAM;AACtB,YAAI,KAAK,SAAS,KAAK,MAAM;AAC3B,iBAAO,kCAAK,OAAS;AAAA;AAAA;AAGzB,aAAO;AAAA;AAAA;AAAA;AARJ;AAaF,yBACL,UACA;AACA,MAAI;AACJ,MAAI,YAAY,UAAU;AACxB,mBAAe;AAAA,SACV;AACL,mBAAe,iDAAkB;AAAA;AAGnC,QAAM,EAAE,WAAW,aAAa,QAAQ,aAAa;AACrD,QAAM,kBAAkB,eAAe;AAGvC,MAAI,eAAe;AACnB,MAAI;AAGJ,MAAI,qBAAkE;AACtE,MAAI,oBAAoB;AACxB,MAAI;AAIJ,QAAM,YAAY,
|
|
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 { onConfiguredOnce } from './conf'\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\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 { useTheme } from './hooks/useTheme'\nimport {\n SpaceTokens,\n StaticComponent,\n StaticConfig,\n StaticConfigParsed,\n TamaguiInternalConfig,\n} from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\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\nconst defaultComponentState = {\n hover: false,\n press: false,\n pressIn: false,\n}\n\ntype ComponentState = typeof defaultComponentState\n\nfunction createShallowUpdate(setter: React.Dispatch<React.SetStateAction<ComponentState>>) {\n return (next: Partial<ComponentState>) => {\n setter((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}\n\nexport function createComponent<ComponentPropTypes 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 defaultNativeStyle: StyleSheet.NamedStyles<{ base: {} }> | null = null\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, ComponentPropTypes>((props: any, forwardedRef) => {\n const forceUpdate = useForceUpdate()\n const features = useFeatures(props, { forceUpdate })\n const theme = useTheme()\n const [state, set_] = useState<ComponentState>(defaultComponentState)\n const set = createShallowUpdate(set_)\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, theme)\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 // 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 return () => {\n mouseUps.delete(unPress)\n internal.current!.isMounted = false\n }\n }, [])\n\n // element\n const isInternalComponent = !Component || typeof Component === 'string'\n // default to tag, fallback to component (when both strings)\n const element = isWeb ? (isInternalComponent ? tag || Component : Component) : 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 defaultNativeStyle ? defaultNativeStyle.base : null,\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-ignore we are optimizing using arguments\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: className.trim().split(' ') })\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\n if (staticConfig.isReactNativeWeb) {\n viewProps.dataSet = viewProps.dataSet || {}\n Object.assign(viewProps.dataSet, { __className: className })\n } else {\n // we already handle Text/View properly\n viewProps.className = className\n }\n\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 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, viewProps.className?.split(' '))\n // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, configIn })\n // only on browser because node expands it huge\n if (isWeb) console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\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 // native, create a default StyleSheet\n // TODO handle next.pseudos\n const sheetStyles = {}\n for (const style of next.style) {\n Object.assign(sheetStyles, style)\n }\n defaultNativeStyle = StyleSheet.create({\n base: sheetStyles,\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<ComponentPropTypes, void>\n\n // add extractable HoC\n res['extractable'] = (Component: any, conf?: StaticConfig) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n ...conf,\n neverFlatten: true,\n defaultProps: {\n ...Component.defaultProps,\n ...conf?.defaultProps,\n },\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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zB,MAAI,QAAQ,GAAG;AACb,WAAO;AAAA;AAET,QAAM,OAAc;AACpB,aAAW,CAAC,OAAO,UAAU,aAAa,WAAW;AACnD,QAAI,UAAU,QAAQ,UAAU,QAAW;AACzC;AAAA;AAGF,UAAM,MAAM,GAAG,gCAAQ,WAAU;AAEjC,SAAK,KAAK,mDAAC,uBAAD;AAAA,MAAU;AAAA,OAAW,WAAW,mDAAC,UAAD,MAAW,SAAoB;AAGzE,QAAI,qCAAQ,YAAR,mBAAkB,qBAAqB;AACzC;AAAA;AAGF,QAAI,UAAU,MAAM,GAAG;AACrB,UAAI,OAAO;AACT,aAAK,KACH,mDAAC,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,mDAAC,0BAAD;AAAA,EAAM,OAAO,MAAM;AAAA,GAAa,WAAlD;AACjB,MAAM,QAAQ,+BAAW,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
|
}
|
|
@@ -65,6 +65,7 @@ function createComponent(configIn) {
|
|
|
65
65
|
let defaultsClassName = "";
|
|
66
66
|
let initialTheme;
|
|
67
67
|
const component = forwardRef((props, forwardedRef) => {
|
|
68
|
+
var _a;
|
|
68
69
|
const forceUpdate = useForceUpdate();
|
|
69
70
|
const features = useFeatures(props, { forceUpdate });
|
|
70
71
|
const theme = useTheme();
|
|
@@ -186,7 +187,7 @@ function createComponent(configIn) {
|
|
|
186
187
|
const className = concatClassName(...classList);
|
|
187
188
|
if (process.env.NODE_ENV === "development") {
|
|
188
189
|
if (props["debug"]) {
|
|
189
|
-
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className });
|
|
190
|
+
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className: className.trim().split(" ") });
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
viewProps.className = className;
|
|
@@ -328,7 +329,7 @@ function createComponent(configIn) {
|
|
|
328
329
|
if (props["debug"]) {
|
|
329
330
|
viewProps["debug"] = true;
|
|
330
331
|
console.log("\u{1F95A} props in:", props);
|
|
331
|
-
console.log("\u{1F95A} props out:", viewProps);
|
|
332
|
+
console.log("\u{1F95A} props out:", viewProps, (_a = viewProps.className) == null ? void 0 : _a.split(" "));
|
|
332
333
|
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, configIn });
|
|
333
334
|
if (isWeb)
|
|
334
335
|
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
@@ -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 { onConfiguredOnce } from './conf'\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\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 { useTheme } from './hooks/useTheme'\nimport {\n SpaceTokens,\n StaticComponent,\n StaticConfig,\n StaticConfigParsed,\n TamaguiInternalConfig,\n} from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\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\nconst defaultComponentState = {\n hover: false,\n press: false,\n pressIn: false,\n}\n\ntype ComponentState = typeof defaultComponentState\n\nfunction createShallowUpdate(setter: React.Dispatch<React.SetStateAction<ComponentState>>) {\n return (next: Partial<ComponentState>) => {\n setter((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}\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 defaultNativeStyle: StyleSheet.NamedStyles<{ base: {} }> | null = null\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 theme = useTheme()\n const [state, set_] = useState<ComponentState>(defaultComponentState)\n const set = createShallowUpdate(set_)\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, theme)\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 // 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 return () => {\n mouseUps.delete(unPress)\n internal.current!.isMounted = false\n }\n }, [])\n\n // element\n const isInternalComponent = !Component || typeof Component === 'string'\n // default to tag, fallback to component (when both strings)\n const element = isWeb ? (isInternalComponent ? tag || Component : Component) : 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 defaultNativeStyle ? defaultNativeStyle.base : null,\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-ignore we are optimizing using arguments\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\n if (staticConfig.isReactNativeWeb) {\n viewProps.dataSet = viewProps.dataSet || {}\n Object.assign(viewProps.dataSet, { __className: className })\n } else {\n // we already handle Text/View properly\n viewProps.className = className\n }\n\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 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 // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, configIn })\n // only on browser because node expands it huge\n if (isWeb) console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\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 // native, create a default StyleSheet\n // TODO handle next.pseudos\n const sheetStyles = {}\n for (const style of next.style) {\n Object.assign(sheetStyles, style)\n }\n defaultNativeStyle = StyleSheet.create({\n base: sheetStyles,\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, conf?: StaticConfig) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n ...conf,\n neverFlatten: true,\n defaultProps: {\n ...Component.defaultProps,\n ...conf?.defaultProps,\n },\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;AACA;AAQA;AAEO,MAAM,WAAW,oBAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAAiB,WAAW,MAAM;AACzC,aAAS,QAAQ,CAAC,MAAM;AACxB,aAAS;AAAA;AAAA;AAMb,MAAM,wBAAwB;AAAA,EAC5B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA;AAKX,6BAA6B,QAA8D;AACzF,SAAO,CAAC,SAAkC;AACxC,WAAO,CAAC,SAAS;AACf,iBAAW,OAAO,MAAM;AACtB,YAAI,KAAK,SAAS,KAAK,MAAM;AAC3B,iBAAO,KAAK,SAAS;AAAA;AAAA;AAGzB,aAAO;AAAA;AAAA;AAAA;AARJ;AAaF,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,oCAAe;AAGvC,MAAI,eAAe;AACnB,MAAI;AAGJ,MAAI,qBAAkE;AACtE,MAAI,oBAAoB;AACxB,MAAI;AAIJ,QAAM,YAAY,
|
|
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 { onConfiguredOnce } from './conf'\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\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 { useTheme } from './hooks/useTheme'\nimport {\n SpaceTokens,\n StaticComponent,\n StaticConfig,\n StaticConfigParsed,\n TamaguiInternalConfig,\n} from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\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\nconst defaultComponentState = {\n hover: false,\n press: false,\n pressIn: false,\n}\n\ntype ComponentState = typeof defaultComponentState\n\nfunction createShallowUpdate(setter: React.Dispatch<React.SetStateAction<ComponentState>>) {\n return (next: Partial<ComponentState>) => {\n setter((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}\n\nexport function createComponent<ComponentPropTypes 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 defaultNativeStyle: StyleSheet.NamedStyles<{ base: {} }> | null = null\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, ComponentPropTypes>((props: any, forwardedRef) => {\n const forceUpdate = useForceUpdate()\n const features = useFeatures(props, { forceUpdate })\n const theme = useTheme()\n const [state, set_] = useState<ComponentState>(defaultComponentState)\n const set = createShallowUpdate(set_)\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, theme)\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 // 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 return () => {\n mouseUps.delete(unPress)\n internal.current!.isMounted = false\n }\n }, [])\n\n // element\n const isInternalComponent = !Component || typeof Component === 'string'\n // default to tag, fallback to component (when both strings)\n const element = isWeb ? (isInternalComponent ? tag || Component : Component) : 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 defaultNativeStyle ? defaultNativeStyle.base : null,\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-ignore we are optimizing using arguments\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: className.trim().split(' ') })\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\n if (staticConfig.isReactNativeWeb) {\n viewProps.dataSet = viewProps.dataSet || {}\n Object.assign(viewProps.dataSet, { __className: className })\n } else {\n // we already handle Text/View properly\n viewProps.className = className\n }\n\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 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, viewProps.className?.split(' '))\n // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, configIn })\n // only on browser because node expands it huge\n if (isWeb) console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\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 // native, create a default StyleSheet\n // TODO handle next.pseudos\n const sheetStyles = {}\n for (const style of next.style) {\n Object.assign(sheetStyles, style)\n }\n defaultNativeStyle = StyleSheet.create({\n base: sheetStyles,\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<ComponentPropTypes, void>\n\n // add extractable HoC\n res['extractable'] = (Component: any, conf?: StaticConfig) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n ...conf,\n neverFlatten: true,\n defaultProps: {\n ...Component.defaultProps,\n ...conf?.defaultProps,\n },\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;AACA;AAQA;AAEO,MAAM,WAAW,oBAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAAiB,WAAW,MAAM;AACzC,aAAS,QAAQ,CAAC,MAAM;AACxB,aAAS;AAAA;AAAA;AAMb,MAAM,wBAAwB;AAAA,EAC5B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA;AAKX,6BAA6B,QAA8D;AACzF,SAAO,CAAC,SAAkC;AACxC,WAAO,CAAC,SAAS;AACf,iBAAW,OAAO,MAAM;AACtB,YAAI,KAAK,SAAS,KAAK,MAAM;AAC3B,iBAAO,KAAK,SAAS;AAAA;AAAA;AAGzB,aAAO;AAAA;AAAA;AAAA;AARJ;AAaF,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,oCAAe;AAGvC,MAAI,eAAe;AACnB,MAAI;AAGJ,MAAI,qBAAkE;AACtE,MAAI,oBAAoB;AACxB,MAAI;AAIJ,QAAM,YAAY,WAAqC,CAAC,OAAY,iBAAiB;AA1FvF;A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BAAkB,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
|
}
|
|
@@ -65,6 +65,7 @@ function createComponent(configIn) {
|
|
|
65
65
|
let defaultsClassName = "";
|
|
66
66
|
let initialTheme;
|
|
67
67
|
const component = forwardRef((props, forwardedRef) => {
|
|
68
|
+
var _a;
|
|
68
69
|
const forceUpdate = useForceUpdate();
|
|
69
70
|
const features = useFeatures(props, { forceUpdate });
|
|
70
71
|
const theme = useTheme();
|
|
@@ -186,7 +187,7 @@ function createComponent(configIn) {
|
|
|
186
187
|
const className = concatClassName(...classList);
|
|
187
188
|
if (process.env.NODE_ENV === "development") {
|
|
188
189
|
if (props["debug"]) {
|
|
189
|
-
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className });
|
|
190
|
+
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className: className.trim().split(" ") });
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
viewProps.className = className;
|
|
@@ -328,7 +329,7 @@ function createComponent(configIn) {
|
|
|
328
329
|
if (props["debug"]) {
|
|
329
330
|
viewProps["debug"] = true;
|
|
330
331
|
console.log("\u{1F95A} props in:", props);
|
|
331
|
-
console.log("\u{1F95A} props out:", viewProps);
|
|
332
|
+
console.log("\u{1F95A} props out:", viewProps, (_a = viewProps.className) == null ? void 0 : _a.split(" "));
|
|
332
333
|
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, configIn });
|
|
333
334
|
if (isWeb)
|
|
334
335
|
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.48",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@tamagui/helpers": "^1.0.0-alpha.
|
|
17
|
+
"@tamagui/helpers": "^1.0.0-alpha.48",
|
|
18
18
|
"@tamagui/ow": "^0.28.1",
|
|
19
19
|
"@tamagui/use-debounce": "^1.0.0-alpha.44",
|
|
20
20
|
"@tamagui/use-force-update": "^1.0.0-alpha.44",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "702845c2953bfbe7e24ea544f9add62f62e78ac4"
|
|
38
38
|
}
|
|
@@ -2,7 +2,7 @@ import { ViewStyle } from 'react-native';
|
|
|
2
2
|
import { StaticComponent, StaticConfig, StaticConfigParsed } from './types';
|
|
3
3
|
export declare const mouseUps: Set<Function>;
|
|
4
4
|
declare type DefaultProps = {};
|
|
5
|
-
export declare function createComponent<
|
|
5
|
+
export declare function createComponent<ComponentPropTypes extends Object = DefaultProps>(configIn: Partial<StaticConfig> | StaticConfigParsed): StaticComponent<ComponentPropTypes, void, StaticConfigParsed, any>;
|
|
6
6
|
export declare const Spacer: StaticComponent<{
|
|
7
7
|
size?: number | `$${string}` | `$${number}` | undefined;
|
|
8
8
|
flex?: number | boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAA;AAYhE,OAAO,EAEL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAEnB,MAAM,SAAS,CAAA;AAGhB,eAAO,MAAM,QAAQ,eAAsB,CAAA;AAS3C,aAAK,YAAY,GAAG,EAAE,CAAA;AAuBtB,wBAAgB,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAA;AAYhE,OAAO,EAEL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAEnB,MAAM,SAAS,CAAA;AAGhB,eAAO,MAAM,QAAQ,eAAsB,CAAA;AAS3C,aAAK,YAAY,GAAG,EAAE,CAAA;AAuBtB,wBAAgB,eAAe,CAAC,kBAAkB,SAAS,MAAM,GAAG,YAAY,EAC9E,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,sEAscrD;AAOD,eAAO,MAAM,MAAM;;;iCAyBjB,CAAA;AAEF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,aAAa,GACd,EAAE;IACD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,GAAG,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,aAAa,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,CAAA;CAC3C,OAwCA"}
|