@karmo-co/drift-kit-public 25.18.1 → 25.18.3

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 CHANGED
@@ -6988,6 +6988,38 @@
6988
6988
  var ms = parseInt(el.getAttribute('data-dk-tooltip-delay'), 10);
6989
6989
  return (isNaN(ms) || ms < 0) ? tokenDelay() : ms;
6990
6990
  }
6991
+ function fit() {
6992
+ surface.style.width = '';
6993
+ if (label.hidden)
6994
+ return;
6995
+ var range = document.createRange && document.createRange();
6996
+ if (!range || typeof range.getClientRects !== 'function')
6997
+ return;
6998
+ range.selectNodeContents(label);
6999
+ var rects = range.getClientRects(), lines = {}, n = 0;
7000
+ for (var i = 0; i < rects.length; i++) {
7001
+ var r = rects[i];
7002
+ if (!r.width)
7003
+ continue;
7004
+ var k = Math.round(r.top);
7005
+ if (!lines[k]) {
7006
+ lines[k] = { l: r.left, r: r.right };
7007
+ n++;
7008
+ }
7009
+ else {
7010
+ lines[k].l = Math.min(lines[k].l, r.left);
7011
+ lines[k].r = Math.max(lines[k].r, r.right);
7012
+ }
7013
+ }
7014
+ if (n < 2)
7015
+ return;
7016
+ var widest = 0;
7017
+ for (var t in lines)
7018
+ widest = Math.max(widest, lines[t].r - lines[t].l);
7019
+ var spare = label.getBoundingClientRect().width - widest;
7020
+ if (spare > 1)
7021
+ surface.style.width = Math.ceil(surface.getBoundingClientRect().width - spare + 1) + 'px';
7022
+ }
6991
7023
  function place(el) {
6992
7024
  var r = dk.position(surface, el, {
6993
7025
  placement: el.getAttribute('data-dk-tooltip-placement') || 'top',
@@ -7057,6 +7089,7 @@
7057
7089
  dk.scope.adopt(b, el);
7058
7090
  el.setAttribute('aria-describedby', b.id);
7059
7091
  surface.style.transition = 'none';
7092
+ fit();
7060
7093
  place(el);
7061
7094
  if (instant)
7062
7095
  b.classList.add('dk-component-tooltip--visible');
@@ -8286,6 +8319,249 @@
8286
8319
  });
8287
8320
  })();
8288
8321
  })(typeof window !== 'undefined' ? window : undefined);
8322
+ (function (w) {
8323
+ if (!w)
8324
+ return;
8325
+ var d = (w.dk = w.dk || {});
8326
+ d.__loaded = d.__loaded || {};
8327
+ if (d.__loaded['components/confetti/behaviour.js'])
8328
+ return;
8329
+ d.__loaded['components/confetti/behaviour.js'] = true;
8330
+ (function () {
8331
+ 'use strict';
8332
+ var dk = (window.dk = window.dk || {});
8333
+ dk.component = dk.component || {};
8334
+ var api = dk.component.confetti = dk.component.confetti || {};
8335
+ var T = '--dk-component-confetti-';
8336
+ api.__bursts = api.__bursts || 0;
8337
+ function reduced() { return !!(dk.motion && dk.motion.reduced && dk.motion.reduced()); }
8338
+ function scopeOf(origin) { return origin && origin.nodeType === 1 ? origin : document.body; }
8339
+ function probe(host, css) {
8340
+ var p = document.createElement('span');
8341
+ p.className = 'dk-component-confetti';
8342
+ p.setAttribute('aria-hidden', 'true');
8343
+ p.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;transition:none;' + (css || '');
8344
+ host.appendChild(p);
8345
+ return p;
8346
+ }
8347
+ function read(scope) {
8348
+ var host = scopeOf(scope);
8349
+ var p = probe(host, 'width:var(' + T + 'size);transition-duration:var(' + T + 'duration);animation-duration:var(' + T + 'rain-duration)');
8350
+ var cs = getComputedStyle(p);
8351
+ var c = probe(host);
8352
+ var colours = [];
8353
+ for (var i = 1; i <= 8; i++) {
8354
+ var raw = cs.getPropertyValue(T + 'color-' + i).trim();
8355
+ if (!raw)
8356
+ break;
8357
+ c.style.color = 'var(' + T + 'color-' + i + ')';
8358
+ var got = getComputedStyle(c).color;
8359
+ colours.push(got && got !== 'rgba(0, 0, 0, 0)' ? got : raw);
8360
+ }
8361
+ var out = {
8362
+ colours: colours,
8363
+ size: parseFloat(cs.width) || 8,
8364
+ count: parseInt(cs.getPropertyValue(T + 'count'), 10) || 72,
8365
+ rainCount: parseInt(cs.getPropertyValue(T + 'rain-count'), 10) || 140,
8366
+ duration: (parseFloat(cs.transitionDuration) || 2.4) * 1000,
8367
+ rainDuration: (parseFloat(cs.animationDuration) || 3.6) * 1000,
8368
+ };
8369
+ p.parentNode.removeChild(p);
8370
+ c.parentNode.removeChild(c);
8371
+ return out;
8372
+ }
8373
+ api.colours = function (scope) { return read(scope).colours; };
8374
+ function shade(colour) {
8375
+ var m = /rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/.exec(colour);
8376
+ if (!m)
8377
+ return colour;
8378
+ return 'rgb(' + Math.round(m[1] * 0.88) + ', ' + Math.round(m[2] * 0.88) + ', ' + Math.round(m[3] * 0.88) + ')';
8379
+ }
8380
+ function pointOf(origin) {
8381
+ if (origin && typeof origin.x === 'number' && typeof origin.y === 'number' && origin.nodeType !== 1)
8382
+ return { x: origin.x, y: origin.y };
8383
+ var r = scopeOf(origin).getBoundingClientRect();
8384
+ return { x: r.left + r.width / 2, y: r.top + r.height / 2 };
8385
+ }
8386
+ function rnd(a, b) { return a + Math.random() * (b - a); }
8387
+ function piece(t, i) {
8388
+ var kind = Math.random();
8389
+ var s = t.size * rnd(0.7, 1.35);
8390
+ var colour = t.colours[i % t.colours.length];
8391
+ return {
8392
+ shape: kind < 0.12 ? 'dot' : kind < 0.32 ? 'ribbon' : 'rect',
8393
+ w: kind < 0.12 ? s * 0.8 : kind < 0.32 ? s * 0.38 : s,
8394
+ h: kind < 0.12 ? s * 0.8 : kind < 0.32 ? s * 1.9 : s * rnd(0.5, 0.75),
8395
+ colour: colour, back: shade(colour),
8396
+ rot: rnd(0, Math.PI * 2), vrot: rnd(-0.08, 0.08),
8397
+ tilt: rnd(0, Math.PI * 2), vtilt: rnd(0.05, 0.13),
8398
+ roll: rnd(0, Math.PI * 2), vroll: rnd(0.03, 0.1),
8399
+ sway: rnd(0, Math.PI * 2), vsway: rnd(0.03, 0.07), swayBy: rnd(0.4, 1.4),
8400
+ born: 0,
8401
+ };
8402
+ }
8403
+ function play(t, pieces, duration, motion) {
8404
+ api.__bursts++;
8405
+ var canvas = document.createElement('canvas');
8406
+ canvas.className = 'dk-component-confetti';
8407
+ canvas.setAttribute('aria-hidden', 'true');
8408
+ document.body.appendChild(canvas);
8409
+ var dpr = Math.min(window.devicePixelRatio || 1, 2);
8410
+ var vw = 0, vh = 0;
8411
+ function fit() {
8412
+ vw = window.innerWidth;
8413
+ vh = window.innerHeight;
8414
+ canvas.width = Math.round(vw * dpr);
8415
+ canvas.height = Math.round(vh * dpr);
8416
+ }
8417
+ fit();
8418
+ var ctx = canvas.getContext('2d');
8419
+ var start = null, last = null, raf = 0, resolve;
8420
+ var done = new Promise(function (r) { resolve = r; });
8421
+ function end() {
8422
+ cancelAnimationFrame(raf);
8423
+ window.removeEventListener('resize', fit);
8424
+ if (canvas.parentNode)
8425
+ canvas.parentNode.removeChild(canvas);
8426
+ resolve();
8427
+ }
8428
+ function frame(now) {
8429
+ if (start == null) {
8430
+ start = now;
8431
+ last = now;
8432
+ }
8433
+ var k = Math.min(3, (now - last) / (1000 / 60));
8434
+ last = now;
8435
+ var elapsed = now - start;
8436
+ var life = elapsed / duration;
8437
+ if (life >= 1) {
8438
+ end();
8439
+ return;
8440
+ }
8441
+ var fade = life < 0.75 ? 1 : 1 - (life - 0.75) / 0.25;
8442
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
8443
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
8444
+ ctx.globalAlpha = Math.max(0, fade);
8445
+ for (var j = 0; j < pieces.length; j++) {
8446
+ var p = pieces[j];
8447
+ if (elapsed < p.born)
8448
+ continue;
8449
+ p.vx *= Math.pow(motion.drag, k);
8450
+ p.vy = Math.min(p.vy * Math.pow(motion.drag, k) + motion.gravity * k, motion.terminal * p.fall);
8451
+ p.sway += p.vsway * k;
8452
+ p.x += (p.vx + Math.sin(p.sway) * p.swayBy) * k;
8453
+ p.y += p.vy * k;
8454
+ p.rot += p.vrot * k;
8455
+ p.tilt += p.vtilt * k;
8456
+ p.roll += p.vroll * k;
8457
+ if (p.y - p.h > vh || p.x < -40 || p.x > vw + 40)
8458
+ continue;
8459
+ var sx = Math.cos(p.roll), sy = Math.cos(p.tilt);
8460
+ ctx.setTransform(dpr, 0, 0, dpr, p.x * dpr, p.y * dpr);
8461
+ ctx.rotate(p.rot);
8462
+ ctx.scale(Math.abs(sx) < 0.06 ? 0.06 : sx, Math.abs(sy) < 0.06 ? 0.06 : sy);
8463
+ ctx.fillStyle = sx * sy < 0 ? p.back : p.colour;
8464
+ if (p.shape === 'dot') {
8465
+ ctx.beginPath();
8466
+ ctx.arc(0, 0, p.w / 2, 0, Math.PI * 2);
8467
+ ctx.fill();
8468
+ }
8469
+ else
8470
+ ctx.fillRect(-p.w / 2, -p.h / 2, p.w, p.h);
8471
+ }
8472
+ raf = requestAnimationFrame(frame);
8473
+ }
8474
+ window.addEventListener('resize', fit);
8475
+ raf = requestAnimationFrame(frame);
8476
+ return { done: done, stop: end };
8477
+ }
8478
+ var NONE = function () { return { done: Promise.resolve(), stop: function () { } }; };
8479
+ api.rain = function (scope, opts) {
8480
+ opts = opts || {};
8481
+ if (reduced() || typeof document === 'undefined')
8482
+ return NONE();
8483
+ var t = read(scope);
8484
+ if (!t.colours.length)
8485
+ return NONE();
8486
+ var w = window.innerWidth, h = window.innerHeight;
8487
+ var count = opts.count || Math.round(t.rainCount * Math.max(0.6, Math.min(1.6, w / 900)));
8488
+ var duration = opts.duration || t.rainDuration;
8489
+ var release = Math.min(700, duration * 0.25);
8490
+ var pieces = [];
8491
+ for (var i = 0; i < count; i++) {
8492
+ var p = piece(t, i);
8493
+ p.x = rnd(-0.02, 1.02) * w;
8494
+ p.y = -rnd(8, 0.08 * h + 8);
8495
+ p.vx = rnd(-1.2, 1.2);
8496
+ p.vy = rnd(2, 4);
8497
+ p.fall = rnd(0.75, 1.25);
8498
+ p.born = Math.random() * release;
8499
+ pieces.push(p);
8500
+ }
8501
+ var terminal = Math.max(4, h / (duration / 1000 * 60 * 0.55));
8502
+ return play(t, pieces, duration, { gravity: 0.16, drag: 0.99, terminal: terminal });
8503
+ };
8504
+ api.burst = function (origin, opts) {
8505
+ opts = opts || {};
8506
+ if (reduced() || typeof document === 'undefined')
8507
+ return NONE();
8508
+ var t = read(origin);
8509
+ if (!t.colours.length)
8510
+ return NONE();
8511
+ var count = opts.count || t.count;
8512
+ var duration = opts.duration || t.duration;
8513
+ var at = pointOf(origin);
8514
+ var pieces = [];
8515
+ for (var i = 0; i < count; i++) {
8516
+ var p = piece(t, i);
8517
+ var angle = (-90 + rnd(-70, 70)) * Math.PI / 180;
8518
+ var speed = rnd(7, 16);
8519
+ p.x = at.x;
8520
+ p.y = at.y;
8521
+ p.vx = Math.cos(angle) * speed;
8522
+ p.vy = Math.sin(angle) * speed;
8523
+ p.fall = rnd(0.8, 1.2);
8524
+ pieces.push(p);
8525
+ }
8526
+ return play(t, pieces, duration, { gravity: 0.3, drag: 0.985, terminal: 5.5 });
8527
+ };
8528
+ var FIRST = /feedback-badge-grow$/;
8529
+ var LAST = /feedback-badge-(draw|swap)$/;
8530
+ function celebrate(badge) {
8531
+ if (badge.getAttribute('data-celebrate') === 'burst')
8532
+ api.burst(badge);
8533
+ else
8534
+ api.rain(badge);
8535
+ }
8536
+ api.watch = function (badge) {
8537
+ if (!badge || badge.__dcConfetti)
8538
+ return;
8539
+ badge.__dcConfetti = true;
8540
+ var fired = false;
8541
+ badge.addEventListener('animationstart', function (e) {
8542
+ var ring = e.target === badge && FIRST.test(e.animationName);
8543
+ if (ring)
8544
+ fired = false;
8545
+ if (fired || !(ring || LAST.test(e.animationName)) || !badge.hasAttribute('data-celebrate'))
8546
+ return;
8547
+ fired = true;
8548
+ celebrate(badge);
8549
+ });
8550
+ if (badge.getAttribute('data-animation') !== 'enter' && badge.hasAttribute('data-celebrate')) {
8551
+ fired = true;
8552
+ celebrate(badge);
8553
+ }
8554
+ };
8555
+ api.init = function (root) {
8556
+ var scope = root && root.querySelectorAll ? root : document;
8557
+ Array.prototype.forEach.call(scope.querySelectorAll('.dk-component-feedback-badge[data-celebrate]'), api.watch);
8558
+ };
8559
+ if (document.readyState === 'loading')
8560
+ document.addEventListener('DOMContentLoaded', function () { api.init(document); });
8561
+ else
8562
+ api.init(document);
8563
+ })();
8564
+ })(typeof window !== 'undefined' ? window : undefined);
8289
8565
  (function (w) {
8290
8566
  if (!w)
8291
8567
  return;
@@ -11272,7 +11548,8 @@
11272
11548
  ind.hidden = false;
11273
11549
  ind.style.width = target.offsetWidth + 'px';
11274
11550
  ind.style.height = target.offsetHeight + 'px';
11275
- ind.style.translate = target.offsetLeft + 'px ' + target.offsetTop + 'px';
11551
+ var at = layoutIn(target, root) || { x: target.offsetLeft, y: target.offsetTop };
11552
+ ind.style.translate = at.x + 'px ' + at.y + 'px';
11276
11553
  ind.__placed = true;
11277
11554
  if (!animate || first) {
11278
11555
  void ind.offsetWidth;
@@ -12584,12 +12861,6 @@
12584
12861
  d.addEventListener('keydown', onKey);
12585
12862
  }
12586
12863
  }
12587
- function place() {
12588
- if (!sumBtn || !detail)
12589
- return;
12590
- var r = root.getBoundingClientRect(), b = sumBtn.getBoundingClientRect();
12591
- root.style.setProperty('--_ab-detail-x', Math.max(0, b.left - r.left) + 'px');
12592
- }
12593
12864
  function emit(on) { root.dispatchEvent(new CustomEvent(P + ':summary', { detail: { open: on }, bubbles: true })); }
12594
12865
  function open() {
12595
12866
  if (!detail)
@@ -12598,7 +12869,6 @@
12598
12869
  detail.removeAttribute('data-closing');
12599
12870
  if (detail.hasAttribute('data-open'))
12600
12871
  return;
12601
- place();
12602
12872
  backdrop(true);
12603
12873
  root.setAttribute('data-detail-open', '');
12604
12874
  detail.setAttribute('data-open', '');