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