source: node_modules/postcss/lib/rule.d.ts@ 505f39a

Last change on this file since 505f39a was 2058e5c, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Working / before login

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[2058e5c]1import Container, {
2 ContainerProps,
3 ContainerWithChildren
4} from './container.js'
5
6declare 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 the text of the semicolon after this 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
43 export type RuleProps = {
44 /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
45 raws?: RuleRaws
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
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 */
81declare class Rule_ extends Container {
82 nodes: NonNullable<Container['nodes']>
83 parent: ContainerWithChildren | undefined
84 raws: Rule.RuleRaws
85 type: 'rule'
86 /**
87 * The rule’s full selector represented as a string.
88 *
89 * ```js
90 * const root = postcss.parse('a, b { }')
91 * const rule = root.first
92 * rule.selector //=> 'a, b'
93 * ```
94 */
95 get selector(): string
96
97 set selector(value: string)
98 /**
99 * An array containing the rule’s individual selectors.
100 * Groups of selectors are split at commas.
101 *
102 * ```js
103 * const root = postcss.parse('a, b { }')
104 * const rule = root.first
105 *
106 * rule.selector //=> 'a, b'
107 * rule.selectors //=> ['a', 'b']
108 *
109 * rule.selectors = ['a', 'strong']
110 * rule.selector //=> 'a, strong'
111 * ```
112 */
113 get selectors(): string[]
114
115 set selectors(values: string[])
116
117 constructor(defaults?: Rule.RuleProps)
118 assign(overrides: object | Rule.RuleProps): this
119 clone(overrides?: Partial<Rule.RuleProps>): this
120 cloneAfter(overrides?: Partial<Rule.RuleProps>): this
121 cloneBefore(overrides?: Partial<Rule.RuleProps>): this
122}
123
124declare class Rule extends Rule_ {}
125
126export = Rule
Note: See TracBrowser for help on using the repository browser.