@keenthemes/ktui 1.1.4 → 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.
- package/dist/ktui.js +174 -49
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/lib/cjs/components/component.js +9 -0
- package/lib/cjs/components/component.js.map +1 -1
- package/lib/cjs/components/datatable/datatable-sort.js +80 -10
- package/lib/cjs/components/datatable/datatable-sort.js.map +1 -1
- package/lib/cjs/components/datatable/datatable.js +36 -5
- package/lib/cjs/components/datatable/datatable.js.map +1 -1
- package/lib/cjs/components/drawer/drawer.js +43 -34
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js +6 -0
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/select/select.js +7 -4
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/esm/components/component.js +9 -0
- package/lib/esm/components/component.js.map +1 -1
- package/lib/esm/components/datatable/datatable-sort.js +80 -10
- package/lib/esm/components/datatable/datatable-sort.js.map +1 -1
- package/lib/esm/components/datatable/datatable.js +36 -5
- package/lib/esm/components/datatable/datatable.js.map +1 -1
- package/lib/esm/components/drawer/drawer.js +43 -34
- package/lib/esm/components/drawer/drawer.js.map +1 -1
- package/lib/esm/components/dropdown/dropdown.js +6 -0
- package/lib/esm/components/dropdown/dropdown.js.map +1 -1
- package/lib/esm/components/select/select.js +7 -4
- package/lib/esm/components/select/select.js.map +1 -1
- package/package.json +1 -1
- package/src/components/component.ts +10 -0
- package/src/components/datatable/datatable-sort.ts +89 -7
- package/src/components/datatable/datatable.ts +44 -13
- package/src/components/datatable/types.ts +14 -0
- package/src/components/drawer/drawer.ts +38 -35
- package/src/components/drawer/types.ts +4 -2
- package/src/components/dropdown/dropdown.ts +5 -0
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
|
-
//
|
|
262
|
-
//
|
|
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
|
-
|
|
265
|
-
if (!
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(/<[^>]*>| /g, '');
|
|
6278
6296
|
var bText = String(b).replace(/<[^>]*>| /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
|
|
6292
|
-
var
|
|
6293
|
-
|
|
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
|
|
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
|
-
? ((
|
|
6314
|
-
: ((
|
|
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
|
-
?
|
|
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(
|
|
6402
|
+
var sortElement = th.querySelector(".".concat(baseClass));
|
|
6321
6403
|
if (sortElement) {
|
|
6322
6404
|
sortElement.className =
|
|
6323
|
-
"".concat(
|
|
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();
|
|
@@ -7819,6 +7913,8 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
7819
7913
|
var ths = Array.from(allThs).filter(function (th) {
|
|
7820
7914
|
return th.hasAttribute('data-kt-datatable-column');
|
|
7821
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);
|
|
7822
7918
|
this._data.forEach(function (item, rowIndex) {
|
|
7823
7919
|
var row = document.createElement('tr');
|
|
7824
7920
|
// Apply original tr class if available
|
|
@@ -7829,8 +7925,8 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
7829
7925
|
var dataRowAttributes_1 = _this.getState().originalDataAttributes
|
|
7830
7926
|
? _this.getState().originalDataAttributes[rowIndex]
|
|
7831
7927
|
: null;
|
|
7832
|
-
// Use
|
|
7833
|
-
|
|
7928
|
+
// Use columnsToRender so tables without data-kt-datatable-column still get cells (by index)
|
|
7929
|
+
columnsToRender.forEach(function (th, colIndex) {
|
|
7834
7930
|
var colName = th.getAttribute('data-kt-datatable-column');
|
|
7835
7931
|
var td = document.createElement('td');
|
|
7836
7932
|
var value;
|
|
@@ -8426,8 +8522,31 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
8426
8522
|
KTDataTable.init = function () {
|
|
8427
8523
|
if (typeof document === 'undefined')
|
|
8428
8524
|
return;
|
|
8429
|
-
|
|
8430
|
-
|
|
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();
|
|
8431
8550
|
KTDataTable.createInstances();
|
|
8432
8551
|
};
|
|
8433
8552
|
/**
|
|
@@ -12437,6 +12556,8 @@ var KTDropdown = /** @class */ (function (_super) {
|
|
|
12437
12556
|
_this._disabled = false;
|
|
12438
12557
|
_this._isTransitioning = false;
|
|
12439
12558
|
_this._isOpen = false;
|
|
12559
|
+
/** Timestamp when _show() was last called; used to ignore duplicate _hide() from double handlers */
|
|
12560
|
+
_this._shownAt = 0;
|
|
12440
12561
|
if (data_1.default.has(element, _this._name)) {
|
|
12441
12562
|
return _this;
|
|
12442
12563
|
}
|
|
@@ -12562,11 +12683,15 @@ var KTDropdown = /** @class */ (function (_super) {
|
|
|
12562
12683
|
_this._fireEvent('shown');
|
|
12563
12684
|
_this._dispatchEvent('shown');
|
|
12564
12685
|
});
|
|
12686
|
+
this._shownAt = Date.now();
|
|
12565
12687
|
};
|
|
12566
12688
|
KTDropdown.prototype._hide = function () {
|
|
12567
12689
|
var _this = this;
|
|
12568
12690
|
if (!this._isOpen || this._isTransitioning)
|
|
12569
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;
|
|
12570
12695
|
var payload = { cancel: false };
|
|
12571
12696
|
this._fireEvent('hide', payload);
|
|
12572
12697
|
this._dispatchEvent('hide', payload);
|