@karmo-co/drift-kit-public 25.21.0 → 25.23.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/components.js +42 -11
- package/drift-kit.min.css +2 -2
- package/package.json +1 -1
package/components.js
CHANGED
|
@@ -556,6 +556,20 @@
|
|
|
556
556
|
setTimeout(function () { reveal(r); }, window.__DK_CASCADE_SAFETY_MS || 10000);
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
|
+
function live() {
|
|
560
|
+
var rule = '@keyframes dk-motion-cascade-fallback { }';
|
|
561
|
+
try {
|
|
562
|
+
var sheet = new CSSStyleSheet();
|
|
563
|
+
sheet.replaceSync(rule);
|
|
564
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.concat(sheet);
|
|
565
|
+
}
|
|
566
|
+
catch (e) {
|
|
567
|
+
var style = document.createElement('style');
|
|
568
|
+
style.textContent = rule;
|
|
569
|
+
(document.head || document.documentElement).appendChild(style);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
live();
|
|
559
573
|
if (document.readyState !== 'loading')
|
|
560
574
|
boot();
|
|
561
575
|
else
|
|
@@ -1509,17 +1523,30 @@
|
|
|
1509
1523
|
var shown = el === document.documentElement && document.body ? document.body : el;
|
|
1510
1524
|
return set(el, current(shown) === 'dark' ? 'light' : 'dark');
|
|
1511
1525
|
}
|
|
1512
|
-
function opted() {
|
|
1526
|
+
function opted(kind) {
|
|
1513
1527
|
var out = [];
|
|
1514
1528
|
var html = document.documentElement, body = document.body;
|
|
1515
|
-
if (html && html.getAttribute(FROM) ===
|
|
1529
|
+
if (html && html.getAttribute(FROM) === kind)
|
|
1516
1530
|
out.push(html);
|
|
1517
|
-
if (body && body.getAttribute(FROM) ===
|
|
1531
|
+
if (body && body.getAttribute(FROM) === kind)
|
|
1518
1532
|
out.push(body);
|
|
1519
1533
|
return out;
|
|
1520
1534
|
}
|
|
1535
|
+
var scheme = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
|
|
1536
|
+
function fromSystem() {
|
|
1537
|
+
if (!scheme)
|
|
1538
|
+
return;
|
|
1539
|
+
opted('system').forEach(function (el) { if (!el.__dkThemeChosen)
|
|
1540
|
+
set(el, scheme.matches ? 'dark' : 'light'); });
|
|
1541
|
+
}
|
|
1542
|
+
if (scheme) {
|
|
1543
|
+
if (scheme.addEventListener)
|
|
1544
|
+
scheme.addEventListener('change', fromSystem);
|
|
1545
|
+
else if (scheme.addListener)
|
|
1546
|
+
scheme.addListener(fromSystem);
|
|
1547
|
+
}
|
|
1521
1548
|
function fromUrl() {
|
|
1522
|
-
var els = opted();
|
|
1549
|
+
var els = opted('url');
|
|
1523
1550
|
if (!els.length)
|
|
1524
1551
|
return;
|
|
1525
1552
|
var q = null;
|
|
@@ -1535,8 +1562,10 @@
|
|
|
1535
1562
|
}
|
|
1536
1563
|
function flip(t) {
|
|
1537
1564
|
var host = t.closest('[' + FROM + ']') || document.querySelector('[' + FROM + ']');
|
|
1538
|
-
if (host)
|
|
1539
|
-
|
|
1565
|
+
if (!host)
|
|
1566
|
+
return;
|
|
1567
|
+
host.__dkThemeChosen = true;
|
|
1568
|
+
toggle(host);
|
|
1540
1569
|
}
|
|
1541
1570
|
function onClick(e) {
|
|
1542
1571
|
var t = e.target && e.target.closest ? e.target.closest('[data-theme-toggle]') : null;
|
|
@@ -1569,21 +1598,23 @@
|
|
|
1569
1598
|
t.setAttribute('tabindex', '0');
|
|
1570
1599
|
});
|
|
1571
1600
|
}
|
|
1572
|
-
dk.theme = { set: set, toggle: toggle, fromUrl: fromUrl, init: init };
|
|
1601
|
+
dk.theme = { set: set, toggle: toggle, fromUrl: fromUrl, fromSystem: fromSystem, init: init };
|
|
1573
1602
|
document.addEventListener('click', onClick);
|
|
1574
1603
|
document.addEventListener('keydown', onKey);
|
|
1604
|
+
fromSystem();
|
|
1575
1605
|
fromUrl();
|
|
1576
1606
|
if (!document.body && window.MutationObserver && document.documentElement) {
|
|
1577
1607
|
var early = new MutationObserver(function () {
|
|
1578
1608
|
if (!document.body)
|
|
1579
1609
|
return;
|
|
1580
1610
|
early.disconnect();
|
|
1611
|
+
fromSystem();
|
|
1581
1612
|
fromUrl();
|
|
1582
1613
|
});
|
|
1583
1614
|
early.observe(document.documentElement, { childList: true });
|
|
1584
1615
|
}
|
|
1585
1616
|
if (document.readyState === 'loading') {
|
|
1586
|
-
document.addEventListener('DOMContentLoaded', function () { fromUrl(); init(document); });
|
|
1617
|
+
document.addEventListener('DOMContentLoaded', function () { fromSystem(); fromUrl(); init(document); });
|
|
1587
1618
|
}
|
|
1588
1619
|
else {
|
|
1589
1620
|
init(document);
|
|
@@ -4603,7 +4634,7 @@
|
|
|
4603
4634
|
var node = scope || document;
|
|
4604
4635
|
if (node.matches && node.matches('.dk-component-select'))
|
|
4605
4636
|
initSelect(node);
|
|
4606
|
-
var nodes = node.querySelectorAll ? node.querySelectorAll('.dk-component-select') : [];
|
|
4637
|
+
var nodes = node.querySelectorAll ? node.querySelectorAll('.dk-component-select:not([data-dk-react])') : [];
|
|
4607
4638
|
Array.prototype.forEach.call(nodes, initSelect);
|
|
4608
4639
|
}
|
|
4609
4640
|
var dk = window.dk = window.dk || {};
|
|
@@ -6803,7 +6834,7 @@
|
|
|
6803
6834
|
var s = scope || document;
|
|
6804
6835
|
if (s.matches && s.matches('.' + P))
|
|
6805
6836
|
initRoot(s);
|
|
6806
|
-
Array.prototype.forEach.call(s.querySelectorAll('.' + P), initRoot);
|
|
6837
|
+
Array.prototype.forEach.call(s.querySelectorAll('.' + P + ':not([data-dk-react])'), initRoot);
|
|
6807
6838
|
}
|
|
6808
6839
|
function sync(root) { if (root)
|
|
6809
6840
|
initRoot(root); }
|
|
@@ -12373,7 +12404,7 @@
|
|
|
12373
12404
|
var s = scope || document;
|
|
12374
12405
|
if (s.matches && s.matches('.' + P))
|
|
12375
12406
|
initRoot(s);
|
|
12376
|
-
Array.prototype.forEach.call(s.querySelectorAll('.' + P), initRoot);
|
|
12407
|
+
Array.prototype.forEach.call(s.querySelectorAll('.' + P + ':not([data-dk-react])'), initRoot);
|
|
12377
12408
|
}
|
|
12378
12409
|
dk.component.sidebar = { init: init };
|
|
12379
12410
|
if (document.readyState !== 'loading')
|