@windi-ui/core 0.7.1 → 0.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +198 -0
- package/dist/badge-B-3Z5qKd.mjs +54 -0
- package/dist/badge-DP_7SF0i.cjs +71 -0
- package/dist/components.cjs +5 -58
- package/dist/components.d.cts +3 -9
- package/dist/components.d.mts +3 -9
- package/dist/components.mjs +1 -54
- package/dist/index.cjs +744 -661
- package/dist/index.d.cts +12 -45
- package/dist/index.d.mts +12 -45
- package/dist/index.mjs +742 -660
- package/dist/types-DKL2Gqrn.d.mts +258 -0
- package/dist/vars-BQT8iude.d.cts +258 -0
- package/package.json +10 -12
- package/dist/components.d.ts +0 -11
- package/dist/index.d.ts +0 -46
- package/dist/shared/core.BBBw5V2R.d.cts +0 -182
- package/dist/shared/core.BBBw5V2R.d.mts +0 -182
- package/dist/shared/core.BBBw5V2R.d.ts +0 -182
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { AdvancedPseudos, AtRule, AtRules, DataType, Properties as Properties$1, Property, PropertyValue, Pseudos, SimplePseudos } from "csstype";
|
|
2
|
+
declare namespace css_d_exports {
|
|
3
|
+
export { AdvancedPseudos, AtRule, AtRules, DataType, ExpandedPseudos, Properties, Property, PropertyValue, Pseudos, Rules, SimplePseudos };
|
|
4
|
+
}
|
|
5
|
+
type Expand<T, TKey extends string | number | symbol = string, TValue = any> = T & Record<TKey, TValue>;
|
|
6
|
+
declare module 'csstype' {
|
|
7
|
+
interface Properties<TLength, TTime> {
|
|
8
|
+
[key: string]: string | number | Properties<TLength, TTime>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
type Properties = Properties$1<string>;
|
|
12
|
+
type Rules = Record<string, Properties>;
|
|
13
|
+
type ExpandedPseudos = Expand<Partial<Record<Pseudos, Properties>>, string, Properties>;
|
|
14
|
+
type FontSize = string | [string, string | {
|
|
15
|
+
lineHeight?: string;
|
|
16
|
+
letterSpacing?: string;
|
|
17
|
+
fontWeight?: string;
|
|
18
|
+
}];
|
|
19
|
+
interface ThemeProvider {
|
|
20
|
+
colors(): Record<string, string>;
|
|
21
|
+
colors(name: string): string | Record<string, string>;
|
|
22
|
+
spacing(name: string): string;
|
|
23
|
+
fontSize(name: string): FontSize;
|
|
24
|
+
applyTextColor(value: string, target: Properties, alpha?: string): void;
|
|
25
|
+
applyBackgroundColor(value: string, target: Properties, alpha?: string): void;
|
|
26
|
+
applyBorderColor(value: string, target: Properties, alpha?: string): void;
|
|
27
|
+
colorValue(value: string, alpha?: number | string): string;
|
|
28
|
+
/** Converts a color to the form `colors()` returns them in. Left out, a color is used as it is written. */
|
|
29
|
+
toColor?(value: string): string;
|
|
30
|
+
}
|
|
31
|
+
type VariantVars = Record<CSSVarName<'v'>, string>;
|
|
32
|
+
type VariantPropValue = CSSVarValue<'c'> | CSSVarValue<'v'>;
|
|
33
|
+
type OpacityValue = '1' | '0' | `0.${number}`;
|
|
34
|
+
interface VariantProperties {
|
|
35
|
+
'bg': VariantPropValue;
|
|
36
|
+
'bg-soft'?: VariantPropValue;
|
|
37
|
+
'bg-muted'?: VariantPropValue;
|
|
38
|
+
'bg-accent'?: VariantPropValue;
|
|
39
|
+
'bg-opacity'?: OpacityValue;
|
|
40
|
+
'border': VariantPropValue;
|
|
41
|
+
'border-soft'?: VariantPropValue;
|
|
42
|
+
'border-muted'?: VariantPropValue;
|
|
43
|
+
'border-accent'?: VariantPropValue;
|
|
44
|
+
'border-opacity'?: OpacityValue;
|
|
45
|
+
'fg': VariantPropValue;
|
|
46
|
+
'fg-soft'?: VariantPropValue;
|
|
47
|
+
'fg-muted'?: VariantPropValue;
|
|
48
|
+
'fg-accent'?: VariantPropValue;
|
|
49
|
+
'fg-opacity'?: OpacityValue;
|
|
50
|
+
}
|
|
51
|
+
type VariantPseudos = Partial<Record<SimplePseudos, Partial<VariantProperties>>>;
|
|
52
|
+
interface Variant extends VariantProperties {
|
|
53
|
+
pseudos?: VariantPseudos;
|
|
54
|
+
dark?: Omit<Partial<Variant>, 'dark'>;
|
|
55
|
+
}
|
|
56
|
+
type VariantProperty = keyof VariantProperties | `${keyof VariantProperties}-${SimplePseudos}`;
|
|
57
|
+
type ApplyVariantMainProp = 'bg' | 'border' | 'text';
|
|
58
|
+
type ApplyVariantSubProp = 'soft' | 'muted' | 'accent' | 'default';
|
|
59
|
+
type ApplyVariantProp = ApplyVariantMainProp | `${ApplyVariantMainProp}-${Exclude<ApplyVariantSubProp, 'default'>}`;
|
|
60
|
+
type ApplyVariant = boolean | ApplyVariantProp[];
|
|
61
|
+
type ApplyVariantPseudos = Partial<Record<SimplePseudos, ApplyVariant>> | SimplePseudos[] | false;
|
|
62
|
+
interface VariantCssVars extends VariantVars {
|
|
63
|
+
'@dark'?: VariantVars;
|
|
64
|
+
}
|
|
65
|
+
interface VariantContext {
|
|
66
|
+
apply(v?: ApplyVariant, pseudos?: ApplyVariantPseudos, target?: Properties): Properties;
|
|
67
|
+
/**
|
|
68
|
+
* Outside the `universal` scope, gives every bare `var()` read of a variant variable in `css` the default
|
|
69
|
+
* variant's value, light or dark, as its fallback.
|
|
70
|
+
*/
|
|
71
|
+
withFallback<T extends Properties>(css: T): T;
|
|
72
|
+
}
|
|
73
|
+
declare class VariantsGenerator extends VarsGeneratorBase<Variant, VariantCssVars> implements VariantContext {
|
|
74
|
+
private readonly scope;
|
|
75
|
+
protected readonly items: Map<string, Variant>;
|
|
76
|
+
constructor(ctx: BuilderContext, scope?: VariantScope);
|
|
77
|
+
cssVars(name: string): VariantCssVars;
|
|
78
|
+
/** Every variable a variant can set, as `initial`: on a child it stops the parent's variant from inheriting. */
|
|
79
|
+
resetVars(): VariantVars;
|
|
80
|
+
utilCss(v: ApplyVariantMainProp, prop?: ApplyVariantSubProp, alpha?: string): Properties;
|
|
81
|
+
/**
|
|
82
|
+
* The two switches a fallback picks its light or dark value with: `var(on-light, <light>) var(on-dark, <dark>)`.
|
|
83
|
+
* The one of the current mode is not set, so its fallback is used, and the other one is empty.
|
|
84
|
+
* They inherit, so a pseudo-element is in the mode of its element, which a dark selector nested in its rule cannot tell.
|
|
85
|
+
*/
|
|
86
|
+
modeVars(): {
|
|
87
|
+
light: VariantVars;
|
|
88
|
+
dark: VariantVars;
|
|
89
|
+
};
|
|
90
|
+
withFallback<T extends Properties>(css: T): T;
|
|
91
|
+
apply(v?: ApplyVariant, pseudos?: ApplyVariantPseudos, target?: Properties): Properties;
|
|
92
|
+
private vApplyProp;
|
|
93
|
+
}
|
|
94
|
+
type SizeVars = Record<CSSVarName<'s'>, string>;
|
|
95
|
+
type SizeProperty = 'text' | `spacing-${keyof Size['spacing']}` | 'line-height';
|
|
96
|
+
type Size = {
|
|
97
|
+
spacing: {
|
|
98
|
+
'1': string;
|
|
99
|
+
'1.5': string;
|
|
100
|
+
'2': string;
|
|
101
|
+
'3': string;
|
|
102
|
+
'4': string;
|
|
103
|
+
};
|
|
104
|
+
text: FontSize;
|
|
105
|
+
};
|
|
106
|
+
declare class SizesGenerator extends VarsGeneratorBase<Size, SizeVars> {
|
|
107
|
+
protected readonly items: Map<string, Size>;
|
|
108
|
+
constructor(ctx: BuilderContext);
|
|
109
|
+
cssVars(name: string): SizeVars;
|
|
110
|
+
}
|
|
111
|
+
declare class ComponentsGenerator extends BuilderBase<IComponent, ComponentBuilderContext> {
|
|
112
|
+
protected readonly items: Map<string, IComponent>;
|
|
113
|
+
constructor(context: ComponentBuilderContext);
|
|
114
|
+
css(): Generator<Rules, void, unknown>;
|
|
115
|
+
}
|
|
116
|
+
type BuilderFunc<TFunc extends (...args: any) => void> = (...args: Parameters<TFunc>) => Builder;
|
|
117
|
+
interface Builder {
|
|
118
|
+
colorsNames: () => string[];
|
|
119
|
+
variantsNames: () => string[];
|
|
120
|
+
sizesNames: () => string[];
|
|
121
|
+
componentsNames: () => string[];
|
|
122
|
+
/** `options` are for the host: the generator itself has no use for them. */
|
|
123
|
+
addColor: (name: string, value: ColorValue, options?: ColorOptions) => Builder;
|
|
124
|
+
addVariant: BuilderFunc<VariantsGenerator['add']>;
|
|
125
|
+
addSize: BuilderFunc<SizesGenerator['add']>;
|
|
126
|
+
addComponent: BuilderFunc<ComponentsGenerator['add']>;
|
|
127
|
+
/** Adds a color, or replaces the one of that name. */
|
|
128
|
+
setColor: Builder['addColor'];
|
|
129
|
+
updateColor: BuilderFunc<ColorsGenerator['update']>;
|
|
130
|
+
updateVariant: BuilderFunc<VariantsGenerator['update']>;
|
|
131
|
+
updateSize: BuilderFunc<SizesGenerator['update']>;
|
|
132
|
+
updateComponent: BuilderFunc<ComponentsGenerator['update']>;
|
|
133
|
+
removeColor: BuilderFunc<ColorsGenerator['remove']>;
|
|
134
|
+
removeVariant: BuilderFunc<VariantsGenerator['remove']>;
|
|
135
|
+
removeSize: BuilderFunc<SizesGenerator['remove']>;
|
|
136
|
+
removeComponent: BuilderFunc<ComponentsGenerator['remove']>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Where the default variant comes from for an element without a `v-*` class of its own:
|
|
140
|
+
* - `universal`: a `*` rule sets it on every element (the 0.7 behaviour);
|
|
141
|
+
* - `element`: a `var()` fallback where a variant value is read, and children of a `v-*` element are reset to it;
|
|
142
|
+
* - `inherit`: the fallback only, so a `v-*` element sets the variant for its content.
|
|
143
|
+
*/
|
|
144
|
+
type VariantScope = 'universal' | 'element' | 'inherit';
|
|
145
|
+
/**
|
|
146
|
+
* What dark mode follows. It takes what Tailwind's `darkMode` takes, or a bare selector such as `'.dark'`, which is
|
|
147
|
+
* the `selector` strategy with that selector.
|
|
148
|
+
*/
|
|
149
|
+
type DarkSelectorOption = 'media' | 'class' | 'selector' | ['class' | 'selector', string] | ['variant', string | string[]] | (string & {});
|
|
150
|
+
/**
|
|
151
|
+
* A palette of 11 shades: the name of a palette of the theme, CSS variables named `{vars}-{shade}`, or the shades
|
|
152
|
+
* themselves.
|
|
153
|
+
*/
|
|
154
|
+
type ColorValue = string | {
|
|
155
|
+
vars: string;
|
|
156
|
+
} | Record<ColorShade, string>;
|
|
157
|
+
interface ColorOptions {
|
|
158
|
+
/**
|
|
159
|
+
* Also registers the palette as a color of the theme, for utilities such as `bg-{name}-{shade}`. This is up to the
|
|
160
|
+
* host; a palette name must then be one of the host's own palettes.
|
|
161
|
+
*/
|
|
162
|
+
utilities?: boolean;
|
|
163
|
+
}
|
|
164
|
+
interface ResolvedConfig {
|
|
165
|
+
prefix: string;
|
|
166
|
+
/** Where the root color and size variables are declared. More selectors let a scoped theme resolve them again. */
|
|
167
|
+
rootSelector: string;
|
|
168
|
+
/** The palette behind `default`. Left out, it is a complete `default` palette of the theme, or else gray. */
|
|
169
|
+
default?: ColorValue;
|
|
170
|
+
/** The palette behind `accent`. Left out, it is a complete `accent` palette of the theme, or else blue. */
|
|
171
|
+
accent?: ColorValue;
|
|
172
|
+
variantScope: VariantScope;
|
|
173
|
+
/** Left out, dark mode follows Tailwind's own. */
|
|
174
|
+
darkSelector?: DarkSelectorOption;
|
|
175
|
+
build?: (builder: Builder) => void;
|
|
176
|
+
/** Asks the host to emit every `c-*`, `v-*` and `s-*` class, also those it does not find in use. */
|
|
177
|
+
safelist: boolean;
|
|
178
|
+
/** Logs what is otherwise skipped silently, such as a theme palette without all 11 shades. */
|
|
179
|
+
debug: boolean;
|
|
180
|
+
}
|
|
181
|
+
type Config = Partial<ResolvedConfig>;
|
|
182
|
+
/** Types a config object, so that one object can be shared by the plugin, a config file and other tools. */
|
|
183
|
+
declare function defineConfig(config: Config): Config;
|
|
184
|
+
type ColorShade = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950';
|
|
185
|
+
type ExColorShade = ColorShade | `default-${ColorShade}` | `accent-${ColorShade}` | 'black' | 'white';
|
|
186
|
+
type ColorVars = Record<CSSVarName<'c'>, string>;
|
|
187
|
+
interface ColorContext {
|
|
188
|
+
toValue(name: ExColorShade | (string & {}), alpha?: number | string): string;
|
|
189
|
+
}
|
|
190
|
+
declare class ColorsGenerator extends VarsGeneratorBase<Map<ColorShade, string>, ColorVars> implements ColorContext {
|
|
191
|
+
private readonly colors;
|
|
192
|
+
protected readonly items: Map<string, Map<ColorShade, string>>;
|
|
193
|
+
constructor(ctx: BuilderContext, options?: Pick<Config, 'default' | 'accent' | 'debug'>);
|
|
194
|
+
/** The 11 shades of a palette given by name, by CSS variables or as the shades themselves. */
|
|
195
|
+
resolve(value: ColorValue): Map<ColorShade, string> | undefined;
|
|
196
|
+
addColor(name: string, value: ColorValue): void;
|
|
197
|
+
/** Adds a palette, or replaces the one of that name. */
|
|
198
|
+
setColor(name: string, value: ColorValue): void;
|
|
199
|
+
names(): string[];
|
|
200
|
+
cssVars(name: string): Record<`--${string}-c-${string}`, string>;
|
|
201
|
+
rootVars(): ColorVars;
|
|
202
|
+
toValue(name: ExColorShade | (string & {}), alpha?: number | string): string;
|
|
203
|
+
}
|
|
204
|
+
type VarType = 'c' | 'v' | 's';
|
|
205
|
+
type VarName<T extends VarType = VarType> = `${T}-${string}`;
|
|
206
|
+
type CSSVarName<T extends VarType = VarType> = `--${string}-${VarName<T>}`;
|
|
207
|
+
type CSSVarValue<T extends VarType = VarType> = `var(${CSSVarName<T>})`;
|
|
208
|
+
interface VarsProvider {
|
|
209
|
+
c(n: string): CSSVarName<'c'>;
|
|
210
|
+
v(n: string): CSSVarName<'v'>;
|
|
211
|
+
s(n: string): CSSVarName<'s'>;
|
|
212
|
+
color: {
|
|
213
|
+
(name: ExColorShade, fallback?: string): CSSVarValue<'c'>;
|
|
214
|
+
default(name: ColorShade, fallback?: string): CSSVarValue<'c'>;
|
|
215
|
+
accent(name: ColorShade, fallback?: string): CSSVarValue<'c'>;
|
|
216
|
+
};
|
|
217
|
+
size(name: SizeProperty, fallback?: string): CSSVarValue<'s'>;
|
|
218
|
+
/** `{ fallback: true }` falls back to the light value of the built-in default variant. */
|
|
219
|
+
variant(name: VariantProperty, fallback?: string | {
|
|
220
|
+
fallback: true;
|
|
221
|
+
}): CSSVarValue<'v'>;
|
|
222
|
+
}
|
|
223
|
+
declare function varsProvider(prefix: string): VarsProvider;
|
|
224
|
+
interface BuilderContext {
|
|
225
|
+
readonly vars: VarsProvider;
|
|
226
|
+
readonly theme: ThemeProvider;
|
|
227
|
+
}
|
|
228
|
+
declare abstract class BuilderBase<T, TContext extends BuilderContext> {
|
|
229
|
+
protected readonly ctx: TContext;
|
|
230
|
+
protected abstract readonly items: Map<string, T>;
|
|
231
|
+
constructor(ctx: TContext);
|
|
232
|
+
protected get vars(): VarsProvider;
|
|
233
|
+
protected get theme(): ThemeProvider;
|
|
234
|
+
names(): string[];
|
|
235
|
+
add(name: string, builder: (ctx: TContext) => T): void;
|
|
236
|
+
update(name: string, builder: (element: T, ctx: TContext) => T | void): void;
|
|
237
|
+
remove(name: string): void;
|
|
238
|
+
}
|
|
239
|
+
declare abstract class VarsGeneratorBase<T, TVars, TContext extends BuilderContext = BuilderContext> extends BuilderBase<T, TContext> {
|
|
240
|
+
constructor(ctx: TContext);
|
|
241
|
+
add(name: string, builder: (ctx: TContext) => T): void;
|
|
242
|
+
remove(name: string): void;
|
|
243
|
+
abstract cssVars(name: string): TVars;
|
|
244
|
+
rootVars(): TVars;
|
|
245
|
+
}
|
|
246
|
+
interface ComponentBuilderContext extends BuilderContext {
|
|
247
|
+
readonly colors: ColorContext;
|
|
248
|
+
readonly variants: VariantContext;
|
|
249
|
+
}
|
|
250
|
+
type ComponentBuilder = (context: ComponentBuilderContext) => IComponent;
|
|
251
|
+
interface IComponent {
|
|
252
|
+
name: string;
|
|
253
|
+
style: Properties;
|
|
254
|
+
pseudos?: ExpandedPseudos;
|
|
255
|
+
applyVariant?: ApplyVariant;
|
|
256
|
+
applyVariantPseudos?: ApplyVariantPseudos;
|
|
257
|
+
}
|
|
258
|
+
export { Variant as C, ThemeProvider as D, FontSize as E, css_d_exports as O, ApplyVariantSubProp as S, VariantsGenerator as T, ComponentsGenerator as _, varsProvider as a, ApplyVariantMainProp as b, ExColorShade as c, Config as d, DarkSelectorOption as f, Builder as g, defineConfig as h, VarsProvider as i, ColorOptions as l, VariantScope as m, ComponentBuilderContext as n, ColorShade as o, ResolvedConfig as p, IComponent as r, ColorsGenerator as s, ComponentBuilder as t, ColorValue as u, SizesGenerator as v, VariantProperties as w, ApplyVariantProp as x, ApplyVariant as y };
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { AdvancedPseudos, AtRule, AtRules, DataType, Properties as Properties$1, Property, PropertyValue, Pseudos, SimplePseudos } from "csstype";
|
|
2
|
+
declare namespace css_d_exports {
|
|
3
|
+
export { AdvancedPseudos, AtRule, AtRules, DataType, ExpandedPseudos, Properties, Property, PropertyValue, Pseudos, Rules, SimplePseudos };
|
|
4
|
+
}
|
|
5
|
+
type Expand<T, TKey extends string | number | symbol = string, TValue = any> = T & Record<TKey, TValue>;
|
|
6
|
+
declare module 'csstype' {
|
|
7
|
+
interface Properties<TLength, TTime> {
|
|
8
|
+
[key: string]: string | number | Properties<TLength, TTime>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
type Properties = Properties$1<string>;
|
|
12
|
+
type Rules = Record<string, Properties>;
|
|
13
|
+
type ExpandedPseudos = Expand<Partial<Record<Pseudos, Properties>>, string, Properties>;
|
|
14
|
+
type FontSize = string | [string, string | {
|
|
15
|
+
lineHeight?: string;
|
|
16
|
+
letterSpacing?: string;
|
|
17
|
+
fontWeight?: string;
|
|
18
|
+
}];
|
|
19
|
+
interface ThemeProvider {
|
|
20
|
+
colors(): Record<string, string>;
|
|
21
|
+
colors(name: string): string | Record<string, string>;
|
|
22
|
+
spacing(name: string): string;
|
|
23
|
+
fontSize(name: string): FontSize;
|
|
24
|
+
applyTextColor(value: string, target: Properties, alpha?: string): void;
|
|
25
|
+
applyBackgroundColor(value: string, target: Properties, alpha?: string): void;
|
|
26
|
+
applyBorderColor(value: string, target: Properties, alpha?: string): void;
|
|
27
|
+
colorValue(value: string, alpha?: number | string): string;
|
|
28
|
+
/** Converts a color to the form `colors()` returns them in. Left out, a color is used as it is written. */
|
|
29
|
+
toColor?(value: string): string;
|
|
30
|
+
}
|
|
31
|
+
interface BuilderContext {
|
|
32
|
+
readonly vars: VarsProvider;
|
|
33
|
+
readonly theme: ThemeProvider;
|
|
34
|
+
}
|
|
35
|
+
declare abstract class BuilderBase<T, TContext extends BuilderContext> {
|
|
36
|
+
protected readonly ctx: TContext;
|
|
37
|
+
protected abstract readonly items: Map<string, T>;
|
|
38
|
+
constructor(ctx: TContext);
|
|
39
|
+
protected get vars(): VarsProvider;
|
|
40
|
+
protected get theme(): ThemeProvider;
|
|
41
|
+
names(): string[];
|
|
42
|
+
add(name: string, builder: (ctx: TContext) => T): void;
|
|
43
|
+
update(name: string, builder: (element: T, ctx: TContext) => T | void): void;
|
|
44
|
+
remove(name: string): void;
|
|
45
|
+
}
|
|
46
|
+
declare abstract class VarsGeneratorBase<T, TVars, TContext extends BuilderContext = BuilderContext> extends BuilderBase<T, TContext> {
|
|
47
|
+
constructor(ctx: TContext);
|
|
48
|
+
add(name: string, builder: (ctx: TContext) => T): void;
|
|
49
|
+
remove(name: string): void;
|
|
50
|
+
abstract cssVars(name: string): TVars;
|
|
51
|
+
rootVars(): TVars;
|
|
52
|
+
}
|
|
53
|
+
type VariantVars = Record<CSSVarName<'v'>, string>;
|
|
54
|
+
type VariantPropValue = CSSVarValue<'c'> | CSSVarValue<'v'>;
|
|
55
|
+
type OpacityValue = '1' | '0' | `0.${number}`;
|
|
56
|
+
interface VariantProperties {
|
|
57
|
+
'bg': VariantPropValue;
|
|
58
|
+
'bg-soft'?: VariantPropValue;
|
|
59
|
+
'bg-muted'?: VariantPropValue;
|
|
60
|
+
'bg-accent'?: VariantPropValue;
|
|
61
|
+
'bg-opacity'?: OpacityValue;
|
|
62
|
+
'border': VariantPropValue;
|
|
63
|
+
'border-soft'?: VariantPropValue;
|
|
64
|
+
'border-muted'?: VariantPropValue;
|
|
65
|
+
'border-accent'?: VariantPropValue;
|
|
66
|
+
'border-opacity'?: OpacityValue;
|
|
67
|
+
'fg': VariantPropValue;
|
|
68
|
+
'fg-soft'?: VariantPropValue;
|
|
69
|
+
'fg-muted'?: VariantPropValue;
|
|
70
|
+
'fg-accent'?: VariantPropValue;
|
|
71
|
+
'fg-opacity'?: OpacityValue;
|
|
72
|
+
}
|
|
73
|
+
type VariantPseudos = Partial<Record<SimplePseudos, Partial<VariantProperties>>>;
|
|
74
|
+
interface Variant extends VariantProperties {
|
|
75
|
+
pseudos?: VariantPseudos;
|
|
76
|
+
dark?: Omit<Partial<Variant>, 'dark'>;
|
|
77
|
+
}
|
|
78
|
+
type VariantProperty = keyof VariantProperties | `${keyof VariantProperties}-${SimplePseudos}`;
|
|
79
|
+
type ApplyVariantMainProp = 'bg' | 'border' | 'text';
|
|
80
|
+
type ApplyVariantSubProp = 'soft' | 'muted' | 'accent' | 'default';
|
|
81
|
+
type ApplyVariantProp = ApplyVariantMainProp | `${ApplyVariantMainProp}-${Exclude<ApplyVariantSubProp, 'default'>}`;
|
|
82
|
+
type ApplyVariant = boolean | ApplyVariantProp[];
|
|
83
|
+
type ApplyVariantPseudos = Partial<Record<SimplePseudos, ApplyVariant>> | SimplePseudos[] | false;
|
|
84
|
+
interface VariantCssVars extends VariantVars {
|
|
85
|
+
'@dark'?: VariantVars;
|
|
86
|
+
}
|
|
87
|
+
interface VariantContext {
|
|
88
|
+
apply(v?: ApplyVariant, pseudos?: ApplyVariantPseudos, target?: Properties): Properties;
|
|
89
|
+
/**
|
|
90
|
+
* Outside the `universal` scope, gives every bare `var()` read of a variant variable in `css` the default
|
|
91
|
+
* variant's value, light or dark, as its fallback.
|
|
92
|
+
*/
|
|
93
|
+
withFallback<T extends Properties>(css: T): T;
|
|
94
|
+
}
|
|
95
|
+
declare class VariantsGenerator extends VarsGeneratorBase<Variant, VariantCssVars> implements VariantContext {
|
|
96
|
+
private readonly scope;
|
|
97
|
+
protected readonly items: Map<string, Variant>;
|
|
98
|
+
constructor(ctx: BuilderContext, scope?: VariantScope);
|
|
99
|
+
cssVars(name: string): VariantCssVars;
|
|
100
|
+
/** Every variable a variant can set, as `initial`: on a child it stops the parent's variant from inheriting. */
|
|
101
|
+
resetVars(): VariantVars;
|
|
102
|
+
utilCss(v: ApplyVariantMainProp, prop?: ApplyVariantSubProp, alpha?: string): Properties;
|
|
103
|
+
/**
|
|
104
|
+
* The two switches a fallback picks its light or dark value with: `var(on-light, <light>) var(on-dark, <dark>)`.
|
|
105
|
+
* The one of the current mode is not set, so its fallback is used, and the other one is empty.
|
|
106
|
+
* They inherit, so a pseudo-element is in the mode of its element, which a dark selector nested in its rule cannot tell.
|
|
107
|
+
*/
|
|
108
|
+
modeVars(): {
|
|
109
|
+
light: VariantVars;
|
|
110
|
+
dark: VariantVars;
|
|
111
|
+
};
|
|
112
|
+
withFallback<T extends Properties>(css: T): T;
|
|
113
|
+
apply(v?: ApplyVariant, pseudos?: ApplyVariantPseudos, target?: Properties): Properties;
|
|
114
|
+
private vApplyProp;
|
|
115
|
+
}
|
|
116
|
+
type SizeVars = Record<CSSVarName<'s'>, string>;
|
|
117
|
+
type SizeProperty = 'text' | `spacing-${keyof Size['spacing']}` | 'line-height';
|
|
118
|
+
type Size = {
|
|
119
|
+
spacing: {
|
|
120
|
+
'1': string;
|
|
121
|
+
'1.5': string;
|
|
122
|
+
'2': string;
|
|
123
|
+
'3': string;
|
|
124
|
+
'4': string;
|
|
125
|
+
};
|
|
126
|
+
text: FontSize;
|
|
127
|
+
};
|
|
128
|
+
declare class SizesGenerator extends VarsGeneratorBase<Size, SizeVars> {
|
|
129
|
+
protected readonly items: Map<string, Size>;
|
|
130
|
+
constructor(ctx: BuilderContext);
|
|
131
|
+
cssVars(name: string): SizeVars;
|
|
132
|
+
}
|
|
133
|
+
interface ComponentBuilderContext extends BuilderContext {
|
|
134
|
+
readonly colors: ColorContext;
|
|
135
|
+
readonly variants: VariantContext;
|
|
136
|
+
}
|
|
137
|
+
type ComponentBuilder = (context: ComponentBuilderContext) => IComponent;
|
|
138
|
+
interface IComponent {
|
|
139
|
+
name: string;
|
|
140
|
+
style: Properties;
|
|
141
|
+
pseudos?: ExpandedPseudos;
|
|
142
|
+
applyVariant?: ApplyVariant;
|
|
143
|
+
applyVariantPseudos?: ApplyVariantPseudos;
|
|
144
|
+
}
|
|
145
|
+
declare class ComponentsGenerator extends BuilderBase<IComponent, ComponentBuilderContext> {
|
|
146
|
+
protected readonly items: Map<string, IComponent>;
|
|
147
|
+
constructor(context: ComponentBuilderContext);
|
|
148
|
+
css(): Generator<Rules, void, unknown>;
|
|
149
|
+
}
|
|
150
|
+
type BuilderFunc<TFunc extends (...args: any) => void> = (...args: Parameters<TFunc>) => Builder;
|
|
151
|
+
interface Builder {
|
|
152
|
+
colorsNames: () => string[];
|
|
153
|
+
variantsNames: () => string[];
|
|
154
|
+
sizesNames: () => string[];
|
|
155
|
+
componentsNames: () => string[];
|
|
156
|
+
/** `options` are for the host: the generator itself has no use for them. */
|
|
157
|
+
addColor: (name: string, value: ColorValue, options?: ColorOptions) => Builder;
|
|
158
|
+
addVariant: BuilderFunc<VariantsGenerator['add']>;
|
|
159
|
+
addSize: BuilderFunc<SizesGenerator['add']>;
|
|
160
|
+
addComponent: BuilderFunc<ComponentsGenerator['add']>;
|
|
161
|
+
/** Adds a color, or replaces the one of that name. */
|
|
162
|
+
setColor: Builder['addColor'];
|
|
163
|
+
updateColor: BuilderFunc<ColorsGenerator['update']>;
|
|
164
|
+
updateVariant: BuilderFunc<VariantsGenerator['update']>;
|
|
165
|
+
updateSize: BuilderFunc<SizesGenerator['update']>;
|
|
166
|
+
updateComponent: BuilderFunc<ComponentsGenerator['update']>;
|
|
167
|
+
removeColor: BuilderFunc<ColorsGenerator['remove']>;
|
|
168
|
+
removeVariant: BuilderFunc<VariantsGenerator['remove']>;
|
|
169
|
+
removeSize: BuilderFunc<SizesGenerator['remove']>;
|
|
170
|
+
removeComponent: BuilderFunc<ComponentsGenerator['remove']>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Where the default variant comes from for an element without a `v-*` class of its own:
|
|
174
|
+
* - `universal`: a `*` rule sets it on every element (the 0.7 behaviour);
|
|
175
|
+
* - `element`: a `var()` fallback where a variant value is read, and children of a `v-*` element are reset to it;
|
|
176
|
+
* - `inherit`: the fallback only, so a `v-*` element sets the variant for its content.
|
|
177
|
+
*/
|
|
178
|
+
type VariantScope = 'universal' | 'element' | 'inherit';
|
|
179
|
+
/**
|
|
180
|
+
* What dark mode follows. It takes what Tailwind's `darkMode` takes, or a bare selector such as `'.dark'`, which is
|
|
181
|
+
* the `selector` strategy with that selector.
|
|
182
|
+
*/
|
|
183
|
+
type DarkSelectorOption = 'media' | 'class' | 'selector' | ['class' | 'selector', string] | ['variant', string | string[]] | (string & {});
|
|
184
|
+
/**
|
|
185
|
+
* A palette of 11 shades: the name of a palette of the theme, CSS variables named `{vars}-{shade}`, or the shades
|
|
186
|
+
* themselves.
|
|
187
|
+
*/
|
|
188
|
+
type ColorValue = string | {
|
|
189
|
+
vars: string;
|
|
190
|
+
} | Record<ColorShade, string>;
|
|
191
|
+
interface ColorOptions {
|
|
192
|
+
/**
|
|
193
|
+
* Also registers the palette as a color of the theme, for utilities such as `bg-{name}-{shade}`. This is up to the
|
|
194
|
+
* host; a palette name must then be one of the host's own palettes.
|
|
195
|
+
*/
|
|
196
|
+
utilities?: boolean;
|
|
197
|
+
}
|
|
198
|
+
interface ResolvedConfig {
|
|
199
|
+
prefix: string;
|
|
200
|
+
/** Where the root color and size variables are declared. More selectors let a scoped theme resolve them again. */
|
|
201
|
+
rootSelector: string;
|
|
202
|
+
/** The palette behind `default`. Left out, it is a complete `default` palette of the theme, or else gray. */
|
|
203
|
+
default?: ColorValue;
|
|
204
|
+
/** The palette behind `accent`. Left out, it is a complete `accent` palette of the theme, or else blue. */
|
|
205
|
+
accent?: ColorValue;
|
|
206
|
+
variantScope: VariantScope;
|
|
207
|
+
/** Left out, dark mode follows Tailwind's own. */
|
|
208
|
+
darkSelector?: DarkSelectorOption;
|
|
209
|
+
build?: (builder: Builder) => void;
|
|
210
|
+
/** Asks the host to emit every `c-*`, `v-*` and `s-*` class, also those it does not find in use. */
|
|
211
|
+
safelist: boolean;
|
|
212
|
+
/** Logs what is otherwise skipped silently, such as a theme palette without all 11 shades. */
|
|
213
|
+
debug: boolean;
|
|
214
|
+
}
|
|
215
|
+
type Config = Partial<ResolvedConfig>;
|
|
216
|
+
/** Types a config object, so that one object can be shared by the plugin, a config file and other tools. */
|
|
217
|
+
declare function defineConfig(config: Config): Config;
|
|
218
|
+
type ColorShade = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950';
|
|
219
|
+
type ExColorShade = ColorShade | `default-${ColorShade}` | `accent-${ColorShade}` | 'black' | 'white';
|
|
220
|
+
type ColorVars = Record<CSSVarName<'c'>, string>;
|
|
221
|
+
interface ColorContext {
|
|
222
|
+
toValue(name: ExColorShade | (string & {}), alpha?: number | string): string;
|
|
223
|
+
}
|
|
224
|
+
declare class ColorsGenerator extends VarsGeneratorBase<Map<ColorShade, string>, ColorVars> implements ColorContext {
|
|
225
|
+
private readonly colors;
|
|
226
|
+
protected readonly items: Map<string, Map<ColorShade, string>>;
|
|
227
|
+
constructor(ctx: BuilderContext, options?: Pick<Config, 'default' | 'accent' | 'debug'>);
|
|
228
|
+
/** The 11 shades of a palette given by name, by CSS variables or as the shades themselves. */
|
|
229
|
+
resolve(value: ColorValue): Map<ColorShade, string> | undefined;
|
|
230
|
+
addColor(name: string, value: ColorValue): void;
|
|
231
|
+
/** Adds a palette, or replaces the one of that name. */
|
|
232
|
+
setColor(name: string, value: ColorValue): void;
|
|
233
|
+
names(): string[];
|
|
234
|
+
cssVars(name: string): Record<`--${string}-c-${string}`, string>;
|
|
235
|
+
rootVars(): ColorVars;
|
|
236
|
+
toValue(name: ExColorShade | (string & {}), alpha?: number | string): string;
|
|
237
|
+
}
|
|
238
|
+
type VarType = 'c' | 'v' | 's';
|
|
239
|
+
type VarName<T extends VarType = VarType> = `${T}-${string}`;
|
|
240
|
+
type CSSVarName<T extends VarType = VarType> = `--${string}-${VarName<T>}`;
|
|
241
|
+
type CSSVarValue<T extends VarType = VarType> = `var(${CSSVarName<T>})`;
|
|
242
|
+
interface VarsProvider {
|
|
243
|
+
c(n: string): CSSVarName<'c'>;
|
|
244
|
+
v(n: string): CSSVarName<'v'>;
|
|
245
|
+
s(n: string): CSSVarName<'s'>;
|
|
246
|
+
color: {
|
|
247
|
+
(name: ExColorShade, fallback?: string): CSSVarValue<'c'>;
|
|
248
|
+
default(name: ColorShade, fallback?: string): CSSVarValue<'c'>;
|
|
249
|
+
accent(name: ColorShade, fallback?: string): CSSVarValue<'c'>;
|
|
250
|
+
};
|
|
251
|
+
size(name: SizeProperty, fallback?: string): CSSVarValue<'s'>;
|
|
252
|
+
/** `{ fallback: true }` falls back to the light value of the built-in default variant. */
|
|
253
|
+
variant(name: VariantProperty, fallback?: string | {
|
|
254
|
+
fallback: true;
|
|
255
|
+
}): CSSVarValue<'v'>;
|
|
256
|
+
}
|
|
257
|
+
declare function varsProvider(prefix: string): VarsProvider;
|
|
258
|
+
export { Variant as C, ThemeProvider as D, FontSize as E, css_d_exports as O, ApplyVariantSubProp as S, VariantsGenerator as T, IComponent as _, ExColorShade as a, ApplyVariantMainProp as b, Config as c, VariantScope as d, defineConfig as f, ComponentBuilderContext as g, ComponentBuilder as h, ColorsGenerator as i, DarkSelectorOption as l, ComponentsGenerator as m, varsProvider as n, ColorOptions as o, Builder as p, ColorShade as r, ColorValue as s, VarsProvider as t, ResolvedConfig as u, SizesGenerator as v, VariantProperties as w, ApplyVariantProp as x, ApplyVariant as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windi-ui/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Waleed Khaled <https://github.com/Waleed-KH>",
|
|
6
6
|
"description": "Modern, modular, and customizable UI component library",
|
|
@@ -16,29 +16,27 @@
|
|
|
16
16
|
"url": "https://github.com/windi-ui/windi-ui/issues"
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
|
-
"module": "dist/index.mjs",
|
|
20
|
-
"main": "dist/index.cjs",
|
|
21
|
-
"types": "dist/index.d.
|
|
19
|
+
"module": "./dist/index.mjs",
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"import": "./dist/index.mjs",
|
|
25
|
-
"require": "./dist/index.cjs"
|
|
26
|
-
"types": "./dist/index.d.ts"
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
27
26
|
},
|
|
28
27
|
"./components": {
|
|
29
28
|
"import": "./dist/components.mjs",
|
|
30
|
-
"require": "./dist/components.cjs"
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
"require": "./dist/components.cjs"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
33
32
|
},
|
|
34
33
|
"files": [
|
|
35
34
|
"dist"
|
|
36
35
|
],
|
|
37
36
|
"dependencies": {
|
|
38
|
-
"csstype": "^3.
|
|
37
|
+
"csstype": "^3.2.4"
|
|
39
38
|
},
|
|
40
39
|
"scripts": {
|
|
41
|
-
"build": "
|
|
42
|
-
"stub": "unbuild --stub"
|
|
40
|
+
"build": "tsdown"
|
|
43
41
|
}
|
|
44
42
|
}
|
package/dist/components.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { I as IComponent, j as ComponentBuilder } from './shared/core.BBBw5V2R.js';
|
|
2
|
-
export { C as ComponentBuilderContext } from './shared/core.BBBw5V2R.js';
|
|
3
|
-
import 'csstype';
|
|
4
|
-
|
|
5
|
-
declare function defineComponent(component: IComponent | ComponentBuilder): ComponentBuilder;
|
|
6
|
-
|
|
7
|
-
declare const _default$1: ComponentBuilder;
|
|
8
|
-
|
|
9
|
-
declare const _default: ComponentBuilder;
|
|
10
|
-
|
|
11
|
-
export { ComponentBuilder, IComponent, _default as badge, _default$1 as button, defineComponent };
|
package/dist/index.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { B as BuilderBase, I as IComponent, C as ComponentBuilderContext, R as Rules, V as VariantsGenerator, S as SizesGenerator, a as ColorsGenerator, b as VarsProvider, T as ThemeProvider } from './shared/core.BBBw5V2R.js';
|
|
2
|
-
export { A as ApplyVariant, f as ApplyVariantMainProp, h as ApplyVariantProp, g as ApplyVariantSubProp, i as CSS, c as ColorShade, E as ExColorShade, F as FontSize, d as Variant, e as VariantProps } from './shared/core.BBBw5V2R.js';
|
|
3
|
-
import 'csstype';
|
|
4
|
-
|
|
5
|
-
declare class ComponentsGenerator extends BuilderBase<IComponent, ComponentBuilderContext> {
|
|
6
|
-
protected readonly items: Map<string, IComponent>;
|
|
7
|
-
constructor(context: ComponentBuilderContext);
|
|
8
|
-
css(): Generator<Rules, void, unknown>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type BuilderFunc<TFunc extends (...args: any) => void> = (...args: Parameters<TFunc>) => Builder;
|
|
12
|
-
interface Builder {
|
|
13
|
-
colorsNames: () => string[];
|
|
14
|
-
variantsNames: () => string[];
|
|
15
|
-
sizesNames: () => string[];
|
|
16
|
-
componentsNames: () => string[];
|
|
17
|
-
addVariant: BuilderFunc<VariantsGenerator['add']>;
|
|
18
|
-
addSize: BuilderFunc<SizesGenerator['add']>;
|
|
19
|
-
addComponent: BuilderFunc<ComponentsGenerator['add']>;
|
|
20
|
-
updateVariant: BuilderFunc<VariantsGenerator['update']>;
|
|
21
|
-
updateSize: BuilderFunc<SizesGenerator['update']>;
|
|
22
|
-
updateComponent: BuilderFunc<ComponentsGenerator['update']>;
|
|
23
|
-
removeVariant: BuilderFunc<VariantsGenerator['remove']>;
|
|
24
|
-
removeSize: BuilderFunc<SizesGenerator['remove']>;
|
|
25
|
-
removeComponent: BuilderFunc<ComponentsGenerator['remove']>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface ResolvedConfig {
|
|
29
|
-
prefix: string;
|
|
30
|
-
build?: (builder: Builder) => void;
|
|
31
|
-
}
|
|
32
|
-
type Config = Partial<ResolvedConfig>;
|
|
33
|
-
|
|
34
|
-
interface Generator$1 {
|
|
35
|
-
readonly colors: ColorsGenerator;
|
|
36
|
-
readonly variants: VariantsGenerator;
|
|
37
|
-
readonly sizes: SizesGenerator;
|
|
38
|
-
readonly components: ComponentsGenerator;
|
|
39
|
-
}
|
|
40
|
-
declare function create(config: Config): {
|
|
41
|
-
vars: VarsProvider;
|
|
42
|
-
generator(theme: ThemeProvider): Generator$1;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export { ThemeProvider, create };
|
|
46
|
-
export type { Config, Generator$1 as Generator };
|