@udixio/tailwind 0.3.6 → 0.4.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/index.cjs +314 -0
  3. package/index.js +297 -0
  4. package/lib/file.d.ts.map +1 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/main.d.ts +3 -0
  7. package/lib/main.d.ts.map +1 -0
  8. package/{src/lib → lib}/plugins-tailwind/font.d.ts +1 -1
  9. package/lib/plugins-tailwind/font.d.ts.map +1 -0
  10. package/lib/plugins-tailwind/index.d.ts.map +1 -0
  11. package/lib/plugins-tailwind/state.d.ts +3 -0
  12. package/lib/plugins-tailwind/state.d.ts.map +1 -0
  13. package/{src/lib → lib}/tailwind.plugin.d.ts +2 -1
  14. package/lib/tailwind.plugin.d.ts.map +1 -0
  15. package/package.json +9 -4
  16. package/src/index.d.ts +0 -4
  17. package/src/index.d.ts.map +0 -1
  18. package/src/index.js +0 -5
  19. package/src/index.js.map +0 -1
  20. package/src/lib/file.d.ts.map +0 -1
  21. package/src/lib/file.js +0 -107
  22. package/src/lib/file.js.map +0 -1
  23. package/src/lib/index.d.ts.map +0 -1
  24. package/src/lib/index.js +0 -4
  25. package/src/lib/index.js.map +0 -1
  26. package/src/lib/main.d.ts +0 -3
  27. package/src/lib/main.d.ts.map +0 -1
  28. package/src/lib/main.js +0 -8
  29. package/src/lib/main.js.map +0 -1
  30. package/src/lib/plugins-tailwind/font.d.ts.map +0 -1
  31. package/src/lib/plugins-tailwind/font.js +0 -36
  32. package/src/lib/plugins-tailwind/font.js.map +0 -1
  33. package/src/lib/plugins-tailwind/index.d.ts.map +0 -1
  34. package/src/lib/plugins-tailwind/index.js +0 -3
  35. package/src/lib/plugins-tailwind/index.js.map +0 -1
  36. package/src/lib/plugins-tailwind/state.d.ts +0 -3
  37. package/src/lib/plugins-tailwind/state.d.ts.map +0 -1
  38. package/src/lib/plugins-tailwind/state.js +0 -61
  39. package/src/lib/plugins-tailwind/state.js.map +0 -1
  40. package/src/lib/tailwind.plugin.d.ts.map +0 -1
  41. package/src/lib/tailwind.plugin.js +0 -92
  42. package/src/lib/tailwind.plugin.js.map +0 -1
  43. /package/{src/lib → lib}/file.d.ts +0 -0
  44. /package/{src/lib → lib}/index.d.ts +0 -0
  45. /package/{src/lib → lib}/plugins-tailwind/index.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 0.3.7 (2025-07-25)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **tailwind:** add `styleFilePath` option for custom style file resolution ([369d03f](https://github.com/Udixio/UI/commit/369d03f))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Joël VIGREUX
10
+
11
+ ## 0.3.6 (2025-07-25)
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - **tailwind:** enhance plugin error message and support additional file extensions ([ad22830](https://github.com/Udixio/UI/commit/ad22830))
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - Joël VIGREUX
20
+
1
21
  ## 0.3.5 (2025-07-25)
2
22
 
3
23
  ### 🧱 Updated Dependencies
package/index.cjs ADDED
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const theme$1 = require("@udixio/theme");
4
+ const plugin = require("tailwindcss/plugin");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const replaceInFile = require("replace-in-file");
8
+ function _interopNamespaceDefault(e) {
9
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
+ if (e) {
11
+ for (const k in e) {
12
+ if (k !== "default") {
13
+ const d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: () => e[k]
17
+ });
18
+ }
19
+ }
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+ const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
25
+ const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
26
+ const createOrUpdateFile = (filePath, content) => {
27
+ try {
28
+ if (!fs__namespace.existsSync(filePath)) {
29
+ const dirPath = path__namespace.dirname(filePath);
30
+ if (!fs__namespace.existsSync(dirPath)) {
31
+ fs__namespace.mkdirSync(dirPath, { recursive: true });
32
+ }
33
+ fs__namespace.writeFileSync(filePath, content);
34
+ console.log(`✅ File successfully created: ${filePath}`);
35
+ } else {
36
+ console.log(`⚠️ File already exists: ${filePath}`);
37
+ replaceFileContent(filePath, /[\s\S]*/, content);
38
+ }
39
+ } catch (error) {
40
+ console.error("❌ Error while creating the file:", error);
41
+ }
42
+ };
43
+ const getFileContent = (filePath, searchPattern) => {
44
+ try {
45
+ if (!fs__namespace.existsSync(filePath)) {
46
+ console.error(`❌ The specified file does not exist: ${filePath}`);
47
+ return null;
48
+ }
49
+ const fileContent = fs__namespace.readFileSync(filePath, "utf8");
50
+ if (searchPattern) {
51
+ if (typeof searchPattern === "string") {
52
+ const found = fileContent.includes(searchPattern) ? searchPattern : false;
53
+ console.log(
54
+ found ? `✅ The file contains the specified string: "${searchPattern}"` : `⚠️ The file does NOT contain the specified string: "${searchPattern}"`
55
+ );
56
+ return found;
57
+ } else {
58
+ const match = fileContent.match(searchPattern);
59
+ if (match) {
60
+ console.log(`✅ Found match: "${match[0]}"`);
61
+ return match[0];
62
+ } else {
63
+ console.log(
64
+ `⚠️ No match found for the pattern: "${searchPattern.toString()}"`
65
+ );
66
+ return false;
67
+ }
68
+ }
69
+ }
70
+ console.log(`✅ File content successfully retrieved.`);
71
+ return fileContent;
72
+ } catch (error) {
73
+ console.error("❌ An error occurred while processing the file:", error);
74
+ return null;
75
+ }
76
+ };
77
+ const replaceFileContent = (filePath, searchPattern, replacement) => {
78
+ try {
79
+ const results = replaceInFile.replaceInFileSync({
80
+ files: filePath,
81
+ from: searchPattern,
82
+ to: replacement
83
+ });
84
+ if (results.length > 0 && results[0].hasChanged) {
85
+ console.log(`✅ Content successfully replaced in the file: ${filePath}`);
86
+ } else {
87
+ console.log(
88
+ `⚠️ No replacement made. Here are some possible reasons:
89
+ - The pattern ${searchPattern} was not found.
90
+ - The file might already contain the expected content.`
91
+ );
92
+ }
93
+ } catch (error) {
94
+ console.error("❌ Error while replacing the file content:", error);
95
+ }
96
+ };
97
+ const findTailwindCssFile = (startDir, searchPattern) => {
98
+ const files = fs__namespace.readdirSync(startDir);
99
+ for (const file of files) {
100
+ const filePath = path__namespace.join(startDir, file);
101
+ const stats = fs__namespace.statSync(filePath);
102
+ if (stats.isDirectory()) {
103
+ const result = findTailwindCssFile(filePath, searchPattern);
104
+ if (result) return result;
105
+ } else if (file.endsWith(".css") || file.endsWith(".scss") || file.endsWith(".sass")) {
106
+ const content = fs__namespace.readFileSync(filePath, "utf8");
107
+ if (content.includes(searchPattern)) {
108
+ console.log("File found:\n", filePath);
109
+ return filePath;
110
+ }
111
+ }
112
+ }
113
+ return null;
114
+ };
115
+ const state = (colorKeys) => plugin((pluginArgs) => {
116
+ addAllNewComponents(
117
+ pluginArgs,
118
+ {
119
+ statePrefix: "state",
120
+ disabledStyles: {
121
+ textOpacity: 0.38,
122
+ backgroundOpacity: 0.12
123
+ },
124
+ transition: {
125
+ duration: 150
126
+ }
127
+ },
128
+ colorKeys
129
+ );
130
+ }, {});
131
+ const addAllNewComponents = ({ addComponents }, { statePrefix, disabledStyles, transition }, colorKeys) => {
132
+ const newComponents = {};
133
+ for (const isGroup of [false, true]) {
134
+ const group = isGroup ? "group-" : "";
135
+ for (const colorName of colorKeys) {
136
+ const className = `.${group}${statePrefix}-${colorName}`;
137
+ newComponents[className] = {
138
+ [`@apply ${group}hover:bg-${colorName}/[0.08]`]: {},
139
+ [`@apply ${group}active:bg-${colorName}/[0.12]`]: {},
140
+ [`@apply ${group}focus-visible:bg-${colorName}/[0.12]`]: {}
141
+ };
142
+ if (transition) {
143
+ newComponents[className][`@apply transition-colors`] = {};
144
+ newComponents[className][`@apply duration-${transition.duration}`] = {};
145
+ }
146
+ if (disabledStyles) {
147
+ newComponents[className][`@apply ${group}disabled:text-on-surface/[${disabledStyles.textOpacity}]`] = {};
148
+ newComponents[className][`@apply ${group}disabled:bg-on-surface/[${disabledStyles.backgroundOpacity}]`] = {};
149
+ }
150
+ }
151
+ }
152
+ for (const colorName of colorKeys) {
153
+ for (const stateName of ["hover", "active", "focus", "disabled"]) {
154
+ const className = `.${stateName}-${statePrefix}-${colorName}`;
155
+ if (stateName === "active" || stateName === "focus") {
156
+ newComponents[className] = {
157
+ [`@apply bg-${colorName}/[0.12]`]: {}
158
+ };
159
+ } else if (stateName === "hover") {
160
+ newComponents[className] = {
161
+ [`@apply bg-${colorName}/[0.08]`]: {}
162
+ };
163
+ } else if (stateName === "disabled") {
164
+ newComponents[className] = {
165
+ [`@apply text-on-surface/[${disabledStyles.textOpacity}]`]: {}
166
+ };
167
+ newComponents[className] = {
168
+ [`@apply bg-on-surface/[${disabledStyles.backgroundOpacity}]`]: {}
169
+ };
170
+ }
171
+ }
172
+ }
173
+ addComponents(newComponents);
174
+ };
175
+ const font = (fontStyles, responsiveBreakPoints) => {
176
+ const createUtilities = ({ theme: theme2 }) => {
177
+ const pixelUnit = "rem";
178
+ const newUtilities = {};
179
+ const baseTextStyle = (sizeValue) => ({
180
+ fontSize: sizeValue.fontSize + pixelUnit,
181
+ fontWeight: sizeValue.fontWeight,
182
+ lineHeight: sizeValue.lineHeight + pixelUnit,
183
+ letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
184
+ fontFamily: theme2("fontFamily." + sizeValue.fontFamily)
185
+ });
186
+ const responsiveTextStyle = (sizeValue, breakPointName, breakPointRatio) => ({
187
+ [`@media (min-width: ${theme2("screens." + breakPointName, {})})`]: {
188
+ fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
189
+ lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
190
+ }
191
+ });
192
+ for (const [roleName, roleValue] of Object.entries(fontStyles)) {
193
+ for (const [sizeName, sizeValue] of Object.entries(roleValue)) {
194
+ newUtilities[".text-" + roleName + "-" + sizeName] = {
195
+ ...baseTextStyle(sizeValue),
196
+ ...Object.entries(responsiveBreakPoints).reduce(
197
+ (acc, [breakPointName, breakPointRatio]) => {
198
+ acc = {
199
+ ...acc,
200
+ ...responsiveTextStyle(
201
+ sizeValue,
202
+ breakPointName,
203
+ breakPointRatio
204
+ )
205
+ };
206
+ return acc;
207
+ },
208
+ {}
209
+ )
210
+ };
211
+ }
212
+ }
213
+ return newUtilities;
214
+ };
215
+ return plugin(
216
+ ({
217
+ addUtilities,
218
+ theme: theme2
219
+ }) => {
220
+ const newUtilities = createUtilities({ theme: theme2 });
221
+ addUtilities(newUtilities);
222
+ }
223
+ );
224
+ };
225
+ class TailwindPlugin extends theme$1.PluginAbstract {
226
+ constructor() {
227
+ super(...arguments);
228
+ this.dependencies = [theme$1.FontPlugin];
229
+ this.name = "tailwind";
230
+ this.pluginClass = TailwindImplPlugin;
231
+ }
232
+ }
233
+ class TailwindImplPlugin extends theme$1.PluginImplAbstract {
234
+ onInit() {
235
+ var _a;
236
+ (_a = this.options).responsiveBreakPoints ?? (_a.responsiveBreakPoints = {
237
+ lg: 1.125
238
+ });
239
+ }
240
+ load() {
241
+ const searchKeyword = '@plugin "@udixio/tailwind"';
242
+ const tailwindCssPath = this.options.styleFilePath ?? findTailwindCssFile(process.cwd(), searchKeyword);
243
+ if (!tailwindCssPath) {
244
+ throw new Error(
245
+ 'The style file containing the Udixio plugin was not found.\n Please use it first. (@plugin "@udixio/tailwind")'
246
+ );
247
+ }
248
+ const searchPattern = /@import ["']tailwindcss["'];/;
249
+ const replacement = `@import 'tailwindcss';
250
+ @import "./udixio.css";`;
251
+ if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
252
+ replaceFileContent(tailwindCssPath, searchPattern, replacement);
253
+ }
254
+ const cssFilePath = path.dirname(tailwindCssPath);
255
+ const colors = {};
256
+ for (const isDark of [false, true]) {
257
+ this.api.themes.update({ isDark });
258
+ for (const [key, value] of this.api.colors.getColors().entries()) {
259
+ const newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
260
+ colors[newKey] ?? (colors[newKey] = { light: "", dark: "" });
261
+ colors[newKey][isDark ? "dark" : "light"] = value.getHex();
262
+ }
263
+ }
264
+ const { fontStyles, fontFamily } = this.api.plugins.getPlugin(theme$1.FontPlugin).getInstance().getFonts();
265
+ createOrUpdateFile(
266
+ path.join(cssFilePath, "udixio.css"),
267
+ `
268
+ @custom-variant dark (&:where(.dark, .dark *));
269
+ @theme {
270
+ --color-*: initial;
271
+ ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
272
+ }
273
+ @layer theme {
274
+ .dark {
275
+ ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.dark};`).join("\n ")}
276
+ }
277
+ }
278
+ `
279
+ );
280
+ const plugins = [
281
+ state(Object.keys(colors)),
282
+ font(fontStyles, this.options.responsiveBreakPoints)
283
+ ];
284
+ return plugin.withOptions(
285
+ // 1) factory(options) → la fonction “handler” du plugin
286
+ (options = {}) => {
287
+ return async function(api) {
288
+ plugins.forEach((plugin2) => {
289
+ plugin2.handler(api);
290
+ });
291
+ };
292
+ },
293
+ // 2) config(options) → objet à merger dans tailwind.config
294
+ (options = {}) => {
295
+ return {
296
+ theme: {
297
+ fontFamily
298
+ }
299
+ };
300
+ }
301
+ );
302
+ }
303
+ }
304
+ const createTheme = () => {
305
+ const app = theme$1.bootstrapFromConfig();
306
+ const plugin2 = app.plugins.getPlugin(TailwindPlugin).getInstance();
307
+ return plugin2.load();
308
+ };
309
+ const theme = createTheme();
310
+ exports.TailwindPlugin = TailwindPlugin;
311
+ exports.createTheme = createTheme;
312
+ exports.default = theme;
313
+ exports.font = font;
314
+ exports.state = state;
package/index.js ADDED
@@ -0,0 +1,297 @@
1
+ import { PluginAbstract, FontPlugin, PluginImplAbstract, bootstrapFromConfig } from "@udixio/theme";
2
+ import plugin from "tailwindcss/plugin";
3
+ import * as fs from "fs";
4
+ import * as path from "path";
5
+ import path__default from "path";
6
+ import { replaceInFileSync } from "replace-in-file";
7
+ const createOrUpdateFile = (filePath, content) => {
8
+ try {
9
+ if (!fs.existsSync(filePath)) {
10
+ const dirPath = path.dirname(filePath);
11
+ if (!fs.existsSync(dirPath)) {
12
+ fs.mkdirSync(dirPath, { recursive: true });
13
+ }
14
+ fs.writeFileSync(filePath, content);
15
+ console.log(`✅ File successfully created: ${filePath}`);
16
+ } else {
17
+ console.log(`⚠️ File already exists: ${filePath}`);
18
+ replaceFileContent(filePath, /[\s\S]*/, content);
19
+ }
20
+ } catch (error) {
21
+ console.error("❌ Error while creating the file:", error);
22
+ }
23
+ };
24
+ const getFileContent = (filePath, searchPattern) => {
25
+ try {
26
+ if (!fs.existsSync(filePath)) {
27
+ console.error(`❌ The specified file does not exist: ${filePath}`);
28
+ return null;
29
+ }
30
+ const fileContent = fs.readFileSync(filePath, "utf8");
31
+ if (searchPattern) {
32
+ if (typeof searchPattern === "string") {
33
+ const found = fileContent.includes(searchPattern) ? searchPattern : false;
34
+ console.log(
35
+ found ? `✅ The file contains the specified string: "${searchPattern}"` : `⚠️ The file does NOT contain the specified string: "${searchPattern}"`
36
+ );
37
+ return found;
38
+ } else {
39
+ const match = fileContent.match(searchPattern);
40
+ if (match) {
41
+ console.log(`✅ Found match: "${match[0]}"`);
42
+ return match[0];
43
+ } else {
44
+ console.log(
45
+ `⚠️ No match found for the pattern: "${searchPattern.toString()}"`
46
+ );
47
+ return false;
48
+ }
49
+ }
50
+ }
51
+ console.log(`✅ File content successfully retrieved.`);
52
+ return fileContent;
53
+ } catch (error) {
54
+ console.error("❌ An error occurred while processing the file:", error);
55
+ return null;
56
+ }
57
+ };
58
+ const replaceFileContent = (filePath, searchPattern, replacement) => {
59
+ try {
60
+ const results = replaceInFileSync({
61
+ files: filePath,
62
+ from: searchPattern,
63
+ to: replacement
64
+ });
65
+ if (results.length > 0 && results[0].hasChanged) {
66
+ console.log(`✅ Content successfully replaced in the file: ${filePath}`);
67
+ } else {
68
+ console.log(
69
+ `⚠️ No replacement made. Here are some possible reasons:
70
+ - The pattern ${searchPattern} was not found.
71
+ - The file might already contain the expected content.`
72
+ );
73
+ }
74
+ } catch (error) {
75
+ console.error("❌ Error while replacing the file content:", error);
76
+ }
77
+ };
78
+ const findTailwindCssFile = (startDir, searchPattern) => {
79
+ const files = fs.readdirSync(startDir);
80
+ for (const file of files) {
81
+ const filePath = path.join(startDir, file);
82
+ const stats = fs.statSync(filePath);
83
+ if (stats.isDirectory()) {
84
+ const result = findTailwindCssFile(filePath, searchPattern);
85
+ if (result) return result;
86
+ } else if (file.endsWith(".css") || file.endsWith(".scss") || file.endsWith(".sass")) {
87
+ const content = fs.readFileSync(filePath, "utf8");
88
+ if (content.includes(searchPattern)) {
89
+ console.log("File found:\n", filePath);
90
+ return filePath;
91
+ }
92
+ }
93
+ }
94
+ return null;
95
+ };
96
+ const state = (colorKeys) => plugin((pluginArgs) => {
97
+ addAllNewComponents(
98
+ pluginArgs,
99
+ {
100
+ statePrefix: "state",
101
+ disabledStyles: {
102
+ textOpacity: 0.38,
103
+ backgroundOpacity: 0.12
104
+ },
105
+ transition: {
106
+ duration: 150
107
+ }
108
+ },
109
+ colorKeys
110
+ );
111
+ }, {});
112
+ const addAllNewComponents = ({ addComponents }, { statePrefix, disabledStyles, transition }, colorKeys) => {
113
+ const newComponents = {};
114
+ for (const isGroup of [false, true]) {
115
+ const group = isGroup ? "group-" : "";
116
+ for (const colorName of colorKeys) {
117
+ const className = `.${group}${statePrefix}-${colorName}`;
118
+ newComponents[className] = {
119
+ [`@apply ${group}hover:bg-${colorName}/[0.08]`]: {},
120
+ [`@apply ${group}active:bg-${colorName}/[0.12]`]: {},
121
+ [`@apply ${group}focus-visible:bg-${colorName}/[0.12]`]: {}
122
+ };
123
+ if (transition) {
124
+ newComponents[className][`@apply transition-colors`] = {};
125
+ newComponents[className][`@apply duration-${transition.duration}`] = {};
126
+ }
127
+ if (disabledStyles) {
128
+ newComponents[className][`@apply ${group}disabled:text-on-surface/[${disabledStyles.textOpacity}]`] = {};
129
+ newComponents[className][`@apply ${group}disabled:bg-on-surface/[${disabledStyles.backgroundOpacity}]`] = {};
130
+ }
131
+ }
132
+ }
133
+ for (const colorName of colorKeys) {
134
+ for (const stateName of ["hover", "active", "focus", "disabled"]) {
135
+ const className = `.${stateName}-${statePrefix}-${colorName}`;
136
+ if (stateName === "active" || stateName === "focus") {
137
+ newComponents[className] = {
138
+ [`@apply bg-${colorName}/[0.12]`]: {}
139
+ };
140
+ } else if (stateName === "hover") {
141
+ newComponents[className] = {
142
+ [`@apply bg-${colorName}/[0.08]`]: {}
143
+ };
144
+ } else if (stateName === "disabled") {
145
+ newComponents[className] = {
146
+ [`@apply text-on-surface/[${disabledStyles.textOpacity}]`]: {}
147
+ };
148
+ newComponents[className] = {
149
+ [`@apply bg-on-surface/[${disabledStyles.backgroundOpacity}]`]: {}
150
+ };
151
+ }
152
+ }
153
+ }
154
+ addComponents(newComponents);
155
+ };
156
+ const font = (fontStyles, responsiveBreakPoints) => {
157
+ const createUtilities = ({ theme: theme2 }) => {
158
+ const pixelUnit = "rem";
159
+ const newUtilities = {};
160
+ const baseTextStyle = (sizeValue) => ({
161
+ fontSize: sizeValue.fontSize + pixelUnit,
162
+ fontWeight: sizeValue.fontWeight,
163
+ lineHeight: sizeValue.lineHeight + pixelUnit,
164
+ letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
165
+ fontFamily: theme2("fontFamily." + sizeValue.fontFamily)
166
+ });
167
+ const responsiveTextStyle = (sizeValue, breakPointName, breakPointRatio) => ({
168
+ [`@media (min-width: ${theme2("screens." + breakPointName, {})})`]: {
169
+ fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
170
+ lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
171
+ }
172
+ });
173
+ for (const [roleName, roleValue] of Object.entries(fontStyles)) {
174
+ for (const [sizeName, sizeValue] of Object.entries(roleValue)) {
175
+ newUtilities[".text-" + roleName + "-" + sizeName] = {
176
+ ...baseTextStyle(sizeValue),
177
+ ...Object.entries(responsiveBreakPoints).reduce(
178
+ (acc, [breakPointName, breakPointRatio]) => {
179
+ acc = {
180
+ ...acc,
181
+ ...responsiveTextStyle(
182
+ sizeValue,
183
+ breakPointName,
184
+ breakPointRatio
185
+ )
186
+ };
187
+ return acc;
188
+ },
189
+ {}
190
+ )
191
+ };
192
+ }
193
+ }
194
+ return newUtilities;
195
+ };
196
+ return plugin(
197
+ ({
198
+ addUtilities,
199
+ theme: theme2
200
+ }) => {
201
+ const newUtilities = createUtilities({ theme: theme2 });
202
+ addUtilities(newUtilities);
203
+ }
204
+ );
205
+ };
206
+ class TailwindPlugin extends PluginAbstract {
207
+ constructor() {
208
+ super(...arguments);
209
+ this.dependencies = [FontPlugin];
210
+ this.name = "tailwind";
211
+ this.pluginClass = TailwindImplPlugin;
212
+ }
213
+ }
214
+ class TailwindImplPlugin extends PluginImplAbstract {
215
+ onInit() {
216
+ var _a;
217
+ (_a = this.options).responsiveBreakPoints ?? (_a.responsiveBreakPoints = {
218
+ lg: 1.125
219
+ });
220
+ }
221
+ load() {
222
+ const searchKeyword = '@plugin "@udixio/tailwind"';
223
+ const tailwindCssPath = this.options.styleFilePath ?? findTailwindCssFile(process.cwd(), searchKeyword);
224
+ if (!tailwindCssPath) {
225
+ throw new Error(
226
+ 'The style file containing the Udixio plugin was not found.\n Please use it first. (@plugin "@udixio/tailwind")'
227
+ );
228
+ }
229
+ const searchPattern = /@import ["']tailwindcss["'];/;
230
+ const replacement = `@import 'tailwindcss';
231
+ @import "./udixio.css";`;
232
+ if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
233
+ replaceFileContent(tailwindCssPath, searchPattern, replacement);
234
+ }
235
+ const cssFilePath = path__default.dirname(tailwindCssPath);
236
+ const colors = {};
237
+ for (const isDark of [false, true]) {
238
+ this.api.themes.update({ isDark });
239
+ for (const [key, value] of this.api.colors.getColors().entries()) {
240
+ const newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
241
+ colors[newKey] ?? (colors[newKey] = { light: "", dark: "" });
242
+ colors[newKey][isDark ? "dark" : "light"] = value.getHex();
243
+ }
244
+ }
245
+ const { fontStyles, fontFamily } = this.api.plugins.getPlugin(FontPlugin).getInstance().getFonts();
246
+ createOrUpdateFile(
247
+ path__default.join(cssFilePath, "udixio.css"),
248
+ `
249
+ @custom-variant dark (&:where(.dark, .dark *));
250
+ @theme {
251
+ --color-*: initial;
252
+ ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
253
+ }
254
+ @layer theme {
255
+ .dark {
256
+ ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.dark};`).join("\n ")}
257
+ }
258
+ }
259
+ `
260
+ );
261
+ const plugins = [
262
+ state(Object.keys(colors)),
263
+ font(fontStyles, this.options.responsiveBreakPoints)
264
+ ];
265
+ return plugin.withOptions(
266
+ // 1) factory(options) → la fonction “handler” du plugin
267
+ (options = {}) => {
268
+ return async function(api) {
269
+ plugins.forEach((plugin2) => {
270
+ plugin2.handler(api);
271
+ });
272
+ };
273
+ },
274
+ // 2) config(options) → objet à merger dans tailwind.config
275
+ (options = {}) => {
276
+ return {
277
+ theme: {
278
+ fontFamily
279
+ }
280
+ };
281
+ }
282
+ );
283
+ }
284
+ }
285
+ const createTheme = () => {
286
+ const app = bootstrapFromConfig();
287
+ const plugin2 = app.plugins.getPlugin(TailwindPlugin).getInstance();
288
+ return plugin2.load();
289
+ };
290
+ const theme = createTheme();
291
+ export {
292
+ TailwindPlugin,
293
+ createTheme,
294
+ theme as default,
295
+ font,
296
+ state
297
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../packages/tailwind/src/lib/file.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,KAAG,IAmBtE,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,gBAAgB,MAAM,GAAG,MAAM,KAC9B,MAAM,GAAG,KAAK,GAAG,IA4CnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,eAAe,MAAM,GAAG,MAAM,EAC9B,aAAa,MAAM,KAClB,IAkBF,CAAC;AACF,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,eAAe,MAAM,KACpB,MAAM,GAAG,IAyBX,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/tailwind/src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
package/lib/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { default as plugin } from 'tailwindcss/plugin';
2
+ export declare const createTheme: () => ReturnType<typeof plugin.withOptions>;
3
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../packages/tailwind/src/lib/main.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,MAAM,UAAU,CAAC,OAAO,MAAM,CAAC,WAAW,CAInE,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { FontRole, FontSize, FontStyle } from '@udixio/theme';
2
- import plugin from 'tailwindcss/plugin';
2
+ import { default as plugin } from 'tailwindcss/plugin';
3
3
  export declare const font: (fontStyles: Record<FontRole, Record<FontSize, FontStyle>>, responsiveBreakPoints: Record<string, number>) => ReturnType<typeof plugin>;
4
4
  //# sourceMappingURL=font.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/plugins-tailwind/font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,MAAqB,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,IAAI,EAAE,CACjB,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,EACzD,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC1C,UAAU,CAAC,OAAO,MAAM,CA2D5B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/plugins-tailwind/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { default as plugin } from 'tailwindcss/plugin';
2
+ export declare const state: (colorKeys: string[]) => ReturnType<typeof plugin>;
3
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/plugins-tailwind/state.ts"],"names":[],"mappings":"AACA,OAAO,MAAqB,MAAM,oBAAoB,CAAC;AAevD,eAAO,MAAM,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,UAAU,CAAC,OAAO,MAAM,CAkB7D,CAAC"}
@@ -1,7 +1,8 @@
1
- import plugin from 'tailwindcss/plugin';
1
+ import { default as plugin } from 'tailwindcss/plugin';
2
2
  import { FontPlugin, PluginAbstract, PluginImplAbstract } from '@udixio/theme';
3
3
  interface TailwindPluginOptions {
4
4
  responsiveBreakPoints?: Record<string, number>;
5
+ styleFilePath?: string;
5
6
  }
6
7
  export declare class TailwindPlugin extends PluginAbstract<TailwindImplPlugin, TailwindPluginOptions> {
7
8
  dependencies: (typeof FontPlugin)[];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.plugin.d.ts","sourceRoot":"","sources":["../../../../packages/tailwind/src/lib/tailwind.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAUxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE/E,UAAU,qBAAqB;IAE7B,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;CAExB;AAED,qBAAa,cAAe,SAAQ,cAAc,CAChD,kBAAkB,EAClB,qBAAqB,CACtB;IACQ,YAAY,wBAAgB;IAC5B,IAAI,SAAc;IACzB,WAAW,4BAAsB;CAClC;AAED,cAAM,kBAAmB,SAAQ,kBAAkB,CAAC,qBAAqB,CAAC;IACxE,MAAM;IAMN,IAAI,IAAI,UAAU,CAAC,OAAO,MAAM,CAAC,WAAW,CAAC;CAwF9C"}
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@udixio/tailwind",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
- "main": "src/index.js",
5
+ "main": "src/index.ts",
6
6
  "types": "./src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./index.js",
10
+ "require": "./index.cjs"
11
+ }
12
+ },
7
13
  "dependencies": {
8
14
  "tslib": "^2.3.0",
9
15
  "@udixio/theme": "0.3.1"
@@ -15,6 +21,5 @@
15
21
  "publishConfig": {
16
22
  "registry": "https://registry.npmjs.org/",
17
23
  "access": "public"
18
- },
19
- "module": "./src/index.js"
24
+ }
20
25
  }
package/src/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const theme: import("node_modules/tailwindcss/dist/types-B254mqw1.mjs").c<unknown>;
2
- export * from './lib';
3
- export default theme;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/tailwind/src/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,KAAK,uEAAgB,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,eAAe,KAAK,CAAC"}
package/src/index.js DELETED
@@ -1,5 +0,0 @@
1
- import { createTheme } from './lib';
2
- const theme = createTheme();
3
- export * from './lib';
4
- export default theme;
5
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/tailwind/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,eAAe,KAAK,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/file.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,KAAG,IAmBtE,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,gBAAgB,MAAM,GAAG,MAAM,KAC9B,MAAM,GAAG,KAAK,GAAG,IA4CnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,eAAe,MAAM,GAAG,MAAM,EAC9B,aAAa,MAAM,KAClB,IAkBF,CAAC;AACF,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,eAAe,MAAM,KACpB,MAAM,GAAG,IAyBX,CAAC"}
package/src/lib/file.js DELETED
@@ -1,107 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { replaceInFileSync } from 'replace-in-file';
4
- export const createOrUpdateFile = (filePath, content) => {
5
- try {
6
- if (!fs.existsSync(filePath)) {
7
- // Create the folder if necessary.
8
- const dirPath = path.dirname(filePath);
9
- if (!fs.existsSync(dirPath)) {
10
- fs.mkdirSync(dirPath, { recursive: true });
11
- }
12
- // Create the file with the provided content.
13
- fs.writeFileSync(filePath, content);
14
- console.log(`✅ File successfully created: ${filePath}`);
15
- }
16
- else {
17
- console.log(`⚠️ File already exists: ${filePath}`);
18
- replaceFileContent(filePath, /[\s\S]*/, content);
19
- }
20
- }
21
- catch (error) {
22
- console.error('❌ Error while creating the file:', error);
23
- }
24
- };
25
- export const getFileContent = (filePath, searchPattern) => {
26
- try {
27
- // Vérifier si le fichier existe
28
- if (!fs.existsSync(filePath)) {
29
- console.error(`❌ The specified file does not exist: ${filePath}`);
30
- return null;
31
- }
32
- // Lire le contenu du fichier entier
33
- const fileContent = fs.readFileSync(filePath, 'utf8');
34
- // Si un motif est fourni, chercher le texte correspondant
35
- if (searchPattern) {
36
- if (typeof searchPattern === 'string') {
37
- const found = fileContent.includes(searchPattern)
38
- ? searchPattern
39
- : false;
40
- console.log(found
41
- ? `✅ The file contains the specified string: "${searchPattern}"`
42
- : `⚠️ The file does NOT contain the specified string: "${searchPattern}"`);
43
- return found;
44
- }
45
- else {
46
- const match = fileContent.match(searchPattern);
47
- if (match) {
48
- console.log(`✅ Found match: "${match[0]}"`);
49
- return match[0]; // Retourner le texte trouvé
50
- }
51
- else {
52
- console.log(`⚠️ No match found for the pattern: "${searchPattern.toString()}"`);
53
- return false; // Aucune correspondance trouvée
54
- }
55
- }
56
- }
57
- // Si aucun motif n'est fourni, retourner tout le contenu
58
- console.log(`✅ File content successfully retrieved.`);
59
- return fileContent;
60
- }
61
- catch (error) {
62
- console.error('❌ An error occurred while processing the file:', error);
63
- return null;
64
- }
65
- };
66
- export const replaceFileContent = (filePath, searchPattern, replacement) => {
67
- try {
68
- const results = replaceInFileSync({
69
- files: filePath,
70
- from: searchPattern,
71
- to: replacement,
72
- });
73
- if (results.length > 0 && results[0].hasChanged) {
74
- console.log(`✅ Content successfully replaced in the file: ${filePath}`);
75
- }
76
- else {
77
- console.log(`⚠️ No replacement made. Here are some possible reasons:\n- The pattern ${searchPattern} was not found.\n- The file might already contain the expected content.`);
78
- }
79
- }
80
- catch (error) {
81
- console.error('❌ Error while replacing the file content:', error);
82
- }
83
- };
84
- export const findTailwindCssFile = (startDir, searchPattern) => {
85
- const files = fs.readdirSync(startDir);
86
- for (const file of files) {
87
- const filePath = path.join(startDir, file);
88
- const stats = fs.statSync(filePath);
89
- if (stats.isDirectory()) {
90
- // Appeler récursivement si c'est un dossier
91
- const result = findTailwindCssFile(filePath, searchPattern);
92
- if (result)
93
- return result;
94
- }
95
- else if (file.endsWith('.css') ||
96
- file.endsWith('.scss') ||
97
- file.endsWith('.sass')) {
98
- const content = fs.readFileSync(filePath, 'utf8');
99
- if (content.includes(searchPattern)) {
100
- console.log('File found:\n', filePath);
101
- return filePath;
102
- }
103
- }
104
- }
105
- return null;
106
- };
107
- //# sourceMappingURL=file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAQ,EAAE;IAC5E,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,kCAAkC;YAClC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5B,EAAE,CAAC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AACnC,cAAc,mBAAmB,CAAC"}
package/src/lib/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from './main';
2
- export * from './plugins-tailwind';
3
- export * from './tailwind.plugin';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
package/src/lib/main.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import plugin from 'tailwindcss/plugin';
2
- export declare const createTheme: () => ReturnType<typeof plugin.withOptions>;
3
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/main.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,MAAM,UAAU,CAAC,OAAO,MAAM,CAAC,WAAW,CAInE,CAAC"}
package/src/lib/main.js DELETED
@@ -1,8 +0,0 @@
1
- import { bootstrapFromConfig } from '@udixio/theme';
2
- import { TailwindPlugin } from './tailwind.plugin';
3
- export const createTheme = () => {
4
- const app = bootstrapFromConfig();
5
- const plugin = app.plugins.getPlugin(TailwindPlugin).getInstance();
6
- return plugin.load();
7
- };
8
- //# sourceMappingURL=main.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,CAAC,MAAM,WAAW,GAAgD,GAAG,EAAE;IAC3E,MAAM,GAAG,GAAG,mBAAmB,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../../../../../packages/tailwind/src/lib/plugins-tailwind/font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,MAAqB,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,IAAI,EAAE,CACjB,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,EACzD,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC1C,UAAU,CAAC,OAAO,MAAM,CA2D5B,CAAC"}
@@ -1,36 +0,0 @@
1
- import plugin from 'tailwindcss/plugin';
2
- export const font = (fontStyles, responsiveBreakPoints) => {
3
- const createUtilities = ({ theme }) => {
4
- const pixelUnit = 'rem';
5
- const newUtilities = {};
6
- const baseTextStyle = (sizeValue) => ({
7
- fontSize: sizeValue.fontSize + pixelUnit,
8
- fontWeight: sizeValue.fontWeight,
9
- lineHeight: sizeValue.lineHeight + pixelUnit,
10
- letterSpacing: sizeValue.letterSpacing
11
- ? sizeValue.letterSpacing + pixelUnit
12
- : null,
13
- fontFamily: theme('fontFamily.' + sizeValue.fontFamily),
14
- });
15
- const responsiveTextStyle = (sizeValue, breakPointName, breakPointRatio) => ({
16
- [`@media (min-width: ${theme('screens.' + breakPointName, {})})`]: {
17
- fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
18
- lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit,
19
- },
20
- });
21
- for (const [roleName, roleValue] of Object.entries(fontStyles)) {
22
- for (const [sizeName, sizeValue] of Object.entries(roleValue)) {
23
- newUtilities['.text-' + roleName + '-' + sizeName] = Object.assign(Object.assign({}, baseTextStyle(sizeValue)), Object.entries(responsiveBreakPoints).reduce((acc, [breakPointName, breakPointRatio]) => {
24
- acc = Object.assign(Object.assign({}, acc), responsiveTextStyle(sizeValue, breakPointName, breakPointRatio));
25
- return acc;
26
- }, {}));
27
- }
28
- }
29
- return newUtilities;
30
- };
31
- return plugin(({ addUtilities, theme, }) => {
32
- const newUtilities = createUtilities({ theme });
33
- addUtilities(newUtilities);
34
- });
35
- };
36
- //# sourceMappingURL=font.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"font.js","sourceRoot":"","sources":["../../../../../../packages/tailwind/src/lib/plugins-tailwind/font.ts"],"names":[],"mappings":"AACA,OAAO,MAAqB,MAAM,oBAAoB,CAAC;AAEvD,MAAM,CAAC,MAAM,IAAI,GAGgB,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE;IACrE,MAAM,eAAe,GAAG,CAAC,EAAE,KAAK,EAA4B,EAAO,EAAE;QACnE,MAAM,SAAS,GAAG,KAAK,CAAC;QACxB,MAAM,YAAY,GAAQ,EAAE,CAAC;QAE7B,MAAM,aAAa,GAAG,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC;YAC/C,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS;YACxC,UAAU,EAAE,SAAS,CAAC,UAA4B;YAClD,UAAU,EAAE,SAAS,CAAC,UAAU,GAAG,SAAS;YAC5C,aAAa,EAAE,SAAS,CAAC,aAAa;gBACpC,CAAC,CAAC,SAAS,CAAC,aAAa,GAAG,SAAS;gBACrC,CAAC,CAAC,IAAI;YACR,UAAU,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC,UAAU,CAAC;SACxD,CAAC,CAAC;QAEH,MAAM,mBAAmB,GAAG,CAC1B,SAAoB,EACpB,cAAsB,EACtB,eAAuB,EACvB,EAAE,CAAC,CAAC;YACJ,CAAC,sBAAsB,KAAK,CAAC,UAAU,GAAG,cAAc,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE;gBACjE,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,eAAe,GAAG,SAAS;gBAC1D,UAAU,EAAE,SAAS,CAAC,UAAU,GAAG,eAAe,GAAG,SAAS;aAC/D;SACF,CAAC,CAAC;QAEH,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/D,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC9D,YAAY,CAAC,QAAQ,GAAG,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC,mCAC7C,aAAa,CAAC,SAAS,CAAC,GACxB,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,EAAE;oBACzC,GAAG,mCACE,GAAG,GACH,mBAAmB,CACpB,SAAS,EACT,cAAc,EACd,eAAe,CAChB,CACF,CAAC;oBACF,OAAO,GAAG,CAAC;gBACb,CAAC,EACD,EAAE,CACH,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,YAAmB,CAAC;IAC7B,CAAC,CAAC;IACF,OAAO,MAAM,CACX,CAAC,EACC,YAAY,EACZ,KAAK,GACsD,EAAE,EAAE;QAC/D,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAChD,YAAY,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/tailwind/src/lib/plugins-tailwind/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './state';
2
- export * from './font';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/tailwind/src/lib/plugins-tailwind/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -1,3 +0,0 @@
1
- import plugin from 'tailwindcss/plugin';
2
- export declare const state: (colorKeys: string[]) => ReturnType<typeof plugin>;
3
- //# sourceMappingURL=state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../../packages/tailwind/src/lib/plugins-tailwind/state.ts"],"names":[],"mappings":"AACA,OAAO,MAAqB,MAAM,oBAAoB,CAAC;AAevD,eAAO,MAAM,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,UAAU,CAAC,OAAO,MAAM,CAkB7D,CAAC"}
@@ -1,61 +0,0 @@
1
- // from tailwindcss src/util/flattenColors
2
- import plugin from 'tailwindcss/plugin';
3
- export const state = (colorKeys) => plugin((pluginArgs) => {
4
- addAllNewComponents(pluginArgs, {
5
- statePrefix: 'state',
6
- disabledStyles: {
7
- textOpacity: 0.38,
8
- backgroundOpacity: 0.12,
9
- },
10
- transition: {
11
- duration: 150,
12
- },
13
- }, colorKeys);
14
- }, {});
15
- const addAllNewComponents = ({ addComponents }, { statePrefix, disabledStyles, transition }, colorKeys) => {
16
- const newComponents = {};
17
- for (const isGroup of [false, true]) {
18
- const group = isGroup ? 'group-' : '';
19
- for (const colorName of colorKeys) {
20
- const className = `.${group}${statePrefix}-${colorName}`;
21
- newComponents[className] = {
22
- [`@apply ${group}hover:bg-${colorName}/[0.08]`]: {},
23
- [`@apply ${group}active:bg-${colorName}/[0.12]`]: {},
24
- [`@apply ${group}focus-visible:bg-${colorName}/[0.12]`]: {},
25
- };
26
- if (transition) {
27
- newComponents[className][`@apply transition-colors`] = {};
28
- newComponents[className][`@apply duration-${transition.duration}`] = {};
29
- }
30
- if (disabledStyles) {
31
- newComponents[className][`@apply ${group}disabled:text-on-surface/[${disabledStyles.textOpacity}]`] = {};
32
- newComponents[className][`@apply ${group}disabled:bg-on-surface/[${disabledStyles.backgroundOpacity}]`] = {};
33
- }
34
- }
35
- }
36
- for (const colorName of colorKeys) {
37
- for (const stateName of ['hover', 'active', 'focus', 'disabled']) {
38
- const className = `.${stateName}-${statePrefix}-${colorName}`;
39
- if (stateName === 'active' || stateName === 'focus') {
40
- newComponents[className] = {
41
- [`@apply bg-${colorName}/[0.12]`]: {},
42
- };
43
- }
44
- else if (stateName === 'hover') {
45
- newComponents[className] = {
46
- [`@apply bg-${colorName}/[0.08]`]: {},
47
- };
48
- }
49
- else if (stateName === 'disabled') {
50
- newComponents[className] = {
51
- [`@apply text-on-surface/[${disabledStyles.textOpacity}]`]: {},
52
- };
53
- newComponents[className] = {
54
- [`@apply bg-on-surface/[${disabledStyles.backgroundOpacity}]`]: {},
55
- };
56
- }
57
- }
58
- }
59
- addComponents(newComponents);
60
- };
61
- //# sourceMappingURL=state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../../packages/tailwind/src/lib/plugins-tailwind/state.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,OAAO,MAAqB,MAAM,oBAAoB,CAAC;AAevD,MAAM,CAAC,MAAM,KAAK,GAAuD,CACvE,SAAS,EACT,EAAE,CACF,MAAM,CAAC,CAAC,UAAqB,EAAE,EAAE;IAC/B,mBAAmB,CACjB,UAAU,EACV;QACE,WAAW,EAAE,OAAO;QACpB,cAAc,EAAE;YACd,WAAW,EAAE,IAAI;YACjB,iBAAiB,EAAE,IAAI;SACxB;QACD,UAAU,EAAE;YACV,QAAQ,EAAE,GAAG;SACd;KACF,EACD,SAAS,CACV,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAET,MAAM,mBAAmB,GAAG,CAC1B,EAAE,aAAa,EAAa,EAC5B,EA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AsB;CAClC;AAED,cAAM,kBAAmB,SAAQ,kBAAkB,CAAC,qBAAqB,CAAC;IACxE,MAAM;IAMN,IAAI,IAAI,UAAU,CAAC,OAAO,MAAM,CAAC,WAAW,CAAC;CAsF9C"}
@@ -1,92 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import plugin from 'tailwindcss/plugin';
3
- import { createOrUpdateFile, findTailwindCssFile, getFileContent, replaceFileContent, } from './file';
4
- import path from 'path';
5
- import { font, state } from './plugins-tailwind';
6
- import { FontPlugin, PluginAbstract, PluginImplAbstract } from '@udixio/theme';
7
- export class TailwindPlugin extends PluginAbstract {
8
- constructor() {
9
- super(...arguments);
10
- this.dependencies = [FontPlugin];
11
- this.name = 'tailwind';
12
- this.pluginClass = TailwindImplPlugin;
13
- }
14
- }
15
- class TailwindImplPlugin extends PluginImplAbstract {
16
- onInit() {
17
- var _a;
18
- var _b;
19
- (_a = (_b = this.options).responsiveBreakPoints) !== null && _a !== void 0 ? _a : (_b.responsiveBreakPoints = {
20
- lg: 1.125,
21
- });
22
- }
23
- load() {
24
- var _a;
25
- const searchKeyword = '@plugin "@udixio/tailwind"';
26
- const tailwindCssPath = findTailwindCssFile(process.cwd(), searchKeyword);
27
- if (!tailwindCssPath) {
28
- throw new Error('The style file containing the Udixio plugin was not found.\n Please use it first. (@plugin "@udixio/tailwind")');
29
- }
30
- const searchPattern = /@import ["']tailwindcss["'];/;
31
- const replacement = `@import 'tailwindcss';\n@import "./udixio.css";`;
32
- if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
33
- replaceFileContent(tailwindCssPath, searchPattern, replacement);
34
- }
35
- const cssFilePath = path.dirname(tailwindCssPath);
36
- const colors = {};
37
- for (const isDark of [false, true]) {
38
- this.api.themes.update({ isDark: isDark });
39
- for (const [key, value] of this.api.colors.getColors().entries()) {
40
- const newKey = key
41
- .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2')
42
- .toLowerCase();
43
- (_a = colors[newKey]) !== null && _a !== void 0 ? _a : (colors[newKey] = { light: '', dark: '' });
44
- colors[newKey][isDark ? 'dark' : 'light'] = value.getHex();
45
- }
46
- }
47
- const { fontStyles, fontFamily } = this.api.plugins
48
- .getPlugin(FontPlugin)
49
- .getInstance()
50
- .getFonts();
51
- createOrUpdateFile(path.join(cssFilePath, 'udixio.css'), `
52
- @custom-variant dark (&:where(.dark, .dark *));
53
- @theme {
54
- --color-*: initial;
55
- ${Object.entries(colors)
56
- .map(([key, value]) => `--color-${key}: ${value.light};`)
57
- .join('\n ')}
58
- }
59
- @layer theme {
60
- .dark {
61
- ${Object.entries(colors)
62
- .map(([key, value]) => `--color-${key}: ${value.dark};`)
63
- .join('\n ')}
64
- }
65
- }
66
- `);
67
- const plugins = [
68
- state(Object.keys(colors)),
69
- font(fontStyles, this.options.responsiveBreakPoints),
70
- ];
71
- return plugin.withOptions(
72
- // 1) factory(options) → la fonction “handler” du plugin
73
- (options = {}) => {
74
- return function (api) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- plugins.forEach((plugin) => {
77
- plugin.handler(api);
78
- });
79
- });
80
- };
81
- },
82
- // 2) config(options) → objet à merger dans tailwind.config
83
- (options = {}) => {
84
- return {
85
- theme: {
86
- fontFamily,
87
- },
88
- };
89
- });
90
- }
91
- }
92
- //# sourceMappingURL=tailwind.plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tailwind.plugin.js","sourceRoot":"","sources":["../../../../../packages/tailwind/src/lib/tailwind.plugin.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAChB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAA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