/
css-selector.d.ts
84 lines (68 loc) · 1.9 KB
/
css-selector.d.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
/**
* @module "ui/styling/css-selector"
*/ /** */
import { Node as ParserNode } from "../../../css";
/**
* An interface describing the shape of a type on which the selectors may apply.
* Note, the ui/core/view.View implements Node.
*/
export interface Node {
parent?: Node;
id?: string;
nodeName?: string;
cssType?: string;
cssClasses?: Set<string>;
cssPseudoClasses?: Set<string>;
getChildIndex?(node: Node): number;
getChildAt?(index: number): Node;
}
export interface Declaration {
property: string;
value: string;
}
export interface SelectorCore {
/**
* Dynamic selectors depend on attributes and pseudo classes.
*/
dynamic: boolean;
match(node: Node): boolean;
ruleset: RuleSet;
}
export class RuleSet {
/**
* Gets the selectors in this ruleset's selector group.
*/
selectors: SelectorCore[];
/**
* Gets the key-value list of declarations for the ruleset.
*/
declarations: Declaration[];
/**
* Optional Tag for rules
**/
tag: string | Number;
}
export class SelectorsMap {
constructor(rules: RuleSet[]);
/**
* Get a list of selectors that are likely to match the node.
*/
query<T extends Node>(node: T): SelectorsMatch<T>;
}
export type ChangeMap<T extends Node> = Map<T, Changes>;
export interface Changes {
attributes?: Set<string>;
pseudoClasses?: Set<string>;
}
export class SelectorsMatch<T extends Node> {
/**
* Gets the static selectors that match the queried node and the dynamic selectors that may potentially match the queried node.
*/
selectors: SelectorCore[];
/**
* Gets a map of nodes to attributes and pseudo classes, that may affect the state of the dynamic
*/
changeMap: ChangeMap<T>;
}
export function fromAstNodes(astRules: ParserNode[]): RuleSet[];
export function createSelector(sel: string): SelectorCore;