@keenthemes/ktui 1.1.3 → 1.1.5

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.
Files changed (38) hide show
  1. package/dist/ktui.js +199 -58
  2. package/dist/ktui.min.js +1 -1
  3. package/dist/ktui.min.js.map +1 -1
  4. package/dist/styles.css +39 -0
  5. package/lib/cjs/components/component.js +9 -0
  6. package/lib/cjs/components/component.js.map +1 -1
  7. package/lib/cjs/components/datatable/datatable-sort.js +80 -10
  8. package/lib/cjs/components/datatable/datatable-sort.js.map +1 -1
  9. package/lib/cjs/components/datatable/datatable.js +54 -10
  10. package/lib/cjs/components/datatable/datatable.js.map +1 -1
  11. package/lib/cjs/components/drawer/drawer.js +43 -34
  12. package/lib/cjs/components/drawer/drawer.js.map +1 -1
  13. package/lib/cjs/components/dropdown/dropdown.js +6 -0
  14. package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
  15. package/lib/cjs/components/select/select.js +7 -4
  16. package/lib/cjs/components/select/select.js.map +1 -1
  17. package/lib/esm/components/component.js +9 -0
  18. package/lib/esm/components/component.js.map +1 -1
  19. package/lib/esm/components/datatable/datatable-sort.js +80 -10
  20. package/lib/esm/components/datatable/datatable-sort.js.map +1 -1
  21. package/lib/esm/components/datatable/datatable.js +54 -10
  22. package/lib/esm/components/datatable/datatable.js.map +1 -1
  23. package/lib/esm/components/drawer/drawer.js +43 -34
  24. package/lib/esm/components/drawer/drawer.js.map +1 -1
  25. package/lib/esm/components/dropdown/dropdown.js +6 -0
  26. package/lib/esm/components/dropdown/dropdown.js.map +1 -1
  27. package/lib/esm/components/select/select.js +7 -4
  28. package/lib/esm/components/select/select.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/components/component.ts +10 -0
  31. package/src/components/datatable/datatable-sort.ts +89 -7
  32. package/src/components/datatable/datatable.ts +59 -10
  33. package/src/components/datatable/types.ts +14 -0
  34. package/src/components/drawer/drawer.ts +38 -35
  35. package/src/components/drawer/types.ts +4 -2
  36. package/src/components/dropdown/dropdown.ts +5 -0
  37. package/src/components/select/select.css +3 -2
  38. package/src/components/select/select.ts +7 -4
package/dist/ktui.js CHANGED
@@ -208,6 +208,7 @@ var KTDrawer = /** @class */ (function (_super) {
208
208
  persistent: false,
209
209
  container: '',
210
210
  focus: true,
211
+ keepInPlaceWithin: '',
211
212
  };
212
213
  _this._config = _this._defaultConfig;
213
214
  _this._isOpen = false;
@@ -258,26 +259,19 @@ var KTDrawer = /** @class */ (function (_super) {
258
259
  return;
259
260
  }
260
261
  KTDrawer.hide();
261
- // If drawer needs to be in front of backdrop, ensure it's in body (for proper z-index stacking)
262
- // This ensures the drawer and backdrop are in the same stacking context
262
+ // When container="body", move drawer to body only if NOT inside an element matching keepInPlaceWithin.
263
+ // When keepInPlaceWithin is set (e.g. for SPA/persisted layouts), keeping the drawer in place lets the host preserve it across navigations.
263
264
  if (this._getOption('container') === 'body' && this._element.parentElement !== document.body) {
264
- // Store original parent for restoration when hiding
265
- if (!this._element.hasAttribute('data-kt-drawer-original-parent-id')) {
266
- var originalParent = this._element.parentElement;
267
- if (originalParent && originalParent !== document.body) {
268
- this._element.setAttribute('data-kt-drawer-original-parent-id', originalParent.id || '');
269
- // Store a reference to find the parent later (using closest to find Livewire component or header)
270
- var livewireComponent = originalParent.closest('[wire\\:id]');
271
- var header = originalParent.closest('header#header');
272
- if (livewireComponent) {
273
- this._element.setAttribute('data-kt-drawer-original-wire-id', livewireComponent.getAttribute('wire:id') || '');
274
- }
275
- if (header) {
276
- this._element.setAttribute('data-kt-drawer-original-in-header', 'true');
265
+ var keepInPlace = this._isKeepInPlace();
266
+ if (!keepInPlace) {
267
+ if (!this._element.hasAttribute('data-kt-drawer-original-parent-id')) {
268
+ var originalParent = this._element.parentElement;
269
+ if (originalParent && originalParent !== document.body) {
270
+ this._element.setAttribute('data-kt-drawer-original-parent-id', originalParent.id || '');
277
271
  }
278
272
  }
273
+ document.body.appendChild(this._element);
279
274
  }
280
- document.body.appendChild(this._element);
281
275
  }
282
276
  if (this._getOption('backdrop') === true)
283
277
  this._createBackdrop();
@@ -365,23 +359,12 @@ var KTDrawer = /** @class */ (function (_super) {
365
359
  var _a;
366
360
  if (this._getOption('container')) {
367
361
  if (this._getOption('container') === 'body') {
368
- // Check if drawer is in a persisted Livewire component (like header with @persist)
369
- // If so, don't move it to body - keep it in place so Livewire can preserve it
370
- // This follows the same pattern as dropdowns/menus which work with wire:navigate
371
- var originalParent = this._element.parentNode;
372
- var isInPersistedComponent = originalParent &&
373
- (originalParent.closest('[wire\\:id]') !== null ||
374
- originalParent.closest('header#header') !== null);
375
- if (isInPersistedComponent) {
376
- // Don't move to body - keep in original location for Livewire persistence
377
- // Use fixed positioning to achieve the same visual effect
378
- // Ensure drawer has fixed positioning to work from its current location
362
+ if (this._isKeepInPlace()) {
379
363
  if (!this._element.style.position || this._element.style.position === 'static') {
380
364
  this._element.style.position = 'fixed';
381
365
  }
382
366
  }
383
367
  else {
384
- // Not in persisted component - safe to move to body (follows original behavior)
385
368
  document.body.appendChild(this._element);
386
369
  }
387
370
  }
@@ -391,6 +374,26 @@ var KTDrawer = /** @class */ (function (_super) {
391
374
  }
392
375
  }
393
376
  };
377
+ /** True when drawer is inside an element matching keepInPlaceWithin (so we keep it in place instead of moving to body). */
378
+ KTDrawer.prototype._isKeepInPlace = function () {
379
+ var _a, _b;
380
+ var selector = (_a = this._getOption('keepInPlaceWithin')) === null || _a === void 0 ? void 0 : _a.trim();
381
+ if (!selector || !((_b = this._element) === null || _b === void 0 ? void 0 : _b.parentElement))
382
+ return false;
383
+ var parent = this._element.parentElement;
384
+ var selectors = selector.split(',').map(function (s) { return s.trim(); }).filter(Boolean);
385
+ for (var _i = 0, selectors_1 = selectors; _i < selectors_1.length; _i++) {
386
+ var sel = selectors_1[_i];
387
+ try {
388
+ if (parent.closest(sel) !== null)
389
+ return true;
390
+ }
391
+ catch (_c) {
392
+ // invalid selector, skip
393
+ }
394
+ }
395
+ return false;
396
+ };
394
397
  KTDrawer.prototype._autoFocus = function () {
395
398
  if (!this._element)
396
399
  return;
@@ -408,7 +411,13 @@ var KTDrawer = /** @class */ (function (_super) {
408
411
  this._backdropElement = document.createElement('DIV');
409
412
  this._backdropElement.style.zIndex = (zindex - 1).toString();
410
413
  this._backdropElement.setAttribute('data-kt-drawer-backdrop', 'true');
411
- document.body.append(this._backdropElement);
414
+ var parent = this._element.parentElement;
415
+ if (parent) {
416
+ parent.insertBefore(this._backdropElement, this._element);
417
+ }
418
+ else {
419
+ document.body.append(this._backdropElement);
420
+ }
412
421
  dom_1.default.reflow(this._backdropElement);
413
422
  dom_1.default.addClass(this._backdropElement, this._getOption('backdropClass'));
414
423
  this._backdropElement.addEventListener('click', function (event) {
@@ -433,8 +442,8 @@ var KTDrawer = /** @class */ (function (_super) {
433
442
  KTDrawer.prototype._isEnabled = function () {
434
443
  return utils_1.default.stringToBoolean(this._getOption('enable'));
435
444
  };
436
- KTDrawer.prototype.toggle = function () {
437
- return this._toggle();
445
+ KTDrawer.prototype.toggle = function (relatedTarget) {
446
+ return this._toggle(relatedTarget);
438
447
  };
439
448
  KTDrawer.prototype.show = function (relatedTarget) {
440
449
  return this._show(relatedTarget);
@@ -612,7 +621,7 @@ var KTDrawer = /** @class */ (function (_super) {
612
621
  // Try to get instance immediately
613
622
  var drawer = KTDrawer.getInstance(target);
614
623
  if (drawer) {
615
- drawer.toggle();
624
+ drawer.toggle(target);
616
625
  }
617
626
  else {
618
627
  // Drawer element not found - wait for it to appear (handles persisted Livewire components)
@@ -630,7 +639,7 @@ var KTDrawer = /** @class */ (function (_super) {
630
639
  // Get instance and toggle
631
640
  var drawerInstance = KTDrawer.getInstance(drawerElement);
632
641
  if (drawerInstance) {
633
- drawerInstance.toggle();
642
+ drawerInstance.toggle(target);
634
643
  }
635
644
  }
636
645
  else {
@@ -646,7 +655,7 @@ var KTDrawer = /** @class */ (function (_super) {
646
655
  }
647
656
  var drawerInstance = KTDrawer.getInstance(drawerAfterReinit);
648
657
  if (drawerInstance) {
649
- drawerInstance.toggle();
658
+ drawerInstance.toggle(target);
650
659
  }
651
660
  }
652
661
  }, 500);
@@ -2265,6 +2274,15 @@ var KTComponent = /** @class */ (function () {
2265
2274
  return;
2266
2275
  this._config = __assign(__assign(__assign(__assign({}, this._defaultConfig), this._getGlobalConfig()), dom_1.default.getDataAttributes(this._element, this._dataOptionPrefix + this._name)), config);
2267
2276
  };
2277
+ /**
2278
+ * Merge config into the existing _config in place. Use when re-applying config to an
2279
+ * already-initialized instance so handlers that hold a reference to _config see updates.
2280
+ */
2281
+ KTComponent.prototype._mergeConfig = function (config) {
2282
+ if (config && typeof config === 'object' && Object.keys(config).length > 0) {
2283
+ Object.assign(this._config, config);
2284
+ }
2285
+ };
2268
2286
  KTComponent.prototype.dispose = function () {
2269
2287
  if (!this._element)
2270
2288
  return;
@@ -6272,7 +6290,7 @@ if (typeof window !== 'undefined') {
6272
6290
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6273
6291
  exports.createSortHandler = createSortHandler;
6274
6292
  function createSortHandler(config, theadElement, getState, setState, fireEvent, dispatchEvent, updateData) {
6275
- // Helper to compare values for sorting
6293
+ // Helper to compare values for sorting (string)
6276
6294
  function compareValues(a, b, sortOrder) {
6277
6295
  var aText = String(a).replace(/<[^>]*>|&nbsp;/g, '');
6278
6296
  var bText = String(b).replace(/<[^>]*>|&nbsp;/g, '');
@@ -6286,11 +6304,63 @@ function createSortHandler(config, theadElement, getState, setState, fireEvent,
6286
6304
  : 1
6287
6305
  : 0;
6288
6306
  }
6307
+ // Parse value for numeric sort: strip currency/commas, then parseFloat
6308
+ function parseNumeric(value) {
6309
+ if (value === null || value === undefined || value === '') {
6310
+ return Number.NaN;
6311
+ }
6312
+ var s = String(value).replace(/[^0-9.-]/g, '');
6313
+ var n = parseFloat(s);
6314
+ return Number.isNaN(n) ? Number.NaN : n;
6315
+ }
6316
+ // Compare two numbers; NaN sorts to the end for both asc and desc
6317
+ function compareNumeric(aNum, bNum, sortOrder) {
6318
+ var aNaN = Number.isNaN(aNum);
6319
+ var bNaN = Number.isNaN(bNum);
6320
+ if (aNaN && bNaN)
6321
+ return 0;
6322
+ if (aNaN)
6323
+ return 1;
6324
+ if (bNaN)
6325
+ return -1;
6326
+ if (aNum < bNum)
6327
+ return sortOrder === 'asc' ? -1 : 1;
6328
+ if (aNum > bNum)
6329
+ return sortOrder === 'asc' ? 1 : -1;
6330
+ return 0;
6331
+ }
6332
+ function getColumnDef(sortField) {
6333
+ var columns = config.columns;
6334
+ if (!columns)
6335
+ return undefined;
6336
+ var key = typeof sortField === 'number'
6337
+ ? Object.keys(columns)[sortField]
6338
+ : sortField;
6339
+ return key !== undefined ? columns[key] : undefined;
6340
+ }
6289
6341
  function sortData(data, sortField, sortOrder) {
6342
+ var columnDef = getColumnDef(sortField);
6343
+ var sortValueFn = columnDef === null || columnDef === void 0 ? void 0 : columnDef.sortValue;
6344
+ var useNumeric = !sortValueFn && (columnDef === null || columnDef === void 0 ? void 0 : columnDef.sortType) === 'numeric';
6290
6345
  return data.sort(function (a, b) {
6291
- var aValue = a[sortField];
6292
- var bValue = b[sortField];
6293
- return compareValues(aValue, bValue, sortOrder);
6346
+ var aRaw = a[sortField];
6347
+ var bRaw = b[sortField];
6348
+ if (typeof sortValueFn === 'function') {
6349
+ var aVal = sortValueFn(aRaw, a);
6350
+ var bVal = sortValueFn(bRaw, b);
6351
+ var aNum = typeof aVal === 'number' ? aVal : parseNumeric(aVal);
6352
+ var bNum = typeof bVal === 'number' ? bVal : parseNumeric(bVal);
6353
+ if (typeof aVal === 'number' && typeof bVal === 'number') {
6354
+ return compareNumeric(aNum, bNum, sortOrder);
6355
+ }
6356
+ return compareValues(aVal, bVal, sortOrder);
6357
+ }
6358
+ if (useNumeric) {
6359
+ var aNum = parseNumeric(aRaw);
6360
+ var bNum = parseNumeric(bRaw);
6361
+ return compareNumeric(aNum, bNum, sortOrder);
6362
+ }
6363
+ return compareValues(aRaw, bRaw, sortOrder);
6294
6364
  });
6295
6365
  }
6296
6366
  function toggleSortOrder(currentField, currentOrder, newField) {
@@ -6307,20 +6377,38 @@ function createSortHandler(config, theadElement, getState, setState, fireEvent,
6307
6377
  return 'asc';
6308
6378
  }
6309
6379
  function setSortIcon(sortField, sortOrder) {
6310
- var _a, _b, _c, _d, _e, _f, _g, _h;
6380
+ var _a, _b, _c, _d, _e, _f;
6381
+ var baseClass = ((_b = (_a = config.sort) === null || _a === void 0 ? void 0 : _a.classes) === null || _b === void 0 ? void 0 : _b.base) || '';
6311
6382
  var sortClass = sortOrder
6312
6383
  ? sortOrder === 'asc'
6313
- ? ((_b = (_a = config.sort) === null || _a === void 0 ? void 0 : _a.classes) === null || _b === void 0 ? void 0 : _b.asc) || ''
6314
- : ((_d = (_c = config.sort) === null || _c === void 0 ? void 0 : _c.classes) === null || _d === void 0 ? void 0 : _d.desc) || ''
6384
+ ? ((_d = (_c = config.sort) === null || _c === void 0 ? void 0 : _c.classes) === null || _d === void 0 ? void 0 : _d.asc) || ''
6385
+ : ((_f = (_e = config.sort) === null || _e === void 0 ? void 0 : _e.classes) === null || _f === void 0 ? void 0 : _f.desc) || ''
6315
6386
  : '';
6387
+ // Clear all headers: remove sort state so only the active column shows highlighted arrow
6388
+ var allTh = theadElement.querySelectorAll('th');
6389
+ allTh.forEach(function (header) {
6390
+ var el = header;
6391
+ el.setAttribute('aria-sort', 'none');
6392
+ var sortElement = header.querySelector(".".concat(baseClass));
6393
+ if (sortElement) {
6394
+ sortElement.className = baseClass;
6395
+ }
6396
+ });
6397
+ // Apply sort state to the active column so table.css [aria-sort='asc'] / [aria-sort='desc'] can highlight the arrow
6316
6398
  var th = typeof sortField === 'number'
6317
- ? theadElement.querySelectorAll('th')[sortField]
6399
+ ? allTh[sortField]
6318
6400
  : theadElement.querySelector("th[data-kt-datatable-column=\"".concat(String(sortField), "\"], th[data-kt-datatable-column-sort=\"").concat(String(sortField), "\"]"));
6319
6401
  if (th) {
6320
- var sortElement = th.querySelector(".".concat((_f = (_e = config.sort) === null || _e === void 0 ? void 0 : _e.classes) === null || _f === void 0 ? void 0 : _f.base));
6402
+ var sortElement = th.querySelector(".".concat(baseClass));
6321
6403
  if (sortElement) {
6322
6404
  sortElement.className =
6323
- "".concat((_h = (_g = config.sort) === null || _g === void 0 ? void 0 : _g.classes) === null || _h === void 0 ? void 0 : _h.base, " ").concat(sortClass).trim();
6405
+ "".concat(baseClass, " ").concat(sortClass).trim();
6406
+ }
6407
+ if (sortOrder) {
6408
+ th.setAttribute('aria-sort', sortOrder);
6409
+ }
6410
+ else {
6411
+ th.setAttribute('aria-sort', 'none');
6324
6412
  }
6325
6413
  }
6326
6414
  }
@@ -7032,8 +7120,14 @@ var KTDataTable = /** @class */ (function (_super) {
7032
7120
  * Used to detect and ignore stale responses from older requests
7033
7121
  */
7034
7122
  _this._requestId = 0;
7035
- if (data_1.default.has(element, _this._name))
7123
+ if (data_1.default.has(element, _this._name)) {
7124
+ // Already initialized (e.g. by createInstances). Merge user config so columns/sortType etc. apply.
7125
+ var existing = KTDataTable.getInstance(element);
7126
+ if (existing && config) {
7127
+ existing._mergeConfig(config);
7128
+ }
7036
7129
  return _this;
7130
+ }
7037
7131
  _this._defaultConfig = _this._initDefaultConfig(config);
7038
7132
  _this._init(element);
7039
7133
  _this._buildConfig();
@@ -7521,9 +7615,13 @@ var KTDataTable = /** @class */ (function (_super) {
7521
7615
  var originalDataAttributes = [];
7522
7616
  this._storeOriginalClasses();
7523
7617
  var rows = this._tbodyElement.querySelectorAll('tr');
7524
- var ths = this._theadElement
7618
+ // Filter th elements to only include those with data-kt-datatable-column attribute
7619
+ var allThs = this._theadElement
7525
7620
  ? this._theadElement.querySelectorAll('th')
7526
7621
  : [];
7622
+ var ths = Array.from(allThs).filter(function (th) {
7623
+ return th.hasAttribute('data-kt-datatable-column');
7624
+ });
7527
7625
  rows.forEach(function (row) {
7528
7626
  var dataRow = {};
7529
7627
  var dataRowAttribute = {};
@@ -7551,9 +7649,13 @@ var KTDataTable = /** @class */ (function (_super) {
7551
7649
  */
7552
7650
  KTDataTable.prototype._localTableHeaderInvalidate = function () {
7553
7651
  var originalData = this.getState().originalData;
7554
- var currentTableHeaders = this._theadElement
7555
- ? this._theadElement.querySelectorAll('th').length
7556
- : 0;
7652
+ // Count only th elements with data-kt-datatable-column attribute
7653
+ var allThs = this._theadElement
7654
+ ? this._theadElement.querySelectorAll('th')
7655
+ : [];
7656
+ var currentTableHeaders = Array.from(allThs).filter(function (th) {
7657
+ return th.hasAttribute('data-kt-datatable-column');
7658
+ }).length;
7557
7659
  var totalColumns = originalData.length
7558
7660
  ? Object.keys(originalData[0]).length
7559
7661
  : 0;
@@ -7803,9 +7905,16 @@ var KTDataTable = /** @class */ (function (_super) {
7803
7905
  this._noticeOnTable(this._config.infoEmpty || '');
7804
7906
  return tbodyElement;
7805
7907
  }
7806
- var ths = this._theadElement
7908
+ // Filter th elements to only include those with data-kt-datatable-column attribute
7909
+ // This prevents creating blank td elements for merged header cells (colspan/rowspan)
7910
+ var allThs = this._theadElement
7807
7911
  ? this._theadElement.querySelectorAll('th')
7808
7912
  : [];
7913
+ var ths = Array.from(allThs).filter(function (th) {
7914
+ return th.hasAttribute('data-kt-datatable-column');
7915
+ });
7916
+ // When no th has data-kt-datatable-column, use all ths so we still render by column index (data extracted with numeric keys)
7917
+ var columnsToRender = ths.length > 0 ? ths : Array.from(allThs);
7809
7918
  this._data.forEach(function (item, rowIndex) {
7810
7919
  var row = document.createElement('tr');
7811
7920
  // Apply original tr class if available
@@ -7816,8 +7925,8 @@ var KTDataTable = /** @class */ (function (_super) {
7816
7925
  var dataRowAttributes_1 = _this.getState().originalDataAttributes
7817
7926
  ? _this.getState().originalDataAttributes[rowIndex]
7818
7927
  : null;
7819
- // Use the order of <th> elements to render <td>s in the correct order
7820
- ths.forEach(function (th, colIndex) {
7928
+ // Use columnsToRender so tables without data-kt-datatable-column still get cells (by index)
7929
+ columnsToRender.forEach(function (th, colIndex) {
7821
7930
  var colName = th.getAttribute('data-kt-datatable-column');
7822
7931
  var td = document.createElement('td');
7823
7932
  var value;
@@ -8413,8 +8522,31 @@ var KTDataTable = /** @class */ (function (_super) {
8413
8522
  KTDataTable.init = function () {
8414
8523
  if (typeof document === 'undefined')
8415
8524
  return;
8416
- // Create instances of KTDataTable for all elements with a
8417
- // data-kt-datatable="true" attribute
8525
+ KTDataTable.createInstances();
8526
+ };
8527
+ /**
8528
+ * Force reinitialization of datatables by clearing existing instances.
8529
+ * Useful for Livewire wire:navigate where the DOM is replaced and new tables need to be initialized.
8530
+ */
8531
+ KTDataTable.reinit = function () {
8532
+ if (typeof document === 'undefined')
8533
+ return;
8534
+ var elements = document.querySelectorAll('[data-kt-datatable="true"]');
8535
+ elements.forEach(function (element) {
8536
+ try {
8537
+ var instance = KTDataTable.getInstance(element);
8538
+ if (instance && typeof instance.dispose === 'function') {
8539
+ instance.dispose();
8540
+ }
8541
+ data_1.default.remove(element, 'datatable');
8542
+ element.removeAttribute('data-kt-datatable-initialized');
8543
+ element.classList.remove('datatable-initialized');
8544
+ }
8545
+ catch (_a) {
8546
+ // ignore per-element errors
8547
+ }
8548
+ });
8549
+ KTDataTable._instances.clear();
8418
8550
  KTDataTable.createInstances();
8419
8551
  };
8420
8552
  /**
@@ -11018,14 +11150,17 @@ var KTSelect = /** @class */ (function (_super) {
11018
11150
  }
11019
11151
  else {
11020
11152
  // Tags are not enabled AND options are selected: render normal text display.
11021
- var content = '';
11153
+ // Wrap content in .kt-select-option-text so long text truncates in single-select (see Asana #1212821478465094).
11154
+ var wrapper = document.createElement('div');
11155
+ wrapper.className = 'kt-select-option-text';
11156
+ wrapper.setAttribute('data-kt-text-container', 'true');
11022
11157
  if (this._config.displayTemplate) {
11023
- content = this.renderDisplayTemplateForSelected(this.getSelectedOptions());
11158
+ wrapper.innerHTML = this.renderDisplayTemplateForSelected(this.getSelectedOptions());
11024
11159
  }
11025
11160
  else {
11026
- content = this.getSelectedOptionsText();
11161
+ wrapper.textContent = this.getSelectedOptionsText();
11027
11162
  }
11028
- valueDisplayEl.innerHTML = content;
11163
+ valueDisplayEl.replaceChildren(wrapper);
11029
11164
  }
11030
11165
  }
11031
11166
  }
@@ -12421,6 +12556,8 @@ var KTDropdown = /** @class */ (function (_super) {
12421
12556
  _this._disabled = false;
12422
12557
  _this._isTransitioning = false;
12423
12558
  _this._isOpen = false;
12559
+ /** Timestamp when _show() was last called; used to ignore duplicate _hide() from double handlers */
12560
+ _this._shownAt = 0;
12424
12561
  if (data_1.default.has(element, _this._name)) {
12425
12562
  return _this;
12426
12563
  }
@@ -12546,11 +12683,15 @@ var KTDropdown = /** @class */ (function (_super) {
12546
12683
  _this._fireEvent('shown');
12547
12684
  _this._dispatchEvent('shown');
12548
12685
  });
12686
+ this._shownAt = Date.now();
12549
12687
  };
12550
12688
  KTDropdown.prototype._hide = function () {
12551
12689
  var _this = this;
12552
12690
  if (!this._isOpen || this._isTransitioning)
12553
12691
  return;
12692
+ // If another handler fired _hide() right after _show() (e.g. double initHandlers), ignore
12693
+ if (this._shownAt && Date.now() - this._shownAt < 150)
12694
+ return;
12554
12695
  var payload = { cancel: false };
12555
12696
  this._fireEvent('hide', payload);
12556
12697
  this._dispatchEvent('hide', payload);