transform-to-unocss-core 0.0.62 → 0.0.63
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.
- package/dist/index.cjs +594 -84
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.iife.js +594 -84
- package/dist/index.js +594 -84
- package/dist/index.umd.js +594 -84
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ function getVal(val, transform$1, inClass, prefix = "") {
|
|
|
55
55
|
return prefix ? `-[${prefix}${transform$1 ? transform$1(val) : val}]` : `-${transform$1 ? transform$1(val) : val}`;
|
|
56
56
|
}
|
|
57
57
|
function getHundred(n) {
|
|
58
|
-
if (typeof n === "string" && n.endsWith("%")) return n.slice(0, -1);
|
|
58
|
+
if (typeof n === "string" && n.endsWith("%")) return +n.slice(0, -1);
|
|
59
59
|
return +n * 100;
|
|
60
60
|
}
|
|
61
61
|
function joinWithLine(s) {
|
|
@@ -84,8 +84,11 @@ function trim(s, type = "around") {
|
|
|
84
84
|
if (type === "around") return s.replace(/(^\s*)|(\s*$)/g, "");
|
|
85
85
|
return s;
|
|
86
86
|
}
|
|
87
|
-
function transformImportant(v) {
|
|
88
|
-
v = v.replace(/\s+/g, " ").replace(/\s*,\s*/g, ",").replace(/\s*\/\s*/g, "/");
|
|
87
|
+
function transformImportant(v, trimSpace = true) {
|
|
88
|
+
if (trimSpace) v = v.replace(/\s+/g, " ").replace(/\s*,\s*/g, ",").replace(/\s*\/\s*/g, "/");
|
|
89
|
+
if (/calc\([^)]+\)/.test(v)) v = v.replace(/calc\(([^)]+)\)/g, (all, k) => {
|
|
90
|
+
return all.replace(k, k.replace(/\s/g, "_"));
|
|
91
|
+
});
|
|
89
92
|
if (/rgb/.test(v)) v = v.replace(/rgba?\(([^)]+)\)/g, (all, k) => {
|
|
90
93
|
const _k = k.trim().split(" ");
|
|
91
94
|
return all.replace(k, _k.map((i, index) => i.endsWith(",") ? i : i + (_k.length - 1 === index ? "" : ",")).join(""));
|
|
@@ -95,8 +98,7 @@ function transformImportant(v) {
|
|
|
95
98
|
return all.replace(k, _k.map((i, index) => i.endsWith(",") ? i : i + (_k.length - 1 === index ? "" : ",")).join(""));
|
|
96
99
|
});
|
|
97
100
|
if (/var\([^)]+\)/.test(v)) v = v.replace(/var\(([^)]+)\)/g, (all, k) => {
|
|
98
|
-
|
|
99
|
-
return all.replace(k, _k.map((i, index) => i.endsWith(",") ? i : i + (_k.length - 1 === index ? "" : ",")).join(""));
|
|
101
|
+
return all.replace(k, k.replace(/\s/g, "_"));
|
|
100
102
|
});
|
|
101
103
|
if (v.endsWith("!important")) return [v.replace(/\s*!important/, "").trim(), "!"];
|
|
102
104
|
return [v.trim(), ""];
|
|
@@ -135,16 +137,43 @@ function getGradient(s) {
|
|
|
135
137
|
return s.startsWith("linear-gradient") ? "linear" : s.startsWith("radial-gradient") ? "radial" : s.startsWith("conic-gradient") ? "conic" : "";
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/accent.ts
|
|
142
|
+
const accentMap = ["accent-color"];
|
|
143
|
+
function accent(key, val) {
|
|
144
|
+
if (!accentMap.includes(key)) return;
|
|
145
|
+
const [value, important] = transformImportant(val);
|
|
146
|
+
return `accent${getVal(value, (v) => `[${v}]`)}${important}`;
|
|
147
|
+
}
|
|
148
|
+
|
|
138
149
|
//#endregion
|
|
139
150
|
//#region src/align.ts
|
|
151
|
+
const alignMap = [
|
|
152
|
+
"align-content",
|
|
153
|
+
"align-items",
|
|
154
|
+
"align-self"
|
|
155
|
+
];
|
|
140
156
|
function align(key, val) {
|
|
157
|
+
if (!alignMap.includes(key)) return;
|
|
141
158
|
const [value, important] = transformImportant(val);
|
|
142
|
-
return `${getLastName(key)}-${getLastName(
|
|
159
|
+
return `${getLastName(key)}-${value.split(" ").reverse().map(getLastName).join("-")}${important}`;
|
|
143
160
|
}
|
|
144
161
|
|
|
145
162
|
//#endregion
|
|
146
163
|
//#region src/animation.ts
|
|
164
|
+
const animationMap = [
|
|
165
|
+
"animation",
|
|
166
|
+
"animation-delay",
|
|
167
|
+
"animation-direction",
|
|
168
|
+
"animation-duration",
|
|
169
|
+
"animation-fill-mode",
|
|
170
|
+
"animation-iteration-count",
|
|
171
|
+
"animation-name",
|
|
172
|
+
"animation-play-state",
|
|
173
|
+
"animation-timing-function"
|
|
174
|
+
];
|
|
147
175
|
function animation(key, val) {
|
|
176
|
+
if (!animationMap.includes(key)) return;
|
|
148
177
|
const [value, important] = transformImportant(val);
|
|
149
178
|
if (key === "animation-delay") return `animate-delay${getVal(value)}${important}`;
|
|
150
179
|
if (key === "animation-duration") return `animate-duration${getVal(value)}${important}`;
|
|
@@ -196,63 +225,105 @@ function animation(key, val) {
|
|
|
196
225
|
return `animate-[${value}]${important}`;
|
|
197
226
|
}
|
|
198
227
|
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/appearance.ts
|
|
230
|
+
const appearanceMap = ["appearance"];
|
|
231
|
+
function appearance(key, val) {
|
|
232
|
+
if (!appearanceMap.includes(key)) return;
|
|
233
|
+
const [value, important] = transformImportant(val);
|
|
234
|
+
return `appearance${getVal(value)}${important}`;
|
|
235
|
+
}
|
|
236
|
+
|
|
199
237
|
//#endregion
|
|
200
238
|
//#region src/aspect.ts
|
|
239
|
+
const aspectMap = ["aspect-ratio"];
|
|
201
240
|
function aspect(key, val) {
|
|
241
|
+
if (!aspectMap.includes(key)) return;
|
|
202
242
|
const [value, important] = transformImportant(val);
|
|
203
243
|
if (value === "auto") return `${getFirstName(key)}-${value}${important}`;
|
|
204
244
|
return `${getFirstName(key)}="[${value}]${important}"`;
|
|
205
245
|
}
|
|
206
246
|
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/box.ts
|
|
209
|
-
const validKey = ["box-shadow", "drop-shadow"];
|
|
210
|
-
function box(key, val) {
|
|
211
|
-
let [value, important] = transformImportant(val);
|
|
212
|
-
if (key.startsWith("box-decoration")) return `box-decoration-${value}${important}`;
|
|
213
|
-
if (key === "box-sizing") return `box-${getFirstName(value)}${important}`;
|
|
214
|
-
if (validKey.includes(key)) return `shadow="[${value.split(" ").join("_")}]${important}"`;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
247
|
//#endregion
|
|
218
248
|
//#region src/filter.ts
|
|
219
|
-
const hundred = [
|
|
220
|
-
"contrast",
|
|
221
|
-
"brightness",
|
|
222
|
-
"saturate"
|
|
223
|
-
];
|
|
224
249
|
const percent = [
|
|
225
250
|
"grayscale",
|
|
226
251
|
"invert",
|
|
227
252
|
"sepia"
|
|
228
253
|
];
|
|
254
|
+
const filterMap = ["filter", "backdrop-filter"];
|
|
229
255
|
function filter(key, val) {
|
|
256
|
+
if (!filterMap.includes(key)) return;
|
|
230
257
|
const [v, important] = transformImportant(val);
|
|
231
258
|
const [_, name, value] = v.match(/([\w-]+)\((.*)\)/);
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
259
|
+
if ([
|
|
260
|
+
"contrast",
|
|
261
|
+
"brightness",
|
|
262
|
+
"saturate"
|
|
263
|
+
].includes(name)) {
|
|
264
|
+
const hundred = getHundred(value);
|
|
265
|
+
if (Number.isNaN(hundred)) return `${name}${getVal(value)}${important}`;
|
|
266
|
+
return `${name}-${hundred}${important}`;
|
|
267
|
+
}
|
|
268
|
+
if (name === "drop-shadow") return `drop-${dropShadow(value, important)}`;
|
|
269
|
+
if (percent.includes(name)) {
|
|
270
|
+
if (value.endsWith("%")) return `${name}-${value.slice(0, -1)}${important}`;
|
|
271
|
+
const hundred = getHundred(value);
|
|
272
|
+
if (Number.isNaN(hundred)) return `${name}${getVal(value)}${important}`;
|
|
273
|
+
return `${name}-${hundred}${important}`;
|
|
274
|
+
}
|
|
275
|
+
if (name === "hue-rotate") {
|
|
276
|
+
if (value.endsWith("deg")) return `${name}-${value.slice(0, -3)}${important}`;
|
|
277
|
+
return `${name}${getVal(value)}${important}`;
|
|
278
|
+
}
|
|
236
279
|
return `${name}-${value}${important}`;
|
|
237
280
|
}
|
|
281
|
+
function dropShadow(val, important = "") {
|
|
282
|
+
const [value] = transformImportant(val);
|
|
283
|
+
return `shadow="[${value.split(" ").join("_")}]${important}"`;
|
|
284
|
+
}
|
|
238
285
|
|
|
239
286
|
//#endregion
|
|
240
287
|
//#region src/backdrop.ts
|
|
288
|
+
const backdropMap = ["backdrop-filter"];
|
|
241
289
|
function backdrop(key, val) {
|
|
290
|
+
if (!backdropMap.includes(key)) return;
|
|
242
291
|
const [value, important] = transformImportant(val);
|
|
292
|
+
if (value.startsWith("var")) return;
|
|
243
293
|
return `backdrop-${filter(key, value)}${important}`;
|
|
244
294
|
}
|
|
245
295
|
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/backface.ts
|
|
298
|
+
const backfaceMap = ["backface-visibility"];
|
|
299
|
+
function backface(key, val) {
|
|
300
|
+
if (!backfaceMap.includes(key)) return;
|
|
301
|
+
const [value, important] = transformImportant(val);
|
|
302
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
303
|
+
}
|
|
304
|
+
|
|
246
305
|
//#endregion
|
|
247
306
|
//#region src/background.ts
|
|
248
|
-
const backgroundMap = [
|
|
307
|
+
const backgroundMap = [
|
|
308
|
+
"background",
|
|
309
|
+
"background-attachment",
|
|
310
|
+
"background-blend-mode",
|
|
311
|
+
"background-clip",
|
|
312
|
+
"background-color",
|
|
313
|
+
"background-image",
|
|
314
|
+
"background-origin",
|
|
315
|
+
"background-position",
|
|
316
|
+
"background-repeat",
|
|
317
|
+
"background-size"
|
|
318
|
+
];
|
|
249
319
|
const lengthRe = "\\d*\\.?\\d+(?:px|em|rem|%|vw|vh)?";
|
|
250
320
|
const positionPair = `(${lengthRe})\\s+(${lengthRe})`;
|
|
251
321
|
const optimizedReg = new RegExp(`${positionPair}\\s*,\\s*${positionPair}`);
|
|
252
322
|
function background(key, val) {
|
|
323
|
+
if (!backgroundMap.includes(key)) return;
|
|
253
324
|
const [value, important] = transformImportant(val);
|
|
254
325
|
if (key === "background-size") return `bg${getVal(value, /\d/.test(value) ? joinWithUnderLine : joinWithLine, false, "length:")}${important}`;
|
|
255
|
-
if (
|
|
326
|
+
if (["background-color", "background-attachment"].includes(key)) return `bg${getVal(value, joinWithLine)}${important}`;
|
|
256
327
|
if (key === "background-position") {
|
|
257
328
|
if (/\d/.test(value)) return `bg${getVal(value, joinWithUnderLine, false, "position:")}${important}`;
|
|
258
329
|
return `bg${getVal(value, joinWithLine)}${important}`;
|
|
@@ -459,38 +530,114 @@ function border(key, val) {
|
|
|
459
530
|
}).join(" ");
|
|
460
531
|
}
|
|
461
532
|
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region src/box.ts
|
|
535
|
+
const boxMap = [
|
|
536
|
+
"box-sizing",
|
|
537
|
+
"box-decoration-break",
|
|
538
|
+
"box-shadow"
|
|
539
|
+
];
|
|
540
|
+
function box(key, val) {
|
|
541
|
+
if (!boxMap.includes(key)) return;
|
|
542
|
+
const [value, important] = transformImportant(val);
|
|
543
|
+
if (key.startsWith("box-decoration-break")) return `box-decoration-${value}${important}`;
|
|
544
|
+
if (key === "box-sizing") return `box-${getFirstName(value)}${important}`;
|
|
545
|
+
if (key === "box-shadow") return `shadow="[${value.split(" ").join("_")}]${important}"`;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/break.ts
|
|
550
|
+
const breakMap = [
|
|
551
|
+
"break-inside",
|
|
552
|
+
"break-before",
|
|
553
|
+
"break-after"
|
|
554
|
+
];
|
|
555
|
+
function transformBreak(key, val) {
|
|
556
|
+
if (!breakMap.includes(key)) return;
|
|
557
|
+
const [value, important] = transformImportant(val);
|
|
558
|
+
return `${key}-${value}${important}`;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/caption.ts
|
|
563
|
+
const captionMap = ["caption-side"];
|
|
564
|
+
function caption(key, val) {
|
|
565
|
+
if (!captionMap.includes(key)) return;
|
|
566
|
+
const [value, important] = transformImportant(val);
|
|
567
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/caret.ts
|
|
572
|
+
const caretMap = ["caret-color"];
|
|
573
|
+
function caret(key, val) {
|
|
574
|
+
if (!caretMap.includes(key)) return;
|
|
575
|
+
const [value, important] = transformImportant(val);
|
|
576
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/clear.ts
|
|
581
|
+
const clearMap = ["clear"];
|
|
582
|
+
function clear(key, val) {
|
|
583
|
+
if (!clearMap.includes(key)) return;
|
|
584
|
+
const [value, important] = transformImportant(val);
|
|
585
|
+
return `${key}-${value}${important}`;
|
|
586
|
+
}
|
|
587
|
+
|
|
462
588
|
//#endregion
|
|
463
589
|
//#region src/color.ts
|
|
590
|
+
const colorMap = ["color"];
|
|
464
591
|
function color(key, val) {
|
|
592
|
+
if (!colorMap.includes(key)) return;
|
|
465
593
|
const [value, important] = transformImportant(val);
|
|
466
594
|
return `text${getVal(value)}${important}`;
|
|
467
595
|
}
|
|
468
596
|
|
|
469
597
|
//#endregion
|
|
470
598
|
//#region src/column.ts
|
|
599
|
+
const columnMap = ["column-gap"];
|
|
471
600
|
function column(key, val) {
|
|
601
|
+
if (!columnMap.includes(key)) return;
|
|
472
602
|
const [value, important] = transformImportant(val);
|
|
473
603
|
if (key === "column-gap") return `gap-x-${value}${important}`;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/columns.ts
|
|
608
|
+
const columnsMap = ["columns"];
|
|
609
|
+
function columns(key, val) {
|
|
610
|
+
if (!columnsMap.includes(key)) return;
|
|
611
|
+
const [value, important] = transformImportant(val);
|
|
474
612
|
return `${key}-${value}${important}`;
|
|
475
613
|
}
|
|
476
614
|
|
|
477
615
|
//#endregion
|
|
478
616
|
//#region src/content.ts
|
|
617
|
+
const contentMap = ["content", "content-visibility"];
|
|
479
618
|
function content(key, val) {
|
|
480
|
-
|
|
481
|
-
|
|
619
|
+
if (!contentMap.includes(key)) return;
|
|
620
|
+
const [value, important] = transformImportant(val, false);
|
|
621
|
+
if (key === "content-visibility") return `content-visibility-${value}${important}`;
|
|
622
|
+
const match = value.match(/^(["'])(.*?)\1$/);
|
|
623
|
+
if (match) return `content-['${match[2].replace(/\s/g, "_")}']${important}`;
|
|
624
|
+
return `content-[${value}]${important}`;
|
|
482
625
|
}
|
|
483
626
|
|
|
484
627
|
//#endregion
|
|
485
628
|
//#region src/cursor.ts
|
|
629
|
+
const cursorMap = ["cursor"];
|
|
486
630
|
function cursor(key, val) {
|
|
631
|
+
if (!cursorMap.includes(key)) return;
|
|
487
632
|
const [value, important] = transformImportant(val);
|
|
488
633
|
return `${key}${getVal(value)}${important}`;
|
|
489
634
|
}
|
|
490
635
|
|
|
491
636
|
//#endregion
|
|
492
637
|
//#region src/display.ts
|
|
638
|
+
const displayMap = ["display"];
|
|
493
639
|
function display(key, val) {
|
|
640
|
+
if (!displayMap.includes(key)) return;
|
|
494
641
|
const [value, important] = transformImportant(val);
|
|
495
642
|
if (value === "none") return `hidden${important}`;
|
|
496
643
|
if (value === "hidden") return `invisible${important}`;
|
|
@@ -499,13 +646,24 @@ function display(key, val) {
|
|
|
499
646
|
|
|
500
647
|
//#endregion
|
|
501
648
|
//#region src/empty.ts
|
|
502
|
-
const
|
|
649
|
+
const emptyKey = {
|
|
503
650
|
show: "visible",
|
|
504
651
|
hide: "hidden"
|
|
505
652
|
};
|
|
653
|
+
const emptyMap = ["empty-cells"];
|
|
506
654
|
function empty(key, val) {
|
|
655
|
+
if (!emptyMap.includes(key)) return;
|
|
656
|
+
const [value, important] = transformImportant(val);
|
|
657
|
+
if (emptyKey[value]) return `table-empty-cells-${emptyKey[value]}${important}`;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/fill.ts
|
|
662
|
+
const fillMap = ["fill"];
|
|
663
|
+
function fill(key, val) {
|
|
664
|
+
if (!fillMap.includes(key)) return;
|
|
507
665
|
const [value, important] = transformImportant(val);
|
|
508
|
-
return
|
|
666
|
+
return `${key}-${value}${important}`;
|
|
509
667
|
}
|
|
510
668
|
|
|
511
669
|
//#endregion
|
|
@@ -515,8 +673,16 @@ const lastMaps = [
|
|
|
515
673
|
"flex-grow",
|
|
516
674
|
"flex-shrink"
|
|
517
675
|
];
|
|
676
|
+
const flexMap = [
|
|
677
|
+
"flex",
|
|
678
|
+
"flex-grow",
|
|
679
|
+
"flex-shrink",
|
|
680
|
+
"flex-basis",
|
|
681
|
+
"flex-wrap",
|
|
682
|
+
"flex-direction"
|
|
683
|
+
];
|
|
518
684
|
function flex(key, val) {
|
|
519
|
-
if (
|
|
685
|
+
if (!flexMap.includes(key)) return;
|
|
520
686
|
const [value, important] = transformImportant(val);
|
|
521
687
|
if (lastMaps.includes(key)) return `${getLastName(key)}${getVal(value)}${important}`;
|
|
522
688
|
if (value === "1") return `flex-1${important}`;
|
|
@@ -528,14 +694,25 @@ function flex(key, val) {
|
|
|
528
694
|
|
|
529
695
|
//#endregion
|
|
530
696
|
//#region src/float.ts
|
|
697
|
+
const floatMap = ["float"];
|
|
531
698
|
function float(key, val) {
|
|
699
|
+
if (!floatMap.includes(key)) return;
|
|
532
700
|
const [value, important] = transformImportant(val);
|
|
533
|
-
return `${key}-${value}${important}`;
|
|
701
|
+
return `${key}-${getLastName(value)}${important}`;
|
|
534
702
|
}
|
|
535
703
|
|
|
536
704
|
//#endregion
|
|
537
705
|
//#region src/font.ts
|
|
706
|
+
const fontMap = [
|
|
707
|
+
"font",
|
|
708
|
+
"font-size",
|
|
709
|
+
"font-weight",
|
|
710
|
+
"font-family",
|
|
711
|
+
"font-style",
|
|
712
|
+
"font-variant-numeric"
|
|
713
|
+
];
|
|
538
714
|
function font(key, val) {
|
|
715
|
+
if (!fontMap.includes(key)) return;
|
|
539
716
|
const [value, important] = transformImportant(val);
|
|
540
717
|
if (key === "font-size") {
|
|
541
718
|
if ([
|
|
@@ -547,7 +724,7 @@ function font(key, val) {
|
|
|
547
724
|
].includes(value)) return `font-size-${value}${important}`;
|
|
548
725
|
return `text-${value}${important}`;
|
|
549
726
|
}
|
|
550
|
-
if (key === "font-weight") return `font
|
|
727
|
+
if (key === "font-weight") return `font${getVal(value)}${important}`;
|
|
551
728
|
if (key === "font-family") {
|
|
552
729
|
const match = value.match(/ui-(\w{0,4})/);
|
|
553
730
|
if (!match) return `font-[${joinWithUnderLine(val)}]${important}`;
|
|
@@ -568,38 +745,84 @@ function transformFont(v) {
|
|
|
568
745
|
return v.split(" ").map((item) => /^\d/.test(item) ? `text-${item}` : item).join(" ");
|
|
569
746
|
}
|
|
570
747
|
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region src/gap.ts
|
|
750
|
+
const gapMap = [
|
|
751
|
+
"gap",
|
|
752
|
+
"gap-x",
|
|
753
|
+
"gap-y"
|
|
754
|
+
];
|
|
755
|
+
function gap(key, val) {
|
|
756
|
+
if (!gapMap.includes(key)) return;
|
|
757
|
+
const [value, important] = transformImportant(val);
|
|
758
|
+
if (key.startsWith("column")) return `gap-x${getVal(value)}${important}`;
|
|
759
|
+
if (key.startsWith("row")) return `gap-y${getVal(value)}${important}`;
|
|
760
|
+
return `gap${getVal(value)}${important}`;
|
|
761
|
+
}
|
|
762
|
+
|
|
571
763
|
//#endregion
|
|
572
764
|
//#region src/grid.ts
|
|
765
|
+
const gridMap = [
|
|
766
|
+
"grid",
|
|
767
|
+
"grid-row",
|
|
768
|
+
"grid-column",
|
|
769
|
+
"grid-template-columns",
|
|
770
|
+
"grid-template-rows",
|
|
771
|
+
"grid-auto-flow",
|
|
772
|
+
"grid-auto-columns",
|
|
773
|
+
"grid-auto-rows",
|
|
774
|
+
"grid-column-start",
|
|
775
|
+
"grid-column-end",
|
|
776
|
+
"grid-row-start",
|
|
777
|
+
"grid-row-end"
|
|
778
|
+
];
|
|
573
779
|
function grid(key, val) {
|
|
780
|
+
if (!gridMap.includes(key)) return;
|
|
574
781
|
const [value, important] = transformImportant(val);
|
|
575
782
|
if (key.startsWith("grid-template")) {
|
|
576
|
-
const matcher$1 = value.match(
|
|
783
|
+
const matcher$1 = value.match(/^repeat\s*\(\s*(\d+)/);
|
|
577
784
|
if (matcher$1) return `grid-${getLastName(key) === "rows" ? "rows" : "cols"}-${matcher$1[1]}${important}`;
|
|
578
|
-
|
|
785
|
+
if (value.startsWith("repeat(")) return;
|
|
786
|
+
return `grid-${getLastName(key) === "rows" ? "rows" : "cols"}${value.includes(" ") ? `-[${joinWithUnderLine(value)}]` : getVal(value)}${important}`;
|
|
579
787
|
}
|
|
580
788
|
if (key === "grid-auto-flow") return `grid-flow-${joinWithLine(value).replace("column", "col")}${important}`;
|
|
581
789
|
if (key.startsWith("grid-auto")) {
|
|
582
|
-
|
|
583
|
-
return `auto-${getLastName(key) === "rows" ? "rows" : "cols"}-${
|
|
790
|
+
if (/\d/.test(value)) return `auto-${getLastName(key) === "rows" ? "rows" : "cols"}-[${joinWithUnderLine(value)}]${important}`;
|
|
791
|
+
return `auto-${getLastName(key) === "rows" ? "rows" : "cols"}-${getFirstName(value)}${important}`;
|
|
792
|
+
}
|
|
793
|
+
const matcher = value.match(/span\s+([^/]+)\/\s*span\s+(.*)/);
|
|
794
|
+
if (matcher) {
|
|
795
|
+
if (matcher[1] !== matcher[2]) return;
|
|
796
|
+
return `${key.slice(5).replace("column", "col")}-span${getVal(matcher[1])}${important}`;
|
|
584
797
|
}
|
|
585
|
-
const matcher = value.match(/span\s+(\d)/);
|
|
586
|
-
if (matcher) return `${key.slice(5).replace("column", "col")}-span-${matcher[1]}${important}`;
|
|
587
798
|
if (value === "1/-1") return `${key.slice(5).replace("column", "col")}-span-full${important}`;
|
|
588
|
-
return `${key.slice(5).replace("column", "col")}
|
|
799
|
+
return `${key.slice(5).replace("column", "col")}${getVal(value)}${important}`;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/hyphens.ts
|
|
804
|
+
const hyphensMap = ["hyphens"];
|
|
805
|
+
function hyphens(key, val) {
|
|
806
|
+
if (!hyphensMap.includes(key)) return;
|
|
807
|
+
const [value, important] = transformImportant(val);
|
|
808
|
+
return `${key}${getVal(value)}${important}`;
|
|
589
809
|
}
|
|
590
810
|
|
|
591
811
|
//#endregion
|
|
592
812
|
//#region src/inset.ts
|
|
813
|
+
const insetMap = ["inset-inline-start", "inset-inline-end"];
|
|
593
814
|
function inset(key, val) {
|
|
815
|
+
if (!insetMap.includes(key)) return;
|
|
594
816
|
const [value, important] = transformImportant(val);
|
|
595
817
|
if (key === "inset-inline-start") return `start${getVal(value)}${important}`;
|
|
596
818
|
if (key === "inset-inline-end") return `end${getVal(value)}${important}`;
|
|
597
|
-
return void 0;
|
|
598
819
|
}
|
|
599
820
|
|
|
600
821
|
//#endregion
|
|
601
822
|
//#region src/isolation.ts
|
|
823
|
+
const isolationMap = ["isolation"];
|
|
602
824
|
function isolation(key, val) {
|
|
825
|
+
if (!isolationMap.includes(key)) return;
|
|
603
826
|
const [value, important] = transformImportant(val);
|
|
604
827
|
if (val === "isolate") return `${value}${important}`;
|
|
605
828
|
return `${key}-${value}${important}`;
|
|
@@ -607,22 +830,32 @@ function isolation(key, val) {
|
|
|
607
830
|
|
|
608
831
|
//#endregion
|
|
609
832
|
//#region src/justify.ts
|
|
833
|
+
const justifyMap = [
|
|
834
|
+
"justify",
|
|
835
|
+
"justify-content",
|
|
836
|
+
"justify-items",
|
|
837
|
+
"justify-self"
|
|
838
|
+
];
|
|
610
839
|
function justify(key, val) {
|
|
840
|
+
if (!justifyMap.includes(key)) return;
|
|
611
841
|
const [value, important] = transformImportant(val);
|
|
842
|
+
if (value.includes(" ")) return;
|
|
612
843
|
if (key === "justify-content") return `justify-${getLastName(value)}${important}`;
|
|
613
844
|
return `${key}-${getLastName(value)}${important}`;
|
|
614
845
|
}
|
|
615
846
|
|
|
616
847
|
//#endregion
|
|
617
848
|
//#region src/letter.ts
|
|
849
|
+
const letterMap = ["letter-spacing"];
|
|
618
850
|
function letter(key, val) {
|
|
851
|
+
if (!letterMap.includes(key)) return;
|
|
619
852
|
const [value, important] = transformImportant(val);
|
|
620
|
-
return `tracking
|
|
853
|
+
return `tracking${getVal(value)}${important}`;
|
|
621
854
|
}
|
|
622
855
|
|
|
623
856
|
//#endregion
|
|
624
857
|
//#region src/line.ts
|
|
625
|
-
const
|
|
858
|
+
const lineKey = {
|
|
626
859
|
1: "none",
|
|
627
860
|
1.25: "tight",
|
|
628
861
|
1.375: "snug",
|
|
@@ -630,16 +863,29 @@ const lineMap = {
|
|
|
630
863
|
1.625: "relaxed",
|
|
631
864
|
2: "loose"
|
|
632
865
|
};
|
|
866
|
+
const lineMap = ["line-height"];
|
|
633
867
|
function line(key, val) {
|
|
868
|
+
if (!lineMap.includes(key)) return;
|
|
634
869
|
const [value, important] = transformImportant(val);
|
|
635
|
-
if (value in
|
|
870
|
+
if (value in lineKey) return `lh-${lineKey[value]}${important}`;
|
|
636
871
|
return `lh${getVal(value, (v) => /\d$/.test(v) ? `[${v}]` : v)}${important}`;
|
|
637
872
|
}
|
|
638
873
|
|
|
639
874
|
//#endregion
|
|
640
875
|
//#region src/list.ts
|
|
876
|
+
const listMap = [
|
|
877
|
+
"list-style",
|
|
878
|
+
"list-style-type",
|
|
879
|
+
"list-style-position",
|
|
880
|
+
"list-style-image"
|
|
881
|
+
];
|
|
641
882
|
function list(key, val) {
|
|
883
|
+
if (!listMap.includes(key)) return;
|
|
642
884
|
const [value, important] = transformImportant(val);
|
|
885
|
+
if (key === "list-style-image") {
|
|
886
|
+
if (value === "none") return `${getFirstName(key)}-none${important}`;
|
|
887
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
888
|
+
}
|
|
643
889
|
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
644
890
|
}
|
|
645
891
|
|
|
@@ -673,33 +919,49 @@ function transformMargin(key, val) {
|
|
|
673
919
|
|
|
674
920
|
//#endregion
|
|
675
921
|
//#region src/mask.ts
|
|
922
|
+
const maskMap = [
|
|
923
|
+
"mask-position",
|
|
924
|
+
"mask-origin",
|
|
925
|
+
"mask-repeat",
|
|
926
|
+
"mask-size",
|
|
927
|
+
"mask-type",
|
|
928
|
+
"mask-image",
|
|
929
|
+
"mask-mode",
|
|
930
|
+
"mask-composite",
|
|
931
|
+
"mask-clip",
|
|
932
|
+
"mask-type"
|
|
933
|
+
];
|
|
676
934
|
function mask(key, val) {
|
|
935
|
+
if (!maskMap.includes(key)) return;
|
|
677
936
|
const [value, important] = transformImportant(val);
|
|
678
937
|
if ([
|
|
679
938
|
"mask-clip",
|
|
680
939
|
"mask-origin",
|
|
681
940
|
"mask-type"
|
|
682
|
-
].includes(key)) return `${
|
|
683
|
-
if (["mask-mode", "mask-composite"].includes(key)) return `${
|
|
941
|
+
].includes(key)) return `${key}-${getFirstName(value)}${important}`;
|
|
942
|
+
if (["mask-mode", "mask-composite"].includes(key)) return `${getFirstName(key)}-${getFirstName(value)}${important}`;
|
|
684
943
|
if (["mask-position", "mask-size"].includes(key)) {
|
|
685
944
|
if (isCalc(value) || isUrl(value) || isHex(value) || isRgb(value) || isHsl(value) || isPercent(value) || isVar(value) || isCubicBezier(value)) return `${important}${key}${getVal(value)}`;
|
|
686
945
|
if (/\d/.test(value)) return `${important}[${key}:${joinWithUnderLine(value)}]`;
|
|
687
946
|
return `${important}${getFirstName(key)}-${joinWithLine(value)}`;
|
|
688
947
|
}
|
|
689
|
-
if (key === "mask-repeat")
|
|
948
|
+
if (key === "mask-repeat") {
|
|
949
|
+
if (value.includes("-")) return `mask-${value}${important}`;
|
|
950
|
+
return `${key}-${value}${important}`;
|
|
951
|
+
}
|
|
690
952
|
if (key === "mask-image") {
|
|
691
953
|
const type = getGradient(value);
|
|
692
954
|
if (type) {
|
|
693
955
|
const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
|
|
694
956
|
const matcher = newValue.match(linearGradientReg);
|
|
695
|
-
if (!matcher) return
|
|
957
|
+
if (!matcher) return `[${key}:${joinWithUnderLine(value)}]${important}`;
|
|
696
958
|
let [direction, from, via, to] = matcher.slice(1);
|
|
697
959
|
direction = direction.split(" ").map((item) => item[0]).join("");
|
|
698
960
|
return direction ? `${getLinearGradientPosition(`mask-${direction}`, from, via, to).trim()}` : getLinearGradientPosition(`mask-${type}`, from, via, to).trim();
|
|
699
961
|
}
|
|
700
|
-
return
|
|
962
|
+
return `mask${getVal(value)}${important}`;
|
|
701
963
|
}
|
|
702
|
-
return `${
|
|
964
|
+
return `${key}${getVal(value)}${important}`;
|
|
703
965
|
}
|
|
704
966
|
function getLinearGradientPosition(prefix, from, via, to) {
|
|
705
967
|
let result = "";
|
|
@@ -730,8 +992,24 @@ function getLinearGradientPosition(prefix, from, via, to) {
|
|
|
730
992
|
|
|
731
993
|
//#endregion
|
|
732
994
|
//#region src/max.ts
|
|
995
|
+
const maxMap = [
|
|
996
|
+
"max-height",
|
|
997
|
+
"max-width",
|
|
998
|
+
"max-block-size",
|
|
999
|
+
"max-inline-size",
|
|
1000
|
+
"min-height",
|
|
1001
|
+
"min-width",
|
|
1002
|
+
"min-block-size",
|
|
1003
|
+
"min-inline-size"
|
|
1004
|
+
];
|
|
733
1005
|
function max(key, val) {
|
|
1006
|
+
if (!maxMap.includes(key)) return;
|
|
734
1007
|
const [value, important] = transformImportant(val);
|
|
1008
|
+
if (/(?:max|min)-(?:inline|block)-size/.test(key)) {
|
|
1009
|
+
const fixedKey = key.split("-").slice(0, 2).join("-");
|
|
1010
|
+
if (/\d/.test(value) || isVar(value) || isCalc(value)) return `${fixedKey}${getVal(value)}${important}`;
|
|
1011
|
+
return `${fixedKey}-${getFirstName(value)}${important}`;
|
|
1012
|
+
}
|
|
735
1013
|
const all = key.split("-");
|
|
736
1014
|
const attributeValue = isCalc(value) || isVar(value) ? getVal(value) : getVal(getFirstName(value));
|
|
737
1015
|
return `${all[0]}-${all[1][0]}${attributeValue}${important}`;
|
|
@@ -739,38 +1017,64 @@ function max(key, val) {
|
|
|
739
1017
|
|
|
740
1018
|
//#endregion
|
|
741
1019
|
//#region src/mix.ts
|
|
1020
|
+
const mixMap = ["mix-blend-mode"];
|
|
742
1021
|
function mix(key, val) {
|
|
1022
|
+
if (!mixMap.includes(key)) return;
|
|
743
1023
|
const [value, important] = transformImportant(val);
|
|
744
1024
|
return `mix-blend-${value}${important}`;
|
|
745
1025
|
}
|
|
746
1026
|
|
|
747
1027
|
//#endregion
|
|
748
1028
|
//#region src/object.ts
|
|
1029
|
+
const objectMap = ["object-fit", "object-position"];
|
|
749
1030
|
function object(key, val) {
|
|
1031
|
+
if (!objectMap.includes(key)) return;
|
|
750
1032
|
const [value, important] = transformImportant(val);
|
|
751
|
-
if (key === "object-position")
|
|
1033
|
+
if (key === "object-position") {
|
|
1034
|
+
if (isVar(value)) return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
1035
|
+
return `${getFirstName(key)}-${joinWithLine(value)}${important}`;
|
|
1036
|
+
}
|
|
752
1037
|
return `${getFirstName(key)}-${value}${important}`;
|
|
753
1038
|
}
|
|
754
1039
|
|
|
755
1040
|
//#endregion
|
|
756
1041
|
//#region src/opacity.ts
|
|
1042
|
+
const opacityMap = ["opacity"];
|
|
757
1043
|
function opacity(key, val) {
|
|
1044
|
+
if (!opacityMap.includes(key)) return;
|
|
758
1045
|
const [value, important] = transformImportant(val);
|
|
759
|
-
|
|
760
|
-
return
|
|
1046
|
+
const hundred = getHundred(value);
|
|
1047
|
+
if (Number.isNaN(hundred)) return `${key}${getVal(value)}${important}`;
|
|
1048
|
+
return `op-${hundred}${important}`;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
//#endregion
|
|
1052
|
+
//#region src/order.ts
|
|
1053
|
+
const orderMap = ["order"];
|
|
1054
|
+
function order(key, val) {
|
|
1055
|
+
if (!orderMap.includes(key)) return;
|
|
1056
|
+
const [value, important] = transformImportant(val);
|
|
1057
|
+
return `${key}${getVal(value)}${important}`;
|
|
761
1058
|
}
|
|
762
1059
|
|
|
763
1060
|
//#endregion
|
|
764
1061
|
//#region src/outline.ts
|
|
765
1062
|
function outline(key, val) {
|
|
766
1063
|
const [value, important] = transformImportant(val);
|
|
767
|
-
if (key === "outline-offset") return `${key}
|
|
768
|
-
return `${getFirstName(key)}
|
|
1064
|
+
if (key === "outline-offset") return `${key}${getVal(value)}${important}`;
|
|
1065
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
769
1066
|
}
|
|
770
1067
|
|
|
771
1068
|
//#endregion
|
|
772
1069
|
//#region src/word.ts
|
|
1070
|
+
const wordMap = [
|
|
1071
|
+
"word-break",
|
|
1072
|
+
"word-spacing",
|
|
1073
|
+
"word-wrap",
|
|
1074
|
+
"overflow-wrap"
|
|
1075
|
+
];
|
|
773
1076
|
function word(key, val) {
|
|
1077
|
+
if (!wordMap.includes(key)) return;
|
|
774
1078
|
const [value, important] = transformImportant(val);
|
|
775
1079
|
if (key.startsWith("word-spacing")) return `word-spacing${getVal(val)}${important}`;
|
|
776
1080
|
if (value === "keep-all") return `break-keep${important}`;
|
|
@@ -780,7 +1084,14 @@ function word(key, val) {
|
|
|
780
1084
|
|
|
781
1085
|
//#endregion
|
|
782
1086
|
//#region src/overflow.ts.ts
|
|
1087
|
+
const overflowMap = [
|
|
1088
|
+
"overflow",
|
|
1089
|
+
"overflow-x",
|
|
1090
|
+
"overflow-y",
|
|
1091
|
+
"overflow-wrap"
|
|
1092
|
+
];
|
|
783
1093
|
function overflow(key, val) {
|
|
1094
|
+
if (!overflowMap.includes(key)) return;
|
|
784
1095
|
const [value, important] = transformImportant(val);
|
|
785
1096
|
if (key === "overflow-wrap") return word(key, val);
|
|
786
1097
|
return `${key}-${value}${important}`;
|
|
@@ -788,27 +1099,71 @@ function overflow(key, val) {
|
|
|
788
1099
|
|
|
789
1100
|
//#endregion
|
|
790
1101
|
//#region src/overscroll.ts
|
|
1102
|
+
const overscrollMap = [
|
|
1103
|
+
"overscroll-behavior",
|
|
1104
|
+
"overscroll-behavior-x",
|
|
1105
|
+
"overscroll-behavior-y"
|
|
1106
|
+
];
|
|
791
1107
|
function overscroll(key, val) {
|
|
1108
|
+
if (!overscrollMap.includes(key)) return;
|
|
792
1109
|
const [value, important] = transformImportant(val);
|
|
793
1110
|
const [prefix, _, suffix] = key.split("-");
|
|
794
1111
|
if (suffix) return `${prefix}-${suffix}-${value}${important}`;
|
|
795
1112
|
return `${prefix}-${value}${important}`;
|
|
796
1113
|
}
|
|
797
1114
|
|
|
1115
|
+
//#endregion
|
|
1116
|
+
//#region src/perspective.ts
|
|
1117
|
+
const perspectiveMap = ["perspective", "perspective-origin"];
|
|
1118
|
+
function perspective(key, val) {
|
|
1119
|
+
if (!perspectiveMap.includes(key)) return;
|
|
1120
|
+
const [value, important] = transformImportant(val);
|
|
1121
|
+
return `${key}${getVal(value, joinWithLine)}${important}`;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
798
1124
|
//#endregion
|
|
799
1125
|
//#region src/place.ts
|
|
1126
|
+
const placeMap = [
|
|
1127
|
+
"place-content",
|
|
1128
|
+
"place-items",
|
|
1129
|
+
"place-self"
|
|
1130
|
+
];
|
|
800
1131
|
function place(key, val) {
|
|
1132
|
+
if (!placeMap.includes(key)) return;
|
|
1133
|
+
const [value, important] = transformImportant(val);
|
|
1134
|
+
if (value.includes(" ")) return;
|
|
1135
|
+
return `${key}-${getLastName(value)}${important}`;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region src/pointer.ts
|
|
1140
|
+
const pointerMap = ["pointer-events"];
|
|
1141
|
+
function pointer(key, val) {
|
|
1142
|
+
if (!pointerMap.includes(key)) return;
|
|
801
1143
|
const [value, important] = transformImportant(val);
|
|
802
1144
|
return `${key}-${getLastName(value)}${important}`;
|
|
803
1145
|
}
|
|
804
1146
|
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/position.ts
|
|
1149
|
+
const positionMap$1 = ["position"];
|
|
1150
|
+
function position(key, val) {
|
|
1151
|
+
if (!positionMap$1.includes(key)) return;
|
|
1152
|
+
const [value, important] = transformImportant(val);
|
|
1153
|
+
if (value === "none") return `hidden${important}`;
|
|
1154
|
+
if (value === "hidden") return `invisible${important}`;
|
|
1155
|
+
return `${value}${important}`;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
805
1158
|
//#endregion
|
|
806
1159
|
//#region src/resize.ts
|
|
807
1160
|
const map = {
|
|
808
1161
|
vertical: "y",
|
|
809
1162
|
horizontal: "x"
|
|
810
1163
|
};
|
|
1164
|
+
const resizeMap = ["resize"];
|
|
811
1165
|
function resize(key, val) {
|
|
1166
|
+
if (!resizeMap.includes(key)) return;
|
|
812
1167
|
const [value, important] = transformImportant(val);
|
|
813
1168
|
if (value === "both") return `${key}${important}`;
|
|
814
1169
|
return `${key}-${map[value] || value}${important}`;
|
|
@@ -816,7 +1171,9 @@ function resize(key, val) {
|
|
|
816
1171
|
|
|
817
1172
|
//#endregion
|
|
818
1173
|
//#region src/rotate.ts
|
|
1174
|
+
const rotateMap = ["rotate"];
|
|
819
1175
|
function rotate(key, val) {
|
|
1176
|
+
if (!rotateMap.includes(key)) return;
|
|
820
1177
|
const [value, important] = transformImportant(val);
|
|
821
1178
|
if (value.includes(" ")) return `rotate-[${joinWithUnderLine(value)}]${important}`;
|
|
822
1179
|
return `rotate${getVal(value)}${important}`;
|
|
@@ -824,34 +1181,111 @@ function rotate(key, val) {
|
|
|
824
1181
|
|
|
825
1182
|
//#endregion
|
|
826
1183
|
//#region src/row.ts
|
|
1184
|
+
const rowMap = ["row-gap"];
|
|
827
1185
|
function row(key, val) {
|
|
1186
|
+
if (!rowMap.includes(key)) return;
|
|
828
1187
|
const [value, important] = transformImportant(val);
|
|
829
|
-
return `gap-y
|
|
1188
|
+
return `gap-y${getVal(value)}${important}`;
|
|
830
1189
|
}
|
|
831
1190
|
|
|
832
1191
|
//#endregion
|
|
833
1192
|
//#region src/scroll.ts
|
|
1193
|
+
const scrollMap = [
|
|
1194
|
+
"scroll-snap-type",
|
|
1195
|
+
"scroll-snap-stop",
|
|
1196
|
+
"scroll-snap-align",
|
|
1197
|
+
"scroll-padding",
|
|
1198
|
+
"scroll-padding-inline",
|
|
1199
|
+
"scroll-padding-block",
|
|
1200
|
+
"scroll-padding-inline-start",
|
|
1201
|
+
"scroll-padding-inline-end",
|
|
1202
|
+
"scroll-padding-block-start",
|
|
1203
|
+
"scroll-padding-block-end",
|
|
1204
|
+
"scroll-padding-top",
|
|
1205
|
+
"scroll-padding-right",
|
|
1206
|
+
"scroll-padding-bottom",
|
|
1207
|
+
"scroll-padding-left",
|
|
1208
|
+
"scroll-margin",
|
|
1209
|
+
"scroll-margin-inline",
|
|
1210
|
+
"scroll-margin-block",
|
|
1211
|
+
"scroll-margin-inline-start",
|
|
1212
|
+
"scroll-margin-inline-end",
|
|
1213
|
+
"scroll-margin-block-start",
|
|
1214
|
+
"scroll-margin-block-end",
|
|
1215
|
+
"scroll-margin-top",
|
|
1216
|
+
"scroll-margin-right",
|
|
1217
|
+
"scroll-margin-bottom",
|
|
1218
|
+
"scroll-margin-left",
|
|
1219
|
+
"scroll-behavior"
|
|
1220
|
+
];
|
|
834
1221
|
function scroll(key, val) {
|
|
1222
|
+
if (!scrollMap.includes(key)) return;
|
|
835
1223
|
const [value, important] = transformImportant(val);
|
|
836
|
-
if (key.startsWith("scroll-snap"))
|
|
1224
|
+
if (key.startsWith("scroll-snap")) {
|
|
1225
|
+
if (value.includes(" ")) {
|
|
1226
|
+
const [pre, after] = value.split(" ");
|
|
1227
|
+
return `snap-${pre}${getVal(after)}${important}`;
|
|
1228
|
+
}
|
|
1229
|
+
return `snap-${value}${important}`;
|
|
1230
|
+
}
|
|
837
1231
|
if (key === "scroll-behavior") return `scroll-${value}${important}`;
|
|
838
1232
|
const [_, prefix, suffix, way] = key.match(/scroll-(margin|padding)-?(\w+)?-?(\w+)?/);
|
|
839
1233
|
if (suffix === "inline" && way) return `scroll-${prefix[0]}${way[0]}${getVal(value)}${important}`;
|
|
840
1234
|
if (suffix) return `scroll-${prefix[0]}${suffix[0]}${getVal(value)}${important}`;
|
|
841
|
-
return `scroll-${prefix[0]}
|
|
1235
|
+
return `scroll-${prefix[0]}${getVal(value)}${important}`;
|
|
842
1236
|
}
|
|
843
1237
|
|
|
844
1238
|
//#endregion
|
|
845
1239
|
//#region src/size.ts
|
|
1240
|
+
const sizeMap = [
|
|
1241
|
+
"z-index",
|
|
1242
|
+
"width",
|
|
1243
|
+
"height"
|
|
1244
|
+
];
|
|
846
1245
|
function size(key, val) {
|
|
1246
|
+
if (!sizeMap.includes(key)) return;
|
|
847
1247
|
const [value, important] = transformImportant(val);
|
|
848
1248
|
if (value.startsWith("-")) return `-${key[0]}${getVal(value.slice(1), getFirstName)}${important}`;
|
|
849
1249
|
return `${key[0]}${getVal(value, getFirstName)}${important}`;
|
|
850
1250
|
}
|
|
851
1251
|
|
|
1252
|
+
//#endregion
|
|
1253
|
+
//#region src/stroke.ts
|
|
1254
|
+
const strokeMap = ["stroke", "stroke-width"];
|
|
1255
|
+
function stroke(key, val) {
|
|
1256
|
+
if (!strokeMap.includes(key)) return;
|
|
1257
|
+
const [value, important] = transformImportant(val);
|
|
1258
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
//#endregion
|
|
1262
|
+
//#region src/table.ts
|
|
1263
|
+
const tableMap = ["table-layout"];
|
|
1264
|
+
function table(key, val) {
|
|
1265
|
+
if (!tableMap.includes(key)) return;
|
|
1266
|
+
const [value, important] = transformImportant(val);
|
|
1267
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
852
1270
|
//#endregion
|
|
853
1271
|
//#region src/text.ts
|
|
1272
|
+
const textMap = [
|
|
1273
|
+
"text-align",
|
|
1274
|
+
"text-align-last",
|
|
1275
|
+
"text-decoration-line",
|
|
1276
|
+
"text-decoration-style",
|
|
1277
|
+
"text-decoration-color",
|
|
1278
|
+
"text-decoration-thickness",
|
|
1279
|
+
"text-indent",
|
|
1280
|
+
"text-underline-offset",
|
|
1281
|
+
"text-transform",
|
|
1282
|
+
"text-wrap",
|
|
1283
|
+
"text-overflow",
|
|
1284
|
+
"text-justify",
|
|
1285
|
+
"text-shadow"
|
|
1286
|
+
];
|
|
854
1287
|
function text(key, val) {
|
|
1288
|
+
if (!textMap.includes(key)) return;
|
|
855
1289
|
const [value, important] = transformImportant(val);
|
|
856
1290
|
if (key === "text-decoration-line") {
|
|
857
1291
|
if (value === "none") return `no-underline${important}`;
|
|
@@ -862,7 +1296,7 @@ function text(key, val) {
|
|
|
862
1296
|
return `${value}${important}`;
|
|
863
1297
|
}
|
|
864
1298
|
if (key.startsWith("text-decoration") || key === "text-indent") return `${key.split("-")[1]}${getVal(value)}${important}`;
|
|
865
|
-
if (key === "text-underline-offset") return `underline-offset
|
|
1299
|
+
if (key === "text-underline-offset") return `underline-offset${getVal(value)}${important}`;
|
|
866
1300
|
if (key === "text-align-last") return `${important}[${key}:${value}]`;
|
|
867
1301
|
if ([
|
|
868
1302
|
"inherit",
|
|
@@ -876,16 +1310,41 @@ function text(key, val) {
|
|
|
876
1310
|
|
|
877
1311
|
//#endregion
|
|
878
1312
|
//#region src/top.ts
|
|
1313
|
+
const topMap = [
|
|
1314
|
+
"top",
|
|
1315
|
+
"right",
|
|
1316
|
+
"bottom",
|
|
1317
|
+
"left"
|
|
1318
|
+
];
|
|
879
1319
|
function top(key, val) {
|
|
1320
|
+
if (!topMap.includes(key)) return;
|
|
880
1321
|
const [value, important] = transformImportant(val);
|
|
881
1322
|
return `${key}${getVal(value)}${important}`;
|
|
882
1323
|
}
|
|
883
1324
|
|
|
1325
|
+
//#endregion
|
|
1326
|
+
//#region src/touch.ts
|
|
1327
|
+
const touchMap = ["touch-action"];
|
|
1328
|
+
function touch(key, val) {
|
|
1329
|
+
if (!touchMap.includes(key)) return;
|
|
1330
|
+
const [value, important] = transformImportant(val);
|
|
1331
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
884
1334
|
//#endregion
|
|
885
1335
|
//#region src/transform.ts
|
|
1336
|
+
const transformMap = [
|
|
1337
|
+
"transform",
|
|
1338
|
+
"transform-origin",
|
|
1339
|
+
"transform-style"
|
|
1340
|
+
];
|
|
886
1341
|
function transform(key, val) {
|
|
1342
|
+
if (!transformMap.includes(key)) return;
|
|
887
1343
|
const [v, important] = transformImportant(val);
|
|
888
|
-
if (key === "transform-origin")
|
|
1344
|
+
if (key === "transform-origin") {
|
|
1345
|
+
if (isVar(v) || isCalc(v)) return `origin${getVal(v)}${important}`;
|
|
1346
|
+
return `origin-${/\d/.test(v) && v.includes(" ") ? `[${joinWithUnderLine(v)}]` : joinWithLine(v)}${important}`;
|
|
1347
|
+
}
|
|
889
1348
|
if (key === "transform-style") return `transform-${v}${important}`;
|
|
890
1349
|
if (val === "none") return `${key}-none${important}`;
|
|
891
1350
|
return joinEmpty(v).split(" ").map((v$1) => {
|
|
@@ -897,10 +1356,14 @@ function transform(key, val) {
|
|
|
897
1356
|
if (values.length > 1) return `${namePrefix}-${nameSuffix.toLowerCase()}="${values.map((v$2) => isVar(v$2) ? `[${v$2}]` : namePrefix === "scale" ? getHundred(v$2) : transformVal(v$2)).join(" ")}${important}"`;
|
|
898
1357
|
return `${namePrefix}="${nameSuffix.toLowerCase()}-${isVar(values[0]) ? `[${values[0]}]` : namePrefix === "scale" ? getHundred(values[0]) : transformVal(values[0])}${important}"`;
|
|
899
1358
|
} else {
|
|
900
|
-
|
|
1359
|
+
let values = value.replace(/,(?![^()]*\))/g, " ").split(" ");
|
|
901
1360
|
if (values.length > 1) {
|
|
902
1361
|
if (namePrefix === "translate") return `${namePrefix}="[${values.join(",")}]"`;
|
|
903
|
-
|
|
1362
|
+
if (values.some((v$2) => (isCalc(v$2) || isVar(v$2)) && !v$2.endsWith(")"))) values = [value];
|
|
1363
|
+
return `${namePrefix}="${values.map((v$2) => {
|
|
1364
|
+
const _v = isVar(v$2) || isCalc(v$2) ? `[${v$2}]` : namePrefix === "scale" ? getHundred(v$2) : transformVal(v$2);
|
|
1365
|
+
return _v;
|
|
1366
|
+
}).join(" ")}${important}"`;
|
|
904
1367
|
}
|
|
905
1368
|
return `${namePrefix}="${isVar(values[0]) ? `[${values[0]}]` : namePrefix === "scale" ? getHundred(values[0]) : transformVal(values[0])}${important}"`;
|
|
906
1369
|
}
|
|
@@ -914,7 +1377,16 @@ function transformVal(val) {
|
|
|
914
1377
|
//#endregion
|
|
915
1378
|
//#region src/transition.ts
|
|
916
1379
|
const times = ["transition-delay", "transition-duration"];
|
|
1380
|
+
const transitionMap = [
|
|
1381
|
+
"transition",
|
|
1382
|
+
"transition-property",
|
|
1383
|
+
"transition-duration",
|
|
1384
|
+
"transition-delay",
|
|
1385
|
+
"transition-timing-function",
|
|
1386
|
+
"transition-behavior"
|
|
1387
|
+
];
|
|
917
1388
|
function transition(key, val) {
|
|
1389
|
+
if (!transitionMap.includes(key)) return;
|
|
918
1390
|
const [value, important] = transformImportant(val);
|
|
919
1391
|
if (key === "transition-timing-function") {
|
|
920
1392
|
if (value === "linear") return `ease-${value}${important}`;
|
|
@@ -926,6 +1398,7 @@ function transition(key, val) {
|
|
|
926
1398
|
if (value === "box-shadow") return `transition-shadow${important}`;
|
|
927
1399
|
return `transition-${value}${important}`;
|
|
928
1400
|
}
|
|
1401
|
+
if (key === "transition-behavior") return `transition-${getLastName(value)}${important}`;
|
|
929
1402
|
const _val = getVal(value);
|
|
930
1403
|
if (_val === `-${value}` && times.includes(key)) {
|
|
931
1404
|
let num = value.trim();
|
|
@@ -952,35 +1425,72 @@ function transformTransition(v, important) {
|
|
|
952
1425
|
|
|
953
1426
|
//#endregion
|
|
954
1427
|
//#region src/user.ts
|
|
1428
|
+
const userMap = ["user-select"];
|
|
955
1429
|
function user(key, val) {
|
|
1430
|
+
if (!userMap.includes(key)) return;
|
|
956
1431
|
const [value, important] = transformImportant(val);
|
|
957
1432
|
return `${getLastName(key)}-${value}${important}`;
|
|
958
1433
|
}
|
|
959
1434
|
|
|
960
1435
|
//#endregion
|
|
961
1436
|
//#region src/vertical.ts
|
|
1437
|
+
const verticalMap = [
|
|
1438
|
+
"vertical-align",
|
|
1439
|
+
"vertical-text-align",
|
|
1440
|
+
"vertical-text-align-last",
|
|
1441
|
+
"vertical-align-last",
|
|
1442
|
+
"vertical-justify",
|
|
1443
|
+
"vertical-justify-content",
|
|
1444
|
+
"vertical-justify-items",
|
|
1445
|
+
"vertical-justify-self"
|
|
1446
|
+
];
|
|
962
1447
|
function vertical(key, val) {
|
|
1448
|
+
if (!verticalMap.includes(key)) return;
|
|
1449
|
+
const [value, important] = transformImportant(val);
|
|
1450
|
+
return `v${getVal(value)}${important}`;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
//#endregion
|
|
1454
|
+
//#region src/visibility.ts
|
|
1455
|
+
const visibilityMap = ["visibility"];
|
|
1456
|
+
function visibility(key, val) {
|
|
1457
|
+
if (!visibilityMap.includes(key)) return;
|
|
963
1458
|
const [value, important] = transformImportant(val);
|
|
964
|
-
return `
|
|
1459
|
+
if (value === "none") return `hidden${important}`;
|
|
1460
|
+
if (value === "hidden") return `invisible${important}`;
|
|
1461
|
+
return `${value}${important}`;
|
|
965
1462
|
}
|
|
966
1463
|
|
|
967
1464
|
//#endregion
|
|
968
1465
|
//#region src/white.ts
|
|
1466
|
+
const whiteMap$1 = ["white-space"];
|
|
969
1467
|
function white(key, val) {
|
|
1468
|
+
if (!whiteMap$1.includes(key)) return;
|
|
970
1469
|
const [value, important] = transformImportant(val);
|
|
971
1470
|
return `whitespace-${value}${important}`;
|
|
972
1471
|
}
|
|
973
1472
|
|
|
974
1473
|
//#endregion
|
|
975
1474
|
//#region src/will.ts
|
|
1475
|
+
const willMap = ["will-change"];
|
|
1476
|
+
const willChangeKeys = {
|
|
1477
|
+
"auto": "auto",
|
|
1478
|
+
"scroll-position": "scroll",
|
|
1479
|
+
"contents": "contents",
|
|
1480
|
+
"transform": "transform"
|
|
1481
|
+
};
|
|
976
1482
|
function will(key, val) {
|
|
1483
|
+
if (!willMap.includes(key)) return;
|
|
977
1484
|
const [value, important] = transformImportant(val);
|
|
978
|
-
return
|
|
1485
|
+
if (value in willChangeKeys) return `will-change-${willChangeKeys[value]}${important}`;
|
|
1486
|
+
return `${key}-[${joinWithUnderLine(value)}]${important}`;
|
|
979
1487
|
}
|
|
980
1488
|
|
|
981
1489
|
//#endregion
|
|
982
1490
|
//#region src/writing.ts
|
|
1491
|
+
const whiteMap = ["writing-mode"];
|
|
983
1492
|
function writing(key, val) {
|
|
1493
|
+
if (!whiteMap.includes(key)) return;
|
|
984
1494
|
const [value, important] = transformImportant(val);
|
|
985
1495
|
if (val === "horizontal-tb") return `write-normal${important}`;
|
|
986
1496
|
return `write-${value.replace("-rl", "-right").replace("-lr", "-left")}${important}`;
|
|
@@ -991,37 +1501,37 @@ function writing(key, val) {
|
|
|
991
1501
|
const typeMap = {
|
|
992
1502
|
animation,
|
|
993
1503
|
aspect,
|
|
994
|
-
backface
|
|
995
|
-
caption
|
|
1504
|
+
backface,
|
|
1505
|
+
caption,
|
|
996
1506
|
column,
|
|
997
|
-
columns
|
|
998
|
-
break:
|
|
1507
|
+
columns,
|
|
1508
|
+
break: transformBreak,
|
|
999
1509
|
empty,
|
|
1000
1510
|
box,
|
|
1001
1511
|
writing,
|
|
1002
1512
|
display,
|
|
1003
1513
|
float,
|
|
1004
|
-
clear
|
|
1514
|
+
clear,
|
|
1005
1515
|
isolation,
|
|
1006
1516
|
object,
|
|
1007
1517
|
overflow,
|
|
1008
1518
|
overscroll,
|
|
1009
|
-
position
|
|
1519
|
+
position,
|
|
1010
1520
|
top,
|
|
1011
1521
|
left: top,
|
|
1012
1522
|
right: top,
|
|
1013
1523
|
bottom: top,
|
|
1014
|
-
visibility
|
|
1524
|
+
visibility,
|
|
1015
1525
|
z: size,
|
|
1016
1526
|
flex,
|
|
1017
|
-
order
|
|
1527
|
+
order,
|
|
1018
1528
|
grid,
|
|
1019
|
-
gap
|
|
1529
|
+
gap,
|
|
1020
1530
|
justify,
|
|
1021
1531
|
align,
|
|
1022
1532
|
place,
|
|
1023
1533
|
padding: transformMargin,
|
|
1024
|
-
perspective
|
|
1534
|
+
perspective,
|
|
1025
1535
|
margin: transformMargin,
|
|
1026
1536
|
width: size,
|
|
1027
1537
|
min: max,
|
|
@@ -1033,7 +1543,7 @@ const typeMap = {
|
|
|
1033
1543
|
list,
|
|
1034
1544
|
text,
|
|
1035
1545
|
mask,
|
|
1036
|
-
hyphens
|
|
1546
|
+
hyphens,
|
|
1037
1547
|
vertical,
|
|
1038
1548
|
white,
|
|
1039
1549
|
word,
|
|
@@ -1046,22 +1556,22 @@ const typeMap = {
|
|
|
1046
1556
|
mix,
|
|
1047
1557
|
filter,
|
|
1048
1558
|
backdrop,
|
|
1049
|
-
table
|
|
1559
|
+
table,
|
|
1050
1560
|
transition,
|
|
1051
1561
|
transform,
|
|
1052
|
-
accent
|
|
1053
|
-
appearance
|
|
1562
|
+
accent,
|
|
1563
|
+
appearance,
|
|
1054
1564
|
cursor,
|
|
1055
|
-
caret
|
|
1056
|
-
pointer
|
|
1565
|
+
caret,
|
|
1566
|
+
pointer,
|
|
1057
1567
|
resize,
|
|
1058
1568
|
scroll,
|
|
1059
1569
|
inset,
|
|
1060
|
-
touch
|
|
1570
|
+
touch,
|
|
1061
1571
|
user,
|
|
1062
1572
|
will,
|
|
1063
|
-
fill
|
|
1064
|
-
stroke
|
|
1573
|
+
fill,
|
|
1574
|
+
stroke,
|
|
1065
1575
|
color,
|
|
1066
1576
|
row
|
|
1067
1577
|
};
|