@karmo-co/drift-kit-public 25.20.0 → 25.22.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 +53 -8
- 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);
|
|
@@ -7912,12 +7943,25 @@
|
|
|
7912
7943
|
svg.appendChild(defs);
|
|
7913
7944
|
el.appendChild(svg);
|
|
7914
7945
|
}
|
|
7946
|
+
function ended(el) {
|
|
7947
|
+
var state = el.getAttribute('data-animation');
|
|
7948
|
+
var turn = el.__dkShieldTurn = (el.__dkShieldTurn || 0) + 1;
|
|
7949
|
+
var list = el.getAnimations ? el.getAnimations({ subtree: true }) : [];
|
|
7950
|
+
return Promise.all(list.map(function (a) { return a.finished; })).then(function () { return true; }, function () { return false; })
|
|
7951
|
+
.then(function (ok) {
|
|
7952
|
+
if (!ok || el.__dkShieldTurn !== turn)
|
|
7953
|
+
return false;
|
|
7954
|
+
el.dispatchEvent(new CustomEvent('dk-component-shield:animation-end', { bubbles: true, detail: { animation: state } }));
|
|
7955
|
+
return true;
|
|
7956
|
+
});
|
|
7957
|
+
}
|
|
7915
7958
|
function play(el, state) {
|
|
7916
7959
|
if (el.getAttribute('data-animation') === state) {
|
|
7917
7960
|
el.removeAttribute('data-animation');
|
|
7918
7961
|
void el.offsetWidth;
|
|
7919
7962
|
}
|
|
7920
7963
|
el.setAttribute('data-animation', state);
|
|
7964
|
+
return ended(el);
|
|
7921
7965
|
}
|
|
7922
7966
|
function init(scope) {
|
|
7923
7967
|
var root = scope && scope.querySelectorAll ? scope : document;
|
|
@@ -7940,6 +7984,7 @@
|
|
|
7940
7984
|
}
|
|
7941
7985
|
api.init = init;
|
|
7942
7986
|
api.play = play;
|
|
7987
|
+
api.ended = ended;
|
|
7943
7988
|
document.addEventListener('DOMContentLoaded', function () { init(document); });
|
|
7944
7989
|
})();
|
|
7945
7990
|
})(typeof window !== 'undefined' ? window : undefined);
|