| 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'] | undefined
|
|---|
| 101 | parent: ContainerWithChildren | undefined
|
|---|
| 102 |
|
|---|
| 103 | raws: AtRule.AtRuleRaws
|
|---|
| 104 | type: 'atrule'
|
|---|
| 105 | /**
|
|---|
| 106 | * The at-rule’s name immediately follows the `@`.
|
|---|
| 107 | *
|
|---|
| 108 | * ```js
|
|---|
| 109 | * const root = postcss.parse('@media print {}')
|
|---|
| 110 | * const media = root.first
|
|---|
| 111 | * media.name //=> 'media'
|
|---|
| 112 | * ```
|
|---|
| 113 | */
|
|---|
| 114 | get name(): string
|
|---|
| 115 | set name(value: string)
|
|---|
| 116 |
|
|---|
| 117 | /**
|
|---|
| 118 | * The at-rule’s parameters, the values that follow the at-rule’s name
|
|---|
| 119 | * but precede any `{}` block.
|
|---|
| 120 | *
|
|---|
| 121 | * ```js
|
|---|
| 122 | * const root = postcss.parse('@media print, screen {}')
|
|---|
| 123 | * const media = root.first
|
|---|
| 124 | * media.params //=> 'print, screen'
|
|---|
| 125 | * ```
|
|---|
| 126 | */
|
|---|
| 127 | get params(): string
|
|---|
| 128 |
|
|---|
| 129 | set params(value: string)
|
|---|
| 130 |
|
|---|
| 131 | constructor(defaults?: AtRule.AtRuleProps)
|
|---|
| 132 | assign(overrides: AtRule.AtRuleProps | object): this
|
|---|
| 133 | clone(overrides?: Partial<AtRule.AtRuleProps>): this
|
|---|
| 134 | cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
|
|---|
| 135 | cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | declare class AtRule extends AtRule_ {}
|
|---|
| 139 |
|
|---|
| 140 | export = AtRule
|
|---|