UNPKG

2.82 kBTypeScriptView Raw
1import Container, { ContainerProps } from './container.js'
2
3declare namespace AtRule {
4 export interface AtRuleRaws 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 between the at-rule name and its parameters.
12 */
13 afterName?: string
14
15 /**
16 * The space symbols before the node. It also stores `*`
17 * and `_` symbols before the declaration (IE hack).
18 */
19 before?: string
20
21 /**
22 * The symbols between the last parameter and `{` for rules.
23 */
24 between?: string
25
26 /**
27 * The rule’s selector with comments.
28 */
29 params?: {
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 AtRuleProps extends ContainerProps {
41 /** Name of the at-rule. */
42 name: string
43 /** Parameters following the name of the at-rule. */
44 params?: number | string
45 /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
46 raws?: AtRuleRaws
47 }
48
49 // eslint-disable-next-line @typescript-eslint/no-use-before-define
50 export { AtRule_ as default }
51}
52
53/**
54 * Represents an at-rule.
55 *
56 * ```js
57 * Once (root, { AtRule }) {
58 * let media = new AtRule({ name: 'media', params: 'print' })
59 * media.append(…)
60 * root.append(media)
61 * }
62 * ```
63 *
64 * If it’s followed in the CSS by a `{}` block, this node will have
65 * a nodes property representing its children.
66 *
67 * ```js
68 * const root = postcss.parse('@charset "UTF-8"; @media print {}')
69 *
70 * const charset = root.first
71 * charset.type //=> 'atrule'
72 * charset.nodes //=> undefined
73 *
74 * const media = root.last
75 * media.nodes //=> []
76 * ```
77 */
78declare class AtRule_ extends Container {
79 /**
80 * The at-rule’s name immediately follows the `@`.
81 *
82 * ```js
83 * const root = postcss.parse('@media print {}')
84 * media.name //=> 'media'
85 * const media = root.first
86 * ```
87 */
88 name: string
89 /**
90 * The at-rule’s parameters, the values that follow the at-rule’s name
91 * but precede any `{}` block.
92 *
93 * ```js
94 * const root = postcss.parse('@media print, screen {}')
95 * const media = root.first
96 * media.params //=> 'print, screen'
97 * ```
98 */
99 params: string
100 parent: Container | undefined
101
102 raws: AtRule.AtRuleRaws
103
104 type: 'atrule'
105
106 constructor(defaults?: AtRule.AtRuleProps)
107 assign(overrides: AtRule.AtRuleProps | object): this
108 clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule
109 cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule
110 cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule
111}
112
113declare class AtRule extends AtRule_ {}
114
115export = AtRule