@tamagui/core 1.0.1-beta.64 → 1.0.1-beta.67
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 +0 -3
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/ThemeManager.js +1 -1
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/constants/constants.js +1 -1
- package/dist/cjs/constants/constants.js.map +1 -1
- package/dist/cjs/createComponent.js +43 -14
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +13 -9
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/helpers/createTamaguiProvider.js +12 -12
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +15 -9
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +1 -0
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/nativeGestureHandler.js +29 -0
- package/dist/cjs/helpers/nativeGestureHandler.js.map +7 -0
- package/dist/cjs/nativeGestureHandler.native.js +18 -0
- package/dist/cjs/nativeGestureHandler.native.js.map +7 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Theme.js +1 -4
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +3 -2
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/esm/Tamagui.js +0 -3
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/ThemeManager.js +1 -1
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/constants/constants.js +1 -1
- package/dist/esm/constants/constants.js.map +1 -1
- package/dist/esm/createComponent.js +44 -15
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +14 -10
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js +7 -7
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +17 -11
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +1 -0
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/nativeGestureHandler.js +7 -0
- package/dist/esm/helpers/nativeGestureHandler.js.map +7 -0
- package/dist/esm/nativeGestureHandler.native.js +2 -0
- package/dist/esm/nativeGestureHandler.native.js.map +7 -0
- package/dist/esm/views/Theme.js +1 -4
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +3 -2
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/jsx/Tamagui.js +0 -3
- package/dist/jsx/ThemeManager.js +1 -1
- package/dist/jsx/constants/constants.js +1 -1
- package/dist/jsx/createComponent.js +42 -12
- package/dist/jsx/createTamagui.js +14 -10
- package/dist/jsx/helpers/createTamaguiProvider.js +4 -7
- package/dist/jsx/helpers/extendStaticConfig.js +17 -11
- package/dist/jsx/helpers/getSplitStyles.js +1 -0
- package/dist/jsx/helpers/nativeGestureHandler.js +6 -0
- package/dist/jsx/nativeGestureHandler.native.js +1 -0
- package/dist/jsx/views/Theme.js +1 -4
- package/dist/jsx/views/ThemeProvider.js +3 -2
- package/package.json +5 -5
- package/reset.css +12 -7
- package/types/constants/constants.d.ts +1 -1
- package/types/constants/constants.d.ts.map +1 -1
- package/types/createComponent.d.ts +3 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts +7 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/helpers/createTamaguiProvider.d.ts +2 -5
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/types.d.ts +5 -2
- package/types/types.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
package/dist/cjs/views/Theme.js
CHANGED
|
@@ -42,10 +42,7 @@ const Theme = (0, import_react.memo)(/* @__PURE__ */ __name(function Theme2(prop
|
|
|
42
42
|
}
|
|
43
43
|
if (import_platform.isWeb) {
|
|
44
44
|
return /* @__PURE__ */ import_react.default.createElement("span", {
|
|
45
|
-
className: [
|
|
46
|
-
`tui_Theme`,
|
|
47
|
-
...!props.disableThemeClass ? [props.className, className].filter(Boolean) : []
|
|
48
|
-
].join(" "),
|
|
45
|
+
className: (!props.disableThemeClass ? [props.className, className].filter(Boolean) : []).join(" "),
|
|
49
46
|
style: {
|
|
50
47
|
display: "contents",
|
|
51
48
|
color: (_b = (_a = themes[name]) == null ? void 0 : _a.color) == null ? void 0 : _b.toString()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../hooks/useTheme'\nimport { ThemeProps } from '../hooks/useTheme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n props.componentName,\n props\n )\n\n const missingTheme = !themes || !name || !theme\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => (missingTheme ? null : wrapThemeManagerContext(props.children, themeManager)),\n [props.children, themeManager]\n )\n\n if (missingTheme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n if (isWeb) {\n return (\n <span\n className={
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAErC,sBAAsB;AACtB,qCAAwC;AACxC,sBAAqC;AAIrC,qBAAM;AAEC,MAAM,QAAQ,uBAAK,uCAAe,OAAmB;AAV5D;AAWE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,0CACvD,MAAM,MACN,MAAM,eACN,KACF;AAEA,QAAM,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC;AAI1C,QAAM,WAAW,0BACf,MAAO,eAAe,OAAO,4DAAwB,MAAM,UAAU,YAAY,GACjF,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,cAAc;AAChB,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,uBAAO;AACT,WACE,mDAAC;AAAA,MACC,
|
|
4
|
+
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../hooks/useTheme'\nimport { ThemeProps } from '../hooks/useTheme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n props.componentName,\n props\n )\n\n const missingTheme = !themes || !name || !theme\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => (missingTheme ? null : wrapThemeManagerContext(props.children, themeManager)),\n [props.children, themeManager]\n )\n\n if (missingTheme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n if (isWeb) {\n return (\n <span\n className={(!props.disableThemeClass\n ? [props.className, className].filter(Boolean)\n : []\n ).join(' ')}\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </span>\n )\n }\n\n return contents\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAErC,sBAAsB;AACtB,qCAAwC;AACxC,sBAAqC;AAIrC,qBAAM;AAEC,MAAM,QAAQ,uBAAK,uCAAe,OAAmB;AAV5D;AAWE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,0CACvD,MAAM,MACN,MAAM,eACN,KACF;AAEA,QAAM,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC;AAI1C,QAAM,WAAW,0BACf,MAAO,eAAe,OAAO,4DAAwB,MAAM,UAAU,YAAY,GACjF,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,cAAc;AAChB,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,uBAAO;AACT,WACE,mDAAC;AAAA,MACC,WAAY,EAAC,MAAM,oBACf,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAC3C,CAAC,GACH,KAAK,GAAG;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,GA1C0B,QA0CzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -40,9 +40,10 @@ const ThemeProvider = /* @__PURE__ */ __name((props) => {
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
const cn = `${import_constants.THEME_CLASSNAME_PREFIX}${props.defaultTheme}`;
|
|
43
|
-
document.body
|
|
43
|
+
const target = props.themeClassNameOnRoot ? document.documentElement : document.body;
|
|
44
|
+
target.classList.add(cn);
|
|
44
45
|
return () => {
|
|
45
|
-
|
|
46
|
+
target.classList.remove(cn);
|
|
46
47
|
};
|
|
47
48
|
}, [props.defaultTheme, props.disableRootThemeClass]);
|
|
48
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useLayoutEffect, useMemo } from 'react'\n\nimport { getHasConfigured } from '../conf'\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { ThemeContext } from '../ThemeContext'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProviderProps = {\n className?: string\n themes: any\n defaultTheme: string\n disableRootThemeClass?: boolean\n children?: any\n reset?: boolean\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n document.body.classList.add(cn)\n return () => {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAEhD,kBAAiC;AACjC,uBAAuC;AACvC,0BAA6B;AAC7B,mBAAsB;AAGtB,qBAAM;
|
|
4
|
+
"sourcesContent": ["import React, { useLayoutEffect, useMemo } from 'react'\n\nimport { getHasConfigured } from '../conf'\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { ThemeContext } from '../ThemeContext'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProviderProps = {\n className?: string\n themes: any\n defaultTheme: string\n disableRootThemeClass?: boolean\n themeClassNameOnRoot?: boolean\n children?: any\n reset?: boolean\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n const target = props.themeClassNameOnRoot ? document.documentElement : document.body\n target.classList.add(cn)\n return () => {\n target.classList.remove(cn)\n }\n }, [props.defaultTheme, props.disableRootThemeClass])\n }\n\n const themeContext = useMemo(() => {\n return {\n themes: props.themes,\n defaultTheme: props.defaultTheme,\n }\n }, [props.themes])\n\n return (\n <ThemeContext.Provider value={themeContext}>\n <Theme\n className={props.className}\n name={props.defaultTheme}\n disableThemeClass={props.disableRootThemeClass}\n >\n {props.children}\n </Theme>\n </ThemeContext.Provider>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAEhD,kBAAiC;AACjC,uBAAuC;AACvC,0BAA6B;AAC7B,mBAAsB;AAGtB,qBAAM;AAYC,MAAM,gBAAgB,wBAAC,UAA8B;AAC1D,MAAI,CAAC,kCAAiB,GAAG;AACvB,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAGA,MAAI,OAAO,aAAa,aAAa;AACnC,sCAAgB,MAAM;AACpB,UAAI,MAAM,uBAAuB;AAC/B;AAAA,MACF;AACA,YAAM,KAAK,GAAG,0CAAyB,MAAM;AAC7C,YAAM,SAAS,MAAM,uBAAuB,SAAS,kBAAkB,SAAS;AAChF,aAAO,UAAU,IAAI,EAAE;AACvB,aAAO,MAAM;AACX,eAAO,UAAU,OAAO,EAAE;AAAA,MAC5B;AAAA,IACF,GAAG,CAAC,MAAM,cAAc,MAAM,qBAAqB,CAAC;AAAA,EACtD;AAEA,QAAM,eAAe,0BAAQ,MAAM;AACjC,WAAO;AAAA,MACL,QAAQ,MAAM;AAAA,MACd,cAAc,MAAM;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,CAAC;AAEjB,SACE,mDAAC,iCAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,KAC5B,mDAAC;AAAA,IACC,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA,IACZ,mBAAmB,MAAM;AAAA,KAExB,MAAM,QACT,CACF;AAEJ,GAtC6B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Tamagui.js
CHANGED
|
@@ -34,9 +34,6 @@ const getValueFromIdentifier = /* @__PURE__ */ __name((identifier) => {
|
|
|
34
34
|
const setIdentifierValue = /* @__PURE__ */ __name((identifier, value) => {
|
|
35
35
|
identifierToValue.set(identifier, value);
|
|
36
36
|
}, "setIdentifierValue");
|
|
37
|
-
if (!globalThis["Tamagui"]) {
|
|
38
|
-
globalThis["Tamagui"] = Tamagui;
|
|
39
|
-
}
|
|
40
37
|
export {
|
|
41
38
|
Tamagui,
|
|
42
39
|
getValueFromIdentifier,
|
package/dist/esm/Tamagui.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import * as Helpers from '@tamagui/helpers'\n\nimport { getConfig } from './conf'\nimport { rnw } from './constants/rnw'\nimport { getAllSelectors, getAllTransforms, getInsertedRules } from './helpers/insertStyleRule'\n\n// serves a central store for state\n\nclass TamaguiManager {\n rnw = rnw\n Helpers = Helpers\n\n get config() {\n return getConfig()\n }\n\n get insertedRules() {\n return getInsertedRules()\n }\n\n get allSelectors() {\n return getAllSelectors()\n }\n\n get allTransforms() {\n return getAllTransforms()\n }\n\n get identifierToValue() {\n return identifierToValue\n }\n}\n\nexport const Tamagui = new TamaguiManager()\n\nconst identifierToValue = new Map<string, any>()\n\nexport const getValueFromIdentifier = (identifier: string) => {\n return identifierToValue.get(identifier)\n}\n\nexport const setIdentifierValue = (identifier: string, value: any) => {\n identifierToValue.set(identifier, value)\n}\n
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM,eAAe;AAAA,EAArB;AACE,eAAM;AACN,mBAAU;AAAA;AAAA,EAEV,IAAI,SAAS;AACX,WAAO,UAAU;AAAA,EACnB;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,iBAAiB;AAAA,EAC1B;AAAA,EAEA,IAAI,eAAe;AACjB,WAAO,gBAAgB;AAAA,EACzB;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,iBAAiB;AAAA,EAC1B;AAAA,EAEA,IAAI,oBAAoB;AACtB,WAAO;AAAA,EACT;AACF;AAvBM;AAyBC,MAAM,UAAU,IAAI,eAAe;AAE1C,MAAM,oBAAoB,oBAAI,IAAiB;AAExC,MAAM,yBAAyB,wBAAC,eAAuB;AAC5D,SAAO,kBAAkB,IAAI,UAAU;AACzC,GAFsC;AAI/B,MAAM,qBAAqB,wBAAC,YAAoB,UAAe;AACpE,oBAAkB,IAAI,YAAY,KAAK;AACzC,GAFkC;
|
|
4
|
+
"sourcesContent": ["import * as Helpers from '@tamagui/helpers'\n\nimport { getConfig } from './conf'\nimport { rnw } from './constants/rnw'\nimport { getAllSelectors, getAllTransforms, getInsertedRules } from './helpers/insertStyleRule'\n\n// serves a central store for state\n\nclass TamaguiManager {\n rnw = rnw\n Helpers = Helpers\n\n get config() {\n return getConfig()\n }\n\n get insertedRules() {\n return getInsertedRules()\n }\n\n get allSelectors() {\n return getAllSelectors()\n }\n\n get allTransforms() {\n return getAllTransforms()\n }\n\n get identifierToValue() {\n return identifierToValue\n }\n}\n\nexport const Tamagui = new TamaguiManager()\n\nconst identifierToValue = new Map<string, any>()\n\nexport const getValueFromIdentifier = (identifier: string) => {\n return identifierToValue.get(identifier)\n}\n\nexport const setIdentifierValue = (identifier: string, value: any) => {\n identifierToValue.set(identifier, value)\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM,eAAe;AAAA,EAArB;AACE,eAAM;AACN,mBAAU;AAAA;AAAA,EAEV,IAAI,SAAS;AACX,WAAO,UAAU;AAAA,EACnB;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,iBAAiB;AAAA,EAC1B;AAAA,EAEA,IAAI,eAAe;AACjB,WAAO,gBAAgB;AAAA,EACzB;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,iBAAiB;AAAA,EAC1B;AAAA,EAEA,IAAI,oBAAoB;AACtB,WAAO;AAAA,EACT;AACF;AAvBM;AAyBC,MAAM,UAAU,IAAI,eAAe;AAE1C,MAAM,oBAAoB,oBAAI,IAAiB;AAExC,MAAM,yBAAyB,wBAAC,eAAuB;AAC5D,SAAO,kBAAkB,IAAI,UAAU;AACzC,GAFsC;AAI/B,MAAM,qBAAqB,wBAAC,YAAoB,UAAe;AACpE,oBAAkB,IAAI,YAAY,KAAK;AACzC,GAFkC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/ThemeManager.js
CHANGED
|
@@ -185,7 +185,7 @@ class ThemeManager {
|
|
|
185
185
|
__name(ThemeManager, "ThemeManager");
|
|
186
186
|
_getClassName = new WeakSet();
|
|
187
187
|
getClassName_fn = /* @__PURE__ */ __name(function(name) {
|
|
188
|
-
return `${THEME_CLASSNAME_PREFIX}${name}
|
|
188
|
+
return `${THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace("light_", "").replace("dark_", "");
|
|
189
189
|
}, "#getClassName");
|
|
190
190
|
const ThemeManagerContext = createContext(null);
|
|
191
191
|
const emptyManager = new ThemeManager();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ThemeManager.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './constants/constants'\nimport { ThemeObject, Themes } from './types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n}\n\nexport type GetNextThemeProps = {\n themes?: Themes\n name?: string | null\n componentName?: string | null\n reset?: boolean\n}\n\nexport class ThemeManager {\n keys = new Map<any, Set<string>>()\n listeners = new Map<any, Function>()\n themeListeners = new Set<ThemeListener>()\n className: string | null = null\n\n constructor(\n public name: string = '',\n public theme: ThemeObject | null = null,\n public parentManager: ThemeManager | null = null,\n public reset: boolean = false\n ) {\n // find the nearest different parentManager\n let parent = parentManager\n let tries = 0\n while (true) {\n tries++\n if (tries > 10) {\n throw new Error(`Nested 10 of the same theme in a row, likely error`)\n }\n if (!parent) break\n if (parent.name === name) {\n // go up if same\n parent = parent.parentManager\n } else {\n this.parentManager = parent\n break\n }\n }\n }\n\n get parentName() {\n return this.parentManager?.name || null\n }\n\n get fullName(): string {\n return this.getNextTheme().name || this.name || ''\n // const parentName = this.parentManager?.fullName || ''\n // const name = this.name || ''\n // const parts = [...new Set([...`${parentName}_${name}`.split('_')])].filter(Boolean)\n // return parts.join('_')\n }\n\n // gets value going up to parents\n getValue(key: string) {\n let theme = this.theme\n let manager = this as ThemeManager | null\n while (true) {\n if (!theme) return\n if (key in theme) {\n return theme[key]\n }\n manager = this.parentManager\n if (!manager) {\n return\n }\n if (manager.theme === theme) {\n return\n }\n theme = manager.theme\n }\n }\n\n update({ name, theme, className }: SetActiveThemeProps = {}) {\n // className compare on web, avoids light/dark re-renders\n const nameChanged = name !== this.name\n if (!nameChanged) {\n return false\n }\n this.className = className || null\n this.name = name || ''\n this.theme = theme\n this.notifyListeners()\n return true\n }\n\n getNextTheme(props: GetNextThemeProps = {}, debug?: any) {\n const { themes = getThemes(), name, componentName } = props\n\n if (props.reset && name) {\n return {\n name: name,\n theme: themes[name],\n className: this.#getClassName(name),\n }\n }\n\n const parentIsReset = this.parentManager?.reset\n\n if (!name) {\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${this.name}_${componentName}`,\n `${withoutComponentName(this.name)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n const className = this.#getClassName(name)\n return { name, theme: themes[name], className }\n }\n }\n }\n return {\n name: this.name,\n theme: this.theme,\n }\n }\n\n let nextName = name || this.name || ''\n let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName\n\n while (true) {\n if (nextName in themes) {\n break\n }\n nextName = `${parentName}_${name}`\n if (nextName in themes) {\n break\n }\n if (!parentName.includes(THEME_NAME_SEPARATOR)) {\n // not found!\n console.warn('theme not found', name)\n // this happens in next during _document.getInitialProps and has a terrible/non-existent stack trace\n // throw new Error(`Theme not found: ${name}`)\n break\n }\n // go up one\n parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR))\n }\n\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${nextName}_${componentName}`,\n `${withoutComponentName(nextName)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n nextName = name\n }\n }\n }\n\n let theme = themes[nextName]\n if (!theme) {\n theme = themes[`light_${nextName}`]\n }\n\n if (process.env.NODE_ENV === 'development' && debug) {\n console.log('getNextTheme', { props, nextName, parentName }, this)\n }\n\n return {\n name: nextName,\n theme,\n className: this.#getClassName(nextName),\n }\n }\n\n #getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name}
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAEA;AACA;AAmBO,MAAM,aAAa;AAAA,EAMxB,YACS,OAAe,IACf,QAA4B,MAC5B,gBAAqC,MACrC,QAAiB,OACxB;AAJO;AACA;AACA;AACA;AAsJT;AA/JA,gBAAO,oBAAI,IAAsB;AACjC,qBA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aAAa,iBAAiB,OAAO;AACnD,cAAQ,IAAI,gBAAgB,EAAE,OAAO,UAAU,WAAW,GAAG,IAAI;AAAA,IACnE;AAEA,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,WAAW,sBAAK,gCAAL,WAAmB;AAAA,IAChC;AAAA,EACF;AAAA,EAMA,MAAM,MAAW,MAAmB;AAClC,QAAI,CAAC,KAAK;AAAM;AAChB,SAAK,KAAK,IAAI,MAAM,IAAI;AAAA,EAC1B;AAAA,EAEA,kBAAkB;AA/LpB;AAgMI,QAAI,CAAC,KAAK,MAAM;AACd,WAAK,KAAK,MAAM;AAAA,IAClB;AACA,eAAW,CAAC,MAAM,SAAS,KAAK,KAAK,QAAQ,GAAG;AAC9C,UAAI,KAAK,MAAM;AACb,mBAAK,UAAU,IAAI,IAAI,MAAvB;AAAA,MACF;AAAA,IACF;AACA,SAAK,eAAe,QAAQ,CAAC,OAAO,GAAG,KAAK,MAAM,IAAI,CAAC;AAAA,EACzD;AAAA,EAEA,cAAc,IAAmB;AAC/B,SAAK,eAAe,IAAI,EAAE;AAC1B,WAAO,MAAM;AACX,WAAK,eAAe,OAAO,EAAE;AAAA,IAC/B;AAAA,EACF;AAAA,EAEA,SAAS,MAAW,IAAc;AAChC,SAAK,UAAU,IAAI,MAAM,EAAE;AAC3B,WAAO,MAAM;AACX,WAAK,UAAU,OAAO,IAAI;AAC1B,WAAK,KAAK,OAAO,IAAI;AAAA,IACvB;AAAA,EACF;AACF;AAnMa;AAgKX;AAAA,kBAAa,gCAAC,MAAc;AAC1B,SAAO,GAAG,yBAAyB,
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './constants/constants'\nimport { ThemeObject, Themes } from './types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n}\n\nexport type GetNextThemeProps = {\n themes?: Themes\n name?: string | null\n componentName?: string | null\n reset?: boolean\n}\n\nexport class ThemeManager {\n keys = new Map<any, Set<string>>()\n listeners = new Map<any, Function>()\n themeListeners = new Set<ThemeListener>()\n className: string | null = null\n\n constructor(\n public name: string = '',\n public theme: ThemeObject | null = null,\n public parentManager: ThemeManager | null = null,\n public reset: boolean = false\n ) {\n // find the nearest different parentManager\n let parent = parentManager\n let tries = 0\n while (true) {\n tries++\n if (tries > 10) {\n throw new Error(`Nested 10 of the same theme in a row, likely error`)\n }\n if (!parent) break\n if (parent.name === name) {\n // go up if same\n parent = parent.parentManager\n } else {\n this.parentManager = parent\n break\n }\n }\n }\n\n get parentName() {\n return this.parentManager?.name || null\n }\n\n get fullName(): string {\n return this.getNextTheme().name || this.name || ''\n // const parentName = this.parentManager?.fullName || ''\n // const name = this.name || ''\n // const parts = [...new Set([...`${parentName}_${name}`.split('_')])].filter(Boolean)\n // return parts.join('_')\n }\n\n // gets value going up to parents\n getValue(key: string) {\n let theme = this.theme\n let manager = this as ThemeManager | null\n while (true) {\n if (!theme) return\n if (key in theme) {\n return theme[key]\n }\n manager = this.parentManager\n if (!manager) {\n return\n }\n if (manager.theme === theme) {\n return\n }\n theme = manager.theme\n }\n }\n\n update({ name, theme, className }: SetActiveThemeProps = {}) {\n // className compare on web, avoids light/dark re-renders\n const nameChanged = name !== this.name\n if (!nameChanged) {\n return false\n }\n this.className = className || null\n this.name = name || ''\n this.theme = theme\n this.notifyListeners()\n return true\n }\n\n getNextTheme(props: GetNextThemeProps = {}, debug?: any) {\n const { themes = getThemes(), name, componentName } = props\n\n if (props.reset && name) {\n return {\n name: name,\n theme: themes[name],\n className: this.#getClassName(name),\n }\n }\n\n const parentIsReset = this.parentManager?.reset\n\n if (!name) {\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${this.name}_${componentName}`,\n `${withoutComponentName(this.name)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n const className = this.#getClassName(name)\n return { name, theme: themes[name], className }\n }\n }\n }\n return {\n name: this.name,\n theme: this.theme,\n }\n }\n\n let nextName = name || this.name || ''\n let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName\n\n while (true) {\n if (nextName in themes) {\n break\n }\n nextName = `${parentName}_${name}`\n if (nextName in themes) {\n break\n }\n if (!parentName.includes(THEME_NAME_SEPARATOR)) {\n // not found!\n console.warn('theme not found', name)\n // this happens in next during _document.getInitialProps and has a terrible/non-existent stack trace\n // throw new Error(`Theme not found: ${name}`)\n break\n }\n // go up one\n parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR))\n }\n\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${nextName}_${componentName}`,\n `${withoutComponentName(nextName)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n nextName = name\n }\n }\n }\n\n let theme = themes[nextName]\n if (!theme) {\n theme = themes[`light_${nextName}`]\n }\n\n if (process.env.NODE_ENV === 'development' && debug) {\n console.log('getNextTheme', { props, nextName, parentName }, this)\n }\n\n return {\n name: nextName,\n theme,\n className: this.#getClassName(nextName),\n }\n }\n\n #getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace('light_', '').replace('dark_', '')\n }\n\n track(uuid: any, keys: Set<string>) {\n if (!this.name) return\n this.keys.set(uuid, keys)\n }\n\n notifyListeners() {\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 | null>(null)\nexport const emptyManager = new ThemeManager()\n\nconst withoutComponentName = (name: string) => name.replace(/(\\_[A-Z][a-zA-Z]+)+$/g, '')\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAEA;AACA;AAmBO,MAAM,aAAa;AAAA,EAMxB,YACS,OAAe,IACf,QAA4B,MAC5B,gBAAqC,MACrC,QAAiB,OACxB;AAJO;AACA;AACA;AACA;AAsJT;AA/JA,gBAAO,oBAAI,IAAsB;AACjC,qBAAY,oBAAI,IAAmB;AACnC,0BAAiB,oBAAI,IAAmB;AACxC,qBAA2B;AASzB,QAAI,SAAS;AACb,QAAI,QAAQ;AACZ,WAAO,MAAM;AACX;AACA,UAAI,QAAQ,IAAI;AACd,cAAM,IAAI,MAAM,oDAAoD;AAAA,MACtE;AACA,UAAI,CAAC;AAAQ;AACb,UAAI,OAAO,SAAS,MAAM;AAExB,iBAAS,OAAO;AAAA,MAClB,OAAO;AACL,aAAK,gBAAgB;AACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,aAAa;AArDnB;AAsDI,WAAO,YAAK,kBAAL,mBAAoB,SAAQ;AAAA,EACrC;AAAA,EAEA,IAAI,WAAmB;AACrB,WAAO,KAAK,aAAa,EAAE,QAAQ,KAAK,QAAQ;AAAA,EAKlD;AAAA,EAGA,SAAS,KAAa;AACpB,QAAI,QAAQ,KAAK;AACjB,QAAI,UAAU;AACd,WAAO,MAAM;AACX,UAAI,CAAC;AAAO;AACZ,UAAI,OAAO,OAAO;AAChB,eAAO,MAAM;AAAA,MACf;AACA,gBAAU,KAAK;AACf,UAAI,CAAC,SAAS;AACZ;AAAA,MACF;AACA,UAAI,QAAQ,UAAU,OAAO;AAC3B;AAAA,MACF;AACA,cAAQ,QAAQ;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,OAAO,EAAE,MAAM,OAAO,cAAmC,CAAC,GAAG;AAE3D,UAAM,cAAc,SAAS,KAAK;AAClC,QAAI,C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ACF;AAnMa;AAgKX;AAAA,kBAAa,gCAAC,MAAc;AAC1B,SAAO,GAAG,yBAAyB,eAAe,QAAQ,UAAU,EAAE,EAAE,QAAQ,SAAS,EAAE;AAC7F,GAFa;AAqCR,MAAM,sBAAsB,cAAmC,IAAI;AACnE,MAAM,eAAe,IAAI,aAAa;AAE7C,MAAM,uBAAuB,wBAAC,SAAiB,KAAK,QAAQ,yBAAyB,EAAE,GAA1D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/constants/constants.ts"],
|
|
4
|
-
"sourcesContent": ["import { isWeb } from './platform'\n\nexport const THEME_NAME_SEPARATOR = '_'\nexport const THEME_CLASSNAME_PREFIX = `
|
|
4
|
+
"sourcesContent": ["import { isWeb } from './platform'\n\nexport const THEME_NAME_SEPARATOR = '_'\nexport const THEME_CLASSNAME_PREFIX = `t_`\n\nexport const stackDefaultStyles = {\n alignItems: 'stretch',\n flexShrink: 0,\n // more accurately match react-native defaults on web\n ...(isWeb && {\n display: 'flex',\n flexBasis: 'auto',\n boxSizing: 'border-box',\n }),\n}\n"],
|
|
5
5
|
"mappings": "AAAA;AAEO,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAE/B,MAAM,qBAAqB;AAAA,EAChC,YAAY;AAAA,EACZ,YAAY;AAAA,EAEZ,GAAI,SAAS;AAAA,IACX,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,7 +15,7 @@ import React, {
|
|
|
15
15
|
useState
|
|
16
16
|
} from "react";
|
|
17
17
|
import { StyleSheet, Text, View } from "react-native";
|
|
18
|
-
import { onConfiguredOnce } from "./conf";
|
|
18
|
+
import { getConfig, onConfiguredOnce } from "./conf";
|
|
19
19
|
import { stackDefaultStyles } from "./constants/constants";
|
|
20
20
|
import { isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
|
|
21
21
|
import { rnw } from "./constants/rnw";
|
|
@@ -577,7 +577,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
577
577
|
const shouldWrapWithHover = events && attachHover;
|
|
578
578
|
if (shouldWrapWithHover || shouldWrapWithComponentTheme) {
|
|
579
579
|
const themeClassName = shouldWrapWithComponentTheme ? `${theme.className}` : "";
|
|
580
|
-
const hoverClassName = shouldWrapWithHover ? "
|
|
580
|
+
const hoverClassName = shouldWrapWithHover ? "t_Hoverable" : "";
|
|
581
581
|
content = /* @__PURE__ */ React.createElement("span", {
|
|
582
582
|
className: `${hoverClassName} ${themeClassName}`,
|
|
583
583
|
style: {
|
|
@@ -612,7 +612,36 @@ function createComponent(configIn, ParentComponent) {
|
|
|
612
612
|
AnimatedText = (_b = tamaguiConfig.animations) == null ? void 0 : _b.Text;
|
|
613
613
|
AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
|
|
614
614
|
initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
|
|
615
|
-
|
|
615
|
+
const config = getConfig();
|
|
616
|
+
let defaultPropsIn = staticConfig.defaultProps;
|
|
617
|
+
const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
|
|
618
|
+
if (config.defaultProps && parentNames) {
|
|
619
|
+
const len = parentNames.length;
|
|
620
|
+
let prev;
|
|
621
|
+
for (let i = 0; i < len; i++) {
|
|
622
|
+
const n = parentNames[i];
|
|
623
|
+
if (!n)
|
|
624
|
+
continue;
|
|
625
|
+
if (DefaultProps.has(n)) {
|
|
626
|
+
prev = DefaultProps.get(n);
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
const props = config.defaultProps[n];
|
|
630
|
+
if (!props) {
|
|
631
|
+
if (prev) {
|
|
632
|
+
DefaultProps.set(n, prev);
|
|
633
|
+
}
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
prev = mergeProps(prev || {}, props);
|
|
637
|
+
DefaultProps.set(n, prev);
|
|
638
|
+
}
|
|
639
|
+
const ourDefaultsMerged = DefaultProps.get(staticConfig.componentName);
|
|
640
|
+
if (ourDefaultsMerged) {
|
|
641
|
+
defaultPropsIn = mergeProps(defaultPropsIn, ourDefaultsMerged);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
initialSplitStyles = insertSplitStyles(defaultPropsIn, staticConfig, initialTheme, {
|
|
616
645
|
mounted: true,
|
|
617
646
|
hover: false,
|
|
618
647
|
press: false,
|
|
@@ -674,6 +703,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
674
703
|
return res;
|
|
675
704
|
}
|
|
676
705
|
__name(createComponent, "createComponent");
|
|
706
|
+
const DefaultProps = /* @__PURE__ */ new Map();
|
|
677
707
|
const Unspaced = /* @__PURE__ */ __name((props) => {
|
|
678
708
|
return props.children;
|
|
679
709
|
}, "Unspaced");
|
|
@@ -730,11 +760,11 @@ function spacedChildren({
|
|
|
730
760
|
}) {
|
|
731
761
|
const hasSpace = !!(space || spaceFlex);
|
|
732
762
|
const hasSeparator = !(separator === void 0 || separator === null);
|
|
733
|
-
if (!hasSpace && !hasSeparator) {
|
|
763
|
+
if (!hasSpace && !hasSeparator && !isZStack) {
|
|
734
764
|
return children;
|
|
735
765
|
}
|
|
736
766
|
const childrenList = Children.toArray(children);
|
|
737
|
-
if (childrenList.length <= 1) {
|
|
767
|
+
if (childrenList.length <= 1 && !isZStack) {
|
|
738
768
|
return childrenList;
|
|
739
769
|
}
|
|
740
770
|
const final = [];
|
|
@@ -747,6 +777,12 @@ function spacedChildren({
|
|
|
747
777
|
key: index
|
|
748
778
|
}, isZStack ? /* @__PURE__ */ React.createElement(AbsoluteFill, null, child) : child));
|
|
749
779
|
}
|
|
780
|
+
if (isUnspaced(child) && index === 0) {
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (isZStack) {
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
750
786
|
const next = childrenList[index + 1];
|
|
751
787
|
if (next && !isUnspaced(next)) {
|
|
752
788
|
if (separator) {
|
|
@@ -797,17 +833,10 @@ function isUnspaced(child) {
|
|
|
797
833
|
}
|
|
798
834
|
__name(isUnspaced, "isUnspaced");
|
|
799
835
|
function AbsoluteFill(props) {
|
|
800
|
-
return
|
|
801
|
-
|
|
802
|
-
position: "absolute",
|
|
803
|
-
top: 0,
|
|
804
|
-
left: 0,
|
|
805
|
-
right: 0,
|
|
806
|
-
bottom: 0
|
|
807
|
-
}
|
|
808
|
-
}, props.children) : /* @__PURE__ */ React.createElement(View, {
|
|
836
|
+
return /* @__PURE__ */ React.createElement(View, {
|
|
837
|
+
pointerEvents: "box-none",
|
|
809
838
|
style: StyleSheet.absoluteFill
|
|
810
|
-
}, props.
|
|
839
|
+
}, props.children);
|
|
811
840
|
}
|
|
812
841
|
__name(AbsoluteFill, "AbsoluteFill");
|
|
813
842
|
function processIDRefList(idRefList) {
|