@keenthemes/ktui 1.0.14 → 1.0.16
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 +65 -35
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.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/config.js +2 -1
- 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 +13 -28
- package/lib/cjs/components/select/select.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/config.js +2 -1
- 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 +13 -28
- package/lib/esm/components/select/select.js.map +1 -1
- package/package.json +1 -1
- package/src/components/dropdown/dropdown.ts +14 -0
- package/src/components/dropdown/types.ts +1 -0
- package/src/components/select/config.ts +5 -4
- package/src/components/select/dropdown.ts +45 -6
- package/src/components/select/select.ts +16 -33
package/dist/ktui.js
CHANGED
|
@@ -9311,6 +9311,12 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9311
9311
|
_this._dropdownElement = dropdownElement;
|
|
9312
9312
|
_this._config = config;
|
|
9313
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
|
+
}
|
|
9314
9320
|
_this._eventManager = new utils_1.EventManager();
|
|
9315
9321
|
_this._focusManager = new utils_1.FocusManager(dropdownElement, '[data-kt-select-option]', config);
|
|
9316
9322
|
_this._setupEventListeners();
|
|
@@ -9478,16 +9484,26 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9478
9484
|
// Reflow
|
|
9479
9485
|
dom_1.default.reflow(this._dropdownElement);
|
|
9480
9486
|
// Apply z-index
|
|
9487
|
+
var zIndexToApply = null;
|
|
9481
9488
|
if (this._config.dropdownZindex) {
|
|
9482
|
-
this.
|
|
9483
|
-
this._config.dropdownZindex.toString();
|
|
9489
|
+
zIndexToApply = this._config.dropdownZindex;
|
|
9484
9490
|
}
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
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;
|
|
9489
9497
|
}
|
|
9490
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
|
+
}
|
|
9491
9507
|
// Initialize popper
|
|
9492
9508
|
this._initPopper();
|
|
9493
9509
|
// Add active classes for visual state
|
|
@@ -9578,6 +9594,20 @@ var KTSelectDropdown = /** @class */ (function (_super) {
|
|
|
9578
9594
|
// Remove data reference
|
|
9579
9595
|
data_1.default.remove(this._element, this._name);
|
|
9580
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
|
+
};
|
|
9581
9611
|
return KTSelectDropdown;
|
|
9582
9612
|
}(component_1.default));
|
|
9583
9613
|
exports.KTSelectDropdown = KTSelectDropdown;
|
|
@@ -11333,7 +11363,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
11333
11363
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11334
11364
|
exports.KTSelect = void 0;
|
|
11335
11365
|
var data_1 = __webpack_require__(8716);
|
|
11336
|
-
var dom_1 = __webpack_require__(9010);
|
|
11337
11366
|
var component_1 = __webpack_require__(2658);
|
|
11338
11367
|
var config_1 = __webpack_require__(9386);
|
|
11339
11368
|
var option_1 = __webpack_require__(4241);
|
|
@@ -11616,9 +11645,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11616
11645
|
// Setup HTML structure
|
|
11617
11646
|
this._createHtmlStructure();
|
|
11618
11647
|
this._setupElementReferences();
|
|
11619
|
-
this._initZIndex();
|
|
11620
11648
|
// Initialize options
|
|
11621
|
-
// this._initializeOptionsHtml();
|
|
11622
11649
|
this._preSelectOptions(this._element);
|
|
11623
11650
|
// Apply disabled state if needed
|
|
11624
11651
|
this._applyInitialDisabledState();
|
|
@@ -11650,7 +11677,7 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11650
11677
|
* Creates the HTML structure for the select component
|
|
11651
11678
|
*/
|
|
11652
11679
|
KTSelect.prototype._createHtmlStructure = function () {
|
|
11653
|
-
var _a;
|
|
11680
|
+
var _a, _b;
|
|
11654
11681
|
var _this = this;
|
|
11655
11682
|
var options = Array.from(this._element.querySelectorAll('option'));
|
|
11656
11683
|
// Create wrapper and display elements
|
|
@@ -11658,16 +11685,20 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11658
11685
|
var displayElement = templates_1.defaultTemplates.display(this._config);
|
|
11659
11686
|
// Add the display element to the wrapper
|
|
11660
11687
|
wrapperElement.appendChild(displayElement);
|
|
11661
|
-
// Move classes from original select to display
|
|
11688
|
+
// Move classes from original select to wrapper and display elements
|
|
11662
11689
|
if (this._element.classList.length > 0) {
|
|
11663
|
-
|
|
11664
|
-
var
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
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);
|
|
11669
11700
|
}
|
|
11670
|
-
this._element.className = '';
|
|
11701
|
+
this._element.className = ''; // Clear classes from original select element
|
|
11671
11702
|
}
|
|
11672
11703
|
// Create an empty dropdown first (without options) using template
|
|
11673
11704
|
var dropdownElement = templates_1.defaultTemplates.dropdown(__assign(__assign({}, this._config), { zindex: this._config.dropdownZindex }));
|
|
@@ -11678,8 +11709,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11678
11709
|
}
|
|
11679
11710
|
// Create options container using template
|
|
11680
11711
|
var optionsContainer = templates_1.defaultTemplates.options(this._config);
|
|
11681
|
-
// Clear the options container
|
|
11682
|
-
optionsContainer.innerHTML = '';
|
|
11683
11712
|
// Add each option directly to the container
|
|
11684
11713
|
options.forEach(function (optionElement) {
|
|
11685
11714
|
// Skip empty placeholder options (only if BOTH value AND text are empty)
|
|
@@ -11858,20 +11887,6 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11858
11887
|
});
|
|
11859
11888
|
}
|
|
11860
11889
|
};
|
|
11861
|
-
/**
|
|
11862
|
-
* Set appropriate z-index for dropdown
|
|
11863
|
-
*/
|
|
11864
|
-
KTSelect.prototype._initZIndex = function () {
|
|
11865
|
-
var zindex = this._config.dropdownZindex;
|
|
11866
|
-
if (parseInt(dom_1.default.getCssProp(this._dropdownContentElement, 'z-index')) >
|
|
11867
|
-
zindex) {
|
|
11868
|
-
zindex = parseInt(dom_1.default.getCssProp(this._dropdownContentElement, 'z-index'));
|
|
11869
|
-
}
|
|
11870
|
-
if (dom_1.default.getHighestZindex(this._wrapperElement) > zindex) {
|
|
11871
|
-
zindex = dom_1.default.getHighestZindex(this._wrapperElement) + 1;
|
|
11872
|
-
}
|
|
11873
|
-
this._dropdownContentElement.style.zIndex = String(zindex);
|
|
11874
|
-
};
|
|
11875
11890
|
/**
|
|
11876
11891
|
* ========================================================================
|
|
11877
11892
|
* DROPDOWN MANAGEMENT
|
|
@@ -13552,6 +13567,7 @@ var KTDropdown = /** @class */ (function (_super) {
|
|
|
13552
13567
|
offset: '0px, 5px',
|
|
13553
13568
|
offsetRtl: '0px, 5px',
|
|
13554
13569
|
hiddenClass: 'hidden',
|
|
13570
|
+
container: '',
|
|
13555
13571
|
};
|
|
13556
13572
|
_this._config = _this._defaultConfig;
|
|
13557
13573
|
_this._disabled = false;
|
|
@@ -13569,8 +13585,21 @@ var KTDropdown = /** @class */ (function (_super) {
|
|
|
13569
13585
|
return _this;
|
|
13570
13586
|
data_1.default.set(_this._menuElement, 'dropdownElement', _this._element);
|
|
13571
13587
|
_this._setupNestedDropdowns();
|
|
13588
|
+
_this._handleContainer();
|
|
13572
13589
|
return _this;
|
|
13573
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
|
+
};
|
|
13574
13603
|
KTDropdown.prototype._setupNestedDropdowns = function () {
|
|
13575
13604
|
var subDropdowns = this._menuElement.querySelectorAll('[data-kt-dropdown-toggle]');
|
|
13576
13605
|
subDropdowns.forEach(function (subToggle) {
|
|
@@ -17502,7 +17531,6 @@ exports.DefaultConfig = {
|
|
|
17502
17531
|
// General Display
|
|
17503
17532
|
debug: false,
|
|
17504
17533
|
placeholder: 'Select an option', // Default placeholder text when no option is selected
|
|
17505
|
-
dropdownZindex: null, // Initial z-index value for the dropdown
|
|
17506
17534
|
// Data Handling
|
|
17507
17535
|
items: [], // Static list of options
|
|
17508
17536
|
isLoading: false, // Indicates if options are being loaded asynchronously
|
|
@@ -17547,6 +17575,8 @@ exports.DefaultConfig = {
|
|
|
17547
17575
|
label: 'Select an option', // Label for the select component (for screen readers)
|
|
17548
17576
|
height: 250, // Maximum height of the dropdown menu in pixels (if exceeded, a scrollbar will appear)
|
|
17549
17577
|
// Dropdown Configuration
|
|
17578
|
+
dropdownZindex: 105, // Initial z-index value for the dropdown
|
|
17579
|
+
dropdownContainer: null, // Container element for the dropdown
|
|
17550
17580
|
dropdownPlacement: null,
|
|
17551
17581
|
dropdownFlip: false,
|
|
17552
17582
|
dropdownPreventOverflow: false,
|