1 | import Container, { ContainerProps } from './container.js'
|
2 |
|
3 | declare namespace Rule {
|
4 | export interface RuleRaws extends Record<string, unknown> {
|
5 | /**
|
6 | * The space symbols after the last child of the node to the end of the node.
|
7 | */
|
8 | after?: string
|
9 |
|
10 | /**
|
11 | * The space symbols before the node. It also stores `*`
|
12 | * and `_` symbols before the declaration (IE hack).
|
13 | */
|
14 | before?: string
|
15 |
|
16 | /**
|
17 | * The symbols between the selector and `{` for rules.
|
18 | */
|
19 | between?: string
|
20 |
|
21 | /**
|
22 | * Contains `true` if there is semicolon after rule.
|
23 | */
|
24 | ownSemicolon?: string
|
25 |
|
26 | /**
|
27 | * The rule’s selector with comments.
|
28 | */
|
29 | selector?: {
|
30 | raw: string
|
31 | value: string
|
32 | }
|
33 |
|
34 | /**
|
35 | * Contains `true` if the last child has an (optional) semicolon.
|
36 | */
|
37 | semicolon?: boolean
|
38 | }
|
39 |
|
40 | export interface RuleProps extends ContainerProps {
|
41 | /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
42 | raws?: RuleRaws
|
43 | /** Selector or selectors of the rule. */
|
44 | selector?: string
|
45 | /** Selectors of the rule represented as an array of strings. */
|
46 | selectors?: string[]
|
47 | }
|
48 |
|
49 | // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
50 | export { Rule_ as default }
|
51 | }
|
52 |
|
53 | /**
|
54 | * Represents a CSS rule: a selector followed by a declaration block.
|
55 | *
|
56 | * ```js
|
57 | * Once (root, { Rule }) {
|
58 | * let a = new Rule({ selector: 'a' })
|
59 | * a.append(…)
|
60 | * root.append(a)
|
61 | * }
|
62 | * ```
|
63 | *
|
64 | * ```js
|
65 | * const root = postcss.parse('a{}')
|
66 | * const rule = root.first
|
67 | * rule.type //=> 'rule'
|
68 | * rule.toString() //=> 'a{}'
|
69 | * ```
|
70 | */
|
71 | declare class Rule_ extends Container {
|
72 | parent: Container | undefined
|
73 | raws: Rule.RuleRaws
|
74 | /**
|
75 | * The rule’s full selector represented as a string.
|
76 | *
|
77 | * ```js
|
78 | * const root = postcss.parse('a, b { }')
|
79 | * const rule = root.first
|
80 | * rule.selector //=> 'a, b'
|
81 | * ```
|
82 | */
|
83 | selector: string
|
84 |
|
85 | /**
|
86 | * An array containing the rule’s individual selectors.
|
87 | * Groups of selectors are split at commas.
|
88 | *
|
89 | * ```js
|
90 | * const root = postcss.parse('a, b { }')
|
91 | * const rule = root.first
|
92 | *
|
93 | * rule.selector //=> 'a, b'
|
94 | * rule.selectors //=> ['a', 'b']
|
95 | *
|
96 | * rule.selectors = ['a', 'strong']
|
97 | * rule.selector //=> 'a, strong'
|
98 | * ```
|
99 | */
|
100 | selectors: string[]
|
101 |
|
102 | type: 'rule'
|
103 |
|
104 | constructor(defaults?: Rule.RuleProps)
|
105 | assign(overrides: object | Rule.RuleProps): this
|
106 | clone(overrides?: Partial<Rule.RuleProps>): Rule
|
107 | cloneAfter(overrides?: Partial<Rule.RuleProps>): Rule
|
108 | cloneBefore(overrides?: Partial<Rule.RuleProps>): Rule
|
109 | }
|
110 |
|
111 | declare class Rule extends Rule_ {}
|
112 |
|
113 | export = Rule
|