@windi-ui/core 0.8.0-beta.1 → 0.8.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.
@@ -0,0 +1,104 @@
1
+ // src/preset.ts
2
+ const CALL = /^(add|set|update|remove)(Color|Variant|Size|Component)$/;
3
+ /** Makes a preset from a `build` function. The preset takes the options every preset takes: `override`, `prefix` and `only`. */
4
+ function definePreset(name, build) {
5
+ return ({ override = false, prefix, only } = {}) => ({
6
+ name,
7
+ build(builder) {
8
+ const b = builder;
9
+ const own = /* @__PURE__ */ new Set();
10
+ const skipped = /* @__PURE__ */ new Set();
11
+ const kept = [];
12
+ const named = (n) => prefix ? `${prefix}-${n}` : n;
13
+ const target = (kind, n) => own.has(`${kind}:${named(n)}`) ? named(n) : n;
14
+ const left = (kind, n) => only?.includes(n) === false || skipped.has(`${kind}:${n}`);
15
+ const scoped = new Proxy(builder, { get(_, key) {
16
+ if (key === "overrideVariant") return (variant, colors, value) => {
17
+ if (!left("Variant", variant)) b.overrideVariant(target("Variant", variant), [colors].flat().flatMap((c) => c.split(",")).map((c) => target("Color", c.trim())), value);
18
+ return scoped;
19
+ };
20
+ const [, action, kind] = CALL.exec(key) ?? [];
21
+ if (!kind) return b[key];
22
+ return (n, ...rest) => {
23
+ if (left(kind, n)) return scoped;
24
+ if (action === "add" || action === "set") {
25
+ const id = `${kind}:${named(n)}`;
26
+ const ours = own.has(id);
27
+ if (!override && !ours && b[`${kind.toLowerCase()}sNames`](true).includes(named(n))) {
28
+ kept.push(named(n));
29
+ skipped.add(`${kind}:${n}`);
30
+ return scoped;
31
+ }
32
+ b[`${override || ours ? "set" : "add"}${kind}`](named(n), ...rest);
33
+ own.add(id);
34
+ } else b[key](target(kind, n), ...rest);
35
+ return scoped;
36
+ };
37
+ } });
38
+ build(scoped);
39
+ if (kept.length) console.warn(`WindiUI: the "${name}" preset keeps ${kept.map((k) => `"${k}"`).join(", ")}, which already ${kept.length > 1 ? "exist" : "exists"}. Pass \`override: true\` to replace ${kept.length > 1 ? "them" : "it"}.`);
40
+ }
41
+ });
42
+ }
43
+ // src/presets/nuxt-ui.ts
44
+ /** The variants of Nuxt UI that WindiUI lacks: `soft`, `subtle`, `ghost` and `link`. `solid` and `outline` exist. */
45
+ const nuxtUi = definePreset("nuxt-ui", (b) => b.setVariant("soft", ({ vars: { color: c } }) => ({
46
+ bg: c("100"),
47
+ border: c("100"),
48
+ "border-opacity": "0",
49
+ fg: c("800"),
50
+ pseudos: { ":hover": { bg: c("200") } },
51
+ dark: {
52
+ bg: c("900"),
53
+ "bg-opacity": "0.5",
54
+ fg: c("300"),
55
+ pseudos: { ":hover": { bg: c("800") } }
56
+ }
57
+ })).setVariant("subtle", ({ vars: { color: c } }) => ({
58
+ bg: c("50"),
59
+ border: c("200"),
60
+ fg: c("800"),
61
+ pseudos: { ":hover": { bg: c("100") } },
62
+ dark: {
63
+ bg: c("950"),
64
+ "bg-opacity": "0.5",
65
+ border: c("800"),
66
+ fg: c("300"),
67
+ pseudos: { ":hover": { bg: c("900") } }
68
+ }
69
+ })).setVariant("ghost", ({ vars: { color: c } }) => ({
70
+ bg: c("50"),
71
+ "bg-opacity": "0",
72
+ border: c("50"),
73
+ "border-opacity": "0",
74
+ fg: c("700"),
75
+ pseudos: { ":hover": { "bg-opacity": "1" } },
76
+ dark: {
77
+ bg: c("900"),
78
+ fg: c("400"),
79
+ pseudos: { ":hover": { "bg-opacity": "0.5" } }
80
+ }
81
+ })).setVariant("link", ({ vars: { color: c } }) => ({
82
+ bg: c("50"),
83
+ "bg-opacity": "0",
84
+ border: c("50"),
85
+ "border-opacity": "0",
86
+ fg: c("700"),
87
+ pseudos: { ":hover": { fg: c("800") } },
88
+ dark: {
89
+ fg: c("400"),
90
+ pseudos: { ":hover": { fg: c("300") } }
91
+ }
92
+ })));
93
+ Object.defineProperty(exports, "definePreset", {
94
+ enumerable: true,
95
+ get: function() {
96
+ return definePreset;
97
+ }
98
+ });
99
+ Object.defineProperty(exports, "nuxtUi", {
100
+ enumerable: true,
101
+ get: function() {
102
+ return nuxtUi;
103
+ }
104
+ });
@@ -0,0 +1,93 @@
1
+ // src/preset.ts
2
+ const CALL = /^(add|set|update|remove)(Color|Variant|Size|Component)$/;
3
+ /** Makes a preset from a `build` function. The preset takes the options every preset takes: `override`, `prefix` and `only`. */
4
+ function definePreset(name, build) {
5
+ return ({ override = false, prefix, only } = {}) => ({
6
+ name,
7
+ build(builder) {
8
+ const b = builder;
9
+ const own = /* @__PURE__ */ new Set();
10
+ const skipped = /* @__PURE__ */ new Set();
11
+ const kept = [];
12
+ const named = (n) => prefix ? `${prefix}-${n}` : n;
13
+ const target = (kind, n) => own.has(`${kind}:${named(n)}`) ? named(n) : n;
14
+ const left = (kind, n) => only?.includes(n) === false || skipped.has(`${kind}:${n}`);
15
+ const scoped = new Proxy(builder, { get(_, key) {
16
+ if (key === "overrideVariant") return (variant, colors, value) => {
17
+ if (!left("Variant", variant)) b.overrideVariant(target("Variant", variant), [colors].flat().flatMap((c) => c.split(",")).map((c) => target("Color", c.trim())), value);
18
+ return scoped;
19
+ };
20
+ const [, action, kind] = CALL.exec(key) ?? [];
21
+ if (!kind) return b[key];
22
+ return (n, ...rest) => {
23
+ if (left(kind, n)) return scoped;
24
+ if (action === "add" || action === "set") {
25
+ const id = `${kind}:${named(n)}`;
26
+ const ours = own.has(id);
27
+ if (!override && !ours && b[`${kind.toLowerCase()}sNames`](true).includes(named(n))) {
28
+ kept.push(named(n));
29
+ skipped.add(`${kind}:${n}`);
30
+ return scoped;
31
+ }
32
+ b[`${override || ours ? "set" : "add"}${kind}`](named(n), ...rest);
33
+ own.add(id);
34
+ } else b[key](target(kind, n), ...rest);
35
+ return scoped;
36
+ };
37
+ } });
38
+ build(scoped);
39
+ if (kept.length) console.warn(`WindiUI: the "${name}" preset keeps ${kept.map((k) => `"${k}"`).join(", ")}, which already ${kept.length > 1 ? "exist" : "exists"}. Pass \`override: true\` to replace ${kept.length > 1 ? "them" : "it"}.`);
40
+ }
41
+ });
42
+ }
43
+ // src/presets/nuxt-ui.ts
44
+ /** The variants of Nuxt UI that WindiUI lacks: `soft`, `subtle`, `ghost` and `link`. `solid` and `outline` exist. */
45
+ const nuxtUi = definePreset("nuxt-ui", (b) => b.setVariant("soft", ({ vars: { color: c } }) => ({
46
+ bg: c("100"),
47
+ border: c("100"),
48
+ "border-opacity": "0",
49
+ fg: c("800"),
50
+ pseudos: { ":hover": { bg: c("200") } },
51
+ dark: {
52
+ bg: c("900"),
53
+ "bg-opacity": "0.5",
54
+ fg: c("300"),
55
+ pseudos: { ":hover": { bg: c("800") } }
56
+ }
57
+ })).setVariant("subtle", ({ vars: { color: c } }) => ({
58
+ bg: c("50"),
59
+ border: c("200"),
60
+ fg: c("800"),
61
+ pseudos: { ":hover": { bg: c("100") } },
62
+ dark: {
63
+ bg: c("950"),
64
+ "bg-opacity": "0.5",
65
+ border: c("800"),
66
+ fg: c("300"),
67
+ pseudos: { ":hover": { bg: c("900") } }
68
+ }
69
+ })).setVariant("ghost", ({ vars: { color: c } }) => ({
70
+ bg: c("50"),
71
+ "bg-opacity": "0",
72
+ border: c("50"),
73
+ "border-opacity": "0",
74
+ fg: c("700"),
75
+ pseudos: { ":hover": { "bg-opacity": "1" } },
76
+ dark: {
77
+ bg: c("900"),
78
+ fg: c("400"),
79
+ pseudos: { ":hover": { "bg-opacity": "0.5" } }
80
+ }
81
+ })).setVariant("link", ({ vars: { color: c } }) => ({
82
+ bg: c("50"),
83
+ "bg-opacity": "0",
84
+ border: c("50"),
85
+ "border-opacity": "0",
86
+ fg: c("700"),
87
+ pseudos: { ":hover": { fg: c("800") } },
88
+ dark: {
89
+ fg: c("400"),
90
+ pseudos: { ":hover": { fg: c("300") } }
91
+ }
92
+ })));
93
+ export { definePreset as n, nuxtUi as t };
@@ -0,0 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_nuxt_ui = require("./nuxt-ui-CvNwRMiY.cjs");
3
+ exports.definePreset = require_nuxt_ui.definePreset;
4
+ exports.nuxtUi = require_nuxt_ui.nuxtUi;
@@ -0,0 +1,4 @@
1
+ import { _ as Preset, v as PresetOptions, y as definePreset } from "./vars-D-T56h9H.cjs";
2
+ /** The variants of Nuxt UI that WindiUI lacks: `soft`, `subtle`, `ghost` and `link`. `solid` and `outline` exist. */
3
+ export declare const nuxtUi: ({ override, prefix, only }?: PresetOptions) => Preset;
4
+ export { type Preset, type PresetOptions, definePreset };
@@ -0,0 +1,4 @@
1
+ import { S as definePreset, b as Preset, x as PresetOptions } from "./types-7pMUZGLb.mjs";
2
+ /** The variants of Nuxt UI that WindiUI lacks: `soft`, `subtle`, `ghost` and `link`. `solid` and `outline` exist. */
3
+ export declare const nuxtUi: ({ override, prefix, only }?: PresetOptions) => Preset;
4
+ export { type Preset, type PresetOptions, definePreset };
@@ -0,0 +1 @@
1
+ export { n as definePreset, t as nuxtUi } from "./nuxt-ui-S3tspIeQ.mjs";
@@ -51,8 +51,16 @@ interface VariantProperties {
51
51
  type VariantPseudos = Partial<Record<SimplePseudos, Partial<VariantProperties>>>;
52
52
  interface Variant extends VariantProperties {
53
53
  pseudos?: VariantPseudos;
54
- dark?: Omit<Partial<Variant>, 'dark'>;
54
+ dark?: Omit<Partial<Variant>, 'dark' | 'colors'>;
55
+ /** Values of the variant for some colors, by color name; `'amber,lime'` names several. */
56
+ colors?: Record<string, VariantOverride>;
55
57
  }
58
+ type WithShades<T> = { [K in keyof T]?: NonNullable<T[K]> extends string ? T[K] | ExColorShade : WithShades<NonNullable<T[K]>>; };
59
+ /**
60
+ * Any values of a variant, `pseudos` and `dark` included, for some colors. A value is a reference or a shade of the
61
+ * color: `'700'`, `'accent-600'`, `'white'`.
62
+ */
63
+ type VariantOverride = WithShades<Omit<Variant, 'colors'>>;
56
64
  type VariantProperty = keyof VariantProperties | `${keyof VariantProperties}-${SimplePseudos}`;
57
65
  type ApplyVariantMainProp = 'bg' | 'border' | 'text';
58
66
  type ApplyVariantSubProp = 'soft' | 'muted' | 'accent' | 'default';
@@ -61,6 +69,16 @@ type ApplyVariant = boolean | ApplyVariantProp[];
61
69
  type ApplyVariantPseudos = Partial<Record<SimplePseudos, ApplyVariant>> | SimplePseudos[] | false;
62
70
  interface VariantCssVars extends VariantVars {
63
71
  '@dark'?: VariantVars;
72
+ /** The rules of the `compound` override mode, such as `&.c-yellow` */
73
+ [compound: `&.${string}`]: VariantVars & {
74
+ '@dark'?: VariantVars;
75
+ };
76
+ }
77
+ /** Values by key: `bg` for a property, `bg-:hover` for its value in a state. */
78
+ type Values = Record<string, string>;
79
+ interface Flat {
80
+ light: Values;
81
+ dark: Values;
64
82
  }
65
83
  interface VariantContext {
66
84
  apply(v?: ApplyVariant, pseudos?: ApplyVariantPseudos, target?: Properties): Properties;
@@ -72,12 +90,51 @@ interface VariantContext {
72
90
  }
73
91
  declare class VariantsGenerator extends VarsGeneratorBase<Variant, VariantCssVars> implements VariantContext {
74
92
  private readonly scope;
93
+ private readonly mode;
75
94
  protected readonly items: Map<string, Variant>;
76
- constructor(ctx: BuilderContext, scope?: VariantScope);
95
+ /** Palettes given by CSS variables that also take their overrides from variables. */
96
+ private readonly aliases;
97
+ /** Whether a color is applied anywhere; the overrides of the others are left out. Set by `colors.only`. */
98
+ hasColor: (_color: string) => boolean;
99
+ constructor(ctx: BuilderContext, scope?: VariantScope, mode?: OverrideMode);
77
100
  cssVars(name: string): VariantCssVars;
101
+ /**
102
+ * Sets values of a variant for some colors, over those they have.
103
+ * @param under keeps the values set before, so that a preset or a calibration never replaces an explicit override
104
+ */
105
+ override(name: string, colors: string | string[], override: VariantOverride | ((ctx: BuilderContext) => VariantOverride), under?: boolean): void;
106
+ /** The colors that overrides name. */
107
+ overrideColors(): string[];
108
+ /** Makes the palette `color` take its overrides from `{vars}-{variant}-{prop}` variables, or with no `value` stops that. */
109
+ alias(color: string, value?: OverrideVars & {
110
+ vars: string;
111
+ }): void;
112
+ /**
113
+ * The override variables a `c-*` class sets: the values of `color`, and `initial` for the others, so that a color
114
+ * inside another one is not overridden by it. In dark mode it resets a light override where the variant has a dark
115
+ * value of its own. With `accent`, those of the `-accent` properties, for `c-accent-*`.
116
+ */
117
+ colorVars(color: string, accent?: boolean): ColorCssVars;
118
+ private values;
119
+ /**
120
+ * The values of a variant, and its overrides by color: `statics` as configured, `entries` with what a palette given
121
+ * by variables forwards. `keys` get an override variable, which the colors of `varEntries` set.
122
+ */
123
+ private resolved;
78
124
  /** Every variable a variant can set, as `initial`: on a child it stops the parent's variant from inheriting. */
79
125
  resetVars(): VariantVars;
80
126
  utilCss(v: ApplyVariantMainProp, prop?: ApplyVariantSubProp, alpha?: string): Properties;
127
+ /**
128
+ * The CSS of `apply-v`: what `btn` gets, `bg`, `border` and `text` with `:hover`. `list` names props and states
129
+ * instead, such as `bg,text,focus-visible`: the props are applied at rest and in each state. Without props it is
130
+ * all three, without states `:hover`. A name it does not know gives `undefined`.
131
+ */
132
+ applyCss(list?: string): Properties | undefined;
133
+ /**
134
+ * The values of a variant on an element of `color`, its overrides applied as the `c-*` and `v-*` classes would
135
+ * resolve them. `dark` holds the values that change in dark mode.
136
+ */
137
+ colorValues(name: string, color: string): Flat | undefined;
81
138
  /**
82
139
  * The two switches a fallback picks its light or dark value with: `var(on-light, <light>) var(on-dark, <dark>)`.
83
140
  * The one of the current mode is not set, so its fallback is used, and the other one is empty.
@@ -92,7 +149,7 @@ declare class VariantsGenerator extends VarsGeneratorBase<Variant, VariantCssVar
92
149
  private vApplyProp;
93
150
  }
94
151
  type SizeVars = Record<CSSVarName<'s'>, string>;
95
- type SizeProperty = 'text' | `spacing-${keyof Size['spacing']}` | 'line-height';
152
+ type SizeProperty = 'text' | `spacing-${keyof Size['spacing']}` | 'line-height' | 'letter-spacing' | 'font-weight' | (string & {});
96
153
  type Size = {
97
154
  spacing: {
98
155
  '1': string;
@@ -102,10 +159,18 @@ type Size = {
102
159
  '4': string;
103
160
  };
104
161
  text: FontSize;
162
+ /** A key of your own: a string or a number is written to `--wui-s-<key>`, after the built-in variables. */
163
+ [key: string]: unknown;
105
164
  };
106
165
  declare class SizesGenerator extends VarsGeneratorBase<Size, SizeVars> {
107
166
  protected readonly items: Map<string, Size>;
167
+ /** Whether `md` names the `default` size while no size of that name exists. Removing `md` ends it. */
168
+ private md;
108
169
  constructor(ctx: BuilderContext);
170
+ private alias;
171
+ names(): string[];
172
+ update(name: string, builder: (element: Size, ctx: BuilderContext) => Size | void): void;
173
+ remove(name: string): void;
109
174
  cssVars(name: string): SizeVars;
110
175
  }
111
176
  declare class ComponentsGenerator extends BuilderBase<IComponent, ComponentBuilderContext> {
@@ -115,7 +180,8 @@ declare class ComponentsGenerator extends BuilderBase<IComponent, ComponentBuild
115
180
  }
116
181
  type BuilderFunc<TFunc extends (...args: any) => void> = (...args: Parameters<TFunc>) => Builder;
117
182
  interface Builder {
118
- colorsNames: () => string[];
183
+ /** @param all also the palettes that `colors.only` leaves without a class */
184
+ colorsNames: (all?: boolean) => string[];
119
185
  variantsNames: () => string[];
120
186
  sizesNames: () => string[];
121
187
  componentsNames: () => string[];
@@ -126,6 +192,10 @@ interface Builder {
126
192
  addComponent: BuilderFunc<ComponentsGenerator['add']>;
127
193
  /** Adds a color, or replaces the one of that name. */
128
194
  setColor: Builder['addColor'];
195
+ /** Adds a variant, or replaces the one of that name, `default` included. */
196
+ setVariant: BuilderFunc<VariantsGenerator['set']>;
197
+ setSize: BuilderFunc<SizesGenerator['set']>;
198
+ setComponent: BuilderFunc<ComponentsGenerator['set']>;
129
199
  updateColor: BuilderFunc<ColorsGenerator['update']>;
130
200
  updateVariant: BuilderFunc<VariantsGenerator['update']>;
131
201
  updateSize: BuilderFunc<SizesGenerator['update']>;
@@ -134,7 +204,29 @@ interface Builder {
134
204
  removeVariant: BuilderFunc<VariantsGenerator['remove']>;
135
205
  removeSize: BuilderFunc<SizesGenerator['remove']>;
136
206
  removeComponent: BuilderFunc<ComponentsGenerator['remove']>;
207
+ /** Sets values of a variant for one or more colors, over the overrides they have. */
208
+ overrideVariant: (variant: string, colors: string | string[], override: VariantOverride | ((ctx: BuilderContext) => VariantOverride)) => Builder;
209
+ }
210
+ interface PresetOptions {
211
+ /** Replaces an item of the same name that exists. Left out, the preset keeps that item and says so once. */
212
+ override?: boolean;
213
+ /** Namespaces the names of the items the preset adds: `nui` gives `nui-soft`. */
214
+ prefix?: string;
215
+ /** The names, without the prefix, of the items the preset adds or changes; the others are left out. */
216
+ only?: string[];
137
217
  }
218
+ /** A named `build` function, which runs before the `build` of the config. */
219
+ interface Preset {
220
+ readonly name: string;
221
+ build(builder: Builder): void;
222
+ }
223
+ /** Makes a preset from a `build` function. The preset takes the options every preset takes: `override`, `prefix` and `only`. */
224
+ declare function definePreset(name: string, build: (builder: Builder) => void): ({ override, prefix, only }?: PresetOptions) => Preset;
225
+ declare const PRESETS: {
226
+ 'nuxt-ui': ({ override, prefix, only }?: PresetOptions) => Preset;
227
+ };
228
+ /** A preset of WindiUI by name, with its default options, as a config file or an `@plugin` block gives it. */
229
+ type PresetName = keyof typeof PRESETS;
138
230
  /**
139
231
  * Where the default variant comes from for an element without a `v-*` class of its own:
140
232
  * - `universal`: a `*` rule sets it on every element (the 0.7 behaviour);
@@ -153,7 +245,25 @@ type DarkSelectorOption = 'media' | 'class' | 'selector' | ['class' | 'selector'
153
245
  */
154
246
  type ColorValue = string | {
155
247
  vars: string;
248
+ overrideVars?: OverrideVars;
156
249
  } | Record<ColorShade, string>;
250
+ /**
251
+ * Which variant values a palette given by CSS variables also takes from variables, named
252
+ * `{vars}-{variant}-{prop}`, such as `--ui-color-primary-solid-bg-hover` for `bg-:hover`.
253
+ */
254
+ interface OverrideVars {
255
+ /** Left out, every registered variant. */
256
+ variants?: string[];
257
+ /** `'calibrated'`, the default, is `bg`, `fg`, `border` and their `:hover` values; `'all'` is every value of the variant. */
258
+ props?: 'calibrated' | 'all' | VariantProperty[];
259
+ }
260
+ /**
261
+ * How a per-color override reaches the variant:
262
+ * - `vars`: the `c-*` class sets override variables that the `v-*` class reads, wherever the two classes are;
263
+ * - `compound`: a `.c-{color}.v-{variant}` rule, for both classes on one element;
264
+ * - `both`.
265
+ */
266
+ type OverrideMode = 'vars' | 'compound' | 'both';
157
267
  interface ColorOptions {
158
268
  /**
159
269
  * Also registers the palette as a color of the theme, for utilities such as `bg-{name}-{shade}`. This is up to the
@@ -161,6 +271,13 @@ interface ColorOptions {
161
271
  */
162
272
  utilities?: boolean;
163
273
  }
274
+ interface ColorsConfig {
275
+ /**
276
+ * The palettes of the theme that get a `c-*` and a `c-accent-*` class; left out, all of them. Colors of the builder
277
+ * always get theirs, and the root variables of `default` and `accent` stay.
278
+ */
279
+ only?: string[];
280
+ }
164
281
  interface ResolvedConfig {
165
282
  prefix: string;
166
283
  /** Where the root color and size variables are declared. More selectors let a scoped theme resolve them again. */
@@ -169,39 +286,75 @@ interface ResolvedConfig {
169
286
  default?: ColorValue;
170
287
  /** The palette behind `accent`. Left out, it is a complete `accent` palette of the theme, or else blue. */
171
288
  accent?: ColorValue;
289
+ colors?: ColorsConfig;
172
290
  variantScope: VariantScope;
291
+ /** Per-color overrides of variants: `{ solid: { yellow: { bg: '700' }, 'amber,lime': { ... } } }`. */
292
+ overrides?: Record<string, Record<string, VariantOverride>>;
293
+ overrideMode: OverrideMode;
294
+ /**
295
+ * Color utilities from a variant: `{ bg: 'solid' }` gives `bg-{color}` the `solid` background of that color, its
296
+ * overrides and dark value included. Left out, there are none.
297
+ */
298
+ variantUtilities?: Partial<Record<ApplyVariantMainProp, string>>;
173
299
  /** Left out, dark mode follows Tailwind's own. */
174
300
  darkSelector?: DarkSelectorOption;
301
+ /** Run in order, before `build`. */
302
+ presets: Preset[];
175
303
  build?: (builder: Builder) => void;
176
304
  /** Asks the host to emit every `c-*`, `v-*` and `s-*` class, also those it does not find in use. */
177
305
  safelist: boolean;
178
306
  /** Logs what is otherwise skipped silently, such as a theme palette without all 11 shades. */
179
307
  debug: boolean;
180
308
  }
181
- type Config = Partial<ResolvedConfig>;
309
+ type Config = Partial<Omit<ResolvedConfig, 'presets'>> & {
310
+ presets?: (Preset | PresetName)[];
311
+ };
182
312
  /** Types a config object, so that one object can be shared by the plugin, a config file and other tools. */
183
313
  declare function defineConfig(config: Config): Config;
184
314
  type ColorShade = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950';
185
315
  type ExColorShade = ColorShade | `default-${ColorShade}` | `accent-${ColorShade}` | 'black' | 'white';
186
- type ColorVars = Record<CSSVarName<'c'>, string>;
316
+ type ColorVars = Record<CSSVarName<'c' | 'cv'>, string>;
317
+ interface ColorCssVars extends ColorVars {
318
+ '@dark'?: ColorVars;
319
+ }
187
320
  interface ColorContext {
188
321
  toValue(name: ExColorShade | (string & {}), alpha?: number | string): string;
189
322
  }
190
- declare class ColorsGenerator extends VarsGeneratorBase<Map<ColorShade, string>, ColorVars> implements ColorContext {
323
+ declare class ColorsGenerator extends VarsGeneratorBase<Map<ColorShade, string>, ColorCssVars> implements ColorContext {
324
+ private readonly options;
325
+ private readonly variants;
191
326
  private readonly colors;
192
327
  protected readonly items: Map<string, Map<ColorShade, string>>;
193
- constructor(ctx: BuilderContext, options?: Pick<Config, 'default' | 'accent' | 'debug'>);
328
+ /** The colors with a `c-*` class: `colors.only` and those of the builder. Left out, all of them. */
329
+ private readonly only?;
330
+ /** @param variants gives the override variables of each `c-*` class */
331
+ constructor(ctx: BuilderContext, options: Pick<Config, 'default' | 'accent' | 'colors' | 'debug'>, variants: VariantsGenerator);
194
332
  /** The 11 shades of a palette given by name, by CSS variables or as the shades themselves. */
195
333
  resolve(value: ColorValue): Map<ColorShade, string> | undefined;
196
334
  addColor(name: string, value: ColorValue): void;
197
335
  /** Adds a palette, or replaces the one of that name. */
198
336
  setColor(name: string, value: ColorValue): void;
199
- names(): string[];
200
- cssVars(name: string): Record<`--${string}-c-${string}`, string>;
201
- rootVars(): ColorVars;
337
+ remove(name: string): void;
338
+ private alias;
339
+ /** @param all also the palettes that `colors.only` leaves without a class */
340
+ names(all?: boolean): string[];
341
+ /** The names of `colors.only` that are not palettes. */
342
+ unknownOnly(): string[];
343
+ cssVars(name: string): {
344
+ [x: `--${string}-c-${string}`]: string;
345
+ '@dark'?: ColorVars;
346
+ };
347
+ rootVars(): ColorCssVars;
348
+ /**
349
+ * `bg-{color}` and the like of `variantUtilities`: the value of `variant` for this color, overrides included, with
350
+ * its opacity unless `alpha` is given, light and dark. A shade is this palette's, not the element's `c-*` class.
351
+ */
352
+ variantUtilCss(color: string, prop: ApplyVariantMainProp, variant: string, alpha?: string): Properties & {
353
+ '@dark'?: Properties;
354
+ };
202
355
  toValue(name: ExColorShade | (string & {}), alpha?: number | string): string;
203
356
  }
204
- type VarType = 'c' | 'v' | 's';
357
+ type VarType = 'c' | 'v' | 's' | 'cv';
205
358
  type VarName<T extends VarType = VarType> = `${T}-${string}`;
206
359
  type CSSVarName<T extends VarType = VarType> = `--${string}-${VarName<T>}`;
207
360
  type CSSVarValue<T extends VarType = VarType> = `var(${CSSVarName<T>})`;
@@ -209,6 +362,8 @@ interface VarsProvider {
209
362
  c(n: string): CSSVarName<'c'>;
210
363
  v(n: string): CSSVarName<'v'>;
211
364
  s(n: string): CSSVarName<'s'>;
365
+ /** An override variable, such as `cv('solid-bg')`: a `c-*` class sets it and the `v-*` class reads it. */
366
+ cv(n: string): CSSVarName<'cv'>;
212
367
  color: {
213
368
  (name: ExColorShade, fallback?: string): CSSVarValue<'c'>;
214
369
  default(name: ColorShade, fallback?: string): CSSVarValue<'c'>;
@@ -233,6 +388,8 @@ declare abstract class BuilderBase<T, TContext extends BuilderContext> {
233
388
  protected get theme(): ThemeProvider;
234
389
  names(): string[];
235
390
  add(name: string, builder: (ctx: TContext) => T): void;
391
+ /** Adds an item, or replaces the one of that name, `default` included. */
392
+ set(name: string, builder: (ctx: TContext) => T): void;
236
393
  update(name: string, builder: (element: T, ctx: TContext) => T | void): void;
237
394
  remove(name: string): void;
238
395
  }
@@ -255,4 +412,4 @@ interface IComponent {
255
412
  applyVariant?: ApplyVariant;
256
413
  applyVariantPseudos?: ApplyVariantPseudos;
257
414
  }
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 };
415
+ export { ApplyVariantProp as A, Builder as C, SizesGenerator as D, SizeProperty as E, VariantsGenerator as F, FontSize as I, ThemeProvider as L, Variant as M, VariantOverride as N, ApplyVariant as O, VariantProperties as P, css_d_exports as R, definePreset as S, Size as T, ResolvedConfig as _, varsProvider as a, Preset as b, ExColorShade as c, ColorsConfig as d, Config as f, PresetName as g, OverrideVars as h, VarsProvider as i, ApplyVariantSubProp as j, ApplyVariantMainProp as k, ColorOptions as l, OverrideMode as m, ComponentBuilderContext as n, ColorShade as o, DarkSelectorOption as p, IComponent as r, ColorsGenerator as s, ComponentBuilder as t, ColorValue as u, VariantScope as v, ComponentsGenerator as w, PresetOptions as x, defineConfig as y };