@udixio/tailwind 1.7.3 → 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.
@@ -0,0 +1,773 @@
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 { kebabCase } from "text-case";
6
+ import { PluginAbstract, FontPlugin, PluginImplAbstract } from "@udixio/theme";
7
+ import { Hct, argbFromHex, hexFromArgb } from "@material/material-color-utilities";
8
+ const createAnimationFunc = ({
9
+ addBase,
10
+ prefix,
11
+ matchUtilities,
12
+ addUtilities
13
+ }) => (name, styles, values, callback) => {
14
+ const variableName = (propertyName) => {
15
+ return `--${prefix}-${propertyName}`;
16
+ };
17
+ const param = (propertyName) => {
18
+ var _a;
19
+ const defaultValue = (_a = values[propertyName]) == null ? void 0 : _a.DEFAULT;
20
+ return `var(${variableName(propertyName)} ${defaultValue ? `, ${defaultValue}` : ""})`;
21
+ };
22
+ const dependencies = [];
23
+ Object.values(styles(param)).forEach((step) => {
24
+ Object.keys(step).forEach((key) => {
25
+ dependencies.push(kebabCase(key));
26
+ });
27
+ });
28
+ addBase({
29
+ [`@keyframes ${prefix}-${name}`]: styles(param)
30
+ });
31
+ addUtilities({
32
+ [`.${prefix}-${name}, .${prefix}-${name}-in, .${prefix}-${name}-out`]: {
33
+ [`--${prefix}-name-${name}`]: `${prefix}-${name}`,
34
+ [`--${prefix}-dependencies-${name}`]: dependencies.join(", "),
35
+ animationDuration: `var(--${prefix}-durations, 300ms)`,
36
+ animationDelay: `var(--${prefix}-delays, 0)`,
37
+ animationTimingFunction: `var(--${prefix}-eases, cubic-bezier(0.4, 0, 0.2, 1))`,
38
+ animationFillMode: "both"
39
+ },
40
+ [`.${prefix}-${name}, .${prefix}-${name}-in`]: {
41
+ animationPlayState: `var(--${prefix}-in-state, paused)`
42
+ },
43
+ [`.${prefix}-${name}-out`]: {
44
+ animationPlayState: `var(--${prefix}-out-state, paused)`
45
+ }
46
+ });
47
+ addUtilities({
48
+ [`.${prefix}-${name}-scroll`]: {
49
+ [`--${prefix}-name-${name}`]: `${prefix}-${name}`,
50
+ [`--${prefix}-dependencies-${name}`]: dependencies.join(", "),
51
+ animationTimeline: `var(--${prefix}-timeline, view())`,
52
+ animationRangeStart: `var(--${prefix}-range-start, entry 20%)`,
53
+ animationRangeEnd: `var(--${prefix}-range-end, cover 50%)`,
54
+ animationFillMode: "both"
55
+ }
56
+ });
57
+ Object.entries(values).forEach(([key, value], index) => {
58
+ let as = value.as;
59
+ if (index !== 0 && !value.as) {
60
+ as = key;
61
+ }
62
+ matchUtilities(
63
+ {
64
+ [`${prefix}-${name}${as ? "-" + as : ""}`]: (value2) => ({
65
+ [variableName(key)]: value2
66
+ })
67
+ },
68
+ {
69
+ values: value.values
70
+ }
71
+ );
72
+ });
73
+ callback == null ? void 0 : callback({ variableName, name, dependencies });
74
+ };
75
+ const animation = plugin.withOptions(
76
+ ({ prefix = "anim" }) => {
77
+ return ({ addBase, matchUtilities, addUtilities }) => {
78
+ const createAnimation = createAnimationFunc({
79
+ addBase,
80
+ prefix,
81
+ matchUtilities,
82
+ addUtilities
83
+ });
84
+ addBase({
85
+ "@keyframes enter": {
86
+ from: {
87
+ opacity: `var(--${prefix}-enter-opacity, 1)`,
88
+ transform: `translate3d(var(--${prefix}-enter-translate-x, 0), var(--${prefix}-enter-translate-y, 0), 0) scale3d(var(--${prefix}-enter-scale, 1), var(--${prefix}-enter-scale, 1), var(--${prefix}-enter-scale, 1)) rotate(var(--${prefix}-enter-rotate, 0))`
89
+ }
90
+ },
91
+ "@keyframes exit": {
92
+ to: {
93
+ opacity: `var(--${prefix}-exit-opacity, 1)`,
94
+ transform: `translate3d(var(--${prefix}-exit-translate-x, 0), var(--${prefix}-exit-translate-y, 0), 0) scale3d(var(--${prefix}-exit-scale, 1), var(--${prefix}-exit-scale, 1), var(--${prefix}-exit-scale, 1)) rotate(var(--${prefix}-exit-rotate, 0))`
95
+ }
96
+ }
97
+ });
98
+ addUtilities({
99
+ // in/out
100
+ // run/pause state
101
+ [`.${prefix}-in-run`]: { [`--${prefix}-in-state`]: "running" },
102
+ [`.${prefix}-in-paused`]: { [`--${prefix}-in-state`]: "paused" },
103
+ // scroll-driven
104
+ [`.${prefix}-timeline-block`]: {
105
+ animationTimeline: "view(block)"
106
+ },
107
+ [`.${prefix}-timeline-inline`]: {
108
+ animationTimeline: "view(inline)"
109
+ },
110
+ // aliases
111
+ [`.${prefix}-timeline-y`]: {
112
+ animationTimeline: "view(block)"
113
+ },
114
+ [`.${prefix}-timeline-x`]: {
115
+ animationTimeline: "view(inline)"
116
+ }
117
+ });
118
+ addBase({
119
+ [`[data-${prefix}-in-run]`]: { [`--${prefix}-in-state`]: "running" },
120
+ [`[data-${prefix}-in-paused]`]: { [`--${prefix}-in-state`]: "paused" }
121
+ });
122
+ createAnimation(
123
+ "fade",
124
+ (v) => ({
125
+ from: {
126
+ opacity: v("opacity")
127
+ }
128
+ }),
129
+ {
130
+ opacity: {
131
+ DEFAULT: "0",
132
+ values: {
133
+ 0: "0",
134
+ 5: "0.05",
135
+ 10: "0.1",
136
+ 20: "0.2",
137
+ 25: "0.25",
138
+ 30: "0.3",
139
+ 40: "0.4",
140
+ 50: "0.5",
141
+ 60: "0.6",
142
+ 70: "0.7",
143
+ 75: "0.75",
144
+ 80: "0.8",
145
+ 90: "0.9",
146
+ 95: "0.95",
147
+ 100: "1"
148
+ }
149
+ }
150
+ }
151
+ );
152
+ createAnimation(
153
+ "scale",
154
+ (v) => ({
155
+ from: {
156
+ scale: v("scale")
157
+ }
158
+ }),
159
+ {
160
+ scale: {
161
+ DEFAULT: ".95",
162
+ values: {
163
+ 0: "0",
164
+ 50: ".5",
165
+ 75: ".75",
166
+ 90: ".9",
167
+ 95: ".95",
168
+ 100: "1",
169
+ 105: "1.05",
170
+ 110: "1.1",
171
+ 125: "1.25",
172
+ 150: "1.5"
173
+ }
174
+ }
175
+ }
176
+ );
177
+ const slideValues = {
178
+ DEFAULT: "2rem",
179
+ values: {
180
+ full: "100%",
181
+ 0: "0px",
182
+ px: "1px",
183
+ 0.5: "0.125rem",
184
+ 1: "0.25rem",
185
+ 1.5: "0.375rem",
186
+ 2: "0.5rem",
187
+ 2.5: "0.625rem",
188
+ 3: "0.75rem",
189
+ 3.5: "0.875rem",
190
+ 4: "1rem",
191
+ 5: "1.25rem",
192
+ 6: "1.5rem",
193
+ 7: "1.75rem",
194
+ 8: "2rem",
195
+ 9: "2.25rem",
196
+ 10: "2.5rem",
197
+ 11: "2.75rem",
198
+ 12: "3rem",
199
+ 14: "3.5rem",
200
+ 16: "4rem",
201
+ 20: "5rem",
202
+ 24: "6rem",
203
+ 28: "7rem",
204
+ 32: "8rem",
205
+ 36: "9rem",
206
+ 40: "10rem",
207
+ 44: "11rem",
208
+ 48: "12rem",
209
+ 52: "13rem",
210
+ 56: "14rem",
211
+ 60: "15rem",
212
+ 64: "16rem",
213
+ 72: "18rem",
214
+ 80: "20rem",
215
+ 96: "24rem"
216
+ }
217
+ };
218
+ createAnimation(
219
+ "slide",
220
+ (param) => ({
221
+ from: {
222
+ translate: `calc(${param("distance")} * ${param("dx")}) calc(${param("distance")} * ${param("dy")});`
223
+ },
224
+ to: {
225
+ translate: `var(--tw-translate-x, 0) var(--tw-translate-y, 0)`
226
+ }
227
+ }),
228
+ {
229
+ distance: {
230
+ ...slideValues
231
+ }
232
+ },
233
+ ({ name, variableName, dependencies }) => {
234
+ [
235
+ "up",
236
+ "down",
237
+ "left",
238
+ "right",
239
+ "from-top",
240
+ "from-bottom",
241
+ "from-left",
242
+ "from-right",
243
+ "from-top-left",
244
+ "from-top-right",
245
+ "from-bottom-left",
246
+ "from-bottom-right",
247
+ "up-left",
248
+ "up-right",
249
+ "down-left",
250
+ "down-right"
251
+ ].forEach((directionAlias) => {
252
+ let direction = "";
253
+ if (directionAlias.startsWith("from-")) {
254
+ direction = directionAlias;
255
+ } else if (directionAlias === "up") {
256
+ direction = "from-bottom";
257
+ } else if (directionAlias === "down") {
258
+ direction = "from-top";
259
+ } else if (directionAlias === "left") {
260
+ direction = "from-right";
261
+ } else if (directionAlias === "right") {
262
+ direction = "from-left";
263
+ } else if (directionAlias === "up-left") {
264
+ direction = "from-bottom-right";
265
+ } else if (directionAlias === "up-right") {
266
+ direction = "from-bottom-left";
267
+ } else if (directionAlias === "down-left") {
268
+ direction = "from-top-right";
269
+ } else if (directionAlias === "down-right") {
270
+ direction = "from-top-left";
271
+ }
272
+ if (!direction) {
273
+ throw new Error(`Invalid direction: ${directionAlias}`);
274
+ }
275
+ const dxdy = {
276
+ "from-top": { dx: "0", dy: "1" },
277
+ "from-bottom": { dx: "0", dy: "-1" },
278
+ "from-left": { dx: "1", dy: "0" },
279
+ "from-right": { dx: "-1", dy: "0" },
280
+ "from-top-left": { dx: "1", dy: "1" },
281
+ "from-top-right": { dx: "-1", dy: "1" },
282
+ "from-bottom-left": { dx: "1", dy: "-1" },
283
+ "from-bottom-right": { dx: "-1", dy: "-1" }
284
+ };
285
+ const { dx, dy } = dxdy[direction];
286
+ addUtilities({
287
+ [`.${prefix}-${name}-${directionAlias}, .${prefix}-${name}-in-${directionAlias}, .${prefix}-${name}-out-${directionAlias}`]: {
288
+ [`--${prefix}-name-${name}-${directionAlias}`]: `${prefix}-${name}`,
289
+ [`--${prefix}-name-${name}`]: `${prefix}-${name}`,
290
+ [`--${prefix}-dependencies-${name}`]: dependencies.join(", "),
291
+ animationDuration: `var(--${prefix}-durations, 300ms)`,
292
+ animationDelay: `var(--${prefix}-delays, 0)`,
293
+ animationTimingFunction: `var(--${prefix}-eases, cubic-bezier(0.4, 0, 0.2, 1))`,
294
+ animationFillMode: "both",
295
+ [variableName("dx")]: dx,
296
+ [variableName("dy")]: dy
297
+ },
298
+ [`.${prefix}-${name}-${directionAlias}, .${prefix}-${name}-in-${directionAlias}`]: {
299
+ animationPlayState: `var(--${prefix}-in-state, paused)`
300
+ },
301
+ [`.${prefix}-${name}-out-${directionAlias}`]: {
302
+ animationPlayState: `var(--${prefix}-out-state, paused)`
303
+ }
304
+ });
305
+ addUtilities({
306
+ [`.${prefix}-${name}-scroll-${directionAlias}`]: {
307
+ [`--${prefix}-name-${name}-${directionAlias}`]: `${prefix}-${name}`,
308
+ [`--${prefix}-name-${name}`]: `${prefix}-${name}`,
309
+ [`--${prefix}-dependencies-${name}`]: dependencies.join(", "),
310
+ animationTimeline: `var(--${prefix}-timeline, view())`,
311
+ animationRangeStart: `var(--${prefix}-range-start, entry 20%)`,
312
+ animationRangeEnd: `var(--${prefix}-range-end, cover 50%)`,
313
+ animationFillMode: "both",
314
+ [variableName("dx")]: dx,
315
+ [variableName("dy")]: dy
316
+ }
317
+ });
318
+ });
319
+ }
320
+ );
321
+ matchUtilities(
322
+ {
323
+ [`${prefix}-duration`]: (value) => ({ animationDuration: value })
324
+ },
325
+ {
326
+ values: {
327
+ 75: "75ms",
328
+ 100: "100ms",
329
+ 150: "150ms",
330
+ 200: "200ms",
331
+ 300: "300ms",
332
+ 500: "500ms",
333
+ 700: "700ms",
334
+ 1e3: "1000ms",
335
+ 1500: "1500ms",
336
+ 2e3: "2000ms",
337
+ 3e3: "3000ms"
338
+ }
339
+ }
340
+ );
341
+ matchUtilities(
342
+ { [`${prefix}-delay`]: (value) => ({ animationDelay: value }) },
343
+ {
344
+ values: {
345
+ 0: "0ms",
346
+ 75: "75ms",
347
+ 100: "100ms",
348
+ 150: "150ms",
349
+ 200: "200ms",
350
+ 300: "300ms",
351
+ 500: "500ms",
352
+ 700: "700ms",
353
+ 1e3: "1000ms",
354
+ 1500: "1500ms",
355
+ 2e3: "2000ms",
356
+ 3e3: "3000ms"
357
+ }
358
+ }
359
+ );
360
+ matchUtilities(
361
+ { [`${prefix}-ease`]: (value) => ({ animationTimingFunction: value }) },
362
+ {
363
+ values: {
364
+ linear: "linear",
365
+ in: "cubic-bezier(0.4, 0, 1, 1)",
366
+ out: "cubic-bezier(0, 0, 0.2, 1)",
367
+ "in-out": "cubic-bezier(0.4, 0, 0.2, 1)"
368
+ }
369
+ }
370
+ );
371
+ matchUtilities(
372
+ { [`${prefix}-fill`]: (value) => ({ animationFillMode: value }) },
373
+ {
374
+ values: {
375
+ none: "none",
376
+ forwards: "forwards",
377
+ backwards: "backwards",
378
+ both: "both"
379
+ }
380
+ }
381
+ );
382
+ matchUtilities(
383
+ {
384
+ [`${prefix}-timeline`]: (value) => ({
385
+ [`--${prefix}-timeline`]: value
386
+ })
387
+ },
388
+ {
389
+ values: {
390
+ view: "view()",
391
+ "view-block": "view(block)",
392
+ "view-inline": "view(inline)"
393
+ }
394
+ }
395
+ );
396
+ matchUtilities(
397
+ {
398
+ [`${prefix}-range-start`]: (value) => ({
399
+ [`--${prefix}-range-start`]: value
400
+ })
401
+ },
402
+ {
403
+ values: {
404
+ "entry-0": "entry 0%",
405
+ "entry-20": "entry 20%",
406
+ "entry-50": "entry 50%",
407
+ "entry-80": "entry 80%",
408
+ "entry-100": "entry 100%",
409
+ "contain-0": "contain 0%",
410
+ "cover-0": "cover 0%",
411
+ "cover-50": "cover 50%",
412
+ "cover-100": "cover 100%",
413
+ "exit-0": "exit 0%",
414
+ "exit-20": "exit 20%",
415
+ "exit-100": "exit 100%"
416
+ }
417
+ }
418
+ );
419
+ matchUtilities(
420
+ {
421
+ [`${prefix}-range-end`]: (value) => ({
422
+ [`--${prefix}-range-end`]: value
423
+ })
424
+ },
425
+ {
426
+ values: {
427
+ "entry-0": "entry 0%",
428
+ "entry-20": "entry 20%",
429
+ "entry-50": "entry 50%",
430
+ "entry-80": "entry 80%",
431
+ "entry-100": "entry 100%",
432
+ "contain-0": "contain 0%",
433
+ "cover-0": "cover 0%",
434
+ "cover-50": "cover 50%",
435
+ "cover-100": "cover 100%",
436
+ "exit-0": "exit 0%",
437
+ "exit-20": "exit 20%",
438
+ "exit-100": "exit 100%"
439
+ }
440
+ }
441
+ );
442
+ };
443
+ }
444
+ );
445
+ const font = plugin.withOptions((options) => {
446
+ return ({
447
+ addUtilities,
448
+ theme
449
+ }) => {
450
+ const { fontStyles, responsiveBreakPoints } = options;
451
+ const pixelUnit = "rem";
452
+ const newUtilities = {};
453
+ const baseTextStyle = (sizeValue) => ({
454
+ fontSize: sizeValue.fontSize + pixelUnit,
455
+ fontWeight: sizeValue.fontWeight,
456
+ lineHeight: sizeValue.lineHeight + pixelUnit,
457
+ letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
458
+ fontFamily: theme("fontFamily." + sizeValue.fontFamily)
459
+ });
460
+ const responsiveTextStyle = (sizeValue, breakPointName, breakPointRatio) => ({
461
+ [`@media (min-width: ${theme("screens." + breakPointName, {})})`]: {
462
+ fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
463
+ lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
464
+ }
465
+ });
466
+ for (const [roleName, roleValue] of Object.entries(fontStyles)) {
467
+ for (const [sizeName, sizeValue] of Object.entries(roleValue)) {
468
+ newUtilities[`.text-${roleName}-${sizeName}`] = {
469
+ ...baseTextStyle(sizeValue),
470
+ ...Object.entries(responsiveBreakPoints).reduce(
471
+ (acc, [breakPointName, breakPointRatio]) => ({
472
+ ...acc,
473
+ ...responsiveTextStyle(
474
+ sizeValue,
475
+ breakPointName,
476
+ breakPointRatio
477
+ )
478
+ }),
479
+ {}
480
+ )
481
+ };
482
+ }
483
+ }
484
+ addUtilities(newUtilities);
485
+ };
486
+ });
487
+ const defaultConfig = {
488
+ statePrefix: "state",
489
+ disabledStyles: {
490
+ textOpacity: 0.38,
491
+ backgroundOpacity: 0.12
492
+ },
493
+ transition: {
494
+ duration: 150
495
+ }
496
+ };
497
+ const state = plugin.withOptions(({ colorKeys }) => {
498
+ const resolved = {
499
+ ...defaultConfig,
500
+ disabledStyles: {
501
+ ...defaultConfig.disabledStyles,
502
+ ...{}
503
+ },
504
+ transition: {
505
+ ...defaultConfig.transition,
506
+ ...{}
507
+ }
508
+ };
509
+ return ({ addComponents }) => {
510
+ const newComponents = {};
511
+ for (const isGroup of [false, true]) {
512
+ const group = isGroup ? "group-" : "";
513
+ for (const colorName of colorKeys) {
514
+ const className = `.${group}${resolved.statePrefix}-${colorName}`;
515
+ newComponents[className] = {
516
+ [`@apply ${group}hover:bg-${colorName}/[0.08]`]: {},
517
+ [`@apply ${group}active:bg-${colorName}/[0.12]`]: {},
518
+ [`@apply ${group}focus-visible:bg-${colorName}/[0.12]`]: {},
519
+ [`@apply transition-colors`]: {},
520
+ [`@apply duration-${resolved.transition.duration}`]: {},
521
+ [`@apply ${group}disabled:text-on-surface/[${resolved.disabledStyles.textOpacity}]`]: {},
522
+ [`@apply ${group}disabled:bg-on-surface/[${resolved.disabledStyles.backgroundOpacity}]`]: {}
523
+ };
524
+ }
525
+ }
526
+ for (const colorName of colorKeys) {
527
+ for (const stateName of ["hover", "active", "focus", "disabled"]) {
528
+ const className = `.${stateName}-${resolved.statePrefix}-${colorName}`;
529
+ if (stateName === "disabled") {
530
+ newComponents[className] = {
531
+ [`@apply text-on-surface/[${resolved.disabledStyles.textOpacity}]`]: {},
532
+ [`@apply bg-on-surface/[${resolved.disabledStyles.backgroundOpacity}]`]: {}
533
+ };
534
+ } else {
535
+ const opacity = stateName === "hover" ? 0.08 : 0.12;
536
+ newComponents[className] = {
537
+ [`@apply bg-${colorName}/[${opacity}]`]: {}
538
+ };
539
+ }
540
+ }
541
+ }
542
+ addComponents(newComponents);
543
+ };
544
+ });
545
+ const shadow = plugin(
546
+ ({ addUtilities }) => {
547
+ addUtilities({
548
+ [".shadow"]: {
549
+ boxShadow: "0 4px 10px #00000008, 0 0 2px #0000000f, 0 2px 6px #0000001f"
550
+ },
551
+ [".shadow-1"]: {
552
+ boxShadow: "0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
553
+ },
554
+ [".shadow-2"]: {
555
+ boxShadow: "0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
556
+ },
557
+ [".shadow-3"]: {
558
+ boxShadow: "0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15)"
559
+ },
560
+ [".shadow-4"]: {
561
+ boxShadow: "0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15)"
562
+ },
563
+ [".box-shadow-5"]: {
564
+ boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)"
565
+ }
566
+ });
567
+ }
568
+ );
569
+ const main = plugin.withOptions((args) => {
570
+ const configCss = args;
571
+ const fontStyles = {};
572
+ configCss.fontStyles.forEach((line) => {
573
+ const [styleToken, ...properties] = line.split(" ");
574
+ const [roleToken, sizeToken] = styleToken.split("-");
575
+ fontStyles[roleToken] ?? (fontStyles[roleToken] = {});
576
+ properties.forEach((properties2) => {
577
+ var _a;
578
+ (_a = fontStyles[roleToken])[sizeToken] ?? (_a[sizeToken] = {});
579
+ const [key, value] = properties2.slice(0, -1).split("[");
580
+ fontStyles[roleToken][sizeToken][key] = value;
581
+ });
582
+ });
583
+ let breakPointsCss = configCss.responsiveBreakPoints;
584
+ if (!Array.isArray(breakPointsCss)) {
585
+ breakPointsCss = [breakPointsCss];
586
+ }
587
+ const responsiveBreakPoints = {};
588
+ breakPointsCss.forEach((line) => {
589
+ const [key, value] = line.split(" ");
590
+ responsiveBreakPoints[key] = value;
591
+ });
592
+ const options = {
593
+ colorKeys: configCss.colorKeys,
594
+ fontStyles,
595
+ responsiveBreakPoints
596
+ };
597
+ return (api) => {
598
+ font(options).handler(api);
599
+ state(options).handler(api);
600
+ shadow.handler(api);
601
+ animation(options).handler(api);
602
+ };
603
+ });
604
+ function createFlexibleSelector(...classes) {
605
+ classes = classes.filter((classeName) => !!classeName);
606
+ if (classes.length === 0) return "";
607
+ if (classes.length === 1 && classes[0]) return classes[0];
608
+ const selectors = [];
609
+ selectors.push(classes.join(""));
610
+ for (let i = 0; i < classes.length; i++) {
611
+ const ancestor = classes[i];
612
+ const descendants = classes.filter(
613
+ (className, index) => index !== i && !!className
614
+ );
615
+ if (descendants.length === 1) {
616
+ selectors.push(`${ancestor} ${descendants[0]}`);
617
+ } else if (descendants.length > 1) {
618
+ selectors.push(`${ancestor} ${descendants.join("")}`);
619
+ for (const desc of descendants) {
620
+ selectors.push(`${ancestor} ${desc}`);
621
+ }
622
+ }
623
+ }
624
+ for (let i = 0; i < classes.length; i++) {
625
+ for (let j = i + 1; j < classes.length; j++) {
626
+ selectors.push(`${classes[i]} ${classes[j]}`);
627
+ selectors.push(`${classes[j]} ${classes[i]}`);
628
+ }
629
+ }
630
+ const uniqueSelectors = [...new Set(selectors)];
631
+ return `:is(${uniqueSelectors.join(", ")})`;
632
+ }
633
+ function darkStyle({
634
+ selectors,
635
+ mode,
636
+ darkSelector,
637
+ styles
638
+ }) {
639
+ selectors = selectors.filter((classeName) => !!classeName);
640
+ if (mode === "media") {
641
+ if (selectors.length !== 0) {
642
+ return `@media (prefers-color-scheme: dark) {
643
+ ${createFlexibleSelector(...selectors)} {
644
+ ${styles}
645
+ }
646
+ }
647
+ `;
648
+ } else {
649
+ return `@media (prefers-color-scheme: dark) {
650
+ ${styles}
651
+ }
652
+ `;
653
+ }
654
+ } else {
655
+ return `${createFlexibleSelector(...selectors, darkSelector)} {
656
+ ${styles}
657
+ }
658
+ `;
659
+ }
660
+ }
661
+ class TailwindPlugin extends PluginAbstract {
662
+ constructor() {
663
+ super(...arguments);
664
+ __publicField(this, "dependencies", [FontPlugin]);
665
+ __publicField(this, "name", "tailwind");
666
+ __publicField(this, "pluginClass", TailwindImplPluginBrowser);
667
+ }
668
+ }
669
+ class TailwindImplPluginBrowser extends PluginImplAbstract {
670
+ constructor() {
671
+ super(...arguments);
672
+ __publicField(this, "outputCss", "");
673
+ }
674
+ onInit() {
675
+ var _a;
676
+ (_a = this.options).responsiveBreakPoints ?? (_a.responsiveBreakPoints = {
677
+ lg: 1.125
678
+ });
679
+ this.options = {
680
+ responsiveBreakPoints: {
681
+ lg: 1.125
682
+ },
683
+ darkMode: "class",
684
+ darkSelector: ".dark",
685
+ dynamicSelector: ".dynamic",
686
+ ...this.options
687
+ };
688
+ }
689
+ loadColor({ isDynamic }) {
690
+ let { dynamicSelector, darkSelector } = this.options;
691
+ if (!isDynamic) {
692
+ dynamicSelector = void 0;
693
+ }
694
+ const darkMode = this.options.darkMode ?? "class";
695
+ if (darkMode == "media") {
696
+ darkSelector = void 0;
697
+ }
698
+ const colors = this.getColors();
699
+ if (isDynamic) {
700
+ this.outputCss += `
701
+ @layer theme {
702
+ .dynamic {
703
+ ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
704
+ }
705
+ }`;
706
+ } else {
707
+ this.outputCss += `
708
+ @theme {
709
+ --color-*: initial;
710
+ ${Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.light};`).join("\n ")}
711
+ }`;
712
+ }
713
+ this.outputCss += `
714
+ @layer theme {
715
+ ${darkStyle({
716
+ selectors: [dynamicSelector],
717
+ mode: darkMode,
718
+ darkSelector: darkSelector ?? "",
719
+ styles: Object.entries(colors).map(([key, value]) => `--color-${key}: ${value.dark};`).join("\n ")
720
+ })}
721
+ }`;
722
+ const sourceColor = this.api.context.sourceColor;
723
+ for (const [key, value] of Object.entries(this.options.subThemes ?? {})) {
724
+ const newHue = Hct.fromInt(argbFromHex(value)).hue;
725
+ const newColor = Hct.from(newHue, sourceColor.chroma, sourceColor.tone);
726
+ this.api.context.sourceColor = hexFromArgb(newColor.toInt());
727
+ const colors2 = this.getColors();
728
+ this.outputCss += `
729
+ @layer theme {
730
+ ${createFlexibleSelector(dynamicSelector, ".theme-" + key)} {
731
+ ${Object.entries(colors2).map(([key2, value2]) => `--color-${key2}: ${value2.light};`).join("\n ")}
732
+ }
733
+ }
734
+ `;
735
+ this.outputCss += `
736
+ @layer theme {
737
+ ${darkStyle({
738
+ selectors: [dynamicSelector, ".theme-" + key],
739
+ mode: darkMode,
740
+ darkSelector: darkSelector ?? "",
741
+ styles: Object.entries(colors2).map(([key2, value2]) => `--color-${key2}: ${value2.dark};`).join("\n ")
742
+ })}
743
+ }`;
744
+ }
745
+ }
746
+ getColors() {
747
+ const colors = {};
748
+ const regex = /([a-z0-9]|(?=[A-Z]))([A-Z])/g;
749
+ [false, true].forEach((isDark) => {
750
+ this.api.context.darkMode = isDark;
751
+ this.api.colors.getAll().forEach((value, key) => {
752
+ const newKey = key.replace(regex, "$1-$2").toLowerCase();
753
+ if (!colors[newKey]) {
754
+ colors[newKey] = { light: "", dark: "" };
755
+ }
756
+ colors[newKey][isDark ? "dark" : "light"] = value.getHex();
757
+ });
758
+ });
759
+ return colors;
760
+ }
761
+ async onLoad() {
762
+ this.getColors();
763
+ this.loadColor({ isDynamic: true });
764
+ }
765
+ }
766
+ export {
767
+ TailwindImplPluginBrowser as T,
768
+ animation as a,
769
+ TailwindPlugin as b,
770
+ font as f,
771
+ main as m,
772
+ state as s
773
+ };