kmaterialize 2.3.3-1.0.20 → 2.3.3-1.0.21

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.20 (https://materializeweb.com)
2
+ * Materialize v2.3.3-1.0.21 (https://materializeweb.com)
3
3
  * Copyright 2014-2026 Materialize
4
4
  * MIT License (https://raw.githubusercontent.com/materializecss/materialize/master/LICENSE)
5
5
  */
@@ -400,7 +400,7 @@ var M = (function (exports) {
400
400
  }
401
401
  }
402
402
 
403
- const _defaults$w = {
403
+ const _defaults$x = {
404
404
  alignment: 'left',
405
405
  autoFocus: true,
406
406
  constrainWidth: true,
@@ -453,7 +453,7 @@ var M = (function (exports) {
453
453
  this._setupEventHandlers();
454
454
  }
455
455
  static get defaults() {
456
- return _defaults$w;
456
+ return _defaults$x;
457
457
  }
458
458
  /**
459
459
  * Initializes instances of Dropdown.
@@ -904,7 +904,7 @@ var M = (function (exports) {
904
904
  };
905
905
  }
906
906
 
907
- const _defaults$v = {
907
+ const _defaults$w = {
908
908
  data: [], // Autocomplete data set
909
909
  onAutocomplete: null, // Callback for when autocompleted
910
910
  dropdownOptions: {
@@ -964,7 +964,7 @@ var M = (function (exports) {
964
964
  this._setupEventHandlers();
965
965
  }
966
966
  static get defaults() {
967
- return _defaults$v;
967
+ return _defaults$w;
968
968
  }
969
969
  /**
970
970
  * Initializes instances of Autocomplete.
@@ -1372,7 +1372,7 @@ var M = (function (exports) {
1372
1372
  }
1373
1373
  }
1374
1374
 
1375
- const _defaults$u = {
1375
+ const _defaults$v = {
1376
1376
  dismissible: true
1377
1377
  };
1378
1378
  /** A persistent, contextual feedback banner. */
@@ -1386,7 +1386,7 @@ var M = (function (exports) {
1386
1386
  this._bindCloseButton();
1387
1387
  }
1388
1388
  static get defaults() {
1389
- return _defaults$u;
1389
+ return _defaults$v;
1390
1390
  }
1391
1391
  static init(els, options = {}) {
1392
1392
  return super.init(els, options, Alert);
@@ -1426,6 +1426,122 @@ var M = (function (exports) {
1426
1426
  }
1427
1427
  }
1428
1428
 
1429
+ const _defaults$u = {
1430
+ draggable: true
1431
+ };
1432
+ /** A lightweight, dependency-free board for columns of draggable cards. */
1433
+ class Kanban extends Component {
1434
+ _draggedCard = null;
1435
+ _dragSourceColumn = null;
1436
+ _onDragStart = (event) => {
1437
+ const card = event.target?.closest('.kanban-card');
1438
+ if (!card || !this.options.draggable)
1439
+ return;
1440
+ this._draggedCard = card;
1441
+ this._dragSourceColumn = card.closest('.kanban-column');
1442
+ card.classList.add('is-dragging');
1443
+ event.dataTransfer?.setData('text/plain', card.dataset.kanbanCard || '');
1444
+ if (event.dataTransfer)
1445
+ event.dataTransfer.effectAllowed = 'move';
1446
+ };
1447
+ _onDragOver = (event) => {
1448
+ if (!this._draggedCard)
1449
+ return;
1450
+ const column = event.target?.closest('.kanban-column');
1451
+ if (!column || !this.el.contains(column))
1452
+ return;
1453
+ event.preventDefault();
1454
+ if (event.dataTransfer)
1455
+ event.dataTransfer.dropEffect = 'move';
1456
+ this.el.querySelectorAll('.kanban-column.is-drag-over').forEach((item) => item.classList.remove('is-drag-over'));
1457
+ column.classList.add('is-drag-over');
1458
+ };
1459
+ _onDrop = (event) => {
1460
+ if (!this._draggedCard)
1461
+ return;
1462
+ const column = event.target?.closest('.kanban-column');
1463
+ if (!column || !this.el.contains(column))
1464
+ return;
1465
+ event.preventDefault();
1466
+ const body = column.querySelector('.kanban-column-body') || column;
1467
+ const targetCard = event.target?.closest('.kanban-card');
1468
+ const source = this._dragSourceColumn;
1469
+ if (targetCard && targetCard !== this._draggedCard && targetCard.parentElement === body) {
1470
+ const box = targetCard.getBoundingClientRect();
1471
+ body.insertBefore(this._draggedCard, event.clientY < box.top + box.height / 2 ? targetCard : targetCard.nextSibling);
1472
+ }
1473
+ else {
1474
+ body.appendChild(this._draggedCard);
1475
+ }
1476
+ this._clearDragState();
1477
+ this._updateCounts();
1478
+ if (source && source !== column)
1479
+ this.options.onMove?.({ card: this._draggedCard, from: source, to: column });
1480
+ };
1481
+ _onDragEnd = () => this._clearDragState();
1482
+ constructor(el, options) {
1483
+ super(el, options, Kanban);
1484
+ this.options = { ...Kanban.defaults, ...options };
1485
+ this.el['M_Kanban'] = this;
1486
+ this._prepareMarkup();
1487
+ if (this.options.draggable)
1488
+ this._bindEvents();
1489
+ }
1490
+ static get defaults() {
1491
+ return _defaults$u;
1492
+ }
1493
+ static init(els, options = {}) {
1494
+ return super.init(els, options, Kanban);
1495
+ }
1496
+ static getInstance(el) {
1497
+ return el['M_Kanban'];
1498
+ }
1499
+ _prepareMarkup() {
1500
+ this.el.setAttribute('role', 'region');
1501
+ this.el.querySelectorAll('.kanban-column').forEach((column) => {
1502
+ column.setAttribute('role', 'group');
1503
+ const body = column.querySelector('.kanban-column-body');
1504
+ if (body)
1505
+ body.setAttribute('role', 'list');
1506
+ column.querySelectorAll('.kanban-card').forEach((card) => {
1507
+ card.setAttribute('role', 'listitem');
1508
+ card.setAttribute('tabindex', '0');
1509
+ if (this.options.draggable)
1510
+ card.draggable = true;
1511
+ });
1512
+ });
1513
+ this._updateCounts();
1514
+ }
1515
+ _bindEvents() {
1516
+ this.el.addEventListener('dragstart', this._onDragStart);
1517
+ this.el.addEventListener('dragover', this._onDragOver);
1518
+ this.el.addEventListener('drop', this._onDrop);
1519
+ this.el.addEventListener('dragend', this._onDragEnd);
1520
+ }
1521
+ _clearDragState() {
1522
+ this._draggedCard?.classList.remove('is-dragging');
1523
+ this.el.querySelectorAll('.kanban-column.is-drag-over').forEach((item) => item.classList.remove('is-drag-over'));
1524
+ this._draggedCard = null;
1525
+ this._dragSourceColumn = null;
1526
+ }
1527
+ _updateCounts() {
1528
+ this.el.querySelectorAll('.kanban-column').forEach((column) => {
1529
+ const count = column.querySelector('.kanban-column-count');
1530
+ const body = column.querySelector('.kanban-column-body');
1531
+ if (count && body)
1532
+ count.textContent = String(body.querySelectorAll(':scope > .kanban-card').length);
1533
+ });
1534
+ }
1535
+ destroy() {
1536
+ this._clearDragState();
1537
+ this.el.removeEventListener('dragstart', this._onDragStart);
1538
+ this.el.removeEventListener('dragover', this._onDragOver);
1539
+ this.el.removeEventListener('drop', this._onDrop);
1540
+ this.el.removeEventListener('dragend', this._onDragEnd);
1541
+ delete this.el['M_Kanban'];
1542
+ }
1543
+ }
1544
+
1429
1545
  const _defaults$t = {
1430
1546
  direction: 'top',
1431
1547
  hoverEnabled: true,
@@ -9265,7 +9381,7 @@ var M = (function (exports) {
9265
9381
  }
9266
9382
 
9267
9383
  /* eslint-disable @typescript-eslint/no-unused-vars */
9268
- const version = '2.3.3-1.0.20';
9384
+ const version = '2.3.3-1.0.21';
9269
9385
  /**
9270
9386
  * Convenience helper matching v1's `M.toast({...})` call, since Toast is a
9271
9387
  * class in v2 with no bare functional equivalent of its own.
@@ -9281,6 +9397,7 @@ var M = (function (exports) {
9281
9397
  function AutoInit(context = document.body, options) {
9282
9398
  const registry = {
9283
9399
  Alert: context.querySelectorAll('.alert:not(.no-autoinit)'),
9400
+ Kanban: context.querySelectorAll('.kanban-board:not(.no-autoinit)'),
9284
9401
  Autocomplete: context.querySelectorAll('.autocomplete:not(.no-autoinit)'),
9285
9402
  Cards: context.querySelectorAll('.cards:not(.no-autoinit)'),
9286
9403
  Carousel: context.querySelectorAll('.carousel:not(.no-autoinit)'),
@@ -9314,6 +9431,7 @@ var M = (function (exports) {
9314
9431
  };
9315
9432
  Autocomplete.init(registry.Autocomplete, options?.Autocomplete ?? {});
9316
9433
  Alert.init(registry.Alert, options?.Alert ?? {});
9434
+ Kanban.init(registry.Kanban, options?.Kanban ?? {});
9317
9435
  Cards.init(registry.Cards, options?.Cards ?? {});
9318
9436
  Carousel.init(registry.Carousel, options?.Carousel ?? {});
9319
9437
  Chips.init(registry.Chips, options?.Chips ?? {});
@@ -9369,6 +9487,7 @@ var M = (function (exports) {
9369
9487
  exports.FloatingActionButton = FloatingActionButton;
9370
9488
  exports.FormSelect = FormSelect;
9371
9489
  exports.Forms = Forms;
9490
+ exports.Kanban = Kanban;
9372
9491
  exports.Materialbox = Materialbox;
9373
9492
  exports.Modal = Modal;
9374
9493
  exports.NumberInput = NumberInput;