@abydahana/aksara-ui 1.1.7 → 1.2.1
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/aksara.css +735 -3
- package/dist/aksara.esm.js +133 -20
- package/dist/aksara.js +133 -20
- package/dist/aksara.min.css +1 -1
- package/dist/aksara.min.js +1 -1
- package/package.json +1 -1
package/dist/aksara.esm.js
CHANGED
|
@@ -1339,9 +1339,22 @@ function getArbitrarySheet() {
|
|
|
1339
1339
|
return null;
|
|
1340
1340
|
if (!arbitrarySheet) {
|
|
1341
1341
|
if ("adoptedStyleSheets" in document && typeof CSSStyleSheet !== "undefined") {
|
|
1342
|
-
|
|
1343
|
-
|
|
1342
|
+
try {
|
|
1343
|
+
arbitrarySheet = new CSSStyleSheet();
|
|
1344
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, arbitrarySheet];
|
|
1345
|
+
return arbitrarySheet;
|
|
1346
|
+
}
|
|
1347
|
+
catch {
|
|
1348
|
+
// Fallback to style tag below
|
|
1349
|
+
}
|
|
1344
1350
|
}
|
|
1351
|
+
let styleEl = document.getElementById("aksara-arbitrary-styles");
|
|
1352
|
+
if (!styleEl) {
|
|
1353
|
+
styleEl = document.createElement("style");
|
|
1354
|
+
styleEl.id = "aksara-arbitrary-styles";
|
|
1355
|
+
document.head?.appendChild(styleEl);
|
|
1356
|
+
}
|
|
1357
|
+
arbitrarySheet = styleEl.sheet;
|
|
1345
1358
|
}
|
|
1346
1359
|
return arbitrarySheet;
|
|
1347
1360
|
}
|
|
@@ -1375,6 +1388,8 @@ const runtimeArbitraryPropertyMap = {
|
|
|
1375
1388
|
gap: (v) => `gap:${v}`,
|
|
1376
1389
|
"row-gap": (v) => `row-gap:${v}`,
|
|
1377
1390
|
"col-gap": (v) => `column-gap:${v}`,
|
|
1391
|
+
"gap-y": (v) => `row-gap:${v}`,
|
|
1392
|
+
"gap-x": (v) => `column-gap:${v}`,
|
|
1378
1393
|
g: (v) => `--aksara-gutter-x:${v};--aksara-gutter-y:${v}`,
|
|
1379
1394
|
gx: (v) => `--aksara-gutter-x:${v}`,
|
|
1380
1395
|
gy: (v) => `--aksara-gutter-y:${v}`,
|
|
@@ -1388,6 +1403,8 @@ const runtimeArbitraryPropertyMap = {
|
|
|
1388
1403
|
bottom: (v) => `inset-block-end:${v}`,
|
|
1389
1404
|
start: (v) => `inset-inline-start:${v}`,
|
|
1390
1405
|
end: (v) => `inset-inline-end:${v}`,
|
|
1406
|
+
left: (v) => `left:${v}`,
|
|
1407
|
+
right: (v) => `right:${v}`,
|
|
1391
1408
|
inset: (v) => `inset:${v}`,
|
|
1392
1409
|
"inset-x": (v) => `inset-inline:${v}`,
|
|
1393
1410
|
"inset-y": (v) => `inset-block:${v}`,
|
|
@@ -1395,17 +1412,66 @@ const runtimeArbitraryPropertyMap = {
|
|
|
1395
1412
|
"translate-y": (v) => `transform:translateY(${v})`,
|
|
1396
1413
|
rotate: (v) => `transform:rotate(${v})`,
|
|
1397
1414
|
scale: (v) => `transform:scale(${v})`,
|
|
1415
|
+
"skew-x": (v) => `transform:skewX(${v})`,
|
|
1416
|
+
"skew-y": (v) => `transform:skewY(${v})`,
|
|
1398
1417
|
rounded: (v) => `border-radius:${v}`,
|
|
1399
1418
|
border: (v) => `border-width:${v}`,
|
|
1419
|
+
"border-t": (v) => `border-top-width:${v}`,
|
|
1420
|
+
"border-b": (v) => `border-bottom-width:${v}`,
|
|
1421
|
+
"border-s": (v) => `border-inline-start-width:${v}`,
|
|
1422
|
+
"border-e": (v) => `border-inline-end-width:${v}`,
|
|
1423
|
+
"border-x": (v) => `border-inline-width:${v}`,
|
|
1424
|
+
"border-y": (v) => `border-block-width:${v}`,
|
|
1400
1425
|
opacity: (v) => `opacity:${v}`,
|
|
1401
1426
|
z: (v) => `z-index:${v}`,
|
|
1402
1427
|
leading: (v) => `line-height:${v}`,
|
|
1403
1428
|
tracking: (v) => `letter-spacing:${v}`,
|
|
1404
|
-
text: (v) =>
|
|
1429
|
+
text: (v) => {
|
|
1430
|
+
if (/^(start|center|end|justify|left|right|inline-start|inline-end)$/i.test(v)) {
|
|
1431
|
+
return `text-align:${v}`;
|
|
1432
|
+
}
|
|
1433
|
+
return /^(#[0-9a-fA-F]+|rgb|hsl|var\(--|currentColor|transparent)/i.test(v) ? `color:${v}` : `font-size:${v}`;
|
|
1434
|
+
},
|
|
1405
1435
|
bg: (v) => `background-color:${v}`,
|
|
1436
|
+
"bg-color": (v) => `background-color:${v}`,
|
|
1406
1437
|
overscroll: (v) => `overscroll-behavior:${v}`,
|
|
1407
1438
|
"overscroll-x": (v) => `overscroll-behavior-x:${v}`,
|
|
1408
|
-
"overscroll-y": (v) => `overscroll-behavior-y:${v}
|
|
1439
|
+
"overscroll-y": (v) => `overscroll-behavior-y:${v}`,
|
|
1440
|
+
fw: (v) => `font-weight:${v}`,
|
|
1441
|
+
"font-weight": (v) => `font-weight:${v}`,
|
|
1442
|
+
fs: (v) => `font-size:${v}`,
|
|
1443
|
+
"font-size": (v) => `font-size:${v}`,
|
|
1444
|
+
lh: (v) => `line-height:${v}`,
|
|
1445
|
+
"line-height": (v) => `line-height:${v}`,
|
|
1446
|
+
"text-align": (v) => `text-align:${v}`,
|
|
1447
|
+
align: (v) => `vertical-align:${v}`,
|
|
1448
|
+
"vertical-align": (v) => `vertical-align:${v}`,
|
|
1449
|
+
items: (v) => `align-items:${v}`,
|
|
1450
|
+
"align-items": (v) => `align-items:${v}`,
|
|
1451
|
+
justify: (v) => `justify-content:${v}`,
|
|
1452
|
+
"justify-content": (v) => `justify-content:${v}`,
|
|
1453
|
+
self: (v) => `align-self:${v}`,
|
|
1454
|
+
"align-self": (v) => `align-self:${v}`,
|
|
1455
|
+
content: (v) => `align-content:${v}`,
|
|
1456
|
+
"align-content": (v) => `align-content:${v}`,
|
|
1457
|
+
d: (v) => `display:${v}`,
|
|
1458
|
+
display: (v) => `display:${v}`,
|
|
1459
|
+
pos: (v) => `position:${v}`,
|
|
1460
|
+
position: (v) => `position:${v}`,
|
|
1461
|
+
aspect: (v) => `aspect-ratio:${v}`,
|
|
1462
|
+
"aspect-ratio": (v) => `aspect-ratio:${v}`,
|
|
1463
|
+
cursor: (v) => `cursor:${v}`,
|
|
1464
|
+
select: (v) => `user-select:${v}`,
|
|
1465
|
+
"user-select": (v) => `user-select:${v}`,
|
|
1466
|
+
pointer: (v) => `pointer-events:${v}`,
|
|
1467
|
+
"pointer-events": (v) => `pointer-events:${v}`,
|
|
1468
|
+
fit: (v) => `object-fit:${v}`,
|
|
1469
|
+
"object-fit": (v) => `object-fit:${v}`,
|
|
1470
|
+
overflow: (v) => `overflow:${v}`,
|
|
1471
|
+
"overflow-x": (v) => `overflow-x:${v}`,
|
|
1472
|
+
"overflow-y": (v) => `overflow-y:${v}`,
|
|
1473
|
+
shadow: (v) => `box-shadow:${v}`,
|
|
1474
|
+
"box-shadow": (v) => `box-shadow:${v}`
|
|
1409
1475
|
};
|
|
1410
1476
|
const runtimeBreakpoints = {
|
|
1411
1477
|
sm: "36rem",
|
|
@@ -1428,39 +1494,86 @@ const runtimeStateSelectors = {
|
|
|
1428
1494
|
odd: ":nth-child(odd)",
|
|
1429
1495
|
even: ":nth-child(even)"
|
|
1430
1496
|
};
|
|
1497
|
+
function parseModifiersAndUtility(className) {
|
|
1498
|
+
const parts = [];
|
|
1499
|
+
let bracketDepth = 0;
|
|
1500
|
+
let current = "";
|
|
1501
|
+
for (let i = 0; i < className.length; i++) {
|
|
1502
|
+
const ch = className[i];
|
|
1503
|
+
if (ch === "[")
|
|
1504
|
+
bracketDepth++;
|
|
1505
|
+
else if (ch === "]")
|
|
1506
|
+
bracketDepth--;
|
|
1507
|
+
if (ch === ":" && bracketDepth === 0) {
|
|
1508
|
+
parts.push(current);
|
|
1509
|
+
current = "";
|
|
1510
|
+
}
|
|
1511
|
+
else {
|
|
1512
|
+
current += ch;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
parts.push(current);
|
|
1516
|
+
const utility = parts.pop() ?? "";
|
|
1517
|
+
return { modifiers: parts, utility };
|
|
1518
|
+
}
|
|
1431
1519
|
function injectArbitraryClass(className) {
|
|
1432
1520
|
if (injectedArbitraryRules.has(className))
|
|
1433
1521
|
return;
|
|
1434
1522
|
injectedArbitraryRules.add(className);
|
|
1435
|
-
const
|
|
1436
|
-
const utility = parts.pop();
|
|
1523
|
+
const { modifiers, utility } = parseModifiersAndUtility(className);
|
|
1437
1524
|
if (!utility)
|
|
1438
1525
|
return;
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1526
|
+
let prop;
|
|
1527
|
+
let val;
|
|
1528
|
+
let isNegative = false;
|
|
1529
|
+
const bracketMatch = utility.match(/^\[([a-zA-Z0-9_-]+):(.+)\]$/);
|
|
1530
|
+
if (bracketMatch) {
|
|
1531
|
+
prop = bracketMatch[1];
|
|
1532
|
+
if (!prop.startsWith("-")) {
|
|
1533
|
+
prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1534
|
+
}
|
|
1535
|
+
val = bracketMatch[2];
|
|
1536
|
+
}
|
|
1537
|
+
else {
|
|
1538
|
+
const match = utility.match(/^(-)?([a-zA-Z0-9_-]+)-\[(.+)\]$/);
|
|
1539
|
+
if (!match)
|
|
1540
|
+
return;
|
|
1541
|
+
isNegative = Boolean(match[1]);
|
|
1542
|
+
prop = match[2];
|
|
1543
|
+
val = match[3];
|
|
1544
|
+
// If leading hyphen was part of a vendor prefix (-webkit-, -moz-, -ms-, -o-), treat it as part of prop
|
|
1545
|
+
if (isNegative && /^(webkit|moz|ms|o)-/i.test(prop)) {
|
|
1546
|
+
prop = `-${prop}`;
|
|
1547
|
+
isNegative = false;
|
|
1548
|
+
}
|
|
1549
|
+
else {
|
|
1550
|
+
prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
// Convert unescaped underscores to spaces (e.g. shadow-[0_4px_6px_rgba(...)])
|
|
1554
|
+
val = val
|
|
1555
|
+
.replace(/(?<!\\)_/g, " ")
|
|
1556
|
+
.replace(/\\_/g, "_")
|
|
1557
|
+
.trim();
|
|
1448
1558
|
if (isNegative && !val.startsWith("-")) {
|
|
1449
1559
|
val = `-${val}`;
|
|
1450
1560
|
}
|
|
1451
|
-
const
|
|
1561
|
+
const resolver = runtimeArbitraryPropertyMap[prop];
|
|
1562
|
+
const declarations = resolver ? resolver(val) : `${prop}:${val}`;
|
|
1452
1563
|
const escaped = escapeArbitraryClass(className);
|
|
1453
1564
|
let selector = `.${escaped}`;
|
|
1454
1565
|
let stateSelector = "";
|
|
1455
1566
|
let themeVariant = "";
|
|
1456
1567
|
let breakpointVariant = "";
|
|
1457
|
-
for (const v of
|
|
1568
|
+
for (const v of modifiers) {
|
|
1458
1569
|
if (v === "dark" || v === "light")
|
|
1459
1570
|
themeVariant = v;
|
|
1460
1571
|
else if (runtimeBreakpoints[v])
|
|
1461
1572
|
breakpointVariant = v;
|
|
1462
1573
|
else if (runtimeStateSelectors[v])
|
|
1463
1574
|
stateSelector += runtimeStateSelectors[v];
|
|
1575
|
+
else if (v === "group-hover")
|
|
1576
|
+
selector = `.group:hover .${escaped}`;
|
|
1464
1577
|
}
|
|
1465
1578
|
selector += stateSelector;
|
|
1466
1579
|
let rule = `${selector}{${declarations}}`;
|
|
@@ -1485,11 +1598,11 @@ function injectArbitraryClass(className) {
|
|
|
1485
1598
|
}
|
|
1486
1599
|
function processElementClasses(el) {
|
|
1487
1600
|
const classAttr = el.getAttribute("class");
|
|
1488
|
-
if (!classAttr || !classAttr.includes("
|
|
1601
|
+
if (!classAttr || !classAttr.includes("["))
|
|
1489
1602
|
return;
|
|
1490
1603
|
const tokens = classAttr.split(/\s+/);
|
|
1491
1604
|
for (const token of tokens) {
|
|
1492
|
-
if (token.includes("
|
|
1605
|
+
if (token.includes("[") && token.endsWith("]")) {
|
|
1493
1606
|
injectArbitraryClass(token);
|
|
1494
1607
|
}
|
|
1495
1608
|
}
|
|
@@ -1500,7 +1613,7 @@ function scanArbitraryDom(root = document) {
|
|
|
1500
1613
|
if (root instanceof Element) {
|
|
1501
1614
|
processElementClasses(root);
|
|
1502
1615
|
}
|
|
1503
|
-
root.querySelectorAll('[class*="
|
|
1616
|
+
root.querySelectorAll('[class*="["]').forEach(processElementClasses);
|
|
1504
1617
|
}
|
|
1505
1618
|
let mutationObserverStarted = false;
|
|
1506
1619
|
function setupArbitraryObserver() {
|
package/dist/aksara.js
CHANGED
|
@@ -1340,9 +1340,22 @@ function getArbitrarySheet() {
|
|
|
1340
1340
|
return null;
|
|
1341
1341
|
if (!arbitrarySheet) {
|
|
1342
1342
|
if ("adoptedStyleSheets" in document && typeof CSSStyleSheet !== "undefined") {
|
|
1343
|
-
|
|
1344
|
-
|
|
1343
|
+
try {
|
|
1344
|
+
arbitrarySheet = new CSSStyleSheet();
|
|
1345
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, arbitrarySheet];
|
|
1346
|
+
return arbitrarySheet;
|
|
1347
|
+
}
|
|
1348
|
+
catch {
|
|
1349
|
+
// Fallback to style tag below
|
|
1350
|
+
}
|
|
1345
1351
|
}
|
|
1352
|
+
let styleEl = document.getElementById("aksara-arbitrary-styles");
|
|
1353
|
+
if (!styleEl) {
|
|
1354
|
+
styleEl = document.createElement("style");
|
|
1355
|
+
styleEl.id = "aksara-arbitrary-styles";
|
|
1356
|
+
document.head?.appendChild(styleEl);
|
|
1357
|
+
}
|
|
1358
|
+
arbitrarySheet = styleEl.sheet;
|
|
1346
1359
|
}
|
|
1347
1360
|
return arbitrarySheet;
|
|
1348
1361
|
}
|
|
@@ -1376,6 +1389,8 @@ const runtimeArbitraryPropertyMap = {
|
|
|
1376
1389
|
gap: (v) => `gap:${v}`,
|
|
1377
1390
|
"row-gap": (v) => `row-gap:${v}`,
|
|
1378
1391
|
"col-gap": (v) => `column-gap:${v}`,
|
|
1392
|
+
"gap-y": (v) => `row-gap:${v}`,
|
|
1393
|
+
"gap-x": (v) => `column-gap:${v}`,
|
|
1379
1394
|
g: (v) => `--aksara-gutter-x:${v};--aksara-gutter-y:${v}`,
|
|
1380
1395
|
gx: (v) => `--aksara-gutter-x:${v}`,
|
|
1381
1396
|
gy: (v) => `--aksara-gutter-y:${v}`,
|
|
@@ -1389,6 +1404,8 @@ const runtimeArbitraryPropertyMap = {
|
|
|
1389
1404
|
bottom: (v) => `inset-block-end:${v}`,
|
|
1390
1405
|
start: (v) => `inset-inline-start:${v}`,
|
|
1391
1406
|
end: (v) => `inset-inline-end:${v}`,
|
|
1407
|
+
left: (v) => `left:${v}`,
|
|
1408
|
+
right: (v) => `right:${v}`,
|
|
1392
1409
|
inset: (v) => `inset:${v}`,
|
|
1393
1410
|
"inset-x": (v) => `inset-inline:${v}`,
|
|
1394
1411
|
"inset-y": (v) => `inset-block:${v}`,
|
|
@@ -1396,17 +1413,66 @@ const runtimeArbitraryPropertyMap = {
|
|
|
1396
1413
|
"translate-y": (v) => `transform:translateY(${v})`,
|
|
1397
1414
|
rotate: (v) => `transform:rotate(${v})`,
|
|
1398
1415
|
scale: (v) => `transform:scale(${v})`,
|
|
1416
|
+
"skew-x": (v) => `transform:skewX(${v})`,
|
|
1417
|
+
"skew-y": (v) => `transform:skewY(${v})`,
|
|
1399
1418
|
rounded: (v) => `border-radius:${v}`,
|
|
1400
1419
|
border: (v) => `border-width:${v}`,
|
|
1420
|
+
"border-t": (v) => `border-top-width:${v}`,
|
|
1421
|
+
"border-b": (v) => `border-bottom-width:${v}`,
|
|
1422
|
+
"border-s": (v) => `border-inline-start-width:${v}`,
|
|
1423
|
+
"border-e": (v) => `border-inline-end-width:${v}`,
|
|
1424
|
+
"border-x": (v) => `border-inline-width:${v}`,
|
|
1425
|
+
"border-y": (v) => `border-block-width:${v}`,
|
|
1401
1426
|
opacity: (v) => `opacity:${v}`,
|
|
1402
1427
|
z: (v) => `z-index:${v}`,
|
|
1403
1428
|
leading: (v) => `line-height:${v}`,
|
|
1404
1429
|
tracking: (v) => `letter-spacing:${v}`,
|
|
1405
|
-
text: (v) =>
|
|
1430
|
+
text: (v) => {
|
|
1431
|
+
if (/^(start|center|end|justify|left|right|inline-start|inline-end)$/i.test(v)) {
|
|
1432
|
+
return `text-align:${v}`;
|
|
1433
|
+
}
|
|
1434
|
+
return /^(#[0-9a-fA-F]+|rgb|hsl|var\(--|currentColor|transparent)/i.test(v) ? `color:${v}` : `font-size:${v}`;
|
|
1435
|
+
},
|
|
1406
1436
|
bg: (v) => `background-color:${v}`,
|
|
1437
|
+
"bg-color": (v) => `background-color:${v}`,
|
|
1407
1438
|
overscroll: (v) => `overscroll-behavior:${v}`,
|
|
1408
1439
|
"overscroll-x": (v) => `overscroll-behavior-x:${v}`,
|
|
1409
|
-
"overscroll-y": (v) => `overscroll-behavior-y:${v}
|
|
1440
|
+
"overscroll-y": (v) => `overscroll-behavior-y:${v}`,
|
|
1441
|
+
fw: (v) => `font-weight:${v}`,
|
|
1442
|
+
"font-weight": (v) => `font-weight:${v}`,
|
|
1443
|
+
fs: (v) => `font-size:${v}`,
|
|
1444
|
+
"font-size": (v) => `font-size:${v}`,
|
|
1445
|
+
lh: (v) => `line-height:${v}`,
|
|
1446
|
+
"line-height": (v) => `line-height:${v}`,
|
|
1447
|
+
"text-align": (v) => `text-align:${v}`,
|
|
1448
|
+
align: (v) => `vertical-align:${v}`,
|
|
1449
|
+
"vertical-align": (v) => `vertical-align:${v}`,
|
|
1450
|
+
items: (v) => `align-items:${v}`,
|
|
1451
|
+
"align-items": (v) => `align-items:${v}`,
|
|
1452
|
+
justify: (v) => `justify-content:${v}`,
|
|
1453
|
+
"justify-content": (v) => `justify-content:${v}`,
|
|
1454
|
+
self: (v) => `align-self:${v}`,
|
|
1455
|
+
"align-self": (v) => `align-self:${v}`,
|
|
1456
|
+
content: (v) => `align-content:${v}`,
|
|
1457
|
+
"align-content": (v) => `align-content:${v}`,
|
|
1458
|
+
d: (v) => `display:${v}`,
|
|
1459
|
+
display: (v) => `display:${v}`,
|
|
1460
|
+
pos: (v) => `position:${v}`,
|
|
1461
|
+
position: (v) => `position:${v}`,
|
|
1462
|
+
aspect: (v) => `aspect-ratio:${v}`,
|
|
1463
|
+
"aspect-ratio": (v) => `aspect-ratio:${v}`,
|
|
1464
|
+
cursor: (v) => `cursor:${v}`,
|
|
1465
|
+
select: (v) => `user-select:${v}`,
|
|
1466
|
+
"user-select": (v) => `user-select:${v}`,
|
|
1467
|
+
pointer: (v) => `pointer-events:${v}`,
|
|
1468
|
+
"pointer-events": (v) => `pointer-events:${v}`,
|
|
1469
|
+
fit: (v) => `object-fit:${v}`,
|
|
1470
|
+
"object-fit": (v) => `object-fit:${v}`,
|
|
1471
|
+
overflow: (v) => `overflow:${v}`,
|
|
1472
|
+
"overflow-x": (v) => `overflow-x:${v}`,
|
|
1473
|
+
"overflow-y": (v) => `overflow-y:${v}`,
|
|
1474
|
+
shadow: (v) => `box-shadow:${v}`,
|
|
1475
|
+
"box-shadow": (v) => `box-shadow:${v}`
|
|
1410
1476
|
};
|
|
1411
1477
|
const runtimeBreakpoints = {
|
|
1412
1478
|
sm: "36rem",
|
|
@@ -1429,39 +1495,86 @@ const runtimeStateSelectors = {
|
|
|
1429
1495
|
odd: ":nth-child(odd)",
|
|
1430
1496
|
even: ":nth-child(even)"
|
|
1431
1497
|
};
|
|
1498
|
+
function parseModifiersAndUtility(className) {
|
|
1499
|
+
const parts = [];
|
|
1500
|
+
let bracketDepth = 0;
|
|
1501
|
+
let current = "";
|
|
1502
|
+
for (let i = 0; i < className.length; i++) {
|
|
1503
|
+
const ch = className[i];
|
|
1504
|
+
if (ch === "[")
|
|
1505
|
+
bracketDepth++;
|
|
1506
|
+
else if (ch === "]")
|
|
1507
|
+
bracketDepth--;
|
|
1508
|
+
if (ch === ":" && bracketDepth === 0) {
|
|
1509
|
+
parts.push(current);
|
|
1510
|
+
current = "";
|
|
1511
|
+
}
|
|
1512
|
+
else {
|
|
1513
|
+
current += ch;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
parts.push(current);
|
|
1517
|
+
const utility = parts.pop() ?? "";
|
|
1518
|
+
return { modifiers: parts, utility };
|
|
1519
|
+
}
|
|
1432
1520
|
function injectArbitraryClass(className) {
|
|
1433
1521
|
if (injectedArbitraryRules.has(className))
|
|
1434
1522
|
return;
|
|
1435
1523
|
injectedArbitraryRules.add(className);
|
|
1436
|
-
const
|
|
1437
|
-
const utility = parts.pop();
|
|
1524
|
+
const { modifiers, utility } = parseModifiersAndUtility(className);
|
|
1438
1525
|
if (!utility)
|
|
1439
1526
|
return;
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1527
|
+
let prop;
|
|
1528
|
+
let val;
|
|
1529
|
+
let isNegative = false;
|
|
1530
|
+
const bracketMatch = utility.match(/^\[([a-zA-Z0-9_-]+):(.+)\]$/);
|
|
1531
|
+
if (bracketMatch) {
|
|
1532
|
+
prop = bracketMatch[1];
|
|
1533
|
+
if (!prop.startsWith("-")) {
|
|
1534
|
+
prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1535
|
+
}
|
|
1536
|
+
val = bracketMatch[2];
|
|
1537
|
+
}
|
|
1538
|
+
else {
|
|
1539
|
+
const match = utility.match(/^(-)?([a-zA-Z0-9_-]+)-\[(.+)\]$/);
|
|
1540
|
+
if (!match)
|
|
1541
|
+
return;
|
|
1542
|
+
isNegative = Boolean(match[1]);
|
|
1543
|
+
prop = match[2];
|
|
1544
|
+
val = match[3];
|
|
1545
|
+
// If leading hyphen was part of a vendor prefix (-webkit-, -moz-, -ms-, -o-), treat it as part of prop
|
|
1546
|
+
if (isNegative && /^(webkit|moz|ms|o)-/i.test(prop)) {
|
|
1547
|
+
prop = `-${prop}`;
|
|
1548
|
+
isNegative = false;
|
|
1549
|
+
}
|
|
1550
|
+
else {
|
|
1551
|
+
prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
// Convert unescaped underscores to spaces (e.g. shadow-[0_4px_6px_rgba(...)])
|
|
1555
|
+
val = val
|
|
1556
|
+
.replace(/(?<!\\)_/g, " ")
|
|
1557
|
+
.replace(/\\_/g, "_")
|
|
1558
|
+
.trim();
|
|
1449
1559
|
if (isNegative && !val.startsWith("-")) {
|
|
1450
1560
|
val = `-${val}`;
|
|
1451
1561
|
}
|
|
1452
|
-
const
|
|
1562
|
+
const resolver = runtimeArbitraryPropertyMap[prop];
|
|
1563
|
+
const declarations = resolver ? resolver(val) : `${prop}:${val}`;
|
|
1453
1564
|
const escaped = escapeArbitraryClass(className);
|
|
1454
1565
|
let selector = `.${escaped}`;
|
|
1455
1566
|
let stateSelector = "";
|
|
1456
1567
|
let themeVariant = "";
|
|
1457
1568
|
let breakpointVariant = "";
|
|
1458
|
-
for (const v of
|
|
1569
|
+
for (const v of modifiers) {
|
|
1459
1570
|
if (v === "dark" || v === "light")
|
|
1460
1571
|
themeVariant = v;
|
|
1461
1572
|
else if (runtimeBreakpoints[v])
|
|
1462
1573
|
breakpointVariant = v;
|
|
1463
1574
|
else if (runtimeStateSelectors[v])
|
|
1464
1575
|
stateSelector += runtimeStateSelectors[v];
|
|
1576
|
+
else if (v === "group-hover")
|
|
1577
|
+
selector = `.group:hover .${escaped}`;
|
|
1465
1578
|
}
|
|
1466
1579
|
selector += stateSelector;
|
|
1467
1580
|
let rule = `${selector}{${declarations}}`;
|
|
@@ -1486,11 +1599,11 @@ function injectArbitraryClass(className) {
|
|
|
1486
1599
|
}
|
|
1487
1600
|
function processElementClasses(el) {
|
|
1488
1601
|
const classAttr = el.getAttribute("class");
|
|
1489
|
-
if (!classAttr || !classAttr.includes("
|
|
1602
|
+
if (!classAttr || !classAttr.includes("["))
|
|
1490
1603
|
return;
|
|
1491
1604
|
const tokens = classAttr.split(/\s+/);
|
|
1492
1605
|
for (const token of tokens) {
|
|
1493
|
-
if (token.includes("
|
|
1606
|
+
if (token.includes("[") && token.endsWith("]")) {
|
|
1494
1607
|
injectArbitraryClass(token);
|
|
1495
1608
|
}
|
|
1496
1609
|
}
|
|
@@ -1501,7 +1614,7 @@ function scanArbitraryDom(root = document) {
|
|
|
1501
1614
|
if (root instanceof Element) {
|
|
1502
1615
|
processElementClasses(root);
|
|
1503
1616
|
}
|
|
1504
|
-
root.querySelectorAll('[class*="
|
|
1617
|
+
root.querySelectorAll('[class*="["]').forEach(processElementClasses);
|
|
1505
1618
|
}
|
|
1506
1619
|
let mutationObserverStarted = false;
|
|
1507
1620
|
function setupArbitraryObserver() {
|