@spartan-ng/brain 0.0.1-alpha.613 → 0.0.1-alpha.628

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.
@@ -56,6 +56,7 @@ type AutocompleteItemToString<T> = (itemValue: T) => string;
56
56
  interface BrnAutocompleteConfig<T> {
57
57
  isItemEqualToValue: AutocompleteItemEqualToValue<T>;
58
58
  itemToString?: AutocompleteItemToString<T>;
59
+ autoHighlight: boolean;
59
60
  }
60
61
  declare function provideBrnAutocompleteConfig<T>(config: Partial<BrnAutocompleteConfig<T>>): ValueProvider;
61
62
  declare function injectBrnAutocompleteConfig<T>(): BrnAutocompleteConfig<T>;
@@ -79,6 +80,8 @@ declare class BrnAutocomplete<T> implements BrnAutocompleteBase<T>, ControlValue
79
80
  readonly isItemEqualToValue: _angular_core.InputSignal<AutocompleteItemEqualToValue<T>>;
80
81
  /** A function to convert an item to a string for display. */
81
82
  readonly itemToString: _angular_core.InputSignal<AutocompleteItemToString<T> | undefined>;
83
+ /** Whether to auto-highlight the first matching item. */
84
+ readonly autoHighlight: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
82
85
  /** The selected value of the autocomplete. */
83
86
  readonly value: _angular_core.ModelSignal<T | null>;
84
87
  /** The current search query. */
@@ -112,7 +115,7 @@ declare class BrnAutocomplete<T> implements BrnAutocompleteBase<T>, ControlValue
112
115
  registerOnTouched(fn: TouchFn): void;
113
116
  setDisabledState(isDisabled: boolean): void;
114
117
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnAutocomplete<any>, never>;
115
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnAutocomplete<any>, "[brnAutocomplete]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "isItemEqualToValue": { "alias": "isItemEqualToValue"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
118
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnAutocomplete<any>, "[brnAutocomplete]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "isItemEqualToValue": { "alias": "isItemEqualToValue"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "autoHighlight": { "alias": "autoHighlight"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
116
119
  }
117
120
 
118
121
  declare class BrnAutocompleteAnchor {
@@ -219,6 +222,8 @@ declare class BrnAutocompleteSearch<T> implements BrnAutocompleteBase<T>, Contro
219
222
  readonly disabledState: _angular_core.Signal<boolean>;
220
223
  /** A function to convert an item to a string for display. */
221
224
  readonly itemToString: _angular_core.InputSignal<AutocompleteItemToString<T> | undefined>;
225
+ /** Whether to auto-highlight the first matching item. */
226
+ readonly autoHighlight: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
222
227
  /** The selected value of the autocomplete. */
223
228
  readonly value: _angular_core.ModelSignal<string | null>;
224
229
  /** The current search query. */
@@ -252,7 +257,7 @@ declare class BrnAutocompleteSearch<T> implements BrnAutocompleteBase<T>, Contro
252
257
  registerOnTouched(fn: TouchFn): void;
253
258
  setDisabledState(isDisabled: boolean): void;
254
259
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnAutocompleteSearch<any>, never>;
255
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnAutocompleteSearch<any>, "[brnAutocomplete]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
260
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnAutocompleteSearch<any>, "[brnAutocomplete]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "autoHighlight": { "alias": "autoHighlight"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
256
261
  }
257
262
 
258
263
  declare class BrnAutocompleteSeparator {
@@ -32,6 +32,7 @@ declare class BrnComboboxItem<T> implements Highlightable {
32
32
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnComboboxItem<any>, "[brnComboboxItem]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": true; "isSignal": true; }; "_disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
33
33
  }
34
34
 
35
+ type ComboboxInputMode = 'combobox' | 'popup';
35
36
  interface BrnComboboxBase<T> {
36
37
  filter: InputSignal<ComboboxFilter<T>>;
37
38
  itemToString: InputSignal<ComboboxItemToString<T> | undefined>;
@@ -44,15 +45,19 @@ interface BrnComboboxBase<T> {
44
45
  visibleItems: Signal<boolean>;
45
46
  isExpanded: Signal<boolean>;
46
47
  searchInputWrapperWidth: Signal<number | null>;
48
+ mode: Signal<ComboboxInputMode>;
47
49
  isSelected: (itemValue: T) => boolean;
48
50
  select: (itemValue: T) => void;
49
51
  open: () => void;
50
52
  resetValue: () => void;
53
+ resetSearch: () => void;
51
54
  /** Select the active item with Enter key. */
52
55
  selectActiveItem: () => void;
53
56
  /** Remove last selected item with Backspace key. Only works with multiple selection comboboxes. */
54
57
  removeLastSelectedItem: () => void;
55
58
  removeValue: (value: T) => void;
59
+ /** Register the combobox input component for single selection mode */
60
+ registerComboboxInput?: (input: BrnComboboxInput<T>) => void;
56
61
  }
57
62
  declare const BrnComboboxBaseToken: InjectionToken<BrnComboboxBase<unknown>>;
58
63
  declare function provideBrnComboboxBase<T>(instance: Type<BrnComboboxBase<T>>): ExistingProvider;
@@ -75,10 +80,30 @@ interface BrnComboboxConfig<T> {
75
80
  filter: ComboboxFilter<T>;
76
81
  isItemEqualToValue: ComboboxItemEqualToValue<T>;
77
82
  itemToString?: ComboboxItemToString<T>;
83
+ autoHighlight: boolean;
78
84
  }
79
85
  declare function provideBrnComboboxConfig<T>(config: Partial<BrnComboboxConfig<T>>): ValueProvider;
80
86
  declare function injectBrnComboboxConfig<T>(): BrnComboboxConfig<T>;
81
87
 
88
+ declare class BrnComboboxInput<T> {
89
+ private static _id;
90
+ private readonly _el;
91
+ private readonly _combobox;
92
+ private readonly _content;
93
+ readonly mode: _angular_core.Signal<ComboboxInputMode>;
94
+ /** The id of the combobox input */
95
+ readonly id: _angular_core.InputSignal<string>;
96
+ readonly disabled: _angular_core.Signal<boolean>;
97
+ /** Whether the combobox panel is expanded */
98
+ protected readonly _isExpanded: _angular_core.Signal<boolean>;
99
+ constructor();
100
+ protected onInput(event: Event): void;
101
+ /** Listen for keydown events */
102
+ protected onKeyDown(event: KeyboardEvent): void;
103
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnComboboxInput<any>, never>;
104
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnComboboxInput<any>, "input[brnComboboxInput]", ["brnComboboxInput"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
105
+ }
106
+
82
107
  declare const BRN_COMBOBOX_VALUE_ACCESSOR: {
83
108
  provide: _angular_core.InjectionToken<readonly ControlValueAccessor[]>;
84
109
  useExisting: _angular_core.Type<any>;
@@ -104,6 +129,8 @@ declare class BrnCombobox<T> implements BrnComboboxBase<T>, ControlValueAccessor
104
129
  readonly itemToString: _angular_core.InputSignal<ComboboxItemToString<T> | undefined>;
105
130
  /** A custom filter function to use when searching. */
106
131
  readonly filter: _angular_core.InputSignal<ComboboxFilter<T>>;
132
+ /** Whether to auto-highlight the first matching item. */
133
+ readonly autoHighlight: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
107
134
  /** The selected value of the combobox. */
108
135
  readonly value: _angular_core.ModelSignal<T | null>;
109
136
  /** The current search query. */
@@ -119,14 +146,18 @@ declare class BrnCombobox<T> implements BrnComboboxBase<T>, ControlValueAccessor
119
146
  readonly keyManager: ActiveDescendantKeyManager<BrnComboboxItem<T>>;
120
147
  /** @internal Whether the combobox is expanded */
121
148
  readonly isExpanded: _angular_core.Signal<boolean>;
149
+ private readonly _comboboxInput;
150
+ readonly mode: _angular_core.Signal<ComboboxInputMode>;
122
151
  protected _onChange?: ChangeFn<T | null>;
123
152
  protected _onTouched?: TouchFn;
124
153
  constructor();
154
+ registerComboboxInput(input: BrnComboboxInput<T>): void;
125
155
  isSelected(itemValue: T): boolean;
126
156
  select(itemValue: T): void;
127
157
  /** Select the active item with Enter key. */
128
158
  selectActiveItem(): void;
129
159
  resetValue(): void;
160
+ resetSearch(): void;
130
161
  removeValue(_: T): void;
131
162
  removeLastSelectedItem(): void;
132
163
  open(): void;
@@ -137,7 +168,7 @@ declare class BrnCombobox<T> implements BrnComboboxBase<T>, ControlValueAccessor
137
168
  registerOnTouched(fn: TouchFn): void;
138
169
  setDisabledState(isDisabled: boolean): void;
139
170
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCombobox<any>, never>;
140
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCombobox<any>, "[brnCombobox]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "filterOptions": { "alias": "filterOptions"; "required": false; "isSignal": true; }; "isItemEqualToValue": { "alias": "isItemEqualToValue"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "filter": { "alias": "filter"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
171
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCombobox<any>, "[brnCombobox]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "filterOptions": { "alias": "filterOptions"; "required": false; "isSignal": true; }; "isItemEqualToValue": { "alias": "isItemEqualToValue"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "filter": { "alias": "filter"; "required": false; "isSignal": true; }; "autoHighlight": { "alias": "autoHighlight"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
141
172
  }
142
173
 
143
174
  declare class BrnComboboxAnchor {
@@ -222,25 +253,6 @@ declare class BrnComboboxGroup {
222
253
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnComboboxGroup, "[brnComboboxGroup]", never, {}, {}, ["_items", "_label"], never, true, never>;
223
254
  }
224
255
 
225
- declare class BrnComboboxInput<T> {
226
- private static _id;
227
- private readonly _el;
228
- private readonly _combobox;
229
- private readonly _content;
230
- private readonly _mode;
231
- /** The id of the combobox input */
232
- readonly id: _angular_core.InputSignal<string>;
233
- readonly disabled: _angular_core.Signal<boolean>;
234
- /** Whether the combobox panel is expanded */
235
- protected readonly _isExpanded: _angular_core.Signal<boolean>;
236
- constructor();
237
- protected onInput(event: Event): void;
238
- /** Listen for keydown events */
239
- protected onKeyDown(event: KeyboardEvent): void;
240
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnComboboxInput<any>, never>;
241
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnComboboxInput<any>, "input[brnComboboxInput]", ["brnComboboxInput"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
242
- }
243
-
244
256
  declare class BrnComboboxInputWrapper {
245
257
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnComboboxInputWrapper, never>;
246
258
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnComboboxInputWrapper, "[brnComboboxInputWrapper]", never, {}, {}, never, never, true, never>;
@@ -290,6 +302,8 @@ declare class BrnComboboxMultiple<T> implements BrnComboboxBase<T>, ControlValue
290
302
  readonly itemToString: _angular_core.InputSignal<ComboboxItemToString<T> | undefined>;
291
303
  /** A custom filter function to use when searching. */
292
304
  readonly filter: _angular_core.InputSignal<ComboboxFilter<T>>;
305
+ /** Whether to auto-highlight the first matching item. */
306
+ readonly autoHighlight: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
293
307
  /** The selected values of the combobox. */
294
308
  readonly value: _angular_core.ModelSignal<T[] | null>;
295
309
  /** The current search query. */
@@ -304,6 +318,7 @@ declare class BrnComboboxMultiple<T> implements BrnComboboxBase<T>, ControlValue
304
318
  readonly keyManager: ActiveDescendantKeyManager<BrnComboboxItem<T>>;
305
319
  /** @internal Whether the autocomplete is expanded */
306
320
  readonly isExpanded: _angular_core.Signal<boolean>;
321
+ readonly mode: _angular_core.Signal<ComboboxInputMode>;
307
322
  protected _onChange?: ChangeFn<T[] | null>;
308
323
  protected _onTouched?: TouchFn;
309
324
  constructor();
@@ -312,6 +327,7 @@ declare class BrnComboboxMultiple<T> implements BrnComboboxBase<T>, ControlValue
312
327
  /** Select the active item with Enter key. */
313
328
  selectActiveItem(): void;
314
329
  resetValue(): void;
330
+ resetSearch(): void;
315
331
  removeValue(itemValue: T): void;
316
332
  removeLastSelectedItem(): void;
317
333
  open(): void;
@@ -322,7 +338,7 @@ declare class BrnComboboxMultiple<T> implements BrnComboboxBase<T>, ControlValue
322
338
  registerOnTouched(fn: TouchFn): void;
323
339
  setDisabledState(isDisabled: boolean): void;
324
340
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnComboboxMultiple<any>, never>;
325
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnComboboxMultiple<any>, "[brnCombobox]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "filterOptions": { "alias": "filterOptions"; "required": false; "isSignal": true; }; "isItemEqualToValue": { "alias": "isItemEqualToValue"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "filter": { "alias": "filter"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
341
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnComboboxMultiple<any>, "[brnCombobox]", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "filterOptions": { "alias": "filterOptions"; "required": false; "isSignal": true; }; "isItemEqualToValue": { "alias": "isItemEqualToValue"; "required": false; "isSignal": true; }; "itemToString": { "alias": "itemToString"; "required": false; "isSignal": true; }; "filter": { "alias": "filter"; "required": false; "isSignal": true; }; "autoHighlight": { "alias": "autoHighlight"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "search": "searchChange"; }, ["_searchInputWrapper", "items"], never, true, never>;
326
342
  }
327
343
 
328
344
  declare class BrnComboboxPopoverTrigger<T> {
@@ -374,9 +390,9 @@ declare const comboboxStartsWithFilter: BrnComboboxFilter;
374
390
  declare const comboboxEndsWithFilter: BrnComboboxFilter;
375
391
 
376
392
  declare const BrnComboboxItemToken: InjectionToken<BrnComboboxItem<unknown>>;
377
- declare function provideBrnComboboxItem<T>(Combobox: Type<BrnComboboxItem<T>>): ExistingProvider;
393
+ declare function provideBrnComboboxItem<T>(comboboxItem: Type<BrnComboboxItem<T>>): ExistingProvider;
378
394
 
379
395
  declare const BrnComboboxImports: readonly [typeof BrnCombobox, typeof BrnComboboxAnchor, typeof BrnComboboxChip, typeof BrnComboboxChipInput, typeof BrnComboboxChipRemove, typeof BrnComboboxClear, typeof BrnComboboxContent, typeof BrnComboboxEmpty, typeof BrnComboboxGroup, typeof BrnComboboxInputWrapper, typeof BrnComboboxInput, typeof BrnComboboxItem, typeof BrnComboboxLabel, typeof BrnComboboxList, typeof BrnComboboxMultiple, typeof BrnComboboxPopoverTrigger, typeof BrnComboboxSeparator, typeof BrnComboboxStatus, typeof BrnComboboxTrigger, typeof BrnComboboxValue, typeof BrnComboboxValues];
380
396
 
381
397
  export { BRN_COMBOBOX_MULTIPLE_VALUE_ACCESSOR, BRN_COMBOBOX_VALUE_ACCESSOR, BrnCombobox, BrnComboboxAnchor, BrnComboboxBaseToken, BrnComboboxChip, BrnComboboxChipInput, BrnComboboxChipRemove, BrnComboboxClear, BrnComboboxContent, BrnComboboxEmpty, BrnComboboxGroup, BrnComboboxImports, BrnComboboxInput, BrnComboboxInputWrapper, BrnComboboxItem, BrnComboboxItemToken, BrnComboboxLabel, BrnComboboxList, BrnComboboxMultiple, BrnComboboxPopoverTrigger, BrnComboboxSeparator, BrnComboboxStatus, BrnComboboxTrigger, BrnComboboxValue, BrnComboboxValues, comboboxContainsFilter, comboboxEndsWithFilter, comboboxStartsWithFilter, injectBrnComboboxBase, injectBrnComboboxConfig, provideBrnComboboxBase, provideBrnComboboxConfig, provideBrnComboboxItem };
382
- export type { BrnComboboxBase, BrnComboboxConfig, BrnComboboxFilter, ComboboxFilter, ComboboxFilterOptions, ComboboxItemEqualToValue, ComboboxItemToString };
398
+ export type { BrnComboboxBase, BrnComboboxConfig, BrnComboboxFilter, ComboboxFilter, ComboboxFilterOptions, ComboboxInputMode, ComboboxItemEqualToValue, ComboboxItemToString };
@@ -3,7 +3,8 @@ import * as _angular_core from '@angular/core';
3
3
  import { InjectionToken, Type, ExistingProvider, ValueProvider, OnInit } from '@angular/core';
4
4
  import { ActiveDescendantKeyManager, Highlightable } from '@angular/cdk/a11y';
5
5
  import { BooleanInput } from '@angular/cdk/coercion';
6
- import { DefaultValueAccessor } from '@angular/forms';
6
+ import { ControlValueAccessor } from '@angular/forms';
7
+ import { ChangeFn, TouchFn } from '@spartan-ng/brain/forms';
7
8
 
8
9
  declare const BrnCommandToken: InjectionToken<BrnCommand>;
9
10
  declare function provideBrnCommand(command: Type<BrnCommand>): ExistingProvider;
@@ -15,7 +16,12 @@ interface BrnCommandConfig {
15
16
  declare function provideBrnCommandConfig(config: Partial<BrnCommandConfig>): ValueProvider;
16
17
  declare function injectBrnCommandConfig(): BrnCommandConfig;
17
18
 
18
- declare class BrnCommand {
19
+ declare const BRN_COMMAND_VALUE_ACCESSOR: {
20
+ provide: _angular_core.InjectionToken<readonly ControlValueAccessor[]>;
21
+ useExisting: _angular_core.Type<any>;
22
+ multi: boolean;
23
+ };
24
+ declare class BrnCommand implements ControlValueAccessor {
19
25
  private static _id;
20
26
  private readonly _injector;
21
27
  private readonly _config;
@@ -23,20 +29,30 @@ declare class BrnCommand {
23
29
  readonly id: _angular_core.InputSignal<string>;
24
30
  /** A custom filter function to use when searching. */
25
31
  readonly filter: _angular_core.InputSignal<CommandFilter>;
32
+ /** Whether the command is disabled */
33
+ readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
34
+ private readonly _disabled;
35
+ /** @internal The disabled state as a readonly signal */
36
+ readonly disabledState: _angular_core.Signal<boolean>;
26
37
  /** when the selection has changed */
27
38
  readonly valueChange: _angular_core.OutputEmitterRef<string>;
28
- /** @internal The search query */
29
- readonly search: _angular_core.Signal<string>;
30
- /** Access the search input if present */
31
- private readonly _searchInput;
39
+ /** The current search query. */
40
+ readonly search: _angular_core.ModelSignal<string>;
32
41
  /** @internal Access all the items within the command */
33
42
  readonly items: _angular_core.Signal<readonly _spartan_ng_brain_command.BrnCommandItem[]>;
34
43
  /** @internal The key manager for managing active descendant */
35
44
  readonly keyManager: ActiveDescendantKeyManager<_spartan_ng_brain_command.BrnCommandItem>;
45
+ protected _onChange?: ChangeFn<string | null>;
46
+ protected _onTouched?: TouchFn;
36
47
  constructor();
37
48
  protected selectActiveItem(): void;
49
+ /** CONTROL VALUE ACCESSOR */
50
+ writeValue(value: string | null): void;
51
+ registerOnChange(fn: ChangeFn<string | null>): void;
52
+ registerOnTouched(fn: TouchFn): void;
53
+ setDisabledState(isDisabled: boolean): void;
38
54
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCommand, never>;
39
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCommand, "[brnCommand]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; "filter": { "alias": "filter"; "required": false; "isSignal": true; }; }, { "valueChange": "valueChange"; }, ["_searchInput", "items"], never, true, never>;
55
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCommand, "[brnCommand]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; "filter": { "alias": "filter"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; }, { "valueChange": "valueChange"; "search": "searchChange"; }, ["items"], never, true, never>;
40
56
  }
41
57
 
42
58
  declare class BrnCommandEmpty {
@@ -62,6 +78,25 @@ declare class BrnCommandGroup {
62
78
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCommandGroup, "[brnCommandGroup]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, ["_items"], never, true, never>;
63
79
  }
64
80
 
81
+ declare class BrnCommandInput {
82
+ private static _id;
83
+ private readonly _el;
84
+ private readonly _command;
85
+ private readonly _initialId;
86
+ /** The id of the command input */
87
+ readonly id: _angular_core.InputSignalWithTransform<string, string | undefined>;
88
+ protected readonly _disabled: _angular_core.Signal<boolean>;
89
+ /** The id of the active option */
90
+ protected readonly _activeDescendant: _angular_core.WritableSignal<string | undefined>;
91
+ constructor();
92
+ /** Listen for changes to the input value */
93
+ protected onInput(): void;
94
+ /** Listen for keydown events */
95
+ protected onKeyDown(event: KeyboardEvent): void;
96
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCommandInput, never>;
97
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCommandInput, "input[brnCommandInput]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
98
+ }
99
+
65
100
  declare class BrnCommandItem implements Highlightable, OnInit {
66
101
  private static _id;
67
102
  private readonly _platform;
@@ -109,30 +144,6 @@ declare class BrnCommandList {
109
144
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCommandList, "[brnCommandList]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
110
145
  }
111
146
 
112
- declare class BrnCommandSearchInput extends DefaultValueAccessor implements OnInit {
113
- private readonly _destroyRef;
114
- private readonly _el;
115
- private readonly _injector;
116
- private readonly _command;
117
- /** The initial value of the search input */
118
- readonly value: _angular_core.InputSignal<string>;
119
- /** @internal The mutable value of the search input */
120
- readonly mutableValue: _angular_core.WritableSignal<string>;
121
- /** @internal The "real" value of the search input */
122
- readonly valueState: _angular_core.Signal<string>;
123
- /** The id of the active option */
124
- protected readonly _activeDescendant: _angular_core.WritableSignal<string | undefined>;
125
- ngOnInit(): void;
126
- /** Listen for changes to the input value */
127
- protected onInput(): void;
128
- /** Listen for keydown events */
129
- protected onKeyDown(event: KeyboardEvent): void;
130
- /** CONROL VALUE ACCESSOR */
131
- writeValue(value: string | null): void;
132
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCommandSearchInput, never>;
133
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCommandSearchInput, "input[brnCommandSearchInput]", never, { "value": { "alias": "value"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
134
- }
135
-
136
147
  declare class BrnCommandSeparator {
137
148
  private readonly _command;
138
149
  /** Determine if the command has any visible items */
@@ -141,13 +152,13 @@ declare class BrnCommandSeparator {
141
152
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCommandSeparator, "[brnCommandSeparator]", never, {}, {}, never, never, true, never>;
142
153
  }
143
154
 
155
+ declare const BrnCommandInputToken: InjectionToken<BrnCommandInput>;
156
+ declare function provideBrnCommandInput(command: Type<BrnCommandInput>): ExistingProvider;
157
+
144
158
  declare const BrnCommandItemToken: InjectionToken<BrnCommandItem>;
145
159
  declare function provideBrnCommandItem(command: Type<BrnCommandItem>): ExistingProvider;
146
160
 
147
- declare const BrnCommandSearchInputToken: InjectionToken<BrnCommandSearchInput>;
148
- declare function provideBrnCommandSearchInput(command: Type<BrnCommandSearchInput>): ExistingProvider;
149
-
150
- declare const BrnCommandImports: readonly [typeof BrnCommand, typeof BrnCommandEmpty, typeof BrnCommandGroup, typeof BrnCommandItem, typeof BrnCommandList, typeof BrnCommandSearchInput, typeof BrnCommandSeparator];
161
+ declare const BrnCommandImports: readonly [typeof BrnCommand, typeof BrnCommandEmpty, typeof BrnCommandGroup, typeof BrnCommandInput, typeof BrnCommandItem, typeof BrnCommandList, typeof BrnCommandSeparator];
151
162
 
152
- export { BrnCommand, BrnCommandEmpty, BrnCommandGroup, BrnCommandImports, BrnCommandItem, BrnCommandItemToken, BrnCommandList, BrnCommandSearchInput, BrnCommandSearchInputToken, BrnCommandSeparator, BrnCommandToken, injectBrnCommand, injectBrnCommandConfig, provideBrnCommand, provideBrnCommandConfig, provideBrnCommandItem, provideBrnCommandSearchInput };
163
+ export { BRN_COMMAND_VALUE_ACCESSOR, BrnCommand, BrnCommandEmpty, BrnCommandGroup, BrnCommandImports, BrnCommandInput, BrnCommandInputToken, BrnCommandItem, BrnCommandItemToken, BrnCommandList, BrnCommandSeparator, BrnCommandToken, injectBrnCommand, injectBrnCommandConfig, provideBrnCommand, provideBrnCommandConfig, provideBrnCommandInput, provideBrnCommandItem };
153
164
  export type { BrnCommandConfig, CommandFilter };
@@ -1,10 +1,10 @@
1
1
  import { ActiveDescendantKeyManager } from '@angular/cdk/a11y';
2
2
  import * as i0 from '@angular/core';
3
- import { Directive, InjectionToken, inject, forwardRef, Injector, input, booleanAttribute, linkedSignal, model, contentChild, ElementRef, computed, contentChildren, Renderer2, TemplateRef, ViewContainerRef, effect, PLATFORM_ID, signal } from '@angular/core';
3
+ import { Directive, InjectionToken, inject, forwardRef, Injector, input, booleanAttribute, linkedSignal, model, contentChild, ElementRef, computed, contentChildren, afterNextRender, effect, untracked, Renderer2, TemplateRef, ViewContainerRef, PLATFORM_ID, signal } from '@angular/core';
4
4
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
5
- import { stringifyAsLabel } from '@spartan-ng/brain/core';
6
5
  import { BrnPopover } from '@spartan-ng/brain/popover';
7
6
  import { BrnDialog } from '@spartan-ng/brain/dialog';
7
+ import { stringifyAsLabel } from '@spartan-ng/brain/core';
8
8
  import { isPlatformBrowser } from '@angular/common';
9
9
 
10
10
  class BrnAutocompleteInputWrapper {
@@ -32,6 +32,7 @@ function getDefaultConfig() {
32
32
  return {
33
33
  isItemEqualToValue: (itemValue, selectedValue) => Object.is(itemValue, selectedValue),
34
34
  itemToString: undefined,
35
+ autoHighlight: false,
35
36
  };
36
37
  }
37
38
  const BrnAutocompleteConfigToken = new InjectionToken('BrnAutocompleteConfig');
@@ -62,6 +63,10 @@ class BrnAutocomplete {
62
63
  isItemEqualToValue = input(this._config.isItemEqualToValue);
63
64
  /** A function to convert an item to a string for display. */
64
65
  itemToString = input(this._config.itemToString);
66
+ /** Whether to auto-highlight the first matching item. */
67
+ autoHighlight = input(this._config.autoHighlight, {
68
+ transform: booleanAttribute,
69
+ });
65
70
  /** The selected value of the autocomplete. */
66
71
  value = model(null);
67
72
  /** The current search query. */
@@ -95,6 +100,21 @@ class BrnAutocomplete {
95
100
  this._brnPopover?.closed.subscribe(() => {
96
101
  this.keyManager.setActiveItem(-1);
97
102
  });
103
+ afterNextRender(() => {
104
+ effect(() => {
105
+ if (!this.autoHighlight() || !this.isExpanded() || !this.search())
106
+ return;
107
+ const hasVisibleItems = this.visibleItems();
108
+ untracked(() => {
109
+ if (hasVisibleItems) {
110
+ this.keyManager.setFirstItemActive();
111
+ }
112
+ else {
113
+ this.keyManager.setActiveItem(-1);
114
+ }
115
+ });
116
+ }, { injector: this._injector });
117
+ });
98
118
  }
99
119
  updateSearch(value) {
100
120
  this.search.set(value);
@@ -109,7 +129,6 @@ class BrnAutocomplete {
109
129
  select(itemValue) {
110
130
  this.value.set(itemValue);
111
131
  this._onChange?.(itemValue);
112
- this.search.set(stringifyAsLabel(itemValue, this.itemToString()));
113
132
  this.close();
114
133
  }
115
134
  /** Select the active item with Enter key. */
@@ -117,9 +136,12 @@ class BrnAutocomplete {
117
136
  if (!this.isExpanded())
118
137
  return;
119
138
  const value = this.keyManager.activeItem?.value();
120
- if (value === undefined)
121
- return;
122
- this.select(value);
139
+ if (value) {
140
+ this.select(value);
141
+ }
142
+ else {
143
+ this.close();
144
+ }
123
145
  }
124
146
  resetValue() {
125
147
  this.value.set(null);
@@ -155,7 +177,7 @@ class BrnAutocomplete {
155
177
  this._disabled.set(isDisabled);
156
178
  }
157
179
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: BrnAutocomplete, deps: [], target: i0.ɵɵFactoryTarget.Directive });
158
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.0.7", type: BrnAutocomplete, isStandalone: true, selector: "[brnAutocomplete]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, isItemEqualToValue: { classPropertyName: "isItemEqualToValue", publicName: "isItemEqualToValue", isSignal: true, isRequired: false, transformFunction: null }, itemToString: { classPropertyName: "itemToString", publicName: "itemToString", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", search: "searchChange" }, providers: [provideBrnAutocompleteBase(BrnAutocomplete), BRN_AUTOCOMPLETE_VALUE_ACCESSOR], queries: [{ propertyName: "_searchInputWrapper", first: true, predicate: BrnAutocompleteInputWrapper, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "items", predicate: BrnAutocompleteItemToken, descendants: true, isSignal: true }], ngImport: i0 });
180
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.0.7", type: BrnAutocomplete, isStandalone: true, selector: "[brnAutocomplete]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, isItemEqualToValue: { classPropertyName: "isItemEqualToValue", publicName: "isItemEqualToValue", isSignal: true, isRequired: false, transformFunction: null }, itemToString: { classPropertyName: "itemToString", publicName: "itemToString", isSignal: true, isRequired: false, transformFunction: null }, autoHighlight: { classPropertyName: "autoHighlight", publicName: "autoHighlight", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", search: "searchChange" }, providers: [provideBrnAutocompleteBase(BrnAutocomplete), BRN_AUTOCOMPLETE_VALUE_ACCESSOR], queries: [{ propertyName: "_searchInputWrapper", first: true, predicate: BrnAutocompleteInputWrapper, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "items", predicate: BrnAutocompleteItemToken, descendants: true, isSignal: true }], ngImport: i0 });
159
181
  }
160
182
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: BrnAutocomplete, decorators: [{
161
183
  type: Directive,
@@ -307,13 +329,13 @@ class BrnAutocompleteInput {
307
329
  constructor() {
308
330
  effect(() => {
309
331
  const value = this._autocomplete.value();
310
- const search = this._autocomplete.search();
311
332
  const valueLabel = stringifyAsLabel(value, this._autocomplete.itemToString());
312
- if (valueLabel === search) {
313
- this._el.nativeElement.value = valueLabel;
314
- }
315
- else if (search === '') {
316
- this._el.nativeElement.value = '';
333
+ this._el.nativeElement.value = valueLabel ?? '';
334
+ });
335
+ effect(() => {
336
+ const search = this._autocomplete.search();
337
+ if (this._el.nativeElement.value !== search) {
338
+ this._el.nativeElement.value = search;
317
339
  }
318
340
  });
319
341
  }
@@ -473,6 +495,10 @@ class BrnAutocompleteSearch {
473
495
  disabledState = this._disabled.asReadonly();
474
496
  /** A function to convert an item to a string for display. */
475
497
  itemToString = input(this._config.itemToString);
498
+ /** Whether to auto-highlight the first matching item. */
499
+ autoHighlight = input(this._config.autoHighlight, {
500
+ transform: booleanAttribute,
501
+ });
476
502
  /** The selected value of the autocomplete. */
477
503
  value = model(null);
478
504
  /** The current search query. */
@@ -506,6 +532,21 @@ class BrnAutocompleteSearch {
506
532
  this._brnPopover?.closed.subscribe(() => {
507
533
  this.keyManager.setActiveItem(-1);
508
534
  });
535
+ afterNextRender(() => {
536
+ effect(() => {
537
+ if (!this.autoHighlight() || !this.isExpanded() || !this.search())
538
+ return;
539
+ const hasVisibleItems = this.visibleItems();
540
+ untracked(() => {
541
+ if (hasVisibleItems) {
542
+ this.keyManager.setFirstItemActive();
543
+ }
544
+ else {
545
+ this.keyManager.setActiveItem(-1);
546
+ }
547
+ });
548
+ }, { injector: this._injector });
549
+ });
509
550
  }
510
551
  updateSearch(value) {
511
552
  this.value.set(value);
@@ -531,9 +572,12 @@ class BrnAutocompleteSearch {
531
572
  if (!this.isExpanded())
532
573
  return;
533
574
  const value = this.keyManager.activeItem?.value();
534
- if (value === undefined)
535
- return;
536
- this.select(value);
575
+ if (value) {
576
+ this.select(value);
577
+ }
578
+ else {
579
+ this.close();
580
+ }
537
581
  }
538
582
  resetValue() {
539
583
  this.value.set(null);
@@ -569,7 +613,7 @@ class BrnAutocompleteSearch {
569
613
  this._disabled.set(isDisabled);
570
614
  }
571
615
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: BrnAutocompleteSearch, deps: [], target: i0.ɵɵFactoryTarget.Directive });
572
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.0.7", type: BrnAutocompleteSearch, isStandalone: true, selector: "[brnAutocomplete]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, itemToString: { classPropertyName: "itemToString", publicName: "itemToString", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", search: "searchChange" }, providers: [provideBrnAutocompleteBase(BrnAutocompleteSearch), BRN_AUTOCOMPLETE_SEARCH_VALUE_ACCESSOR], queries: [{ propertyName: "_searchInputWrapper", first: true, predicate: BrnAutocompleteInputWrapper, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "items", predicate: BrnAutocompleteItemToken, descendants: true, isSignal: true }], ngImport: i0 });
616
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.0.7", type: BrnAutocompleteSearch, isStandalone: true, selector: "[brnAutocomplete]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, itemToString: { classPropertyName: "itemToString", publicName: "itemToString", isSignal: true, isRequired: false, transformFunction: null }, autoHighlight: { classPropertyName: "autoHighlight", publicName: "autoHighlight", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", search: "searchChange" }, providers: [provideBrnAutocompleteBase(BrnAutocompleteSearch), BRN_AUTOCOMPLETE_SEARCH_VALUE_ACCESSOR], queries: [{ propertyName: "_searchInputWrapper", first: true, predicate: BrnAutocompleteInputWrapper, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "items", predicate: BrnAutocompleteItemToken, descendants: true, isSignal: true }], ngImport: i0 });
573
617
  }
574
618
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: BrnAutocompleteSearch, decorators: [{
575
619
  type: Directive,