@keenthemes/ktui 1.0.22 → 1.0.24
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 +101 -22
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/dist/styles.css +156 -20
- package/examples/datatable/sorting-test.html +5 -145
- package/examples/select/global-config-test.html +81 -0
- package/examples/select/modal-container.html +128 -0
- package/examples/select/modal.html +39 -30
- package/examples/select/native-selected.html +64 -0
- package/examples/select/remote-data.html +13 -12
- package/examples/select/tags-enhanced.html +86 -0
- package/examples/select/{tags-icons_.html → tags-icons.html} +1 -2
- package/examples/select/template-customization.html +0 -1
- package/lib/cjs/components/image-input/image-input.js +0 -3
- package/lib/cjs/components/image-input/image-input.js.map +1 -1
- package/lib/cjs/components/select/select.js +91 -13
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/select/tags.js +9 -5
- package/lib/cjs/components/select/tags.js.map +1 -1
- package/lib/cjs/components/select/templates.js +1 -1
- package/lib/cjs/components/select/templates.js.map +1 -1
- package/lib/esm/components/image-input/image-input.js +0 -3
- package/lib/esm/components/image-input/image-input.js.map +1 -1
- package/lib/esm/components/select/select.js +91 -13
- package/lib/esm/components/select/select.js.map +1 -1
- package/lib/esm/components/select/tags.js +9 -5
- package/lib/esm/components/select/tags.js.map +1 -1
- package/lib/esm/components/select/templates.js +1 -1
- package/lib/esm/components/select/templates.js.map +1 -1
- package/package.json +1 -1
- package/src/components/image-input/image-input.ts +13 -15
- package/src/components/select/select.css +39 -0
- package/src/components/select/select.ts +110 -7
- package/src/components/select/tags.ts +10 -8
- package/src/components/select/templates.ts +1 -1
- package/examples/select/combobox-icons_.html +0 -59
- package/examples/select/combobox_.html +0 -46
- package/examples/select/tags-selected_.html +0 -59
- package/examples/select/tags_.html +0 -58
- package/examples/select/test-optimizations.html +0 -227
- package/examples/select/test-remote-search.html +0 -151
package/dist/ktui.js
CHANGED
|
@@ -2636,7 +2636,6 @@ var component_1 = __webpack_require__(2658);
|
|
|
2636
2636
|
var KTImageInput = /** @class */ (function (_super) {
|
|
2637
2637
|
__extends(KTImageInput, _super);
|
|
2638
2638
|
function KTImageInput(element, config) {
|
|
2639
|
-
if (config === void 0) { config = null; }
|
|
2640
2639
|
var _this = _super.call(this) || this;
|
|
2641
2640
|
_this._name = 'image-input';
|
|
2642
2641
|
_this._defaultConfig = {
|
|
@@ -2683,8 +2682,6 @@ var KTImageInput = /** @class */ (function (_super) {
|
|
|
2683
2682
|
};
|
|
2684
2683
|
reader.readAsDataURL(this._inputElement.files[0]);
|
|
2685
2684
|
this._selectedFile = this._inputElement.files[0];
|
|
2686
|
-
this._inputElement.value = '';
|
|
2687
|
-
this._hiddenElement.value = '';
|
|
2688
2685
|
this._lastMode = 'new';
|
|
2689
2686
|
this._element.classList.add('changed');
|
|
2690
2687
|
this._removeElement.classList.remove('hidden');
|
|
@@ -11630,6 +11627,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
11630
11627
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11631
11628
|
exports.KTSelect = void 0;
|
|
11632
11629
|
var data_1 = __webpack_require__(8716);
|
|
11630
|
+
var dom_1 = __webpack_require__(9010);
|
|
11633
11631
|
var component_1 = __webpack_require__(2658);
|
|
11634
11632
|
var config_1 = __webpack_require__(9386);
|
|
11635
11633
|
var option_1 = __webpack_require__(4241);
|
|
@@ -11696,6 +11694,31 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
11696
11694
|
}
|
|
11697
11695
|
return _this;
|
|
11698
11696
|
}
|
|
11697
|
+
/**
|
|
11698
|
+
* Set global select configuration options.
|
|
11699
|
+
* This allows setting default configuration that will be applied to all new KTSelect instances.
|
|
11700
|
+
* @param options Partial select config to merge with global config.
|
|
11701
|
+
* @example
|
|
11702
|
+
* KTSelect.config({
|
|
11703
|
+
* enableSearch: true,
|
|
11704
|
+
* searchPlaceholder: 'Type to search...',
|
|
11705
|
+
* dropdownZindex: 9999,
|
|
11706
|
+
* height: 300
|
|
11707
|
+
* });
|
|
11708
|
+
*/
|
|
11709
|
+
KTSelect.config = function (options) {
|
|
11710
|
+
this.globalConfig = __assign(__assign({}, this.globalConfig), options);
|
|
11711
|
+
};
|
|
11712
|
+
/**
|
|
11713
|
+
* Override _buildConfig to include static globalConfig in the merge chain
|
|
11714
|
+
*/
|
|
11715
|
+
KTSelect.prototype._buildConfig = function (config) {
|
|
11716
|
+
if (config === void 0) { config = {}; }
|
|
11717
|
+
if (!this._element)
|
|
11718
|
+
return;
|
|
11719
|
+
// Cast to writable to allow assignment (config is readonly but needs initialization)
|
|
11720
|
+
this._config = __assign(__assign(__assign(__assign(__assign({}, this._defaultConfig), KTSelect.globalConfig), this._getGlobalConfig()), dom_1.default.getDataAttributes(this._element, this._dataOptionPrefix + this._name)), config);
|
|
11721
|
+
};
|
|
11699
11722
|
/**
|
|
11700
11723
|
* Initialize remote data fetching
|
|
11701
11724
|
*/
|
|
@@ -12492,8 +12515,10 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12492
12515
|
// Options are selected.
|
|
12493
12516
|
if (tagsEnabled) {
|
|
12494
12517
|
// Tags are enabled AND options are selected: tags module has rendered them.
|
|
12495
|
-
//
|
|
12496
|
-
|
|
12518
|
+
// Completely clear all content to avoid redundancy with tags
|
|
12519
|
+
// Don't touch the innerHTML here as tags module manages it
|
|
12520
|
+
// Just ensure no text content is generated
|
|
12521
|
+
return; // Exit early to prevent any text generation
|
|
12497
12522
|
}
|
|
12498
12523
|
else {
|
|
12499
12524
|
// Tags are not enabled AND options are selected: render normal text display.
|
|
@@ -12562,6 +12587,10 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12562
12587
|
KTSelect.prototype.clearSelection = function () {
|
|
12563
12588
|
// Clear the current selection
|
|
12564
12589
|
this._state.setSelectedOptions([]);
|
|
12590
|
+
// Clear all native select options
|
|
12591
|
+
Array.from(this._element.querySelectorAll('option')).forEach(function (opt) {
|
|
12592
|
+
opt.selected = false;
|
|
12593
|
+
});
|
|
12565
12594
|
this.updateSelectedOptionDisplay();
|
|
12566
12595
|
this._updateSelectedOptionClass();
|
|
12567
12596
|
// Update select all button state
|
|
@@ -12877,17 +12906,20 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12877
12906
|
// Call parent dispose to clean up data
|
|
12878
12907
|
_super.prototype.dispose.call(this);
|
|
12879
12908
|
};
|
|
12909
|
+
/**
|
|
12910
|
+
* ========================================================================
|
|
12911
|
+
* STATIC METHODS
|
|
12912
|
+
* ========================================================================
|
|
12913
|
+
*/
|
|
12880
12914
|
/**
|
|
12881
12915
|
* Create instances of KTSelect for all matching elements
|
|
12882
12916
|
*/
|
|
12883
12917
|
KTSelect.createInstances = function () {
|
|
12884
|
-
var _this = this;
|
|
12885
12918
|
var elements = document.querySelectorAll('[data-kt-select]');
|
|
12886
12919
|
elements.forEach(function (element) {
|
|
12887
12920
|
if (element.hasAttribute('data-kt-select') &&
|
|
12888
12921
|
!element.classList.contains('data-kt-select-initialized')) {
|
|
12889
|
-
|
|
12890
|
-
_this._instances.set(element, instance);
|
|
12922
|
+
new KTSelect(element);
|
|
12891
12923
|
}
|
|
12892
12924
|
});
|
|
12893
12925
|
};
|
|
@@ -12897,6 +12929,26 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
12897
12929
|
KTSelect.init = function () {
|
|
12898
12930
|
KTSelect.createInstances();
|
|
12899
12931
|
};
|
|
12932
|
+
/**
|
|
12933
|
+
* Get an existing KTSelect instance from an element
|
|
12934
|
+
*/
|
|
12935
|
+
KTSelect.getInstance = function (element) {
|
|
12936
|
+
if (!element)
|
|
12937
|
+
return null;
|
|
12938
|
+
if (data_1.default.has(element, 'select')) {
|
|
12939
|
+
return data_1.default.get(element, 'select');
|
|
12940
|
+
}
|
|
12941
|
+
if (element.getAttribute('data-kt-select')) {
|
|
12942
|
+
return new KTSelect(element);
|
|
12943
|
+
}
|
|
12944
|
+
return null;
|
|
12945
|
+
};
|
|
12946
|
+
/**
|
|
12947
|
+
* Get an existing KTSelect instance or create a new one
|
|
12948
|
+
*/
|
|
12949
|
+
KTSelect.getOrCreateInstance = function (element, config) {
|
|
12950
|
+
return this.getInstance(element) || new KTSelect(element, config);
|
|
12951
|
+
};
|
|
12900
12952
|
/**
|
|
12901
12953
|
* Handle remote search
|
|
12902
12954
|
* @param event Input event
|
|
@@ -13016,13 +13068,40 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
13016
13068
|
optionsContainer.appendChild(noResultsElement);
|
|
13017
13069
|
return;
|
|
13018
13070
|
}
|
|
13019
|
-
//
|
|
13020
|
-
this.
|
|
13071
|
+
// First update the original select element with search results
|
|
13072
|
+
this._updateOriginalSelectWithSearchResults(items);
|
|
13073
|
+
// Then update dropdown using the standard flow
|
|
13074
|
+
this._updateDropdownWithNewOptions();
|
|
13021
13075
|
// Add pagination "Load More" button if needed
|
|
13022
13076
|
if (this._config.pagination && this._remoteModule.hasMorePages()) {
|
|
13023
13077
|
this._addLoadMoreButton();
|
|
13024
13078
|
}
|
|
13025
13079
|
};
|
|
13080
|
+
/**
|
|
13081
|
+
* Update original select element with search results
|
|
13082
|
+
* @param items Search result items
|
|
13083
|
+
*/
|
|
13084
|
+
KTSelect.prototype._updateOriginalSelectWithSearchResults = function (items) {
|
|
13085
|
+
var _this = this;
|
|
13086
|
+
// Clear existing options except placeholder
|
|
13087
|
+
this._clearExistingOptions();
|
|
13088
|
+
// Add search result items to original select element
|
|
13089
|
+
items.forEach(function (item) {
|
|
13090
|
+
var optionElement = document.createElement('option');
|
|
13091
|
+
optionElement.value = item.id || '';
|
|
13092
|
+
optionElement.textContent = item.title || '';
|
|
13093
|
+
if (item.selected) {
|
|
13094
|
+
optionElement.setAttribute('selected', 'selected');
|
|
13095
|
+
}
|
|
13096
|
+
if (item.disabled) {
|
|
13097
|
+
optionElement.setAttribute('disabled', 'disabled');
|
|
13098
|
+
}
|
|
13099
|
+
_this._element.appendChild(optionElement);
|
|
13100
|
+
});
|
|
13101
|
+
if (this._config.debug) {
|
|
13102
|
+
console.log("Updated original select with ".concat(items.length, " search results"));
|
|
13103
|
+
}
|
|
13104
|
+
};
|
|
13026
13105
|
/**
|
|
13027
13106
|
* Check if dropdown is open
|
|
13028
13107
|
*/
|
|
@@ -13331,12 +13410,8 @@ var KTSelect = /** @class */ (function (_super) {
|
|
|
13331
13410
|
? this._config.clearAllText
|
|
13332
13411
|
: this._config.selectAllText;
|
|
13333
13412
|
};
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
* STATIC METHODS
|
|
13337
|
-
* ========================================================================
|
|
13338
|
-
*/
|
|
13339
|
-
KTSelect._instances = new Map();
|
|
13413
|
+
// Static global configuration
|
|
13414
|
+
KTSelect.globalConfig = {};
|
|
13340
13415
|
return KTSelect;
|
|
13341
13416
|
}(component_1.default));
|
|
13342
13417
|
exports.KTSelect = KTSelect;
|
|
@@ -15219,12 +15294,16 @@ var KTSelectTags = /** @class */ (function () {
|
|
|
15219
15294
|
var wrapper = this._valueDisplayElement.parentElement;
|
|
15220
15295
|
if (!wrapper)
|
|
15221
15296
|
return;
|
|
15222
|
-
//
|
|
15223
|
-
Array.from(wrapper.querySelectorAll('[data-kt-select-tag]')).forEach(function (tag) { return tag.remove(); });
|
|
15224
|
-
// If no options selected, do nothing (let display show placeholder)
|
|
15297
|
+
// If no options selected, ensure placeholder is shown
|
|
15225
15298
|
if (selectedOptions.length === 0) {
|
|
15299
|
+
// Clear any existing content and show placeholder
|
|
15300
|
+
this._valueDisplayElement.innerHTML = '';
|
|
15301
|
+
var placeholderEl = templates_1.defaultTemplates.placeholder(this._config);
|
|
15302
|
+
this._valueDisplayElement.appendChild(placeholderEl);
|
|
15226
15303
|
return;
|
|
15227
15304
|
}
|
|
15305
|
+
// Clear all existing content before adding tags
|
|
15306
|
+
this._valueDisplayElement.innerHTML = '';
|
|
15228
15307
|
// Insert each tag before the display element
|
|
15229
15308
|
selectedOptions.forEach(function (optionValue) {
|
|
15230
15309
|
// Find the original option element (in dropdown or select)
|
|
@@ -15258,8 +15337,8 @@ var KTSelectTags = /** @class */ (function () {
|
|
|
15258
15337
|
_this._removeTag(optionValue);
|
|
15259
15338
|
});
|
|
15260
15339
|
}
|
|
15261
|
-
// Insert tag
|
|
15262
|
-
|
|
15340
|
+
// Insert tag inside the display element
|
|
15341
|
+
_this._valueDisplayElement.appendChild(tag);
|
|
15263
15342
|
});
|
|
15264
15343
|
};
|
|
15265
15344
|
/**
|
|
@@ -16900,7 +16979,7 @@ exports.defaultTemplates = {
|
|
|
16900
16979
|
tag: function (option, config) {
|
|
16901
16980
|
var _a;
|
|
16902
16981
|
var template = getTemplateStrings(config).tag;
|
|
16903
|
-
var preparedContent = option.
|
|
16982
|
+
var preparedContent = option.textContent || option.innerText || option.value || ''; // Default content is the option's text
|
|
16904
16983
|
if (config.tagTemplate) {
|
|
16905
16984
|
var tagTemplateString_1 = config.tagTemplate;
|
|
16906
16985
|
var optionValue = option.getAttribute('data-value') || option.value;
|