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 | * The at-rule’s name immediately follows the `@`.
|
---|
84 | *
|
---|
85 | * ```js
|
---|
86 | * const root = postcss.parse('@media print {}')
|
---|
87 | * const media = root.first
|
---|
88 | * media.name //=> 'media'
|
---|
89 | * ```
|
---|
90 | */
|
---|
91 | get name(): string
|
---|
92 | set name(value: string)
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * An array containing the layer’s children.
|
---|
96 | *
|
---|
97 | * ```js
|
---|
98 | * const root = postcss.parse('@layer example { a { color: black } }')
|
---|
99 | * const layer = root.first
|
---|
100 | * layer.nodes.length //=> 1
|
---|
101 | * layer.nodes[0].selector //=> 'a'
|
---|
102 | * ```
|
---|
103 | *
|
---|
104 | * Can be `undefinded` if the at-rule has no body.
|
---|
105 | *
|
---|
106 | * ```js
|
---|
107 | * const root = postcss.parse('@layer a, b, c;')
|
---|
108 | * const layer = root.first
|
---|
109 | * layer.nodes //=> undefined
|
---|
110 | * ```
|
---|
111 | */
|
---|
112 | nodes: Container['nodes']
|
---|
113 | /**
|
---|
114 | * The at-rule’s parameters, the values that follow the at-rule’s name
|
---|
115 | * but precede any `{}` block.
|
---|
116 | *
|
---|
117 | * ```js
|
---|
118 | * const root = postcss.parse('@media print, screen {}')
|
---|
119 | * const media = root.first
|
---|
120 | * media.params //=> 'print, screen'
|
---|
121 | * ```
|
---|
122 | */
|
---|
123 | get params(): string
|
---|
124 | set params(value: string)
|
---|
125 | parent: ContainerWithChildren | undefined
|
---|
126 |
|
---|
127 | raws: AtRule.AtRuleRaws
|
---|
128 |
|
---|
129 | type: 'atrule'
|
---|
130 |
|
---|
131 | constructor(defaults?: AtRule.AtRuleProps)
|
---|
132 | assign(overrides: AtRule.AtRuleProps | object): this
|
---|
133 | clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
---|
134 | cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
---|
135 | cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
---|
136 | }
|
---|
137 |
|
---|
138 | declare class AtRule extends AtRule_ {}
|
---|
139 |
|
---|
140 | export = AtRule
|
---|