@tamagui/core 1.0.1-beta.61 → 1.0.1-beta.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createComponent.js +15 -5
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -1
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +34 -15
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +2 -1
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +30 -23
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +29 -14
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +7 -21
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +2 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +40 -0
- package/dist/cjs/helpers/mergeProps.js.map +7 -0
- package/dist/cjs/helpers/pseudos.js +41 -0
- package/dist/cjs/helpers/pseudos.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +2 -2
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/static.js +2 -0
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/createComponent.js +15 -8
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +1 -1
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +34 -15
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +5 -3
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +30 -23
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +29 -14
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +6 -19
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +2 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/mergeProps.js +18 -0
- package/dist/esm/helpers/mergeProps.js.map +7 -0
- package/dist/esm/helpers/pseudos.js +18 -0
- package/dist/esm/helpers/pseudos.js.map +7 -0
- package/dist/esm/helpers/themeable.js +2 -1
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/static.js +2 -0
- package/dist/esm/static.js.map +2 -2
- package/dist/jsx/createComponent.js +15 -8
- package/dist/jsx/helpers/createMediaStyle.js +1 -1
- package/dist/jsx/helpers/createPropMapper.js +34 -15
- package/dist/jsx/helpers/extendStaticConfig.js +5 -3
- package/dist/jsx/helpers/generateAtomicStyles.js +30 -23
- package/dist/jsx/helpers/getSplitStyles.js +29 -14
- package/dist/jsx/helpers/getStylesAtomic.js +6 -19
- package/dist/jsx/helpers/insertStyleRule.js +2 -1
- package/dist/jsx/helpers/mergeProps.js +17 -0
- package/dist/jsx/helpers/pseudos.js +17 -0
- package/dist/jsx/helpers/themeable.js +2 -1
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/static.js +2 -0
- package/package.json +5 -5
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +1 -1
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +2 -2
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +0 -14
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/mergeProps.d.ts +2 -0
- package/types/helpers/mergeProps.d.ts.map +1 -0
- package/types/helpers/pseudos.d.ts +15 -0
- package/types/helpers/pseudos.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -1
- package/types/static.d.ts +2 -0
- package/types/static.d.ts.map +1 -1
- package/types/types.d.ts +3 -2
- package/types/types.d.ts.map +1 -1
|
@@ -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.error(`Missing transform`, identifier, css, rule)\n }\n return\n }\n const startI = s + 'transform:'.length\n const endI = css.indexOf(';')\n const value = css.slice(startI, endI)\n insertedTransforms[identifier] = value\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) {\n console.warn('hasnt inserted since')\n return\n }\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\n insertedSelectors[identifier] = rule\n
|
|
5
|
-
"mappings": ";;AAIA,MAAM,eAAe,CAAC;AACtB,MAAM,oBAAoB,CAAC;AACpB,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,6BAAM,cAAN;AACxB,MAAM,mBAAmB,6BAAM,OAAO,OAAO,iBAAiB,GAArC;AACzB,MAAM,mBAAmB,6BAAM,oBAAN;AAGhC,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,MAAM,qBAAqB,YAAY,KAAK,IAAI;AAAA,IAC1D;AACA;AAAA,EACF;AACA,QAAM,SAAS,IAAI,aAAa;AAChC,QAAM,OAAO,IAAI,QAAQ,GAAG;AAC5B,QAAM,QAAQ,IAAI,MAAM,QAAQ,IAAI;AACpC,qBAAmB,cAAc;AACnC;AAjBS;AAmBT,MAAM,WAAW,OAAO,aAAa;AAQrC,IAAI,yBAAyB;AAEtB,0BAA0B;AAC/B,MAAI,QAAQ,IAAI,aAAa;AAAQ;AACrC,MAAI,CAAC;AAAU;AACf,MAAI,CAAC,wBAAwB;AAC3B,YAAQ,KAAK,sBAAsB;AACnC;AAAA,EACF;AACA,QAAM,SAAS,SAAS;AACxB,MAAI,CAAC;AAAQ;AACb,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,QAAQ,OAAO,GAAG;AACxB,UAAM,YAAY,MAAM;AACxB,QAAI,CAAE,sBAAqB;AAAe;AAC1C,UAAM,gBAAgB,UAAU;AAChC,QAAI,CAAC;AAAe;AACpB,QAAI,kBAAkB,WAAW,cAAc,WAAW,IAAI,GAAG;AAC/D,eAAS,KAAI,GAAG,KAAI,MAAM,QAAQ,MAAK;AACrC,cAAM,OAAO,MAAM,KAAK,EAAC;AACzB,YAAI,CAAE,iBAAgB;AAAe;AACrC,cAAM,aAAa,KAAK,aAAa,MAAM,CAAC;AAC5C,YAAI,CAAC,aAAa,aAAa;AAC7B,uBAAa,cAAc,QAAQ,IAAI,aAAa,gBAAgB,KAAK,UAAU;AACnF,cAAI,WAAW,WAAW,YAAY,GAAG;AACvC,yBAAa,YAAY,KAAK,SAAS,IAAI;AAAA,UAC7C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,2BAAyB;AAC3B;AA9BgB;AAgChB,eAAe;AAEf,MAAM,QAAQ,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,OAAO,CAAC,EAAE,QAAQ;AAErF,6BAA6B,YAAoB,MAAc;AACpE,MAAI,kBAAkB;AAAa;AACnC,oBAAkB,cAAc;AAChC,
|
|
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.error(`Missing transform`, identifier, css, rule)\n }\n return\n }\n const startI = s + 'transform:'.length\n const endI = css.indexOf(';')\n const value = css.slice(startI, endI)\n insertedTransforms[identifier] = value\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) {\n console.warn('hasnt inserted since')\n return\n }\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\n insertedSelectors[identifier] = rule\n const isTransform = identifier.startsWith('_transform')\n if (isTransform) {\n addTransform(identifier, rule)\n }\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": ";;AAIA,MAAM,eAAe,CAAC;AACtB,MAAM,oBAAoB,CAAC;AACpB,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,6BAAM,cAAN;AACxB,MAAM,mBAAmB,6BAAM,OAAO,OAAO,iBAAiB,GAArC;AACzB,MAAM,mBAAmB,6BAAM,oBAAN;AAGhC,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,MAAM,qBAAqB,YAAY,KAAK,IAAI;AAAA,IAC1D;AACA;AAAA,EACF;AACA,QAAM,SAAS,IAAI,aAAa;AAChC,QAAM,OAAO,IAAI,QAAQ,GAAG;AAC5B,QAAM,QAAQ,IAAI,MAAM,QAAQ,IAAI;AACpC,qBAAmB,cAAc;AACnC;AAjBS;AAmBT,MAAM,WAAW,OAAO,aAAa;AAQrC,IAAI,yBAAyB;AAEtB,0BAA0B;AAC/B,MAAI,QAAQ,IAAI,aAAa;AAAQ;AACrC,MAAI,CAAC;AAAU;AACf,MAAI,CAAC,wBAAwB;AAC3B,YAAQ,KAAK,sBAAsB;AACnC;AAAA,EACF;AACA,QAAM,SAAS,SAAS;AACxB,MAAI,CAAC;AAAQ;AACb,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,QAAQ,OAAO,GAAG;AACxB,UAAM,YAAY,MAAM;AACxB,QAAI,CAAE,sBAAqB;AAAe;AAC1C,UAAM,gBAAgB,UAAU;AAChC,QAAI,CAAC;AAAe;AACpB,QAAI,kBAAkB,WAAW,cAAc,WAAW,IAAI,GAAG;AAC/D,eAAS,KAAI,GAAG,KAAI,MAAM,QAAQ,MAAK;AACrC,cAAM,OAAO,MAAM,KAAK,EAAC;AACzB,YAAI,CAAE,iBAAgB;AAAe;AACrC,cAAM,aAAa,KAAK,aAAa,MAAM,CAAC;AAC5C,YAAI,CAAC,aAAa,aAAa;AAC7B,uBAAa,cAAc,QAAQ,IAAI,aAAa,gBAAgB,KAAK,UAAU;AACnF,cAAI,WAAW,WAAW,YAAY,GAAG;AACvC,yBAAa,YAAY,KAAK,SAAS,IAAI;AAAA,UAC7C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,2BAAyB;AAC3B;AA9BgB;AAgChB,eAAe;AAEf,MAAM,QAAQ,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,OAAO,CAAC,EAAE,QAAQ;AAErF,6BAA6B,YAAoB,MAAc;AACpE,MAAI,kBAAkB;AAAa;AACnC,oBAAkB,cAAc;AAChC,QAAM,cAAc,WAAW,WAAW,YAAY;AACtD,MAAI,aAAa;AACf,iBAAa,YAAY,IAAI;AAAA,EAC/B;AACF;AAPgB;AAST,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;AANgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const mergeProps = /* @__PURE__ */ __name((a, b) => {
|
|
4
|
+
const out = {};
|
|
5
|
+
for (const key in a) {
|
|
6
|
+
if (!(key in b)) {
|
|
7
|
+
out[key] = a[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
for (const key in b) {
|
|
11
|
+
out[key] = b[key];
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}, "mergeProps");
|
|
15
|
+
export {
|
|
16
|
+
mergeProps
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=mergeProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/mergeProps.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Preserves prop ordering, so that the order most closely matches the last spread objects\n * Useful for having { ...defaultProps, ...props } that ensure props ordering is always kept\n *\n * Given:\n * mergeProps({ a: 1, b: 2 }, { b: 1, a: 2 })\n * The final key order will be:\n * b, a\n */\n\nexport const mergeProps = (a: Object, b: Object) => {\n const out = {}\n\n for (const key in a) {\n if (!(key in b)) {\n out[key] = a[key]\n }\n }\n\n for (const key in b) {\n out[key] = b[key]\n }\n\n return out\n}\n"],
|
|
5
|
+
"mappings": ";;AAUO,MAAM,aAAa,wBAAC,GAAW,MAAc;AAClD,QAAM,MAAM,CAAC;AAEb,aAAW,OAAO,GAAG;AACnB,QAAI,CAAE,QAAO,IAAI;AACf,UAAI,OAAO,EAAE;AAAA,IACf;AAAA,EACF;AAEA,aAAW,OAAO,GAAG;AACnB,QAAI,OAAO,EAAE;AAAA,EACf;AAEA,SAAO;AACT,GAd0B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const pseudos = {
|
|
2
|
+
hoverStyle: {
|
|
3
|
+
name: "hover",
|
|
4
|
+
priority: 1
|
|
5
|
+
},
|
|
6
|
+
pressStyle: {
|
|
7
|
+
name: "active",
|
|
8
|
+
priority: 2
|
|
9
|
+
},
|
|
10
|
+
focusStyle: {
|
|
11
|
+
name: "focus",
|
|
12
|
+
priority: 3
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
pseudos
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=pseudos.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/pseudos.ts"],
|
|
4
|
+
"sourcesContent": ["// *0 order matches to *1\n\nexport const pseudos = {\n hoverStyle: {\n name: 'hover',\n priority: 1,\n },\n pressStyle: {\n name: 'active',\n priority: 2,\n },\n focusStyle: {\n name: 'focus',\n priority: 3,\n },\n} as const\n"],
|
|
5
|
+
"mappings": "AAEO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,7 +4,8 @@ import React, { forwardRef } from "react";
|
|
|
4
4
|
import { Theme } from "../views/Theme";
|
|
5
5
|
import { ThemeInverse } from "../views/ThemeInverse";
|
|
6
6
|
function themeable(component, opts) {
|
|
7
|
-
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(
|
|
7
|
+
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(props, ref) {
|
|
8
|
+
const { themeInverse, theme, ...rest } = props;
|
|
8
9
|
const element = React.createElement(component, { ...rest, ref });
|
|
9
10
|
if (themeInverse) {
|
|
10
11
|
return /* @__PURE__ */ React.createElement(ThemeInverse, null, element);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/themeable.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { forwardRef } from 'react'\n\nimport { ThemeName } from '../types'\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: ThemeName | string | null\n themeInverse?: boolean\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(\n { themeInverse, theme, ...rest }
|
|
5
|
-
"mappings": ";;AAAA;AAGA;AACA;AAOO,mBACL,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,
|
|
4
|
+
"sourcesContent": ["import React, { forwardRef } from 'react'\n\nimport { ThemeName } from '../types'\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: ThemeName | string | null\n themeInverse?: boolean\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(props: any, ref) {\n const { themeInverse, theme, ...rest } = props\n const element = React.createElement(component, { ...rest, ref } as any)\n if (themeInverse) {\n return <ThemeInverse>{element}</ThemeInverse>\n }\n if (theme || opts) {\n return (\n <Theme componentName={opts?.componentName} name={(theme as any) || null}>\n {element}\n </Theme>\n )\n }\n return element\n })\n\n const withTheme: any = withThemeComponent\n withTheme.displayName = `Themed(${\n (component as any)?.displayName || (component as any)?.name || 'Anonymous'\n })`\n\n return withTheme as Component extends (props: infer P) => infer R\n ? (\n props: Omit<P, 'theme' | 'themeInverse'> & {\n theme?: ThemeName | null\n themeInverse?: boolean\n }\n ) => R\n : unknown\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGA;AACA;AAOO,mBACL,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,0CAAmB,OAAY,KAAK;AACxE,UAAM,EAAE,cAAc,UAAU,SAAS;AACzC,UAAM,UAAU,MAAM,cAAc,WAAW,EAAE,GAAG,MAAM,IAAI,CAAQ;AACtE,QAAI,cAAc;AAChB,aAAO,oCAAC,oBAAc,OAAQ;AAAA,IAChC;AACA,QAAI,SAAS,MAAM;AACjB,aACE,oCAAC;AAAA,QAAM,eAAe,6BAAM;AAAA,QAAe,MAAO,SAAiB;AAAA,SAChE,OACH;AAAA,IAEJ;AACA,WAAO;AAAA,EACT,GAdsC,YAcrC;AAED,QAAM,YAAiB;AACvB,YAAU,cAAc,UACrB,wCAAmB,gBAAgB,wCAAmB,SAAQ;AAGjE,SAAO;AAQT;AAjCgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -23,6 +23,9 @@ export * from "./helpers/getExpandedShorthands";
|
|
|
23
23
|
export * from "./helpers/getSize";
|
|
24
24
|
export * from "./helpers/getSplitStyles";
|
|
25
25
|
export * from "./helpers/getStylesAtomic";
|
|
26
|
+
export * from "./helpers/pseudos";
|
|
27
|
+
export * from "./helpers/mergeProps";
|
|
28
|
+
import { expandStyles } from "./helpers/generateAtomicStyles";
|
|
26
29
|
export * from "./helpers/getTextSize";
|
|
27
30
|
export * from "./helpers/isObj";
|
|
28
31
|
export * from "./helpers/isTamaguiElement";
|
|
@@ -52,6 +55,7 @@ export * from "@tamagui/helpers";
|
|
|
52
55
|
export {
|
|
53
56
|
RNWTextProps,
|
|
54
57
|
RNWViewProps,
|
|
58
|
+
expandStyles,
|
|
55
59
|
getConfig,
|
|
56
60
|
getHasConfigured,
|
|
57
61
|
getThemes,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
-
"mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudos'\nexport * from './helpers/mergeProps'\nexport { expandStyles } from './helpers/generateAtomicStyles'\nexport * from './helpers/getTextSize'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/static.js
CHANGED
|
@@ -9,6 +9,8 @@ export * from "./hooks/useMedia";
|
|
|
9
9
|
export * from "./hooks/useTheme";
|
|
10
10
|
export * from "./helpers/isObj";
|
|
11
11
|
export * from "./helpers/getStylesAtomic";
|
|
12
|
+
export * from "./helpers/generateAtomicStyles";
|
|
13
|
+
export * from "./helpers/pseudos";
|
|
12
14
|
export * from "./helpers/proxyThemeVariables";
|
|
13
15
|
export * from "./helpers/getSplitStyles";
|
|
14
16
|
export * from "@tamagui/helpers";
|
package/dist/esm/static.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/static.ts"],
|
|
4
|
-
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\n\nexport * from './styled'\nexport * from './createComponent'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createTamagui'\nexport * from './createVariable'\nexport * from './constants/constants'\n\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/proxyThemeVariables'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/rnw'\n\nexport * from './types'\n"],
|
|
5
|
-
"mappings": "AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;",
|
|
4
|
+
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\n\nexport * from './styled'\nexport * from './createComponent'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createTamagui'\nexport * from './createVariable'\nexport * from './constants/constants'\n\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/generateAtomicStyles'\nexport * from './helpers/pseudos'\nexport * from './helpers/proxyThemeVariables'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/rnw'\n\nexport * from './types'\n"],
|
|
5
|
+
"mappings": "AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,6 +23,7 @@ import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
|
23
23
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
24
24
|
import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
|
|
25
25
|
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
26
|
+
import { mergeProps } from "./helpers/mergeProps";
|
|
26
27
|
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
27
28
|
import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
|
|
28
29
|
import { useFeatures } from "./hooks/useFeatures";
|
|
@@ -96,14 +97,23 @@ function createComponent(configIn, ParentComponent) {
|
|
|
96
97
|
__name(addPseudoToStyles, "addPseudoToStyles");
|
|
97
98
|
const component = forwardRef((propsIn, forwardedRef) => {
|
|
98
99
|
var _a, _b, _c, _d, _e;
|
|
99
|
-
|
|
100
|
+
let props;
|
|
101
|
+
if (tamaguiDefaultProps && !propsIn.asChild) {
|
|
102
|
+
props = mergeProps(tamaguiDefaultProps, propsIn);
|
|
103
|
+
} else {
|
|
104
|
+
props = propsIn;
|
|
105
|
+
}
|
|
100
106
|
const { Component, isText, isZStack } = staticConfig;
|
|
101
107
|
const componentName = props.componentName || staticConfig.componentName;
|
|
102
108
|
const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
|
|
103
109
|
if (process.env.NODE_ENV === "development") {
|
|
104
110
|
if (props["debug"]) {
|
|
105
111
|
console.log("\u26A0\uFE0F", componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
|
|
106
|
-
console.log("props in:", {
|
|
112
|
+
console.log("props in:", {
|
|
113
|
+
propsIn,
|
|
114
|
+
props,
|
|
115
|
+
ordered: Object.keys(props)
|
|
116
|
+
});
|
|
107
117
|
if (props["debug"] === "break")
|
|
108
118
|
debugger;
|
|
109
119
|
}
|
|
@@ -121,7 +131,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
121
131
|
noClassNames: true,
|
|
122
132
|
dynamicStylesInline: true,
|
|
123
133
|
resolveVariablesAs: "value"
|
|
124
|
-
}, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames);
|
|
134
|
+
}, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames, props["debug"]);
|
|
125
135
|
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
126
136
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
127
137
|
const isAnimated = !!(useAnimations && props.animation);
|
|
@@ -597,11 +607,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
597
607
|
focus: false,
|
|
598
608
|
resolveVariablesAs: "both",
|
|
599
609
|
keepVariantsAsProps: true
|
|
600
|
-
});
|
|
601
|
-
const defaults =
|
|
602
|
-
...component.defaultProps,
|
|
603
|
-
...initialSplitStyles.viewProps
|
|
604
|
-
};
|
|
610
|
+
}, void 0, staticConfig.defaultProps["debug"]);
|
|
611
|
+
const defaults = mergeProps(component.defaultProps, initialSplitStyles.viewProps);
|
|
605
612
|
defaultNativeStyle = {};
|
|
606
613
|
const validStyles2 = staticConfig.validStyles || stylePropsView;
|
|
607
614
|
for (const key in staticConfig.defaultProps) {
|
|
@@ -12,7 +12,7 @@ const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey
|
|
|
12
12
|
const screenStr = negate ? "not all" : "screen";
|
|
13
13
|
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
14
14
|
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
15
|
-
const styleInner = rules
|
|
15
|
+
const styleInner = rules.map((rule) => rule.replace(identifier, nextIdentifier)).join(";");
|
|
16
16
|
let styleRule = "";
|
|
17
17
|
if (styleInner.includes("@media")) {
|
|
18
18
|
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
@@ -9,14 +9,14 @@ import { isObj } from "./isObj";
|
|
|
9
9
|
const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
10
10
|
const variants = staticConfig.variants || {};
|
|
11
11
|
const defaultProps = staticConfig.defaultProps || {};
|
|
12
|
-
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false) => {
|
|
12
|
+
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false, debug) => {
|
|
13
13
|
const conf = getConfig();
|
|
14
14
|
if (!conf) {
|
|
15
15
|
console.trace("no conf! err");
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const props = state.fallbackProps || propsIn;
|
|
19
|
-
const returnVariablesAs = state.resolveVariablesAs === "value" || !!props.animation ? "value" : "auto";
|
|
19
|
+
const returnVariablesAs = state.resolveVariablesAs === "value" || !!props.animation ? "non-color-value" : "auto";
|
|
20
20
|
const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
21
21
|
const variantValue = resolveVariants(key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, "", avoidDefaultProps);
|
|
22
22
|
if (variantValue) {
|
|
@@ -29,9 +29,9 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
29
29
|
}
|
|
30
30
|
if (value) {
|
|
31
31
|
if (value[0] === "$") {
|
|
32
|
-
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs);
|
|
32
|
+
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs, debug);
|
|
33
33
|
} else if (isVariable(value)) {
|
|
34
|
-
value = getVariableValue(value, returnVariablesAs);
|
|
34
|
+
value = getVariableValue(key, value, returnVariablesAs);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
if (shouldReturn) {
|
|
@@ -40,7 +40,7 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
40
40
|
}, "mapper");
|
|
41
41
|
return mapper;
|
|
42
42
|
}, "createPropMapper");
|
|
43
|
-
const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps = false) => {
|
|
43
|
+
const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps = false, debug) => {
|
|
44
44
|
var _a;
|
|
45
45
|
const variant = variants && variants[key];
|
|
46
46
|
if (variant && value !== void 0) {
|
|
@@ -51,7 +51,7 @@ const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps,
|
|
|
51
51
|
variantValue = fn(value, getVariantExtras(props, theme, defaultProps, avoidDefaultProps));
|
|
52
52
|
}
|
|
53
53
|
if (isObj(variantValue)) {
|
|
54
|
-
variantValue = resolveTokensAndVariants(key, variantValue, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps);
|
|
54
|
+
variantValue = resolveTokensAndVariants(key, variantValue, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps, debug);
|
|
55
55
|
}
|
|
56
56
|
return Object.entries(expandStyles(variantValue));
|
|
57
57
|
} else {
|
|
@@ -59,13 +59,14 @@ const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps,
|
|
|
59
59
|
if ((_a = staticConfig.validStyles) == null ? void 0 : _a[key]) {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
const name = staticConfig.componentName || "[UnnamedComponent]";
|
|
63
|
+
console.warn(`No variant found: ${name} has variant "${key}", but no matching value "${value}"`);
|
|
63
64
|
}
|
|
64
65
|
return null;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}, "resolveVariants");
|
|
68
|
-
const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps) => {
|
|
69
|
+
const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps, debug) => {
|
|
69
70
|
var _a;
|
|
70
71
|
let res = {};
|
|
71
72
|
for (const rKey in value) {
|
|
@@ -79,15 +80,15 @@ const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defa
|
|
|
79
80
|
} else {
|
|
80
81
|
res = {
|
|
81
82
|
...res,
|
|
82
|
-
...Object.fromEntries(resolveVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps))
|
|
83
|
+
...Object.fromEntries(resolveVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps, debug))
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
} else if (typeof val === "string") {
|
|
86
|
-
const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs) : val;
|
|
87
|
+
const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs, debug) : val;
|
|
87
88
|
res[fKey] = fVal;
|
|
88
89
|
} else {
|
|
89
90
|
if (isObj(val)) {
|
|
90
|
-
res[fKey] = resolveTokensAndVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps);
|
|
91
|
+
res[fKey] = resolveTokensAndVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps, debug);
|
|
91
92
|
} else {
|
|
92
93
|
res[fKey] = value[fKey];
|
|
93
94
|
}
|
|
@@ -128,7 +129,7 @@ const fontShorthand = {
|
|
|
128
129
|
fontSize: "size",
|
|
129
130
|
fontWeight: "weight"
|
|
130
131
|
};
|
|
131
|
-
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs) => {
|
|
132
|
+
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs, debug) => {
|
|
132
133
|
var _a, _b, _c;
|
|
133
134
|
let valOrVar;
|
|
134
135
|
let hasSet = false;
|
|
@@ -167,21 +168,39 @@ const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed
|
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
if (hasSet) {
|
|
170
|
-
return getVariableValue(valOrVar, resolveAs);
|
|
171
|
+
return getVariableValue(key, valOrVar, resolveAs);
|
|
171
172
|
}
|
|
172
173
|
if (process.env.NODE_ENV === "development") {
|
|
173
174
|
if (value && value[0] === "$") {
|
|
174
|
-
console.warn(`\u26A0\uFE0F
|
|
175
|
+
console.warn(`\u26A0\uFE0F You've passed the value "${value}" to the style property "${key}", but there's no theme or token with the key "${value}". Using theme "${theme.name}".
|
|
176
|
+
|
|
177
|
+
Set the debug prop to true to see more detailed debug information.`);
|
|
178
|
+
if (debug) {
|
|
179
|
+
if (typeof window !== "undefined") {
|
|
180
|
+
console.log("Looked in:");
|
|
181
|
+
console.log("Theme:", theme);
|
|
182
|
+
console.log("Tokens:", tokensParsed);
|
|
183
|
+
console.log("Fonts:", fontsParsed);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
175
186
|
return null;
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
189
|
return value;
|
|
179
190
|
}, "getToken");
|
|
180
|
-
function getVariableValue(valOrVar, resolveAs = "auto") {
|
|
191
|
+
function getVariableValue(key, valOrVar, resolveAs = "auto") {
|
|
181
192
|
if (isVariable(valOrVar)) {
|
|
182
193
|
if (resolveAs === "variable") {
|
|
183
194
|
return valOrVar;
|
|
184
195
|
}
|
|
196
|
+
if (resolveAs === "non-color-value") {
|
|
197
|
+
if (isWeb) {
|
|
198
|
+
if (key in tokenCategories.color) {
|
|
199
|
+
return valOrVar.variable;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return valOrVar.val;
|
|
203
|
+
}
|
|
185
204
|
if (!isWeb || resolveAs === "value") {
|
|
186
205
|
return valOrVar.val;
|
|
187
206
|
}
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { stylePropsView } from "@tamagui/helpers";
|
|
4
4
|
import { createPropMapper } from "./createPropMapper";
|
|
5
|
+
import { mergeProps } from "./mergeProps";
|
|
5
6
|
function extendStaticConfig(config, parent) {
|
|
6
7
|
var _a;
|
|
7
8
|
if (!parent || !("staticConfig" in parent)) {
|
|
@@ -35,12 +36,13 @@ function extendStaticConfig(config, parent) {
|
|
|
35
36
|
...parent.staticConfig.validStyles,
|
|
36
37
|
...config.validStyles
|
|
37
38
|
} : parent.staticConfig.validStyles || stylePropsView,
|
|
38
|
-
defaultProps: {
|
|
39
|
+
defaultProps: mergeProps({
|
|
39
40
|
...parent.staticConfig.defaultProps,
|
|
40
|
-
...parent.staticConfig.defaultVariants
|
|
41
|
+
...parent.staticConfig.defaultVariants
|
|
42
|
+
}, {
|
|
41
43
|
...config.defaultProps,
|
|
42
44
|
...config.defaultVariants
|
|
43
|
-
}
|
|
45
|
+
})
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
__name(extendStaticConfig, "extendStaticConfig");
|
|
@@ -4,10 +4,28 @@ import { simpleHash } from "@tamagui/helpers";
|
|
|
4
4
|
import hyphenateStyleName from "hyphenate-style-name";
|
|
5
5
|
import normalizeCSSColor from "normalize-css-color";
|
|
6
6
|
import { isWeb } from "../constants/platform";
|
|
7
|
+
import { pseudos } from "./pseudos";
|
|
8
|
+
const reducedStyleKeys = {
|
|
9
|
+
shadowColor: true,
|
|
10
|
+
shadowOffset: true,
|
|
11
|
+
shadowOpacity: true,
|
|
12
|
+
shadowRadius: true,
|
|
13
|
+
textShadowColor: true,
|
|
14
|
+
textShadowOffset: true,
|
|
15
|
+
textShadowRadius: true
|
|
16
|
+
};
|
|
7
17
|
function expandStyles(style) {
|
|
8
18
|
const res = {};
|
|
19
|
+
boxShadowReducer(res, style);
|
|
20
|
+
textShadowReducer(res, style);
|
|
9
21
|
for (const key in style) {
|
|
10
|
-
|
|
22
|
+
if (reducedStyleKeys[key])
|
|
23
|
+
continue;
|
|
24
|
+
if (key in pseudos) {
|
|
25
|
+
res[key] = expandStyles(style[key]);
|
|
26
|
+
} else {
|
|
27
|
+
updateReactDOMStyle(res, key, style[key]);
|
|
28
|
+
}
|
|
11
29
|
}
|
|
12
30
|
return res;
|
|
13
31
|
}
|
|
@@ -24,19 +42,6 @@ function updateReactDOMStyle(style, key, value) {
|
|
|
24
42
|
__name(updateReactDOMStyle, "updateReactDOMStyle");
|
|
25
43
|
const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
26
44
|
const res = expandStyles(style);
|
|
27
|
-
if (style.shadowColor != null || style.shadowOffset != null || style.shadowOpacity != null || style.shadowRadius != null) {
|
|
28
|
-
boxShadowReducer(res, style);
|
|
29
|
-
delete res["shadowColor"];
|
|
30
|
-
delete res["shadowOffset"];
|
|
31
|
-
delete res["shadowOpacity"];
|
|
32
|
-
delete res["shadowRadius"];
|
|
33
|
-
}
|
|
34
|
-
if (style.textShadowColor != null || style.textShadowOffset != null || style.textShadowRadius != null) {
|
|
35
|
-
textShadowReducer(res, style);
|
|
36
|
-
delete res["textShadowColor"];
|
|
37
|
-
delete res["textShadowOffset"];
|
|
38
|
-
delete res["textShadowRadius"];
|
|
39
|
-
}
|
|
40
45
|
const out = {};
|
|
41
46
|
for (const key in res) {
|
|
42
47
|
const value = res[key];
|
|
@@ -47,8 +52,8 @@ const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
|
47
52
|
const { identifier } = cachedResult;
|
|
48
53
|
out[identifier] = cachedResult;
|
|
49
54
|
} else {
|
|
50
|
-
const identifier = simpleHash(key +
|
|
51
|
-
const rules = createAtomicRules(identifier, key,
|
|
55
|
+
const identifier = simpleHash(key + valueString);
|
|
56
|
+
const rules = createAtomicRules(identifier, key, valueString);
|
|
52
57
|
const cachedResult2 = cache.set(key, valueString, {
|
|
53
58
|
property: key,
|
|
54
59
|
value: valueString,
|
|
@@ -194,8 +199,7 @@ const cache = {
|
|
|
194
199
|
}
|
|
195
200
|
};
|
|
196
201
|
function stringifyValueWithProperty(value, property) {
|
|
197
|
-
|
|
198
|
-
return typeof normalizedValue !== "string" ? JSON.stringify(normalizedValue || "") : normalizedValue;
|
|
202
|
+
return normalizeValueWithProperty(value, property);
|
|
199
203
|
}
|
|
200
204
|
__name(stringifyValueWithProperty, "stringifyValueWithProperty");
|
|
201
205
|
const mapTransform = /* @__PURE__ */ __name((transform) => {
|
|
@@ -222,7 +226,8 @@ const colorProps = {
|
|
|
222
226
|
};
|
|
223
227
|
function normalizeValueWithProperty(value, property) {
|
|
224
228
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
225
|
-
|
|
229
|
+
const shouldCoerceToPx = typeof value === "number" && (property === void 0 || property === null || !unitlessNumbers[property]);
|
|
230
|
+
if (shouldCoerceToPx) {
|
|
226
231
|
return `${value}px`;
|
|
227
232
|
}
|
|
228
233
|
}
|
|
@@ -250,6 +255,7 @@ const normalizeColor = /* @__PURE__ */ __name((color, opacity = 1) => {
|
|
|
250
255
|
const alpha = (a * opacity).toFixed(2);
|
|
251
256
|
return `rgba(${r},${g},${b},${alpha})`;
|
|
252
257
|
}
|
|
258
|
+
return `${color}`;
|
|
253
259
|
}, "normalizeColor");
|
|
254
260
|
const isWebColor = /* @__PURE__ */ __name((color) => color === "currentcolor" || color === "currentColor" || color === "inherit" || color.indexOf("var(") === 0, "isWebColor");
|
|
255
261
|
const processColor = /* @__PURE__ */ __name((color) => {
|
|
@@ -311,14 +317,15 @@ const unitlessNumbers = {
|
|
|
311
317
|
};
|
|
312
318
|
const resolveShadowValue = /* @__PURE__ */ __name((style) => {
|
|
313
319
|
const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
|
|
320
|
+
if (shadowRadius === void 0) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
314
323
|
const { height, width } = shadowOffset || defaultOffset;
|
|
315
324
|
const offsetX = normalizeValueWithProperty(width);
|
|
316
325
|
const offsetY = normalizeValueWithProperty(height);
|
|
317
326
|
const blurRadius = normalizeValueWithProperty(shadowRadius || 0);
|
|
318
|
-
const color = normalizeColor(shadowColor || "black", shadowOpacity);
|
|
319
|
-
|
|
320
|
-
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
321
|
-
}
|
|
327
|
+
const color = normalizeColor(String(shadowColor || "black"), shadowOpacity);
|
|
328
|
+
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
322
329
|
}, "resolveShadowValue");
|
|
323
330
|
function boxShadowReducer(resolvedStyle, style) {
|
|
324
331
|
const { boxShadow } = style;
|