kmaterialize 2.3.3-1.0.21 → 2.3.3-1.0.22

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Materialize v2.3.3-1.0.21 (https://materializeweb.com)
2
+ * Materialize v2.3.3-1.0.22 (https://materializeweb.com)
3
3
  * Copyright 2014-2026 Materialize
4
4
  * MIT License (https://raw.githubusercontent.com/materializecss/materialize/master/LICENSE)
5
5
  */
@@ -1430,13 +1430,24 @@ const _defaults$u = {
1430
1430
  class Kanban extends Component {
1431
1431
  _draggedCard = null;
1432
1432
  _dragSourceColumn = null;
1433
+ _dropPreview = null;
1434
+ _dragImage = null;
1435
+ _previewHeight = 64;
1433
1436
  _onDragStart = (event) => {
1434
1437
  const card = event.target?.closest('.kanban-card');
1435
- if (!card || !this.options.draggable)
1438
+ if (!card || !this.options.draggable || card.classList.contains('is-disabled') || card.getAttribute('aria-disabled') === 'true')
1436
1439
  return;
1437
1440
  this._draggedCard = card;
1438
1441
  this._dragSourceColumn = card.closest('.kanban-column');
1442
+ this._previewHeight = Math.max(64, Math.round(card.getBoundingClientRect().height));
1439
1443
  card.classList.add('is-dragging');
1444
+ this._dragImage = card.cloneNode(true);
1445
+ this._dragImage.classList.remove('is-dragging');
1446
+ this._dragImage.classList.add('kanban-drag-image');
1447
+ this._dragImage.setAttribute('aria-hidden', 'true');
1448
+ this._dragImage.style.width = `${card.getBoundingClientRect().width}px`;
1449
+ document.body.appendChild(this._dragImage);
1450
+ event.dataTransfer?.setDragImage(this._dragImage, card.offsetWidth / 2, card.offsetHeight / 2);
1440
1451
  event.dataTransfer?.setData('text/plain', card.dataset.kanbanCard || '');
1441
1452
  if (event.dataTransfer)
1442
1453
  event.dataTransfer.effectAllowed = 'move';
@@ -1452,6 +1463,7 @@ class Kanban extends Component {
1452
1463
  event.dataTransfer.dropEffect = 'move';
1453
1464
  this.el.querySelectorAll('.kanban-column.is-drag-over').forEach((item) => item.classList.remove('is-drag-over'));
1454
1465
  column.classList.add('is-drag-over');
1466
+ this._updateDropPreview(column, event);
1455
1467
  };
1456
1468
  _onDrop = (event) => {
1457
1469
  if (!this._draggedCard)
@@ -1463,17 +1475,21 @@ class Kanban extends Component {
1463
1475
  const body = column.querySelector('.kanban-column-body') || column;
1464
1476
  const targetCard = event.target?.closest('.kanban-card');
1465
1477
  const source = this._dragSourceColumn;
1466
- if (targetCard && targetCard !== this._draggedCard && targetCard.parentElement === body) {
1467
- const box = targetCard.getBoundingClientRect();
1468
- body.insertBefore(this._draggedCard, event.clientY < box.top + box.height / 2 ? targetCard : targetCard.nextSibling);
1478
+ const movedCard = this._draggedCard;
1479
+ if (this._dropPreview?.parentElement === body) {
1480
+ body.insertBefore(movedCard, this._dropPreview);
1481
+ this._dropPreview.remove();
1482
+ }
1483
+ else if (targetCard && targetCard !== movedCard && targetCard.parentElement === body) {
1484
+ body.insertBefore(movedCard, targetCard);
1469
1485
  }
1470
1486
  else {
1471
- body.appendChild(this._draggedCard);
1487
+ body.appendChild(movedCard);
1472
1488
  }
1473
1489
  this._clearDragState();
1474
1490
  this._updateCounts();
1475
1491
  if (source && source !== column)
1476
- this.options.onMove?.({ card: this._draggedCard, from: source, to: column });
1492
+ this.options.onMove?.({ card: movedCard, from: source, to: column });
1477
1493
  };
1478
1494
  _onDragEnd = () => this._clearDragState();
1479
1495
  constructor(el, options) {
@@ -1502,9 +1518,15 @@ class Kanban extends Component {
1502
1518
  body.setAttribute('role', 'list');
1503
1519
  column.querySelectorAll('.kanban-card').forEach((card) => {
1504
1520
  card.setAttribute('role', 'listitem');
1505
- card.setAttribute('tabindex', '0');
1506
- if (this.options.draggable)
1521
+ const disabled = card.classList.contains('is-disabled') || card.getAttribute('aria-disabled') === 'true';
1522
+ card.setAttribute('tabindex', disabled ? '-1' : '0');
1523
+ if (disabled) {
1524
+ card.setAttribute('aria-disabled', 'true');
1525
+ card.draggable = false;
1526
+ }
1527
+ else if (this.options.draggable) {
1507
1528
  card.draggable = true;
1529
+ }
1508
1530
  });
1509
1531
  });
1510
1532
  this._updateCounts();
@@ -1516,10 +1538,15 @@ class Kanban extends Component {
1516
1538
  this.el.addEventListener('dragend', this._onDragEnd);
1517
1539
  }
1518
1540
  _clearDragState() {
1541
+ this._dragImage?.remove();
1542
+ this._dragImage = null;
1543
+ this._dropPreview?.remove();
1544
+ this._dropPreview = null;
1519
1545
  this._draggedCard?.classList.remove('is-dragging');
1520
1546
  this.el.querySelectorAll('.kanban-column.is-drag-over').forEach((item) => item.classList.remove('is-drag-over'));
1521
1547
  this._draggedCard = null;
1522
1548
  this._dragSourceColumn = null;
1549
+ this._previewHeight = 64;
1523
1550
  }
1524
1551
  _updateCounts() {
1525
1552
  this.el.querySelectorAll('.kanban-column').forEach((column) => {
@@ -1527,8 +1554,33 @@ class Kanban extends Component {
1527
1554
  const body = column.querySelector('.kanban-column-body');
1528
1555
  if (count && body)
1529
1556
  count.textContent = String(body.querySelectorAll(':scope > .kanban-card').length);
1557
+ const empty = body?.querySelector('.kanban-empty');
1558
+ if (empty && body)
1559
+ empty.hidden = body.querySelectorAll(':scope > .kanban-card').length > 0;
1530
1560
  });
1531
1561
  }
1562
+ _updateDropPreview(column, event) {
1563
+ const body = column.querySelector('.kanban-column-body') || column;
1564
+ const targetCard = event.target?.closest('.kanban-card');
1565
+ if (targetCard === this._draggedCard)
1566
+ return;
1567
+ if (!this._dropPreview) {
1568
+ this._dropPreview = document.createElement('div');
1569
+ this._dropPreview.className = 'kanban-drop-preview';
1570
+ this._dropPreview.setAttribute('aria-hidden', 'true');
1571
+ }
1572
+ // Keep the preview tied to the dragged card's original height. Using the
1573
+ // hovered card's height makes the placeholder jump as the pointer crosses
1574
+ // cards with different content lengths.
1575
+ this._dropPreview.style.height = `${this._previewHeight}px`;
1576
+ if (targetCard && targetCard.parentElement === body) {
1577
+ const box = targetCard.getBoundingClientRect();
1578
+ body.insertBefore(this._dropPreview, event.clientY < box.top + box.height / 2 ? targetCard : targetCard.nextSibling);
1579
+ }
1580
+ else if (this._dropPreview.parentElement !== body) {
1581
+ body.appendChild(this._dropPreview);
1582
+ }
1583
+ }
1532
1584
  destroy() {
1533
1585
  this._clearDragState();
1534
1586
  this.el.removeEventListener('dragstart', this._onDragStart);
@@ -9378,7 +9430,7 @@ class Waves {
9378
9430
  }
9379
9431
 
9380
9432
  /* eslint-disable @typescript-eslint/no-unused-vars */
9381
- const version = '2.3.3-1.0.21';
9433
+ const version = '2.3.3-1.0.22';
9382
9434
  /**
9383
9435
  * Convenience helper matching v1's `M.toast({...})` call, since Toast is a
9384
9436
  * class in v2 with no bare functional equivalent of its own.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "The responsive front-end library based on Material Design from Google.",
4
4
  "author": "The Materialize Team",
5
5
  "homepage": "https://materialize.kevinzarshenas.com",
6
- "version": "2.3.3-1.0.21",
6
+ "version": "2.3.3-1.0.22",
7
7
  "style": "dist/css/materialize.css",
8
8
  "sass": "sass/materialize.scss",
9
9
  "typings": "dist/js/materialize.d.ts",