@tamagui/core 1.0.0-alpha.30 → 1.0.0-alpha.37
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/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js.map +2 -2
- package/dist/cjs/helpers/fixNativeShadow.native.js +23 -19
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/cjs/styled.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/constants/platform.js +2 -1
- package/dist/esm/constants/platform.js.map +1 -1
- package/dist/esm/createComponent.js +23 -19
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createTamagui.js +2 -1
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTheme.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +10 -8
- package/dist/esm/helpers/createPropMapper.js.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.js +3 -2
- package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
- package/dist/esm/helpers/fixNativeShadow.native.js +23 -19
- package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +2 -1
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/isTamaguiElement.js +2 -1
- package/dist/esm/helpers/isTamaguiElement.js.map +1 -1
- package/dist/esm/helpers/themeable.js +1 -1
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/hooks/useMedia.js +5 -3
- package/dist/esm/hooks/useMedia.js.map +1 -1
- package/dist/esm/hooks/usePressable.js +2 -1
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +3 -2
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/views/TextAncestorContext.js +2 -1
- package/dist/esm/views/TextAncestorContext.js.map +1 -1
- package/dist/esm/views/Theme.js +2 -1
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/ThemeManagerContext.js +2 -1
- package/dist/esm/views/ThemeManagerContext.js.map +1 -1
- package/dist/jsx/constants/platform.js +2 -1
- package/dist/jsx/createComponent.js +23 -19
- package/dist/jsx/createTamagui.js +2 -1
- package/dist/jsx/helpers/createPropMapper.js +10 -8
- package/dist/jsx/helpers/extendStaticConfig.js +3 -2
- package/dist/jsx/helpers/fixNativeShadow.native.js +23 -19
- package/dist/jsx/helpers/getStylesAtomic.js +2 -1
- package/dist/jsx/helpers/isTamaguiElement.js +2 -1
- package/dist/jsx/helpers/themeable.js +1 -1
- package/dist/jsx/hooks/useMedia.js +5 -3
- package/dist/jsx/hooks/usePressable.js +2 -1
- package/dist/jsx/hooks/useTheme.js +3 -2
- package/dist/jsx/views/TextAncestorContext.js +2 -1
- package/dist/jsx/views/Theme.js +2 -1
- package/dist/jsx/views/ThemeManagerContext.js +2 -1
- package/package.json +6 -6
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTheme.d.ts +1 -1
- package/types/createTheme.d.ts.map +1 -1
- package/types/helpers/fixNativeShadow.native.d.ts +1 -1
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -1
- package/types/styled.d.ts +1 -1
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +10 -2
- package/types/types.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { getStyleRules } from '@tamagui/helpers'\n\nimport { isWeb } from './constants/platform'\nimport { Variable, createVariable } from './createVariable'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAE9B,sBAAsB;AACtB,4BAAyC;AACzC,mCAAsC;
|
|
4
|
+
"sourcesContent": ["import { getStyleRules } from '@tamagui/helpers'\n\nimport { isWeb } from './constants/platform'\nimport { Variable, createVariable } from './createVariable'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport { configureMedia } from './hooks/useMedia'\nimport {\n CreateTamaguiConfig,\n GenericTamaguiConfig,\n MediaQueryKey,\n TamaguiInternalConfig,\n TamaguiProviderProps,\n} from './types'\n\nexport type CreateTamaguiProps = TamaguiProviderProps &\n // we omit and re-declare it because we need to allow instantation types to be flexible\n // user then re-defines the types after createTamagui returns the typed object they want\n Omit<GenericTamaguiConfig, 'themes'> & {\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n // for ssr/native, will default to active\n mediaQueryDefaultActive?: MediaQueryKey[]\n }\n\nlet conf: TamaguiInternalConfig | null\n\nexport const getHasConfigured = () => !!conf\n\nexport const getTamagui = () => conf!\nexport const getTokens = () => conf!.tokensParsed\nexport const getThemes = () => conf!.themes\n\ntype ConfigListener = (conf: TamaguiInternalConfig) => void\nconst configListeners = new Set<ConfigListener>()\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf)\n } else {\n configListeners.add(cb)\n }\n}\n\nconst PREFIX = `theme--`\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n config: Conf\n): Conf extends CreateTamaguiConfig<infer A, infer B, infer C, infer D>\n ? TamaguiInternalConfig<A, B, C, D>\n : unknown {\n // config is re-run by the @tamagui/static, dont double validate\n // but cheap to check and not much downside just returning here if parsed\n if (config['parsed']) {\n return config as any\n }\n\n // test env loads a few times as it runs diff tests\n if (conf) {\n console.warn('Called createTamagui twice! Should never do so')\n // throw new Error(`#000 createTamagui called twice`)\n }\n\n configureMedia({\n queries: config.media as any,\n defaultActive: config.mediaQueryDefaultActive,\n })\n\n const themeConfig = (() => {\n let cssRules: string[] = []\n const varsByValue = new Map<string, Variable>()\n\n if (isWeb) {\n // tokens\n let tokenRule = `:root {`\n const addVar = (v: Variable) => {\n varsByValue[v.val] = v\n const rule = `--${v.name}:${typeof v.val === 'number' ? `${v.val}px` : v.val};`\n tokenRule += rule\n }\n\n for (const key in config.tokens) {\n for (const skey in config.tokens[key]) {\n const val = config.tokens[key][skey]\n if (key === 'font') {\n for (const fkey in val) {\n if (fkey === 'family') {\n addVar(val[fkey])\n } else {\n for (const fskey in val[fkey]) {\n addVar(val[fkey][fskey])\n }\n }\n }\n } else {\n addVar(val)\n }\n }\n }\n cssRules.push(`${tokenRule}\\n}`)\n }\n\n // themes\n for (const themeName in config.themes) {\n // to allow using the same theme with diff names, be sure we don't mutate!\n const theme = { ...config.themes[themeName] }\n config.themes[themeName] = theme\n\n let vars = ''\n\n for (const themeKey in theme) {\n if (isWeb) {\n const val = theme[themeKey]\n // TODO sanity check is necessary\n const varName = val instanceof Variable ? val.name : varsByValue[val]?.name\n vars += `--${themeKey}:${varName ? `var(--${varName});` : `${val}`};`\n }\n\n // make sure properly names theme variables\n ensureThemeVariable(theme, themeKey)\n }\n\n if (isWeb) {\n const [themeClassName, parentName] = themeName.includes('-')\n ? themeName.split('-')\n : [themeName, '']\n // tiny hack for now assuming light/dark are typical parentName\n const oppositeName = parentName === 'dark' ? 'light' : 'dark'\n const cssParentSel = parentName ? `.${PREFIX}${parentName}` : ''\n const cssChildSel = `.${PREFIX}${themeClassName}`\n const cssSel = `${cssParentSel} ${cssChildSel}`\n // we need to force specificity\n const cssRule = `${cssSel}, .${PREFIX}${oppositeName} ${cssSel} {\\n${vars}\\n}`\n cssRules.push(cssRule)\n }\n }\n\n varsByValue.clear()\n Object.freeze(cssRules)\n\n return {\n cssRules,\n css: cssRules.join('\\n'),\n }\n })()\n\n // faster lookups token keys become $keys to match input\n const tokensParsed: any = parseTokens(config.tokens)\n\n // we could do this above in theme loop\n // all themes should match key and we just need variable name\n // TODO once w react native we'd want to have a reverse lookup back to value\n const themeParsed: any = {}\n const firstKey = Object.keys(config.themes)[0]\n for (const key in config.themes[firstKey]) {\n // themeParsed[`$${key}`] = config.themes[firstKey][key]\n const val = config.themes[firstKey][key].val\n themeParsed[`$${key}`] = new Variable({ val, name: key })\n }\n\n const next: TamaguiInternalConfig = {\n // @ts-ignore\n shorthands: {},\n ...config,\n Provider: createTamaguiProvider({\n defaultTheme: 'light',\n ...config,\n }),\n themeConfig,\n themeParsed,\n tokensParsed,\n parsed: true,\n getCSS() {\n return `${themeConfig.css}\\n${[...getStyleRules()].join('\\n')}`\n },\n }\n conf = next\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n configListeners.clear()\n }\n\n // @ts-expect-error\n return next\n}\n\nexport function getThemeParentClassName(themeName?: string | null) {\n return `theme-parent ${themeName ? `${PREFIX}${themeName}` : ''}`\n}\n\nconst parseTokens = (tokens: any) => {\n const res: any = {}\n for (const key in tokens) {\n res[key] = {}\n if (key === 'font') {\n for (const family in tokens.font) {\n const obj = {}\n res.font[`$${family}`] = obj\n for (const attrKey in tokens.font[family]) {\n const attr = tokens.font[family][attrKey]\n if (attrKey === 'family') {\n obj[attrKey] = attr\n continue\n }\n obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {\n acc[`$${cur}`] = attr[cur]\n return acc\n }, {})\n }\n }\n continue\n }\n for (const skey in tokens[key]) {\n res[key][`$${skey}`] = tokens[key][skey]\n }\n }\n\n return res\n}\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nfunction ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n if (!(val instanceof Variable)) {\n theme[key] = createVariable({\n name: key,\n val,\n })\n } else {\n if (val.name !== key) {\n // rename to theme name\n theme[key] = createVariable({\n name: key,\n val: val.val,\n })\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAE9B,sBAAsB;AACtB,4BAAyC;AACzC,mCAA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GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n
|
|
5
|
-
"mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc,wBACzB,
|
|
4
|
+
"sourcesContent": ["import { Variable } from './createVariable'\n\ntype GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n [K in keyof Theme]: Theme[K] | string | Variable\n} => theme\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc,wBACzB,UAGG,OAJsB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,27 +9,31 @@ var __export = (target, all) => {
|
|
|
9
9
|
__export(exports, {
|
|
10
10
|
fixNativeShadow: () => fixNativeShadow
|
|
11
11
|
});
|
|
12
|
-
const
|
|
12
|
+
const matchRgbaHsla = /(rgba|hsla)\(\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,})\s*\)$/;
|
|
13
13
|
function fixNativeShadow(props) {
|
|
14
|
-
if (props.shadowColor) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
if (!props.shadowColor) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!props.shadowOffset) {
|
|
18
|
+
props.shadowOffset = {
|
|
19
|
+
width: 0,
|
|
20
|
+
height: 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if ("shadowOpacity" in props) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const c = `${props.shadowColor}`;
|
|
27
|
+
if ((c[0] === "r" || c[0] === "h") && c[3] === "a") {
|
|
28
|
+
const [_, type, _1, _2, _3, a] = c.match(matchRgbaHsla) || [];
|
|
29
|
+
if (typeof a !== "string") {
|
|
30
|
+
console.warn("invalid", c, type);
|
|
31
|
+
return;
|
|
32
32
|
}
|
|
33
|
+
props.shadowColor = `${type.replace("a", "")}(${_1},${_2},${_3})`;
|
|
34
|
+
props.shadowOpacity = +a;
|
|
35
|
+
} else {
|
|
36
|
+
props.shadowOpacity = 1;
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
__name(fixNativeShadow, "fixNativeShadow");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/fixNativeShadow.native.tsx"],
|
|
4
|
-
"sourcesContent": ["const
|
|
5
|
-
"mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA,MAAM,
|
|
4
|
+
"sourcesContent": ["const matchRgbaHsla =\n /(rgba|hsla)\\(\\s*([\\d\\.]{1,}%?)\\s*,\\s*([\\d\\.]{1,}%?)\\s*,\\s*([\\d\\.]{1,}%?)\\s*,\\s*([\\d\\.]{1,})\\s*\\)$/\n\nexport function fixNativeShadow(props: any) {\n if (!props.shadowColor) {\n return\n }\n if (!props.shadowOffset) {\n // fixes some broken shadows\n props.shadowOffset = {\n width: 0,\n height: 0,\n }\n }\n if ('shadowOpacity' in props) {\n return\n }\n const c = `${props.shadowColor}`\n // react native has issues sometimes with rgba()\n // supports rgba + hsla\n if ((c[0] === 'r' || c[0] === 'h') && c[3] === 'a') {\n const [_, type, _1, _2, _3, a] = c.match(matchRgbaHsla) || []\n if (typeof a !== 'string') {\n console.warn('invalid', c, type)\n return\n }\n props.shadowColor = `${type.replace('a', '')}(${_1},${_2},${_3})`\n props.shadowOpacity = +a\n } else {\n props.shadowOpacity = 1\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA,MAAM,gBACJ;AAEK,yBAAyB,OAAY;AAC1C,MAAI,CAAC,MAAM,aAAa;AACtB;AAAA;AAEF,MAAI,CAAC,MAAM,cAAc;AAEvB,UAAM,eAAe;AAAA,MACnB,OAAO;AAAA,MACP,QAAQ;AAAA;AAAA;AAGZ,MAAI,mBAAmB,OAAO;AAC5B;AAAA;AAEF,QAAM,IAAI,GAAG,MAAM;AAGnB,MAAK,GAAE,OAAO,OAAO,EAAE,OAAO,QAAQ,EAAE,OAAO,KAAK;AAClD,UAAM,CAAC,GAAG,MAAM,IAAI,IAAI,IAAI,KAAK,EAAE,MAAM,kBAAkB;AAC3D,QAAI,OAAO,MAAM,UAAU;AACzB,cAAQ,KAAK,WAAW,GAAG;AAC3B;AAAA;AAEF,UAAM,cAAc,GAAG,KAAK,QAAQ,KAAK,OAAO,MAAM,MAAM;AAC5D,UAAM,gBAAgB,CAAC;AAAA,SAClB;AACL,UAAM,gBAAgB;AAAA;AAAA;AA1BV;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.ts"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\n\nimport { createComponent } from './createComponent'\nimport { extendStaticConfig } from './helpers/extendStaticConfig'\nimport { MediaProps, StaticComponent, StaticConfig, TamaguiConfig, Themes, Tokens } from './types'\n\nexport function styled<\n ParentComponent extends StaticComponent | React.Component<any>,\n Variants extends GetVariants<ParentComponent>\n>(\n Component: ParentComponent,\n options?: GetProps<ParentComponent> & {\n variants?: Variants\n },\n staticExtractionOptions?: StaticConfig\n) {\n const staticConfigProps: StaticConfig = (() => {\n if (options) {\n const { variants, ...defaultProps } = options\n return { ...staticExtractionOptions, variants, defaultProps }\n }\n return {}\n })()\n const config = extendStaticConfig(Component, staticConfigProps)\n const component = createComponent(config!) // error is good here its on init\n type VariantProps = GetVariantProps<Variants>\n return component as StaticComponent<\n
|
|
4
|
+
"sourcesContent": ["import React from 'react'\n\nimport { createComponent } from './createComponent'\nimport { extendStaticConfig } from './helpers/extendStaticConfig'\nimport { MediaProps, StaticComponent, StaticConfig, TamaguiConfig, Themes, Tokens } from './types'\n\nexport function styled<\n ParentComponent extends StaticComponent | React.Component<any>,\n Variants extends GetVariants<ParentComponent>\n>(\n Component: ParentComponent,\n options?: GetProps<ParentComponent> & {\n variants?: Variants\n },\n staticExtractionOptions?: StaticConfig\n) {\n const staticConfigProps: StaticConfig = (() => {\n if (options) {\n const { variants, ...defaultProps } = options\n return { ...staticExtractionOptions, variants, defaultProps }\n }\n return {}\n })()\n const config = extendStaticConfig(Component, staticConfigProps)\n const component = createComponent(config!) // error is good here its on init\n type VariantProps = GetVariantProps<Variants>\n return component as StaticComponent<\n // if not options/variants passed just styled(Text):\n keyof VariantProps extends never\n ? GetProps<ParentComponent>\n : // if options passed: styled(Text, { ... })\n Omit<GetProps<ParentComponent>, keyof VariantProps> &\n VariantProps &\n MediaProps<VariantProps>,\n void\n >\n}\n\n// type ParentVariants = A extends StaticComponent<any, infer Variants> ? Variants : {}\n\nexport type GetProps<A> = A extends StaticComponent<infer Props>\n ? Props\n : A extends React.Component<infer Props>\n ? Props\n : {}\n\nexport type GetVariants<ParentComponent extends StaticComponent | React.Component<any>> = void | {\n [key: string]: {\n [key: string]:\n | Partial<GetProps<ParentComponent>>\n | ((\n val: any,\n config: {\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: GetProps<ParentComponent>\n }\n ) => Partial<GetProps<ParentComponent>>)\n }\n}\n\nexport type GetVariantProps<Variants> = Variants extends void\n ? {}\n : {\n // ensure variants actually defined\n [Key in keyof Variants]?: keyof Variants[Key] extends `...${infer VariantSpread}`\n ? VariantSpread extends keyof Tokens\n ? keyof Tokens[VariantSpread] extends string | number\n ? `$${keyof Tokens[VariantSpread]}` | null\n : unknown\n : unknown\n : keyof Variants[Key] extends 'true'\n ? boolean | null\n : keyof Exclude<Variants[Key], undefined>\n }\n\n// type X = { ok: 1 }\n// type Y = { okk: 2; ok: 3 }\n// type Z = X & Y\n// type Z2 = Z\n\n// TODO get name\n// const displayName = `styled(Component)`\n// Object.defineProperty(component, 'name', {\n// value: displayName,\n// writable: false,\n// })\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAEA,6BAAgC;AAChC,gCAAmC;AAG5B,gBAIL,WACA,SAGA,yBACA;AACA,QAAM,oBAAmC,OAAM;AAC7C,QAAI,SAAS;AACX,YAAsC,cAA9B,eAA8B,IAAjB,yBAAiB,IAAjB,CAAb;AACR,aAAO,iCAAK,0BAAL,EAA8B,UAAU;AAAA;AAEjD,WAAO;AAAA;AAET,QAAM,SAAS,kDAAmB,WAAW;AAC7C,QAAM,YAAY,4CAAgB;AAElC,SAAO;AAAA;AApBO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { RefObject } from 'react'\nimport { TextProps as ReactTextProps, TextStyle } from 'react-native'\nimport { GestureResponderEvent, View, ViewProps, ViewStyle } from 'react-native'\n\nimport { Variable } from './createVariable'\nimport { ThemeProviderProps } from './views/ThemeProvider'\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport interface CreateTokens<Val extends number | string | Variable = number | string | Variable> {\n font: { [key: string]: GenericFont }\n color: { [key: string]: Val }\n space: { [key: string]: Val }\n size: { [key: string]: Val }\n radius: { [key: string]: Val }\n zIndex: { [key: string]: Val }\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]: {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n bg: string | Variable\n bg2: string | Variable\n bg3: string | Variable\n bg4: string | Variable\n color: string | Variable\n color2: string | Variable\n color3: string | Variable\n color4: string | Variable\n borderColor: string | Variable\n borderColor2: string | Variable\n shadowColor: string | Variable\n shadowColor2: string | Variable\n }\n}\ntype GenericShorthands = {}\ntype GenericMedia<K extends string = string> = {\n // name => media shorthand name (camelCase) => value\n [key in K]: {\n [key: string]: number | string\n }\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands,\n D extends GenericMedia\n> = Partial<Pick<ThemeProviderProps, 'defaultTheme' | 'disableRootThemeClass'>> & {\n tokens: A\n themes: B\n shorthands: C\n media: D\n}\n\n// for use in creation functions so it doesnt get overwrtitten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeObject = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\n// themes\nexport type ThemeName = keyof Themes extends `${infer Prefix}-${string}`\n ? Prefix | keyof Themes\n : keyof Themes\nexport type ThemeKeys = keyof ThemeObject\nexport type ThemeKeyVariables = `$${ThemeKeys}`\n// export type Spaces = TamaguiConfig['tokens']['spaces'][keyof TamaguiConfig['tokens']['spaces']]\n// export type FontSizes = TamaguiConfig['tokens']['fontSizes'][keyof TamaguiConfig['tokens']['fontSizes']]\n// export type Colors = TamaguiConfig['tokens']['colors'][keyof TamaguiConfig['tokens']['colors']]\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia\n> = CreateTamaguiConfig<A, B, C, D> & {\n Provider: (props: TamaguiProviderProps) => any\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n themeParsed: { [key: string]: Variable }\n tokensParsed: CreateTokens<Variable>\n themeConfig: any\n getCSS: () => string\n parsed: boolean\n}\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends StaticComponent> = A extends React.FunctionComponent<infer Props>\n ? Props\n : unknown\n\nexport type GenericFont = {\n size: { [key: string | number]: number | Variable }\n lineHeight: { [key: string | number]: number | Variable }\n letterSpacing: { [key: string | number]: number | Variable }\n weight: { [key: string | number]: string | Variable }\n family: string | Variable\n}\n\n// media\nexport type MediaKeys = keyof Media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryState = {\n [key in string]: boolean\n}\nexport type MediaQueryKey = keyof Media\nexport type MediaProps<A> = {\n [key in `$${MediaQueryKey}`]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\nexport type ConfigureMediaQueryOptions = {\n queries?: MediaQueries\n defaultActive?: MediaQueryKey[]\n}\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n//\n// base props that are accepted by createComponent (additional to react-native-web)\n//\ntype ComponentPropsBase = {\n className?: string\n tag?: string\n animated?: boolean\n onHoverIn?: (e: MouseEvent) => any\n onHoverOut?: (e: MouseEvent) => any\n onPress?: (e: GestureResponderEvent) => any\n onPressIn?: (e: GestureResponderEvent) => any\n onPressOut?: (e: GestureResponderEvent) => any\n // WEB ONLY\n onMouseEnter?: (e: GestureResponderEvent) => any\n // WEB ONLY\n onMouseLeave?: (e: GestureResponderEvent) => any\n space?: Tokens['space'][keyof Tokens['space']] | boolean | string | number\n pointerEvents?: string\n}\n\ntype GetTokenFontKeysFor<A extends 'size' | 'weight' | 'letterSpacing' | 'family' | 'lineHeight'> =\n keyof Tokens['font'][keyof Tokens['font']][A]\n\nexport type SpaceTokens = `$${keyof Tokens['space']}`\n\n//\n// adds in theme short values to relevant props\n//\ntype ThemeValue<A> = Omit<A, string> | UnionableString | Variable\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]:\n | ThemeValue<T[K]>\n | (K extends ColorableKeys\n ? ThemeKeyVariables\n : K extends SizeKeys\n ? `$${keyof Tokens['size']}`\n : K extends FontKeys\n ? `$${keyof Tokens['font']}`\n : K extends FontSizeKeys\n ? `$${GetTokenFontKeysFor<'size'>}`\n : K extends SpaceKeys\n ? `$${keyof Tokens['space']}`\n : K extends ColorKeys\n ? `$${keyof Tokens['color']}`\n : K extends ZIndexKeys\n ? `$${keyof Tokens['zIndex']}`\n : K extends LineHeightKeys\n ? `$${GetTokenFontKeysFor<'lineHeight'>}`\n : K extends FontWeightKeys\n ? `$${GetTokenFontKeysFor<'weight'>}`\n : K extends FontLetterSpacingKeys\n ? `$${GetTokenFontKeysFor<'letterSpacing'>}`\n : {})\n}\n\n//\n// adds in shorthand props\n//\ntype WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// adds theme and shorthands + pseudo styles with both\n//\ntype WithThemeShorthandsAndPseudos<A extends object> = WithThemeAndShorthands<A> & {\n hoverStyle?: WithThemeAndShorthands<A> | null\n pressStyle?: WithThemeAndShorthands<A> | null\n}\n\n//\n// adds theme, shorthands, psuedos, then all the previous to media queries\n//\ntype WithThemeShorthandsPseudosAndMedia<A extends object> = WithThemeShorthandsAndPseudos<A> &\n MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n//\n// Stack\n//\n\ntype WebOnlyStyleProps = {\n // WEB ONLY\n cursor?: string\n // WEB ONLY\n contain?: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'paint' | string\n // WEB ONLY values: inherit, inline, block, content\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n // WEB ONLY pointerEvents can be a style prop\n pointerEvents?: ViewProps['pointerEvents']\n}\n\nexport type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &\n TransformStyleProps &\n WebOnlyStyleProps\n\nexport type StackStyleProps = WithThemeShorthandsPseudosAndMedia<StackStylePropsBase>\n\nexport type StackProps = Omit<RNWInternalProps, 'children'> &\n Omit<ViewProps, 'display' | 'children'> &\n StackStyleProps &\n ComponentPropsBase & {\n ref?: RefObject<View | HTMLElement> | ((node: View | HTMLElement) => any)\n children?: any | any[]\n }\n\n//\n// Text props\n//\n\n// type EnhancedTextStyleProps = WithThemeValues<\n// Omit<TextStyle, 'display' | 'backfaceVisibility'> & TransformStyleProps\n// >\n// export type TextStylePropsBase = EnhancedTextStyleProps\n// export type TextStyleProps<S = TextStylePropsBase> = S & {\n// hoverStyle?: S | null\n// pressStyle?: S | null\n// }\n\ntype TextStyleProps = WithThemeShorthandsPseudosAndMedia<\n Omit<TextStyle, 'display' | 'backfaceVisibility'> & TransformStyleProps & WebOnlyStyleProps\n>\n\nexport type TextProps = Omit<ReactTextProps, 'style'> &\n TextStyleProps &\n ComponentPropsBase & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n }\n\n//\n// StaticComponent\n//\n\nexport type StaticComponent<\n Props = any,\n VariantProps = any,\n StaticConfParsed = StaticConfigParsed,\n ParentVariantProps = any\n> = React.FunctionComponent<Props> & {\n staticConfig: StaticConfParsed\n variantProps?: VariantProps\n\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: StaticConfig) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n initialWindowMetrics?: any\n fallback?: any\n children?: any\n}\n\nexport type RNWInternalProps = {\n accessibilityState?: {\n busy?: boolean\n checked?: boolean | 'mixed'\n disabled?: boolean\n expanded?: boolean\n grabbed?: boolean\n hidden?: boolean\n invalid?: boolean\n modal?: boolean\n pressed?: boolean\n readonly?: boolean\n required?: boolean\n selected?: boolean\n }\n accessibilityValue?: {\n max?: number\n min?: number\n now?: number\n text?: string\n }\n children?: any\n focusable?: boolean\n nativeID?: string\n onBlur?: (e: any) => void\n onClick?: (e: any) => void\n onClickCapture?: (e: any) => void\n onContextMenu?: (e: any) => void\n onFocus?: (e: any) => void\n onKeyDown?: (e: any) => void\n onKeyUp?: (e: any) => void\n onMoveShouldSetResponder?: (e: any) => boolean\n onMoveShouldSetResponderCapture?: (e: any) => boolean\n onResponderEnd?: (e: any) => void\n onResponderGrant?: (e: any) => void\n onResponderMove?: (e: any) => void\n onResponderReject?: (e: any) => void\n onResponderRelease?: (e: any) => void\n onResponderStart?: (e: any) => void\n onResponderTerminate?: (e: any) => void\n onResponderTerminationRequest?: (e: any) => boolean\n onScrollShouldSetResponder?: (e: any) => boolean\n onScrollShouldSetResponderCapture?: (e: any) => boolean\n onSelectionChangeShouldSetResponder?: (e: any) => boolean\n onSelectionChangeShouldSetResponderCapture?: (e: any) => boolean\n onStartShouldSetResponder?: (e: any) => boolean\n onStartShouldSetResponderCapture?: (e: any) => boolean\n pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto'\n testID?: string\n // unstable\n dataSet?: Object\n onMouseDown?: (e: any) => void\n onMouseEnter?: (e: any) => void\n onMouseLeave?: (e: any) => void\n onMouseMove?: (e: any) => void\n onMouseOver?: (e: any) => void\n onMouseOut?: (e: any) => void\n onMouseUp?: (e: any) => void\n onScroll?: (e: any) => void\n onTouchCancel?: (e: any) => void\n onTouchCancelCapture?: (e: any) => void\n onTouchEnd?: (e: any) => void\n onTouchEndCapture?: (e: any) => void\n onTouchMove?: (e: any) => void\n onTouchMoveCapture?: (e: any) => void\n onTouchStart?: (e: any) => void\n onTouchStartCapture?: (e: any) => void\n onWheel?: (e: any) => void\n href?: string\n hrefAttrs?: { download?: boolean; rel?: string; target?: string }\n}\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: (\n key: string,\n value: any,\n theme: ThemeObject,\n props: any\n ) => undefined | boolean | { [key: string]: any }\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfig = {\n Component?: StaticComponent\n\n variants?: {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n }\n\n /*\n * If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /*\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /*\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /*\n * Allows for defining extra valid props to be extracted beyond\n * the default ones.\n */\n validPropsExtra?: { [key: string]: any }\n\n /*\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps?: any\n\n /*\n * If this prop is encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /*\n * A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /*\n * We need to wrap children\n */\n isZStack?: boolean\n}\n\ntype ColorableKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderTopColor'\n | 'borderBottomColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n\ntype SizeKeys = 'width' | 'height' | 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight'\n\ntype FontKeys = 'fontFamily'\n\ntype FontSizeKeys = 'fontSize'\n\ntype FontWeightKeys = 'fontWeight'\n\ntype FontLetterSpacingKeys = 'letterSpacing'\n\ntype LineHeightKeys = 'lineHeight'\n\ntype ZIndexKeys = 'zIndex'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n\ntype SpaceKeys =\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n"],
|
|
4
|
+
"sourcesContent": ["import React, { RefObject } from 'react'\nimport { TextProps as ReactTextProps, TextStyle } from 'react-native'\nimport { GestureResponderEvent, View, ViewProps, ViewStyle } from 'react-native'\n\nimport { Variable } from './createVariable'\nimport { ThemeProviderProps } from './views/ThemeProvider'\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport interface CreateTokens<Val extends number | string | Variable = number | string | Variable> {\n font: { [key: string]: GenericFont }\n color: { [key: string]: Val }\n space: { [key: string]: Val }\n size: { [key: string]: Val }\n radius: { [key: string]: Val }\n zIndex: { [key: string]: Val }\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]: {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n bg: string | Variable\n bg2: string | Variable\n bg3: string | Variable\n bg4: string | Variable\n color: string | Variable\n color2: string | Variable\n color3: string | Variable\n color4: string | Variable\n borderColor: string | Variable\n borderColor2: string | Variable\n shadowColor: string | Variable\n shadowColor2: string | Variable\n }\n}\ntype GenericShorthands = {}\ntype GenericMedia<K extends string = string> = {\n // name => media shorthand name (camelCase) => value\n [key in K]: {\n [key: string]: number | string\n }\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands,\n D extends GenericMedia\n> = Partial<Pick<ThemeProviderProps, 'defaultTheme' | 'disableRootThemeClass'>> & {\n tokens: A\n themes: B\n shorthands: C\n media: D\n}\n\n// for use in creation functions so it doesnt get overwrtitten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeObject = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\n// themes\nexport type ThemeName = keyof Themes extends `${infer Prefix}-${string}`\n ? Prefix | keyof Themes\n : keyof Themes\nexport type ThemeKeys = keyof ThemeObject\nexport type ThemeKeyVariables = `$${ThemeKeys}`\n// export type Spaces = TamaguiConfig['tokens']['spaces'][keyof TamaguiConfig['tokens']['spaces']]\n// export type FontSizes = TamaguiConfig['tokens']['fontSizes'][keyof TamaguiConfig['tokens']['fontSizes']]\n// export type Colors = TamaguiConfig['tokens']['colors'][keyof TamaguiConfig['tokens']['colors']]\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia\n> = CreateTamaguiConfig<A, B, C, D> & {\n Provider: (props: TamaguiProviderProps) => any\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n themeParsed: { [key: string]: Variable }\n tokensParsed: CreateTokens<Variable>\n themeConfig: any\n getCSS: () => string\n parsed: boolean\n}\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends StaticComponent> = A extends React.FunctionComponent<infer Props>\n ? Props\n : unknown\n\nexport type GenericFont = {\n size: { [key: string | number]: number | Variable }\n lineHeight: { [key: string | number]: number | Variable }\n letterSpacing: { [key: string | number]: number | Variable }\n weight: { [key: string | number]: string | Variable }\n family: string | Variable\n}\n\n// media\nexport type MediaKeys = keyof Media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryState = {\n [key in string]: boolean\n}\nexport type MediaQueryKey = keyof Media\nexport type MediaProps<A> = {\n [key in `$${MediaQueryKey}`]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\nexport type ConfigureMediaQueryOptions = {\n queries?: MediaQueries\n defaultActive?: MediaQueryKey[]\n}\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n//\n// base props that are accepted by createComponent (additional to react-native-web)\n//\ntype ComponentPropsBase = {\n className?: string\n tag?: string\n animated?: boolean\n onHoverIn?: (e: MouseEvent) => any\n onHoverOut?: (e: MouseEvent) => any\n onPress?: (e: GestureResponderEvent) => any\n onPressIn?: (e: GestureResponderEvent) => any\n onPressOut?: (e: GestureResponderEvent) => any\n // WEB ONLY\n onMouseEnter?: (e: GestureResponderEvent) => any\n // WEB ONLY\n onMouseLeave?: (e: GestureResponderEvent) => any\n space?: Tokens['space'][keyof Tokens['space']] | boolean | string | number\n pointerEvents?: string\n}\n\ntype GetTokenFontKeysFor<A extends 'size' | 'weight' | 'letterSpacing' | 'family' | 'lineHeight'> =\n keyof Tokens['font'][keyof Tokens['font']][A]\n\nexport type SizeTokens = `$${keyof Tokens['size']}`\nexport type FontTokens = `$${keyof Tokens['font']}`\nexport type FontSizeTokens = `$${GetTokenFontKeysFor<'size'>}`\nexport type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}`\nexport type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}`\nexport type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}`\nexport type SpaceTokens = `$${keyof Tokens['space']}`\nexport type ColorTokens = `$${keyof Tokens['color']}`\nexport type ZIndexTokens = `$${keyof Tokens['zIndex']}`\n\n//\n// adds in theme short values to relevant props\n//\ntype ThemeValue<A> = Omit<A, string> | UnionableString | Variable\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]:\n | ThemeValue<T[K]>\n | (K extends ColorableKeys\n ? ThemeKeyVariables\n : K extends SizeKeys\n ? SizeTokens\n : K extends FontKeys\n ? FontTokens\n : K extends FontSizeKeys\n ? FontSizeTokens\n : K extends SpaceKeys\n ? SpaceTokens\n : K extends ColorKeys\n ? ColorTokens\n : K extends ZIndexKeys\n ? ZIndexTokens\n : K extends LineHeightKeys\n ? FontLineHeightTokens\n : K extends FontWeightKeys\n ? FontWeightTokens\n : K extends FontLetterSpacingKeys\n ? FontLetterSpacingTokens\n : {})\n}\n\n//\n// adds in shorthand props\n//\ntype WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// adds theme and shorthands + pseudo styles with both\n//\ntype WithThemeShorthandsAndPseudos<A extends object> = WithThemeAndShorthands<A> & {\n hoverStyle?: WithThemeAndShorthands<A> | null\n pressStyle?: WithThemeAndShorthands<A> | null\n}\n\n//\n// adds theme, shorthands, psuedos, then all the previous to media queries\n//\ntype WithThemeShorthandsPseudosAndMedia<A extends object> = WithThemeShorthandsAndPseudos<A> &\n MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n//\n// Stack\n//\n\ntype WebOnlyStyleProps = {\n // WEB ONLY\n cursor?: string\n // WEB ONLY\n contain?: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'paint' | string\n // WEB ONLY values: inherit, inline, block, content\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n // WEB ONLY pointerEvents can be a style prop\n pointerEvents?: ViewProps['pointerEvents']\n}\n\nexport type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &\n TransformStyleProps &\n WebOnlyStyleProps\n\nexport type StackStyleProps = WithThemeShorthandsPseudosAndMedia<StackStylePropsBase>\n\nexport type StackProps = Omit<RNWInternalProps, 'children'> &\n // Omit<ViewProps, 'display' | 'children'> &\n StackStyleProps &\n ComponentPropsBase & {\n ref?: RefObject<View | HTMLElement> | ((node: View | HTMLElement) => any)\n children?: any | any[]\n }\n\n//\n// Text props\n//\n\n// type EnhancedTextStyleProps = WithThemeValues<\n// Omit<TextStyle, 'display' | 'backfaceVisibility'> & TransformStyleProps\n// >\n// export type TextStylePropsBase = EnhancedTextStyleProps\n// export type TextStyleProps<S = TextStylePropsBase> = S & {\n// hoverStyle?: S | null\n// pressStyle?: S | null\n// }\n\ntype TextStyleProps = WithThemeShorthandsPseudosAndMedia<\n Omit<TextStyle, 'display' | 'backfaceVisibility'> & TransformStyleProps & WebOnlyStyleProps\n>\n\nexport type TextProps = Omit<ReactTextProps, 'style'> &\n TextStyleProps &\n ComponentPropsBase & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n }\n\n//\n// StaticComponent\n//\n\nexport type StaticComponent<\n Props = any,\n VariantProps = any,\n StaticConfParsed = StaticConfigParsed,\n ParentVariantProps = any\n> = React.FunctionComponent<Props> & {\n staticConfig: StaticConfParsed\n variantProps?: VariantProps\n\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: StaticConfig) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n initialWindowMetrics?: any\n fallback?: any\n children?: any\n}\n\nexport type RNWInternalProps = {\n accessibilityState?: {\n busy?: boolean\n checked?: boolean | 'mixed'\n disabled?: boolean\n expanded?: boolean\n grabbed?: boolean\n hidden?: boolean\n invalid?: boolean\n modal?: boolean\n pressed?: boolean\n readonly?: boolean\n required?: boolean\n selected?: boolean\n }\n accessibilityValue?: {\n max?: number\n min?: number\n now?: number\n text?: string\n }\n children?: any\n focusable?: boolean\n nativeID?: string\n onBlur?: (e: any) => void\n onClick?: (e: any) => void\n onClickCapture?: (e: any) => void\n onContextMenu?: (e: any) => void\n onFocus?: (e: any) => void\n onKeyDown?: (e: any) => void\n onKeyUp?: (e: any) => void\n onMoveShouldSetResponder?: (e: any) => boolean\n onMoveShouldSetResponderCapture?: (e: any) => boolean\n onResponderEnd?: (e: any) => void\n onResponderGrant?: (e: any) => void\n onResponderMove?: (e: any) => void\n onResponderReject?: (e: any) => void\n onResponderRelease?: (e: any) => void\n onResponderStart?: (e: any) => void\n onResponderTerminate?: (e: any) => void\n onResponderTerminationRequest?: (e: any) => boolean\n onScrollShouldSetResponder?: (e: any) => boolean\n onScrollShouldSetResponderCapture?: (e: any) => boolean\n onSelectionChangeShouldSetResponder?: (e: any) => boolean\n onSelectionChangeShouldSetResponderCapture?: (e: any) => boolean\n onStartShouldSetResponder?: (e: any) => boolean\n onStartShouldSetResponderCapture?: (e: any) => boolean\n pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto'\n testID?: string\n // unstable\n dataSet?: Object\n onMouseDown?: (e: any) => void\n onMouseEnter?: (e: any) => void\n onMouseLeave?: (e: any) => void\n onMouseMove?: (e: any) => void\n onMouseOver?: (e: any) => void\n onMouseOut?: (e: any) => void\n onMouseUp?: (e: any) => void\n onScroll?: (e: any) => void\n onTouchCancel?: (e: any) => void\n onTouchCancelCapture?: (e: any) => void\n onTouchEnd?: (e: any) => void\n onTouchEndCapture?: (e: any) => void\n onTouchMove?: (e: any) => void\n onTouchMoveCapture?: (e: any) => void\n onTouchStart?: (e: any) => void\n onTouchStartCapture?: (e: any) => void\n onWheel?: (e: any) => void\n href?: string\n hrefAttrs?: { download?: boolean; rel?: string; target?: string }\n}\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: (\n key: string,\n value: any,\n theme: ThemeObject,\n props: any\n ) => undefined | boolean | { [key: string]: any }\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfig = {\n Component?: StaticComponent\n\n variants?: {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n }\n\n /*\n * If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /*\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /*\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /*\n * Allows for defining extra valid props to be extracted beyond\n * the default ones.\n */\n validPropsExtra?: { [key: string]: any }\n\n /*\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps?: any\n\n /*\n * If this prop is encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /*\n * A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /*\n * We need to wrap children\n */\n isZStack?: boolean\n}\n\ntype ColorableKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderTopColor'\n | 'borderBottomColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n\ntype SizeKeys = 'width' | 'height' | 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight'\n\ntype FontKeys = 'fontFamily'\n\ntype FontSizeKeys = 'fontSize'\n\ntype FontWeightKeys = 'fontWeight'\n\ntype FontLetterSpacingKeys = 'letterSpacing'\n\ntype LineHeightKeys = 'lineHeight'\n\ntype ZIndexKeys = 'zIndex'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n\ntype SpaceKeys =\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n"],
|
|
5
5
|
"mappings": ";;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { useEffect, useLayoutEffect } from "react";
|
|
2
3
|
import { Platform } from "react-native";
|
|
3
|
-
const isWeb = process.env.TAMAGUI_TARGET === "web" ? true : Platform
|
|
4
|
+
const isWeb = process.env.TAMAGUI_TARGET === "web" ? true : ((_a = Platform) == null ? void 0 : _a.OS) === "web";
|
|
4
5
|
const isSSR = isWeb && typeof window === "undefined";
|
|
5
6
|
const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
|
|
6
7
|
const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/constants/platform.ts"],
|
|
4
4
|
"sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isWeb = process.env.TAMAGUI_TARGET === 'web' ? true : Platform?.OS === 'web'\nexport const isSSR = isWeb && typeof window === 'undefined'\nexport const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const supportsTouchWeb = typeof window !== 'undefined' && 'ontouchstart' in window\nexport const isTouchDevice = !isWeb || supportsTouchWeb\nexport const isWebIOS =\n isWeb &&\n typeof navigator !== 'undefined' &&\n (/iPad|iPhone|iPod/.test(navigator.platform) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&\n !window['MSStream']\n"],
|
|
5
|
-
"mappings": "AAAA;AACA;AAEO,MAAM,QAAQ,QAAQ,IAAI,mBAAmB,QAAQ,OAAO,
|
|
5
|
+
"mappings": "AAAA;AAAA;AACA;AAEO,MAAM,QAAQ,QAAQ,IAAI,mBAAmB,QAAQ,OAAO,uCAAU,QAAO;AAC7E,MAAM,QAAQ,SAAS,OAAO,WAAW;AACzC,MAAM,4BAA4B,QAAQ,YAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa;AAC1F,MAAM,mBAAmB,OAAO,WAAW,eAAe,kBAAkB;AAC5E,MAAM,gBAAgB,CAAC,SAAS;AAChC,MAAM,WACX,SACA,OAAO,cAAc,eACpB,oBAAmB,KAAK,UAAU,aAChC,UAAU,aAAa,cAAc,UAAU,iBAAiB,MACnE,CAAC,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -58,13 +58,14 @@ function createComponent(configIn) {
|
|
|
58
58
|
staticConfig = parseStaticConfig(configIn);
|
|
59
59
|
}
|
|
60
60
|
const { Component, validStyles, isText, isZStack } = staticConfig;
|
|
61
|
-
const validStyleProps = validStyles
|
|
61
|
+
const validStyleProps = validStyles != null ? validStyles : stylePropsView;
|
|
62
62
|
let defaultProps = null;
|
|
63
63
|
let tamaguiConfig;
|
|
64
64
|
let defaultsStyle;
|
|
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();
|
|
@@ -233,7 +234,7 @@ function createComponent(configIn) {
|
|
|
233
234
|
...!isWeb && {
|
|
234
235
|
onPressOut: (e) => {
|
|
235
236
|
unPress();
|
|
236
|
-
onPressOut
|
|
237
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
237
238
|
}
|
|
238
239
|
},
|
|
239
240
|
...isWeb && !isTouchDevice && {
|
|
@@ -248,8 +249,8 @@ function createComponent(configIn) {
|
|
|
248
249
|
if (Object.keys(next).length) {
|
|
249
250
|
set(next);
|
|
250
251
|
}
|
|
251
|
-
onHoverIn
|
|
252
|
-
onMouseEnter
|
|
252
|
+
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
253
|
+
onMouseEnter == null ? void 0 : onMouseEnter(e);
|
|
253
254
|
} : void 0,
|
|
254
255
|
onMouseLeave: attachHover || attachPress ? (e) => {
|
|
255
256
|
let next = {};
|
|
@@ -264,8 +265,8 @@ function createComponent(configIn) {
|
|
|
264
265
|
if (Object.keys(next).length) {
|
|
265
266
|
set(next);
|
|
266
267
|
}
|
|
267
|
-
onHoverOut
|
|
268
|
-
onMouseLeave
|
|
268
|
+
onHoverOut == null ? void 0 : onHoverOut(e);
|
|
269
|
+
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
269
270
|
} : void 0
|
|
270
271
|
},
|
|
271
272
|
onMouseDown: attachPress ? (e) => {
|
|
@@ -273,14 +274,14 @@ function createComponent(configIn) {
|
|
|
273
274
|
press: true,
|
|
274
275
|
pressIn: true
|
|
275
276
|
});
|
|
276
|
-
onPressIn
|
|
277
|
-
onMouseDown
|
|
277
|
+
onPressIn == null ? void 0 : onPressIn(e);
|
|
278
|
+
onMouseDown == null ? void 0 : onMouseDown(e);
|
|
278
279
|
} : onPressIn,
|
|
279
280
|
onClick: attachPress ? (e) => {
|
|
280
|
-
onPress
|
|
281
|
-
onClick
|
|
281
|
+
onPress == null ? void 0 : onPress(e);
|
|
282
|
+
onClick == null ? void 0 : onClick(e);
|
|
282
283
|
unPress();
|
|
283
|
-
onPressOut
|
|
284
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
284
285
|
} : onPressOut
|
|
285
286
|
} : null;
|
|
286
287
|
if (events) {
|
|
@@ -300,7 +301,7 @@ function createComponent(configIn) {
|
|
|
300
301
|
const childEls = spacedChildren({
|
|
301
302
|
children,
|
|
302
303
|
space,
|
|
303
|
-
flexDirection: props.flexDirection || defaultProps
|
|
304
|
+
flexDirection: props.flexDirection || (defaultProps == null ? void 0 : defaultProps.flexDirection),
|
|
304
305
|
isZStack
|
|
305
306
|
});
|
|
306
307
|
let content;
|
|
@@ -322,7 +323,7 @@ function createComponent(configIn) {
|
|
|
322
323
|
viewProps["debug"] = true;
|
|
323
324
|
console.log("\u{1F95A} props in:", props);
|
|
324
325
|
console.log("\u{1F95A} props out:", viewProps);
|
|
325
|
-
console.log(props.onClick
|
|
326
|
+
console.log((_a = props.onClick) == null ? void 0 : _a.toString());
|
|
326
327
|
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls });
|
|
327
328
|
if (isWeb) {
|
|
328
329
|
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
@@ -332,6 +333,7 @@ function createComponent(configIn) {
|
|
|
332
333
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, features, content);
|
|
333
334
|
});
|
|
334
335
|
onConfiguredOnce((conf) => {
|
|
336
|
+
var _a;
|
|
335
337
|
tamaguiConfig = conf;
|
|
336
338
|
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
337
339
|
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
@@ -351,7 +353,7 @@ function createComponent(configIn) {
|
|
|
351
353
|
...component.defaultProps
|
|
352
354
|
};
|
|
353
355
|
if (process.env.NODE_ENV === "development") {
|
|
354
|
-
if (staticConfig.defaultProps
|
|
356
|
+
if ((_a = staticConfig.defaultProps) == null ? void 0 : _a.debug) {
|
|
355
357
|
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
356
358
|
}
|
|
357
359
|
}
|
|
@@ -367,7 +369,7 @@ function createComponent(configIn) {
|
|
|
367
369
|
neverFlatten: true,
|
|
368
370
|
defaultProps: {
|
|
369
371
|
...Component2.defaultProps,
|
|
370
|
-
...conf
|
|
372
|
+
...conf == null ? void 0 : conf.defaultProps
|
|
371
373
|
}
|
|
372
374
|
});
|
|
373
375
|
return Component2;
|
|
@@ -384,10 +386,11 @@ const Spacer = createComponent({
|
|
|
384
386
|
variants: {
|
|
385
387
|
size: {
|
|
386
388
|
"...size": (size, { tokens }) => {
|
|
389
|
+
var _a, _b;
|
|
387
390
|
size = size == true ? "$true" : size;
|
|
388
391
|
return {
|
|
389
|
-
width: tokens.size[size]
|
|
390
|
-
height: tokens.size[size]
|
|
392
|
+
width: (_a = tokens.size[size]) != null ? _a : size,
|
|
393
|
+
height: (_b = tokens.size[size]) != null ? _b : size
|
|
391
394
|
};
|
|
392
395
|
}
|
|
393
396
|
},
|
|
@@ -407,6 +410,7 @@ function spacedChildren({
|
|
|
407
410
|
space,
|
|
408
411
|
flexDirection
|
|
409
412
|
}) {
|
|
413
|
+
var _a, _b;
|
|
410
414
|
if (!space && !isZStack) {
|
|
411
415
|
return children;
|
|
412
416
|
}
|
|
@@ -420,11 +424,11 @@ function spacedChildren({
|
|
|
420
424
|
if (child === null || child === void 0) {
|
|
421
425
|
continue;
|
|
422
426
|
}
|
|
423
|
-
const key = `${child
|
|
427
|
+
const key = `${(_a = child == null ? void 0 : child["key"]) != null ? _a : index}`;
|
|
424
428
|
next.push(/* @__PURE__ */ React.createElement(Fragment, {
|
|
425
429
|
key
|
|
426
430
|
}, isZStack ? /* @__PURE__ */ React.createElement(Absolute, null, child) : child));
|
|
427
|
-
if (child
|
|
431
|
+
if ((_b = child == null ? void 0 : child["type"]) == null ? void 0 : _b["isVisuallyHidden"]) {
|
|
428
432
|
continue;
|
|
429
433
|
}
|
|
430
434
|
if (index !== len - 1) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createComponent.tsx"],
|
|
4
4
|
"sourcesContent": ["import { concatClassName, stylePropsView } from '@tamagui/helpers'\nimport { useForceUpdate } from '@tamagui/use-force-update'\nimport React, {\n Children,\n Fragment,\n createElement,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport { StyleSheet, Text, View, ViewStyle } from 'react-native'\n\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\nimport { onConfiguredOnce } from './createTamagui'\nimport { addStylesUsingClassname, useStylesAsClassname } from './helpers/addStylesUsingClassname'\nimport { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'\nimport { getSplitStyles } from './helpers/getSplitStyles'\nimport { useFeatures } from './hooks/useFeatures'\nimport { usePressable } from './hooks/usePressable'\nimport { 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 defaultsStyle: any\n let defaultsClassName = ''\n let initialTheme: any\n\n // see onConfiguredOnce below which attaches a name then to this component\n\n const component = forwardRef<View, A>((props: any, forwardedRef) => {\n const forceUpdate = useForceUpdate()\n const features = useFeatures(props, { forceUpdate })\n const 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 element = isWeb\n ? !Component || typeof Component === 'string'\n ? // default to tag, fallback to component (when both strings)\n tag || Component\n : Component\n : Component\n const ReactView = !isWeb ? View : element || (hasTextAncestor ? 'span' : 'div')\n const ReactText = !isWeb ? Text : element || 'span'\n const ViewComponent = isText ? ReactText : ReactView\n\n // styles\n const isHovering = !isTouchDevice && !disabled && pseudos && state.hover\n const isPressing = !disabled && pseudos && state.press\n\n const styles = [\n // parity w react-native-web, only for text in text\n // TODO this should be able to be done w css to replicate after extraction:\n // (.text .text { display: inline-flex; }) (but if they set display we'd need stronger precendence)\n // isText && hasTextAncestor && isWeb ? { display: 'inline-flex' } : null,\n style,\n isHovering ? pseudos.hoverStyle || null : null,\n isPressing ? pseudos.pressStyle || null : null,\n ]\n\n if (isWeb) {\n const stylesClassNames = useStylesAsClassname(styles)\n const classList = isText\n ? [\n defaultsClassName,\n // hasTextAncestor === true && cssText.textHasAncestor,\n // TODO MOVE TO VARIANTS [number] [any]\n // numberOfLines != null && numberOfLines > 1 && cssText.textMultiLine,\n classNames,\n stylesClassNames,\n props.className,\n ]\n : [defaultsClassName, props.className, classNames, stylesClassNames]\n\n // @ts-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 viewProps.className = className\n content = createElement(ViewComponent, viewProps, childEls)\n } else {\n content = createElement(ViewComponent, viewProps, childEls)\n }\n\n const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor\n if (shouldWrapTextAncestor) {\n // from react-native-web\n // @ts-ignore\n content = createElement(TextAncestorContext.Provider, { value: true }, content)\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n viewProps['debug'] = true\n console.log('\uD83E\uDD5A props in:', props)\n console.log('\uD83E\uDD5A props out:', viewProps)\n console.log(props.onClick?.toString())\n // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls })\n // only on browser because node expands it huge\n if (isWeb) {\n console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\n }\n }\n }\n\n return (\n <>\n {features}\n {content}\n </>\n )\n })\n\n // Once configuration is run and all components are registered\n // get default props + className and analyze styles\n onConfiguredOnce((conf) => {\n tamaguiConfig = conf\n initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]\n const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true)\n if (isWeb) {\n if (next.classNames) {\n defaultsClassName += next.classNames + ' '\n }\n defaultsClassName += addStylesUsingClassname([next.style, next.pseudos])\n } else {\n if (!hasWarnedOnce) {\n hasWarnedOnce = true\n console.log('\u26A0\uFE0F TODO account for default styles for media queries')\n }\n }\n // @ts-ignore\n component.defaultProps = {\n ...next.viewProps,\n ...component.defaultProps,\n }\n if (process.env.NODE_ENV === 'development') {\n if (staticConfig.defaultProps?.debug) {\n console.log('tamagui debug component:', next, defaultsClassName, component.defaultProps)\n }\n }\n })\n\n component['staticConfig'] = {\n validStyles: validStyleProps,\n ...staticConfig,\n }\n\n const res = component as any as StaticComponent<A, void>\n\n // add extractable HoC\n res['extractable'] = (Component: any, 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,IAAI;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,
|
|
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,IAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAA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,SAAS,CAAC,UAAU;AACvB,WAAO;AAAA;AAET,QAAM,eAAe,SAAS,QAAQ;AACtC,QAAM,MAAM,aAAa;AACzB,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,qCAAQ,WAAR,YAAkB;AAEjC,SAAK,KAAK,oCAAC,UAAD;AAAA,MAAU;AAAA,OAAW,WAAW,oCAAC,UAAD,MAAW,SAAoB;AAGzE,QAAI,qCAAQ,YAAR,mBAAkB,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
|
}
|
|
@@ -31,6 +31,7 @@ function createTamagui(config) {
|
|
|
31
31
|
defaultActive: config.mediaQueryDefaultActive
|
|
32
32
|
});
|
|
33
33
|
const themeConfig = (() => {
|
|
34
|
+
var _a;
|
|
34
35
|
let cssRules = [];
|
|
35
36
|
const varsByValue = new Map();
|
|
36
37
|
if (isWeb) {
|
|
@@ -68,7 +69,7 @@ function createTamagui(config) {
|
|
|
68
69
|
for (const themeKey in theme) {
|
|
69
70
|
if (isWeb) {
|
|
70
71
|
const val = theme[themeKey];
|
|
71
|
-
const varName = val instanceof Variable ? val.name : varsByValue[val]
|
|
72
|
+
const varName = val instanceof Variable ? val.name : (_a = varsByValue[val]) == null ? void 0 : _a.name;
|
|
72
73
|
vars += `--${themeKey}:${varName ? `var(--${varName});` : `${val}`};`;
|
|
73
74
|
}
|
|
74
75
|
ensureThemeVariable(theme, themeKey);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { getStyleRules } from '@tamagui/helpers'\n\nimport { isWeb } from './constants/platform'\nimport { Variable, createVariable } from './createVariable'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport {
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import { getStyleRules } from '@tamagui/helpers'\n\nimport { isWeb } from './constants/platform'\nimport { Variable, createVariable } from './createVariable'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport { configureMedia } from './hooks/useMedia'\nimport {\n CreateTamaguiConfig,\n GenericTamaguiConfig,\n MediaQueryKey,\n TamaguiInternalConfig,\n TamaguiProviderProps,\n} from './types'\n\nexport type CreateTamaguiProps = TamaguiProviderProps &\n // we omit and re-declare it because we need to allow instantation types to be flexible\n // user then re-defines the types after createTamagui returns the typed object they want\n Omit<GenericTamaguiConfig, 'themes'> & {\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n // for ssr/native, will default to active\n mediaQueryDefaultActive?: MediaQueryKey[]\n }\n\nlet conf: TamaguiInternalConfig | null\n\nexport const getHasConfigured = () => !!conf\n\nexport const getTamagui = () => conf!\nexport const getTokens = () => conf!.tokensParsed\nexport const getThemes = () => conf!.themes\n\ntype ConfigListener = (conf: TamaguiInternalConfig) => void\nconst configListeners = new Set<ConfigListener>()\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf)\n } else {\n configListeners.add(cb)\n }\n}\n\nconst PREFIX = `theme--`\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n config: Conf\n): Conf extends CreateTamaguiConfig<infer A, infer B, infer C, infer D>\n ? TamaguiInternalConfig<A, B, C, D>\n : unknown {\n // config is re-run by the @tamagui/static, dont double validate\n // but cheap to check and not much downside just returning here if parsed\n if (config['parsed']) {\n return config as any\n }\n\n // test env loads a few times as it runs diff tests\n if (conf) {\n console.warn('Called createTamagui twice! Should never do so')\n // throw new Error(`#000 createTamagui called twice`)\n }\n\n configureMedia({\n queries: config.media as any,\n defaultActive: config.mediaQueryDefaultActive,\n })\n\n const themeConfig = (() => {\n let cssRules: string[] = []\n const varsByValue = new Map<string, Variable>()\n\n if (isWeb) {\n // tokens\n let tokenRule = `:root {`\n const addVar = (v: Variable) => {\n varsByValue[v.val] = v\n const rule = `--${v.name}:${typeof v.val === 'number' ? `${v.val}px` : v.val};`\n tokenRule += rule\n }\n\n for (const key in config.tokens) {\n for (const skey in config.tokens[key]) {\n const val = config.tokens[key][skey]\n if (key === 'font') {\n for (const fkey in val) {\n if (fkey === 'family') {\n addVar(val[fkey])\n } else {\n for (const fskey in val[fkey]) {\n addVar(val[fkey][fskey])\n }\n }\n }\n } else {\n addVar(val)\n }\n }\n }\n cssRules.push(`${tokenRule}\\n}`)\n }\n\n // themes\n for (const themeName in config.themes) {\n // to allow using the same theme with diff names, be sure we don't mutate!\n const theme = { ...config.themes[themeName] }\n config.themes[themeName] = theme\n\n let vars = ''\n\n for (const themeKey in theme) {\n if (isWeb) {\n const val = theme[themeKey]\n // TODO sanity check is necessary\n const varName = val instanceof Variable ? val.name : varsByValue[val]?.name\n vars += `--${themeKey}:${varName ? `var(--${varName});` : `${val}`};`\n }\n\n // make sure properly names theme variables\n ensureThemeVariable(theme, themeKey)\n }\n\n if (isWeb) {\n const [themeClassName, parentName] = themeName.includes('-')\n ? themeName.split('-')\n : [themeName, '']\n // tiny hack for now assuming light/dark are typical parentName\n const oppositeName = parentName === 'dark' ? 'light' : 'dark'\n const cssParentSel = parentName ? `.${PREFIX}${parentName}` : ''\n const cssChildSel = `.${PREFIX}${themeClassName}`\n const cssSel = `${cssParentSel} ${cssChildSel}`\n // we need to force specificity\n const cssRule = `${cssSel}, .${PREFIX}${oppositeName} ${cssSel} {\\n${vars}\\n}`\n cssRules.push(cssRule)\n }\n }\n\n varsByValue.clear()\n Object.freeze(cssRules)\n\n return {\n cssRules,\n css: cssRules.join('\\n'),\n }\n })()\n\n // faster lookups token keys become $keys to match input\n const tokensParsed: any = parseTokens(config.tokens)\n\n // we could do this above in theme loop\n // all themes should match key and we just need variable name\n // TODO once w react native we'd want to have a reverse lookup back to value\n const themeParsed: any = {}\n const firstKey = Object.keys(config.themes)[0]\n for (const key in config.themes[firstKey]) {\n // themeParsed[`$${key}`] = config.themes[firstKey][key]\n const val = config.themes[firstKey][key].val\n themeParsed[`$${key}`] = new Variable({ val, name: key })\n }\n\n const next: TamaguiInternalConfig = {\n // @ts-ignore\n shorthands: {},\n ...config,\n Provider: createTamaguiProvider({\n defaultTheme: 'light',\n ...config,\n }),\n themeConfig,\n themeParsed,\n tokensParsed,\n parsed: true,\n getCSS() {\n return `${themeConfig.css}\\n${[...getStyleRules()].join('\\n')}`\n },\n }\n conf = next\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n configListeners.clear()\n }\n\n // @ts-expect-error\n return next\n}\n\nexport function getThemeParentClassName(themeName?: string | null) {\n return `theme-parent ${themeName ? `${PREFIX}${themeName}` : ''}`\n}\n\nconst parseTokens = (tokens: any) => {\n const res: any = {}\n for (const key in tokens) {\n res[key] = {}\n if (key === 'font') {\n for (const family in tokens.font) {\n const obj = {}\n res.font[`$${family}`] = obj\n for (const attrKey in tokens.font[family]) {\n const attr = tokens.font[family][attrKey]\n if (attrKey === 'family') {\n obj[attrKey] = attr\n continue\n }\n obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {\n acc[`$${cur}`] = attr[cur]\n return acc\n }, {})\n }\n }\n continue\n }\n for (const skey in tokens[key]) {\n res[key][`$${skey}`] = tokens[key][skey]\n }\n }\n\n return res\n}\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nfunction ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n if (!(val instanceof Variable)) {\n theme[key] = createVariable({\n name: key,\n val,\n })\n } else {\n if (val.name !== key) {\n // rename to theme name\n theme[key] = createVariable({\n name: key,\n val: val.val,\n })\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AACA;AAsBA,IAAI;AAEG,MAAM,mBAAmB,6BAAM,CAAC,CAAC,MAAR;AAEzB,MAAM,aAAa,6BAAM,MAAN;AACnB,MAAM,YAAY,6BAAM,KAAM,cAAZ;AAClB,MAAM,YAAY,6BAAM,KAAM,QAAZ;AAGzB,MAAM,kBAAkB,IAAI;AACrB,MAAM,mBAAmB,wBAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG;AAAA,SACE;AACL,oBAAgB,IAAI;AAAA;AAAA,GAJQ;AAQhC,MAAM,SAAS;AAER,uBACL,QAGU;AAGV,MAAI,OAAO,WAAW;AACpB,WAAO;AAAA;AAIT,MAAI,MAAM;AACR,YAAQ,KAAK;AAAA;AAIf,iBAAe;AAAA,IACb,SAAS,OAAO;AAAA,IAChB,eAAe,OAAO;AAAA;AAGxB,QAAM,cAAe,OAAM;AArE7B;AAsEI,QAAI,WAAqB;AACzB,UAAM,cAAc,IAAI;AAExB,QAAI,OAAO;AAET,UAAI,YAAY;AAChB,YAAM,SAAS,wBAAC,MAAgB;AAC9B,oBAAY,EAAE,OAAO;AACrB,cAAM,OAAO,KAAK,EAAE,QAAQ,OAAO,EAAE,QAAQ,WAAW,GAAG,EAAE,UAAU,EAAE;AACzE,qBAAa;AAAA,SAHA;AAMf,iBAAW,OAAO,OAAO,QAAQ;AAC/B,mBAAW,QAAQ,OAAO,OAAO,MAAM;AACrC,gBA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AM;AAAA,MACN;AAAA;AAAA,SAEG;AACL,QAAI,IAAI,SAAS,KAAK;AAEpB,YAAM,OAAO,eAAe;AAAA,QAC1B,MAAM;AAAA,QACN,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA;AAZR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTheme.ts"],
|
|
4
|
-
"sourcesContent": ["import { Variable } from './createVariable'\n\ntype GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n
|
|
5
|
-
"mappings": ";;AAIO,MAAM,cAAc,wBACzB,
|
|
4
|
+
"sourcesContent": ["import { Variable } from './createVariable'\n\ntype GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n [K in keyof Theme]: Theme[K] | string | Variable\n} => theme\n"],
|
|
5
|
+
"mappings": ";;AAIO,MAAM,cAAc,wBACzB,UAGG,OAJsB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|