@pandabox/utils
Version:
A bunch of utilities
41 lines (36 loc) • 1.72 kB
TypeScript
import { TokenCategory } from '@pandacss/types';
import { CssVarOptions } from '@pandacss/shared';
type CssVar<Name extends string> = {
var: `--${Name}`;
ref: `var(--${Name})`;
};
type ToCssVar<Cat extends string, T extends string> = `--${Cat}-${T}`;
type CssVarsOptions = Omit<CssVarOptions, 'fallback'>;
declare function defineCssVars<K extends string>(scope: string, keys: Array<K | [K, string]>, options?: CssVarsOptions): { [Var in K]: CssVar<Var>; };
declare const cssVar: {
/**
* ⚠️ doesn't handle prefixing/hashing, instead use `cssVar.create` for that
*/
ref: <Value extends string>(value: Value, fallback?: string) => `var(--${Value}${string})`;
/**
* ⚠️ doesn't handle prefixing/hashing, instead use `cssVar.create` for that
*/
name: <Value_1 extends string>(value: Value_1) => `--${Value_1}`;
create: <Value_2 extends string>(value: Value_2, options?: CssVarOptions) => CssVar<Value_2>;
scope: typeof defineCssVars;
};
interface TokenRecord extends Record<TokenCategory | (string & {}), Record<string, number | string | undefined>> {
}
type ToTokenRecord<TTokens extends Record<string, any>> = {
[Category in TokenCategory]-?: {
[TokenName in TTokens[Category]]?: number | string;
};
};
declare const assignInlineVars: <TRecord extends TokenRecord>(userVars?: Partial<TRecord> | undefined, options?: CssVarsOptions & {
separator?: string;
}) => Record<string, any>;
/**
* Recursively wraps each value in a { value: xxx } object
*/
declare const wrapValue: (obj: Record<string, any>) => Record<string, any>;
export { type CssVar, type CssVarsOptions, type ToCssVar, type ToTokenRecord, assignInlineVars, cssVar, wrapValue };