Comparing version 0.1.21 to 0.1.22
@@ -29,3 +29,3 @@ "use strict"; | ||
NSMixinContext.prototype.insertRules = function (rules) { | ||
this.insertSelector('', rules); | ||
this.selectors['**inline**'] = __assign({}, this.selectors['**inline**'], rules); | ||
}; | ||
@@ -32,0 +32,0 @@ NSMixinContext.prototype.insertSelector = function (selector, rules) { |
@@ -77,2 +77,5 @@ "use strict"; | ||
break; | ||
case "global": | ||
sheet.globals.push(definition.localKey); | ||
break; | ||
default: | ||
@@ -192,2 +195,5 @@ throw new Error('Unknown kind: ' + JSON.stringify(definition)); | ||
var _a = sheet.scopedMap[name], definition = _a.definition, scopedName = _a.scopedName; | ||
if (~sheet.globals.indexOf(node.name)) { | ||
return; | ||
} | ||
if (definition._kind === 'root') { | ||
@@ -209,3 +215,3 @@ node.name = scopedName; | ||
currentType = definition.type; | ||
node.before = "." + sheet.scopedRoot() + " ." + scopedName; | ||
node.before = (firstElement ? "." + sheet.scopedRoot() + " " : '') + ("." + scopedName); | ||
node.name = currentType.scopedRoot(); | ||
@@ -212,0 +218,0 @@ } |
@@ -42,3 +42,3 @@ import { StylesheetContext } from "./stylesheet-context"; | ||
export interface CustomizeDef extends TypedClass { | ||
_kind: "customize"; | ||
_kind: "customize" | "global"; | ||
} | ||
@@ -45,0 +45,0 @@ export interface SelectorDef { |
@@ -52,16 +52,24 @@ "use strict"; | ||
} | ||
function createCSS(sheet, selector, rules, bucket, localSelector, theme) { | ||
function createCSS(sheet, selector, mainRules, bucket, localSelector, theme) { | ||
var css = ''; | ||
var key; | ||
var mixinContext = new define_mixin_1.NSMixinContext(localSelector, rules, sheet); | ||
for (key in rules) { | ||
var rawValue = rules[key]; //TODO: handle arrays!!! | ||
if (rawValue._kind === 'mixin') { | ||
rawValue.apply(mixinContext, rawValue.options); | ||
var mixinContext = new define_mixin_1.NSMixinContext(localSelector, mainRules, sheet); | ||
function collectRules(rules) { | ||
for (key in rules) { | ||
var rawValue = rules[key]; //TODO: handle arrays!!! | ||
if (rawValue._kind === 'mixin') { | ||
rawValue.apply(mixinContext, rawValue.options); | ||
if (mixinContext.selectors['**inline**']) { | ||
var inlineRules = mixinContext.selectors['**inline**']; | ||
delete mixinContext.selectors['**inline**']; | ||
collectRules(inlineRules); | ||
} | ||
} | ||
else { | ||
var value = theme ? tpl('' + rawValue, theme) : rawValue; | ||
css += kebabCase(key) + ':' + value + ';'; | ||
} | ||
} | ||
else { | ||
var value = theme ? tpl('' + rawValue, theme) : rawValue; | ||
css += kebabCase(key) + ':' + value + ';'; | ||
} | ||
} | ||
collectRules(mainRules); | ||
if (css) { | ||
@@ -68,0 +76,0 @@ bucket.push(selector + '{' + css + '}'); |
@@ -9,2 +9,3 @@ import { TypedClasses, Map, RootDef, StateDef, ComponentDef, CustomizeDef, ScopedDef, TypedStyle, TypedStylesheetInput } from './nscss.interfaces'; | ||
scopedMap: Map<ScopedDef>; | ||
globals: string[]; | ||
constructor(styleDef: Partial<TypedStyle>); | ||
@@ -19,2 +20,3 @@ cssStates(stateMapping?: Map<boolean>): {}; | ||
static scoped(type: TypedStylesheetInput): CustomizeDef; | ||
static global(): CustomizeDef; | ||
} |
@@ -42,4 +42,7 @@ "use strict"; | ||
}; | ||
NSCSSStylesheet.global = function () { | ||
return { _kind: 'global', type: functions_1.getStylesheetFromType('*') }; | ||
}; | ||
return NSCSSStylesheet; | ||
}()); | ||
exports.NSCSSStylesheet = NSCSSStylesheet; |
{ | ||
"name": "nscss", | ||
"version": "0.1.21", | ||
"version": "0.1.22", | ||
"description": "CSS for Components", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/nscss.js", |
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
114002
44
1941