transform-to-unocss-core 0.0.61 → 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 +602 -85
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.iife.js +602 -85
- package/dist/index.js +602 -85
- package/dist/index.umd.js +602 -85
- 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}`;
|
|
@@ -441,49 +512,132 @@ function border(key, val) {
|
|
|
441
512
|
if (key.startsWith("border-image")) return "";
|
|
442
513
|
if (key === "border-width" && value.includes(" ")) return value.split(" ").map((v, i) => `border-${borderSize[i].split("-")[1][0]}${getVal(v)}${important}`).join(" ");
|
|
443
514
|
if (/^\d[%|(px)rem]$/.test(value) || key === "border-collapse") return `border-${value}${important}`;
|
|
444
|
-
if (key === "border-width"
|
|
515
|
+
if (key === "border-width") return `border${getVal(value)}${important}`;
|
|
445
516
|
if (key === "border-color") {
|
|
446
517
|
if (value === "currentColor") return `border-current${important}`;
|
|
447
518
|
return `border${getVal(value)}${important}`;
|
|
448
519
|
}
|
|
520
|
+
if (key === "border-style") {
|
|
521
|
+
const styles = value.split(" ");
|
|
522
|
+
if (styles.length === 4) return `border-t-${styles[0]} border-r-${styles[1]} border-b-${styles[2]} border-l-${styles[3]}`;
|
|
523
|
+
if (styles.length === 3) return `border-t-${styles[0]} border-x-${styles[1]} border-b-${styles[2]}`;
|
|
524
|
+
if (styles.length === 2) return `border-y-${styles[0]} border-x-${styles[1]}`;
|
|
525
|
+
return `border${getVal(value)}${important}`;
|
|
526
|
+
}
|
|
449
527
|
return value.split(" ").map((v) => {
|
|
450
528
|
if (value === "currentColor") return `border-current${important}`;
|
|
451
529
|
return `border${getVal(v)}${important}`;
|
|
452
530
|
}).join(" ");
|
|
453
531
|
}
|
|
454
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
|
+
|
|
455
588
|
//#endregion
|
|
456
589
|
//#region src/color.ts
|
|
590
|
+
const colorMap = ["color"];
|
|
457
591
|
function color(key, val) {
|
|
592
|
+
if (!colorMap.includes(key)) return;
|
|
458
593
|
const [value, important] = transformImportant(val);
|
|
459
594
|
return `text${getVal(value)}${important}`;
|
|
460
595
|
}
|
|
461
596
|
|
|
462
597
|
//#endregion
|
|
463
598
|
//#region src/column.ts
|
|
599
|
+
const columnMap = ["column-gap"];
|
|
464
600
|
function column(key, val) {
|
|
601
|
+
if (!columnMap.includes(key)) return;
|
|
465
602
|
const [value, important] = transformImportant(val);
|
|
466
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);
|
|
467
612
|
return `${key}-${value}${important}`;
|
|
468
613
|
}
|
|
469
614
|
|
|
470
615
|
//#endregion
|
|
471
616
|
//#region src/content.ts
|
|
617
|
+
const contentMap = ["content", "content-visibility"];
|
|
472
618
|
function content(key, val) {
|
|
473
|
-
|
|
474
|
-
|
|
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}`;
|
|
475
625
|
}
|
|
476
626
|
|
|
477
627
|
//#endregion
|
|
478
628
|
//#region src/cursor.ts
|
|
629
|
+
const cursorMap = ["cursor"];
|
|
479
630
|
function cursor(key, val) {
|
|
631
|
+
if (!cursorMap.includes(key)) return;
|
|
480
632
|
const [value, important] = transformImportant(val);
|
|
481
633
|
return `${key}${getVal(value)}${important}`;
|
|
482
634
|
}
|
|
483
635
|
|
|
484
636
|
//#endregion
|
|
485
637
|
//#region src/display.ts
|
|
638
|
+
const displayMap = ["display"];
|
|
486
639
|
function display(key, val) {
|
|
640
|
+
if (!displayMap.includes(key)) return;
|
|
487
641
|
const [value, important] = transformImportant(val);
|
|
488
642
|
if (value === "none") return `hidden${important}`;
|
|
489
643
|
if (value === "hidden") return `invisible${important}`;
|
|
@@ -492,13 +646,24 @@ function display(key, val) {
|
|
|
492
646
|
|
|
493
647
|
//#endregion
|
|
494
648
|
//#region src/empty.ts
|
|
495
|
-
const
|
|
649
|
+
const emptyKey = {
|
|
496
650
|
show: "visible",
|
|
497
651
|
hide: "hidden"
|
|
498
652
|
};
|
|
653
|
+
const emptyMap = ["empty-cells"];
|
|
499
654
|
function empty(key, val) {
|
|
655
|
+
if (!emptyMap.includes(key)) return;
|
|
500
656
|
const [value, important] = transformImportant(val);
|
|
501
|
-
return `table-empty-cells-${
|
|
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;
|
|
665
|
+
const [value, important] = transformImportant(val);
|
|
666
|
+
return `${key}-${value}${important}`;
|
|
502
667
|
}
|
|
503
668
|
|
|
504
669
|
//#endregion
|
|
@@ -508,8 +673,16 @@ const lastMaps = [
|
|
|
508
673
|
"flex-grow",
|
|
509
674
|
"flex-shrink"
|
|
510
675
|
];
|
|
676
|
+
const flexMap = [
|
|
677
|
+
"flex",
|
|
678
|
+
"flex-grow",
|
|
679
|
+
"flex-shrink",
|
|
680
|
+
"flex-basis",
|
|
681
|
+
"flex-wrap",
|
|
682
|
+
"flex-direction"
|
|
683
|
+
];
|
|
511
684
|
function flex(key, val) {
|
|
512
|
-
if (
|
|
685
|
+
if (!flexMap.includes(key)) return;
|
|
513
686
|
const [value, important] = transformImportant(val);
|
|
514
687
|
if (lastMaps.includes(key)) return `${getLastName(key)}${getVal(value)}${important}`;
|
|
515
688
|
if (value === "1") return `flex-1${important}`;
|
|
@@ -521,14 +694,25 @@ function flex(key, val) {
|
|
|
521
694
|
|
|
522
695
|
//#endregion
|
|
523
696
|
//#region src/float.ts
|
|
697
|
+
const floatMap = ["float"];
|
|
524
698
|
function float(key, val) {
|
|
699
|
+
if (!floatMap.includes(key)) return;
|
|
525
700
|
const [value, important] = transformImportant(val);
|
|
526
|
-
return `${key}-${value}${important}`;
|
|
701
|
+
return `${key}-${getLastName(value)}${important}`;
|
|
527
702
|
}
|
|
528
703
|
|
|
529
704
|
//#endregion
|
|
530
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
|
+
];
|
|
531
714
|
function font(key, val) {
|
|
715
|
+
if (!fontMap.includes(key)) return;
|
|
532
716
|
const [value, important] = transformImportant(val);
|
|
533
717
|
if (key === "font-size") {
|
|
534
718
|
if ([
|
|
@@ -540,7 +724,7 @@ function font(key, val) {
|
|
|
540
724
|
].includes(value)) return `font-size-${value}${important}`;
|
|
541
725
|
return `text-${value}${important}`;
|
|
542
726
|
}
|
|
543
|
-
if (key === "font-weight") return `font
|
|
727
|
+
if (key === "font-weight") return `font${getVal(value)}${important}`;
|
|
544
728
|
if (key === "font-family") {
|
|
545
729
|
const match = value.match(/ui-(\w{0,4})/);
|
|
546
730
|
if (!match) return `font-[${joinWithUnderLine(val)}]${important}`;
|
|
@@ -561,38 +745,84 @@ function transformFont(v) {
|
|
|
561
745
|
return v.split(" ").map((item) => /^\d/.test(item) ? `text-${item}` : item).join(" ");
|
|
562
746
|
}
|
|
563
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
|
+
|
|
564
763
|
//#endregion
|
|
565
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
|
+
];
|
|
566
779
|
function grid(key, val) {
|
|
780
|
+
if (!gridMap.includes(key)) return;
|
|
567
781
|
const [value, important] = transformImportant(val);
|
|
568
782
|
if (key.startsWith("grid-template")) {
|
|
569
|
-
const matcher$1 = value.match(
|
|
783
|
+
const matcher$1 = value.match(/^repeat\s*\(\s*(\d+)/);
|
|
570
784
|
if (matcher$1) return `grid-${getLastName(key) === "rows" ? "rows" : "cols"}-${matcher$1[1]}${important}`;
|
|
571
|
-
|
|
785
|
+
if (value.startsWith("repeat(")) return;
|
|
786
|
+
return `grid-${getLastName(key) === "rows" ? "rows" : "cols"}${value.includes(" ") ? `-[${joinWithUnderLine(value)}]` : getVal(value)}${important}`;
|
|
572
787
|
}
|
|
573
788
|
if (key === "grid-auto-flow") return `grid-flow-${joinWithLine(value).replace("column", "col")}${important}`;
|
|
574
789
|
if (key.startsWith("grid-auto")) {
|
|
575
|
-
|
|
576
|
-
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}`;
|
|
577
797
|
}
|
|
578
|
-
const matcher = value.match(/span\s+(\d)/);
|
|
579
|
-
if (matcher) return `${key.slice(5).replace("column", "col")}-span-${matcher[1]}${important}`;
|
|
580
798
|
if (value === "1/-1") return `${key.slice(5).replace("column", "col")}-span-full${important}`;
|
|
581
|
-
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}`;
|
|
582
809
|
}
|
|
583
810
|
|
|
584
811
|
//#endregion
|
|
585
812
|
//#region src/inset.ts
|
|
813
|
+
const insetMap = ["inset-inline-start", "inset-inline-end"];
|
|
586
814
|
function inset(key, val) {
|
|
815
|
+
if (!insetMap.includes(key)) return;
|
|
587
816
|
const [value, important] = transformImportant(val);
|
|
588
817
|
if (key === "inset-inline-start") return `start${getVal(value)}${important}`;
|
|
589
818
|
if (key === "inset-inline-end") return `end${getVal(value)}${important}`;
|
|
590
|
-
return void 0;
|
|
591
819
|
}
|
|
592
820
|
|
|
593
821
|
//#endregion
|
|
594
822
|
//#region src/isolation.ts
|
|
823
|
+
const isolationMap = ["isolation"];
|
|
595
824
|
function isolation(key, val) {
|
|
825
|
+
if (!isolationMap.includes(key)) return;
|
|
596
826
|
const [value, important] = transformImportant(val);
|
|
597
827
|
if (val === "isolate") return `${value}${important}`;
|
|
598
828
|
return `${key}-${value}${important}`;
|
|
@@ -600,22 +830,32 @@ function isolation(key, val) {
|
|
|
600
830
|
|
|
601
831
|
//#endregion
|
|
602
832
|
//#region src/justify.ts
|
|
833
|
+
const justifyMap = [
|
|
834
|
+
"justify",
|
|
835
|
+
"justify-content",
|
|
836
|
+
"justify-items",
|
|
837
|
+
"justify-self"
|
|
838
|
+
];
|
|
603
839
|
function justify(key, val) {
|
|
840
|
+
if (!justifyMap.includes(key)) return;
|
|
604
841
|
const [value, important] = transformImportant(val);
|
|
842
|
+
if (value.includes(" ")) return;
|
|
605
843
|
if (key === "justify-content") return `justify-${getLastName(value)}${important}`;
|
|
606
844
|
return `${key}-${getLastName(value)}${important}`;
|
|
607
845
|
}
|
|
608
846
|
|
|
609
847
|
//#endregion
|
|
610
848
|
//#region src/letter.ts
|
|
849
|
+
const letterMap = ["letter-spacing"];
|
|
611
850
|
function letter(key, val) {
|
|
851
|
+
if (!letterMap.includes(key)) return;
|
|
612
852
|
const [value, important] = transformImportant(val);
|
|
613
|
-
return `tracking
|
|
853
|
+
return `tracking${getVal(value)}${important}`;
|
|
614
854
|
}
|
|
615
855
|
|
|
616
856
|
//#endregion
|
|
617
857
|
//#region src/line.ts
|
|
618
|
-
const
|
|
858
|
+
const lineKey = {
|
|
619
859
|
1: "none",
|
|
620
860
|
1.25: "tight",
|
|
621
861
|
1.375: "snug",
|
|
@@ -623,16 +863,29 @@ const lineMap = {
|
|
|
623
863
|
1.625: "relaxed",
|
|
624
864
|
2: "loose"
|
|
625
865
|
};
|
|
866
|
+
const lineMap = ["line-height"];
|
|
626
867
|
function line(key, val) {
|
|
868
|
+
if (!lineMap.includes(key)) return;
|
|
627
869
|
const [value, important] = transformImportant(val);
|
|
628
|
-
if (value in
|
|
870
|
+
if (value in lineKey) return `lh-${lineKey[value]}${important}`;
|
|
629
871
|
return `lh${getVal(value, (v) => /\d$/.test(v) ? `[${v}]` : v)}${important}`;
|
|
630
872
|
}
|
|
631
873
|
|
|
632
874
|
//#endregion
|
|
633
875
|
//#region src/list.ts
|
|
876
|
+
const listMap = [
|
|
877
|
+
"list-style",
|
|
878
|
+
"list-style-type",
|
|
879
|
+
"list-style-position",
|
|
880
|
+
"list-style-image"
|
|
881
|
+
];
|
|
634
882
|
function list(key, val) {
|
|
883
|
+
if (!listMap.includes(key)) return;
|
|
635
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
|
+
}
|
|
636
889
|
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
637
890
|
}
|
|
638
891
|
|
|
@@ -666,33 +919,49 @@ function transformMargin(key, val) {
|
|
|
666
919
|
|
|
667
920
|
//#endregion
|
|
668
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
|
+
];
|
|
669
934
|
function mask(key, val) {
|
|
935
|
+
if (!maskMap.includes(key)) return;
|
|
670
936
|
const [value, important] = transformImportant(val);
|
|
671
937
|
if ([
|
|
672
938
|
"mask-clip",
|
|
673
939
|
"mask-origin",
|
|
674
940
|
"mask-type"
|
|
675
|
-
].includes(key)) return `${
|
|
676
|
-
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}`;
|
|
677
943
|
if (["mask-position", "mask-size"].includes(key)) {
|
|
678
944
|
if (isCalc(value) || isUrl(value) || isHex(value) || isRgb(value) || isHsl(value) || isPercent(value) || isVar(value) || isCubicBezier(value)) return `${important}${key}${getVal(value)}`;
|
|
679
945
|
if (/\d/.test(value)) return `${important}[${key}:${joinWithUnderLine(value)}]`;
|
|
680
946
|
return `${important}${getFirstName(key)}-${joinWithLine(value)}`;
|
|
681
947
|
}
|
|
682
|
-
if (key === "mask-repeat")
|
|
948
|
+
if (key === "mask-repeat") {
|
|
949
|
+
if (value.includes("-")) return `mask-${value}${important}`;
|
|
950
|
+
return `${key}-${value}${important}`;
|
|
951
|
+
}
|
|
683
952
|
if (key === "mask-image") {
|
|
684
953
|
const type = getGradient(value);
|
|
685
954
|
if (type) {
|
|
686
955
|
const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
|
|
687
956
|
const matcher = newValue.match(linearGradientReg);
|
|
688
|
-
if (!matcher) return
|
|
957
|
+
if (!matcher) return `[${key}:${joinWithUnderLine(value)}]${important}`;
|
|
689
958
|
let [direction, from, via, to] = matcher.slice(1);
|
|
690
959
|
direction = direction.split(" ").map((item) => item[0]).join("");
|
|
691
960
|
return direction ? `${getLinearGradientPosition(`mask-${direction}`, from, via, to).trim()}` : getLinearGradientPosition(`mask-${type}`, from, via, to).trim();
|
|
692
961
|
}
|
|
693
|
-
return
|
|
962
|
+
return `mask${getVal(value)}${important}`;
|
|
694
963
|
}
|
|
695
|
-
return `${
|
|
964
|
+
return `${key}${getVal(value)}${important}`;
|
|
696
965
|
}
|
|
697
966
|
function getLinearGradientPosition(prefix, from, via, to) {
|
|
698
967
|
let result = "";
|
|
@@ -723,8 +992,24 @@ function getLinearGradientPosition(prefix, from, via, to) {
|
|
|
723
992
|
|
|
724
993
|
//#endregion
|
|
725
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
|
+
];
|
|
726
1005
|
function max(key, val) {
|
|
1006
|
+
if (!maxMap.includes(key)) return;
|
|
727
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
|
+
}
|
|
728
1013
|
const all = key.split("-");
|
|
729
1014
|
const attributeValue = isCalc(value) || isVar(value) ? getVal(value) : getVal(getFirstName(value));
|
|
730
1015
|
return `${all[0]}-${all[1][0]}${attributeValue}${important}`;
|
|
@@ -732,38 +1017,64 @@ function max(key, val) {
|
|
|
732
1017
|
|
|
733
1018
|
//#endregion
|
|
734
1019
|
//#region src/mix.ts
|
|
1020
|
+
const mixMap = ["mix-blend-mode"];
|
|
735
1021
|
function mix(key, val) {
|
|
1022
|
+
if (!mixMap.includes(key)) return;
|
|
736
1023
|
const [value, important] = transformImportant(val);
|
|
737
1024
|
return `mix-blend-${value}${important}`;
|
|
738
1025
|
}
|
|
739
1026
|
|
|
740
1027
|
//#endregion
|
|
741
1028
|
//#region src/object.ts
|
|
1029
|
+
const objectMap = ["object-fit", "object-position"];
|
|
742
1030
|
function object(key, val) {
|
|
1031
|
+
if (!objectMap.includes(key)) return;
|
|
743
1032
|
const [value, important] = transformImportant(val);
|
|
744
|
-
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
|
+
}
|
|
745
1037
|
return `${getFirstName(key)}-${value}${important}`;
|
|
746
1038
|
}
|
|
747
1039
|
|
|
748
1040
|
//#endregion
|
|
749
1041
|
//#region src/opacity.ts
|
|
1042
|
+
const opacityMap = ["opacity"];
|
|
750
1043
|
function opacity(key, val) {
|
|
1044
|
+
if (!opacityMap.includes(key)) return;
|
|
1045
|
+
const [value, important] = transformImportant(val);
|
|
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;
|
|
751
1056
|
const [value, important] = transformImportant(val);
|
|
752
|
-
|
|
753
|
-
return `op-${+value * 100}${important}`;
|
|
1057
|
+
return `${key}${getVal(value)}${important}`;
|
|
754
1058
|
}
|
|
755
1059
|
|
|
756
1060
|
//#endregion
|
|
757
1061
|
//#region src/outline.ts
|
|
758
1062
|
function outline(key, val) {
|
|
759
1063
|
const [value, important] = transformImportant(val);
|
|
760
|
-
if (key === "outline-offset") return `${key}
|
|
761
|
-
return `${getFirstName(key)}
|
|
1064
|
+
if (key === "outline-offset") return `${key}${getVal(value)}${important}`;
|
|
1065
|
+
return `${getFirstName(key)}${getVal(value)}${important}`;
|
|
762
1066
|
}
|
|
763
1067
|
|
|
764
1068
|
//#endregion
|
|
765
1069
|
//#region src/word.ts
|
|
1070
|
+
const wordMap = [
|
|
1071
|
+
"word-break",
|
|
1072
|
+
"word-spacing",
|
|
1073
|
+
"word-wrap",
|
|
1074
|
+
"overflow-wrap"
|
|
1075
|
+
];
|
|
766
1076
|
function word(key, val) {
|
|
1077
|
+
if (!wordMap.includes(key)) return;
|
|
767
1078
|
const [value, important] = transformImportant(val);
|
|
768
1079
|
if (key.startsWith("word-spacing")) return `word-spacing${getVal(val)}${important}`;
|
|
769
1080
|
if (value === "keep-all") return `break-keep${important}`;
|
|
@@ -773,7 +1084,14 @@ function word(key, val) {
|
|
|
773
1084
|
|
|
774
1085
|
//#endregion
|
|
775
1086
|
//#region src/overflow.ts.ts
|
|
1087
|
+
const overflowMap = [
|
|
1088
|
+
"overflow",
|
|
1089
|
+
"overflow-x",
|
|
1090
|
+
"overflow-y",
|
|
1091
|
+
"overflow-wrap"
|
|
1092
|
+
];
|
|
776
1093
|
function overflow(key, val) {
|
|
1094
|
+
if (!overflowMap.includes(key)) return;
|
|
777
1095
|
const [value, important] = transformImportant(val);
|
|
778
1096
|
if (key === "overflow-wrap") return word(key, val);
|
|
779
1097
|
return `${key}-${value}${important}`;
|
|
@@ -781,27 +1099,71 @@ function overflow(key, val) {
|
|
|
781
1099
|
|
|
782
1100
|
//#endregion
|
|
783
1101
|
//#region src/overscroll.ts
|
|
1102
|
+
const overscrollMap = [
|
|
1103
|
+
"overscroll-behavior",
|
|
1104
|
+
"overscroll-behavior-x",
|
|
1105
|
+
"overscroll-behavior-y"
|
|
1106
|
+
];
|
|
784
1107
|
function overscroll(key, val) {
|
|
1108
|
+
if (!overscrollMap.includes(key)) return;
|
|
785
1109
|
const [value, important] = transformImportant(val);
|
|
786
1110
|
const [prefix, _, suffix] = key.split("-");
|
|
787
1111
|
if (suffix) return `${prefix}-${suffix}-${value}${important}`;
|
|
788
1112
|
return `${prefix}-${value}${important}`;
|
|
789
1113
|
}
|
|
790
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
|
+
|
|
791
1124
|
//#endregion
|
|
792
1125
|
//#region src/place.ts
|
|
1126
|
+
const placeMap = [
|
|
1127
|
+
"place-content",
|
|
1128
|
+
"place-items",
|
|
1129
|
+
"place-self"
|
|
1130
|
+
];
|
|
793
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;
|
|
794
1143
|
const [value, important] = transformImportant(val);
|
|
795
1144
|
return `${key}-${getLastName(value)}${important}`;
|
|
796
1145
|
}
|
|
797
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
|
+
|
|
798
1158
|
//#endregion
|
|
799
1159
|
//#region src/resize.ts
|
|
800
1160
|
const map = {
|
|
801
1161
|
vertical: "y",
|
|
802
1162
|
horizontal: "x"
|
|
803
1163
|
};
|
|
1164
|
+
const resizeMap = ["resize"];
|
|
804
1165
|
function resize(key, val) {
|
|
1166
|
+
if (!resizeMap.includes(key)) return;
|
|
805
1167
|
const [value, important] = transformImportant(val);
|
|
806
1168
|
if (value === "both") return `${key}${important}`;
|
|
807
1169
|
return `${key}-${map[value] || value}${important}`;
|
|
@@ -809,7 +1171,9 @@ function resize(key, val) {
|
|
|
809
1171
|
|
|
810
1172
|
//#endregion
|
|
811
1173
|
//#region src/rotate.ts
|
|
1174
|
+
const rotateMap = ["rotate"];
|
|
812
1175
|
function rotate(key, val) {
|
|
1176
|
+
if (!rotateMap.includes(key)) return;
|
|
813
1177
|
const [value, important] = transformImportant(val);
|
|
814
1178
|
if (value.includes(" ")) return `rotate-[${joinWithUnderLine(value)}]${important}`;
|
|
815
1179
|
return `rotate${getVal(value)}${important}`;
|
|
@@ -817,34 +1181,111 @@ function rotate(key, val) {
|
|
|
817
1181
|
|
|
818
1182
|
//#endregion
|
|
819
1183
|
//#region src/row.ts
|
|
1184
|
+
const rowMap = ["row-gap"];
|
|
820
1185
|
function row(key, val) {
|
|
1186
|
+
if (!rowMap.includes(key)) return;
|
|
821
1187
|
const [value, important] = transformImportant(val);
|
|
822
|
-
return `gap-y
|
|
1188
|
+
return `gap-y${getVal(value)}${important}`;
|
|
823
1189
|
}
|
|
824
1190
|
|
|
825
1191
|
//#endregion
|
|
826
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
|
+
];
|
|
827
1221
|
function scroll(key, val) {
|
|
1222
|
+
if (!scrollMap.includes(key)) return;
|
|
828
1223
|
const [value, important] = transformImportant(val);
|
|
829
|
-
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
|
+
}
|
|
830
1231
|
if (key === "scroll-behavior") return `scroll-${value}${important}`;
|
|
831
1232
|
const [_, prefix, suffix, way] = key.match(/scroll-(margin|padding)-?(\w+)?-?(\w+)?/);
|
|
832
1233
|
if (suffix === "inline" && way) return `scroll-${prefix[0]}${way[0]}${getVal(value)}${important}`;
|
|
833
1234
|
if (suffix) return `scroll-${prefix[0]}${suffix[0]}${getVal(value)}${important}`;
|
|
834
|
-
return `scroll-${prefix[0]}
|
|
1235
|
+
return `scroll-${prefix[0]}${getVal(value)}${important}`;
|
|
835
1236
|
}
|
|
836
1237
|
|
|
837
1238
|
//#endregion
|
|
838
1239
|
//#region src/size.ts
|
|
1240
|
+
const sizeMap = [
|
|
1241
|
+
"z-index",
|
|
1242
|
+
"width",
|
|
1243
|
+
"height"
|
|
1244
|
+
];
|
|
839
1245
|
function size(key, val) {
|
|
1246
|
+
if (!sizeMap.includes(key)) return;
|
|
840
1247
|
const [value, important] = transformImportant(val);
|
|
841
1248
|
if (value.startsWith("-")) return `-${key[0]}${getVal(value.slice(1), getFirstName)}${important}`;
|
|
842
1249
|
return `${key[0]}${getVal(value, getFirstName)}${important}`;
|
|
843
1250
|
}
|
|
844
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
|
+
|
|
845
1270
|
//#endregion
|
|
846
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
|
+
];
|
|
847
1287
|
function text(key, val) {
|
|
1288
|
+
if (!textMap.includes(key)) return;
|
|
848
1289
|
const [value, important] = transformImportant(val);
|
|
849
1290
|
if (key === "text-decoration-line") {
|
|
850
1291
|
if (value === "none") return `no-underline${important}`;
|
|
@@ -855,7 +1296,7 @@ function text(key, val) {
|
|
|
855
1296
|
return `${value}${important}`;
|
|
856
1297
|
}
|
|
857
1298
|
if (key.startsWith("text-decoration") || key === "text-indent") return `${key.split("-")[1]}${getVal(value)}${important}`;
|
|
858
|
-
if (key === "text-underline-offset") return `underline-offset
|
|
1299
|
+
if (key === "text-underline-offset") return `underline-offset${getVal(value)}${important}`;
|
|
859
1300
|
if (key === "text-align-last") return `${important}[${key}:${value}]`;
|
|
860
1301
|
if ([
|
|
861
1302
|
"inherit",
|
|
@@ -869,16 +1310,41 @@ function text(key, val) {
|
|
|
869
1310
|
|
|
870
1311
|
//#endregion
|
|
871
1312
|
//#region src/top.ts
|
|
1313
|
+
const topMap = [
|
|
1314
|
+
"top",
|
|
1315
|
+
"right",
|
|
1316
|
+
"bottom",
|
|
1317
|
+
"left"
|
|
1318
|
+
];
|
|
872
1319
|
function top(key, val) {
|
|
1320
|
+
if (!topMap.includes(key)) return;
|
|
873
1321
|
const [value, important] = transformImportant(val);
|
|
874
1322
|
return `${key}${getVal(value)}${important}`;
|
|
875
1323
|
}
|
|
876
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
|
+
|
|
877
1334
|
//#endregion
|
|
878
1335
|
//#region src/transform.ts
|
|
1336
|
+
const transformMap = [
|
|
1337
|
+
"transform",
|
|
1338
|
+
"transform-origin",
|
|
1339
|
+
"transform-style"
|
|
1340
|
+
];
|
|
879
1341
|
function transform(key, val) {
|
|
1342
|
+
if (!transformMap.includes(key)) return;
|
|
880
1343
|
const [v, important] = transformImportant(val);
|
|
881
|
-
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
|
+
}
|
|
882
1348
|
if (key === "transform-style") return `transform-${v}${important}`;
|
|
883
1349
|
if (val === "none") return `${key}-none${important}`;
|
|
884
1350
|
return joinEmpty(v).split(" ").map((v$1) => {
|
|
@@ -890,10 +1356,14 @@ function transform(key, val) {
|
|
|
890
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}"`;
|
|
891
1357
|
return `${namePrefix}="${nameSuffix.toLowerCase()}-${isVar(values[0]) ? `[${values[0]}]` : namePrefix === "scale" ? getHundred(values[0]) : transformVal(values[0])}${important}"`;
|
|
892
1358
|
} else {
|
|
893
|
-
|
|
1359
|
+
let values = value.replace(/,(?![^()]*\))/g, " ").split(" ");
|
|
894
1360
|
if (values.length > 1) {
|
|
895
1361
|
if (namePrefix === "translate") return `${namePrefix}="[${values.join(",")}]"`;
|
|
896
|
-
|
|
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}"`;
|
|
897
1367
|
}
|
|
898
1368
|
return `${namePrefix}="${isVar(values[0]) ? `[${values[0]}]` : namePrefix === "scale" ? getHundred(values[0]) : transformVal(values[0])}${important}"`;
|
|
899
1369
|
}
|
|
@@ -907,7 +1377,16 @@ function transformVal(val) {
|
|
|
907
1377
|
//#endregion
|
|
908
1378
|
//#region src/transition.ts
|
|
909
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
|
+
];
|
|
910
1388
|
function transition(key, val) {
|
|
1389
|
+
if (!transitionMap.includes(key)) return;
|
|
911
1390
|
const [value, important] = transformImportant(val);
|
|
912
1391
|
if (key === "transition-timing-function") {
|
|
913
1392
|
if (value === "linear") return `ease-${value}${important}`;
|
|
@@ -919,6 +1398,7 @@ function transition(key, val) {
|
|
|
919
1398
|
if (value === "box-shadow") return `transition-shadow${important}`;
|
|
920
1399
|
return `transition-${value}${important}`;
|
|
921
1400
|
}
|
|
1401
|
+
if (key === "transition-behavior") return `transition-${getLastName(value)}${important}`;
|
|
922
1402
|
const _val = getVal(value);
|
|
923
1403
|
if (_val === `-${value}` && times.includes(key)) {
|
|
924
1404
|
let num = value.trim();
|
|
@@ -945,35 +1425,72 @@ function transformTransition(v, important) {
|
|
|
945
1425
|
|
|
946
1426
|
//#endregion
|
|
947
1427
|
//#region src/user.ts
|
|
1428
|
+
const userMap = ["user-select"];
|
|
948
1429
|
function user(key, val) {
|
|
1430
|
+
if (!userMap.includes(key)) return;
|
|
949
1431
|
const [value, important] = transformImportant(val);
|
|
950
1432
|
return `${getLastName(key)}-${value}${important}`;
|
|
951
1433
|
}
|
|
952
1434
|
|
|
953
1435
|
//#endregion
|
|
954
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
|
+
];
|
|
955
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;
|
|
956
1458
|
const [value, important] = transformImportant(val);
|
|
957
|
-
return `
|
|
1459
|
+
if (value === "none") return `hidden${important}`;
|
|
1460
|
+
if (value === "hidden") return `invisible${important}`;
|
|
1461
|
+
return `${value}${important}`;
|
|
958
1462
|
}
|
|
959
1463
|
|
|
960
1464
|
//#endregion
|
|
961
1465
|
//#region src/white.ts
|
|
1466
|
+
const whiteMap$1 = ["white-space"];
|
|
962
1467
|
function white(key, val) {
|
|
1468
|
+
if (!whiteMap$1.includes(key)) return;
|
|
963
1469
|
const [value, important] = transformImportant(val);
|
|
964
1470
|
return `whitespace-${value}${important}`;
|
|
965
1471
|
}
|
|
966
1472
|
|
|
967
1473
|
//#endregion
|
|
968
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
|
+
};
|
|
969
1482
|
function will(key, val) {
|
|
1483
|
+
if (!willMap.includes(key)) return;
|
|
970
1484
|
const [value, important] = transformImportant(val);
|
|
971
|
-
return
|
|
1485
|
+
if (value in willChangeKeys) return `will-change-${willChangeKeys[value]}${important}`;
|
|
1486
|
+
return `${key}-[${joinWithUnderLine(value)}]${important}`;
|
|
972
1487
|
}
|
|
973
1488
|
|
|
974
1489
|
//#endregion
|
|
975
1490
|
//#region src/writing.ts
|
|
1491
|
+
const whiteMap = ["writing-mode"];
|
|
976
1492
|
function writing(key, val) {
|
|
1493
|
+
if (!whiteMap.includes(key)) return;
|
|
977
1494
|
const [value, important] = transformImportant(val);
|
|
978
1495
|
if (val === "horizontal-tb") return `write-normal${important}`;
|
|
979
1496
|
return `write-${value.replace("-rl", "-right").replace("-lr", "-left")}${important}`;
|
|
@@ -984,37 +1501,37 @@ function writing(key, val) {
|
|
|
984
1501
|
const typeMap = {
|
|
985
1502
|
animation,
|
|
986
1503
|
aspect,
|
|
987
|
-
backface
|
|
988
|
-
caption
|
|
1504
|
+
backface,
|
|
1505
|
+
caption,
|
|
989
1506
|
column,
|
|
990
|
-
columns
|
|
991
|
-
break:
|
|
1507
|
+
columns,
|
|
1508
|
+
break: transformBreak,
|
|
992
1509
|
empty,
|
|
993
1510
|
box,
|
|
994
1511
|
writing,
|
|
995
1512
|
display,
|
|
996
1513
|
float,
|
|
997
|
-
clear
|
|
1514
|
+
clear,
|
|
998
1515
|
isolation,
|
|
999
1516
|
object,
|
|
1000
1517
|
overflow,
|
|
1001
1518
|
overscroll,
|
|
1002
|
-
position
|
|
1519
|
+
position,
|
|
1003
1520
|
top,
|
|
1004
1521
|
left: top,
|
|
1005
1522
|
right: top,
|
|
1006
1523
|
bottom: top,
|
|
1007
|
-
visibility
|
|
1524
|
+
visibility,
|
|
1008
1525
|
z: size,
|
|
1009
1526
|
flex,
|
|
1010
|
-
order
|
|
1527
|
+
order,
|
|
1011
1528
|
grid,
|
|
1012
|
-
gap
|
|
1529
|
+
gap,
|
|
1013
1530
|
justify,
|
|
1014
1531
|
align,
|
|
1015
1532
|
place,
|
|
1016
1533
|
padding: transformMargin,
|
|
1017
|
-
perspective
|
|
1534
|
+
perspective,
|
|
1018
1535
|
margin: transformMargin,
|
|
1019
1536
|
width: size,
|
|
1020
1537
|
min: max,
|
|
@@ -1026,7 +1543,7 @@ const typeMap = {
|
|
|
1026
1543
|
list,
|
|
1027
1544
|
text,
|
|
1028
1545
|
mask,
|
|
1029
|
-
hyphens
|
|
1546
|
+
hyphens,
|
|
1030
1547
|
vertical,
|
|
1031
1548
|
white,
|
|
1032
1549
|
word,
|
|
@@ -1039,22 +1556,22 @@ const typeMap = {
|
|
|
1039
1556
|
mix,
|
|
1040
1557
|
filter,
|
|
1041
1558
|
backdrop,
|
|
1042
|
-
table
|
|
1559
|
+
table,
|
|
1043
1560
|
transition,
|
|
1044
1561
|
transform,
|
|
1045
|
-
accent
|
|
1046
|
-
appearance
|
|
1562
|
+
accent,
|
|
1563
|
+
appearance,
|
|
1047
1564
|
cursor,
|
|
1048
|
-
caret
|
|
1049
|
-
pointer
|
|
1565
|
+
caret,
|
|
1566
|
+
pointer,
|
|
1050
1567
|
resize,
|
|
1051
1568
|
scroll,
|
|
1052
1569
|
inset,
|
|
1053
|
-
touch
|
|
1570
|
+
touch,
|
|
1054
1571
|
user,
|
|
1055
1572
|
will,
|
|
1056
|
-
fill
|
|
1057
|
-
stroke
|
|
1573
|
+
fill,
|
|
1574
|
+
stroke,
|
|
1058
1575
|
color,
|
|
1059
1576
|
row
|
|
1060
1577
|
};
|