@keenthemes/ktui 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ktui.js +183 -98
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/dist/styles.css +4 -2
- package/examples/select/modal.html +0 -3
- package/lib/cjs/components/datatable/datatable.js +13 -10
- package/lib/cjs/components/datatable/datatable.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js +14 -0
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/select/combobox.js.map +1 -1
- package/lib/cjs/components/select/config.js +14 -6
- package/lib/cjs/components/select/config.js.map +1 -1
- package/lib/cjs/components/select/dropdown.js +36 -6
- package/lib/cjs/components/select/dropdown.js.map +1 -1
- package/lib/cjs/components/select/select.js +106 -74
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/select/templates.js +0 -2
- package/lib/cjs/components/select/templates.js.map +1 -1
- package/lib/cjs/components/select/utils.js.map +1 -1
- package/lib/esm/components/datatable/datatable.js +13 -10
- package/lib/esm/components/datatable/datatable.js.map +1 -1
- package/lib/esm/components/dropdown/dropdown.js +14 -0
- package/lib/esm/components/dropdown/dropdown.js.map +1 -1
- package/lib/esm/components/select/combobox.js.map +1 -1
- package/lib/esm/components/select/config.js +14 -6
- package/lib/esm/components/select/config.js.map +1 -1
- package/lib/esm/components/select/dropdown.js +36 -6
- package/lib/esm/components/select/dropdown.js.map +1 -1
- package/lib/esm/components/select/select.js +106 -74
- package/lib/esm/components/select/select.js.map +1 -1
- package/lib/esm/components/select/templates.js +0 -2
- package/lib/esm/components/select/templates.js.map +1 -1
- package/lib/esm/components/select/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/components/datatable/datatable.ts +13 -10
- package/src/components/dropdown/dropdown.ts +14 -0
- package/src/components/dropdown/types.ts +1 -0
- package/src/components/select/combobox.ts +1 -1
- package/src/components/select/config.ts +18 -7
- package/src/components/select/dropdown.ts +45 -6
- package/src/components/select/select.css +3 -1
- package/src/components/select/select.ts +114 -77
- package/src/components/select/templates.ts +1 -5
- package/src/components/select/utils.ts +1 -1
- package/src/components/toast/toast.css +1 -1
package/dist/ktui.js
CHANGED
|
@@ -8436,16 +8436,19 @@ var KTDataTable = /** @class */ (function (_super) {
|
|
|
8436
8436
|
if (!_sizeElement) {
|
|
8437
8437
|
return _sizeElement;
|
|
8438
8438
|
}
|
|
8439
|
-
//
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8439
|
+
// Wait for the element to be attached to the DOM
|
|
8440
|
+
setTimeout(function () {
|
|
8441
|
+
// Create <option> elements for each page size option
|
|
8442
|
+
var options = _this._config.pageSizes.map(function (size) {
|
|
8443
|
+
var option = document.createElement('option');
|
|
8444
|
+
option.value = String(size);
|
|
8445
|
+
option.text = String(size);
|
|
8446
|
+
option.selected = _this.getState().pageSize === size;
|
|
8447
|
+
return option;
|
|
8448
|
+
});
|
|
8449
|
+
// Add the <option> elements to the provided element
|
|
8450
|
+
_sizeElement.append.apply(_sizeElement, options);
|
|
8451
|
+
}, 100);
|
|
8449
8452
|
// Create an event listener for the "change" event on the element
|
|
8450
8453
|
var _pageSizeControlsEvent = function (event) {
|
|
8451
8454
|
// When the element changes, reload the page with the new page size and page number 1
|
|
@@ -9308,6 +9311,12 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9308
9311
|
_this._dropdownElement = dropdownElement;
|
|
9309
9312
|
_this._config = config;
|
|
9310
9313
|
_this._ktSelectInstance = ktSelectInstance; // Assign instance
|
|
9314
|
+
var container = _this._resolveDropdownContainer();
|
|
9315
|
+
if (container) {
|
|
9316
|
+
if (container !== _this._dropdownElement.parentElement) {
|
|
9317
|
+
container.appendChild(_this._dropdownElement);
|
|
9318
|
+
}
|
|
9319
|
+
}
|
|
9311
9320
|
_this._eventManager = new utils_1.EventManager();
|
|
9312
9321
|
_this._focusManager = new utils_1.FocusManager(dropdownElement, '[data-kt-select-option]', config);
|
|
9313
9322
|
_this._setupEventListeners();
|
|
@@ -9475,16 +9484,26 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9475
9484
|
// Reflow
|
|
9476
9485
|
dom_1.default.reflow(this._dropdownElement);
|
|
9477
9486
|
// Apply z-index
|
|
9487
|
+
var zIndexToApply = null;
|
|
9478
9488
|
if (this._config.dropdownZindex) {
|
|
9479
|
-
this.
|
|
9480
|
-
this._config.dropdownZindex.toString();
|
|
9489
|
+
zIndexToApply = this._config.dropdownZindex;
|
|
9481
9490
|
}
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9491
|
+
// Consider the dropdown's current z-index if it's already set and higher
|
|
9492
|
+
var currentDropdownZIndexStr = dom_1.default.getCssProp(this._dropdownElement, 'z-index');
|
|
9493
|
+
if (currentDropdownZIndexStr && currentDropdownZIndexStr !== 'auto') {
|
|
9494
|
+
var currentDropdownZIndex = parseInt(currentDropdownZIndexStr);
|
|
9495
|
+
if (!isNaN(currentDropdownZIndex) && currentDropdownZIndex > (zIndexToApply || 0)) {
|
|
9496
|
+
zIndexToApply = currentDropdownZIndex;
|
|
9486
9497
|
}
|
|
9487
9498
|
}
|
|
9499
|
+
// Ensure dropdown is above elements within its original toggle's parent context
|
|
9500
|
+
var toggleParentContextZindex = dom_1.default.getHighestZindex(this._element); // _element is the select wrapper
|
|
9501
|
+
if (toggleParentContextZindex !== null && toggleParentContextZindex >= (zIndexToApply || 0)) {
|
|
9502
|
+
zIndexToApply = toggleParentContextZindex + 1;
|
|
9503
|
+
}
|
|
9504
|
+
if (zIndexToApply !== null) {
|
|
9505
|
+
this._dropdownElement.style.zIndex = zIndexToApply.toString();
|
|
9506
|
+
}
|
|
9488
9507
|
// Initialize popper
|
|
9489
9508
|
this._initPopper();
|
|
9490
9509
|
// Add active classes for visual state
|
|
@@ -9575,6 +9594,20 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9575
9594
|
// Remove data reference
|
|
9576
9595
|
data_1.default.remove(this._element, this._name);
|
|
9577
9596
|
};
|
|
9597
|
+
KTSelectDropdown.prototype._resolveDropdownContainer = function () {
|
|
9598
|
+
var containerSelector = this._config.dropdownContainer;
|
|
9599
|
+
if (containerSelector && containerSelector !== 'body') {
|
|
9600
|
+
var containerElement = document.querySelector(containerSelector);
|
|
9601
|
+
if (!containerElement && this._config.debug) {
|
|
9602
|
+
console.warn("KTSelectDropdown: dropdownContainer selector \"".concat(containerSelector, "\" not found. Dropdown will remain in its default position."));
|
|
9603
|
+
}
|
|
9604
|
+
return containerElement;
|
|
9605
|
+
}
|
|
9606
|
+
else if (containerSelector === 'body') {
|
|
9607
|
+
return document.body;
|
|
9608
|
+
}
|
|
9609
|
+
return null;
|
|
9610
|
+
};
|
|
9578
9611
|
return KTSelectDropdown;
|
|
9579
9612
|
}(component_1.default));
|
|
9580
9613
|
exports.KTSelectDropdown = KTSelectDropdown;
|
|
@@ -11330,7 +11363,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
11330
11363
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11331
11364
|
exports.KTSelect = void 0;
|
|
11332
11365
|
var data_1 = __webpack_require__(8716);
|
|
11333
|
-
var dom_1 = __webpack_require__(9010);
|
|
11334
11366
|
var component_1 = __webpack_require__(2658);
|
|
11335
11367
|
var config_1 = __webpack_require__(9386);
|
|
11336
11368
|
var option_1 = __webpack_require__(4241);
|
|
@@ -11358,6 +11390,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11358
11390
|
_this._dropdownModule = null;
|
|
11359
11391
|
_this._loadMoreIndicator = null;
|
|
11360
11392
|
_this._typeToSearchBuffer = new utils_1.TypeToSearchBuffer();
|
|
11393
|
+
_this._mutationObserver = null;
|
|
11361
11394
|
// Search debounce timeout
|
|
11362
11395
|
_this._searchDebounceTimeout = null;
|
|
11363
11396
|
// Store original options HTML for restoring after search
|
|
@@ -11612,9 +11645,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11612
11645
|
// Setup HTML structure
|
|
11613
11646
|
this._createHtmlStructure();
|
|
11614
11647
|
this._setupElementReferences();
|
|
11615
|
-
this._initZIndex();
|
|
11616
11648
|
// Initialize options
|
|
11617
|
-
// this._initializeOptionsHtml();
|
|
11618
11649
|
this._preSelectOptions(this._element);
|
|
11619
11650
|
// Apply disabled state if needed
|
|
11620
11651
|
this._applyInitialDisabledState();
|
|
@@ -11640,12 +11671,13 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11640
11671
|
this._setAriaAttributes();
|
|
11641
11672
|
// Attach event listeners after all modules are initialized
|
|
11642
11673
|
this._attachEventListeners();
|
|
11674
|
+
this._observeNativeSelect();
|
|
11643
11675
|
};
|
|
11644
11676
|
/**
|
|
11645
11677
|
* Creates the HTML structure for the select component
|
|
11646
11678
|
*/
|
|
11647
11679
|
KTSelect.prototype._createHtmlStructure = function () {
|
|
11648
|
-
var _a;
|
|
11680
|
+
var _a, _b;
|
|
11649
11681
|
var _this = this;
|
|
11650
11682
|
var options = Array.from(this._element.querySelectorAll('option'));
|
|
11651
11683
|
// Create wrapper and display elements
|
|
@@ -11653,10 +11685,20 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11653
11685
|
var displayElement = templates_1.defaultTemplates.display(this._config);
|
|
11654
11686
|
// Add the display element to the wrapper
|
|
11655
11687
|
wrapperElement.appendChild(displayElement);
|
|
11656
|
-
// Move classes from original select to display
|
|
11688
|
+
// Move classes from original select to wrapper and display elements
|
|
11657
11689
|
if (this._element.classList.length > 0) {
|
|
11658
|
-
|
|
11659
|
-
|
|
11690
|
+
var originalClasses = Array.from(this._element.classList);
|
|
11691
|
+
var displaySpecificClasses_1 = ['kt-select', 'kt-select-sm', 'kt-select-lg'];
|
|
11692
|
+
var classesForWrapper = originalClasses.filter(function (className) { return !displaySpecificClasses_1.includes(className); });
|
|
11693
|
+
if (classesForWrapper.length > 0) {
|
|
11694
|
+
(_a = wrapperElement.classList).add.apply(_a, classesForWrapper);
|
|
11695
|
+
}
|
|
11696
|
+
// Move display-specific classes to display element
|
|
11697
|
+
var classesForDisplay = originalClasses.filter(function (className) { return displaySpecificClasses_1.includes(className); });
|
|
11698
|
+
if (classesForDisplay.length > 0) {
|
|
11699
|
+
(_b = displayElement.classList).add.apply(_b, classesForDisplay);
|
|
11700
|
+
}
|
|
11701
|
+
this._element.className = ''; // Clear classes from original select element
|
|
11660
11702
|
}
|
|
11661
11703
|
// Create an empty dropdown first (without options) using template
|
|
11662
11704
|
var dropdownElement = templates_1.defaultTemplates.dropdown(__assign(__assign({}, this._config), { zindex: this._config.dropdownZindex }));
|
|
@@ -11667,8 +11709,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11667
11709
|
}
|
|
11668
11710
|
// Create options container using template
|
|
11669
11711
|
var optionsContainer = templates_1.defaultTemplates.options(this._config);
|
|
11670
|
-
// Clear the options container
|
|
11671
|
-
optionsContainer.innerHTML = '';
|
|
11672
11712
|
// Add each option directly to the container
|
|
11673
11713
|
options.forEach(function (optionElement) {
|
|
11674
11714
|
// Skip empty placeholder options (only if BOTH value AND text are empty)
|
|
@@ -11689,7 +11729,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11689
11729
|
wrapperElement.appendChild(dropdownElement);
|
|
11690
11730
|
// Insert after the original element
|
|
11691
11731
|
this._element.after(wrapperElement);
|
|
11692
|
-
this._element.
|
|
11732
|
+
this._element.classList.add('hidden');
|
|
11693
11733
|
};
|
|
11694
11734
|
/**
|
|
11695
11735
|
* Setup all element references after DOM is created
|
|
@@ -11847,20 +11887,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11847
11887
|
});
|
|
11848
11888
|
}
|
|
11849
11889
|
};
|
|
11850
|
-
/**
|
|
11851
|
-
* Set appropriate z-index for dropdown
|
|
11852
|
-
*/
|
|
11853
|
-
KTSelect.prototype._initZIndex = function () {
|
|
11854
|
-
var zindex = this._config.dropdownZindex;
|
|
11855
|
-
if (parseInt(dom_1.default.getCssProp(this._dropdownContentElement, 'z-index')) >
|
|
11856
|
-
zindex) {
|
|
11857
|
-
zindex = parseInt(dom_1.default.getCssProp(this._dropdownContentElement, 'z-index'));
|
|
11858
|
-
}
|
|
11859
|
-
if (dom_1.default.getHighestZindex(this._wrapperElement) > zindex) {
|
|
11860
|
-
zindex = dom_1.default.getHighestZindex(this._wrapperElement) + 1;
|
|
11861
|
-
}
|
|
11862
|
-
this._dropdownContentElement.style.zIndex = String(zindex);
|
|
11863
|
-
};
|
|
11864
11890
|
/**
|
|
11865
11891
|
* ========================================================================
|
|
11866
11892
|
* DROPDOWN MANAGEMENT
|
|
@@ -12040,62 +12066,34 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12040
12066
|
}
|
|
12041
12067
|
return; // Nothing to display on if the element is missing
|
|
12042
12068
|
}
|
|
12043
|
-
// 1. Custom render function takes highest precedence
|
|
12044
12069
|
if (typeof this._config.renderSelected === 'function') {
|
|
12045
12070
|
valueDisplayEl.innerHTML = this._config.renderSelected(selectedOptions);
|
|
12046
|
-
return;
|
|
12047
|
-
}
|
|
12048
|
-
// 2. Custom displayTemplate string
|
|
12049
|
-
// Check if a custom display template string is provided directly in config or via config.templates
|
|
12050
|
-
var customDisplayTemplateString = this._config.displayTemplate || (this._config.templates && this._config.templates.display);
|
|
12051
|
-
if (customDisplayTemplateString) {
|
|
12052
|
-
// If tags are enabled and items are selected, the tags module handles display, so clear the main display area.
|
|
12053
|
-
if (tagsEnabled && selectedOptions.length > 0) {
|
|
12054
|
-
valueDisplayEl.innerHTML = '';
|
|
12055
|
-
}
|
|
12056
|
-
else {
|
|
12057
|
-
// Otherwise, render the custom display template.
|
|
12058
|
-
// If no options are selected, renderDisplayTemplateForSelected should handle showing a placeholder if the template supports it,
|
|
12059
|
-
// or we might need a separate placeholder rendering for custom templates if they don't handle empty selection.
|
|
12060
|
-
// For now, assume renderDisplayTemplateForSelected handles it or shows selected text.
|
|
12061
|
-
valueDisplayEl.innerHTML = this.renderDisplayTemplateForSelected(selectedOptions);
|
|
12062
|
-
}
|
|
12063
|
-
return;
|
|
12064
|
-
}
|
|
12065
|
-
// 3. Default template behavior (no custom function or string template)
|
|
12066
|
-
var textContainer = valueDisplayEl.querySelector('[data-kt-text-container="true"]');
|
|
12067
|
-
if (tagsEnabled && selectedOptions.length > 0) {
|
|
12068
|
-
// Tags are active and have content, clear the text container if it exists,
|
|
12069
|
-
// or the whole display if it doesn't (though it should with default template).
|
|
12070
|
-
if (textContainer) {
|
|
12071
|
-
textContainer.innerHTML = '';
|
|
12072
|
-
}
|
|
12073
|
-
else {
|
|
12074
|
-
valueDisplayEl.innerHTML = ''; // Fallback: clear entire display area
|
|
12075
|
-
}
|
|
12076
|
-
}
|
|
12077
|
-
else if (selectedOptions.length === 0) {
|
|
12078
|
-
// No options selected: display placeholder text in the text container.
|
|
12079
|
-
var placeholderTemplate = templates_1.defaultTemplates.placeholder(this._config);
|
|
12080
|
-
var placeholderText = placeholderTemplate.textContent || ''; // Get text from placeholder element
|
|
12081
|
-
if (textContainer) {
|
|
12082
|
-
textContainer.innerHTML = placeholderText;
|
|
12083
|
-
}
|
|
12084
|
-
else {
|
|
12085
|
-
// Fallback: If no text container, replace children of valueDisplayEl with the placeholder element itself.
|
|
12086
|
-
// This ensures the placeholder (which might have its own structure/classes) is displayed.
|
|
12087
|
-
valueDisplayEl.replaceChildren(placeholderTemplate);
|
|
12088
|
-
}
|
|
12089
12071
|
}
|
|
12090
12072
|
else {
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12073
|
+
if (selectedOptions.length === 0) {
|
|
12074
|
+
// No options selected: display placeholder.
|
|
12075
|
+
// This runs if tags are off, OR if tags are on but no items are selected (tags module would have cleared tags).
|
|
12076
|
+
var placeholderEl = templates_1.defaultTemplates.placeholder(this._config);
|
|
12077
|
+
valueDisplayEl.replaceChildren(placeholderEl);
|
|
12096
12078
|
}
|
|
12097
12079
|
else {
|
|
12098
|
-
|
|
12080
|
+
// Options are selected.
|
|
12081
|
+
if (tagsEnabled) {
|
|
12082
|
+
// Tags are enabled AND options are selected: tags module has rendered them.
|
|
12083
|
+
// Clear valueDisplayEl as tags are the primary display.
|
|
12084
|
+
valueDisplayEl.innerHTML = '';
|
|
12085
|
+
}
|
|
12086
|
+
else {
|
|
12087
|
+
// Tags are not enabled AND options are selected: render normal text display.
|
|
12088
|
+
var content = '';
|
|
12089
|
+
if (this._config.displayTemplate) {
|
|
12090
|
+
content = this.renderDisplayTemplateForSelected(this.getSelectedOptions());
|
|
12091
|
+
}
|
|
12092
|
+
else {
|
|
12093
|
+
content = this.getSelectedOptionsText();
|
|
12094
|
+
}
|
|
12095
|
+
valueDisplayEl.innerHTML = content;
|
|
12096
|
+
}
|
|
12099
12097
|
}
|
|
12100
12098
|
}
|
|
12101
12099
|
};
|
|
@@ -12756,6 +12754,73 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12756
12754
|
KTSelect.prototype.getDisplayElement = function () {
|
|
12757
12755
|
return this._displayElement;
|
|
12758
12756
|
};
|
|
12757
|
+
KTSelect.prototype._observeNativeSelect = function () {
|
|
12758
|
+
var _this = this;
|
|
12759
|
+
if (this._mutationObserver)
|
|
12760
|
+
return; // Prevent double observers
|
|
12761
|
+
this._mutationObserver = new MutationObserver(function (mutations) {
|
|
12762
|
+
var needsRebuild = false;
|
|
12763
|
+
var needsSelectionSync = false;
|
|
12764
|
+
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
12765
|
+
var mutation = mutations_1[_i];
|
|
12766
|
+
if (mutation.type === 'childList') {
|
|
12767
|
+
// Option(s) added or removed
|
|
12768
|
+
needsRebuild = true;
|
|
12769
|
+
}
|
|
12770
|
+
else if (mutation.type === 'attributes' && mutation.target instanceof HTMLOptionElement) {
|
|
12771
|
+
if (mutation.attributeName === 'selected') {
|
|
12772
|
+
needsSelectionSync = true;
|
|
12773
|
+
}
|
|
12774
|
+
}
|
|
12775
|
+
}
|
|
12776
|
+
if (needsRebuild) {
|
|
12777
|
+
// Rebuild the custom dropdown options
|
|
12778
|
+
_this._rebuildOptionsFromNative();
|
|
12779
|
+
}
|
|
12780
|
+
if (needsSelectionSync) {
|
|
12781
|
+
_this._syncSelectionFromNative();
|
|
12782
|
+
}
|
|
12783
|
+
});
|
|
12784
|
+
this._mutationObserver.observe(this._element, {
|
|
12785
|
+
childList: true,
|
|
12786
|
+
attributes: true,
|
|
12787
|
+
subtree: true,
|
|
12788
|
+
attributeFilter: ['selected'],
|
|
12789
|
+
});
|
|
12790
|
+
};
|
|
12791
|
+
KTSelect.prototype._rebuildOptionsFromNative = function () {
|
|
12792
|
+
var _this = this;
|
|
12793
|
+
// Remove and rebuild the custom dropdown options from the native select
|
|
12794
|
+
if (this._dropdownContentElement) {
|
|
12795
|
+
var optionsContainer_1 = this._dropdownContentElement.querySelector('[data-kt-select-options]');
|
|
12796
|
+
if (optionsContainer_1) {
|
|
12797
|
+
optionsContainer_1.innerHTML = '';
|
|
12798
|
+
var options = Array.from(this._element.querySelectorAll('option'));
|
|
12799
|
+
options.forEach(function (optionElement) {
|
|
12800
|
+
if (optionElement.value === '' &&
|
|
12801
|
+
optionElement.textContent.trim() === '') {
|
|
12802
|
+
return;
|
|
12803
|
+
}
|
|
12804
|
+
var selectOption = new option_1.KTSelectOption(optionElement, _this._config);
|
|
12805
|
+
var renderedOption = selectOption.render();
|
|
12806
|
+
optionsContainer_1.appendChild(renderedOption);
|
|
12807
|
+
});
|
|
12808
|
+
// Update internal references
|
|
12809
|
+
this._options = this._wrapperElement.querySelectorAll('[data-kt-select-option]');
|
|
12810
|
+
}
|
|
12811
|
+
}
|
|
12812
|
+
// Sync selection after rebuilding
|
|
12813
|
+
this._syncSelectionFromNative();
|
|
12814
|
+
this.updateSelectedOptionDisplay();
|
|
12815
|
+
this._updateSelectedOptionClass();
|
|
12816
|
+
};
|
|
12817
|
+
KTSelect.prototype._syncSelectionFromNative = function () {
|
|
12818
|
+
// Sync internal state from the native select's selected options
|
|
12819
|
+
var selected = Array.from(this._element.querySelectorAll('option:checked')).map(function (opt) { return opt.value; });
|
|
12820
|
+
this._state.setSelectedOptions(this._config.multiple ? selected : selected[0] || '');
|
|
12821
|
+
this.updateSelectedOptionDisplay();
|
|
12822
|
+
this._updateSelectedOptionClass();
|
|
12823
|
+
};
|
|
12759
12824
|
/**
|
|
12760
12825
|
* ========================================================================
|
|
12761
12826
|
* STATIC METHODS
|
|
@@ -13502,6 +13567,7 @@ var KTDropdown = /** @class */ (function (_super) {
|
|
|
13502
13567
|
offset: '0px, 5px',
|
|
13503
13568
|
offsetRtl: '0px, 5px',
|
|
13504
13569
|
hiddenClass: 'hidden',
|
|
13570
|
+
container: '',
|
|
13505
13571
|
};
|
|
13506
13572
|
_this._config = _this._defaultConfig;
|
|
13507
13573
|
_this._disabled = false;
|
|
@@ -13519,8 +13585,21 @@ var KTDropdown = /** @class */ (function (_super) {
|
|
|
13519
13585
|
return _this;
|
|
13520
13586
|
data_1.default.set(_this._menuElement, 'dropdownElement', _this._element);
|
|
13521
13587
|
_this._setupNestedDropdowns();
|
|
13588
|
+
_this._handleContainer();
|
|
13522
13589
|
return _this;
|
|
13523
13590
|
}
|
|
13591
|
+
KTDropdown.prototype._handleContainer = function () {
|
|
13592
|
+
var _a;
|
|
13593
|
+
if (this._getOption('container')) {
|
|
13594
|
+
if (this._getOption('container') === 'body') {
|
|
13595
|
+
document.body.appendChild(this._menuElement);
|
|
13596
|
+
}
|
|
13597
|
+
else {
|
|
13598
|
+
(_a = document
|
|
13599
|
+
.querySelector(this._getOption('container'))) === null || _a === void 0 ? void 0 : _a.appendChild(this._menuElement);
|
|
13600
|
+
}
|
|
13601
|
+
}
|
|
13602
|
+
};
|
|
13524
13603
|
KTDropdown.prototype._setupNestedDropdowns = function () {
|
|
13525
13604
|
var subDropdowns = this._menuElement.querySelectorAll('[data-kt-dropdown-toggle]');
|
|
13526
13605
|
subDropdowns.forEach(function (subToggle) {
|
|
@@ -16174,8 +16253,6 @@ exports.defaultTemplates = {
|
|
|
16174
16253
|
wrapper: function (config) {
|
|
16175
16254
|
var html = getTemplateStrings(config).wrapper.replace('{{class}}', config.wrapperClass || '');
|
|
16176
16255
|
var element = stringToElement(html);
|
|
16177
|
-
element.setAttribute('data-kt-select-combobox', config.combobox ? 'true' : 'false');
|
|
16178
|
-
element.setAttribute('data-kt-select-tags', config.tags ? 'true' : 'false');
|
|
16179
16256
|
return element;
|
|
16180
16257
|
},
|
|
16181
16258
|
/**
|
|
@@ -17454,7 +17531,6 @@ exports.DefaultConfig = {
|
|
|
17454
17531
|
// General Display
|
|
17455
17532
|
debug: false,
|
|
17456
17533
|
placeholder: 'Select an option', // Default placeholder text when no option is selected
|
|
17457
|
-
dropdownZindex: null, // Initial z-index value for the dropdown
|
|
17458
17534
|
// Data Handling
|
|
17459
17535
|
items: [], // Static list of options
|
|
17460
17536
|
isLoading: false, // Indicates if options are being loaded asynchronously
|
|
@@ -17477,6 +17553,7 @@ exports.DefaultConfig = {
|
|
|
17477
17553
|
paginationLimitParam: 'limit', // Parameter name for items per page
|
|
17478
17554
|
paginationTotalParam: 'total', // Parameter name for total items
|
|
17479
17555
|
// Selection Behavior
|
|
17556
|
+
allowClear: false, // Allow clearing the selection (if true, an empty value can be set)
|
|
17480
17557
|
multiple: false, // Enable/disable multi-select
|
|
17481
17558
|
maxSelections: null, // Maximum number of selections allowed in multi-select mode (null for unlimited)
|
|
17482
17559
|
disabled: false, // Disable the select component
|
|
@@ -17498,6 +17575,8 @@ exports.DefaultConfig = {
|
|
|
17498
17575
|
label: 'Select an option', // Label for the select component (for screen readers)
|
|
17499
17576
|
height: 250, // Maximum height of the dropdown menu in pixels (if exceeded, a scrollbar will appear)
|
|
17500
17577
|
// Dropdown Configuration
|
|
17578
|
+
dropdownZindex: null, // Initial z-index value for the dropdown
|
|
17579
|
+
dropdownContainer: null, // Container element for the dropdown
|
|
17501
17580
|
dropdownPlacement: null,
|
|
17502
17581
|
dropdownFlip: false,
|
|
17503
17582
|
dropdownPreventOverflow: false,
|
|
@@ -17581,11 +17660,17 @@ var KTSelectState = /** @class */ (function () {
|
|
|
17581
17660
|
return this._config.items || [];
|
|
17582
17661
|
};
|
|
17583
17662
|
KTSelectState.prototype.setItemsFromOptions = function (options) {
|
|
17584
|
-
this._config.items = options.map(function (option) {
|
|
17585
|
-
|
|
17586
|
-
|
|
17587
|
-
|
|
17588
|
-
|
|
17663
|
+
this._config.items = options.map(function (option) {
|
|
17664
|
+
var item = {
|
|
17665
|
+
id: option.value,
|
|
17666
|
+
title: option.textContent || option.value, // Use value as fallback for title
|
|
17667
|
+
// 'selected' property will be definitively set by _preSelectOptions
|
|
17668
|
+
disabled: option.disabled,
|
|
17669
|
+
};
|
|
17670
|
+
return item;
|
|
17671
|
+
});
|
|
17672
|
+
// The 'selected' status of these items and the overall component selection state
|
|
17673
|
+
// are now fully managed by _preSelectOptions in KTSelect during initialization.
|
|
17589
17674
|
};
|
|
17590
17675
|
KTSelectState.prototype.getConfig = function () {
|
|
17591
17676
|
return this._config;
|