@cobalt-ui/core
Advanced tools
Comparing version 1.7.3 to 1.8.0
# @cobalt-ui/core | ||
## 1.8.0 | ||
### Minor Changes | ||
- [#218](https://github.com/drwpow/cobalt-ui/pull/218) [`041a8d070b74d2bca46e0c26c0c522f96b585458`](https://github.com/drwpow/cobalt-ui/commit/041a8d070b74d2bca46e0c26c0c522f96b585458) Thanks [@drwpow](https://github.com/drwpow)! - Add `lint()` and `registerRules()` stages to plugins | ||
- [#218](https://github.com/drwpow/cobalt-ui/pull/218) [`041a8d070b74d2bca46e0c26c0c522f96b585458`](https://github.com/drwpow/cobalt-ui/commit/041a8d070b74d2bca46e0c26c0c522f96b585458) Thanks [@drwpow](https://github.com/drwpow)! - Support `lint` and lint rules in config | ||
### Patch Changes | ||
- [#218](https://github.com/drwpow/cobalt-ui/pull/218) [`041a8d070b74d2bca46e0c26c0c522f96b585458`](https://github.com/drwpow/cobalt-ui/commit/041a8d070b74d2bca46e0c26c0c522f96b585458) Thanks [@drwpow](https://github.com/drwpow)! - build() command is no longer required in types | ||
## 1.7.3 | ||
@@ -4,0 +16,0 @@ |
@@ -1,6 +0,7 @@ | ||
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" /> | ||
import type { Group, ParsedToken } from './token.js'; | ||
export type { BorderToken, ColorToken, CubicBezierToken, DimensionToken, DurationToken, FontFamilyToken, FontWeightToken, NumberToken, GradientStop, GradientToken, Group, LinkToken, Mode, ParsedBorderToken, ParsedColorToken, ParsedCubicBezierToken, ParsedDimensionToken, ParsedDurationToken, ParsedFontFamilyToken, ParsedFontWeightToken, ParsedNumberToken, ParsedGradientToken, ParsedLinkToken, ParsedShadowToken, ParsedStrokeStyleToken, ParsedToken, ParsedTransitionToken, ParsedTypographyToken, ParsedTypographyValue, ShadowToken, ShadowValue, StrokeStyleToken, Token, TokenBase, TokenOrGroup, TokenType, TransitionToken, TypographyToken, TypographyValue, } from './token.js'; | ||
import { ParseOptions, parse } from './parse/index.js'; | ||
export { parse, ParseOptions, ParseResult } from './parse/index.js'; | ||
import type { LintRule, LintRuleSeverity, ParseOptions } from './parse/index.js'; | ||
import { parse } from './parse/index.js'; | ||
export { parse, type LintRule, type ParseOptions, type ParseResult } from './parse/index.js'; | ||
export interface BuildResult { | ||
@@ -12,7 +13,31 @@ /** File to output inside config.outDir (ex: ./tokens.sass) */ | ||
} | ||
export interface ResolvedConfig extends ParseOptions { | ||
export interface ResolvedConfig extends Omit<ParseOptions, 'lint'> { | ||
tokens: URL[]; | ||
outDir: URL; | ||
plugins: Plugin[]; | ||
lint: { | ||
rules: Record<string, LintRule>; | ||
}; | ||
} | ||
export interface BuildStageOptions { | ||
/** Parsed, normalized, resolved tokens schema */ | ||
tokens: ParsedToken[]; | ||
metadata: Record<string, unknown>; | ||
/** The user’s original schema, as-authored */ | ||
rawSchema: Group; | ||
} | ||
export interface LintStageOptions { | ||
/** Parsed, normalized, resolved tokens schema */ | ||
tokens: ParsedToken[]; | ||
/** IDs of enabled rules to report on (warning: may be empty!) */ | ||
rules: LintRule[]; | ||
/** The user’s original schema, as-authored */ | ||
rawSchema: Group; | ||
} | ||
export interface LintNotice { | ||
/** Must match a registered rule */ | ||
id: string; | ||
/** Lint message shown to the user */ | ||
message: string; | ||
} | ||
export interface Plugin { | ||
@@ -22,10 +47,12 @@ name: string; | ||
config?(config: ResolvedConfig): void | ResolvedConfig | undefined; | ||
/** (optional) register lint rule IDs */ | ||
registerRules?(): Omit<LintRule, 'options'>[]; | ||
/** (optional) throw lint errors/warnings */ | ||
lint?(options: LintStageOptions): Promise<LintNotice[] | undefined>; | ||
/** main build fn */ | ||
build(options: { | ||
tokens: ParsedToken[]; | ||
metadata: Record<string, unknown>; | ||
rawSchema: Group; | ||
}): Promise<BuildResult[]>; | ||
build?(options: BuildStageOptions): Promise<BuildResult[]>; | ||
} | ||
export interface Config extends Partial<ParseOptions> { | ||
type LintRuleShorthand = LintRuleSeverity | 0 | 1 | 2; | ||
type LintRuleLonghand = [LintRuleSeverity | 0 | 1 | 2, any]; | ||
export interface Config extends Partial<Omit<ParseOptions, 'lint'>> { | ||
/** path to tokens.json (default: "./tokens.json") */ | ||
@@ -37,2 +64,6 @@ tokens?: string | string[]; | ||
plugins: Plugin[]; | ||
/** specify lint rules */ | ||
lint?: { | ||
rules?: Record<string, LintRuleShorthand | LintRuleLonghand>; | ||
}; | ||
} | ||
@@ -39,0 +70,0 @@ declare const _default: { |
@@ -1,6 +0,7 @@ | ||
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" /> | ||
import type { Group, ParsedToken } from './token.js'; | ||
export type { BorderToken, ColorToken, CubicBezierToken, DimensionToken, DurationToken, FontFamilyToken, FontWeightToken, NumberToken, GradientStop, GradientToken, Group, LinkToken, Mode, ParsedBorderToken, ParsedColorToken, ParsedCubicBezierToken, ParsedDimensionToken, ParsedDurationToken, ParsedFontFamilyToken, ParsedFontWeightToken, ParsedNumberToken, ParsedGradientToken, ParsedLinkToken, ParsedShadowToken, ParsedStrokeStyleToken, ParsedToken, ParsedTransitionToken, ParsedTypographyToken, ParsedTypographyValue, ShadowToken, ShadowValue, StrokeStyleToken, Token, TokenBase, TokenOrGroup, TokenType, TransitionToken, TypographyToken, TypographyValue, } from './token.js'; | ||
import { ParseOptions, parse } from './parse/index.js'; | ||
export { parse, ParseOptions, ParseResult } from './parse/index.js'; | ||
import type { LintRule, LintRuleSeverity, ParseOptions } from './parse/index.js'; | ||
import { parse } from './parse/index.js'; | ||
export { parse, type LintRule, type ParseOptions, type ParseResult } from './parse/index.js'; | ||
export interface BuildResult { | ||
@@ -12,7 +13,31 @@ /** File to output inside config.outDir (ex: ./tokens.sass) */ | ||
} | ||
export interface ResolvedConfig extends ParseOptions { | ||
export interface ResolvedConfig extends Omit<ParseOptions, 'lint'> { | ||
tokens: URL[]; | ||
outDir: URL; | ||
plugins: Plugin[]; | ||
lint: { | ||
rules: Record<string, LintRule>; | ||
}; | ||
} | ||
export interface BuildStageOptions { | ||
/** Parsed, normalized, resolved tokens schema */ | ||
tokens: ParsedToken[]; | ||
metadata: Record<string, unknown>; | ||
/** The user’s original schema, as-authored */ | ||
rawSchema: Group; | ||
} | ||
export interface LintStageOptions { | ||
/** Parsed, normalized, resolved tokens schema */ | ||
tokens: ParsedToken[]; | ||
/** IDs of enabled rules to report on (warning: may be empty!) */ | ||
rules: LintRule[]; | ||
/** The user’s original schema, as-authored */ | ||
rawSchema: Group; | ||
} | ||
export interface LintNotice { | ||
/** Must match a registered rule */ | ||
id: string; | ||
/** Lint message shown to the user */ | ||
message: string; | ||
} | ||
export interface Plugin { | ||
@@ -22,10 +47,12 @@ name: string; | ||
config?(config: ResolvedConfig): void | ResolvedConfig | undefined; | ||
/** (optional) register lint rule IDs */ | ||
registerRules?(): Omit<LintRule, 'options'>[]; | ||
/** (optional) throw lint errors/warnings */ | ||
lint?(options: LintStageOptions): Promise<LintNotice[] | undefined>; | ||
/** main build fn */ | ||
build(options: { | ||
tokens: ParsedToken[]; | ||
metadata: Record<string, unknown>; | ||
rawSchema: Group; | ||
}): Promise<BuildResult[]>; | ||
build?(options: BuildStageOptions): Promise<BuildResult[]>; | ||
} | ||
export interface Config extends Partial<ParseOptions> { | ||
type LintRuleShorthand = LintRuleSeverity | 0 | 1 | 2; | ||
type LintRuleLonghand = [LintRuleSeverity | 0 | 1 | 2, any]; | ||
export interface Config extends Partial<Omit<ParseOptions, 'lint'>> { | ||
/** path to tokens.json (default: "./tokens.json") */ | ||
@@ -37,2 +64,6 @@ tokens?: string | string[]; | ||
plugins: Plugin[]; | ||
/** specify lint rules */ | ||
lint?: { | ||
rules?: Record<string, LintRuleShorthand | LintRuleLonghand>; | ||
}; | ||
} | ||
@@ -39,0 +70,0 @@ declare const _default: { |
@@ -183,4 +183,9 @@ import { formatHex, formatHex8, oklch } from 'culori'; | ||
export function isFigmaVariablesFormat(manifest) { | ||
return !!manifest && typeof manifest === 'object' && 'variables' in manifest && typeof manifest.variables === 'object' && 'variableCollections' in manifest && typeof manifest.variableCollections === 'object'; | ||
return (!!manifest && | ||
typeof manifest === 'object' && | ||
'variables' in manifest && | ||
typeof manifest.variables === 'object' && | ||
'variableCollections' in manifest && | ||
typeof manifest.variableCollections === 'object'); | ||
} | ||
//# sourceMappingURL=figma.js.map |
import type { ParsedToken } from '../token.js'; | ||
import { ParseColorOptions } from './tokens/color.js'; | ||
import type { ParseColorOptions } from './tokens/color.js'; | ||
import { type FigmaParseOptions } from './figma.js'; | ||
@@ -12,2 +12,8 @@ export interface ParseResult { | ||
} | ||
export interface LintRule { | ||
id: string; | ||
severity: LintRuleSeverity; | ||
options?: unknown; | ||
} | ||
export type LintRuleSeverity = 'error' | 'warn' | 'off' | number; | ||
export interface ParseOptions { | ||
@@ -17,2 +23,6 @@ /** Configure transformations for color tokens */ | ||
figma?: FigmaParseOptions; | ||
/** Configure plugin lint rules (if any) */ | ||
lint: { | ||
rules: Record<string, LintRule>; | ||
}; | ||
} | ||
@@ -19,0 +29,0 @@ export declare function parse(rawTokens: unknown, options: ParseOptions): ParseResult; |
@@ -47,4 +47,5 @@ import { cloneDeep, FG_YELLOW, getAliasID, invalidTokenIDError, isAlias, RESET } from '@cobalt-ui/utils'; | ||
function walk(node, chain = [], group = { $extensions: { requiredModes: [] } }) { | ||
if (!node || !isObj(node)) | ||
if (!node || !isObj(node)) { | ||
return; | ||
} | ||
for (const [k, v] of Object.entries(node)) { | ||
@@ -93,4 +94,5 @@ if (!v || !isObj(v)) { | ||
for (const modeID of group.$extensions.requiredModes) { | ||
if (!token.$extensions || !token.$extensions.mode || !token.$extensions.mode[modeID]) | ||
if (!token.$extensions || !token.$extensions.mode || !token.$extensions.mode[modeID]) { | ||
errors.push(`${token.id}: missing mode "${modeID}" required from parent group`); | ||
} | ||
} | ||
@@ -108,9 +110,12 @@ } | ||
// merge $extensions; don’t overwrite them | ||
if (propertyKey === '$extensions') | ||
if (propertyKey === '$extensions') { | ||
nextGroup.$extensions = { ...nextGroup.$extensions, ...v.$extensions }; | ||
else | ||
} | ||
else { | ||
nextGroup[propertyKey] = v[propertyKey]; | ||
} | ||
if (!RESERVED_KEYS.has(propertyKey)) { | ||
if (!result.warnings) | ||
if (!result.warnings) { | ||
result.warnings = []; | ||
} | ||
result.warnings.push(`Unknown property "${propertyKey}"`); | ||
@@ -139,9 +144,12 @@ } | ||
if (k.startsWith('$')) { | ||
if (k === '$extensions') | ||
if (k === '$extensions') { | ||
group.$extensions = { ...schema.$extensions, ...group.$extensions }; | ||
else | ||
} | ||
else { | ||
group[k] = schema[k]; | ||
} | ||
if (!RESERVED_KEYS.has(k)) { | ||
if (!result.warnings) | ||
if (!result.warnings) { | ||
result.warnings = []; | ||
} | ||
result.warnings.push(`Unknown property "${k}"`); | ||
@@ -178,4 +186,5 @@ } | ||
string(strVal) { | ||
if (!isAlias(strVal)) | ||
if (!isAlias(strVal)) { | ||
return strVal; | ||
} | ||
const nextID = getAliasID(strVal); | ||
@@ -221,4 +230,5 @@ if (!(nextID in values)) { | ||
const token = tokens[id]; | ||
if (!token.$extensions || !token.$extensions.mode) | ||
if (!token.$extensions || !token.$extensions.mode) { | ||
return; | ||
} | ||
for (const k of Object.keys(token.$extensions.mode || {})) { | ||
@@ -246,4 +256,5 @@ tokens[id].$extensions.mode[k] = validate(values[`${id}#${k}`]); | ||
case 'fontFamily': { | ||
if (token.$type === 'font') | ||
console.warn(`${FG_YELLOW}@cobalt-ui/core${RESET} $type: "font" is deprecated. Please use "fontFamily" instead.`); // eslint-disable-line no-console | ||
if (token.$type === 'font') { | ||
warnings.push(`${FG_YELLOW}@cobalt-ui/core${RESET} $type: "font" is deprecated. Please use "fontFamily" instead.`); | ||
} | ||
tokens[id].$value = normalizeFontFamilyValue(values[id]); | ||
@@ -332,6 +343,8 @@ normalizeModes(id, (v) => normalizeFontFamilyValue(v)); | ||
// 4. finish | ||
if (errors.length) | ||
if (errors.length) { | ||
result.errors = errors; | ||
if (warnings.length) | ||
} | ||
if (warnings.length) { | ||
result.warnings = warnings; | ||
} | ||
result.result.tokens = Object.values(tokens); | ||
@@ -344,4 +357,5 @@ result.result.tokens.sort((a, b) => a.id.localeCompare(b.id, 'en-us', { numeric: true })); // sort alphabetically | ||
const matches = []; | ||
if (!input.includes('{')) | ||
if (!input.includes('{')) { | ||
return matches; | ||
} | ||
let lastI = -1; | ||
@@ -352,4 +366,5 @@ for (let n = 0; n < input.length; n++) { | ||
// if '\{' or '\}' encountered, skip | ||
if (input[n + 1] == '{' || input[n + 1] == '}') | ||
if (input[n + 1] == '{' || input[n + 1] == '}') { | ||
n += 1; | ||
} | ||
break; | ||
@@ -362,4 +377,5 @@ } | ||
case '}': { | ||
if (lastI === -1) | ||
continue; // ignore '}' if no '{' | ||
if (lastI === -1) { | ||
continue; | ||
} // ignore '}' if no '{' | ||
matches.push(input.substring(lastI, n + 1)); | ||
@@ -378,6 +394,8 @@ lastI = -1; // reset last index | ||
array: (value) => value.some((part) => { | ||
if (typeof part === 'string') | ||
if (typeof part === 'string') { | ||
return isAlias(part); | ||
if (isObj(part)) | ||
} | ||
if (isObj(part)) { | ||
return unaliasedValues(part); | ||
} | ||
return false; | ||
@@ -384,0 +402,0 @@ }), |
@@ -141,6 +141,8 @@ /** | ||
let order = [values[0], values[1], values[0], values[1]]; // TL, BR | ||
if (values.length === 3) | ||
order = [values[0], values[1], values[2], values[1]]; // TL, TR/BL, BR | ||
else if (values.length === 4) | ||
order = [values[0], values[1], values[2], values[3]]; // TL, TR, BR, BL | ||
if (values.length === 3) { | ||
order = [values[0], values[1], values[2], values[1]]; | ||
} // TL, TR/BL, BR | ||
else if (values.length === 4) { | ||
order = [values[0], values[1], values[2], values[3]]; | ||
} // TL, TR, BR, BL | ||
addToken({ $type: 'dimension', $value: order[0], $description: v.description }, [...path, `${k}TopLeft`]); | ||
@@ -276,6 +278,8 @@ addToken({ $type: 'dimension', $value: order[1], $description: v.description }, [...path, `${k}TopRight`]); | ||
let order = [values[0], values[1], values[0], values[1]]; // TB, RL | ||
if (values.length === 3) | ||
order = [values[0], values[1], values[2], values[1]]; // T, RL, B | ||
else if (values.length === 4) | ||
order = [values[0], values[1], values[2], values[3]]; // T, R, B, L | ||
if (values.length === 3) { | ||
order = [values[0], values[1], values[2], values[1]]; | ||
} // T, RL, B | ||
else if (values.length === 4) { | ||
order = [values[0], values[1], values[2], values[3]]; | ||
} // T, R, B, L | ||
addToken({ $type: 'dimension', $value: order[0], $description: v.description }, [...path, `${k}Top`]); | ||
@@ -374,3 +378,8 @@ addToken({ $type: 'dimension', $value: order[1], $description: v.description }, [...path, `${k}Right`]); | ||
export function isTokensStudioFormat(rawTokens) { | ||
return !!rawTokens && typeof rawTokens === 'object' && '$themes' in rawTokens && Array.isArray(rawTokens.$themes) && '$metadata' in rawTokens && typeof rawTokens.$metadata === 'object'; | ||
return (!!rawTokens && | ||
typeof rawTokens === 'object' && | ||
'$themes' in rawTokens && | ||
Array.isArray(rawTokens.$themes) && | ||
'$metadata' in rawTokens && | ||
typeof rawTokens.$metadata === 'object'); | ||
} | ||
@@ -377,0 +386,0 @@ function get(obj, path) { |
import type { ParsedBorderToken } from '../../token.js'; | ||
import { ParseColorOptions } from './color.js'; | ||
import type { ParseColorOptions } from './color.js'; | ||
export interface ParseBorderOptions { | ||
@@ -4,0 +4,0 @@ color: ParseColorOptions; |
@@ -18,11 +18,15 @@ import { isObj } from '../../util.js'; | ||
export function normalizeBorderValue(value, options) { | ||
if (!isObj(value)) | ||
if (!isObj(value)) { | ||
throw new Error(`Expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
} | ||
const tokenValue = value; | ||
if (!('color' in tokenValue)) | ||
if (!('color' in tokenValue)) { | ||
throw new Error(`Token missing required "color" property`); | ||
if (!('width' in tokenValue)) | ||
} | ||
if (!('width' in tokenValue)) { | ||
throw new Error(`Token missing required "width" property`); | ||
if (!('style' in tokenValue)) | ||
} | ||
if (!('style' in tokenValue)) { | ||
throw new Error(`Token missing required "style" property`); | ||
} | ||
return { | ||
@@ -29,0 +33,0 @@ color: normalizeColorValue(tokenValue.color, options.color), |
@@ -12,9 +12,11 @@ import { formatHex, formatHex8, parse } from 'culori'; | ||
export function normalizeColorValue(value, options) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value === 'string') { | ||
if (options.convertToHex === true) { | ||
const parsed = parse(value); | ||
if (!parsed) | ||
if (!parsed) { | ||
throw new Error(`invalid color "${value}"`); | ||
} | ||
return typeof parsed.alpha === 'number' && parsed.alpha < 1 ? formatHex8(parsed) : formatHex(parsed); | ||
@@ -21,0 +23,0 @@ } |
@@ -11,6 +11,8 @@ /** | ||
export function normalizeCubicBezierValue(value) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
if (!Array.isArray(value) || value.length !== 4 || value.some((v) => typeof v !== 'number')) | ||
} | ||
if (!Array.isArray(value) || value.length !== 4 || value.some((v) => typeof v !== 'number')) { | ||
throw new Error(`expected [𝑥1, 𝑦1, 𝑥2, 𝑦2], received ${JSON.stringify(value)}`); | ||
} | ||
return [ | ||
@@ -17,0 +19,0 @@ Math.max(0, Math.min(1, value[0])), // x must be between 0–1 |
@@ -15,9 +15,11 @@ /** | ||
if (typeof value === 'number') { | ||
if (value === 0) | ||
if (value === 0) { | ||
return '0'; | ||
} | ||
throw new Error('missing units'); | ||
} | ||
if (typeof value === 'string') { | ||
if (parseFloat(value) === 0) | ||
if (parseFloat(value) === 0) { | ||
return '0'; | ||
} | ||
return value; | ||
@@ -24,0 +26,0 @@ } |
@@ -19,4 +19,5 @@ const DURATION_RE = /^\d+(\.\d+)?(ms|s)$/; | ||
if (typeof value === 'string') { | ||
if (parseFloat(value) === 0) | ||
return '0ms'; // allow '0', but throw on everything else | ||
if (parseFloat(value) === 0) { | ||
return '0ms'; | ||
} // allow '0', but throw on everything else | ||
if (DURATION_RE.test(value)) { | ||
@@ -23,0 +24,0 @@ return value; |
@@ -17,6 +17,8 @@ /** | ||
export function normalizeFontFamilyValue(value) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
if (typeof value === 'string') | ||
} | ||
if (typeof value === 'string') { | ||
return [value]; | ||
} | ||
if (Array.isArray(value)) { | ||
@@ -23,0 +25,0 @@ if (value.every((v) => !!v && typeof v === 'string')) { |
@@ -37,6 +37,8 @@ const fontWeightAliases = { | ||
export function normalizeFontWeightValue(value) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
if (typeof value === 'number') | ||
} | ||
if (typeof value === 'number') { | ||
return value; | ||
} | ||
if (typeof value === 'string' && value in fontWeightAliases) { | ||
@@ -43,0 +45,0 @@ return fontWeightAliases[value]; |
import type { ParsedGradientToken } from '../../token.js'; | ||
import { ParseColorOptions } from './color.js'; | ||
import type { ParseColorOptions } from './color.js'; | ||
export interface ParseGradientOptions { | ||
@@ -4,0 +4,0 @@ color: ParseColorOptions; |
@@ -14,8 +14,11 @@ import { normalizeColorValue } from './color.js'; | ||
export function normalizeGradientValue(value, options) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
if (!Array.isArray(value)) | ||
} | ||
if (!Array.isArray(value)) { | ||
throw new Error(`expected array, received ${typeof value}`); | ||
if (value.some((v) => !v || !v.color)) | ||
} | ||
if (value.some((v) => !v || !v.color)) { | ||
throw new Error('all gradient stops must have color'); | ||
} | ||
return value.map((v) => ({ | ||
@@ -22,0 +25,0 @@ color: normalizeColorValue(v.color, options.color), |
@@ -12,4 +12,5 @@ /** | ||
export function normalizeLinkValue(value) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value === 'string') { | ||
@@ -16,0 +17,0 @@ return value; |
@@ -19,8 +19,10 @@ /** | ||
export function normalizeNumberValue(value) { | ||
if (value === null || value === undefined) | ||
if (value === null || value === undefined) { | ||
throw new Error('missing value'); | ||
if (typeof value === 'number') | ||
} | ||
if (typeof value === 'number') { | ||
return value; | ||
} | ||
throw new Error(`expected number, received ${typeof value}`); | ||
} | ||
//# sourceMappingURL=number.js.map |
import type { ParsedShadowToken } from '../../token.js'; | ||
import { ParseColorOptions } from './color.js'; | ||
import type { ParseColorOptions } from './color.js'; | ||
export interface ParseShadowOptions { | ||
@@ -4,0 +4,0 @@ color: ParseColorOptions; |
@@ -19,6 +19,8 @@ import { normalizeColorValue } from './color.js'; | ||
export function normalizeShadowValue(value, options) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
if (typeof value !== 'object' && !Array.isArray(value)) | ||
} | ||
if (typeof value !== 'object' && !Array.isArray(value)) { | ||
throw new Error(`expected object or array of objects, got ${typeof value}`); | ||
} | ||
const v = Array.isArray(value) ? value : [value]; | ||
@@ -25,0 +27,0 @@ return v.map((shadow, i) => { |
@@ -18,11 +18,15 @@ import { normalizeDurationValue } from './duration.js'; | ||
export function normalizeTransitionValue(value) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
if (typeof value !== 'object' || Array.isArray(value)) | ||
} | ||
if (typeof value !== 'object' || Array.isArray(value)) { | ||
throw new Error(`expected object, got ${typeof value}`); | ||
if (!('duration' in value)) | ||
} | ||
if (!('duration' in value)) { | ||
throw new Error('missing duration'); | ||
} | ||
// currently delay is optional; is that right? | ||
if (!('timingFunction' in value)) | ||
if (!('timingFunction' in value)) { | ||
throw new Error('missing timingFunction'); | ||
} | ||
const v = value; | ||
@@ -29,0 +33,0 @@ return { |
@@ -20,8 +20,11 @@ import { camelize } from '@cobalt-ui/utils'; | ||
export function normalizeTypographyValue(value) { | ||
if (!value) | ||
if (!value) { | ||
throw new Error('missing value'); | ||
if (typeof value !== 'object' || Array.isArray(value)) | ||
} | ||
if (typeof value !== 'object' || Array.isArray(value)) { | ||
throw new Error(`expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
if (!Object.keys(value).length) | ||
} | ||
if (!Object.keys(value).length) { | ||
throw new Error('must specify at least 1 font property'); | ||
} | ||
const normalized = {}; | ||
@@ -28,0 +31,0 @@ for (const [k, v] of Object.entries(value)) { |
@@ -6,10 +6,14 @@ export function isObj(value) { | ||
export function isEmpty(value) { | ||
if (value === undefined || value === null) | ||
if (value === undefined || value === null) { | ||
return true; | ||
if (typeof value === 'string') | ||
} | ||
if (typeof value === 'string') { | ||
return value.length === 0; | ||
if (Array.isArray(value)) | ||
} | ||
if (Array.isArray(value)) { | ||
return value.length === 0; | ||
if (isObj(value)) | ||
} | ||
if (isObj(value)) { | ||
return Object.keys(value).length === 0; | ||
} | ||
return false; | ||
@@ -16,0 +20,0 @@ } |
{ | ||
"name": "@cobalt-ui/core", | ||
"description": "Parser/validator for the Design Tokens Community Group (DTCG) standard.", | ||
"version": "1.7.3", | ||
"version": "1.8.0", | ||
"author": { | ||
@@ -33,10 +33,10 @@ "name": "Drew Powers", | ||
"dependencies": { | ||
"@cobalt-ui/utils": "^1.2.3", | ||
"@types/culori": "^2.0.4", | ||
"@cobalt-ui/utils": "^1.2.4", | ||
"@types/culori": "^2.1.0", | ||
"culori": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.11.16", | ||
"@types/node": "^20.11.27", | ||
"esbuild": "^0.19.12", | ||
"vitest": "^1.2.2" | ||
"vitest": "^1.3.1" | ||
}, | ||
@@ -43,0 +43,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
import type {Group, ParsedToken} from './token.js'; | ||
import type { Group, ParsedToken } from './token.js'; | ||
export type { | ||
@@ -44,5 +44,7 @@ BorderToken, | ||
import {ParseOptions, parse} from './parse/index.js'; | ||
export {parse, ParseOptions, ParseResult} from './parse/index.js'; | ||
import type { LintRule, LintRuleSeverity, ParseOptions } from './parse/index.js'; | ||
import { parse } from './parse/index.js'; | ||
export { parse, type LintRule, type ParseOptions, type ParseResult } from './parse/index.js'; | ||
export interface BuildResult { | ||
@@ -55,8 +57,36 @@ /** File to output inside config.outDir (ex: ./tokens.sass) */ | ||
export interface ResolvedConfig extends ParseOptions { | ||
export interface ResolvedConfig extends Omit<ParseOptions, 'lint'> { | ||
tokens: URL[]; | ||
outDir: URL; | ||
plugins: Plugin[]; | ||
lint: { | ||
rules: Record<string, LintRule>; | ||
}; | ||
} | ||
export interface BuildStageOptions { | ||
/** Parsed, normalized, resolved tokens schema */ | ||
tokens: ParsedToken[]; | ||
metadata: Record<string, unknown>; | ||
/** The user’s original schema, as-authored */ | ||
rawSchema: Group; | ||
} | ||
export interface LintStageOptions { | ||
/** Parsed, normalized, resolved tokens schema */ | ||
tokens: ParsedToken[]; | ||
/** IDs of enabled rules to report on (warning: may be empty!) */ | ||
rules: LintRule[]; | ||
/** The user’s original schema, as-authored */ | ||
rawSchema: Group; | ||
} | ||
export interface LintNotice { | ||
/** Must match a registered rule */ | ||
id: string; | ||
// node?: SchemaNode // "node" will be added in 2.0; | ||
/** Lint message shown to the user */ | ||
message: string; | ||
} | ||
export interface Plugin { | ||
@@ -66,7 +96,14 @@ name: string; | ||
config?(config: ResolvedConfig): void | ResolvedConfig | undefined; | ||
/** (optional) register lint rule IDs */ | ||
registerRules?(): Omit<LintRule, 'options'>[]; | ||
/** (optional) throw lint errors/warnings */ | ||
lint?(options: LintStageOptions): Promise<LintNotice[] | undefined>; | ||
/** main build fn */ | ||
build(options: {tokens: ParsedToken[]; metadata: Record<string, unknown>; rawSchema: Group}): Promise<BuildResult[]>; | ||
build?(options: BuildStageOptions): Promise<BuildResult[]>; | ||
} | ||
export interface Config extends Partial<ParseOptions> { | ||
type LintRuleShorthand = LintRuleSeverity | 0 | 1 | 2; | ||
type LintRuleLonghand = [LintRuleSeverity | 0 | 1 | 2, any]; | ||
export interface Config extends Partial<Omit<ParseOptions, 'lint'>> { | ||
/** path to tokens.json (default: "./tokens.json") */ | ||
@@ -78,2 +115,6 @@ tokens?: string | string[]; | ||
plugins: Plugin[]; | ||
/** specify lint rules */ | ||
lint?: { | ||
rules?: Record<string, LintRuleShorthand | LintRuleLonghand>; | ||
}; | ||
} | ||
@@ -80,0 +121,0 @@ |
@@ -1,4 +0,4 @@ | ||
import {formatHex, formatHex8, oklch} from 'culori'; | ||
import type {Group, Token, TokenType} from '../token.js'; | ||
import {invalidTokenIDError, isTokenMatch} from '@cobalt-ui/utils'; | ||
import { formatHex, formatHex8, oklch } from 'culori'; | ||
import type { Group, Token, TokenType } from '../token.js'; | ||
import { invalidTokenIDError, isTokenMatch } from '@cobalt-ui/utils'; | ||
@@ -15,3 +15,3 @@ export interface FigmaParseOptions { | ||
/** Convert value (e.g. from px to rem) */ | ||
transform?: (options: {variable: Variable; collection: VariableCollection; mode: VariableMode}) => Token['$value'] | undefined | null; | ||
transform?: (options: { variable: Variable; collection: VariableCollection; mode: VariableMode }) => Token['$value'] | undefined | null; | ||
} | ||
@@ -78,3 +78,3 @@ | ||
/** The values for each mode of this variable. */ | ||
valuesByMode: {[modeId: string]: boolean | VariableAlias}; | ||
valuesByMode: { [modeId: string]: boolean | VariableAlias }; | ||
} | ||
@@ -86,3 +86,3 @@ | ||
/** The values for each mode of this variable. */ | ||
valuesByMode: {[modeId: string]: number | VariableAlias}; | ||
valuesByMode: { [modeId: string]: number | VariableAlias }; | ||
} | ||
@@ -94,3 +94,3 @@ | ||
/** The values for each mode of this variable. */ | ||
valuesByMode: {[modeId: string]: string | VariableAlias}; | ||
valuesByMode: { [modeId: string]: string | VariableAlias }; | ||
} | ||
@@ -102,3 +102,3 @@ | ||
/** The values for each mode of this variable. */ | ||
valuesByMode: {[modeId: string]: FigmaColor | VariableAlias}; | ||
valuesByMode: { [modeId: string]: FigmaColor | VariableAlias }; | ||
} | ||
@@ -128,3 +128,3 @@ | ||
export function figmaColorToHex(color: FigmaColor): string { | ||
const c = oklch({mode: 'rgb', r: color.r, g: color.g, b: color.b, alpha: color.a}); | ||
const c = oklch({ mode: 'rgb', r: color.r, g: color.g, b: color.b, alpha: color.a }); | ||
if (!c.h) { | ||
@@ -177,3 +177,3 @@ c.h = 0; | ||
const transformResults = transformToken({variable, collection, override}); | ||
const transformResults = transformToken({ variable, collection, override }); | ||
warnings.push(...(transformResults.warnings ?? [])); | ||
@@ -236,3 +236,7 @@ errors.push(...(transformResults.errors ?? [])); | ||
export function transformToken({variable, collection, override}: {variable: Variable; collection: VariableCollection; override?: FigmaOverride}): {warnings?: string[]; errors?: string[]; result: Token | undefined} { | ||
export function transformToken({ variable, collection, override }: { variable: Variable; collection: VariableCollection; override?: FigmaOverride }): { | ||
warnings?: string[]; | ||
errors?: string[]; | ||
result: Token | undefined; | ||
} { | ||
const token = {} as Token; | ||
@@ -257,3 +261,3 @@ const errors: string[] = []; | ||
if (isMultiModal && !token.$extensions) { | ||
token.$extensions = {mode: {}}; | ||
token.$extensions = { mode: {} }; | ||
} | ||
@@ -280,3 +284,3 @@ | ||
try { | ||
let transformedValue = override?.transform?.({variable, collection, mode: collectionMode}); | ||
let transformedValue = override?.transform?.({ variable, collection, mode: collectionMode }); | ||
if (transformedValue === undefined || transformedValue == null) { | ||
@@ -324,3 +328,10 @@ switch ($type) { | ||
export function isFigmaVariablesFormat(manifest: unknown): boolean { | ||
return !!manifest && typeof manifest === 'object' && 'variables' in manifest && typeof manifest.variables === 'object' && 'variableCollections' in manifest && typeof manifest.variableCollections === 'object'; | ||
return ( | ||
!!manifest && | ||
typeof manifest === 'object' && | ||
'variables' in manifest && | ||
typeof manifest.variables === 'object' && | ||
'variableCollections' in manifest && | ||
typeof manifest.variableCollections === 'object' | ||
); | ||
} |
@@ -1,20 +0,22 @@ | ||
import {cloneDeep, FG_YELLOW, getAliasID, invalidTokenIDError, isAlias, RESET} from '@cobalt-ui/utils'; | ||
import type {Group, ParsedToken, TokenType, TokenOrGroup} from '../token.js'; | ||
import {isEmpty, isObj, splitType} from '../util.js'; | ||
import {normalizeColorValue, ParseColorOptions} from './tokens/color.js'; | ||
import {normalizeFontFamilyValue} from './tokens/fontFamily.js'; | ||
import {normalizeDurationValue} from './tokens/duration.js'; | ||
import {normalizeDimensionValue} from './tokens/dimension.js'; | ||
import {normalizeCubicBezierValue} from './tokens/cubic-bezier.js'; | ||
import {normalizeLinkValue} from './tokens/link.js'; | ||
import {normalizeStrokeStyleValue} from './tokens/stroke-style.js'; | ||
import {normalizeBorderValue} from './tokens/border.js'; | ||
import {normalizeTransitionValue} from './tokens/transition.js'; | ||
import {normalizeShadowValue} from './tokens/shadow.js'; | ||
import {normalizeGradientValue} from './tokens/gradient.js'; | ||
import {normalizeTypographyValue} from './tokens/typography.js'; | ||
import {normalizeFontWeightValue} from './tokens/fontWeight.js'; | ||
import {normalizeNumberValue} from './tokens/number.js'; | ||
import {convertTokensStudioFormat, isTokensStudioFormat} from './tokens-studio.js'; | ||
import {convertFigmaVariablesFormat, isFigmaVariablesFormat, type FigmaParseOptions, FigmaVariableManifest} from './figma.js'; | ||
import { cloneDeep, FG_YELLOW, getAliasID, invalidTokenIDError, isAlias, RESET } from '@cobalt-ui/utils'; | ||
import type { Group, ParsedToken, TokenType, TokenOrGroup } from '../token.js'; | ||
import { isEmpty, isObj, splitType } from '../util.js'; | ||
import type { ParseColorOptions } from './tokens/color.js'; | ||
import { normalizeColorValue } from './tokens/color.js'; | ||
import { normalizeFontFamilyValue } from './tokens/fontFamily.js'; | ||
import { normalizeDurationValue } from './tokens/duration.js'; | ||
import { normalizeDimensionValue } from './tokens/dimension.js'; | ||
import { normalizeCubicBezierValue } from './tokens/cubic-bezier.js'; | ||
import { normalizeLinkValue } from './tokens/link.js'; | ||
import { normalizeStrokeStyleValue } from './tokens/stroke-style.js'; | ||
import { normalizeBorderValue } from './tokens/border.js'; | ||
import { normalizeTransitionValue } from './tokens/transition.js'; | ||
import { normalizeShadowValue } from './tokens/shadow.js'; | ||
import { normalizeGradientValue } from './tokens/gradient.js'; | ||
import { normalizeTypographyValue } from './tokens/typography.js'; | ||
import { normalizeFontWeightValue } from './tokens/fontWeight.js'; | ||
import { normalizeNumberValue } from './tokens/number.js'; | ||
import { convertTokensStudioFormat, isTokensStudioFormat } from './tokens-studio.js'; | ||
import type { FigmaVariableManifest } from './figma.js'; | ||
import { convertFigmaVariablesFormat, isFigmaVariablesFormat, type FigmaParseOptions } from './figma.js'; | ||
@@ -30,2 +32,10 @@ export interface ParseResult { | ||
export interface LintRule { | ||
id: string; | ||
severity: LintRuleSeverity; | ||
options?: unknown; | ||
} | ||
export type LintRuleSeverity = 'error' | 'warn' | 'off' | number; | ||
export interface ParseOptions { | ||
@@ -35,2 +45,6 @@ /** Configure transformations for color tokens */ | ||
figma?: FigmaParseOptions; | ||
/** Configure plugin lint rules (if any) */ | ||
lint: { | ||
rules: Record<string, LintRule>; | ||
}; | ||
} | ||
@@ -50,3 +64,3 @@ | ||
const warnings: string[] = []; | ||
const result: ParseResult = {result: {metadata: {}, tokens: []}}; | ||
const result: ParseResult = { result: { metadata: {}, tokens: [] } }; | ||
if (!rawTokens || typeof rawTokens !== 'object' || Array.isArray(rawTokens)) { | ||
@@ -78,4 +92,6 @@ errors.push(`Invalid schema type. Expected object, received "${Array.isArray(rawTokens) ? 'Array' : typeof rawTokens}"`); | ||
const tokens: Record<string, ParsedToken> = {}; | ||
function walk(node: TokenOrGroup, chain: string[] = [], group: InheritedGroup = {$extensions: {requiredModes: []}}): void { | ||
if (!node || !isObj(node)) return; | ||
function walk(node: TokenOrGroup, chain: string[] = [], group: InheritedGroup = { $extensions: { requiredModes: [] } }): void { | ||
if (!node || !isObj(node)) { | ||
return; | ||
} | ||
for (const [k, v] of Object.entries(node)) { | ||
@@ -125,3 +141,5 @@ if (!v || !isObj(v)) { | ||
for (const modeID of group.$extensions.requiredModes) { | ||
if (!token.$extensions || !token.$extensions.mode || !token.$extensions.mode[modeID]) errors.push(`${token.id}: missing mode "${modeID}" required from parent group`); | ||
if (!token.$extensions || !token.$extensions.mode || !token.$extensions.mode[modeID]) { | ||
errors.push(`${token.id}: missing mode "${modeID}" required from parent group`); | ||
} | ||
} | ||
@@ -133,3 +151,3 @@ } | ||
else { | ||
const nextGroup = {...group}; | ||
const nextGroup = { ...group }; | ||
@@ -141,6 +159,11 @@ const groupTokens: Record<string, TokenOrGroup> = {}; | ||
// merge $extensions; don’t overwrite them | ||
if (propertyKey === '$extensions') nextGroup.$extensions = {...nextGroup.$extensions, ...v.$extensions}; | ||
else (nextGroup as any)[propertyKey] = v[propertyKey]; | ||
if (propertyKey === '$extensions') { | ||
nextGroup.$extensions = { ...nextGroup.$extensions, ...v.$extensions }; | ||
} else { | ||
(nextGroup as any)[propertyKey] = v[propertyKey]; | ||
} | ||
if (!RESERVED_KEYS.has(propertyKey)) { | ||
if (!result.warnings) result.warnings = []; | ||
if (!result.warnings) { | ||
result.warnings = []; | ||
} | ||
result.warnings.push(`Unknown property "${propertyKey}"`); | ||
@@ -167,10 +190,15 @@ } | ||
const group: InheritedGroup = {$extensions: {requiredModes: []}}; | ||
const group: InheritedGroup = { $extensions: { requiredModes: [] } }; | ||
const topNodes: Record<string, TokenOrGroup> = {}; | ||
for (const k of Object.keys(schema)) { | ||
if (k.startsWith('$')) { | ||
if (k === '$extensions') group.$extensions = {...schema.$extensions, ...group.$extensions}; | ||
else (group as any)[k] = schema[k]; | ||
if (k === '$extensions') { | ||
group.$extensions = { ...schema.$extensions, ...group.$extensions }; | ||
} else { | ||
(group as any)[k] = schema[k]; | ||
} | ||
if (!RESERVED_KEYS.has(k)) { | ||
if (!result.warnings) result.warnings = []; | ||
if (!result.warnings) { | ||
result.warnings = []; | ||
} | ||
result.warnings.push(`Unknown property "${k}"`); | ||
@@ -209,3 +237,5 @@ } | ||
string(strVal) { | ||
if (!isAlias(strVal)) return strVal; | ||
if (!isAlias(strVal)) { | ||
return strVal; | ||
} | ||
const nextID = getAliasID(strVal); | ||
@@ -253,3 +283,5 @@ if (!(nextID in values)) { | ||
const token = tokens[id]!; | ||
if (!token.$extensions || !token.$extensions.mode) return; | ||
if (!token.$extensions || !token.$extensions.mode) { | ||
return; | ||
} | ||
for (const k of Object.keys(token.$extensions.mode || {})) { | ||
@@ -278,3 +310,5 @@ (tokens[id] as any).$extensions.mode[k] = validate(values[`${id}#${k}`]); | ||
case 'fontFamily': { | ||
if ((token.$type as any) === 'font') console.warn(`${FG_YELLOW}@cobalt-ui/core${RESET} $type: "font" is deprecated. Please use "fontFamily" instead.`); // eslint-disable-line no-console | ||
if ((token.$type as any) === 'font') { | ||
warnings.push(`${FG_YELLOW}@cobalt-ui/core${RESET} $type: "font" is deprecated. Please use "fontFamily" instead.`); | ||
} | ||
tokens[id]!.$value = normalizeFontFamilyValue(values[id]); | ||
@@ -322,4 +356,4 @@ normalizeModes(id, (v) => normalizeFontFamilyValue(v)); | ||
case 'border': { | ||
tokens[id]!.$value = normalizeBorderValue(values[id], {color: options.color}); | ||
normalizeModes(id, (v) => normalizeBorderValue(v, {color: options.color})); | ||
tokens[id]!.$value = normalizeBorderValue(values[id], { color: options.color }); | ||
normalizeModes(id, (v) => normalizeBorderValue(v, { color: options.color })); | ||
break; | ||
@@ -335,4 +369,4 @@ } | ||
case 'shadow': { | ||
tokens[id]!.$value = normalizeShadowValue(values[id], {color: options.color}); | ||
normalizeModes(id, (v) => normalizeShadowValue(v, {color: options.color})); | ||
tokens[id]!.$value = normalizeShadowValue(values[id], { color: options.color }); | ||
normalizeModes(id, (v) => normalizeShadowValue(v, { color: options.color })); | ||
break; | ||
@@ -342,4 +376,4 @@ } | ||
case 'gradient': { | ||
tokens[id]!.$value = normalizeGradientValue(values[id], {color: options.color}); | ||
normalizeModes(id, (v) => normalizeGradientValue(v, {color: options.color})); | ||
tokens[id]!.$value = normalizeGradientValue(values[id], { color: options.color }); | ||
normalizeModes(id, (v) => normalizeGradientValue(v, { color: options.color })); | ||
break; | ||
@@ -366,6 +400,10 @@ } | ||
// 4. finish | ||
if (errors.length) result.errors = errors; | ||
if (warnings.length) result.warnings = warnings; | ||
if (errors.length) { | ||
result.errors = errors; | ||
} | ||
if (warnings.length) { | ||
result.warnings = warnings; | ||
} | ||
result.result.tokens = Object.values(tokens); | ||
result.result.tokens.sort((a, b) => a.id.localeCompare(b.id, 'en-us', {numeric: true})); // sort alphabetically | ||
result.result.tokens.sort((a, b) => a.id.localeCompare(b.id, 'en-us', { numeric: true })); // sort alphabetically | ||
return result; | ||
@@ -377,3 +415,5 @@ } | ||
const matches: string[] = []; | ||
if (!input.includes('{')) return matches; | ||
if (!input.includes('{')) { | ||
return matches; | ||
} | ||
let lastI = -1; | ||
@@ -384,3 +424,5 @@ for (let n = 0; n < input.length; n++) { | ||
// if '\{' or '\}' encountered, skip | ||
if (input[n + 1] == '{' || input[n + 1] == '}') n += 1; | ||
if (input[n + 1] == '{' || input[n + 1] == '}') { | ||
n += 1; | ||
} | ||
break; | ||
@@ -393,3 +435,5 @@ } | ||
case '}': { | ||
if (lastI === -1) continue; // ignore '}' if no '{' | ||
if (lastI === -1) { | ||
continue; | ||
} // ignore '}' if no '{' | ||
matches.push(input.substring(lastI, n + 1)); | ||
@@ -411,4 +455,8 @@ lastI = -1; // reset last index | ||
value.some((part) => { | ||
if (typeof part === 'string') return isAlias(part); | ||
if (isObj(part)) return unaliasedValues(part as Record<string, unknown>); | ||
if (typeof part === 'string') { | ||
return isAlias(part); | ||
} | ||
if (isObj(part)) { | ||
return unaliasedValues(part as Record<string, unknown>); | ||
} | ||
return false; | ||
@@ -415,0 +463,0 @@ }), |
@@ -6,4 +6,4 @@ /** | ||
*/ | ||
import {parseAlias} from '@cobalt-ui/utils'; | ||
import type {GradientStop, Group, Token} from '../token.js'; | ||
import { parseAlias } from '@cobalt-ui/utils'; | ||
import type { GradientStop, Group, Token } from '../token.js'; | ||
@@ -172,3 +172,3 @@ // I’m not sure this is comprehensive at all but better than nothing | ||
export function convertTokensStudioFormat(rawTokens: Record<string, unknown>): {errors?: string[]; warnings?: string[]; result: Group} { | ||
export function convertTokensStudioFormat(rawTokens: Record<string, unknown>): { errors?: string[]; warnings?: string[]; result: Group } { | ||
const errors: string[] = []; | ||
@@ -206,3 +206,3 @@ const warnings: string[] = []; | ||
matchLoop: for (const match of matches) { | ||
const {id} = parseAlias(match); | ||
const { id } = parseAlias(match); | ||
const tokenAliasPath = id.split('.'); | ||
@@ -283,14 +283,16 @@ | ||
if (values.length === 1) { | ||
addToken({$type: 'dimension', $value: v.value.trim(), $description: v.description}, tokenPath); | ||
addToken({ $type: 'dimension', $value: v.value.trim(), $description: v.description }, tokenPath); | ||
} else if (values.length === 2 || values.length === 3 || values.length === 4) { | ||
// Tokens Studio doesn’t support the "/" character … right? | ||
warnings.push(`Token "${tokenID}" is a multi value borderRadius token. Expanding into ${tokenID}TopLeft, ${tokenID}TopRight, ${tokenID}BottomRight, and ${tokenID}BottomLeft.`); | ||
warnings.push( | ||
`Token "${tokenID}" is a multi value borderRadius token. Expanding into ${tokenID}TopLeft, ${tokenID}TopRight, ${tokenID}BottomRight, and ${tokenID}BottomLeft.`, | ||
); | ||
let order = [values[0], values[1], values[0], values[1]] as [string, string, string, string]; // TL, BR | ||
if (values.length === 3) | ||
order = [values[0], values[1], values[2], values[1]] as [string, string, string, string]; // TL, TR/BL, BR | ||
else if (values.length === 4) order = [values[0], values[1], values[2], values[3]] as [string, string, string, string]; // TL, TR, BR, BL | ||
addToken({$type: 'dimension', $value: order[0], $description: v.description}, [...path, `${k}TopLeft`]); | ||
addToken({$type: 'dimension', $value: order[1], $description: v.description}, [...path, `${k}TopRight`]); | ||
addToken({$type: 'dimension', $value: order[2], $description: v.description}, [...path, `${k}BottomRight`]); | ||
addToken({$type: 'dimension', $value: order[3], $description: v.description}, [...path, `${k}BottomLeft`]); | ||
{order = [values[0], values[1], values[2], values[1]] as [string, string, string, string];} // TL, TR/BL, BR | ||
else if (values.length === 4) {order = [values[0], values[1], values[2], values[3]] as [string, string, string, string];} // TL, TR, BR, BL | ||
addToken({ $type: 'dimension', $value: order[0], $description: v.description }, [...path, `${k}TopLeft`]); | ||
addToken({ $type: 'dimension', $value: order[1], $description: v.description }, [...path, `${k}TopRight`]); | ||
addToken({ $type: 'dimension', $value: order[2], $description: v.description }, [...path, `${k}BottomRight`]); | ||
addToken({ $type: 'dimension', $value: order[3], $description: v.description }, [...path, `${k}BottomLeft`]); | ||
} else { | ||
@@ -359,3 +361,3 @@ addToken( | ||
position = resolveAlias(position, path) || position; | ||
stops.push({color, position: position as number}); | ||
stops.push({ color, position: position as number }); | ||
} | ||
@@ -443,3 +445,3 @@ addToken( | ||
if (values.length === 1) { | ||
addToken({$type: 'dimension', $value: v.value, $description: v.description}, tokenPath); | ||
addToken({ $type: 'dimension', $value: v.value, $description: v.description }, tokenPath); | ||
} else if (values.length === 2 || values.length === 3 || values.length === 4) { | ||
@@ -449,8 +451,8 @@ warnings.push(`Token "${tokenID}" is a multi value spacing token. Expanding into ${tokenID}Top, ${tokenID}Right, ${tokenID}Bottom, and ${tokenID}Left.`); | ||
if (values.length === 3) | ||
order = [values[0], values[1], values[2], values[1]] as [string, string, string, string]; // T, RL, B | ||
else if (values.length === 4) order = [values[0], values[1], values[2], values[3]] as [string, string, string, string]; // T, R, B, L | ||
addToken({$type: 'dimension', $value: order[0], $description: v.description}, [...path, `${k}Top`]); | ||
addToken({$type: 'dimension', $value: order[1], $description: v.description}, [...path, `${k}Right`]); | ||
addToken({$type: 'dimension', $value: order[2], $description: v.description}, [...path, `${k}Bottom`]); | ||
addToken({$type: 'dimension', $value: order[3], $description: v.description}, [...path, `${k}Left`]); | ||
{order = [values[0], values[1], values[2], values[1]] as [string, string, string, string];} // T, RL, B | ||
else if (values.length === 4) {order = [values[0], values[1], values[2], values[3]] as [string, string, string, string];} // T, R, B, L | ||
addToken({ $type: 'dimension', $value: order[0], $description: v.description }, [...path, `${k}Top`]); | ||
addToken({ $type: 'dimension', $value: order[1], $description: v.description }, [...path, `${k}Right`]); | ||
addToken({ $type: 'dimension', $value: order[2], $description: v.description }, [...path, `${k}Bottom`]); | ||
addToken({ $type: 'dimension', $value: order[3], $description: v.description }, [...path, `${k}Left`]); | ||
} else { | ||
@@ -550,3 +552,10 @@ addToken( | ||
export function isTokensStudioFormat(rawTokens: unknown): boolean { | ||
return !!rawTokens && typeof rawTokens === 'object' && '$themes' in rawTokens && Array.isArray(rawTokens.$themes) && '$metadata' in rawTokens && typeof rawTokens.$metadata === 'object'; | ||
return ( | ||
!!rawTokens && | ||
typeof rawTokens === 'object' && | ||
'$themes' in rawTokens && | ||
Array.isArray(rawTokens.$themes) && | ||
'$metadata' in rawTokens && | ||
typeof rawTokens.$metadata === 'object' | ||
); | ||
} | ||
@@ -553,0 +562,0 @@ |
@@ -1,6 +0,7 @@ | ||
import type {BorderToken, ParsedBorderToken} from '../../token.js'; | ||
import {isObj} from '../../util.js'; | ||
import {ParseColorOptions, normalizeColorValue} from './color.js'; | ||
import {normalizeDimensionValue} from './dimension.js'; | ||
import {normalizeStrokeStyleValue} from './stroke-style.js'; | ||
import type { BorderToken, ParsedBorderToken } from '../../token.js'; | ||
import { isObj } from '../../util.js'; | ||
import type { ParseColorOptions } from './color.js'; | ||
import { normalizeColorValue } from './color.js'; | ||
import { normalizeDimensionValue } from './dimension.js'; | ||
import { normalizeStrokeStyleValue } from './stroke-style.js'; | ||
@@ -25,7 +26,15 @@ export interface ParseBorderOptions { | ||
export function normalizeBorderValue(value: unknown, options: ParseBorderOptions): ParsedBorderToken['$value'] { | ||
if (!isObj(value)) throw new Error(`Expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
if (!isObj(value)) { | ||
throw new Error(`Expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
} | ||
const tokenValue = value as BorderToken['$value']; | ||
if (!('color' in tokenValue)) throw new Error(`Token missing required "color" property`); | ||
if (!('width' in tokenValue)) throw new Error(`Token missing required "width" property`); | ||
if (!('style' in tokenValue)) throw new Error(`Token missing required "style" property`); | ||
if (!('color' in tokenValue)) { | ||
throw new Error(`Token missing required "color" property`); | ||
} | ||
if (!('width' in tokenValue)) { | ||
throw new Error(`Token missing required "width" property`); | ||
} | ||
if (!('style' in tokenValue)) { | ||
throw new Error(`Token missing required "style" property`); | ||
} | ||
return { | ||
@@ -32,0 +41,0 @@ color: normalizeColorValue(tokenValue.color, options.color), |
@@ -1,3 +0,3 @@ | ||
import {formatHex, formatHex8, parse} from 'culori'; | ||
import type {ParsedColorToken} from '../../token.js'; | ||
import { formatHex, formatHex8, parse } from 'culori'; | ||
import type { ParsedColorToken } from '../../token.js'; | ||
@@ -19,7 +19,11 @@ export interface ParseColorOptions { | ||
export function normalizeColorValue(value: unknown, options: ParseColorOptions): ParsedColorToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value === 'string') { | ||
if (options.convertToHex === true) { | ||
const parsed = parse(value); | ||
if (!parsed) throw new Error(`invalid color "${value}"`); | ||
if (!parsed) { | ||
throw new Error(`invalid color "${value}"`); | ||
} | ||
return typeof parsed.alpha === 'number' && parsed.alpha < 1 ? formatHex8(parsed) : formatHex(parsed); | ||
@@ -26,0 +30,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type {ParsedCubicBezierToken} from '../../token.js'; | ||
import type { ParsedCubicBezierToken } from '../../token.js'; | ||
@@ -13,4 +13,8 @@ /** | ||
export function normalizeCubicBezierValue(value: unknown): ParsedCubicBezierToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (!Array.isArray(value) || value.length !== 4 || value.some((v) => typeof v !== 'number')) throw new Error(`expected [𝑥1, 𝑦1, 𝑥2, 𝑦2], received ${JSON.stringify(value)}`); | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (!Array.isArray(value) || value.length !== 4 || value.some((v) => typeof v !== 'number')) { | ||
throw new Error(`expected [𝑥1, 𝑦1, 𝑥2, 𝑦2], received ${JSON.stringify(value)}`); | ||
} | ||
return [ | ||
@@ -17,0 +21,0 @@ Math.max(0, Math.min(1, value[0])), // x must be between 0–1 |
@@ -1,2 +0,2 @@ | ||
import type {ParsedDimensionToken} from '../../token.js'; | ||
import type { ParsedDimensionToken } from '../../token.js'; | ||
@@ -17,7 +17,11 @@ /** | ||
if (typeof value === 'number') { | ||
if (value === 0) return '0'; | ||
if (value === 0) { | ||
return '0'; | ||
} | ||
throw new Error('missing units'); | ||
} | ||
if (typeof value === 'string') { | ||
if (parseFloat(value) === 0) return '0'; | ||
if (parseFloat(value) === 0) { | ||
return '0'; | ||
} | ||
return value; | ||
@@ -24,0 +28,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type {ParsedDurationToken} from '../../token.js'; | ||
import type { ParsedDurationToken } from '../../token.js'; | ||
@@ -22,3 +22,5 @@ const DURATION_RE = /^\d+(\.\d+)?(ms|s)$/; | ||
if (typeof value === 'string') { | ||
if (parseFloat(value) === 0) return '0ms'; // allow '0', but throw on everything else | ||
if (parseFloat(value) === 0) { | ||
return '0ms'; | ||
} // allow '0', but throw on everything else | ||
if (DURATION_RE.test(value)) { | ||
@@ -25,0 +27,0 @@ return value; |
@@ -1,2 +0,2 @@ | ||
import type {ParsedFontFamilyToken} from '../../token.js'; | ||
import type { ParsedFontFamilyToken } from '../../token.js'; | ||
@@ -19,4 +19,8 @@ /** | ||
export function normalizeFontFamilyValue(value: unknown): ParsedFontFamilyToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (typeof value === 'string') return [value]; | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value === 'string') { | ||
return [value]; | ||
} | ||
if (Array.isArray(value)) { | ||
@@ -23,0 +27,0 @@ if (value.every((v) => !!v && typeof v === 'string')) { |
@@ -1,2 +0,2 @@ | ||
import type {ParsedFontWeightToken} from '../../token.js'; | ||
import type { ParsedFontWeightToken } from '../../token.js'; | ||
@@ -60,4 +60,8 @@ export type FontWeightName = | ||
export function normalizeFontWeightValue(value: unknown): ParsedFontWeightToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (typeof value === 'number') return value; | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value === 'number') { | ||
return value; | ||
} | ||
if (typeof value === 'string' && value in fontWeightAliases) { | ||
@@ -64,0 +68,0 @@ return fontWeightAliases[value as FontWeightName]; |
@@ -1,3 +0,4 @@ | ||
import type {GradientStop, ParsedGradientToken} from '../../token.js'; | ||
import {ParseColorOptions, normalizeColorValue} from './color.js'; | ||
import type { GradientStop, ParsedGradientToken } from '../../token.js'; | ||
import type { ParseColorOptions } from './color.js'; | ||
import { normalizeColorValue } from './color.js'; | ||
@@ -20,5 +21,11 @@ export interface ParseGradientOptions { | ||
export function normalizeGradientValue(value: unknown, options: ParseGradientOptions): ParsedGradientToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (!Array.isArray(value)) throw new Error(`expected array, received ${typeof value}`); | ||
if (value.some((v) => !v || !v.color)) throw new Error('all gradient stops must have color'); | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (!Array.isArray(value)) { | ||
throw new Error(`expected array, received ${typeof value}`); | ||
} | ||
if (value.some((v) => !v || !v.color)) { | ||
throw new Error('all gradient stops must have color'); | ||
} | ||
return (value as any).map((v: GradientStop) => ({ | ||
@@ -25,0 +32,0 @@ color: normalizeColorValue(v.color, options.color), |
@@ -1,2 +0,2 @@ | ||
import type {ParsedLinkToken} from '../../token.js'; | ||
import type { ParsedLinkToken } from '../../token.js'; | ||
@@ -14,3 +14,5 @@ /** | ||
export function normalizeLinkValue(value: unknown): ParsedLinkToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value === 'string') { | ||
@@ -17,0 +19,0 @@ return value; |
@@ -1,2 +0,2 @@ | ||
import type {ParsedNumberToken} from '../../token.js'; | ||
import type { ParsedNumberToken } from '../../token.js'; | ||
@@ -21,5 +21,9 @@ /** | ||
export function normalizeNumberValue(value: unknown): ParsedNumberToken['$value'] { | ||
if (value === null || value === undefined) throw new Error('missing value'); | ||
if (typeof value === 'number') return value; | ||
if (value === null || value === undefined) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value === 'number') { | ||
return value; | ||
} | ||
throw new Error(`expected number, received ${typeof value}`); | ||
} |
@@ -1,4 +0,5 @@ | ||
import type {ParsedShadowToken} from '../../token.js'; | ||
import {ParseColorOptions, normalizeColorValue} from './color.js'; | ||
import {normalizeDimensionValue} from './dimension.js'; | ||
import type { ParsedShadowToken } from '../../token.js'; | ||
import type { ParseColorOptions } from './color.js'; | ||
import { normalizeColorValue } from './color.js'; | ||
import { normalizeDimensionValue } from './dimension.js'; | ||
@@ -25,4 +26,8 @@ export interface ParseShadowOptions { | ||
export function normalizeShadowValue(value: unknown, options: ParseShadowOptions): ParsedShadowToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (typeof value !== 'object' && !Array.isArray(value)) throw new Error(`expected object or array of objects, got ${typeof value}`); | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value !== 'object' && !Array.isArray(value)) { | ||
throw new Error(`expected object or array of objects, got ${typeof value}`); | ||
} | ||
const v = Array.isArray(value) ? value : [value]; | ||
@@ -29,0 +34,0 @@ return v.map((shadow: any, i: number) => { |
@@ -1,2 +0,2 @@ | ||
import type {ParsedStrokeStyleToken} from '../../token.js'; | ||
import type { ParsedStrokeStyleToken } from '../../token.js'; | ||
@@ -3,0 +3,0 @@ const VALID_STROKE_STYLES = new Set(['solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'outset', 'inset']); |
@@ -1,4 +0,4 @@ | ||
import type {CubicBezierToken, ParsedTransitionToken} from '../../token.js'; | ||
import {normalizeDurationValue} from './duration.js'; | ||
import {normalizeCubicBezierValue} from './cubic-bezier.js'; | ||
import type { CubicBezierToken, ParsedTransitionToken } from '../../token.js'; | ||
import { normalizeDurationValue } from './duration.js'; | ||
import { normalizeCubicBezierValue } from './cubic-bezier.js'; | ||
@@ -21,7 +21,15 @@ const EASE: CubicBezierToken['$value'] = [0.25, 0.1, 0.25, 1]; | ||
export function normalizeTransitionValue(value: unknown): ParsedTransitionToken['$value'] { | ||
if (!value) throw new Error('missing value'); | ||
if (typeof value !== 'object' || Array.isArray(value)) throw new Error(`expected object, got ${typeof value}`); | ||
if (!('duration' in value)) throw new Error('missing duration'); | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value !== 'object' || Array.isArray(value)) { | ||
throw new Error(`expected object, got ${typeof value}`); | ||
} | ||
if (!('duration' in value)) { | ||
throw new Error('missing duration'); | ||
} | ||
// currently delay is optional; is that right? | ||
if (!('timingFunction' in value)) throw new Error('missing timingFunction'); | ||
if (!('timingFunction' in value)) { | ||
throw new Error('missing timingFunction'); | ||
} | ||
const v = value as any; | ||
@@ -28,0 +36,0 @@ return { |
@@ -1,6 +0,6 @@ | ||
import type {ParsedTypographyValue} from '../../token.js'; | ||
import {camelize} from '@cobalt-ui/utils'; | ||
import {normalizeFontFamilyValue} from './fontFamily.js'; | ||
import {normalizeDimensionValue} from './dimension.js'; | ||
import {normalizeFontWeightValue} from './fontWeight.js'; | ||
import type { ParsedTypographyValue } from '../../token.js'; | ||
import { camelize } from '@cobalt-ui/utils'; | ||
import { normalizeFontFamilyValue } from './fontFamily.js'; | ||
import { normalizeDimensionValue } from './dimension.js'; | ||
import { normalizeFontWeightValue } from './fontWeight.js'; | ||
@@ -22,5 +22,11 @@ /** | ||
export function normalizeTypographyValue(value: unknown): Partial<ParsedTypographyValue> { | ||
if (!value) throw new Error('missing value'); | ||
if (typeof value !== 'object' || Array.isArray(value)) throw new Error(`expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
if (!Object.keys(value).length) throw new Error('must specify at least 1 font property'); | ||
if (!value) { | ||
throw new Error('missing value'); | ||
} | ||
if (typeof value !== 'object' || Array.isArray(value)) { | ||
throw new Error(`expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
} | ||
if (!Object.keys(value).length) { | ||
throw new Error('must specify at least 1 font property'); | ||
} | ||
@@ -27,0 +33,0 @@ const normalized = {} as ParsedTypographyValue; |
@@ -9,3 +9,3 @@ // Base | ||
$extensions?: Record<string, unknown>; | ||
} & {[childNodes: string]: TokenOrGroup}; | ||
} & { [childNodes: string]: TokenOrGroup }; | ||
@@ -12,0 +12,0 @@ export type Mode<T = string> = Record<string, T>; |
@@ -7,6 +7,14 @@ export function isObj(value: unknown): boolean { | ||
export function isEmpty(value: unknown): boolean { | ||
if (value === undefined || value === null) return true; | ||
if (typeof value === 'string') return value.length === 0; | ||
if (Array.isArray(value)) return (value as Array<unknown>).length === 0; | ||
if (isObj(value)) return Object.keys(value as object).length === 0; | ||
if (value === undefined || value === null) { | ||
return true; | ||
} | ||
if (typeof value === 'string') { | ||
return value.length === 0; | ||
} | ||
if (Array.isArray(value)) { | ||
return (value as Array<unknown>).length === 0; | ||
} | ||
if (isObj(value)) { | ||
return Object.keys(value as object).length === 0; | ||
} | ||
return false; | ||
@@ -13,0 +21,0 @@ } |
@@ -21,15 +21,15 @@ { | ||
"example": "{\n \"$value\": \"#ff00ff\",\n \"$type\": \"color\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["border"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/borderValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["border"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/borderValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"borderGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["border"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/border"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["border"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/border" }] } | ||
}, | ||
@@ -40,5 +40,5 @@ "borderValue": { | ||
"properties": { | ||
"color": {"oneOf": [{"$ref": "#/$defs/colorValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"width": {"oneOf": [{"$ref": "#/$defs/dimensionValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"style": {"oneOf": [{"$ref": "#/$defs/strokeStyleValue"}, {"$ref": "#/$defs/alias"}]} | ||
"color": { "oneOf": [{ "$ref": "#/$defs/colorValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"width": { "oneOf": [{ "$ref": "#/$defs/dimensionValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"style": { "oneOf": [{ "$ref": "#/$defs/strokeStyleValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
@@ -49,15 +49,15 @@ }, | ||
"example": "{\n \"$value\": {\n \"color\": \"#36363600\",\n \"width\": \"3px\",\n \"style\": \"solid\"\n },\n \"$type\": \"border\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["color"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/colorValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["color"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/colorValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"colorGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["color"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/color"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["color"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/color" }] } | ||
}, | ||
@@ -70,9 +70,9 @@ "colorValue": { | ||
"example": "{\n \"$value\": [0, 0, 0.5, 1],\n \"$type\": \"cubicBezier\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["cubicBezier"]}, | ||
"$type": { "type": "string", "enum": ["cubicBezier"] }, | ||
"$value": { | ||
"oneOf": [{"$ref": "#/$defs/cubicBezierValue"}, {"$ref": "#/$defs/alias"}] | ||
"oneOf": [{ "$ref": "#/$defs/cubicBezierValue" }, { "$ref": "#/$defs/alias" }] | ||
} | ||
@@ -82,10 +82,10 @@ } | ||
"cubicBezierGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["cubicBezier"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/cubicBezier"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["cubicBezier"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/cubicBezier" }] } | ||
}, | ||
"cubicBezierValue": { | ||
"type": "array", | ||
"items": {"type": "number"}, | ||
"items": { "type": "number" }, | ||
"minItems": 4, | ||
@@ -97,15 +97,15 @@ "maxItems": 4 | ||
"example": "{\n{ \"$value\": \"0.25rem\",\n \"$type\": \"dimension\"}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["dimension"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/dimensionValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["dimension"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/dimensionValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"dimensionGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["dimension"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/dimension"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["dimension"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/dimension" }] } | ||
}, | ||
@@ -119,15 +119,15 @@ "dimensionValue": { | ||
"example": "{\n \"$value\": \"100ms\",\n \"$type\": \"duration\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["duration"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/durationValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["duration"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/durationValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"durationGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["dimension"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/dimension"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["dimension"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/dimension" }] } | ||
}, | ||
@@ -141,9 +141,9 @@ "durationValue": { | ||
"example": "{\n \"$value\": [\"Helvetica\", \"Arial\", \"sans-serif\"],\n \"$type\": \"fontFamily\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["fontFamily"]}, | ||
"$type": { "type": "string", "enum": ["fontFamily"] }, | ||
"$value": { | ||
"oneOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}}, {"$ref": "#/$defs/alias"}] | ||
"oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }, { "$ref": "#/$defs/alias" }] | ||
} | ||
@@ -153,6 +153,6 @@ } | ||
"fontFamilyGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["fontFamily"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/fontFamily"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["fontFamily"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/fontFamily" }] } | ||
}, | ||
@@ -162,15 +162,15 @@ "fontWeight": { | ||
"example": "{\n \"$value\": 350,\n \"$type\": \"fontWeight\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["fontWeight"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/fontWeightNumericValue"}, {"$ref": "#/$defs/fontWeightStringValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["fontWeight"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/fontWeightNumericValue" }, { "$ref": "#/$defs/fontWeightStringValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"fontWeightGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["fontWeight"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/fontWeight"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["fontWeight"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/fontWeight" }] } | ||
}, | ||
@@ -185,3 +185,22 @@ "fontWeightNumericValue": { | ||
"type": "string", | ||
"enum": ["thin", "hairline", "extra-light", "ultra-light", "light", "normal", "regular", "book", "medium", "semi-bold", "demi-bold", "bold", "extra-bold", "ultra-bold", "black", "heavy", "extra-black", "ultra-black"] | ||
"enum": [ | ||
"thin", | ||
"hairline", | ||
"extra-light", | ||
"ultra-light", | ||
"light", | ||
"normal", | ||
"regular", | ||
"book", | ||
"medium", | ||
"semi-bold", | ||
"demi-bold", | ||
"bold", | ||
"extra-bold", | ||
"ultra-bold", | ||
"black", | ||
"heavy", | ||
"extra-black", | ||
"ultra-black" | ||
] | ||
}, | ||
@@ -191,15 +210,15 @@ "gradient": { | ||
"example": "{\n \"$value\": [{\"color\": \"#0000ff\", \"position\": 0}, {\"color\": \"#ff0000\", \"position\": 1}],\n \"$type\": \"gradient\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["gradient"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/gradientValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["gradient"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/gradientValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"gradientGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["gradient"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/gradient"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["gradient"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/gradient" }] } | ||
}, | ||
@@ -210,4 +229,4 @@ "gradientValue": { | ||
"properties": { | ||
"color": {"oneOf": [{"$ref": "#/$defs/colorValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"position": {"oneOf": [{"type": "number"}, {"$ref": "#/$defs/alias"}]} | ||
"color": { "oneOf": [{ "$ref": "#/$defs/colorValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"position": { "oneOf": [{ "type": "number" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
@@ -218,15 +237,15 @@ }, | ||
"oneOf": [ | ||
{"$ref": "#/$defs/borderGroup"}, | ||
{"$ref": "#/$defs/colorGroup"}, | ||
{"$ref": "#/$defs/cubicBezierGroup"}, | ||
{"$ref": "#/$defs/dimensionGroup"}, | ||
{"$ref": "#/$defs/durationGroup"}, | ||
{"$ref": "#/$defs/fontFamilyGroup"}, | ||
{"$ref": "#/$defs/fontWeightGroup"}, | ||
{"$ref": "#/$defs/gradientGroup"}, | ||
{"$ref": "#/$defs/numberGroup"}, | ||
{"$ref": "#/$defs/shadowGroup"}, | ||
{"$ref": "#/$defs/strokeStyleGroup"}, | ||
{"$ref": "#/$defs/transitionGroup"}, | ||
{"$ref": "#/$defs/typographyGroup"} | ||
{ "$ref": "#/$defs/borderGroup" }, | ||
{ "$ref": "#/$defs/colorGroup" }, | ||
{ "$ref": "#/$defs/cubicBezierGroup" }, | ||
{ "$ref": "#/$defs/dimensionGroup" }, | ||
{ "$ref": "#/$defs/durationGroup" }, | ||
{ "$ref": "#/$defs/fontFamilyGroup" }, | ||
{ "$ref": "#/$defs/fontWeightGroup" }, | ||
{ "$ref": "#/$defs/gradientGroup" }, | ||
{ "$ref": "#/$defs/numberGroup" }, | ||
{ "$ref": "#/$defs/shadowGroup" }, | ||
{ "$ref": "#/$defs/strokeStyleGroup" }, | ||
{ "$ref": "#/$defs/transitionGroup" }, | ||
{ "$ref": "#/$defs/typographyGroup" } | ||
] | ||
@@ -254,15 +273,15 @@ }, | ||
"example": "{\n \"$value\": \"2.3\",\n \"$type\": \"number\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["number"]}, | ||
"$value": {"oneOf": [{"type": "number"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["number"] }, | ||
"$value": { "oneOf": [{ "type": "number" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"numberGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["number"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/number"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["number"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/number" }] } | ||
}, | ||
@@ -272,15 +291,15 @@ "shadow": { | ||
"example": "{\n \"$value\": {\n \"color\": \"#00000020\",\n \"offsetX\": \"0.5rem\",\n \"offsetY\": \"0.5rem\",\n \"blur\": \"1.5rem\",\n \"spread\": \"0rem\"\n },\n \"$type\": \"strokeStyle\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["shadow"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/shadowValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["shadow"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/shadowValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"shadowGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["shadow"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/shadow"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["shadow"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/shadow" }] } | ||
}, | ||
@@ -291,7 +310,7 @@ "shadowValue": { | ||
"properties": { | ||
"color": {"oneOf": [{"$ref": "#/$defs/colorValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"offsetX": {"oneOf": [{"$ref": "#/$defs/dimensionValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"offsetY": {"oneOf": [{"$ref": "#/$defs/dimensionValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"blur": {"oneOf": [{"$ref": "#/$defs/dimensionValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"spread": {"oneOf": [{"$ref": "#/$defs/dimensionValue"}, {"$ref": "#/$defs/alias"}]} | ||
"color": { "oneOf": [{ "$ref": "#/$defs/colorValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"offsetX": { "oneOf": [{ "$ref": "#/$defs/dimensionValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"offsetY": { "oneOf": [{ "$ref": "#/$defs/dimensionValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"blur": { "oneOf": [{ "$ref": "#/$defs/dimensionValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"spread": { "oneOf": [{ "$ref": "#/$defs/dimensionValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
@@ -302,18 +321,18 @@ }, | ||
"example": "{\n \"$value\": {\n \"dashArray\": [\"0.5rem\", \"0.25rem\"],\n \"lineCap\": \"round\"\n },\n \"$type\": \"strokeStyle\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["number"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/strokeStyleValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["number"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/strokeStyleValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"strokeStyleGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["strokeStyle"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/strokeStyle"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["strokeStyle"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/strokeStyle" }] } | ||
}, | ||
"strokeStyleValue": { | ||
"oneOf": [{"$ref": "#/$defs/strokeStyleStringValue"}, {"$ref": "#/$defs/strokeStyleObjectValue"}] | ||
"oneOf": [{ "$ref": "#/$defs/strokeStyleStringValue" }, { "$ref": "#/$defs/strokeStyleObjectValue" }] | ||
}, | ||
@@ -328,4 +347,4 @@ "strokeStyleStringValue": { | ||
"properties": { | ||
"dashArray": {"type": "array", "items": {"$ref": "#/$defs/dimensionValue"}}, | ||
"lineCap": {"type": "string", "enum": ["round", "butt", "square"]} | ||
"dashArray": { "type": "array", "items": { "$ref": "#/$defs/dimensionValue" } }, | ||
"lineCap": { "type": "string", "enum": ["round", "butt", "square"] } | ||
} | ||
@@ -335,15 +354,15 @@ }, | ||
"oneOf": [ | ||
{"$ref": "#/$defs/border"}, | ||
{"$ref": "#/$defs/color"}, | ||
{"$ref": "#/$defs/cubicBezier"}, | ||
{"$ref": "#/$defs/dimension"}, | ||
{"$ref": "#/$defs/duration"}, | ||
{"$ref": "#/$defs/fontFamily"}, | ||
{"$ref": "#/$defs/fontWeight"}, | ||
{"$ref": "#/$defs/gradient"}, | ||
{"$ref": "#/$defs/number"}, | ||
{"$ref": "#/$defs/shadow"}, | ||
{"$ref": "#/$defs/strokeStyle"}, | ||
{"$ref": "#/$defs/transition"}, | ||
{"$ref": "#/$defs/typography"} | ||
{ "$ref": "#/$defs/border" }, | ||
{ "$ref": "#/$defs/color" }, | ||
{ "$ref": "#/$defs/cubicBezier" }, | ||
{ "$ref": "#/$defs/dimension" }, | ||
{ "$ref": "#/$defs/duration" }, | ||
{ "$ref": "#/$defs/fontFamily" }, | ||
{ "$ref": "#/$defs/fontWeight" }, | ||
{ "$ref": "#/$defs/gradient" }, | ||
{ "$ref": "#/$defs/number" }, | ||
{ "$ref": "#/$defs/shadow" }, | ||
{ "$ref": "#/$defs/strokeStyle" }, | ||
{ "$ref": "#/$defs/transition" }, | ||
{ "$ref": "#/$defs/typography" } | ||
], | ||
@@ -376,3 +395,3 @@ "discriminator": { | ||
}, | ||
"$extensions": {"$ref": "#/$defs/$extensions"} | ||
"$extensions": { "$ref": "#/$defs/$extensions" } | ||
}, | ||
@@ -384,15 +403,15 @@ "additionalProperties": true | ||
"example": "{\n \"$value\": {\n \"duration\": \"200ms\",\n \"delay\": \"0ms\",\n \"timingFunction\": [0.5, 0, 1, 1]\n },\n \"$type\": \"transition\"\n}", | ||
"allOf": [{"$ref": "#/$defs/tokenCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/tokenCommon" }], | ||
"type": "object", | ||
"required": ["$value"], | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["transition"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/transitionValue"}, {"$ref": "#/$defs/alias"}]} | ||
"$type": { "type": "string", "enum": ["transition"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/transitionValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
}, | ||
"transitionGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["transition"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/transition"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["transition"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/transition" }] } | ||
}, | ||
@@ -403,5 +422,5 @@ "transitionValue": { | ||
"properties": { | ||
"duration": {"oneOf": [{"$ref": "#/$defs/durationValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"delay": {"oneOf": [{"$ref": "#/$defs/durationValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"timingFunction": {"oneOf": [{"$ref": "#/$defs/cubicBezierValue"}, {"$ref": "#/$defs/alias"}]} | ||
"duration": { "oneOf": [{ "$ref": "#/$defs/durationValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"delay": { "oneOf": [{ "$ref": "#/$defs/durationValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"timingFunction": { "oneOf": [{ "$ref": "#/$defs/cubicBezierValue" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
@@ -415,5 +434,5 @@ }, | ||
"properties": { | ||
"$type": {"type": "string", "enum": ["typography"]}, | ||
"$value": {"oneOf": [{"$ref": "#/$defs/typographyValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"$extensions": {"$ref": "#/$defs/$extensions"} | ||
"$type": { "type": "string", "enum": ["typography"] }, | ||
"$value": { "oneOf": [{ "$ref": "#/$defs/typographyValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"$extensions": { "$ref": "#/$defs/$extensions" } | ||
}, | ||
@@ -423,6 +442,6 @@ "additionalProperties": true | ||
"typographyGroup": { | ||
"allOf": [{"$ref": "#/$defs/groupCommon"}], | ||
"allOf": [{ "$ref": "#/$defs/groupCommon" }], | ||
"type": "object", | ||
"properties": {"$type": {"type": "string", "enum": ["typography"]}}, | ||
"additionalProperties": {"oneOf": [{"$ref": "#/$defs/group"}, {"$ref": "#/$defs/typography"}]} | ||
"properties": { "$type": { "type": "string", "enum": ["typography"] } }, | ||
"additionalProperties": { "oneOf": [{ "$ref": "#/$defs/group" }, { "$ref": "#/$defs/typography" }] } | ||
}, | ||
@@ -433,7 +452,7 @@ "typographyValue": { | ||
"properties": { | ||
"fontFamily": {"oneOf": [{"$ref": "#/$defs/fontFamily"}, {"$ref": "#/$defs/alias"}]}, | ||
"fontSize": {"oneOf": [{"$ref": "#/$defs/dimensionValue"}, {"$ref": "#/$defs/alias"}]}, | ||
"fontWeight": {"oneOf": [{"type": "number"}, {"$ref": "#/$defs/alias"}]}, | ||
"letterSpacing": {"oneOf": [{"$ref": "#/$defs/duration"}, {"$ref": "#/$defs/alias"}]}, | ||
"lineHeight": {"oneOf": [{"type": "number"}, {"$ref": "#/$defs/alias"}]} | ||
"fontFamily": { "oneOf": [{ "$ref": "#/$defs/fontFamily" }, { "$ref": "#/$defs/alias" }] }, | ||
"fontSize": { "oneOf": [{ "$ref": "#/$defs/dimensionValue" }, { "$ref": "#/$defs/alias" }] }, | ||
"fontWeight": { "oneOf": [{ "type": "number" }, { "$ref": "#/$defs/alias" }] }, | ||
"letterSpacing": { "oneOf": [{ "$ref": "#/$defs/duration" }, { "$ref": "#/$defs/alias" }] }, | ||
"lineHeight": { "oneOf": [{ "type": "number" }, { "$ref": "#/$defs/alias" }] } | ||
} | ||
@@ -440,0 +459,0 @@ } |
Sorry, the diff of this file is not supported yet
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
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
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
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
672087
5159
Updated@cobalt-ui/utils@^1.2.4
Updated@types/culori@^2.1.0