@microsoft/atlas-css
Advanced tools
Comparing version 3.30.0 to 3.31.0
@@ -25,7 +25,21 @@ // To parse this data: | ||
function invalidValue(typ: any, val: any, key: any = ''): never { | ||
if (key) { | ||
throw Error(`Invalid value for key "${key}". Expected type ${JSON.stringify(typ)} but got ${JSON.stringify(val)}`); | ||
function invalidValue(typ: any, val: any, key: any, parent: any = ''): never { | ||
const prettyTyp = prettyTypeName(typ); | ||
const parentText = parent ? ` on ${parent}` : ''; | ||
const keyText = key ? ` for key "${key}"` : ''; | ||
throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`); | ||
} | ||
function prettyTypeName(typ: any): string { | ||
if (Array.isArray(typ)) { | ||
if (typ.length === 2 && typ[0] === undefined) { | ||
return `an optional ${prettyTypeName(typ[1])}`; | ||
} else { | ||
return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`; | ||
} | ||
} else if (typeof typ === "object" && typ.literal !== undefined) { | ||
return typ.literal; | ||
} else { | ||
return typeof typ; | ||
} | ||
throw Error(`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`, ); | ||
} | ||
@@ -51,6 +65,6 @@ | ||
function transform(val: any, typ: any, getProps: any, key: any = ''): any { | ||
function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any { | ||
function transformPrimitive(typ: string, val: any): any { | ||
if (typeof typ === typeof val) return val; | ||
return invalidValue(typ, val, key); | ||
return invalidValue(typ, val, key, parent); | ||
} | ||
@@ -67,3 +81,3 @@ | ||
} | ||
return invalidValue(typs, val); | ||
return invalidValue(typs, val, key, parent); | ||
} | ||
@@ -73,3 +87,3 @@ | ||
if (cases.indexOf(val) !== -1) return val; | ||
return invalidValue(cases, val); | ||
return invalidValue(cases.map(a => { return l(a); }), val, key, parent); | ||
} | ||
@@ -79,3 +93,3 @@ | ||
// val must be an array with no invalid elements | ||
if (!Array.isArray(val)) return invalidValue("array", val); | ||
if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent); | ||
return val.map(el => transform(el, typ, getProps)); | ||
@@ -90,3 +104,3 @@ } | ||
if (isNaN(d.valueOf())) { | ||
return invalidValue("Date", val); | ||
return invalidValue(l("Date"), val, key, parent); | ||
} | ||
@@ -98,3 +112,3 @@ return d; | ||
if (val === null || typeof val !== "object" || Array.isArray(val)) { | ||
return invalidValue("object", val); | ||
return invalidValue(l(ref || "object"), val, key, parent); | ||
} | ||
@@ -105,7 +119,7 @@ const result: any = {}; | ||
const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined; | ||
result[prop.key] = transform(v, prop.typ, getProps, prop.key); | ||
result[prop.key] = transform(v, prop.typ, getProps, key, ref); | ||
}); | ||
Object.getOwnPropertyNames(val).forEach(key => { | ||
if (!Object.prototype.hasOwnProperty.call(props, key)) { | ||
result[key] = transform(val[key], additional, getProps, key); | ||
result[key] = transform(val[key], additional, getProps, key, ref); | ||
} | ||
@@ -119,6 +133,8 @@ }); | ||
if (val === null) return val; | ||
return invalidValue(typ, val); | ||
return invalidValue(typ, val, key, parent); | ||
} | ||
if (typ === false) return invalidValue(typ, val); | ||
if (typ === false) return invalidValue(typ, val, key, parent); | ||
let ref: any = undefined; | ||
while (typeof typ === "object" && typ.ref !== undefined) { | ||
ref = typ.ref; | ||
typ = typeMap[typ.ref]; | ||
@@ -131,3 +147,3 @@ } | ||
: typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val) | ||
: invalidValue(typ, val); | ||
: invalidValue(typ, val, key, parent); | ||
} | ||
@@ -147,2 +163,6 @@ // Numbers can be parsed by Date but shouldn't be. | ||
function l(typ: any) { | ||
return { literal: typ }; | ||
} | ||
function a(typ: any) { | ||
@@ -149,0 +169,0 @@ return { arrayItems: typ }; |
@@ -424,7 +424,21 @@ // To parse this data: | ||
function invalidValue(typ: any, val: any, key: any = ''): never { | ||
if (key) { | ||
throw Error(`Invalid value for key "${key}". Expected type ${JSON.stringify(typ)} but got ${JSON.stringify(val)}`); | ||
function invalidValue(typ: any, val: any, key: any, parent: any = ''): never { | ||
const prettyTyp = prettyTypeName(typ); | ||
const parentText = parent ? ` on ${parent}` : ''; | ||
const keyText = key ? ` for key "${key}"` : ''; | ||
throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`); | ||
} | ||
function prettyTypeName(typ: any): string { | ||
if (Array.isArray(typ)) { | ||
if (typ.length === 2 && typ[0] === undefined) { | ||
return `an optional ${prettyTypeName(typ[1])}`; | ||
} else { | ||
return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`; | ||
} | ||
} else if (typeof typ === "object" && typ.literal !== undefined) { | ||
return typ.literal; | ||
} else { | ||
return typeof typ; | ||
} | ||
throw Error(`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`, ); | ||
} | ||
@@ -450,6 +464,6 @@ | ||
function transform(val: any, typ: any, getProps: any, key: any = ''): any { | ||
function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any { | ||
function transformPrimitive(typ: string, val: any): any { | ||
if (typeof typ === typeof val) return val; | ||
return invalidValue(typ, val, key); | ||
return invalidValue(typ, val, key, parent); | ||
} | ||
@@ -466,3 +480,3 @@ | ||
} | ||
return invalidValue(typs, val); | ||
return invalidValue(typs, val, key, parent); | ||
} | ||
@@ -472,3 +486,3 @@ | ||
if (cases.indexOf(val) !== -1) return val; | ||
return invalidValue(cases, val); | ||
return invalidValue(cases.map(a => { return l(a); }), val, key, parent); | ||
} | ||
@@ -478,3 +492,3 @@ | ||
// val must be an array with no invalid elements | ||
if (!Array.isArray(val)) return invalidValue("array", val); | ||
if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent); | ||
return val.map(el => transform(el, typ, getProps)); | ||
@@ -489,3 +503,3 @@ } | ||
if (isNaN(d.valueOf())) { | ||
return invalidValue("Date", val); | ||
return invalidValue(l("Date"), val, key, parent); | ||
} | ||
@@ -497,3 +511,3 @@ return d; | ||
if (val === null || typeof val !== "object" || Array.isArray(val)) { | ||
return invalidValue("object", val); | ||
return invalidValue(l(ref || "object"), val, key, parent); | ||
} | ||
@@ -504,7 +518,7 @@ const result: any = {}; | ||
const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined; | ||
result[prop.key] = transform(v, prop.typ, getProps, prop.key); | ||
result[prop.key] = transform(v, prop.typ, getProps, key, ref); | ||
}); | ||
Object.getOwnPropertyNames(val).forEach(key => { | ||
if (!Object.prototype.hasOwnProperty.call(props, key)) { | ||
result[key] = transform(val[key], additional, getProps, key); | ||
result[key] = transform(val[key], additional, getProps, key, ref); | ||
} | ||
@@ -518,6 +532,8 @@ }); | ||
if (val === null) return val; | ||
return invalidValue(typ, val); | ||
return invalidValue(typ, val, key, parent); | ||
} | ||
if (typ === false) return invalidValue(typ, val); | ||
if (typ === false) return invalidValue(typ, val, key, parent); | ||
let ref: any = undefined; | ||
while (typeof typ === "object" && typ.ref !== undefined) { | ||
ref = typ.ref; | ||
typ = typeMap[typ.ref]; | ||
@@ -530,3 +546,3 @@ } | ||
: typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val) | ||
: invalidValue(typ, val); | ||
: invalidValue(typ, val, key, parent); | ||
} | ||
@@ -546,2 +562,6 @@ // Numbers can be parsed by Date but shouldn't be. | ||
function l(typ: any) { | ||
return { literal: typ }; | ||
} | ||
function a(typ: any) { | ||
@@ -548,0 +568,0 @@ return { arrayItems: typ }; |
{ | ||
"name": "@microsoft/atlas-css", | ||
"version": "3.30.0", | ||
"version": "3.31.0", | ||
"description": "Styles backing the Atlas Design System used by Microsoft's Developer Relations.", | ||
@@ -76,17 +76,17 @@ "scripts": { | ||
"@microsoft/stylelint-config-atlas": "4.0.2", | ||
"@parcel/transformer-sass": "^2.7.0", | ||
"css-tree": "^2.2.1", | ||
"eslint-plugin-security": "^1.5.0", | ||
"fs-extra": "^10.1.0", | ||
"parcel": "^2.7.0", | ||
"lightningcss": "1.16.0", | ||
"prettier": "^2.7.1", | ||
"quicktype-core": "^6.0.62", | ||
"@parcel/transformer-sass": "^2.8.3", | ||
"css-tree": "^2.3.1", | ||
"eslint-plugin-security": "^1.7.1", | ||
"fs-extra": "^11.1.1", | ||
"parcel": "^2.8.3", | ||
"lightningcss": "1.19.0", | ||
"prettier": "^2.8.7", | ||
"quicktype-core": "^23.0.19", | ||
"grass": "^1.0.2", | ||
"sass-export": "^2.1.2", | ||
"stylelint": "^14.13.0", | ||
"stylelint-config-prettier": "^9.0.3", | ||
"stylelint-prettier": "^2.0.0", | ||
"stylelint": "^14.16.1", | ||
"stylelint-config-prettier": "^9.0.5", | ||
"stylelint-prettier": "^3.0.0", | ||
"wireit": "^0.9.5" | ||
} | ||
} |
@@ -7,3 +7,3 @@ # Atlas CSS Tokens | ||
Firstly, in order to access these tokens, you must have installed atlas-css in your project. [See installation steps]('https://github.com/microsoft/atlas-design'). Once this is complete, you'll need to decide whether you want to reference them in Scss or JSON. | ||
Firstly, in order to access these tokens, you must have installed atlas-css in your project. [See installation steps](https://github.com/microsoft/atlas-design). Once this is complete, you'll need to decide whether you want to reference them in Scss or JSON. | ||
@@ -10,0 +10,0 @@ ### Get Scss from NPM |
Sorry, the diff of this file is too big to display
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
Sorry, the diff of this file is not supported yet
817117
104
2635