source: trip-planner-front/node_modules/css-select/lib/types.d.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.2 KB
Line 
1import type { Selector } from "css-what";
2export declare type InternalSelector = Selector | {
3 type: "_flexibleDescendant";
4};
5export declare type Predicate<Value> = (v: Value) => boolean;
6export interface Adapter<Node, ElementNode extends Node> {
7 /**
8 * Is the node a tag?
9 */
10 isTag: (node: Node) => node is ElementNode;
11 /**
12 * Does at least one of passed element nodes pass the test predicate?
13 */
14 existsOne: (test: Predicate<ElementNode>, elems: Node[]) => boolean;
15 /**
16 * Get the attribute value.
17 */
18 getAttributeValue: (elem: ElementNode, name: string) => string | undefined;
19 /**
20 * Get the node's children
21 */
22 getChildren: (node: Node) => Node[];
23 /**
24 * Get the name of the tag
25 */
26 getName: (elem: ElementNode) => string;
27 /**
28 * Get the parent of the node
29 */
30 getParent: (node: ElementNode) => ElementNode | null;
31 /**
32 * Get the siblings of the node. Note that unlike jQuery's `siblings` method,
33 * this is expected to include the current node as well
34 */
35 getSiblings: (node: Node) => Node[];
36 /**
37 * Get the text content of the node, and its children if it has any.
38 */
39 getText: (node: Node) => string;
40 /**
41 * Does the element have the named attribute?
42 */
43 hasAttrib: (elem: ElementNode, name: string) => boolean;
44 /**
45 * Takes an array of nodes, and removes any duplicates, as well as any
46 * nodes whose ancestors are also in the array.
47 */
48 removeSubsets: (nodes: Node[]) => Node[];
49 /**
50 * Finds all of the element nodes in the array that match the test predicate,
51 * as well as any of their children that match it.
52 */
53 findAll: (test: Predicate<ElementNode>, nodes: Node[]) => ElementNode[];
54 /**
55 * Finds the first node in the array that matches the test predicate, or one
56 * of its children.
57 */
58 findOne: (test: Predicate<ElementNode>, elems: Node[]) => ElementNode | null;
59 /**
60 * The adapter can also optionally include an equals method, if your DOM
61 * structure needs a custom equality test to compare two objects which refer
62 * to the same underlying node. If not provided, `css-select` will fall back to
63 * `a === b`.
64 */
65 equals?: (a: Node, b: Node) => boolean;
66 /**
67 * Is the element in hovered state?
68 */
69 isHovered?: (elem: ElementNode) => boolean;
70 /**
71 * Is the element in visited state?
72 */
73 isVisited?: (elem: ElementNode) => boolean;
74 /**
75 * Is the element in active state?
76 */
77 isActive?: (elem: ElementNode) => boolean;
78}
79export interface Options<Node, ElementNode extends Node> {
80 /**
81 * When enabled, tag names will be case-sensitive.
82 *
83 * @default false
84 */
85 xmlMode?: boolean;
86 /**
87 * The last function in the stack, will be called with the last element
88 * that's looked at.
89 */
90 rootFunc?: (element: ElementNode) => boolean;
91 /**
92 * The adapter to use when interacting with the backing DOM structure. By
93 * default it uses the `domutils` module.
94 */
95 adapter?: Adapter<Node, ElementNode>;
96 /**
97 * The context of the current query. Used to limit the scope of searches.
98 * Can be matched directly using the `:scope` pseudo-selector.
99 */
100 context?: Node | Node[];
101 /**
102 * Allow css-select to cache results for some selectors, sometimes greatly
103 * improving querying performance. Disable this if your document can
104 * change in between queries with the same compiled selector.
105 *
106 * @default true
107 */
108 cacheResults?: boolean;
109}
110export interface InternalOptions<Node, ElementNode extends Node> extends Options<Node, ElementNode> {
111 adapter: Adapter<Node, ElementNode>;
112 equals: (a: Node, b: Node) => boolean;
113}
114export interface CompiledQuery<ElementNode> {
115 (node: ElementNode): boolean;
116 shouldTestNextSiblings?: boolean;
117}
118export declare type Query<ElementNode> = string | CompiledQuery<ElementNode> | Selector[][];
119export declare type CompileToken<Node, ElementNode extends Node> = (token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node) => CompiledQuery<ElementNode>;
120//# sourceMappingURL=types.d.ts.map
Note: See TracBrowser for help on using the repository browser.