Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "windicss", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "windicss is a css compiler or css interpreter, which is based on the grammar of tailwindcss and adds other features.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -5,4 +5,4 @@ import { StyleSheet } from '../utils/style'; | ||
ignored: string[]; | ||
className: string; | ||
className: string | undefined; | ||
styleSheet: StyleSheet; | ||
}; |
@@ -69,3 +69,3 @@ "use strict"; | ||
ignored: ignored, | ||
className: className, | ||
className: success.length > 0 ? className : undefined, | ||
styleSheet: style.combine() | ||
@@ -72,0 +72,0 @@ }; |
@@ -101,4 +101,4 @@ "use strict"; | ||
.map(function (i) { | ||
var _a, _b; | ||
var list = __spreadArrays(((_a = i.atRules) !== null && _a !== void 0 ? _a : []).sort(sort_1.sortMediaQuery), [(_b = i.selector) !== null && _b !== void 0 ? _b : '']); | ||
var _a; | ||
var list = __spreadArrays(((_a = i.atRules) !== null && _a !== void 0 ? _a : []).sort(sort_1.sortMediaQuery), [i.rule]); | ||
return deepList(list, new style_1.Style(undefined, i.property)); | ||
@@ -105,0 +105,0 @@ }) |
@@ -9,4 +9,4 @@ import { StyleSheet } from './style'; | ||
private _generateStyle; | ||
private _clearDirectives; | ||
private _handleDirectives; | ||
parse(css?: string, transform?: boolean): StyleSheet; | ||
} |
@@ -16,2 +16,3 @@ "use strict"; | ||
var processor_1 = require("../processor"); | ||
var variants_1 = require("../processor/variants"); | ||
var screen_1 = __importDefault(require("../processor/variants/screen")); | ||
@@ -90,11 +91,16 @@ var CSSParser = /** @class */ (function () { | ||
}; | ||
CSSParser.prototype._clearDirectives = function (atrule) { | ||
CSSParser.prototype._handleDirectives = function (atrule) { | ||
var _a; | ||
// transform @screen, keep @layer, remove other directives | ||
var iatrule = style_1.InlineAtRule.parse(atrule); | ||
if (["tailwind", "variants", "responsive"].includes(iatrule.name)) | ||
if (["tailwind", "responsive"].includes(iatrule.name)) | ||
return undefined; | ||
if (iatrule.name === 'screen' && iatrule.value && screen_1.default.hasOwnProperty(iatrule.value)) | ||
return (_a = screen_1.default[iatrule.value]().atRules) === null || _a === void 0 ? void 0 : _a[0]; | ||
return atrule; | ||
if (iatrule.name === "variants" && iatrule.value) | ||
return { variants: iatrule.value.split(',').map(function (i) { return i.trim().split(':'); }) }; | ||
if (iatrule.name === 'screen' && iatrule.value) { | ||
if (screen_1.default.hasOwnProperty(iatrule.value)) | ||
return { atrule: (_a = screen_1.default[iatrule.value]().atRules) === null || _a === void 0 ? void 0 : _a[0] }; | ||
if (['dark', 'light'].includes(iatrule.value)) | ||
return { atrule: "@media (prefers-color-scheme: " + iatrule.value + ")" }; | ||
} | ||
return { atrule: atrule }; | ||
}; | ||
@@ -117,5 +123,9 @@ CSSParser.prototype.parse = function (css, transform) { | ||
// inline atrule | ||
var atrule = this_1._clearDirectives(css.substring(firstLetter, ruleEnd).trim()); | ||
if (atrule) | ||
styleSheet.add(style_1.InlineAtRule.parse(atrule).toStyle()); | ||
var atrule = css.substring(firstLetter, ruleEnd).trim(); | ||
if (transform) { | ||
var directives = this_1._handleDirectives(atrule); | ||
if (directives === null || directives === void 0 ? void 0 : directives.atrule) | ||
atrule = directives.atrule; | ||
} | ||
styleSheet.add(style_1.InlineAtRule.parse(atrule).toStyle()); | ||
index = ruleEnd + 1; | ||
@@ -127,6 +137,16 @@ } | ||
var atrule_1 = css.substring(firstLetter, nestStart).trim(); | ||
if (transform) | ||
atrule_1 = this_1._clearDirectives(atrule_1); | ||
var result = this_1.parse(css.substring(nestStart + 1, nestEnd), transform).children.map(function (i) { return i.atRule(atrule_1); }); | ||
styleSheet.add(result); | ||
if (transform) { | ||
var directives_1 = this_1._handleDirectives(atrule_1); | ||
if (directives_1 === null || directives_1 === void 0 ? void 0 : directives_1.atrule) { | ||
styleSheet.add(this_1.parse(css.substring(nestStart + 1, nestEnd), transform).children.map(function (i) { return i.atRule(directives_1.atrule); })); | ||
} | ||
else if (directives_1 === null || directives_1 === void 0 ? void 0 : directives_1.variants) { | ||
var variants = directives_1.variants; | ||
var style_2 = this_1.parse(css.substring(nestStart + 1, nestEnd), transform).children; | ||
variants.map(function (i) { return variants_1.apply(i, style_2); }).forEach(function (i) { return styleSheet.add(i); }); | ||
} | ||
} | ||
else { | ||
styleSheet.add(this_1.parse(css.substring(nestStart + 1, nestEnd), transform).children.map(function (i) { return i.atRule(atrule_1); })); | ||
} | ||
index = nestEnd + 1; | ||
@@ -133,0 +153,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237721
5534