@stylable/core
Version:
CSS for Components
46 lines • 2.31 kB
TypeScript
import { StylableMeta } from './stylable-meta';
import { StylableResolver } from './stylable-resolver';
import { ParsedValue } from './types';
export interface Box<Type extends string, Value extends any> {
type: Type;
value: Value;
}
export declare function box<Type extends string, Value extends any>(type: Type, value: Value): Box<Type, Value>;
export declare function unbox<B extends Box<string, unknown>>(boxed: B | string): any;
export interface BoxedValueMap {
[k: string]: string | Box<string, unknown>;
}
export declare type BoxedValueArray = Array<string | Box<string, unknown>>;
declare type CustomTypes = Record<string, CustomValueExtension<any>>;
export interface CustomValueExtension<T> {
evalVarAst(valueAst: ParsedValue, customTypes: {
[typeID: string]: CustomValueExtension<unknown>;
}): Box<string, T>;
getValue(path: string[], value: Box<string, T>, node: ParsedValue, customTypes: CustomTypes): string;
}
export declare const stTypes: CustomTypes;
export declare const CustomValueStrategy: {
args: (fnNode: ParsedValue, customTypes: CustomTypes) => (string | Box<string, any>)[];
named: (fnNode: ParsedValue, customTypes: CustomTypes) => BoxedValueMap;
};
export interface JSValueExtension<Value> {
_kind: 'CustomValue';
register(localTypeSymbol: string): CustomValueExtension<Value>;
}
interface ExtensionApi<Value, Args> {
processArgs: (fnNode: ParsedValue, customTypes: CustomTypes) => Args;
createValue: (args: Args) => Value;
getValue: (v: Value, key: string) => string | Box<string, unknown>;
flattenValue?: (v: Box<string, Value>) => {
parts: Array<string | Box<string, unknown>>;
delimiter: ',' | ' ';
};
}
export declare function resolveCustomValues(meta: StylableMeta, resolver: StylableResolver): {
[x: string]: CustomValueExtension<any>;
};
export declare function createCustomValue<Value, Args>({ processArgs, createValue, flattenValue, getValue, }: ExtensionApi<Value, Args>): JSValueExtension<Value>;
export declare function getBoxValue(path: string[], value: string | Box<string, unknown>, node: ParsedValue, customTypes: CustomTypes): string;
export declare function isCustomValue(symbol: any): symbol is JSValueExtension<unknown>;
export {};
//# sourceMappingURL=custom-values.d.ts.map