UNPKG

2.1 kBTypeScriptView Raw
1import { IStyle } from './IStyle';
2import { IStyleFunctionOrObject, IStyleFunction } from './IStyleFunction';
3export declare type Diff<T extends keyof any, U extends keyof any> = ({
4 [P in T]: P;
5} & {
6 [P in U]: never;
7} & {
8 [x: string]: never;
9})[T];
10/**
11 * {@docCategory Omit}
12 */
13export declare type Omit<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>;
14/**
15 * Helper function whose role is supposed to express that regardless if T is a style object or style function,
16 * it will always map to a style function.
17 */
18export declare type __MapToFunctionType<T> = Extract<T, Function> extends never ? (...args: any[]) => Partial<T> : Extract<T, Function>;
19/**
20 * A style set is a dictionary of display areas to IStyle objects.
21 * It may optionally contain style functions for sub components in the special `subComponentStyles`
22 * property.
23 */
24export declare type IStyleSet<TStyleSet extends IStyleSet<TStyleSet> = {
25 [key: string]: any;
26}> = {
27 [P in keyof Omit<TStyleSet, 'subComponentStyles'>]: IStyle;
28} & {
29 subComponentStyles?: {
30 [P in keyof TStyleSet['subComponentStyles']]: IStyleFunctionOrObject<any, any>;
31 };
32};
33/**
34 * A concatenated style set differs from `IStyleSet` in that subComponentStyles will always be a style function.
35 */
36export declare type IConcatenatedStyleSet<TStyleSet extends IStyleSet<TStyleSet>> = {
37 [P in keyof Omit<TStyleSet, 'subComponentStyles'>]: IStyle;
38} & {
39 subComponentStyles?: {
40 [P in keyof TStyleSet['subComponentStyles']]: IStyleFunction<any, any>;
41 };
42};
43/**
44 * A processed style set is one which the set of styles associated with each area has been converted
45 * into a class name. Additionally, all subComponentStyles are style functions.
46 */
47export declare type IProcessedStyleSet<TStyleSet extends IStyleSet<TStyleSet>> = {
48 [P in keyof Omit<TStyleSet, 'subComponentStyles'>]: string;
49} & {
50 subComponentStyles: {
51 [P in keyof TStyleSet['subComponentStyles']]: __MapToFunctionType<TStyleSet['subComponentStyles'] extends infer J ? (P extends keyof J ? J[P] : never) : never>;
52 };
53};