oak-domain/lib/types/Style.d.ts

41 lines
1.1 KiB
TypeScript

import { EntityDict, GeneralEntityShape } from './Entity';
import { EntityDict as BaseEntityDict } from '../base-app-domain';
type Color = `#${string}`;
type IconName = string;
export type StyleDesc<Action extends string = '', V extends Record<string, string> = {
['##oak_illegal##']: '';
}> = Action extends '' ? (keyof V extends '##oak_illegal##' ? {} : {
color: {
[A in keyof V]: {
[E in V[A]]: Color;
};
};
}) : (keyof V extends '##oak_illegal##' ? {
icon: {
[A in Action]?: IconName;
};
} : {
icon: {
[A in Action]?: IconName;
};
color: {
[A in keyof V]: {
[E in V[A]]: Color;
};
};
});
export type StyleDef<ED extends GeneralEntityShape, Action extends string> = {
color?: {
[A in keyof ED]?: {
[E in ED[A]]?: Color;
};
};
icon?: {
[A in Action]?: IconName;
};
};
export type StyleDict<ED extends BaseEntityDict & EntityDict> = {
[T in keyof ED]?: StyleDef<ED[T]['OpSchema'], ED[T]['Action']>;
};
export {};