-
Notifications
You must be signed in to change notification settings - Fork 59
/
types.ts
101 lines (86 loc) · 2.34 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import type { GriffelStyle } from '@griffel/style-types';
export interface IsomorphicStyleSheet {
/**
* Attributes applied to the underlying HTMLStyleElement
*/
elementAttributes: Record<string, string>;
/**
* Underlying HTMLStyleElement
*/
element: HTMLStyleElement | undefined;
bucketName: StyleBucketName;
/**
* Returns all CSS rules on the stylesheet
*/
cssRules(): string[];
insertRule(rule: string): number | undefined;
}
export interface GriffelRenderer {
id: string;
/**
* @private
*/
insertionCache: Record<string, StyleBucketName>;
/**
* @private
*/
stylesheets: { [key in StyleBucketName]?: IsomorphicStyleSheet } & Record<string, IsomorphicStyleSheet>;
/**
* @private
*/
styleElementAttributes?: Readonly<Record<string, string>>;
/**
* @private
*/
insertCSSRules(cssRules: CSSRulesByBucket): void;
/**
* @private
*/
compareMediaQueries(a: string, b: string): number;
}
/**
* Buckets under which we will group our stylesheets.
*/
export type StyleBucketName = keyof CSSRulesByBucket;
export type SequenceHash = string;
export type PropertyHash = string;
export type CSSClasses = /* ltrClassName */ string | [/* ltrClassName */ string, /* rtlClassName */ string];
export type CSSClassesMap = Record<PropertyHash, CSSClasses>;
export type CSSClassesMapBySlot<Slots extends string | number> = Record<Slots, CSSClassesMap>;
export type CSSRulesByBucket = {
// reset
r?: CSSBucketEntry[];
// default
d?: CSSBucketEntry[];
// link
l?: CSSBucketEntry[];
// visited
v?: CSSBucketEntry[];
// focus-within
w?: CSSBucketEntry[];
// focus
f?: CSSBucketEntry[];
// focus-visible
i?: CSSBucketEntry[];
// hover
h?: CSSBucketEntry[];
// active
a?: CSSBucketEntry[];
// @keyframes definitions
k?: CSSBucketEntry[];
// at-rules (@support, @layer)
t?: CSSBucketEntry[];
// @media rules
m?: CSSBucketEntry[];
// @container rules
c?: CSSBucketEntry[];
};
export type GriffelInsertionFactory = () => (
renderer: GriffelRenderer,
dir: string,
cssRules: CSSRulesByBucket,
) => void;
/** @internal */
export type CSSBucketEntry = string | [string, Record<string, unknown>];
export type StylesBySlots<Slots extends string | number> = Record<Slots, GriffelStyle>;
export type LookupItem = [/* definitions */ CSSClassesMap, /* dir */ 'rtl' | 'ltr'];