@tamagui/core 1.0.0-alpha.32 → 1.0.0-alpha.39
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/helpers/fixNativeShadow.native.js +23 -19
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
- 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 +1 -1
- 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/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 -9
- package/types/helpers/fixNativeShadow.native.d.ts +1 -1
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -1
|
@@ -2,7 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { isValidElement } from "react";
|
|
4
4
|
const isTamaguiElement = /* @__PURE__ */ __name((child) => {
|
|
5
|
-
|
|
5
|
+
var _a;
|
|
6
|
+
return isValidElement(child) && !!((_a = child.type["staticConfig"]) == null ? void 0 : _a.parsed);
|
|
6
7
|
}, "isTamaguiElement");
|
|
7
8
|
export {
|
|
8
9
|
isTamaguiElement
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/isTamaguiElement.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { isValidElement } from 'react'\n\nexport const isTamaguiElement = (child: any): child is React.ReactElement => {\n return isValidElement(child) && !!child.type['staticConfig']?.parsed\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEO,MAAM,mBAAmB,wBAAC,UAA4C;
|
|
5
|
+
"mappings": ";;AAAA;AAEO,MAAM,mBAAmB,wBAAC,UAA4C;AAF7E;AAGE,SAAO,eAAe,UAAU,CAAC,CAAC,aAAM,KAAK,oBAAX,mBAA4B;AAAA,GADhC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ const themeable = /* @__PURE__ */ __name(function graphql(component) {
|
|
|
17
17
|
return el;
|
|
18
18
|
}, "WithTheme"));
|
|
19
19
|
const withTheme = withThemeComponent;
|
|
20
|
-
withTheme.displayName = `Themed(${component
|
|
20
|
+
withTheme.displayName = `Themed(${(component == null ? void 0 : component.displayName) || (component == null ? void 0 : component.name) || "Anonymous"})`;
|
|
21
21
|
return withTheme;
|
|
22
22
|
}, "graphql");
|
|
23
23
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/themeable.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { ReactElement, forwardRef } from 'react'\n\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: string | null\n themeInverse?: boolean\n}\n\nexport const themeable: ThemeableHOC = function graphql<\n R extends ReactElement<any, any> | null,\n P extends ThemeableProps = {}\n>(component: (props: P) => R) {\n const withThemeComponent = forwardRef(function WithTheme({ themeInverse, ...rest }: P, ref) {\n const el = React.createElement(component, { ...rest, ref } as any) as R\n if (themeInverse) {\n return (<ThemeInverse>{el}</ThemeInverse>) as R\n }\n if (rest.theme) {\n return (<Theme name={rest.theme || null}>{el}</Theme>) as R\n }\n return el\n })\n\n const withTheme: {\n (props: P): R\n displayName: string\n } = withThemeComponent as any\n\n withTheme.displayName = `Themed(${\n (component as any)?.displayName || (component as any)?.name || 'Anonymous'\n })`\n\n return withTheme\n}\n\nexport interface ThemeableHOC {\n <R extends ReactElement<any, any> | null, P extends ThemeableProps = {}>(\n component: (props: P) => R\n ): (props: P) => R\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AAOO,MAAM,YAA0B,wCAGrC,WAA4B;AAC5B,QAAM,qBAAqB,WAAW,0CAAmB,EAAE,iBAAiB,QAAW,KAAK;AAC1F,UAAM,KAAK,MAAM,cAAc,WAAW,KAAK,MAAM;AACrD,QAAI,cAAc;AAChB,aAAQ,oCAAC,cAAD,MAAe;AAAA;AAEzB,QAAI,KAAK,OAAO;AACd,aAAQ,oCAAC,OAAD;AAAA,QAAO,MAAM,KAAK,SAAS;AAAA,SAAO;AAAA;AAE5C,WAAO;AAAA,KAR6B;AAWtC,QAAM,YAGF;AAEJ,YAAU,cAAc,UACrB,
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AAOO,MAAM,YAA0B,wCAGrC,WAA4B;AAC5B,QAAM,qBAAqB,WAAW,0CAAmB,EAAE,iBAAiB,QAAW,KAAK;AAC1F,UAAM,KAAK,MAAM,cAAc,WAAW,KAAK,MAAM;AACrD,QAAI,cAAc;AAChB,aAAQ,oCAAC,cAAD,MAAe;AAAA;AAEzB,QAAI,KAAK,OAAO;AACd,aAAQ,oCAAC,OAAD;AAAA,QAAO,MAAM,KAAK,SAAS;AAAA,SAAO;AAAA;AAE5C,WAAO;AAAA,KAR6B;AAWtC,QAAM,YAGF;AAEJ,YAAU,cAAc,UACrB,wCAAmB,gBAAgB,wCAAmB,SAAQ;AAGjE,SAAO;AAAA,GAxB8B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,7 +12,8 @@ const addMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
|
12
12
|
mediaQueryListeners[key].add(cb);
|
|
13
13
|
}, "addMediaQueryListener");
|
|
14
14
|
const removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
15
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = mediaQueryListeners[key]) == null ? void 0 : _a.delete(cb);
|
|
16
17
|
}, "removeMediaQueryListener");
|
|
17
18
|
let conf = null;
|
|
18
19
|
const mediaQueryConfig = new Proxy({}, {
|
|
@@ -47,6 +48,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
47
48
|
queries,
|
|
48
49
|
defaultActive = ["sm", "xs"]
|
|
49
50
|
} = {}) => {
|
|
51
|
+
var _a;
|
|
50
52
|
if (conf) {
|
|
51
53
|
console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
|
|
52
54
|
}
|
|
@@ -68,7 +70,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
68
70
|
return;
|
|
69
71
|
mediaState[key] = next;
|
|
70
72
|
const listeners = mediaQueryListeners[key];
|
|
71
|
-
if (listeners
|
|
73
|
+
if (listeners == null ? void 0 : listeners.size) {
|
|
72
74
|
for (const cb of [...listeners]) {
|
|
73
75
|
cb();
|
|
74
76
|
}
|
|
@@ -76,7 +78,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
76
78
|
});
|
|
77
79
|
} catch (err) {
|
|
78
80
|
console.error("Error running media query", str, err.message, err.stack);
|
|
79
|
-
const isDefaultActive = defaultActive
|
|
81
|
+
const isDefaultActive = (_a = defaultActive == null ? void 0 : defaultActive.includes(key)) != null ? _a : true;
|
|
80
82
|
mediaState[key] = isDefaultActive;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useMedia.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n ConfigureMediaQueryOptions,\n MediaQueries,\n MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: { [key in keyof MediaQueryState]: boolean } = {} as any\nconst mediaQueryListeners: { [key: string]: Set<Function> } = {}\n\nexport const addMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n}\n\nexport const removeMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nlet conf: MediaQueries | null = null\n\nexport const mediaQueryConfig = new Proxy<MediaQueries>({} as any, {\n get(target, key) {\n if (!conf) {\n console.warn('Warning: accessing media query before init')\n return null\n }\n return Reflect.get(conf, key)\n },\n ownKeys() {\n if (!conf) {\n console.warn('Warning: accessing media query before init')\n return []\n }\n return Object.keys(conf)\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n})\n\nexport const getMedia = () => {\n if (!conf) {\n throw new Error(`not configured yet`)\n }\n return mediaState\n}\n\nexport const configureMedia = ({\n queries,\n defaultActive = ['sm', 'xs'],\n}: ConfigureMediaQueryOptions = {}) => {\n if (conf) {\n console.warn(\n `Already configured mediaQueries once (you may have called getMedia() before configureMedia())`\n )\n }\n\n if (queries) {\n conf = queries\n }\n\n // setup\n for (const key in queries) {\n const str = mediaObjectToString(queries[key])\n try {\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match || typeof match.addListener !== 'function') {\n // caught below\n throw new Error('\u26A0\uFE0F No match (seeing this in RN sometimes)')\n }\n mediaState[key] = !!match.matches\n match.addListener(() => {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n const listeners = mediaQueryListeners[key]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n })\n } catch (err: any) {\n console.error('Error running media query', str, err.message, err.stack)\n const isDefaultActive = defaultActive?.includes(key as any) ?? true\n mediaState[key] = isDefaultActive\n }\n }\n}\n\ntype UseMediaState = {\n selections: { [key: string]: boolean }\n nextSelections: { [key: string]: boolean }\n isRendering: boolean\n isUnmounted: boolean\n}\n\nexport const useMedia = () => {\n const forceUpdate = useForceUpdate()\n const state = useRef() as React.MutableRefObject<UseMediaState>\n if (!state.current) {\n state.current = {\n selections: {},\n nextSelections: {},\n isUnmounted: false,\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 // delete old\n for (const key in st.selections) {\n if (!(key in st.nextSelections)) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n // add new\n for (const key in st.nextSelections) {\n if (!(key in st.selections)) {\n addMediaQueryListener(key, forceUpdate)\n }\n }\n })\n\n // unmount\n useIsomorphicLayoutEffect(() => {\n return () => {\n const st = state.current\n st.isUnmounted = true\n const allKeys = {\n ...st.selections,\n ...st.nextSelections,\n }\n for (const key in allKeys) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n }, [])\n\n return useConstant(() => {\n const st = state.current\n return new Proxy(mediaState, {\n get(target, key: string) {\n if (!(key in mediaState)) {\n return Reflect.get(target, key)\n }\n if (!st.isUnmounted) {\n if (st.isRendering) {\n st.nextSelections[key] = true\n }\n }\n if (key in mediaState) {\n return mediaState[key]\n }\n return Reflect.get(mediaState, key)\n },\n })\n })\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AACA;AAEA;AACA;AAOA;AAEO,MAAM,aAA0D;AACvE,MAAM,sBAAwD;AAEvD,MAAM,wBAAwB,wBAAC,KAAa,OAAY;AAC7D,sBAAoB,OAAO,oBAAoB,QAAQ,IAAI;AAC3D,sBAAoB,KAAK,IAAI;AAAA,GAFM;AAK9B,MAAM,2BAA2B,wBAAC,KAAa,OAAY;
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAEA;AACA;AAOA;AAEO,MAAM,aAA0D;AACvE,MAAM,sBAA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ClB,eAAG,eAAe,OAAO;AAAA;AAAA;AAG7B,YAAI,OAAO,YAAY;AACrB,iBAAO,WAAW;AAAA;AAEpB,eAAO,QAAQ,IAAI,YAAY;AAAA;AAAA;AAAA;AAAA,GA7Df;AAmExB,uBAAuB,KAAa;AAClC,SAAO,IAAI,QAAQ,UAAU,CAAC,MAAM,IAAI,EAAE,iBAAiB;AAAA;AADpD;AAIF,6BAA6B,OAAkC;AACpE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA;AAET,SAAO,OAAO,QAAQ,OACnB,IAAI,CAAC,CAAC,SAAS,WAAW;AACzB,cAAU,cAAc;AACxB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,IAAI,YAAY;AAAA;AAEzB,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,UAAU;AAChE,cAAQ,GAAG;AAAA;AAEb,WAAO,IAAI,YAAY;AAAA,KAExB,KAAK;AAAA;AAfM;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var _a, _b;
|
|
3
4
|
import { Pressable } from "react-native";
|
|
4
|
-
const getPressable = Pressable
|
|
5
|
+
const getPressable = (_b = (_a = Pressable) == null ? void 0 : _a["type"]) == null ? void 0 : _b["render"];
|
|
5
6
|
const usePressable = /* @__PURE__ */ __name((props) => {
|
|
6
7
|
const out = getPressable(props);
|
|
7
8
|
const { children, style, ...pressableProps } = out.props;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/usePressable.tsx"],
|
|
4
4
|
"sourcesContent": ["import { Pressable, PressableProps } from 'react-native'\n\nconst getPressable = Pressable?.['type']?.['render']\n\nexport const usePressable = (props: PressableProps) => {\n const out = getPressable(props)\n const { children, style, ...pressableProps } = out.props\n return [pressableProps, style] as const\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEA,MAAM,eAAe,
|
|
5
|
+
"mappings": ";;AAAA;AAAA;AAEA,MAAM,eAAe,6CAAY,YAAZ,mBAAsB;AAEpC,MAAM,eAAe,wBAAC,UAA0B;AACrD,QAAM,MAAM,aAAa;AACzB,QAAM,EAAE,UAAU,UAAU,mBAAmB,IAAI;AACnD,SAAO,CAAC,gBAAgB;AAAA,GAHE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,7 +22,7 @@ const useThemeName = /* @__PURE__ */ __name((opts) => {
|
|
|
22
22
|
const [name, setName] = useState(parent.name);
|
|
23
23
|
useIsomorphicLayoutEffect(() => {
|
|
24
24
|
return parent.onChangeTheme((next, manager) => {
|
|
25
|
-
setName(opts
|
|
25
|
+
setName((opts == null ? void 0 : opts.parent) ? manager.parentName : next);
|
|
26
26
|
});
|
|
27
27
|
}, [parent]);
|
|
28
28
|
return name || "light";
|
|
@@ -31,6 +31,7 @@ const useDefaultThemeName = /* @__PURE__ */ __name(() => {
|
|
|
31
31
|
return useContext(ThemeContext)[GET_DEFAULT_THEME];
|
|
32
32
|
}, "useDefaultThemeName");
|
|
33
33
|
const useTheme = /* @__PURE__ */ __name(() => {
|
|
34
|
+
var _a;
|
|
34
35
|
const forceUpdate = useForceUpdate();
|
|
35
36
|
const manager = useContext(ThemeManagerContext);
|
|
36
37
|
const themes = useContext(ThemeContext);
|
|
@@ -54,7 +55,7 @@ const useTheme = /* @__PURE__ */ __name(() => {
|
|
|
54
55
|
useEffect(() => {
|
|
55
56
|
return manager.onUpdate(state.current.uuid, forceUpdate);
|
|
56
57
|
}, []);
|
|
57
|
-
const theme = (manager.name ? themes[manager.name] : themes.light)
|
|
58
|
+
const theme = (_a = manager.name ? themes[manager.name] : themes.light) != null ? _a : themes.light;
|
|
58
59
|
return useMemo(() => {
|
|
59
60
|
return new Proxy(theme, {
|
|
60
61
|
get(_, key) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { Variable } from '../createVariable'\nimport { ThemeName, ThemeObject } from '../types'\nimport { ThemeContext } from '../views/ThemeContext'\nimport { ThemeManagerContext } from '../views/ThemeManagerContext'\nimport { GET_DEFAULT_THEME } from '../views/ThemeProvider'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nconst areEqualSets = (a: Set<string>, b: Set<string>) => {\n if (a.size !== b.size) return false\n for (const val in a) {\n if (!b.has(val)) {\n return false\n }\n }\n return true\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent.name)\n\n useIsomorphicLayoutEffect(() => {\n return parent.onChangeTheme((next, manager) => {\n setName(opts?.parent ? manager.parentName : next)\n })\n }, [parent])\n\n return name || 'light'\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)[GET_DEFAULT_THEME] as any as ThemeName\n}\n\nexport const useTheme = (): ThemeObject => {\n const forceUpdate = useForceUpdate()\n const manager = useContext(ThemeManagerContext)\n const themes = useContext(ThemeContext)\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 = manager.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n manager.track(st.uuid, st.keys)\n }\n })\n\n useEffect(() => {\n return manager.onUpdate(state.current.uuid, forceUpdate)\n }, [])\n\n const theme = (manager.name ? themes[manager.name] : themes.light) ?? themes.light\n\n return useMemo(\n () => {\n return new Proxy(theme, {\n get(_, key: string) {\n const name = manager.name\n if (!name) {\n return Reflect.get(_, key)\n }\n let activeTheme = themes[name]\n if (!activeTheme) {\n console.error('No theme by name', name, 'only:', themes, 'keeping current theme')\n activeTheme = theme\n }\n const val = activeTheme[key]\n if (process.env.NODE_ENV === 'development') {\n if (typeof val === 'undefined') {\n console.warn(`No theme value \"${String(key)}\" in`, activeTheme, themes)\n return null\n }\n if (!(val instanceof Variable)) {\n console.warn('Non variable!', val)\n }\n if (val.name !== key) {\n console.warn('Non-matching name for variable to key', key, val.name)\n }\n }\n if (state.current.isRendering) {\n state.current.keys.add(key)\n }\n return val\n },\n })\n },\n [\n /* if concurrent mode wanted put manager.name here */\n ]\n )\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAQA,MAAM,eAAe,wBAAC,GAAgB,MAAmB;AACvD,MAAI,EAAE,SAAS,EAAE;AAAM,WAAO;AAC9B,aAAW,OAAO,GAAG;AACnB,QAAI,CAAC,EAAE,IAAI,MAAM;AACf,aAAO;AAAA;AAAA;AAGX,SAAO;AAAA,GAPY;AAUd,MAAM,eAAe,wBAAC,SAA6B;AACxD,QAAM,SAAS,WAAW;AAC1B,QAAM,CAAC,MAAM,WAAW,SAAS,OAAO;AAExC,4BAA0B,MAAM;AAC9B,WAAO,OAAO,cAAc,CAAC,MAAM,YAAY;AAC7C,cAAQ,
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAQA,MAAM,eAAe,wBAAC,GAAgB,MAAmB;AACvD,MAAI,EAAE,SAAS,EAAE;AAAM,WAAO;AAC9B,aAAW,OAAO,GAAG;AACnB,QAAI,CAAC,EAAE,IAAI,MAAM;AACf,aAAO;AAAA;AAAA;AAGX,SAAO;AAAA,GAPY;AAUd,MAAM,eAAe,wBAAC,SAA6B;AACxD,QAAM,SAAS,WAAW;AAC1B,QAAM,CAAC,MAAM,WAAW,SAAS,OAAO;AAExC,4BAA0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B,oBAAQ,KAAK,mBAAmB,OAAO,YAAY,aAAa;AAChE,mBAAO;AAAA;AAET,cAAI,CAAE,gBAAe,WAAW;AAC9B,oBAAQ,KAAK,iBAAiB;AAAA;AAEhC,cAAI,IAAI,SAAS,KAAK;AACpB,oBAAQ,KAAK,yCAAyC,KAAK,IAAI;AAAA;AAAA;AAGnE,YAAI,MAAM,QAAQ,aAAa;AAC7B,gBAAM,QAAQ,KAAK,IAAI;AAAA;AAEzB,eAAO;AAAA;AAAA;AAAA,KAIb;AAAA,GA/DoB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var _a, _b;
|
|
3
4
|
import React, { createContext } from "react";
|
|
4
5
|
import { rnw } from "../constants/rnw";
|
|
5
6
|
const FallbackNativeContext = createContext(false);
|
|
6
|
-
const TextAncestorContext = rnw
|
|
7
|
+
const TextAncestorContext = (_b = (_a = rnw) == null ? void 0 : _a.TextAncestorContext) != null ? _b : FallbackNativeContext;
|
|
7
8
|
const TextAncestorProvider = /* @__PURE__ */ __name((props) => {
|
|
8
9
|
return /* @__PURE__ */ React.createElement(TextAncestorContext.Provider, {
|
|
9
10
|
value: false
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/TextAncestorContext.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { createContext } from 'react'\n\nimport { rnw } from '../constants/rnw'\n\nexport const FallbackNativeContext = createContext(false)\n\nexport const TextAncestorContext = rnw?.TextAncestorContext ?? FallbackNativeContext\n\nexport const TextAncestorProvider = (props) => {\n return <TextAncestorContext.Provider value={false}>{props.children}</TextAncestorContext.Provider>\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AAEO,MAAM,wBAAwB,cAAc;AAE5C,MAAM,sBAAsB,
|
|
5
|
+
"mappings": ";;AAAA;AAAA;AAEA;AAEO,MAAM,wBAAwB,cAAc;AAE5C,MAAM,sBAAsB,uCAAK,wBAAL,YAA4B;AAExD,MAAM,uBAAuB,wBAAC,UAAU;AAC7C,SAAO,oCAAC,oBAAoB,UAArB;AAAA,IAA8B,OAAO;AAAA,KAAQ,MAAM;AAAA,GADxB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Theme.js
CHANGED
|
@@ -7,6 +7,7 @@ import { useConstant } from "../hooks/useConstant";
|
|
|
7
7
|
import { ThemeContext } from "./ThemeContext";
|
|
8
8
|
import { ThemeManager, ThemeManagerContext } from "./ThemeManagerContext";
|
|
9
9
|
const Theme = /* @__PURE__ */ __name((props) => {
|
|
10
|
+
var _a, _b;
|
|
10
11
|
const parent = useContext(ThemeManagerContext);
|
|
11
12
|
const themes = useContext(ThemeContext);
|
|
12
13
|
const [parentName, setParentName] = useState(parent.name || "light");
|
|
@@ -53,7 +54,7 @@ const Theme = /* @__PURE__ */ __name((props) => {
|
|
|
53
54
|
return contents;
|
|
54
55
|
}
|
|
55
56
|
if (name) {
|
|
56
|
-
const color = themes[name]
|
|
57
|
+
const color = (_b = (_a = themes[name]) == null ? void 0 : _a["color"]) == null ? void 0 : _b["variable"];
|
|
57
58
|
return /* @__PURE__ */ React.createElement("div", {
|
|
58
59
|
className: getThemeParentClassName(props.name),
|
|
59
60
|
style: { display: "contents", color }
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { useContext, useState } from 'react'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { getThemeParentClassName } from '../createTamagui'\nimport { useConstant } from '../hooks/useConstant'\nimport { ThemeName } from '../types'\nimport { ThemeContext } from './ThemeContext'\nimport { ThemeManager, ThemeManagerContext } from './ThemeManagerContext'\n\nexport type ThemeProps = {\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n}\n\nexport const Theme = (props: ThemeProps) => {\n const parent = useContext(ThemeManagerContext)\n const themes = useContext(ThemeContext)\n const [parentName, setParentName] = useState(parent.name || 'light')\n if (!themes) {\n console.warn('Error, no themes in context', props)\n return props.children\n }\n\n const nextNameParent = `${props.name}-${parentName}`\n const nextNameParentParent = `${props.name}-${parent.parentName}`\n const name = !props.name\n ? null\n : props.name in themes\n ? props.name\n : nextNameParent in themes\n ? nextNameParent\n : nextNameParentParent in themes\n ? nextNameParentParent\n : null\n const theme = name ? themes[name] : null\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!theme) {\n return null\n }\n const manager = new ThemeManager()\n if (name) {\n manager.setActiveTheme({ name, theme: themes[name], parentName })\n }\n return manager\n })\n\n useIsomorphicLayoutEffect(() => {\n if (!themeManager) {\n return\n }\n if (name) {\n themeManager.setActiveTheme({ name, theme, parentName })\n }\n return parent.onChangeTheme((next) => {\n if (next) {\n themeManager.setActiveTheme({ name: next, theme: themes[next], parentName })\n setParentName(next)\n }\n })\n }, [themes, name, parentName])\n\n if (!name || !theme) {\n return props.children\n }\n\n const contents = themeManager ? (\n <ThemeManagerContext.Provider value={themeManager}>\n {props.children}\n </ThemeManagerContext.Provider>\n ) : (\n props.children\n )\n\n if (isWeb) {\n if (props.disableThemeClass) {\n return contents\n }\n if (name) {\n const color = themes[name]?.['color']?.['variable']\n return (\n <div\n className={getThemeParentClassName(props.name)}\n // in order to provide currentColor, set color by default\n style={{ display: 'contents', color }}\n >\n {contents}\n </div>\n )\n }\n }\n\n return contents\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AACA;AAEA;AACA;AAQO,MAAM,QAAQ,wBAAC,UAAsB;
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AAEA;AACA;AAQO,MAAM,QAAQ,wBAAC,UAAsB;AAf5C;AAgBE,QAAM,SAAS,WAAW;AAC1B,QAAM,SAAS,WAA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7B;AAAA;AAAA;AAMT,SAAO;AAAA,GA7EY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -28,12 +28,13 @@ class ThemeManager {
|
|
|
28
28
|
this.keys.set(uuid, keys);
|
|
29
29
|
}
|
|
30
30
|
update() {
|
|
31
|
+
var _a;
|
|
31
32
|
if (!this.name) {
|
|
32
33
|
this.keys.clear();
|
|
33
34
|
}
|
|
34
35
|
for (const [uuid, keys] of this.keys.entries()) {
|
|
35
36
|
if (keys.size) {
|
|
36
|
-
this.listeners.get(uuid)
|
|
37
|
+
(_a = this.listeners.get(uuid)) == null ? void 0 : _a();
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
this.themeListeners.forEach((cb) => cb(this.name, this));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeManagerContext.tsx"],
|
|
4
4
|
"sourcesContent": ["import { createContext } from 'react'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport class ThemeManager {\n name: string | null = 'light'\n parentName: string | null = null\n keys = new Map<any, Set<string>>()\n listeners = new Map<any, Function>()\n themeListeners = new Set<ThemeListener>()\n theme = null\n\n setActiveTheme({\n name,\n theme,\n parentName,\n }: {\n parentName?: string | null\n name: string | null\n theme?: any\n }) {\n if (name === this.name) return\n this.name = name\n this.theme = theme\n this.parentName = parentName || null\n this.update()\n }\n\n track(uuid: any, keys: Set<string>) {\n if (!this.name) return\n this.keys.set(uuid, keys)\n }\n\n update() {\n if (!this.name) {\n this.keys.clear()\n }\n for (const [uuid, keys] of this.keys.entries()) {\n if (keys.size) {\n this.listeners.get(uuid)?.()\n }\n }\n this.themeListeners.forEach((cb) => cb(this.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n\n onUpdate(uuid: any, cb: Function) {\n this.listeners.set(uuid, cb)\n return () => {\n this.listeners.delete(uuid)\n this.keys.delete(uuid)\n }\n }\n}\n\nexport const ThemeManagerContext = createContext<ThemeManager>(new ThemeManager())\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAIO,mBAAmB;AAAA,EAAnB,cAJP;AAKE,gBAAsB;AACtB,sBAA4B;AAC5B,gBAAO,IAAI;AACX,qBAAY,IAAI;AAChB,0BAAiB,IAAI;AACrB,iBAAQ;AAAA;AAAA,EAER,eAAe;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,KAKC;AACD,QAAI,SAAS,KAAK;AAAM;AACxB,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,aAAa,cAAc;AAChC,SAAK;AAAA;AAAA,EAGP,MAAM,MAAW,MAAmB;AAClC,QAAI,CAAC,KAAK;AAAM;AAChB,SAAK,KAAK,IAAI,MAAM;AAAA;AAAA,EAGtB,SAAS;
|
|
5
|
+
"mappings": ";;AAAA;AAIO,mBAAmB;AAAA,EAAnB,cAJP;AAKE,gBAAsB;AACtB,sBAA4B;AAC5B,gBAAO,IAAI;AACX,qBAAY,IAAI;AAChB,0BAAiB,IAAI;AACrB,iBAAQ;AAAA;AAAA,EAER,eAAe;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,KAKC;AACD,QAAI,SAAS,KAAK;AAAM;AACxB,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,aAAa,cAAc;AAChC,SAAK;AAAA;AAAA,EAGP,MAAM,MAAW,MAAmB;AAClC,QAAI,CAAC,KAAK;AAAM;AAChB,SAAK,KAAK,IAAI,MAAM;AAAA;AAAA,EAGtB,SAAS;AAjCX;AAkCI,QAAI,CAAC,KAAK,MAAM;AACd,WAAK,KAAK;AAAA;AAEZ,eAAW,CAAC,MAAM,SAAS,KAAK,KAAK,WAAW;AAC9C,UAAI,KAAK,MAAM;AACb,mBAAK,UAAU,IAAI,UAAnB;AAAA;AAAA;AAGJ,SAAK,eAAe,QAAQ,CAAC,OAAO,GAAG,KAAK,MAAM;AAAA;AAAA,EAGpD,cAAc,IAAmB;AAC/B,SAAK,eAAe,IAAI;AACxB,WAAO,MAAM;AACX,WAAK,eAAe,OAAO;AAAA;AAAA;AAAA,EAI/B,SAAS,MAAW,IAAc;AAChC,SAAK,UAAU,IAAI,MAAM;AACzB,WAAO,MAAM;AACX,WAAK,UAAU,OAAO;AACtB,WAAK,KAAK,OAAO;AAAA;AAAA;AAAA;AApDhB;AAyDA,MAAM,sBAAsB,cAA4B,IAAI;",
|
|
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 || "");
|
|
@@ -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 });
|
|
@@ -335,6 +336,7 @@ function createComponent(configIn) {
|
|
|
335
336
|
</>;
|
|
336
337
|
});
|
|
337
338
|
onConfiguredOnce((conf) => {
|
|
339
|
+
var _a;
|
|
338
340
|
tamaguiConfig = conf;
|
|
339
341
|
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
340
342
|
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
@@ -354,7 +356,7 @@ function createComponent(configIn) {
|
|
|
354
356
|
...component.defaultProps
|
|
355
357
|
};
|
|
356
358
|
if (process.env.NODE_ENV === "development") {
|
|
357
|
-
if (staticConfig.defaultProps
|
|
359
|
+
if ((_a = staticConfig.defaultProps) == null ? void 0 : _a.debug) {
|
|
358
360
|
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
359
361
|
}
|
|
360
362
|
}
|
|
@@ -370,7 +372,7 @@ function createComponent(configIn) {
|
|
|
370
372
|
neverFlatten: true,
|
|
371
373
|
defaultProps: {
|
|
372
374
|
...Component2.defaultProps,
|
|
373
|
-
...conf
|
|
375
|
+
...conf == null ? void 0 : conf.defaultProps
|
|
374
376
|
}
|
|
375
377
|
});
|
|
376
378
|
return Component2;
|
|
@@ -387,10 +389,11 @@ const Spacer = createComponent({
|
|
|
387
389
|
variants: {
|
|
388
390
|
size: {
|
|
389
391
|
"...size": (size, { tokens }) => {
|
|
392
|
+
var _a, _b;
|
|
390
393
|
size = size == true ? "$true" : size;
|
|
391
394
|
return {
|
|
392
|
-
width: tokens.size[size]
|
|
393
|
-
height: tokens.size[size]
|
|
395
|
+
width: (_a = tokens.size[size]) != null ? _a : size,
|
|
396
|
+
height: (_b = tokens.size[size]) != null ? _b : size
|
|
394
397
|
};
|
|
395
398
|
}
|
|
396
399
|
},
|
|
@@ -410,6 +413,7 @@ function spacedChildren({
|
|
|
410
413
|
space,
|
|
411
414
|
flexDirection
|
|
412
415
|
}) {
|
|
416
|
+
var _a, _b;
|
|
413
417
|
if (!space && !isZStack) {
|
|
414
418
|
return children;
|
|
415
419
|
}
|
|
@@ -423,9 +427,9 @@ function spacedChildren({
|
|
|
423
427
|
if (child === null || child === void 0) {
|
|
424
428
|
continue;
|
|
425
429
|
}
|
|
426
|
-
const key = `${child
|
|
430
|
+
const key = `${(_a = child == null ? void 0 : child["key"]) != null ? _a : index}`;
|
|
427
431
|
next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>);
|
|
428
|
-
if (child
|
|
432
|
+
if ((_b = child == null ? void 0 : child["type"]) == null ? void 0 : _b["isVisuallyHidden"]) {
|
|
429
433
|
continue;
|
|
430
434
|
}
|
|
431
435
|
if (index !== len - 1) {
|
|
@@ -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);
|
|
@@ -9,6 +9,7 @@ const createPropMapper = /* @__PURE__ */ __name((c) => {
|
|
|
9
9
|
let variantsParsed;
|
|
10
10
|
const defaultProps = c.defaultProps || {};
|
|
11
11
|
return (key, value, theme, props) => {
|
|
12
|
+
var _a, _b;
|
|
12
13
|
const conf = getTamagui();
|
|
13
14
|
if (!conf) {
|
|
14
15
|
console.trace("no conf! err");
|
|
@@ -18,9 +19,9 @@ const createPropMapper = /* @__PURE__ */ __name((c) => {
|
|
|
18
19
|
variantsParsed = parseVariants(variants, conf);
|
|
19
20
|
}
|
|
20
21
|
let fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
21
|
-
const variant = variantsParsed
|
|
22
|
+
const variant = variantsParsed == null ? void 0 : variantsParsed[key];
|
|
22
23
|
if (variant && typeof value !== "undefined") {
|
|
23
|
-
const val = value === true ? variant["$true"] || variant["true"] : variant[value]
|
|
24
|
+
const val = value === true ? variant["$true"] || variant["true"] : (_b = (_a = variant[value]) != null ? _a : variant["..."]) != null ? _b : value;
|
|
24
25
|
const res = typeof val === "function" ? val(value, { tokens: conf.tokensParsed, theme, props }) : isObj(val) ? { ...val } : val;
|
|
25
26
|
if (isObj(res)) {
|
|
26
27
|
resolveTokens(res, conf, theme, fontFamily);
|
|
@@ -64,30 +65,31 @@ const resolveTokens = /* @__PURE__ */ __name((res, conf, theme, fontFamily) => {
|
|
|
64
65
|
}
|
|
65
66
|
}, "resolveTokens");
|
|
66
67
|
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, themeParsed }, theme, fontFamily = "$body") => {
|
|
68
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
67
69
|
if (themeParsed[value]) {
|
|
68
70
|
if (isWeb && themeParsed[value].variable) {
|
|
69
71
|
return themeParsed[value].variable;
|
|
70
72
|
} else {
|
|
71
73
|
if (value && value[0] === "$") {
|
|
72
|
-
return theme[`${value.slice(1)}`]
|
|
74
|
+
return ((_a = theme[`${value.slice(1)}`]) == null ? void 0 : _a.val) || ((_b = themeParsed[value]) == null ? void 0 : _b.val);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
let valOrVar;
|
|
77
79
|
if (key === "fontFamily") {
|
|
78
|
-
valOrVar = tokensParsed.font[value]
|
|
80
|
+
valOrVar = ((_c = tokensParsed.font[value]) == null ? void 0 : _c.family) || value;
|
|
79
81
|
}
|
|
80
82
|
if (key === "fontSize") {
|
|
81
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
83
|
+
valOrVar = ((_d = tokensParsed.font[fontFamily]) == null ? void 0 : _d.size[value]) || value;
|
|
82
84
|
}
|
|
83
85
|
if (key === "lineHeight") {
|
|
84
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
86
|
+
valOrVar = ((_e = tokensParsed.font[fontFamily]) == null ? void 0 : _e.lineHeight[value]) || value;
|
|
85
87
|
}
|
|
86
88
|
if (key === "letterSpacing") {
|
|
87
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
89
|
+
valOrVar = ((_f = tokensParsed.font[fontFamily]) == null ? void 0 : _f.letterSpacing[value]) || value;
|
|
88
90
|
}
|
|
89
91
|
if (key === "fontWeight") {
|
|
90
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
92
|
+
valOrVar = ((_g = tokensParsed.font[fontFamily]) == null ? void 0 : _g.weight[value]) || value;
|
|
91
93
|
}
|
|
92
94
|
if (typeof valOrVar !== "undefined") {
|
|
93
95
|
if (valOrVar instanceof Variable) {
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { createPropMapper } from "./createPropMapper";
|
|
4
4
|
function extendStaticConfig(Component, config = {}) {
|
|
5
|
+
var _a, _b;
|
|
5
6
|
const parent = Component || {};
|
|
6
7
|
if (!parent.staticConfig) {
|
|
7
8
|
parent.staticConfig = {
|
|
@@ -28,8 +29,8 @@ function extendStaticConfig(Component, config = {}) {
|
|
|
28
29
|
isZStack: config.isZStack || parent.staticConfig.isZStack,
|
|
29
30
|
variants,
|
|
30
31
|
isText: config.isText || parent.staticConfig.isText || false,
|
|
31
|
-
neverFlatten: config.neverFlatten
|
|
32
|
-
ensureOverriddenProp: config.ensureOverriddenProp
|
|
32
|
+
neverFlatten: (_a = config.neverFlatten) != null ? _a : parent.staticConfig.neverFlatten,
|
|
33
|
+
ensureOverriddenProp: (_b = config.ensureOverriddenProp) != null ? _b : parent.staticConfig.ensureOverriddenProp,
|
|
33
34
|
validStyles: config.validStyles ? {
|
|
34
35
|
...parent.staticConfig.validStyles,
|
|
35
36
|
...config.validStyles
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const
|
|
3
|
+
const matchRgbaHsla = /(rgba|hsla)\(\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,})\s*\)$/;
|
|
4
4
|
function fixNativeShadow(props) {
|
|
5
|
-
if (props.shadowColor) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
if (!props.shadowColor) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (!props.shadowOffset) {
|
|
9
|
+
props.shadowOffset = {
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if ("shadowOpacity" in props) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const c = `${props.shadowColor}`;
|
|
18
|
+
if ((c[0] === "r" || c[0] === "h") && c[3] === "a") {
|
|
19
|
+
const [_, type, _1, _2, _3, a] = c.match(matchRgbaHsla) || [];
|
|
20
|
+
if (typeof a !== "string") {
|
|
21
|
+
console.warn("invalid", c, type);
|
|
22
|
+
return;
|
|
23
23
|
}
|
|
24
|
+
props.shadowColor = `${type.replace("a", "")}(${_1},${_2},${_3})`;
|
|
25
|
+
props.shadowOpacity = +a;
|
|
26
|
+
} else {
|
|
27
|
+
props.shadowOpacity = 1;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
__name(fixNativeShadow, "fixNativeShadow");
|
|
@@ -34,12 +34,13 @@ function getStylesAtomic(style, avoidCollection = false) {
|
|
|
34
34
|
__name(getStylesAtomic, "getStylesAtomic");
|
|
35
35
|
const importantRegex = /\!important*/g;
|
|
36
36
|
function getAtomicStyle(style, pseudo, avoidCollection) {
|
|
37
|
+
var _a;
|
|
37
38
|
if (style == null || typeof style !== "object") {
|
|
38
39
|
throw new Error(`Wrong style type: "${typeof style}": ${style}`);
|
|
39
40
|
}
|
|
40
41
|
for (const key in borderDefaults) {
|
|
41
42
|
if (key in style) {
|
|
42
|
-
style[borderDefaults[key]] = style[borderDefaults[key]]
|
|
43
|
+
style[borderDefaults[key]] = (_a = style[borderDefaults[key]]) != null ? _a : "solid";
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
const all = generateStyle(style);
|
|
@@ -2,7 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { isValidElement } from "react";
|
|
4
4
|
const isTamaguiElement = /* @__PURE__ */ __name((child) => {
|
|
5
|
-
|
|
5
|
+
var _a;
|
|
6
|
+
return isValidElement(child) && !!((_a = child.type["staticConfig"]) == null ? void 0 : _a.parsed);
|
|
6
7
|
}, "isTamaguiElement");
|
|
7
8
|
export {
|
|
8
9
|
isTamaguiElement
|
|
@@ -15,7 +15,7 @@ const themeable = /* @__PURE__ */ __name(function graphql(component) {
|
|
|
15
15
|
return el;
|
|
16
16
|
}, "WithTheme"));
|
|
17
17
|
const withTheme = withThemeComponent;
|
|
18
|
-
withTheme.displayName = `Themed(${component
|
|
18
|
+
withTheme.displayName = `Themed(${(component == null ? void 0 : component.displayName) || (component == null ? void 0 : component.name) || "Anonymous"})`;
|
|
19
19
|
return withTheme;
|
|
20
20
|
}, "graphql");
|
|
21
21
|
export {
|