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