1 | import Container, {
|
2 | ContainerProps,
|
3 | ContainerWithChildren
|
4 | } from './container.js'
|
5 |
|
6 | declare namespace AtRule {
|
7 | export interface AtRuleRaws extends Record<string, unknown> {
|
8 | /**
|
9 | * The space symbols after the last child of the node to the end of the node.
|
10 | */
|
11 | after?: string
|
12 |
|
13 | /**
|
14 | * The space between the at-rule name and its parameters.
|
15 | */
|
16 | afterName?: string
|
17 |
|
18 | /**
|
19 | * The space symbols before the node. It also stores `*`
|
20 | * and `_` symbols before the declaration (IE hack).
|
21 | */
|
22 | before?: string
|
23 |
|
24 | /**
|
25 | * The symbols between the last parameter and `{` for rules.
|
26 | */
|
27 | between?: string
|
28 |
|
29 | /**
|
30 | * The rule’s selector with comments.
|
31 | */
|
32 | params?: {
|
33 | raw: string
|
34 | value: string
|
35 | }
|
36 |
|
37 | /**
|
38 | * Contains `true` if the last child has an (optional) semicolon.
|
39 | */
|
40 | semicolon?: boolean
|
41 | }
|
42 |
|
43 | export interface AtRuleProps extends ContainerProps {
|
44 | /** Name of the at-rule. */
|
45 | name: string
|
46 | /** Parameters following the name of the at-rule. */
|
47 | params?: number | string
|
48 | /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
49 | raws?: AtRuleRaws
|
50 | }
|
51 |
|
52 | // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
53 | export { AtRule_ as default }
|
54 | }
|
55 |
|
56 | /**
|
57 | * Represents an at-rule.
|
58 | *
|
59 | * ```js
|
60 | * Once (root, { AtRule }) {
|
61 | * let media = new AtRule({ name: 'media', params: 'print' })
|
62 | * media.append(…)
|
63 | * root.append(media)
|
64 | * }
|
65 | * ```
|
66 | *
|
67 | * If it’s followed in the CSS by a `{}` block, this node will have
|
68 | * a nodes property representing its children.
|
69 | *
|
70 | * ```js
|
71 | * const root = postcss.parse('@charset "UTF-8"; @media print {}')
|
72 | *
|
73 | * const charset = root.first
|
74 | * charset.type //=> 'atrule'
|
75 | * charset.nodes //=> undefined
|
76 | *
|
77 | * const media = root.last
|
78 | * media.nodes //=> []
|
79 | * ```
|
80 | */
|
81 | declare class AtRule_ extends Container {
|
82 | /**
|
83 | * An array containing the layer’s children.
|
84 | *
|
85 | * ```js
|
86 | * const root = postcss.parse('@layer example { a { color: black } }')
|
87 | * const layer = root.first
|
88 | * layer.nodes.length //=> 1
|
89 | * layer.nodes[0].selector //=> 'a'
|
90 | * ```
|
91 | *
|
92 | * Can be `undefinded` if the at-rule has no body.
|
93 | *
|
94 | * ```js
|
95 | * const root = postcss.parse('@layer a, b, c;')
|
96 | * const layer = root.first
|
97 | * layer.nodes //=> undefined
|
98 | * ```
|
99 | */
|
100 | nodes: Container['nodes']
|
101 | parent: ContainerWithChildren | undefined
|
102 |
|
103 | raws: AtRule.AtRuleRaws
|
104 | type: 'atrule'
|
105 | constructor(defaults?: AtRule.AtRuleProps)
|
106 | assign(overrides: AtRule.AtRuleProps | object): this
|
107 |
|
108 | clone(overrides?: Partial<AtRule.AtRuleProps>): this
|
109 |
|
110 | cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
|
111 |
|
112 | cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
|
113 | /**
|
114 | * The at-rule’s name immediately follows the `@`.
|
115 | *
|
116 | * ```js
|
117 | * const root = postcss.parse(')
print {}' |
118 | * const media = root.first
|
119 | * media.name //=> 'media'
|
120 | * ```
|
121 | */
|
122 | get name(): string
|
123 | set name(value: string)
|
124 | /**
|
125 | * The at-rule’s parameters, the values that follow the at-rule’s name
|
126 | * but precede any `{}` block.
|
127 | *
|
128 | * ```js
|
129 | * const root = postcss.parse('@media print, screen {}')
|
130 | * const media = root.first
|
131 | * media.params //=> 'print, screen'
|
132 | * ```
|
133 | */
|
134 | get params(): string
|
135 | set params(value: string)
|
136 | }
|
137 |
|
138 | declare class AtRule extends AtRule_ {}
|
139 |
|
140 | export = AtRule
|
141 |
|
\ | No newline at end of file |