@windi-ui/tailwind 0.8.0-beta.1 → 0.8.0
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 +88 -57
- package/dist/index.cjs +15 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +3 -2
- package/dist/{plugin-BmHj0642.cjs → plugin-BDVW4Keh.cjs} +42 -6
- package/dist/{plugin-BWBKFnff.mjs → plugin-DJjsT2Zj.mjs} +42 -6
- package/dist/presets.cjs +15 -0
- package/dist/presets.d.cts +2 -0
- package/dist/presets.d.mts +2 -0
- package/dist/presets.mjs +2 -0
- package/dist/v3.cjs +1 -1
- package/dist/v3.mjs +1 -1
- package/dist/v4.cjs +1 -1
- package/dist/v4.mjs +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/windi-ui/windi-ui/main/docs/public/logo-lockup.svg" alt="WindiUI" width="
|
|
2
|
+
<img src="https://raw.githubusercontent.com/windi-ui/windi-ui/main/docs/public/logo-lockup-npm.svg" alt="WindiUI" width="306">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# WindiUI
|
|
6
6
|
|
|
7
7
|
🚧 under development 🚧
|
|
8
8
|
|
|
9
|
-
WindiUI is a
|
|
9
|
+
WindiUI is a Tailwind CSS plugin that adds three axes to your classes: a color (`c-*`), a variant (`v-*`) and a size
|
|
10
|
+
(`s-*`). Each one is a class that sets CSS variables, so `btn c-blue v-solid s-lg` is a large, solid, blue button, and
|
|
11
|
+
the same `btn` takes every palette of your theme, in light and dark mode.
|
|
12
|
+
|
|
13
|
+
**[Documentation](https://windi-ui.github.io/windi-ui/guide/introduction)** ·
|
|
14
|
+
[Installation](https://windi-ui.github.io/windi-ui/guide/installation) ·
|
|
15
|
+
[Options](https://windi-ui.github.io/windi-ui/reference/options) ·
|
|
16
|
+
[Builder API](https://windi-ui.github.io/windi-ui/reference/builder) ·
|
|
17
|
+
[Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8)
|
|
10
18
|
|
|
11
19
|
## Features
|
|
12
20
|
|
|
13
|
-
- **
|
|
14
|
-
|
|
15
|
-
- **
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
- **Three axes.** `c-*` picks one of your palettes, `v-*` a variant and `s-*` a size. They combine freely, and colors
|
|
22
|
+
and sizes inherit down the tree.
|
|
23
|
+
- **Calibrated variants.** `default`, `solid`, `outline` and `light` pick shades of the 11-shade palette for the
|
|
24
|
+
background, border and text, with soft, muted and accent levels, a hover state and dark values. A variant can use
|
|
25
|
+
other shades for some colors, such as a darker `solid` yellow.
|
|
26
|
+
- **Presets.** `nuxt-ui` adds `soft`, `subtle`, `ghost` and `link`, with text that passes a contrast of 4.5:1.
|
|
27
|
+
- **Components and utilities.** `btn`, `badge`, `bg-v`, `text-v`, `border-v`, and `apply-v` for your own CSS.
|
|
28
|
+
- **Builder API.** Add, replace, change or remove colors, variants, sizes and components.
|
|
29
|
+
- **Runtime palettes.** A color given by CSS variables follows a theme set at runtime.
|
|
30
|
+
- **Dark mode.** Follows the dark variant of your Tailwind setup, with nothing to configure.
|
|
31
|
+
- **Tailwind v3 and v4**, with the same class names.
|
|
18
32
|
|
|
19
33
|
## Getting Started
|
|
20
34
|
|
|
21
35
|
### Prerequisites
|
|
22
36
|
|
|
23
|
-
- Node.js
|
|
24
|
-
-
|
|
37
|
+
- Node.js 22 or higher, or 22.12 or higher to load a
|
|
38
|
+
[config file](https://windi-ui.github.io/windi-ui/reference/config-file). The tests run on Node.js 26.
|
|
39
|
+
- Tailwind CSS v3.3 or higher, or v4. The tests run on Tailwind CSS 3.4, 4.1.16 and the current 4.3.
|
|
25
40
|
|
|
26
41
|
### Installation
|
|
27
42
|
|
|
@@ -36,87 +51,100 @@ On Tailwind v4, load it from your stylesheet:
|
|
|
36
51
|
@plugin "@windi-ui/tailwind";
|
|
37
52
|
```
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
a `windiui.plugin.ts` plugin module that exports `windiui({ ... })` and is loaded with `@plugin "./windiui.plugin.ts"`;
|
|
41
|
-
see [Installation](https://windi-ui.github.io/windi-ui/guide/installation) and [Config file and plugin module](https://windi-ui.github.io/windi-ui/reference/config-file).
|
|
42
|
-
|
|
43
|
-
On Tailwind v3, add the plugin to your `tailwind.config.ts` / `tailwind.config.js` file:
|
|
54
|
+
On Tailwind v3, add it to the plugins of your Tailwind config:
|
|
44
55
|
|
|
45
56
|
```ts
|
|
46
57
|
import type { Config } from 'tailwindcss';
|
|
47
58
|
import windiui from '@windi-ui/tailwind';
|
|
48
59
|
|
|
49
60
|
export default {
|
|
50
|
-
|
|
51
|
-
plugins: [
|
|
52
|
-
windiui()
|
|
53
|
-
],
|
|
61
|
+
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
|
|
62
|
+
plugins: [windiui()],
|
|
54
63
|
} satisfies Config;
|
|
55
64
|
```
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
WindiUI automatically detect all the colors in your theme and make them available to be used with components and utility classes.
|
|
66
|
+
Options go in the `@plugin` block, in a `windiui.config.ts` config file, or in a plugin module; see
|
|
67
|
+
[Installation](https://windi-ui.github.io/windi-ui/guide/installation) and
|
|
68
|
+
[Options](https://windi-ui.github.io/windi-ui/reference/options).
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
### Usage
|
|
64
71
|
|
|
65
72
|
```html
|
|
66
|
-
<
|
|
73
|
+
<button class="btn c-blue v-solid">Save</button>
|
|
74
|
+
<button class="btn c-red v-outline s-sm">Delete</button>
|
|
75
|
+
<button class="btn c-blue v-light s-lg">Inbox <span class="badge c-red v-solid">3</span></button>
|
|
76
|
+
<div class="c-green v-light bg-v text-v border border-v-muted rounded p-4">A box painted by its variant</div>
|
|
77
|
+
<div class="c-amber bg-c-100 text-c-800 p-4">Shades of the current color</div>
|
|
67
78
|
```
|
|
68
79
|
|
|
69
|
-
|
|
80
|
+
A plugin module configures WindiUI with the builder API. This one adds the `nuxt-ui` variants, gives `solid` a darker
|
|
81
|
+
background with yellow, and adds a `c-primary` color whose shades are CSS variables set at runtime:
|
|
70
82
|
|
|
71
|
-
|
|
83
|
+
```ts
|
|
84
|
+
// windiui.plugin.ts
|
|
85
|
+
import windiui from '@windi-ui/tailwind';
|
|
72
86
|
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
export default windiui({
|
|
88
|
+
presets: ['nuxt-ui'],
|
|
89
|
+
build: (builder) => builder
|
|
90
|
+
.overrideVariant('solid', 'yellow', { bg: '700', pseudos: { ':hover': { bg: '800' } } })
|
|
91
|
+
.addColor('primary', { vars: '--ui-color-primary' }),
|
|
92
|
+
});
|
|
75
93
|
```
|
|
76
94
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
```css
|
|
96
|
+
@import "tailwindcss";
|
|
97
|
+
@plugin "./windiui.plugin.ts";
|
|
98
|
+
```
|
|
80
99
|
|
|
81
100
|
```html
|
|
82
|
-
<button class="btn
|
|
83
|
-
|
|
84
|
-
<span class="badge v-solid c-red leading-none rounded-full absolute top-0 start-full -translate-1/2">32</span>
|
|
85
|
-
</button>
|
|
101
|
+
<button class="btn c-yellow v-solid">Solid yellow, on shade 700</button>
|
|
102
|
+
<button class="btn c-primary v-soft">Soft, in the runtime color</button>
|
|
86
103
|
```
|
|
87
104
|
|
|
88
|
-
|
|
105
|
+
The [guide](https://windi-ui.github.io/windi-ui/guide/introduction) covers each part, with live examples. The
|
|
106
|
+
[playground](https://github.com/windi-ui/windi-ui/blob/main/playground/vue-tailwindv4/src/App.vue) has more.
|
|
89
107
|
|
|
90
|
-
####
|
|
108
|
+
#### Variants and sizes in your own CSS
|
|
91
109
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
On Tailwind v4, add one line to the stylesheet. `safelistSource()` returns the string for your config:
|
|
110
|
+
`apply-v` paints the background, border and text from the current variant, at rest and on hover, as `btn` does. A
|
|
111
|
+
list in brackets chooses the properties and the states. The `s-*` classes set size variables that a control of your
|
|
112
|
+
own can read:
|
|
96
113
|
|
|
97
114
|
```css
|
|
98
|
-
@
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
import { safelistSource } from '@windi-ui/tailwind';
|
|
115
|
+
@import "tailwindcss";
|
|
116
|
+
@plugin "@windi-ui/tailwind";
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
.card-action { @apply apply-v; } /* bg, border, text + :hover */
|
|
119
|
+
.tab { @apply apply-v-[bg,text,hover,focus-visible]; } /* chosen properties and states */
|
|
120
|
+
.my-input { /* as tall as a btn of the same size */
|
|
121
|
+
padding: calc(var(--wui-s-spacing-1\.5) - 1px) calc(var(--wui-s-spacing-3) - 1px);
|
|
122
|
+
border: 1px solid;
|
|
123
|
+
font-size: var(--wui-s-text);
|
|
124
|
+
line-height: var(--wui-s-line-height);
|
|
125
|
+
}
|
|
105
126
|
```
|
|
106
127
|
|
|
107
|
-
|
|
128
|
+
| Size variable | Meaning |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `--wui-s-spacing-1`, `-1\.5`, `-2`, `-3`, `-4` | Spacing slots |
|
|
131
|
+
| `--wui-s-text`, `--wui-s-line-height` | Font size and line height |
|
|
132
|
+
| `--wui-s-<key>` | A key of your own on a size, such as `height` for an app that wants a fixed control height |
|
|
108
133
|
|
|
109
|
-
|
|
134
|
+
The `variantUtilities` option adds color utilities painted from a variant, such as `bg-yellow` with the `solid`
|
|
135
|
+
background of yellow, overrides and dark values included. See
|
|
136
|
+
[Utilities](https://windi-ui.github.io/windi-ui/guide/utilities) and
|
|
137
|
+
[Sizes](https://windi-ui.github.io/windi-ui/guide/sizes).
|
|
110
138
|
|
|
111
139
|
## Upgrading from 0.7
|
|
112
140
|
|
|
113
|
-
See [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8). The one thing to check: 0.8
|
|
114
|
-
element with a `*` rule (the new `variantScope` option, default
|
|
115
|
-
`text-v`, `border-v` utilities look the same, but your own CSS that
|
|
116
|
-
`background: var(--wui-v-bg)`, on an element without a `v-*` class no
|
|
117
|
-
`windiui({ variantScope: 'universal' })` to keep the 0.7 output, or give the rule a
|
|
118
|
-
`@apply v-default v-scope`. A rule that uses `@apply v-*` should also apply `v-scope`, so its children
|
|
119
|
-
inherit the variant.
|
|
141
|
+
See [Changes in 0.8](https://windi-ui.github.io/windi-ui/changes-0.8#upgrading-from-0-7). The one thing to check: 0.8
|
|
142
|
+
no longer sets the default variant on every element with a `*` rule (the new `variantScope` option, default
|
|
143
|
+
`'element'`). `btn`, `badge` and the `bg-v`, `text-v`, `border-v` utilities look the same, but your own CSS that
|
|
144
|
+
reads a variant variable directly, such as `background: var(--wui-v-bg)`, on an element without a `v-*` class no
|
|
145
|
+
longer gets a value. Either set `windiui({ variantScope: 'universal' })` to keep the 0.7 output, or give the rule a
|
|
146
|
+
variant with `@apply v-default v-scope`. A rule that uses `@apply v-*` should also apply `v-scope`, so its children
|
|
147
|
+
do not inherit the variant.
|
|
120
148
|
|
|
121
149
|
## Documentation
|
|
122
150
|
|
|
@@ -169,6 +197,9 @@ The tests are in `test/` and run on Vitest.
|
|
|
169
197
|
snapshot diff with the code, so the review shows what changed for users.
|
|
170
198
|
- **Browser.** `test/browser.test.ts` checks what a snapshot cannot: how the CSS cascades and inherits.
|
|
171
199
|
It drives the Chrome or Edge already installed on the machine, and is skipped locally if there is neither.
|
|
200
|
+
- **README.** `test/readme.ts` compiles every TypeScript sample of this file on each fixture and every CSS sample
|
|
201
|
+
on the Tailwind v4 ones, and checks that the classes of its HTML samples exist. Keep the samples compilable when
|
|
202
|
+
you change them.
|
|
172
203
|
- A test file works with one fixture only, because the helper that loads a fixture changes the working directory.
|
|
173
204
|
|
|
174
205
|
### Project Structure
|
package/dist/index.cjs
CHANGED
|
@@ -2,10 +2,12 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_plugin = require("./plugin-
|
|
5
|
+
const require_plugin = require("./plugin-BDVW4Keh.cjs");
|
|
6
6
|
const require_config = require("./config.cjs");
|
|
7
7
|
const require_safelist = require("./safelist.cjs");
|
|
8
|
+
require("./presets.cjs");
|
|
8
9
|
let _windi_ui_core = require("@windi-ui/core");
|
|
10
|
+
let _windi_ui_core_presets = require("@windi-ui/core/presets");
|
|
9
11
|
// src/index.ts
|
|
10
12
|
var src_default = require_plugin.createWindiUIPlugin();
|
|
11
13
|
exports.classSource = require_safelist.classSource;
|
|
@@ -16,7 +18,19 @@ Object.defineProperty(exports, "defineConfig", {
|
|
|
16
18
|
return _windi_ui_core.defineConfig;
|
|
17
19
|
}
|
|
18
20
|
});
|
|
21
|
+
Object.defineProperty(exports, "definePreset", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return _windi_ui_core_presets.definePreset;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
19
27
|
exports.loadWindiUIConfig = require_config.loadWindiUIConfig;
|
|
28
|
+
Object.defineProperty(exports, "nuxtUi", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function() {
|
|
31
|
+
return _windi_ui_core_presets.nuxtUi;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
20
34
|
exports.safelistSource = require_safelist.safelistSource;
|
|
21
35
|
|
|
22
36
|
module.exports = Object.assign(exports.default, exports);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { n as WindiUIPlugin } from "./plugin-QCWiD6Wb.cjs";
|
|
2
2
|
import { Config, LoadConfigOptions, LoadedConfig, defineConfig, loadWindiUIConfig } from "./config.cjs";
|
|
3
3
|
import { SafelistAxis, SafelistOptions, classSource, safelistSource } from "./safelist.cjs";
|
|
4
|
+
import { Preset, PresetOptions, definePreset, nuxtUi } from "./presets.cjs";
|
|
4
5
|
declare const _default: WindiUIPlugin<{
|
|
5
6
|
handler: import("tailwindcss/types/config").PluginCreator;
|
|
6
7
|
config?: Partial<import("tailwindcss/types/config").Config>;
|
|
7
8
|
}>;
|
|
8
9
|
declare function _cjs(...args: Parameters<typeof _default>): ReturnType<typeof _default>;
|
|
9
10
|
declare namespace _cjs {
|
|
10
|
-
export { type Config, LoadConfigOptions, LoadedConfig, SafelistAxis, SafelistOptions, classSource, _default as default, defineConfig, loadWindiUIConfig, safelistSource };
|
|
11
|
+
export { type Config, LoadConfigOptions, LoadedConfig, type Preset, type PresetOptions, SafelistAxis, SafelistOptions, classSource, _default as default, defineConfig, definePreset, loadWindiUIConfig, nuxtUi, safelistSource };
|
|
11
12
|
export const __isOptionsFunction: true;
|
|
12
13
|
}
|
|
13
14
|
export = _cjs;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { n as WindiUIPlugin } from "./plugin-ayXaeLBM.mjs";
|
|
2
2
|
import { Config, LoadConfigOptions, LoadedConfig, defineConfig, loadWindiUIConfig } from "./config.mjs";
|
|
3
3
|
import { SafelistAxis, SafelistOptions, classSource, safelistSource } from "./safelist.mjs";
|
|
4
|
+
import { Preset, PresetOptions, definePreset, nuxtUi } from "./presets.mjs";
|
|
4
5
|
declare const _default: WindiUIPlugin<{
|
|
5
6
|
handler: import("tailwindcss/types/config").PluginCreator;
|
|
6
7
|
config?: Partial<import("tailwindcss/types/config").Config>;
|
|
7
8
|
}>;
|
|
8
|
-
export { type Config, LoadConfigOptions, LoadedConfig, SafelistAxis, SafelistOptions, classSource, _default as default, defineConfig, loadWindiUIConfig, safelistSource };
|
|
9
|
+
export { type Config, LoadConfigOptions, LoadedConfig, type Preset, type PresetOptions, SafelistAxis, SafelistOptions, classSource, _default as default, defineConfig, definePreset, loadWindiUIConfig, nuxtUi, safelistSource };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { t as createWindiUIPlugin } from "./plugin-
|
|
1
|
+
import { t as createWindiUIPlugin } from "./plugin-DJjsT2Zj.mjs";
|
|
2
2
|
import { defineConfig, loadWindiUIConfig } from "./config.mjs";
|
|
3
3
|
import { classSource, safelistSource } from "./safelist.mjs";
|
|
4
|
+
import { definePreset, nuxtUi } from "./presets.mjs";
|
|
4
5
|
// src/index.ts
|
|
5
6
|
var src_default = createWindiUIPlugin();
|
|
6
|
-
export { classSource, src_default as default, defineConfig, loadWindiUIConfig, safelistSource };
|
|
7
|
+
export { classSource, src_default as default, defineConfig, definePreset, loadWindiUIConfig, nuxtUi, safelistSource };
|
|
7
8
|
|
|
@@ -230,6 +230,10 @@ function getDarkSelector(darkMode) {
|
|
|
230
230
|
default: return [selector];
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
+
/** The dark selector for a rule on the root element, which `&:is(.dark *)` never matches and `&:not(.light *)` always does: it has no ancestor. */
|
|
234
|
+
function rootDarkSelector(selector) {
|
|
235
|
+
return selector.map((chain) => chain.map((s) => s.replace(/^&:(is|not)\((.+) \*\)$/, "&:$1($2, $2 *)")));
|
|
236
|
+
}
|
|
233
237
|
function setNestedValue(obj, keys, value) {
|
|
234
238
|
if (keys.length === 0) return obj;
|
|
235
239
|
let curr = obj;
|
|
@@ -245,6 +249,7 @@ function setNestedValue(obj, keys, value) {
|
|
|
245
249
|
}
|
|
246
250
|
function applyDark(selector, styles) {
|
|
247
251
|
const { "@dark": darkStyle, ...style } = styles;
|
|
252
|
+
for (const [key, value] of Object.entries(style)) if (value && typeof value === "object" && "@dark" in value) style[key] = applyDark(selector, value);
|
|
248
253
|
if (darkStyle) for (const s of selector) setNestedValue(style, s, darkStyle);
|
|
249
254
|
return style;
|
|
250
255
|
}
|
|
@@ -323,8 +328,13 @@ const OPTIONS = [
|
|
|
323
328
|
"rootSelector",
|
|
324
329
|
"default",
|
|
325
330
|
"accent",
|
|
331
|
+
"colors",
|
|
326
332
|
"variantScope",
|
|
333
|
+
"overrides",
|
|
334
|
+
"overrideMode",
|
|
335
|
+
"variantUtilities",
|
|
327
336
|
"darkSelector",
|
|
337
|
+
"presets",
|
|
328
338
|
"build",
|
|
329
339
|
"safelist",
|
|
330
340
|
"debug",
|
|
@@ -345,7 +355,10 @@ function resolveOptions(options = {}, strict = false) {
|
|
|
345
355
|
continue;
|
|
346
356
|
}
|
|
347
357
|
if (key === "build" && value != null && typeof value !== "function") throw new Error("WindiUI: `build` is a function, which an `@plugin` block cannot hold. Put it in a config file or a plugin module.");
|
|
358
|
+
if ((key === "overrides" || key === "variantUtilities") && value != null && (typeof value !== "object" || Array.isArray(value))) throw new Error(`WindiUI: \`${key}\` is an object, which an \`@plugin\` block cannot hold. Put it in a config file or a plugin module.`);
|
|
348
359
|
if (value !== void 0) inline[key] = key === "rootSelector" && Array.isArray(value) ? value.join(", ") : value;
|
|
360
|
+
if (key === "presets" && typeof value === "string") inline[key] = [value];
|
|
361
|
+
if (key === "colors" && (typeof value === "string" || Array.isArray(value))) inline[key] = { only: [value].flat() };
|
|
349
362
|
}
|
|
350
363
|
const { config: file, ...config } = inline;
|
|
351
364
|
if (file === false || file == null && config.build || require_configState.isLoadingConfig()) return config;
|
|
@@ -355,10 +368,10 @@ function resolveOptions(options = {}, strict = false) {
|
|
|
355
368
|
};
|
|
356
369
|
}
|
|
357
370
|
/**
|
|
358
|
-
* The palettes `build`
|
|
359
|
-
*
|
|
371
|
+
* The palettes the presets and `build` add with `utilities: true`. Tailwind resolves its theme before the builder can
|
|
372
|
+
* run, so they are first run on a builder that does nothing but note them.
|
|
360
373
|
*/
|
|
361
|
-
function utilityColors(build, inTheme) {
|
|
374
|
+
function utilityColors({ presets, build }, inTheme) {
|
|
362
375
|
const found = /* @__PURE__ */ new Map();
|
|
363
376
|
const removed = /* @__PURE__ */ new Set();
|
|
364
377
|
const set = (name, value, options) => {
|
|
@@ -372,6 +385,7 @@ function utilityColors(build, inTheme) {
|
|
|
372
385
|
removeColor: (name) => (found.delete(name), removed.add(name), builder)
|
|
373
386
|
}, { get: (target, key) => target[key] ?? (() => key.endsWith("Names") ? [] : builder) });
|
|
374
387
|
try {
|
|
388
|
+
for (const preset of presets) preset.build(builder);
|
|
375
389
|
build?.(builder);
|
|
376
390
|
} catch {}
|
|
377
391
|
return found;
|
|
@@ -406,7 +420,7 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
406
420
|
const darkMode = wiu.config.darkSelector != null ? toDarkMode(wiu.config.darkSelector) : tw.config("darkMode");
|
|
407
421
|
const darkSelector = darkMode != null ? getDarkSelector(darkMode) : tp.ver === 4 && tailwindAtLeast(4, 1, 17) ? VARIANT_DARK : getDarkSelector("media");
|
|
408
422
|
const root = wiu.config.rootSelector;
|
|
409
|
-
tw.addBase({ [root]: gt.colors.rootVars() });
|
|
423
|
+
tw.addBase({ [root]: applyDark(rootDarkSelector(darkSelector), gt.colors.rootVars()) });
|
|
410
424
|
tw.addBase({ [root]: gt.sizes.rootVars() });
|
|
411
425
|
const scope = wiu.config.variantScope;
|
|
412
426
|
if (scope === "universal") tw.addBase({ "*": applyDark(darkSelector, gt.variants.rootVars()) });
|
|
@@ -438,7 +452,7 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
438
452
|
s: sizeNames
|
|
439
453
|
})}");`);
|
|
440
454
|
}
|
|
441
|
-
tw.matchUtilities({ c: known(colorNames, (val) => gt.colors.cssVars(val)) }, { values: keyValuePairs(colorNames) });
|
|
455
|
+
tw.matchUtilities({ c: known(colorNames, (val) => applyDark(darkSelector, gt.colors.cssVars(val))) }, { values: keyValuePairs(colorNames) });
|
|
442
456
|
tw.matchUtilities({ v: known(variantNames, (val) => applyDark(darkSelector, gt.variants.cssVars(val))) }, { values: keyValuePairs(variantNames) });
|
|
443
457
|
const variantUtil = (prop) => known(Object.values(VARIANT_UTILS), (val, ext) => gt.variants.utilCss(prop, val, ext.modifier ?? void 0));
|
|
444
458
|
tw.matchUtilities({
|
|
@@ -450,6 +464,28 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
450
464
|
modifiers: tw.theme("opacity"),
|
|
451
465
|
...tp.ver === 3 ? { type: ["lookup"] } : {}
|
|
452
466
|
});
|
|
467
|
+
tw.matchUtilities({ "apply-v": (val) => gt.variants.applyCss(val) ?? NOTHING }, { values: { DEFAULT: "" } });
|
|
468
|
+
const variantUtils = Object.entries(wiu.config.variantUtilities ?? {}).filter(([prop, variant]) => {
|
|
469
|
+
if (![
|
|
470
|
+
"bg",
|
|
471
|
+
"border",
|
|
472
|
+
"text"
|
|
473
|
+
].includes(prop)) {
|
|
474
|
+
console.error(`WindiUI: \`variantUtilities\` takes bg, border and text, not "${prop}".`);
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
if (!variantNames.includes(variant)) console.error(`WindiUI: \`variantUtilities\` names the variant "${variant}", which does not exist.`);
|
|
478
|
+
return variantNames.includes(variant);
|
|
479
|
+
});
|
|
480
|
+
if (variantUtils.length) {
|
|
481
|
+
const theme = tp.colors();
|
|
482
|
+
const named = colorNames.filter((c) => !(c.startsWith("accent-") && colorNames.includes(c.slice(7))) && !(c in theme));
|
|
483
|
+
tw.matchUtilities(Object.fromEntries(variantUtils.map(([prop, variant]) => [prop, known(named, (color, ext) => applyDark(darkSelector, gt.colors.variantUtilCss(color, prop, variant, ext.modifier ?? void 0)))])), {
|
|
484
|
+
values: keyValuePairs(named),
|
|
485
|
+
modifiers: tw.theme("opacity"),
|
|
486
|
+
type: ["lookup"]
|
|
487
|
+
});
|
|
488
|
+
}
|
|
453
489
|
tw.matchUtilities({ s: known(sizeNames, (val) => gt.sizes.cssVars(val)) }, { values: keyValuePairs(sizeNames) });
|
|
454
490
|
tw.addComponents([...gt.components.css()]);
|
|
455
491
|
}, {
|
|
@@ -479,7 +515,7 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
479
515
|
const shades = Object.keys(fallback[name]).filter((s) => !theme.includes(`${name}-${s}`));
|
|
480
516
|
if (wiu.config[name] == null && shades.length && shades.length < 11) missing[name] = shades;
|
|
481
517
|
}
|
|
482
|
-
utilities ??= utilityColors(wiu.config
|
|
518
|
+
utilities ??= utilityColors(wiu.config, inTheme);
|
|
483
519
|
const own = {};
|
|
484
520
|
for (const [name, value] of utilities) if (typeof value !== "string") own[name] = "vars" in value ? keyValuePairs(Object.keys(colors.gray), (s) => isV3 ? `rgb(var(${value.vars}-${s}) / <alpha-value>)` : `var(${value.vars}-${s})`) : value;
|
|
485
521
|
else if (value in colors) own[name] = colors[value];
|
|
@@ -230,6 +230,10 @@ function getDarkSelector(darkMode) {
|
|
|
230
230
|
default: return [selector];
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
+
/** The dark selector for a rule on the root element, which `&:is(.dark *)` never matches and `&:not(.light *)` always does: it has no ancestor. */
|
|
234
|
+
function rootDarkSelector(selector) {
|
|
235
|
+
return selector.map((chain) => chain.map((s) => s.replace(/^&:(is|not)\((.+) \*\)$/, "&:$1($2, $2 *)")));
|
|
236
|
+
}
|
|
233
237
|
function setNestedValue(obj, keys, value) {
|
|
234
238
|
if (keys.length === 0) return obj;
|
|
235
239
|
let curr = obj;
|
|
@@ -245,6 +249,7 @@ function setNestedValue(obj, keys, value) {
|
|
|
245
249
|
}
|
|
246
250
|
function applyDark(selector, styles) {
|
|
247
251
|
const { "@dark": darkStyle, ...style } = styles;
|
|
252
|
+
for (const [key, value] of Object.entries(style)) if (value && typeof value === "object" && "@dark" in value) style[key] = applyDark(selector, value);
|
|
248
253
|
if (darkStyle) for (const s of selector) setNestedValue(style, s, darkStyle);
|
|
249
254
|
return style;
|
|
250
255
|
}
|
|
@@ -323,8 +328,13 @@ const OPTIONS = [
|
|
|
323
328
|
"rootSelector",
|
|
324
329
|
"default",
|
|
325
330
|
"accent",
|
|
331
|
+
"colors",
|
|
326
332
|
"variantScope",
|
|
333
|
+
"overrides",
|
|
334
|
+
"overrideMode",
|
|
335
|
+
"variantUtilities",
|
|
327
336
|
"darkSelector",
|
|
337
|
+
"presets",
|
|
328
338
|
"build",
|
|
329
339
|
"safelist",
|
|
330
340
|
"debug",
|
|
@@ -345,7 +355,10 @@ function resolveOptions(options = {}, strict = false) {
|
|
|
345
355
|
continue;
|
|
346
356
|
}
|
|
347
357
|
if (key === "build" && value != null && typeof value !== "function") throw new Error("WindiUI: `build` is a function, which an `@plugin` block cannot hold. Put it in a config file or a plugin module.");
|
|
358
|
+
if ((key === "overrides" || key === "variantUtilities") && value != null && (typeof value !== "object" || Array.isArray(value))) throw new Error(`WindiUI: \`${key}\` is an object, which an \`@plugin\` block cannot hold. Put it in a config file or a plugin module.`);
|
|
348
359
|
if (value !== void 0) inline[key] = key === "rootSelector" && Array.isArray(value) ? value.join(", ") : value;
|
|
360
|
+
if (key === "presets" && typeof value === "string") inline[key] = [value];
|
|
361
|
+
if (key === "colors" && (typeof value === "string" || Array.isArray(value))) inline[key] = { only: [value].flat() };
|
|
349
362
|
}
|
|
350
363
|
const { config: file, ...config } = inline;
|
|
351
364
|
if (file === false || file == null && config.build || isLoadingConfig()) return config;
|
|
@@ -355,10 +368,10 @@ function resolveOptions(options = {}, strict = false) {
|
|
|
355
368
|
};
|
|
356
369
|
}
|
|
357
370
|
/**
|
|
358
|
-
* The palettes `build`
|
|
359
|
-
*
|
|
371
|
+
* The palettes the presets and `build` add with `utilities: true`. Tailwind resolves its theme before the builder can
|
|
372
|
+
* run, so they are first run on a builder that does nothing but note them.
|
|
360
373
|
*/
|
|
361
|
-
function utilityColors(build, inTheme) {
|
|
374
|
+
function utilityColors({ presets, build }, inTheme) {
|
|
362
375
|
const found = /* @__PURE__ */ new Map();
|
|
363
376
|
const removed = /* @__PURE__ */ new Set();
|
|
364
377
|
const set = (name, value, options) => {
|
|
@@ -372,6 +385,7 @@ function utilityColors(build, inTheme) {
|
|
|
372
385
|
removeColor: (name) => (found.delete(name), removed.add(name), builder)
|
|
373
386
|
}, { get: (target, key) => target[key] ?? (() => key.endsWith("Names") ? [] : builder) });
|
|
374
387
|
try {
|
|
388
|
+
for (const preset of presets) preset.build(builder);
|
|
375
389
|
build?.(builder);
|
|
376
390
|
} catch {}
|
|
377
391
|
return found;
|
|
@@ -406,7 +420,7 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
406
420
|
const darkMode = wiu.config.darkSelector != null ? toDarkMode(wiu.config.darkSelector) : tw.config("darkMode");
|
|
407
421
|
const darkSelector = darkMode != null ? getDarkSelector(darkMode) : tp.ver === 4 && tailwindAtLeast(4, 1, 17) ? VARIANT_DARK : getDarkSelector("media");
|
|
408
422
|
const root = wiu.config.rootSelector;
|
|
409
|
-
tw.addBase({ [root]: gt.colors.rootVars() });
|
|
423
|
+
tw.addBase({ [root]: applyDark(rootDarkSelector(darkSelector), gt.colors.rootVars()) });
|
|
410
424
|
tw.addBase({ [root]: gt.sizes.rootVars() });
|
|
411
425
|
const scope = wiu.config.variantScope;
|
|
412
426
|
if (scope === "universal") tw.addBase({ "*": applyDark(darkSelector, gt.variants.rootVars()) });
|
|
@@ -438,7 +452,7 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
438
452
|
s: sizeNames
|
|
439
453
|
})}");`);
|
|
440
454
|
}
|
|
441
|
-
tw.matchUtilities({ c: known(colorNames, (val) => gt.colors.cssVars(val)) }, { values: keyValuePairs(colorNames) });
|
|
455
|
+
tw.matchUtilities({ c: known(colorNames, (val) => applyDark(darkSelector, gt.colors.cssVars(val))) }, { values: keyValuePairs(colorNames) });
|
|
442
456
|
tw.matchUtilities({ v: known(variantNames, (val) => applyDark(darkSelector, gt.variants.cssVars(val))) }, { values: keyValuePairs(variantNames) });
|
|
443
457
|
const variantUtil = (prop) => known(Object.values(VARIANT_UTILS), (val, ext) => gt.variants.utilCss(prop, val, ext.modifier ?? void 0));
|
|
444
458
|
tw.matchUtilities({
|
|
@@ -450,6 +464,28 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
450
464
|
modifiers: tw.theme("opacity"),
|
|
451
465
|
...tp.ver === 3 ? { type: ["lookup"] } : {}
|
|
452
466
|
});
|
|
467
|
+
tw.matchUtilities({ "apply-v": (val) => gt.variants.applyCss(val) ?? NOTHING }, { values: { DEFAULT: "" } });
|
|
468
|
+
const variantUtils = Object.entries(wiu.config.variantUtilities ?? {}).filter(([prop, variant]) => {
|
|
469
|
+
if (![
|
|
470
|
+
"bg",
|
|
471
|
+
"border",
|
|
472
|
+
"text"
|
|
473
|
+
].includes(prop)) {
|
|
474
|
+
console.error(`WindiUI: \`variantUtilities\` takes bg, border and text, not "${prop}".`);
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
if (!variantNames.includes(variant)) console.error(`WindiUI: \`variantUtilities\` names the variant "${variant}", which does not exist.`);
|
|
478
|
+
return variantNames.includes(variant);
|
|
479
|
+
});
|
|
480
|
+
if (variantUtils.length) {
|
|
481
|
+
const theme = tp.colors();
|
|
482
|
+
const named = colorNames.filter((c) => !(c.startsWith("accent-") && colorNames.includes(c.slice(7))) && !(c in theme));
|
|
483
|
+
tw.matchUtilities(Object.fromEntries(variantUtils.map(([prop, variant]) => [prop, known(named, (color, ext) => applyDark(darkSelector, gt.colors.variantUtilCss(color, prop, variant, ext.modifier ?? void 0)))])), {
|
|
484
|
+
values: keyValuePairs(named),
|
|
485
|
+
modifiers: tw.theme("opacity"),
|
|
486
|
+
type: ["lookup"]
|
|
487
|
+
});
|
|
488
|
+
}
|
|
453
489
|
tw.matchUtilities({ s: known(sizeNames, (val) => gt.sizes.cssVars(val)) }, { values: keyValuePairs(sizeNames) });
|
|
454
490
|
tw.addComponents([...gt.components.css()]);
|
|
455
491
|
}, {
|
|
@@ -479,7 +515,7 @@ function WindiUITailwindCSS(config, ver) {
|
|
|
479
515
|
const shades = Object.keys(fallback[name]).filter((s) => !theme.includes(`${name}-${s}`));
|
|
480
516
|
if (wiu.config[name] == null && shades.length && shades.length < 11) missing[name] = shades;
|
|
481
517
|
}
|
|
482
|
-
utilities ??= utilityColors(wiu.config
|
|
518
|
+
utilities ??= utilityColors(wiu.config, inTheme);
|
|
483
519
|
const own = {};
|
|
484
520
|
for (const [name, value] of utilities) if (typeof value !== "string") own[name] = "vars" in value ? keyValuePairs(Object.keys(colors.gray), (s) => isV3 ? `rgb(var(${value.vars}-${s}) / <alpha-value>)` : `var(${value.vars}-${s})`) : value;
|
|
485
521
|
else if (value in colors) own[name] = colors[value];
|
package/dist/presets.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _windi_ui_core_presets = require("@windi-ui/core/presets");
|
|
3
|
+
Object.defineProperty(exports, "definePreset", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _windi_ui_core_presets.definePreset;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(exports, "nuxtUi", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return _windi_ui_core_presets.nuxtUi;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
package/dist/presets.mjs
ADDED
package/dist/v3.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/v3.ts
|
|
2
2
|
/** Builds for Tailwind 3 without looking at the Tailwind that runs the plugin. */
|
|
3
|
-
var v3_default = require("./plugin-
|
|
3
|
+
var v3_default = require("./plugin-BDVW4Keh.cjs").createWindiUIPlugin(3);
|
|
4
4
|
module.exports = v3_default;
|
|
5
5
|
|
package/dist/v3.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createWindiUIPlugin } from "./plugin-
|
|
1
|
+
import { t as createWindiUIPlugin } from "./plugin-DJjsT2Zj.mjs";
|
|
2
2
|
// src/v3.ts
|
|
3
3
|
/** Builds for Tailwind 3 without looking at the Tailwind that runs the plugin. */
|
|
4
4
|
var v3_default = createWindiUIPlugin(3);
|
package/dist/v4.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/v4.ts
|
|
2
2
|
/** Builds for Tailwind 4 without looking at the Tailwind that runs the plugin. */
|
|
3
|
-
var v4_default = require("./plugin-
|
|
3
|
+
var v4_default = require("./plugin-BDVW4Keh.cjs").createWindiUIPlugin(4);
|
|
4
4
|
module.exports = v4_default;
|
|
5
5
|
|
package/dist/v4.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createWindiUIPlugin } from "./plugin-
|
|
1
|
+
import { t as createWindiUIPlugin } from "./plugin-DJjsT2Zj.mjs";
|
|
2
2
|
// src/v4.ts
|
|
3
3
|
/** Builds for Tailwind 4 without looking at the Tailwind that runs the plugin. */
|
|
4
4
|
var v4_default = createWindiUIPlugin(4);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windi-ui/tailwind",
|
|
3
|
-
"version": "0.8.0
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Waleed Khaled <https://github.com/Waleed-KH>",
|
|
6
6
|
"description": "Modern, modular, and customizable UI component library",
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"import": "./dist/config.mjs",
|
|
30
30
|
"require": "./dist/config.cjs"
|
|
31
31
|
},
|
|
32
|
+
"./presets": {
|
|
33
|
+
"import": "./dist/presets.mjs",
|
|
34
|
+
"require": "./dist/presets.cjs"
|
|
35
|
+
},
|
|
32
36
|
"./safelist": {
|
|
33
37
|
"import": "./dist/safelist.mjs",
|
|
34
38
|
"require": "./dist/safelist.cjs"
|
|
@@ -47,7 +51,7 @@
|
|
|
47
51
|
"dist"
|
|
48
52
|
],
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@windi-ui/core": "0.8.0
|
|
54
|
+
"@windi-ui/core": "0.8.0",
|
|
51
55
|
"unconfig": "^7.5.0"
|
|
52
56
|
},
|
|
53
57
|
"peerDependencies": {
|