@tamagui/core 1.0.1-beta.53 → 1.0.1-beta.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/createComponent.js +16 -2
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +89 -66
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createVariable.js +8 -0
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariables.js +2 -2
- package/dist/cjs/createVariables.js.map +2 -2
- package/dist/cjs/helpers/calc.js +71 -0
- package/dist/cjs/helpers/calc.js.map +7 -0
- package/dist/cjs/helpers/createPropMapper.js +2 -9
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/getSize.js +16 -7
- package/dist/cjs/helpers/getSize.js.map +2 -2
- package/dist/cjs/helpers/getStackSize.js +11 -39
- package/dist/cjs/helpers/getStackSize.js.map +2 -2
- package/dist/cjs/helpers/getTextSize.js +1 -1
- package/dist/cjs/helpers/getTextSize.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +3 -15
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/views/Slot.js +12 -6
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/createComponent.js +16 -3
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +92 -68
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createVariable.js +7 -0
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariables.js +2 -2
- package/dist/esm/createVariables.js.map +2 -2
- package/dist/esm/helpers/calc.js +49 -0
- package/dist/esm/helpers/calc.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +2 -9
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/getSize.js +15 -6
- package/dist/esm/helpers/getSize.js.map +2 -2
- package/dist/esm/helpers/getStackSize.js +10 -36
- package/dist/esm/helpers/getStackSize.js.map +2 -2
- package/dist/esm/helpers/getTextSize.js +1 -1
- package/dist/esm/helpers/getTextSize.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +3 -15
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/views/Slot.js +10 -5
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/jsx/createComponent.js +16 -3
- package/dist/jsx/createTamagui.js +92 -68
- package/dist/jsx/createVariable.js +7 -0
- package/dist/jsx/createVariables.js +2 -2
- package/dist/jsx/helpers/calc.js +48 -0
- package/dist/jsx/helpers/createPropMapper.js +2 -9
- package/dist/jsx/helpers/getSize.js +15 -6
- package/dist/jsx/helpers/getStackSize.js +10 -36
- package/dist/jsx/helpers/getTextSize.js +1 -1
- package/dist/jsx/hooks/useTheme.js +3 -15
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/views/Slot.js +10 -5
- package/package.json +5 -5
- package/reset.css +8 -0
- package/types/Tamagui.d.ts +1 -2
- package/types/Tamagui.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts +2 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createVariable.d.ts +1 -0
- package/types/createVariable.d.ts.map +1 -1
- package/types/helpers/calc.d.ts +12 -0
- package/types/helpers/calc.d.ts.map +1 -0
- package/types/helpers/getSize.d.ts +3 -2
- package/types/helpers/getSize.d.ts.map +1 -1
- package/types/helpers/getStackSize.d.ts +4 -28
- package/types/helpers/getStackSize.d.ts.map +1 -1
- package/types/{nativeGestureHandler.native.d.ts → helpers/nativeGestureHandler.native.d.ts} +0 -0
- package/types/helpers/nativeGestureHandler.native.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/views/Slot.d.ts +1 -0
- package/types/views/Slot.d.ts.map +1 -1
- package/dist/cjs/helpers/nativeGestureHandler.js +0 -29
- package/dist/cjs/helpers/nativeGestureHandler.js.map +0 -7
- package/dist/cjs/nativeGestureHandler.native.js +0 -18
- package/dist/cjs/nativeGestureHandler.native.js.map +0 -7
- package/dist/esm/helpers/nativeGestureHandler.js +0 -7
- package/dist/esm/helpers/nativeGestureHandler.js.map +0 -7
- package/dist/esm/nativeGestureHandler.native.js +0 -2
- package/dist/esm/nativeGestureHandler.native.js.map +0 -7
- package/dist/jsx/helpers/nativeGestureHandler.js +0 -6
- package/dist/jsx/nativeGestureHandler.native.js +0 -1
- package/types/nativeGestureHandler.native.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getSize.ts"],
|
|
4
|
-
"sourcesContent": ["import { getTokens } from '../conf'\nimport { SizeTokens } from '../types'\n\nexport const getSize = (size?: SizeTokens | undefined,
|
|
5
|
-
"mappings": ";;AAAA;AAGO,MAAM,UAAU,wBAAC,MAA+B,
|
|
4
|
+
"sourcesContent": ["import { getTokens } from '../conf'\nimport { SizeTokens, SpaceTokens } from '../types'\n\nexport const getSize = (size?: SizeTokens | undefined, shift = 0, bounds = [0]) => {\n return stepTokenUpOrDown(getTokens().size, size, shift, bounds)\n}\n\nexport const stepTokenUpOrDown = (\n tokens: Object,\n current?: SizeTokens | SpaceTokens | string,\n shift = 0,\n bounds = [0]\n) => {\n const sizeNames = Object.keys(tokens)\n const currentKeyNum = (typeof current === 'string' ? current.replace('$', '') : current) || '4'\n const nextKeyName = `$${+currentKeyNum + shift}`\n const min = bounds[0] ?? 0\n const max = bounds[1] ?? sizeNames.length - 1\n const index = Math.min(max, Math.max(min, sizeNames.indexOf(nextKeyName)))\n const key = sizeNames[index]\n return tokens[key] || tokens['$4']\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGO,MAAM,UAAU,wBAAC,MAA+B,QAAQ,GAAG,SAAS,CAAC,CAAC,MAAM;AACjF,SAAO,kBAAkB,UAAU,EAAE,MAAM,MAAM,OAAO,MAAM;AAChE,GAFuB;AAIhB,MAAM,oBAAoB,wBAC/B,QACA,SACA,QAAQ,GACR,SAAS,CAAC,CAAC,MACR;AAZL;AAaE,QAAM,YAAY,OAAO,KAAK,MAAM;AACpC,QAAM,gBAAiB,QAAO,YAAY,WAAW,QAAQ,QAAQ,KAAK,EAAE,IAAI,YAAY;AAC5F,QAAM,cAAc,IAAI,CAAC,gBAAgB;AACzC,QAAM,MAAM,aAAO,OAAP,YAAa;AACzB,QAAM,MAAM,aAAO,OAAP,YAAa,UAAU,SAAS;AAC5C,QAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,UAAU,QAAQ,WAAW,CAAC,CAAC;AACzE,QAAM,MAAM,UAAU;AACtB,SAAO,OAAO,QAAQ,OAAO;AAC/B,GAdiC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,44 +1,18 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6
|
-
const size = (_c = (_b = (_a = tokens.size[val]) != null ? _a : val) != null ? _b : tokens.size["$4"]) != null ? _c : 14;
|
|
7
|
-
const radius = (_e = (_d = tokens.radius[val]) != null ? _d : tokens.radius["$4"]) != null ? _e : size;
|
|
8
|
-
const sizePx = +(isVariable(size) ? size.val : size);
|
|
9
|
-
const scaleSize = isVariable(size) ? 2 : 1;
|
|
10
|
-
const px = Math.round(sizePx * sizeX);
|
|
11
|
-
const py = Math.round(sizePx * sizeY);
|
|
12
|
-
const font = fonts[props.fontFamily] || fonts["$body"];
|
|
13
|
-
const lineHeights = font.lineHeight;
|
|
14
|
-
const lineHeight = (_f = lineHeights[val]) != null ? _f : lineHeights["$4"];
|
|
15
|
-
const minHeight = Math.round(getVariableValue(lineHeight) + py * scaleSize);
|
|
16
|
-
return {
|
|
17
|
-
px,
|
|
18
|
-
py,
|
|
19
|
-
radius,
|
|
20
|
-
size,
|
|
21
|
-
lineHeight,
|
|
22
|
-
minHeight
|
|
23
|
-
};
|
|
24
|
-
}, "getSizeScaledToFont");
|
|
25
|
-
const createGetStackSize = /* @__PURE__ */ __name((scale) => (val, extras) => {
|
|
3
|
+
import { getSize, stepTokenUpOrDown } from "./getSize";
|
|
4
|
+
const getButtonSize = /* @__PURE__ */ __name((val, { tokens }) => {
|
|
26
5
|
var _a;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
6
|
+
const ySize = getSize(val, 0);
|
|
7
|
+
const xSize = stepTokenUpOrDown(tokens.space, val);
|
|
8
|
+
const radiusToken = (_a = tokens.radius[val]) != null ? _a : tokens.radius["$4"];
|
|
29
9
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
paddingVertical: props.circular ? 0 : py
|
|
10
|
+
paddingHorizontal: xSize,
|
|
11
|
+
height: ySize,
|
|
12
|
+
borderRadius: radiusToken
|
|
34
13
|
};
|
|
35
|
-
}, "
|
|
36
|
-
const buttonScaling = { sizeX: 0.75, sizeY: 0.333 };
|
|
37
|
-
const getButtonSize = createGetStackSize(buttonScaling);
|
|
14
|
+
}, "getButtonSize");
|
|
38
15
|
export {
|
|
39
|
-
|
|
40
|
-
createGetStackSize,
|
|
41
|
-
getButtonSize,
|
|
42
|
-
getSizeScaledToFont
|
|
16
|
+
getButtonSize
|
|
43
17
|
};
|
|
44
18
|
//# sourceMappingURL=getStackSize.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getStackSize.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;
|
|
4
|
+
"sourcesContent": ["import { SizeTokens, VariantSpreadExtras } from '../types'\nimport { getSize, stepTokenUpOrDown } from './getSize'\n\nexport type ScaleVariantExtras = Pick<VariantSpreadExtras<any>, 'tokens' | 'props' | 'fonts'>\n\nexport const getButtonSize = (val: SizeTokens, { tokens }: VariantSpreadExtras<any>) => {\n const ySize = getSize(val, 0)\n const xSize = stepTokenUpOrDown(tokens.space, val)\n const radiusToken = tokens.radius[val] ?? tokens.radius['$4']\n return {\n paddingHorizontal: xSize,\n height: ySize,\n borderRadius: radiusToken,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AACA;AAIO,MAAM,gBAAgB,wBAAC,KAAiB,EAAE,aAAuC;AALxF;AAME,QAAM,QAAQ,QAAQ,KAAK,CAAC;AAC5B,QAAM,QAAQ,kBAAkB,OAAO,OAAO,GAAG;AACjD,QAAM,cAAc,aAAO,OAAO,SAAd,YAAsB,OAAO,OAAO;AACxD,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB,QAAQ;AAAA,IACR,cAAc;AAAA,EAChB;AACF,GAT6B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ const getTextSize = /* @__PURE__ */ __name((val = "$4", { fonts, theme, props })
|
|
|
7
7
|
const font = fonts[family] || fonts["$body"];
|
|
8
8
|
if (!font) {
|
|
9
9
|
console.warn("\u26A0\uFE0F no font found", { family, fontTokens: Object.keys(fonts), val });
|
|
10
|
-
return;
|
|
10
|
+
return {};
|
|
11
11
|
}
|
|
12
12
|
const fontFamily = font.family;
|
|
13
13
|
const fontSize = props.fontSize || font.size[val];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getTextSize.tsx"],
|
|
4
|
-
"sourcesContent": ["import { getVariableValue } from '../createVariable'\nimport { FontSizeTokens, TextProps, VariantSpreadFunction } from '../types'\n\nexport const getTextSize: VariantSpreadFunction<TextProps, FontSizeTokens> = (\n val = '$4',\n { fonts, theme, props }\n) => {\n const family = getVariableValue(props.fontFamily) || '$body'\n const font = fonts[family] || fonts['$body']\n if (!font) {\n console.warn('\u26A0\uFE0F no font found', { family, fontTokens: Object.keys(fonts), val })\n return\n }\n const fontFamily = font.family\n const fontSize = props.fontSize || font.size[val]\n const lineHeight = props.lineHeight || font.lineHeight[val]\n const fontWeight = props.fontWeight || font.weight[val]\n const letterSpacing = props.letterSpacing || font.letterSpacing[val]\n const fontStyle = props.fontStyle || font.style?.[val]\n const textTransform = props.textTransform || font.transform?.[val]\n const color = props.color || font.color?.[val] || theme.color\n return {\n color,\n fontStyle,\n textTransform,\n fontFamily,\n fontWeight,\n letterSpacing,\n fontSize,\n lineHeight,\n } as any\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAGO,MAAM,cAAgE,wBAC3E,MAAM,MACN,EAAE,OAAO,OAAO,YACb;AANL;AAOE,QAAM,SAAS,iBAAiB,MAAM,UAAU,KAAK;AACrD,QAAM,OAAO,MAAM,WAAW,MAAM;AACpC,MAAI,CAAC,MAAM;AACT,YAAQ,KAAK,8BAAoB,EAAE,QAAQ,YAAY,OAAO,KAAK,KAAK,GAAG,IAAI,CAAC;AAChF;AAAA,
|
|
4
|
+
"sourcesContent": ["import { getVariableValue } from '../createVariable'\nimport { FontSizeTokens, TextProps, VariantSpreadFunction } from '../types'\n\nexport const getTextSize: VariantSpreadFunction<TextProps, FontSizeTokens> = (\n val = '$4',\n { fonts, theme, props }\n) => {\n const family = getVariableValue(props.fontFamily) || '$body'\n const font = fonts[family] || fonts['$body']\n if (!font) {\n console.warn('\u26A0\uFE0F no font found', { family, fontTokens: Object.keys(fonts), val })\n return {} as any\n }\n const fontFamily = font.family\n const fontSize = props.fontSize || font.size[val]\n const lineHeight = props.lineHeight || font.lineHeight[val]\n const fontWeight = props.fontWeight || font.weight[val]\n const letterSpacing = props.letterSpacing || font.letterSpacing[val]\n const fontStyle = props.fontStyle || font.style?.[val]\n const textTransform = props.textTransform || font.transform?.[val]\n const color = props.color || font.color?.[val] || theme.color\n return {\n color,\n fontStyle,\n textTransform,\n fontFamily,\n fontWeight,\n letterSpacing,\n fontSize,\n lineHeight,\n } as any\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGO,MAAM,cAAgE,wBAC3E,MAAM,MACN,EAAE,OAAO,OAAO,YACb;AANL;AAOE,QAAM,SAAS,iBAAiB,MAAM,UAAU,KAAK;AACrD,QAAM,OAAO,MAAM,WAAW,MAAM;AACpC,MAAI,CAAC,MAAM;AACT,YAAQ,KAAK,8BAAoB,EAAE,QAAQ,YAAY,OAAO,KAAK,KAAK,GAAG,IAAI,CAAC;AAChF,WAAO,CAAC;AAAA,EACV;AACA,QAAM,aAAa,KAAK;AACxB,QAAM,WAAW,MAAM,YAAY,KAAK,KAAK;AAC7C,QAAM,aAAa,MAAM,cAAc,KAAK,WAAW;AACvD,QAAM,aAAa,MAAM,cAAc,KAAK,OAAO;AACnD,QAAM,gBAAgB,MAAM,iBAAiB,KAAK,cAAc;AAChE,QAAM,YAAY,MAAM,aAAa,YAAK,UAAL,mBAAa;AAClD,QAAM,gBAAgB,MAAM,iBAAiB,YAAK,cAAL,mBAAiB;AAC9D,QAAM,QAAQ,MAAM,SAAS,YAAK,UAAL,mBAAa,SAAQ,MAAM;AACxD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA5B6E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -51,14 +51,11 @@ const useTheme = /* @__PURE__ */ __name((themeName, componentName, props, forceU
|
|
|
51
51
|
get(_, key) {
|
|
52
52
|
if (!name || key === "__proto__" || typeof key === "symbol") {
|
|
53
53
|
if (key === GetThemeManager) {
|
|
54
|
-
if (process.env.NODE_ENV === "development") {
|
|
55
|
-
|
|
56
|
-
console.log("did change", { themeName, didChangeTheme, name, componentName }, themeManager == null ? void 0 : themeManager.parentName);
|
|
57
|
-
}
|
|
54
|
+
if (process.env.NODE_ENV === "development" && (props == null ? void 0 : props.debug)) {
|
|
55
|
+
console.log(">>", { themeName, didChangeTheme, name, componentName }, themeManager);
|
|
58
56
|
}
|
|
59
|
-
if (!didChangeTheme)
|
|
57
|
+
if (!didChangeTheme)
|
|
60
58
|
return null;
|
|
61
|
-
}
|
|
62
59
|
return themeManager;
|
|
63
60
|
}
|
|
64
61
|
return Reflect.get(_, key);
|
|
@@ -66,11 +63,6 @@ const useTheme = /* @__PURE__ */ __name((themeName, componentName, props, forceU
|
|
|
66
63
|
if (typeof key !== "string" || key === "$typeof") {
|
|
67
64
|
return Reflect.get(_, key);
|
|
68
65
|
}
|
|
69
|
-
if (process.env.NODE_ENV === "development") {
|
|
70
|
-
if (key === "__state") {
|
|
71
|
-
return state.current;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
66
|
if (key === "name") {
|
|
75
67
|
return name;
|
|
76
68
|
}
|
|
@@ -96,10 +88,6 @@ const useTheme = /* @__PURE__ */ __name((themeName, componentName, props, forceU
|
|
|
96
88
|
}
|
|
97
89
|
return val;
|
|
98
90
|
}
|
|
99
|
-
if (process.env.NODE_ENV === "development") {
|
|
100
|
-
console.log(`No theme value "${String(key)}" in ${name}`);
|
|
101
|
-
}
|
|
102
|
-
return Reflect.get(_, key);
|
|
103
91
|
}
|
|
104
92
|
});
|
|
105
93
|
}, [name, theme, className, didChangeTheme]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { GetNextThemeProps, ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (process.env.NODE_ENV === 'development'
|
|
5
|
-
"mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAkBO,MAAM,WAAW,wBACtB,WACA,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AAC3B,gBAAI,QAAQ,IAAI,aAAa,
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { GetNextThemeProps, ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (process.env.NODE_ENV === 'development' && props?.debug) {\n console.log('>>', { themeName, didChangeTheme, name, componentName }, themeManager)\n }\n if (!didChangeTheme) return null\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (typeof key !== 'string' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = { name, componentName, themes, reset }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) return null\n return new ThemeManager(next.name, next.theme, parentManager, reset)\n })\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAkBO,MAAM,WAAW,wBACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAO,WAAU,WAAW;AAC9B,cAAQ,IAAI,mBAAgB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC3E;AAAA,EACF;AAEA,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,6CAAc,KAAK,IAAI,GAAG;AACtC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,GAAG,GAAG;AACvC,mDAAc,MAAM,GAAG,MAAM,GAAG;AAAA,IAClC;AAAA,EACF,CAAC;AAED,SAAO,QAAQ,M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O;AAClB,WAAO,IAAI,aAAa,KAAK,MAAM,KAAK,OAAO,eAAe,KAAK;AAAA,EACrE,CAAC;AAED,MAAI,OAAO,aAAa,aAAa;AACnC,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,6BAAM,MAAM;AACd,qBAAa,OAAO,IAAI;AAAA,MAC1B;AACA,aAAO,cAAc,cAAc,MAAM;AACvC,cAAM,QAAO,cAAc,aAAa,eAAe,KAAK;AAC5D,YAAI,CAAC;AAAM;AACX,YAAI,aAAa,OAAO,KAAI,GAAG;AAC7B,sBAAY;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,QAAM,iBAAiB,QAAQ,iBAAiB,KAAK,SAAS,cAAc;AAE5E,SAAO;AAAA,IACL,GAAI,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA9CoC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } f
|
|
|
14
14
|
export * from "./constants/constants";
|
|
15
15
|
export * from "./constants/platform";
|
|
16
16
|
export * from "./constants/rnw";
|
|
17
|
+
export * from "./helpers/calc";
|
|
17
18
|
export * from "./helpers/createShallowUpdate";
|
|
18
19
|
export * from "./helpers/getStackSize";
|
|
19
20
|
export * from "./helpers/getVariantExtras";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
-
"mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Slot.js
CHANGED
|
@@ -52,10 +52,7 @@ function mergeProps(child, slotProps) {
|
|
|
52
52
|
}
|
|
53
53
|
const isHandler = /^on[A-Z]/.test(propName);
|
|
54
54
|
if (isHandler) {
|
|
55
|
-
overrideProps[propName] = (
|
|
56
|
-
childPropValue == null ? void 0 : childPropValue(...args);
|
|
57
|
-
slotPropValue == null ? void 0 : slotPropValue(...args);
|
|
58
|
-
};
|
|
55
|
+
overrideProps[propName] = mergeEvent(childPropValue, slotPropValue);
|
|
59
56
|
} else if (propName === "style") {
|
|
60
57
|
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
61
58
|
} else if (propName === "className") {
|
|
@@ -65,8 +62,16 @@ function mergeProps(child, slotProps) {
|
|
|
65
62
|
return { ...slotProps, ...overrideProps };
|
|
66
63
|
}
|
|
67
64
|
__name(mergeProps, "mergeProps");
|
|
65
|
+
function mergeEvent(a, b) {
|
|
66
|
+
return (...args) => {
|
|
67
|
+
a == null ? void 0 : a(...args);
|
|
68
|
+
b == null ? void 0 : b(...args);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
__name(mergeEvent, "mergeEvent");
|
|
68
72
|
export {
|
|
69
73
|
Slot,
|
|
70
|
-
Slottable
|
|
74
|
+
Slottable,
|
|
75
|
+
mergeEvent
|
|
71
76
|
};
|
|
72
77
|
//# sourceMappingURL=Slot.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Slot.tsx"],
|
|
4
|
-
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\nimport { isWeb } from '../constants/platform'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n const childProps = {\n ...mergeProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return React.cloneElement(children, childProps)\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\n// function isSlottable(child: React.ReactNode): child is React.ReactElement {\n// return React.isValidElement(child)\n// }\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n
|
|
5
|
-
"mappings": ";;AAEA;AACA;AAEA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AACnC,SACE,oCAAC;AAAA,IAAW,GAAG;AAAA,IAAW,KAAK;AAAA,KAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAM,EAAE,aAAa,cAAc;AAEnC,MAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,UAAM,aAAa;AAAA,MACjB,GAAG,WAAW,UAAU,SAAS;AAAA,MACjC,KAAK,YAAY,cAAe,SAAiB,GAAG;AAAA,IACtD;AACA,WAAO,MAAM,aAAa,UAAU,UAAU;AAAA,EAChD;AAEA,SAAO,MAAM,SAAS,MAAM,QAAQ,IAAI,IAAI,MAAM,SAAS,KAAK,IAAI,IAAI;AAC1E,CAAC;AAED,UAAU,cAAc;AAMjB,MAAM,YAAY,wBAAC,EAAE,eAA8C;AACxE,SAAO,0DAAG,QAAS;AACrB,GAFyB;AAYzB,MAAM,WAAW,QACb;AAAA,EACE,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AACb,IACA,CAAC;AAEL,oBAAoB,OAAY,WAAqB;AACnD,QAAM,aAAa,MAAM;AAGzB,QAAM,gBAAgB,EAAE,GAAG,WAAW;
|
|
4
|
+
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\nimport { isWeb } from '../constants/platform'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n const childProps = {\n ...mergeProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return React.cloneElement(children, childProps)\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\n// function isSlottable(child: React.ReactNode): child is React.ReactElement {\n// return React.isValidElement(child)\n// }\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = /^on[A-Z]/.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = mergeEvent(childPropValue, slotPropValue)\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n\nexport function mergeEvent(a?: Function, b?: Function) {\n return (...args: unknown[]) => {\n a?.(...args)\n b?.(...args)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAEA;AACA;AAEA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AACnC,SACE,oCAAC;AAAA,IAAW,GAAG;AAAA,IAAW,KAAK;AAAA,KAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAA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EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,WAAW,GAAG,cAAc;AAC1C;AAvCS;AAyCF,oBAAoB,GAAc,GAAc;AACrD,SAAO,IAAI,SAAoB;AAC7B,2BAAI,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;AALgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,7 +34,7 @@ import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
|
|
|
34
34
|
import { mediaState } from "./hooks/useMedia";
|
|
35
35
|
import { usePressable } from "./hooks/usePressable";
|
|
36
36
|
import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
|
|
37
|
-
import { Slot } from "./views/Slot";
|
|
37
|
+
import { Slot, mergeEvent } from "./views/Slot";
|
|
38
38
|
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
39
39
|
React["keep"];
|
|
40
40
|
const defaultComponentState = {
|
|
@@ -130,12 +130,13 @@ function createComponent(configIn, ParentComponent) {
|
|
|
130
130
|
const isAnimated = !!(useAnimations && props.animation);
|
|
131
131
|
const hasEnterStyle = !!props.enterStyle;
|
|
132
132
|
const hostRef = useRef(null);
|
|
133
|
+
const animationFeatureStylesIn = props.animation ? { ...defaultNativeStyle, ...style } : null;
|
|
133
134
|
const features = useFeatures(props, {
|
|
134
135
|
forceUpdate,
|
|
135
136
|
setStateShallow,
|
|
136
137
|
useAnimations,
|
|
137
138
|
state,
|
|
138
|
-
style:
|
|
139
|
+
style: animationFeatureStylesIn,
|
|
139
140
|
pseudos,
|
|
140
141
|
staticConfig,
|
|
141
142
|
theme,
|
|
@@ -153,6 +154,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
153
154
|
onHoverIn,
|
|
154
155
|
onHoverOut,
|
|
155
156
|
space: spaceProp,
|
|
157
|
+
spaceDirection: _spaceDirection,
|
|
156
158
|
disabled: disabledProp,
|
|
157
159
|
onMouseDown,
|
|
158
160
|
onMouseEnter,
|
|
@@ -511,6 +513,17 @@ function createComponent(configIn, ParentComponent) {
|
|
|
511
513
|
}
|
|
512
514
|
}
|
|
513
515
|
}
|
|
516
|
+
if (process.env.TAMAGUI_TARGET === "native") {
|
|
517
|
+
const attachFocus = !!(pseudos && pseudos.focusStyle || initialPseudos && initialPseudos.focusStyle);
|
|
518
|
+
if (attachFocus) {
|
|
519
|
+
viewProps.onFocus = mergeEvent(viewProps.onFocus, () => {
|
|
520
|
+
setStateShallow({ focus: true });
|
|
521
|
+
});
|
|
522
|
+
viewProps.onBlur = mergeEvent(viewProps.onBlur, () => {
|
|
523
|
+
setStateShallow({ focus: false });
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
514
527
|
content = createElement(elementType, viewProps, childEls);
|
|
515
528
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
516
529
|
if (attachPress && events) {
|
|
@@ -524,7 +537,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
524
537
|
}
|
|
525
538
|
if (process.env.NODE_ENV === "development") {
|
|
526
539
|
if (props["debug"]) {
|
|
527
|
-
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_b = props.className) == null ? void 0 : _b.split(" "), classNamesOut: (_c = viewProps.className) == null ? void 0 : _c.split(" "), events, shouldAttach, ViewComponent: elementType, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme,
|
|
540
|
+
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_b = props.className) == null ? void 0 : _b.split(" "), classNamesOut: (_c = viewProps.className) == null ? void 0 : _c.split(" "), events, shouldAttach, ViewComponent: elementType, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
|
|
528
541
|
}
|
|
529
542
|
}
|
|
530
543
|
if (features.elements.length) {
|
|
@@ -4,6 +4,7 @@ import { configListeners, getHasConfigured, setConfig } from "./conf";
|
|
|
4
4
|
import { THEME_CLASSNAME_PREFIX } from "./constants/constants";
|
|
5
5
|
import { isWeb } from "./constants/platform";
|
|
6
6
|
import { createCSSVariable, createVariable, isVariable } from "./createVariable";
|
|
7
|
+
import { createVariables } from "./createVariables";
|
|
7
8
|
import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
|
|
8
9
|
import { getInsertedRules } from "./helpers/insertStyleRule";
|
|
9
10
|
import { configureMedia } from "./hooks/useMedia";
|
|
@@ -19,41 +20,73 @@ function createTamagui(config) {
|
|
|
19
20
|
if (!config.themes) {
|
|
20
21
|
throw new Error(`No themes provided to Tamagui config`);
|
|
21
22
|
}
|
|
23
|
+
if (!config.fonts) {
|
|
24
|
+
throw new Error(`No fonts defined!`);
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
if (getHasConfigured()) {
|
|
24
|
-
console.warn(
|
|
28
|
+
console.warn(`Warning: createTamagui called twice (maybe HMR)`);
|
|
25
29
|
}
|
|
26
30
|
configureMedia({
|
|
27
31
|
queries: config.media,
|
|
28
32
|
defaultActive: config.mediaQueryDefaultActive
|
|
29
33
|
});
|
|
34
|
+
const fontTokens = createVariables(config.fonts);
|
|
35
|
+
const fontsParsed = (() => {
|
|
36
|
+
const res = {};
|
|
37
|
+
for (const familyName in fontTokens) {
|
|
38
|
+
const definition = fontTokens[familyName];
|
|
39
|
+
const parsed = {};
|
|
40
|
+
for (const attrKey in definition) {
|
|
41
|
+
const attr = definition[attrKey];
|
|
42
|
+
if (attrKey === "family") {
|
|
43
|
+
parsed[attrKey] = attr;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
parsed[attrKey] = {};
|
|
47
|
+
for (const key in attr) {
|
|
48
|
+
let val = attr[key];
|
|
49
|
+
if (val.val[0] === "$") {
|
|
50
|
+
val = val.val;
|
|
51
|
+
}
|
|
52
|
+
parsed[attrKey][`$${key}`] = val;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
res[`$${familyName}`] = parsed;
|
|
56
|
+
}
|
|
57
|
+
return res;
|
|
58
|
+
})();
|
|
30
59
|
const themeConfig = (() => {
|
|
31
|
-
var _a, _b
|
|
60
|
+
var _a, _b;
|
|
32
61
|
const themes = { ...config.themes };
|
|
33
62
|
let cssRules = [];
|
|
34
|
-
const
|
|
63
|
+
const tokensValueToVariable = /* @__PURE__ */ new Map();
|
|
35
64
|
if (isWeb) {
|
|
36
65
|
const tokenRules = /* @__PURE__ */ new Set();
|
|
37
66
|
const addVar = /* @__PURE__ */ __name((v) => {
|
|
38
|
-
|
|
67
|
+
tokensValueToVariable.set(v.val, v);
|
|
39
68
|
const rule = `--${createCSSVariable(v.name, false)}:${typeof v.val === "number" ? `${v.val}px` : v.val}`;
|
|
40
69
|
tokenRules.add(rule);
|
|
41
70
|
}, "addVar");
|
|
42
71
|
for (const key in config.tokens) {
|
|
43
72
|
for (const skey in config.tokens[key]) {
|
|
44
73
|
const val = config.tokens[key][skey];
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
74
|
+
addVar(val);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (const key in fontsParsed) {
|
|
78
|
+
const val = fontsParsed[key];
|
|
79
|
+
for (const fkey in val) {
|
|
80
|
+
if (fkey === "family") {
|
|
81
|
+
addVar(val[fkey]);
|
|
82
|
+
} else {
|
|
83
|
+
for (const fskey in val[fkey]) {
|
|
84
|
+
const fval = val[fkey][fskey];
|
|
85
|
+
if (typeof fval === "string") {
|
|
49
86
|
} else {
|
|
50
|
-
|
|
51
|
-
addVar(val[fkey][fskey]);
|
|
52
|
-
}
|
|
87
|
+
addVar(val[fkey][fskey]);
|
|
53
88
|
}
|
|
54
89
|
}
|
|
55
|
-
} else {
|
|
56
|
-
addVar(val);
|
|
57
90
|
}
|
|
58
91
|
}
|
|
59
92
|
}
|
|
@@ -62,12 +95,13 @@ function createTamagui(config) {
|
|
|
62
95
|
}
|
|
63
96
|
const hasDarkLight = "light" in config.themes && "dark" in config.themes;
|
|
64
97
|
const CNP = `.${THEME_CLASSNAME_PREFIX}`;
|
|
65
|
-
const existing = /* @__PURE__ */ new WeakMap();
|
|
66
98
|
const dedupedThemes = {};
|
|
99
|
+
const existing = /* @__PURE__ */ new WeakMap();
|
|
67
100
|
for (const themeName in themes) {
|
|
68
101
|
const rawTheme = themes[themeName];
|
|
69
102
|
if (existing.has(rawTheme)) {
|
|
70
103
|
const e = existing.get(rawTheme);
|
|
104
|
+
themes[themeName] = e.theme;
|
|
71
105
|
e.names.push(themeName);
|
|
72
106
|
continue;
|
|
73
107
|
}
|
|
@@ -80,33 +114,22 @@ function createTamagui(config) {
|
|
|
80
114
|
names: [themeName],
|
|
81
115
|
theme
|
|
82
116
|
};
|
|
83
|
-
existing.set(
|
|
117
|
+
existing.set(config.themes[themeName], dedupedThemes[themeName]);
|
|
84
118
|
}
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
varName = val.key;
|
|
95
|
-
varVal = val.isFloating ? val.val : createCSSVariable(varName);
|
|
119
|
+
if (isWeb) {
|
|
120
|
+
for (const themeName in dedupedThemes) {
|
|
121
|
+
const { theme, names } = dedupedThemes[themeName];
|
|
122
|
+
let vars = "";
|
|
123
|
+
for (const themeKey in theme) {
|
|
124
|
+
const variable = theme[themeKey];
|
|
125
|
+
let value = null;
|
|
126
|
+
if (variable.isFloating || !tokensValueToVariable.has(variable.val)) {
|
|
127
|
+
value = variable.val;
|
|
96
128
|
} else {
|
|
97
|
-
|
|
98
|
-
varVal = varName ? createCSSVariable(varName) : `${val}`;
|
|
99
|
-
}
|
|
100
|
-
if (process.env.NODE_ENV === "development") {
|
|
101
|
-
if (!varName) {
|
|
102
|
-
console.warn("no var name in theme", themeName, themeKey);
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
129
|
+
value = tokensValueToVariable.get(variable.val).variable;
|
|
105
130
|
}
|
|
106
|
-
vars += `--${themeKey}:${
|
|
131
|
+
vars += `--${themeKey}:${value};`;
|
|
107
132
|
}
|
|
108
|
-
}
|
|
109
|
-
if (isWeb) {
|
|
110
133
|
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
111
134
|
const isDark = themeName.startsWith("dark");
|
|
112
135
|
const selectors = names.map((name) => {
|
|
@@ -120,7 +143,7 @@ function createTamagui(config) {
|
|
|
120
143
|
order.reverse();
|
|
121
144
|
}
|
|
122
145
|
const [stronger, weaker] = order;
|
|
123
|
-
const max = (
|
|
146
|
+
const max = (_a = config.maxDarkLightNesting) != null ? _a : 3;
|
|
124
147
|
new Array(max * 2).fill(void 0).forEach((_, pi) => {
|
|
125
148
|
if (pi % 2 === 1)
|
|
126
149
|
return;
|
|
@@ -133,17 +156,42 @@ function createTamagui(config) {
|
|
|
133
156
|
}
|
|
134
157
|
const rootSep = config.themeClassNameOnRoot ? "" : " ";
|
|
135
158
|
cssRules.push(`${selectors.map((x) => `:root${rootSep}${x}`).join(", ")} {${vars}}`);
|
|
136
|
-
if ((
|
|
159
|
+
if ((_b = config.shouldAddPrefersColorThemes) != null ? _b : true) {
|
|
137
160
|
if (isDarkOrLightBase) {
|
|
138
161
|
cssRules.push(`@media(prefers-color-scheme: ${isDark ? "dark" : "light"}) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
162
|
+
body { background:${theme.background}; color: ${theme.color} }
|
|
163
|
+
:root {${vars} }
|
|
164
|
+
}`);
|
|
142
165
|
}
|
|
143
166
|
}
|
|
144
167
|
}
|
|
145
168
|
}
|
|
146
|
-
|
|
169
|
+
for (const themeName in themes) {
|
|
170
|
+
const cur = [];
|
|
171
|
+
const parents = themeName.split("_").slice(0, -1).map((part) => {
|
|
172
|
+
cur.push(part);
|
|
173
|
+
return cur.join("_");
|
|
174
|
+
});
|
|
175
|
+
if (!parents.length)
|
|
176
|
+
continue;
|
|
177
|
+
themes[themeName] = new Proxy(themes[themeName], {
|
|
178
|
+
get(target, key) {
|
|
179
|
+
if (Reflect.has(target, key)) {
|
|
180
|
+
return Reflect.get(target, key);
|
|
181
|
+
}
|
|
182
|
+
for (let i = parents.length - 1; i >= 0; i--) {
|
|
183
|
+
const parent = themes[parents[i]];
|
|
184
|
+
if (!parent) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (Reflect.has(parent, key)) {
|
|
188
|
+
return Reflect.get(parent, key);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
tokensValueToVariable.clear();
|
|
147
195
|
Object.freeze(cssRules);
|
|
148
196
|
const css = cssRules.join("\n");
|
|
149
197
|
return {
|
|
@@ -153,29 +201,6 @@ function createTamagui(config) {
|
|
|
153
201
|
};
|
|
154
202
|
})();
|
|
155
203
|
const tokensParsed = parseTokens(config.tokens);
|
|
156
|
-
const fontsParsed = (() => {
|
|
157
|
-
if (!config.fonts) {
|
|
158
|
-
throw new Error(`No fonts defined!`);
|
|
159
|
-
}
|
|
160
|
-
const res = {};
|
|
161
|
-
for (const familyName in config.fonts) {
|
|
162
|
-
const family = config.fonts[familyName];
|
|
163
|
-
const parsed = {};
|
|
164
|
-
for (const attrKey in family) {
|
|
165
|
-
const attr = family[attrKey];
|
|
166
|
-
if (attrKey === "family") {
|
|
167
|
-
parsed[attrKey] = attr;
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
parsed[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
171
|
-
acc[`$${cur}`] = attr[cur];
|
|
172
|
-
return acc;
|
|
173
|
-
}, {});
|
|
174
|
-
}
|
|
175
|
-
res[`$${familyName}`] = parsed;
|
|
176
|
-
}
|
|
177
|
-
return res;
|
|
178
|
-
})();
|
|
179
204
|
const getCSS = /* @__PURE__ */ __name(() => {
|
|
180
205
|
return `${themeConfig.css}
|
|
181
206
|
${getInsertedRules().join("\n")}`;
|
|
@@ -231,8 +256,7 @@ function ensureThemeVariable(theme, key) {
|
|
|
231
256
|
theme[key] = createVariable({
|
|
232
257
|
key: themeKey,
|
|
233
258
|
name: themeKey,
|
|
234
|
-
val
|
|
235
|
-
isFloating: true
|
|
259
|
+
val
|
|
236
260
|
});
|
|
237
261
|
} else {
|
|
238
262
|
if (val.name !== themeKey) {
|
|
@@ -44,6 +44,12 @@ function getVariableName(v) {
|
|
|
44
44
|
return v;
|
|
45
45
|
}
|
|
46
46
|
__name(getVariableName, "getVariableName");
|
|
47
|
+
function getVariableVariable(v) {
|
|
48
|
+
if (isVariable(v))
|
|
49
|
+
return v.variable;
|
|
50
|
+
return v;
|
|
51
|
+
}
|
|
52
|
+
__name(getVariableVariable, "getVariableVariable");
|
|
47
53
|
const createCSSVariable = /* @__PURE__ */ __name((nameProp, includeVar = true) => {
|
|
48
54
|
if (process.env.NODE_ENV === "development") {
|
|
49
55
|
if (!nameProp || typeof nameProp !== "string") {
|
|
@@ -60,5 +66,6 @@ export {
|
|
|
60
66
|
createVariable,
|
|
61
67
|
getVariableName,
|
|
62
68
|
getVariableValue,
|
|
69
|
+
getVariableVariable,
|
|
63
70
|
isVariable
|
|
64
71
|
};
|