@tamagui/core 1.0.0-beta.189 → 1.0.0-beta.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Tamagui.js +5 -0
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/constants/pseudos.js +37 -0
- package/dist/cjs/constants/pseudos.js.map +7 -0
- package/dist/cjs/createComponent.js +66 -88
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createShallowUpdate.js +1 -0
- package/dist/cjs/createShallowUpdate.js.map +7 -0
- package/dist/cjs/defaultComponentState.js +0 -30
- package/dist/cjs/defaultComponentState.js.map +3 -3
- package/dist/cjs/devtools.js +32 -0
- package/dist/cjs/devtools.js.map +7 -0
- package/dist/cjs/helpers/RNComponents.js +34 -0
- package/dist/cjs/helpers/RNComponents.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +2 -0
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +25 -26
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +51 -0
- package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
- package/dist/cjs/helpers/createTamaguiProvider.js +1 -5
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +25 -14
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +1 -0
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +11 -6
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/hooks/useFeatures.js +93 -7
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +13 -14
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/styled.js +2 -12
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/tamagui-base.css +8 -0
- package/dist/cjs/tamagui-base.css.map +7 -0
- package/dist/cjs/types-rnw.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Stack.js +1 -0
- package/dist/cjs/views/Stack.js.map +2 -2
- package/dist/cjs/views/Text.js +1 -0
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/Theme.js +4 -1
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/esm/Tamagui.js +2 -0
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/constants/pseudos.js +18 -0
- package/dist/esm/constants/pseudos.js.map +7 -0
- package/dist/esm/createComponent.js +66 -91
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createShallowUpdate.js +1 -0
- package/dist/esm/createShallowUpdate.js.map +7 -0
- package/dist/esm/defaultComponentState.js +0 -11
- package/dist/esm/defaultComponentState.js.map +3 -3
- package/dist/esm/devtools.js +14 -0
- package/dist/esm/devtools.js.map +7 -0
- package/dist/esm/helpers/RNComponents.js +12 -0
- package/dist/esm/helpers/RNComponents.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +2 -0
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +25 -26
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createShallowUpdate.js +19 -0
- package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
- package/dist/esm/helpers/createTamaguiProvider.js +1 -4
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +25 -14
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +1 -0
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +11 -6
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/hooks/useFeatures.js +93 -12
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +13 -14
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/styled.js +1 -8
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/tamagui-base.css +8 -0
- package/dist/esm/tamagui-base.css.map +7 -0
- package/dist/esm/views/Stack.js +1 -0
- package/dist/esm/views/Stack.js.map +2 -2
- package/dist/esm/views/Text.js +1 -0
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +4 -1
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/jsx/Tamagui.js +2 -0
- package/dist/jsx/constants/pseudos.js +17 -0
- package/dist/jsx/createComponent.js +62 -88
- package/dist/jsx/createShallowUpdate.js +0 -0
- package/dist/jsx/defaultComponentState.js +0 -11
- package/dist/jsx/devtools.js +13 -0
- package/dist/jsx/helpers/RNComponents.js +11 -0
- package/dist/jsx/helpers/createMediaStyle.js +2 -0
- package/dist/jsx/helpers/createPropMapper.js +25 -26
- package/dist/jsx/helpers/createShallowUpdate.js +18 -0
- package/dist/jsx/helpers/createTamaguiProvider.js +1 -2
- package/dist/jsx/helpers/getSplitStyles.js +25 -14
- package/dist/jsx/helpers/getStylesAtomic.js +1 -0
- package/dist/jsx/helpers/insertStyleRule.js +11 -6
- package/dist/jsx/hooks/useFeatures.js +93 -12
- package/dist/jsx/hooks/useTheme.js +13 -14
- package/dist/jsx/styled.js +1 -8
- package/dist/jsx/tamagui-base.css +7 -0
- package/dist/jsx/views/Stack.js +1 -0
- package/dist/jsx/views/Text.js +1 -0
- package/dist/jsx/views/Theme.js +4 -1
- package/package.json +6 -6
- package/types/Tamagui.d.ts +2 -0
- package/types/Tamagui.d.ts.map +1 -1
- package/types/createComponent.d.ts +5 -6
- package/types/createComponent.d.ts.map +1 -1
- package/types/createFont.d.ts +1 -1
- package/types/createFont.d.ts.map +1 -1
- package/types/defaultComponentState.d.ts +0 -12
- package/types/defaultComponentState.d.ts.map +1 -1
- package/types/helpers/RNComponents.d.ts +2 -0
- package/types/helpers/RNComponents.d.ts.map +1 -0
- package/types/helpers/createMediaStyle.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +2 -2
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/createShallowUpdate.d.ts +4 -0
- package/types/helpers/createShallowUpdate.d.ts.map +1 -0
- package/types/helpers/createTamaguiProvider.d.ts +1 -1
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +3 -14
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/hooks/useFeatures.d.ts +7 -5
- package/types/hooks/useFeatures.d.ts.map +1 -1
- package/types/styled.d.ts +3 -7
- package/types/styled.d.ts.map +1 -1
- package/types/types-rnw.d.ts +0 -5
- package/types/types-rnw.d.ts.map +1 -1
- package/types/types.d.ts +82 -69
- package/types/types.d.ts.map +1 -1
- package/types/views/Stack.d.ts +2 -2
- package/types/views/Stack.d.ts.map +1 -1
- package/types/views/Text.d.ts +2 -2
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: any,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__'
|
|
5
|
-
"mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAQO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAQ,cAAa,WAAW;AAClC,cAAQ,IAAI,mBAAgB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC3E;AAAA,EACF;AAEA,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,6CAAc,KAAK,IAAI,GAAG;AACtC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,GAAG,GAAG;AACvC,mDAAc,MAAM,GAAG,MAAM,GAAG;AAAA,IAClC;AAAA,EACF,CAAC;AAED,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,OAAO;AACV,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAQ,KAAK,YAAY,EAAE,WAAW,OAAO,eAAe,UAAU,CAAC;AAAA,MACzE;AACA,aAAO,OAAO,UAAU,EAAE,gBAAgB;AAAA,IAC5C;AACA,WAAO,IAAI,MAAM,OAAO;AAAA,MACtB,IAAI,GAAG,KAAK;AACV,YAAI,OAAO,QAAQ,UAAU;AAC3B,cAAI,IAAI,OAAO,KAAK;AAClB,kBAAM,IAAI,MAAM,CAAC;AAAA,UACnB;AAAA,QACF;AACA,eAAO,QAAQ,IAAI,OAAO,GAAG;AAAA,MAC/B;AAAA,MACA,IAAI,GAAG,KAAK;AACV,YAAI,CAAC,QAAQ,QAAQ,
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: any,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (!didChangeTheme) {\n return null\n }\n // TODO\n // console.log('DID CHANGE THEME')\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (process.env.NODE_ENV === 'development') {\n if (key === '__state') {\n return state.current\n }\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n if (typeof key === 'string') {\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n // react native debuger uses toJSON\n if (process.env.NODE_ENV === 'development') {\n console.log(`No theme value \"${String(key)}\" in ${name}`)\n }\n }\n return Reflect.get(_, key)\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: any,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const next = parentManager.getNextTheme({ name, componentName, themes }, props)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) {\n return null\n }\n return new ThemeManager(next.name, next.theme, parentManager)\n })\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme({ name, componentName, themes }, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAQO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAA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AS,cAAc;AAE5E,SAAO;AAAA,OACD,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,OACG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/styled.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as ReactNative from "react-native";
|
|
4
3
|
import { Image, Text, TextInput } from "react-native";
|
|
5
4
|
import { createComponent } from "./createComponent";
|
|
6
5
|
import { extendStaticConfig } from "./helpers/extendStaticConfig";
|
|
7
|
-
|
|
8
|
-
for (const key of ["Image", "TextInput", "Text", "View"]) {
|
|
9
|
-
const val = ReactNative[key];
|
|
10
|
-
if (val && typeof val === "object") {
|
|
11
|
-
RNComponents.set(val, true);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
6
|
+
import { RNComponents } from "./helpers/RNComponents";
|
|
14
7
|
function styled(Component, options, staticExtractionOptions) {
|
|
15
8
|
const staticConfigProps = (() => {
|
|
16
9
|
if (options) {
|
package/dist/esm/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;AAAA;
|
|
4
|
+
"sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { extendStaticConfig } from './helpers/extendStaticConfig'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n} from './types'\n\nexport function styled<\n ParentComponent extends StylableComponent,\n // = VariantDefinitions<GetProps<ParentComponent>> gives type inference to variants: { true: { ... } }\n // but causes \"Type instantiation is excessively deep and possibly infinite.\"...\n Variants extends VariantDefinitions<ParentComponent> | symbol =\n | VariantDefinitions<ParentComponent>\n | symbol\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n defaultVariants?: Variants extends Object ? GetVariantProps<Variants> : never\n },\n staticExtractionOptions?: StaticConfig\n) {\n const staticConfigProps = (() => {\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNativeWeb = RNComponents.has(Component)\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = Component as any\n const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false))\n const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false))\n const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false))\n const conf: StaticConfig = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n componentName: name,\n isReactNativeWeb,\n isInput,\n isText,\n isImage,\n }\n return conf\n }\n return {}\n })()\n const config = extendStaticConfig(Component, staticConfigProps)\n const component = createComponent(config!) // error is good here its on init\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V>\n ? V\n : Object\n\n // sprinkle in our variants\n type OurVariants = Variants extends symbol\n ? {}\n : {\n [Key in keyof Variants]?: GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void | symbol\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// test types:\n\n// export const SizableText = styled(Stack, {\n// name: 'SizableText',\n// backgroundColor: 'red',\n// variants: {\n// size: {\n// '...fontSize': (val, { props }) => {\n// return {\n// backgroundColor: '',\n// }\n// },\n// },\n// },\n// })\n// export const Heading = styled(SizableText, {\n// tag: 'span',\n// name: 'Heading',\n// accessibilityRole: 'header',\n// size: '$8',\n// margin: 0,\n// })\n// export const Paragraph = styled(SizableText, {\n// tag: 'p',\n// margin: 10,\n// variants: {\n// another: {\n// true: {},\n// },\n// },\n// })\n// export const Paragraph2 = styled(Paragraph, {\n// tag: 'p',\n// variants: {\n// another: {\n// '...color': (val) => ({\n// backgroundColor: 'red',\n// }),\n// },\n// },\n// })\n// const a = <SizableText size=\"$10\" />\n// const b = <Paragraph size=\"$10\" another />\n// const c = <Paragraph2 size=\"$10\" another=\"aliceblue\" />\n// export const SizableText2 = styled(SizableText, {\n// })\n// const xx = <SizableText2 abc />\n// export const Paragraph = styled(SizableText, {\n// name: 'Paragraph',\n// })\n// export const Heading = styled(Paragraph, {\n// tag: 'span',\n// margin: 0,\n// })\n// export const H2 = styled(Heading, {\n// name: 'H2',\n// })\n// const x = <H2 color=\"red\" />\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AAaO,gBAQL,WAEA,SAKA,yBACA;AACA,QAAM,oBAAqB,OAAM;AAC/B,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBAAmB,aAAa,IAAI,SAAS;AACnD,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO;AACb,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,QAAQ;AAC1E,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,YAAY;AAC9E,YAAM,SAAS,CAAC,CAAE,cAAa,UAAW,EAAC,YAAY,WAAW,SAAS,OAAO;AAClF,YAAM,OAAqB;AAAA,WACtB;AAAA,WACC,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AACH,QAAM,SAAS,mBAAmB,WAAW,iBAAiB;AAC9D,QAAM,YAAY,gBAAgB,MAAO;AA6BzC,SAAO;AAOT;AAtFgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Stack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Stack.tsx"],
|
|
4
|
-
"sourcesContent": ["import { View } from 'react-native'\n\nimport { stackDefaultStyles } from '../constants/constants'\nimport { createComponent } from '../createComponent'\nimport { StackProps } from '../types'\n\nexport const Stack = createComponent<StackProps, View>({\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n },\n})\n\n// test types\n// export const YStack = styled(Stack, {\n// flexDirection: 'column',\n// })\n// // test types\n// const x00 = <Stack missing={0} /> // should err\n// const x0 = <YStack missing={0} /> // should err\n// const x1 = (props: StackProps) => <YStack {...props} />\n// type ys = typeof YStack\n// type ysv = ys extends StaticComponent<any, infer V> ? V : unknown\n"],
|
|
5
|
-
"mappings": "AAEA;AACA;AAGO,MAAM,QAAQ,
|
|
4
|
+
"sourcesContent": ["import { View } from 'react-native'\n\nimport { stackDefaultStyles } from '../constants/constants'\nimport { createComponent } from '../createComponent'\nimport { StackProps, StackPropsBase } from '../types'\n\nexport const Stack = createComponent<StackProps, View, StackPropsBase>({\n componentName: 'Stack',\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n },\n})\n\n// test types\n// export const YStack = styled(Stack, {\n// flexDirection: 'column',\n// })\n// // test types\n// const x00 = <Stack missing={0} /> // should err\n// const x0 = <YStack missing={0} /> // should err\n// const x1 = (props: StackProps) => <YStack {...props} />\n// type ys = typeof YStack\n// type ysv = ys extends StaticComponent<any, infer V> ? V : unknown\n"],
|
|
5
|
+
"mappings": "AAEA;AACA;AAGO,MAAM,QAAQ,gBAAkD;AAAA,EACrE,eAAe;AAAA,EACf,cAAc;AAAA,OACT;AAAA,IACH,eAAe;AAAA,EACjB;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Text.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Text.tsx"],
|
|
4
|
-
"sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView>({\n isText: true,\n defaultProps: {\n display: isWeb ? 'inline' : 'flex',\n boxSizing: 'border-box',\n fontFamily: 'System',\n wordWrap: 'break-word',\n },\n variants: {\n numberOfLines: {\n 1: ellipseStyle,\n // TODO imply fn, test 1, could do types `>1` `<2`\n ':number': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n ...(isWeb && {\n userSelect: true,\n textOverflow: true,\n whiteSpace: true,\n wordWrap: true,\n selectable: true,\n cursor: true,\n }),\n },\n})\n"],
|
|
5
|
-
"mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,
|
|
4
|
+
"sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n componentName: 'Text',\n isText: true,\n defaultProps: {\n display: isWeb ? 'inline' : 'flex',\n boxSizing: 'border-box',\n fontFamily: 'System',\n wordWrap: 'break-word',\n },\n variants: {\n numberOfLines: {\n 1: ellipseStyle,\n // TODO imply fn, test 1, could do types `>1` `<2`\n ':number': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n ...(isWeb && {\n userSelect: true,\n textOverflow: true,\n whiteSpace: true,\n wordWrap: true,\n selectable: true,\n cursor: true,\n }),\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAoD;AAAA,EACtE,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,cAAc;AAAA,IACZ,SAAS,QAAQ,WAAW;AAAA,IAC5B,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,UAAU;AAAA,IACR,eAAe;AAAA,MACb,GAAG;AAAA,MAEH,WAAW,CAAC,UAAW,QAAQ,IAAI,EAAE,iBAAiB,EAAE,IAAI;AAAA,IAC9D;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACT,MAAM;AAAA,QACJ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACP,MAAM,QACF,eACA;AAAA,QACE,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACN;AAAA,EACF;AAAA,EACA,YAAY,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AAAA,EAC5C,aAAa;AAAA,OACR;AAAA,OACA;AAAA,OACC,SAAS;AAAA,MACX,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,IACV;AAAA,EACF;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Theme.js
CHANGED
|
@@ -17,7 +17,10 @@ const Theme = memo(/* @__PURE__ */ __name(function Theme2(props) {
|
|
|
17
17
|
const contents = useMemo(() => wrapThemeManagerContext(props.children, themeManager), [props.children, themeManager]);
|
|
18
18
|
if (isWeb) {
|
|
19
19
|
return /* @__PURE__ */ React.createElement("div", {
|
|
20
|
-
className:
|
|
20
|
+
className: [
|
|
21
|
+
`tui_Theme`,
|
|
22
|
+
...!props.disableThemeClass ? [props.className, className].filter(Boolean) : []
|
|
23
|
+
].join(" "),
|
|
21
24
|
style: {
|
|
22
25
|
display: "contents",
|
|
23
26
|
color: (_b = (_a = themes[name]) == null ? void 0 : _a.color) == null ? void 0 : _b.toString()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../static'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n undefined,\n props\n )\n\n if (!themes || !name || !theme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => wrapThemeManagerContext(props.children, themeManager),\n [props.children, themeManager]\n )\n\n if (isWeb) {\n return (\n <div\n className={\n props.disableThemeClass
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAUC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAlB5D;AAmBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,QACA,KACF;AAEA,MAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;AAC9B,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAIA,QAAM,WAAW,QACf,MAAM,wBAAwB,MAAM,UAAU,YAAY,GAC1D,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,OAAO;AACT,WACE,oCAAC;AAAA,MACC,
|
|
4
|
+
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../static'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n undefined,\n props\n )\n\n if (!themes || !name || !theme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => wrapThemeManagerContext(props.children, themeManager),\n [props.children, themeManager]\n )\n\n if (isWeb) {\n return (\n <div\n className={[\n `tui_Theme`,\n ...(!props.disableThemeClass ? [props.className, className].filter(Boolean) : []),\n ].join(' ')}\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </div>\n )\n }\n\n return contents\n})\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAUC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAlB5D;AAmBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,QACA,KACF;AAEA,MAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;AAC9B,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAIA,QAAM,WAAW,QACf,MAAM,wBAAwB,MAAM,UAAU,YAAY,GAC1D,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,OAAO;AACT,WACE,oCAAC;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,GAAI,CAAC,MAAM,oBAAoB,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,MACjF,EAAE,KAAK,GAAG;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,GAxC0B,QAwCzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Tamagui.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import * as Helpers from "@tamagui/helpers";
|
|
3
4
|
import { rnw } from "./constants/rnw";
|
|
4
5
|
import { getAllSelectors, getAllTransforms } from "./helpers/insertStyleRule";
|
|
5
6
|
class TamaguiManager {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.config = null;
|
|
8
9
|
this.rnw = rnw;
|
|
10
|
+
this.Helpers = Helpers;
|
|
9
11
|
}
|
|
10
12
|
get allSelectors() {
|
|
11
13
|
return getAllSelectors();
|
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { stylePropsView } from "@tamagui/helpers";
|
|
4
4
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
5
|
-
import {
|
|
5
|
+
import React, {
|
|
6
6
|
Children,
|
|
7
7
|
Fragment,
|
|
8
8
|
createElement,
|
|
@@ -10,26 +10,33 @@ import {
|
|
|
10
10
|
memo,
|
|
11
11
|
useCallback,
|
|
12
12
|
useContext,
|
|
13
|
-
useEffect,
|
|
14
13
|
useRef,
|
|
15
14
|
useState
|
|
16
15
|
} from "react";
|
|
17
16
|
import { StyleSheet, Text, View } from "react-native";
|
|
18
17
|
import { onConfiguredOnce } from "./conf";
|
|
19
18
|
import { stackDefaultStyles } from "./constants/constants";
|
|
20
|
-
import { isAndroid, isTouchDevice, isWeb } from "./constants/platform";
|
|
19
|
+
import { isAndroid, isTouchDevice, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
|
|
21
20
|
import { rnw } from "./constants/rnw";
|
|
22
21
|
import { isVariable } from "./createVariable";
|
|
23
|
-
import {
|
|
22
|
+
import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
24
23
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
} from "./helpers/getSplitStyles";
|
|
24
|
+
import { getSplitStyles } from "./helpers/getSplitStyles";
|
|
25
|
+
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
28
26
|
import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
|
|
29
27
|
import { useFeatures } from "./hooks/useFeatures";
|
|
30
28
|
import { usePressable } from "./hooks/usePressable";
|
|
31
29
|
import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
|
|
32
30
|
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
31
|
+
React["keep"];
|
|
32
|
+
const defaultComponentState = {
|
|
33
|
+
hover: false,
|
|
34
|
+
press: false,
|
|
35
|
+
pressIn: false,
|
|
36
|
+
focus: false,
|
|
37
|
+
mounted: false,
|
|
38
|
+
animation: null
|
|
39
|
+
};
|
|
33
40
|
const mouseUps = /* @__PURE__ */ new Set();
|
|
34
41
|
if (typeof document !== "undefined") {
|
|
35
42
|
document.addEventListener("mouseup", () => {
|
|
@@ -37,19 +44,6 @@ if (typeof document !== "undefined") {
|
|
|
37
44
|
mouseUps.clear();
|
|
38
45
|
});
|
|
39
46
|
}
|
|
40
|
-
function createShallowUpdate(setter) {
|
|
41
|
-
return (next) => {
|
|
42
|
-
setter((prev) => {
|
|
43
|
-
for (const key in next) {
|
|
44
|
-
if (prev[key] !== next[key]) {
|
|
45
|
-
return { ...prev, ...next };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return prev;
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
__name(createShallowUpdate, "createShallowUpdate");
|
|
53
47
|
function createComponent(configIn) {
|
|
54
48
|
let staticConfig;
|
|
55
49
|
if ("parsed" in configIn) {
|
|
@@ -63,13 +57,13 @@ function createComponent(configIn) {
|
|
|
63
57
|
let tamaguiConfig;
|
|
64
58
|
let AnimatedText;
|
|
65
59
|
let AnimatedView;
|
|
66
|
-
let avoidClasses =
|
|
60
|
+
let avoidClasses = true;
|
|
67
61
|
let defaultPseudos = {};
|
|
68
62
|
let defaultNativeStyle;
|
|
69
63
|
let defaultNativeStyleSheet = null;
|
|
70
64
|
let defaultsClassName = null;
|
|
71
65
|
let initialTheme;
|
|
72
|
-
let
|
|
66
|
+
let defaultSplitStyleResult = null;
|
|
73
67
|
function addPseudoToStyles(styles, name, pseudos) {
|
|
74
68
|
const pseudoStyle = pseudos[name];
|
|
75
69
|
if (pseudoStyle) {
|
|
@@ -85,7 +79,8 @@ function createComponent(configIn) {
|
|
|
85
79
|
var _a, _b, _c, _d;
|
|
86
80
|
if (process.env.NODE_ENV === "development") {
|
|
87
81
|
if (props["debug"]) {
|
|
88
|
-
console.warn(componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "
|
|
82
|
+
console.warn(componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
|
|
83
|
+
console.log("props in:", props);
|
|
89
84
|
if (props["debug"] === "break")
|
|
90
85
|
debugger;
|
|
91
86
|
}
|
|
@@ -94,19 +89,22 @@ function createComponent(configIn) {
|
|
|
94
89
|
const theme = useTheme(props.theme, componentName, props, forceUpdate);
|
|
95
90
|
const [state, set_] = useState(defaultComponentState);
|
|
96
91
|
const setStateShallow = createShallowUpdate(set_);
|
|
97
|
-
const shouldAvoidClasses = !!(
|
|
98
|
-
const
|
|
99
|
-
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } =
|
|
92
|
+
const shouldAvoidClasses = !!(props.animation && avoidClasses);
|
|
93
|
+
const splitStyles = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : defaultsClassName);
|
|
94
|
+
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
100
95
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
101
96
|
const isAnimated = !!(useAnimations && props.animation);
|
|
102
|
-
const
|
|
97
|
+
const hasEnterStyle = !!props.enterStyle;
|
|
103
98
|
const features = useFeatures(props, {
|
|
104
99
|
forceUpdate,
|
|
105
100
|
setStateShallow,
|
|
106
101
|
useAnimations,
|
|
107
102
|
state,
|
|
108
|
-
style:
|
|
109
|
-
pseudos
|
|
103
|
+
style: props.animation ? { ...defaultNativeStyle, ...style } : null,
|
|
104
|
+
pseudos,
|
|
105
|
+
staticConfig,
|
|
106
|
+
theme,
|
|
107
|
+
onDidAnimate: props.onDidAnimate
|
|
110
108
|
});
|
|
111
109
|
const {
|
|
112
110
|
tag,
|
|
@@ -160,25 +158,22 @@ function createComponent(configIn) {
|
|
|
160
158
|
}
|
|
161
159
|
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
162
160
|
const hostRef = useRef(null);
|
|
163
|
-
const hasEnterStyle = !!props.enterStyle;
|
|
164
161
|
const internal = useRef();
|
|
165
162
|
if (!internal.current) {
|
|
166
163
|
internal.current = {
|
|
167
164
|
isMounted: true
|
|
168
165
|
};
|
|
169
166
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
175
|
-
}
|
|
167
|
+
useIsomorphicLayoutEffect(() => {
|
|
168
|
+
setStateShallow({
|
|
169
|
+
mounted: true
|
|
170
|
+
});
|
|
176
171
|
internal.current.isMounted = true;
|
|
177
172
|
return () => {
|
|
178
173
|
mouseUps.delete(unPress);
|
|
179
174
|
internal.current.isMounted = false;
|
|
180
175
|
};
|
|
181
|
-
}, []);
|
|
176
|
+
}, [hasEnterStyle]);
|
|
182
177
|
if (nativeID) {
|
|
183
178
|
viewProps.id = nativeID;
|
|
184
179
|
}
|
|
@@ -254,10 +249,11 @@ function createComponent(configIn) {
|
|
|
254
249
|
const className = classList.join(" ");
|
|
255
250
|
if (process.env.NODE_ENV === "development") {
|
|
256
251
|
if (props["debug"]) {
|
|
257
|
-
console.log(" \xBB className", { isStringElement, pseudos, state, defaultsClassName, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className });
|
|
252
|
+
console.log(" \xBB className", { isStringElement, pseudos, state, defaultsClassName, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className, values: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) });
|
|
258
253
|
}
|
|
259
254
|
}
|
|
260
255
|
viewProps.className = className;
|
|
256
|
+
viewProps.style = animationStyles;
|
|
261
257
|
} else {
|
|
262
258
|
viewProps.style = styles;
|
|
263
259
|
}
|
|
@@ -294,7 +290,7 @@ function createComponent(configIn) {
|
|
|
294
290
|
viewProps.ref = forwardedRef;
|
|
295
291
|
}
|
|
296
292
|
}
|
|
297
|
-
const attachPress = !!(pseudos && pseudos.pressStyle || onPress || onPressOut || onPressIn);
|
|
293
|
+
const attachPress = !!(pseudos && pseudos.pressStyle || defaultPseudos && defaultPseudos.pressStyle || onPress || onPressOut || onPressIn);
|
|
298
294
|
const isHoverable = isWeb && !isTouchDevice;
|
|
299
295
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
300
296
|
const pressEventKey = isStringElement ? "onClick" : "onPress";
|
|
@@ -377,18 +373,6 @@ function createComponent(configIn) {
|
|
|
377
373
|
} : {
|
|
378
374
|
disabled: true
|
|
379
375
|
});
|
|
380
|
-
if (events) {
|
|
381
|
-
if (!isStringElement) {
|
|
382
|
-
Object.assign(viewProps, pressProps);
|
|
383
|
-
} else {
|
|
384
|
-
Object.assign(viewProps, events);
|
|
385
|
-
}
|
|
386
|
-
if (isWeb && isHoverable) {
|
|
387
|
-
childEls = <span style={{
|
|
388
|
-
display: "contents"
|
|
389
|
-
}} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{children}</span>;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
376
|
let content;
|
|
393
377
|
if (isWeb) {
|
|
394
378
|
if (staticConfig.isReactNativeWeb) {
|
|
@@ -405,11 +389,23 @@ function createComponent(configIn) {
|
|
|
405
389
|
}
|
|
406
390
|
}
|
|
407
391
|
}
|
|
392
|
+
if (events) {
|
|
393
|
+
if (!isStringElement) {
|
|
394
|
+
Object.assign(viewProps, pressProps);
|
|
395
|
+
} else {
|
|
396
|
+
Object.assign(viewProps, events);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
408
399
|
content = createElement(ViewComponent, viewProps, childEls);
|
|
400
|
+
if (isWeb && events && attachHover) {
|
|
401
|
+
content = <span className="tui_Hoverable" style={{
|
|
402
|
+
display: "contents"
|
|
403
|
+
}} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{content}</span>;
|
|
404
|
+
}
|
|
409
405
|
if (process.env.NODE_ENV === "development") {
|
|
410
406
|
if (props["debug"]) {
|
|
411
407
|
viewProps["debug"] = true;
|
|
412
|
-
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps,
|
|
408
|
+
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, defaultsClassName, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, defaultSplitStyleResult, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
|
|
413
409
|
}
|
|
414
410
|
}
|
|
415
411
|
if (features.length) {
|
|
@@ -422,17 +418,24 @@ function createComponent(configIn) {
|
|
|
422
418
|
});
|
|
423
419
|
onConfiguredOnce((conf) => {
|
|
424
420
|
var _a, _b, _c, _d;
|
|
421
|
+
if (process.env.IS_STATIC === "is_static") {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
425
424
|
const shouldDebug = (_a = staticConfig.defaultProps) == null ? void 0 : _a.debug;
|
|
426
425
|
tamaguiConfig = conf;
|
|
427
426
|
avoidClasses = !!((_b = tamaguiConfig.animations) == null ? void 0 : _b.avoidClasses);
|
|
428
427
|
AnimatedText = (_c = tamaguiConfig.animations) == null ? void 0 : _c.Text;
|
|
429
428
|
AnimatedView = (_d = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _d.View;
|
|
430
429
|
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
431
|
-
|
|
430
|
+
defaultSplitStyleResult = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
|
|
432
431
|
mounted: true,
|
|
433
|
-
|
|
432
|
+
hover: false,
|
|
433
|
+
press: false,
|
|
434
|
+
pressIn: false,
|
|
435
|
+
focus: false,
|
|
436
|
+
resolveVariablesAs: "both"
|
|
434
437
|
});
|
|
435
|
-
const { classNames, pseudos, style, viewProps } =
|
|
438
|
+
const { classNames, pseudos, style, viewProps } = defaultSplitStyleResult;
|
|
436
439
|
if (isWeb) {
|
|
437
440
|
defaultsClassName = classNames;
|
|
438
441
|
}
|
|
@@ -451,13 +454,14 @@ function createComponent(configIn) {
|
|
|
451
454
|
...component.defaultProps
|
|
452
455
|
};
|
|
453
456
|
if (process.env.NODE_ENV === "development" && shouldDebug && process.env.IS_STATIC !== "is_static") {
|
|
454
|
-
console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, { staticConfig, ...
|
|
457
|
+
console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, { staticConfig, ...defaultSplitStyleResult });
|
|
455
458
|
}
|
|
456
459
|
});
|
|
457
460
|
let res = component;
|
|
458
461
|
if (configIn.memo) {
|
|
459
462
|
res = memo(res);
|
|
460
463
|
}
|
|
464
|
+
res["whyDidYouRender"] = true;
|
|
461
465
|
res["staticConfig"] = {
|
|
462
466
|
validStyles: validStyleProps,
|
|
463
467
|
...staticConfig
|
|
@@ -478,6 +482,7 @@ function createComponent(configIn) {
|
|
|
478
482
|
__name(createComponent, "createComponent");
|
|
479
483
|
const Spacer = createComponent({
|
|
480
484
|
memo: true,
|
|
485
|
+
componentName: "Spacer",
|
|
481
486
|
defaultProps: {
|
|
482
487
|
...stackDefaultStyles,
|
|
483
488
|
size: true
|
|
@@ -550,38 +555,6 @@ function spacedChildren({
|
|
|
550
555
|
return next;
|
|
551
556
|
}
|
|
552
557
|
__name(spacedChildren, "spacedChildren");
|
|
553
|
-
const merge = /* @__PURE__ */ __name((...styles) => {
|
|
554
|
-
if (!styles[0])
|
|
555
|
-
return;
|
|
556
|
-
const res = {};
|
|
557
|
-
const len = styles.length;
|
|
558
|
-
for (let i = len - 1; i >= 0; i--) {
|
|
559
|
-
const cur = styles[i];
|
|
560
|
-
if (!cur)
|
|
561
|
-
continue;
|
|
562
|
-
for (const key in cur) {
|
|
563
|
-
const val = cur[key];
|
|
564
|
-
if (key !== "transform") {
|
|
565
|
-
if (!(key in res)) {
|
|
566
|
-
res[key] = val;
|
|
567
|
-
}
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
if (!res.transform) {
|
|
571
|
-
res.transform = val;
|
|
572
|
-
continue;
|
|
573
|
-
}
|
|
574
|
-
for (const t of val) {
|
|
575
|
-
const tkey = Object.keys(t)[0];
|
|
576
|
-
if (res.transform.find((existing) => tkey in existing)) {
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
res.transform.push(t);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
return res;
|
|
584
|
-
}, "merge");
|
|
585
558
|
const AbsoluteFill = /* @__PURE__ */ __name((props) => isWeb ? <div style={{
|
|
586
559
|
position: "absolute",
|
|
587
560
|
top: 0,
|
|
@@ -593,6 +566,7 @@ export {
|
|
|
593
566
|
AbsoluteFill,
|
|
594
567
|
Spacer,
|
|
595
568
|
createComponent,
|
|
569
|
+
defaultComponentState,
|
|
596
570
|
mouseUps,
|
|
597
571
|
spacedChildren
|
|
598
572
|
};
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { onConfiguredOnce } from "./conf";
|
|
2
|
+
import { insertedSelectors } from "./helpers/insertStyleRule";
|
|
3
|
+
onConfiguredOnce((conf) => {
|
|
4
|
+
if (globalThis["Tamagui"]) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
globalThis["Tamagui"] = {
|
|
8
|
+
...conf,
|
|
9
|
+
get insertedCSS() {
|
|
10
|
+
return insertedSelectors;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ReactNative from "react-native";
|
|
2
|
+
const RNComponents = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
for (const key of ["Image", "TextInput", "Text", "View"]) {
|
|
4
|
+
const val = ReactNative[key];
|
|
5
|
+
if (val && typeof val === "object") {
|
|
6
|
+
RNComponents.set(val, true);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
RNComponents
|
|
11
|
+
};
|
|
@@ -13,6 +13,8 @@ const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey
|
|
|
13
13
|
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
14
14
|
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
15
15
|
const styleInner = rules[0].replace(identifier, nextIdentifier);
|
|
16
|
+
if (styleInner.includes("2:r;"))
|
|
17
|
+
debugger;
|
|
16
18
|
let styleRule = "";
|
|
17
19
|
if (styleInner.includes("@media")) {
|
|
18
20
|
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|