@tamagui/core 1.0.1-beta.73 → 1.0.1-beta.76
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/createComponent.js +25 -20
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createFont.js.map +1 -1
- package/dist/cjs/createTamagui.js +2 -2
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createVariable.js +9 -1
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +3 -1
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +55 -70
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +15 -10
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +4 -2
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +12 -10
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/pseudoDescriptors.js +41 -0
- package/dist/cjs/helpers/pseudoDescriptors.js.map +7 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/insertFont.js +17 -4
- package/dist/cjs/insertFont.js.map +2 -2
- package/dist/cjs/static.js +1 -1
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/ThemeManager.js +6 -22
- package/dist/esm/ThemeManager.js.map +1 -1
- package/dist/esm/constants/constants.js +23 -8
- package/dist/esm/constants/constants.js.map +1 -1
- package/dist/esm/createComponent.js +239 -131
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createFont.js.map +1 -1
- package/dist/esm/createTamagui.js +28 -10
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createVariable.js +9 -1
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +20 -5
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createShallowUpdate.js +17 -1
- package/dist/esm/helpers/createShallowUpdate.js.map +1 -1
- package/dist/esm/helpers/createTamaguiProvider.js +39 -9
- package/dist/esm/helpers/createTamaguiProvider.js.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.js +28 -27
- package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
- package/dist/esm/helpers/fixNativeShadow.native.js +2 -3
- package/dist/esm/helpers/fixNativeShadow.native.js.map +1 -1
- package/dist/esm/helpers/generateAtomicStyles.js +75 -76
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSize.js +2 -3
- package/dist/esm/helpers/getSize.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +47 -30
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStackSize.js +1 -2
- package/dist/esm/helpers/getStackSize.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +38 -7
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +12 -10
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/mergeTransform.js +1 -1
- package/dist/esm/helpers/mergeTransform.js.map +1 -1
- package/dist/esm/helpers/pseudoDescriptors.js +18 -0
- package/dist/esm/helpers/pseudoDescriptors.js.map +7 -0
- package/dist/esm/helpers/themeable.js +33 -2
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/helpers/validate.js +30 -5
- package/dist/esm/helpers/validate.js.map +1 -1
- package/dist/esm/hooks/useFeatures.js +40 -8
- package/dist/esm/hooks/useFeatures.js.map +1 -1
- package/dist/esm/hooks/useId.js +2 -3
- package/dist/esm/hooks/useId.js.map +1 -1
- package/dist/esm/hooks/useMedia.js +18 -6
- package/dist/esm/hooks/useMedia.js.map +1 -1
- package/dist/esm/hooks/usePressable.js +16 -1
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +24 -7
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/insertFont.js +17 -4
- package/dist/esm/insertFont.js.map +2 -2
- package/dist/esm/static.js +1 -1
- package/dist/esm/static.js.map +1 -1
- package/dist/esm/styled.js +38 -9
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/views/Slot.js +40 -11
- package/dist/esm/views/Slot.js.map +1 -1
- package/dist/esm/views/Stack.js +21 -3
- package/dist/esm/views/Stack.js.map +1 -1
- package/dist/esm/views/Text.js +24 -12
- package/dist/esm/views/Text.js.map +1 -1
- package/dist/esm/views/TextAncestorContext.js +2 -2
- package/dist/esm/views/TextAncestorContext.js.map +1 -1
- package/dist/jsx/createComponent.js +13 -11
- package/dist/jsx/createTamagui.js +2 -2
- package/dist/jsx/insertFont.js +17 -4
- package/package.json +6 -6
- package/reset.css +4 -0
- package/types/createComponent.d.ts +2 -4
- package/types/createComponent.d.ts.map +1 -1
- package/types/createVariable.d.ts.map +1 -1
- package/types/helpers/createTamaguiProvider.d.ts +0 -1
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts +2 -2
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +2 -0
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/pseudoDescriptors.d.ts +16 -0
- package/types/helpers/pseudoDescriptors.d.ts.map +1 -0
- package/types/helpers/pseudos.d.ts +2 -2
- package/types/helpers/pseudos.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/insertFont.d.ts +1 -1
- package/types/insertFont.d.ts.map +1 -1
- package/types/static.d.ts +1 -1
- package/types/static.d.ts.map +1 -1
- package/types/types.d.ts +2 -2
- package/types/types.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getStylesAtomic.ts"],
|
|
4
|
-
"sourcesContent": ["import { StyleObject, stylePropsTransform } from '@tamagui/helpers'\nimport { ViewStyle } from 'react-native'\n\nimport { isVariable } from '../createVariable'\nimport { generateAtomicStyles } from './generateAtomicStyles'\nimport { invertMapTransformKeys, mergeTransform } from './mergeTransform'\nimport { PseudoDescriptor,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAiD;AAGjD,4BAA2B;AAC3B,kCAAqC;AACrC,4BAAuD;AACvD
|
|
4
|
+
"sourcesContent": ["import { StyleObject, stylePropsTransform } from '@tamagui/helpers'\nimport { ViewStyle } from 'react-native'\n\nimport { isVariable } from '../createVariable'\nimport { generateAtomicStyles } from './generateAtomicStyles'\nimport { invertMapTransformKeys, mergeTransform } from './mergeTransform'\nimport { PseudoDescriptor, pseudoDescriptors } from './pseudoDescriptors'\n\n// refactor this file away next...\n\nexport type ViewStyleWithPseudos = ViewStyle & {\n hoverStyle?: ViewStyle\n pressStyle?: ViewStyle\n focusStyle?: ViewStyle\n}\n\ntype AtomicStyleOptions = {\n // StyleObject.propererty will be original transform key, so extractor can keep prop/spread logic\n splitTransforms?: boolean\n}\n\nconst pseudosOrdered = Object.values(pseudoDescriptors)\n\nexport function getStylesAtomic(stylesIn: ViewStyleWithPseudos, options?: AtomicStyleOptions) {\n // performance optimization\n if (!stylesIn.hoverStyle && !stylesIn.pressStyle && !stylesIn.focusStyle) {\n return getAtomicStyle(stylesIn, undefined, options)\n }\n\n // only for pseudos\n const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn\n let res: StyleObject[] = []\n // *1 order matched to *0\n for (const [index, style] of [hoverStyle, pressStyle, focusStyle, base].entries()) {\n if (!style || !Object.keys(style).length) {\n continue\n }\n const pseudo = pseudosOrdered[index]\n for (const skey in style) {\n const val = style[skey]\n if (isVariable(val)) {\n style[skey] = val.toString()\n }\n if (stylePropsTransform[skey]) {\n delete style[skey]\n mergeTransform(style, skey, val)\n }\n }\n res = [...res, ...getAtomicStyle(style, pseudo, options)]\n }\n return res\n}\n\nexport function getAtomicStyle(\n style: ViewStyle,\n pseudo?: PseudoDescriptor,\n options?: AtomicStyleOptions\n): StyleObject[] {\n if (process.env.NODE_ENV === 'development') {\n if (!style || typeof style !== 'object') {\n throw new Error(`Wrong style type: \"${typeof style}\": ${style}`)\n }\n } else {\n if (!style) {\n console.warn(`Invalid style`)\n return []\n }\n }\n\n if (options && options.splitTransforms && style.transform) {\n let atomicStyles: StyleObject[] = []\n let { transform, ...rest } = style\n for (const t of transform) {\n const tKey = Object.keys(t)[0]\n const transformProperty = invertMapTransformKeys[tKey] || tKey\n const out = generateAtomicStyles({ transform: [t] }, pseudo)[0]\n atomicStyles.push({\n ...out,\n property: transformProperty,\n })\n }\n return [...atomicStyles, ...generateAtomicStyles(rest, pseudo)]\n }\n\n return generateAtomicStyles(style, pseudo)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAiD;AAGjD,4BAA2B;AAC3B,kCAAqC;AACrC,4BAAuD;AACvD,+BAAoD;AAepD,MAAM,iBAAiB,OAAO,OAAO,0CAAiB;AAE/C,yBAAyB,UAAgC,SAA8B;AAE5F,MAAI,CAAC,SAAS,cAAc,CAAC,SAAS,cAAc,CAAC,SAAS,YAAY;AACxE,WAAO,eAAe,UAAU,QAAW,OAAO;AAAA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AAU;AAAA,MACZ,EAAC;AAAA,IACH;AACA,WAAO,CAAC,GAAG,cAAc,GAAG,sDAAqB,MAAM,MAAM,CAAC;AAAA,EAChE;AAEA,SAAO,sDAAqB,OAAO,MAAM;AAC3C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -41,14 +41,18 @@ function addTransform(identifier, css, rule) {
|
|
|
41
41
|
console.trace();
|
|
42
42
|
console.groupEnd();
|
|
43
43
|
} else {
|
|
44
|
-
console.
|
|
44
|
+
console.warn(`Missing transform`, identifier, css, rule);
|
|
45
45
|
}
|
|
46
|
-
return;
|
|
46
|
+
return false;
|
|
47
47
|
}
|
|
48
48
|
const startI = s + "transform:".length;
|
|
49
49
|
const endI = css.indexOf(";");
|
|
50
50
|
const value = css.slice(startI, endI);
|
|
51
|
-
insertedTransforms[identifier]
|
|
51
|
+
if (!insertedTransforms[identifier]) {
|
|
52
|
+
insertedTransforms[identifier] = value;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
52
56
|
}
|
|
53
57
|
const isClient = typeof document !== "undefined";
|
|
54
58
|
let hasInsertedSinceUpdate = true;
|
|
@@ -57,10 +61,8 @@ function updateInserted() {
|
|
|
57
61
|
return;
|
|
58
62
|
if (!isClient)
|
|
59
63
|
return;
|
|
60
|
-
if (!hasInsertedSinceUpdate)
|
|
61
|
-
console.warn("hasnt inserted since");
|
|
64
|
+
if (!hasInsertedSinceUpdate)
|
|
62
65
|
return;
|
|
63
|
-
}
|
|
64
66
|
const sheets = document.styleSheets;
|
|
65
67
|
if (!sheets)
|
|
66
68
|
return;
|
|
@@ -93,12 +95,12 @@ updateInserted();
|
|
|
93
95
|
const sheet = isClient ? document.head.appendChild(document.createElement("style")).sheet : null;
|
|
94
96
|
function updateInsertedCache(identifier, rule) {
|
|
95
97
|
if (insertedSelectors[identifier])
|
|
96
|
-
return;
|
|
98
|
+
return false;
|
|
97
99
|
insertedSelectors[identifier] = rule;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
addTransform(identifier, rule);
|
|
100
|
+
if (identifier.startsWith("_transform")) {
|
|
101
|
+
return addTransform(identifier, rule);
|
|
101
102
|
}
|
|
103
|
+
return true;
|
|
102
104
|
}
|
|
103
105
|
function insertStyleRule(identifier, rule) {
|
|
104
106
|
if (allSelectors[identifier])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/insertStyleRule.tsx"],
|
|
4
|
-
"sourcesContent": ["// this needs to check if its inserted already? 99% of the time it is\n// this should avoid re-inserts, but need to test the perf trade-offs\n// i tested with the site itself and the initial insert was trivial\n\nconst allSelectors = {}\nconst insertedSelectors = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getInsertedRules = () => Object.values(insertedSelectors)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, css: string, rule?: CSSRule) {\n const s = css.indexOf('transform:')\n if (s === -1) {\n if (process.env.NODE_ENV === 'development') {\n console.groupCollapsed(`\u274C Invalid transform, likely used deg/% improperly ${identifier}`)\n console.log('rule:', rule)\n console.trace()\n console.groupEnd()\n } else {\n console.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,MAAM,eAAe,CAAC;AACtB,MAAM,oBAAoB,CAAC;AACpB,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,MAAM;AAC9B,MAAM,mBAAmB,MAAM,OAAO,OAAO,iBAAiB;AAC9D,MAAM,mBAAmB,MAAM;AAGtC,sBAAsB,YAAoB,KAAa,MAAgB;AACrE,QAAM,IAAI,IAAI,QAAQ,YAAY;AAClC,MAAI,MAAM,IAAI;AACZ,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,cAAQ,eAAe,0DAAqD,YAAY;AACxF,cAAQ,IAAI,SAAS,IAAI;AACzB,cAAQ,MAAM;AACd,cAAQ,SAAS;AAAA,IACnB,OAAO;AACL,cAAQ,
|
|
4
|
+
"sourcesContent": ["// this needs to check if its inserted already? 99% of the time it is\n// this should avoid re-inserts, but need to test the perf trade-offs\n// i tested with the site itself and the initial insert was trivial\n\nconst allSelectors = {}\nconst insertedSelectors = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getInsertedRules = () => Object.values(insertedSelectors)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, css: string, rule?: CSSRule) {\n const s = css.indexOf('transform:')\n if (s === -1) {\n if (process.env.NODE_ENV === 'development') {\n console.groupCollapsed(`\u274C Invalid transform, likely used deg/% improperly ${identifier}`)\n console.log('rule:', rule)\n console.trace()\n console.groupEnd()\n } else {\n console.warn(`Missing transform`, identifier, css, rule)\n }\n return false\n }\n const startI = s + 'transform:'.length\n const endI = css.indexOf(';')\n const value = css.slice(startI, endI)\n if (!insertedTransforms[identifier]) {\n insertedTransforms[identifier] = value\n return true\n }\n return false\n}\n\nconst isClient = typeof document !== 'undefined'\n\n// gets existing ones (client side)\n// takes ~0.1ms for a fairly large page\n// used now for three things:\n// 1. debugging at dev time\n// 2. avoid duplicate insert styles at runtime\n// 3. used now for merging transforms atomically\nlet hasInsertedSinceUpdate = true\n\nexport function updateInserted() {\n if (process.env.NODE_ENV === 'test') return\n if (!isClient) return\n if (!hasInsertedSinceUpdate) return\n const sheets = document.styleSheets\n if (!sheets) return\n for (let i = 0; i < sheets.length; i++) {\n const rules = sheets[i].cssRules\n const firstRule = rules[0]\n if (!(firstRule instanceof CSSStyleRule)) continue\n const firstSelector = firstRule.selectorText\n if (!firstSelector) continue\n if (firstSelector === ':root' || firstSelector.startsWith('._')) {\n for (let i = 0; i < rules.length; i++) {\n const rule = rules.item(i)\n if (!(rule instanceof CSSStyleRule)) continue\n const identifier = rule.selectorText.slice(1)\n if (!allSelectors[identifier]) {\n allSelectors[identifier] = process.env.NODE_ENV === 'development' ? rule.cssText : true\n if (identifier.startsWith('_transform')) {\n addTransform(identifier, rule.cssText, rule)\n }\n }\n }\n }\n }\n hasInsertedSinceUpdate = false\n}\n\nupdateInserted()\n\nconst sheet = isClient ? document.head.appendChild(document.createElement('style')).sheet : null\n\nexport function updateInsertedCache(identifier: string, rule: string) {\n if (insertedSelectors[identifier]) return false\n insertedSelectors[identifier] = rule\n if (identifier.startsWith('_transform')) {\n return addTransform(identifier, rule)\n }\n return true\n}\n\nexport function insertStyleRule(identifier: string, rule: string) {\n if (allSelectors[identifier]) return\n hasInsertedSinceUpdate = true\n updateInsertedCache(identifier, rule)\n allSelectors[identifier] = process.env.NODE_ENV === 'development' ? rule : true\n sheet?.insertRule(rule, sheet.cssRules.length)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,MAAM,eAAe,CAAC;AACtB,MAAM,oBAAoB,CAAC;AACpB,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,MAAM;AAC9B,MAAM,mBAAmB,MAAM,OAAO,OAAO,iBAAiB;AAC9D,MAAM,mBAAmB,MAAM;AAGtC,sBAAsB,YAAoB,KAAa,MAAgB;AACrE,QAAM,IAAI,IAAI,QAAQ,YAAY;AAClC,MAAI,MAAM,IAAI;AACZ,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,cAAQ,eAAe,0DAAqD,YAAY;AACxF,cAAQ,IAAI,SAAS,IAAI;AACzB,cAAQ,MAAM;AACd,cAAQ,SAAS;AAAA,IACnB,OAAO;AACL,cAAQ,KAAK,qBAAqB,YAAY,KAAK,IAAI;AAAA,IACzD;AACA,WAAO;AAAA,EACT;AACA,QAAM,SAAS,IAAI,aAAa;AAChC,QAAM,OAAO,IAAI,QAAQ,GAAG;AAC5B,QAAM,QAAQ,IAA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O,yBAAyB,YAAoB,MAAc;AAChE,MAAI,aAAa;AAAa;AAC9B,2BAAyB;AACzB,sBAAoB,YAAY,IAAI;AACpC,eAAa,cAAc,QAAQ,IAAI,aAAa,gBAAgB,OAAO;AAC3E,iCAAO,WAAW,MAAM,MAAM,SAAS;AACzC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var pseudoDescriptors_exports = {};
|
|
19
|
+
__export(pseudoDescriptors_exports, {
|
|
20
|
+
pseudoDescriptors: () => pseudoDescriptors
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(pseudoDescriptors_exports);
|
|
23
|
+
const pseudoDescriptors = {
|
|
24
|
+
hoverStyle: {
|
|
25
|
+
name: "hover",
|
|
26
|
+
priority: 1
|
|
27
|
+
},
|
|
28
|
+
pressStyle: {
|
|
29
|
+
name: "active",
|
|
30
|
+
priority: 2
|
|
31
|
+
},
|
|
32
|
+
focusStyle: {
|
|
33
|
+
name: "focus",
|
|
34
|
+
priority: 3
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
pseudoDescriptors
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=pseudoDescriptors.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/pseudoDescriptors.ts"],
|
|
4
|
+
"sourcesContent": ["// *0 order matches to *1\n\nexport const pseudoDescriptors = {\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\nexport type PseudoDescriptor = typeof pseudoDescriptors[keyof typeof pseudoDescriptors]\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,oBAAoB;AAAA,EAC/B,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
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -53,7 +53,7 @@ __reExport(src_exports, require("./helpers/getExpandedShorthands"), module.expor
|
|
|
53
53
|
__reExport(src_exports, require("./helpers/getSize"), module.exports);
|
|
54
54
|
__reExport(src_exports, require("./helpers/getSplitStyles"), module.exports);
|
|
55
55
|
__reExport(src_exports, require("./helpers/getStylesAtomic"), module.exports);
|
|
56
|
-
__reExport(src_exports, require("./helpers/
|
|
56
|
+
__reExport(src_exports, require("./helpers/pseudoDescriptors"), module.exports);
|
|
57
57
|
__reExport(src_exports, require("./helpers/mergeProps"), module.exports);
|
|
58
58
|
var import_generateAtomicStyles = require("./helpers/generateAtomicStyles");
|
|
59
59
|
__reExport(src_exports, require("./helpers/getTextSize"), module.exports);
|
package/dist/cjs/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/
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,4BAJd;AAKA,wBAAc,yBALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,6BAPd;AAQA,wBAAc,8BARd;AASA,wBAAc,yBATd;AAUA,wBAAc,qBAVd;AAWA,wBAAc,oBAXd;AAaA,uBAA2C;AAC3C,kBAAoF;AAEpF,wBAAc,kCAhBd;AAiBA,wBAAc,iCAjBd;AAkBA,wBAAc,4BAlBd;AAoBA,wBAAc,2BApBd;AAqBA,wBAAc,0CArBd;AAsBA,wBAAc,mCAtBd;AAuBA,wBAAc,uCAvBd;AAwBA,wBAAc,4CAxBd;AAyBA,wBAAc,8BAzBd;AA0BA,wBAAc,qCA1Bd;AA2BA,wBAAc,sCA3Bd;AA4BA,wBAAc,
|
|
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/pseudoDescriptors'\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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c,0BAtDd;AAuDA,wBAAc,iCAvDd;AAwDA,wBAAc,kCAxDd;AAyDA,wBAAc,+BAzDd;AA2DA,wBAAc,sCA3Dd;AA4DA,wBAAc,6BA5Dd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/insertFont.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(insertFont_exports, {
|
|
|
22
22
|
registerFontVariables: () => registerFontVariables
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(insertFont_exports);
|
|
25
|
+
var import_core = require("@tamagui/core");
|
|
25
26
|
var import_conf = require("./conf");
|
|
26
27
|
var import_createFont = require("./createFont");
|
|
27
28
|
var import_createVariables = require("./createVariables");
|
|
@@ -30,7 +31,13 @@ function insertFont(name, fontIn) {
|
|
|
30
31
|
const font = (0, import_createFont.createFont)(fontIn);
|
|
31
32
|
const tokened = (0, import_createVariables.createVariables)(font, name);
|
|
32
33
|
const parsed = parseFont(tokened);
|
|
33
|
-
|
|
34
|
+
if (import_core.isWeb && typeof document !== "undefined") {
|
|
35
|
+
const css = registerFontVariables(parsed, true);
|
|
36
|
+
const style = document.createElement("style");
|
|
37
|
+
style.innerText = `:root {${css}}`;
|
|
38
|
+
style.setAttribute("data-tamagui-font", name);
|
|
39
|
+
document.head.appendChild(style);
|
|
40
|
+
}
|
|
34
41
|
(0, import_conf.setConfigFont)(name, tokened, parsed);
|
|
35
42
|
return parsed;
|
|
36
43
|
}
|
|
@@ -53,20 +60,26 @@ function parseFont(definition) {
|
|
|
53
60
|
}
|
|
54
61
|
return parsed;
|
|
55
62
|
}
|
|
56
|
-
function registerFontVariables(parsedFont) {
|
|
63
|
+
function registerFontVariables(parsedFont, collect = false) {
|
|
64
|
+
let vals = "";
|
|
57
65
|
for (const fkey in parsedFont) {
|
|
58
66
|
if (fkey === "family") {
|
|
59
|
-
(0, import_registerCSSVariable.registerCSSVariable)(parsedFont[fkey]);
|
|
67
|
+
const val = (0, import_registerCSSVariable.registerCSSVariable)(parsedFont[fkey]);
|
|
68
|
+
if (collect)
|
|
69
|
+
vals += val + ";";
|
|
60
70
|
} else {
|
|
61
71
|
for (const fskey in parsedFont[fkey]) {
|
|
62
72
|
const fval = parsedFont[fkey][fskey];
|
|
63
73
|
if (typeof fval === "string") {
|
|
64
74
|
} else {
|
|
65
|
-
(0, import_registerCSSVariable.registerCSSVariable)(parsedFont[fkey][fskey]);
|
|
75
|
+
const val = (0, import_registerCSSVariable.registerCSSVariable)(parsedFont[fkey][fskey]);
|
|
76
|
+
if (collect)
|
|
77
|
+
vals += val + ";";
|
|
66
78
|
}
|
|
67
79
|
}
|
|
68
80
|
}
|
|
69
81
|
}
|
|
82
|
+
return vals;
|
|
70
83
|
}
|
|
71
84
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
85
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/insertFont.ts"],
|
|
4
|
-
"sourcesContent": ["import { setConfigFont } from './conf'\nimport { createFont } from './createFont'\nimport { Variable } from './createVariable'\nimport { DeepVariableObject, createVariables } from './createVariables'\nimport { registerCSSVariable } from './helpers/registerCSSVariable'\nimport { GenericFont } from './types'\n\nexport function insertFont<A extends GenericFont>(name: string, fontIn: A): DeepVariableObject<A> {\n const font = createFont(fontIn)\n const tokened = createVariables(font, name) as GenericFont\n const parsed = parseFont(tokened) as DeepVariableObject<A>\n registerFontVariables(parsed)\n setConfigFont(name, tokened, parsed)\n return parsed\n}\n\nexport function parseFont<A extends GenericFont>(definition: A): DeepVariableObject<A> {\n const parsed: any = {}\n for (const attrKey in definition) {\n const attr = definition[attrKey]\n if (attrKey === 'family') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = {}\n for (const key in attr) {\n let val = attr[key] as any as Variable\n // is a theme reference\n if (val.val[0] === '$') {\n val = val.val\n }\n parsed[attrKey][`$${key}`] = val\n }\n }\n return parsed\n}\n\nexport function registerFontVariables(parsedFont: any) {\n for (const fkey in parsedFont) {\n if (fkey === 'family') {\n registerCSSVariable(parsedFont[fkey])\n } else {\n for (const fskey in parsedFont[fkey]) {\n const fval = parsedFont[fkey][fskey]\n if (typeof fval === 'string') {\n // no need to add its a theme reference
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA8B;AAC9B,wBAA2B;AAE3B,6BAAoD;AACpD,iCAAoC;AAG7B,oBAA2C,MAAc,QAAkC;AAChG,QAAM,OAAO,kCAAW,MAAM;AAC9B,QAAM,UAAU,4CAAgB,MAAM,IAAI;AAC1C,QAAM,SAAS,UAAU,OAAO;AAChC,
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/core'\nimport { setConfigFont } from './conf'\nimport { createFont } from './createFont'\nimport { Variable } from './createVariable'\nimport { DeepVariableObject, createVariables } from './createVariables'\nimport { registerCSSVariable } from './helpers/registerCSSVariable'\nimport { GenericFont } from './types'\n\nexport function insertFont<A extends GenericFont>(name: string, fontIn: A): DeepVariableObject<A> {\n const font = createFont(fontIn)\n const tokened = createVariables(font, name) as GenericFont\n const parsed = parseFont(tokened) as DeepVariableObject<A>\n if (isWeb && typeof document !== 'undefined') {\n const css = registerFontVariables(parsed, true)\n const style = document.createElement('style')\n style.innerText = `:root {${css}}`\n style.setAttribute('data-tamagui-font', name)\n document.head.appendChild(style)\n }\n setConfigFont(name, tokened, parsed)\n return parsed\n}\n\nexport function parseFont<A extends GenericFont>(definition: A): DeepVariableObject<A> {\n const parsed: any = {}\n for (const attrKey in definition) {\n const attr = definition[attrKey]\n if (attrKey === 'family') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = {}\n for (const key in attr) {\n let val = attr[key] as any as Variable\n // is a theme reference\n if (val.val[0] === '$') {\n val = val.val\n }\n parsed[attrKey][`$${key}`] = val\n }\n }\n return parsed\n}\n\nexport function registerFontVariables(parsedFont: any, collect = false) {\n let vals = ''\n for (const fkey in parsedFont) {\n if (fkey === 'family') {\n const val = registerCSSVariable(parsedFont[fkey])\n if (collect) vals += val + ';'\n } else {\n for (const fskey in parsedFont[fkey]) {\n const fval = parsedFont[fkey][fskey]\n if (typeof fval === 'string') {\n // no need to add its a theme reference like \"$borderColor\"\n } else {\n const val = registerCSSVariable(parsedFont[fkey][fskey])\n if (collect) vals += val + ';'\n }\n }\n }\n }\n return vals\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAsB;AACtB,kBAA8B;AAC9B,wBAA2B;AAE3B,6BAAoD;AACpD,iCAAoC;AAG7B,oBAA2C,MAAc,QAAkC;AAChG,QAAM,OAAO,kCAAW,MAAM;AAC9B,QAAM,UAAU,4CAAgB,MAAM,IAAI;AAC1C,QAAM,SAAS,UAAU,OAAO;AAChC,MAAI,qBAAS,OAAO,aAAa,aAAa;AAC5C,UAAM,MAAM,sBAAsB,QAAQ,IAAI;AAC9C,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,YAAY,UAAU;AAC5B,UAAM,aAAa,qBAAqB,IAAI;AAC5C,aAAS,KAAK,YAAY,KAAK;AAAA,EACjC;AACA,iCAAc,MAAM,SAAS,MAAM;AACnC,SAAO;AACT;AAEO,mBAA0C,YAAsC;AACrF,QAAM,SAAc,CAAC;AACrB,aAAW,WAAW,YAAY;AAChC,UAAM,OAAO,WAAW;AACxB,QAAI,YAAY,UAAU;AACxB,aAAO,WAAW;AAClB;AAAA,IACF;AACA,WAAO,WAAW,CAAC;AACnB,eAAW,OAAO,MAAM;AACtB,UAAI,MAAM,KAAK;AAEf,UAAI,IAAI,IAAI,OAAO,KAAK;AACtB,cAAM,IAAI;AAAA,MACZ;AACA,aAAO,SAAS,IAAI,SAAS;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;AAEO,+BAA+B,YAAiB,UAAU,OAAO;AACtE,MAAI,OAAO;AACX,aAAW,QAAQ,YAAY;AAC7B,QAAI,SAAS,UAAU;AACrB,YAAM,MAAM,oDAAoB,WAAW,KAAK;AAChD,UAAI;AAAS,gBAAQ,MAAM;AAAA,IAC7B,OAAO;AACL,iBAAW,SAAS,WAAW,OAAO;AACpC,cAAM,OAAO,WAAW,MAAM;AAC9B,YAAI,OAAO,SAAS,UAAU;AAAA,QAE9B,OAAO;AACL,gBAAM,MAAM,oDAAoB,WAAW,MAAM,MAAM;AACvD,cAAI;AAAS,oBAAQ,MAAM;AAAA,QAC7B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/static.js
CHANGED
|
@@ -26,7 +26,7 @@ __reExport(static_exports, require("./hooks/useTheme"), module.exports);
|
|
|
26
26
|
__reExport(static_exports, require("./helpers/isObj"), module.exports);
|
|
27
27
|
__reExport(static_exports, require("./helpers/getStylesAtomic"), module.exports);
|
|
28
28
|
__reExport(static_exports, require("./helpers/generateAtomicStyles"), module.exports);
|
|
29
|
-
__reExport(static_exports, require("./helpers/
|
|
29
|
+
__reExport(static_exports, require("./helpers/pseudoDescriptors"), module.exports);
|
|
30
30
|
__reExport(static_exports, require("./helpers/proxyThemeVariables"), module.exports);
|
|
31
31
|
__reExport(static_exports, require("./helpers/getSplitStyles"), module.exports);
|
|
32
32
|
__reExport(static_exports, require("@tamagui/helpers"), module.exports);
|
package/dist/cjs/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/generateAtomicStyles'\nexport * from './helpers/
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAEA,2BAAc,qBAFd;AAGA,2BAAc,8BAHd;AAIA,2BAAc,yBAJd;AAKA,2BAAc,2BALd;AAMA,2BAAc,4BANd;AAOA,2BAAc,6BAPd;AAQA,2BAAc,kCARd;AAUA,2BAAc,6BAVd;AAWA,2BAAc,6BAXd;AAaA,2BAAc,4BAbd;AAcA,2BAAc,sCAdd;AAeA,2BAAc,2CAfd;AAgBA,2BAAc,
|
|
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/pseudoDescriptors'\nexport * from './helpers/proxyThemeVariables'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/rnw'\n\nexport * from './types'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAEA,2BAAc,qBAFd;AAGA,2BAAc,8BAHd;AAIA,2BAAc,yBAJd;AAKA,2BAAc,2BALd;AAMA,2BAAc,4BANd;AAOA,2BAAc,6BAPd;AAQA,2BAAc,kCARd;AAUA,2BAAc,6BAVd;AAWA,2BAAc,6BAXd;AAaA,2BAAc,4BAbd;AAcA,2BAAc,sCAdd;AAeA,2BAAc,2CAfd;AAgBA,2BAAc,wCAhBd;AAiBA,2BAAc,0CAjBd;AAkBA,2BAAc,qCAlBd;AAmBA,2BAAc,6BAnBd;AAqBA,2BAAc,4BArBd;AAuBA,2BAAc,oBAvBd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.tsx"],
|
|
4
|
-
"sourcesContent": ["// TODO split this into own package @tamagui/types to share with animations packages\n\nimport { Properties } from 'csstype'\nimport React from 'react'\nimport {\n GestureResponderEvent,\n Image,\n TextProps as ReactTextProps,\n Text,\n TextInput,\n TextStyle,\n View,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport { Variable } from './createVariable'\nimport { ResolveVariableTypes } from './helpers/createPropMapper'\nimport { RNWTextProps, RNWViewProps } from './types-rnw'\nimport { ThemeProviderProps } from './views/ThemeProvider'\n\nexport type SpaceFlexDirection = ViewStyle['flexDirection'] | 'both'\n\nexport type TamaguiElement = HTMLElement | View\n\nexport type DebugProp = boolean | 'break' | 'verbose'\n\n//\n// base props that are accepted by createComponent (additional to react-native-web)\n//\nexport type TamaguiComponentPropsBase = {\n asChild?: boolean\n space?: SpaceTokens\n spaceDirection?: SpaceFlexDirection\n separator?: React.ReactNode\n dangerouslySetInnerHTML?: { __html: string }\n animation?: AnimationProp\n animateOnly?: string[]\n children?: any | any[]\n debug?: DebugProp\n disabled?: boolean\n className?: string\n id?: string\n tag?: string\n theme?: ThemeName | null\n componentName?: string\n forceStyle?: 'hover' | 'press' | 'focus'\n onHoverIn?: (e: MouseEvent) => any\n onHoverOut?: (e: MouseEvent) => any\n onPress?: (e: GestureResponderEvent) => any\n onPressIn?: (e: GestureResponderEvent) => any\n onPressOut?: (e: GestureResponderEvent) => any\n // WEB ONLY\n onMouseEnter?: (e: MouseEvent) => any\n onMouseLeave?: (e: MouseEvent) => any\n onMouseDown?: (e: MouseEvent) => any\n // WEB STYLES\n userSelect?: Properties['userSelect']\n cursor?: Properties['cursor']\n}\n\nexport type ReactComponentWithRef<Props, Ref> = React.ForwardRefExoticComponent<\n Props & React.RefAttributes<Ref>\n>\n\nexport type ConfigListener = (conf: TamaguiInternalConfig) => void\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport type VariableVal = number | string | Variable\nexport type VariableColorVal = string | Variable\n\ntype GenericKey = string | number | symbol\n\nexport interface CreateTokens<Val extends VariableVal = VariableVal> {\n color: { [key: GenericKey]: Val }\n space: { [key: GenericKey]: Val }\n size: { [key: GenericKey]: Val }\n radius: { [key: GenericKey]: Val }\n zIndex: { [key: GenericKey]: Val }\n}\n\nexport type TamaguiBaseTheme = {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n background: VariableColorVal\n backgroundHover: VariableColorVal\n backgroundPress: VariableColorVal\n backgroundFocus: VariableColorVal\n color: VariableColorVal\n colorHover: VariableColorVal\n colorPress: VariableColorVal\n colorFocus: VariableColorVal\n borderColor: VariableColorVal\n borderColorHover: VariableColorVal\n borderColorPress: VariableColorVal\n borderColorFocus: VariableColorVal\n shadowColor: VariableColorVal\n shadowColorHover: VariableColorVal\n shadowColorPress: VariableColorVal\n shadowColorFocus: VariableColorVal\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]:\n | Partial<TamaguiBaseTheme> & {\n [key: string]: VariableVal\n }\n}\ntype GenericShorthands = {\n // [key: string]: string\n}\n\ntype GenericMedia<K extends string = string> = {\n // name => media shorthand name (camelCase) => value\n [key in K]: {\n [key: string]: number | string\n }\n}\n\nexport type GenericFonts = {\n [key: string]: GenericFont\n}\n\ntype GenericAnimations = {\n [key: string]:\n | string\n | {\n [key: string]: any\n }\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = Partial<Pick<ThemeProviderProps, 'defaultTheme' | 'disableRootThemeClass'>> & {\n fonts: F\n tokens: A\n themes: B\n shorthands: C\n media: D\n animations: AnimationDriver<E>\n defaultProps?: Record<string, Object>\n}\n\n// for use in creation functions so it doesnt get overwrtitten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia,\n GenericAnimations,\n GenericFonts\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeObject = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\nexport type ThemeName = GetAltThemeNames<keyof Themes>\n// export type ThemeNameWithSubThemes = GetSubThemes<ThemeName>\nexport type ThemeKeys = keyof ThemeObject\nexport type ThemeTokens = `$${ThemeKeys}`\nexport type AnimationKeys = Omit<GetAnimationKeys<TamaguiConfig>, number>\n\ntype GetAltThemeNames<S> = (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S) | S\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = CreateTamaguiConfig<A, B, C, D, E, F> & {\n // TODO need to make it this but this breaks types, revisit\n // animations: E //AnimationDriver<E>\n Provider: (props: TamaguiProviderProps) => any\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n tokensParsed: CreateTokens<Variable>\n themeConfig: any\n fontsParsed: GenericFonts\n getCSS: () => string\n parsed: boolean\n\n // just passed in from CreateTamaguiProps\n themeClassNameOnRoot?: boolean\n}\n\nexport type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']['animations']\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends TamaguiComponent> = A extends React.FunctionComponent<infer Props>\n ? Props\n : unknown\n\nexport type GenericFont<Key extends number | string = number | string> = {\n size: { [key in Key]: number | Variable }\n lineHeight: Partial<{ [key in Key]: number | Variable }>\n letterSpacing: Partial<{ [key in Key]: number | Variable }>\n weight: Partial<{ [key in Key]: number | string | Variable }>\n family: string | Variable\n style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>\n transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>\n color?: Partial<{ [key in Key]: string | Variable }>\n}\n\n// media\nexport type MediaKeys = keyof Media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryKey = keyof Media\nexport type MediaPropKeys = `$${MediaQueryKey}`\nexport type MediaQueryState = { [key in MediaPropKeys]: boolean }\nexport type MediaProps<A> = {\n [key in MediaPropKeys]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\nexport type ConfigureMediaQueryOptions = {\n queries?: MediaQueries\n defaultActive?: MediaQueryKey[]\n}\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n// animation=\"bouncy\"\n// animation={['bouncy', { }]}\n// { all: 'name' }\n\n// TODO can override for better types\nexport type AnimationConfigType = any\n\nexport type AnimationProp =\n | AnimationKeys\n | {\n [key: string]:\n | AnimationKeys\n | {\n type: AnimationKeys\n [key: string]: any\n }\n }\n | [\n AnimationKeys,\n {\n [key: string]:\n | AnimationKeys\n | {\n type?: AnimationKeys\n [key: string]: any\n }\n }\n ]\n\ntype GetTokenFontKeysFor<\n A extends\n | 'size'\n | 'weight'\n | 'letterSpacing'\n | 'family'\n | 'lineHeight'\n | 'transform'\n | 'style'\n | 'color'\n> = keyof TamaguiConfig['fonts']['body'][A]\n\ntype GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`\n\n// base tokens\nexport type SizeTokens = GetTokenString<keyof Tokens['size']> | number\nexport type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean\nexport type ColorTokens =\n | GetTokenString<keyof Tokens['color']>\n | GetTokenString<keyof ThemeObject>\n | CSSColorNames\nexport type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number\nexport type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number\n\n// font tokens\nexport type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>\nexport type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number\nexport type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number\nexport type FontWeightTokens =\n | `$${GetTokenFontKeysFor<'weight'>}`\n | `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`\nexport type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number\nexport type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number\nexport type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']\nexport type FontTransformTokens =\n | `$${GetTokenFontKeysFor<'transform'>}`\n | TextStyle['textTransform']\n\n//\n// adds theme short values to relevant props\n//\n\nexport type ThemeValueByCategory<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends 'size'\n ? SizeTokens\n : K extends 'font'\n ? FontTokens\n : K extends 'fontSize'\n ? FontSizeTokens\n : K extends 'space'\n ? SpaceTokens\n : K extends 'color'\n ? ColorTokens\n : K extends 'zIndex'\n ? ZIndexTokens\n : K extends 'lineHeight'\n ? FontLineHeightTokens\n : K extends 'fontWeight'\n ? FontWeightTokens\n : K extends 'letterSpacing'\n ? FontLetterSpacingTokens\n : {}\n\ntype FontKeys = 'fontFamily'\ntype FontSizeKeys = 'fontSize'\ntype FontWeightKeys = 'fontWeight'\ntype FontLetterSpacingKeys = 'letterSpacing'\ntype LineHeightKeys = 'lineHeight'\ntype ZIndexKeys = 'zIndex'\n\nexport type ThemeValueGet<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends SizeKeys\n ? SizeTokens\n : K extends FontKeys\n ? FontTokens\n : K extends FontSizeKeys\n ? FontSizeTokens\n : K extends SpaceKeys\n ? K extends 'shadowOffset'\n ? { width: SpaceTokens; height: SpaceTokens }\n : SpaceTokens\n : K extends ColorKeys\n ? ColorTokens\n : K extends ZIndexKeys\n ? ZIndexTokens\n : K extends LineHeightKeys\n ? FontLineHeightTokens\n : K extends FontWeightKeys\n ? FontWeightTokens\n : K extends FontLetterSpacingKeys\n ? FontLetterSpacingTokens\n : never\n\nexport type ThemeValueFallback = UnionableString | Variable\n\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]: ThemeValueGet<K> extends never\n ? T[K]\n : ThemeValueGet<K> | Exclude<T[K], string> | ThemeValueFallback\n}\n\n// adds shorthand props\nexport type WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n// adds pseudo props\nexport type PseudoProps<A> = {\n hoverStyle?: A | null\n pressStyle?: A | null\n focusStyle?: A | null\n exitStyle?: A | null\n enterStyle?: A | null\n}\n\nexport type PseudoPropKeys = keyof PseudoProps<any>\n\nexport type PseudoStyles = {\n hoverStyle?: ViewStyle\n pressStyle?: ViewStyle\n focusStyle?: ViewStyle\n enterStyle?: ViewStyle\n exitStyle?: ViewStyle\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// combines all of theme, shorthands, pseudos...\n//\ntype WithThemeShorthandsAndPseudos<A extends object> =\n | WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>\n\n//\n// ... media queries and animations\n//\ntype WithThemeShorthandsPseudosMediaAnimation<A extends object> = WithThemeShorthandsAndPseudos<A> &\n MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n//\n// Stack\n//\n\ntype WebOnlyStyleProps = {\n // WEB ONLY\n cursor?: string\n // WEB ONLY\n contain?: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'paint' | string\n // WEB ONLY values: inherit, inline, block, content\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n // WEB ONLY pointerEvents can be a style prop\n pointerEvents?: ViewProps['pointerEvents']\n}\n\nexport type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &\n TransformStyleProps &\n WebOnlyStyleProps\n\nexport type StackPropsBaseShared = Omit<ViewProps, 'display' | 'children'> &\n RNWViewProps &\n TamaguiComponentPropsBase\n\nexport type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>\nexport type StackPropsBase = StackPropsBaseShared & WithThemeAndShorthands<StackStylePropsBase>\nexport type StackProps = StackPropsBaseShared & StackStyleProps\n\nexport type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (\n event: infer Event\n) => void\n ? Event\n : never\n\n//\n// Text props\n//\n\nexport type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &\n TransformStyleProps &\n WebOnlyStyleProps & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n textOverflow?: Properties['textOverflow']\n whiteSpace?: Properties['whiteSpace']\n wordWrap?: Properties['wordWrap']\n }\n\nexport type TextPropsBaseShared = Omit<ReactTextProps, 'children'> &\n RNWTextProps &\n TamaguiComponentPropsBase\nexport type TextPropsBase = TextPropsBaseShared & WithThemeAndShorthands<TextStylePropsBase>\nexport type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>\nexport type TextProps = TextPropsBaseShared & TextStyleProps\n\n// could actually infer from parent\nexport type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<\n Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase\n>\n\n//\n// StaticComponent\n//\n\nexport type TamaguiComponent<\n Props = any,\n Ref = any,\n BaseProps = {},\n VariantProps = {}\n> = ReactComponentWithRef<Props, Ref> & StaticComponentObject\n\ntype StaticComponentObject = {\n staticConfig: StaticConfig\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: Partial<StaticConfig>) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n disableInjectCSS?: boolean\n children?: React.ReactNode\n}\n\nexport type PropMapper = (\n key: string,\n value: any,\n theme: ThemeObject,\n props: Record<string, any>,\n state: Partial<SplitStyleState>,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => undefined | [string, any][]\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: PropMapper\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type GenericVariantDefinitions = {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfig = {\n Component?: React.FunctionComponent<any> & StaticComponentObject\n\n variants?: GenericVariantDefinitions\n\n /**\n * Used for applying sub theme style\n */\n componentName?: string\n\n /**\n * (compiler) If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /**\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /**\n * Attempts to attach focus styles at runtime (useful for native)\n */\n isInput?: boolean\n\n /**\n * React native web images need special handling for className support\n */\n isImage?: boolean\n\n /**\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /**\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps?: any\n\n /**\n * (compiler) If these props are encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /**\n * (compiler) If these props are encountered, leave them un-extracted.\n */\n inlineProps?: Set<string>\n\n /**\n * (compiler) If not flattening, leave this prop as original value.\n * Only applies to style attributes\n */\n inlineWhenUnflattened?: Set<string>\n\n /**\n * (compiler) A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /**\n * Auto-detected, but can ovverride. Wraps children to space them on top\n */\n isZStack?: boolean\n\n /**\n * Merges into defaultProps later on, used internally yonly\n */\n defaultVariants?: { [key: string]: any }\n\n /**\n * Auto-detect, but can ovverride, passes styles properly to react-native-web\n */\n isReactNativeWeb?: boolean\n\n /**\n * Used internally to keep reference to the original rnw component\n */\n reactNativeWebComponent?: any\n\n /**\n * Memoize the component\n */\n memo?: boolean\n\n /**\n * Auto-detect, but can ovverride, passes styles properly to react-native-web\n */\n isTamagui?: boolean\n\n /**\n * Used internally to handle extractable HoC separate\n */\n isExtractable?: boolean\n\n /**\n * Used insternally to attach default props to names\n */\n parentNames?: string[]\n}\n\n/**\n * --------------------------------------------\n * variants\n * --------------------------------------------\n */\n\nexport type StylableComponent =\n | TamaguiComponent\n | React.Component\n | React.ForwardRefExoticComponent<any>\n | (new (props: any) => any)\n | typeof View\n | typeof Text\n | typeof TextInput\n | typeof Image\n\nexport type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer BaseProps\n>\n ? BaseProps\n : never\n\nexport type GetProps<A extends StylableComponent> = A extends TamaguiComponent<infer Props>\n ? Props\n : A extends React.Component<infer Props>\n ? GetGenericComponentTamaguiProps<Props>\n : A extends new (props: infer Props) => any\n ? GetGenericComponentTamaguiProps<Props>\n : {}\n\ntype GetGenericComponentTamaguiProps<P> = P &\n Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>\n\nexport type SpreadKeys =\n | '...fontSize'\n | '...fontStyle'\n | '...fontTransform'\n | '...lineHeight'\n | '...letterSpacing'\n | '...size'\n | '...color'\n | '...zIndex'\n | '...theme'\n | '...radius'\n\nexport type VariantDefinitions<\n Parent extends StylableComponent = TamaguiComponent,\n MyProps extends Object = GetProps<Parent>,\n Val = any\n> = VariantDefinitionFromProps<MyProps, Val>\n\nexport type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object\n ? {\n [propName: string]:\n | VariantSpreadFunction<MyProps, Val>\n | ({\n [Key in SpreadKeys]?: Key extends '...fontSize'\n ? FontSizeVariantSpreadFunction<MyProps>\n : Key extends '...size'\n ? SizeVariantSpreadFunction<MyProps>\n : Key extends '...color'\n ? ColorVariantSpreadFunction<MyProps>\n : Key extends '...lineHeight'\n ? FontLineHeightVariantSpreadFunction<MyProps>\n : Key extends '...fontTransform'\n ? FontTransformVariantSpreadFunction<MyProps>\n : Key extends '...fontStyle'\n ? FontStyleVariantSpreadFunction<MyProps>\n : Key extends '...letterSpacing'\n ? FontLetterSpacingVariantSpreadFunction<MyProps>\n : Key extends '...zIndex'\n ? ZIndexVariantSpreadFunction<MyProps>\n : Key extends '...radius'\n ? RadiusVariantSpreadFunction<MyProps>\n : Key extends '...theme'\n ? ThemeVariantSpreadFunction<MyProps>\n : never\n } & {\n [Key in string | number]?: MyProps | VariantSpreadFunction<MyProps, Val>\n } & {\n [Key in VariantTypeKeys]?: Key extends ':number'\n ? VariantSpreadFunction<MyProps, number>\n : Key extends ':boolean'\n ? VariantSpreadFunction<MyProps, boolean>\n : Key extends ':string'\n ? VariantSpreadFunction<MyProps, string>\n : never\n })\n }\n : never\n\nexport type GenericStackVariants = VariantDefinitionFromProps<StackProps, any>\nexport type GenericTextVariants = VariantDefinitionFromProps<StackProps, any>\n\nexport type GetVariantProps<Variants> = {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n}\n\nexport type VariantSpreadExtras<Props> = {\n fonts: TamaguiConfig['fonts']\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: Props\n}\n\ntype PropLike = { [key: string]: any }\n\nexport type VariantSpreadFunction<Props extends PropLike, Val = any> = (\n val: Val,\n config: VariantSpreadExtras<Props>\n) =>\n | {\n [Key in keyof Props]: Props[Key] | Variable\n }\n | null\n | undefined\n\nexport type VariantTypeKeys = ':string' | ':boolean' | ':number'\n\nexport type GetVariantValues<Key> = Key extends `...${infer VariantSpread}`\n ? ThemeValueByCategory<VariantSpread>\n : Key extends 'true' | 'false'\n ? boolean\n : Key extends ':string'\n ? string\n : Key extends ':boolean'\n ? boolean\n : Key extends ':number'\n ? number\n : Key\n\nexport type FontSizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontSizeTokens\n>\nexport type SizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, SizeTokens>\nexport type ColorVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ColorTokens>\nexport type FontLineHeightVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLineHeightTokens\n>\nexport type FontLetterSpacingVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLetterSpacingTokens\n>\nexport type FontStyleVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontStyleTokens\n>\nexport type FontTransformVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontTransformTokens\n>\nexport type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ZIndexTokens>\nexport type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, RadiusTokens>\nexport type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ThemeTokens>\n\n/**\n * --------------------------------------------\n * end variants\n * --------------------------------------------\n */\n\ntype SizeKeys =\n | 'width'\n | 'height'\n | 'minWidth'\n | 'minHeight'\n | 'maxWidth'\n | 'maxHeight'\n | 'shadowRadius'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n | 'textShadowColor'\n\ntype SpaceKeys =\n | 'space'\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n\ntype CSSColorNames =\n | 'aliceblue'\n | 'antiquewhite'\n | 'aqua'\n | 'aquamarine'\n | 'azure'\n | 'beige'\n | 'bisque'\n | 'black'\n | 'blanchedalmond'\n | 'blue'\n | 'blueviolet'\n | 'brown'\n | 'burlywood'\n | 'cadetblue'\n | 'chartreuse'\n | 'chocolate'\n | 'coral'\n | 'cornflowerblue'\n | 'cornsilk'\n | 'crimson'\n | 'cyan'\n | 'darkblue'\n | 'darkcyan'\n | 'darkgoldenrod'\n | 'darkgray'\n | 'darkgreen'\n | 'darkkhaki'\n | 'darkmagenta'\n | 'darkolivegreen'\n | 'darkorange'\n | 'darkorchid'\n | 'darkred'\n | 'darksalmon'\n | 'darkseagreen'\n | 'darkslateblue'\n | 'darkslategray'\n | 'darkturquoise'\n | 'darkviolet'\n | 'deeppink'\n | 'deepskyblue'\n | 'dimgray'\n | 'dodgerblue'\n | 'firebrick'\n | 'floralwhite'\n | 'forestgreen'\n | 'fuchsia'\n | 'gainsboro'\n | 'ghostwhite'\n | 'gold'\n | 'goldenrod'\n | 'gray'\n | 'green'\n | 'greenyellow'\n | 'honeydew'\n | 'hotpink'\n | 'indianred '\n | 'indigo '\n | 'ivory'\n | 'khaki'\n | 'lavender'\n | 'lavenderblush'\n | 'lawngreen'\n | 'lemonchiffon'\n | 'lightblue'\n | 'lightcoral'\n | 'lightcyan'\n | 'lightgoldenrodyellow'\n | 'lightgrey'\n | 'lightgreen'\n | 'lightpink'\n | 'lightsalmon'\n | 'lightseagreen'\n | 'lightskyblue'\n | 'lightslategray'\n | 'lightsteelblue'\n | 'lightyellow'\n | 'lime'\n | 'limegreen'\n | 'linen'\n | 'magenta'\n | 'maroon'\n | 'mediumaquamarine'\n | 'mediumblue'\n | 'mediumorchid'\n | 'mediumpurple'\n | 'mediumseagreen'\n | 'mediumslateblue'\n | 'mediumspringgreen'\n | 'mediumturquoise'\n | 'mediumvioletred'\n | 'midnightblue'\n | 'mintcream'\n | 'mistyrose'\n | 'moccasin'\n | 'navajowhite'\n | 'navy'\n | 'oldlace'\n | 'olive'\n | 'olivedrab'\n | 'orange'\n | 'orangered'\n | 'orchid'\n | 'palegoldenrod'\n | 'palegreen'\n | 'paleturquoise'\n | 'palevioletred'\n | 'papayawhip'\n | 'peachpuff'\n | 'peru'\n | 'pink'\n | 'plum'\n | 'powderblue'\n | 'purple'\n | 'red'\n | 'rosybrown'\n | 'royalblue'\n | 'saddlebrown'\n | 'salmon'\n | 'sandybrown'\n | 'seagreen'\n | 'seashell'\n | 'sienna'\n | 'silver'\n | 'skyblue'\n | 'slateblue'\n | 'slategray'\n | 'snow'\n | 'springgreen'\n | 'steelblue'\n | 'tan'\n | 'teal'\n | 'thistle'\n | 'tomato'\n | 'turquoise'\n | 'violet'\n | 'wheat'\n | 'white'\n | 'whitesmoke'\n | 'yellow'\n | 'yellowgreen'\n\nexport type TamaguiComponentState = {\n hover: boolean\n press: boolean\n pressIn: boolean\n focus: boolean\n mounted: boolean\n animation?: null | {\n style?: any\n avoidClasses?: boolean\n }\n}\n\nexport type SplitStyleState = TamaguiComponentState & {\n noClassNames?: boolean\n dynamicStylesInline?: boolean\n resolveVariablesAs?: ResolveVariableTypes\n fallbackProps?: Record<string, any>\n}\n\n// Animations:\n\ntype AnimationConfig = {\n [key: string]: any\n}\n\nexport type AnimationDriver<A extends AnimationConfig = AnimationConfig> = {\n avoidClasses?: boolean\n useAnimations: UseAnimationHook\n animations: A\n View?: any\n Text?: any\n}\n\nexport type UseAnimationProps = TamaguiComponentPropsBase & Record<string, any>\n\nexport type UseAnimationHelpers = {\n staticConfig: StaticConfigParsed\n getStyle: (props?: {\n isEntering?: boolean\n isExiting?: boolean\n exitVariant?: string | null\n enterVariant?: string | null\n }) => ViewStyle\n state: SplitStyleState\n pseudos: PseudoProps<ViewStyle>\n // style: ViewStyle | null | undefined\n // isMounted: boolean\n // exitStyle?: ViewStyle | null\n onDidAnimate?: any\n delay?: number\n // mergedStyles(props?: { isExiting?: boolean }): ViewStyle\n}\n\nexport type UseAnimationHook = (\n props: UseAnimationProps,\n helpers: UseAnimationHelpers\n) => {\n style?: StackStylePropsBase | StackStylePropsBase[]\n safeToUnmount?: () => void\n}\n"],
|
|
4
|
+
"sourcesContent": ["// TODO split this into own package @tamagui/types to share with animations packages\n\nimport { Properties } from 'csstype'\nimport React from 'react'\nimport {\n GestureResponderEvent,\n Image,\n TextProps as ReactTextProps,\n Text,\n TextInput,\n TextStyle,\n View,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport { Variable } from './createVariable'\nimport { ResolveVariableTypes } from './helpers/createPropMapper'\nimport { RNWTextProps, RNWViewProps } from './types-rnw'\nimport { ThemeProviderProps } from './views/ThemeProvider'\n\nexport type SpaceDirection = 'vertical' | 'horizontal' | 'both'\n\nexport type TamaguiElement = HTMLElement | View\n\nexport type DebugProp = boolean | 'break' | 'verbose'\n\n//\n// base props that are accepted by createComponent (additional to react-native-web)\n//\nexport type TamaguiComponentPropsBase = {\n asChild?: boolean\n space?: SpaceTokens\n spaceDirection?: SpaceDirection\n separator?: React.ReactNode\n dangerouslySetInnerHTML?: { __html: string }\n animation?: AnimationProp\n animateOnly?: string[]\n children?: any | any[]\n debug?: DebugProp\n disabled?: boolean\n className?: string\n id?: string\n tag?: string\n theme?: ThemeName | null\n componentName?: string\n forceStyle?: 'hover' | 'press' | 'focus'\n onHoverIn?: (e: MouseEvent) => any\n onHoverOut?: (e: MouseEvent) => any\n onPress?: (e: GestureResponderEvent) => any\n onPressIn?: (e: GestureResponderEvent) => any\n onPressOut?: (e: GestureResponderEvent) => any\n // WEB ONLY\n onMouseEnter?: (e: MouseEvent) => any\n onMouseLeave?: (e: MouseEvent) => any\n onMouseDown?: (e: MouseEvent) => any\n // WEB STYLES\n userSelect?: Properties['userSelect']\n cursor?: Properties['cursor']\n}\n\nexport type ReactComponentWithRef<Props, Ref> = React.ForwardRefExoticComponent<\n Props & React.RefAttributes<Ref>\n>\n\nexport type ConfigListener = (conf: TamaguiInternalConfig) => void\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport type VariableVal = number | string | Variable\nexport type VariableColorVal = string | Variable\n\ntype GenericKey = string | number | symbol\n\nexport interface CreateTokens<Val extends VariableVal = VariableVal> {\n color: { [key: GenericKey]: Val }\n space: { [key: GenericKey]: Val }\n size: { [key: GenericKey]: Val }\n radius: { [key: GenericKey]: Val }\n zIndex: { [key: GenericKey]: Val }\n}\n\nexport type TamaguiBaseTheme = {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n background: VariableColorVal\n backgroundHover: VariableColorVal\n backgroundPress: VariableColorVal\n backgroundFocus: VariableColorVal\n color: VariableColorVal\n colorHover: VariableColorVal\n colorPress: VariableColorVal\n colorFocus: VariableColorVal\n borderColor: VariableColorVal\n borderColorHover: VariableColorVal\n borderColorPress: VariableColorVal\n borderColorFocus: VariableColorVal\n shadowColor: VariableColorVal\n shadowColorHover: VariableColorVal\n shadowColorPress: VariableColorVal\n shadowColorFocus: VariableColorVal\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]:\n | Partial<TamaguiBaseTheme> & {\n [key: string]: VariableVal\n }\n}\ntype GenericShorthands = {\n // [key: string]: string\n}\n\ntype GenericMedia<K extends string = string> = {\n // name => media shorthand name (camelCase) => value\n [key in K]: {\n [key: string]: number | string\n }\n}\n\nexport type GenericFonts = {\n [key: string]: GenericFont\n}\n\ntype GenericAnimations = {\n [key: string]:\n | string\n | {\n [key: string]: any\n }\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = Partial<Pick<ThemeProviderProps, 'defaultTheme' | 'disableRootThemeClass'>> & {\n fonts: F\n tokens: A\n themes: B\n shorthands: C\n media: D\n animations: AnimationDriver<E>\n defaultProps?: Record<string, Object>\n}\n\n// for use in creation functions so it doesnt get overwrtitten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia,\n GenericAnimations,\n GenericFonts\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeObject = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\nexport type ThemeName = GetAltThemeNames<keyof Themes>\n// export type ThemeNameWithSubThemes = GetSubThemes<ThemeName>\nexport type ThemeKeys = keyof ThemeObject\nexport type ThemeTokens = `$${ThemeKeys}`\nexport type AnimationKeys = Omit<GetAnimationKeys<TamaguiConfig>, number>\n\ntype GetAltThemeNames<S> = (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S) | S\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = CreateTamaguiConfig<A, B, C, D, E, F> & {\n // TODO need to make it this but this breaks types, revisit\n // animations: E //AnimationDriver<E>\n Provider: (props: TamaguiProviderProps) => any\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n tokensParsed: CreateTokens<Variable>\n themeConfig: any\n fontsParsed: GenericFonts\n getCSS: () => string\n parsed: boolean\n\n // just passed in from CreateTamaguiProps\n themeClassNameOnRoot?: boolean\n}\n\nexport type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']['animations']\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends TamaguiComponent> = A extends React.FunctionComponent<infer Props>\n ? Props\n : unknown\n\nexport type GenericFont<Key extends number | string = number | string> = {\n size: { [key in Key]: number | Variable }\n lineHeight: Partial<{ [key in Key]: number | Variable }>\n letterSpacing: Partial<{ [key in Key]: number | Variable }>\n weight: Partial<{ [key in Key]: number | string | Variable }>\n family: string | Variable\n style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>\n transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>\n color?: Partial<{ [key in Key]: string | Variable }>\n}\n\n// media\nexport type MediaKeys = keyof Media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryKey = keyof Media\nexport type MediaPropKeys = `$${MediaQueryKey}`\nexport type MediaQueryState = { [key in MediaPropKeys]: boolean }\nexport type MediaProps<A> = {\n [key in MediaPropKeys]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\nexport type ConfigureMediaQueryOptions = {\n queries?: MediaQueries\n defaultActive?: MediaQueryKey[]\n}\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n// animation=\"bouncy\"\n// animation={['bouncy', { }]}\n// { all: 'name' }\n\n// TODO can override for better types\nexport type AnimationConfigType = any\n\nexport type AnimationProp =\n | AnimationKeys\n | {\n [key: string]:\n | AnimationKeys\n | {\n type: AnimationKeys\n [key: string]: any\n }\n }\n | [\n AnimationKeys,\n {\n [key: string]:\n | AnimationKeys\n | {\n type?: AnimationKeys\n [key: string]: any\n }\n }\n ]\n\ntype GetTokenFontKeysFor<\n A extends\n | 'size'\n | 'weight'\n | 'letterSpacing'\n | 'family'\n | 'lineHeight'\n | 'transform'\n | 'style'\n | 'color'\n> = keyof TamaguiConfig['fonts']['body'][A]\n\ntype GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`\n\n// base tokens\nexport type SizeTokens = GetTokenString<keyof Tokens['size']> | number\nexport type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean\nexport type ColorTokens =\n | GetTokenString<keyof Tokens['color']>\n | GetTokenString<keyof ThemeObject>\n | CSSColorNames\nexport type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number\nexport type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number\n\n// font tokens\nexport type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>\nexport type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number\nexport type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number\nexport type FontWeightTokens =\n | `$${GetTokenFontKeysFor<'weight'>}`\n | `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`\nexport type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number\nexport type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number\nexport type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']\nexport type FontTransformTokens =\n | `$${GetTokenFontKeysFor<'transform'>}`\n | TextStyle['textTransform']\n\n//\n// adds theme short values to relevant props\n//\n\nexport type ThemeValueByCategory<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends 'size'\n ? SizeTokens\n : K extends 'font'\n ? FontTokens\n : K extends 'fontSize'\n ? FontSizeTokens\n : K extends 'space'\n ? SpaceTokens\n : K extends 'color'\n ? ColorTokens\n : K extends 'zIndex'\n ? ZIndexTokens\n : K extends 'lineHeight'\n ? FontLineHeightTokens\n : K extends 'fontWeight'\n ? FontWeightTokens\n : K extends 'letterSpacing'\n ? FontLetterSpacingTokens\n : {}\n\ntype FontKeys = 'fontFamily'\ntype FontSizeKeys = 'fontSize'\ntype FontWeightKeys = 'fontWeight'\ntype FontLetterSpacingKeys = 'letterSpacing'\ntype LineHeightKeys = 'lineHeight'\ntype ZIndexKeys = 'zIndex'\n\nexport type ThemeValueGet<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends SizeKeys\n ? SizeTokens\n : K extends FontKeys\n ? FontTokens\n : K extends FontSizeKeys\n ? FontSizeTokens\n : K extends SpaceKeys\n ? K extends 'shadowOffset'\n ? { width: SpaceTokens; height: SpaceTokens }\n : SpaceTokens\n : K extends ColorKeys\n ? ColorTokens\n : K extends ZIndexKeys\n ? ZIndexTokens\n : K extends LineHeightKeys\n ? FontLineHeightTokens\n : K extends FontWeightKeys\n ? FontWeightTokens\n : K extends FontLetterSpacingKeys\n ? FontLetterSpacingTokens\n : never\n\nexport type ThemeValueFallback = UnionableString | Variable\n\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]: ThemeValueGet<K> extends never\n ? T[K]\n : ThemeValueGet<K> | Exclude<T[K], string> | ThemeValueFallback\n}\n\n// adds shorthand props\nexport type WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n// adds pseudo props\nexport type PseudoProps<A> = {\n hoverStyle?: A | null\n pressStyle?: A | null\n focusStyle?: A | null\n exitStyle?: A | null\n enterStyle?: A | null\n}\n\nexport type PseudoPropKeys = keyof PseudoProps<any>\n\nexport type PseudoStyles = {\n hoverStyle?: ViewStyle\n pressStyle?: ViewStyle\n focusStyle?: ViewStyle\n enterStyle?: ViewStyle\n exitStyle?: ViewStyle\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// combines all of theme, shorthands, pseudos...\n//\ntype WithThemeShorthandsAndPseudos<A extends object> =\n | WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>\n\n//\n// ... media queries and animations\n//\ntype WithThemeShorthandsPseudosMediaAnimation<A extends object> = WithThemeShorthandsAndPseudos<A> &\n MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n//\n// Stack\n//\n\ntype WebOnlyStyleProps = {\n // WEB ONLY\n cursor?: string\n // WEB ONLY\n contain?: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'paint' | string\n // WEB ONLY values: inherit, inline, block, content\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n // WEB ONLY pointerEvents can be a style prop\n pointerEvents?: ViewProps['pointerEvents']\n}\n\nexport type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &\n TransformStyleProps &\n WebOnlyStyleProps\n\nexport type StackPropsBaseShared = Omit<ViewProps, 'display' | 'children'> &\n RNWViewProps &\n TamaguiComponentPropsBase\n\nexport type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>\nexport type StackPropsBase = StackPropsBaseShared & WithThemeAndShorthands<StackStylePropsBase>\nexport type StackProps = StackPropsBaseShared & StackStyleProps\n\nexport type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (\n event: infer Event\n) => void\n ? Event\n : never\n\n//\n// Text props\n//\n\nexport type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &\n TransformStyleProps &\n WebOnlyStyleProps & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n textOverflow?: Properties['textOverflow']\n whiteSpace?: Properties['whiteSpace']\n wordWrap?: Properties['wordWrap']\n }\n\nexport type TextPropsBaseShared = Omit<ReactTextProps, 'children'> &\n RNWTextProps &\n TamaguiComponentPropsBase\nexport type TextPropsBase = TextPropsBaseShared & WithThemeAndShorthands<TextStylePropsBase>\nexport type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>\nexport type TextProps = TextPropsBaseShared & TextStyleProps\n\n// could actually infer from parent\nexport type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<\n Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase\n>\n\n//\n// StaticComponent\n//\n\nexport type TamaguiComponent<\n Props = any,\n Ref = any,\n BaseProps = {},\n VariantProps = {}\n> = ReactComponentWithRef<Props, Ref> & StaticComponentObject\n\ntype StaticComponentObject = {\n staticConfig: StaticConfig\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: Partial<StaticConfig>) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n disableInjectCSS?: boolean\n children?: React.ReactNode\n}\n\nexport type PropMapper = (\n key: string,\n value: any,\n theme: ThemeObject,\n props: Record<string, any>,\n state: Partial<SplitStyleState>,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => undefined | [string, any][]\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: PropMapper\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type GenericVariantDefinitions = {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfig = {\n Component?: React.FunctionComponent<any> & StaticComponentObject\n\n variants?: GenericVariantDefinitions\n\n /**\n * Used for applying sub theme style\n */\n componentName?: string\n\n /**\n * (compiler) If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /**\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /**\n * Attempts to attach focus styles at runtime (useful for native)\n */\n isInput?: boolean\n\n /**\n * React native web images need special handling for className support\n */\n isImage?: boolean\n\n /**\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /**\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps?: any\n\n /**\n * (compiler) If these props are encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /**\n * (compiler) If these props are encountered, leave them un-extracted.\n */\n inlineProps?: Set<string>\n\n /**\n * (compiler) If not flattening, leave this prop as original value.\n * Only applies to style attributes\n */\n inlineWhenUnflattened?: Set<string>\n\n /**\n * (compiler) A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /**\n * Auto-detected, but can ovverride. Wraps children to space them on top\n */\n isZStack?: boolean\n\n /**\n * Merges into defaultProps later on, used internally yonly\n */\n defaultVariants?: { [key: string]: any }\n\n /**\n * Auto-detect, but can ovverride, passes styles properly to react-native-web\n */\n isReactNativeWeb?: boolean\n\n /**\n * Used internally to keep reference to the original rnw component\n */\n reactNativeWebComponent?: any\n\n /**\n * Memoize the component\n */\n memo?: boolean\n\n /**\n * Auto-detect, but can ovverride, passes styles properly to react-native-web\n */\n isTamagui?: boolean\n\n /**\n * Used internally to handle extractable HoC separate\n */\n isExtractable?: boolean\n\n /**\n * Used insternally to attach default props to names\n */\n parentNames?: string[]\n}\n\n/**\n * --------------------------------------------\n * variants\n * --------------------------------------------\n */\n\nexport type StylableComponent =\n | TamaguiComponent\n | React.Component\n | React.ForwardRefExoticComponent<any>\n | (new (props: any) => any)\n | typeof View\n | typeof Text\n | typeof TextInput\n | typeof Image\n\nexport type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer BaseProps\n>\n ? BaseProps\n : never\n\nexport type GetProps<A extends StylableComponent> = A extends TamaguiComponent<infer Props>\n ? Props\n : A extends React.Component<infer Props>\n ? GetGenericComponentTamaguiProps<Props>\n : A extends new (props: infer Props) => any\n ? GetGenericComponentTamaguiProps<Props>\n : {}\n\ntype GetGenericComponentTamaguiProps<P> = P &\n Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>\n\nexport type SpreadKeys =\n | '...fontSize'\n | '...fontStyle'\n | '...fontTransform'\n | '...lineHeight'\n | '...letterSpacing'\n | '...size'\n | '...color'\n | '...zIndex'\n | '...theme'\n | '...radius'\n\nexport type VariantDefinitions<\n Parent extends StylableComponent = TamaguiComponent,\n MyProps extends Object = GetProps<Parent>,\n Val = any\n> = VariantDefinitionFromProps<MyProps, Val>\n\nexport type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object\n ? {\n [propName: string]:\n | VariantSpreadFunction<MyProps, Val>\n | ({\n [Key in SpreadKeys]?: Key extends '...fontSize'\n ? FontSizeVariantSpreadFunction<MyProps>\n : Key extends '...size'\n ? SizeVariantSpreadFunction<MyProps>\n : Key extends '...color'\n ? ColorVariantSpreadFunction<MyProps>\n : Key extends '...lineHeight'\n ? FontLineHeightVariantSpreadFunction<MyProps>\n : Key extends '...fontTransform'\n ? FontTransformVariantSpreadFunction<MyProps>\n : Key extends '...fontStyle'\n ? FontStyleVariantSpreadFunction<MyProps>\n : Key extends '...letterSpacing'\n ? FontLetterSpacingVariantSpreadFunction<MyProps>\n : Key extends '...zIndex'\n ? ZIndexVariantSpreadFunction<MyProps>\n : Key extends '...radius'\n ? RadiusVariantSpreadFunction<MyProps>\n : Key extends '...theme'\n ? ThemeVariantSpreadFunction<MyProps>\n : never\n } & {\n [Key in string | number]?: MyProps | VariantSpreadFunction<MyProps, Val>\n } & {\n [Key in VariantTypeKeys]?: Key extends ':number'\n ? VariantSpreadFunction<MyProps, number>\n : Key extends ':boolean'\n ? VariantSpreadFunction<MyProps, boolean>\n : Key extends ':string'\n ? VariantSpreadFunction<MyProps, string>\n : never\n })\n }\n : never\n\nexport type GenericStackVariants = VariantDefinitionFromProps<StackProps, any>\nexport type GenericTextVariants = VariantDefinitionFromProps<StackProps, any>\n\nexport type GetVariantProps<Variants> = {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n}\n\nexport type VariantSpreadExtras<Props> = {\n fonts: TamaguiConfig['fonts']\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: Props\n}\n\ntype PropLike = { [key: string]: any }\n\nexport type VariantSpreadFunction<Props extends PropLike, Val = any> = (\n val: Val,\n config: VariantSpreadExtras<Props>\n) =>\n | {\n [Key in keyof Props]: Props[Key] | Variable\n }\n | null\n | undefined\n\nexport type VariantTypeKeys = ':string' | ':boolean' | ':number'\n\nexport type GetVariantValues<Key> = Key extends `...${infer VariantSpread}`\n ? ThemeValueByCategory<VariantSpread>\n : Key extends 'true' | 'false'\n ? boolean\n : Key extends ':string'\n ? string\n : Key extends ':boolean'\n ? boolean\n : Key extends ':number'\n ? number\n : Key\n\nexport type FontSizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontSizeTokens\n>\nexport type SizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, SizeTokens>\nexport type ColorVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ColorTokens>\nexport type FontLineHeightVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLineHeightTokens\n>\nexport type FontLetterSpacingVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontLetterSpacingTokens\n>\nexport type FontStyleVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontStyleTokens\n>\nexport type FontTransformVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontTransformTokens\n>\nexport type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ZIndexTokens>\nexport type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, RadiusTokens>\nexport type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<A, ThemeTokens>\n\n/**\n * --------------------------------------------\n * end variants\n * --------------------------------------------\n */\n\ntype SizeKeys =\n | 'width'\n | 'height'\n | 'minWidth'\n | 'minHeight'\n | 'maxWidth'\n | 'maxHeight'\n | 'shadowRadius'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n | 'textShadowColor'\n\ntype SpaceKeys =\n | 'space'\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n\ntype CSSColorNames =\n | 'aliceblue'\n | 'antiquewhite'\n | 'aqua'\n | 'aquamarine'\n | 'azure'\n | 'beige'\n | 'bisque'\n | 'black'\n | 'blanchedalmond'\n | 'blue'\n | 'blueviolet'\n | 'brown'\n | 'burlywood'\n | 'cadetblue'\n | 'chartreuse'\n | 'chocolate'\n | 'coral'\n | 'cornflowerblue'\n | 'cornsilk'\n | 'crimson'\n | 'cyan'\n | 'darkblue'\n | 'darkcyan'\n | 'darkgoldenrod'\n | 'darkgray'\n | 'darkgreen'\n | 'darkkhaki'\n | 'darkmagenta'\n | 'darkolivegreen'\n | 'darkorange'\n | 'darkorchid'\n | 'darkred'\n | 'darksalmon'\n | 'darkseagreen'\n | 'darkslateblue'\n | 'darkslategray'\n | 'darkturquoise'\n | 'darkviolet'\n | 'deeppink'\n | 'deepskyblue'\n | 'dimgray'\n | 'dodgerblue'\n | 'firebrick'\n | 'floralwhite'\n | 'forestgreen'\n | 'fuchsia'\n | 'gainsboro'\n | 'ghostwhite'\n | 'gold'\n | 'goldenrod'\n | 'gray'\n | 'green'\n | 'greenyellow'\n | 'honeydew'\n | 'hotpink'\n | 'indianred '\n | 'indigo '\n | 'ivory'\n | 'khaki'\n | 'lavender'\n | 'lavenderblush'\n | 'lawngreen'\n | 'lemonchiffon'\n | 'lightblue'\n | 'lightcoral'\n | 'lightcyan'\n | 'lightgoldenrodyellow'\n | 'lightgrey'\n | 'lightgreen'\n | 'lightpink'\n | 'lightsalmon'\n | 'lightseagreen'\n | 'lightskyblue'\n | 'lightslategray'\n | 'lightsteelblue'\n | 'lightyellow'\n | 'lime'\n | 'limegreen'\n | 'linen'\n | 'magenta'\n | 'maroon'\n | 'mediumaquamarine'\n | 'mediumblue'\n | 'mediumorchid'\n | 'mediumpurple'\n | 'mediumseagreen'\n | 'mediumslateblue'\n | 'mediumspringgreen'\n | 'mediumturquoise'\n | 'mediumvioletred'\n | 'midnightblue'\n | 'mintcream'\n | 'mistyrose'\n | 'moccasin'\n | 'navajowhite'\n | 'navy'\n | 'oldlace'\n | 'olive'\n | 'olivedrab'\n | 'orange'\n | 'orangered'\n | 'orchid'\n | 'palegoldenrod'\n | 'palegreen'\n | 'paleturquoise'\n | 'palevioletred'\n | 'papayawhip'\n | 'peachpuff'\n | 'peru'\n | 'pink'\n | 'plum'\n | 'powderblue'\n | 'purple'\n | 'red'\n | 'rosybrown'\n | 'royalblue'\n | 'saddlebrown'\n | 'salmon'\n | 'sandybrown'\n | 'seagreen'\n | 'seashell'\n | 'sienna'\n | 'silver'\n | 'skyblue'\n | 'slateblue'\n | 'slategray'\n | 'snow'\n | 'springgreen'\n | 'steelblue'\n | 'tan'\n | 'teal'\n | 'thistle'\n | 'tomato'\n | 'turquoise'\n | 'violet'\n | 'wheat'\n | 'white'\n | 'whitesmoke'\n | 'yellow'\n | 'yellowgreen'\n\nexport type TamaguiComponentState = {\n hover: boolean\n press: boolean\n pressIn: boolean\n focus: boolean\n mounted: boolean\n animation?: null | {\n style?: any\n avoidClasses?: boolean\n }\n}\n\nexport type SplitStyleState = TamaguiComponentState & {\n noClassNames?: boolean\n dynamicStylesInline?: boolean\n resolveVariablesAs?: ResolveVariableTypes\n fallbackProps?: Record<string, any>\n}\n\n// Animations:\n\ntype AnimationConfig = {\n [key: string]: any\n}\n\nexport type AnimationDriver<A extends AnimationConfig = AnimationConfig> = {\n avoidClasses?: boolean\n useAnimations: UseAnimationHook\n animations: A\n View?: any\n Text?: any\n}\n\nexport type UseAnimationProps = TamaguiComponentPropsBase & Record<string, any>\n\nexport type UseAnimationHelpers = {\n staticConfig: StaticConfigParsed\n getStyle: (props?: {\n isEntering?: boolean\n isExiting?: boolean\n exitVariant?: string | null\n enterVariant?: string | null\n }) => ViewStyle\n state: SplitStyleState\n pseudos: PseudoProps<ViewStyle>\n // style: ViewStyle | null | undefined\n // isMounted: boolean\n // exitStyle?: ViewStyle | null\n onDidAnimate?: any\n delay?: number\n // mergedStyles(props?: { isExiting?: boolean }): ViewStyle\n}\n\nexport type UseAnimationHook = (\n props: UseAnimationProps,\n helpers: UseAnimationHelpers\n) => {\n style?: StackStylePropsBase | StackStylePropsBase[]\n safeToUnmount?: () => void\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/ThemeManager.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
var __accessCheck = (obj, member, msg) => {
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateAdd = (obj, member, value) => {
|
|
6
|
-
if (member.has(obj))
|
|
7
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
9
|
-
};
|
|
10
|
-
var __privateMethod = (obj, member, method) => {
|
|
11
|
-
__accessCheck(obj, member, "access private method");
|
|
12
|
-
return method;
|
|
13
|
-
};
|
|
14
|
-
var _getClassName, getClassName_fn;
|
|
15
1
|
import { createContext } from "react";
|
|
16
2
|
import { getThemes } from "./conf";
|
|
17
3
|
import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from "./constants/constants";
|
|
@@ -21,7 +7,6 @@ class ThemeManager {
|
|
|
21
7
|
this.theme = theme;
|
|
22
8
|
this.parentManager = parentManager;
|
|
23
9
|
this.reset = reset;
|
|
24
|
-
__privateAdd(this, _getClassName);
|
|
25
10
|
this.keys = /* @__PURE__ */ new Map();
|
|
26
11
|
this.listeners = /* @__PURE__ */ new Map();
|
|
27
12
|
this.themeListeners = /* @__PURE__ */ new Set();
|
|
@@ -87,7 +72,7 @@ class ThemeManager {
|
|
|
87
72
|
return {
|
|
88
73
|
name,
|
|
89
74
|
theme: themes[name],
|
|
90
|
-
className:
|
|
75
|
+
className: this.#getClassName(name)
|
|
91
76
|
};
|
|
92
77
|
}
|
|
93
78
|
const parentIsReset = (_a = this.parentManager) == null ? void 0 : _a.reset;
|
|
@@ -99,7 +84,7 @@ class ThemeManager {
|
|
|
99
84
|
];
|
|
100
85
|
for (const name2 of names) {
|
|
101
86
|
if (name2 in themes) {
|
|
102
|
-
const className =
|
|
87
|
+
const className = this.#getClassName(name2);
|
|
103
88
|
return { name: name2, theme: themes[name2], className };
|
|
104
89
|
}
|
|
105
90
|
}
|
|
@@ -146,9 +131,12 @@ class ThemeManager {
|
|
|
146
131
|
return {
|
|
147
132
|
name: nextName,
|
|
148
133
|
theme,
|
|
149
|
-
className:
|
|
134
|
+
className: this.#getClassName(nextName)
|
|
150
135
|
};
|
|
151
136
|
}
|
|
137
|
+
#getClassName(name) {
|
|
138
|
+
return `${THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace("light_", "").replace("dark_", "");
|
|
139
|
+
}
|
|
152
140
|
track(uuid, keys) {
|
|
153
141
|
if (!this.name)
|
|
154
142
|
return;
|
|
@@ -180,10 +168,6 @@ class ThemeManager {
|
|
|
180
168
|
};
|
|
181
169
|
}
|
|
182
170
|
}
|
|
183
|
-
_getClassName = new WeakSet();
|
|
184
|
-
getClassName_fn = function(name) {
|
|
185
|
-
return `${THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace("light_", "").replace("dark_", "");
|
|
186
|
-
};
|
|
187
171
|
const ThemeManagerContext = createContext(null);
|
|
188
172
|
const emptyManager = new ThemeManager();
|
|
189
173
|
const withoutComponentName = (name) => name.replace(/(\_[A-Z][a-zA-Z]+)+$/g, "");
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ThemeManager.tsx"],
|
|
4
4
|
"sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './constants/constants'\nimport { ThemeObject, Themes } from './types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n}\n\nexport type GetNextThemeProps = {\n themes?: Themes\n name?: string | null\n componentName?: string | null\n reset?: boolean\n}\n\nexport class ThemeManager {\n keys = new Map<any, Set<string>>()\n listeners = new Map<any, Function>()\n themeListeners = new Set<ThemeListener>()\n className: string | null = null\n\n constructor(\n public name: string = '',\n public theme: ThemeObject | null = null,\n public parentManager: ThemeManager | null = null,\n public reset: boolean = false\n ) {\n // find the nearest different parentManager\n let parent = parentManager\n let tries = 0\n while (true) {\n tries++\n if (tries > 10) {\n throw new Error(`Nested 10 of the same theme in a row, likely error`)\n }\n if (!parent) break\n if (parent.name === name) {\n // go up if same\n parent = parent.parentManager\n } else {\n this.parentManager = parent\n break\n }\n }\n }\n\n get parentName() {\n return this.parentManager?.name || null\n }\n\n get fullName(): string {\n return this.getNextTheme().name || this.name || ''\n // const parentName = this.parentManager?.fullName || ''\n // const name = this.name || ''\n // const parts = [...new Set([...`${parentName}_${name}`.split('_')])].filter(Boolean)\n // return parts.join('_')\n }\n\n // gets value going up to parents\n getValue(key: string) {\n let theme = this.theme\n let manager = this as ThemeManager | null\n while (true) {\n if (!theme) return\n if (key in theme) {\n return theme[key]\n }\n manager = this.parentManager\n if (!manager) {\n return\n }\n if (manager.theme === theme) {\n return\n }\n theme = manager.theme\n }\n }\n\n update({ name, theme, className }: SetActiveThemeProps = {}) {\n // className compare on web, avoids light/dark re-renders\n const nameChanged = name !== this.name\n if (!nameChanged) {\n return false\n }\n this.className = className || null\n this.name = name || ''\n this.theme = theme\n this.notifyListeners()\n return true\n }\n\n getNextTheme(props: GetNextThemeProps = {}, debug?: any) {\n const { themes = getThemes(), name, componentName } = props\n\n if (props.reset && name) {\n return {\n name: name,\n theme: themes[name],\n className: this.#getClassName(name),\n }\n }\n\n const parentIsReset = this.parentManager?.reset\n\n if (!name) {\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${this.name}_${componentName}`,\n `${withoutComponentName(this.name)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n const className = this.#getClassName(name)\n return { name, theme: themes[name], className }\n }\n }\n }\n return {\n name: this.name,\n theme: this.theme,\n }\n }\n\n let nextName = name || this.name || ''\n let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName\n\n while (true) {\n if (nextName in themes) {\n break\n }\n nextName = `${parentName}_${name}`\n if (nextName in themes) {\n break\n }\n if (!parentName.includes(THEME_NAME_SEPARATOR)) {\n // not found!\n console.warn('theme not found', name)\n // this happens in next during _document.getInitialProps and has a terrible/non-existent stack trace\n // throw new Error(`Theme not found: ${name}`)\n break\n }\n // go up one\n parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR))\n }\n\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${nextName}_${componentName}`,\n `${withoutComponentName(nextName)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n nextName = name\n }\n }\n }\n\n let theme = themes[nextName]\n if (!theme) {\n theme = themes[`light_${nextName}`]\n }\n\n if (process.env.NODE_ENV === 'development' && debug) {\n console.log('getNextTheme', { props, nextName, parentName }, this)\n }\n\n return {\n name: nextName,\n theme,\n className: this.#getClassName(nextName),\n }\n }\n\n #getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace('light_', '').replace('dark_', '')\n }\n\n track(uuid: any, keys: Set<string>) {\n if (!this.name) return\n this.keys.set(uuid, keys)\n }\n\n notifyListeners() {\n if (!this.name) {\n this.keys.clear()\n }\n for (const [uuid, keys] of this.keys.entries()) {\n if (keys.size) {\n this.listeners.get(uuid)?.()\n }\n }\n this.themeListeners.forEach((cb) => cb(this.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n\n onUpdate(uuid: any, cb: Function) {\n this.listeners.set(uuid, cb)\n return () => {\n this.listeners.delete(uuid)\n this.keys.delete(uuid)\n }\n }\n}\n\nexport const ThemeManagerContext = createContext<ThemeManager | null>(null)\nexport const emptyManager = new ThemeManager()\n\nconst withoutComponentName = (name: string) => name.replace(/(\\_[A-Z][a-zA-Z]+)+$/g, '')\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAEA;AACA;AAmBO,MAAM,aAAa;AAAA,EAMxB,YACS,OAAe,IACf,QAA4B,MAC5B,gBAAqC,MACrC,QAAiB,OACxB;AAJO;AACA;AACA;AACA;AATT,gBAAO,oBAAI,IAAsB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