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
  */
@@ -397,7 +397,7 @@ class Component {
397
397
  }
398
398
  }
399
399
 
400
- const _defaults$w = {
400
+ const _defaults$x = {
401
401
  alignment: 'left',
402
402
  autoFocus: true,
403
403
  constrainWidth: true,
@@ -450,7 +450,7 @@ class Dropdown extends Component {
450
450
  this._setupEventHandlers();
451
451
  }
452
452
  static get defaults() {
453
- return _defaults$w;
453
+ return _defaults$x;
454
454
  }
455
455
  /**
456
456
  * Initializes instances of Dropdown.
@@ -901,7 +901,7 @@ class Dropdown extends Component {
901
901
  };
902
902
  }
903
903
 
904
- const _defaults$v = {
904
+ const _defaults$w = {
905
905
  data: [], // Autocomplete data set
906
906
  onAutocomplete: null, // Callback for when autocompleted
907
907
  dropdownOptions: {
@@ -961,7 +961,7 @@ class Autocomplete extends Component {
961
961
  this._setupEventHandlers();
962
962
  }
963
963
  static get defaults() {
964
- return _defaults$v;
964
+ return _defaults$w;
965
965
  }
966
966
  /**
967
967
  * Initializes instances of Autocomplete.
@@ -1369,7 +1369,7 @@ class Autocomplete extends Component {
1369
1369
  }
1370
1370
  }
1371
1371
 
1372
- const _defaults$u = {
1372
+ const _defaults$v = {
1373
1373
  dismissible: true
1374
1374
  };
1375
1375
  /** A persistent, contextual feedback banner. */
@@ -1383,7 +1383,7 @@ class Alert extends Component {
1383
1383
  this._bindCloseButton();
1384
1384
  }
1385
1385
  static get defaults() {
1386
- return _defaults$u;
1386
+ return _defaults$v;
1387
1387
  }
1388
1388
  static init(els, options = {}) {
1389
1389
  return super.init(els, options, Alert);
@@ -1423,6 +1423,122 @@ class Alert extends Component {
1423
1423
  }
1424
1424
  }
1425
1425
 
1426
+ const _defaults$u = {
1427
+ draggable: true
1428
+ };
1429
+ /** A lightweight, dependency-free board for columns of draggable cards. */
1430
+ class Kanban extends Component {
1431
+ _draggedCard = null;
1432
+ _dragSourceColumn = null;
1433
+ _onDragStart = (event) => {
1434
+ const card = event.target?.closest('.kanban-card');
1435
+ if (!card || !this.options.draggable)
1436
+ return;
1437
+ this._draggedCard = card;
1438
+ this._dragSourceColumn = card.closest('.kanban-column');
1439
+ card.classList.add('is-dragging');
1440
+ event.dataTransfer?.setData('text/plain', card.dataset.kanbanCard || '');
1441
+ if (event.dataTransfer)
1442
+ event.dataTransfer.effectAllowed = 'move';
1443
+ };
1444
+ _onDragOver = (event) => {
1445
+ if (!this._draggedCard)
1446
+ return;
1447
+ const column = event.target?.closest('.kanban-column');
1448
+ if (!column || !this.el.contains(column))
1449
+ return;
1450
+ event.preventDefault();
1451
+ if (event.dataTransfer)
1452
+ event.dataTransfer.dropEffect = 'move';
1453
+ this.el.querySelectorAll('.kanban-column.is-drag-over').forEach((item) => item.classList.remove('is-drag-over'));
1454
+ column.classList.add('is-drag-over');
1455
+ };
1456
+ _onDrop = (event) => {
1457
+ if (!this._draggedCard)
1458
+ return;
1459
+ const column = event.target?.closest('.kanban-column');
1460
+ if (!column || !this.el.contains(column))
1461
+ return;
1462
+ event.preventDefault();
1463
+ const body = column.querySelector('.kanban-column-body') || column;
1464
+ const targetCard = event.target?.closest('.kanban-card');
1465
+ 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);
1469
+ }
1470
+ else {
1471
+ body.appendChild(this._draggedCard);
1472
+ }
1473
+ this._clearDragState();
1474
+ this._updateCounts();
1475
+ if (source && source !== column)
1476
+ this.options.onMove?.({ card: this._draggedCard, from: source, to: column });
1477
+ };
1478
+ _onDragEnd = () => this._clearDragState();
1479
+ constructor(el, options) {
1480
+ super(el, options, Kanban);
1481
+ this.options = { ...Kanban.defaults, ...options };
1482
+ this.el['M_Kanban'] = this;
1483
+ this._prepareMarkup();
1484
+ if (this.options.draggable)
1485
+ this._bindEvents();
1486
+ }
1487
+ static get defaults() {
1488
+ return _defaults$u;
1489
+ }
1490
+ static init(els, options = {}) {
1491
+ return super.init(els, options, Kanban);
1492
+ }
1493
+ static getInstance(el) {
1494
+ return el['M_Kanban'];
1495
+ }
1496
+ _prepareMarkup() {
1497
+ this.el.setAttribute('role', 'region');
1498
+ this.el.querySelectorAll('.kanban-column').forEach((column) => {
1499
+ column.setAttribute('role', 'group');
1500
+ const body = column.querySelector('.kanban-column-body');
1501
+ if (body)
1502
+ body.setAttribute('role', 'list');
1503
+ column.querySelectorAll('.kanban-card').forEach((card) => {
1504
+ card.setAttribute('role', 'listitem');
1505
+ card.setAttribute('tabindex', '0');
1506
+ if (this.options.draggable)
1507
+ card.draggable = true;
1508
+ });
1509
+ });
1510
+ this._updateCounts();
1511
+ }
1512
+ _bindEvents() {
1513
+ this.el.addEventListener('dragstart', this._onDragStart);
1514
+ this.el.addEventListener('dragover', this._onDragOver);
1515
+ this.el.addEventListener('drop', this._onDrop);
1516
+ this.el.addEventListener('dragend', this._onDragEnd);
1517
+ }
1518
+ _clearDragState() {
1519
+ this._draggedCard?.classList.remove('is-dragging');
1520
+ this.el.querySelectorAll('.kanban-column.is-drag-over').forEach((item) => item.classList.remove('is-drag-over'));
1521
+ this._draggedCard = null;
1522
+ this._dragSourceColumn = null;
1523
+ }
1524
+ _updateCounts() {
1525
+ this.el.querySelectorAll('.kanban-column').forEach((column) => {
1526
+ const count = column.querySelector('.kanban-column-count');
1527
+ const body = column.querySelector('.kanban-column-body');
1528
+ if (count && body)
1529
+ count.textContent = String(body.querySelectorAll(':scope > .kanban-card').length);
1530
+ });
1531
+ }
1532
+ destroy() {
1533
+ this._clearDragState();
1534
+ this.el.removeEventListener('dragstart', this._onDragStart);
1535
+ this.el.removeEventListener('dragover', this._onDragOver);
1536
+ this.el.removeEventListener('drop', this._onDrop);
1537
+ this.el.removeEventListener('dragend', this._onDragEnd);
1538
+ delete this.el['M_Kanban'];
1539
+ }
1540
+ }
1541
+
1426
1542
  const _defaults$t = {
1427
1543
  direction: 'top',
1428
1544
  hoverEnabled: true,
@@ -9262,7 +9378,7 @@ class Waves {
9262
9378
  }
9263
9379
 
9264
9380
  /* eslint-disable @typescript-eslint/no-unused-vars */
9265
- const version = '2.3.3-1.0.20';
9381
+ const version = '2.3.3-1.0.21';
9266
9382
  /**
9267
9383
  * Convenience helper matching v1's `M.toast({...})` call, since Toast is a
9268
9384
  * class in v2 with no bare functional equivalent of its own.
@@ -9278,6 +9394,7 @@ function toast(options) {
9278
9394
  function AutoInit(context = document.body, options) {
9279
9395
  const registry = {
9280
9396
  Alert: context.querySelectorAll('.alert:not(.no-autoinit)'),
9397
+ Kanban: context.querySelectorAll('.kanban-board:not(.no-autoinit)'),
9281
9398
  Autocomplete: context.querySelectorAll('.autocomplete:not(.no-autoinit)'),
9282
9399
  Cards: context.querySelectorAll('.cards:not(.no-autoinit)'),
9283
9400
  Carousel: context.querySelectorAll('.carousel:not(.no-autoinit)'),
@@ -9311,6 +9428,7 @@ function AutoInit(context = document.body, options) {
9311
9428
  };
9312
9429
  Autocomplete.init(registry.Autocomplete, options?.Autocomplete ?? {});
9313
9430
  Alert.init(registry.Alert, options?.Alert ?? {});
9431
+ Kanban.init(registry.Kanban, options?.Kanban ?? {});
9314
9432
  Cards.init(registry.Cards, options?.Cards ?? {});
9315
9433
  Carousel.init(registry.Carousel, options?.Carousel ?? {});
9316
9434
  Chips.init(registry.Chips, options?.Chips ?? {});
@@ -9350,4 +9468,4 @@ Waves.Init();
9350
9468
  Range.Init();
9351
9469
  Cards.Init();
9352
9470
 
9353
- export { AirDatepickerField, Alert, AutoInit, Autocomplete, Cards, Carousel, CharacterCounter, Chips, Collapsible, ColorInput, Datepicker, Dropdown, FileInput, FloatingActionButton, FormSelect, Forms, Materialbox, Modal, NumberInput, Parallax, PasswordInput, Pushpin, Range, ScrollSpy, Sidenav, Slider, Tabs, TapTarget, Timepicker, Toast, TomSelectField, Toolbar, Tooltip, Waves, toast, version };
9471
+ export { AirDatepickerField, Alert, AutoInit, Autocomplete, Cards, Carousel, CharacterCounter, Chips, Collapsible, ColorInput, Datepicker, Dropdown, FileInput, FloatingActionButton, FormSelect, Forms, Kanban, Materialbox, Modal, NumberInput, Parallax, PasswordInput, Pushpin, Range, ScrollSpy, Sidenav, Slider, Tabs, TapTarget, Timepicker, Toast, TomSelectField, Toolbar, Tooltip, Waves, toast, version };
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.20",
6
+ "version": "2.3.3-1.0.21",
7
7
  "style": "dist/css/materialize.css",
8
8
  "sass": "sass/materialize.scss",
9
9
  "typings": "dist/js/materialize.d.ts",
@@ -19,6 +19,7 @@
19
19
 
20
20
  @forward '../components/button/buttons';
21
21
  @forward '../components/alert/alerts';
22
+ @forward '../components/kanban/kanban';
22
23
  @forward '../components/collapsible/collapsible'; // custom
23
24
  @forward '../components/badge/badges';
24
25
  @forward '../components/card/cards';