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