@stylexjs/shared 0.10.0-beta.1 → 0.10.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.
@@ -13,7 +13,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
13
13
|
function styleXDefineVars(variables, options) {
|
14
14
|
const {
|
15
15
|
classNamePrefix,
|
16
|
-
themeName
|
16
|
+
themeName,
|
17
|
+
debug
|
17
18
|
} = {
|
18
19
|
..._defaultOptions.defaultOptions,
|
19
20
|
...options
|
@@ -21,7 +22,7 @@ function styleXDefineVars(variables, options) {
|
|
21
22
|
const themeNameHash = classNamePrefix + (0, _hash.default)(themeName);
|
22
23
|
const typedVariables = {};
|
23
24
|
const variablesMap = (0, _objectUtils.objMap)(variables, (value, key) => {
|
24
|
-
const nameHash = key.startsWith('--') ? key.slice(2) : classNamePrefix + (0, _hash.default)(`${themeName}.${key}`);
|
25
|
+
const nameHash = key.startsWith('--') ? key.slice(2) : debug ? key + '-' + classNamePrefix + (0, _hash.default)(`${themeName}.${key}`) : classNamePrefix + (0, _hash.default)(`${themeName}.${key}`);
|
25
26
|
if ((0, _types.isCSSType)(value)) {
|
26
27
|
const v = value;
|
27
28
|
typedVariables[nameHash] = {
|
package/lib/transform-value.js
CHANGED
@@ -12,12 +12,15 @@ function transformValue(key, rawValue, options) {
|
|
12
12
|
const value = typeof rawValue === 'number' ? String(Math.round(rawValue * 10000) / 10000) + getNumberSuffix(key) : rawValue;
|
13
13
|
if ((key === 'content' || key === 'hyphenateCharacter' || key === 'hyphenate-character') && typeof value === 'string') {
|
14
14
|
const val = value.trim();
|
15
|
-
|
15
|
+
const cssContentFunctions = ['attr(', 'counter(', 'counters(', 'url(', 'linear-gradient(', 'image-set('];
|
16
|
+
const cssContentKeywords = new Set(['normal', 'none', 'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote', 'inherit', 'initial', 'revert', 'revert-layer', 'unset']);
|
17
|
+
const isCssFunction = cssContentFunctions.some(func => val.includes(func));
|
18
|
+
const isKeyword = cssContentKeywords.has(val);
|
19
|
+
const hasMatchingQuotes = (val.match(/"/g)?.length ?? 0) >= 2 || (val.match(/'/g)?.length ?? 0) >= 2;
|
20
|
+
if (isCssFunction || isKeyword || hasMatchingQuotes) {
|
16
21
|
return val;
|
17
22
|
}
|
18
|
-
|
19
|
-
return `"${val}"`;
|
20
|
-
}
|
23
|
+
return `"${val}"`;
|
21
24
|
}
|
22
25
|
return (0, _normalizeValue.default)(value, key, options);
|
23
26
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@stylexjs/shared",
|
3
|
-
"version": "0.10.0
|
3
|
+
"version": "0.10.0",
|
4
4
|
"main": "lib/index.js",
|
5
5
|
"repository": "https://www.github.com/facebook/stylex",
|
6
6
|
"license": "MIT",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"postcss-value-parser": "^4.1.0"
|
14
14
|
},
|
15
15
|
"devDependencies": {
|
16
|
-
"@stylexjs/scripts": "0.10.0
|
16
|
+
"@stylexjs/scripts": "0.10.0"
|
17
17
|
},
|
18
18
|
"jest": {
|
19
19
|
"snapshotFormat": {
|