@tamagui/core 1.0.1-beta.59 → 1.0.1-beta.62
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/Pressability.js +28 -0
- package/dist/cjs/Pressability.js.map +7 -0
- package/dist/cjs/Pressability.native.js +28 -0
- package/dist/cjs/Pressability.native.js.map +7 -0
- package/dist/cjs/createComponent.js +53 -15
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -1
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +34 -15
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createTamaguiProvider.js +3 -3
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +2 -1
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +79 -121
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +29 -15
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +8 -22
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +2 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js +38 -0
- package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiElement.js +2 -8
- package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +40 -0
- package/dist/cjs/helpers/mergeProps.js.map +7 -0
- package/dist/cjs/helpers/pseudos.js +41 -0
- package/dist/cjs/helpers/pseudos.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +2 -2
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +1 -1
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/static.js +2 -0
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +2 -1
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/esm/Pressability.js +5 -0
- package/dist/esm/Pressability.js.map +7 -0
- package/dist/esm/Pressability.native.js +5 -0
- package/dist/esm/Pressability.native.js.map +7 -0
- package/dist/esm/createComponent.js +57 -20
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +1 -1
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +34 -15
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +5 -3
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +65 -119
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +29 -15
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +7 -20
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +2 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js +16 -0
- package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +2 -8
- package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
- package/dist/esm/helpers/mergeProps.js +18 -0
- package/dist/esm/helpers/mergeProps.js.map +7 -0
- package/dist/esm/helpers/pseudos.js +18 -0
- package/dist/esm/helpers/pseudos.js.map +7 -0
- package/dist/esm/helpers/themeable.js +2 -1
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +2 -2
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/static.js +2 -0
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/views/Slot.js +2 -1
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/jsx/Pressability.js +4 -0
- package/dist/jsx/Pressability.native.js +4 -0
- package/dist/jsx/createComponent.js +57 -16
- package/dist/jsx/helpers/createMediaStyle.js +1 -1
- package/dist/jsx/helpers/createPropMapper.js +34 -15
- package/dist/jsx/helpers/createTamaguiProvider.js +2 -2
- package/dist/jsx/helpers/extendStaticConfig.js +5 -3
- package/dist/jsx/helpers/generateAtomicStyles.js +65 -119
- package/dist/jsx/helpers/getSplitStyles.js +29 -15
- package/dist/jsx/helpers/getStylesAtomic.js +7 -20
- package/dist/jsx/helpers/insertStyleRule.js +2 -1
- package/dist/jsx/helpers/isTamaguiComponent.js +15 -0
- package/dist/jsx/helpers/isTamaguiElement.js +2 -8
- package/dist/jsx/helpers/mergeProps.js +17 -0
- package/dist/jsx/helpers/pseudos.js +17 -0
- package/dist/jsx/helpers/themeable.js +2 -1
- package/dist/jsx/hooks/useTheme.js +2 -2
- package/dist/jsx/index.js +5 -0
- package/dist/jsx/static.js +2 -0
- package/dist/jsx/views/Slot.js +2 -1
- package/package.json +5 -6
- package/types/Pressability.d.ts +2 -0
- package/types/Pressability.d.ts.map +1 -0
- package/types/Pressability.native.d.ts +2 -0
- package/types/Pressability.native.d.ts.map +1 -0
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +1 -1
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/createTamaguiProvider.d.ts +1 -1
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts +5 -6
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +2 -2
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +0 -14
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/isTamaguiComponent.d.ts +5 -0
- package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -1
- package/types/helpers/mergeProps.d.ts +2 -0
- package/types/helpers/mergeProps.d.ts.map +1 -0
- package/types/helpers/pseudos.d.ts +15 -0
- package/types/helpers/pseudos.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/index.d.ts +4 -0
- package/types/index.d.ts.map +1 -1
- package/types/static.d.ts +2 -0
- package/types/static.d.ts.map +1 -1
- package/types/types.d.ts +4 -3
- package/types/types.d.ts.map +1 -1
- package/types/views/Slot.d.ts.map +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const mergeProps = /* @__PURE__ */ __name((a, b) => {
|
|
4
|
+
const out = {};
|
|
5
|
+
for (const key in a) {
|
|
6
|
+
if (!(key in b)) {
|
|
7
|
+
out[key] = a[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
for (const key in b) {
|
|
11
|
+
out[key] = b[key];
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}, "mergeProps");
|
|
15
|
+
export {
|
|
16
|
+
mergeProps
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=mergeProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/mergeProps.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Preserves prop ordering, so that the order most closely matches the last spread objects\n * Useful for having { ...defaultProps, ...props } that ensure props ordering is always kept\n *\n * Given:\n * mergeProps({ a: 1, b: 2 }, { b: 1, a: 2 })\n * The final key order will be:\n * b, a\n */\n\nexport const mergeProps = (a: Object, b: Object) => {\n const out = {}\n\n for (const key in a) {\n if (!(key in b)) {\n out[key] = a[key]\n }\n }\n\n for (const key in b) {\n out[key] = b[key]\n }\n\n return out\n}\n"],
|
|
5
|
+
"mappings": ";;AAUO,MAAM,aAAa,wBAAC,GAAW,MAAc;AAClD,QAAM,MAAM,CAAC;AAEb,aAAW,OAAO,GAAG;AACnB,QAAI,CAAE,QAAO,IAAI;AACf,UAAI,OAAO,EAAE;AAAA,IACf;AAAA,EACF;AAEA,aAAW,OAAO,GAAG;AACnB,QAAI,OAAO,EAAE;AAAA,EACf;AAEA,SAAO;AACT,GAd0B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const pseudos = {
|
|
2
|
+
hoverStyle: {
|
|
3
|
+
name: "hover",
|
|
4
|
+
priority: 1
|
|
5
|
+
},
|
|
6
|
+
pressStyle: {
|
|
7
|
+
name: "active",
|
|
8
|
+
priority: 2
|
|
9
|
+
},
|
|
10
|
+
focusStyle: {
|
|
11
|
+
name: "focus",
|
|
12
|
+
priority: 3
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
pseudos
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=pseudos.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/pseudos.ts"],
|
|
4
|
+
"sourcesContent": ["// *0 order matches to *1\n\nexport const pseudos = {\n hoverStyle: {\n name: 'hover',\n priority: 1,\n },\n pressStyle: {\n name: 'active',\n priority: 2,\n },\n focusStyle: {\n name: 'focus',\n priority: 3,\n },\n} as const\n"],
|
|
5
|
+
"mappings": "AAEO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,7 +4,8 @@ import React, { forwardRef } from "react";
|
|
|
4
4
|
import { Theme } from "../views/Theme";
|
|
5
5
|
import { ThemeInverse } from "../views/ThemeInverse";
|
|
6
6
|
function themeable(component, opts) {
|
|
7
|
-
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(
|
|
7
|
+
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(props, ref) {
|
|
8
|
+
const { themeInverse, theme, ...rest } = props;
|
|
8
9
|
const element = React.createElement(component, { ...rest, ref });
|
|
9
10
|
if (themeInverse) {
|
|
10
11
|
return /* @__PURE__ */ React.createElement(ThemeInverse, null, element);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/themeable.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { forwardRef } from 'react'\n\nimport { ThemeName } from '../types'\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: ThemeName | string | null\n themeInverse?: boolean\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(\n { themeInverse, theme, ...rest }
|
|
5
|
-
"mappings": ";;AAAA;AAGA;AACA;AAOO,mBACL,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,
|
|
4
|
+
"sourcesContent": ["import React, { forwardRef } from 'react'\n\nimport { ThemeName } from '../types'\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: ThemeName | string | null\n themeInverse?: boolean\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(props: any, ref) {\n const { themeInverse, theme, ...rest } = props\n const element = React.createElement(component, { ...rest, ref } as any)\n if (themeInverse) {\n return <ThemeInverse>{element}</ThemeInverse>\n }\n if (theme || opts) {\n return (\n <Theme componentName={opts?.componentName} name={(theme as any) || null}>\n {element}\n </Theme>\n )\n }\n return element\n })\n\n const withTheme: any = withThemeComponent\n withTheme.displayName = `Themed(${\n (component as any)?.displayName || (component as any)?.name || 'Anonymous'\n })`\n\n return withTheme as Component extends (props: infer P) => infer R\n ? (\n props: Omit<P, 'theme' | 'themeInverse'> & {\n theme?: ThemeName | null\n themeInverse?: boolean\n }\n ) => R\n : unknown\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGA;AACA;AAOO,mBACL,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,0CAAmB,OAAY,KAAK;AACxE,UAAM,EAAE,cAAc,UAAU,SAAS;AACzC,UAAM,UAAU,MAAM,cAAc,WAAW,EAAE,GAAG,MAAM,IAAI,CAAQ;AACtE,QAAI,cAAc;AAChB,aAAO,oCAAC,oBAAc,OAAQ;AAAA,IAChC;AACA,QAAI,SAAS,MAAM;AACjB,aACE,oCAAC;AAAA,QAAM,eAAe,6BAAM;AAAA,QAAe,MAAO,SAAiB;AAAA,SAChE,OACH;AAAA,IAEJ;AACA,WAAO;AAAA,EACT,GAdsC,YAcrC;AAED,QAAM,YAAiB;AACvB,YAAU,cAAc,UACrB,wCAAmB,gBAAgB,wCAAmB,SAAQ;AAGjE,SAAO;AAQT;AAjCgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
4
4
|
import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { getConfig } from "../conf";
|
|
6
|
-
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
6
|
+
import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
7
7
|
import { areEqualSets } from "../helpers/areEqualSets";
|
|
8
8
|
import { ThemeContext } from "../ThemeContext";
|
|
9
9
|
import { ThemeManager, ThemeManagerContext, emptyManager } from "../ThemeManager";
|
|
@@ -128,7 +128,7 @@ const useChangeThemeEffect = /* @__PURE__ */ __name((name, componentName, props,
|
|
|
128
128
|
return null;
|
|
129
129
|
return new ThemeManager(next.name, next.theme, parentManager, reset);
|
|
130
130
|
});
|
|
131
|
-
if (typeof document !== "undefined") {
|
|
131
|
+
if (!isWeb || typeof document !== "undefined") {
|
|
132
132
|
useLayoutEffect(() => {
|
|
133
133
|
if (!themeManager)
|
|
134
134
|
return;
|
|
@@ -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' && 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,WAC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QAAI,CAAC;AAAQ;AACb,WAAO,OAAO,cAAc,CAAC,MAAM,YAAY;AAC7C,YAAM,QAAO,8BAAM,UAAS,QAAQ,cAAc,OAAO;AACzD,UAAI,CAAC;AAAM;AACX,cAAQ,KAAI;AAAA,IACd,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,CAAC;AAEX,SAAO;AACT,GAd4B;AAgBrB,MAAM,sBAAsB,6BAAM;AAtJzC;AAuJE,SAAO,iBAAW,YAAY,MAAvB,mBAA0B;AACnC,GAFmC;AAI5B,MAAM,uBAAuB,wBAClC,MACA,eACA,OACA,oBACG;AACH,QAAM,QAAQ,SAAS,MAAM;AAC7B,QAAM,gBAAgB,WAAW,mBAAmB,KAAK;AACzD,QAAM,EAAE,WAAW,WAAW,YAAY;AAC1C,QAAM,QAAQ,gCAAO,UAAS;AAC9B,QAAM,gBAAmC,EAAE,MAAM,eAAe,QAAQ,MAAM;AAC9E,QAAM,OAAO,cAAc,aAAa,eAAe,KAAK;AAC5D,QAAM,cAAc,mBAAmB,eAAe;AACtD,QAAM,eAAe,YAAiC,MAAM;AAC1D,QAAI,CAAC;AAAM,aAAO;AAClB,WAAO,IAAI,aAAa,KAAK,MAAM,KAAK,OAAO,eAAe,KAAK;AAAA,EACrE,CAAC;AAED,MAAI,OAAO,aAAa,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 { isWeb, 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 (!isWeb || 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"],
|
|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,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
|
@@ -23,9 +23,13 @@ export * from "./helpers/getExpandedShorthands";
|
|
|
23
23
|
export * from "./helpers/getSize";
|
|
24
24
|
export * from "./helpers/getSplitStyles";
|
|
25
25
|
export * from "./helpers/getStylesAtomic";
|
|
26
|
+
export * from "./helpers/pseudos";
|
|
27
|
+
export * from "./helpers/mergeProps";
|
|
28
|
+
import { expandStyles } from "./helpers/generateAtomicStyles";
|
|
26
29
|
export * from "./helpers/getTextSize";
|
|
27
30
|
export * from "./helpers/isObj";
|
|
28
31
|
export * from "./helpers/isTamaguiElement";
|
|
32
|
+
export * from "./helpers/isTamaguiComponent";
|
|
29
33
|
export * from "./helpers/matchMedia";
|
|
30
34
|
export * from "./helpers/themeable";
|
|
31
35
|
export * from "./helpers/withStaticProperties";
|
|
@@ -51,6 +55,7 @@ export * from "@tamagui/helpers";
|
|
|
51
55
|
export {
|
|
52
56
|
RNWTextProps,
|
|
53
57
|
RNWViewProps,
|
|
58
|
+
expandStyles,
|
|
54
59
|
getConfig,
|
|
55
60
|
getHasConfigured,
|
|
56
61
|
getThemes,
|
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 './insertFont'\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;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;",
|
|
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 './insertFont'\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/pseudos'\nexport * from './helpers/mergeProps'\nexport { expandStyles } from './helpers/generateAtomicStyles'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\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;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;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/static.js
CHANGED
|
@@ -9,6 +9,8 @@ export * from "./hooks/useMedia";
|
|
|
9
9
|
export * from "./hooks/useTheme";
|
|
10
10
|
export * from "./helpers/isObj";
|
|
11
11
|
export * from "./helpers/getStylesAtomic";
|
|
12
|
+
export * from "./helpers/generateAtomicStyles";
|
|
13
|
+
export * from "./helpers/pseudos";
|
|
12
14
|
export * from "./helpers/proxyThemeVariables";
|
|
13
15
|
export * from "./helpers/getSplitStyles";
|
|
14
16
|
export * from "@tamagui/helpers";
|
package/dist/esm/static.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/static.ts"],
|
|
4
|
-
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\n\nexport * from './styled'\nexport * from './createComponent'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createTamagui'\nexport * from './createVariable'\nexport * from './constants/constants'\n\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/proxyThemeVariables'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/rnw'\n\nexport * from './types'\n"],
|
|
5
|
-
"mappings": "AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;",
|
|
4
|
+
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\n\nexport * from './styled'\nexport * from './createComponent'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createTamagui'\nexport * from './createVariable'\nexport * from './constants/constants'\n\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/generateAtomicStyles'\nexport * from './helpers/pseudos'\nexport * from './helpers/proxyThemeVariables'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/rnw'\n\nexport * from './types'\n"],
|
|
5
|
+
"mappings": "AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Slot.js
CHANGED
|
@@ -50,7 +50,7 @@ function mergeProps(child, slotProps) {
|
|
|
50
50
|
propName = pressMap[propName];
|
|
51
51
|
delete overrideProps[propName];
|
|
52
52
|
}
|
|
53
|
-
const isHandler =
|
|
53
|
+
const isHandler = handleRegex.test(propName);
|
|
54
54
|
if (isHandler) {
|
|
55
55
|
overrideProps[propName] = mergeEvent(childPropValue, slotPropValue);
|
|
56
56
|
} else if (propName === "style") {
|
|
@@ -62,6 +62,7 @@ function mergeProps(child, slotProps) {
|
|
|
62
62
|
return { ...slotProps, ...overrideProps };
|
|
63
63
|
}
|
|
64
64
|
__name(mergeProps, "mergeProps");
|
|
65
|
+
const handleRegex = /^on[A-Z]/;
|
|
65
66
|
function mergeEvent(a, b) {
|
|
66
67
|
return (...args) => {
|
|
67
68
|
a == null ? void 0 : a(...args);
|
|
@@ -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 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 =
|
|
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;AACtC,QAAM,cAAc,OAAO,MAAM,SAAS;AAE1C,MAAI,aAAa;AACf,eAAW,OAAO,UAAU;AAC1B,UAAI,OAAO,WAAW;AACpB,kBAAU,SAAS,QAAQ,UAAU;AACrC,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAEA,WAAS,YAAY,YAAY;AAC/B,UAAM,gBAAgB,UAAU;AAChC,UAAM,iBAAiB,WAAW;AAElC,QAAI,eAAe,SAAS,WAAW;AACrC,iBAAW,SAAS;AACpB,aAAO,cAAc;AAAA,IACvB;AAEA,UAAM,YAAY,
|
|
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 = handleRegex.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\nconst handleRegex = /^on[A-Z]/\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,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;AACtC,QAAM,cAAc,OAAO,MAAM,SAAS;AAE1C,MAAI,aAAa;AACf,eAAW,OAAO,UAAU;AAC1B,UAAI,OAAO,WAAW;AACpB,kBAAU,SAAS,QAAQ,UAAU;AACrC,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAEA,WAAS,YAAY,YAAY;AAC/B,UAAM,gBAAgB,UAAU;AAChC,UAAM,iBAAiB,WAAW;AAElC,QAAI,eAAe,SAAS,WAAW;AACrC,iBAAW,SAAS;AACpB,aAAO,cAAc;AAAA,IACvB;AAEA,UAAM,YAAY,YAAY,KAAK,QAAQ;AAE3C,QAAI,WAAW;AACb,oBAAc,YAAY,WAAW,gBAAgB,aAAa;AAAA,IACpE,WAES,aAAa,SAAS;AAC7B,oBAAc,YAAY,EAAE,GAAG,eAAe,GAAG,eAAe;AAAA,IAClE,WAAW,aAAa,aAAa;AACnC,oBAAc,YAAY,CAAC,eAAe,cAAc,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,WAAW,GAAG,cAAc;AAC1C;AAvCS;AAyCT,MAAM,cAAc;AAEb,oBAAoB,GAAc,GAAc;AACrD,SAAO,IAAI,SAAoB;AAC7B,2BAAI,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;AALgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { stylePropsView, validStyles } from "@tamagui/helpers";
|
|
3
|
+
import { composeEventHandlers, stylePropsView, validStyles } from "@tamagui/helpers";
|
|
4
4
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
5
5
|
import React, {
|
|
6
6
|
Children,
|
|
@@ -10,10 +10,11 @@ import React, {
|
|
|
10
10
|
memo,
|
|
11
11
|
useCallback,
|
|
12
12
|
useContext,
|
|
13
|
+
useMemo,
|
|
13
14
|
useRef,
|
|
14
15
|
useState
|
|
15
16
|
} from "react";
|
|
16
|
-
import { StyleSheet, Text,
|
|
17
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
17
18
|
import { onConfiguredOnce } from "./conf";
|
|
18
19
|
import { stackDefaultStyles } from "./constants/constants";
|
|
19
20
|
import { isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
|
|
@@ -22,6 +23,7 @@ import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
|
22
23
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
23
24
|
import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
|
|
24
25
|
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
26
|
+
import { mergeProps } from "./helpers/mergeProps";
|
|
25
27
|
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
26
28
|
import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
|
|
27
29
|
import { useFeatures } from "./hooks/useFeatures";
|
|
@@ -29,6 +31,7 @@ import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
|
|
|
29
31
|
import { mediaState } from "./hooks/useMedia";
|
|
30
32
|
import { usePressable } from "./hooks/usePressable";
|
|
31
33
|
import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
|
|
34
|
+
import { Pressability } from "./Pressability";
|
|
32
35
|
import { Slot, mergeEvent } from "./views/Slot";
|
|
33
36
|
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
34
37
|
React["keep"];
|
|
@@ -93,15 +96,24 @@ function createComponent(configIn, ParentComponent) {
|
|
|
93
96
|
}
|
|
94
97
|
__name(addPseudoToStyles, "addPseudoToStyles");
|
|
95
98
|
const component = forwardRef((propsIn, forwardedRef) => {
|
|
96
|
-
var _a, _b, _c;
|
|
97
|
-
|
|
99
|
+
var _a, _b, _c, _d, _e;
|
|
100
|
+
let props;
|
|
101
|
+
if (tamaguiDefaultProps && !propsIn.asChild) {
|
|
102
|
+
props = mergeProps(tamaguiDefaultProps, propsIn);
|
|
103
|
+
} else {
|
|
104
|
+
props = propsIn;
|
|
105
|
+
}
|
|
98
106
|
const { Component, isText, isZStack } = staticConfig;
|
|
99
107
|
const componentName = props.componentName || staticConfig.componentName;
|
|
100
108
|
const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
|
|
101
109
|
if (process.env.NODE_ENV === "development") {
|
|
102
110
|
if (props["debug"]) {
|
|
103
111
|
console.log("\u26A0\uFE0F", componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
|
|
104
|
-
console.log("props in:", {
|
|
112
|
+
console.log("props in:", {
|
|
113
|
+
propsIn,
|
|
114
|
+
props,
|
|
115
|
+
ordered: Object.keys(props)
|
|
116
|
+
});
|
|
105
117
|
if (props["debug"] === "break")
|
|
106
118
|
debugger;
|
|
107
119
|
}
|
|
@@ -119,7 +131,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
119
131
|
noClassNames: true,
|
|
120
132
|
dynamicStylesInline: true,
|
|
121
133
|
resolveVariablesAs: "value"
|
|
122
|
-
}, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames);
|
|
134
|
+
}, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames, props["debug"]);
|
|
123
135
|
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
124
136
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
125
137
|
const isAnimated = !!(useAnimations && props.animation);
|
|
@@ -333,8 +345,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
333
345
|
}
|
|
334
346
|
internal.current.isMounted = true;
|
|
335
347
|
return () => {
|
|
348
|
+
var _a2;
|
|
336
349
|
mouseUps.delete(unPress);
|
|
337
350
|
internal.current.isMounted = false;
|
|
351
|
+
(_a2 = internal.current.unmountEffects) == null ? void 0 : _a2.forEach((cb) => cb());
|
|
338
352
|
};
|
|
339
353
|
}, [hasEnterStyle, props.animation]);
|
|
340
354
|
let styles;
|
|
@@ -390,7 +404,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
390
404
|
viewProps.style = styles;
|
|
391
405
|
}
|
|
392
406
|
const initialPseudos = initialSplitStyles.pseudos;
|
|
393
|
-
const attachPress = !!(pseudos
|
|
407
|
+
const attachPress = !!((pseudos == null ? void 0 : pseudos.pressStyle) || (initialPseudos == null ? void 0 : initialPseudos.pressStyle) || onPress || onPressOut || onPressIn || onClick);
|
|
394
408
|
const isTouch = useIsTouchDevice();
|
|
395
409
|
const isHoverable = isWeb && !isTouch;
|
|
396
410
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
@@ -459,7 +473,17 @@ function createComponent(configIn, ParentComponent) {
|
|
|
459
473
|
unPress();
|
|
460
474
|
onClick == null ? void 0 : onClick(e);
|
|
461
475
|
onPress == null ? void 0 : onPress(e);
|
|
462
|
-
} : null
|
|
476
|
+
} : null,
|
|
477
|
+
...!isWeb && {
|
|
478
|
+
cancelable: !props.rejectResponderTermination,
|
|
479
|
+
disabled: props.disabled !== null ? props.disabled : (_b = props.accessibilityState) == null ? void 0 : _b.disabled,
|
|
480
|
+
hitSlop: props.hitSlop,
|
|
481
|
+
delayLongPress: props.delayLongPress,
|
|
482
|
+
delayPressIn: props.delayPressIn,
|
|
483
|
+
delayPressOut: props.delayPressOut,
|
|
484
|
+
focusable: (_c = viewProps.focusable) != null ? _c : true,
|
|
485
|
+
minPressDuration: 0
|
|
486
|
+
}
|
|
463
487
|
} : null;
|
|
464
488
|
let space = spaceProp;
|
|
465
489
|
if (features.enabled.mediaQuery) {
|
|
@@ -519,12 +543,32 @@ function createComponent(configIn, ParentComponent) {
|
|
|
519
543
|
});
|
|
520
544
|
}
|
|
521
545
|
}
|
|
522
|
-
|
|
546
|
+
const pressability = isWeb ? null : useMemo(() => {
|
|
547
|
+
if (attachPress && events) {
|
|
548
|
+
const pressability2 = new Pressability(events);
|
|
549
|
+
internal.current.unmountEffects = [
|
|
550
|
+
() => {
|
|
551
|
+
pressability2.reset();
|
|
552
|
+
}
|
|
553
|
+
];
|
|
554
|
+
return pressability2;
|
|
555
|
+
}
|
|
556
|
+
}, []);
|
|
523
557
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
524
558
|
if (attachPress && events) {
|
|
525
|
-
|
|
559
|
+
pressability.configure(events);
|
|
560
|
+
const eventHandlers = pressability.getEventHandlers();
|
|
561
|
+
for (const key in eventHandlers) {
|
|
562
|
+
if (key === "onBlur" || key === "onFocus") {
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
const og = props[key];
|
|
566
|
+
const val = eventHandlers[key];
|
|
567
|
+
viewProps[key] = og ? composeEventHandlers(og, val) : val;
|
|
568
|
+
}
|
|
526
569
|
}
|
|
527
570
|
}
|
|
571
|
+
content = createElement(elementType, viewProps, childEls);
|
|
528
572
|
if (isWeb && events && attachHover) {
|
|
529
573
|
content = <span className="tui_Hoverable" style={{
|
|
530
574
|
display: "contents"
|
|
@@ -532,7 +576,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
532
576
|
}
|
|
533
577
|
if (process.env.NODE_ENV === "development") {
|
|
534
578
|
if (props["debug"]) {
|
|
535
|
-
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (
|
|
579
|
+
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_d = props.className) == null ? void 0 : _d.split(" "), classNamesOut: (_e = viewProps.className) == null ? void 0 : _e.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 });
|
|
536
580
|
}
|
|
537
581
|
}
|
|
538
582
|
if (features.elements.length) {
|
|
@@ -563,11 +607,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
563
607
|
focus: false,
|
|
564
608
|
resolveVariablesAs: "both",
|
|
565
609
|
keepVariantsAsProps: true
|
|
566
|
-
});
|
|
567
|
-
const defaults =
|
|
568
|
-
...component.defaultProps,
|
|
569
|
-
...initialSplitStyles.viewProps
|
|
570
|
-
};
|
|
610
|
+
}, void 0, staticConfig.defaultProps["debug"]);
|
|
611
|
+
const defaults = mergeProps(component.defaultProps, initialSplitStyles.viewProps);
|
|
571
612
|
defaultNativeStyle = {};
|
|
572
613
|
const validStyles2 = staticConfig.validStyles || stylePropsView;
|
|
573
614
|
for (const key in staticConfig.defaultProps) {
|
|
@@ -12,7 +12,7 @@ const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey
|
|
|
12
12
|
const screenStr = negate ? "not all" : "screen";
|
|
13
13
|
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
14
14
|
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
15
|
-
const styleInner = rules
|
|
15
|
+
const styleInner = rules.map((rule) => rule.replace(identifier, nextIdentifier)).join(";");
|
|
16
16
|
let styleRule = "";
|
|
17
17
|
if (styleInner.includes("@media")) {
|
|
18
18
|
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
@@ -9,14 +9,14 @@ import { isObj } from "./isObj";
|
|
|
9
9
|
const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
10
10
|
const variants = staticConfig.variants || {};
|
|
11
11
|
const defaultProps = staticConfig.defaultProps || {};
|
|
12
|
-
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false) => {
|
|
12
|
+
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false, debug) => {
|
|
13
13
|
const conf = getConfig();
|
|
14
14
|
if (!conf) {
|
|
15
15
|
console.trace("no conf! err");
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const props = state.fallbackProps || propsIn;
|
|
19
|
-
const returnVariablesAs = state.resolveVariablesAs === "value" || !!props.animation ? "value" : "auto";
|
|
19
|
+
const returnVariablesAs = state.resolveVariablesAs === "value" || !!props.animation ? "non-color-value" : "auto";
|
|
20
20
|
const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
21
21
|
const variantValue = resolveVariants(key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, "", avoidDefaultProps);
|
|
22
22
|
if (variantValue) {
|
|
@@ -29,9 +29,9 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
29
29
|
}
|
|
30
30
|
if (value) {
|
|
31
31
|
if (value[0] === "$") {
|
|
32
|
-
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs);
|
|
32
|
+
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs, debug);
|
|
33
33
|
} else if (isVariable(value)) {
|
|
34
|
-
value = getVariableValue(value, returnVariablesAs);
|
|
34
|
+
value = getVariableValue(key, value, returnVariablesAs);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
if (shouldReturn) {
|
|
@@ -40,7 +40,7 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
40
40
|
}, "mapper");
|
|
41
41
|
return mapper;
|
|
42
42
|
}, "createPropMapper");
|
|
43
|
-
const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps = false) => {
|
|
43
|
+
const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps = false, debug) => {
|
|
44
44
|
var _a;
|
|
45
45
|
const variant = variants && variants[key];
|
|
46
46
|
if (variant && value !== void 0) {
|
|
@@ -51,7 +51,7 @@ const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps,
|
|
|
51
51
|
variantValue = fn(value, getVariantExtras(props, theme, defaultProps, avoidDefaultProps));
|
|
52
52
|
}
|
|
53
53
|
if (isObj(variantValue)) {
|
|
54
|
-
variantValue = resolveTokensAndVariants(key, variantValue, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps);
|
|
54
|
+
variantValue = resolveTokensAndVariants(key, variantValue, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps, debug);
|
|
55
55
|
}
|
|
56
56
|
return Object.entries(expandStyles(variantValue));
|
|
57
57
|
} else {
|
|
@@ -59,13 +59,14 @@ const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps,
|
|
|
59
59
|
if ((_a = staticConfig.validStyles) == null ? void 0 : _a[key]) {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
const name = staticConfig.componentName || "[UnnamedComponent]";
|
|
63
|
+
console.warn(`No variant found: ${name} has variant "${key}", but no matching value "${value}"`);
|
|
63
64
|
}
|
|
64
65
|
return null;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}, "resolveVariants");
|
|
68
|
-
const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps) => {
|
|
69
|
+
const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps, debug) => {
|
|
69
70
|
var _a;
|
|
70
71
|
let res = {};
|
|
71
72
|
for (const rKey in value) {
|
|
@@ -79,15 +80,15 @@ const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defa
|
|
|
79
80
|
} else {
|
|
80
81
|
res = {
|
|
81
82
|
...res,
|
|
82
|
-
...Object.fromEntries(resolveVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps))
|
|
83
|
+
...Object.fromEntries(resolveVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps, debug))
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
} else if (typeof val === "string") {
|
|
86
|
-
const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs) : val;
|
|
87
|
+
const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs, debug) : val;
|
|
87
88
|
res[fKey] = fVal;
|
|
88
89
|
} else {
|
|
89
90
|
if (isObj(val)) {
|
|
90
|
-
res[fKey] = resolveTokensAndVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps);
|
|
91
|
+
res[fKey] = resolveTokensAndVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps, debug);
|
|
91
92
|
} else {
|
|
92
93
|
res[fKey] = value[fKey];
|
|
93
94
|
}
|
|
@@ -128,7 +129,7 @@ const fontShorthand = {
|
|
|
128
129
|
fontSize: "size",
|
|
129
130
|
fontWeight: "weight"
|
|
130
131
|
};
|
|
131
|
-
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs) => {
|
|
132
|
+
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs, debug) => {
|
|
132
133
|
var _a, _b, _c;
|
|
133
134
|
let valOrVar;
|
|
134
135
|
let hasSet = false;
|
|
@@ -167,21 +168,39 @@ const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed
|
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
if (hasSet) {
|
|
170
|
-
return getVariableValue(valOrVar, resolveAs);
|
|
171
|
+
return getVariableValue(key, valOrVar, resolveAs);
|
|
171
172
|
}
|
|
172
173
|
if (process.env.NODE_ENV === "development") {
|
|
173
174
|
if (value && value[0] === "$") {
|
|
174
|
-
console.warn(`\u26A0\uFE0F
|
|
175
|
+
console.warn(`\u26A0\uFE0F You've passed the value "${value}" to the style property "${key}", but there's no theme or token with the key "${value}". Using theme "${theme.name}".
|
|
176
|
+
|
|
177
|
+
Set the debug prop to true to see more detailed debug information.`);
|
|
178
|
+
if (debug) {
|
|
179
|
+
if (typeof window !== "undefined") {
|
|
180
|
+
console.log("Looked in:");
|
|
181
|
+
console.log("Theme:", theme);
|
|
182
|
+
console.log("Tokens:", tokensParsed);
|
|
183
|
+
console.log("Fonts:", fontsParsed);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
175
186
|
return null;
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
189
|
return value;
|
|
179
190
|
}, "getToken");
|
|
180
|
-
function getVariableValue(valOrVar, resolveAs = "auto") {
|
|
191
|
+
function getVariableValue(key, valOrVar, resolveAs = "auto") {
|
|
181
192
|
if (isVariable(valOrVar)) {
|
|
182
193
|
if (resolveAs === "variable") {
|
|
183
194
|
return valOrVar;
|
|
184
195
|
}
|
|
196
|
+
if (resolveAs === "non-color-value") {
|
|
197
|
+
if (isWeb) {
|
|
198
|
+
if (key in tokenCategories.color) {
|
|
199
|
+
return valOrVar.variable;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return valOrVar.val;
|
|
203
|
+
}
|
|
185
204
|
if (!isWeb || resolveAs === "value") {
|
|
186
205
|
return valOrVar.val;
|
|
187
206
|
}
|
|
@@ -9,13 +9,13 @@ function createTamaguiProvider({
|
|
|
9
9
|
...themeProps
|
|
10
10
|
}) {
|
|
11
11
|
return /* @__PURE__ */ __name(function TamaguiProvider({
|
|
12
|
-
|
|
12
|
+
disableInjectCSS,
|
|
13
13
|
children,
|
|
14
14
|
...themePropsProvider
|
|
15
15
|
}) {
|
|
16
16
|
if (typeof document !== "undefined") {
|
|
17
17
|
React.useLayoutEffect(() => {
|
|
18
|
-
if (
|
|
18
|
+
if (disableInjectCSS)
|
|
19
19
|
return;
|
|
20
20
|
const style = document.createElement("style");
|
|
21
21
|
style.appendChild(document.createTextNode(getCSS()));
|