@coolon/angular-ui-powerups 16.1.0-alpha.262 → 16.1.0-alpha.263

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,5 +1,5 @@
1
- import { OnInit, TemplateRef, TrackByFunction } from '@angular/core';
2
- import { BooleanValueModelChain, ListModel, ListModelChain } from '@coolon/pectin';
1
+ import { AfterViewChecked, DoCheck, OnInit, TemplateRef, TrackByFunction } from '@angular/core';
2
+ import { BooleanValueModelChain, ListModel, ListModelChain, MutableValueModel, Predicate } from '@coolon/pectin';
3
3
  import { AbstractValueInputComponent } from '../abstract-value-input.component';
4
4
  import * as i0 from "@angular/core";
5
5
  /**
@@ -9,8 +9,18 @@ import * as i0 from "@angular/core";
9
9
  * <ng-template #selectedOptionTemplate let-option>{{option.thePropertyYouWant}} note, not used for nils (the placeholder is used)</ng-template>
10
10
  * <ng-template #nilOptionTemplate>Uses the placeholder by default but you can customise it</ng-template>
11
11
  * </aup-select_input>
12
+ *
13
+ * Searching (opt in, off by default so existing usages are unchanged):
14
+ * <aup-select-input [value$]="myModel" [options]="myOptions" [searchable]="true"
15
+ * searchPlaceholder="Find a hero…" noResultsText="No heros match"></aup-select-input>
16
+ * A search box is rendered at the top of the dropdown panel and filters the options client side on
17
+ * optionLabelFormat. Override {@link filterFactory} for different matching, and bind
18
+ * {@link searchText$} to observe or pre-seed the text (it is cleared whenever the panel closes).
19
+ * The nil option is never filtered - it is a clear-the-selection affordance, not a data option.
12
20
  */
13
- export declare class SelectInputComponent<T = any> extends AbstractValueInputComponent<T> implements OnInit {
21
+ export declare class SelectInputComponent<T = any> extends AbstractValueInputComponent<T> implements OnInit, DoCheck, AfterViewChecked {
22
+ /** Keys the search box hands back to MatSelect's key manager instead of consuming itself. */
23
+ private static readonly NAVIGATION_KEYS;
14
24
  accessor options$: ListModel<T>;
15
25
  accessor options: readonly T[];
16
26
  optionLabel: keyof T;
@@ -19,14 +29,76 @@ export declare class SelectInputComponent<T = any> extends AbstractValueInputCom
19
29
  optionTemplateRef: TemplateRef<any>;
20
30
  nilOptionTemplateRef: TemplateRef<any>;
21
31
  optionLabelFormat: (option: T) => any;
32
+ /** Opt-in: renders a search box at the top of the dropdown panel that filters the options. */
33
+ searchable: boolean;
34
+ /** Placeholder for the in-panel search box. {@link FormField} has no slot for this. */
35
+ searchPlaceholder: string;
36
+ /** Shown inside the panel when the search matches nothing. */
37
+ noResultsText: string;
38
+ /** Bindable so a host can pre-seed or observe the search text. Cleared when the panel closes. */
39
+ accessor searchText$: MutableValueModel<string>;
40
+ /**
41
+ * NOTE: deliberately NOT the AutocompleteInputComponent default - there an empty filter matches
42
+ * nothing, here it must match everything or the panel opens blank. It also guards a nil or
43
+ * non-string optionLabelFormat result, which the autocomplete version does not.
44
+ */
45
+ filterFactory: (filterText: string) => Predicate<T>;
22
46
  readonly isNil$: BooleanValueModelChain;
23
47
  private readonly id$;
24
48
  readonly cookedOptions$: ListModelChain<T>;
49
+ /** The options passing the current filter - drives the no-results state. */
50
+ readonly matchingOptions$: ListModelChain<T>;
51
+ /**
52
+ * What the panel renders: the matches, plus the selected option even when it does not match.
53
+ * MatSelect renders `<span class="mat-mdc-select-placeholder">` instead of our <mat-select-trigger>
54
+ * the moment its _selectionModel empties, so dropping the selected <mat-option> would blank the
55
+ * field's displayed value while the user types. It is rendered disabled + display:none instead
56
+ * (disabled is what MatSelect's keyManager skipPredicate reads, so arrow navigation skips it).
57
+ */
58
+ readonly panelOptions$: ListModelChain<T>;
59
+ readonly noMatches$: BooleanValueModelChain;
60
+ /** MatSelect._canOpen() refuses to open with zero options, so the filter is inert while closed. */
61
+ private readonly panelOpen$;
62
+ private focusSearchPending;
63
+ private readonly filterPredicate$;
64
+ private searchInputRef;
65
+ private matSelect;
25
66
  private readonly delegatedIdentityOf;
26
67
  readonly trackByIdentity: TrackByFunction<T>;
27
68
  constructor();
28
69
  select(item: T): void;
70
+ /**
71
+ * True when the option is only in {@link panelOptions$} to keep MatSelect's selection model
72
+ * populated. The template renders it disabled and display:none.
73
+ */
74
+ isHiddenOption(option: T): boolean;
75
+ /**
76
+ * MatSelect's (opened)/(closed) outputs are driven by its panel animation: the template holds
77
+ * [@transformPanel] at a constant 'showing', and ngOnInit pipes (@transformPanel.done) through
78
+ * distinctUntilChanged(). When the CDK detaches the overlay before the leave animation completes
79
+ * - which is exactly what its ESCAPE handling does - the 'void' is never emitted, so the next
80
+ * open's 'showing' is deduped away and BOTH outputs silently stop firing for good. A stale filter
81
+ * surviving a close would then wedge the select shut (MatSelect._canOpen() needs options.length),
82
+ * so the panel state is tracked from _panelOpen, which open()/close() set synchronously.
83
+ */
84
+ ngDoCheck(): void;
85
+ /** The search box only exists in the DOM once the overlay has attached, hence the retry flag. */
86
+ ngAfterViewChecked(): void;
87
+ clearSearch(): void;
88
+ onSearchInput(event: Event): void;
89
+ /**
90
+ * MatSelect listens for keydown on the panel div and our search box sits inside it, so every
91
+ * keystroke bubbles into _handleOpenKeydown. Everything the text box owns is stopped; the
92
+ * navigation keys are let through to MatSelect's key manager. Because every printable key is
93
+ * stopped, manager.isTyping() stays false - which is what makes MatSelect treat Enter as
94
+ * "select the active option" rather than as part of its own typeahead.
95
+ */
96
+ onSearchKeydown(event: KeyboardEvent): void;
97
+ notifyFocusIn(): void;
98
+ notifyFocusOut(): void;
99
+ private matchesSearch;
100
+ private isSelectedOption;
29
101
  ngOnInit(): void;
30
102
  static ɵfac: i0.ɵɵFactoryDeclaration<SelectInputComponent<any>, never>;
31
- static ɵcmp: i0.ɵɵComponentDeclaration<SelectInputComponent<any>, "aup-select-input", never, { "options$": { "alias": "options$"; "required": false; }; "options": { "alias": "options"; "required": false; }; "optionLabel": { "alias": "optionLabel"; "required": false; }; "allowNil": { "alias": "allowNil"; "required": false; }; "optionLabelFormat": { "alias": "optionLabelFormat"; "required": false; }; }, {}, ["selectedOptionTemplateRef", "optionTemplateRef", "nilOptionTemplateRef"], ["[select-option-footer]"], false, never>;
103
+ static ɵcmp: i0.ɵɵComponentDeclaration<SelectInputComponent<any>, "aup-select-input", never, { "options$": { "alias": "options$"; "required": false; }; "options": { "alias": "options"; "required": false; }; "optionLabel": { "alias": "optionLabel"; "required": false; }; "allowNil": { "alias": "allowNil"; "required": false; }; "optionLabelFormat": { "alias": "optionLabelFormat"; "required": false; }; "searchable": { "alias": "searchable"; "required": false; }; "searchPlaceholder": { "alias": "searchPlaceholder"; "required": false; }; "noResultsText": { "alias": "noResultsText"; "required": false; }; "searchText$": { "alias": "searchText$"; "required": false; }; "filterFactory": { "alias": "filterFactory"; "required": false; }; }, {}, ["selectedOptionTemplateRef", "optionTemplateRef", "nilOptionTemplateRef"], ["[select-option-footer]"], false, never>;
32
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolon/angular-ui-powerups",
3
- "version": "16.1.0-alpha.262",
3
+ "version": "16.1.0-alpha.263",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.9",
6
6
  "@angular/common": "^16.2.9",