This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.d.ts
162 lines (135 loc) · 3.76 KB
/
plugin.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/// <reference path="base.d.ts" />
/// <reference path="features.d.ts" />
/// <reference path="theme.d.ts" />
declare namespace Tailwind {
type ValueType =
| "any"
| "color"
| "url"
| "image"
| "length"
| "percentage"
| "position"
| "lookup"
| "generic-name"
| "family-name"
| "number"
| "line-width"
| "absolute-size"
| "relative-size"
| "shadow"
interface AddOption {
respectPrefix?: boolean
respectImportant?: boolean
}
interface MatchOption {
values?: ConfigObject
type?: ValueType | ValueType[]
supportsNegativeValues?: boolean
filterDefault?: boolean
respectPrefix?: boolean
respectImportant?: boolean
}
interface VariantFunc {
(options: {
container: import("postcss").Root
separator: string
// Private API
wrap?(node: import("postcss").AtRule): void
format?(selectorFormat: string): void
modifySelectors?(
modifierFunction: (payload: {
get className(): string
selector: string
}) => string,
): import("postcss").Root
}): string | string[]
}
interface MatchVariantFunc {
(options: { value: string }): string | string[]
}
interface UserPluginOptions {
addDefaults(
group: string,
declarations: Record<string, string | string[]>,
): void
/** Register new base styles. */
addBase(bases: Styles | Styles[]): void
/** Register new utilities. */
addUtilities(utilities: Styles | Styles[], options?: AddOption): void
/** Register new components. */
addComponents(components: Styles | Styles[], options?: AddOption): void
/** Register new utilities. */
matchUtilities(
utilities: Record<string, (value: CSSValue) => Styles | Styles[]>,
options?: MatchOption,
): void
/** Register new components. */
matchComponents(
components: Record<string, (value: CSSValue) => Styles | Styles[]>,
options?: MatchOption,
): void
/** Register a custom variant. */
addVariant(
variantName: string,
variantFunc: string | VariantFunc | Array<string | VariantFunc>,
options?: {},
): void
/**
* Register an arbitrary variant.
*
* `config.experimental.matchVariant = true`
* @experimental
*/
matchVariant(
variantName: string,
variantFunc: MatchVariantFunc,
options?: { values?: ConfigObject },
): void
/** Look up values in the user's theme configuration. */
theme: ResolvePath
/** Look up values in the user's Tailwind configuration. */
config: ResolvePath
/** Escape strings meant to be used in class names. */
e(classname: string): string
/** Apply the user's configured prefix to parts of a selector. */
prefix(selector: string): string
/** @deprecated */
variants(corePlugin: string): string[]
// Check if a core plugin is enabled.
corePlugins(feature: keyof CorePluginFeatures): boolean
/** low-level manipulation with PostCSS directly */
postcss: import("postcss").Postcss
}
interface UserPluginFunction {
(options: UserPluginOptions): void
}
interface UserPluginObject {
handler?: UserPluginFunction
config?: ConfigJS
name?: string
[key: string | symbol]: ConfigEntry
}
interface UserPluginFunctionWithOption<Options = unknown> {
(options?: Options): UserPluginObject
}
type Plugin = UserPluginObject | UserPluginFunction
interface PluginFunction<Options> {
(options: Options): UserPluginFunction
}
interface ConfigFunction<Options> {
(options: Options): ConfigJS
}
interface CreatePluginWithOptions {
/** Create a tailwind plugin with options. */
<Options = unknown>(
pluginFunction: PluginFunction<Options>,
configFunction?: ConfigFunction<Options>,
): UserPluginFunctionWithOption<Options>
}
interface CreatePlugin {
(handler: UserPluginFunction, config?: ConfigJS): Plugin
/** Create a tailwind plugin with options. */
withOptions: CreatePluginWithOptions
}
}