source: node_modules/postcss/lib/declaration.d.ts@ 2058e5c

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

Working / before login

  • Property mode set to 100644
File size: 3.8 KB
Line 
1import { ContainerWithChildren } from './container.js'
2import Node from './node.js'
3
4declare namespace Declaration {
5 export interface DeclarationRaws extends Record<string, unknown> {
6 /**
7 * The space symbols before the node. It also stores `*`
8 * and `_` symbols before the declaration (IE hack).
9 */
10 before?: string
11
12 /**
13 * The symbols between the property and value for declarations.
14 */
15 between?: string
16
17 /**
18 * The content of the important statement, if it is not just `!important`.
19 */
20 important?: string
21
22 /**
23 * Declaration value with comments.
24 */
25 value?: {
26 raw: string
27 value: string
28 }
29 }
30
31 export interface DeclarationProps {
32 /** Whether the declaration has an `!important` annotation. */
33 important?: boolean
34 /** Name of the declaration. */
35 prop: string
36 /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
37 raws?: DeclarationRaws
38 /** Value of the declaration. */
39 value: string
40 }
41
42 // eslint-disable-next-line @typescript-eslint/no-use-before-define
43 export { Declaration_ as default }
44}
45
46/**
47 * It represents a class that handles
48 * [CSS declarations](https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax#css_declarations)
49 *
50 * ```js
51 * Once (root, { Declaration }) {
52 * const color = new Declaration({ prop: 'color', value: 'black' })
53 * root.append(color)
54 * }
55 * ```
56 *
57 * ```js
58 * const root = postcss.parse('a { color: black }')
59 * const decl = root.first?.first
60 *
61 * decl.type //=> 'decl'
62 * decl.toString() //=> ' color: black'
63 * ```
64 */
65declare class Declaration_ extends Node {
66 parent: ContainerWithChildren | undefined
67 raws: Declaration.DeclarationRaws
68
69 type: 'decl'
70
71 /**
72 * It represents a specificity of the declaration.
73 *
74 * If true, the CSS declaration will have an
75 * [important](https://developer.mozilla.org/en-US/docs/Web/CSS/important)
76 * specifier.
77 *
78 * ```js
79 * const root = postcss.parse('a { color: black !important; color: red }')
80 *
81 * root.first.first.important //=> true
82 * root.first.last.important //=> undefined
83 * ```
84 */
85 get important(): boolean
86 set important(value: boolean)
87
88 /**
89 * The property name for a CSS declaration.
90 *
91 * ```js
92 * const root = postcss.parse('a { color: black }')
93 * const decl = root.first.first
94 *
95 * decl.prop //=> 'color'
96 * ```
97 */
98 get prop(): string
99
100 set prop(value: string)
101
102 /**
103 * The property value for a CSS declaration.
104 *
105 * Any CSS comments inside the value string will be filtered out.
106 * CSS comments present in the source value will be available in
107 * the `raws` property.
108 *
109 * Assigning new `value` would ignore the comments in `raws`
110 * property while compiling node to string.
111 *
112 * ```js
113 * const root = postcss.parse('a { color: black }')
114 * const decl = root.first.first
115 *
116 * decl.value //=> 'black'
117 * ```
118 */
119 get value(): string
120 set value(value: string)
121
122 /**
123 * It represents a getter that returns `true` if a declaration starts with
124 * `--` or `$`, which are used to declare variables in CSS and SASS/SCSS.
125 *
126 * ```js
127 * const root = postcss.parse(':root { --one: 1 }')
128 * const one = root.first.first
129 *
130 * one.variable //=> true
131 * ```
132 *
133 * ```js
134 * const root = postcss.parse('$one: 1')
135 * const one = root.first
136 *
137 * one.variable //=> true
138 * ```
139 */
140 get variable(): boolean
141 constructor(defaults?: Declaration.DeclarationProps)
142
143 assign(overrides: Declaration.DeclarationProps | object): this
144 clone(overrides?: Partial<Declaration.DeclarationProps>): this
145 cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
146 cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
147}
148
149declare class Declaration extends Declaration_ {}
150
151export = Declaration
Note: See TracBrowser for help on using the repository browser.