@tamagui/core 1.0.1-beta.48 → 1.0.1-beta.49
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 +3 -0
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/conf.js +0 -4
- package/dist/cjs/conf.js.map +2 -2
- package/dist/cjs/createComponent.js +173 -169
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +71 -29
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js +3 -1
- package/dist/cjs/createTheme.js.map +2 -2
- package/dist/cjs/createTokens.js +4 -19
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createVariable.js +22 -8
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariables.js +57 -0
- package/dist/cjs/createVariables.js.map +7 -0
- package/dist/cjs/helpers/createPropMapper.js +81 -51
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +41 -36
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +35 -4
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStackSize.js +4 -4
- package/dist/cjs/helpers/getStackSize.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +9 -2
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +2 -0
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/validate.js +2 -2
- package/dist/cjs/helpers/validate.js.map +2 -2
- package/dist/cjs/hooks/useIsMounted.js +2 -2
- package/dist/cjs/hooks/useIsMounted.js.map +2 -2
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/styled.js +5 -0
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Theme.js +3 -2
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/esm/Tamagui.js +3 -0
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/conf.js +0 -4
- package/dist/esm/conf.js.map +2 -2
- package/dist/esm/createComponent.js +173 -170
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +70 -29
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTheme.js +3 -1
- package/dist/esm/createTheme.js.map +2 -2
- package/dist/esm/createTokens.js +3 -17
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createVariable.js +22 -7
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariables.js +35 -0
- package/dist/esm/createVariables.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +70 -51
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +41 -36
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +36 -5
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStackSize.js +1 -1
- package/dist/esm/helpers/getStackSize.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +7 -1
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +2 -0
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/validate.js +2 -2
- package/dist/esm/helpers/validate.js.map +2 -2
- package/dist/esm/hooks/useIsMounted.js +1 -1
- package/dist/esm/hooks/useIsMounted.js.map +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/styled.js +5 -0
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/Theme.js +3 -2
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/jsx/Tamagui.js +3 -0
- package/dist/jsx/conf.js +0 -4
- package/dist/jsx/createComponent.js +173 -170
- package/dist/jsx/createTamagui.js +70 -29
- package/dist/jsx/createTheme.js +3 -1
- package/dist/jsx/createTokens.js +3 -17
- package/dist/jsx/createVariable.js +22 -7
- package/dist/jsx/createVariables.js +34 -0
- package/dist/jsx/helpers/createPropMapper.js +70 -51
- package/dist/jsx/helpers/generateAtomicStyles.js +41 -36
- package/dist/jsx/helpers/getSplitStyles.js +36 -5
- package/dist/jsx/helpers/getStackSize.js +1 -1
- package/dist/jsx/helpers/getStylesAtomic.js +7 -1
- package/dist/jsx/helpers/insertStyleRule.js +2 -0
- package/dist/jsx/helpers/validate.js +2 -2
- package/dist/jsx/hooks/useIsMounted.js +1 -1
- package/dist/jsx/index.js +2 -2
- package/dist/jsx/styled.js +5 -0
- package/dist/jsx/views/Theme.js +3 -2
- package/package.json +5 -5
- package/types/ThemeManager.d.ts.map +1 -1
- package/types/conf.d.ts +1 -1
- package/types/conf.d.ts.map +1 -1
- package/types/createComponent.d.ts +1 -0
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTheme.d.ts +1 -1
- package/types/createTheme.d.ts.map +1 -1
- package/types/createTokens.d.ts +0 -1
- package/types/createTokens.d.ts.map +1 -1
- package/types/createVariable.d.ts +15 -13
- package/types/createVariable.d.ts.map +1 -1
- package/types/createVariables.d.ts +10 -0
- package/types/createVariables.d.ts.map +1 -0
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getSize.d.ts +1 -1
- package/types/helpers/getSize.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStackSize.d.ts +4 -5
- package/types/helpers/getStackSize.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +5 -0
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getVariantExtras.d.ts +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/hooks/useIsMounted.d.ts.map +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +10 -7
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
package/dist/esm/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;
|
|
4
|
+
"sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // for now wrapping a styled() around an extractable() HOC (like Button) isn't allowed\n if (process.env.NODE_ENV === 'development') {\n if (Component['staticConfig'] && Component['staticConfig'].isExtractable) {\n console.warn(\n `Warning: Wrapping styled() around an extractable HOC component isn't allowed yet. Support for this is on the roadmap, see: https://github.com/tamagui/tamagui/issues/88.`\n )\n // return (props) => {\n // // @ts-ignore\n // return <Component {...options} {...props} />\n // }\n }\n }\n\n const staticConfigProps = (() => {\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNativeWeb =\n 'staticConfig' in Component\n ? Component.staticConfig.isReactNativeWeb\n : RNComponents.has(Component)\n const reactNativeWebComponent = isReactNativeWeb\n ? Component['staticConfig']?.reactNativeWebComponent || Component\n : null\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = reactNativeWebComponent || (Component as any)\n const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false))\n const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false))\n const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n // for nesting multiple levels of rnw styled() need keep use the OG component\n reactNativeWebComponent,\n isInput,\n isText,\n isImage,\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// breaking...\n// TODO see core/types.ts bug\n\n// export const XStack = styled(Stack, {\n// variants: {\n// horizontal: {\n// true: {\n// // flexDirection: 'row',\n// width: 0,\n// },\n// },\n// },\n// })\n\n// const Separator = styled(Stack, {\n// variants: {\n// vertical: {\n// true: {\n// flexDirection: 'row',\n// },\n// },\n// },\n// <--- have to add as const to get working???\n// })\n\n// type props = GetProps<typeof XStack>\n// type variants = typeof XStack extends TamaguiComponent<any, infer Variants> ? Variants : never\n// type variants2 = typeof Separator extends TamaguiComponent<any, infer Variants> ? Variants : never\n\n// const x = <XStack horizontal />\n// const x2 = <Separator vertical />\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AAoBO,gBAIL,WAEA,SAMA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,mBAAmB,UAAU,gBAAgB,eAAe;AACxE,cAAQ,KACN,0KACF;AAAA,IAKF;AAAA,EACF;AAEA,QAAM,oBAAqB,OAAM;AAlDnC;AAmDI,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBACJ,kBAAkB,YACd,UAAU,aAAa,mBACvB,aAAa,IAAI,SAAS;AAChC,YAAM,0BAA0B,mBAC5B,iBAAU,oBAAV,mBAA2B,4BAA2B,YACtD;AACJ,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO,2BAA4B;AACzC,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,QAAQ;AAC1E,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,YAAY;AAC9E,YAAM,SAAS,CAAC,CAAE,cAAa,UAAW,EAAC,YAAY,WAAW,SAAS,OAAO;AAElF,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAOT;AA1GgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Theme.js
CHANGED
|
@@ -8,13 +8,14 @@ React["createElement"];
|
|
|
8
8
|
const Theme = memo(/* @__PURE__ */ __name(function Theme2(props) {
|
|
9
9
|
var _a, _b;
|
|
10
10
|
const { name, theme, themeManager, themes, className } = useChangeThemeEffect(props.name, props.componentName, props);
|
|
11
|
-
|
|
11
|
+
const missingTheme = !themes || !name || !theme;
|
|
12
|
+
const contents = useMemo(() => missingTheme ? null : wrapThemeManagerContext(props.children, themeManager), [props.children, themeManager]);
|
|
13
|
+
if (missingTheme) {
|
|
12
14
|
if (name && !theme && process.env.NODE_ENV === "development") {
|
|
13
15
|
console.warn(`No theme found by name ${name}`);
|
|
14
16
|
}
|
|
15
17
|
return props.children;
|
|
16
18
|
}
|
|
17
|
-
const contents = useMemo(() => wrapThemeManagerContext(props.children, themeManager), [props.children, themeManager]);
|
|
18
19
|
if (isWeb) {
|
|
19
20
|
return /* @__PURE__ */ React.createElement("span", {
|
|
20
21
|
className: [
|
|
@@ -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
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAEC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAV5D;AAWE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,MAAM,eACN,KACF;AAEA,
|
|
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={[\n `tui_Theme`,\n ...(!props.disableThemeClass ? [props.className, className].filter(Boolean) : []),\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;AAEA;AACA;AACA;AAIA,MAAM;AAEC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAV5D;AAWE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,MAAM,eACN,KACF;AAEA,QAAM,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC;AAI1C,QAAM,WAAW,QACf,MAAO,eAAe,OAAO,wBAAwB,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,OAAO;AACT,WACE,oCAAC;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,GAAI,CAAC,MAAM,oBAAoB,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,MACjF,EAAE,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
|
}
|
package/dist/jsx/Tamagui.js
CHANGED
|
@@ -34,6 +34,9 @@ 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
|
+
}
|
|
37
40
|
export {
|
|
38
41
|
Tamagui,
|
|
39
42
|
getValueFromIdentifier,
|
package/dist/jsx/conf.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { Tamagui } from "./Tamagui";
|
|
4
3
|
let conf;
|
|
5
4
|
const setConfig = /* @__PURE__ */ __name((next) => {
|
|
6
5
|
conf = next;
|
|
@@ -20,9 +19,6 @@ const onConfiguredOnce = /* @__PURE__ */ __name((cb) => {
|
|
|
20
19
|
} else {
|
|
21
20
|
configListeners.add(cb);
|
|
22
21
|
}
|
|
23
|
-
if (!globalThis["Tamagui"]) {
|
|
24
|
-
globalThis["Tamagui"] = Tamagui;
|
|
25
|
-
}
|
|
26
22
|
}, "onConfiguredOnce");
|
|
27
23
|
export {
|
|
28
24
|
configListeners,
|
|
@@ -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 } from "@tamagui/helpers";
|
|
3
|
+
import { stylePropsView, validStyles } from "@tamagui/helpers";
|
|
4
4
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
5
5
|
import React, {
|
|
6
6
|
Children,
|
|
@@ -244,164 +244,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
244
244
|
...webProps
|
|
245
245
|
} = nonTamaguiProps;
|
|
246
246
|
viewProps = webProps;
|
|
247
|
-
|
|
248
|
-
if (accessibilityRole === "none") {
|
|
249
|
-
viewProps.role = "presentation";
|
|
250
|
-
} else {
|
|
251
|
-
const webRole = accessibilityRoleToWebRole[accessibilityRole];
|
|
252
|
-
if (webRole != null) {
|
|
253
|
-
viewProps.role = webRole || accessibilityRole;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const role = viewProps.role;
|
|
258
|
-
if (accessibilityActiveDescendant != null) {
|
|
259
|
-
viewProps["aria-activedescendant"] = accessibilityActiveDescendant;
|
|
260
|
-
}
|
|
261
|
-
if (accessibilityAtomic != null) {
|
|
262
|
-
viewProps["aria-atomic"] = accessibilityAtomic;
|
|
263
|
-
}
|
|
264
|
-
if (accessibilityAutoComplete != null) {
|
|
265
|
-
viewProps["aria-autocomplete"] = accessibilityAutoComplete;
|
|
266
|
-
}
|
|
267
|
-
if (accessibilityBusy != null) {
|
|
268
|
-
viewProps["aria-busy"] = accessibilityBusy;
|
|
269
|
-
}
|
|
270
|
-
if (accessibilityChecked != null) {
|
|
271
|
-
viewProps["aria-checked"] = accessibilityChecked;
|
|
272
|
-
}
|
|
273
|
-
if (accessibilityColumnCount != null) {
|
|
274
|
-
viewProps["aria-colcount"] = accessibilityColumnCount;
|
|
275
|
-
}
|
|
276
|
-
if (accessibilityColumnIndex != null) {
|
|
277
|
-
viewProps["aria-colindex"] = accessibilityColumnIndex;
|
|
278
|
-
}
|
|
279
|
-
if (accessibilityColumnSpan != null) {
|
|
280
|
-
viewProps["aria-colspan"] = accessibilityColumnSpan;
|
|
281
|
-
}
|
|
282
|
-
if (accessibilityControls != null) {
|
|
283
|
-
viewProps["aria-controls"] = processIDRefList(accessibilityControls);
|
|
284
|
-
}
|
|
285
|
-
if (accessibilityCurrent != null) {
|
|
286
|
-
viewProps["aria-current"] = accessibilityCurrent;
|
|
287
|
-
}
|
|
288
|
-
if (accessibilityDescribedBy != null) {
|
|
289
|
-
viewProps["aria-describedby"] = processIDRefList(accessibilityDescribedBy);
|
|
290
|
-
}
|
|
291
|
-
if (accessibilityDetails != null) {
|
|
292
|
-
viewProps["aria-details"] = accessibilityDetails;
|
|
293
|
-
}
|
|
294
|
-
if (disabled === true) {
|
|
295
|
-
viewProps["aria-disabled"] = true;
|
|
296
|
-
if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
|
|
297
|
-
viewProps.disabled = true;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (accessibilityErrorMessage != null) {
|
|
301
|
-
viewProps["aria-errormessage"] = accessibilityErrorMessage;
|
|
302
|
-
}
|
|
303
|
-
if (accessibilityExpanded != null) {
|
|
304
|
-
viewProps["aria-expanded"] = accessibilityExpanded;
|
|
305
|
-
}
|
|
306
|
-
if (accessibilityFlowTo != null) {
|
|
307
|
-
viewProps["aria-flowto"] = processIDRefList(accessibilityFlowTo);
|
|
308
|
-
}
|
|
309
|
-
if (accessibilityHasPopup != null) {
|
|
310
|
-
viewProps["aria-haspopup"] = accessibilityHasPopup;
|
|
311
|
-
}
|
|
312
|
-
if (accessibilityHidden === true) {
|
|
313
|
-
viewProps["aria-hidden"] = accessibilityHidden;
|
|
314
|
-
}
|
|
315
|
-
if (accessibilityInvalid != null) {
|
|
316
|
-
viewProps["aria-invalid"] = accessibilityInvalid;
|
|
317
|
-
}
|
|
318
|
-
if (accessibilityKeyShortcuts != null && Array.isArray(accessibilityKeyShortcuts)) {
|
|
319
|
-
viewProps["aria-keyshortcuts"] = accessibilityKeyShortcuts.join(" ");
|
|
320
|
-
}
|
|
321
|
-
if (accessibilityLabel != null) {
|
|
322
|
-
viewProps["aria-label"] = accessibilityLabel;
|
|
323
|
-
}
|
|
324
|
-
if (accessibilityLabelledBy != null) {
|
|
325
|
-
viewProps["aria-labelledby"] = processIDRefList(accessibilityLabelledBy);
|
|
326
|
-
}
|
|
327
|
-
if (accessibilityLevel != null) {
|
|
328
|
-
viewProps["aria-level"] = accessibilityLevel;
|
|
329
|
-
}
|
|
330
|
-
if (accessibilityLiveRegion != null) {
|
|
331
|
-
viewProps["aria-live"] = accessibilityLiveRegion === "none" ? "off" : accessibilityLiveRegion;
|
|
332
|
-
}
|
|
333
|
-
if (accessibilityModal != null) {
|
|
334
|
-
viewProps["aria-modal"] = accessibilityModal;
|
|
335
|
-
}
|
|
336
|
-
if (accessibilityMultiline != null) {
|
|
337
|
-
viewProps["aria-multiline"] = accessibilityMultiline;
|
|
338
|
-
}
|
|
339
|
-
if (accessibilityMultiSelectable != null) {
|
|
340
|
-
viewProps["aria-multiselectable"] = accessibilityMultiSelectable;
|
|
341
|
-
}
|
|
342
|
-
if (accessibilityOrientation != null) {
|
|
343
|
-
viewProps["aria-orientation"] = accessibilityOrientation;
|
|
344
|
-
}
|
|
345
|
-
if (accessibilityOwns != null) {
|
|
346
|
-
viewProps["aria-owns"] = processIDRefList(accessibilityOwns);
|
|
347
|
-
}
|
|
348
|
-
if (accessibilityPlaceholder != null) {
|
|
349
|
-
viewProps["aria-placeholder"] = accessibilityPlaceholder;
|
|
350
|
-
}
|
|
351
|
-
if (accessibilityPosInSet != null) {
|
|
352
|
-
viewProps["aria-posinset"] = accessibilityPosInSet;
|
|
353
|
-
}
|
|
354
|
-
if (accessibilityPressed != null) {
|
|
355
|
-
viewProps["aria-pressed"] = accessibilityPressed;
|
|
356
|
-
}
|
|
357
|
-
if (accessibilityReadOnly != null) {
|
|
358
|
-
viewProps["aria-readonly"] = accessibilityReadOnly;
|
|
359
|
-
if (elementType === "input" || elementType === "select" || elementType === "textarea") {
|
|
360
|
-
viewProps.readOnly = true;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (accessibilityRequired != null) {
|
|
364
|
-
viewProps["aria-required"] = accessibilityRequired;
|
|
365
|
-
if (elementType === "input" || elementType === "select" || elementType === "textarea") {
|
|
366
|
-
viewProps.required = true;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (accessibilityRoleDescription != null) {
|
|
370
|
-
viewProps["aria-roledescription"] = accessibilityRoleDescription;
|
|
371
|
-
}
|
|
372
|
-
if (accessibilityRowCount != null) {
|
|
373
|
-
viewProps["aria-rowcount"] = accessibilityRowCount;
|
|
374
|
-
}
|
|
375
|
-
if (accessibilityRowIndex != null) {
|
|
376
|
-
viewProps["aria-rowindex"] = accessibilityRowIndex;
|
|
377
|
-
}
|
|
378
|
-
if (accessibilityRowSpan != null) {
|
|
379
|
-
viewProps["aria-rowspan"] = accessibilityRowSpan;
|
|
380
|
-
}
|
|
381
|
-
if (accessibilitySelected != null) {
|
|
382
|
-
viewProps["aria-selected"] = accessibilitySelected;
|
|
383
|
-
}
|
|
384
|
-
if (accessibilitySetSize != null) {
|
|
385
|
-
viewProps["aria-setsize"] = accessibilitySetSize;
|
|
386
|
-
}
|
|
387
|
-
if (accessibilitySort != null) {
|
|
388
|
-
viewProps["aria-sort"] = accessibilitySort;
|
|
389
|
-
}
|
|
390
|
-
if (accessibilityValueMax != null) {
|
|
391
|
-
viewProps["aria-valuemax"] = accessibilityValueMax;
|
|
392
|
-
}
|
|
393
|
-
if (accessibilityValueMin != null) {
|
|
394
|
-
viewProps["aria-valuemin"] = accessibilityValueMin;
|
|
395
|
-
}
|
|
396
|
-
if (accessibilityValueNow != null) {
|
|
397
|
-
viewProps["aria-valuenow"] = accessibilityValueNow;
|
|
398
|
-
}
|
|
399
|
-
if (accessibilityValueText != null) {
|
|
400
|
-
viewProps["aria-valuetext"] = accessibilityValueText;
|
|
401
|
-
}
|
|
402
|
-
if (nativeID) {
|
|
403
|
-
viewProps.id = nativeID;
|
|
404
|
-
}
|
|
247
|
+
assignNativePropsToWeb(elementType, viewProps, nonTamaguiProps);
|
|
405
248
|
if (!asChild) {
|
|
406
249
|
rnw.useElementLayout(hostRef, onLayout);
|
|
407
250
|
rnw.useResponderEvents(hostRef, {
|
|
@@ -444,6 +287,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
444
287
|
viewProps.target = target.charAt(0) !== "_" ? "_" + target : target;
|
|
445
288
|
}
|
|
446
289
|
}
|
|
290
|
+
const role = viewProps.role;
|
|
447
291
|
const _focusable = focusable != null ? focusable : accessible;
|
|
448
292
|
if (_focusable === false) {
|
|
449
293
|
viewProps.tabIndex = "-1";
|
|
@@ -717,10 +561,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
717
561
|
...initialSplitStyles.viewProps
|
|
718
562
|
};
|
|
719
563
|
defaultNativeStyle = {};
|
|
720
|
-
const
|
|
564
|
+
const validStyles2 = staticConfig.validStyles || stylePropsView;
|
|
721
565
|
for (const key in staticConfig.defaultProps) {
|
|
722
566
|
const val = staticConfig.defaultProps[key];
|
|
723
|
-
if (typeof val === "string" && val[0] === "$" || !
|
|
567
|
+
if (typeof val === "string" && val[0] === "$" || !validStyles2[key]) {
|
|
724
568
|
defaults[key] = val;
|
|
725
569
|
} else {
|
|
726
570
|
defaultNativeStyle[key] = val;
|
|
@@ -748,18 +592,16 @@ function createComponent(configIn, ParentComponent) {
|
|
|
748
592
|
if (configIn.memo) {
|
|
749
593
|
res = memo(res);
|
|
750
594
|
}
|
|
751
|
-
res
|
|
595
|
+
res.staticConfig = {
|
|
752
596
|
validStyles: staticConfig.validStyles || stylePropsView,
|
|
753
597
|
...staticConfig
|
|
754
598
|
};
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
res["extractable"] = (Component, conf) => {
|
|
759
|
-
Component["staticConfig"] = extendStaticConfig({
|
|
599
|
+
res.extractable = (Component, conf) => {
|
|
600
|
+
Component.staticConfig = extendStaticConfig({
|
|
760
601
|
Component,
|
|
761
602
|
...conf,
|
|
762
603
|
neverFlatten: true,
|
|
604
|
+
isExtractable: true,
|
|
763
605
|
defaultProps: {
|
|
764
606
|
...Component.defaultProps,
|
|
765
607
|
...conf == null ? void 0 : conf.defaultProps
|
|
@@ -777,6 +619,7 @@ Unspaced["isUnspaced"] = true;
|
|
|
777
619
|
const Spacer = createComponent({
|
|
778
620
|
memo: true,
|
|
779
621
|
componentName: "Spacer",
|
|
622
|
+
validStyles,
|
|
780
623
|
defaultProps: {
|
|
781
624
|
...stackDefaultStyles,
|
|
782
625
|
size: true
|
|
@@ -797,9 +640,8 @@ const Spacer = createComponent({
|
|
|
797
640
|
},
|
|
798
641
|
flex: {
|
|
799
642
|
true: {
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
":number": (flex) => ({ flex })
|
|
643
|
+
flexGrow: 1
|
|
644
|
+
}
|
|
803
645
|
},
|
|
804
646
|
direction: {
|
|
805
647
|
horizontal: {
|
|
@@ -913,10 +755,171 @@ const accessibilityRoleToWebRole = {
|
|
|
913
755
|
summary: "region",
|
|
914
756
|
text: null
|
|
915
757
|
};
|
|
758
|
+
function assignNativePropsToWeb(elementType, viewProps, nativeProps) {
|
|
759
|
+
if (!viewProps.role && nativeProps.accessibilityRole) {
|
|
760
|
+
if (nativeProps.accessibilityRole === "none") {
|
|
761
|
+
viewProps.role = "presentation";
|
|
762
|
+
} else {
|
|
763
|
+
const webRole = accessibilityRoleToWebRole[nativeProps.accessibilityRole];
|
|
764
|
+
if (webRole != null) {
|
|
765
|
+
viewProps.role = webRole || nativeProps.accessibilityRole;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
if (nativeProps.accessibilityActiveDescendant != null) {
|
|
770
|
+
viewProps["aria-activedescendant"] = nativeProps.accessibilityActiveDescendant;
|
|
771
|
+
}
|
|
772
|
+
if (nativeProps.accessibilityAtomic != null) {
|
|
773
|
+
viewProps["aria-atomic"] = nativeProps.accessibilityAtomic;
|
|
774
|
+
}
|
|
775
|
+
if (nativeProps.accessibilityAutoComplete != null) {
|
|
776
|
+
viewProps["aria-autocomplete"] = nativeProps.accessibilityAutoComplete;
|
|
777
|
+
}
|
|
778
|
+
if (nativeProps.accessibilityBusy != null) {
|
|
779
|
+
viewProps["aria-busy"] = nativeProps.accessibilityBusy;
|
|
780
|
+
}
|
|
781
|
+
if (nativeProps.accessibilityChecked != null) {
|
|
782
|
+
viewProps["aria-checked"] = nativeProps.accessibilityChecked;
|
|
783
|
+
}
|
|
784
|
+
if (nativeProps.accessibilityColumnCount != null) {
|
|
785
|
+
viewProps["aria-colcount"] = nativeProps.accessibilityColumnCount;
|
|
786
|
+
}
|
|
787
|
+
if (nativeProps.accessibilityColumnIndex != null) {
|
|
788
|
+
viewProps["aria-colindex"] = nativeProps.accessibilityColumnIndex;
|
|
789
|
+
}
|
|
790
|
+
if (nativeProps.accessibilityColumnSpan != null) {
|
|
791
|
+
viewProps["aria-colspan"] = nativeProps.accessibilityColumnSpan;
|
|
792
|
+
}
|
|
793
|
+
if (nativeProps.accessibilityControls != null) {
|
|
794
|
+
viewProps["aria-controls"] = processIDRefList(nativeProps.accessibilityControls);
|
|
795
|
+
}
|
|
796
|
+
if (nativeProps.accessibilityCurrent != null) {
|
|
797
|
+
viewProps["aria-current"] = nativeProps.accessibilityCurrent;
|
|
798
|
+
}
|
|
799
|
+
if (nativeProps.accessibilityDescribedBy != null) {
|
|
800
|
+
viewProps["aria-describedby"] = processIDRefList(nativeProps.accessibilityDescribedBy);
|
|
801
|
+
}
|
|
802
|
+
if (nativeProps.accessibilityDetails != null) {
|
|
803
|
+
viewProps["aria-details"] = nativeProps.accessibilityDetails;
|
|
804
|
+
}
|
|
805
|
+
if (nativeProps.disabled === true) {
|
|
806
|
+
viewProps["aria-disabled"] = true;
|
|
807
|
+
if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
|
|
808
|
+
viewProps.disabled = true;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
if (nativeProps.accessibilityErrorMessage != null) {
|
|
812
|
+
viewProps["aria-errormessage"] = nativeProps.accessibilityErrorMessage;
|
|
813
|
+
}
|
|
814
|
+
if (nativeProps.accessibilityExpanded != null) {
|
|
815
|
+
viewProps["aria-expanded"] = nativeProps.accessibilityExpanded;
|
|
816
|
+
}
|
|
817
|
+
if (nativeProps.accessibilityFlowTo != null) {
|
|
818
|
+
viewProps["aria-flowto"] = processIDRefList(nativeProps.accessibilityFlowTo);
|
|
819
|
+
}
|
|
820
|
+
if (nativeProps.accessibilityHasPopup != null) {
|
|
821
|
+
viewProps["aria-haspopup"] = nativeProps.accessibilityHasPopup;
|
|
822
|
+
}
|
|
823
|
+
if (nativeProps.accessibilityHidden === true) {
|
|
824
|
+
viewProps["aria-hidden"] = nativeProps.accessibilityHidden;
|
|
825
|
+
}
|
|
826
|
+
if (nativeProps.accessibilityInvalid != null) {
|
|
827
|
+
viewProps["aria-invalid"] = nativeProps.accessibilityInvalid;
|
|
828
|
+
}
|
|
829
|
+
if (nativeProps.accessibilityKeyShortcuts != null && Array.isArray(nativeProps.accessibilityKeyShortcuts)) {
|
|
830
|
+
viewProps["aria-keyshortcuts"] = nativeProps.accessibilityKeyShortcuts.join(" ");
|
|
831
|
+
}
|
|
832
|
+
if (nativeProps.accessibilityLabel != null) {
|
|
833
|
+
viewProps["aria-label"] = nativeProps.accessibilityLabel;
|
|
834
|
+
}
|
|
835
|
+
if (nativeProps.accessibilityLabelledBy != null) {
|
|
836
|
+
viewProps["aria-labelledby"] = processIDRefList(nativeProps.accessibilityLabelledBy);
|
|
837
|
+
}
|
|
838
|
+
if (nativeProps.accessibilityLevel != null) {
|
|
839
|
+
viewProps["aria-level"] = nativeProps.accessibilityLevel;
|
|
840
|
+
}
|
|
841
|
+
if (nativeProps.accessibilityLiveRegion != null) {
|
|
842
|
+
viewProps["aria-live"] = nativeProps.accessibilityLiveRegion === "none" ? "off" : nativeProps.accessibilityLiveRegion;
|
|
843
|
+
}
|
|
844
|
+
if (nativeProps.accessibilityModal != null) {
|
|
845
|
+
viewProps["aria-modal"] = nativeProps.accessibilityModal;
|
|
846
|
+
}
|
|
847
|
+
if (nativeProps.accessibilityMultiline != null) {
|
|
848
|
+
viewProps["aria-multiline"] = nativeProps.accessibilityMultiline;
|
|
849
|
+
}
|
|
850
|
+
if (nativeProps.accessibilityMultiSelectable != null) {
|
|
851
|
+
viewProps["aria-multiselectable"] = nativeProps.accessibilityMultiSelectable;
|
|
852
|
+
}
|
|
853
|
+
if (nativeProps.accessibilityOrientation != null) {
|
|
854
|
+
viewProps["aria-orientation"] = nativeProps.accessibilityOrientation;
|
|
855
|
+
}
|
|
856
|
+
if (nativeProps.accessibilityOwns != null) {
|
|
857
|
+
viewProps["aria-owns"] = processIDRefList(nativeProps.accessibilityOwns);
|
|
858
|
+
}
|
|
859
|
+
if (nativeProps.accessibilityPlaceholder != null) {
|
|
860
|
+
viewProps["aria-placeholder"] = nativeProps.accessibilityPlaceholder;
|
|
861
|
+
}
|
|
862
|
+
if (nativeProps.accessibilityPosInSet != null) {
|
|
863
|
+
viewProps["aria-posinset"] = nativeProps.accessibilityPosInSet;
|
|
864
|
+
}
|
|
865
|
+
if (nativeProps.accessibilityPressed != null) {
|
|
866
|
+
viewProps["aria-pressed"] = nativeProps.accessibilityPressed;
|
|
867
|
+
}
|
|
868
|
+
if (nativeProps.accessibilityReadOnly != null) {
|
|
869
|
+
viewProps["aria-readonly"] = nativeProps.accessibilityReadOnly;
|
|
870
|
+
if (elementType === "input" || elementType === "select" || elementType === "textarea") {
|
|
871
|
+
viewProps.readOnly = true;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (nativeProps.accessibilityRequired != null) {
|
|
875
|
+
viewProps["aria-required"] = nativeProps.accessibilityRequired;
|
|
876
|
+
if (elementType === "input" || elementType === "select" || elementType === "textarea") {
|
|
877
|
+
viewProps.required = true;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
if (nativeProps.accessibilityRoleDescription != null) {
|
|
881
|
+
viewProps["aria-roledescription"] = nativeProps.accessibilityRoleDescription;
|
|
882
|
+
}
|
|
883
|
+
if (nativeProps.accessibilityRowCount != null) {
|
|
884
|
+
viewProps["aria-rowcount"] = nativeProps.accessibilityRowCount;
|
|
885
|
+
}
|
|
886
|
+
if (nativeProps.accessibilityRowIndex != null) {
|
|
887
|
+
viewProps["aria-rowindex"] = nativeProps.accessibilityRowIndex;
|
|
888
|
+
}
|
|
889
|
+
if (nativeProps.accessibilityRowSpan != null) {
|
|
890
|
+
viewProps["aria-rowspan"] = nativeProps.accessibilityRowSpan;
|
|
891
|
+
}
|
|
892
|
+
if (nativeProps.accessibilitySelected != null) {
|
|
893
|
+
viewProps["aria-selected"] = nativeProps.accessibilitySelected;
|
|
894
|
+
}
|
|
895
|
+
if (nativeProps.accessibilitySetSize != null) {
|
|
896
|
+
viewProps["aria-setsize"] = nativeProps.accessibilitySetSize;
|
|
897
|
+
}
|
|
898
|
+
if (nativeProps.accessibilitySort != null) {
|
|
899
|
+
viewProps["aria-sort"] = nativeProps.accessibilitySort;
|
|
900
|
+
}
|
|
901
|
+
if (nativeProps.accessibilityValueMax != null) {
|
|
902
|
+
viewProps["aria-valuemax"] = nativeProps.accessibilityValueMax;
|
|
903
|
+
}
|
|
904
|
+
if (nativeProps.accessibilityValueMin != null) {
|
|
905
|
+
viewProps["aria-valuemin"] = nativeProps.accessibilityValueMin;
|
|
906
|
+
}
|
|
907
|
+
if (nativeProps.accessibilityValueNow != null) {
|
|
908
|
+
viewProps["aria-valuenow"] = nativeProps.accessibilityValueNow;
|
|
909
|
+
}
|
|
910
|
+
if (nativeProps.accessibilityValueText != null) {
|
|
911
|
+
viewProps["aria-valuetext"] = nativeProps.accessibilityValueText;
|
|
912
|
+
}
|
|
913
|
+
if (nativeProps.nativeID) {
|
|
914
|
+
viewProps.id = nativeProps.nativeID;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
__name(assignNativePropsToWeb, "assignNativePropsToWeb");
|
|
916
918
|
export {
|
|
917
919
|
AbsoluteFill,
|
|
918
920
|
Spacer,
|
|
919
921
|
Unspaced,
|
|
922
|
+
assignNativePropsToWeb,
|
|
920
923
|
createComponent,
|
|
921
924
|
mouseUps,
|
|
922
925
|
spacedChildren
|
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
import { configListeners, getHasConfigured, setConfig } from "./conf";
|
|
4
4
|
import { THEME_CLASSNAME_PREFIX } from "./constants/constants";
|
|
5
5
|
import { isWeb } from "./constants/platform";
|
|
6
|
-
import {
|
|
6
|
+
import { createCSSVariable, createVariable, isVariable } from "./createVariable";
|
|
7
7
|
import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
|
|
8
8
|
import { getInsertedRules } from "./helpers/insertStyleRule";
|
|
9
9
|
import { configureMedia } from "./hooks/useMedia";
|
|
@@ -29,6 +29,7 @@ function createTamagui(config) {
|
|
|
29
29
|
});
|
|
30
30
|
const themeConfig = (() => {
|
|
31
31
|
var _a, _b, _c;
|
|
32
|
+
const themes = { ...config.themes };
|
|
32
33
|
let cssRules = [];
|
|
33
34
|
const varsByValue = /* @__PURE__ */ new Map();
|
|
34
35
|
if (isWeb) {
|
|
@@ -61,39 +62,74 @@ function createTamagui(config) {
|
|
|
61
62
|
}
|
|
62
63
|
const hasDarkLight = "light" in config.themes && "dark" in config.themes;
|
|
63
64
|
const CNP = `.${THEME_CLASSNAME_PREFIX}`;
|
|
64
|
-
|
|
65
|
+
const existing = /* @__PURE__ */ new WeakMap();
|
|
66
|
+
const dedupedThemes = {};
|
|
67
|
+
for (const themeName in themes) {
|
|
68
|
+
const rawTheme = themes[themeName];
|
|
69
|
+
if (existing.has(rawTheme)) {
|
|
70
|
+
const e = existing.get(rawTheme);
|
|
71
|
+
e.names.push(themeName);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
65
74
|
const theme = { ...config.themes[themeName] };
|
|
66
|
-
|
|
75
|
+
for (const key in theme) {
|
|
76
|
+
ensureThemeVariable(theme, key);
|
|
77
|
+
}
|
|
78
|
+
themes[themeName] = theme;
|
|
79
|
+
dedupedThemes[themeName] = {
|
|
80
|
+
names: [themeName],
|
|
81
|
+
theme
|
|
82
|
+
};
|
|
83
|
+
existing.set(theme, dedupedThemes[themeName]);
|
|
84
|
+
}
|
|
85
|
+
for (const themeName in dedupedThemes) {
|
|
86
|
+
const { theme, names } = dedupedThemes[themeName];
|
|
67
87
|
let vars = "";
|
|
68
88
|
for (const themeKey in theme) {
|
|
69
89
|
if (isWeb) {
|
|
70
90
|
const val = theme[themeKey];
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
let varName;
|
|
92
|
+
let varVal;
|
|
93
|
+
if (isVariable(val)) {
|
|
94
|
+
varName = val.key;
|
|
95
|
+
varVal = val.isFloating ? val.val : createCSSVariable(varName);
|
|
96
|
+
} else {
|
|
97
|
+
varName = (_a = varsByValue[val]) == null ? void 0 : _a.key;
|
|
98
|
+
varVal = varName ? createCSSVariable(varName) : `${val}`;
|
|
99
|
+
}
|
|
100
|
+
if (process.env.NODE_ENV === "development") {
|
|
101
|
+
if (!varName) {
|
|
102
|
+
console.warn("no var name in theme", themeName, themeKey);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
vars += `--${themeKey}:${varVal};`;
|
|
73
107
|
}
|
|
74
|
-
ensureThemeVariable(theme, themeKey);
|
|
75
108
|
}
|
|
76
109
|
if (isWeb) {
|
|
77
110
|
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
78
111
|
const isDark = themeName.startsWith("dark");
|
|
79
|
-
const
|
|
80
|
-
|
|
112
|
+
const selectors = names.map((name) => {
|
|
113
|
+
return `${CNP}${name}`;
|
|
114
|
+
});
|
|
81
115
|
if (hasDarkLight) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
116
|
+
for (const subName of names) {
|
|
117
|
+
const childSelector = `${CNP}${subName.replace("dark_", "").replace("light_", "")}`;
|
|
118
|
+
const order = isDark ? ["dark", "light"] : ["light", "dark"];
|
|
119
|
+
if (isDarkOrLightBase) {
|
|
120
|
+
order.reverse();
|
|
121
|
+
}
|
|
122
|
+
const [stronger, weaker] = order;
|
|
123
|
+
const max = (_b = config.maxDarkLightNesting) != null ? _b : 3;
|
|
124
|
+
new Array(max * 2).fill(void 0).forEach((_, pi) => {
|
|
125
|
+
if (pi % 2 === 1)
|
|
126
|
+
return;
|
|
127
|
+
const parents = new Array(pi + 1).fill(void 0).map((_2, psi) => {
|
|
128
|
+
return `${CNP}${psi % 2 === 0 ? stronger : weaker}`;
|
|
129
|
+
});
|
|
130
|
+
selectors.push(`${(parents.length > 1 ? parents.slice(1) : parents).join(" ")} ${childSelector}`);
|
|
94
131
|
});
|
|
95
|
-
|
|
96
|
-
});
|
|
132
|
+
}
|
|
97
133
|
}
|
|
98
134
|
const rootSep = config.themeClassNameOnRoot ? "" : " ";
|
|
99
135
|
cssRules.push(`${selectors.map((x) => `:root${rootSep}${x}`).join(", ")} {${vars}}`);
|
|
@@ -111,6 +147,7 @@ function createTamagui(config) {
|
|
|
111
147
|
Object.freeze(cssRules);
|
|
112
148
|
const css = cssRules.join("\n");
|
|
113
149
|
return {
|
|
150
|
+
themes,
|
|
114
151
|
cssRules,
|
|
115
152
|
css
|
|
116
153
|
};
|
|
@@ -154,10 +191,12 @@ ${getInsertedRules().join("\n")}`;
|
|
|
154
191
|
shorthands: {},
|
|
155
192
|
media: {},
|
|
156
193
|
...config,
|
|
194
|
+
themes: themeConfig.themes,
|
|
157
195
|
Provider: createTamaguiProvider({
|
|
158
196
|
getCSS,
|
|
159
197
|
defaultTheme: "light",
|
|
160
|
-
...config
|
|
198
|
+
...config,
|
|
199
|
+
themes: themeConfig.themes
|
|
161
200
|
}),
|
|
162
201
|
fontsParsed,
|
|
163
202
|
themeConfig,
|
|
@@ -187,17 +226,19 @@ const parseTokens = /* @__PURE__ */ __name((tokens) => {
|
|
|
187
226
|
}, "parseTokens");
|
|
188
227
|
function ensureThemeVariable(theme, key) {
|
|
189
228
|
const val = theme[key];
|
|
229
|
+
const themeKey = key;
|
|
190
230
|
if (!isVariable(val)) {
|
|
191
231
|
theme[key] = createVariable({
|
|
192
|
-
key,
|
|
193
|
-
name:
|
|
194
|
-
val
|
|
232
|
+
key: themeKey,
|
|
233
|
+
name: themeKey,
|
|
234
|
+
val,
|
|
235
|
+
isFloating: true
|
|
195
236
|
});
|
|
196
237
|
} else {
|
|
197
|
-
if (val.name !==
|
|
238
|
+
if (val.name !== themeKey) {
|
|
198
239
|
theme[key] = createVariable({
|
|
199
|
-
key,
|
|
200
|
-
name:
|
|
240
|
+
key: val.name,
|
|
241
|
+
name: themeKey,
|
|
201
242
|
val: val.val
|
|
202
243
|
});
|
|
203
244
|
}
|