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