1 | import { AstPseudoClassArgument, AstPseudoElementArgument } from './ast.js';
|
2 | export type PseudoClassType = Exclude<'NoArgument' | AstPseudoClassArgument['type'], 'Substitution'>;
|
3 | export type PseudoElementType = Exclude<'NoArgument' | AstPseudoElementArgument['type'], 'Substitution'>;
|
4 | export type CssLevel = 'css1' | 'css2' | 'css3' | 'selectors-3' | 'selectors-4' | 'latest' | 'progressive';
|
5 | /**
|
6 | * CSS Selector Syntax Definition can be used to define custom CSS selector parsing rules.
|
7 | */
|
8 | export interface SyntaxDefinition {
|
9 | /**
|
10 | * When specified, syntax will be based on the specified predefined CSS standard.
|
11 | * If not specified, syntax will be defined from scratch.
|
12 | */
|
13 | baseSyntax?: CssLevel;
|
14 | /**
|
15 | * CSS Tag (type).
|
16 | * @example div
|
17 | * @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Type_Class_and_ID_Selectors
|
18 | */
|
19 | tag?: {
|
20 | /**
|
21 | * Allows using wildcard (*).
|
22 | */
|
23 | wildcard?: boolean;
|
24 | } | boolean;
|
25 | /**
|
26 | * CSS3 Namespaces.
|
27 | * @example ns|div
|
28 | * @see https://www.w3.org/TR/css3-namespace/
|
29 | */
|
30 | namespace?: {
|
31 | /**
|
32 | * Allows using wildcard (*).
|
33 | */
|
34 | wildcard?: boolean;
|
35 | } | boolean;
|
36 | /**
|
37 | * CSS IDs (yes, there can be multiple).
|
38 | * @example #root#root
|
39 | * @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Type_Class_and_ID_Selectors
|
40 | */
|
41 | ids?: boolean;
|
42 | /**
|
43 | * CSS Class Names
|
44 | * @example .element.highlighted
|
45 | * @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Type_Class_and_ID_Selectors
|
46 | */
|
47 | classNames?: boolean;
|
48 | /**
|
49 | * CSS selector rule nesting combinators.
|
50 | * @example div.class > span
|
51 | * @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Combinators
|
52 | */
|
53 | combinators?: string[];
|
54 | /**
|
55 | * CSS Attribute Selector.
|
56 | * @example [href="#"]
|
57 | * @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Attribute_selectors
|
58 | */
|
59 | attributes?: {
|
60 | /**
|
61 | * Attribute comparison operator list.
|
62 | * @example ['=', '~=', '|=', '^=', '$=', '*=']
|
63 | * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#syntax
|
64 | */
|
65 | operators?: string[];
|
66 | /**
|
67 | * How to handle unknown case sensitivity modifiers.
|
68 | * `accept` - still parse.
|
69 | * `reject` - throw an error.
|
70 | */
|
71 | unknownCaseSensitivityModifiers?: 'accept' | 'reject';
|
72 | /**
|
73 | * List of pre-defined case sensitivity modifiers.
|
74 | * @example ['i', 'I', 's', 'S']
|
75 | * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#syntax
|
76 | */
|
77 | caseSensitivityModifiers?: string[];
|
78 | } | false;
|
79 | /**
|
80 | * CSS Pseudo-elements.
|
81 | * @example ::before
|
82 | * @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements
|
83 | */
|
84 | pseudoElements?: {
|
85 | /**
|
86 | * How to handle unknown pseudo-elements.
|
87 | * `accept` - still parse.
|
88 | * `reject` - throw an error.
|
89 | */
|
90 | unknown?: 'accept' | 'reject';
|
91 | /**
|
92 | * In the past pseudo selements were defined starting with a single colon.
|
93 | * Later this notation changed to double colon.
|
94 | */
|
95 | notation?: 'singleColon' | 'doubleColon' | 'both';
|
96 | /**
|
97 | * List of predefined pseudo-elements. If string array is specified, the pseudo-elements are assumed to be
|
98 | * NoArgument.
|
99 | * @example ['before', 'after']
|
100 | * @example {NoArgument: ['before', 'after'], String: ['highlight'], Selector: ['slotted']}
|
101 | */
|
102 | definitions?: string[] | {
|
103 | [K in PseudoElementType]?: string[];
|
104 | };
|
105 | } | false;
|
106 | /**
|
107 | * CSS Pseudo-classes.
|
108 | * @example :nth-child(2n+1)
|
109 | * @see https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements
|
110 | */
|
111 | pseudoClasses?: {
|
112 | /**
|
113 | * How to handle unknown pseudo-classes.
|
114 | * `accept` - still parse.
|
115 | * `reject` - throw an error.
|
116 | */
|
117 | unknown?: 'accept' | 'reject';
|
118 | /**
|
119 | * Predefined pseudo-classes.
|
120 | * @example {NoArgument: ['first-child'], Formula: ['nth-child'], String: ['dir'], Selector: ['not']}
|
121 | */
|
122 | definitions?: {
|
123 | [K in PseudoClassType]?: string[];
|
124 | };
|
125 | } | false;
|
126 | }
|
127 | interface SyntaxDefinitionXmlOptions {
|
128 | wildcard?: boolean;
|
129 | }
|
130 | export declare function getXmlOptions(param: SyntaxDefinitionXmlOptions | boolean | undefined): SyntaxDefinitionXmlOptions;
|
131 | type MergeMethod<T> = (base: T, extension: T) => T;
|
132 | export declare const extendSyntaxDefinition: MergeMethod<SyntaxDefinition>;
|
133 | export declare const cssSyntaxDefinitions: Record<CssLevel, SyntaxDefinition>;
|
134 | export {};
|