UNPKG

2.26 kBSource Map (JSON)View Raw
1{"version":3,"file":"IStyleSet.js","sourceRoot":"../src/","sources":["IStyleSet.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle } from './IStyle';\nimport { IStyleFunctionOrObject, IStyleFunction } from './IStyleFunction';\n\nexport type Diff<T extends keyof any, U extends keyof any> = ({ [P in T]: P } &\n { [P in U]: never } & { [x: string]: never })[T];\n\n/**\n * {@docCategory Omit}\n */\nexport type Omit<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>;\n\n/**\n * Helper function whose role is supposed to express that regardless if T is a style object or style function,\n * it will always map to a style function.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type __MapToFunctionType<T> = Extract<T, Function> extends never\n ? (...args: any[]) => Partial<T>\n : Extract<T, Function>;\n\n/**\n * A style set is a dictionary of display areas to IStyle objects.\n * It may optionally contain style functions for sub components in the special `subComponentStyles`\n * property.\n */\nexport type IStyleSet<TStyleSet extends IStyleSet<TStyleSet> = { [key: string]: any }> = {\n [P in keyof Omit<TStyleSet, 'subComponentStyles'>]: IStyle;\n} & {\n subComponentStyles?: { [P in keyof TStyleSet['subComponentStyles']]: IStyleFunctionOrObject<any, any> };\n};\n\n/**\n * A concatenated style set differs from `IStyleSet` in that subComponentStyles will always be a style function.\n */\nexport type IConcatenatedStyleSet<TStyleSet extends IStyleSet<TStyleSet>> = {\n [P in keyof Omit<TStyleSet, 'subComponentStyles'>]: IStyle;\n} & {\n subComponentStyles?: { [P in keyof TStyleSet['subComponentStyles']]: IStyleFunction<any, any> };\n};\n\n/**\n * A processed style set is one which the set of styles associated with each area has been converted\n * into a class name. Additionally, all subComponentStyles are style functions.\n */\nexport type IProcessedStyleSet<TStyleSet extends IStyleSet<TStyleSet>> = {\n [P in keyof Omit<TStyleSet, 'subComponentStyles'>]: string;\n} & {\n subComponentStyles: {\n [P in keyof TStyleSet['subComponentStyles']]: __MapToFunctionType<\n TStyleSet['subComponentStyles'] extends infer J ? (P extends keyof J ? J[P] : never) : never\n >;\n };\n};\n"]}
\No newline at end of file