@udixio/tailwind 1.7.2 → 2.0.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.
@@ -1,329 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- const plugin = require("tailwindcss/plugin");
6
- const theme = require("@udixio/theme");
7
- const defaultConfig = {
8
- statePrefix: "state",
9
- disabledStyles: {
10
- textOpacity: 0.38,
11
- backgroundOpacity: 0.12
12
- },
13
- transition: {
14
- duration: 150
15
- }
16
- };
17
- const state = plugin.withOptions(({ colorKeys }) => {
18
- const resolved = {
19
- ...defaultConfig,
20
- disabledStyles: {
21
- ...defaultConfig.disabledStyles,
22
- ...{}
23
- },
24
- transition: {
25
- ...defaultConfig.transition,
26
- ...{}
27
- }
28
- };
29
- return ({ addComponents }) => {
30
- const newComponents = {};
31
- for (const isGroup of [false, true]) {
32
- const group = isGroup ? "group-" : "";
33
- for (const colorName of colorKeys) {
34
- const className = `.${group}${resolved.statePrefix}-${colorName}`;
35
- newComponents[className] = {
36
- [`@apply ${group}hover:bg-${colorName}/[0.08]`]: {},
37
- [`@apply ${group}active:bg-${colorName}/[0.12]`]: {},
38
- [`@apply ${group}focus-visible:bg-${colorName}/[0.12]`]: {},
39
- [`@apply transition-colors`]: {},
40
- [`@apply duration-${resolved.transition.duration}`]: {},
41
- [`@apply ${group}disabled:text-on-surface/[${resolved.disabledStyles.textOpacity}]`]: {},
42
- [`@apply ${group}disabled:bg-on-surface/[${resolved.disabledStyles.backgroundOpacity}]`]: {}
43
- };
44
- }
45
- }
46
- for (const colorName of colorKeys) {
47
- for (const stateName of ["hover", "active", "focus", "disabled"]) {
48
- const className = `.${stateName}-${resolved.statePrefix}-${colorName}`;
49
- if (stateName === "disabled") {
50
- newComponents[className] = {
51
- [`@apply text-on-surface/[${resolved.disabledStyles.textOpacity}]`]: {},
52
- [`@apply bg-on-surface/[${resolved.disabledStyles.backgroundOpacity}]`]: {}
53
- };
54
- } else {
55
- const opacity = stateName === "hover" ? 0.08 : 0.12;
56
- newComponents[className] = {
57
- [`@apply bg-${colorName}/[${opacity}]`]: {}
58
- };
59
- }
60
- }
61
- }
62
- addComponents(newComponents);
63
- };
64
- });
65
- const font = plugin.withOptions((options) => {
66
- return ({
67
- addUtilities,
68
- theme: theme2
69
- }) => {
70
- const { fontStyles, responsiveBreakPoints } = options;
71
- const pixelUnit = "rem";
72
- const newUtilities = {};
73
- const baseTextStyle = (sizeValue) => ({
74
- fontSize: sizeValue.fontSize + pixelUnit,
75
- fontWeight: sizeValue.fontWeight,
76
- lineHeight: sizeValue.lineHeight + pixelUnit,
77
- letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
78
- fontFamily: theme2("fontFamily." + sizeValue.fontFamily)
79
- });
80
- const responsiveTextStyle = (sizeValue, breakPointName, breakPointRatio) => ({
81
- [`@media (min-width: ${theme2("screens." + breakPointName, {})})`]: {
82
- fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
83
- lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
84
- }
85
- });
86
- for (const [roleName, roleValue] of Object.entries(fontStyles)) {
87
- for (const [sizeName, sizeValue] of Object.entries(roleValue)) {
88
- newUtilities[`.text-${roleName}-${sizeName}`] = {
89
- ...baseTextStyle(sizeValue),
90
- ...Object.entries(responsiveBreakPoints).reduce(
91
- (acc, [breakPointName, breakPointRatio]) => ({
92
- ...acc,
93
- ...responsiveTextStyle(
94
- sizeValue,
95
- breakPointName,
96
- breakPointRatio
97
- )
98
- }),
99
- {}
100
- )
101
- };
102
- }
103
- }
104
- addUtilities(newUtilities);
105
- };
106
- });
107
- const shadow = plugin(
108
- ({ addUtilities }) => {
109
- addUtilities({
110
- [".shadow"]: {
111
- boxShadow: "0 4px 10px #00000008, 0 0 2px #0000000f, 0 2px 6px #0000001f"
112
- },
113
- [".shadow-1"]: {
114
- boxShadow: "0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
115
- },
116
- [".shadow-2"]: {
117
- boxShadow: "0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
118
- },
119
- [".shadow-3"]: {
120
- boxShadow: "0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15)"
121
- },
122
- [".shadow-4"]: {
123
- boxShadow: "0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15)"
124
- },
125
- [".box-shadow-5"]: {
126
- boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)"
127
- }
128
- });
129
- }
130
- );
131
- const main = plugin.withOptions((args) => {
132
- const configCss = args;
133
- const fontStyles = {};
134
- configCss.fontStyles.forEach((line) => {
135
- const [styleToken, ...properties] = line.split(" ");
136
- const [roleToken, sizeToken] = styleToken.split("-");
137
- fontStyles[roleToken] ?? (fontStyles[roleToken] = {});
138
- properties.forEach((properties2) => {
139
- var _a;
140
- (_a = fontStyles[roleToken])[sizeToken] ?? (_a[sizeToken] = {});
141
- const [key, value] = properties2.slice(0, -1).split("[");
142
- fontStyles[roleToken][sizeToken][key] = value;
143
- });
144
- });
145
- let breakPointsCss = configCss.responsiveBreakPoints;
146
- if (!Array.isArray(breakPointsCss)) {
147
- breakPointsCss = [breakPointsCss];
148
- }
149
- const responsiveBreakPoints = {};
150
- breakPointsCss.forEach((line) => {
151
- const [key, value] = line.split(" ");
152
- responsiveBreakPoints[key] = value;
153
- });
154
- const options = {
155
- colorKeys: configCss.colorKeys,
156
- fontStyles,
157
- responsiveBreakPoints
158
- };
159
- return (api) => {
160
- font(options).handler(api);
161
- state(options).handler(api);
162
- shadow.handler(api);
163
- };
164
- });
165
- function createFlexibleSelector(...classes) {
166
- classes = classes.filter((classeName) => !!classeName);
167
- if (classes.length === 0) return "";
168
- if (classes.length === 1 && classes[0]) return classes[0];
169
- const selectors = [];
170
- selectors.push(classes.join(""));
171
- for (let i = 0; i < classes.length; i++) {
172
- const ancestor = classes[i];
173
- const descendants = classes.filter(
174
- (className, index) => index !== i && !!className
175
- );
176
- if (descendants.length === 1) {
177
- selectors.push(`${ancestor} ${descendants[0]}`);
178
- } else if (descendants.length > 1) {
179
- selectors.push(`${ancestor} ${descendants.join("")}`);
180
- for (const desc of descendants) {
181
- selectors.push(`${ancestor} ${desc}`);
182
- }
183
- }
184
- }
185
- for (let i = 0; i < classes.length; i++) {
186
- for (let j = i + 1; j < classes.length; j++) {
187
- selectors.push(`${classes[i]} ${classes[j]}`);
188
- selectors.push(`${classes[j]} ${classes[i]}`);
189
- }
190
- }
191
- const uniqueSelectors = [...new Set(selectors)];
192
- return `:is(${uniqueSelectors.join(", ")})`;
193
- }
194
- function darkStyle({
195
- selectors,
196
- mode,
197
- darkSelector,
198
- styles
199
- }) {
200
- selectors = selectors.filter((classeName) => !!classeName);
201
- if (mode === "media") {
202
- if (selectors.length !== 0) {
203
- return `@media (prefers-color-scheme: dark) {
204
- ${createFlexibleSelector(...selectors)} {
205
- ${styles}
206
- }
207
- }
208
- `;
209
- } else {
210
- return `@media (prefers-color-scheme: dark) {
211
- ${styles}
212
- }
213
- `;
214
- }
215
- } else {
216
- return `${createFlexibleSelector(...selectors, darkSelector)} {
217
- ${styles}
218
- }
219
- `;
220
- }
221
- }
222
- class TailwindPlugin extends theme.PluginAbstract {
223
- constructor() {
224
- super(...arguments);
225
- __publicField(this, "dependencies", [theme.FontPlugin]);
226
- __publicField(this, "name", "tailwind");
227
- __publicField(this, "pluginClass", TailwindImplPluginBrowser);
228
- }
229
- }
230
- class TailwindImplPluginBrowser extends theme.PluginImplAbstract {
231
- constructor() {
232
- super(...arguments);
233
- __publicField(this, "outputCss", "");
234
- }
235
- onInit() {
236
- var _a;
237
- (_a = this.options).responsiveBreakPoints ?? (_a.responsiveBreakPoints = {
238
- lg: 1.125
239
- });
240
- this.options = {
241
- responsiveBreakPoints: {
242
- lg: 1.125
243
- },
244
- darkMode: "class",
245
- darkSelector: ".dark",
246
- dynamicSelector: ".dynamic",
247
- ...this.options
248
- };
249
- }
250
- loadColor({ isDynamic }) {
251
- let { dynamicSelector, darkSelector } = this.options;
252
- if (!isDynamic) {
253
- dynamicSelector = void 0;
254
- }
255
- const darkMode = this.options.darkMode ?? "class";
256
- if (darkMode == "media") {
257
- darkSelector = void 0;
258
- }
259
- const colors = this.getColors();
260
- if (isDynamic) {
261
- this.outputCss += `
262
- @layer theme {
263
- .dynamic {
264
- ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
265
- }
266
- }`;
267
- } else {
268
- this.outputCss += `
269
- @theme {
270
- --color-*: initial;
271
- ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
272
- }`;
273
- }
274
- this.outputCss += `
275
- @layer theme {
276
- ${darkStyle({
277
- selectors: [dynamicSelector],
278
- mode: darkMode,
279
- darkSelector: darkSelector ?? "",
280
- styles: Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.dark};`).join("\n ")
281
- })}
282
- }`;
283
- for (const [key, value] of Object.entries(this.options.subThemes ?? {})) {
284
- this.api.themes.update({ sourceColorHex: value });
285
- const colors2 = this.getColors();
286
- this.outputCss += `
287
- @layer theme {
288
- ${createFlexibleSelector(dynamicSelector, ".theme-" + key)} {
289
- ${Object.entries(colors2).map(([key2, value2]) => `--color-${key2}: ${value2.dark};`).join("\n ")}
290
- }
291
- }
292
- `;
293
- this.outputCss += `
294
- @layer theme {
295
- ${darkStyle({
296
- selectors: [dynamicSelector, ".theme-" + key],
297
- mode: darkMode,
298
- darkSelector: darkSelector ?? "",
299
- styles: Object.entries(colors2).map(([key2, value2]) => `--color-${key2}: ${value2.dark};`).join("\n ")
300
- })}
301
- }`;
302
- }
303
- }
304
- getColors() {
305
- const colors = {};
306
- for (const isDark of [false, true]) {
307
- this.api.themes.update({ isDark });
308
- for (const [key, value] of this.api.colors.getColors().entries()) {
309
- const newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
310
- colors[newKey] ?? (colors[newKey] = { light: "", dark: "" });
311
- colors[newKey][isDark ? "dark" : "light"] = value.getHex();
312
- }
313
- }
314
- return colors;
315
- }
316
- async onLoad() {
317
- this.getColors();
318
- if (typeof window !== "undefined") {
319
- const { tailwindBrowserInit } = await Promise.resolve().then(() => require("./tailwind-browser-COFzjMN4.cjs"));
320
- this.outputCss = await tailwindBrowserInit(this.outputCss);
321
- }
322
- this.loadColor({ isDynamic: true });
323
- }
324
- }
325
- exports.TailwindImplPluginBrowser = TailwindImplPluginBrowser;
326
- exports.TailwindPlugin = TailwindPlugin;
327
- exports.font = font;
328
- exports.main = main;
329
- exports.state = state;
@@ -1,330 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import plugin from "tailwindcss/plugin";
5
- import { PluginAbstract, FontPlugin, PluginImplAbstract } from "@udixio/theme";
6
- const defaultConfig = {
7
- statePrefix: "state",
8
- disabledStyles: {
9
- textOpacity: 0.38,
10
- backgroundOpacity: 0.12
11
- },
12
- transition: {
13
- duration: 150
14
- }
15
- };
16
- const state = plugin.withOptions(({ colorKeys }) => {
17
- const resolved = {
18
- ...defaultConfig,
19
- disabledStyles: {
20
- ...defaultConfig.disabledStyles,
21
- ...{}
22
- },
23
- transition: {
24
- ...defaultConfig.transition,
25
- ...{}
26
- }
27
- };
28
- return ({ addComponents }) => {
29
- const newComponents = {};
30
- for (const isGroup of [false, true]) {
31
- const group = isGroup ? "group-" : "";
32
- for (const colorName of colorKeys) {
33
- const className = `.${group}${resolved.statePrefix}-${colorName}`;
34
- newComponents[className] = {
35
- [`@apply ${group}hover:bg-${colorName}/[0.08]`]: {},
36
- [`@apply ${group}active:bg-${colorName}/[0.12]`]: {},
37
- [`@apply ${group}focus-visible:bg-${colorName}/[0.12]`]: {},
38
- [`@apply transition-colors`]: {},
39
- [`@apply duration-${resolved.transition.duration}`]: {},
40
- [`@apply ${group}disabled:text-on-surface/[${resolved.disabledStyles.textOpacity}]`]: {},
41
- [`@apply ${group}disabled:bg-on-surface/[${resolved.disabledStyles.backgroundOpacity}]`]: {}
42
- };
43
- }
44
- }
45
- for (const colorName of colorKeys) {
46
- for (const stateName of ["hover", "active", "focus", "disabled"]) {
47
- const className = `.${stateName}-${resolved.statePrefix}-${colorName}`;
48
- if (stateName === "disabled") {
49
- newComponents[className] = {
50
- [`@apply text-on-surface/[${resolved.disabledStyles.textOpacity}]`]: {},
51
- [`@apply bg-on-surface/[${resolved.disabledStyles.backgroundOpacity}]`]: {}
52
- };
53
- } else {
54
- const opacity = stateName === "hover" ? 0.08 : 0.12;
55
- newComponents[className] = {
56
- [`@apply bg-${colorName}/[${opacity}]`]: {}
57
- };
58
- }
59
- }
60
- }
61
- addComponents(newComponents);
62
- };
63
- });
64
- const font = plugin.withOptions((options) => {
65
- return ({
66
- addUtilities,
67
- theme
68
- }) => {
69
- const { fontStyles, responsiveBreakPoints } = options;
70
- const pixelUnit = "rem";
71
- const newUtilities = {};
72
- const baseTextStyle = (sizeValue) => ({
73
- fontSize: sizeValue.fontSize + pixelUnit,
74
- fontWeight: sizeValue.fontWeight,
75
- lineHeight: sizeValue.lineHeight + pixelUnit,
76
- letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
77
- fontFamily: theme("fontFamily." + sizeValue.fontFamily)
78
- });
79
- const responsiveTextStyle = (sizeValue, breakPointName, breakPointRatio) => ({
80
- [`@media (min-width: ${theme("screens." + breakPointName, {})})`]: {
81
- fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
82
- lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
83
- }
84
- });
85
- for (const [roleName, roleValue] of Object.entries(fontStyles)) {
86
- for (const [sizeName, sizeValue] of Object.entries(roleValue)) {
87
- newUtilities[`.text-${roleName}-${sizeName}`] = {
88
- ...baseTextStyle(sizeValue),
89
- ...Object.entries(responsiveBreakPoints).reduce(
90
- (acc, [breakPointName, breakPointRatio]) => ({
91
- ...acc,
92
- ...responsiveTextStyle(
93
- sizeValue,
94
- breakPointName,
95
- breakPointRatio
96
- )
97
- }),
98
- {}
99
- )
100
- };
101
- }
102
- }
103
- addUtilities(newUtilities);
104
- };
105
- });
106
- const shadow = plugin(
107
- ({ addUtilities }) => {
108
- addUtilities({
109
- [".shadow"]: {
110
- boxShadow: "0 4px 10px #00000008, 0 0 2px #0000000f, 0 2px 6px #0000001f"
111
- },
112
- [".shadow-1"]: {
113
- boxShadow: "0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
114
- },
115
- [".shadow-2"]: {
116
- boxShadow: "0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
117
- },
118
- [".shadow-3"]: {
119
- boxShadow: "0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15)"
120
- },
121
- [".shadow-4"]: {
122
- boxShadow: "0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15)"
123
- },
124
- [".box-shadow-5"]: {
125
- boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)"
126
- }
127
- });
128
- }
129
- );
130
- const main = plugin.withOptions((args) => {
131
- const configCss = args;
132
- const fontStyles = {};
133
- configCss.fontStyles.forEach((line) => {
134
- const [styleToken, ...properties] = line.split(" ");
135
- const [roleToken, sizeToken] = styleToken.split("-");
136
- fontStyles[roleToken] ?? (fontStyles[roleToken] = {});
137
- properties.forEach((properties2) => {
138
- var _a;
139
- (_a = fontStyles[roleToken])[sizeToken] ?? (_a[sizeToken] = {});
140
- const [key, value] = properties2.slice(0, -1).split("[");
141
- fontStyles[roleToken][sizeToken][key] = value;
142
- });
143
- });
144
- let breakPointsCss = configCss.responsiveBreakPoints;
145
- if (!Array.isArray(breakPointsCss)) {
146
- breakPointsCss = [breakPointsCss];
147
- }
148
- const responsiveBreakPoints = {};
149
- breakPointsCss.forEach((line) => {
150
- const [key, value] = line.split(" ");
151
- responsiveBreakPoints[key] = value;
152
- });
153
- const options = {
154
- colorKeys: configCss.colorKeys,
155
- fontStyles,
156
- responsiveBreakPoints
157
- };
158
- return (api) => {
159
- font(options).handler(api);
160
- state(options).handler(api);
161
- shadow.handler(api);
162
- };
163
- });
164
- function createFlexibleSelector(...classes) {
165
- classes = classes.filter((classeName) => !!classeName);
166
- if (classes.length === 0) return "";
167
- if (classes.length === 1 && classes[0]) return classes[0];
168
- const selectors = [];
169
- selectors.push(classes.join(""));
170
- for (let i = 0; i < classes.length; i++) {
171
- const ancestor = classes[i];
172
- const descendants = classes.filter(
173
- (className, index) => index !== i && !!className
174
- );
175
- if (descendants.length === 1) {
176
- selectors.push(`${ancestor} ${descendants[0]}`);
177
- } else if (descendants.length > 1) {
178
- selectors.push(`${ancestor} ${descendants.join("")}`);
179
- for (const desc of descendants) {
180
- selectors.push(`${ancestor} ${desc}`);
181
- }
182
- }
183
- }
184
- for (let i = 0; i < classes.length; i++) {
185
- for (let j = i + 1; j < classes.length; j++) {
186
- selectors.push(`${classes[i]} ${classes[j]}`);
187
- selectors.push(`${classes[j]} ${classes[i]}`);
188
- }
189
- }
190
- const uniqueSelectors = [...new Set(selectors)];
191
- return `:is(${uniqueSelectors.join(", ")})`;
192
- }
193
- function darkStyle({
194
- selectors,
195
- mode,
196
- darkSelector,
197
- styles
198
- }) {
199
- selectors = selectors.filter((classeName) => !!classeName);
200
- if (mode === "media") {
201
- if (selectors.length !== 0) {
202
- return `@media (prefers-color-scheme: dark) {
203
- ${createFlexibleSelector(...selectors)} {
204
- ${styles}
205
- }
206
- }
207
- `;
208
- } else {
209
- return `@media (prefers-color-scheme: dark) {
210
- ${styles}
211
- }
212
- `;
213
- }
214
- } else {
215
- return `${createFlexibleSelector(...selectors, darkSelector)} {
216
- ${styles}
217
- }
218
- `;
219
- }
220
- }
221
- class TailwindPlugin extends PluginAbstract {
222
- constructor() {
223
- super(...arguments);
224
- __publicField(this, "dependencies", [FontPlugin]);
225
- __publicField(this, "name", "tailwind");
226
- __publicField(this, "pluginClass", TailwindImplPluginBrowser);
227
- }
228
- }
229
- class TailwindImplPluginBrowser extends PluginImplAbstract {
230
- constructor() {
231
- super(...arguments);
232
- __publicField(this, "outputCss", "");
233
- }
234
- onInit() {
235
- var _a;
236
- (_a = this.options).responsiveBreakPoints ?? (_a.responsiveBreakPoints = {
237
- lg: 1.125
238
- });
239
- this.options = {
240
- responsiveBreakPoints: {
241
- lg: 1.125
242
- },
243
- darkMode: "class",
244
- darkSelector: ".dark",
245
- dynamicSelector: ".dynamic",
246
- ...this.options
247
- };
248
- }
249
- loadColor({ isDynamic }) {
250
- let { dynamicSelector, darkSelector } = this.options;
251
- if (!isDynamic) {
252
- dynamicSelector = void 0;
253
- }
254
- const darkMode = this.options.darkMode ?? "class";
255
- if (darkMode == "media") {
256
- darkSelector = void 0;
257
- }
258
- const colors = this.getColors();
259
- if (isDynamic) {
260
- this.outputCss += `
261
- @layer theme {
262
- .dynamic {
263
- ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
264
- }
265
- }`;
266
- } else {
267
- this.outputCss += `
268
- @theme {
269
- --color-*: initial;
270
- ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
271
- }`;
272
- }
273
- this.outputCss += `
274
- @layer theme {
275
- ${darkStyle({
276
- selectors: [dynamicSelector],
277
- mode: darkMode,
278
- darkSelector: darkSelector ?? "",
279
- styles: Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.dark};`).join("\n ")
280
- })}
281
- }`;
282
- for (const [key, value] of Object.entries(this.options.subThemes ?? {})) {
283
- this.api.themes.update({ sourceColorHex: value });
284
- const colors2 = this.getColors();
285
- this.outputCss += `
286
- @layer theme {
287
- ${createFlexibleSelector(dynamicSelector, ".theme-" + key)} {
288
- ${Object.entries(colors2).map(([key2, value2]) => `--color-${key2}: ${value2.dark};`).join("\n ")}
289
- }
290
- }
291
- `;
292
- this.outputCss += `
293
- @layer theme {
294
- ${darkStyle({
295
- selectors: [dynamicSelector, ".theme-" + key],
296
- mode: darkMode,
297
- darkSelector: darkSelector ?? "",
298
- styles: Object.entries(colors2).map(([key2, value2]) => `--color-${key2}: ${value2.dark};`).join("\n ")
299
- })}
300
- }`;
301
- }
302
- }
303
- getColors() {
304
- const colors = {};
305
- for (const isDark of [false, true]) {
306
- this.api.themes.update({ isDark });
307
- for (const [key, value] of this.api.colors.getColors().entries()) {
308
- const newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
309
- colors[newKey] ?? (colors[newKey] = { light: "", dark: "" });
310
- colors[newKey][isDark ? "dark" : "light"] = value.getHex();
311
- }
312
- }
313
- return colors;
314
- }
315
- async onLoad() {
316
- this.getColors();
317
- if (typeof window !== "undefined") {
318
- const { tailwindBrowserInit } = await import("./tailwind-browser-CTGKNrKy.js");
319
- this.outputCss = await tailwindBrowserInit(this.outputCss);
320
- }
321
- this.loadColor({ isDynamic: true });
322
- }
323
- }
324
- export {
325
- TailwindImplPluginBrowser as T,
326
- TailwindPlugin as a,
327
- font as f,
328
- main as m,
329
- state as s
330
- };