[d565449] | 1 | import Container, {
|
---|
| 2 | ContainerProps,
|
---|
| 3 | ContainerWithChildren
|
---|
| 4 | } from './container.js'
|
---|
| 5 |
|
---|
| 6 | declare namespace Rule {
|
---|
| 7 | export interface RuleRaws 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 symbols before the node. It also stores `*`
|
---|
| 15 | * and `_` symbols before the declaration (IE hack).
|
---|
| 16 | */
|
---|
| 17 | before?: string
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * The symbols between the selector and `{` for rules.
|
---|
| 21 | */
|
---|
| 22 | between?: string
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * Contains `true` if there is semicolon after rule.
|
---|
| 26 | */
|
---|
| 27 | ownSemicolon?: string
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * The rule’s selector with comments.
|
---|
| 31 | */
|
---|
| 32 | selector?: {
|
---|
| 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 |
|
---|
[0c6b92a] | 43 | export type RuleProps = {
|
---|
[d565449] | 44 | /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
---|
| 45 | raws?: RuleRaws
|
---|
[0c6b92a] | 46 | } & (
|
---|
| 47 | | {
|
---|
| 48 | /** Selector or selectors of the rule. */
|
---|
| 49 | selector: string
|
---|
| 50 | selectors?: never
|
---|
| 51 | }
|
---|
| 52 | | {
|
---|
| 53 | selector?: never
|
---|
| 54 | /** Selectors of the rule represented as an array of strings. */
|
---|
| 55 | selectors: readonly string[]
|
---|
| 56 | }
|
---|
| 57 | ) & ContainerProps
|
---|
[d565449] | 58 |
|
---|
| 59 | // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
---|
| 60 | export { Rule_ as default }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | /**
|
---|
| 64 | * Represents a CSS rule: a selector followed by a declaration block.
|
---|
| 65 | *
|
---|
| 66 | * ```js
|
---|
| 67 | * Once (root, { Rule }) {
|
---|
| 68 | * let a = new Rule({ selector: 'a' })
|
---|
| 69 | * a.append(…)
|
---|
| 70 | * root.append(a)
|
---|
| 71 | * }
|
---|
| 72 | * ```
|
---|
| 73 | *
|
---|
| 74 | * ```js
|
---|
| 75 | * const root = postcss.parse('a{}')
|
---|
| 76 | * const rule = root.first
|
---|
| 77 | * rule.type //=> 'rule'
|
---|
| 78 | * rule.toString() //=> 'a{}'
|
---|
| 79 | * ```
|
---|
| 80 | */
|
---|
| 81 | declare class Rule_ extends Container {
|
---|
| 82 | nodes: NonNullable<Container['nodes']>
|
---|
| 83 | parent: ContainerWithChildren | undefined
|
---|
| 84 | raws: Rule.RuleRaws
|
---|
[0c6b92a] | 85 | type: 'rule'
|
---|
| 86 | constructor(defaults?: Rule.RuleProps)
|
---|
| 87 |
|
---|
| 88 | assign(overrides: object | Rule.RuleProps): this
|
---|
| 89 | clone(overrides?: Partial<Rule.RuleProps>): this
|
---|
| 90 |
|
---|
| 91 | cloneAfter(overrides?: Partial<Rule.RuleProps>): this
|
---|
| 92 |
|
---|
| 93 | cloneBefore(overrides?: Partial<Rule.RuleProps>): this
|
---|
[d565449] | 94 | /**
|
---|
| 95 | * The rule’s full selector represented as a string.
|
---|
| 96 | *
|
---|
| 97 | * ```js
|
---|
| 98 | * const root = postcss.parse('a, b { }')
|
---|
| 99 | * const rule = root.first
|
---|
| 100 | * rule.selector //=> 'a, b'
|
---|
| 101 | * ```
|
---|
| 102 | */
|
---|
| 103 | get selector(): string
|
---|
[0c6b92a] | 104 | set selector(value: string)
|
---|
[d565449] | 105 | /**
|
---|
| 106 | * An array containing the rule’s individual selectors.
|
---|
| 107 | * Groups of selectors are split at commas.
|
---|
| 108 | *
|
---|
| 109 | * ```js
|
---|
| 110 | * const root = postcss.parse('a, b { }')
|
---|
| 111 | * const rule = root.first
|
---|
| 112 | *
|
---|
| 113 | * rule.selector //=> 'a, b'
|
---|
| 114 | * rule.selectors //=> ['a', 'b']
|
---|
| 115 | *
|
---|
| 116 | * rule.selectors = ['a', 'strong']
|
---|
| 117 | * rule.selector //=> 'a, strong'
|
---|
| 118 | * ```
|
---|
| 119 | */
|
---|
| 120 | get selectors(): string[]
|
---|
[0c6b92a] | 121 | set selectors(values: string[])
|
---|
[d565449] | 122 | }
|
---|
| 123 |
|
---|
| 124 | declare class Rule extends Rule_ {}
|
---|
| 125 |
|
---|
| 126 | export = Rule
|
---|