2023-07-24 03:13:08 +00:00
|
|
|
|
import Container, { ContainerProps } from './container.js'
|
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
declare namespace AtRule {
|
|
|
|
|
export interface AtRuleRaws extends Record<string, unknown> {
|
|
|
|
|
/**
|
|
|
|
|
* The space symbols after the last child of the node to the end of the node.
|
|
|
|
|
*/
|
|
|
|
|
after?: string
|
2023-07-24 03:13:08 +00:00
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* The space between the at-rule name and its parameters.
|
|
|
|
|
*/
|
|
|
|
|
afterName?: string
|
2023-07-24 03:13:08 +00:00
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* The space symbols before the node. It also stores `*`
|
|
|
|
|
* and `_` symbols before the declaration (IE hack).
|
|
|
|
|
*/
|
|
|
|
|
before?: string
|
2023-07-24 03:13:08 +00:00
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* The symbols between the last parameter and `{` for rules.
|
|
|
|
|
*/
|
|
|
|
|
between?: string
|
2023-07-24 03:13:08 +00:00
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* The rule’s selector with comments.
|
|
|
|
|
*/
|
|
|
|
|
params?: {
|
|
|
|
|
raw: string
|
|
|
|
|
value: string
|
|
|
|
|
}
|
2023-07-24 03:13:08 +00:00
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* Contains `true` if the last child has an (optional) semicolon.
|
|
|
|
|
*/
|
|
|
|
|
semicolon?: boolean
|
2023-07-24 03:13:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
export interface AtRuleProps extends ContainerProps {
|
|
|
|
|
/** Name of the at-rule. */
|
|
|
|
|
name: string
|
|
|
|
|
/** Parameters following the name of the at-rule. */
|
|
|
|
|
params?: number | string
|
|
|
|
|
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
|
|
|
|
raws?: AtRuleRaws
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
|
|
|
export { AtRule_ as default }
|
2023-07-24 03:13:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Represents an at-rule.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* Once (root, { AtRule }) {
|
|
|
|
|
* let media = new AtRule({ name: 'media', params: 'print' })
|
|
|
|
|
* media.append(…)
|
|
|
|
|
* root.append(media)
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*
|
2023-09-06 01:51:55 +00:00
|
|
|
|
* If it’s followed in the CSS by a `{}` block, this node will have
|
2023-07-24 03:13:08 +00:00
|
|
|
|
* a nodes property representing its children.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* const root = postcss.parse('@charset "UTF-8"; @media print {}')
|
|
|
|
|
*
|
|
|
|
|
* const charset = root.first
|
|
|
|
|
* charset.type //=> 'atrule'
|
|
|
|
|
* charset.nodes //=> undefined
|
|
|
|
|
*
|
|
|
|
|
* const media = root.last
|
|
|
|
|
* media.nodes //=> []
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
2023-09-06 01:51:55 +00:00
|
|
|
|
declare class AtRule_ extends Container {
|
2023-07-24 03:13:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* The at-rule’s name immediately follows the `@`.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* const root = postcss.parse('@media print {}')
|
|
|
|
|
* media.name //=> 'media'
|
|
|
|
|
* const media = root.first
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
|
|
|
|
name: string
|
|
|
|
|
/**
|
|
|
|
|
* The at-rule’s parameters, the values that follow the at-rule’s name
|
2023-09-06 01:51:55 +00:00
|
|
|
|
* but precede any `{}` block.
|
2023-07-24 03:13:08 +00:00
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* const root = postcss.parse('@media print, screen {}')
|
|
|
|
|
* const media = root.first
|
|
|
|
|
* media.params //=> 'print, screen'
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
|
|
|
|
params: string
|
2023-09-06 01:51:55 +00:00
|
|
|
|
parent: Container | undefined
|
|
|
|
|
|
|
|
|
|
raws: AtRule.AtRuleRaws
|
|
|
|
|
|
|
|
|
|
type: 'atrule'
|
2023-07-24 03:13:08 +00:00
|
|
|
|
|
2023-09-06 01:51:55 +00:00
|
|
|
|
constructor(defaults?: AtRule.AtRuleProps)
|
|
|
|
|
assign(overrides: AtRule.AtRuleProps | object): this
|
|
|
|
|
clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
|
|
|
|
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
|
|
|
|
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
2023-07-24 03:13:08 +00:00
|
|
|
|
}
|
2023-09-06 01:51:55 +00:00
|
|
|
|
|
|
|
|
|
declare class AtRule extends AtRule_ {}
|
|
|
|
|
|
|
|
|
|
export = AtRule
|