@karmo-co/drift-kit-public 24.1.0 → 24.3.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 +75 -6
- package/drift-kit.min.css +2 -2
- package/package.json +1 -1
package/components.js
CHANGED
|
@@ -3505,6 +3505,11 @@
|
|
|
3505
3505
|
session.reposition(); }
|
|
3506
3506
|
function sheetTitle() {
|
|
3507
3507
|
var existing = menu.querySelector('.dk-component-select__sheet-title');
|
|
3508
|
+
if (root.getAttribute('data-sheet-title') === 'hidden') {
|
|
3509
|
+
if (existing)
|
|
3510
|
+
existing.remove();
|
|
3511
|
+
return;
|
|
3512
|
+
}
|
|
3508
3513
|
var label = root.querySelector('.dk-component-select__label, .dk-component-input__label');
|
|
3509
3514
|
var text = label ? (label.textContent || '').replace('*', '').trim()
|
|
3510
3515
|
: (trigger.getAttribute('aria-label') || '').trim();
|
|
@@ -3707,6 +3712,10 @@
|
|
|
3707
3712
|
if (isOpen())
|
|
3708
3713
|
return;
|
|
3709
3714
|
root.setAttribute('data-open', '');
|
|
3715
|
+
if (root.getAttribute('data-sheet-size') === 'tall')
|
|
3716
|
+
menu.setAttribute('data-sheet-size', 'tall');
|
|
3717
|
+
else
|
|
3718
|
+
menu.removeAttribute('data-sheet-size');
|
|
3710
3719
|
session = dk.menu.open(menu, trigger, {
|
|
3711
3720
|
root: root, placement: 'bottom', offset: 6,
|
|
3712
3721
|
align: root.getAttribute('data-align') === 'end' ? 'end' : 'start',
|
|
@@ -5986,7 +5995,7 @@
|
|
|
5986
5995
|
function create(root, track) {
|
|
5987
5996
|
var pulls = new WeakMap();
|
|
5988
5997
|
var pres = null, loop = false, made = [], current = -1, lastReal = [];
|
|
5989
|
-
var scroller = null;
|
|
5998
|
+
var scroller = null, padL = 0;
|
|
5990
5999
|
var down = false, active = false, settling = false, dragged = false, startX = 0, startScroll = 0;
|
|
5991
6000
|
var raf = 0, quietT = 0, settleT = 0, dragT = 0;
|
|
5992
6001
|
function cards() { return itemsOf(track).filter(function (it) { return !it.hidden; }); }
|
|
@@ -5996,6 +6005,7 @@
|
|
|
5996
6005
|
return (r.left + r.width / 2 - track.getBoundingClientRect().left) / zoomOf(track) + track.scrollLeft - (pulls.get(card) || 0);
|
|
5997
6006
|
}
|
|
5998
6007
|
function startOf(card) { return cardMid(card) - card.offsetWidth / 2; }
|
|
6008
|
+
function restOf(card) { return startOf(card) - padL; }
|
|
5999
6009
|
function edges() {
|
|
6000
6010
|
var prev = root.querySelector(':scope > .' + P + '__prev');
|
|
6001
6011
|
var next = root.querySelector(':scope > .' + P + '__next');
|
|
@@ -6034,6 +6044,7 @@
|
|
|
6034
6044
|
}
|
|
6035
6045
|
function bleed() {
|
|
6036
6046
|
if (!root.hasAttribute('data-bleed')) {
|
|
6047
|
+
padL = 0;
|
|
6037
6048
|
root.style.removeProperty('--_bleed-l');
|
|
6038
6049
|
root.style.removeProperty('--_bleed-r');
|
|
6039
6050
|
return;
|
|
@@ -6041,7 +6052,8 @@
|
|
|
6041
6052
|
var z = zoomOf(track);
|
|
6042
6053
|
var b = edgeOf();
|
|
6043
6054
|
var w = root.getBoundingClientRect();
|
|
6044
|
-
|
|
6055
|
+
padL = Math.max(0, (w.left - b.left) / z);
|
|
6056
|
+
root.style.setProperty('--_bleed-l', padL + 'px');
|
|
6045
6057
|
root.style.setProperty('--_bleed-r', Math.max(0, (b.right - w.right) / z) + 'px');
|
|
6046
6058
|
}
|
|
6047
6059
|
function realIndex(i, list) {
|
|
@@ -6057,7 +6069,7 @@
|
|
|
6057
6069
|
var mid = track.scrollLeft + track.clientWidth / 2;
|
|
6058
6070
|
var best = 0, bd = Infinity;
|
|
6059
6071
|
list.forEach(function (card, i) {
|
|
6060
|
-
var d = pres === 'row' ? Math.abs(track.scrollLeft -
|
|
6072
|
+
var d = pres === 'row' ? Math.abs(track.scrollLeft - restOf(card)) : Math.abs(mid - cardMid(card));
|
|
6061
6073
|
if (d < bd) {
|
|
6062
6074
|
bd = d;
|
|
6063
6075
|
best = i;
|
|
@@ -6251,7 +6263,7 @@
|
|
|
6251
6263
|
var mid = track.scrollLeft + track.clientWidth / 2;
|
|
6252
6264
|
var best = null, bd = Infinity;
|
|
6253
6265
|
cards().forEach(function (card) {
|
|
6254
|
-
var d = pres === 'row' ? Math.abs(track.scrollLeft -
|
|
6266
|
+
var d = pres === 'row' ? Math.abs(track.scrollLeft - restOf(card)) : Math.abs(mid - cardMid(card));
|
|
6255
6267
|
if (d < bd) {
|
|
6256
6268
|
bd = d;
|
|
6257
6269
|
best = card;
|
|
@@ -6259,7 +6271,7 @@
|
|
|
6259
6271
|
});
|
|
6260
6272
|
settling = true;
|
|
6261
6273
|
if (best)
|
|
6262
|
-
track.scrollTo({ left: pres === 'row' ?
|
|
6274
|
+
track.scrollTo({ left: pres === 'row' ? restOf(best) : cardMid(best) - track.clientWidth / 2, behavior: smooth() });
|
|
6263
6275
|
settleT = setTimeout(onIdle, SETTLE);
|
|
6264
6276
|
dragT = setTimeout(function () { dragged = false; }, 0);
|
|
6265
6277
|
}
|
|
@@ -6313,6 +6325,7 @@
|
|
|
6313
6325
|
hit = m !== orig || orig.matches(FOCUSABLE) ? m : orig.querySelector(FOCUSABLE) || orig;
|
|
6314
6326
|
hit.click();
|
|
6315
6327
|
}
|
|
6328
|
+
function onDragStart(e) { e.preventDefault(); }
|
|
6316
6329
|
function onClick(e) {
|
|
6317
6330
|
if (dragged) {
|
|
6318
6331
|
e.preventDefault();
|
|
@@ -6345,6 +6358,7 @@
|
|
|
6345
6358
|
on(track, 'pointerup', onUp);
|
|
6346
6359
|
on(track, 'pointercancel', onUp);
|
|
6347
6360
|
on(track, 'click', onClick, true);
|
|
6361
|
+
on(track, 'dragstart', onDragStart);
|
|
6348
6362
|
on(root, 'click', onArrow);
|
|
6349
6363
|
on(window, 'pointerup', onWinUp);
|
|
6350
6364
|
on(window, 'pointercancel', onWinUp);
|
|
@@ -6375,6 +6389,37 @@
|
|
|
6375
6389
|
}) : null;
|
|
6376
6390
|
if (mo)
|
|
6377
6391
|
mo.observe(root, { attributes: true, attributeFilter: ['data-presentation', 'data-presentation-fixed', 'data-device', 'data-loop', 'data-bleed'] });
|
|
6392
|
+
function arrowLook() {
|
|
6393
|
+
var given = root.getAttribute('data-arrow-look');
|
|
6394
|
+
if (given === 'solid' || given === 'raised-inverse')
|
|
6395
|
+
return given;
|
|
6396
|
+
var holder = root.closest('[data-theme]');
|
|
6397
|
+
return holder && holder.getAttribute('data-theme') === 'dark' ? 'raised-inverse' : 'solid';
|
|
6398
|
+
}
|
|
6399
|
+
function paintArrows() {
|
|
6400
|
+
var inverse = arrowLook() === 'raised-inverse';
|
|
6401
|
+
Array.prototype.forEach.call(root.children, function (b) {
|
|
6402
|
+
if (!b.classList.contains(P + '__prev') && !b.classList.contains(P + '__next'))
|
|
6403
|
+
return;
|
|
6404
|
+
var v = inverse ? 'raised' : 'solid';
|
|
6405
|
+
if (b.getAttribute('data-variant') !== v)
|
|
6406
|
+
b.setAttribute('data-variant', v);
|
|
6407
|
+
if (inverse && b.getAttribute('data-theme') !== 'light')
|
|
6408
|
+
b.setAttribute('data-theme', 'light');
|
|
6409
|
+
if (!inverse && b.hasAttribute('data-theme'))
|
|
6410
|
+
b.removeAttribute('data-theme');
|
|
6411
|
+
});
|
|
6412
|
+
}
|
|
6413
|
+
paintArrows();
|
|
6414
|
+
var themeMo = typeof MutationObserver !== 'undefined' ? new MutationObserver(function () {
|
|
6415
|
+
if (!root.isConnected) {
|
|
6416
|
+
teardown();
|
|
6417
|
+
return;
|
|
6418
|
+
}
|
|
6419
|
+
paintArrows();
|
|
6420
|
+
}) : null;
|
|
6421
|
+
if (themeMo)
|
|
6422
|
+
themeMo.observe(root.ownerDocument.documentElement, { attributes: true, subtree: true, attributeFilter: ['data-theme', 'data-arrow-look'] });
|
|
6378
6423
|
function teardown() {
|
|
6379
6424
|
bound.forEach(function (b) { b[0].removeEventListener(b[1], b[2], b[3]); });
|
|
6380
6425
|
bound = [];
|
|
@@ -6382,6 +6427,8 @@
|
|
|
6382
6427
|
ro.disconnect();
|
|
6383
6428
|
if (mo)
|
|
6384
6429
|
mo.disconnect();
|
|
6430
|
+
if (themeMo)
|
|
6431
|
+
themeMo.disconnect();
|
|
6385
6432
|
if (unwatch)
|
|
6386
6433
|
unwatch();
|
|
6387
6434
|
if (raf)
|
|
@@ -10118,8 +10165,9 @@
|
|
|
10118
10165
|
return qa(root, '.' + P + '__body .' + P + '__list:not([data-level="2"]) > li > .' + P + '__item');
|
|
10119
10166
|
}
|
|
10120
10167
|
function utilityRows() {
|
|
10121
|
-
return foot ? qa(foot, '.' + P + '__list > li > .' + P + '__item').filter(function (i) { return !i.classList.contains(P + '__toggle'); }) : [];
|
|
10168
|
+
return foot ? qa(foot, '.' + P + '__list > li:not([data-rail-only]) > .' + P + '__item').filter(function (i) { return !i.classList.contains(P + '__toggle'); }) : [];
|
|
10122
10169
|
}
|
|
10170
|
+
function railOnlyRows() { return foot ? qa(foot, '.' + P + '__list > li[data-rail-only]') : []; }
|
|
10123
10171
|
function account() { return q(root, '.' + P + '__account'); }
|
|
10124
10172
|
function railOnly(el) { return !el.closest('.' + P + '__panel'); }
|
|
10125
10173
|
function decorate() {
|
|
@@ -10881,6 +10929,24 @@
|
|
|
10881
10929
|
});
|
|
10882
10930
|
});
|
|
10883
10931
|
}
|
|
10932
|
+
function syncMark() {
|
|
10933
|
+
var logo = q(root, '.' + P + '__mark > .dk-component-logo');
|
|
10934
|
+
if (!logo || logo.getAttribute('data-rendered') === 'react')
|
|
10935
|
+
return;
|
|
10936
|
+
var own = logo.getAttribute('data-sb-lockup') || logo.getAttribute('data-lockup');
|
|
10937
|
+
if (own !== 'symbol-text')
|
|
10938
|
+
return;
|
|
10939
|
+
var want = isCollapsed() && isRail() ? 'symbol' : own;
|
|
10940
|
+
if (logo.getAttribute('data-lockup') === want)
|
|
10941
|
+
return;
|
|
10942
|
+
mute(function () {
|
|
10943
|
+
if (want === own)
|
|
10944
|
+
logo.removeAttribute('data-sb-lockup');
|
|
10945
|
+
else
|
|
10946
|
+
logo.setAttribute('data-sb-lockup', own);
|
|
10947
|
+
logo.setAttribute('data-lockup', want);
|
|
10948
|
+
});
|
|
10949
|
+
}
|
|
10884
10950
|
function setCollapsed(on, fromUser) {
|
|
10885
10951
|
if (on === isCollapsed())
|
|
10886
10952
|
return;
|
|
@@ -10909,6 +10975,7 @@
|
|
|
10909
10975
|
if (now && root.hasAttribute('data-rising'))
|
|
10910
10976
|
mute(function () { root.removeAttribute('data-rising'); });
|
|
10911
10977
|
wasCollapsed = now;
|
|
10978
|
+
syncMark();
|
|
10912
10979
|
syncToggles();
|
|
10913
10980
|
syncTips();
|
|
10914
10981
|
syncGroups();
|
|
@@ -10963,6 +11030,7 @@
|
|
|
10963
11030
|
var shown = needMore ? kept.slice(0, Math.max(room - 1, 0)) : kept;
|
|
10964
11031
|
var rest = all.filter(function (r) { return shown.indexOf(r) === -1; });
|
|
10965
11032
|
rest.forEach(function (r) { r.closest('li').setAttribute('data-bar-hidden', ''); });
|
|
11033
|
+
railOnlyRows().forEach(function (li) { li.setAttribute('data-bar-hidden', ''); });
|
|
10966
11034
|
moreRows = needMore ? rest.concat(utils) : [];
|
|
10967
11035
|
ensureMore();
|
|
10968
11036
|
if (!more)
|
|
@@ -11185,6 +11253,7 @@
|
|
|
11185
11253
|
clearance();
|
|
11186
11254
|
syncGroups();
|
|
11187
11255
|
syncPanel();
|
|
11256
|
+
syncMark();
|
|
11188
11257
|
syncToggles();
|
|
11189
11258
|
syncTips();
|
|
11190
11259
|
paint(!changed && ready);
|