@windi-ui/tailwind 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/config.cjs +92 -0
- package/dist/config.d.cts +18 -0
- package/dist/config.d.mts +18 -0
- package/dist/config.mjs +85 -0
- package/dist/configState-BnylRpdM.cjs +42 -0
- package/dist/configState-DfiH-8b9.mjs +19 -0
- package/dist/index.cjs +22 -330
- package/dist/index.d.cts +13 -6
- package/dist/index.d.mts +8 -6
- package/dist/index.mjs +6 -322
- package/dist/plugin-BWBKFnff.mjs +504 -0
- package/dist/plugin-BmHj0642.cjs +509 -0
- package/dist/plugin-QCWiD6Wb.d.cts +16 -0
- package/dist/plugin-ayXaeLBM.d.mts +17 -0
- package/dist/safelist.cjs +85 -0
- package/dist/safelist.d.cts +21 -0
- package/dist/safelist.d.mts +21 -0
- package/dist/safelist.mjs +83 -0
- package/dist/v3.cjs +5 -0
- package/dist/v3.d.cts +7 -0
- package/dist/v3.d.mts +7 -0
- package/dist/v3.mjs +6 -0
- package/dist/v4.cjs +5 -0
- package/dist/v4.d.cts +4 -0
- package/dist/v4.d.mts +4 -0
- package/dist/v4.mjs +6 -0
- package/package.json +27 -11
- package/dist/index.d.ts +0 -6
package/dist/index.cjs
CHANGED
|
@@ -1,330 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
|
|
25
|
-
}
|
|
26
|
-
function hueToRgb(p, q, t) {
|
|
27
|
-
if (t < 0) t += 1;
|
|
28
|
-
if (t > 1) t -= 1;
|
|
29
|
-
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
30
|
-
if (t < 1 / 2) return q;
|
|
31
|
-
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
32
|
-
return p;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _interopDefaultCompat$1(e) {
|
|
36
|
-
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
37
|
-
}
|
|
38
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
39
|
-
const flattenColorPalette = _interopDefaultCompat$1(
|
|
40
|
-
require$1(require$1.resolve("tailwindcss/lib/util/flattenColorPalette", { paths: [process.cwd()] }))
|
|
41
|
-
);
|
|
42
|
-
const NUM_REGEX = /(\d*\.\d+|\d+)/;
|
|
43
|
-
const ANGLE_REGEX = new RegExp(`^${NUM_REGEX.source}(deg|rad|grad|turn)?$`);
|
|
44
|
-
const PERCENT_REGEX = new RegExp(`^${NUM_REGEX.source}%?$`);
|
|
45
|
-
let twPkgPath;
|
|
46
|
-
let twPkg;
|
|
47
|
-
try {
|
|
48
|
-
twPkgPath = node_module.findPackageJSON(undefined("tailwindcss", process.cwd()));
|
|
49
|
-
if (twPkgPath) {
|
|
50
|
-
twPkg = JSON.parse(node_fs.readFileSync(twPkgPath, { encoding: "utf8" }));
|
|
51
|
-
}
|
|
52
|
-
} catch (e) {
|
|
53
|
-
console.error("Failed to read Tailwind CSS package.json:", e);
|
|
54
|
-
}
|
|
55
|
-
const TW_VER_REGEX = /^(3|4)\./;
|
|
56
|
-
const match = twPkg?.version.match(TW_VER_REGEX);
|
|
57
|
-
if (!match) {
|
|
58
|
-
console.warn(`Unsupported Tailwind CSS version: ${twPkg?.version}. Expected 3.x or 4.x.`);
|
|
59
|
-
}
|
|
60
|
-
const TailwindVer = match ? Number(match[1]) : 3;
|
|
61
|
-
function createTailwindTheme(tw) {
|
|
62
|
-
return TailwindVer === 4 ? new TailwindV4Theme(tw) : new TailwindV3Theme(tw);
|
|
63
|
-
}
|
|
64
|
-
class TailwindTheme {
|
|
65
|
-
theme;
|
|
66
|
-
fSize;
|
|
67
|
-
constructor(pluginApi) {
|
|
68
|
-
this.theme = pluginApi.theme;
|
|
69
|
-
this.fSize = this.theme("fontSize");
|
|
70
|
-
}
|
|
71
|
-
colors(name) {
|
|
72
|
-
const cname = name ? `colors.${name}` : "colors";
|
|
73
|
-
const c = this.theme(cname);
|
|
74
|
-
return typeof c === "object" ? flattenColorPalette(c) : c;
|
|
75
|
-
}
|
|
76
|
-
spacing(name) {
|
|
77
|
-
return this.theme(`spacing[${name}]`);
|
|
78
|
-
}
|
|
79
|
-
fontSize(name) {
|
|
80
|
-
return this.fSize[name];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
class TailwindV4Theme extends TailwindTheme {
|
|
84
|
-
ver = 4;
|
|
85
|
-
constructor(pluginApi) {
|
|
86
|
-
super(pluginApi);
|
|
87
|
-
}
|
|
88
|
-
colorValue(value, alpha) {
|
|
89
|
-
return this.withAlpha(value, alpha);
|
|
90
|
-
}
|
|
91
|
-
applyTextColor(value, target, alpha) {
|
|
92
|
-
target.color = this.withAlpha(value, alpha);
|
|
93
|
-
}
|
|
94
|
-
applyBackgroundColor(value, target, alpha) {
|
|
95
|
-
target.backgroundColor = this.withAlpha(value, alpha);
|
|
96
|
-
}
|
|
97
|
-
applyBorderColor(value, target, alpha) {
|
|
98
|
-
target.borderColor = this.withAlpha(value, alpha);
|
|
99
|
-
}
|
|
100
|
-
// https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L165C1-L182C2
|
|
101
|
-
withAlpha(value, alpha) {
|
|
102
|
-
if (alpha == null || alpha === "") return value;
|
|
103
|
-
const alphaAsNumber = Number(alpha);
|
|
104
|
-
if (!Number.isNaN(alphaAsNumber)) {
|
|
105
|
-
alpha = `${alphaAsNumber * 100}%`;
|
|
106
|
-
}
|
|
107
|
-
if (alpha === "100%") {
|
|
108
|
-
return value;
|
|
109
|
-
}
|
|
110
|
-
if (typeof alpha === "string" && alpha.startsWith("var(")) {
|
|
111
|
-
alpha = `calc(${alpha} * 100%)`;
|
|
112
|
-
}
|
|
113
|
-
return `color-mix(in oklab, ${value} ${alpha}, transparent)`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
class TailwindV3Theme extends TailwindTheme {
|
|
117
|
-
ver = 3;
|
|
118
|
-
withAlphaVariable = _interopDefaultCompat$1(require$1("tailwindcss/lib/util/withAlphaVariable"));
|
|
119
|
-
parseColorFormat = require$1("tailwindcss/lib/util/pluginUtils").parseColorFormat;
|
|
120
|
-
parseColor = require$1("tailwindcss/lib/util/color").parseColor;
|
|
121
|
-
corePlugins;
|
|
122
|
-
constructor(pluginApi) {
|
|
123
|
-
super(pluginApi);
|
|
124
|
-
this.corePlugins = (p) => pluginApi.corePlugins(p);
|
|
125
|
-
}
|
|
126
|
-
colors(name) {
|
|
127
|
-
const c = super.colors(name);
|
|
128
|
-
return typeof c === "string" ? this.colorToRgb(c) : this.colorsToRgb(c);
|
|
129
|
-
}
|
|
130
|
-
colorValue(value, alpha) {
|
|
131
|
-
const c = this.parseRgbFormat(value);
|
|
132
|
-
return typeof c === "string" ? c : c({ opacityValue: alpha?.toString() });
|
|
133
|
-
}
|
|
134
|
-
applyTextColor(value, target, alpha) {
|
|
135
|
-
this.applyColor({
|
|
136
|
-
color: value,
|
|
137
|
-
property: "color",
|
|
138
|
-
variable: "--tw-text-opacity"
|
|
139
|
-
}, "textOpacity", target, alpha);
|
|
140
|
-
}
|
|
141
|
-
applyBackgroundColor(value, target, alpha) {
|
|
142
|
-
this.applyColor({
|
|
143
|
-
color: value,
|
|
144
|
-
property: "background-color",
|
|
145
|
-
variable: "--tw-bg-opacity"
|
|
146
|
-
}, "backgroundOpacity", target, alpha);
|
|
147
|
-
}
|
|
148
|
-
applyBorderColor(value, target, alpha) {
|
|
149
|
-
this.applyColor({
|
|
150
|
-
color: value,
|
|
151
|
-
property: "border-color",
|
|
152
|
-
variable: "--tw-border-opacity"
|
|
153
|
-
}, "borderOpacity", target, alpha);
|
|
154
|
-
}
|
|
155
|
-
applyColor(args, opacityPlugin, target, alpha) {
|
|
156
|
-
args = {
|
|
157
|
-
...args,
|
|
158
|
-
color: this.parseRgbFormat(args.color)
|
|
159
|
-
};
|
|
160
|
-
Object.assign(target, this.corePlugins?.(opacityPlugin) ? this.withAlphaVariable(args) : { [args.property]: this.toColorValue(args.color, alpha) });
|
|
161
|
-
if (alpha != null && alpha !== "" && args.variable in target) {
|
|
162
|
-
const alphaValue = alpha.toString();
|
|
163
|
-
target[args.variable] = alphaValue;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
toColorValue(maybeFunction, alpha) {
|
|
167
|
-
return typeof maybeFunction === "function" ? maybeFunction(alpha != null && alpha !== "" ? { opacityValue: alpha.toString() } : {}) : maybeFunction;
|
|
168
|
-
}
|
|
169
|
-
parseRgbFormat(color) {
|
|
170
|
-
return this.parseColorFormat(`rgb(${color} / <alpha-value>)`);
|
|
171
|
-
}
|
|
172
|
-
colorsToRgb(colors) {
|
|
173
|
-
for (const c in colors) {
|
|
174
|
-
if (c === "black" || c === "white" || !c.startsWith("c-") && /^(?:.+-)?(?:50|950|[1-9]00)$/.exec(c))
|
|
175
|
-
colors[c] = this.colorToRgb(colors[c]);
|
|
176
|
-
}
|
|
177
|
-
return colors;
|
|
178
|
-
}
|
|
179
|
-
colorToRgb(color) {
|
|
180
|
-
const parsed = this.parseColor(color, { loose: true });
|
|
181
|
-
if (parsed?.mode.startsWith("rgb")) {
|
|
182
|
-
return parsed.color.join(" ");
|
|
183
|
-
} else if (parsed?.mode.startsWith("hsl")) {
|
|
184
|
-
if (parsed.color.length === 3) {
|
|
185
|
-
const rh = ANGLE_REGEX.exec(parsed.color[0]);
|
|
186
|
-
const rs = PERCENT_REGEX.exec(parsed.color[1]);
|
|
187
|
-
const rl = PERCENT_REGEX.exec(parsed.color[2]);
|
|
188
|
-
if (rh && rs && rl) {
|
|
189
|
-
const h = parseFloat(rh[1]) / (rh[2] === "rad" ? 2 * Math.PI : rh[2] === "grad" ? 400 : rh[2] === "turn" ? 1 : 360);
|
|
190
|
-
const s = parseFloat(rs[1]) / 100;
|
|
191
|
-
const l = parseFloat(rl[1]) / 100;
|
|
192
|
-
return hslToRgb(h, s, l).join(" ");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
console.warn(`Unsupported color format: ${color}`);
|
|
197
|
-
return color;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const BLOCK_SELECTOR_REGEX = /^([^{]+)\{([^}]+)\}$/;
|
|
202
|
-
function getDarkSelector(darkMode) {
|
|
203
|
-
let [mode, selector = ".dark"] = Array.isArray(darkMode) ? darkMode : [darkMode];
|
|
204
|
-
if (typeof selector === "function") {
|
|
205
|
-
selector = selector();
|
|
206
|
-
}
|
|
207
|
-
if (typeof selector === "string") {
|
|
208
|
-
selector = [selector];
|
|
209
|
-
}
|
|
210
|
-
if (mode === "variant") {
|
|
211
|
-
for (const s of selector) {
|
|
212
|
-
if (!s.startsWith("@") && !s.includes("&")) {
|
|
213
|
-
console.warn("Invalid `variant` selector");
|
|
214
|
-
return [];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
} else if (selector.length !== 1) {
|
|
218
|
-
console.warn("Invalid `darkMode` selector");
|
|
219
|
-
return [];
|
|
220
|
-
}
|
|
221
|
-
switch (mode) {
|
|
222
|
-
case "media":
|
|
223
|
-
return [["@media (prefers-color-scheme: dark)"]];
|
|
224
|
-
case "class":
|
|
225
|
-
return [[`&:is(${selector[0]} *)`]];
|
|
226
|
-
case "selector":
|
|
227
|
-
return [[`&:where(${selector[0]}, ${selector[0]} *)`]];
|
|
228
|
-
case "variant": {
|
|
229
|
-
const ss = [];
|
|
230
|
-
for (const s of selector) {
|
|
231
|
-
const bsMatch = BLOCK_SELECTOR_REGEX.exec(s);
|
|
232
|
-
ss.push(bsMatch ? [bsMatch[1].trim(), bsMatch[2].trim()] : [s]);
|
|
233
|
-
}
|
|
234
|
-
return ss;
|
|
235
|
-
}
|
|
236
|
-
default:
|
|
237
|
-
return [selector];
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
function setNestedValue(obj, keys, value) {
|
|
241
|
-
if (keys.length === 0) {
|
|
242
|
-
return obj;
|
|
243
|
-
}
|
|
244
|
-
let curr = obj;
|
|
245
|
-
for (let i = 0; i < keys.length; i++) {
|
|
246
|
-
const K = keys[i];
|
|
247
|
-
if (i === keys.length - 1) {
|
|
248
|
-
curr[K] = value;
|
|
249
|
-
} else {
|
|
250
|
-
if (typeof curr[K] !== "object" || curr[K] === null) {
|
|
251
|
-
curr[K] = {};
|
|
252
|
-
}
|
|
253
|
-
curr = curr[K];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return obj;
|
|
257
|
-
}
|
|
258
|
-
function applyDark(selector, styles) {
|
|
259
|
-
const { "@dark": darkStyle, ...style } = styles;
|
|
260
|
-
if (darkStyle) {
|
|
261
|
-
for (const s of selector) {
|
|
262
|
-
setNestedValue(style, s, darkStyle);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return style;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function keyValuePairs(keys, val = (k) => k) {
|
|
269
|
-
return keys.reduce((acc, k) => {
|
|
270
|
-
acc[k] = val(k);
|
|
271
|
-
return acc;
|
|
272
|
-
}, {});
|
|
273
|
-
}
|
|
274
|
-
function WindUITailwindCSS(config = {}) {
|
|
275
|
-
const wiu = core.create(config);
|
|
276
|
-
return createPlugin__default((tw) => {
|
|
277
|
-
const tp = createTailwindTheme(tw);
|
|
278
|
-
const gt = wiu.generator(tp);
|
|
279
|
-
const darkMode = tw.config("darkMode", "media");
|
|
280
|
-
const darkSelector = getDarkSelector(darkMode);
|
|
281
|
-
tw.addBase({ ":root": gt.colors.rootVars() });
|
|
282
|
-
tw.addBase({ ":root": gt.sizes.rootVars() });
|
|
283
|
-
tw.addBase({ "*": applyDark(darkSelector, gt.variants.rootVars()) });
|
|
284
|
-
tw.matchUtilities({
|
|
285
|
-
c: (val) => gt.colors.cssVars(val)
|
|
286
|
-
}, { values: keyValuePairs(gt.colors.names()) });
|
|
287
|
-
tw.matchUtilities({
|
|
288
|
-
v: (val) => applyDark(darkSelector, gt.variants.cssVars(val))
|
|
289
|
-
}, { values: keyValuePairs(gt.variants.names()) });
|
|
290
|
-
tw.matchUtilities({
|
|
291
|
-
"bg": (val, ext) => {
|
|
292
|
-
return gt.variants.utilCss("bg", val, ext.modifier);
|
|
293
|
-
},
|
|
294
|
-
"border": (val, ext) => {
|
|
295
|
-
return gt.variants.utilCss("border", val, ext.modifier);
|
|
296
|
-
},
|
|
297
|
-
"text": (val, ext) => {
|
|
298
|
-
return gt.variants.utilCss("text", val, ext.modifier);
|
|
299
|
-
}
|
|
300
|
-
}, {
|
|
301
|
-
values: { v: "default", "v-soft": "soft", "v-muted": "muted", "v-accent": "accent" },
|
|
302
|
-
modifiers: tw.theme("opacity")
|
|
303
|
-
});
|
|
304
|
-
tw.matchUtilities({
|
|
305
|
-
s: (val) => gt.sizes.cssVars(val)
|
|
306
|
-
}, {
|
|
307
|
-
values: keyValuePairs(gt.sizes.names())
|
|
308
|
-
});
|
|
309
|
-
tw.addComponents([...gt.components.css()]);
|
|
310
|
-
}, {
|
|
311
|
-
content: [],
|
|
312
|
-
theme: {
|
|
313
|
-
extend: {
|
|
314
|
-
colors({ colors }) {
|
|
315
|
-
return {
|
|
316
|
-
c: keyValuePairs(Object.keys(colors.gray), (v) => {
|
|
317
|
-
const c = wiu.vars.color(v);
|
|
318
|
-
return TailwindVer === 4 ? c : `rgb(${c} / <alpha-value>)`;
|
|
319
|
-
}),
|
|
320
|
-
// TODO: add as configurable option
|
|
321
|
-
default: colors.gray,
|
|
322
|
-
accent: colors.blue
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
module.exports = WindUITailwindCSS;
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_plugin = require("./plugin-BmHj0642.cjs");
|
|
6
|
+
const require_config = require("./config.cjs");
|
|
7
|
+
const require_safelist = require("./safelist.cjs");
|
|
8
|
+
let _windi_ui_core = require("@windi-ui/core");
|
|
9
|
+
// src/index.ts
|
|
10
|
+
var src_default = require_plugin.createWindiUIPlugin();
|
|
11
|
+
exports.classSource = require_safelist.classSource;
|
|
12
|
+
exports.default = src_default;
|
|
13
|
+
Object.defineProperty(exports, "defineConfig", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return _windi_ui_core.defineConfig;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
exports.loadWindiUIConfig = require_config.loadWindiUIConfig;
|
|
20
|
+
exports.safelistSource = require_safelist.safelistSource;
|
|
21
|
+
|
|
22
|
+
module.exports = Object.assign(exports.default, exports);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Config } from
|
|
3
|
-
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { n as WindiUIPlugin } from "./plugin-QCWiD6Wb.cjs";
|
|
2
|
+
import { Config, LoadConfigOptions, LoadedConfig, defineConfig, loadWindiUIConfig } from "./config.cjs";
|
|
3
|
+
import { SafelistAxis, SafelistOptions, classSource, safelistSource } from "./safelist.cjs";
|
|
4
|
+
declare const _default: WindiUIPlugin<{
|
|
5
|
+
handler: import("tailwindcss/types/config").PluginCreator;
|
|
6
|
+
config?: Partial<import("tailwindcss/types/config").Config>;
|
|
7
|
+
}>;
|
|
8
|
+
declare function _cjs(...args: Parameters<typeof _default>): ReturnType<typeof _default>;
|
|
9
|
+
declare namespace _cjs {
|
|
10
|
+
export { type Config, LoadConfigOptions, LoadedConfig, SafelistAxis, SafelistOptions, classSource, _default as default, defineConfig, loadWindiUIConfig, safelistSource };
|
|
11
|
+
export const __isOptionsFunction: true;
|
|
12
|
+
}
|
|
13
|
+
export = _cjs;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Config } from
|
|
3
|
-
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { n as WindiUIPlugin } from "./plugin-ayXaeLBM.mjs";
|
|
2
|
+
import { Config, LoadConfigOptions, LoadedConfig, defineConfig, loadWindiUIConfig } from "./config.mjs";
|
|
3
|
+
import { SafelistAxis, SafelistOptions, classSource, safelistSource } from "./safelist.mjs";
|
|
4
|
+
declare const _default: WindiUIPlugin<{
|
|
5
|
+
handler: import("tailwindcss/types/config").PluginCreator;
|
|
6
|
+
config?: Partial<import("tailwindcss/types/config").Config>;
|
|
7
|
+
}>;
|
|
8
|
+
export { type Config, LoadConfigOptions, LoadedConfig, SafelistAxis, SafelistOptions, classSource, _default as default, defineConfig, loadWindiUIConfig, safelistSource };
|