@abydahana/aksara-ui 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/aksara.css +399 -35
- package/dist/aksara.d.ts +4 -0
- package/dist/aksara.esm.js +136 -1
- package/dist/aksara.js +136 -1
- package/dist/aksara.min.css +1 -1
- package/dist/aksara.min.js +1 -1
- package/dist/components/data/bento.d.ts +50 -0
- package/dist/components/data/bento.js +45 -0
- package/dist/components/data/index.d.ts +2 -0
- package/dist/components/data/index.js +2 -0
- package/dist/components/data/timeline.d.ts +29 -0
- package/dist/components/data/timeline.js +29 -0
- package/dist/components/feedback/index.d.ts +1 -0
- package/dist/components/feedback/index.js +1 -0
- package/dist/components/feedback/skeleton.d.ts +23 -0
- package/dist/components/feedback/skeleton.js +25 -0
- package/package.json +8 -6
package/dist/aksara.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Aksara UI
|
|
1
|
+
/*! Aksara UI v1.0.0 | Static CSS, no JIT, TypeScript */
|
|
2
2
|
const registry = new Map();
|
|
3
3
|
const instances = new Set();
|
|
4
4
|
const focusableSelector = [
|
|
@@ -1522,6 +1522,76 @@ function setupArbitraryObserver() {
|
|
|
1522
1522
|
attributeFilter: ["class"]
|
|
1523
1523
|
});
|
|
1524
1524
|
}
|
|
1525
|
+
let currentTheme = "system";
|
|
1526
|
+
function getSystemTheme() {
|
|
1527
|
+
if (typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
1528
|
+
return "dark";
|
|
1529
|
+
}
|
|
1530
|
+
return "light";
|
|
1531
|
+
}
|
|
1532
|
+
function applyTheme(theme) {
|
|
1533
|
+
if (typeof document === "undefined")
|
|
1534
|
+
return;
|
|
1535
|
+
const root = document.documentElement;
|
|
1536
|
+
const effectiveTheme = theme === "system" ? getSystemTheme() : theme;
|
|
1537
|
+
root.setAttribute("data-theme", effectiveTheme);
|
|
1538
|
+
if (effectiveTheme === "dark") {
|
|
1539
|
+
root.classList.add("dark");
|
|
1540
|
+
root.classList.remove("light");
|
|
1541
|
+
}
|
|
1542
|
+
else {
|
|
1543
|
+
root.classList.add("light");
|
|
1544
|
+
root.classList.remove("dark");
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
function setupClipboard(root = document) {
|
|
1548
|
+
if (typeof document === "undefined")
|
|
1549
|
+
return;
|
|
1550
|
+
root.querySelectorAll("[data-clipboard]").forEach((trigger) => {
|
|
1551
|
+
if (trigger.dataset.aksaraClipboardBound)
|
|
1552
|
+
return;
|
|
1553
|
+
trigger.dataset.aksaraClipboardBound = "true";
|
|
1554
|
+
trigger.addEventListener("click", async (e) => {
|
|
1555
|
+
e.preventDefault();
|
|
1556
|
+
const targetSelector = trigger.getAttribute("data-clipboard");
|
|
1557
|
+
let textToCopy = "";
|
|
1558
|
+
if (targetSelector && targetSelector.startsWith("#")) {
|
|
1559
|
+
const targetEl = document.querySelector(targetSelector);
|
|
1560
|
+
if (targetEl) {
|
|
1561
|
+
textToCopy = targetEl.value ?? targetEl.textContent ?? "";
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
else if (targetSelector) {
|
|
1565
|
+
textToCopy = targetSelector;
|
|
1566
|
+
}
|
|
1567
|
+
else {
|
|
1568
|
+
textToCopy = trigger.getAttribute("data-clipboard-text") || trigger.textContent || "";
|
|
1569
|
+
}
|
|
1570
|
+
if (navigator.clipboard && textToCopy) {
|
|
1571
|
+
try {
|
|
1572
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
1573
|
+
const originalText = trigger.getAttribute("data-clipboard-original") || trigger.innerHTML;
|
|
1574
|
+
const successText = trigger.getAttribute("data-clipboard-success");
|
|
1575
|
+
if (successText) {
|
|
1576
|
+
if (!trigger.hasAttribute("data-clipboard-original")) {
|
|
1577
|
+
trigger.setAttribute("data-clipboard-original", originalText);
|
|
1578
|
+
}
|
|
1579
|
+
trigger.innerHTML = successText;
|
|
1580
|
+
setTimeout(() => {
|
|
1581
|
+
trigger.innerHTML = originalText;
|
|
1582
|
+
}, 2000);
|
|
1583
|
+
}
|
|
1584
|
+
trigger.classList.add("is-copied");
|
|
1585
|
+
setTimeout(() => trigger.classList.remove("is-copied"), 2000);
|
|
1586
|
+
emit(trigger, "clipboard:copy", { text: textToCopy });
|
|
1587
|
+
}
|
|
1588
|
+
catch {
|
|
1589
|
+
// ignore error
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1525
1595
|
export const Aksara = {
|
|
1526
1596
|
Modal,
|
|
1527
1597
|
Tooltip,
|
|
@@ -1568,7 +1638,72 @@ export const Aksara = {
|
|
|
1568
1638
|
const args = resolveArgs(target, options, ".offcanvas");
|
|
1569
1639
|
return createAll(args.target, Offcanvas, args.options);
|
|
1570
1640
|
},
|
|
1641
|
+
setTheme(theme) {
|
|
1642
|
+
currentTheme = theme;
|
|
1643
|
+
if (typeof localStorage !== "undefined") {
|
|
1644
|
+
try {
|
|
1645
|
+
localStorage.setItem("aksara-theme", theme);
|
|
1646
|
+
}
|
|
1647
|
+
catch {
|
|
1648
|
+
// ignore storage errors
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
applyTheme(theme);
|
|
1652
|
+
if (typeof document !== "undefined") {
|
|
1653
|
+
emit(document.documentElement, "theme:change", { theme });
|
|
1654
|
+
}
|
|
1655
|
+
return theme;
|
|
1656
|
+
},
|
|
1657
|
+
getTheme() {
|
|
1658
|
+
return currentTheme;
|
|
1659
|
+
},
|
|
1660
|
+
initTheme() {
|
|
1661
|
+
if (typeof localStorage !== "undefined") {
|
|
1662
|
+
try {
|
|
1663
|
+
const saved = (localStorage.getItem("aksara-theme") || localStorage.getItem("aksara-docs-theme"));
|
|
1664
|
+
if (saved && (saved === "light" || saved === "dark" || saved === "system")) {
|
|
1665
|
+
currentTheme = saved;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
catch {
|
|
1669
|
+
// ignore storage errors
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
applyTheme(currentTheme);
|
|
1673
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
1674
|
+
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
1675
|
+
if (currentTheme === "system") {
|
|
1676
|
+
applyTheme("system");
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
return currentTheme;
|
|
1681
|
+
},
|
|
1682
|
+
async clipboard(target, text) {
|
|
1683
|
+
if (typeof navigator === "undefined" || !navigator.clipboard)
|
|
1684
|
+
return false;
|
|
1685
|
+
let textToCopy = text ?? "";
|
|
1686
|
+
if (!textToCopy && typeof document !== "undefined") {
|
|
1687
|
+
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
1688
|
+
if (el) {
|
|
1689
|
+
textToCopy = el.value ?? el.textContent ?? "";
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
if (!textToCopy)
|
|
1693
|
+
return false;
|
|
1694
|
+
try {
|
|
1695
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
1696
|
+
return true;
|
|
1697
|
+
}
|
|
1698
|
+
catch {
|
|
1699
|
+
return false;
|
|
1700
|
+
}
|
|
1701
|
+
},
|
|
1571
1702
|
init(root = document) {
|
|
1703
|
+
if (root === document) {
|
|
1704
|
+
this.initTheme();
|
|
1705
|
+
}
|
|
1706
|
+
setupClipboard(root);
|
|
1572
1707
|
scanArbitraryDom(root);
|
|
1573
1708
|
setupArbitraryObserver();
|
|
1574
1709
|
createAll(root.querySelectorAll("[data-tooltip]"), Tooltip);
|
package/dist/aksara.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Aksara UI
|
|
1
|
+
/*! Aksara UI v1.0.0 | Static CSS, no JIT, TypeScript */
|
|
2
2
|
(function(){
|
|
3
3
|
const registry = new Map();
|
|
4
4
|
const instances = new Set();
|
|
@@ -1523,6 +1523,76 @@ function setupArbitraryObserver() {
|
|
|
1523
1523
|
attributeFilter: ["class"]
|
|
1524
1524
|
});
|
|
1525
1525
|
}
|
|
1526
|
+
let currentTheme = "system";
|
|
1527
|
+
function getSystemTheme() {
|
|
1528
|
+
if (typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
1529
|
+
return "dark";
|
|
1530
|
+
}
|
|
1531
|
+
return "light";
|
|
1532
|
+
}
|
|
1533
|
+
function applyTheme(theme) {
|
|
1534
|
+
if (typeof document === "undefined")
|
|
1535
|
+
return;
|
|
1536
|
+
const root = document.documentElement;
|
|
1537
|
+
const effectiveTheme = theme === "system" ? getSystemTheme() : theme;
|
|
1538
|
+
root.setAttribute("data-theme", effectiveTheme);
|
|
1539
|
+
if (effectiveTheme === "dark") {
|
|
1540
|
+
root.classList.add("dark");
|
|
1541
|
+
root.classList.remove("light");
|
|
1542
|
+
}
|
|
1543
|
+
else {
|
|
1544
|
+
root.classList.add("light");
|
|
1545
|
+
root.classList.remove("dark");
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
function setupClipboard(root = document) {
|
|
1549
|
+
if (typeof document === "undefined")
|
|
1550
|
+
return;
|
|
1551
|
+
root.querySelectorAll("[data-clipboard]").forEach((trigger) => {
|
|
1552
|
+
if (trigger.dataset.aksaraClipboardBound)
|
|
1553
|
+
return;
|
|
1554
|
+
trigger.dataset.aksaraClipboardBound = "true";
|
|
1555
|
+
trigger.addEventListener("click", async (e) => {
|
|
1556
|
+
e.preventDefault();
|
|
1557
|
+
const targetSelector = trigger.getAttribute("data-clipboard");
|
|
1558
|
+
let textToCopy = "";
|
|
1559
|
+
if (targetSelector && targetSelector.startsWith("#")) {
|
|
1560
|
+
const targetEl = document.querySelector(targetSelector);
|
|
1561
|
+
if (targetEl) {
|
|
1562
|
+
textToCopy = targetEl.value ?? targetEl.textContent ?? "";
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
else if (targetSelector) {
|
|
1566
|
+
textToCopy = targetSelector;
|
|
1567
|
+
}
|
|
1568
|
+
else {
|
|
1569
|
+
textToCopy = trigger.getAttribute("data-clipboard-text") || trigger.textContent || "";
|
|
1570
|
+
}
|
|
1571
|
+
if (navigator.clipboard && textToCopy) {
|
|
1572
|
+
try {
|
|
1573
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
1574
|
+
const originalText = trigger.getAttribute("data-clipboard-original") || trigger.innerHTML;
|
|
1575
|
+
const successText = trigger.getAttribute("data-clipboard-success");
|
|
1576
|
+
if (successText) {
|
|
1577
|
+
if (!trigger.hasAttribute("data-clipboard-original")) {
|
|
1578
|
+
trigger.setAttribute("data-clipboard-original", originalText);
|
|
1579
|
+
}
|
|
1580
|
+
trigger.innerHTML = successText;
|
|
1581
|
+
setTimeout(() => {
|
|
1582
|
+
trigger.innerHTML = originalText;
|
|
1583
|
+
}, 2000);
|
|
1584
|
+
}
|
|
1585
|
+
trigger.classList.add("is-copied");
|
|
1586
|
+
setTimeout(() => trigger.classList.remove("is-copied"), 2000);
|
|
1587
|
+
emit(trigger, "clipboard:copy", { text: textToCopy });
|
|
1588
|
+
}
|
|
1589
|
+
catch {
|
|
1590
|
+
// ignore error
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1526
1596
|
const Aksara = {
|
|
1527
1597
|
Modal,
|
|
1528
1598
|
Tooltip,
|
|
@@ -1569,7 +1639,72 @@ const Aksara = {
|
|
|
1569
1639
|
const args = resolveArgs(target, options, ".offcanvas");
|
|
1570
1640
|
return createAll(args.target, Offcanvas, args.options);
|
|
1571
1641
|
},
|
|
1642
|
+
setTheme(theme) {
|
|
1643
|
+
currentTheme = theme;
|
|
1644
|
+
if (typeof localStorage !== "undefined") {
|
|
1645
|
+
try {
|
|
1646
|
+
localStorage.setItem("aksara-theme", theme);
|
|
1647
|
+
}
|
|
1648
|
+
catch {
|
|
1649
|
+
// ignore storage errors
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
applyTheme(theme);
|
|
1653
|
+
if (typeof document !== "undefined") {
|
|
1654
|
+
emit(document.documentElement, "theme:change", { theme });
|
|
1655
|
+
}
|
|
1656
|
+
return theme;
|
|
1657
|
+
},
|
|
1658
|
+
getTheme() {
|
|
1659
|
+
return currentTheme;
|
|
1660
|
+
},
|
|
1661
|
+
initTheme() {
|
|
1662
|
+
if (typeof localStorage !== "undefined") {
|
|
1663
|
+
try {
|
|
1664
|
+
const saved = (localStorage.getItem("aksara-theme") || localStorage.getItem("aksara-docs-theme"));
|
|
1665
|
+
if (saved && (saved === "light" || saved === "dark" || saved === "system")) {
|
|
1666
|
+
currentTheme = saved;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
catch {
|
|
1670
|
+
// ignore storage errors
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
applyTheme(currentTheme);
|
|
1674
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
1675
|
+
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
1676
|
+
if (currentTheme === "system") {
|
|
1677
|
+
applyTheme("system");
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
return currentTheme;
|
|
1682
|
+
},
|
|
1683
|
+
async clipboard(target, text) {
|
|
1684
|
+
if (typeof navigator === "undefined" || !navigator.clipboard)
|
|
1685
|
+
return false;
|
|
1686
|
+
let textToCopy = text ?? "";
|
|
1687
|
+
if (!textToCopy && typeof document !== "undefined") {
|
|
1688
|
+
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
1689
|
+
if (el) {
|
|
1690
|
+
textToCopy = el.value ?? el.textContent ?? "";
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
if (!textToCopy)
|
|
1694
|
+
return false;
|
|
1695
|
+
try {
|
|
1696
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
1697
|
+
return true;
|
|
1698
|
+
}
|
|
1699
|
+
catch {
|
|
1700
|
+
return false;
|
|
1701
|
+
}
|
|
1702
|
+
},
|
|
1572
1703
|
init(root = document) {
|
|
1704
|
+
if (root === document) {
|
|
1705
|
+
this.initTheme();
|
|
1706
|
+
}
|
|
1707
|
+
setupClipboard(root);
|
|
1573
1708
|
scanArbitraryDom(root);
|
|
1574
1709
|
setupArbitraryObserver();
|
|
1575
1710
|
createAll(root.querySelectorAll("[data-tooltip]"), Tooltip);
|