@abydahana/aksara-ui 1.1.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/aksara.css CHANGED
@@ -26172,7 +26172,8 @@ textarea.form-control {
26172
26172
  line-height:1;
26173
26173
  overflow:visible;
26174
26174
  user-select:none;
26175
- flex-shrink:0
26175
+ flex-shrink:0;
26176
+ border-color:var(--aksara-bg-body)
26176
26177
  }
26177
26178
  .avatar-xs {
26178
26179
  width:1.5rem;
@@ -1339,9 +1339,22 @@ function getArbitrarySheet() {
1339
1339
  return null;
1340
1340
  if (!arbitrarySheet) {
1341
1341
  if ("adoptedStyleSheets" in document && typeof CSSStyleSheet !== "undefined") {
1342
- arbitrarySheet = new CSSStyleSheet();
1343
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, arbitrarySheet];
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
  }
@@ -1388,6 +1401,8 @@ const runtimeArbitraryPropertyMap = {
1388
1401
  bottom: (v) => `inset-block-end:${v}`,
1389
1402
  start: (v) => `inset-inline-start:${v}`,
1390
1403
  end: (v) => `inset-inline-end:${v}`,
1404
+ left: (v) => `left:${v}`,
1405
+ right: (v) => `right:${v}`,
1391
1406
  inset: (v) => `inset:${v}`,
1392
1407
  "inset-x": (v) => `inset-inline:${v}`,
1393
1408
  "inset-y": (v) => `inset-block:${v}`,
@@ -1395,17 +1410,66 @@ const runtimeArbitraryPropertyMap = {
1395
1410
  "translate-y": (v) => `transform:translateY(${v})`,
1396
1411
  rotate: (v) => `transform:rotate(${v})`,
1397
1412
  scale: (v) => `transform:scale(${v})`,
1413
+ "skew-x": (v) => `transform:skewX(${v})`,
1414
+ "skew-y": (v) => `transform:skewY(${v})`,
1398
1415
  rounded: (v) => `border-radius:${v}`,
1399
1416
  border: (v) => `border-width:${v}`,
1417
+ "border-t": (v) => `border-top-width:${v}`,
1418
+ "border-b": (v) => `border-bottom-width:${v}`,
1419
+ "border-s": (v) => `border-inline-start-width:${v}`,
1420
+ "border-e": (v) => `border-inline-end-width:${v}`,
1421
+ "border-x": (v) => `border-inline-width:${v}`,
1422
+ "border-y": (v) => `border-block-width:${v}`,
1400
1423
  opacity: (v) => `opacity:${v}`,
1401
1424
  z: (v) => `z-index:${v}`,
1402
1425
  leading: (v) => `line-height:${v}`,
1403
1426
  tracking: (v) => `letter-spacing:${v}`,
1404
- text: (v) => (/^(#[0-9a-fA-F]+|rgb|hsl)/.test(v) ? `color:${v}` : `font-size:${v}`),
1427
+ text: (v) => {
1428
+ if (/^(start|center|end|justify|left|right|inline-start|inline-end)$/i.test(v)) {
1429
+ return `text-align:${v}`;
1430
+ }
1431
+ return /^(#[0-9a-fA-F]+|rgb|hsl|var\(--|currentColor|transparent)/i.test(v) ? `color:${v}` : `font-size:${v}`;
1432
+ },
1405
1433
  bg: (v) => `background-color:${v}`,
1434
+ "bg-color": (v) => `background-color:${v}`,
1406
1435
  overscroll: (v) => `overscroll-behavior:${v}`,
1407
1436
  "overscroll-x": (v) => `overscroll-behavior-x:${v}`,
1408
- "overscroll-y": (v) => `overscroll-behavior-y:${v}`
1437
+ "overscroll-y": (v) => `overscroll-behavior-y:${v}`,
1438
+ fw: (v) => `font-weight:${v}`,
1439
+ "font-weight": (v) => `font-weight:${v}`,
1440
+ fs: (v) => `font-size:${v}`,
1441
+ "font-size": (v) => `font-size:${v}`,
1442
+ lh: (v) => `line-height:${v}`,
1443
+ "line-height": (v) => `line-height:${v}`,
1444
+ "text-align": (v) => `text-align:${v}`,
1445
+ align: (v) => `vertical-align:${v}`,
1446
+ "vertical-align": (v) => `vertical-align:${v}`,
1447
+ items: (v) => `align-items:${v}`,
1448
+ "align-items": (v) => `align-items:${v}`,
1449
+ justify: (v) => `justify-content:${v}`,
1450
+ "justify-content": (v) => `justify-content:${v}`,
1451
+ self: (v) => `align-self:${v}`,
1452
+ "align-self": (v) => `align-self:${v}`,
1453
+ content: (v) => `align-content:${v}`,
1454
+ "align-content": (v) => `align-content:${v}`,
1455
+ d: (v) => `display:${v}`,
1456
+ display: (v) => `display:${v}`,
1457
+ pos: (v) => `position:${v}`,
1458
+ position: (v) => `position:${v}`,
1459
+ aspect: (v) => `aspect-ratio:${v}`,
1460
+ "aspect-ratio": (v) => `aspect-ratio:${v}`,
1461
+ cursor: (v) => `cursor:${v}`,
1462
+ select: (v) => `user-select:${v}`,
1463
+ "user-select": (v) => `user-select:${v}`,
1464
+ pointer: (v) => `pointer-events:${v}`,
1465
+ "pointer-events": (v) => `pointer-events:${v}`,
1466
+ fit: (v) => `object-fit:${v}`,
1467
+ "object-fit": (v) => `object-fit:${v}`,
1468
+ overflow: (v) => `overflow:${v}`,
1469
+ "overflow-x": (v) => `overflow-x:${v}`,
1470
+ "overflow-y": (v) => `overflow-y:${v}`,
1471
+ shadow: (v) => `box-shadow:${v}`,
1472
+ "box-shadow": (v) => `box-shadow:${v}`
1409
1473
  };
1410
1474
  const runtimeBreakpoints = {
1411
1475
  sm: "36rem",
@@ -1428,39 +1492,86 @@ const runtimeStateSelectors = {
1428
1492
  odd: ":nth-child(odd)",
1429
1493
  even: ":nth-child(even)"
1430
1494
  };
1495
+ function parseModifiersAndUtility(className) {
1496
+ const parts = [];
1497
+ let bracketDepth = 0;
1498
+ let current = "";
1499
+ for (let i = 0; i < className.length; i++) {
1500
+ const ch = className[i];
1501
+ if (ch === "[")
1502
+ bracketDepth++;
1503
+ else if (ch === "]")
1504
+ bracketDepth--;
1505
+ if (ch === ":" && bracketDepth === 0) {
1506
+ parts.push(current);
1507
+ current = "";
1508
+ }
1509
+ else {
1510
+ current += ch;
1511
+ }
1512
+ }
1513
+ parts.push(current);
1514
+ const utility = parts.pop() ?? "";
1515
+ return { modifiers: parts, utility };
1516
+ }
1431
1517
  function injectArbitraryClass(className) {
1432
1518
  if (injectedArbitraryRules.has(className))
1433
1519
  return;
1434
1520
  injectedArbitraryRules.add(className);
1435
- const parts = className.split(":");
1436
- const utility = parts.pop();
1521
+ const { modifiers, utility } = parseModifiersAndUtility(className);
1437
1522
  if (!utility)
1438
1523
  return;
1439
- const match = utility.match(/^(-)?([a-zA-Z0-9_-]+)-\[(.+)\]$/);
1440
- if (!match)
1441
- return;
1442
- const isNegative = Boolean(match[1]);
1443
- const prop = match[2];
1444
- let val = match[3];
1445
- const resolver = runtimeArbitraryPropertyMap[prop];
1446
- if (!resolver)
1447
- return;
1524
+ let prop;
1525
+ let val;
1526
+ let isNegative = false;
1527
+ const bracketMatch = utility.match(/^\[([a-zA-Z0-9_-]+):(.+)\]$/);
1528
+ if (bracketMatch) {
1529
+ prop = bracketMatch[1];
1530
+ if (!prop.startsWith("-")) {
1531
+ prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1532
+ }
1533
+ val = bracketMatch[2];
1534
+ }
1535
+ else {
1536
+ const match = utility.match(/^(-)?([a-zA-Z0-9_-]+)-\[(.+)\]$/);
1537
+ if (!match)
1538
+ return;
1539
+ isNegative = Boolean(match[1]);
1540
+ prop = match[2];
1541
+ val = match[3];
1542
+ // If leading hyphen was part of a vendor prefix (-webkit-, -moz-, -ms-, -o-), treat it as part of prop
1543
+ if (isNegative && /^(webkit|moz|ms|o)-/i.test(prop)) {
1544
+ prop = `-${prop}`;
1545
+ isNegative = false;
1546
+ }
1547
+ else {
1548
+ prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1549
+ }
1550
+ }
1551
+ // Convert unescaped underscores to spaces (e.g. shadow-[0_4px_6px_rgba(...)])
1552
+ val = val
1553
+ .replace(/(?<!\\)_/g, " ")
1554
+ .replace(/\\_/g, "_")
1555
+ .trim();
1448
1556
  if (isNegative && !val.startsWith("-")) {
1449
1557
  val = `-${val}`;
1450
1558
  }
1451
- const declarations = resolver(val);
1559
+ const resolver = runtimeArbitraryPropertyMap[prop];
1560
+ const declarations = resolver ? resolver(val) : `${prop}:${val}`;
1452
1561
  const escaped = escapeArbitraryClass(className);
1453
1562
  let selector = `.${escaped}`;
1454
1563
  let stateSelector = "";
1455
1564
  let themeVariant = "";
1456
1565
  let breakpointVariant = "";
1457
- for (const v of parts) {
1566
+ for (const v of modifiers) {
1458
1567
  if (v === "dark" || v === "light")
1459
1568
  themeVariant = v;
1460
1569
  else if (runtimeBreakpoints[v])
1461
1570
  breakpointVariant = v;
1462
1571
  else if (runtimeStateSelectors[v])
1463
1572
  stateSelector += runtimeStateSelectors[v];
1573
+ else if (v === "group-hover")
1574
+ selector = `.group:hover .${escaped}`;
1464
1575
  }
1465
1576
  selector += stateSelector;
1466
1577
  let rule = `${selector}{${declarations}}`;
@@ -1485,11 +1596,11 @@ function injectArbitraryClass(className) {
1485
1596
  }
1486
1597
  function processElementClasses(el) {
1487
1598
  const classAttr = el.getAttribute("class");
1488
- if (!classAttr || !classAttr.includes("-["))
1599
+ if (!classAttr || !classAttr.includes("["))
1489
1600
  return;
1490
1601
  const tokens = classAttr.split(/\s+/);
1491
1602
  for (const token of tokens) {
1492
- if (token.includes("-[") && token.endsWith("]")) {
1603
+ if (token.includes("[") && token.endsWith("]")) {
1493
1604
  injectArbitraryClass(token);
1494
1605
  }
1495
1606
  }
@@ -1500,7 +1611,7 @@ function scanArbitraryDom(root = document) {
1500
1611
  if (root instanceof Element) {
1501
1612
  processElementClasses(root);
1502
1613
  }
1503
- root.querySelectorAll('[class*="-["]').forEach(processElementClasses);
1614
+ root.querySelectorAll('[class*="["]').forEach(processElementClasses);
1504
1615
  }
1505
1616
  let mutationObserverStarted = false;
1506
1617
  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
- arbitrarySheet = new CSSStyleSheet();
1344
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, arbitrarySheet];
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
  }
@@ -1389,6 +1402,8 @@ const runtimeArbitraryPropertyMap = {
1389
1402
  bottom: (v) => `inset-block-end:${v}`,
1390
1403
  start: (v) => `inset-inline-start:${v}`,
1391
1404
  end: (v) => `inset-inline-end:${v}`,
1405
+ left: (v) => `left:${v}`,
1406
+ right: (v) => `right:${v}`,
1392
1407
  inset: (v) => `inset:${v}`,
1393
1408
  "inset-x": (v) => `inset-inline:${v}`,
1394
1409
  "inset-y": (v) => `inset-block:${v}`,
@@ -1396,17 +1411,66 @@ const runtimeArbitraryPropertyMap = {
1396
1411
  "translate-y": (v) => `transform:translateY(${v})`,
1397
1412
  rotate: (v) => `transform:rotate(${v})`,
1398
1413
  scale: (v) => `transform:scale(${v})`,
1414
+ "skew-x": (v) => `transform:skewX(${v})`,
1415
+ "skew-y": (v) => `transform:skewY(${v})`,
1399
1416
  rounded: (v) => `border-radius:${v}`,
1400
1417
  border: (v) => `border-width:${v}`,
1418
+ "border-t": (v) => `border-top-width:${v}`,
1419
+ "border-b": (v) => `border-bottom-width:${v}`,
1420
+ "border-s": (v) => `border-inline-start-width:${v}`,
1421
+ "border-e": (v) => `border-inline-end-width:${v}`,
1422
+ "border-x": (v) => `border-inline-width:${v}`,
1423
+ "border-y": (v) => `border-block-width:${v}`,
1401
1424
  opacity: (v) => `opacity:${v}`,
1402
1425
  z: (v) => `z-index:${v}`,
1403
1426
  leading: (v) => `line-height:${v}`,
1404
1427
  tracking: (v) => `letter-spacing:${v}`,
1405
- text: (v) => (/^(#[0-9a-fA-F]+|rgb|hsl)/.test(v) ? `color:${v}` : `font-size:${v}`),
1428
+ text: (v) => {
1429
+ if (/^(start|center|end|justify|left|right|inline-start|inline-end)$/i.test(v)) {
1430
+ return `text-align:${v}`;
1431
+ }
1432
+ return /^(#[0-9a-fA-F]+|rgb|hsl|var\(--|currentColor|transparent)/i.test(v) ? `color:${v}` : `font-size:${v}`;
1433
+ },
1406
1434
  bg: (v) => `background-color:${v}`,
1435
+ "bg-color": (v) => `background-color:${v}`,
1407
1436
  overscroll: (v) => `overscroll-behavior:${v}`,
1408
1437
  "overscroll-x": (v) => `overscroll-behavior-x:${v}`,
1409
- "overscroll-y": (v) => `overscroll-behavior-y:${v}`
1438
+ "overscroll-y": (v) => `overscroll-behavior-y:${v}`,
1439
+ fw: (v) => `font-weight:${v}`,
1440
+ "font-weight": (v) => `font-weight:${v}`,
1441
+ fs: (v) => `font-size:${v}`,
1442
+ "font-size": (v) => `font-size:${v}`,
1443
+ lh: (v) => `line-height:${v}`,
1444
+ "line-height": (v) => `line-height:${v}`,
1445
+ "text-align": (v) => `text-align:${v}`,
1446
+ align: (v) => `vertical-align:${v}`,
1447
+ "vertical-align": (v) => `vertical-align:${v}`,
1448
+ items: (v) => `align-items:${v}`,
1449
+ "align-items": (v) => `align-items:${v}`,
1450
+ justify: (v) => `justify-content:${v}`,
1451
+ "justify-content": (v) => `justify-content:${v}`,
1452
+ self: (v) => `align-self:${v}`,
1453
+ "align-self": (v) => `align-self:${v}`,
1454
+ content: (v) => `align-content:${v}`,
1455
+ "align-content": (v) => `align-content:${v}`,
1456
+ d: (v) => `display:${v}`,
1457
+ display: (v) => `display:${v}`,
1458
+ pos: (v) => `position:${v}`,
1459
+ position: (v) => `position:${v}`,
1460
+ aspect: (v) => `aspect-ratio:${v}`,
1461
+ "aspect-ratio": (v) => `aspect-ratio:${v}`,
1462
+ cursor: (v) => `cursor:${v}`,
1463
+ select: (v) => `user-select:${v}`,
1464
+ "user-select": (v) => `user-select:${v}`,
1465
+ pointer: (v) => `pointer-events:${v}`,
1466
+ "pointer-events": (v) => `pointer-events:${v}`,
1467
+ fit: (v) => `object-fit:${v}`,
1468
+ "object-fit": (v) => `object-fit:${v}`,
1469
+ overflow: (v) => `overflow:${v}`,
1470
+ "overflow-x": (v) => `overflow-x:${v}`,
1471
+ "overflow-y": (v) => `overflow-y:${v}`,
1472
+ shadow: (v) => `box-shadow:${v}`,
1473
+ "box-shadow": (v) => `box-shadow:${v}`
1410
1474
  };
1411
1475
  const runtimeBreakpoints = {
1412
1476
  sm: "36rem",
@@ -1429,39 +1493,86 @@ const runtimeStateSelectors = {
1429
1493
  odd: ":nth-child(odd)",
1430
1494
  even: ":nth-child(even)"
1431
1495
  };
1496
+ function parseModifiersAndUtility(className) {
1497
+ const parts = [];
1498
+ let bracketDepth = 0;
1499
+ let current = "";
1500
+ for (let i = 0; i < className.length; i++) {
1501
+ const ch = className[i];
1502
+ if (ch === "[")
1503
+ bracketDepth++;
1504
+ else if (ch === "]")
1505
+ bracketDepth--;
1506
+ if (ch === ":" && bracketDepth === 0) {
1507
+ parts.push(current);
1508
+ current = "";
1509
+ }
1510
+ else {
1511
+ current += ch;
1512
+ }
1513
+ }
1514
+ parts.push(current);
1515
+ const utility = parts.pop() ?? "";
1516
+ return { modifiers: parts, utility };
1517
+ }
1432
1518
  function injectArbitraryClass(className) {
1433
1519
  if (injectedArbitraryRules.has(className))
1434
1520
  return;
1435
1521
  injectedArbitraryRules.add(className);
1436
- const parts = className.split(":");
1437
- const utility = parts.pop();
1522
+ const { modifiers, utility } = parseModifiersAndUtility(className);
1438
1523
  if (!utility)
1439
1524
  return;
1440
- const match = utility.match(/^(-)?([a-zA-Z0-9_-]+)-\[(.+)\]$/);
1441
- if (!match)
1442
- return;
1443
- const isNegative = Boolean(match[1]);
1444
- const prop = match[2];
1445
- let val = match[3];
1446
- const resolver = runtimeArbitraryPropertyMap[prop];
1447
- if (!resolver)
1448
- return;
1525
+ let prop;
1526
+ let val;
1527
+ let isNegative = false;
1528
+ const bracketMatch = utility.match(/^\[([a-zA-Z0-9_-]+):(.+)\]$/);
1529
+ if (bracketMatch) {
1530
+ prop = bracketMatch[1];
1531
+ if (!prop.startsWith("-")) {
1532
+ prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1533
+ }
1534
+ val = bracketMatch[2];
1535
+ }
1536
+ else {
1537
+ const match = utility.match(/^(-)?([a-zA-Z0-9_-]+)-\[(.+)\]$/);
1538
+ if (!match)
1539
+ return;
1540
+ isNegative = Boolean(match[1]);
1541
+ prop = match[2];
1542
+ val = match[3];
1543
+ // If leading hyphen was part of a vendor prefix (-webkit-, -moz-, -ms-, -o-), treat it as part of prop
1544
+ if (isNegative && /^(webkit|moz|ms|o)-/i.test(prop)) {
1545
+ prop = `-${prop}`;
1546
+ isNegative = false;
1547
+ }
1548
+ else {
1549
+ prop = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1550
+ }
1551
+ }
1552
+ // Convert unescaped underscores to spaces (e.g. shadow-[0_4px_6px_rgba(...)])
1553
+ val = val
1554
+ .replace(/(?<!\\)_/g, " ")
1555
+ .replace(/\\_/g, "_")
1556
+ .trim();
1449
1557
  if (isNegative && !val.startsWith("-")) {
1450
1558
  val = `-${val}`;
1451
1559
  }
1452
- const declarations = resolver(val);
1560
+ const resolver = runtimeArbitraryPropertyMap[prop];
1561
+ const declarations = resolver ? resolver(val) : `${prop}:${val}`;
1453
1562
  const escaped = escapeArbitraryClass(className);
1454
1563
  let selector = `.${escaped}`;
1455
1564
  let stateSelector = "";
1456
1565
  let themeVariant = "";
1457
1566
  let breakpointVariant = "";
1458
- for (const v of parts) {
1567
+ for (const v of modifiers) {
1459
1568
  if (v === "dark" || v === "light")
1460
1569
  themeVariant = v;
1461
1570
  else if (runtimeBreakpoints[v])
1462
1571
  breakpointVariant = v;
1463
1572
  else if (runtimeStateSelectors[v])
1464
1573
  stateSelector += runtimeStateSelectors[v];
1574
+ else if (v === "group-hover")
1575
+ selector = `.group:hover .${escaped}`;
1465
1576
  }
1466
1577
  selector += stateSelector;
1467
1578
  let rule = `${selector}{${declarations}}`;
@@ -1486,11 +1597,11 @@ function injectArbitraryClass(className) {
1486
1597
  }
1487
1598
  function processElementClasses(el) {
1488
1599
  const classAttr = el.getAttribute("class");
1489
- if (!classAttr || !classAttr.includes("-["))
1600
+ if (!classAttr || !classAttr.includes("["))
1490
1601
  return;
1491
1602
  const tokens = classAttr.split(/\s+/);
1492
1603
  for (const token of tokens) {
1493
- if (token.includes("-[") && token.endsWith("]")) {
1604
+ if (token.includes("[") && token.endsWith("]")) {
1494
1605
  injectArbitraryClass(token);
1495
1606
  }
1496
1607
  }
@@ -1501,7 +1612,7 @@ function scanArbitraryDom(root = document) {
1501
1612
  if (root instanceof Element) {
1502
1613
  processElementClasses(root);
1503
1614
  }
1504
- root.querySelectorAll('[class*="-["]').forEach(processElementClasses);
1615
+ root.querySelectorAll('[class*="["]').forEach(processElementClasses);
1505
1616
  }
1506
1617
  let mutationObserverStarted = false;
1507
1618
  function setupArbitraryObserver() {