cps-ui-kit 17.15.0 → 17.16.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.
@@ -2599,32 +2599,6 @@ class CpsBaseTreeDropdownComponent {
2599
2599
  this.treeContainerElement?.removeEventListener('click', this._handleOnContainerClick.bind(this));
2600
2600
  this.resizeObserver?.disconnect();
2601
2601
  }
2602
- _initContainerClickListener() {
2603
- this.treeContainerElement =
2604
- this.treeList?.el?.nativeElement?.querySelector('.p-tree-container');
2605
- if (this.treeContainerElement) {
2606
- this.treeContainerElement.addEventListener('click', this._handleOnContainerClick.bind(this));
2607
- }
2608
- }
2609
- _handleOnContainerClick(event) {
2610
- function getParentWithClass(element, className) {
2611
- let currentElement = element;
2612
- while (currentElement) {
2613
- if (currentElement.classList.contains(className)) {
2614
- return currentElement;
2615
- }
2616
- currentElement = currentElement.parentElement;
2617
- }
2618
- return null;
2619
- }
2620
- this.optionFocused = true;
2621
- const elem = event.target.classList.contains('p-treenode-content')
2622
- ? event.target
2623
- : getParentWithClass(event.target, 'p-treenode-content');
2624
- if (elem?.parentElement?.classList?.contains('cps-tree-node-fully-expandable')) {
2625
- this.onClickFullyExpandable(elem);
2626
- }
2627
- }
2628
2602
  registerOnChange(fn) {
2629
2603
  this.onChange = fn;
2630
2604
  }
@@ -2637,11 +2611,34 @@ class CpsBaseTreeDropdownComponent {
2637
2611
  this.treeSelection = this._valueToTreeSelection(this.value);
2638
2612
  }
2639
2613
  }
2614
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2615
+ setDisabledState(disabled) { }
2616
+ onBlur() {
2617
+ this.control?.control?.markAsTouched();
2618
+ this._checkErrors();
2619
+ }
2620
+ focus() {
2621
+ this.componentContainer?.nativeElement?.focus();
2622
+ this.toggleOptions(true);
2623
+ }
2640
2624
  updateValue(value) {
2641
2625
  this.writeValue(value, true);
2642
2626
  this.onChange(value);
2643
2627
  this.valueChanged.emit(value);
2644
2628
  }
2629
+ clear(event) {
2630
+ event?.stopPropagation();
2631
+ if ((!this.multiple && this.treeSelection) ||
2632
+ (this.multiple && this.treeSelection?.length > 0)) {
2633
+ if (this.openOnClear) {
2634
+ this.toggleOptions(true);
2635
+ }
2636
+ const val = this.multiple ? [] : undefined;
2637
+ this.treeSelection = val;
2638
+ this.updateValue(val);
2639
+ }
2640
+ this.optionFocused = false;
2641
+ }
2645
2642
  onSelectNode() {
2646
2643
  if (!this.multiple) {
2647
2644
  this.toggleOptions(false);
@@ -2661,17 +2658,6 @@ class CpsBaseTreeDropdownComponent {
2661
2658
  this._nodeToggled(elem);
2662
2659
  });
2663
2660
  }
2664
- _getHTMLElementKey(elem) {
2665
- if (!elem?.classList)
2666
- return '';
2667
- const classList = [...elem.classList];
2668
- const key = classList.find((className) => {
2669
- return className.startsWith('key-');
2670
- });
2671
- if (!key)
2672
- return '';
2673
- return key.replace('key-', '');
2674
- }
2675
2661
  treeSelectionChanged(selection) {
2676
2662
  this.updateValue(this.treeSelectionToValue(selection));
2677
2663
  }
@@ -2751,6 +2737,65 @@ class CpsBaseTreeDropdownComponent {
2751
2737
  this.optionFocused = true;
2752
2738
  }
2753
2739
  }
2740
+ onNodeExpand(event) {
2741
+ this._nodeToggledWithChevron(event?.originalEvent?.currentTarget?.parentElement);
2742
+ }
2743
+ onNodeCollapse(event) {
2744
+ this._nodeToggledWithChevron(event?.originalEvent?.currentTarget?.parentElement);
2745
+ }
2746
+ treeSelectionToValue(selection) {
2747
+ if (!selection)
2748
+ return this.multiple ? [] : undefined;
2749
+ if (this.multiple) {
2750
+ return selection.map((s) => this.originalOptionsMap.get(s.key));
2751
+ }
2752
+ else {
2753
+ return this.originalOptionsMap.get(selection.key);
2754
+ }
2755
+ }
2756
+ // this is a fix of primeng change detection bug when virtual scroller is enabled
2757
+ updateOptions() {
2758
+ if (!this.virtualScroll)
2759
+ return;
2760
+ this.treeList?.updateSerializedValue();
2761
+ }
2762
+ _initContainerClickListener() {
2763
+ this.treeContainerElement =
2764
+ this.treeList?.el?.nativeElement?.querySelector('.p-tree-container');
2765
+ if (this.treeContainerElement) {
2766
+ this.treeContainerElement.addEventListener('click', this._handleOnContainerClick.bind(this));
2767
+ }
2768
+ }
2769
+ _handleOnContainerClick(event) {
2770
+ function getParentWithClass(element, className) {
2771
+ let currentElement = element;
2772
+ while (currentElement) {
2773
+ if (currentElement.classList.contains(className)) {
2774
+ return currentElement;
2775
+ }
2776
+ currentElement = currentElement.parentElement;
2777
+ }
2778
+ return null;
2779
+ }
2780
+ this.optionFocused = true;
2781
+ const elem = event.target.classList.contains('p-treenode-content')
2782
+ ? event.target
2783
+ : getParentWithClass(event.target, 'p-treenode-content');
2784
+ if (elem?.parentElement?.classList?.contains('cps-tree-node-fully-expandable')) {
2785
+ this.onClickFullyExpandable(elem);
2786
+ }
2787
+ }
2788
+ _getHTMLElementKey(elem) {
2789
+ if (!elem?.classList)
2790
+ return '';
2791
+ const classList = [...elem.classList];
2792
+ const key = classList.find((className) => {
2793
+ return className.startsWith('key-');
2794
+ });
2795
+ if (!key)
2796
+ return '';
2797
+ return key.replace('key-', '');
2798
+ }
2754
2799
  _setTreeListHeight(height) {
2755
2800
  if (this.treeList?.scroller?.style)
2756
2801
  this.treeList.scroller.style.height = height;
@@ -2768,25 +2813,6 @@ class CpsBaseTreeDropdownComponent {
2768
2813
  // fix primeng tree event stop propagation
2769
2814
  this.optionsMenu.selfClick = false;
2770
2815
  }
2771
- onNodeExpand(event) {
2772
- this._nodeToggledWithChevron(event?.originalEvent?.currentTarget?.parentElement);
2773
- }
2774
- onNodeCollapse(event) {
2775
- this._nodeToggledWithChevron(event?.originalEvent?.currentTarget?.parentElement);
2776
- }
2777
- clear(event) {
2778
- event.stopPropagation();
2779
- if ((!this.multiple && this.treeSelection) ||
2780
- (this.multiple && this.treeSelection?.length > 0)) {
2781
- if (this.openOnClear) {
2782
- this.toggleOptions(true);
2783
- }
2784
- const val = this.multiple ? [] : undefined;
2785
- this.treeSelection = val;
2786
- this.updateValue(val);
2787
- }
2788
- this.optionFocused = false;
2789
- }
2790
2816
  _checkErrors() {
2791
2817
  const errors = this.control?.errors;
2792
2818
  if (!this.control?.control?.touched || !errors) {
@@ -2805,16 +2831,6 @@ class CpsBaseTreeDropdownComponent {
2805
2831
  const message = errArr.find((msg) => typeof msg === 'string');
2806
2832
  this.error = message || 'Unknown error';
2807
2833
  }
2808
- // eslint-disable-next-line @typescript-eslint/no-empty-function
2809
- setDisabledState(disabled) { }
2810
- onBlur() {
2811
- this.control?.control?.markAsTouched();
2812
- this._checkErrors();
2813
- }
2814
- focus() {
2815
- this.componentContainer?.nativeElement?.focus();
2816
- this.toggleOptions(true);
2817
- }
2818
2834
  _expandToNodes(nodes) {
2819
2835
  function getParentKey(key) {
2820
2836
  const lastSeparatorIndex = key.lastIndexOf('-');
@@ -2877,16 +2893,6 @@ class CpsBaseTreeDropdownComponent {
2877
2893
  }
2878
2894
  return nodeMap;
2879
2895
  }
2880
- treeSelectionToValue(selection) {
2881
- if (!selection)
2882
- return this.multiple ? [] : undefined;
2883
- if (this.multiple) {
2884
- return selection.map((s) => this.originalOptionsMap.get(s.key));
2885
- }
2886
- else {
2887
- return this.originalOptionsMap.get(selection.key);
2888
- }
2889
- }
2890
2896
  _valueToTreeSelection(value) {
2891
2897
  function getKey(v, map) {
2892
2898
  for (const [key, val] of map.entries()) {
@@ -2912,12 +2918,6 @@ class CpsBaseTreeDropdownComponent {
2912
2918
  return key ? this.optionsMap.get(key) : undefined;
2913
2919
  }
2914
2920
  }
2915
- // this is a fix of primeng change detection bug when virtual scroller is enabled
2916
- updateOptions() {
2917
- if (!this.virtualScroll)
2918
- return;
2919
- this.treeList?.updateSerializedValue();
2920
- }
2921
2921
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: CpsBaseTreeDropdownComponent, deps: [{ token: i1.NgControl, optional: true, self: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
2922
2922
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.0", type: CpsBaseTreeDropdownComponent, selector: "ng-component", inputs: { label: "label", hint: "hint", multiple: "multiple", disabled: "disabled", width: "width", chips: "chips", closableChips: "closableChips", clearable: "clearable", openOnClear: "openOnClear", optionLabel: "optionLabel", optionInfo: "optionInfo", hideDetails: "hideDetails", persistentClear: "persistentClear", prefixIcon: "prefixIcon", prefixIconSize: "prefixIconSize", loading: "loading", virtualScroll: "virtualScroll", numToleratedItems: "numToleratedItems", infoTooltip: "infoTooltip", infoTooltipClass: "infoTooltipClass", infoTooltipMaxWidth: "infoTooltipMaxWidth", infoTooltipPersistent: "infoTooltipPersistent", infoTooltipPosition: "infoTooltipPosition", initialExpandDirectories: "initialExpandDirectories", initialExpandAll: "initialExpandAll", showChevron: "showChevron", options: "options", _value: ["value", "_value"] }, outputs: { valueChanged: "valueChanged" }, viewQueries: [{ propertyName: "componentContainer", first: true, predicate: ["componentContainer"], descendants: true }, { propertyName: "optionsMenu", first: true, predicate: ["optionsMenu"], descendants: true }, { propertyName: "treeList", first: true, predicate: ["treeList"], descendants: true }, { propertyName: "boxEl", first: true, predicate: ["boxEl"], descendants: true }], ngImport: i0, template: '', isInline: true }); }
2923
2923
  }
@@ -3994,28 +3994,6 @@ class CpsTreeAutocompleteComponent extends CpsBaseTreeDropdownComponent {
3994
3994
  this.focusInput();
3995
3995
  }, 0);
3996
3996
  }
3997
- _select(option) {
3998
- function includes(array, val) {
3999
- return array?.some((item) => isEqual(item, val)) || false;
4000
- }
4001
- this.backspaceClickedOnce = false;
4002
- if (this.multiple) {
4003
- if (includes(this.treeSelection, option)) {
4004
- this.treeSelection = this.treeSelection.filter((v) => !isEqual(v, option));
4005
- }
4006
- else {
4007
- this.treeSelection.push(option);
4008
- }
4009
- }
4010
- else {
4011
- this.treeSelection = option;
4012
- }
4013
- this.updateValue(this.treeSelectionToValue(this.treeSelection));
4014
- this._clearInput();
4015
- setTimeout(() => {
4016
- this.focusInput();
4017
- }, 0);
4018
- }
4019
3997
  clear(event) {
4020
3998
  super.clear(event);
4021
3999
  this._clearInput();
@@ -4044,6 +4022,28 @@ class CpsTreeAutocompleteComponent extends CpsBaseTreeDropdownComponent {
4044
4022
  else
4045
4023
  this.treeList._filter(searchVal);
4046
4024
  }
4025
+ _select(option) {
4026
+ function includes(array, val) {
4027
+ return array?.some((item) => isEqual(item, val)) || false;
4028
+ }
4029
+ this.backspaceClickedOnce = false;
4030
+ if (this.multiple) {
4031
+ if (includes(this.treeSelection, option)) {
4032
+ this.treeSelection = this.treeSelection.filter((v) => !isEqual(v, option));
4033
+ }
4034
+ else {
4035
+ this.treeSelection.push(option);
4036
+ }
4037
+ }
4038
+ else {
4039
+ this.treeSelection = option;
4040
+ }
4041
+ this.updateValue(this.treeSelectionToValue(this.treeSelection));
4042
+ this._clearInput();
4043
+ setTimeout(() => {
4044
+ this.focusInput();
4045
+ }, 0);
4046
+ }
4047
4047
  _getValueLabel() {
4048
4048
  return this.treeSelection?.label || '';
4049
4049
  }