@ng-select/ng-select 14.6.0 → 14.7.0

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.
@@ -1978,13 +1978,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
1978
1978
 
1979
1979
  var KeyCode;
1980
1980
  (function (KeyCode) {
1981
- KeyCode[KeyCode["Tab"] = 9] = "Tab";
1982
- KeyCode[KeyCode["Enter"] = 13] = "Enter";
1983
- KeyCode[KeyCode["Esc"] = 27] = "Esc";
1984
- KeyCode[KeyCode["Space"] = 32] = "Space";
1985
- KeyCode[KeyCode["ArrowUp"] = 38] = "ArrowUp";
1986
- KeyCode[KeyCode["ArrowDown"] = 40] = "ArrowDown";
1987
- KeyCode[KeyCode["Backspace"] = 8] = "Backspace";
1981
+ KeyCode["Tab"] = "Tab";
1982
+ KeyCode["Enter"] = "Enter";
1983
+ KeyCode["Esc"] = "Escape";
1984
+ KeyCode["Space"] = " ";
1985
+ KeyCode["ArrowUp"] = "ArrowUp";
1986
+ KeyCode["ArrowDown"] = "ArrowDown";
1987
+ KeyCode["Backspace"] = "Backspace";
1988
1988
  })(KeyCode || (KeyCode = {}));
1989
1989
 
1990
1990
  function DefaultSelectionModelFactory() {
@@ -2251,7 +2251,7 @@ class NgSelectComponent {
2251
2251
  return this.typeahead && this.typeahead.observers.length > 0;
2252
2252
  }
2253
2253
  get _validTerm() {
2254
- const term = this.searchTerm && this.searchTerm.trim();
2254
+ const term = this.searchTerm?.trim();
2255
2255
  return term && term.length >= this.minTermLength;
2256
2256
  }
2257
2257
  ngOnInit() {
@@ -2291,15 +2291,15 @@ class NgSelectComponent {
2291
2291
  this._destroy$.complete();
2292
2292
  }
2293
2293
  handleKeyDown($event) {
2294
- const keyCode = KeyCode[$event.which];
2295
- if (keyCode) {
2294
+ const keyName = $event.key;
2295
+ if (Object.values(KeyCode).includes(keyName)) {
2296
2296
  if (this.keyDownFn($event) === false) {
2297
2297
  return;
2298
2298
  }
2299
2299
  this.handleKeyCode($event);
2300
2300
  }
2301
- else if ($event.key && $event.key.length === 1) {
2302
- this._keyPress$.next($event.key.toLocaleLowerCase());
2301
+ else if (keyName && keyName.length === 1) {
2302
+ this._keyPress$.next(keyName.toLocaleLowerCase());
2303
2303
  }
2304
2304
  }
2305
2305
  handleKeyCode($event) {
@@ -2312,7 +2312,7 @@ class NgSelectComponent {
2312
2312
  }
2313
2313
  }
2314
2314
  handleKeyCodeInput($event) {
2315
- switch ($event.which) {
2315
+ switch ($event.key) {
2316
2316
  case KeyCode.ArrowDown:
2317
2317
  this._handleArrowDown($event);
2318
2318
  break;
@@ -2338,7 +2338,7 @@ class NgSelectComponent {
2338
2338
  }
2339
2339
  }
2340
2340
  handleKeyCodeClear($event) {
2341
- switch ($event.which) {
2341
+ switch ($event.key) {
2342
2342
  case KeyCode.Enter:
2343
2343
  this.handleClearClick();
2344
2344
  $event.preventDefault();
@@ -2595,8 +2595,8 @@ class NgSelectComponent {
2595
2595
  }
2596
2596
  }
2597
2597
  _setSearchTermFromItems() {
2598
- const selected = this.selectedItems && this.selectedItems[0];
2599
- this.searchTerm = (selected && selected.label) || null;
2598
+ const selected = this.selectedItems?.[0];
2599
+ this.searchTerm = selected?.label ?? null;
2600
2600
  }
2601
2601
  _setItems(items) {
2602
2602
  const firstItem = items[0];
@@ -2891,17 +2891,33 @@ class NgSelectComponent {
2891
2891
  this.addTagText = this.addTagText || config.addTagText;
2892
2892
  this.loadingText = this.loadingText || config.loadingText;
2893
2893
  this.clearAllText = this.clearAllText || config.clearAllText;
2894
- this.virtualScroll = isDefined(this.virtualScroll)
2895
- ? this.virtualScroll
2896
- : isDefined(config.disableVirtualScroll)
2897
- ? !config.disableVirtualScroll
2898
- : false;
2894
+ this.virtualScroll = this.getVirtualScroll(config);
2899
2895
  this.openOnEnter = isDefined(this.openOnEnter) ? this.openOnEnter : config.openOnEnter;
2900
2896
  this.appendTo = this.appendTo || config.appendTo;
2901
2897
  this.bindValue = this.bindValue || config.bindValue;
2902
2898
  this.bindLabel = this.bindLabel || config.bindLabel;
2903
2899
  this.appearance = this.appearance || config.appearance;
2904
2900
  }
2901
+ /**
2902
+ * Gets virtual scroll value from input or from config
2903
+ *
2904
+ * @param config NgSelectConfig object
2905
+ *
2906
+ * @returns `true` if virtual scroll is enabled, `false` otherwise
2907
+ */
2908
+ getVirtualScroll(config) {
2909
+ return isDefined(this.virtualScroll) ? this.virtualScroll : this.isVirtualScrollDisabled(config);
2910
+ }
2911
+ /**
2912
+ * Gets disableVirtualScroll value from input or from config
2913
+ *
2914
+ * @param config NgSelectConfig object
2915
+ *
2916
+ * @returns `true` if disableVirtualScroll is enabled, `false` otherwise
2917
+ */
2918
+ isVirtualScrollDisabled(config) {
2919
+ return isDefined(config.disableVirtualScroll) ? !config.disableVirtualScroll : false;
2920
+ }
2905
2921
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgSelectComponent, deps: [{ token: 'class', attribute: true }, { token: 'autofocus', attribute: true }, { token: NgSelectConfig }, { token: SELECTION_MODEL_FACTORY, optional: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: ConsoleService }], target: i0.ɵɵFactoryTarget.Component }); }
2906
2922
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: NgSelectComponent, isStandalone: true, selector: "ng-select", inputs: { ariaLabelDropdown: { classPropertyName: "ariaLabelDropdown", publicName: "ariaLabelDropdown", isSignal: false, isRequired: false, transformFunction: null }, bindLabel: { classPropertyName: "bindLabel", publicName: "bindLabel", isSignal: false, isRequired: false, transformFunction: null }, bindValue: { classPropertyName: "bindValue", publicName: "bindValue", isSignal: false, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: false, isRequired: false, transformFunction: null }, markFirst: { classPropertyName: "markFirst", publicName: "markFirst", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, fixedPlaceholder: { classPropertyName: "fixedPlaceholder", publicName: "fixedPlaceholder", isSignal: false, isRequired: false, transformFunction: null }, notFoundText: { classPropertyName: "notFoundText", publicName: "notFoundText", isSignal: false, isRequired: false, transformFunction: null }, typeToSearchText: { classPropertyName: "typeToSearchText", publicName: "typeToSearchText", isSignal: false, isRequired: false, transformFunction: null }, preventToggleOnRightClick: { classPropertyName: "preventToggleOnRightClick", publicName: "preventToggleOnRightClick", isSignal: false, isRequired: false, transformFunction: null }, addTagText: { classPropertyName: "addTagText", publicName: "addTagText", isSignal: false, isRequired: false, transformFunction: null }, loadingText: { classPropertyName: "loadingText", publicName: "loadingText", isSignal: false, isRequired: false, transformFunction: null }, clearAllText: { classPropertyName: "clearAllText", publicName: "clearAllText", isSignal: false, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: false, isRequired: false, transformFunction: null }, dropdownPosition: { classPropertyName: "dropdownPosition", publicName: "dropdownPosition", isSignal: false, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: false, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, hideSelected: { classPropertyName: "hideSelected", publicName: "hideSelected", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, selectOnTab: { classPropertyName: "selectOnTab", publicName: "selectOnTab", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, openOnEnter: { classPropertyName: "openOnEnter", publicName: "openOnEnter", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, maxSelectedItems: { classPropertyName: "maxSelectedItems", publicName: "maxSelectedItems", isSignal: false, isRequired: false, transformFunction: numberAttribute }, groupBy: { classPropertyName: "groupBy", publicName: "groupBy", isSignal: false, isRequired: false, transformFunction: null }, groupValue: { classPropertyName: "groupValue", publicName: "groupValue", isSignal: false, isRequired: false, transformFunction: null }, bufferAmount: { classPropertyName: "bufferAmount", publicName: "bufferAmount", isSignal: false, isRequired: false, transformFunction: numberAttribute }, virtualScroll: { classPropertyName: "virtualScroll", publicName: "virtualScroll", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, selectableGroup: { classPropertyName: "selectableGroup", publicName: "selectableGroup", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, selectableGroupAsModel: { classPropertyName: "selectableGroupAsModel", publicName: "selectableGroupAsModel", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, searchFn: { classPropertyName: "searchFn", publicName: "searchFn", isSignal: false, isRequired: false, transformFunction: null }, trackByFn: { classPropertyName: "trackByFn", publicName: "trackByFn", isSignal: false, isRequired: false, transformFunction: null }, clearOnBackspace: { classPropertyName: "clearOnBackspace", publicName: "clearOnBackspace", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, labelForId: { classPropertyName: "labelForId", publicName: "labelForId", isSignal: false, isRequired: false, transformFunction: null }, inputAttrs: { classPropertyName: "inputAttrs", publicName: "inputAttrs", isSignal: false, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "tabIndex", isSignal: false, isRequired: false, transformFunction: numberAttribute }, tabFocusOnClearButton: { classPropertyName: "tabFocusOnClearButton", publicName: "tabFocusOnClearButton", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, searchWhileComposing: { classPropertyName: "searchWhileComposing", publicName: "searchWhileComposing", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, minTermLength: { classPropertyName: "minTermLength", publicName: "minTermLength", isSignal: false, isRequired: false, transformFunction: numberAttribute }, editableSearchTerm: { classPropertyName: "editableSearchTerm", publicName: "editableSearchTerm", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, ngClass: { classPropertyName: "ngClass", publicName: "ngClass", isSignal: false, isRequired: false, transformFunction: null }, typeahead: { classPropertyName: "typeahead", publicName: "typeahead", isSignal: false, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, addTag: { classPropertyName: "addTag", publicName: "addTag", isSignal: false, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: false, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: false, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: false, isRequired: false, transformFunction: null }, clearSearchOnAdd: { classPropertyName: "clearSearchOnAdd", publicName: "clearSearchOnAdd", isSignal: false, isRequired: false, transformFunction: null }, deselectOnClick: { classPropertyName: "deselectOnClick", publicName: "deselectOnClick", isSignal: false, isRequired: false, transformFunction: null }, keyDownFn: { classPropertyName: "keyDownFn", publicName: "keyDownFn", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { blurEvent: "blur", focusEvent: "focus", changeEvent: "change", openEvent: "open", closeEvent: "close", searchEvent: "search", clearEvent: "clear", addEvent: "add", removeEvent: "remove", scroll: "scroll", scrollToEnd: "scrollToEnd" }, host: { listeners: { "keydown": "handleKeyDown($event)" }, properties: { "class.ng-select-typeahead": "this.typeahead", "class.ng-select-multiple": "this.multiple", "class.ng-select-taggable": "this.addTag", "class.ng-select-searchable": "this.searchable", "class.ng-select-clearable": "this.clearable", "class.ng-select-opened": "this.isOpen", "class.ng-select": "this.useDefaultClass", "class.ng-select-filtered": "this.filtered", "class.ng-select-single": "this.single", "class.ng-select-disabled": "this.disabled" } }, providers: [
2907
2923
  {