@keenthemes/ktui 1.0.10 → 1.0.12
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/README.md +2 -2
- package/dist/ktui.js +1283 -1100
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/examples/select/basic-usage.html +43 -0
- package/examples/select/combobox-icons.html +58 -0
- package/examples/select/combobox.html +46 -0
- package/examples/select/description.html +69 -0
- package/examples/select/disable-option.html +43 -0
- package/examples/select/disable-select.html +34 -0
- package/examples/select/icon-description.html +56 -0
- package/examples/select/icon-multiple.html +58 -0
- package/examples/select/icon.html +58 -0
- package/examples/select/max-selection.html +39 -0
- package/examples/select/modal.html +70 -0
- package/examples/select/multiple.html +42 -0
- package/examples/select/placeholder.html +43 -0
- package/examples/select/remote-data.html +32 -0
- package/examples/select/search.html +49 -0
- package/examples/select/tags-icons.html +58 -0
- package/examples/select/tags-selected.html +59 -0
- package/examples/select/tags.html +58 -0
- package/examples/select/template-customization.html +65 -0
- package/examples/select/test.html +94 -0
- package/examples/toast/example.html +427 -0
- package/lib/cjs/components/component.js +1 -1
- package/lib/cjs/components/component.js.map +1 -1
- package/lib/cjs/components/datatable/datatable.js +22 -6
- package/lib/cjs/components/datatable/datatable.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +0 -4
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/select/combobox.js +38 -120
- package/lib/cjs/components/select/combobox.js.map +1 -1
- package/lib/cjs/components/select/config.js +4 -16
- package/lib/cjs/components/select/config.js.map +1 -1
- package/lib/cjs/components/select/dropdown.js +10 -49
- package/lib/cjs/components/select/dropdown.js.map +1 -1
- package/lib/cjs/components/select/index.js +2 -1
- package/lib/cjs/components/select/index.js.map +1 -1
- package/lib/cjs/components/select/option.js +21 -4
- package/lib/cjs/components/select/option.js.map +1 -1
- package/lib/cjs/components/select/remote.js +1 -37
- package/lib/cjs/components/select/remote.js.map +1 -1
- package/lib/cjs/components/select/search.js +11 -41
- package/lib/cjs/components/select/search.js.map +1 -1
- package/lib/cjs/components/select/select.js +213 -326
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/select/tags.js +39 -31
- package/lib/cjs/components/select/tags.js.map +1 -1
- package/lib/cjs/components/select/templates.js +120 -179
- package/lib/cjs/components/select/templates.js.map +1 -1
- package/lib/cjs/components/select/types.js +0 -12
- package/lib/cjs/components/select/types.js.map +1 -1
- package/lib/cjs/components/select/utils.js +204 -257
- package/lib/cjs/components/select/utils.js.map +1 -1
- package/lib/cjs/components/toast/index.js +10 -0
- package/lib/cjs/components/toast/index.js.map +1 -0
- package/lib/cjs/components/toast/toast.js +543 -0
- package/lib/cjs/components/toast/toast.js.map +1 -0
- package/lib/cjs/components/toast/types.js +7 -0
- package/lib/cjs/components/toast/types.js.map +1 -0
- package/lib/cjs/helpers/dom.js +24 -0
- package/lib/cjs/helpers/dom.js.map +1 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/component.js +1 -1
- package/lib/esm/components/component.js.map +1 -1
- package/lib/esm/components/datatable/datatable.js +22 -6
- package/lib/esm/components/datatable/datatable.js.map +1 -1
- package/lib/esm/components/modal/modal.js +0 -4
- package/lib/esm/components/modal/modal.js.map +1 -1
- package/lib/esm/components/select/combobox.js +39 -121
- package/lib/esm/components/select/combobox.js.map +1 -1
- package/lib/esm/components/select/config.js +3 -15
- package/lib/esm/components/select/config.js.map +1 -1
- package/lib/esm/components/select/dropdown.js +10 -49
- package/lib/esm/components/select/dropdown.js.map +1 -1
- package/lib/esm/components/select/index.js +1 -1
- package/lib/esm/components/select/index.js.map +1 -1
- package/lib/esm/components/select/option.js +21 -4
- package/lib/esm/components/select/option.js.map +1 -1
- package/lib/esm/components/select/remote.js +1 -37
- package/lib/esm/components/select/remote.js.map +1 -1
- package/lib/esm/components/select/search.js +12 -42
- package/lib/esm/components/select/search.js.map +1 -1
- package/lib/esm/components/select/select.js +214 -327
- package/lib/esm/components/select/select.js.map +1 -1
- package/lib/esm/components/select/tags.js +39 -31
- package/lib/esm/components/select/tags.js.map +1 -1
- package/lib/esm/components/select/templates.js +119 -178
- package/lib/esm/components/select/templates.js.map +1 -1
- package/lib/esm/components/select/types.js +1 -11
- package/lib/esm/components/select/types.js.map +1 -1
- package/lib/esm/components/select/utils.js +201 -255
- package/lib/esm/components/select/utils.js.map +1 -1
- package/lib/esm/components/toast/index.js +6 -0
- package/lib/esm/components/toast/index.js.map +1 -0
- package/lib/esm/components/toast/toast.js +540 -0
- package/lib/esm/components/toast/toast.js.map +1 -0
- package/lib/esm/components/toast/types.js +6 -0
- package/lib/esm/components/toast/types.js.map +1 -0
- package/lib/esm/helpers/dom.js +24 -0
- package/lib/esm/helpers/dom.js.map +1 -1
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -1
- package/package.json +8 -6
- package/src/components/alert/alert.css +20 -2
- package/src/components/badge/badge.css +5 -0
- package/src/components/component.ts +4 -0
- package/src/components/datatable/datatable.ts +24 -16
- package/src/components/drawer/drawer.css +1 -1
- package/src/components/input/input.css +3 -1
- package/src/components/link/link.css +2 -2
- package/src/components/modal/modal.css +18 -2
- package/src/components/modal/modal.ts +0 -5
- package/src/components/select/combobox.ts +42 -149
- package/src/components/select/config.ts +38 -33
- package/src/components/select/dropdown.ts +8 -55
- package/src/components/select/index.ts +1 -1
- package/src/components/select/option.ts +28 -7
- package/src/components/select/remote.ts +2 -42
- package/src/components/select/search.ts +14 -54
- package/src/components/select/select.css +49 -0
- package/src/components/select/select.ts +231 -437
- package/src/components/select/tags.ts +40 -37
- package/src/components/select/templates.ts +166 -303
- package/src/components/select/types.ts +0 -10
- package/src/components/select/utils.ts +214 -304
- package/src/components/table/table.css +1 -1
- package/src/components/textarea/textarea.css +2 -1
- package/src/components/toast/index.ts +7 -0
- package/src/components/toast/toast.css +60 -0
- package/src/components/toast/toast.ts +605 -0
- package/src/components/toast/types.ts +169 -0
- package/src/helpers/dom.ts +30 -0
- package/src/index.ts +4 -0
- package/styles/main.css +3 -0
- package/styles/vars.css +138 -0
- package/styles.css +1 -0
package/dist/ktui.js
CHANGED
|
@@ -21,7 +21,7 @@ return /******/ (function() { // webpackBootstrap
|
|
|
21
21
|
* Copyright 2025 by Keenthemes Inc
|
|
22
22
|
*/
|
|
23
23
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24
|
-
exports.EventManager = exports.FocusManager = exports.filterOptions = exports.KTSelectDropdown = exports.KTSelectTags = exports.KTSelectSearch = exports.KTSelectCombobox = exports.KTSelectRemote = exports.KTSelect = void 0;
|
|
24
|
+
exports.TypeToSearchBuffer = exports.EventManager = exports.FocusManager = exports.filterOptions = exports.KTSelectDropdown = exports.KTSelectTags = exports.KTSelectSearch = exports.KTSelectCombobox = exports.KTSelectRemote = exports.KTSelect = void 0;
|
|
25
25
|
var select_1 = __webpack_require__(8016);
|
|
26
26
|
Object.defineProperty(exports, "KTSelect", ({ enumerable: true, get: function () { return select_1.KTSelect; } }));
|
|
27
27
|
var remote_1 = __webpack_require__(3710);
|
|
@@ -38,6 +38,7 @@ var utils_1 = __webpack_require__(9011);
|
|
|
38
38
|
Object.defineProperty(exports, "filterOptions", ({ enumerable: true, get: function () { return utils_1.filterOptions; } }));
|
|
39
39
|
Object.defineProperty(exports, "FocusManager", ({ enumerable: true, get: function () { return utils_1.FocusManager; } }));
|
|
40
40
|
Object.defineProperty(exports, "EventManager", ({ enumerable: true, get: function () { return utils_1.EventManager; } }));
|
|
41
|
+
Object.defineProperty(exports, "TypeToSearchBuffer", ({ enumerable: true, get: function () { return utils_1.TypeToSearchBuffer; } }));
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
/***/ }),
|
|
@@ -2452,7 +2453,7 @@ var KTComponent = /** @class */ (function () {
|
|
|
2452
2453
|
if (config === void 0) { config = {}; }
|
|
2453
2454
|
if (!this._element)
|
|
2454
2455
|
return;
|
|
2455
|
-
this._config = __assign(__assign(__assign(__assign({}, this._defaultConfig), this._getGlobalConfig()), dom_1.default.getDataAttributes(this._element, this._dataOptionPrefix + this._name)), config);
|
|
2456
|
+
this._config = __assign(__assign(__assign(__assign(__assign({}, this._defaultConfig), this._getGlobalConfig()), dom_1.default.getDataAttributes(this._element, this._dataOptionPrefix + this._name)), dom_1.default.getDataAttributesByJson(this._element, this._dataOptionPrefix + this._name + '-config')), config);
|
|
2456
2457
|
};
|
|
2457
2458
|
KTComponent.prototype.dispose = function () {
|
|
2458
2459
|
if (!this._element)
|
|
@@ -3266,10 +3267,8 @@ var KTSelectRemote = /** @class */ (function () {
|
|
|
3266
3267
|
// Get the field mapping from config with fallbacks for common field names
|
|
3267
3268
|
var valueField = this._config.dataValueField || 'id';
|
|
3268
3269
|
var labelField = this._config.dataFieldText || 'title';
|
|
3269
|
-
var descriptionField = this._config.dataFieldDescription || 'description';
|
|
3270
|
-
var iconField = this._config.dataFieldIcon || 'icon';
|
|
3271
3270
|
if (this._config.debug)
|
|
3272
|
-
console.log("Mapping fields: value=".concat(valueField, ", label=").concat(labelField
|
|
3271
|
+
console.log("Mapping fields: value=".concat(valueField, ", label=").concat(labelField));
|
|
3273
3272
|
if (this._config.debug)
|
|
3274
3273
|
console.log('Item data:', JSON.stringify(item).substring(0, 200) + '...'); // Trimmed for readability
|
|
3275
3274
|
// Extract values using dot notation if needed
|
|
@@ -3360,44 +3359,10 @@ var KTSelectRemote = /** @class */ (function () {
|
|
|
3360
3359
|
if (this._config.debug)
|
|
3361
3360
|
console.log('After fallback checks, title:', title);
|
|
3362
3361
|
}
|
|
3363
|
-
// Get description - make sure we don't pass null, undefined, or "null" string values
|
|
3364
|
-
var description = getValue(item, descriptionField);
|
|
3365
|
-
if (description === null ||
|
|
3366
|
-
description === undefined ||
|
|
3367
|
-
String(description) === 'null' ||
|
|
3368
|
-
String(description) === 'undefined') {
|
|
3369
|
-
description = null;
|
|
3370
|
-
}
|
|
3371
|
-
else {
|
|
3372
|
-
description = String(description);
|
|
3373
|
-
}
|
|
3374
|
-
if (this._config.debug)
|
|
3375
|
-
console.log("Description field [".concat(descriptionField, "]:"), description);
|
|
3376
|
-
// Try to get an icon - make sure we don't pass null, undefined, or "null" string values
|
|
3377
|
-
var icon = getValue(item, iconField);
|
|
3378
|
-
if (icon === null ||
|
|
3379
|
-
icon === undefined ||
|
|
3380
|
-
String(icon) === 'null' ||
|
|
3381
|
-
String(icon) === 'undefined') {
|
|
3382
|
-
icon = null;
|
|
3383
|
-
}
|
|
3384
|
-
else {
|
|
3385
|
-
icon = String(icon);
|
|
3386
|
-
}
|
|
3387
|
-
if (this._config.debug)
|
|
3388
|
-
console.log("Icon field [".concat(iconField, "]:"), icon);
|
|
3389
|
-
// If ID is null, use the title as fallback
|
|
3390
|
-
if (id === null || id === '') {
|
|
3391
|
-
id = title;
|
|
3392
|
-
if (this._config.debug)
|
|
3393
|
-
console.log("Using title as fallback for ID: ".concat(id));
|
|
3394
|
-
}
|
|
3395
3362
|
// Create the option object with non-empty values
|
|
3396
3363
|
var result = {
|
|
3397
3364
|
id: id || title || 'id-' + Math.random().toString(36).substr(2, 9), // Ensure we always have an ID
|
|
3398
3365
|
title: title || 'Unnamed option',
|
|
3399
|
-
description: description,
|
|
3400
|
-
icon: icon,
|
|
3401
3366
|
};
|
|
3402
3367
|
if (this._config.debug)
|
|
3403
3368
|
console.log('Final mapped item:', JSON.stringify(result));
|
|
@@ -5702,6 +5667,11 @@ var KTSelectOption = /** @class */ (function (_super) {
|
|
|
5702
5667
|
_this._init(element);
|
|
5703
5668
|
_this._buildConfig();
|
|
5704
5669
|
_this._globalConfig = config;
|
|
5670
|
+
// Clean the config
|
|
5671
|
+
_this._config = _this._config[''] || {};
|
|
5672
|
+
// Add the option config to the global config
|
|
5673
|
+
_this._globalConfig.optionsConfig = _this._globalConfig.optionsConfig || {};
|
|
5674
|
+
_this._globalConfig.optionsConfig[element.value] = _this._config;
|
|
5705
5675
|
// Don't store in KTData to avoid Singleton pattern issues
|
|
5706
5676
|
// Each option should be a unique instance
|
|
5707
5677
|
element.instance = _this;
|
|
@@ -5711,11 +5681,23 @@ var KTSelectOption = /** @class */ (function (_super) {
|
|
|
5711
5681
|
return this._element;
|
|
5712
5682
|
};
|
|
5713
5683
|
KTSelectOption.prototype.render = function () {
|
|
5684
|
+
var _this = this;
|
|
5714
5685
|
var optionElement = this.getHTMLOptionElement();
|
|
5715
|
-
//
|
|
5716
|
-
var
|
|
5717
|
-
|
|
5718
|
-
|
|
5686
|
+
// Get the original template
|
|
5687
|
+
var originalTemplate = this._globalConfig.optionTemplate;
|
|
5688
|
+
if (this._globalConfig.optionTemplate) {
|
|
5689
|
+
// Replace all {{varname}} in option.innerHTML with values from _config
|
|
5690
|
+
Object.entries(this._config || {}).forEach(function (_a) {
|
|
5691
|
+
var key = _a[0], value = _a[1];
|
|
5692
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
5693
|
+
_this._globalConfig.optionTemplate = _this._globalConfig.optionTemplate.replace(new RegExp("{{".concat(key, "}}"), 'g'), String(value));
|
|
5694
|
+
}
|
|
5695
|
+
});
|
|
5696
|
+
}
|
|
5697
|
+
var template = templates_1.defaultTemplates.option(optionElement, this._globalConfig);
|
|
5698
|
+
// Restore the original template
|
|
5699
|
+
this._globalConfig.optionTemplate = originalTemplate;
|
|
5700
|
+
return template;
|
|
5719
5701
|
};
|
|
5720
5702
|
return KTSelectOption;
|
|
5721
5703
|
}(component_1.default));
|
|
@@ -6538,6 +6520,8 @@ var utils_1 = __webpack_require__(9011);
|
|
|
6538
6520
|
*/
|
|
6539
6521
|
var KTSelectCombobox = /** @class */ (function () {
|
|
6540
6522
|
function KTSelectCombobox(select) {
|
|
6523
|
+
var _this = this;
|
|
6524
|
+
var _a;
|
|
6541
6525
|
this._select = select;
|
|
6542
6526
|
this._config = select.getConfig();
|
|
6543
6527
|
// Get the display element (could be the input directly or a parent div)
|
|
@@ -6547,17 +6531,36 @@ var KTSelectCombobox = /** @class */ (function () {
|
|
|
6547
6531
|
displayElement.tagName === 'INPUT'
|
|
6548
6532
|
? displayElement
|
|
6549
6533
|
: displayElement.querySelector('input[data-kt-select-search]');
|
|
6550
|
-
// Find the clear button
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6534
|
+
// Find the clear button robustly
|
|
6535
|
+
var clearButtonContainer = null;
|
|
6536
|
+
if (displayElement.tagName === 'DIV') {
|
|
6537
|
+
clearButtonContainer = displayElement;
|
|
6538
|
+
}
|
|
6539
|
+
else if (displayElement.tagName === 'INPUT') {
|
|
6540
|
+
clearButtonContainer = displayElement.parentElement;
|
|
6541
|
+
}
|
|
6542
|
+
this._clearButtonElement = clearButtonContainer
|
|
6543
|
+
? clearButtonContainer.querySelector('[data-kt-select-clear-button]')
|
|
6544
|
+
: null;
|
|
6545
|
+
this._valuesContainerElement = (_a = displayElement === null || displayElement === void 0 ? void 0 : displayElement.closest('[data-kt-select-combobox]')) === null || _a === void 0 ? void 0 : _a.querySelector('[data-kt-select-combobox-values]');
|
|
6555
6546
|
// Create bound handler references to allow proper cleanup
|
|
6556
|
-
this._boundKeyNavHandler = this._handleComboboxKeyNav.bind(this);
|
|
6557
6547
|
this._boundInputHandler = this._handleComboboxInput.bind(this);
|
|
6558
6548
|
this._boundClearHandler = this._handleClearButtonClick.bind(this);
|
|
6559
6549
|
// Attach event listeners
|
|
6560
6550
|
this._attachEventListeners();
|
|
6551
|
+
// Reset combobox search state when dropdown closes
|
|
6552
|
+
this._select.getElement().addEventListener('dropdown.close', function () {
|
|
6553
|
+
_this._searchInputElement.value = '';
|
|
6554
|
+
// this._toggleClearButtonVisibility('');
|
|
6555
|
+
_this._select.showAllOptions();
|
|
6556
|
+
});
|
|
6557
|
+
// When selection changes, update the input value to the selected option's text
|
|
6558
|
+
// this._select.getElement().addEventListener('change', () => {
|
|
6559
|
+
// // Only update the input value, do not reset the filter or show all options
|
|
6560
|
+
// const selectedValues = this._select.getSelectedOptions();
|
|
6561
|
+
// const content = this._select.renderDisplayTemplateForSelected(selectedValues);
|
|
6562
|
+
// this._valuesContainerElement?.append(stringToElement(content));
|
|
6563
|
+
// });
|
|
6561
6564
|
if (this._config.debug)
|
|
6562
6565
|
console.log('KTSelectCombobox initialized');
|
|
6563
6566
|
}
|
|
@@ -6569,8 +6572,6 @@ var KTSelectCombobox = /** @class */ (function () {
|
|
|
6569
6572
|
this._removeEventListeners();
|
|
6570
6573
|
// Add input event handler to filter options as user types
|
|
6571
6574
|
this._searchInputElement.addEventListener('input', this._boundInputHandler);
|
|
6572
|
-
// Add keyboard navigation for the combobox
|
|
6573
|
-
this._searchInputElement.addEventListener('keydown', this._boundKeyNavHandler);
|
|
6574
6575
|
// Add clear button click event listener
|
|
6575
6576
|
if (this._clearButtonElement) {
|
|
6576
6577
|
this._clearButtonElement.addEventListener('click', this._boundClearHandler);
|
|
@@ -6584,7 +6585,6 @@ var KTSelectCombobox = /** @class */ (function () {
|
|
|
6584
6585
|
KTSelectCombobox.prototype._removeEventListeners = function () {
|
|
6585
6586
|
if (this._searchInputElement) {
|
|
6586
6587
|
this._searchInputElement.removeEventListener('input', this._boundInputHandler);
|
|
6587
|
-
this._searchInputElement.removeEventListener('keydown', this._boundKeyNavHandler);
|
|
6588
6588
|
}
|
|
6589
6589
|
if (this._clearButtonElement) {
|
|
6590
6590
|
this._clearButtonElement.removeEventListener('click', this._boundClearHandler);
|
|
@@ -6599,7 +6599,7 @@ var KTSelectCombobox = /** @class */ (function () {
|
|
|
6599
6599
|
if (this._config.debug)
|
|
6600
6600
|
console.log('Combobox input event, query:', query);
|
|
6601
6601
|
// Toggle clear button visibility based on input value
|
|
6602
|
-
this._toggleClearButtonVisibility(query);
|
|
6602
|
+
// this._toggleClearButtonVisibility(query);
|
|
6603
6603
|
// If dropdown isn't open, open it when user starts typing
|
|
6604
6604
|
if (!this._select._dropdownIsOpen) {
|
|
6605
6605
|
this._select.openDropdown();
|
|
@@ -6616,12 +6616,16 @@ var KTSelectCombobox = /** @class */ (function () {
|
|
|
6616
6616
|
// Clear the input
|
|
6617
6617
|
this._searchInputElement.value = '';
|
|
6618
6618
|
// Hide the clear button
|
|
6619
|
-
this._toggleClearButtonVisibility('');
|
|
6619
|
+
// this._toggleClearButtonVisibility('');
|
|
6620
6620
|
// Show all options and open dropdown
|
|
6621
6621
|
this._select.showAllOptions();
|
|
6622
6622
|
this._select.openDropdown();
|
|
6623
6623
|
// Clear the current selection
|
|
6624
6624
|
this._select.clearSelection();
|
|
6625
|
+
// Clear the combobox values container if present (for displayTemplate)
|
|
6626
|
+
if (this._valuesContainerElement) {
|
|
6627
|
+
this._valuesContainerElement.innerHTML = '';
|
|
6628
|
+
}
|
|
6625
6629
|
// Focus on the input
|
|
6626
6630
|
this._searchInputElement.focus();
|
|
6627
6631
|
};
|
|
@@ -6642,115 +6646,11 @@ var KTSelectCombobox = /** @class */ (function () {
|
|
|
6642
6646
|
* Filter options for combobox based on input query
|
|
6643
6647
|
*/
|
|
6644
6648
|
KTSelectCombobox.prototype._filterOptionsForCombobox = function (query) {
|
|
6645
|
-
//
|
|
6646
|
-
this._select.
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
*/
|
|
6651
|
-
KTSelectCombobox.prototype._handleComboboxKeyNav = function (event) {
|
|
6652
|
-
if (this._config.debug)
|
|
6653
|
-
console.log('Combobox keydown event:', event.key);
|
|
6654
|
-
// Prevent event propagation to stop bubbling to other handlers
|
|
6655
|
-
event.stopPropagation();
|
|
6656
|
-
// Handle clear with Escape when dropdown is closed
|
|
6657
|
-
if (event.key === 'Escape' &&
|
|
6658
|
-
!this._select._dropdownIsOpen &&
|
|
6659
|
-
this._searchInputElement.value !== '') {
|
|
6660
|
-
event.preventDefault();
|
|
6661
|
-
this._searchInputElement.value = '';
|
|
6662
|
-
this._toggleClearButtonVisibility('');
|
|
6663
|
-
this._select.clearSelection();
|
|
6664
|
-
return;
|
|
6665
|
-
}
|
|
6666
|
-
// Handle dropdown visibility with special keys
|
|
6667
|
-
if (!this._select._dropdownIsOpen &&
|
|
6668
|
-
(event.key === 'ArrowDown' ||
|
|
6669
|
-
event.key === 'ArrowUp' ||
|
|
6670
|
-
event.key === 'Enter')) {
|
|
6671
|
-
if (this._config.debug)
|
|
6672
|
-
console.log('Opening dropdown from keyboard in combobox');
|
|
6673
|
-
this._select.openDropdown();
|
|
6674
|
-
event.preventDefault();
|
|
6675
|
-
// If it's arrow keys, also move focus
|
|
6676
|
-
if (event.key === 'ArrowDown') {
|
|
6677
|
-
this._select._focusNextOption();
|
|
6678
|
-
}
|
|
6679
|
-
else if (event.key === 'ArrowUp') {
|
|
6680
|
-
this._select._focusPreviousOption();
|
|
6681
|
-
}
|
|
6682
|
-
return;
|
|
6683
|
-
}
|
|
6684
|
-
// Use the shared keyboard navigation handler
|
|
6685
|
-
(0, utils_1.handleDropdownKeyNavigation)(event, this._select, {
|
|
6686
|
-
multiple: this._config.multiple,
|
|
6687
|
-
closeOnSelect: this._config.closeOnSelect,
|
|
6688
|
-
});
|
|
6689
|
-
};
|
|
6690
|
-
/**
|
|
6691
|
-
* Update the combobox input value when an option is selected
|
|
6692
|
-
*/
|
|
6693
|
-
KTSelectCombobox.prototype.updateSelectedValue = function (selectedText) {
|
|
6694
|
-
if (this._searchInputElement) {
|
|
6695
|
-
// Extract just the text content if it contains HTML
|
|
6696
|
-
var cleanText = selectedText;
|
|
6697
|
-
// If the text might contain HTML (when description is present)
|
|
6698
|
-
if (selectedText.includes('<') || selectedText.includes('>')) {
|
|
6699
|
-
// Create a temporary element to extract just the text
|
|
6700
|
-
var tempDiv = document.createElement('div');
|
|
6701
|
-
tempDiv.innerHTML = selectedText;
|
|
6702
|
-
// Find and use only the option-title text if available
|
|
6703
|
-
var titleElement = tempDiv.querySelector('[data-kt-option-title]');
|
|
6704
|
-
if (titleElement) {
|
|
6705
|
-
cleanText = titleElement.textContent || selectedText;
|
|
6706
|
-
}
|
|
6707
|
-
else {
|
|
6708
|
-
// Fallback to all text content if option-title not found
|
|
6709
|
-
cleanText = tempDiv.textContent || selectedText;
|
|
6710
|
-
}
|
|
6711
|
-
}
|
|
6712
|
-
// Set the input value directly for immediate feedback
|
|
6713
|
-
this._searchInputElement.value = cleanText;
|
|
6714
|
-
// Show the clear button if there's a value
|
|
6715
|
-
this._toggleClearButtonVisibility(cleanText);
|
|
6716
|
-
// Trigger an input event to ensure any input-based listeners are notified
|
|
6717
|
-
var inputEvent = new Event('input', { bubbles: true });
|
|
6718
|
-
this._searchInputElement.dispatchEvent(inputEvent);
|
|
6719
|
-
if (this._config.debug)
|
|
6720
|
-
console.log('Combobox value updated to:', cleanText);
|
|
6721
|
-
}
|
|
6722
|
-
};
|
|
6723
|
-
/**
|
|
6724
|
-
* Reset the input value to match the current selection
|
|
6725
|
-
* This can be called to sync the input with the current state
|
|
6726
|
-
*/
|
|
6727
|
-
KTSelectCombobox.prototype.resetInputValueToSelection = function () {
|
|
6728
|
-
var _a, _b;
|
|
6729
|
-
var selectedOptions = this._select.getSelectedOptions();
|
|
6730
|
-
if (selectedOptions.length > 0) {
|
|
6731
|
-
var selectedOption = Array.from(this._select.getOptionsElement()).find(function (opt) { return opt.dataset.value === selectedOptions[0]; });
|
|
6732
|
-
if (selectedOption) {
|
|
6733
|
-
// Find the option-title element to get just the title text
|
|
6734
|
-
var titleElement = selectedOption.querySelector('[data-kt-option-title]');
|
|
6735
|
-
var selectedText = '';
|
|
6736
|
-
if (titleElement) {
|
|
6737
|
-
// If it has a structured content with a title element
|
|
6738
|
-
selectedText = ((_a = titleElement.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
6739
|
-
}
|
|
6740
|
-
else {
|
|
6741
|
-
// Fallback to the whole text content
|
|
6742
|
-
selectedText = ((_b = selectedOption.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '';
|
|
6743
|
-
}
|
|
6744
|
-
this.updateSelectedValue(selectedText);
|
|
6745
|
-
}
|
|
6746
|
-
}
|
|
6747
|
-
else {
|
|
6748
|
-
// No selection, clear the input
|
|
6749
|
-
if (this._searchInputElement) {
|
|
6750
|
-
this._searchInputElement.value = '';
|
|
6751
|
-
this._toggleClearButtonVisibility('');
|
|
6752
|
-
}
|
|
6753
|
-
}
|
|
6649
|
+
// Use the same filter logic as KTSelectSearch
|
|
6650
|
+
var options = Array.from(this._select.getOptionsElement());
|
|
6651
|
+
var config = this._select.getConfig();
|
|
6652
|
+
var dropdownElement = this._select.getDropdownElement();
|
|
6653
|
+
(0, utils_1.filterOptions)(options, query, config, dropdownElement);
|
|
6754
6654
|
};
|
|
6755
6655
|
/**
|
|
6756
6656
|
* Destroy the combobox component and clean up event listeners
|
|
@@ -7169,6 +7069,22 @@ var stepper_1 = __webpack_require__(770);
|
|
|
7169
7069
|
Object.defineProperty(exports, "KTStepper", ({ enumerable: true, get: function () { return stepper_1.KTStepper; } }));
|
|
7170
7070
|
|
|
7171
7071
|
|
|
7072
|
+
/***/ }),
|
|
7073
|
+
|
|
7074
|
+
/***/ 6265:
|
|
7075
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7076
|
+
|
|
7077
|
+
|
|
7078
|
+
/**
|
|
7079
|
+
* KTUI - Free & Open-Source Tailwind UI Components by Keenthemes
|
|
7080
|
+
* Copyright 2025 by Keenthemes Inc
|
|
7081
|
+
*/
|
|
7082
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7083
|
+
exports.KTToast = void 0;
|
|
7084
|
+
var toast_1 = __webpack_require__(8834);
|
|
7085
|
+
Object.defineProperty(exports, "KTToast", ({ enumerable: true, get: function () { return toast_1.KTToast; } }));
|
|
7086
|
+
|
|
7087
|
+
|
|
7172
7088
|
/***/ }),
|
|
7173
7089
|
|
|
7174
7090
|
/***/ 6292:
|
|
@@ -7627,6 +7543,7 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
7627
7543
|
_this._originalTdClasses = []; // Store original td classes as a 2D array [row][col]
|
|
7628
7544
|
_this._originalThClasses = []; // Store original th classes
|
|
7629
7545
|
_this._data = [];
|
|
7546
|
+
_this._isFetching = false;
|
|
7630
7547
|
if (data_1.default.has(element, _this._name))
|
|
7631
7548
|
return _this;
|
|
7632
7549
|
_this._defaultConfig = _this._initDefaultConfig(config);
|
|
@@ -7930,11 +7847,21 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
7930
7847
|
KTDataTable.prototype._updateData = function () {
|
|
7931
7848
|
return __awaiter(this, void 0, void 0, function () {
|
|
7932
7849
|
return __generator(this, function (_a) {
|
|
7933
|
-
this.
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7850
|
+
if (this._isFetching)
|
|
7851
|
+
return [2 /*return*/]; // Prevent duplicate fetches
|
|
7852
|
+
this._isFetching = true;
|
|
7853
|
+
try {
|
|
7854
|
+
this._showSpinner(); // Show spinner before fetching data
|
|
7855
|
+
// Fetch data from the DOM and initialize the checkbox plugin
|
|
7856
|
+
return [2 /*return*/, typeof this._config.apiEndpoint === 'undefined'
|
|
7857
|
+
? this._fetchDataFromLocal().then(this._finalize.bind(this))
|
|
7858
|
+
: this._fetchDataFromServer().then(this._finalize.bind(this))];
|
|
7859
|
+
}
|
|
7860
|
+
finally {
|
|
7861
|
+
this._isFetching = false;
|
|
7862
|
+
}
|
|
7863
|
+
// removed by dead control flow
|
|
7864
|
+
{}
|
|
7938
7865
|
});
|
|
7939
7866
|
});
|
|
7940
7867
|
};
|
|
@@ -8374,7 +8301,13 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
8374
8301
|
td.className = _this._originalTdClasses[rowIndex][colIndex];
|
|
8375
8302
|
}
|
|
8376
8303
|
if (typeof columnDef.render === 'function') {
|
|
8377
|
-
|
|
8304
|
+
var result = columnDef.render.call(_this, item[key], item, _this);
|
|
8305
|
+
if (result instanceof HTMLElement || result instanceof DocumentFragment) {
|
|
8306
|
+
td.appendChild(result);
|
|
8307
|
+
}
|
|
8308
|
+
else if (typeof result === 'string') {
|
|
8309
|
+
td.innerHTML = result;
|
|
8310
|
+
}
|
|
8378
8311
|
}
|
|
8379
8312
|
else {
|
|
8380
8313
|
td.textContent = item[key];
|
|
@@ -9011,10 +8944,6 @@ var KTModal = /** @class */ (function (_super) {
|
|
|
9011
8944
|
if (this._isOpen || this._isTransitioning) {
|
|
9012
8945
|
return;
|
|
9013
8946
|
}
|
|
9014
|
-
//const beforeScroll = this.fireEvent('beforeScroll', this.el);
|
|
9015
|
-
//this.dispatch('beforeScroll.hs.scrollspy', this.el, this.el);
|
|
9016
|
-
//if (beforeScroll instanceof Promise) beforeScroll.then(() => scrollFn());
|
|
9017
|
-
//else scrollFn();
|
|
9018
8947
|
if (targetElement)
|
|
9019
8948
|
this._targetElement = targetElement;
|
|
9020
8949
|
var payload = { cancel: false };
|
|
@@ -9321,8 +9250,6 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9321
9250
|
KTSelectDropdown.prototype._setupEventListeners = function () {
|
|
9322
9251
|
// Toggle click
|
|
9323
9252
|
this._eventManager.addListener(this._toggleElement, 'click', this._handleToggleClick.bind(this));
|
|
9324
|
-
// Keyboard navigation
|
|
9325
|
-
this._eventManager.addListener(this._element, 'keydown', this._handleKeyDown.bind(this));
|
|
9326
9253
|
// Close on outside click
|
|
9327
9254
|
this._eventManager.addListener(document, 'click', this._handleOutsideClick.bind(this));
|
|
9328
9255
|
};
|
|
@@ -9334,47 +9261,6 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9334
9261
|
event.stopPropagation();
|
|
9335
9262
|
this.toggle();
|
|
9336
9263
|
};
|
|
9337
|
-
/**
|
|
9338
|
-
* Handle keyboard events
|
|
9339
|
-
*/
|
|
9340
|
-
KTSelectDropdown.prototype._handleKeyDown = function (event) {
|
|
9341
|
-
if (!this._isOpen)
|
|
9342
|
-
return;
|
|
9343
|
-
switch (event.key) {
|
|
9344
|
-
case 'Escape':
|
|
9345
|
-
event.preventDefault();
|
|
9346
|
-
this.close();
|
|
9347
|
-
this._toggleElement.focus();
|
|
9348
|
-
break;
|
|
9349
|
-
case 'ArrowDown':
|
|
9350
|
-
event.preventDefault();
|
|
9351
|
-
this._focusManager.focusNext();
|
|
9352
|
-
break;
|
|
9353
|
-
case 'ArrowUp':
|
|
9354
|
-
event.preventDefault();
|
|
9355
|
-
this._focusManager.focusPrevious();
|
|
9356
|
-
break;
|
|
9357
|
-
case 'Home':
|
|
9358
|
-
event.preventDefault();
|
|
9359
|
-
// Focus first visible option
|
|
9360
|
-
var firstOption = this._focusManager.getVisibleOptions()[0];
|
|
9361
|
-
if (firstOption) {
|
|
9362
|
-
this._focusManager.applyFocus(firstOption);
|
|
9363
|
-
this._focusManager.scrollIntoView(firstOption);
|
|
9364
|
-
}
|
|
9365
|
-
break;
|
|
9366
|
-
case 'End':
|
|
9367
|
-
event.preventDefault();
|
|
9368
|
-
// Focus last visible option
|
|
9369
|
-
var visibleOptions = this._focusManager.getVisibleOptions();
|
|
9370
|
-
var lastOption = visibleOptions[visibleOptions.length - 1];
|
|
9371
|
-
if (lastOption) {
|
|
9372
|
-
this._focusManager.applyFocus(lastOption);
|
|
9373
|
-
this._focusManager.scrollIntoView(lastOption);
|
|
9374
|
-
}
|
|
9375
|
-
break;
|
|
9376
|
-
}
|
|
9377
|
-
};
|
|
9378
9264
|
/**
|
|
9379
9265
|
* Handle clicks outside the dropdown
|
|
9380
9266
|
*/
|
|
@@ -9490,6 +9376,11 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9490
9376
|
* Toggle the dropdown
|
|
9491
9377
|
*/
|
|
9492
9378
|
KTSelectDropdown.prototype.toggle = function () {
|
|
9379
|
+
if (this._config.disabled) {
|
|
9380
|
+
if (this._config.debug)
|
|
9381
|
+
console.log('KTSelectDropdown.toggle: select is disabled, not toggling');
|
|
9382
|
+
return;
|
|
9383
|
+
}
|
|
9493
9384
|
if (this._config.debug)
|
|
9494
9385
|
console.log('KTSelectDropdown.toggle called - isOpen:', this._isOpen);
|
|
9495
9386
|
if (this._isTransitioning) {
|
|
@@ -9509,6 +9400,11 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9509
9400
|
*/
|
|
9510
9401
|
KTSelectDropdown.prototype.open = function () {
|
|
9511
9402
|
var _this = this;
|
|
9403
|
+
if (this._config.disabled) {
|
|
9404
|
+
if (this._config.debug)
|
|
9405
|
+
console.log('KTSelectDropdown.open: select is disabled, not opening');
|
|
9406
|
+
return;
|
|
9407
|
+
}
|
|
9512
9408
|
if (this._isOpen || this._isTransitioning)
|
|
9513
9409
|
return;
|
|
9514
9410
|
// Fire before show event
|
|
@@ -9558,12 +9454,6 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9558
9454
|
if (searchInput) {
|
|
9559
9455
|
searchInput.focus();
|
|
9560
9456
|
}
|
|
9561
|
-
else {
|
|
9562
|
-
_this._focusFirstOption();
|
|
9563
|
-
}
|
|
9564
|
-
}
|
|
9565
|
-
else {
|
|
9566
|
-
_this._focusFirstOption();
|
|
9567
9457
|
}
|
|
9568
9458
|
// Fire after show event
|
|
9569
9459
|
var afterShowEvent = new CustomEvent('kt.select.dropdown.shown', {
|
|
@@ -10007,7 +9897,6 @@ var KTSelectSearch = /** @class */ (function () {
|
|
|
10007
9897
|
this._searchInput = select.getSearchInput();
|
|
10008
9898
|
this._eventManager = new utils_1.EventManager();
|
|
10009
9899
|
this._focusManager = new utils_1.FocusManager(this._select.getDropdownElement(), '[data-kt-select-option]', select.getConfig());
|
|
10010
|
-
this._boundKeyNavHandler = this._handleKeyboardNavigation.bind(this);
|
|
10011
9900
|
this.handleSearchInput = this._handleSearchInput.bind(this);
|
|
10012
9901
|
this._config = select.getConfig();
|
|
10013
9902
|
this._cacheOriginalOptionContents();
|
|
@@ -10047,21 +9936,13 @@ var KTSelectSearch = /** @class */ (function () {
|
|
|
10047
9936
|
_this.refreshOptionCache();
|
|
10048
9937
|
});
|
|
10049
9938
|
}
|
|
10050
|
-
// Add keyboard navigation for search results
|
|
10051
|
-
// This is stopping event propagation to prevent conflicts
|
|
10052
|
-
this._eventManager.addListener(this._searchInput, 'keydown', this._boundKeyNavHandler);
|
|
10053
9939
|
// Listen for dropdown close to reset options if search is empty
|
|
10054
9940
|
this._select.getElement().addEventListener('dropdown.close', function () {
|
|
10055
9941
|
_this._focusManager.resetFocus();
|
|
10056
|
-
// Always clear highlights when dropdown closes
|
|
10057
9942
|
_this.clearSearchHighlights();
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
// Clear the search input when dropdown closes if configured
|
|
10062
|
-
if (_this._select.getConfig().clearSearchOnClose) {
|
|
10063
|
-
_this._searchInput.value = '';
|
|
10064
|
-
}
|
|
9943
|
+
_this._searchInput.value = '';
|
|
9944
|
+
_this._resetAllOptions();
|
|
9945
|
+
_this._clearNoResultsMessage();
|
|
10065
9946
|
});
|
|
10066
9947
|
// Clear highlights when an option is selected
|
|
10067
9948
|
this._select.getElement().addEventListener('change', function () {
|
|
@@ -10101,33 +9982,6 @@ var KTSelectSearch = /** @class */ (function () {
|
|
|
10101
9982
|
this._eventManager.removeAllListeners(this._searchInput);
|
|
10102
9983
|
}
|
|
10103
9984
|
};
|
|
10104
|
-
/**
|
|
10105
|
-
* Handle keyboard navigation for search results
|
|
10106
|
-
*/
|
|
10107
|
-
KTSelectSearch.prototype._handleKeyboardNavigation = function (event) {
|
|
10108
|
-
var _this = this;
|
|
10109
|
-
// Stop propagation to prevent multiple handlers from firing
|
|
10110
|
-
event.stopPropagation();
|
|
10111
|
-
if (this._config.debug)
|
|
10112
|
-
console.log('Search module keydown:', event.key);
|
|
10113
|
-
var visibleOptions = this._focusManager.getVisibleOptions();
|
|
10114
|
-
if (visibleOptions.length === 0)
|
|
10115
|
-
return;
|
|
10116
|
-
// Use the shared keyboard navigation handler with custom callbacks
|
|
10117
|
-
(0, utils_1.handleDropdownKeyNavigation)(event, this._select, {
|
|
10118
|
-
multiple: this._select.getConfig().multiple,
|
|
10119
|
-
closeOnSelect: this._select.getConfig().closeOnSelect,
|
|
10120
|
-
}, {
|
|
10121
|
-
onArrowDown: function () { return _this._focusManager.focusNext(); },
|
|
10122
|
-
onArrowUp: function () { return _this._focusManager.focusPrevious(); },
|
|
10123
|
-
onEnter: function () { return _this._selectFocusedOption(); },
|
|
10124
|
-
onClose: function () {
|
|
10125
|
-
if (event.key === 'Escape') {
|
|
10126
|
-
_this.clearSearchHighlights();
|
|
10127
|
-
}
|
|
10128
|
-
},
|
|
10129
|
-
});
|
|
10130
|
-
};
|
|
10131
9985
|
/**
|
|
10132
9986
|
* Select the currently focused option
|
|
10133
9987
|
*/
|
|
@@ -10257,9 +10111,9 @@ var KTSelectSearch = /** @class */ (function () {
|
|
|
10257
10111
|
KTSelectSearch.prototype._showNoResultsMessage = function () {
|
|
10258
10112
|
this._clearNoResultsMessage();
|
|
10259
10113
|
var config = this._select.getConfig();
|
|
10260
|
-
this._noResultsElement = templates_1.defaultTemplates.
|
|
10114
|
+
this._noResultsElement = templates_1.defaultTemplates.empty(config);
|
|
10261
10115
|
var dropdownElement = this._select.getDropdownElement();
|
|
10262
|
-
var optionsContainer = dropdownElement.querySelector('[data-kt-select-options
|
|
10116
|
+
var optionsContainer = dropdownElement.querySelector('[data-kt-select-options]');
|
|
10263
10117
|
if (optionsContainer) {
|
|
10264
10118
|
optionsContainer.appendChild(this._noResultsElement);
|
|
10265
10119
|
}
|
|
@@ -10295,6 +10149,12 @@ var KTSelectSearch = /** @class */ (function () {
|
|
|
10295
10149
|
*/
|
|
10296
10150
|
KTSelectSearch.prototype._clearDisplayHighlights = function () {
|
|
10297
10151
|
// Implementation for clearing display highlights
|
|
10152
|
+
var options = Array.from(this._select.getOptionsElement());
|
|
10153
|
+
options.forEach(function (option) {
|
|
10154
|
+
if (option.dataset && !option.dataset.originalText) {
|
|
10155
|
+
option.dataset.originalText = option.innerHTML;
|
|
10156
|
+
}
|
|
10157
|
+
});
|
|
10298
10158
|
};
|
|
10299
10159
|
/**
|
|
10300
10160
|
* This ensures that search highlighting works correctly with new options
|
|
@@ -11428,7 +11288,6 @@ var combobox_1 = __webpack_require__(5539);
|
|
|
11428
11288
|
var dropdown_1 = __webpack_require__(7125);
|
|
11429
11289
|
var utils_1 = __webpack_require__(9011);
|
|
11430
11290
|
var tags_1 = __webpack_require__(8797);
|
|
11431
|
-
var types_1 = __webpack_require__(8135);
|
|
11432
11291
|
var KTSelect = /** @class */ (function (_super) {
|
|
11433
11292
|
__extends(KTSelect, _super);
|
|
11434
11293
|
/**
|
|
@@ -11445,6 +11304,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11445
11304
|
_this._tagsModule = null;
|
|
11446
11305
|
_this._dropdownModule = null;
|
|
11447
11306
|
_this._loadMoreIndicator = null;
|
|
11307
|
+
_this._typeToSearchBuffer = new utils_1.TypeToSearchBuffer();
|
|
11448
11308
|
// Search debounce timeout
|
|
11449
11309
|
_this._searchDebounceTimeout = null;
|
|
11450
11310
|
// Store original options HTML for restoring after search
|
|
@@ -11529,11 +11389,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11529
11389
|
// Keep only the empty/placeholder option and remove the rest
|
|
11530
11390
|
var options = Array.from(this._element.querySelectorAll('option:not([value=""])'));
|
|
11531
11391
|
options.forEach(function (option) { return option.remove(); });
|
|
11532
|
-
// Ensure we have at least an empty option
|
|
11533
|
-
if (this._element.querySelectorAll('option').length === 0) {
|
|
11534
|
-
var emptyOption = templates_1.defaultTemplates.emptyOption(__assign(__assign({}, this._config), { placeholder: this._config.placeholder }));
|
|
11535
|
-
this._element.appendChild(emptyOption);
|
|
11536
|
-
}
|
|
11537
11392
|
};
|
|
11538
11393
|
/**
|
|
11539
11394
|
* Helper to show a dropdown message (error, loading, noResults)
|
|
@@ -11541,7 +11396,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11541
11396
|
KTSelect.prototype._showDropdownMessage = function (type, message) {
|
|
11542
11397
|
if (!this._dropdownContentElement)
|
|
11543
11398
|
return;
|
|
11544
|
-
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options
|
|
11399
|
+
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options]');
|
|
11545
11400
|
if (!optionsContainer)
|
|
11546
11401
|
return;
|
|
11547
11402
|
switch (type) {
|
|
@@ -11551,9 +11406,9 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11551
11406
|
case 'loading':
|
|
11552
11407
|
optionsContainer.innerHTML = templates_1.defaultTemplates.loading(this._config, message || 'Loading...').outerHTML;
|
|
11553
11408
|
break;
|
|
11554
|
-
case '
|
|
11409
|
+
case 'empty':
|
|
11555
11410
|
optionsContainer.innerHTML = '';
|
|
11556
|
-
optionsContainer.appendChild(templates_1.defaultTemplates.
|
|
11411
|
+
optionsContainer.appendChild(templates_1.defaultTemplates.empty(this._config));
|
|
11557
11412
|
break;
|
|
11558
11413
|
}
|
|
11559
11414
|
};
|
|
@@ -11572,14 +11427,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11572
11427
|
* @param message Error message
|
|
11573
11428
|
*/
|
|
11574
11429
|
KTSelect.prototype._renderErrorState = function (message) {
|
|
11575
|
-
// Create error option if the select is empty
|
|
11576
|
-
if (this._element.querySelectorAll('option').length <= 1) {
|
|
11577
|
-
var loadingOptions = this._element.querySelectorAll('option[disabled]:not([value])');
|
|
11578
|
-
loadingOptions.forEach(function (option) { return option.remove(); });
|
|
11579
|
-
// Use template function for error option instead of hardcoded element
|
|
11580
|
-
var errorOption = templates_1.defaultTemplates.errorOption(__assign(__assign({}, this._config), { errorMessage: message }));
|
|
11581
|
-
this._element.appendChild(errorOption);
|
|
11582
|
-
}
|
|
11583
11430
|
// If dropdown is already created, show error message there
|
|
11584
11431
|
this._showDropdownMessage('error', message);
|
|
11585
11432
|
if (!this._wrapperElement) {
|
|
@@ -11602,7 +11449,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11602
11449
|
// Create load more button using template
|
|
11603
11450
|
this._loadMoreIndicator = templates_1.defaultTemplates.loadMore(this._config);
|
|
11604
11451
|
// Add to dropdown
|
|
11605
|
-
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options
|
|
11452
|
+
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options]');
|
|
11606
11453
|
if (optionsContainer) {
|
|
11607
11454
|
optionsContainer.appendChild(this._loadMoreIndicator);
|
|
11608
11455
|
}
|
|
@@ -11672,42 +11519,26 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11672
11519
|
* @param newItems New items to add to the dropdown
|
|
11673
11520
|
*/
|
|
11674
11521
|
KTSelect.prototype._updateOptionsInDropdown = function (newItems) {
|
|
11675
|
-
var _this = this;
|
|
11676
11522
|
if (!this._dropdownContentElement || !newItems.length)
|
|
11677
11523
|
return;
|
|
11678
|
-
var optionsContainer = this._dropdownContentElement.querySelector(
|
|
11524
|
+
var optionsContainer = this._dropdownContentElement.querySelector("[data-kt-select-options]");
|
|
11679
11525
|
if (!optionsContainer)
|
|
11680
11526
|
return;
|
|
11681
11527
|
// Get the load more button
|
|
11682
|
-
var loadMoreButton = optionsContainer.querySelector(
|
|
11528
|
+
var loadMoreButton = optionsContainer.querySelector("[data-kt-select-load-more]");
|
|
11683
11529
|
// Process each new item
|
|
11684
11530
|
newItems.forEach(function (item) {
|
|
11685
11531
|
// Create option for the original select
|
|
11686
|
-
var selectOption =
|
|
11532
|
+
var selectOption = document.createElement('option');
|
|
11687
11533
|
selectOption.value = item.id || '';
|
|
11688
|
-
// Add description and icon attributes if available and valid
|
|
11689
|
-
if (item.description &&
|
|
11690
|
-
item.description !== 'null' &&
|
|
11691
|
-
item.description !== 'undefined') {
|
|
11692
|
-
selectOption.setAttribute('data-kt-select-option-description', item.description);
|
|
11693
|
-
}
|
|
11694
|
-
if (item.icon && item.icon !== 'null' && item.icon !== 'undefined') {
|
|
11695
|
-
selectOption.setAttribute('data-kt-select-option-icon', item.icon);
|
|
11696
|
-
}
|
|
11697
|
-
// Add the option to the original select element
|
|
11698
|
-
_this._element.appendChild(selectOption);
|
|
11699
|
-
// Create option element for the dropdown using the KTSelectOption class
|
|
11700
|
-
// This ensures consistent option rendering
|
|
11701
|
-
var ktOption = new option_1.KTSelectOption(selectOption, _this._config);
|
|
11702
|
-
var renderedOption = ktOption.render();
|
|
11703
11534
|
// Add to dropdown container
|
|
11704
11535
|
if (loadMoreButton) {
|
|
11705
11536
|
// Insert before the load more button
|
|
11706
|
-
optionsContainer.insertBefore(
|
|
11537
|
+
optionsContainer.insertBefore(selectOption, loadMoreButton);
|
|
11707
11538
|
}
|
|
11708
11539
|
else {
|
|
11709
11540
|
// Append to the end
|
|
11710
|
-
optionsContainer.appendChild(
|
|
11541
|
+
optionsContainer.appendChild(selectOption);
|
|
11711
11542
|
}
|
|
11712
11543
|
});
|
|
11713
11544
|
// Update options NodeList to include the new options
|
|
@@ -11729,7 +11560,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11729
11560
|
this._setupElementReferences();
|
|
11730
11561
|
this._initZIndex();
|
|
11731
11562
|
// Initialize options
|
|
11732
|
-
this._initializeOptionsHtml();
|
|
11563
|
+
// this._initializeOptionsHtml();
|
|
11733
11564
|
this._preSelectOptions(this._element);
|
|
11734
11565
|
// Apply disabled state if needed
|
|
11735
11566
|
this._applyInitialDisabledState();
|
|
@@ -11738,11 +11569,11 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11738
11569
|
this._initializeSearchModule();
|
|
11739
11570
|
}
|
|
11740
11571
|
// Initialize combobox if enabled
|
|
11741
|
-
if (this._config.
|
|
11572
|
+
if (this._config.combobox) {
|
|
11742
11573
|
this._comboboxModule = new combobox_1.KTSelectCombobox(this);
|
|
11743
11574
|
}
|
|
11744
11575
|
// Initialize tags if enabled
|
|
11745
|
-
if (this._config.
|
|
11576
|
+
if (this._config.tags) {
|
|
11746
11577
|
this._tagsModule = new tags_1.KTSelectTags(this);
|
|
11747
11578
|
}
|
|
11748
11579
|
// Initialize focus manager after dropdown element is created
|
|
@@ -11759,31 +11590,37 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11759
11590
|
/**
|
|
11760
11591
|
* Initialize options HTML from data
|
|
11761
11592
|
*/
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
}
|
|
11593
|
+
// private _initializeOptionsHtml() {
|
|
11594
|
+
// this._generateOptionsHtml(this._element);
|
|
11595
|
+
// }
|
|
11765
11596
|
/**
|
|
11766
11597
|
* Creates the HTML structure for the select component
|
|
11767
11598
|
*/
|
|
11768
11599
|
KTSelect.prototype._createHtmlStructure = function () {
|
|
11600
|
+
var _a;
|
|
11769
11601
|
var _this = this;
|
|
11770
11602
|
var options = Array.from(this._element.querySelectorAll('option'));
|
|
11771
11603
|
// Create wrapper and display elements
|
|
11772
|
-
var wrapperElement = templates_1.defaultTemplates.
|
|
11604
|
+
var wrapperElement = templates_1.defaultTemplates.wrapper(this._config);
|
|
11773
11605
|
var displayElement = templates_1.defaultTemplates.display(this._config);
|
|
11774
11606
|
// Add the display element to the wrapper
|
|
11775
11607
|
wrapperElement.appendChild(displayElement);
|
|
11608
|
+
// Move classes from original select to display element
|
|
11609
|
+
if (this._element.classList.length > 0) {
|
|
11610
|
+
(_a = displayElement.classList).add.apply(_a, Array.from(this._element.classList));
|
|
11611
|
+
this._element.className = '';
|
|
11612
|
+
}
|
|
11776
11613
|
// Create an empty dropdown first (without options) using template
|
|
11777
|
-
var dropdownElement = templates_1.defaultTemplates.
|
|
11614
|
+
var dropdownElement = templates_1.defaultTemplates.dropdown(__assign(__assign({}, this._config), { zindex: this._config.dropdownZindex }));
|
|
11778
11615
|
// Add search input if needed
|
|
11779
|
-
|
|
11780
|
-
var hasSearch = this._config.enableSearch && !isCombobox;
|
|
11781
|
-
if (hasSearch) {
|
|
11616
|
+
if (this._config.enableSearch) {
|
|
11782
11617
|
var searchElement = templates_1.defaultTemplates.search(this._config);
|
|
11783
11618
|
dropdownElement.appendChild(searchElement);
|
|
11784
11619
|
}
|
|
11785
11620
|
// Create options container using template
|
|
11786
|
-
var optionsContainer = templates_1.defaultTemplates.
|
|
11621
|
+
var optionsContainer = templates_1.defaultTemplates.options(this._config);
|
|
11622
|
+
// Clear the options container
|
|
11623
|
+
optionsContainer.innerHTML = '';
|
|
11787
11624
|
// Add each option directly to the container
|
|
11788
11625
|
options.forEach(function (optionElement) {
|
|
11789
11626
|
// Skip empty placeholder options (only if BOTH value AND text are empty)
|
|
@@ -11814,20 +11651,17 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11814
11651
|
// Get display element
|
|
11815
11652
|
this._displayElement = this._wrapperElement.querySelector("[data-kt-select-display]");
|
|
11816
11653
|
// Get dropdown content element - this is critical for dropdown functionality
|
|
11817
|
-
this._dropdownContentElement = this._wrapperElement.querySelector("[data-kt-select-dropdown
|
|
11654
|
+
this._dropdownContentElement = this._wrapperElement.querySelector("[data-kt-select-dropdown]");
|
|
11818
11655
|
if (!this._dropdownContentElement) {
|
|
11656
|
+
console.log(this._element);
|
|
11819
11657
|
console.error('Dropdown content element not found', this._wrapperElement);
|
|
11820
11658
|
}
|
|
11821
11659
|
// Get search input element - this is used for the search functionality
|
|
11822
|
-
// First check if it's in dropdown, then check if it's in display (for combobox)
|
|
11823
11660
|
this._searchInputElement = this._dropdownContentElement.querySelector("[data-kt-select-search]");
|
|
11824
|
-
// If not found in dropdown, check if it's the display element itself
|
|
11825
|
-
if (!this._searchInputElement
|
|
11826
|
-
this._config.mode === types_1.SelectMode.COMBOBOX) {
|
|
11661
|
+
// If not found in dropdown, check if it's the display element itself
|
|
11662
|
+
if (!this._searchInputElement) {
|
|
11827
11663
|
this._searchInputElement = this._displayElement;
|
|
11828
11664
|
}
|
|
11829
|
-
if (this._config.debug)
|
|
11830
|
-
console.log('Search input found:', this._searchInputElement ? 'Yes' : 'No', 'Mode:', this._config.mode, 'EnableSearch:', this._config.enableSearch);
|
|
11831
11665
|
this._valueDisplayElement = this._wrapperElement.querySelector("[data-kt-select-value]");
|
|
11832
11666
|
this._options = this._wrapperElement.querySelectorAll("[data-kt-select-option]");
|
|
11833
11667
|
};
|
|
@@ -11837,17 +11671,18 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11837
11671
|
KTSelect.prototype._attachEventListeners = function () {
|
|
11838
11672
|
// Document level event listeners
|
|
11839
11673
|
document.addEventListener('click', this._handleDocumentClick.bind(this));
|
|
11840
|
-
document.addEventListener('keydown', this._handleEscKey.bind(this));
|
|
11841
11674
|
// Dropdown option click events
|
|
11842
11675
|
this._eventManager.addListener(this._dropdownContentElement, 'click', this._handleDropdownOptionClick.bind(this));
|
|
11843
11676
|
// Only attach click handler to display element
|
|
11844
|
-
this._eventManager.addListener(
|
|
11845
|
-
//
|
|
11846
|
-
//
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
|
|
11677
|
+
// this._eventManager.addListener(
|
|
11678
|
+
// this._wrapperElement,
|
|
11679
|
+
// 'click',
|
|
11680
|
+
// this._handleDropdownClick.bind(this),
|
|
11681
|
+
// );
|
|
11682
|
+
// Attach centralized keyboard handler
|
|
11683
|
+
var keyboardTarget = this._searchInputElement || this._wrapperElement;
|
|
11684
|
+
if (keyboardTarget) {
|
|
11685
|
+
keyboardTarget.addEventListener('keydown', this._handleKeyboardEvent.bind(this));
|
|
11851
11686
|
}
|
|
11852
11687
|
};
|
|
11853
11688
|
/**
|
|
@@ -11917,52 +11752,12 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11917
11752
|
label =
|
|
11918
11753
|
extractedLabel !== null ? String(extractedLabel) : 'Unnamed option';
|
|
11919
11754
|
}
|
|
11920
|
-
// Get description - skip if null, undefined, or "null" string
|
|
11921
|
-
var description = null;
|
|
11922
|
-
if (item.description !== undefined &&
|
|
11923
|
-
item.description !== null &&
|
|
11924
|
-
String(item.description) !== 'null' &&
|
|
11925
|
-
String(item.description) !== 'undefined') {
|
|
11926
|
-
description = String(item.description);
|
|
11927
|
-
}
|
|
11928
|
-
else if (_this._config.dataFieldDescription) {
|
|
11929
|
-
var extractedDesc = _this._getValueByKey(item, _this._config.dataFieldDescription);
|
|
11930
|
-
if (extractedDesc !== null &&
|
|
11931
|
-
extractedDesc !== undefined &&
|
|
11932
|
-
String(extractedDesc) !== 'null' &&
|
|
11933
|
-
String(extractedDesc) !== 'undefined') {
|
|
11934
|
-
description = String(extractedDesc);
|
|
11935
|
-
}
|
|
11936
|
-
}
|
|
11937
|
-
// Get icon - skip if null, undefined, or "null" string
|
|
11938
|
-
var icon = null;
|
|
11939
|
-
if (item.icon !== undefined &&
|
|
11940
|
-
item.icon !== null &&
|
|
11941
|
-
String(item.icon) !== 'null' &&
|
|
11942
|
-
String(item.icon) !== 'undefined') {
|
|
11943
|
-
icon = String(item.icon);
|
|
11944
|
-
}
|
|
11945
|
-
else if (_this._config.dataFieldIcon) {
|
|
11946
|
-
var extractedIcon = _this._getValueByKey(item, _this._config.dataFieldIcon);
|
|
11947
|
-
if (extractedIcon !== null &&
|
|
11948
|
-
extractedIcon !== undefined &&
|
|
11949
|
-
String(extractedIcon) !== 'null' &&
|
|
11950
|
-
String(extractedIcon) !== 'undefined') {
|
|
11951
|
-
icon = String(extractedIcon);
|
|
11952
|
-
}
|
|
11953
|
-
}
|
|
11954
11755
|
// Log the extracted values for debugging
|
|
11955
11756
|
if (_this._config.debug)
|
|
11956
|
-
console.log("Option: value=".concat(value, ", label=").concat(label
|
|
11757
|
+
console.log("Option: value=".concat(value, ", label=").concat(label));
|
|
11957
11758
|
// Set option attributes
|
|
11958
11759
|
optionElement.value = value;
|
|
11959
11760
|
optionElement.textContent = label || 'Unnamed option';
|
|
11960
|
-
if (description) {
|
|
11961
|
-
optionElement.setAttribute('data-kt-select-option-description', description);
|
|
11962
|
-
}
|
|
11963
|
-
if (icon) {
|
|
11964
|
-
optionElement.setAttribute('data-kt-select-option-icon', icon);
|
|
11965
|
-
}
|
|
11966
11761
|
if (item.selected) {
|
|
11967
11762
|
optionElement.setAttribute('selected', 'selected');
|
|
11968
11763
|
}
|
|
@@ -12032,8 +11827,14 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12032
11827
|
*/
|
|
12033
11828
|
/**
|
|
12034
11829
|
* Toggle dropdown visibility
|
|
11830
|
+
* @deprecated
|
|
12035
11831
|
*/
|
|
12036
11832
|
KTSelect.prototype.toggleDropdown = function () {
|
|
11833
|
+
if (this._config.disabled) {
|
|
11834
|
+
if (this._config.debug)
|
|
11835
|
+
console.log('toggleDropdown: select is disabled, not opening');
|
|
11836
|
+
return;
|
|
11837
|
+
}
|
|
12037
11838
|
if (this._config.debug)
|
|
12038
11839
|
console.log('toggleDropdown called');
|
|
12039
11840
|
if (this._dropdownModule) {
|
|
@@ -12055,6 +11856,11 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12055
11856
|
*/
|
|
12056
11857
|
KTSelect.prototype.openDropdown = function () {
|
|
12057
11858
|
var _this = this;
|
|
11859
|
+
if (this._config.disabled) {
|
|
11860
|
+
if (this._config.debug)
|
|
11861
|
+
console.log('openDropdown: select is disabled, not opening');
|
|
11862
|
+
return;
|
|
11863
|
+
}
|
|
12058
11864
|
if (this._config.debug)
|
|
12059
11865
|
console.log('openDropdown called, dropdownModule exists:', !!this._dropdownModule);
|
|
12060
11866
|
if (!this._dropdownModule) {
|
|
@@ -12160,6 +11966,12 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12160
11966
|
* Select an option by value
|
|
12161
11967
|
*/
|
|
12162
11968
|
KTSelect.prototype._selectOption = function (value) {
|
|
11969
|
+
// Prevent selection if the option is disabled (in dropdown or original select)
|
|
11970
|
+
if (this._isOptionDisabled(value)) {
|
|
11971
|
+
if (this._config.debug)
|
|
11972
|
+
console.log('_selectOption: Option is disabled, ignoring selection');
|
|
11973
|
+
return;
|
|
11974
|
+
}
|
|
12163
11975
|
// Get current selection state
|
|
12164
11976
|
var isSelected = this._state.isSelected(value);
|
|
12165
11977
|
// Toggle selection in state
|
|
@@ -12205,105 +12017,35 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12205
12017
|
* Update selected option display value
|
|
12206
12018
|
*/
|
|
12207
12019
|
KTSelect.prototype.updateSelectedOptionDisplay = function () {
|
|
12208
|
-
var _this = this;
|
|
12209
12020
|
var selectedOptions = this.getSelectedOptions();
|
|
12210
|
-
if
|
|
12021
|
+
// Tag mode: render tags if enabled
|
|
12022
|
+
if (this._config.tags && this._tagsModule) {
|
|
12023
|
+
this._tagsModule.updateTagsDisplay(selectedOptions);
|
|
12024
|
+
return;
|
|
12025
|
+
}
|
|
12026
|
+
if (typeof this._config.renderSelected === 'function') {
|
|
12211
12027
|
// Use the custom renderSelected function if provided
|
|
12212
|
-
this.
|
|
12028
|
+
this._valueDisplayElement.innerHTML = this._config.renderSelected(selectedOptions);
|
|
12213
12029
|
}
|
|
12214
12030
|
else {
|
|
12215
12031
|
if (selectedOptions.length === 0) {
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
}
|
|
12219
|
-
}
|
|
12220
|
-
else if (this._config.multiple) {
|
|
12221
|
-
if (this._config.mode === types_1.SelectMode.TAGS) {
|
|
12222
|
-
// Use the tags module to render selected options as tags
|
|
12223
|
-
if (this._tagsModule) {
|
|
12224
|
-
this._tagsModule.updateTagsDisplay(selectedOptions);
|
|
12225
|
-
}
|
|
12226
|
-
else {
|
|
12227
|
-
// Fallback if tags module not initialized for some reason
|
|
12228
|
-
this._updateValueDisplay(selectedOptions.join(', '));
|
|
12229
|
-
}
|
|
12230
|
-
}
|
|
12231
|
-
else {
|
|
12232
|
-
// Render as comma-separated values
|
|
12233
|
-
var displayText = selectedOptions
|
|
12234
|
-
.map(function (option) { return _this._getOptionInnerHtml(option) || ''; })
|
|
12235
|
-
.join(', ');
|
|
12236
|
-
this._updateValueDisplay(displayText);
|
|
12237
|
-
}
|
|
12032
|
+
var placeholder = templates_1.defaultTemplates.placeholder(this._config);
|
|
12033
|
+
this._valueDisplayElement.replaceChildren(placeholder);
|
|
12238
12034
|
}
|
|
12239
12035
|
else {
|
|
12240
|
-
var
|
|
12241
|
-
if (
|
|
12242
|
-
var
|
|
12243
|
-
this.
|
|
12244
|
-
// Update combobox input value if in combobox mode
|
|
12245
|
-
if (this._config.mode === types_1.SelectMode.COMBOBOX &&
|
|
12246
|
-
this._comboboxModule) {
|
|
12247
|
-
this._comboboxModule.updateSelectedValue(selectedText);
|
|
12248
|
-
}
|
|
12249
|
-
}
|
|
12250
|
-
else {
|
|
12251
|
-
this._updateValueDisplay(this._config.placeholder);
|
|
12252
|
-
}
|
|
12253
|
-
}
|
|
12254
|
-
}
|
|
12255
|
-
// Update any debug display boxes if they exist
|
|
12256
|
-
this._updateDebugDisplays();
|
|
12257
|
-
};
|
|
12258
|
-
/**
|
|
12259
|
-
* Update the value display element
|
|
12260
|
-
*/
|
|
12261
|
-
KTSelect.prototype._updateValueDisplay = function (value) {
|
|
12262
|
-
if (this._config.mode === types_1.SelectMode.COMBOBOX) {
|
|
12263
|
-
// For combobox, we only update the hidden value element, not the input
|
|
12264
|
-
// The combobox module will handle updating the input value
|
|
12265
|
-
if (!this._comboboxModule) {
|
|
12266
|
-
this._valueDisplayElement.value = value;
|
|
12267
|
-
}
|
|
12268
|
-
}
|
|
12269
|
-
else {
|
|
12270
|
-
this._valueDisplayElement.innerHTML = value;
|
|
12271
|
-
}
|
|
12272
|
-
};
|
|
12273
|
-
/**
|
|
12274
|
-
* Update debug displays if present
|
|
12275
|
-
*/
|
|
12276
|
-
KTSelect.prototype._updateDebugDisplays = function () {
|
|
12277
|
-
// Check if we're in a test environment with debug boxes
|
|
12278
|
-
var selectId = this.getElement().id;
|
|
12279
|
-
if (selectId) {
|
|
12280
|
-
var debugElement = document.getElementById("".concat(selectId, "-value"));
|
|
12281
|
-
if (debugElement) {
|
|
12282
|
-
var selectedOptions = this.getSelectedOptions();
|
|
12283
|
-
// Format display based on selection mode
|
|
12284
|
-
if (this._config.multiple) {
|
|
12285
|
-
// For multiple selection, show comma-separated list
|
|
12286
|
-
debugElement.textContent =
|
|
12287
|
-
selectedOptions.length > 0 ? selectedOptions.join(', ') : 'None';
|
|
12036
|
+
var content = '';
|
|
12037
|
+
if (this._config.displayTemplate) {
|
|
12038
|
+
var selectedValues = this.getSelectedOptions();
|
|
12039
|
+
content = this.renderDisplayTemplateForSelected(selectedValues);
|
|
12288
12040
|
}
|
|
12289
12041
|
else {
|
|
12290
|
-
//
|
|
12291
|
-
|
|
12292
|
-
selectedOptions.length > 0 ? selectedOptions[0] : 'None';
|
|
12042
|
+
// If no displayTemplate is provided, use the default comma-separated list of selected options
|
|
12043
|
+
content = this.getSelectedOptionsText();
|
|
12293
12044
|
}
|
|
12045
|
+
this._valueDisplayElement.innerHTML = content;
|
|
12294
12046
|
}
|
|
12295
12047
|
}
|
|
12296
12048
|
};
|
|
12297
|
-
/**
|
|
12298
|
-
* Get option inner HTML content by option value
|
|
12299
|
-
*/
|
|
12300
|
-
KTSelect.prototype._getOptionInnerHtml = function (optionValue) {
|
|
12301
|
-
var option = Array.from(this._options).find(function (opt) { return opt.dataset.value === optionValue; });
|
|
12302
|
-
if (this._config.mode == types_1.SelectMode.COMBOBOX) {
|
|
12303
|
-
return option.textContent;
|
|
12304
|
-
}
|
|
12305
|
-
return option.innerHTML; // Get the entire HTML content of the option
|
|
12306
|
-
};
|
|
12307
12049
|
/**
|
|
12308
12050
|
* Update CSS classes for selected options
|
|
12309
12051
|
*/
|
|
@@ -12348,17 +12090,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12348
12090
|
this._state.setSelectedOptions([]);
|
|
12349
12091
|
this.updateSelectedOptionDisplay();
|
|
12350
12092
|
this._updateSelectedOptionClass();
|
|
12351
|
-
// For combobox, also clear the input value
|
|
12352
|
-
if (this._config.mode === types_1.SelectMode.COMBOBOX) {
|
|
12353
|
-
if (this._searchInputElement) {
|
|
12354
|
-
this._searchInputElement.value = '';
|
|
12355
|
-
}
|
|
12356
|
-
// If combobox has a clear button, hide it
|
|
12357
|
-
if (this._comboboxModule) {
|
|
12358
|
-
// The combobox module will handle hiding the clear button
|
|
12359
|
-
this._comboboxModule.resetInputValueToSelection();
|
|
12360
|
-
}
|
|
12361
|
-
}
|
|
12362
12093
|
// Dispatch change event
|
|
12363
12094
|
this._dispatchEvent('change');
|
|
12364
12095
|
this._fireEvent('change');
|
|
@@ -12370,49 +12101,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12370
12101
|
var values = Array.from(options).map(function (option) { return option.value; });
|
|
12371
12102
|
this._state.setSelectedOptions(values);
|
|
12372
12103
|
};
|
|
12373
|
-
/**
|
|
12374
|
-
* ========================================================================
|
|
12375
|
-
* KEYBOARD NAVIGATION
|
|
12376
|
-
* ========================================================================
|
|
12377
|
-
*/
|
|
12378
|
-
/**
|
|
12379
|
-
* Handle dropdown key down events for keyboard navigation
|
|
12380
|
-
* Only used for standard (non-combobox) dropdowns
|
|
12381
|
-
*/
|
|
12382
|
-
KTSelect.prototype._handleDropdownKeyDown = function (event) {
|
|
12383
|
-
// Log event for debugging
|
|
12384
|
-
if (this._config.debug)
|
|
12385
|
-
console.log('Standard dropdown keydown:', event.key);
|
|
12386
|
-
// Use the shared handler
|
|
12387
|
-
(0, utils_1.handleDropdownKeyNavigation)(event, this, {
|
|
12388
|
-
multiple: this._config.multiple,
|
|
12389
|
-
closeOnSelect: this._config.closeOnSelect,
|
|
12390
|
-
});
|
|
12391
|
-
};
|
|
12392
|
-
/**
|
|
12393
|
-
* Focus next option in dropdown
|
|
12394
|
-
*/
|
|
12395
|
-
KTSelect.prototype._focusNextOption = function () {
|
|
12396
|
-
return this._focusManager.focusNext();
|
|
12397
|
-
};
|
|
12398
|
-
/**
|
|
12399
|
-
* Focus previous option in dropdown
|
|
12400
|
-
*/
|
|
12401
|
-
KTSelect.prototype._focusPreviousOption = function () {
|
|
12402
|
-
return this._focusManager.focusPrevious();
|
|
12403
|
-
};
|
|
12404
|
-
/**
|
|
12405
|
-
* Apply hover/focus state to focused option
|
|
12406
|
-
*/
|
|
12407
|
-
KTSelect.prototype._hoverFocusedOption = function (option) {
|
|
12408
|
-
this._focusManager.applyFocus(option);
|
|
12409
|
-
};
|
|
12410
|
-
/**
|
|
12411
|
-
* Scroll option into view when navigating
|
|
12412
|
-
*/
|
|
12413
|
-
KTSelect.prototype._scrollOptionIntoView = function (option) {
|
|
12414
|
-
this._focusManager.scrollIntoView(option);
|
|
12415
|
-
};
|
|
12416
12104
|
/**
|
|
12417
12105
|
* Select the currently focused option
|
|
12418
12106
|
*/
|
|
@@ -12436,52 +12124,16 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12436
12124
|
if (selectedValue) {
|
|
12437
12125
|
this._selectOption(selectedValue);
|
|
12438
12126
|
}
|
|
12439
|
-
// For combobox mode, update input value AFTER selection to ensure consistency
|
|
12440
|
-
if (this._config.mode === types_1.SelectMode.COMBOBOX && this._comboboxModule) {
|
|
12441
|
-
this._comboboxModule.updateSelectedValue(selectedText);
|
|
12442
|
-
// Also directly update the input value for immediate visual feedback
|
|
12443
|
-
if (this._searchInputElement) {
|
|
12444
|
-
this._searchInputElement.value = selectedText;
|
|
12445
|
-
}
|
|
12446
|
-
}
|
|
12447
12127
|
}
|
|
12448
12128
|
};
|
|
12449
12129
|
/**
|
|
12450
12130
|
* ========================================================================
|
|
12451
|
-
*
|
|
12131
|
+
* EVENT HANDLERS
|
|
12452
12132
|
* ========================================================================
|
|
12453
12133
|
*/
|
|
12454
12134
|
/**
|
|
12455
|
-
* Handle
|
|
12456
|
-
|
|
12457
|
-
KTSelect.prototype._handleComboboxInput = function (event) {
|
|
12458
|
-
if (this._comboboxModule) {
|
|
12459
|
-
return;
|
|
12460
|
-
}
|
|
12461
|
-
var inputElement = event.target;
|
|
12462
|
-
var query = inputElement.value.toLowerCase();
|
|
12463
|
-
// If dropdown isn't open, open it when user starts typing
|
|
12464
|
-
if (!this._dropdownIsOpen) {
|
|
12465
|
-
this.openDropdown();
|
|
12466
|
-
}
|
|
12467
|
-
// Filter options based on input
|
|
12468
|
-
this._filterOptionsForCombobox(query);
|
|
12469
|
-
};
|
|
12470
|
-
/**
|
|
12471
|
-
* Filter options for combobox based on input query
|
|
12472
|
-
* Uses the shared filterOptions function
|
|
12473
|
-
*/
|
|
12474
|
-
KTSelect.prototype._filterOptionsForCombobox = function (query) {
|
|
12475
|
-
var options = Array.from(this._dropdownContentElement.querySelectorAll('[data-kt-select-option]'));
|
|
12476
|
-
(0, utils_1.filterOptions)(options, query, this._config, this._dropdownContentElement);
|
|
12477
|
-
};
|
|
12478
|
-
/**
|
|
12479
|
-
* ========================================================================
|
|
12480
|
-
* EVENT HANDLERS
|
|
12481
|
-
* ========================================================================
|
|
12482
|
-
*/
|
|
12483
|
-
/**
|
|
12484
|
-
* Handle display element click
|
|
12135
|
+
* Handle display element click
|
|
12136
|
+
* @deprecated
|
|
12485
12137
|
*/
|
|
12486
12138
|
KTSelect.prototype._handleDropdownClick = function (event) {
|
|
12487
12139
|
if (this._config.debug)
|
|
@@ -12543,14 +12195,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12543
12195
|
this.closeDropdown();
|
|
12544
12196
|
}
|
|
12545
12197
|
};
|
|
12546
|
-
/**
|
|
12547
|
-
* Handle escape key press
|
|
12548
|
-
*/
|
|
12549
|
-
KTSelect.prototype._handleEscKey = function (event) {
|
|
12550
|
-
if (event.key === 'Escape' && this._dropdownIsOpen) {
|
|
12551
|
-
this.closeDropdown();
|
|
12552
|
-
}
|
|
12553
|
-
};
|
|
12554
12198
|
/**
|
|
12555
12199
|
* ========================================================================
|
|
12556
12200
|
* ACCESSIBILITY METHODS
|
|
@@ -12562,18 +12206,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12562
12206
|
KTSelect.prototype._setAriaAttributes = function () {
|
|
12563
12207
|
this._displayElement.setAttribute('aria-expanded', this._dropdownIsOpen.toString());
|
|
12564
12208
|
};
|
|
12565
|
-
/**
|
|
12566
|
-
* Handle focus events
|
|
12567
|
-
*/
|
|
12568
|
-
KTSelect.prototype._handleFocus = function () {
|
|
12569
|
-
// Implementation pending
|
|
12570
|
-
};
|
|
12571
|
-
/**
|
|
12572
|
-
* Handle blur events
|
|
12573
|
-
*/
|
|
12574
|
-
KTSelect.prototype._handleBlur = function () {
|
|
12575
|
-
// Implementation pending
|
|
12576
|
-
};
|
|
12577
12209
|
/**
|
|
12578
12210
|
* ========================================================================
|
|
12579
12211
|
* PUBLIC API
|
|
@@ -12642,7 +12274,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12642
12274
|
}
|
|
12643
12275
|
});
|
|
12644
12276
|
// If search input exists, clear it
|
|
12645
|
-
if (this._searchInputElement
|
|
12277
|
+
if (this._searchInputElement) {
|
|
12646
12278
|
this._searchInputElement.value = '';
|
|
12647
12279
|
// If we have a search module, clear any search filtering
|
|
12648
12280
|
if (this._searchModule) {
|
|
@@ -12666,6 +12298,12 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12666
12298
|
* Toggle the selection of an option
|
|
12667
12299
|
*/
|
|
12668
12300
|
KTSelect.prototype.toggleSelection = function (value) {
|
|
12301
|
+
// Prevent selection if the option is disabled (in dropdown or original select)
|
|
12302
|
+
if (this._isOptionDisabled(value)) {
|
|
12303
|
+
if (this._config.debug)
|
|
12304
|
+
console.log('toggleSelection: Option is disabled, ignoring selection');
|
|
12305
|
+
return;
|
|
12306
|
+
}
|
|
12669
12307
|
// Get current selection state
|
|
12670
12308
|
var isSelected = this._state.isSelected(value);
|
|
12671
12309
|
if (this._config.debug)
|
|
@@ -12833,7 +12471,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12833
12471
|
*/
|
|
12834
12472
|
KTSelect.prototype._renderSearchLoadingState = function () {
|
|
12835
12473
|
if (!this._originalOptionsHtml && this._dropdownContentElement) {
|
|
12836
|
-
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options
|
|
12474
|
+
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options]');
|
|
12837
12475
|
if (optionsContainer) {
|
|
12838
12476
|
this._originalOptionsHtml = optionsContainer.innerHTML;
|
|
12839
12477
|
}
|
|
@@ -12852,36 +12490,26 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12852
12490
|
* @param items Search result items
|
|
12853
12491
|
*/
|
|
12854
12492
|
KTSelect.prototype._updateSearchResults = function (items) {
|
|
12855
|
-
var _this = this;
|
|
12856
12493
|
if (!this._dropdownContentElement)
|
|
12857
12494
|
return;
|
|
12858
|
-
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options
|
|
12495
|
+
var optionsContainer = this._dropdownContentElement.querySelector('[data-kt-select-options]');
|
|
12859
12496
|
if (!optionsContainer)
|
|
12860
12497
|
return;
|
|
12861
12498
|
// Clear current options
|
|
12862
12499
|
optionsContainer.innerHTML = '';
|
|
12863
12500
|
if (items.length === 0) {
|
|
12864
12501
|
// Show no results message using template for consistency and customization
|
|
12865
|
-
var noResultsElement = templates_1.defaultTemplates.
|
|
12502
|
+
var noResultsElement = templates_1.defaultTemplates.empty(this._config);
|
|
12866
12503
|
optionsContainer.appendChild(noResultsElement);
|
|
12867
12504
|
return;
|
|
12868
12505
|
}
|
|
12869
12506
|
// Process each item individually to create options
|
|
12870
12507
|
items.forEach(function (item) {
|
|
12871
12508
|
// Create option for the original select
|
|
12872
|
-
var selectOption =
|
|
12509
|
+
var selectOption = document.createElement('option');
|
|
12873
12510
|
selectOption.value = item.id;
|
|
12874
|
-
if (item.description) {
|
|
12875
|
-
selectOption.setAttribute('data-kt-select-option-description', item.description);
|
|
12876
|
-
}
|
|
12877
|
-
if (item.icon) {
|
|
12878
|
-
selectOption.setAttribute('data-kt-select-option-icon', item.icon);
|
|
12879
|
-
}
|
|
12880
|
-
// Create option element for the dropdown
|
|
12881
|
-
var ktOption = new option_1.KTSelectOption(selectOption, _this._config);
|
|
12882
|
-
var renderedOption = ktOption.render();
|
|
12883
12511
|
// Add to dropdown container
|
|
12884
|
-
optionsContainer.appendChild(
|
|
12512
|
+
optionsContainer.appendChild(selectOption);
|
|
12885
12513
|
});
|
|
12886
12514
|
// Add pagination "Load More" button if needed
|
|
12887
12515
|
if (this._config.pagination && this._remoteModule.hasMorePages()) {
|
|
@@ -12890,18 +12518,137 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12890
12518
|
// Update options NodeList
|
|
12891
12519
|
this._options = this._wrapperElement.querySelectorAll("[data-kt-select-option]");
|
|
12892
12520
|
};
|
|
12893
|
-
/**
|
|
12894
|
-
* Filter options by query
|
|
12895
|
-
*/
|
|
12896
|
-
KTSelect.prototype.filterOptions = function (query) {
|
|
12897
|
-
this._filterOptionsForCombobox(query);
|
|
12898
|
-
};
|
|
12899
12521
|
/**
|
|
12900
12522
|
* Check if dropdown is open
|
|
12901
12523
|
*/
|
|
12902
12524
|
KTSelect.prototype.isDropdownOpen = function () {
|
|
12903
12525
|
return this._dropdownIsOpen;
|
|
12904
12526
|
};
|
|
12527
|
+
KTSelect.prototype.getSelectedOptionsText = function () {
|
|
12528
|
+
var _this = this;
|
|
12529
|
+
var selectedValues = this.getSelectedOptions();
|
|
12530
|
+
var displaySeparator = this._config.displaySeparator || ', ';
|
|
12531
|
+
var texts = selectedValues.map(function (value) {
|
|
12532
|
+
var option = Array.from(_this._options).find(function (opt) { return opt.getAttribute('data-value') === value; });
|
|
12533
|
+
return (option === null || option === void 0 ? void 0 : option.getAttribute('data-text')) || '';
|
|
12534
|
+
}).filter(Boolean);
|
|
12535
|
+
return texts.join(displaySeparator);
|
|
12536
|
+
};
|
|
12537
|
+
/**
|
|
12538
|
+
* Check if an option is disabled (either in dropdown or original select)
|
|
12539
|
+
*/
|
|
12540
|
+
KTSelect.prototype._isOptionDisabled = function (value) {
|
|
12541
|
+
var dropdownOption = Array.from(this._options).find(function (opt) { return opt.getAttribute('data-value') === value; });
|
|
12542
|
+
var isDropdownDisabled = dropdownOption && (dropdownOption.classList.contains('disabled') || dropdownOption.getAttribute('aria-disabled') === 'true');
|
|
12543
|
+
var selectOption = Array.from(this._element.querySelectorAll('option')).find(function (opt) { return opt.value === value; });
|
|
12544
|
+
var isNativeDisabled = selectOption && selectOption.disabled;
|
|
12545
|
+
return Boolean(isDropdownDisabled || isNativeDisabled);
|
|
12546
|
+
};
|
|
12547
|
+
/**
|
|
12548
|
+
* Centralized keyboard event handler for all select modes
|
|
12549
|
+
*/
|
|
12550
|
+
KTSelect.prototype._handleKeyboardEvent = function (event) {
|
|
12551
|
+
var isOpen = this._dropdownIsOpen;
|
|
12552
|
+
var config = this._config;
|
|
12553
|
+
var focusManager = this._focusManager;
|
|
12554
|
+
var buffer = this._typeToSearchBuffer;
|
|
12555
|
+
// Ignore modifier keys
|
|
12556
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
12557
|
+
return;
|
|
12558
|
+
// Type-to-search: only for single char keys
|
|
12559
|
+
if (event.key.length === 1 && !event.repeat && !event.key.match(/\s/)) {
|
|
12560
|
+
buffer.push(event.key);
|
|
12561
|
+
var str = buffer.getBuffer();
|
|
12562
|
+
focusManager.focusByString(str);
|
|
12563
|
+
return;
|
|
12564
|
+
}
|
|
12565
|
+
switch (event.key) {
|
|
12566
|
+
case 'ArrowDown':
|
|
12567
|
+
event.preventDefault();
|
|
12568
|
+
if (!isOpen) {
|
|
12569
|
+
this.openDropdown();
|
|
12570
|
+
}
|
|
12571
|
+
else {
|
|
12572
|
+
focusManager.focusNext();
|
|
12573
|
+
}
|
|
12574
|
+
break;
|
|
12575
|
+
case 'ArrowUp':
|
|
12576
|
+
event.preventDefault();
|
|
12577
|
+
if (!isOpen) {
|
|
12578
|
+
this.openDropdown();
|
|
12579
|
+
}
|
|
12580
|
+
else {
|
|
12581
|
+
focusManager.focusPrevious();
|
|
12582
|
+
}
|
|
12583
|
+
break;
|
|
12584
|
+
case 'Home':
|
|
12585
|
+
event.preventDefault();
|
|
12586
|
+
if (isOpen)
|
|
12587
|
+
focusManager.focusFirst();
|
|
12588
|
+
break;
|
|
12589
|
+
case 'End':
|
|
12590
|
+
event.preventDefault();
|
|
12591
|
+
if (isOpen)
|
|
12592
|
+
focusManager.focusLast();
|
|
12593
|
+
break;
|
|
12594
|
+
case 'Enter':
|
|
12595
|
+
case ' ': // Space
|
|
12596
|
+
if (isOpen) {
|
|
12597
|
+
var focused = focusManager.getFocusedOption();
|
|
12598
|
+
if (focused) {
|
|
12599
|
+
var value = focused.dataset.value;
|
|
12600
|
+
if (value) {
|
|
12601
|
+
this.toggleSelection(value);
|
|
12602
|
+
if (!config.multiple && config.closeOnSelect) {
|
|
12603
|
+
this.closeDropdown();
|
|
12604
|
+
}
|
|
12605
|
+
}
|
|
12606
|
+
}
|
|
12607
|
+
// Prevent form submit
|
|
12608
|
+
event.preventDefault();
|
|
12609
|
+
}
|
|
12610
|
+
else {
|
|
12611
|
+
this.openDropdown();
|
|
12612
|
+
}
|
|
12613
|
+
break;
|
|
12614
|
+
case 'Escape':
|
|
12615
|
+
if (isOpen) {
|
|
12616
|
+
this.closeDropdown();
|
|
12617
|
+
event.target.blur();
|
|
12618
|
+
}
|
|
12619
|
+
break;
|
|
12620
|
+
case 'Tab':
|
|
12621
|
+
// Let Tab propagate for normal focus movement
|
|
12622
|
+
break;
|
|
12623
|
+
default:
|
|
12624
|
+
break;
|
|
12625
|
+
}
|
|
12626
|
+
};
|
|
12627
|
+
KTSelect.prototype.renderDisplayTemplateForSelected = function (selectedValues) {
|
|
12628
|
+
var _this = this;
|
|
12629
|
+
var optionsConfig = this._config.optionsConfig || {};
|
|
12630
|
+
var displaySeparator = this._config.displaySeparator || ', ';
|
|
12631
|
+
var contentArray = Array.from(new Set(selectedValues.map(function (value) {
|
|
12632
|
+
var option = Array.from(_this._options).find(function (opt) { return opt.getAttribute('data-value') === value; });
|
|
12633
|
+
if (!option)
|
|
12634
|
+
return '';
|
|
12635
|
+
var displayTemplate = _this._config.displayTemplate;
|
|
12636
|
+
var text = option.getAttribute('data-text') || '';
|
|
12637
|
+
// Replace all {{varname}} in option.innerHTML with values from _config
|
|
12638
|
+
Object.entries(optionsConfig[value] || {}).forEach(function (_a) {
|
|
12639
|
+
var key = _a[0], val = _a[1];
|
|
12640
|
+
if (["string", "number", "boolean"].includes(typeof val)) {
|
|
12641
|
+
displayTemplate = displayTemplate.replace(new RegExp("{{".concat(key, "}}"), 'g'), String(val));
|
|
12642
|
+
}
|
|
12643
|
+
});
|
|
12644
|
+
return (0, utils_1.renderTemplateString)(displayTemplate, {
|
|
12645
|
+
selectedCount: selectedValues.length || 0,
|
|
12646
|
+
selectedTexts: _this.getSelectedOptionsText() || '',
|
|
12647
|
+
text: text,
|
|
12648
|
+
});
|
|
12649
|
+
}).filter(Boolean)));
|
|
12650
|
+
return contentArray.join(displaySeparator);
|
|
12651
|
+
};
|
|
12905
12652
|
/**
|
|
12906
12653
|
* ========================================================================
|
|
12907
12654
|
* STATIC METHODS
|
|
@@ -12929,31 +12676,6 @@ var tooltip_1 = __webpack_require__(1850);
|
|
|
12929
12676
|
Object.defineProperty(exports, "KTTooltip", ({ enumerable: true, get: function () { return tooltip_1.KTTooltip; } }));
|
|
12930
12677
|
|
|
12931
12678
|
|
|
12932
|
-
/***/ }),
|
|
12933
|
-
|
|
12934
|
-
/***/ 8135:
|
|
12935
|
-
/***/ (function(__unused_webpack_module, exports) {
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
/**
|
|
12939
|
-
* KTUI - Free & Open-Source Tailwind UI Components by Keenthemes
|
|
12940
|
-
* Copyright 2025 by Keenthemes Inc
|
|
12941
|
-
*/
|
|
12942
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12943
|
-
exports.SelectMode = void 0;
|
|
12944
|
-
/**
|
|
12945
|
-
* Common type interfaces for the KTSelect component
|
|
12946
|
-
*/
|
|
12947
|
-
/**
|
|
12948
|
-
* Select mode options
|
|
12949
|
-
*/
|
|
12950
|
-
var SelectMode;
|
|
12951
|
-
(function (SelectMode) {
|
|
12952
|
-
SelectMode["TAGS"] = "tags";
|
|
12953
|
-
SelectMode["COMBOBOX"] = "combobox";
|
|
12954
|
-
})(SelectMode || (exports.SelectMode = SelectMode = {}));
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
12679
|
/***/ }),
|
|
12958
12680
|
|
|
12959
12681
|
/***/ 8151:
|
|
@@ -13507,7 +13229,7 @@ exports.KTDatepickerKeyboard = KTDatepickerKeyboard;
|
|
|
13507
13229
|
* Copyright 2025 by Keenthemes Inc
|
|
13508
13230
|
*/
|
|
13509
13231
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
13510
|
-
exports.KTSelect = exports.KTDatepicker = exports.KTDataTable = exports.KTTogglePassword = exports.KTImageInput = exports.KTThemeSwitch = exports.KTStepper = exports.KTTooltip = exports.KTToggle = exports.KTReparent = exports.KTSticky = exports.KTScrollto = exports.KTScrollable = exports.KTScrollspy = exports.KTAccordion = exports.KTTabs = exports.KTDismiss = exports.KTCollapse = exports.KTDrawer = exports.KTModal = exports.KTDropdown = void 0;
|
|
13232
|
+
exports.KTToast = exports.KTSelect = exports.KTDatepicker = exports.KTDataTable = exports.KTTogglePassword = exports.KTImageInput = exports.KTThemeSwitch = exports.KTStepper = exports.KTTooltip = exports.KTToggle = exports.KTReparent = exports.KTSticky = exports.KTScrollto = exports.KTScrollable = exports.KTScrollspy = exports.KTAccordion = exports.KTTabs = exports.KTDismiss = exports.KTCollapse = exports.KTDrawer = exports.KTModal = exports.KTDropdown = void 0;
|
|
13511
13233
|
var dom_1 = __webpack_require__(9010);
|
|
13512
13234
|
var dropdown_1 = __webpack_require__(5071);
|
|
13513
13235
|
var modal_1 = __webpack_require__(3395);
|
|
@@ -13530,6 +13252,7 @@ var toggle_password_1 = __webpack_require__(2232);
|
|
|
13530
13252
|
var datatable_1 = __webpack_require__(2626);
|
|
13531
13253
|
var datepicker_1 = __webpack_require__(5116);
|
|
13532
13254
|
var select_1 = __webpack_require__(494);
|
|
13255
|
+
var toast_1 = __webpack_require__(6265);
|
|
13533
13256
|
var dropdown_2 = __webpack_require__(5071);
|
|
13534
13257
|
Object.defineProperty(exports, "KTDropdown", ({ enumerable: true, get: function () { return dropdown_2.KTDropdown; } }));
|
|
13535
13258
|
var modal_2 = __webpack_require__(3395);
|
|
@@ -13572,6 +13295,8 @@ var datepicker_2 = __webpack_require__(5116);
|
|
|
13572
13295
|
Object.defineProperty(exports, "KTDatepicker", ({ enumerable: true, get: function () { return datepicker_2.KTDatepicker; } }));
|
|
13573
13296
|
var select_2 = __webpack_require__(494);
|
|
13574
13297
|
Object.defineProperty(exports, "KTSelect", ({ enumerable: true, get: function () { return select_2.KTSelect; } }));
|
|
13298
|
+
var toast_2 = __webpack_require__(6265);
|
|
13299
|
+
Object.defineProperty(exports, "KTToast", ({ enumerable: true, get: function () { return toast_2.KTToast; } }));
|
|
13575
13300
|
var KTComponents = {
|
|
13576
13301
|
init: function () {
|
|
13577
13302
|
dropdown_1.KTDropdown.init();
|
|
@@ -13595,6 +13320,7 @@ var KTComponents = {
|
|
|
13595
13320
|
datatable_1.KTDataTable.init();
|
|
13596
13321
|
datepicker_1.KTDatepicker.init();
|
|
13597
13322
|
select_1.KTSelect.init();
|
|
13323
|
+
toast_1.KTToast.init();
|
|
13598
13324
|
},
|
|
13599
13325
|
};
|
|
13600
13326
|
exports["default"] = KTComponents;
|
|
@@ -14793,43 +14519,51 @@ var KTSelectTags = /** @class */ (function () {
|
|
|
14793
14519
|
*/
|
|
14794
14520
|
KTSelectTags.prototype.updateTagsDisplay = function (selectedOptions) {
|
|
14795
14521
|
var _this = this;
|
|
14796
|
-
//
|
|
14797
|
-
this._valueDisplayElement.
|
|
14798
|
-
|
|
14522
|
+
// Remove any existing tag elements
|
|
14523
|
+
var wrapper = this._valueDisplayElement.parentElement;
|
|
14524
|
+
if (!wrapper)
|
|
14525
|
+
return;
|
|
14526
|
+
// Remove all previous tags
|
|
14527
|
+
Array.from(wrapper.querySelectorAll('[data-kt-select-tag]')).forEach(function (tag) { return tag.remove(); });
|
|
14528
|
+
// If no options selected, do nothing (let display show placeholder)
|
|
14799
14529
|
if (selectedOptions.length === 0) {
|
|
14800
|
-
this._valueDisplayElement.textContent = this._config.placeholder || '';
|
|
14801
14530
|
return;
|
|
14802
14531
|
}
|
|
14803
|
-
//
|
|
14532
|
+
// Insert each tag before the display element
|
|
14804
14533
|
selectedOptions.forEach(function (optionValue) {
|
|
14805
|
-
|
|
14806
|
-
|
|
14534
|
+
// Find the original option element (in dropdown or select)
|
|
14535
|
+
var optionElement = null;
|
|
14536
|
+
var optionElements = _this._select.getOptionsElement();
|
|
14537
|
+
for (var _i = 0, _a = Array.from(optionElements); _i < _a.length; _i++) {
|
|
14538
|
+
var opt = _a[_i];
|
|
14539
|
+
if (opt.dataset.value === optionValue) {
|
|
14540
|
+
optionElement = opt;
|
|
14541
|
+
break;
|
|
14542
|
+
}
|
|
14543
|
+
}
|
|
14544
|
+
if (!optionElement) {
|
|
14545
|
+
var originalOptions = _this._select.getElement().querySelectorAll('option');
|
|
14546
|
+
for (var _b = 0, _c = Array.from(originalOptions); _b < _c.length; _b++) {
|
|
14547
|
+
var opt = _c[_b];
|
|
14548
|
+
if (opt.value === optionValue) {
|
|
14549
|
+
optionElement = opt;
|
|
14550
|
+
break;
|
|
14551
|
+
}
|
|
14552
|
+
}
|
|
14553
|
+
}
|
|
14554
|
+
var tag = templates_1.defaultTemplates.tag(optionElement, _this._config);
|
|
14555
|
+
// Add event listener to the close button
|
|
14556
|
+
var closeButton = tag.querySelector('[data-kt-select-remove-button]');
|
|
14557
|
+
if (closeButton) {
|
|
14558
|
+
_this._eventManager.addListener(closeButton, 'click', function (event) {
|
|
14559
|
+
event.stopPropagation();
|
|
14560
|
+
_this._removeTag(optionValue);
|
|
14561
|
+
});
|
|
14562
|
+
}
|
|
14563
|
+
// Insert tag before the display element
|
|
14564
|
+
wrapper.insertBefore(tag, _this._valueDisplayElement);
|
|
14807
14565
|
});
|
|
14808
14566
|
};
|
|
14809
|
-
/**
|
|
14810
|
-
* Create tag element for a selected option
|
|
14811
|
-
*/
|
|
14812
|
-
KTSelectTags.prototype._createTagElement = function (optionValue) {
|
|
14813
|
-
var _this = this;
|
|
14814
|
-
var optionLabel = this._getOptionLabel(optionValue);
|
|
14815
|
-
// Create a mock option object to pass to the tag template
|
|
14816
|
-
var mockOption = {
|
|
14817
|
-
id: optionValue,
|
|
14818
|
-
title: optionLabel,
|
|
14819
|
-
selected: true,
|
|
14820
|
-
};
|
|
14821
|
-
// Use the tag template
|
|
14822
|
-
var tag = templates_1.defaultTemplates.tag(mockOption, this._config);
|
|
14823
|
-
// Add event listener to the close button
|
|
14824
|
-
var closeButton = tag.querySelector("[data-kt-select-remove-button]");
|
|
14825
|
-
if (closeButton) {
|
|
14826
|
-
this._eventManager.addListener(closeButton, 'click', function (event) {
|
|
14827
|
-
event.stopPropagation();
|
|
14828
|
-
_this._removeTag(optionValue);
|
|
14829
|
-
});
|
|
14830
|
-
}
|
|
14831
|
-
return tag;
|
|
14832
|
-
};
|
|
14833
14567
|
/**
|
|
14834
14568
|
* Get the label/text for an option by its value
|
|
14835
14569
|
*/
|
|
@@ -14874,6 +14608,555 @@ var KTSelectTags = /** @class */ (function () {
|
|
|
14874
14608
|
exports.KTSelectTags = KTSelectTags;
|
|
14875
14609
|
|
|
14876
14610
|
|
|
14611
|
+
/***/ }),
|
|
14612
|
+
|
|
14613
|
+
/***/ 8834:
|
|
14614
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
14615
|
+
|
|
14616
|
+
|
|
14617
|
+
/**
|
|
14618
|
+
* KTUI - Free & Open-Source Tailwind UI Components by Keenthemes
|
|
14619
|
+
* Copyright 2025 by Keenthemes Inc
|
|
14620
|
+
*/
|
|
14621
|
+
var __extends = (this && this.__extends) || (function () {
|
|
14622
|
+
var extendStatics = function (d, b) {
|
|
14623
|
+
extendStatics = Object.setPrototypeOf ||
|
|
14624
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
14625
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
14626
|
+
return extendStatics(d, b);
|
|
14627
|
+
};
|
|
14628
|
+
return function (d, b) {
|
|
14629
|
+
if (typeof b !== "function" && b !== null)
|
|
14630
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14631
|
+
extendStatics(d, b);
|
|
14632
|
+
function __() { this.constructor = d; }
|
|
14633
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14634
|
+
};
|
|
14635
|
+
})();
|
|
14636
|
+
var __assign = (this && this.__assign) || function () {
|
|
14637
|
+
__assign = Object.assign || function(t) {
|
|
14638
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
14639
|
+
s = arguments[i];
|
|
14640
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
14641
|
+
t[p] = s[p];
|
|
14642
|
+
}
|
|
14643
|
+
return t;
|
|
14644
|
+
};
|
|
14645
|
+
return __assign.apply(this, arguments);
|
|
14646
|
+
};
|
|
14647
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14648
|
+
exports.KTToast = void 0;
|
|
14649
|
+
var component_1 = __webpack_require__(2658);
|
|
14650
|
+
var data_1 = __webpack_require__(8716);
|
|
14651
|
+
var DEFAULT_CONFIG = {
|
|
14652
|
+
position: 'top-end',
|
|
14653
|
+
duration: 4000,
|
|
14654
|
+
className: '',
|
|
14655
|
+
maxToasts: 5,
|
|
14656
|
+
offset: 15,
|
|
14657
|
+
gap: 10,
|
|
14658
|
+
};
|
|
14659
|
+
var DEFAULT_TOAST_OPTIONS = {
|
|
14660
|
+
appearance: 'solid',
|
|
14661
|
+
progress: false,
|
|
14662
|
+
size: 'md',
|
|
14663
|
+
action: false,
|
|
14664
|
+
cancel: false,
|
|
14665
|
+
dismiss: true,
|
|
14666
|
+
};
|
|
14667
|
+
var KTToast = /** @class */ (function (_super) {
|
|
14668
|
+
__extends(KTToast, _super);
|
|
14669
|
+
/**
|
|
14670
|
+
* Creates a new KTToast instance for a specific element (not commonly used; most use static API).
|
|
14671
|
+
* @param element The target HTML element.
|
|
14672
|
+
* @param config Optional toast config for this instance.
|
|
14673
|
+
*/
|
|
14674
|
+
function KTToast(element, config) {
|
|
14675
|
+
var _this = _super.call(this) || this;
|
|
14676
|
+
_this._name = 'toast';
|
|
14677
|
+
_this._defaultConfig = DEFAULT_CONFIG;
|
|
14678
|
+
_this._config = DEFAULT_CONFIG;
|
|
14679
|
+
_this._defaultToastOptions = DEFAULT_TOAST_OPTIONS;
|
|
14680
|
+
if (data_1.default.has(element, _this._name))
|
|
14681
|
+
return _this;
|
|
14682
|
+
_this._init(element);
|
|
14683
|
+
_this._buildConfig(config);
|
|
14684
|
+
data_1.default.set(element, _this._name, _this);
|
|
14685
|
+
return _this;
|
|
14686
|
+
}
|
|
14687
|
+
/**
|
|
14688
|
+
* Generates the HTML content for a toast based on the provided options.
|
|
14689
|
+
* @param options Toast options (message, icon, actions, etc).
|
|
14690
|
+
* @returns The toast's HTML markup as a string.
|
|
14691
|
+
*/
|
|
14692
|
+
KTToast.getContent = function (options) {
|
|
14693
|
+
var classNames = __assign(__assign({}, (this.globalConfig.classNames || {})), ((options === null || options === void 0 ? void 0 : options.classNames) || {}));
|
|
14694
|
+
if (options === null || options === void 0 ? void 0 : options.content) {
|
|
14695
|
+
if (typeof options.content === 'string') {
|
|
14696
|
+
return options.content;
|
|
14697
|
+
}
|
|
14698
|
+
else if (typeof options.content === 'function') {
|
|
14699
|
+
var node = options.content();
|
|
14700
|
+
if (node instanceof HTMLElement) {
|
|
14701
|
+
return node.outerHTML;
|
|
14702
|
+
}
|
|
14703
|
+
}
|
|
14704
|
+
else if (options.content instanceof HTMLElement) {
|
|
14705
|
+
return options.content.outerHTML;
|
|
14706
|
+
}
|
|
14707
|
+
}
|
|
14708
|
+
var template = '';
|
|
14709
|
+
if (options === null || options === void 0 ? void 0 : options.icon) {
|
|
14710
|
+
template +=
|
|
14711
|
+
'<div class="kt-alert-icon ' +
|
|
14712
|
+
(classNames.icon || '') +
|
|
14713
|
+
'">' +
|
|
14714
|
+
options.icon +
|
|
14715
|
+
'</div>';
|
|
14716
|
+
}
|
|
14717
|
+
if (options === null || options === void 0 ? void 0 : options.message) {
|
|
14718
|
+
template +=
|
|
14719
|
+
'<div class="kt-alert-title ' +
|
|
14720
|
+
(classNames.message || '') +
|
|
14721
|
+
'">' +
|
|
14722
|
+
options.message +
|
|
14723
|
+
'</div>';
|
|
14724
|
+
}
|
|
14725
|
+
if ((options === null || options === void 0 ? void 0 : options.action) !== false ||
|
|
14726
|
+
(options === null || options === void 0 ? void 0 : options.dismiss) !== false ||
|
|
14727
|
+
(options === null || options === void 0 ? void 0 : options.cancel) !== false) {
|
|
14728
|
+
template +=
|
|
14729
|
+
'<div class="kt-alert-toolbar ' + (classNames.toolbar || '') + '">';
|
|
14730
|
+
template +=
|
|
14731
|
+
'<div class="kt-alert-actions ' + (classNames.actions || '') + '">';
|
|
14732
|
+
if ((options === null || options === void 0 ? void 0 : options.action) && typeof options.action === 'object') {
|
|
14733
|
+
template +=
|
|
14734
|
+
'<button data-kt-toast-action="true" class="' +
|
|
14735
|
+
(options.action.className || '') +
|
|
14736
|
+
'">' +
|
|
14737
|
+
options.action.label +
|
|
14738
|
+
'</button>';
|
|
14739
|
+
}
|
|
14740
|
+
if ((options === null || options === void 0 ? void 0 : options.cancel) && typeof options.cancel === 'object') {
|
|
14741
|
+
template +=
|
|
14742
|
+
'<button data-kt-toast-cancel="true" class="' +
|
|
14743
|
+
(options.cancel.className || '') +
|
|
14744
|
+
'">' +
|
|
14745
|
+
options.cancel.label +
|
|
14746
|
+
'</button>';
|
|
14747
|
+
}
|
|
14748
|
+
if ((options === null || options === void 0 ? void 0 : options.dismiss) !== false) {
|
|
14749
|
+
template +=
|
|
14750
|
+
'<button data-kt-toast-dismiss="true" class="kt-alert-close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>';
|
|
14751
|
+
}
|
|
14752
|
+
template += '</div>';
|
|
14753
|
+
template += '</div>';
|
|
14754
|
+
}
|
|
14755
|
+
template += '</div>';
|
|
14756
|
+
return template;
|
|
14757
|
+
};
|
|
14758
|
+
/**
|
|
14759
|
+
* Update all toasts in the container with smooth animation.
|
|
14760
|
+
*
|
|
14761
|
+
* @param container The toast container element.
|
|
14762
|
+
* @param offset Optional offset from the edge.
|
|
14763
|
+
*/
|
|
14764
|
+
KTToast.update = function (container, offset) {
|
|
14765
|
+
var _this = this;
|
|
14766
|
+
var _a;
|
|
14767
|
+
if (!container)
|
|
14768
|
+
return;
|
|
14769
|
+
offset =
|
|
14770
|
+
typeof offset === 'number' ? offset : ((_a = this.globalConfig.offset) !== null && _a !== void 0 ? _a : 15);
|
|
14771
|
+
requestAnimationFrame(function () {
|
|
14772
|
+
var _a;
|
|
14773
|
+
var gap = (_a = _this.globalConfig.gap) !== null && _a !== void 0 ? _a : 8;
|
|
14774
|
+
// Group toasts by alignment (top/bottom)
|
|
14775
|
+
var positionGroups = {
|
|
14776
|
+
top: [],
|
|
14777
|
+
bottom: [],
|
|
14778
|
+
};
|
|
14779
|
+
var toasts = Array.from(container.children);
|
|
14780
|
+
toasts.forEach(function (toast) {
|
|
14781
|
+
if (toast.classList.contains('kt-toast-top-end') ||
|
|
14782
|
+
toast.classList.contains('kt-toast-top-center') ||
|
|
14783
|
+
toast.classList.contains('kt-toast-top-start')) {
|
|
14784
|
+
positionGroups.top.push(toast);
|
|
14785
|
+
}
|
|
14786
|
+
else {
|
|
14787
|
+
positionGroups.bottom.push(toast);
|
|
14788
|
+
}
|
|
14789
|
+
});
|
|
14790
|
+
// Stack top toasts from the top down
|
|
14791
|
+
var currentOffset = offset;
|
|
14792
|
+
positionGroups.top.forEach(function (toast) {
|
|
14793
|
+
toast.style.top = "".concat(currentOffset, "px");
|
|
14794
|
+
toast.style.bottom = '';
|
|
14795
|
+
toast.style.transition =
|
|
14796
|
+
'top 0.28s cubic-bezier(.4,0,.2,1), opacity 0.28s cubic-bezier(.4,0,.2,1)';
|
|
14797
|
+
currentOffset += toast.offsetHeight + gap;
|
|
14798
|
+
if (toast.classList.contains('kt-toast-top-start')) {
|
|
14799
|
+
toast.style.insetInlineStart = "".concat(offset, "px");
|
|
14800
|
+
}
|
|
14801
|
+
if (toast.classList.contains('kt-toast-top-end')) {
|
|
14802
|
+
toast.style.insetInlineEnd = "".concat(offset, "px");
|
|
14803
|
+
}
|
|
14804
|
+
});
|
|
14805
|
+
// Stack bottom toasts from the bottom up
|
|
14806
|
+
currentOffset = offset;
|
|
14807
|
+
for (var i = positionGroups.bottom.length - 1; i >= 0; i--) {
|
|
14808
|
+
var toast = positionGroups.bottom[i];
|
|
14809
|
+
toast.style.bottom = "".concat(currentOffset, "px");
|
|
14810
|
+
toast.style.top = '';
|
|
14811
|
+
toast.style.transition =
|
|
14812
|
+
'bottom 0.28s cubic-bezier(.4,0,.2,1), opacity 0.28s cubic-bezier(.4,0,.2,1)';
|
|
14813
|
+
currentOffset += toast.offsetHeight + gap;
|
|
14814
|
+
if (toast.classList.contains('kt-toast-bottom-start')) {
|
|
14815
|
+
toast.style.insetInlineStart = "".concat(offset, "px");
|
|
14816
|
+
}
|
|
14817
|
+
if (toast.classList.contains('kt-toast-bottom-end')) {
|
|
14818
|
+
toast.style.insetInlineEnd = "".concat(offset, "px");
|
|
14819
|
+
}
|
|
14820
|
+
}
|
|
14821
|
+
});
|
|
14822
|
+
};
|
|
14823
|
+
/**
|
|
14824
|
+
* Set global toast configuration options.
|
|
14825
|
+
* @param options Partial toast config to merge with global config.
|
|
14826
|
+
*/
|
|
14827
|
+
KTToast.config = function (options) {
|
|
14828
|
+
this.globalConfig = __assign(__assign({}, this.globalConfig), options);
|
|
14829
|
+
};
|
|
14830
|
+
/**
|
|
14831
|
+
* Show a toast notification.
|
|
14832
|
+
* @param inputOptions Toast options (message, duration, variant, etc).
|
|
14833
|
+
* @returns Toast instance with dismiss method, or undefined if invalid input.
|
|
14834
|
+
*/
|
|
14835
|
+
KTToast.show = function (inputOptions) {
|
|
14836
|
+
var _a, _b, _c, _d;
|
|
14837
|
+
var options = __assign(__assign({}, DEFAULT_TOAST_OPTIONS), inputOptions);
|
|
14838
|
+
if (!options || (!options.message && !options.content)) {
|
|
14839
|
+
return undefined;
|
|
14840
|
+
}
|
|
14841
|
+
// Always resolve the id once and use it everywhere
|
|
14842
|
+
var id = "kt-toast-".concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 8));
|
|
14843
|
+
var position = options.position || this.globalConfig.position || 'top-end';
|
|
14844
|
+
var classNames = __assign(__assign({}, (this.globalConfig.classNames || {})), (options.classNames || {}));
|
|
14845
|
+
var container = this.containerMap.get(position);
|
|
14846
|
+
if (!container) {
|
|
14847
|
+
container = document.createElement('div');
|
|
14848
|
+
var classNames_1 = __assign(__assign({}, (this.globalConfig.classNames || {})), (options.classNames || {}));
|
|
14849
|
+
// Fallback to default hardcoded classes if not provided in options or globalConfig
|
|
14850
|
+
container.className =
|
|
14851
|
+
classNames_1.container || "kt-toast-container ".concat(position);
|
|
14852
|
+
document.body.appendChild(container);
|
|
14853
|
+
this.containerMap.set(position, container);
|
|
14854
|
+
}
|
|
14855
|
+
// Enforce maxToasts
|
|
14856
|
+
if (container.children.length >=
|
|
14857
|
+
(this.globalConfig.maxToasts || DEFAULT_CONFIG.maxToasts)) {
|
|
14858
|
+
var firstToast_1 = container.firstElementChild;
|
|
14859
|
+
if (firstToast_1) {
|
|
14860
|
+
firstToast_1.classList.add('kt-toast-closing');
|
|
14861
|
+
firstToast_1.addEventListener('animationend', function () {
|
|
14862
|
+
firstToast_1.remove();
|
|
14863
|
+
});
|
|
14864
|
+
}
|
|
14865
|
+
}
|
|
14866
|
+
// Create toast element
|
|
14867
|
+
var variantMap = {
|
|
14868
|
+
info: 'kt-alert-info',
|
|
14869
|
+
success: 'kt-alert-success',
|
|
14870
|
+
error: 'kt-alert-error',
|
|
14871
|
+
warning: 'kt-alert-warning',
|
|
14872
|
+
primary: 'kt-alert-primary',
|
|
14873
|
+
secondary: 'kt-alert-secondary',
|
|
14874
|
+
destructive: 'kt-alert-destructive',
|
|
14875
|
+
mono: 'kt-alert-mono',
|
|
14876
|
+
};
|
|
14877
|
+
var appearanceMap = {
|
|
14878
|
+
solid: 'kt-alert-solid',
|
|
14879
|
+
outline: 'kt-alert-outline',
|
|
14880
|
+
light: 'kt-alert-light',
|
|
14881
|
+
};
|
|
14882
|
+
var sizeMap = {
|
|
14883
|
+
sm: 'kt-alert-sm',
|
|
14884
|
+
md: 'kt-alert-md',
|
|
14885
|
+
lg: 'kt-alert-lg',
|
|
14886
|
+
};
|
|
14887
|
+
var toast = document.createElement('div');
|
|
14888
|
+
toast.className = "kt-toast kt-alert ".concat(variantMap[options.variant] || '', " ").concat(appearanceMap[options.appearance] || '', " ").concat(sizeMap[options.size] || '', " ").concat(options.className || '', " ").concat(classNames.toast || '');
|
|
14889
|
+
// ARIA support
|
|
14890
|
+
toast.setAttribute('role', options.role || 'status');
|
|
14891
|
+
toast.setAttribute('aria-live', 'polite');
|
|
14892
|
+
toast.setAttribute('aria-atomic', 'true');
|
|
14893
|
+
toast.setAttribute('tabindex', '0');
|
|
14894
|
+
// Always resolve the id once and use it everywhere
|
|
14895
|
+
// Always resolve id ONCE at the top, use everywhere
|
|
14896
|
+
// (Move this up to replace the previous const id = ... assignment)
|
|
14897
|
+
// Populate content via getContent
|
|
14898
|
+
var contentHtml = KTToast.getContent(options);
|
|
14899
|
+
toast.innerHTML = contentHtml;
|
|
14900
|
+
// Assign event handlers to buttons by data attribute
|
|
14901
|
+
var actionBtn = toast.querySelector('[data-kt-toast-action]');
|
|
14902
|
+
if (actionBtn &&
|
|
14903
|
+
options.action &&
|
|
14904
|
+
typeof options.action === 'object' &&
|
|
14905
|
+
options.action.onClick) {
|
|
14906
|
+
actionBtn.addEventListener('click', function (e) {
|
|
14907
|
+
e.stopPropagation();
|
|
14908
|
+
if (typeof options.action === 'object' && options.action.onClick) {
|
|
14909
|
+
options.action.onClick(id);
|
|
14910
|
+
KTToast.close(id);
|
|
14911
|
+
}
|
|
14912
|
+
});
|
|
14913
|
+
}
|
|
14914
|
+
var cancelBtn = toast.querySelector('[data-kt-toast-cancel]');
|
|
14915
|
+
if (cancelBtn && options.cancel && typeof options.cancel === 'object') {
|
|
14916
|
+
cancelBtn.addEventListener('click', function (e) {
|
|
14917
|
+
e.stopPropagation();
|
|
14918
|
+
if (typeof options.cancel === 'object' && options.cancel.onClick) {
|
|
14919
|
+
options.cancel.onClick(id);
|
|
14920
|
+
KTToast.close(id);
|
|
14921
|
+
}
|
|
14922
|
+
});
|
|
14923
|
+
}
|
|
14924
|
+
// Dismiss button handler
|
|
14925
|
+
var dismissBtn = toast.querySelector('[data-kt-toast-dismiss]');
|
|
14926
|
+
if (dismissBtn && options.dismiss !== false) {
|
|
14927
|
+
dismissBtn.addEventListener('click', function (e) {
|
|
14928
|
+
e.stopPropagation();
|
|
14929
|
+
KTToast.close(id);
|
|
14930
|
+
});
|
|
14931
|
+
}
|
|
14932
|
+
// If modal-like, set aria-modal
|
|
14933
|
+
if (options.important)
|
|
14934
|
+
toast.setAttribute('aria-modal', 'true');
|
|
14935
|
+
toast.style.pointerEvents = 'auto';
|
|
14936
|
+
// Progress line
|
|
14937
|
+
var duration = options.important
|
|
14938
|
+
? null
|
|
14939
|
+
: ((_b = (_a = options.duration) !== null && _a !== void 0 ? _a : this.globalConfig.duration) !== null && _b !== void 0 ? _b : DEFAULT_CONFIG.duration);
|
|
14940
|
+
if (duration && options.progress) {
|
|
14941
|
+
var progress = document.createElement('div');
|
|
14942
|
+
progress.className = 'kt-toast-progress ' + (classNames.progress || '');
|
|
14943
|
+
progress.style.animationDuration = duration + 'ms';
|
|
14944
|
+
progress.setAttribute('data-kt-toast-progress', 'true');
|
|
14945
|
+
toast.appendChild(progress);
|
|
14946
|
+
}
|
|
14947
|
+
// Assign direction class to the toast itself, not the container
|
|
14948
|
+
var directionClassMap = {
|
|
14949
|
+
'top-end': 'kt-toast-top-end',
|
|
14950
|
+
'top-center': 'kt-toast-top-center',
|
|
14951
|
+
'top-start': 'kt-toast-top-start',
|
|
14952
|
+
'bottom-end': 'kt-toast-bottom-end',
|
|
14953
|
+
'bottom-center': 'kt-toast-bottom-center',
|
|
14954
|
+
'bottom-start': 'kt-toast-bottom-start',
|
|
14955
|
+
};
|
|
14956
|
+
Object.values(directionClassMap).forEach(function (cls) {
|
|
14957
|
+
return toast.classList.remove(cls);
|
|
14958
|
+
});
|
|
14959
|
+
var dirClass = directionClassMap[position] || 'kt-toast-top-end';
|
|
14960
|
+
toast.classList.add(dirClass);
|
|
14961
|
+
// Enforce maxToasts: remove oldest if needed
|
|
14962
|
+
var maxToasts = (_d = (_c = options.maxToasts) !== null && _c !== void 0 ? _c : this.globalConfig.maxToasts) !== null && _d !== void 0 ? _d : DEFAULT_CONFIG.maxToasts;
|
|
14963
|
+
var currentToasts = Array.from(container.children);
|
|
14964
|
+
if (currentToasts.length >= maxToasts && currentToasts.length > 0) {
|
|
14965
|
+
var oldestToast = currentToasts[currentToasts.length - 1];
|
|
14966
|
+
var oldestId = oldestToast.getAttribute('data-kt-toast-id');
|
|
14967
|
+
if (oldestId) {
|
|
14968
|
+
KTToast.close(oldestId);
|
|
14969
|
+
}
|
|
14970
|
+
else {
|
|
14971
|
+
oldestToast.remove();
|
|
14972
|
+
}
|
|
14973
|
+
}
|
|
14974
|
+
// Insert toast at the top
|
|
14975
|
+
container.insertBefore(toast, container.firstChild);
|
|
14976
|
+
KTToast.update(container);
|
|
14977
|
+
// Play beep if requested
|
|
14978
|
+
if (options.beep) {
|
|
14979
|
+
try {
|
|
14980
|
+
// Use Web Audio API for a short beep
|
|
14981
|
+
var ctx_1 = new (window.AudioContext ||
|
|
14982
|
+
window.webkitAudioContext)();
|
|
14983
|
+
var o_1 = ctx_1.createOscillator();
|
|
14984
|
+
var g = ctx_1.createGain();
|
|
14985
|
+
o_1.type = 'sine';
|
|
14986
|
+
o_1.frequency.value = 880;
|
|
14987
|
+
g.gain.value = 0.09;
|
|
14988
|
+
o_1.connect(g);
|
|
14989
|
+
g.connect(ctx_1.destination);
|
|
14990
|
+
o_1.start();
|
|
14991
|
+
setTimeout(function () {
|
|
14992
|
+
o_1.stop();
|
|
14993
|
+
ctx_1.close();
|
|
14994
|
+
}, 120);
|
|
14995
|
+
}
|
|
14996
|
+
catch (e) {
|
|
14997
|
+
/* ignore */
|
|
14998
|
+
}
|
|
14999
|
+
}
|
|
15000
|
+
KTToast._fireEventOnElement(toast, 'show', { id: id });
|
|
15001
|
+
KTToast._dispatchEventOnElement(toast, 'show', { id: id });
|
|
15002
|
+
var instance = { id: id, element: toast, timeoutId: 0 };
|
|
15003
|
+
KTToast.toasts.set(id, instance);
|
|
15004
|
+
// Auto-dismiss
|
|
15005
|
+
var timeoutId = undefined;
|
|
15006
|
+
var remaining = duration;
|
|
15007
|
+
var startTime;
|
|
15008
|
+
var paused = false;
|
|
15009
|
+
var progressEl = null;
|
|
15010
|
+
if (duration) {
|
|
15011
|
+
var startTimer_1 = function (ms) {
|
|
15012
|
+
startTime = Date.now();
|
|
15013
|
+
timeoutId = window.setTimeout(function () {
|
|
15014
|
+
var _a;
|
|
15015
|
+
(_a = options.onAutoClose) === null || _a === void 0 ? void 0 : _a.call(options, id);
|
|
15016
|
+
KTToast.close(id);
|
|
15017
|
+
}, ms);
|
|
15018
|
+
instance.timeoutId = timeoutId;
|
|
15019
|
+
};
|
|
15020
|
+
startTimer_1(duration);
|
|
15021
|
+
if (options.pauseOnHover) {
|
|
15022
|
+
progressEl = toast.querySelector('[data-kt-toast-progress]');
|
|
15023
|
+
var progressPausedAt_1 = 0;
|
|
15024
|
+
var pause = function () {
|
|
15025
|
+
if (!paused && timeoutId) {
|
|
15026
|
+
paused = true;
|
|
15027
|
+
window.clearTimeout(timeoutId);
|
|
15028
|
+
if (startTime) {
|
|
15029
|
+
remaining -= Date.now() - startTime;
|
|
15030
|
+
}
|
|
15031
|
+
// Pause progress bar
|
|
15032
|
+
if (progressEl) {
|
|
15033
|
+
var computedStyle = window.getComputedStyle(progressEl);
|
|
15034
|
+
var matrix = computedStyle.transform;
|
|
15035
|
+
var scaleX = 1;
|
|
15036
|
+
if (matrix && matrix !== 'none') {
|
|
15037
|
+
var values = matrix.match(/matrix\(([^)]+)\)/);
|
|
15038
|
+
if (values && values[1]) {
|
|
15039
|
+
scaleX = parseFloat(values[1].split(',')[0]);
|
|
15040
|
+
}
|
|
15041
|
+
}
|
|
15042
|
+
progressPausedAt_1 = scaleX;
|
|
15043
|
+
progressEl.style.animation = 'none';
|
|
15044
|
+
progressEl.style.transition = 'none';
|
|
15045
|
+
progressEl.style.transform = "scaleX(".concat(scaleX, ")");
|
|
15046
|
+
}
|
|
15047
|
+
}
|
|
15048
|
+
};
|
|
15049
|
+
var resume = function () {
|
|
15050
|
+
if (paused && remaining > 0) {
|
|
15051
|
+
paused = false;
|
|
15052
|
+
startTimer_1(remaining);
|
|
15053
|
+
// Resume progress bar
|
|
15054
|
+
if (progressEl) {
|
|
15055
|
+
progressEl.style.transition = 'transform 0ms';
|
|
15056
|
+
progressEl.style.transform = "scaleX(".concat(progressPausedAt_1, ")");
|
|
15057
|
+
progressEl.offsetHeight; // force reflow
|
|
15058
|
+
progressEl.style.transition = "transform ".concat(remaining, "ms linear");
|
|
15059
|
+
progressEl.style.transform = 'scaleX(0)';
|
|
15060
|
+
}
|
|
15061
|
+
}
|
|
15062
|
+
};
|
|
15063
|
+
toast.addEventListener('mouseenter', pause);
|
|
15064
|
+
toast.addEventListener('mouseleave', resume);
|
|
15065
|
+
}
|
|
15066
|
+
}
|
|
15067
|
+
KTToast._fireEventOnElement(toast, 'shown', { id: id });
|
|
15068
|
+
KTToast._dispatchEventOnElement(toast, 'shown', { id: id });
|
|
15069
|
+
return __assign(__assign({}, instance), { dismiss: function () { return KTToast.close(id); } });
|
|
15070
|
+
};
|
|
15071
|
+
/**
|
|
15072
|
+
* Close and remove all active toasts.
|
|
15073
|
+
*/
|
|
15074
|
+
KTToast.clearAll = function () {
|
|
15075
|
+
for (var _i = 0, _a = Array.from(this.toasts.keys()); _i < _a.length; _i++) {
|
|
15076
|
+
var id = _a[_i];
|
|
15077
|
+
console.log('clearAll:', id);
|
|
15078
|
+
this.close(id);
|
|
15079
|
+
}
|
|
15080
|
+
};
|
|
15081
|
+
/**
|
|
15082
|
+
* Close a toast by ID or instance.
|
|
15083
|
+
* @param idOrInstance Toast ID string or KTToastInstance.
|
|
15084
|
+
*/
|
|
15085
|
+
KTToast.close = function (idOrInstance) {
|
|
15086
|
+
var inst;
|
|
15087
|
+
var id;
|
|
15088
|
+
if (!idOrInstance)
|
|
15089
|
+
return;
|
|
15090
|
+
if (typeof idOrInstance === 'string') {
|
|
15091
|
+
id = idOrInstance;
|
|
15092
|
+
inst = this.toasts.get(id);
|
|
15093
|
+
}
|
|
15094
|
+
else if (typeof idOrInstance === 'object' && idOrInstance.id) {
|
|
15095
|
+
id = idOrInstance.id;
|
|
15096
|
+
inst = idOrInstance;
|
|
15097
|
+
}
|
|
15098
|
+
if (!inst || !id)
|
|
15099
|
+
return;
|
|
15100
|
+
if (inst._closing)
|
|
15101
|
+
return; // Prevent double-close
|
|
15102
|
+
inst._closing = true;
|
|
15103
|
+
clearTimeout(inst.timeoutId);
|
|
15104
|
+
KTToast._fireEventOnElement(inst.element, 'hide', { id: id });
|
|
15105
|
+
KTToast._dispatchEventOnElement(inst.element, 'hide', { id: id });
|
|
15106
|
+
// Remove progress bar instantly if present
|
|
15107
|
+
var progressEl = inst.element.querySelector('[data-kt-toast-progress]');
|
|
15108
|
+
if (progressEl)
|
|
15109
|
+
progressEl.remove();
|
|
15110
|
+
inst.element.style.animation = 'kt-toast-out 0.25s forwards';
|
|
15111
|
+
setTimeout(function () {
|
|
15112
|
+
var _a;
|
|
15113
|
+
var parent = inst === null || inst === void 0 ? void 0 : inst.element.parentElement;
|
|
15114
|
+
inst === null || inst === void 0 ? void 0 : inst.element.remove();
|
|
15115
|
+
KTToast.toasts.delete(id);
|
|
15116
|
+
// Try to call onDismiss if available in the toast instance (if stored)
|
|
15117
|
+
if (typeof ((_a = inst.options) === null || _a === void 0 ? void 0 : _a.onDismiss) === 'function') {
|
|
15118
|
+
inst.options.onDismiss(id);
|
|
15119
|
+
}
|
|
15120
|
+
KTToast._fireEventOnElement(inst.element, 'hidden', { id: id });
|
|
15121
|
+
KTToast._dispatchEventOnElement(inst.element, 'hidden', { id: id });
|
|
15122
|
+
// update toasts asynchronously after DOM update
|
|
15123
|
+
setTimeout(function () {
|
|
15124
|
+
KTToast.update(parent);
|
|
15125
|
+
}, 0);
|
|
15126
|
+
}, 250);
|
|
15127
|
+
};
|
|
15128
|
+
/**
|
|
15129
|
+
* Dispatches a custom 'kt.toast.{eventType}' event on the given element.
|
|
15130
|
+
* @param element The toast element.
|
|
15131
|
+
* @param eventType The event type (e.g. 'show', 'hide').
|
|
15132
|
+
* @param payload Optional event detail payload.
|
|
15133
|
+
*/
|
|
15134
|
+
KTToast._fireEventOnElement = function (element, eventType, payload) {
|
|
15135
|
+
var event = new CustomEvent("kt.toast.".concat(eventType), { detail: payload });
|
|
15136
|
+
element.dispatchEvent(event);
|
|
15137
|
+
};
|
|
15138
|
+
/**
|
|
15139
|
+
* Dispatches a custom event (not namespaced) on the given element.
|
|
15140
|
+
* @param element The toast element.
|
|
15141
|
+
* @param eventType The event type.
|
|
15142
|
+
* @param payload Optional event detail payload.
|
|
15143
|
+
*/
|
|
15144
|
+
KTToast._dispatchEventOnElement = function (element, eventType, payload) {
|
|
15145
|
+
var event = new CustomEvent(eventType, { detail: payload });
|
|
15146
|
+
element.dispatchEvent(event);
|
|
15147
|
+
};
|
|
15148
|
+
/**
|
|
15149
|
+
* Initialize toast system (placeholder for future use).
|
|
15150
|
+
*/
|
|
15151
|
+
KTToast.init = function () { };
|
|
15152
|
+
KTToast.containerMap = new Map();
|
|
15153
|
+
KTToast.toasts = new Map();
|
|
15154
|
+
KTToast.globalConfig = __assign({}, DEFAULT_CONFIG);
|
|
15155
|
+
return KTToast;
|
|
15156
|
+
}(component_1.default));
|
|
15157
|
+
exports.KTToast = KTToast;
|
|
15158
|
+
|
|
15159
|
+
|
|
14877
15160
|
/***/ }),
|
|
14878
15161
|
|
|
14879
15162
|
/***/ 9010:
|
|
@@ -15168,6 +15451,30 @@ var KTDom = {
|
|
|
15168
15451
|
}
|
|
15169
15452
|
return attributes;
|
|
15170
15453
|
},
|
|
15454
|
+
getDataAttributesByJson: function (element, prefix) {
|
|
15455
|
+
if (!element) {
|
|
15456
|
+
return {};
|
|
15457
|
+
}
|
|
15458
|
+
var rawValue = element.dataset[prefix];
|
|
15459
|
+
if (!rawValue) {
|
|
15460
|
+
return {};
|
|
15461
|
+
}
|
|
15462
|
+
var parsedValue = utils_1.default.parseDataAttribute(rawValue);
|
|
15463
|
+
if (typeof parsedValue === 'string') {
|
|
15464
|
+
try {
|
|
15465
|
+
return JSON.parse(parsedValue);
|
|
15466
|
+
}
|
|
15467
|
+
catch (e) {
|
|
15468
|
+
console.error("Invalid JSON format for '".concat(prefix, "': ").concat(e instanceof Error ? e.message : e, " ").concat(rawValue));
|
|
15469
|
+
}
|
|
15470
|
+
}
|
|
15471
|
+
// If it's already an object, return as is
|
|
15472
|
+
if (typeof parsedValue === 'object' && parsedValue !== null) {
|
|
15473
|
+
return parsedValue;
|
|
15474
|
+
}
|
|
15475
|
+
// For other types (number, boolean, null), return an empty object
|
|
15476
|
+
return {};
|
|
15477
|
+
},
|
|
15171
15478
|
ready: function (callback) {
|
|
15172
15479
|
if (document.readyState === 'loading') {
|
|
15173
15480
|
document.addEventListener('DOMContentLoaded', function () {
|
|
@@ -15193,12 +15500,14 @@ exports["default"] = KTDom;
|
|
|
15193
15500
|
* Copyright 2025 by Keenthemes Inc
|
|
15194
15501
|
*/
|
|
15195
15502
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15196
|
-
exports.EventManager = exports.FocusManager = void 0;
|
|
15503
|
+
exports.TypeToSearchBuffer = exports.EventManager = exports.FocusManager = exports.highlightTextInElementDebounced = void 0;
|
|
15197
15504
|
exports.formatCurrency = formatCurrency;
|
|
15198
15505
|
exports.filterOptions = filterOptions;
|
|
15199
15506
|
exports.highlightTextInElement = highlightTextInElement;
|
|
15200
|
-
exports.handleDropdownKeyNavigation = handleDropdownKeyNavigation;
|
|
15201
15507
|
exports.debounce = debounce;
|
|
15508
|
+
exports.renderTemplateString = renderTemplateString;
|
|
15509
|
+
exports.stringToElement = stringToElement;
|
|
15510
|
+
// utils.ts
|
|
15202
15511
|
var templates_1 = __webpack_require__(9069);
|
|
15203
15512
|
/**
|
|
15204
15513
|
* Format a number as a currency string
|
|
@@ -15239,6 +15548,17 @@ function filterOptions(options, query, config, dropdownElement, onVisibleCount)
|
|
|
15239
15548
|
option.setAttribute('style', styleAttr.replace(/display:\s*[^;]+;?/gi, '').trim());
|
|
15240
15549
|
}
|
|
15241
15550
|
}
|
|
15551
|
+
// Clear highlights by restoring original text content
|
|
15552
|
+
if (option.dataset && option.dataset.originalText) {
|
|
15553
|
+
option.innerHTML = option.dataset.originalText;
|
|
15554
|
+
}
|
|
15555
|
+
else {
|
|
15556
|
+
option.innerHTML = option.textContent || '';
|
|
15557
|
+
}
|
|
15558
|
+
// Remove the cache if present
|
|
15559
|
+
if (option.dataset && option.dataset.originalText) {
|
|
15560
|
+
delete option.dataset.originalText;
|
|
15561
|
+
}
|
|
15242
15562
|
visibleOptionsCount++;
|
|
15243
15563
|
}
|
|
15244
15564
|
// Call the callback with the visible count if provided
|
|
@@ -15252,6 +15572,8 @@ function filterOptions(options, query, config, dropdownElement, onVisibleCount)
|
|
|
15252
15572
|
var option = options_2[_b];
|
|
15253
15573
|
var optionText = ((_a = option.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
15254
15574
|
var isMatch = optionText.includes(query.toLowerCase());
|
|
15575
|
+
// Check if option is disabled
|
|
15576
|
+
var isDisabled = option.classList.contains('disabled') || option.getAttribute('aria-disabled') === 'true';
|
|
15255
15577
|
if (isMatch || query.trim() === '') {
|
|
15256
15578
|
// Show option by removing the hidden class and any display inline styles
|
|
15257
15579
|
option.classList.remove('hidden');
|
|
@@ -15268,22 +15590,11 @@ function filterOptions(options, query, config, dropdownElement, onVisibleCount)
|
|
|
15268
15590
|
}
|
|
15269
15591
|
}
|
|
15270
15592
|
visibleOptionsCount++;
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
var hasIcon = option.querySelector('[data-kt-select-option-icon]') !== null;
|
|
15275
|
-
var hasDescription = option.querySelector('[data-kt-select-option-description]') !== null;
|
|
15276
|
-
if (hasIcon || hasDescription) {
|
|
15277
|
-
// Only highlight the text part without changing structure
|
|
15278
|
-
var titleElement = option.querySelector('[data-kt-option-title]');
|
|
15279
|
-
if (titleElement) {
|
|
15280
|
-
highlightTextInElement(titleElement, query, config);
|
|
15281
|
-
}
|
|
15282
|
-
}
|
|
15283
|
-
else {
|
|
15284
|
-
// Simple option with just text - standard highlighting
|
|
15285
|
-
highlightTextInElement(option, query, config);
|
|
15593
|
+
if (config.searchHighlight && query.trim() !== '') {
|
|
15594
|
+
if (option.dataset && !option.dataset.originalText) {
|
|
15595
|
+
option.dataset.originalText = option.innerHTML;
|
|
15286
15596
|
}
|
|
15597
|
+
(0, exports.highlightTextInElementDebounced)(option, query, config);
|
|
15287
15598
|
}
|
|
15288
15599
|
}
|
|
15289
15600
|
else {
|
|
@@ -15320,37 +15631,39 @@ function highlightTextInElement(element, query, config) {
|
|
|
15320
15631
|
if (!element || !query || query.trim() === '')
|
|
15321
15632
|
return;
|
|
15322
15633
|
var queryLower = query.toLowerCase();
|
|
15323
|
-
|
|
15324
|
-
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
// Use the highlight template, which returns an HTMLElement
|
|
15337
|
-
var highlightSpan = templates_1.defaultTemplates.highlight(config, match);
|
|
15338
|
-
frag.appendChild(highlightSpan);
|
|
15339
|
-
if (after)
|
|
15340
|
-
frag.appendChild(document.createTextNode(after));
|
|
15341
|
-
(_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(frag, node);
|
|
15342
|
-
// Only highlight the first occurrence in this node
|
|
15343
|
-
}
|
|
15344
|
-
}
|
|
15345
|
-
else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
15346
|
-
// Don't re-highlight already highlighted nodes
|
|
15347
|
-
if (node.classList.contains('highlight'))
|
|
15348
|
-
return;
|
|
15349
|
-
Array.from(node.childNodes).forEach(walk);
|
|
15350
|
-
}
|
|
15634
|
+
var text = element.textContent || '';
|
|
15635
|
+
if (!text)
|
|
15636
|
+
return;
|
|
15637
|
+
// Escape regex special characters in query
|
|
15638
|
+
var escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
15639
|
+
var regex = new RegExp(escapedQuery, 'gi');
|
|
15640
|
+
// Replace all matches with the highlight template
|
|
15641
|
+
var lastIndex = 0;
|
|
15642
|
+
var result = '';
|
|
15643
|
+
var match;
|
|
15644
|
+
var matches = [];
|
|
15645
|
+
while ((match = regex.exec(text)) !== null) {
|
|
15646
|
+
matches.push({ start: match.index, end: regex.lastIndex });
|
|
15351
15647
|
}
|
|
15352
|
-
|
|
15648
|
+
if (matches.length === 0) {
|
|
15649
|
+
element.innerHTML = text;
|
|
15650
|
+
return;
|
|
15651
|
+
}
|
|
15652
|
+
for (var i = 0; i < matches.length; i++) {
|
|
15653
|
+
var _a = matches[i], start = _a.start, end = _a.end;
|
|
15654
|
+
// Add text before match
|
|
15655
|
+
result += text.slice(lastIndex, start);
|
|
15656
|
+
// Add highlighted match using template
|
|
15657
|
+
var highlighted = templates_1.defaultTemplates.highlight(config, text.slice(start, end)).outerHTML;
|
|
15658
|
+
result += highlighted;
|
|
15659
|
+
lastIndex = end;
|
|
15660
|
+
}
|
|
15661
|
+
// Add remaining text
|
|
15662
|
+
result += text.slice(lastIndex);
|
|
15663
|
+
element.innerHTML = result;
|
|
15353
15664
|
}
|
|
15665
|
+
// Debounced version for performance
|
|
15666
|
+
exports.highlightTextInElementDebounced = debounce(highlightTextInElement, 100);
|
|
15354
15667
|
/**
|
|
15355
15668
|
* Focus manager for keyboard navigation
|
|
15356
15669
|
* Consolidates redundant focus management logic into shared functions
|
|
@@ -15359,16 +15672,14 @@ var FocusManager = /** @class */ (function () {
|
|
|
15359
15672
|
function FocusManager(element, optionsSelector, config) {
|
|
15360
15673
|
if (optionsSelector === void 0) { optionsSelector = '[data-kt-select-option]'; }
|
|
15361
15674
|
this._focusedOptionIndex = null;
|
|
15675
|
+
this._onFocusChange = null;
|
|
15362
15676
|
this._element = element;
|
|
15363
15677
|
this._optionsSelector = optionsSelector;
|
|
15364
15678
|
this._eventManager = new EventManager();
|
|
15365
|
-
// Use config values if provided, otherwise fallback to defaults
|
|
15366
|
-
this._focusClass = (config === null || config === void 0 ? void 0 : config.focusClass) || 'option-focused';
|
|
15367
|
-
this._hoverClass = (config === null || config === void 0 ? void 0 : config.hoverClass) || 'hovered';
|
|
15368
|
-
this._bgClass = (config === null || config === void 0 ? void 0 : config.bgClass) || 'bg-blue-50';
|
|
15369
|
-
this._fontClass = (config === null || config === void 0 ? void 0 : config.fontClass) || 'font-medium';
|
|
15370
15679
|
// Add click handler to update focus state when options are clicked
|
|
15371
15680
|
this._setupOptionClickHandlers();
|
|
15681
|
+
this._focusClass = 'focus'; // or whatever your intended class is
|
|
15682
|
+
this._hoverClass = 'hover'; // or your intended class
|
|
15372
15683
|
}
|
|
15373
15684
|
/**
|
|
15374
15685
|
* Set up click handlers for all options to update focus state
|
|
@@ -15380,15 +15691,6 @@ var FocusManager = /** @class */ (function () {
|
|
|
15380
15691
|
var target = e.target;
|
|
15381
15692
|
var optionElement = target.closest(_this._optionsSelector);
|
|
15382
15693
|
if (optionElement) {
|
|
15383
|
-
// First clear all focus
|
|
15384
|
-
_this.resetFocus();
|
|
15385
|
-
// Then update the focused index based on the clicked option
|
|
15386
|
-
var options = _this.getVisibleOptions();
|
|
15387
|
-
var clickedIndex = options.indexOf(optionElement);
|
|
15388
|
-
if (clickedIndex >= 0) {
|
|
15389
|
-
_this._focusedOptionIndex = clickedIndex;
|
|
15390
|
-
_this.applyFocus(options[clickedIndex]);
|
|
15391
|
-
}
|
|
15392
15694
|
}
|
|
15393
15695
|
});
|
|
15394
15696
|
};
|
|
@@ -15410,24 +15712,88 @@ var FocusManager = /** @class */ (function () {
|
|
|
15410
15712
|
});
|
|
15411
15713
|
};
|
|
15412
15714
|
/**
|
|
15413
|
-
* Focus the
|
|
15715
|
+
* Focus the first visible option
|
|
15414
15716
|
*/
|
|
15415
|
-
FocusManager.prototype.
|
|
15717
|
+
FocusManager.prototype.focusFirst = function () {
|
|
15416
15718
|
var options = this.getVisibleOptions();
|
|
15417
15719
|
if (options.length === 0)
|
|
15418
15720
|
return null;
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15721
|
+
for (var i = 0; i < options.length; i++) {
|
|
15722
|
+
var option = options[i];
|
|
15723
|
+
if (!option.classList.contains('disabled') && option.getAttribute('aria-disabled') !== 'true') {
|
|
15724
|
+
this.resetFocus();
|
|
15725
|
+
this._focusedOptionIndex = i;
|
|
15726
|
+
this.applyFocus(option);
|
|
15727
|
+
this.scrollIntoView(option);
|
|
15728
|
+
return option;
|
|
15729
|
+
}
|
|
15422
15730
|
}
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15731
|
+
return null;
|
|
15732
|
+
};
|
|
15733
|
+
/**
|
|
15734
|
+
* Focus the last visible option
|
|
15735
|
+
*/
|
|
15736
|
+
FocusManager.prototype.focusLast = function () {
|
|
15737
|
+
var options = this.getVisibleOptions();
|
|
15738
|
+
if (options.length === 0)
|
|
15739
|
+
return null;
|
|
15740
|
+
for (var i = options.length - 1; i >= 0; i--) {
|
|
15741
|
+
var option = options[i];
|
|
15742
|
+
if (!option.classList.contains('disabled') && option.getAttribute('aria-disabled') !== 'true') {
|
|
15743
|
+
this.resetFocus();
|
|
15744
|
+
this._focusedOptionIndex = i;
|
|
15745
|
+
this.applyFocus(option);
|
|
15746
|
+
this.scrollIntoView(option);
|
|
15747
|
+
return option;
|
|
15748
|
+
}
|
|
15426
15749
|
}
|
|
15427
|
-
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
|
|
15750
|
+
return null;
|
|
15751
|
+
};
|
|
15752
|
+
/**
|
|
15753
|
+
* Focus the next visible option that matches the search string
|
|
15754
|
+
*/
|
|
15755
|
+
FocusManager.prototype.focusByString = function (str) {
|
|
15756
|
+
var _a, _b, _c;
|
|
15757
|
+
var options = this.getVisibleOptions();
|
|
15758
|
+
if (options.length === 0)
|
|
15759
|
+
return null;
|
|
15760
|
+
var lowerStr = str.toLowerCase();
|
|
15761
|
+
var startIdx = ((_a = this._focusedOptionIndex) !== null && _a !== void 0 ? _a : -1) + 1;
|
|
15762
|
+
for (var i = 0; i < options.length; i++) {
|
|
15763
|
+
var idx = (startIdx + i) % options.length;
|
|
15764
|
+
var option = options[idx];
|
|
15765
|
+
if (!option.classList.contains('disabled') &&
|
|
15766
|
+
option.getAttribute('aria-disabled') !== 'true' &&
|
|
15767
|
+
(((_b = option.textContent) === null || _b === void 0 ? void 0 : _b.toLowerCase().startsWith(lowerStr)) || ((_c = option.dataset.value) === null || _c === void 0 ? void 0 : _c.toLowerCase().startsWith(lowerStr)))) {
|
|
15768
|
+
this._focusedOptionIndex = idx;
|
|
15769
|
+
this.applyFocus(option);
|
|
15770
|
+
this.scrollIntoView(option);
|
|
15771
|
+
return option;
|
|
15772
|
+
}
|
|
15773
|
+
}
|
|
15774
|
+
return null;
|
|
15775
|
+
};
|
|
15776
|
+
/**
|
|
15777
|
+
* Focus the next visible option
|
|
15778
|
+
*/
|
|
15779
|
+
FocusManager.prototype.focusNext = function () {
|
|
15780
|
+
var options = this.getVisibleOptions();
|
|
15781
|
+
if (options.length === 0)
|
|
15782
|
+
return null;
|
|
15783
|
+
var idx = this._focusedOptionIndex === null ? 0 : (this._focusedOptionIndex + 1) % options.length;
|
|
15784
|
+
var startIdx = idx;
|
|
15785
|
+
do {
|
|
15786
|
+
var option = options[idx];
|
|
15787
|
+
if (!option.classList.contains('disabled') && option.getAttribute('aria-disabled') !== 'true') {
|
|
15788
|
+
this.resetFocus();
|
|
15789
|
+
this._focusedOptionIndex = idx;
|
|
15790
|
+
this.applyFocus(option);
|
|
15791
|
+
this.scrollIntoView(option);
|
|
15792
|
+
return option;
|
|
15793
|
+
}
|
|
15794
|
+
idx = (idx + 1) % options.length;
|
|
15795
|
+
} while (idx !== startIdx);
|
|
15796
|
+
return null;
|
|
15431
15797
|
};
|
|
15432
15798
|
/**
|
|
15433
15799
|
* Focus the previous visible option
|
|
@@ -15436,18 +15802,20 @@ var FocusManager = /** @class */ (function () {
|
|
|
15436
15802
|
var options = this.getVisibleOptions();
|
|
15437
15803
|
if (options.length === 0)
|
|
15438
15804
|
return null;
|
|
15439
|
-
this.
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15805
|
+
var idx = this._focusedOptionIndex === null ? options.length - 1 : (this._focusedOptionIndex - 1 + options.length) % options.length;
|
|
15806
|
+
var startIdx = idx;
|
|
15807
|
+
do {
|
|
15808
|
+
var option = options[idx];
|
|
15809
|
+
if (!option.classList.contains('disabled') && option.getAttribute('aria-disabled') !== 'true') {
|
|
15810
|
+
this.resetFocus();
|
|
15811
|
+
this._focusedOptionIndex = idx;
|
|
15812
|
+
this.applyFocus(option);
|
|
15813
|
+
this.scrollIntoView(option);
|
|
15814
|
+
return option;
|
|
15815
|
+
}
|
|
15816
|
+
idx = (idx - 1 + options.length) % options.length;
|
|
15817
|
+
} while (idx !== startIdx);
|
|
15818
|
+
return null;
|
|
15451
15819
|
};
|
|
15452
15820
|
/**
|
|
15453
15821
|
* Apply focus to a specific option
|
|
@@ -15455,27 +15823,23 @@ var FocusManager = /** @class */ (function () {
|
|
|
15455
15823
|
FocusManager.prototype.applyFocus = function (option) {
|
|
15456
15824
|
if (!option)
|
|
15457
15825
|
return;
|
|
15458
|
-
|
|
15826
|
+
if (option.classList.contains('disabled') || option.getAttribute('aria-disabled') === 'true') {
|
|
15827
|
+
return;
|
|
15828
|
+
}
|
|
15459
15829
|
this.resetFocus();
|
|
15460
|
-
// Add focus to this option
|
|
15461
15830
|
option.classList.add(this._focusClass);
|
|
15462
15831
|
option.classList.add(this._hoverClass);
|
|
15463
|
-
|
|
15464
|
-
option.classList.add(this._fontClass);
|
|
15832
|
+
this._triggerFocusChange();
|
|
15465
15833
|
};
|
|
15466
15834
|
/**
|
|
15467
15835
|
* Reset focus on all options
|
|
15468
15836
|
*/
|
|
15469
15837
|
FocusManager.prototype.resetFocus = function () {
|
|
15470
15838
|
var _this = this;
|
|
15471
|
-
|
|
15472
|
-
|
|
15473
|
-
// Remove classes from all elements
|
|
15839
|
+
var focusedElements = this._element.querySelectorAll(".".concat(this._focusClass, ", .").concat(this._hoverClass));
|
|
15840
|
+
// Remove focus and hover classes from all options
|
|
15474
15841
|
focusedElements.forEach(function (element) {
|
|
15475
|
-
element.classList.remove(_this._focusClass);
|
|
15476
|
-
element.classList.remove(_this._hoverClass);
|
|
15477
|
-
element.classList.remove(_this._bgClass);
|
|
15478
|
-
element.classList.remove(_this._fontClass);
|
|
15842
|
+
element.classList.remove(_this._focusClass, _this._hoverClass);
|
|
15479
15843
|
});
|
|
15480
15844
|
// Reset index if visible options have changed
|
|
15481
15845
|
var visibleOptions = this.getVisibleOptions();
|
|
@@ -15490,7 +15854,7 @@ var FocusManager = /** @class */ (function () {
|
|
|
15490
15854
|
FocusManager.prototype.scrollIntoView = function (option) {
|
|
15491
15855
|
if (!option)
|
|
15492
15856
|
return;
|
|
15493
|
-
var container = this._element.querySelector('[data-kt-select-options
|
|
15857
|
+
var container = this._element.querySelector('[data-kt-select-options]');
|
|
15494
15858
|
if (!container)
|
|
15495
15859
|
return;
|
|
15496
15860
|
var optionRect = option.getBoundingClientRect();
|
|
@@ -15541,6 +15905,17 @@ var FocusManager = /** @class */ (function () {
|
|
|
15541
15905
|
FocusManager.prototype.setFocusedIndex = function (index) {
|
|
15542
15906
|
this._focusedOptionIndex = index;
|
|
15543
15907
|
};
|
|
15908
|
+
/**
|
|
15909
|
+
* Set a callback to be called when focus changes
|
|
15910
|
+
*/
|
|
15911
|
+
FocusManager.prototype.setOnFocusChange = function (cb) {
|
|
15912
|
+
this._onFocusChange = cb;
|
|
15913
|
+
};
|
|
15914
|
+
FocusManager.prototype._triggerFocusChange = function () {
|
|
15915
|
+
if (this._onFocusChange) {
|
|
15916
|
+
this._onFocusChange(this.getFocusedOption(), this._focusedOptionIndex);
|
|
15917
|
+
}
|
|
15918
|
+
};
|
|
15544
15919
|
/**
|
|
15545
15920
|
* Clean up event listeners
|
|
15546
15921
|
*/
|
|
@@ -15552,166 +15927,6 @@ var FocusManager = /** @class */ (function () {
|
|
|
15552
15927
|
return FocusManager;
|
|
15553
15928
|
}());
|
|
15554
15929
|
exports.FocusManager = FocusManager;
|
|
15555
|
-
/**
|
|
15556
|
-
* Shared keyboard navigation handler for dropdown options
|
|
15557
|
-
* Can be used by both combobox and search modules
|
|
15558
|
-
*/
|
|
15559
|
-
function handleDropdownKeyNavigation(event, select, config, callbacks) {
|
|
15560
|
-
try {
|
|
15561
|
-
// Get the dropdown state
|
|
15562
|
-
var isDropdownOpen = select._dropdownIsOpen;
|
|
15563
|
-
// Log the event to help debug
|
|
15564
|
-
var origin_1 = 'handleDropdownKeyNavigation';
|
|
15565
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15566
|
-
console.log("[".concat(origin_1, "] Key: ").concat(event.key, ", Dropdown open: ").concat(isDropdownOpen));
|
|
15567
|
-
// Handle basic keyboard navigation
|
|
15568
|
-
switch (event.key) {
|
|
15569
|
-
case 'ArrowDown':
|
|
15570
|
-
if (!isDropdownOpen) {
|
|
15571
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15572
|
-
console.log("[".concat(origin_1, "] Opening dropdown on ArrowDown"));
|
|
15573
|
-
select.openDropdown();
|
|
15574
|
-
// Focus the first option after opening
|
|
15575
|
-
setTimeout(function () {
|
|
15576
|
-
select._focusNextOption();
|
|
15577
|
-
}, 50);
|
|
15578
|
-
}
|
|
15579
|
-
else if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onArrowDown) {
|
|
15580
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15581
|
-
console.log("[".concat(origin_1, "] Using custom onArrowDown callback"));
|
|
15582
|
-
callbacks.onArrowDown();
|
|
15583
|
-
}
|
|
15584
|
-
else {
|
|
15585
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15586
|
-
console.log("[".concat(origin_1, "] Using default _focusNextOption"));
|
|
15587
|
-
var focusedOption = select._focusNextOption();
|
|
15588
|
-
// Ensure we have a focused option
|
|
15589
|
-
if (focusedOption) {
|
|
15590
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15591
|
-
console.log("[".concat(origin_1, "] Focused next option:"), focusedOption);
|
|
15592
|
-
}
|
|
15593
|
-
}
|
|
15594
|
-
event.preventDefault();
|
|
15595
|
-
break;
|
|
15596
|
-
case 'ArrowUp':
|
|
15597
|
-
if (!isDropdownOpen) {
|
|
15598
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15599
|
-
console.log("[".concat(origin_1, "] Opening dropdown on ArrowUp"));
|
|
15600
|
-
select.openDropdown();
|
|
15601
|
-
// Focus the last option after opening
|
|
15602
|
-
setTimeout(function () {
|
|
15603
|
-
select._focusPreviousOption();
|
|
15604
|
-
}, 50);
|
|
15605
|
-
}
|
|
15606
|
-
else if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onArrowUp) {
|
|
15607
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15608
|
-
console.log("[".concat(origin_1, "] Using custom onArrowUp callback"));
|
|
15609
|
-
callbacks.onArrowUp();
|
|
15610
|
-
}
|
|
15611
|
-
else {
|
|
15612
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15613
|
-
console.log("[".concat(origin_1, "] Using default _focusPreviousOption"));
|
|
15614
|
-
var focusedOption = select._focusPreviousOption();
|
|
15615
|
-
// Ensure we have a focused option
|
|
15616
|
-
if (focusedOption) {
|
|
15617
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15618
|
-
console.log("[".concat(origin_1, "] Focused previous option:"), focusedOption);
|
|
15619
|
-
}
|
|
15620
|
-
}
|
|
15621
|
-
event.preventDefault();
|
|
15622
|
-
break;
|
|
15623
|
-
case 'Enter':
|
|
15624
|
-
// Prevent form submission
|
|
15625
|
-
event.preventDefault();
|
|
15626
|
-
if (isDropdownOpen) {
|
|
15627
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15628
|
-
console.log("[".concat(origin_1, "] Enter pressed with dropdown open"));
|
|
15629
|
-
// For combobox mode, ensure we update the input value directly
|
|
15630
|
-
var isCombobox = select.getConfig().mode === 'combobox';
|
|
15631
|
-
var comboboxModule = select._comboboxModule;
|
|
15632
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onEnter) {
|
|
15633
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15634
|
-
console.log("[".concat(origin_1, "] Using custom onEnter callback"));
|
|
15635
|
-
callbacks.onEnter();
|
|
15636
|
-
}
|
|
15637
|
-
else {
|
|
15638
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15639
|
-
console.log("[".concat(origin_1, "] Using default selectFocusedOption"));
|
|
15640
|
-
// Make sure there is a focused option before trying to select it
|
|
15641
|
-
if (select._focusManager &&
|
|
15642
|
-
select._focusManager.getFocusedOption()) {
|
|
15643
|
-
select.selectFocusedOption();
|
|
15644
|
-
}
|
|
15645
|
-
else {
|
|
15646
|
-
// If no option is focused, try to focus the first one
|
|
15647
|
-
var focusedOption = select._focusNextOption();
|
|
15648
|
-
// Only select if an option was successfully focused
|
|
15649
|
-
if (focusedOption) {
|
|
15650
|
-
select.selectFocusedOption();
|
|
15651
|
-
}
|
|
15652
|
-
}
|
|
15653
|
-
}
|
|
15654
|
-
// Close dropdown after selection if not multiple and closeOnSelect is true
|
|
15655
|
-
if (!config.multiple && config.closeOnSelect !== false) {
|
|
15656
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15657
|
-
console.log("[".concat(origin_1, "] Closing dropdown after selection"));
|
|
15658
|
-
select.closeDropdown();
|
|
15659
|
-
}
|
|
15660
|
-
}
|
|
15661
|
-
else {
|
|
15662
|
-
// If dropdown is closed, open it on Enter
|
|
15663
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15664
|
-
console.log("[".concat(origin_1, "] Opening dropdown on Enter"));
|
|
15665
|
-
select.openDropdown();
|
|
15666
|
-
// Focus the first option after opening
|
|
15667
|
-
setTimeout(function () {
|
|
15668
|
-
select._focusNextOption();
|
|
15669
|
-
}, 50);
|
|
15670
|
-
}
|
|
15671
|
-
break;
|
|
15672
|
-
case 'Tab':
|
|
15673
|
-
// Only handle tab if dropdown is open
|
|
15674
|
-
if (isDropdownOpen) {
|
|
15675
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15676
|
-
console.log("[".concat(origin_1, "] Closing dropdown on Tab"));
|
|
15677
|
-
select.closeDropdown();
|
|
15678
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onClose) {
|
|
15679
|
-
callbacks.onClose();
|
|
15680
|
-
}
|
|
15681
|
-
// Don't prevent default tab behavior - let it move focus naturally
|
|
15682
|
-
}
|
|
15683
|
-
break;
|
|
15684
|
-
case 'Escape':
|
|
15685
|
-
// Only handle escape if dropdown is open
|
|
15686
|
-
if (isDropdownOpen) {
|
|
15687
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15688
|
-
console.log("[".concat(origin_1, "] Closing dropdown on Escape"));
|
|
15689
|
-
select.closeDropdown();
|
|
15690
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onClose) {
|
|
15691
|
-
callbacks.onClose();
|
|
15692
|
-
}
|
|
15693
|
-
event.preventDefault(); // Prevent other escape handlers
|
|
15694
|
-
}
|
|
15695
|
-
break;
|
|
15696
|
-
case ' ': // Space key
|
|
15697
|
-
// If dropdown is closed, space should open it (but not if in combobox mode)
|
|
15698
|
-
if (!isDropdownOpen && !(select.getConfig().mode === 'combobox')) {
|
|
15699
|
-
if (select.getConfig && select.getConfig().debug)
|
|
15700
|
-
console.log("[".concat(origin_1, "] Opening dropdown on Space"));
|
|
15701
|
-
select.openDropdown();
|
|
15702
|
-
// Focus the first option after opening
|
|
15703
|
-
setTimeout(function () {
|
|
15704
|
-
select._focusNextOption();
|
|
15705
|
-
}, 50);
|
|
15706
|
-
event.preventDefault();
|
|
15707
|
-
}
|
|
15708
|
-
break;
|
|
15709
|
-
}
|
|
15710
|
-
}
|
|
15711
|
-
catch (error) {
|
|
15712
|
-
console.error('Error in keyboard navigation handler:', error);
|
|
15713
|
-
}
|
|
15714
|
-
}
|
|
15715
15930
|
/**
|
|
15716
15931
|
* Centralized event listener management
|
|
15717
15932
|
*/
|
|
@@ -15768,7 +15983,7 @@ var EventManager = /** @class */ (function () {
|
|
|
15768
15983
|
// Go through each event type
|
|
15769
15984
|
this._boundHandlers.forEach(function (eventMap, event) {
|
|
15770
15985
|
// For each event type, go through each handler
|
|
15771
|
-
eventMap.forEach(function (boundHandler
|
|
15986
|
+
eventMap.forEach(function (boundHandler) {
|
|
15772
15987
|
element.removeEventListener(event, boundHandler);
|
|
15773
15988
|
});
|
|
15774
15989
|
});
|
|
@@ -15792,6 +16007,45 @@ function debounce(func, delay) {
|
|
|
15792
16007
|
timeout = setTimeout(function () { return func.apply(void 0, args); }, delay);
|
|
15793
16008
|
};
|
|
15794
16009
|
}
|
|
16010
|
+
/**
|
|
16011
|
+
* Replaces all {{key}} in the template with the corresponding value from the data object.
|
|
16012
|
+
* If a key is missing in data, replaces with an empty string.
|
|
16013
|
+
*/
|
|
16014
|
+
function renderTemplateString(template, data) {
|
|
16015
|
+
return template.replace(/{{(\w+)}}/g, function (_, key) {
|
|
16016
|
+
return data[key] !== undefined && data[key] !== null ? String(data[key]) : '';
|
|
16017
|
+
});
|
|
16018
|
+
}
|
|
16019
|
+
// Type-to-search buffer utility for keyboard navigation
|
|
16020
|
+
var TypeToSearchBuffer = /** @class */ (function () {
|
|
16021
|
+
function TypeToSearchBuffer(timeout) {
|
|
16022
|
+
if (timeout === void 0) { timeout = 500; }
|
|
16023
|
+
this.buffer = '';
|
|
16024
|
+
this.lastTime = 0;
|
|
16025
|
+
this.timeout = timeout;
|
|
16026
|
+
}
|
|
16027
|
+
TypeToSearchBuffer.prototype.push = function (char) {
|
|
16028
|
+
var now = Date.now();
|
|
16029
|
+
if (now - this.lastTime > this.timeout) {
|
|
16030
|
+
this.buffer = '';
|
|
16031
|
+
}
|
|
16032
|
+
this.buffer += char;
|
|
16033
|
+
this.lastTime = now;
|
|
16034
|
+
};
|
|
16035
|
+
TypeToSearchBuffer.prototype.getBuffer = function () {
|
|
16036
|
+
return this.buffer;
|
|
16037
|
+
};
|
|
16038
|
+
TypeToSearchBuffer.prototype.clear = function () {
|
|
16039
|
+
this.buffer = '';
|
|
16040
|
+
};
|
|
16041
|
+
return TypeToSearchBuffer;
|
|
16042
|
+
}());
|
|
16043
|
+
exports.TypeToSearchBuffer = TypeToSearchBuffer;
|
|
16044
|
+
function stringToElement(html) {
|
|
16045
|
+
var template = document.createElement('template');
|
|
16046
|
+
template.innerHTML = html.trim();
|
|
16047
|
+
return template.content.firstElementChild;
|
|
16048
|
+
}
|
|
15795
16049
|
|
|
15796
16050
|
|
|
15797
16051
|
/***/ }),
|
|
@@ -15832,34 +16086,30 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15832
16086
|
return __assign.apply(this, arguments);
|
|
15833
16087
|
};
|
|
15834
16088
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15835
|
-
exports.defaultTemplates = void 0;
|
|
16089
|
+
exports.defaultTemplates = exports.coreTemplateStrings = void 0;
|
|
15836
16090
|
exports.setTemplateStrings = setTemplateStrings;
|
|
15837
16091
|
exports.getTemplateStrings = getTemplateStrings;
|
|
15838
|
-
var
|
|
16092
|
+
var utils_1 = __webpack_require__(9011);
|
|
15839
16093
|
/**
|
|
15840
16094
|
* Default HTML string templates for KTSelect. All UI structure is defined here.
|
|
15841
16095
|
* Users can override any template by providing a matching key in the config.templates object.
|
|
15842
16096
|
*/
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15856
|
-
|
|
15857
|
-
|
|
15858
|
-
|
|
15859
|
-
search: "<div class=\"px-3 py-2 border-b border-gray-200\"><input type=\"text\" data-kt-select-search placeholder=\"{{searchPlaceholder}}\" class=\"w-full border-none focus:outline-none text-sm\" role=\"searchbox\" aria-label=\"{{searchPlaceholder}}\"/></div>",
|
|
15860
|
-
noResults: "<li class=\"px-3 py-2 text-gray-500\" role=\"status\">{{searchNotFoundText}}</li>",
|
|
15861
|
-
loading: "<li class=\"px-3 py-2 text-gray-500 italic\" role=\"status\" aria-live=\"polite\">{{loadingMessage}}</li>",
|
|
15862
|
-
tag: "<div data-kt-select-tag class=\"inline-flex items-center bg-blue-50 border border-blue-100 rounded px-2 py-1 text-sm mr-1 mb-1\"><span>{{title}}</span><span data-kt-select-remove-button data-value=\"{{id}}\" class=\"ml-1 text-blue-400 hover:text-blue-600 cursor-pointer\" role=\"button\" aria-label=\"Remove {{safeTitle}}\" tabindex=\"0\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg></span></div>",
|
|
16097
|
+
exports.coreTemplateStrings = {
|
|
16098
|
+
dropdown: "<div data-kt-select-dropdown class=\"kt-select-dropdown hidden {{class}}\" style=\"z-index: {{zindex}};\">{{content}}</div>",
|
|
16099
|
+
options: "<ul role=\"listbox\" aria-label=\"{{label}}\" class=\"kt-select-options {{class}}\" data-kt-select-options=\"true\">{{content}}</ul>",
|
|
16100
|
+
error: "<li class=\"kt-select-error\" role=\"alert\">{{content}}</li>",
|
|
16101
|
+
highlight: "<span data-kt-select-highlight class=\"kt-select-highlight highlighted {{class}}\">{{text}}</span>",
|
|
16102
|
+
wrapper: "<div data-kt-select-wrapper class=\"kt-select-wrapper {{class}}\"></div>",
|
|
16103
|
+
combobox: "\n\t\t<div data-kt-select-combobox data-kt-select-display class=\"kt-select-combobox {{class}}\">\n\t\t\t<input class=\"kt-input kt-select-combobox-input\" data-kt-select-search=\"true\" data-kt-select-value=\"true\" type=\"text\" placeholder=\"{{placeholder}}\" role=\"searchbox\" aria-label=\"{{label}}\" {{disabled}} />\n\t\t\t<button type=\"button\" data-kt-select-clear-button=\"true\" class=\"kt-select-combobox-clear-btn\" aria-label=\"Clear selection\">\n\t\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n\t\t\t\t\t<line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n\t\t\t\t</svg>\n\t\t\t</button>\n\t\t</div>\n\t",
|
|
16104
|
+
display: "\n\t\t<div data-kt-select-display class=\"kt-select-display {{class}}\" tabindex=\"{{tabindex}}\" role=\"button\" data-selected=\"0\" aria-haspopup=\"listbox\" aria-expanded=\"false\" aria-label=\"{{label}}\" {{disabled}}>\n\t\t\t<div data-kt-select-value=\"true\" class=\"kt-select-label\">{{content}}</div>\n\t\t</div>\n\t",
|
|
16105
|
+
placeholder: "<div data-kt-select-placeholder class=\"kt-select-placeholder {{class}}\">{{content}}</div>",
|
|
16106
|
+
option: "<li data-kt-select-option data-value=\"{{value}}\" data-text=\"{{text}}\" class=\"kt-select-option {{class}}\" role=\"option\" {{selected}} {{disabled}}>{{content}}</li>",
|
|
16107
|
+
search: "<div data-kt-select-search class=\"kt-select-search {{class}}\"><input type=\"text\" data-kt-select-search=\"true\" placeholder=\"{{searchPlaceholder}}\" class=\"kt-input kt-select-search-input\" role=\"searchbox\" aria-label=\"{{searchPlaceholder}}\"/></div>",
|
|
16108
|
+
empty: "<li data-kt-select-empty class=\"kt-select-no-result {{class}}\" role=\"status\">{{content}}</li>",
|
|
16109
|
+
loading: "<li class=\"kt-select-loading {{class}}\" role=\"status\" aria-live=\"polite\">{{content}}</li>",
|
|
16110
|
+
tag: "<div data-kt-select-tag=\"true\" class=\"kt-select-tag {{class}}\">\n\t\t\t{{content}}\n\t\t</div>",
|
|
16111
|
+
loadMore: "<li class=\"kt-select-load-more {{class}}\" data-kt-select-load-more=\"true\">{{content}}</li>",
|
|
16112
|
+
tagRemoveButton: "<button type=\"button\" data-kt-select-remove-button class=\"kt-select-tag-remove\" aria-label=\"Remove tag\" tabindex=\"0\"><svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"3\" x2=\"9\" y2=\"9\"/><line x1=\"9\" y1=\"3\" x2=\"3\" y2=\"9\"/></svg></button>",
|
|
15863
16113
|
};
|
|
15864
16114
|
/**
|
|
15865
16115
|
* Default templates for KTSelect component
|
|
@@ -15889,9 +16139,9 @@ function getTemplateStrings(config) {
|
|
|
15889
16139
|
? config.templates
|
|
15890
16140
|
: undefined;
|
|
15891
16141
|
if (templates) {
|
|
15892
|
-
return __assign(__assign(__assign({},
|
|
16142
|
+
return __assign(__assign(__assign({}, exports.coreTemplateStrings), userTemplateStrings), templates);
|
|
15893
16143
|
}
|
|
15894
|
-
return __assign(__assign({},
|
|
16144
|
+
return __assign(__assign({}, exports.coreTemplateStrings), userTemplateStrings);
|
|
15895
16145
|
}
|
|
15896
16146
|
/**
|
|
15897
16147
|
* Default templates for KTSelect component
|
|
@@ -15902,44 +16152,38 @@ exports.defaultTemplates = {
|
|
|
15902
16152
|
*/
|
|
15903
16153
|
highlight: function (config, text) {
|
|
15904
16154
|
var template = getTemplateStrings(config).highlight;
|
|
15905
|
-
var html = template.replace('{{text}}', text);
|
|
16155
|
+
var html = template.replace('{{text}}', text).replace('{{class}}', config.highlightClass || '');
|
|
15906
16156
|
return stringToElement(html);
|
|
15907
16157
|
},
|
|
15908
16158
|
/**
|
|
15909
16159
|
* Renders the dropdown content
|
|
15910
16160
|
*/
|
|
15911
|
-
|
|
15912
|
-
var template = getTemplateStrings(config).
|
|
16161
|
+
dropdown: function (config) {
|
|
16162
|
+
var template = getTemplateStrings(config).dropdown;
|
|
16163
|
+
var content = config.content || '';
|
|
16164
|
+
if (config.dropdownTemplate) {
|
|
16165
|
+
content = (0, utils_1.renderTemplateString)(config.dropdownTemplate, {
|
|
16166
|
+
zindex: config.zindex ? String(config.zindex) : '',
|
|
16167
|
+
content: config.content || '',
|
|
16168
|
+
class: config.dropdownClass || '',
|
|
16169
|
+
});
|
|
16170
|
+
}
|
|
15913
16171
|
var html = template
|
|
15914
16172
|
.replace('{{zindex}}', config.zindex ? String(config.zindex) : '')
|
|
15915
|
-
.replace('{{content}}',
|
|
16173
|
+
.replace('{{content}}', content)
|
|
16174
|
+
.replace('{{class}}', config.dropdownClass || '');
|
|
15916
16175
|
return stringToElement(html);
|
|
15917
16176
|
},
|
|
15918
16177
|
/**
|
|
15919
16178
|
* Renders the options container for the dropdown
|
|
15920
16179
|
*/
|
|
15921
|
-
|
|
15922
|
-
var template = getTemplateStrings(config).
|
|
16180
|
+
options: function (config) {
|
|
16181
|
+
var template = getTemplateStrings(config).options;
|
|
15923
16182
|
var html = template
|
|
15924
16183
|
.replace('{{label}}', config.label || 'Options')
|
|
15925
16184
|
.replace('{{height}}', config.height ? String(config.height) : '250')
|
|
15926
|
-
.replace('{{options}}', config.options || '')
|
|
15927
|
-
|
|
15928
|
-
},
|
|
15929
|
-
/**
|
|
15930
|
-
* Renders an empty option in the dropdown
|
|
15931
|
-
*/
|
|
15932
|
-
emptyOption: function (config) {
|
|
15933
|
-
var template = getTemplateStrings(config).emptyOption;
|
|
15934
|
-
var html = template.replace('{{placeholder}}', config.placeholder || 'Select...');
|
|
15935
|
-
return stringToElement(html);
|
|
15936
|
-
},
|
|
15937
|
-
/**
|
|
15938
|
-
* Renders an error option in the dropdown
|
|
15939
|
-
*/
|
|
15940
|
-
errorOption: function (config) {
|
|
15941
|
-
var template = getTemplateStrings(config).errorOption;
|
|
15942
|
-
var html = template.replace('{{errorMessage}}', config.errorMessage || 'An error occurred');
|
|
16185
|
+
.replace('{{options}}', config.options || '')
|
|
16186
|
+
.replace('{{class}}', config.optionsClass || '');
|
|
15943
16187
|
return stringToElement(html);
|
|
15944
16188
|
},
|
|
15945
16189
|
/**
|
|
@@ -15954,51 +16198,41 @@ exports.defaultTemplates = {
|
|
|
15954
16198
|
*/
|
|
15955
16199
|
error: function (config) {
|
|
15956
16200
|
var template = getTemplateStrings(config).error;
|
|
15957
|
-
return template
|
|
16201
|
+
return template
|
|
16202
|
+
.replace('{{errorMessage}}', config.errorMessage || 'An error occurred')
|
|
16203
|
+
.replace('{{class}}', config.errorClass || '');
|
|
15958
16204
|
},
|
|
15959
16205
|
/**
|
|
15960
16206
|
* Renders the main container for the select component
|
|
15961
16207
|
*/
|
|
15962
|
-
|
|
15963
|
-
var html = getTemplateStrings(config).
|
|
15964
|
-
|
|
16208
|
+
wrapper: function (config) {
|
|
16209
|
+
var html = getTemplateStrings(config).wrapper
|
|
16210
|
+
.replace('{{class}}', config.wrapperClass || '');
|
|
16211
|
+
var element = stringToElement(html);
|
|
16212
|
+
element.setAttribute('data-kt-select-combobox', config.combobox ? 'true' : 'false');
|
|
16213
|
+
element.setAttribute('data-kt-select-tags', config.tags ? 'true' : 'false');
|
|
16214
|
+
return element;
|
|
15965
16215
|
},
|
|
15966
16216
|
/**
|
|
15967
16217
|
* Renders the display element (trigger) for the select
|
|
15968
16218
|
*/
|
|
15969
16219
|
display: function (config) {
|
|
15970
|
-
|
|
15971
|
-
if (isCombobox) {
|
|
16220
|
+
if (config.combobox) {
|
|
15972
16221
|
var html_1 = getTemplateStrings(config)
|
|
15973
|
-
.
|
|
16222
|
+
.combobox.replace(/{{placeholder}}/g, config.placeholder || 'Select...')
|
|
15974
16223
|
.replace(/{{label}}/g, config.label || config.placeholder || 'Select...')
|
|
15975
|
-
.replace('{{disabled}}', config.disabled ? 'disabled' : '')
|
|
16224
|
+
.replace('{{disabled}}', config.disabled ? 'disabled' : '')
|
|
16225
|
+
.replace('{{class}}', config.displayClass || '');
|
|
15976
16226
|
return stringToElement(html_1);
|
|
15977
16227
|
}
|
|
15978
|
-
var
|
|
15979
|
-
|
|
16228
|
+
var content = config.label || config.placeholder || 'Select...';
|
|
16229
|
+
var html = getTemplateStrings(config).display
|
|
16230
|
+
.replace('{{tabindex}}', config.disabled ? '-1' : '0')
|
|
15980
16231
|
.replace('{{label}}', config.label || config.placeholder || 'Select...')
|
|
15981
16232
|
.replace('{{disabled}}', config.disabled ? 'aria-disabled="true"' : '')
|
|
15982
|
-
.replace('{{placeholder}}', config.placeholder || 'Select...')
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
/**
|
|
15986
|
-
* Renders the dropdown content container
|
|
15987
|
-
*/
|
|
15988
|
-
dropdown: function (config, optionsHtml) {
|
|
15989
|
-
var isCombobox = config.mode === types_1.SelectMode.COMBOBOX;
|
|
15990
|
-
var hasSearch = config.enableSearch && !isCombobox;
|
|
15991
|
-
var template = getTemplateStrings(config).dropdown;
|
|
15992
|
-
var searchHtml = '';
|
|
15993
|
-
if (hasSearch) {
|
|
15994
|
-
var searchElement = exports.defaultTemplates.search(config);
|
|
15995
|
-
searchHtml = searchElement.outerHTML;
|
|
15996
|
-
}
|
|
15997
|
-
var html = template
|
|
15998
|
-
.replace('{{search}}', searchHtml)
|
|
15999
|
-
.replace('{{options}}', optionsHtml)
|
|
16000
|
-
.replace('{{label}}', config.label || 'Options')
|
|
16001
|
-
.replace('{{height}}', config.height ? String(config.height) : '250');
|
|
16233
|
+
.replace('{{placeholder}}', config.placeholder || 'Select...')
|
|
16234
|
+
.replace('{{class}}', config.displayClass || '')
|
|
16235
|
+
.replace('{{content}}', content);
|
|
16002
16236
|
return stringToElement(html);
|
|
16003
16237
|
},
|
|
16004
16238
|
/**
|
|
@@ -16014,141 +16248,102 @@ exports.defaultTemplates = {
|
|
|
16014
16248
|
var selected = isHtmlOption
|
|
16015
16249
|
? option.selected
|
|
16016
16250
|
: !!option.selected;
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
catch (e) {
|
|
16029
|
-
// fallback to legacy attributes if JSON is invalid
|
|
16030
|
-
description =
|
|
16031
|
-
option.getAttribute('data-kt-select-option-description') ||
|
|
16032
|
-
undefined;
|
|
16033
|
-
icon = option.getAttribute('data-kt-select-option-icon') || undefined;
|
|
16034
|
-
}
|
|
16035
|
-
}
|
|
16036
|
-
else {
|
|
16037
|
-
description =
|
|
16038
|
-
option.getAttribute('data-kt-select-option-description') || undefined;
|
|
16039
|
-
icon = option.getAttribute('data-kt-select-option-icon') || undefined;
|
|
16040
|
-
}
|
|
16041
|
-
}
|
|
16042
|
-
else {
|
|
16043
|
-
description = option.description;
|
|
16044
|
-
icon = option.icon;
|
|
16251
|
+
var content = text;
|
|
16252
|
+
if (config.optionTemplate) {
|
|
16253
|
+
// Use the user template to render the content, but only for {{content}}
|
|
16254
|
+
content = (0, utils_1.renderTemplateString)(config.optionTemplate, {
|
|
16255
|
+
value: value,
|
|
16256
|
+
text: text,
|
|
16257
|
+
class: config.optionClass || '',
|
|
16258
|
+
selected: selected ? 'aria-selected="true"' : 'aria-selected="false"',
|
|
16259
|
+
disabled: disabled ? 'aria-disabled="true"' : '',
|
|
16260
|
+
content: text,
|
|
16261
|
+
});
|
|
16045
16262
|
}
|
|
16046
|
-
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
var html = getTemplateStrings(config)
|
|
16050
|
-
.option.replace('{{value}}', value)
|
|
16051
|
-
.replace('{{selectedClass}}', selectedClass)
|
|
16052
|
-
.replace('{{disabledClass}}', disabledClass)
|
|
16263
|
+
var html = getTemplateStrings(config).option
|
|
16264
|
+
.replace('{{value}}', value)
|
|
16265
|
+
.replace('{{text}}', text)
|
|
16053
16266
|
.replace('{{selected}}', selected ? 'aria-selected="true"' : 'aria-selected="false"')
|
|
16054
16267
|
.replace('{{disabled}}', disabled ? 'aria-disabled="true"' : '')
|
|
16055
|
-
.replace(
|
|
16056
|
-
.replace('{{
|
|
16057
|
-
.replace(/{{description}}/g, description
|
|
16058
|
-
? exports.defaultTemplates.description(description, config).outerHTML
|
|
16059
|
-
: '');
|
|
16060
|
-
return stringToElement(html);
|
|
16061
|
-
},
|
|
16062
|
-
/**
|
|
16063
|
-
* Renders an icon
|
|
16064
|
-
*/
|
|
16065
|
-
icon: function (icon, config) {
|
|
16066
|
-
var html = getTemplateStrings(config).icon.replace('{{icon}}', icon);
|
|
16067
|
-
return stringToElement(html);
|
|
16068
|
-
},
|
|
16069
|
-
/**
|
|
16070
|
-
* Renders a description
|
|
16071
|
-
*/
|
|
16072
|
-
description: function (description, config) {
|
|
16073
|
-
var html = getTemplateStrings(config).description.replace('{{description}}', description);
|
|
16074
|
-
return stringToElement(html);
|
|
16075
|
-
},
|
|
16076
|
-
/**
|
|
16077
|
-
* Renders an option group with header
|
|
16078
|
-
*/
|
|
16079
|
-
optionGroup: function (label, optionsHtml, config) {
|
|
16080
|
-
var html = getTemplateStrings(config)
|
|
16081
|
-
.optionGroup.replace(/{{label}}/g, label)
|
|
16082
|
-
.replace('{{optionsHtml}}', optionsHtml);
|
|
16268
|
+
.replace('{{content}}', content)
|
|
16269
|
+
.replace('{{class}}', config.optionClass || '');
|
|
16083
16270
|
return stringToElement(html);
|
|
16084
16271
|
},
|
|
16085
16272
|
/**
|
|
16086
16273
|
* Renders the search input
|
|
16087
16274
|
*/
|
|
16088
16275
|
search: function (config) {
|
|
16089
|
-
var html = getTemplateStrings(config)
|
|
16276
|
+
var html = getTemplateStrings(config)
|
|
16277
|
+
.search.replace('{{searchPlaceholder}}', config.searchPlaceholder || 'Search...')
|
|
16278
|
+
.replace('{{class}}', config.searchClass || '');
|
|
16090
16279
|
return stringToElement(html);
|
|
16091
16280
|
},
|
|
16092
16281
|
/**
|
|
16093
16282
|
* Renders the no results message
|
|
16094
16283
|
*/
|
|
16095
|
-
|
|
16096
|
-
var html = getTemplateStrings(config)
|
|
16284
|
+
empty: function (config) {
|
|
16285
|
+
var html = getTemplateStrings(config)
|
|
16286
|
+
.empty.replace('{{searchNotFoundText}}', config.searchNotFoundText || 'No results found')
|
|
16287
|
+
.replace('{{class}}', config.emptyClass || '');
|
|
16097
16288
|
return stringToElement(html);
|
|
16098
16289
|
},
|
|
16099
16290
|
/**
|
|
16100
16291
|
* Renders the loading state
|
|
16101
16292
|
*/
|
|
16102
16293
|
loading: function (config, loadingMessage) {
|
|
16103
|
-
var html = getTemplateStrings(config)
|
|
16294
|
+
var html = getTemplateStrings(config)
|
|
16295
|
+
.loading.replace('{{loadingMessage}}', loadingMessage || 'Loading options...')
|
|
16296
|
+
.replace('{{class}}', config.loadingClass || '');
|
|
16104
16297
|
return stringToElement(html);
|
|
16105
16298
|
},
|
|
16106
16299
|
/**
|
|
16107
16300
|
* Renders a tag for multi-select
|
|
16108
16301
|
*/
|
|
16109
16302
|
tag: function (option, config) {
|
|
16110
|
-
|
|
16111
|
-
var
|
|
16112
|
-
|
|
16113
|
-
|
|
16114
|
-
|
|
16115
|
-
|
|
16116
|
-
|
|
16117
|
-
|
|
16118
|
-
|
|
16119
|
-
|
|
16120
|
-
|
|
16303
|
+
var template = getTemplateStrings(config).tag;
|
|
16304
|
+
var content = option.title;
|
|
16305
|
+
if (config.tagTemplate) {
|
|
16306
|
+
var tagTemplate_1 = config.tagTemplate;
|
|
16307
|
+
var text = option.getAttribute('data-text');
|
|
16308
|
+
var value = option.getAttribute('data-value');
|
|
16309
|
+
// Replace all {{varname}} in option.innerHTML with values from _config
|
|
16310
|
+
Object.entries(config.optionsConfig[value] || {}).forEach(function (_a) {
|
|
16311
|
+
var key = _a[0], value = _a[1];
|
|
16312
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
16313
|
+
tagTemplate_1 = tagTemplate_1.replace(new RegExp("{{".concat(key, "}}"), 'g'), String(value));
|
|
16314
|
+
}
|
|
16121
16315
|
});
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
16125
|
-
|
|
16126
|
-
|
|
16316
|
+
content = (0, utils_1.renderTemplateString)(tagTemplate_1, {
|
|
16317
|
+
title: option.title,
|
|
16318
|
+
id: option.id,
|
|
16319
|
+
class: config.tagClass || '',
|
|
16320
|
+
content: option.innerHTML,
|
|
16321
|
+
text: option.innerText,
|
|
16322
|
+
});
|
|
16323
|
+
}
|
|
16324
|
+
content += getTemplateStrings(config).tagRemoveButton;
|
|
16325
|
+
var html = template
|
|
16326
|
+
.replace('{{title}}', option.title)
|
|
16127
16327
|
.replace('{{id}}', option.id)
|
|
16128
|
-
.replace('{{
|
|
16328
|
+
.replace('{{content}}', content)
|
|
16329
|
+
.replace('{{class}}', config.tagClass || '');
|
|
16129
16330
|
return stringToElement(html);
|
|
16130
16331
|
},
|
|
16131
16332
|
/**
|
|
16132
|
-
*
|
|
16333
|
+
* Renders the placeholder for the select
|
|
16133
16334
|
*/
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
|
|
16138
|
-
if (config.
|
|
16139
|
-
|
|
16140
|
-
|
|
16141
|
-
|
|
16142
|
-
}
|
|
16143
|
-
if (config.showSelectedCount) {
|
|
16144
|
-
var count = selectedOptions.length;
|
|
16145
|
-
return "".concat(count, " ").concat(count === 1 ? 'item' : 'items', " selected");
|
|
16146
|
-
}
|
|
16147
|
-
return selectedOptions.map(function (option) { return option.title; }).join(', ');
|
|
16148
|
-
}
|
|
16149
|
-
else {
|
|
16150
|
-
return selectedOptions[0].title;
|
|
16335
|
+
placeholder: function (config) {
|
|
16336
|
+
var html = getTemplateStrings(config)
|
|
16337
|
+
.placeholder.replace('{{class}}', config.placeholderClass || '');
|
|
16338
|
+
var content = config.placeholder || 'Select...';
|
|
16339
|
+
if (config.placeholderTemplate) {
|
|
16340
|
+
content = (0, utils_1.renderTemplateString)(config.placeholderTemplate, {
|
|
16341
|
+
placeholder: config.placeholder || 'Select...',
|
|
16342
|
+
class: config.placeholderClass || '',
|
|
16343
|
+
});
|
|
16151
16344
|
}
|
|
16345
|
+
html = html.replace('{{content}}', content);
|
|
16346
|
+
return stringToElement(html);
|
|
16152
16347
|
},
|
|
16153
16348
|
};
|
|
16154
16349
|
|
|
@@ -17267,7 +17462,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
17267
17462
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
17268
17463
|
};
|
|
17269
17464
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
17270
|
-
exports.
|
|
17465
|
+
exports.KTSelectState = exports.DefaultConfig = void 0;
|
|
17271
17466
|
exports.DefaultConfig = {
|
|
17272
17467
|
// ...other config options
|
|
17273
17468
|
loadMoreText: 'Load more...',
|
|
@@ -17287,10 +17482,6 @@ exports.DefaultConfig = {
|
|
|
17287
17482
|
// Field Mapping
|
|
17288
17483
|
dataValueField: null, // Property in the option object that contains the value (default: 'id')
|
|
17289
17484
|
dataFieldText: null, // Property in the option object that contains the text (default: 'title')
|
|
17290
|
-
dataFieldDescription: null, // Property in the option object that contains the description
|
|
17291
|
-
dataFieldIcon: null, // Property in the option object that contains the icon
|
|
17292
|
-
dataFieldIconWidth: null, // Property in the option object that contains the icon width
|
|
17293
|
-
dataFieldIconHeight: null, // Property in the option object that contains the icon height
|
|
17294
17485
|
// Search Configuration
|
|
17295
17486
|
searchParam: '', // Query parameter for API search requests
|
|
17296
17487
|
searchDebounce: 300, // Debounce delay for search (in ms)
|
|
@@ -17303,10 +17494,9 @@ exports.DefaultConfig = {
|
|
|
17303
17494
|
// Selection Behavior
|
|
17304
17495
|
multiple: false, // Enable/disable multi-select
|
|
17305
17496
|
maxSelections: null, // Maximum number of selections allowed in multi-select mode (null for unlimited)
|
|
17306
|
-
closeOnSelect:
|
|
17497
|
+
closeOnSelect: false, // Close the dropdown after selecting an option (single-select only)
|
|
17307
17498
|
disabled: false, // Disable the select component
|
|
17308
17499
|
isRequired: false, // Make selection required
|
|
17309
|
-
mode: null, // Select mode: tags or combobox
|
|
17310
17500
|
// Search Functionality
|
|
17311
17501
|
enableSearch: false, // Enable/disable search functionality within the dropdown
|
|
17312
17502
|
searchPlaceholder: 'Search...', // Placeholder text for the search input
|
|
@@ -17330,11 +17520,8 @@ exports.DefaultConfig = {
|
|
|
17330
17520
|
dropdownPreventOverflow: false,
|
|
17331
17521
|
dropdownStrategy: null,
|
|
17332
17522
|
dropdownWidth: null, // Custom width for dropdown (e.g., '300px'), null to match toggle element width
|
|
17333
|
-
//
|
|
17334
|
-
|
|
17335
|
-
hoverClass: 'hovered',
|
|
17336
|
-
bgClass: 'bg-blue-50',
|
|
17337
|
-
fontClass: 'font-medium',
|
|
17523
|
+
// New Config
|
|
17524
|
+
dropdownTemplate: '',
|
|
17338
17525
|
};
|
|
17339
17526
|
var KTSelectState = /** @class */ (function () {
|
|
17340
17527
|
function KTSelectState(config) {
|
|
@@ -17462,10 +17649,6 @@ var KTSelectState = /** @class */ (function () {
|
|
|
17462
17649
|
return KTSelectState;
|
|
17463
17650
|
}());
|
|
17464
17651
|
exports.KTSelectState = KTSelectState;
|
|
17465
|
-
exports.SelectOptionDefaultConfig = {
|
|
17466
|
-
description: '',
|
|
17467
|
-
icon: null,
|
|
17468
|
-
};
|
|
17469
17652
|
|
|
17470
17653
|
|
|
17471
17654
|
/***/ }),
|