asksuite-citrus 3.20.5 → 3.20.7

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.
@@ -1,11 +1,13 @@
1
- import { ElementRef, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
1
+ import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
2
2
  import { ControlValueAccessor } from '@angular/forms';
3
3
  import { SelectV2Option } from '../select-v2/select-v2.component';
4
4
  import { MenuSpacing } from '../menu/menu.component';
5
5
  import { CompareWithFn } from '../select-v2/base-multi-select';
6
6
  import * as i0 from "@angular/core";
7
- export declare class ComboboxV2Component implements ControlValueAccessor, OnChanges {
7
+ export declare class ComboboxV2Component implements ControlValueAccessor, OnChanges, AfterViewInit, OnDestroy {
8
8
  private elementRef;
9
+ private zone;
10
+ private cdr;
9
11
  value: any;
10
12
  options: SelectV2Option[];
11
13
  placeholder: string;
@@ -16,18 +18,30 @@ export declare class ComboboxV2Component implements ControlValueAccessor, OnChan
16
18
  menuSpacing: MenuSpacing;
17
19
  multiple: boolean;
18
20
  maxTagWidth: number;
19
- overflowThreshold: number;
21
+ /**
22
+ * @deprecated Chips now auto-fit the available trigger width. When set, acts as a
23
+ * hard CAP: shows at most this many chips even if more would fit.
24
+ */
25
+ overflowThreshold?: number;
20
26
  compareWith: CompareWithFn<any>;
21
27
  valueChange: EventEmitter<any>;
22
28
  selectionChange: EventEmitter<any>;
23
29
  menuSearchInput?: ElementRef<HTMLInputElement>;
30
+ private tagGroupRef?;
31
+ private measureRowRef?;
24
32
  search: string;
25
33
  showList: boolean;
26
34
  /** Index (within filteredOptions) of the keyboard-highlighted option; -1 = none. */
27
35
  activeIndex: number;
28
36
  /** Multi mode only — internal source of truth. */
29
37
  selectedValues: any[];
30
- constructor(elementRef: ElementRef);
38
+ /** null = not measured yet → show all (clipped by overflow:hidden for a frame at most). */
39
+ private fitCount;
40
+ private measurer;
41
+ constructor(elementRef: ElementRef, zone: NgZone, cdr: ChangeDetectorRef);
42
+ ngAfterViewInit(): void;
43
+ ngOnDestroy(): void;
44
+ private readChipMeasurement;
31
45
  ngOnChanges(changes: SimpleChanges): void;
32
46
  get selectedOption(): SelectV2Option | undefined;
33
47
  get selectedOptions(): SelectV2Option[];
@@ -12,6 +12,20 @@ export declare function computeOverflow<T>(values: T[], threshold: number): {
12
12
  visible: T[];
13
13
  overflowCount: number;
14
14
  };
15
+ /** Keep in sync with `gap: 4px` on `__tag-group` in select-v2 / combobox-v2 scss. */
16
+ export declare const CHIP_GAP_PX = 4;
17
+ export interface WidthOverflowResult {
18
+ visibleCount: number;
19
+ overflowCount: number;
20
+ }
21
+ /**
22
+ * Fits as many chips as possible in `containerWidth` (greedy, in order).
23
+ * - When ALL chips fit, no space is reserved for the `+N` chip.
24
+ * - Otherwise reserves `plusNWidth` and packs chips until the next one wouldn't fit.
25
+ * - Always keeps at least 1 chip visible — when even `chip[0] + gap + plusN` doesn't
26
+ * fit, CSS degrades gracefully (the chip ellipsizes, the group clips overflow).
27
+ */
28
+ export declare function computeWidthOverflow(chipWidths: number[], containerWidth: number, gap: number, plusNWidth: number): WidthOverflowResult;
15
29
  /** Normalizes the value coming from `writeValue`/`@Input value` into an internal array. */
16
30
  export declare function rehydrate<T>(raw: T | T[] | null | undefined, multiple: boolean): T[];
17
31
  /** Converts the internal array back to the shape consumers expect (scalar vs array). */
@@ -0,0 +1,32 @@
1
+ import { NgZone } from '@angular/core';
2
+ export interface ChipMeasurement {
3
+ containerWidth: number;
4
+ chipWidths: number[];
5
+ plusNWidth: number;
6
+ }
7
+ /**
8
+ * Shared by `ask-select-v2` and `ask-combobox-v2`: watches the trigger width and
9
+ * recomputes how many chips fit, outside the Angular zone. Re-enters the zone only
10
+ * when the fitted count actually changes — this keeps ResizeObserver/rAF callbacks
11
+ * from churning change detection or creating measure→render→measure loops.
12
+ */
13
+ export declare class ChipOverflowMeasurer {
14
+ private zone;
15
+ /** Reads the DOM. Return null when there's nothing to measure (e.g. single mode). */
16
+ private read;
17
+ /** Called inside the zone, only when the fitted count changes. */
18
+ private apply;
19
+ private resizeObserver?;
20
+ private rafId;
21
+ private lastApplied;
22
+ constructor(zone: NgZone,
23
+ /** Reads the DOM. Return null when there's nothing to measure (e.g. single mode). */
24
+ read: () => ChipMeasurement | null,
25
+ /** Called inside the zone, only when the fitted count changes. */
26
+ apply: (visibleCount: number) => void);
27
+ observe(container: HTMLElement): void;
28
+ /** rAF-debounced so a selection change + resize coalesce into one measurement. */
29
+ schedule(): void;
30
+ private measureNow;
31
+ destroy(): void;
32
+ }
@@ -1,4 +1,4 @@
1
- import { ElementRef, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
1
+ import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
2
2
  import { ControlValueAccessor } from '@angular/forms';
3
3
  import { MenuSpacing } from '../menu/menu.component';
4
4
  import { CompareWithFn } from './base-multi-select';
@@ -8,8 +8,10 @@ export interface SelectV2Option {
8
8
  label: string;
9
9
  disabled?: boolean;
10
10
  }
11
- export declare class SelectV2Component implements ControlValueAccessor, OnChanges {
11
+ export declare class SelectV2Component implements ControlValueAccessor, OnChanges, AfterViewInit, OnDestroy {
12
12
  private elementRef;
13
+ private zone;
14
+ private cdr;
13
15
  value: any;
14
16
  options: SelectV2Option[];
15
17
  placeholder: string;
@@ -21,15 +23,27 @@ export declare class SelectV2Component implements ControlValueAccessor, OnChange
21
23
  /** Multi-select mode: trigger shows tags + `+N` overflow, menu items toggle on click. */
22
24
  multiple: boolean;
23
25
  maxTagWidth: number;
24
- overflowThreshold: number;
26
+ /**
27
+ * @deprecated Chips now auto-fit the available trigger width. When set, acts as a
28
+ * hard CAP: shows at most this many chips even if more would fit.
29
+ */
30
+ overflowThreshold?: number;
25
31
  compareWith: CompareWithFn<any>;
26
32
  valueChange: EventEmitter<any>;
27
33
  selectionChange: EventEmitter<any>;
28
34
  showList: boolean;
29
35
  /** Multi mode only — internal source of truth. Single mode keeps using `value`. */
30
36
  selectedValues: any[];
31
- constructor(elementRef: ElementRef);
37
+ private tagGroupRef?;
38
+ private measureRowRef?;
39
+ /** null = not measured yet → show all (clipped by overflow:hidden for a frame at most). */
40
+ private fitCount;
41
+ private measurer;
42
+ constructor(elementRef: ElementRef, zone: NgZone, cdr: ChangeDetectorRef);
32
43
  ngOnChanges(changes: SimpleChanges): void;
44
+ ngAfterViewInit(): void;
45
+ ngOnDestroy(): void;
46
+ private readChipMeasurement;
33
47
  get selectedOption(): SelectV2Option | undefined;
34
48
  /** Multi mode: ordered list of selected options resolved against `options`. */
35
49
  get selectedOptions(): SelectV2Option[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asksuite-citrus",
3
- "version": "3.20.5",
3
+ "version": "3.20.7",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^17.3.7",
6
6
  "@angular/core": "^17.3.7",