@tamagui/web 1.5.23 → 1.6.0
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/helpers/expandStyles.js +6 -4
- package/dist/cjs/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/expandStyles.js +6 -4
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/expandStyles.mjs +6 -4
- package/dist/esm/helpers/expandStyles.mjs.map +2 -2
- package/package.json +9 -9
- package/src/helpers/expandStyles.ts +8 -4
- package/types/helpers/expandStyles.d.ts.map +1 -1
|
@@ -22,6 +22,7 @@ __export(expandStyles_exports, {
|
|
|
22
22
|
fixStyles: () => fixStyles
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(expandStyles_exports);
|
|
25
|
+
var import_constants = require("@tamagui/constants");
|
|
25
26
|
var import_config = require("../config.js");
|
|
26
27
|
var import_expandStyle = require("./expandStyle.js");
|
|
27
28
|
var import_normalizeShadow = require("./normalizeShadow");
|
|
@@ -60,12 +61,13 @@ function fixStyles(style) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
const nativeStyle = import_constants.isWeb ? null : "borderStyle";
|
|
63
65
|
const borderDefaults = {
|
|
64
66
|
borderWidth: "borderStyle",
|
|
65
|
-
borderBottomWidth: "borderBottomStyle",
|
|
66
|
-
borderTopWidth: "borderTopStyle",
|
|
67
|
-
borderLeftWidth: "borderLeftStyle",
|
|
68
|
-
borderRightWidth: "borderRightStyle"
|
|
67
|
+
borderBottomWidth: nativeStyle || "borderBottomStyle",
|
|
68
|
+
borderTopWidth: nativeStyle || "borderTopStyle",
|
|
69
|
+
borderLeftWidth: nativeStyle || "borderLeftStyle",
|
|
70
|
+
borderRightWidth: nativeStyle || "borderRightStyle"
|
|
69
71
|
};
|
|
70
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71
73
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/expandStyles.ts"],
|
|
4
|
-
"sourcesContent": ["import { getConfig } from '../config.js'\nimport { expandStyle } from './expandStyle.js'\nimport { normalizeShadow } from './normalizeShadow'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { pseudoDescriptors } from './pseudoDescriptors.js'\n\nlet shorthands: Record<string, string> | null = null\n\n/**\n * This is what you want to run before Object.assign() a style onto another.\n * It does the following:\n * 1. Turns user shorthands into longhands, ie px = paddingHorizontal\n * 2. Normalizes various inconsistent styles to be more consistent\n * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight\n */\n\nexport function expandStyles(style: Record<string, any>, config = getConfig()) {\n const res: Record<string, any> = {}\n\n for (let key in style) {\n shorthands = shorthands || (config ? config.shorthands : null)\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (key in pseudoDescriptors) {\n res[key] = expandStyles(style[key])\n continue\n }\n const val = normalizeValueWithProperty(style[key], key)\n // expand react-native shorthands\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n\n fixStyles(res)\n\n return res\n}\n\nexport function fixStyles(style: Record<string, any>) {\n if (\n style.shadowRadius ||\n style.shadowColor ||\n style.shadowOpacity ||\n style.shadowOffset\n ) {\n Object.assign(style, normalizeShadow(style))\n }\n\n // TODO could be native-only\n // ensure border style set by default to solid\n for (const key in borderDefaults) {\n if (key in style && !style[borderDefaults[key]]) {\n style[borderDefaults[key]] = 'solid'\n }\n }\n}\n\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderTopWidth: 'borderTopStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAC1B,yBAA4B;AAC5B,6BAAgC;AAChC,wCAA2C;AAC3C,+BAAkC;AAElC,IAAI,aAA4C;AAUzC,SAAS,aAAa,OAA4B,aAAS,yBAAU,GAAG;AAC7E,QAAM,MAA2B,CAAC;AAElC,WAAS,OAAO,OAAO;AACrB,iBAAa,eAAe,SAAS,OAAO,aAAa;AACzD,QAAI,YAAY;AACd,YAAM,WAAW,GAAG,KAAK;AAAA,IAC3B;AACA,QAAI,OAAO,4CAAmB;AAC5B,UAAI,GAAG,IAAI,aAAa,MAAM,GAAG,CAAC;AAClC;AAAA,IACF;AACA,UAAM,UAAM,8DAA2B,MAAM,GAAG,GAAG,GAAG;AAEtD,UAAM,UAAM,gCAAY,KAAK,GAAG;AAChC,QAAI,KAAK;AACP,aAAO,OAAO,KAAK,OAAO,YAAY,GAAG,CAAC;AAAA,IAC5C,OAAO;AACL,UAAI,GAAG,IAAI;AAAA,IACb;AAAA,EACF;AAEA,YAAU,GAAG;AAEb,SAAO;AACT;AAEO,SAAS,UAAU,OAA4B;AACpD,MACE,MAAM,gBACN,MAAM,eACN,MAAM,iBACN,MAAM,cACN;AACA,WAAO,OAAO,WAAO,wCAAgB,KAAK,CAAC;AAAA,EAC7C;AAIA,aAAW,OAAO,gBAAgB;AAChC,QAAI,OAAO,SAAS,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG;AAC/C,YAAM,eAAe,GAAG,CAAC,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\n\nimport { getConfig } from '../config.js'\nimport { expandStyle } from './expandStyle.js'\nimport { normalizeShadow } from './normalizeShadow'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { pseudoDescriptors } from './pseudoDescriptors.js'\n\nlet shorthands: Record<string, string> | null = null\n\n/**\n * This is what you want to run before Object.assign() a style onto another.\n * It does the following:\n * 1. Turns user shorthands into longhands, ie px = paddingHorizontal\n * 2. Normalizes various inconsistent styles to be more consistent\n * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight\n */\n\nexport function expandStyles(style: Record<string, any>, config = getConfig()) {\n const res: Record<string, any> = {}\n\n for (let key in style) {\n shorthands = shorthands || (config ? config.shorthands : null)\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (key in pseudoDescriptors) {\n res[key] = expandStyles(style[key])\n continue\n }\n const val = normalizeValueWithProperty(style[key], key)\n // expand react-native shorthands\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n\n fixStyles(res)\n\n return res\n}\n\nexport function fixStyles(style: Record<string, any>) {\n if (\n style.shadowRadius ||\n style.shadowColor ||\n style.shadowOpacity ||\n style.shadowOffset\n ) {\n Object.assign(style, normalizeShadow(style))\n }\n\n // TODO could be native-only\n // ensure border style set by default to solid\n for (const key in borderDefaults) {\n if (key in style && !style[borderDefaults[key]]) {\n style[borderDefaults[key]] = 'solid'\n }\n }\n}\n\n// native doesn't support specific border edge style\nconst nativeStyle = isWeb ? null : 'borderStyle'\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: nativeStyle || 'borderBottomStyle',\n borderTopWidth: nativeStyle || 'borderTopStyle',\n borderLeftWidth: nativeStyle || 'borderLeftStyle',\n borderRightWidth: nativeStyle || 'borderRightStyle',\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AAEtB,oBAA0B;AAC1B,yBAA4B;AAC5B,6BAAgC;AAChC,wCAA2C;AAC3C,+BAAkC;AAElC,IAAI,aAA4C;AAUzC,SAAS,aAAa,OAA4B,aAAS,yBAAU,GAAG;AAC7E,QAAM,MAA2B,CAAC;AAElC,WAAS,OAAO,OAAO;AACrB,iBAAa,eAAe,SAAS,OAAO,aAAa;AACzD,QAAI,YAAY;AACd,YAAM,WAAW,GAAG,KAAK;AAAA,IAC3B;AACA,QAAI,OAAO,4CAAmB;AAC5B,UAAI,GAAG,IAAI,aAAa,MAAM,GAAG,CAAC;AAClC;AAAA,IACF;AACA,UAAM,UAAM,8DAA2B,MAAM,GAAG,GAAG,GAAG;AAEtD,UAAM,UAAM,gCAAY,KAAK,GAAG;AAChC,QAAI,KAAK;AACP,aAAO,OAAO,KAAK,OAAO,YAAY,GAAG,CAAC;AAAA,IAC5C,OAAO;AACL,UAAI,GAAG,IAAI;AAAA,IACb;AAAA,EACF;AAEA,YAAU,GAAG;AAEb,SAAO;AACT;AAEO,SAAS,UAAU,OAA4B;AACpD,MACE,MAAM,gBACN,MAAM,eACN,MAAM,iBACN,MAAM,cACN;AACA,WAAO,OAAO,WAAO,wCAAgB,KAAK,CAAC;AAAA,EAC7C;AAIA,aAAW,OAAO,gBAAgB;AAChC,QAAI,OAAO,SAAS,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG;AAC/C,YAAM,eAAe,GAAG,CAAC,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;AAGA,MAAM,cAAc,yBAAQ,OAAO;AACnC,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,mBAAmB,eAAe;AAAA,EAClC,gBAAgB,eAAe;AAAA,EAC/B,iBAAiB,eAAe;AAAA,EAChC,kBAAkB,eAAe;AACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isWeb } from "@tamagui/constants";
|
|
1
2
|
import { getConfig } from "../config.js";
|
|
2
3
|
import { expandStyle } from "./expandStyle.js";
|
|
3
4
|
import { normalizeShadow } from "./normalizeShadow";
|
|
@@ -36,12 +37,13 @@ function fixStyles(style) {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
40
|
+
const nativeStyle = isWeb ? null : "borderStyle";
|
|
39
41
|
const borderDefaults = {
|
|
40
42
|
borderWidth: "borderStyle",
|
|
41
|
-
borderBottomWidth: "borderBottomStyle",
|
|
42
|
-
borderTopWidth: "borderTopStyle",
|
|
43
|
-
borderLeftWidth: "borderLeftStyle",
|
|
44
|
-
borderRightWidth: "borderRightStyle"
|
|
43
|
+
borderBottomWidth: nativeStyle || "borderBottomStyle",
|
|
44
|
+
borderTopWidth: nativeStyle || "borderTopStyle",
|
|
45
|
+
borderLeftWidth: nativeStyle || "borderLeftStyle",
|
|
46
|
+
borderRightWidth: nativeStyle || "borderRightStyle"
|
|
45
47
|
};
|
|
46
48
|
export {
|
|
47
49
|
expandStyles,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/expandStyles.ts"],
|
|
4
|
-
"sourcesContent": ["import { getConfig } from '../config.js'\nimport { expandStyle } from './expandStyle.js'\nimport { normalizeShadow } from './normalizeShadow'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { pseudoDescriptors } from './pseudoDescriptors.js'\n\nlet shorthands: Record<string, string> | null = null\n\n/**\n * This is what you want to run before Object.assign() a style onto another.\n * It does the following:\n * 1. Turns user shorthands into longhands, ie px = paddingHorizontal\n * 2. Normalizes various inconsistent styles to be more consistent\n * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight\n */\n\nexport function expandStyles(style: Record<string, any>, config = getConfig()) {\n const res: Record<string, any> = {}\n\n for (let key in style) {\n shorthands = shorthands || (config ? config.shorthands : null)\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (key in pseudoDescriptors) {\n res[key] = expandStyles(style[key])\n continue\n }\n const val = normalizeValueWithProperty(style[key], key)\n // expand react-native shorthands\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n\n fixStyles(res)\n\n return res\n}\n\nexport function fixStyles(style: Record<string, any>) {\n if (\n style.shadowRadius ||\n style.shadowColor ||\n style.shadowOpacity ||\n style.shadowOffset\n ) {\n Object.assign(style, normalizeShadow(style))\n }\n\n // TODO could be native-only\n // ensure border style set by default to solid\n for (const key in borderDefaults) {\n if (key in style && !style[borderDefaults[key]]) {\n style[borderDefaults[key]] = 'solid'\n }\n }\n}\n\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderTopWidth: 'borderTopStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,yBAAyB;AAElC,IAAI,aAA4C;AAUzC,SAAS,aAAa,OAA4B,SAAS,UAAU,GAAG;AAC7E,QAAM,MAA2B,CAAC;AAElC,WAAS,OAAO,OAAO;AACrB,iBAAa,eAAe,SAAS,OAAO,aAAa;AACzD,QAAI,YAAY;AACd,YAAM,WAAW,GAAG,KAAK;AAAA,IAC3B;AACA,QAAI,OAAO,mBAAmB;AAC5B,UAAI,GAAG,IAAI,aAAa,MAAM,GAAG,CAAC;AAClC;AAAA,IACF;AACA,UAAM,MAAM,2BAA2B,MAAM,GAAG,GAAG,GAAG;AAEtD,UAAM,MAAM,YAAY,KAAK,GAAG;AAChC,QAAI,KAAK;AACP,aAAO,OAAO,KAAK,OAAO,YAAY,GAAG,CAAC;AAAA,IAC5C,OAAO;AACL,UAAI,GAAG,IAAI;AAAA,IACb;AAAA,EACF;AAEA,YAAU,GAAG;AAEb,SAAO;AACT;AAEO,SAAS,UAAU,OAA4B;AACpD,MACE,MAAM,gBACN,MAAM,eACN,MAAM,iBACN,MAAM,cACN;AACA,WAAO,OAAO,OAAO,gBAAgB,KAAK,CAAC;AAAA,EAC7C;AAIA,aAAW,OAAO,gBAAgB;AAChC,QAAI,OAAO,SAAS,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG;AAC/C,YAAM,eAAe,GAAG,CAAC,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\n\nimport { getConfig } from '../config.js'\nimport { expandStyle } from './expandStyle.js'\nimport { normalizeShadow } from './normalizeShadow'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { pseudoDescriptors } from './pseudoDescriptors.js'\n\nlet shorthands: Record<string, string> | null = null\n\n/**\n * This is what you want to run before Object.assign() a style onto another.\n * It does the following:\n * 1. Turns user shorthands into longhands, ie px = paddingHorizontal\n * 2. Normalizes various inconsistent styles to be more consistent\n * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight\n */\n\nexport function expandStyles(style: Record<string, any>, config = getConfig()) {\n const res: Record<string, any> = {}\n\n for (let key in style) {\n shorthands = shorthands || (config ? config.shorthands : null)\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (key in pseudoDescriptors) {\n res[key] = expandStyles(style[key])\n continue\n }\n const val = normalizeValueWithProperty(style[key], key)\n // expand react-native shorthands\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n\n fixStyles(res)\n\n return res\n}\n\nexport function fixStyles(style: Record<string, any>) {\n if (\n style.shadowRadius ||\n style.shadowColor ||\n style.shadowOpacity ||\n style.shadowOffset\n ) {\n Object.assign(style, normalizeShadow(style))\n }\n\n // TODO could be native-only\n // ensure border style set by default to solid\n for (const key in borderDefaults) {\n if (key in style && !style[borderDefaults[key]]) {\n style[borderDefaults[key]] = 'solid'\n }\n }\n}\n\n// native doesn't support specific border edge style\nconst nativeStyle = isWeb ? null : 'borderStyle'\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: nativeStyle || 'borderBottomStyle',\n borderTopWidth: nativeStyle || 'borderTopStyle',\n borderLeftWidth: nativeStyle || 'borderLeftStyle',\n borderRightWidth: nativeStyle || 'borderRightStyle',\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AAEtB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,yBAAyB;AAElC,IAAI,aAA4C;AAUzC,SAAS,aAAa,OAA4B,SAAS,UAAU,GAAG;AAC7E,QAAM,MAA2B,CAAC;AAElC,WAAS,OAAO,OAAO;AACrB,iBAAa,eAAe,SAAS,OAAO,aAAa;AACzD,QAAI,YAAY;AACd,YAAM,WAAW,GAAG,KAAK;AAAA,IAC3B;AACA,QAAI,OAAO,mBAAmB;AAC5B,UAAI,GAAG,IAAI,aAAa,MAAM,GAAG,CAAC;AAClC;AAAA,IACF;AACA,UAAM,MAAM,2BAA2B,MAAM,GAAG,GAAG,GAAG;AAEtD,UAAM,MAAM,YAAY,KAAK,GAAG;AAChC,QAAI,KAAK;AACP,aAAO,OAAO,KAAK,OAAO,YAAY,GAAG,CAAC;AAAA,IAC5C,OAAO;AACL,UAAI,GAAG,IAAI;AAAA,IACb;AAAA,EACF;AAEA,YAAU,GAAG;AAEb,SAAO;AACT;AAEO,SAAS,UAAU,OAA4B;AACpD,MACE,MAAM,gBACN,MAAM,eACN,MAAM,iBACN,MAAM,cACN;AACA,WAAO,OAAO,OAAO,gBAAgB,KAAK,CAAC;AAAA,EAC7C;AAIA,aAAW,OAAO,gBAAgB;AAChC,QAAI,OAAO,SAAS,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG;AAC/C,YAAM,eAAe,GAAG,CAAC,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;AAGA,MAAM,cAAc,QAAQ,OAAO;AACnC,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,mBAAmB,eAAe;AAAA,EAClC,gBAAgB,eAAe;AAAA,EAC/B,iBAAiB,eAAe;AAAA,EAChC,kBAAkB,eAAe;AACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isWeb } from "@tamagui/constants";
|
|
1
2
|
import { getConfig } from "../config.js";
|
|
2
3
|
import { expandStyle } from "./expandStyle.js";
|
|
3
4
|
import { normalizeShadow } from "./normalizeShadow";
|
|
@@ -36,12 +37,13 @@ function fixStyles(style) {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
40
|
+
const nativeStyle = isWeb ? null : "borderStyle";
|
|
39
41
|
const borderDefaults = {
|
|
40
42
|
borderWidth: "borderStyle",
|
|
41
|
-
borderBottomWidth: "borderBottomStyle",
|
|
42
|
-
borderTopWidth: "borderTopStyle",
|
|
43
|
-
borderLeftWidth: "borderLeftStyle",
|
|
44
|
-
borderRightWidth: "borderRightStyle"
|
|
43
|
+
borderBottomWidth: nativeStyle || "borderBottomStyle",
|
|
44
|
+
borderTopWidth: nativeStyle || "borderTopStyle",
|
|
45
|
+
borderLeftWidth: nativeStyle || "borderLeftStyle",
|
|
46
|
+
borderRightWidth: nativeStyle || "borderRightStyle"
|
|
45
47
|
};
|
|
46
48
|
export {
|
|
47
49
|
expandStyles,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/expandStyles.ts"],
|
|
4
|
-
"sourcesContent": ["import { getConfig } from '../config.js'\nimport { expandStyle } from './expandStyle.js'\nimport { normalizeShadow } from './normalizeShadow'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { pseudoDescriptors } from './pseudoDescriptors.js'\n\nlet shorthands: Record<string, string> | null = null\n\n/**\n * This is what you want to run before Object.assign() a style onto another.\n * It does the following:\n * 1. Turns user shorthands into longhands, ie px = paddingHorizontal\n * 2. Normalizes various inconsistent styles to be more consistent\n * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight\n */\n\nexport function expandStyles(style: Record<string, any>, config = getConfig()) {\n const res: Record<string, any> = {}\n\n for (let key in style) {\n shorthands = shorthands || (config ? config.shorthands : null)\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (key in pseudoDescriptors) {\n res[key] = expandStyles(style[key])\n continue\n }\n const val = normalizeValueWithProperty(style[key], key)\n // expand react-native shorthands\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n\n fixStyles(res)\n\n return res\n}\n\nexport function fixStyles(style: Record<string, any>) {\n if (\n style.shadowRadius ||\n style.shadowColor ||\n style.shadowOpacity ||\n style.shadowOffset\n ) {\n Object.assign(style, normalizeShadow(style))\n }\n\n // TODO could be native-only\n // ensure border style set by default to solid\n for (const key in borderDefaults) {\n if (key in style && !style[borderDefaults[key]]) {\n style[borderDefaults[key]] = 'solid'\n }\n }\n}\n\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderTopWidth: 'borderTopStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,yBAAyB;AAElC,IAAI,aAA4C;AAUzC,SAAS,aAAa,OAA4B,SAAS,UAAU,GAAG;AAC7E,QAAM,MAA2B,CAAC;AAElC,WAAS,OAAO,OAAO;AACrB,iBAAa,eAAe,SAAS,OAAO,aAAa;AACzD,QAAI,YAAY;AACd,YAAM,WAAW,GAAG,KAAK;AAAA,IAC3B;AACA,QAAI,OAAO,mBAAmB;AAC5B,UAAI,GAAG,IAAI,aAAa,MAAM,GAAG,CAAC;AAClC;AAAA,IACF;AACA,UAAM,MAAM,2BAA2B,MAAM,GAAG,GAAG,GAAG;AAEtD,UAAM,MAAM,YAAY,KAAK,GAAG;AAChC,QAAI,KAAK;AACP,aAAO,OAAO,KAAK,OAAO,YAAY,GAAG,CAAC;AAAA,IAC5C,OAAO;AACL,UAAI,GAAG,IAAI;AAAA,IACb;AAAA,EACF;AAEA,YAAU,GAAG;AAEb,SAAO;AACT;AAEO,SAAS,UAAU,OAA4B;AACpD,MACE,MAAM,gBACN,MAAM,eACN,MAAM,iBACN,MAAM,cACN;AACA,WAAO,OAAO,OAAO,gBAAgB,KAAK,CAAC;AAAA,EAC7C;AAIA,aAAW,OAAO,gBAAgB;AAChC,QAAI,OAAO,SAAS,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG;AAC/C,YAAM,eAAe,GAAG,CAAC,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\n\nimport { getConfig } from '../config.js'\nimport { expandStyle } from './expandStyle.js'\nimport { normalizeShadow } from './normalizeShadow'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\nimport { pseudoDescriptors } from './pseudoDescriptors.js'\n\nlet shorthands: Record<string, string> | null = null\n\n/**\n * This is what you want to run before Object.assign() a style onto another.\n * It does the following:\n * 1. Turns user shorthands into longhands, ie px = paddingHorizontal\n * 2. Normalizes various inconsistent styles to be more consistent\n * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight\n */\n\nexport function expandStyles(style: Record<string, any>, config = getConfig()) {\n const res: Record<string, any> = {}\n\n for (let key in style) {\n shorthands = shorthands || (config ? config.shorthands : null)\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (key in pseudoDescriptors) {\n res[key] = expandStyles(style[key])\n continue\n }\n const val = normalizeValueWithProperty(style[key], key)\n // expand react-native shorthands\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n\n fixStyles(res)\n\n return res\n}\n\nexport function fixStyles(style: Record<string, any>) {\n if (\n style.shadowRadius ||\n style.shadowColor ||\n style.shadowOpacity ||\n style.shadowOffset\n ) {\n Object.assign(style, normalizeShadow(style))\n }\n\n // TODO could be native-only\n // ensure border style set by default to solid\n for (const key in borderDefaults) {\n if (key in style && !style[borderDefaults[key]]) {\n style[borderDefaults[key]] = 'solid'\n }\n }\n}\n\n// native doesn't support specific border edge style\nconst nativeStyle = isWeb ? null : 'borderStyle'\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: nativeStyle || 'borderBottomStyle',\n borderTopWidth: nativeStyle || 'borderTopStyle',\n borderLeftWidth: nativeStyle || 'borderLeftStyle',\n borderRightWidth: nativeStyle || 'borderRightStyle',\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AAEtB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,yBAAyB;AAElC,IAAI,aAA4C;AAUzC,SAAS,aAAa,OAA4B,SAAS,UAAU,GAAG;AAC7E,QAAM,MAA2B,CAAC;AAElC,WAAS,OAAO,OAAO;AACrB,iBAAa,eAAe,SAAS,OAAO,aAAa;AACzD,QAAI,YAAY;AACd,YAAM,WAAW,GAAG,KAAK;AAAA,IAC3B;AACA,QAAI,OAAO,mBAAmB;AAC5B,UAAI,GAAG,IAAI,aAAa,MAAM,GAAG,CAAC;AAClC;AAAA,IACF;AACA,UAAM,MAAM,2BAA2B,MAAM,GAAG,GAAG,GAAG;AAEtD,UAAM,MAAM,YAAY,KAAK,GAAG;AAChC,QAAI,KAAK;AACP,aAAO,OAAO,KAAK,OAAO,YAAY,GAAG,CAAC;AAAA,IAC5C,OAAO;AACL,UAAI,GAAG,IAAI;AAAA,IACb;AAAA,EACF;AAEA,YAAU,GAAG;AAEb,SAAO;AACT;AAEO,SAAS,UAAU,OAA4B;AACpD,MACE,MAAM,gBACN,MAAM,eACN,MAAM,iBACN,MAAM,cACN;AACA,WAAO,OAAO,OAAO,gBAAgB,KAAK,CAAC;AAAA,EAC7C;AAIA,aAAW,OAAO,gBAAgB;AAChC,QAAI,OAAO,SAAS,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG;AAC/C,YAAM,eAAe,GAAG,CAAC,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;AAGA,MAAM,cAAc,QAAQ,OAAO;AACnC,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,mBAAmB,eAAe;AAAA,EAClC,gBAAgB,eAAe;AAAA,EAC/B,iBAAiB,eAAe;AAAA,EAChC,kBAAkB,eAAe;AACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "
|
|
31
|
-
"@tamagui/constants": "
|
|
32
|
-
"@tamagui/helpers": "
|
|
33
|
-
"@tamagui/normalize-css-color": "
|
|
34
|
-
"@tamagui/use-did-finish-ssr": "
|
|
35
|
-
"@tamagui/use-event": "
|
|
36
|
-
"@tamagui/use-force-update": "
|
|
30
|
+
"@tamagui/compose-refs": "1.6.0",
|
|
31
|
+
"@tamagui/constants": "1.6.0",
|
|
32
|
+
"@tamagui/helpers": "1.6.0",
|
|
33
|
+
"@tamagui/normalize-css-color": "1.6.0",
|
|
34
|
+
"@tamagui/use-did-finish-ssr": "1.6.0",
|
|
35
|
+
"@tamagui/use-event": "1.6.0",
|
|
36
|
+
"@tamagui/use-force-update": "1.6.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "
|
|
42
|
+
"@tamagui/build": "1.6.0",
|
|
43
43
|
"@testing-library/react": "^13.4.0",
|
|
44
44
|
"csstype": "^3.0.10",
|
|
45
45
|
"react": "^18.2.0",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isWeb } from '@tamagui/constants'
|
|
2
|
+
|
|
1
3
|
import { getConfig } from '../config.js'
|
|
2
4
|
import { expandStyle } from './expandStyle.js'
|
|
3
5
|
import { normalizeShadow } from './normalizeShadow'
|
|
@@ -60,10 +62,12 @@ export function fixStyles(style: Record<string, any>) {
|
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
// native doesn't support specific border edge style
|
|
66
|
+
const nativeStyle = isWeb ? null : 'borderStyle'
|
|
63
67
|
const borderDefaults = {
|
|
64
68
|
borderWidth: 'borderStyle',
|
|
65
|
-
borderBottomWidth: 'borderBottomStyle',
|
|
66
|
-
borderTopWidth: 'borderTopStyle',
|
|
67
|
-
borderLeftWidth: 'borderLeftStyle',
|
|
68
|
-
borderRightWidth: 'borderRightStyle',
|
|
69
|
+
borderBottomWidth: nativeStyle || 'borderBottomStyle',
|
|
70
|
+
borderTopWidth: nativeStyle || 'borderTopStyle',
|
|
71
|
+
borderLeftWidth: nativeStyle || 'borderLeftStyle',
|
|
72
|
+
borderRightWidth: nativeStyle || 'borderRightStyle',
|
|
69
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/expandStyles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expandStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/expandStyles.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;;;;;;;;;;;;sCAAc,uBAyB5E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAiBnD"}
|