@aesthetic/sss
Advanced tools
Comparing version 0.6.2 to 0.6.3
@@ -1,4 +0,4 @@ | ||
import { ClassName, Value } from '@aesthetic/types'; | ||
import { Value } from '@aesthetic/types'; | ||
export default class Block<T extends object = object> { | ||
className: string; | ||
result?: unknown; | ||
media: string; | ||
@@ -14,3 +14,3 @@ readonly nested: Record<string, Block<T>>; | ||
constructor(id?: string); | ||
addClassName(name: ClassName): void; | ||
addResult(result: unknown): void; | ||
nest(child: Block<T>): Block<T>; | ||
@@ -17,0 +17,0 @@ merge(block: Block<T>): this; |
import { LocalStyleSheet, GlobalStyleSheet, ParserOptions } from './types'; | ||
export declare const CLASS_NAME: RegExp; | ||
export default function parse<T extends object>(type: 'local' | 'global', styleSheet: LocalStyleSheet | GlobalStyleSheet, baseOptions: Partial<ParserOptions<T>>): void; | ||
export default function parse<T extends object>(type: 'local' | 'global', styleSheet: LocalStyleSheet<T> | GlobalStyleSheet<T>, baseOptions: Partial<ParserOptions<T>>): void; | ||
//# sourceMappingURL=parse.d.ts.map |
@@ -42,19 +42,19 @@ import CSSType from 'csstype'; | ||
export declare type LocalBlockVariants = Record<string, LocalBlockMap>; | ||
export declare type LocalBlockNeverize<T> = { | ||
[K in keyof T]: K extends keyof LocalBlock ? T[K] : never; | ||
export declare type LocalStyleSheet<B = LocalBlock> = RuleMap<string | B>; | ||
export declare type LocalStyleSheetNeverize<T, B> = { | ||
[K in keyof T]: T[K] extends string ? string : LocalStyleSheetElementNeverize<T[K], B>; | ||
}; | ||
export declare type LocalStyleSheet = RuleMap<string | LocalBlock>; | ||
export declare type LocalStyleSheetNeverize<T> = { | ||
[K in keyof T]: T[K] extends string ? string : LocalBlockNeverize<T[K]>; | ||
export declare type LocalStyleSheetElementNeverize<T, B> = { | ||
[K in keyof T]: K extends keyof B ? T[K] : never; | ||
}; | ||
export declare type GlobalAtRule = '@font-face' | '@import' | '@keyframes' | '@root' | '@variables'; | ||
export interface GlobalStyleSheet { | ||
export interface GlobalStyleSheet<B = LocalBlock> { | ||
'@font-face'?: FontFaceMap; | ||
'@import'?: ImportList; | ||
'@keyframes'?: KeyframesMap; | ||
'@root'?: LocalBlock; | ||
'@root'?: B; | ||
'@variables'?: VariablesMap; | ||
} | ||
export declare type GlobalStyleSheetNeverize<T> = { | ||
[K in keyof T]: K extends keyof GlobalStyleSheet ? GlobalStyleSheet[K] : never; | ||
export declare type GlobalStyleSheetNeverize<T, B> = { | ||
[K in keyof T]: K extends keyof GlobalStyleSheet<B> ? GlobalStyleSheet<B>[K] : never; | ||
}; | ||
@@ -61,0 +61,0 @@ export declare type AtRule = LocalAtRule | GlobalAtRule; |
@@ -11,3 +11,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
this.className = ''; | ||
this.result = void 0; | ||
this.media = ''; | ||
@@ -27,8 +27,23 @@ this.nested = {}; | ||
_proto.addClassName = function addClassName(name) { | ||
_proto.addResult = function addResult(result) { | ||
if (this.parent) { | ||
this.parent.addClassName(name); | ||
} else { | ||
this.className += " " + name; | ||
this.parent.addResult(result); | ||
return; | ||
} | ||
var type = typeof result; | ||
if (type === 'string') { | ||
if (this.result === undefined) { | ||
this.result = result; | ||
} else { | ||
this.result += " " + result; | ||
} | ||
} else if (type === 'object' && result) { | ||
if (this.result === undefined) { | ||
this.result = result; | ||
} else { | ||
Object.assign(this.result, result); | ||
} | ||
} | ||
}; | ||
@@ -147,5 +162,4 @@ | ||
}); | ||
obj[key] = undefined; | ||
} | ||
obj[key] = undefined; | ||
}, | ||
@@ -152,0 +166,0 @@ process: function process() { |
@@ -17,3 +17,3 @@ 'use strict'; | ||
this.className = ''; | ||
this.result = void 0; | ||
this.media = ''; | ||
@@ -33,8 +33,23 @@ this.nested = {}; | ||
_proto.addClassName = function addClassName(name) { | ||
_proto.addResult = function addResult(result) { | ||
if (this.parent) { | ||
this.parent.addClassName(name); | ||
} else { | ||
this.className += " " + name; | ||
this.parent.addResult(result); | ||
return; | ||
} | ||
var type = typeof result; | ||
if (type === 'string') { | ||
if (this.result === undefined) { | ||
this.result = result; | ||
} else { | ||
this.result += " " + result; | ||
} | ||
} else if (type === 'object' && result) { | ||
if (this.result === undefined) { | ||
this.result = result; | ||
} else { | ||
Object.assign(this.result, result); | ||
} | ||
} | ||
}; | ||
@@ -153,5 +168,4 @@ | ||
}); | ||
obj[key] = undefined; | ||
} | ||
obj[key] = undefined; | ||
}, | ||
@@ -158,0 +172,0 @@ process: function process() { |
{ | ||
"name": "@aesthetic/sss", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "A strict, type-safe, and structure-safe component style sheet format.", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@aesthetic/types": "^0.4.2", | ||
"@aesthetic/types": "^0.4.3", | ||
"@aesthetic/utils": "^0.6.1", | ||
@@ -41,3 +41,3 @@ "csstype": "^3.0.5" | ||
}, | ||
"gitHead": "ba9b49086e409517e03cd920008934773fd4e6e9" | ||
"gitHead": "86b9207ab41751e081de1269c5a850a5ba439a5c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
94823
1093
Updated@aesthetic/types@^0.4.3