@keenthemes/ktui 1.0.23 → 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 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
  */
@@ -12883,17 +12906,20 @@ var KTSelect = /** @class */ (function (_super) {
12883
12906
  // Call parent dispose to clean up data
12884
12907
  _super.prototype.dispose.call(this);
12885
12908
  };
12909
+ /**
12910
+ * ========================================================================
12911
+ * STATIC METHODS
12912
+ * ========================================================================
12913
+ */
12886
12914
  /**
12887
12915
  * Create instances of KTSelect for all matching elements
12888
12916
  */
12889
12917
  KTSelect.createInstances = function () {
12890
- var _this = this;
12891
12918
  var elements = document.querySelectorAll('[data-kt-select]');
12892
12919
  elements.forEach(function (element) {
12893
12920
  if (element.hasAttribute('data-kt-select') &&
12894
12921
  !element.classList.contains('data-kt-select-initialized')) {
12895
- var instance = new KTSelect(element);
12896
- _this._instances.set(element, instance);
12922
+ new KTSelect(element);
12897
12923
  }
12898
12924
  });
12899
12925
  };
@@ -12903,6 +12929,26 @@ var KTSelect = /** @class */ (function (_super) {
12903
12929
  KTSelect.init = function () {
12904
12930
  KTSelect.createInstances();
12905
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
+ };
12906
12952
  /**
12907
12953
  * Handle remote search
12908
12954
  * @param event Input event
@@ -13022,13 +13068,40 @@ var KTSelect = /** @class */ (function (_super) {
13022
13068
  optionsContainer.appendChild(noResultsElement);
13023
13069
  return;
13024
13070
  }
13025
- // Use unified renderer for search results
13026
- this._renderOptionsInDropdown(items, true);
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();
13027
13075
  // Add pagination "Load More" button if needed
13028
13076
  if (this._config.pagination && this._remoteModule.hasMorePages()) {
13029
13077
  this._addLoadMoreButton();
13030
13078
  }
13031
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
+ };
13032
13105
  /**
13033
13106
  * Check if dropdown is open
13034
13107
  */
@@ -13337,12 +13410,8 @@ var KTSelect = /** @class */ (function (_super) {
13337
13410
  ? this._config.clearAllText
13338
13411
  : this._config.selectAllText;
13339
13412
  };
13340
- /**
13341
- * ========================================================================
13342
- * STATIC METHODS
13343
- * ========================================================================
13344
- */
13345
- KTSelect._instances = new Map();
13413
+ // Static global configuration
13414
+ KTSelect.globalConfig = {};
13346
13415
  return KTSelect;
13347
13416
  }(component_1.default));
13348
13417
  exports.KTSelect = KTSelect;