@sevtech/kit 21.0.0 → 21.1.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.
@@ -1,594 +1,1317 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, Injectable, viewChild, input, booleanAttribute, numberAttribute, computed, effect, Directive, contentChild, TemplateRef, signal, forwardRef, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
2
+ import { InjectionToken, inject, Injectable, signal, computed, contentChild, TemplateRef, Directive, booleanAttribute, numberAttribute, ElementRef, viewChild, input, output, Renderer2, effect, ChangeDetectionStrategy, Component, linkedSignal, DestroyRef, afterNextRender, makeEnvironmentProviders } from '@angular/core';
3
+ import { map, Subject, debounce, timer, filter, tap, switchMap, exhaustMap, defer, catchError, EMPTY } from 'rxjs';
4
+ import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
5
+ import { NgControl } from '@angular/forms';
6
+ import { isDefined, isFunction, isString, isArray, isNil, isNonEmptyString, isNonEmptyArray, isEmptyArray, noop, resolveMaybeFn, objectKeys } from '@sevtech/kit/misc';
3
7
  import { NgTemplateOutlet } from '@angular/common';
4
- import * as i2 from '@angular/forms';
5
- import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
6
- import * as i3 from 'primeng/iconfield';
7
- import { IconFieldModule } from 'primeng/iconfield';
8
- import * as i4 from 'primeng/inputicon';
9
- import { InputIconModule } from 'primeng/inputicon';
8
+ import { SlotOutletDirective, HighlightPipe } from '@sevtech/kit/ui';
9
+ import { cssDimensionAttribute, htmlBooleanAttribute, defineKitFeature, resolveConfigProviders, collectFeatureProviders } from '@sevtech/kit/ng-misc';
10
+ import { IS_MOBILE_BREAKPOINT } from '@sevtech/kit/browser';
10
11
  import { HttpClient } from '@angular/common/http';
11
- import { isDefined, isFunction, isNil, isArray, noop, isNonEmptyString, isEmptyArray, isNonEmptyArray, isString } from '@sevtech/kit/misc';
12
- import { map, BehaviorSubject, filter, switchMap, debounceTime, distinctUntilChanged, skip, tap, first, catchError, of } from 'rxjs';
13
- import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
14
- import * as i1 from 'primeng/inputtext';
15
- import { InputText, InputTextModule } from 'primeng/inputtext';
16
- import { Overlay } from 'primeng/overlay';
17
- import { AutoFocus } from 'primeng/autofocus';
18
- import { htmlBooleanAttribute } from '@sevtech/kit/ng-misc';
19
- import { PrimeNG } from 'primeng/config';
12
+ import * as i1 from '@angular/cdk/overlay';
13
+ import { ScrollStrategyOptions, OverlayContainer, OverlayModule } from '@angular/cdk/overlay';
14
+
15
+ const DEFAULT_ICONS = {
16
+ toggle: `<svg width="1em" height="1em" fill="currentColor" viewBox="0 0 24 24"><path d="M18.33 7.31a.96.96 0 0 1 1.42 1.3l-7.04 7.68a.96.96 0 0 1-1.42 0L4.25 8.6a.96.96 0 0 1 1.42-1.3L12 14.2z"/></svg>`,
17
+ loader: `<svg width="1em" height="1em" fill="currentColor" viewBox="0 0 24 24"><path d="M12 20.5a8.5 8.5 0 1 1 5.83-14.69.7.7 0 0 1-.22 1.17.7.7 0 0 1-.78-.16A7.1 7.1 0 1 0 19.08 12a.7.7 0 0 1 1.42 0 8.5 8.5 0 0 1-8.5 8.5"/></svg>`,
18
+ create: `<svg width="1em" height="1em" fill="currentColor" viewBox="0 0 24 24"><path d="M12.77 11.23V4.77a.77.77 0 0 0-1.54 0v6.46H4.77a.77.77 0 0 0 0 1.54h6.46v6.46A.8.8 0 0 0 12 20a.77.77 0 0 0 .77-.77v-6.46h6.46a.77.77 0 0 0 0-1.54z"/></svg>`,
19
+ clear: `<svg width="1em" height="1em" fill="currentColor" viewBox="0 0 24 24"><path d="M12.28 12.02 17.7 6.6a.92.92 0 1 0-1.3-1.3l-5.43 5.43L5.55 5.3a.92.92 0 0 0-1.3 1.3l5.43 5.43-5.43 5.43a.92.92 0 0 0 1.3 1.3l5.43-5.43 5.43 5.43a.92.92 0 0 0 1.3-1.3z"/></svg>`,
20
+ reload: `<svg width="1em" height="1em" fill="currentColor" viewBox="0 0 24 24"><path d="M4 13.34a7.3 7.3 0 0 1 7.31-7.31h1.2l-1.73-1.74a.76.76 0 1 1 1.07-1.07l3.56 3.56-3.56 3.56a.76.76 0 1 1-1.07-1.07l1.73-1.73h-1.2a5.8 5.8 0 1 0 5.8 5.8.76.76 0 1 1 1.52 0 7.31 7.31 0 1 1-14.63 0"/></svg>`,
21
+ };
22
+
23
+ const DEFAULT_MESSAGES = {
24
+ hint: 'Start typing to search',
25
+ empty: 'Nothing found',
26
+ more: 'Show more',
27
+ actions: {
28
+ clear: {
29
+ label: 'Clear',
30
+ title: 'Clear the field',
31
+ },
32
+ create: {
33
+ label: 'Create option',
34
+ title: 'Create an option from the entered text',
35
+ },
36
+ toggle: {
37
+ label: 'Toggle options',
38
+ },
39
+ loader: {},
40
+ reload: {
41
+ label: 'Retry',
42
+ title: 'Request failed',
43
+ },
44
+ },
45
+ };
46
+
47
+ const CONNECTED_POSITION_BELOW = {
48
+ originX: 'start',
49
+ originY: 'bottom',
50
+ overlayX: 'start',
51
+ overlayY: 'top',
52
+ };
53
+ const CONNECTED_POSITION_ABOVE = {
54
+ originX: 'start',
55
+ originY: 'top',
56
+ overlayX: 'start',
57
+ overlayY: 'bottom',
58
+ };
20
59
 
21
60
  const DEFAULT_CONFIG = {
22
- delay: 300,
23
- apiUrl: '/yoda/ajax',
24
61
  itemsShow: 20,
25
- minQueryLength: 0,
26
- paramsMapper: ({ type, action, repository, queryString }) => ({
27
- repo: repository ?? '',
28
- action: action ?? '',
29
- index: type,
30
- qs: queryString ?? '',
31
- }),
62
+ size: undefined,
63
+ variant: 'outline',
64
+ separator: 'border',
65
+ mode: 'autocomplete',
66
+ native: 'auto',
67
+ createPlace: 'start',
68
+ createMode: 'empty',
69
+ loopScroll: true,
70
+ autoSelect: true,
71
+ autoSelectClose: true,
72
+ scrollHeight: '200px',
73
+ show: {
74
+ hint: false,
75
+ empty: false,
76
+ more: false,
77
+ clear: true,
78
+ counter: true,
79
+ highlight: true,
80
+ toggle: true,
81
+ loader: true,
82
+ },
83
+ overlay: {
84
+ scrollStrategy: 'reposition',
85
+ panelClass: '',
86
+ matchWidth: true,
87
+ zIndex: 1000,
88
+ },
89
+ request: {
90
+ apiUrl: '/yoda/ajax',
91
+ delay: 300,
92
+ minQueryLength: 0,
93
+ paramsMapper: ({ type, action, repository, query, parent }) => ({
94
+ repo: repository ?? '',
95
+ action: action ?? '',
96
+ index: type,
97
+ qs: query ?? '',
98
+ ...(isDefined(parent) ? { parent } : {}),
99
+ }),
100
+ },
32
101
  };
33
- const CONFIG = new InjectionToken('[CONFIG]: Конфигурация параметров по умолчанию', {
34
- providedIn: 'root',
35
- factory: () => DEFAULT_CONFIG,
36
- });
37
- function provideYodaConfig(config) {
38
- return {
39
- provide: CONFIG,
40
- useValue: {
41
- ...DEFAULT_CONFIG,
42
- ...config,
43
- },
44
- };
102
+
103
+ function createToken(description, value) {
104
+ return new InjectionToken(description, { factory: () => value });
45
105
  }
106
+ const ICONS = createToken('[YODA]: глифы иконок', DEFAULT_ICONS);
107
+ const MESSAGES = createToken('[YODA]: тексты интерфейса', DEFAULT_MESSAGES);
108
+ const CONFIG = createToken('[YODA]: конфигурация полей', DEFAULT_CONFIG);
109
+ const Z_INDEX = createToken('[YODA]: расчёт z-index', (base) => base);
110
+
111
+ var RequestType;
112
+ (function (RequestType) {
113
+ RequestType[RequestType["Get"] = 0] = "Get";
114
+ RequestType[RequestType["Search"] = 1] = "Search";
115
+ RequestType[RequestType["Create"] = 2] = "Create";
116
+ })(RequestType || (RequestType = {}));
46
117
 
47
- class YodaService {
118
+ class ApiService {
48
119
  constructor() {
49
120
  this.config = inject(CONFIG);
50
121
  this.httpClient = inject(HttpClient);
51
122
  }
52
- request(params) {
53
- const [url, queryParams] = this.buildUrl(params);
54
- return this.httpClient.get(url, {
55
- params: queryParams,
56
- responseType: 'json',
57
- });
123
+ request(data) {
124
+ const { url, params } = this.resolveEndpoint(data);
125
+ return this.httpClient
126
+ .get(url, { params })
127
+ .pipe(map((rows) => this.parseResponse(rows, data.transform)));
58
128
  }
59
- buildUrl({ apiUrl, ...params }) {
60
- if (isDefined(apiUrl)) {
61
- return isFunction(apiUrl) ? [apiUrl(params), {}] : [apiUrl, this.config.paramsMapper(params)];
129
+ resolveEndpoint(data) {
130
+ const params = toRequestParams(data);
131
+ if (isFunction(data.url)) {
132
+ return { url: data.url(params) };
62
133
  }
63
- if (isNil(params.action) || isNil(params.repository)) {
64
- throw new Error('[YODA]: action or repository is not defined');
134
+ if (isString(data.url)) {
135
+ return { url: data.url, params: this.config.request.paramsMapper(params) };
65
136
  }
66
- return [this.config.apiUrl, this.config.paramsMapper(params)];
137
+ if (params.action && params.repository) {
138
+ return { url: this.config.request.apiUrl, params: this.config.request.paramsMapper(params) };
139
+ }
140
+ throw new Error('[YODA]: provide either `url` or both `action` and `repository`');
141
+ }
142
+ parseResponse(rows, transform) {
143
+ if (!isArray(rows))
144
+ throw new Error('[YODA]: expected array in response');
145
+ if (isFunction(transform))
146
+ return flattenOptions(transform(rows));
147
+ return rows.map(parseResponseRaw);
67
148
  }
68
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
69
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaService, providedIn: 'root' }); }
149
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
150
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiService, providedIn: 'root' }); }
70
151
  }
71
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaService, decorators: [{
152
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiService, decorators: [{
72
153
  type: Injectable,
73
154
  args: [{
74
155
  providedIn: 'root',
75
156
  }]
76
157
  }] });
158
+ function flattenOptions(options) {
159
+ return options.flatMap((option, index) => {
160
+ if (!isGroupOption(option))
161
+ return toFlatOption(option);
162
+ const { items, ...group } = option;
163
+ const id = `group-${index}`;
164
+ return [{ ...group, id, kind: 'group' }, ...items.map((item) => toFlatOption(item, id))];
165
+ });
166
+ }
167
+ function isGroupOption(option) {
168
+ return 'items' in option && isArray(option.items);
169
+ }
170
+ function parseResponseRaw([value, label, ...payload]) {
171
+ return { kind: 'option', value, label, payload };
172
+ }
173
+ function toRequestParams({ action, repository, type, query, parent }) {
174
+ return { action, repository, type, query, parent };
175
+ }
176
+ function toFlatOption(item, parent) {
177
+ return { ...item, kind: 'option', parent };
178
+ }
179
+
180
+ class StateService {
181
+ constructor() {
182
+ this.api = inject(ApiService);
183
+ this.search$ = new Subject();
184
+ this.create$ = new Subject();
185
+ this.fetch$ = new Subject();
186
+ this.querySource = signal('', ...(ngDevMode ? [{ debugName: "querySource" }] : []));
187
+ this.filterSource = signal('', ...(ngDevMode ? [{ debugName: "filterSource" }] : []));
188
+ this.openSource = signal(false, ...(ngDevMode ? [{ debugName: "openSource" }] : []));
189
+ this.stateSource = signal({ status: 'idle' }, ...(ngDevMode ? [{ debugName: "stateSource" }] : []));
190
+ this.optionsSource = signal(null, ...(ngDevMode ? [{ debugName: "optionsSource" }] : []));
191
+ this.selectedSource = signal(null, ...(ngDevMode ? [{ debugName: "selectedSource" }] : []));
192
+ this.createdSource = signal(null, ...(ngDevMode ? [{ debugName: "createdSource" }] : []));
193
+ this.matchSource = signal(matchByLabel, ...(ngDevMode ? [{ debugName: "matchSource" }] : []));
194
+ this.query$$ = this.querySource.asReadonly();
195
+ this.selected$$ = this.selectedSource.asReadonly();
196
+ this.isOpen$$ = this.openSource.asReadonly();
197
+ this.requestState$$ = this.stateSource.asReadonly();
198
+ this.created$$ = this.createdSource.asReadonly();
199
+ this.options$$ = computed(() => {
200
+ const options = this.optionsSource();
201
+ const query = this.filterSource().trim().toLowerCase();
202
+ if (isNil(options) || query.length === 0)
203
+ return options;
204
+ return filterOptions(options, query, this.matchSource());
205
+ }, ...(ngDevMode ? [{ debugName: "options$$" }] : []));
206
+ this.search$
207
+ .pipe(debounce(({ delay }) => timer(delay)), filter((request) => shouldSearch(request, this.querySource())), tap(({ query }) => this.querySource.set(query)), switchMap((request) => this.executeRequest(request, true)), takeUntilDestroyed())
208
+ .subscribe();
209
+ this.fetch$
210
+ .pipe(switchMap((request) => this.executeRequest(request)), takeUntilDestroyed())
211
+ .subscribe();
212
+ this.create$
213
+ .pipe(exhaustMap((request) => this.executeRequest(request)), takeUntilDestroyed())
214
+ .subscribe();
215
+ }
216
+ queryChange(query, options) {
217
+ const value = query.trim();
218
+ if (this.selectedSource()) {
219
+ this.select(null);
220
+ }
221
+ this.open();
222
+ if (isShortQuery(value, options.minQueryLength)) {
223
+ this.clearOptions();
224
+ }
225
+ this.search$.next(buildRequest(value, RequestType.Search, 'options', options));
226
+ }
227
+ load(query, options, type = RequestType.Get) {
228
+ this.fetch$.next(buildRequest(query, type, 'options', options));
229
+ }
230
+ resolve(value, options) {
231
+ this.fetch$.next(buildRequest(value.toString(), RequestType.Get, 'selection', options));
232
+ }
233
+ createByQuery(query, options) {
234
+ this.create$.next(buildRequest(query, RequestType.Create, 'selection', options));
235
+ }
236
+ retry() {
237
+ const state = this.stateSource();
238
+ if (state.status !== 'error')
239
+ return;
240
+ if (state.request.type === RequestType.Create) {
241
+ return this.create$.next(state.request);
242
+ }
243
+ this.fetch$.next(state.request);
244
+ }
245
+ select(option) {
246
+ this.selectedSource.set(option);
247
+ }
248
+ filter(query, match) {
249
+ this.filterSource.set(query);
250
+ this.querySource.set(query.trim());
251
+ this.matchSource.set(match ?? matchByLabel);
252
+ }
253
+ clear() {
254
+ this.filterSource.set('');
255
+ this.selectedSource.set(null);
256
+ this.stateSource.set({ status: 'idle' });
257
+ this.clearOptions();
258
+ }
259
+ clearOptions() {
260
+ this.optionsSource.set(null);
261
+ this.querySource.set('');
262
+ }
263
+ open() {
264
+ this.openSource.set(true);
265
+ }
266
+ close() {
267
+ this.openSource.set(false);
268
+ }
269
+ toggle() {
270
+ this.openSource() ? this.close() : this.open();
271
+ }
272
+ apply(request, options, fromSearch) {
273
+ this.stateSource.set({ status: 'idle' });
274
+ if (request.target === 'options') {
275
+ return this.applyOptions(request, options, fromSearch);
276
+ }
277
+ this.applySelection(request, options);
278
+ }
279
+ executeRequest(request, fromSearch = false) {
280
+ return defer(() => {
281
+ this.stateSource.set({ status: 'loading' });
282
+ return this.api.request(request);
283
+ }).pipe(tap((options) => this.apply(request, options, fromSearch)), catchError((error) => {
284
+ this.stateSource.set({ status: 'error', request, error });
285
+ return EMPTY;
286
+ }));
287
+ }
288
+ applyOptions(request, options, fromSearch) {
289
+ if (fromSearch && request.query !== this.querySource())
290
+ return;
291
+ this.optionsSource.set(options);
292
+ }
293
+ applySelection(request, [option]) {
294
+ if (isNil(option))
295
+ return;
296
+ if (request.type === RequestType.Create) {
297
+ this.optionsSource.update((current) => [option, ...(current ?? [])]);
298
+ this.createdSource.set(option);
299
+ }
300
+ this.select(option);
301
+ }
302
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
303
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StateService }); }
304
+ }
305
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StateService, decorators: [{
306
+ type: Injectable
307
+ }], ctorParameters: () => [] });
308
+ function buildRequest(query, type, target, options) {
309
+ return { ...options, type, query, target };
310
+ }
311
+ function matchByLabel(option, query) {
312
+ return option.label.toLowerCase().includes(query);
313
+ }
314
+ function isShortQuery(query, minQueryLength) {
315
+ return query.length === 0 || query.length < minQueryLength;
316
+ }
317
+ function shouldSearch(request, query) {
318
+ if (isShortQuery(request.query, request.minQueryLength))
319
+ return false;
320
+ return request.query !== query;
321
+ }
322
+ function filterOptions(options, query, match) {
323
+ const result = [];
324
+ let group = null;
325
+ for (const option of options) {
326
+ if (option.kind === 'group') {
327
+ group = option;
328
+ continue;
329
+ }
330
+ if (!match(option, query))
331
+ continue;
332
+ if (group) {
333
+ result.push(group);
334
+ group = null;
335
+ }
336
+ result.push(option);
337
+ }
338
+ return result;
339
+ }
77
340
 
78
- class YodaBase {
79
- get inputElementRef() {
80
- return this.inputRef()?.el.nativeElement ?? null;
341
+ class SlotsService {
342
+ constructor() {
343
+ this.source = null;
81
344
  }
345
+ init(slots) {
346
+ this.source = slots;
347
+ }
348
+ get(name) {
349
+ if (!this.source)
350
+ return null;
351
+ return this.source[`${name}Ref`]() ?? null;
352
+ }
353
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
354
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotsService }); }
355
+ }
356
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotsService, decorators: [{
357
+ type: Injectable
358
+ }] });
359
+
360
+ class ChainService {
82
361
  constructor() {
362
+ this.links$$ = signal([], ...(ngDevMode ? [{ debugName: "links$$" }] : []));
363
+ this.inlineSource$$ = signal(false, ...(ngDevMode ? [{ debugName: "inlineSource$$" }] : []));
364
+ this.pendingSource$$ = signal('none', ...(ngDevMode ? [{ debugName: "pendingSource$$" }] : []));
365
+ this.inline$$ = this.inlineSource$$.asReadonly();
366
+ this.pending$$ = this.pendingSource$$.asReadonly();
367
+ }
368
+ setInline(inline) {
369
+ this.inlineSource$$.set(inline);
370
+ }
371
+ setPending(pending) {
372
+ this.pendingSource$$.set(pending);
373
+ }
374
+ position(link) {
375
+ const links = this.links$$();
376
+ const index = links.indexOf(link);
377
+ if (index < 0 || links.length <= 1)
378
+ return 'only';
379
+ if (index === 0)
380
+ return 'first';
381
+ return index === links.length - 1 ? 'last' : 'middle';
382
+ }
383
+ register(link) {
384
+ this.links$$.update((links) => [...links, link]);
385
+ }
386
+ unregister(link) {
387
+ this.links$$.update((links) => links.filter((item) => item !== link));
388
+ }
389
+ parentValue(link) {
390
+ const links = this.links$$();
391
+ const index = links.indexOf(link);
392
+ if (index <= 0)
393
+ return undefined;
394
+ return links[index - 1].selection$$()?.value ?? null;
395
+ }
396
+ resetAfter(link) {
397
+ const links = this.links$$();
398
+ const index = links.indexOf(link);
399
+ if (index < 0)
400
+ return;
401
+ links.slice(index + 1).forEach((item) => item.reset());
402
+ }
403
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ChainService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
404
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ChainService }); }
405
+ }
406
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ChainService, decorators: [{
407
+ type: Injectable
408
+ }] });
409
+
410
+ class SlotDirective {
411
+ constructor() {
412
+ this.slotsService = inject(SlotsService);
413
+ this.createIconRef = contentChild('createIcon', ...(ngDevMode ? [{ debugName: "createIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
414
+ this.clearIconRef = contentChild('clearIcon', ...(ngDevMode ? [{ debugName: "clearIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
415
+ this.toggleIconRef = contentChild('toggleIcon', ...(ngDevMode ? [{ debugName: "toggleIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
416
+ this.loaderIconRef = contentChild('loaderIcon', ...(ngDevMode ? [{ debugName: "loaderIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
417
+ this.reloadIconRef = contentChild('reloadIcon', ...(ngDevMode ? [{ debugName: "reloadIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
418
+ this.counterRef = contentChild('counter', ...(ngDevMode ? [{ debugName: "counterRef", read: TemplateRef }] : [{ read: TemplateRef }]));
419
+ this.optionRef = contentChild('option', ...(ngDevMode ? [{ debugName: "optionRef", read: TemplateRef }] : [{ read: TemplateRef }]));
420
+ this.groupRef = contentChild('group', ...(ngDevMode ? [{ debugName: "groupRef", read: TemplateRef }] : [{ read: TemplateRef }]));
421
+ this.hintRef = contentChild('hint', ...(ngDevMode ? [{ debugName: "hintRef", read: TemplateRef }] : [{ read: TemplateRef }]));
422
+ this.emptyRef = contentChild('empty', ...(ngDevMode ? [{ debugName: "emptyRef", read: TemplateRef }] : [{ read: TemplateRef }]));
423
+ this.headerRef = contentChild('header', ...(ngDevMode ? [{ debugName: "headerRef", read: TemplateRef }] : [{ read: TemplateRef }]));
424
+ this.footerRef = contentChild('footer', ...(ngDevMode ? [{ debugName: "footerRef", read: TemplateRef }] : [{ read: TemplateRef }]));
425
+ this.slotsService.init(this);
426
+ }
427
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
428
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.3.18", type: SlotDirective, isStandalone: true, queries: [{ propertyName: "createIconRef", first: true, predicate: ["createIcon"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "clearIconRef", first: true, predicate: ["clearIcon"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "toggleIconRef", first: true, predicate: ["toggleIcon"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "loaderIconRef", first: true, predicate: ["loaderIcon"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "reloadIconRef", first: true, predicate: ["reloadIcon"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "counterRef", first: true, predicate: ["counter"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "optionRef", first: true, predicate: ["option"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "hintRef", first: true, predicate: ["hint"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "emptyRef", first: true, predicate: ["empty"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "headerRef", first: true, predicate: ["header"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "footerRef", first: true, predicate: ["footer"], descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0 }); }
429
+ }
430
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotDirective, decorators: [{
431
+ type: Directive
432
+ }], ctorParameters: () => [], propDecorators: { createIconRef: [{ type: i0.ContentChild, args: ['createIcon', { ...{ read: TemplateRef }, isSignal: true }] }], clearIconRef: [{ type: i0.ContentChild, args: ['clearIcon', { ...{ read: TemplateRef }, isSignal: true }] }], toggleIconRef: [{ type: i0.ContentChild, args: ['toggleIcon', { ...{ read: TemplateRef }, isSignal: true }] }], loaderIconRef: [{ type: i0.ContentChild, args: ['loaderIcon', { ...{ read: TemplateRef }, isSignal: true }] }], reloadIconRef: [{ type: i0.ContentChild, args: ['reloadIcon', { ...{ read: TemplateRef }, isSignal: true }] }], counterRef: [{ type: i0.ContentChild, args: ['counter', { ...{ read: TemplateRef }, isSignal: true }] }], optionRef: [{ type: i0.ContentChild, args: ['option', { ...{ read: TemplateRef }, isSignal: true }] }], groupRef: [{ type: i0.ContentChild, args: ['group', { ...{ read: TemplateRef }, isSignal: true }] }], hintRef: [{ type: i0.ContentChild, args: ['hint', { ...{ read: TemplateRef }, isSignal: true }] }], emptyRef: [{ type: i0.ContentChild, args: ['empty', { ...{ read: TemplateRef }, isSignal: true }] }], headerRef: [{ type: i0.ContentChild, args: ['header', { ...{ read: TemplateRef }, isSignal: true }] }], footerRef: [{ type: i0.ContentChild, args: ['footer', { ...{ read: TemplateRef }, isSignal: true }] }] } });
433
+
434
+ const nativeTransform = (value) => (value === 'auto' ? 'auto' : booleanAttribute(value));
435
+ const itemsShowTransform = (value) => isNil(value) || value === '' ? null : numberAttribute(value);
436
+ class BaseDirective extends SlotDirective {
437
+ constructor() {
438
+ super(...arguments);
83
439
  this.config = inject(CONFIG);
84
- this.primeConfig = inject(PrimeNG);
85
- this.inputRef = viewChild(InputText, ...(ngDevMode ? [{ debugName: "inputRef" }] : []));
440
+ this.messages = inject(MESSAGES);
441
+ this.host = inject(ElementRef);
442
+ this.isMobile$$ = inject(IS_MOBILE_BREAKPOINT);
443
+ this.inputRef = viewChild('inputRef', ...(ngDevMode ? [{ debugName: "inputRef" }] : []));
444
+ /** Имя репозитория */
445
+ this.repository = input(...(ngDevMode ? [undefined, { debugName: "repository" }] : []));
446
+ /** Действие репозитория */
447
+ this.action = input(...(ngDevMode ? [undefined, { debugName: "action" }] : []));
448
+ /** Свой эндпоинт вместо общего. Функции достаётся весь набор параметров запроса */
449
+ this.apiUrl = input(...(ngDevMode ? [undefined, { debugName: "apiUrl" }] : []));
450
+ /** Преобразует сырой ответ. Вложенные `items` превращаются в группы */
451
+ this.transformOptions = input(...(ngDevMode ? [undefined, { debugName: "transformOptions" }] : []));
452
+ /** Дебаунс поиска, мс */
453
+ this.delay = input(this.config.request.delay, ...(ngDevMode ? [{ debugName: "delay", transform: numberAttribute }] : [{ transform: numberAttribute }]));
454
+ /** Запрос уходит начиная с этой длины. Пустая строка не ищется никогда */
455
+ this.minQueryLength = input(this.config.request.minQueryLength, ...(ngDevMode ? [{ debugName: "minQueryLength", transform: numberAttribute }] : [{
456
+ transform: numberAttribute,
457
+ }]));
458
+ /** Что уходит в `qs` разовой загрузки списка — она нужна режиму `select` и нативному пикеру, которые догружать по клику не умеют */
459
+ this.preloadQuery = input('', ...(ngDevMode ? [{ debugName: "preloadQuery" }] : []));
460
+ /** Индекс разовой загрузки. В легаси это `fetchDefaultsIndex` */
461
+ this.preloadType = input(RequestType.Get, ...(ngDevMode ? [{ debugName: "preloadType" }] : []));
462
+ /** `select` грузит список один раз и дальше фильтрует его локально */
463
+ this.mode = input(this.config.mode, ...(ngDevMode ? [{ debugName: "mode" }] : []));
464
+ /** Прозрачный `<select>` поверх стрелки; `auto` по мобильному брейкпоинту */
465
+ this.native = input(this.config.native, ...(ngDevMode ? [{ debugName: "native", transform: nativeTransform }] : [{ transform: nativeTransform }]));
466
+ /** Решение конкретного места в вёрстке: `inline` двигает поток под полем */
467
+ this.listRender = input('overlay', ...(ngDevMode ? [{ debugName: "listRender" }] : []));
468
+ /** Сколько строк рисовать; `null` - показать все */
469
+ this.itemsShow = input(this.config.itemsShow, ...(ngDevMode ? [{ debugName: "itemsShow", transform: itemsShowTransform }] : [{
470
+ transform: itemsShowTransform,
471
+ }]));
472
+ /** Высота области прокрутки списка; `null` - без ограничения */
473
+ this.scrollHeight = input(this.config.scrollHeight, ...(ngDevMode ? [{ debugName: "scrollHeight", transform: cssDimensionAttribute }] : [{ transform: cssDimensionAttribute }]));
474
+ /** Перекидывать ли стрелками с последней опции на первую */
475
+ this.loopScroll = input(this.config.loopScroll, ...(ngDevMode ? [{ debugName: "loopScroll", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
476
+ /** Делает заголовок группы выбираемой опцией */
477
+ this.selectGroup = input(false, ...(ngDevMode ? [{ debugName: "selectGroup", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
478
+ /** Прилепляет заголовок группы к верху списка при прокрутке */
479
+ this.groupSticky = input(false, ...(ngDevMode ? [{ debugName: "groupSticky", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
480
+ /** Предикат для определения отключённых опций */
481
+ this.disabledOption = input(...(ngDevMode ? [undefined, { debugName: "disabledOption" }] : []));
482
+ /** Предикат для фильтрации опций в режиме `select` */
483
+ this.filterOption = input(...(ngDevMode ? [undefined, { debugName: "filterOption" }] : []));
484
+ /** Выбрать результат, если он пришёл единственным */
485
+ this.autoSelect = input(this.config.autoSelect, ...(ngDevMode ? [{ debugName: "autoSelect", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
486
+ /** Закрывать ли список после автовыбора */
487
+ this.autoSelectClose = input(this.config.autoSelectClose, ...(ngDevMode ? [{ debugName: "autoSelectClose", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
488
+ /** Включает кнопку `+`, которая отправляет введённый текст запросом на создание */
489
+ this.create = input(false, ...(ngDevMode ? [{ debugName: "create", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
490
+ /** `empty` - показывать кнопку, только когда ничего не нашлось */
491
+ this.createMode = input(this.config.createMode, ...(ngDevMode ? [{ debugName: "createMode" }] : []));
492
+ /** С какой стороны поля стоит кнопка `+` */
493
+ this.createPlace = input(this.config.createPlace, ...(ngDevMode ? [{ debugName: "createPlace" }] : []));
494
+ /** Показывать подсказку, пока списка ещё нет */
495
+ this.showHint = input(this.config.show.hint, ...(ngDevMode ? [{ debugName: "showHint", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
496
+ /** Показывать сообщение о пустой выдаче */
497
+ this.showEmpty = input(this.config.show.empty, ...(ngDevMode ? [{ debugName: "showEmpty", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
498
+ /** Показывать последнюю строку, разворачивающую список дальше */
499
+ this.showMore = input(this.config.show.more, ...(ngDevMode ? [{ debugName: "showMore", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
500
+ /** Показывать крестик, который очищает поле ввода */
501
+ this.showClear = input(this.config.show.clear, ...(ngDevMode ? [{ debugName: "showClear", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
502
+ /** Показывать счётчик совпадений если список опций не пустой */
503
+ this.showCounter = input(this.config.show.counter, ...(ngDevMode ? [{ debugName: "showCounter", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
504
+ /** Подсветка совпадений */
505
+ this.showHighlight = input(this.config.show.highlight, ...(ngDevMode ? [{ debugName: "showHighlight", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
506
+ /** Показывать стрелку */
507
+ this.showToggle = input(this.config.show.toggle, ...(ngDevMode ? [{ debugName: "showToggle", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
508
+ /** Показывать спиннер вместо стрелки на время запроса */
509
+ this.showLoader = input(this.config.show.loader, ...(ngDevMode ? [{ debugName: "showLoader", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
510
+ /** Текст подсказки, если не задан слот `#hint` */
511
+ this.hintMessage = input(this.messages.hint, ...(ngDevMode ? [{ debugName: "hintMessage" }] : []));
512
+ /** Текст пустой выдачи, если не задан слот `#empty` */
513
+ this.emptyMessage = input(this.messages.empty, ...(ngDevMode ? [{ debugName: "emptyMessage" }] : []));
514
+ /** Подпись строки, разворачивающей список */
515
+ this.moreMessage = input(this.messages.more, ...(ngDevMode ? [{ debugName: "moreMessage" }] : []));
516
+ /** Тултип иконки повтора. Без него берётся текст из `withMessages` */
517
+ this.errorMessage = input(...(ngDevMode ? [undefined, { debugName: "errorMessage" }] : []));
518
+ /** Размер поля */
519
+ this.size = input(this.config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
520
+ /** Заливка или рамка */
521
+ this.variant = input(this.config.variant, ...(ngDevMode ? [{ debugName: "variant" }] : []));
522
+ /** Чем отделять сегменты поля друг от друга */
523
+ this.separator = input(this.config.separator, ...(ngDevMode ? [{ debugName: "separator" }] : []));
524
+ /** Ширина поля */
525
+ this.width = input(null, ...(ngDevMode ? [{ debugName: "width", transform: cssDimensionAttribute }] : [{
526
+ transform: cssDimensionAttribute,
527
+ }]));
528
+ /** Класс панели оверлея */
529
+ this.panelClass = input(this.config.overlay.panelClass, ...(ngDevMode ? [{ debugName: "panelClass" }] : []));
530
+ /** Что делать с панелью, когда страница прокручивается под ней */
531
+ this.scrollStrategy = input(this.config.overlay.scrollStrategy, ...(ngDevMode ? [{ debugName: "scrollStrategy" }] : []));
532
+ /** Идентификатор `<input>` - нужен внешнему `<label for>` */
86
533
  this.id = input(...(ngDevMode ? [undefined, { debugName: "id" }] : []));
534
+ /** Имя поля при нативной отправке формы */
87
535
  this.name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : []));
536
+ /** Текст в пустом поле */
88
537
  this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
89
- this.size = input(...(ngDevMode ? [undefined, { debugName: "size" }] : []));
538
+ /** По умолчанию `off`: подсказки браузера перекрывают собой список */
90
539
  this.autocomplete = input('off', ...(ngDevMode ? [{ debugName: "autocomplete" }] : []));
91
- this.variant = input('outlined', ...(ngDevMode ? [{ debugName: "variant" }] : []));
540
+ /** Блокирует поле вне реактивной формы; в форме этим распоряжается контрол */
92
541
  this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
542
+ /** Ставит фокус в поле после первой отрисовки */
93
543
  this.autofocus = input(false, ...(ngDevMode ? [{ debugName: "autofocus", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
544
+ /** Проставляет атрибут на `<input>` */
94
545
  this.required = input(undefined, ...(ngDevMode ? [{ debugName: "required", transform: htmlBooleanAttribute }] : [{ transform: htmlBooleanAttribute }]));
546
+ /** Ведёт себя как `disabled`, но поле остаётся в таб-порядке */
95
547
  this.inputReadonly = input(undefined, ...(ngDevMode ? [{ debugName: "inputReadonly", alias: 'readonly', transform: htmlBooleanAttribute }] : [{ alias: 'readonly', transform: htmlBooleanAttribute }]));
548
+ /** Порядок обхода по Tab */
96
549
  this.tabindex = input(undefined, ...(ngDevMode ? [{ debugName: "tabindex", transform: numberAttribute }] : [{ transform: numberAttribute }]));
550
+ /** Ограничение длины ввода */
97
551
  this.minlength = input(undefined, ...(ngDevMode ? [{ debugName: "minlength", transform: numberAttribute }] : [{ transform: numberAttribute }]));
552
+ /** Ограничение длины ввода */
98
553
  this.maxlength = input(undefined, ...(ngDevMode ? [{ debugName: "maxlength", transform: numberAttribute }] : [{ transform: numberAttribute }]));
554
+ /** Атрибут `size` у `<input>`. Ширину самого поля задаёт `width` */
99
555
  this.inputSize = input(undefined, ...(ngDevMode ? [{ debugName: "inputSize", transform: numberAttribute }] : [{ transform: numberAttribute }]));
100
- this.overlayOptions = input(...(ngDevMode ? [undefined, { debugName: "overlayOptions" }] : []));
101
- this.overlayHideTransition = input('.1s linear', ...(ngDevMode ? [{ debugName: "overlayHideTransition" }] : []));
102
- this.overlayShowTransition = input('.12s cubic-bezier(0, 0, 0.2, 1)', ...(ngDevMode ? [{ debugName: "overlayShowTransition" }] : []));
103
- this.overlayAppendTo = input('body', ...(ngDevMode ? [{ debugName: "overlayAppendTo" }] : []));
104
- this.appendTo$$ = computed(this.computeAppendTo.bind(this), ...(ngDevMode ? [{ debugName: "appendTo$$" }] : []));
105
- effect(() => this.changeInputSize(this.inputRef(), this.size()));
106
- }
107
- computeAppendTo() {
108
- return this.overlayAppendTo() || this.primeConfig.overlayOptions?.appendTo;
109
- }
110
- changeInputSize(inputRef, size) {
111
- if (isNil(inputRef) || isNil(size)) {
112
- return;
113
- }
114
- inputRef.pSize = size;
556
+ /** Значение родителя вручную — для случаев вне `ss-yoda-chain` */
557
+ this.parentValue = input(null, ...(ngDevMode ? [{ debugName: "parentValue" }] : []));
558
+ /** Сменился выбор, включая сброс в `null` */
559
+ this.selectionChanged = output();
560
+ /** Создание по кнопке `+` прошло успешно */
561
+ this.optionCreated = output();
562
+ /** Запрос упал */
563
+ this.requestFailed = output();
564
+ this.isNative$$ = computed(() => {
565
+ const native = this.native();
566
+ return native === 'auto' ? this.isMobile$$() : native;
567
+ }, ...(ngDevMode ? [{ debugName: "isNative$$" }] : []));
568
+ }
569
+ get inputElement() {
570
+ return this.inputRef()?.nativeElement ?? null;
115
571
  }
116
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
117
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.3.18", type: YodaBase, isStandalone: true, inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, inputReadonly: { classPropertyName: "inputReadonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, inputSize: { classPropertyName: "inputSize", publicName: "inputSize", isSignal: true, isRequired: false, transformFunction: null }, overlayOptions: { classPropertyName: "overlayOptions", publicName: "overlayOptions", isSignal: true, isRequired: false, transformFunction: null }, overlayHideTransition: { classPropertyName: "overlayHideTransition", publicName: "overlayHideTransition", isSignal: true, isRequired: false, transformFunction: null }, overlayShowTransition: { classPropertyName: "overlayShowTransition", publicName: "overlayShowTransition", isSignal: true, isRequired: false, transformFunction: null }, overlayAppendTo: { classPropertyName: "overlayAppendTo", publicName: "overlayAppendTo", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "inputRef", first: true, predicate: InputText, descendants: true, isSignal: true }], ngImport: i0 }); }
572
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: BaseDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
573
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.3.18", type: BaseDirective, isStandalone: true, inputs: { repository: { classPropertyName: "repository", publicName: "repository", isSignal: true, isRequired: false, transformFunction: null }, action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: false, transformFunction: null }, apiUrl: { classPropertyName: "apiUrl", publicName: "apiUrl", isSignal: true, isRequired: false, transformFunction: null }, transformOptions: { classPropertyName: "transformOptions", publicName: "transformOptions", isSignal: true, isRequired: false, transformFunction: null }, delay: { classPropertyName: "delay", publicName: "delay", isSignal: true, isRequired: false, transformFunction: null }, minQueryLength: { classPropertyName: "minQueryLength", publicName: "minQueryLength", isSignal: true, isRequired: false, transformFunction: null }, preloadQuery: { classPropertyName: "preloadQuery", publicName: "preloadQuery", isSignal: true, isRequired: false, transformFunction: null }, preloadType: { classPropertyName: "preloadType", publicName: "preloadType", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, native: { classPropertyName: "native", publicName: "native", isSignal: true, isRequired: false, transformFunction: null }, listRender: { classPropertyName: "listRender", publicName: "listRender", isSignal: true, isRequired: false, transformFunction: null }, itemsShow: { classPropertyName: "itemsShow", publicName: "itemsShow", isSignal: true, isRequired: false, transformFunction: null }, scrollHeight: { classPropertyName: "scrollHeight", publicName: "scrollHeight", isSignal: true, isRequired: false, transformFunction: null }, loopScroll: { classPropertyName: "loopScroll", publicName: "loopScroll", isSignal: true, isRequired: false, transformFunction: null }, selectGroup: { classPropertyName: "selectGroup", publicName: "selectGroup", isSignal: true, isRequired: false, transformFunction: null }, groupSticky: { classPropertyName: "groupSticky", publicName: "groupSticky", isSignal: true, isRequired: false, transformFunction: null }, disabledOption: { classPropertyName: "disabledOption", publicName: "disabledOption", isSignal: true, isRequired: false, transformFunction: null }, filterOption: { classPropertyName: "filterOption", publicName: "filterOption", isSignal: true, isRequired: false, transformFunction: null }, autoSelect: { classPropertyName: "autoSelect", publicName: "autoSelect", isSignal: true, isRequired: false, transformFunction: null }, autoSelectClose: { classPropertyName: "autoSelectClose", publicName: "autoSelectClose", isSignal: true, isRequired: false, transformFunction: null }, create: { classPropertyName: "create", publicName: "create", isSignal: true, isRequired: false, transformFunction: null }, createMode: { classPropertyName: "createMode", publicName: "createMode", isSignal: true, isRequired: false, transformFunction: null }, createPlace: { classPropertyName: "createPlace", publicName: "createPlace", isSignal: true, isRequired: false, transformFunction: null }, showHint: { classPropertyName: "showHint", publicName: "showHint", isSignal: true, isRequired: false, transformFunction: null }, showEmpty: { classPropertyName: "showEmpty", publicName: "showEmpty", isSignal: true, isRequired: false, transformFunction: null }, showMore: { classPropertyName: "showMore", publicName: "showMore", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null }, showCounter: { classPropertyName: "showCounter", publicName: "showCounter", isSignal: true, isRequired: false, transformFunction: null }, showHighlight: { classPropertyName: "showHighlight", publicName: "showHighlight", isSignal: true, isRequired: false, transformFunction: null }, showToggle: { classPropertyName: "showToggle", publicName: "showToggle", isSignal: true, isRequired: false, transformFunction: null }, showLoader: { classPropertyName: "showLoader", publicName: "showLoader", isSignal: true, isRequired: false, transformFunction: null }, hintMessage: { classPropertyName: "hintMessage", publicName: "hintMessage", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, moreMessage: { classPropertyName: "moreMessage", publicName: "moreMessage", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, separator: { classPropertyName: "separator", publicName: "separator", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, panelClass: { classPropertyName: "panelClass", publicName: "panelClass", isSignal: true, isRequired: false, transformFunction: null }, scrollStrategy: { classPropertyName: "scrollStrategy", publicName: "scrollStrategy", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, inputReadonly: { classPropertyName: "inputReadonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, minlength: { classPropertyName: "minlength", publicName: "minlength", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, inputSize: { classPropertyName: "inputSize", publicName: "inputSize", isSignal: true, isRequired: false, transformFunction: null }, parentValue: { classPropertyName: "parentValue", publicName: "parentValue", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectionChanged: "selectionChanged", optionCreated: "optionCreated", requestFailed: "requestFailed" }, viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["inputRef"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 }); }
118
574
  }
119
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaBase, decorators: [{
575
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: BaseDirective, decorators: [{
120
576
  type: Directive
121
- }], ctorParameters: () => [], propDecorators: { inputRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => InputText), { isSignal: true }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], inputReadonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], inputSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputSize", required: false }] }], overlayOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "overlayOptions", required: false }] }], overlayHideTransition: [{ type: i0.Input, args: [{ isSignal: true, alias: "overlayHideTransition", required: false }] }], overlayShowTransition: [{ type: i0.Input, args: [{ isSignal: true, alias: "overlayShowTransition", required: false }] }], overlayAppendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "overlayAppendTo", required: false }] }] } });
577
+ }], propDecorators: { inputRef: [{ type: i0.ViewChild, args: ['inputRef', { isSignal: true }] }], repository: [{ type: i0.Input, args: [{ isSignal: true, alias: "repository", required: false }] }], action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: false }] }], apiUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "apiUrl", required: false }] }], transformOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformOptions", required: false }] }], delay: [{ type: i0.Input, args: [{ isSignal: true, alias: "delay", required: false }] }], minQueryLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minQueryLength", required: false }] }], preloadQuery: [{ type: i0.Input, args: [{ isSignal: true, alias: "preloadQuery", required: false }] }], preloadType: [{ type: i0.Input, args: [{ isSignal: true, alias: "preloadType", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], native: [{ type: i0.Input, args: [{ isSignal: true, alias: "native", required: false }] }], listRender: [{ type: i0.Input, args: [{ isSignal: true, alias: "listRender", required: false }] }], itemsShow: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsShow", required: false }] }], scrollHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollHeight", required: false }] }], loopScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "loopScroll", required: false }] }], selectGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectGroup", required: false }] }], groupSticky: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupSticky", required: false }] }], disabledOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledOption", required: false }] }], filterOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterOption", required: false }] }], autoSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoSelect", required: false }] }], autoSelectClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoSelectClose", required: false }] }], create: [{ type: i0.Input, args: [{ isSignal: true, alias: "create", required: false }] }], createMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "createMode", required: false }] }], createPlace: [{ type: i0.Input, args: [{ isSignal: true, alias: "createPlace", required: false }] }], showHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "showHint", required: false }] }], showEmpty: [{ type: i0.Input, args: [{ isSignal: true, alias: "showEmpty", required: false }] }], showMore: [{ type: i0.Input, args: [{ isSignal: true, alias: "showMore", required: false }] }], showClear: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClear", required: false }] }], showCounter: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCounter", required: false }] }], showHighlight: [{ type: i0.Input, args: [{ isSignal: true, alias: "showHighlight", required: false }] }], showToggle: [{ type: i0.Input, args: [{ isSignal: true, alias: "showToggle", required: false }] }], showLoader: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLoader", required: false }] }], hintMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintMessage", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], moreMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "moreMessage", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], separator: [{ type: i0.Input, args: [{ isSignal: true, alias: "separator", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], panelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelClass", required: false }] }], scrollStrategy: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollStrategy", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], inputReadonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }], minlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minlength", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], inputSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputSize", required: false }] }], parentValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentValue", required: false }] }], selectionChanged: [{ type: i0.Output, args: ["selectionChanged"] }], optionCreated: [{ type: i0.Output, args: ["optionCreated"] }], requestFailed: [{ type: i0.Output, args: ["requestFailed"] }] } });
122
578
 
123
- function limitIndex(index, max, circular) {
124
- if (circular) {
125
- return index < 0 ? max : index > max ? 0 : index;
579
+ const WHITESPACE = /\s+/;
580
+ const MARKUP = /^\s*</;
581
+ class IconDirective {
582
+ constructor() {
583
+ this.icons = inject(ICONS);
584
+ this.renderer = inject(Renderer2);
585
+ this.element = inject(ElementRef).nativeElement;
586
+ this.type = input.required(...(ngDevMode ? [{ debugName: "type", alias: 'ssYodaIcon' }] : [{ alias: 'ssYodaIcon' }]));
587
+ this.classNames = [];
588
+ this.node = null;
589
+ effect(() => this.render(this.type()));
126
590
  }
127
- return Math.max(0, Math.min(index || 0, max));
128
- }
129
- function findFirstValidIndex(options, isValid) {
130
- if (isArray(options)) {
131
- return options.findIndex(isValid);
591
+ render(type) {
592
+ this.clear();
593
+ if (isNil(type))
594
+ return;
595
+ const glyph = this.icons[type] ?? '';
596
+ const isMarkup = MARKUP.test(glyph);
597
+ this.addClass(type, isMarkup ? [] : glyph.trim().split(WHITESPACE));
598
+ if (isMarkup) {
599
+ this.addNode(glyph);
600
+ }
132
601
  }
133
- return -1;
602
+ clear() {
603
+ this.classNames.forEach((token) => this.renderer.removeClass(this.element, token));
604
+ this.classNames = [];
605
+ if (this.node) {
606
+ this.renderer.removeChild(this.element, this.node);
607
+ this.node = null;
608
+ }
609
+ }
610
+ addClass(type, classList) {
611
+ const tokens = ['yoda-icon', `yoda-icon--${type}`, ...classList];
612
+ for (const token of tokens) {
613
+ const item = token.trim();
614
+ if (item) {
615
+ this.classNames.push(item);
616
+ this.renderer.addClass(this.element, item);
617
+ }
618
+ }
619
+ }
620
+ addNode(markup) {
621
+ if (!isNonEmptyString(markup))
622
+ return;
623
+ const template = this.renderer.createElement('template');
624
+ template.innerHTML = markup;
625
+ this.node = template.content.firstElementChild;
626
+ if (!this.node)
627
+ return;
628
+ this.renderer.appendChild(this.element, this.node);
629
+ }
630
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: IconDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
631
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.18", type: IconDirective, isStandalone: true, selector: "[ssYodaIcon]", inputs: { type: { classPropertyName: "type", publicName: "ssYodaIcon", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
134
632
  }
633
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: IconDirective, decorators: [{
634
+ type: Directive,
635
+ args: [{
636
+ selector: '[ssYodaIcon]',
637
+ }]
638
+ }], ctorParameters: () => [], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "ssYodaIcon", required: true }] }] } });
135
639
 
136
- // TODO:
137
- // 1. Вынести иконки в отдельных компонент
138
- // 2. Вынести список в отдельный компонент
139
- // 3. Cделать select режим
140
- // 4. Cделать multiple режим
141
- // 5. Сделать режим отображения списка как в оверлее так и как часть контента
142
- // 6. Cделать оутпут евент с выбранными опциями
143
- // 7. на мобилках нужно показывать мобильный дропдаун
144
- class Yoda extends YodaBase {
145
- get transformOptionsFn() {
146
- return this.transformOptions();
147
- }
148
- get disabledOptionFn() {
149
- return this.disabledOption();
640
+ class ActionComponent {
641
+ constructor() {
642
+ this.messages = inject(MESSAGES);
643
+ this.slots = inject(SlotsService);
644
+ this.state = inject(StateService);
645
+ this.type = input.required(...(ngDevMode ? [{ debugName: "type" }] : []));
646
+ this.errorText = input(null, ...(ngDevMode ? [{ debugName: "errorText" }] : []));
647
+ this.selectGroup = input(false, ...(ngDevMode ? [{ debugName: "selectGroup", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
648
+ this.itemsShow = input(null, ...(ngDevMode ? [{ debugName: "itemsShow" }] : []));
649
+ this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
650
+ this.native = input(false, ...(ngDevMode ? [{ debugName: "native", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
651
+ this.activated = output();
652
+ this.config$$ = computed(() => this.resolveConfig(), ...(ngDevMode ? [{ debugName: "config$$" }] : []));
653
+ this.slot$$ = computed(() => {
654
+ const { icon } = this.config$$();
655
+ return this.slots.get(isDefined(icon) ? `${icon}Icon` : 'counter');
656
+ }, ...(ngDevMode ? [{ debugName: "slot$$" }] : []));
657
+ this.icon$$ = computed(() => (this.slot$$() ? null : this.config$$().icon), ...(ngDevMode ? [{ debugName: "icon$$" }] : []));
658
+ this.count$$ = computed(() => {
659
+ const options = this.state.options$$() ?? [];
660
+ return this.selectGroup()
661
+ ? options.length
662
+ : options.filter((option) => option.kind === 'option').length;
663
+ }, ...(ngDevMode ? [{ debugName: "count$$" }] : []));
664
+ }
665
+ counterText() {
666
+ const total = this.count$$();
667
+ const limit = this.itemsShow();
668
+ if (total <= 0)
669
+ return null;
670
+ return isDefined(limit) && total > limit ? `${limit}+` : String(total);
671
+ }
672
+ activate(icon) {
673
+ if (isDefined(icon)) {
674
+ this.activated.emit(icon);
675
+ }
676
+ }
677
+ resolveConfig() {
678
+ switch (this.type()) {
679
+ case 'counter':
680
+ return this.toConfig(null, { interactive: false, text: this.counterText() });
681
+ case 'clear':
682
+ return this.toConfig('clear');
683
+ case 'create':
684
+ return this.toConfig('create');
685
+ case 'state':
686
+ return this.resolveStateConfig();
687
+ }
688
+ }
689
+ resolveStateConfig() {
690
+ const { status } = this.state.requestState$$();
691
+ if (status === 'error') {
692
+ const view = this.toConfig('reload');
693
+ return { ...view, title: this.errorText() ?? view.title };
694
+ }
695
+ if (status === 'loading') {
696
+ return this.toConfig('loader', { interactive: false });
697
+ }
698
+ const canOpen = isNonEmptyArray(this.state.options$$()) && !this.native();
699
+ return this.toConfig('toggle', { interactive: canOpen });
700
+ }
701
+ toConfig(icon, patch = {}) {
702
+ const { label, title } = isDefined(icon) ? this.messages.actions[icon] : {};
703
+ return {
704
+ icon,
705
+ text: null,
706
+ interactive: true,
707
+ label: label ?? null,
708
+ title: title ?? null,
709
+ ...patch,
710
+ };
150
711
  }
712
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
713
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: ActionComponent, isStandalone: true, selector: "ss-yoda-action", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, errorText: { classPropertyName: "errorText", publicName: "errorText", isSignal: true, isRequired: false, transformFunction: null }, selectGroup: { classPropertyName: "selectGroup", publicName: "selectGroup", isSignal: true, isRequired: false, transformFunction: null }, itemsShow: { classPropertyName: "itemsShow", publicName: "itemsShow", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, native: { classPropertyName: "native", publicName: "native", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activated: "activated" }, host: { properties: { "class": "'yoda-action--' + type()" } }, ngImport: i0, template: "@let config = config$$();\n\n@if (config.interactive) {\n <button\n class=\"yoda-action\"\n type=\"button\"\n [attr.title]=\"config.title\"\n [attr.aria-label]=\"config.label\"\n [ssYodaIcon]=\"icon$$()\"\n [disabled]=\"disabled()\"\n (click)=\"activate(config.icon)\"\n (mousedown)=\"$event.preventDefault()\"\n >\n <ng-container [ngTemplateOutlet]=\"body\" />\n </button>\n} @else {\n <span\n class=\"yoda-action\"\n aria-hidden=\"true\"\n [ssYodaIcon]=\"icon$$()\"\n >\n <ng-container [ngTemplateOutlet]=\"body\" />\n </span>\n}\n\n<ng-template #body>\n <ng-container\n *slotOutlet=\"\n slot$$() ?? config.text;\n context: {\n $implicit: config.icon,\n text: config.text,\n };\n let text\n \"\n >\n {{ text }}\n </ng-container>\n</ng-template>\n", styles: [":host{display:inline-flex}.yoda-action{display:inline-flex;flex:0 0 auto;align-items:center;justify-content:center;padding:0;border:0;color:inherit;font:inherit;font-size:var(--ss-yoda-font-size, 1rem);background:transparent;-webkit-user-select:none;user-select:none}:host(.yoda-action--counter) .yoda-action{color:var(--ss-yoda-muted-color, #a1a1aa);font-size:var(--ss-yoda-small-font-size, .875em)}button.yoda-action{cursor:pointer}button.yoda-action:focus:not(:focus-visible){outline:none}button.yoda-action:disabled{cursor:not-allowed;opacity:var(--ss-yoda-action-disabled-opacity, .5)}.yoda-icon{display:inline-flex;color:var(--ss-yoda-icon-color, inherit);font-size:var(--ss-yoda-icon-size, 1rem)}.yoda-icon--reload{color:var(--ss-yoda-error-color, #ef4444)}.yoda-icon--loader{animation:yoda-spin 1s linear infinite}@keyframes yoda-spin{to{rotate:360deg}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: IconDirective, selector: "[ssYodaIcon]", inputs: ["ssYodaIcon"] }, { kind: "directive", type: SlotOutletDirective, selector: "[slotOutlet]", inputs: ["slotOutlet", "slotOutletContext"], exportAs: ["slotOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
714
+ }
715
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ActionComponent, decorators: [{
716
+ type: Component,
717
+ args: [{ selector: 'ss-yoda-action', changeDetection: ChangeDetectionStrategy.OnPush, host: {
718
+ '[class]': "'yoda-action--' + type()",
719
+ }, imports: [NgTemplateOutlet, IconDirective, SlotOutletDirective], template: "@let config = config$$();\n\n@if (config.interactive) {\n <button\n class=\"yoda-action\"\n type=\"button\"\n [attr.title]=\"config.title\"\n [attr.aria-label]=\"config.label\"\n [ssYodaIcon]=\"icon$$()\"\n [disabled]=\"disabled()\"\n (click)=\"activate(config.icon)\"\n (mousedown)=\"$event.preventDefault()\"\n >\n <ng-container [ngTemplateOutlet]=\"body\" />\n </button>\n} @else {\n <span\n class=\"yoda-action\"\n aria-hidden=\"true\"\n [ssYodaIcon]=\"icon$$()\"\n >\n <ng-container [ngTemplateOutlet]=\"body\" />\n </span>\n}\n\n<ng-template #body>\n <ng-container\n *slotOutlet=\"\n slot$$() ?? config.text;\n context: {\n $implicit: config.icon,\n text: config.text,\n };\n let text\n \"\n >\n {{ text }}\n </ng-container>\n</ng-template>\n", styles: [":host{display:inline-flex}.yoda-action{display:inline-flex;flex:0 0 auto;align-items:center;justify-content:center;padding:0;border:0;color:inherit;font:inherit;font-size:var(--ss-yoda-font-size, 1rem);background:transparent;-webkit-user-select:none;user-select:none}:host(.yoda-action--counter) .yoda-action{color:var(--ss-yoda-muted-color, #a1a1aa);font-size:var(--ss-yoda-small-font-size, .875em)}button.yoda-action{cursor:pointer}button.yoda-action:focus:not(:focus-visible){outline:none}button.yoda-action:disabled{cursor:not-allowed;opacity:var(--ss-yoda-action-disabled-opacity, .5)}.yoda-icon{display:inline-flex;color:var(--ss-yoda-icon-color, inherit);font-size:var(--ss-yoda-icon-size, 1rem)}.yoda-icon--reload{color:var(--ss-yoda-error-color, #ef4444)}.yoda-icon--loader{animation:yoda-spin 1s linear infinite}@keyframes yoda-spin{to{rotate:360deg}}\n"] }]
720
+ }], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], errorText: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorText", required: false }] }], selectGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectGroup", required: false }] }], itemsShow: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsShow", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], native: [{ type: i0.Input, args: [{ isSignal: true, alias: "native", required: false }] }], activated: [{ type: i0.Output, args: ["activated"] }] } });
721
+
722
+ const MORE_ROW = { kind: 'more' };
723
+ class ListComponent {
151
724
  constructor() {
152
- super();
153
- this.yodaService = inject(YodaService);
725
+ this.slots = inject(SlotsService);
726
+ this.state = inject(StateService);
154
727
  this.listRef = viewChild('listRef', ...(ngDevMode ? [{ debugName: "listRef" }] : []));
155
- this.hintContentRef = contentChild('hint', ...(ngDevMode ? [{ debugName: "hintContentRef", read: TemplateRef }] : [{ read: TemplateRef }]));
156
- this.emptyContentRef = contentChild('empty', ...(ngDevMode ? [{ debugName: "emptyContentRef", read: TemplateRef }] : [{ read: TemplateRef }]));
157
- this.headerContentRef = contentChild('header', ...(ngDevMode ? [{ debugName: "headerContentRef", read: TemplateRef }] : [{ read: TemplateRef }]));
158
- this.footerContentRef = contentChild('footer', ...(ngDevMode ? [{ debugName: "footerContentRef", read: TemplateRef }] : [{ read: TemplateRef }]));
159
- this.optionContentRef = contentChild('option', ...(ngDevMode ? [{ debugName: "optionContentRef", read: TemplateRef }] : [{ read: TemplateRef }]));
160
- this.groupOptionContentRef = contentChild('groupOption', ...(ngDevMode ? [{ debugName: "groupOptionContentRef", read: TemplateRef }] : [{ read: TemplateRef }]));
161
- this.action = input(...(ngDevMode ? [undefined, { debugName: "action" }] : []));
162
- this.repository = input(...(ngDevMode ? [undefined, { debugName: "repository" }] : []));
163
- this.apiUrl = input(...(ngDevMode ? [undefined, { debugName: "apiUrl" }] : []));
164
- this.hintMessage = input(...(ngDevMode ? [undefined, { debugName: "hintMessage" }] : []));
165
- this.createMode = input('always', ...(ngDevMode ? [{ debugName: "createMode" }] : []));
166
- this.scrollHeight = input('200px', ...(ngDevMode ? [{ debugName: "scrollHeight" }] : []));
167
- this.emptyMessage = input('Элементы не найдены', ...(ngDevMode ? [{ debugName: "emptyMessage" }] : []));
168
- this.viewMode = input('overlay', ...(ngDevMode ? [{ debugName: "viewMode" }] : []));
169
- this.group = input(true, ...(ngDevMode ? [{ debugName: "group", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
170
- this.create = input(false, ...(ngDevMode ? [{ debugName: "create", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
171
- this.showHint = input(true, ...(ngDevMode ? [{ debugName: "showHint", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
172
- this.showEmpty = input(true, ...(ngDevMode ? [{ debugName: "showEmpty", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
173
- this.showClear = input(true, ...(ngDevMode ? [{ debugName: "showClear", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
174
- this.showCreate = input(true, ...(ngDevMode ? [{ debugName: "showCreate", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
728
+ this.itemsShow = input(null, ...(ngDevMode ? [{ debugName: "itemsShow" }] : []));
729
+ this.moreMessage = input(...(ngDevMode ? [undefined, { debugName: "moreMessage" }] : []));
730
+ this.showMore = input(false, ...(ngDevMode ? [{ debugName: "showMore", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
731
+ this.showHighlight = input(false, ...(ngDevMode ? [{ debugName: "showHighlight", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
175
732
  this.loopScroll = input(true, ...(ngDevMode ? [{ debugName: "loopScroll", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
176
- this.showLoading = input(true, ...(ngDevMode ? [{ debugName: "showLoading", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
177
733
  this.selectGroup = input(false, ...(ngDevMode ? [{ debugName: "selectGroup", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
178
734
  this.groupSticky = input(false, ...(ngDevMode ? [{ debugName: "groupSticky", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
179
- this.showDropdown = input(true, ...(ngDevMode ? [{ debugName: "showDropdown", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
180
- this.autoSelect = input(false, ...(ngDevMode ? [{ debugName: "autoSelect", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
181
- this.delay = input(this.config.delay, ...(ngDevMode ? [{ debugName: "delay", transform: (value) => numberAttribute(value, this.config.delay) }] : [{
182
- transform: (value) => numberAttribute(value, this.config.delay),
183
- }]));
184
- this.itemsShow = input(this.config.itemsShow, ...(ngDevMode ? [{ debugName: "itemsShow", transform: (value) => numberAttribute(value, this.config.itemsShow) }] : [{
185
- transform: (value) => numberAttribute(value, this.config.itemsShow),
735
+ this.disabledOption = input(...(ngDevMode ? [undefined, { debugName: "disabledOption" }] : []));
736
+ this.selected = output();
737
+ this.query$$ = this.state.query$$;
738
+ this.optionSlot$$ = computed(() => this.slots.get('option'), ...(ngDevMode ? [{ debugName: "optionSlot$$" }] : []));
739
+ this.groupSlot$$ = computed(() => this.slots.get('group'), ...(ngDevMode ? [{ debugName: "groupSlot$$" }] : []));
740
+ this.options$$ = computed(() => this.state.options$$() ?? [], ...(ngDevMode ? [{ debugName: "options$$" }] : []));
741
+ this.limit$$ = linkedSignal(...(ngDevMode ? [{ debugName: "limit$$", source: () => this.options$$(),
742
+ computation: () => this.itemsShow() }] : [{
743
+ source: () => this.options$$(),
744
+ computation: () => this.itemsShow(),
186
745
  }]));
187
- this.minQueryLength = input(this.config.minQueryLength, ...(ngDevMode ? [{ debugName: "minQueryLength", transform: (value) => numberAttribute(value, this.config.minQueryLength) }] : [{
188
- transform: (value) => numberAttribute(value, this.config.minQueryLength),
746
+ this.visible$$ = computed(() => {
747
+ const options = this.options$$();
748
+ const limit = this.limit$$();
749
+ return isNil(limit) ? options : options.slice(0, limit);
750
+ }, ...(ngDevMode ? [{ debugName: "visible$$" }] : []));
751
+ this.hasMore$$ = computed(() => this.showMore() && this.visible$$().length < this.options$$().length, ...(ngDevMode ? [{ debugName: "hasMore$$" }] : []));
752
+ this.rows$$ = computed(() => {
753
+ const visible = this.visible$$();
754
+ return this.hasMore$$() ? [...visible, MORE_ROW] : visible;
755
+ }, ...(ngDevMode ? [{ debugName: "rows$$" }] : []));
756
+ this.hasGroups$$ = computed(() => this.options$$().some((option) => option.kind === 'group'), ...(ngDevMode ? [{ debugName: "hasGroups$$" }] : []));
757
+ this.focusedIndex$$ = linkedSignal(...(ngDevMode ? [{ debugName: "focusedIndex$$", source: () => this.options$$(),
758
+ computation: () => this.rows$$().findIndex((row) => this.isSelectable(row)) }] : [{
759
+ source: () => this.options$$(),
760
+ computation: () => this.rows$$().findIndex((row) => this.isSelectable(row)),
189
761
  }]));
190
- // TODO: сделать поддержку в интерфейсе
191
- this.disabledOption = input(...(ngDevMode ? [undefined, { debugName: "disabledOption" }] : []));
192
- this.transformOptions = input(...(ngDevMode ? [undefined, { debugName: "transformOptions" }] : []));
193
- this.onTouched = noop;
194
- this.onChange = noop;
195
- this.onValidationChange = noop;
196
- this.touched$$ = signal(false, ...(ngDevMode ? [{ debugName: "touched$$" }] : []));
197
- this.isLoading$$ = signal(false, ...(ngDevMode ? [{ debugName: "isLoading$$" }] : []));
198
- this.overlayVisible$$ = signal(false, ...(ngDevMode ? [{ debugName: "overlayVisible$$" }] : []));
199
- this.focusedOptionIndex$$ = signal(-1, ...(ngDevMode ? [{ debugName: "focusedOptionIndex$$" }] : []));
200
- this.queryString$$ = signal('', ...(ngDevMode ? [{ debugName: "queryString$$" }] : []));
201
- this.options$$ = signal(null, ...(ngDevMode ? [{ debugName: "options$$" }] : []));
202
- this.selectedOptions$$ = signal(null, ...(ngDevMode ? [{ debugName: "selectedOptions$$" }] : []));
203
- this.queryStringControl = new FormControl(null);
204
- this.queryString$ = this.queryStringControl.valueChanges.pipe(map((value) => this.normalizeQueryString(value)));
205
- this.controlSubject = new BehaviorSubject(null);
206
- this.isCreatDisabled$$ = computed(this.computeCreatDisabled.bind(this), ...(ngDevMode ? [{ debugName: "isCreatDisabled$$" }] : []));
207
- this.iconType$$ = computed(this.computeIconType.bind(this), ...(ngDevMode ? [{ debugName: "iconType$$" }] : []));
208
- this.canShowCreate$$ = computed(this.computeCanShowCreate.bind(this), ...(ngDevMode ? [{ debugName: "canShowCreate$$" }] : []));
209
- this.filteredOptions$$ = computed(this.computeFilteredOptions.bind(this), ...(ngDevMode ? [{ debugName: "filteredOptions$$" }] : []));
210
- this.optionsListStatus$$ = computed(this.computeOptionsListStatus.bind(this), ...(ngDevMode ? [{ debugName: "optionsListStatus$$" }] : []));
211
- this.invalid$$ = toSignal(this.controlSubject.pipe(filter(isDefined), switchMap((control) => control.statusChanges), map((status) => status === 'INVALID')), { initialValue: false });
212
- this.formDisabled$$ = signal(false, ...(ngDevMode ? [{ debugName: "formDisabled$$" }] : []));
213
- this.isDisabled$$ = computed(() => this.disabled() || this.formDisabled$$(), ...(ngDevMode ? [{ debugName: "isDisabled$$" }] : []));
214
- this.interactionBlocked$$ = computed(() => !this.overlayVisible$$() ||
215
- this.isDisabled$$() ||
216
- !!this.inputReadonly() ||
217
- this.isLoading$$(), ...(ngDevMode ? [{ debugName: "interactionBlocked$$" }] : []));
218
- effect(this.markTouched.bind(this));
219
- effect(() => this.changeDisabledState(this.isDisabled$$()));
220
- this.queryString$
221
- .pipe(debounceTime(this.delay()), distinctUntilChanged(this.compareFunction), skip(1), tap((queryString) => this.prepareSearch(queryString)), filter((query) => this.isValidQuery(query)), switchMap((query) => this.request(query, 1 /* ActionType.Search */)), tap((data) => this.handleSearch(data)), takeUntilDestroyed())
222
- .subscribe();
223
- }
224
- compareFunction(previos, current) {
225
- return isNonEmptyString(current) ? previos === current : false;
762
+ effect(() => this.scrollToFocused(this.focusedIndex$$()));
226
763
  }
227
- validate(control) {
228
- if (isNil(this.controlSubject.getValue())) {
229
- this.controlSubject.next(control);
230
- }
231
- return null;
764
+ moveFocus(step) {
765
+ const rows = this.rows$$();
766
+ if (isEmptyArray(rows))
767
+ return false;
768
+ const start = this.focusedIndex$$();
769
+ const next = this.findNextValid(rows, start, step);
770
+ if (next === start)
771
+ return false;
772
+ this.focusedIndex$$.set(next);
773
+ return true;
232
774
  }
233
- registerOnValidatorChange(onValidationChange) {
234
- this.onValidationChange = onValidationChange;
775
+ activateFocused() {
776
+ const row = this.rows$$().at(this.focusedIndex$$());
777
+ if (isNil(row) || !this.isSelectable(row))
778
+ return false;
779
+ this.activate(row);
780
+ return true;
235
781
  }
236
- writeValue(value) {
237
- if (isNil(value)) {
782
+ activate(row) {
783
+ if (!this.isSelectable(row))
238
784
  return;
785
+ if (row.kind === 'more')
786
+ return this.expand();
787
+ this.selected.emit(row);
788
+ }
789
+ focus(index, row) {
790
+ if (this.isSelectable(row)) {
791
+ this.focusedIndex$$.set(index);
239
792
  }
240
- this.request(value, 0 /* ActionType.Get */)
241
- .pipe(first(), tap((data) => this.updateWithSelection(data)))
242
- .subscribe();
243
793
  }
244
- registerOnChange(onChange) {
245
- this.onChange = onChange;
794
+ isSelected(row) {
795
+ if (row.kind === 'more' || isNil(row.value))
796
+ return false;
797
+ return this.state.selected$$()?.value === row.value;
246
798
  }
247
- registerOnTouched(onTouched) {
248
- this.onTouched = onTouched;
799
+ isSelectable(row) {
800
+ if (row.kind === 'more')
801
+ return true;
802
+ if (row.kind === 'group' && !this.selectGroup())
803
+ return false;
804
+ const isDisabled = this.disabledOption();
805
+ return isFunction(isDisabled) ? !isDisabled(row) : true;
249
806
  }
250
- setDisabledState(isDisabled) {
251
- this.formDisabled$$.set(isDisabled);
807
+ expand() {
808
+ const step = this.itemsShow();
809
+ if (isNil(step))
810
+ return;
811
+ const next = this.visible$$().length;
812
+ this.limit$$.update((limit) => (limit ?? step) + step);
813
+ this.focusedIndex$$.set(next);
252
814
  }
253
- isValidQuery(queryString) {
254
- return queryString.length > this.minQueryLength();
815
+ findNextValid(rows, start, step) {
816
+ const max = rows.length - 1;
817
+ let next = limitIndex(start + step, max, this.loopScroll());
818
+ for (let attempt = 0; attempt <= max; attempt++) {
819
+ if (this.isSelectable(rows[next]))
820
+ return next;
821
+ next = limitIndex(next + step, max, this.loopScroll());
822
+ if (next === start)
823
+ break;
824
+ }
825
+ return start;
255
826
  }
256
- actionIconClick(event, type) {
257
- if (this.isDisabled$$()) {
827
+ scrollToFocused(index) {
828
+ const container = this.listRef()?.nativeElement;
829
+ if (isNil(container) || index < 0)
258
830
  return;
259
- }
260
- event.stopPropagation();
261
- if (isDefined(this.inputElementRef)) {
262
- this.inputElementRef.focus();
263
- }
264
- switch (type) {
265
- case 'clear':
266
- return this.clear();
267
- case 'create':
268
- return this.createByQuery();
269
- }
831
+ container
832
+ .querySelector(`li[data-index="${index}"]`)
833
+ ?.scrollIntoView({ behavior: 'auto', block: 'nearest', inline: 'nearest' });
270
834
  }
271
- showOverlay() {
272
- this.overlayVisible$$.set(true);
273
- this.focusFirstValidOption();
835
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
836
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: ListComponent, isStandalone: true, selector: "ss-yoda-list", inputs: { itemsShow: { classPropertyName: "itemsShow", publicName: "itemsShow", isSignal: true, isRequired: false, transformFunction: null }, moreMessage: { classPropertyName: "moreMessage", publicName: "moreMessage", isSignal: true, isRequired: false, transformFunction: null }, showMore: { classPropertyName: "showMore", publicName: "showMore", isSignal: true, isRequired: false, transformFunction: null }, showHighlight: { classPropertyName: "showHighlight", publicName: "showHighlight", isSignal: true, isRequired: false, transformFunction: null }, loopScroll: { classPropertyName: "loopScroll", publicName: "loopScroll", isSignal: true, isRequired: false, transformFunction: null }, selectGroup: { classPropertyName: "selectGroup", publicName: "selectGroup", isSignal: true, isRequired: false, transformFunction: null }, groupSticky: { classPropertyName: "groupSticky", publicName: "groupSticky", isSignal: true, isRequired: false, transformFunction: null }, disabledOption: { classPropertyName: "disabledOption", publicName: "disabledOption", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selected" }, viewQueries: [{ propertyName: "listRef", first: true, predicate: ["listRef"], descendants: true, isSignal: true }], ngImport: i0, template: "<ul\n #listRef\n class=\"yoda-list\"\n role=\"listbox\"\n [class.yoda-list--grouped]=\"hasGroups$$()\"\n>\n @for (row of rows$$(); track $index; let index = $index) {\n <li\n class=\"yoda-list__option\"\n role=\"option\"\n tabindex=\"-1\"\n [class.select]=\"isSelected(row)\"\n [class.focus]=\"focusedIndex$$() === index\"\n [class.yoda-list__option--more]=\"row.kind === 'more'\"\n [class.yoda-list__option--group]=\"row.kind === 'group'\"\n [class.yoda-list__option--sticky]=\"row.kind === 'group' && groupSticky()\"\n [attr.data-index]=\"index\"\n [attr.aria-selected]=\"isSelected(row)\"\n [attr.aria-disabled]=\"isSelectable(row) ? null : true\"\n (click)=\"activate(row)\"\n (pointerenter)=\"focus(index, row)\"\n >\n @if (row.kind === 'more') {\n {{ moreMessage() }}\n } @else {\n @let slot = row.kind === 'group' ? groupSlot$$() : optionSlot$$();\n\n <ng-container\n *slotOutlet=\"\n slot ?? row;\n context: {\n $implicit: row,\n query: query$$(),\n };\n let item\n \"\n >\n @if (showHighlight() && item.kind === 'option') {\n <span [innerHTML]=\"item.label | highlight: query$$()\"></span>\n } @else {\n {{ item.label }}\n }\n </ng-container>\n }\n </li>\n }\n</ul>\n", styles: [":host{display:block}.yoda-list{display:flex;flex-direction:column;margin:0;padding:0;color:var(--ss-yoda-list-color, inherit);list-style-type:none}.yoda-list--grouped .yoda-list__option{padding-inline-start:var(--ss-yoda-list-nested-padding, 1.5rem)}.yoda-list--grouped .yoda-list__option--group,.yoda-list--grouped .yoda-list__option--more{padding-inline-start:var(--ss-yoda-padding-x, .75rem)}.yoda-list__option{padding:var(--ss-yoda-padding-y, .5rem) var(--ss-yoda-padding-x, .75rem);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;scroll-margin-block-start:var(--ss-yoda-group-height, 2.25rem)}.yoda-list__option.focus{color:var(--ss-yoda-list-focus-color, #3b82f6);background:var(--ss-yoda-list-focus-background, rgba(59, 130, 246, .08));cursor:pointer}.yoda-list__option.select{color:var(--ss-yoda-list-selected-color, inherit);font-weight:600;background:var(--ss-yoda-list-selected-background, rgba(59, 130, 246, .14))}.yoda-list__option.select.focus{color:var(--ss-yoda-list-selected-focus-color, var(--ss-yoda-list-selected-color, inherit));background:var(--ss-yoda-list-selected-focus-background, rgba(59, 130, 246, .2))}.yoda-list__option[aria-disabled=true]{color:var(--ss-yoda-muted-color, #a1a1aa);cursor:not-allowed}.yoda-list__option--group[aria-disabled=true]{cursor:default}.yoda-list__option--group{color:var(--ss-yoda-muted-color, #71717a);font-size:var(--ss-yoda-group-font-size, .8125em);font-weight:600}.yoda-list__option--group:not([aria-disabled=true]){color:inherit;cursor:pointer}.yoda-list__option--sticky{position:sticky;inset-block-start:0;z-index:1;background:var(--ss-yoda-panel-background, #fff)}.yoda-list__option--more{color:var(--ss-yoda-accent-color, #3b82f6);font-size:var(--ss-yoda-small-font-size, .875em);font-weight:600;text-align:center;border-block-start:1px solid var(--ss-yoda-separator-color, #e4e4e7);cursor:pointer}.yoda-list__option--more.focus{color:var(--ss-yoda-accent-color, #3b82f6);background:var(--ss-yoda-list-focus-background, rgba(59, 130, 246, .08))}\n"], dependencies: [{ kind: "directive", type: SlotOutletDirective, selector: "[slotOutlet]", inputs: ["slotOutlet", "slotOutletContext"], exportAs: ["slotOutlet"] }, { kind: "pipe", type: HighlightPipe, name: "highlight" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
837
+ }
838
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ListComponent, decorators: [{
839
+ type: Component,
840
+ args: [{ selector: 'ss-yoda-list', changeDetection: ChangeDetectionStrategy.OnPush, imports: [HighlightPipe, SlotOutletDirective], template: "<ul\n #listRef\n class=\"yoda-list\"\n role=\"listbox\"\n [class.yoda-list--grouped]=\"hasGroups$$()\"\n>\n @for (row of rows$$(); track $index; let index = $index) {\n <li\n class=\"yoda-list__option\"\n role=\"option\"\n tabindex=\"-1\"\n [class.select]=\"isSelected(row)\"\n [class.focus]=\"focusedIndex$$() === index\"\n [class.yoda-list__option--more]=\"row.kind === 'more'\"\n [class.yoda-list__option--group]=\"row.kind === 'group'\"\n [class.yoda-list__option--sticky]=\"row.kind === 'group' && groupSticky()\"\n [attr.data-index]=\"index\"\n [attr.aria-selected]=\"isSelected(row)\"\n [attr.aria-disabled]=\"isSelectable(row) ? null : true\"\n (click)=\"activate(row)\"\n (pointerenter)=\"focus(index, row)\"\n >\n @if (row.kind === 'more') {\n {{ moreMessage() }}\n } @else {\n @let slot = row.kind === 'group' ? groupSlot$$() : optionSlot$$();\n\n <ng-container\n *slotOutlet=\"\n slot ?? row;\n context: {\n $implicit: row,\n query: query$$(),\n };\n let item\n \"\n >\n @if (showHighlight() && item.kind === 'option') {\n <span [innerHTML]=\"item.label | highlight: query$$()\"></span>\n } @else {\n {{ item.label }}\n }\n </ng-container>\n }\n </li>\n }\n</ul>\n", styles: [":host{display:block}.yoda-list{display:flex;flex-direction:column;margin:0;padding:0;color:var(--ss-yoda-list-color, inherit);list-style-type:none}.yoda-list--grouped .yoda-list__option{padding-inline-start:var(--ss-yoda-list-nested-padding, 1.5rem)}.yoda-list--grouped .yoda-list__option--group,.yoda-list--grouped .yoda-list__option--more{padding-inline-start:var(--ss-yoda-padding-x, .75rem)}.yoda-list__option{padding:var(--ss-yoda-padding-y, .5rem) var(--ss-yoda-padding-x, .75rem);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;scroll-margin-block-start:var(--ss-yoda-group-height, 2.25rem)}.yoda-list__option.focus{color:var(--ss-yoda-list-focus-color, #3b82f6);background:var(--ss-yoda-list-focus-background, rgba(59, 130, 246, .08));cursor:pointer}.yoda-list__option.select{color:var(--ss-yoda-list-selected-color, inherit);font-weight:600;background:var(--ss-yoda-list-selected-background, rgba(59, 130, 246, .14))}.yoda-list__option.select.focus{color:var(--ss-yoda-list-selected-focus-color, var(--ss-yoda-list-selected-color, inherit));background:var(--ss-yoda-list-selected-focus-background, rgba(59, 130, 246, .2))}.yoda-list__option[aria-disabled=true]{color:var(--ss-yoda-muted-color, #a1a1aa);cursor:not-allowed}.yoda-list__option--group[aria-disabled=true]{cursor:default}.yoda-list__option--group{color:var(--ss-yoda-muted-color, #71717a);font-size:var(--ss-yoda-group-font-size, .8125em);font-weight:600}.yoda-list__option--group:not([aria-disabled=true]){color:inherit;cursor:pointer}.yoda-list__option--sticky{position:sticky;inset-block-start:0;z-index:1;background:var(--ss-yoda-panel-background, #fff)}.yoda-list__option--more{color:var(--ss-yoda-accent-color, #3b82f6);font-size:var(--ss-yoda-small-font-size, .875em);font-weight:600;text-align:center;border-block-start:1px solid var(--ss-yoda-separator-color, #e4e4e7);cursor:pointer}.yoda-list__option--more.focus{color:var(--ss-yoda-accent-color, #3b82f6);background:var(--ss-yoda-list-focus-background, rgba(59, 130, 246, .08))}\n"] }]
841
+ }], ctorParameters: () => [], propDecorators: { listRef: [{ type: i0.ViewChild, args: ['listRef', { isSignal: true }] }], itemsShow: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsShow", required: false }] }], moreMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "moreMessage", required: false }] }], showMore: [{ type: i0.Input, args: [{ isSignal: true, alias: "showMore", required: false }] }], showHighlight: [{ type: i0.Input, args: [{ isSignal: true, alias: "showHighlight", required: false }] }], loopScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "loopScroll", required: false }] }], selectGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectGroup", required: false }] }], groupSticky: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupSticky", required: false }] }], disabledOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledOption", required: false }] }], selected: [{ type: i0.Output, args: ["selected"] }] } });
842
+ function limitIndex(index, max, circular) {
843
+ if (circular) {
844
+ return index < 0 ? max : index > max ? 0 : index;
274
845
  }
275
- hideOverlay() {
276
- this.overlayVisible$$.set(false);
277
- this.focusedOptionIndex$$.set(-1);
846
+ return Math.max(0, Math.min(index, max));
847
+ }
848
+
849
+ class NativeComponent {
850
+ constructor() {
851
+ this.state = inject(StateService);
852
+ this.selectRef = viewChild('nativeRef', ...(ngDevMode ? [{ debugName: "selectRef" }] : []));
853
+ this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
854
+ this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
855
+ this.groups$$ = computed(() => {
856
+ const result = [];
857
+ let current = null;
858
+ for (const option of this.state.options$$() ?? []) {
859
+ if (option.kind === 'group') {
860
+ current = { label: option.label, items: [] };
861
+ result.push(current);
862
+ continue;
863
+ }
864
+ if (isNil(current)) {
865
+ current = { label: null, items: [] };
866
+ result.push(current);
867
+ }
868
+ current.items.push(option);
869
+ }
870
+ return result;
871
+ }, ...(ngDevMode ? [{ debugName: "groups$$" }] : []));
872
+ effect(() => this.syncValue(this.groups$$()));
278
873
  }
279
- clear() {
280
- this.options$$.set(null);
281
- this.updateQueryString(null);
282
- this.updateSelectedOption(null);
283
- }
284
- inputFocus(event) {
285
- event.preventDefault();
286
- event.stopPropagation();
287
- if (this.overlayVisible$$()) {
288
- return;
289
- }
290
- if (this.inputReadonly() || this.isDisabled$$() || isNil(this.optionsListStatus$$())) {
291
- return;
874
+ syncValue(_) {
875
+ const selected = this.state.selected$$();
876
+ const select = this.selectRef()?.nativeElement;
877
+ if (select) {
878
+ select.value = String(selected?.value ?? '');
292
879
  }
293
- this.overlayVisible$$.set(true);
294
880
  }
295
- onSelectOption(event) {
296
- if (this.interactionBlocked$$()) {
297
- return;
881
+ select(value, options) {
882
+ const option = options.find((item) => item.kind === 'option' && String(item.value) === value);
883
+ if (isDefined(option)) {
884
+ this.state.select(option);
298
885
  }
299
- event.stopPropagation();
300
- event.preventDefault();
301
- this.selectFocusedOption();
302
886
  }
303
- moveFocus(event, index) {
304
- if (this.interactionBlocked$$()) {
887
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: NativeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
888
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: NativeComponent, isStandalone: true, selector: "ss-yoda-native", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "selectRef", first: true, predicate: ["nativeRef"], descendants: true, isSignal: true }], ngImport: i0, template: "<select\n #nativeRef\n [disabled]=\"disabled()\"\n (change)=\"select(nativeRef.value, state.options$$() ?? [])\"\n>\n <option\n disabled\n value=\"\"\n >\n {{ placeholder() }}\n </option>\n\n @for (group of groups$$(); track $index) {\n @if (group.label; as label) {\n <optgroup [label]=\"label\">\n @for (item of group.items; track item.value) {\n <option [value]=\"item.value\">{{ item.label }}</option>\n }\n </optgroup>\n } @else {\n @for (item of group.items; track item.value) {\n <option [value]=\"item.value\">{{ item.label }}</option>\n }\n }\n }\n</select>\n", styles: [":host{position:absolute;top:0;right:0;bottom:0;left:0}select{inline-size:100%;block-size:100%;-webkit-appearance:none;appearance:none;border:0;opacity:0;cursor:pointer}select:disabled{cursor:not-allowed}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
889
+ }
890
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: NativeComponent, decorators: [{
891
+ type: Component,
892
+ args: [{ selector: 'ss-yoda-native', changeDetection: ChangeDetectionStrategy.OnPush, template: "<select\n #nativeRef\n [disabled]=\"disabled()\"\n (change)=\"select(nativeRef.value, state.options$$() ?? [])\"\n>\n <option\n disabled\n value=\"\"\n >\n {{ placeholder() }}\n </option>\n\n @for (group of groups$$(); track $index) {\n @if (group.label; as label) {\n <optgroup [label]=\"label\">\n @for (item of group.items; track item.value) {\n <option [value]=\"item.value\">{{ item.label }}</option>\n }\n </optgroup>\n } @else {\n @for (item of group.items; track item.value) {\n <option [value]=\"item.value\">{{ item.label }}</option>\n }\n }\n }\n</select>\n", styles: [":host{position:absolute;top:0;right:0;bottom:0;left:0}select{inline-size:100%;block-size:100%;-webkit-appearance:none;appearance:none;border:0;opacity:0;cursor:pointer}select:disabled{cursor:not-allowed}\n"] }]
893
+ }], ctorParameters: () => [], propDecorators: { selectRef: [{ type: i0.ViewChild, args: ['nativeRef', { isSignal: true }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
894
+
895
+ class PanelComponent {
896
+ applyZIndex(isOpen) {
897
+ if (!isOpen)
305
898
  return;
306
- }
307
- event.preventDefault();
308
- event.stopPropagation();
309
- const options = this.filteredOptions$$();
310
- if (isNil(options)) {
899
+ const container = this.overlayContainer.getContainerElement();
900
+ container.style.zIndex = String(this.zIndex(this.config.overlay.zIndex));
901
+ }
902
+ onPositionChange({ connectionPair }) {
903
+ this.above$$.set(connectionPair.overlayY === 'bottom');
904
+ }
905
+ constructor() {
906
+ this.config = inject(CONFIG);
907
+ this.slots = inject(SlotsService);
908
+ this.state = inject(StateService);
909
+ this.scrollStrategies = inject(ScrollStrategyOptions);
910
+ this.overlayContainer = inject(OverlayContainer);
911
+ this.zIndex = inject(Z_INDEX);
912
+ this.origin = input.required(...(ngDevMode ? [{ debugName: "origin" }] : []));
913
+ this.listRender = input('overlay', ...(ngDevMode ? [{ debugName: "listRender" }] : []));
914
+ this.scrollStrategy = input('reposition', ...(ngDevMode ? [{ debugName: "scrollStrategy" }] : []));
915
+ this.panelClass = input('', ...(ngDevMode ? [{ debugName: "panelClass" }] : []));
916
+ this.scrollHeight = input('200px', ...(ngDevMode ? [{ debugName: "scrollHeight" }] : []));
917
+ this.showHint = input(true, ...(ngDevMode ? [{ debugName: "showHint", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
918
+ this.showEmpty = input(true, ...(ngDevMode ? [{ debugName: "showEmpty", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
919
+ this.minQueryLength = input(0, ...(ngDevMode ? [{ debugName: "minQueryLength", transform: numberAttribute }] : [{ transform: numberAttribute }]));
920
+ this.hintMessage = input(...(ngDevMode ? [undefined, { debugName: "hintMessage" }] : []));
921
+ this.emptyMessage = input(...(ngDevMode ? [undefined, { debugName: "emptyMessage" }] : []));
922
+ this.hintSlot$$ = computed(() => this.slots.get('hint'), ...(ngDevMode ? [{ debugName: "hintSlot$$" }] : []));
923
+ this.emptySlot$$ = computed(() => this.slots.get('empty'), ...(ngDevMode ? [{ debugName: "emptySlot$$" }] : []));
924
+ this.headerSlot$$ = computed(() => this.slots.get('header'), ...(ngDevMode ? [{ debugName: "headerSlot$$" }] : []));
925
+ this.footerSlot$$ = computed(() => this.slots.get('footer'), ...(ngDevMode ? [{ debugName: "footerSlot$$" }] : []));
926
+ this.isOpen$$ = computed(() => this.state.isOpen$$() && this.status$$() !== null, ...(ngDevMode ? [{ debugName: "isOpen$$" }] : []));
927
+ this.status$$ = computed(() => {
928
+ if (this.canShowHint())
929
+ return 'hint';
930
+ if (this.canShowEmpty())
931
+ return 'empty';
932
+ return isNonEmptyArray(this.state.options$$()) ? 'list' : null;
933
+ }, ...(ngDevMode ? [{ debugName: "status$$" }] : []));
934
+ this.positions = [
935
+ CONNECTED_POSITION_BELOW,
936
+ CONNECTED_POSITION_ABOVE,
937
+ ];
938
+ this.above$$ = signal(false, ...(ngDevMode ? [{ debugName: "above$$" }] : []));
939
+ this.width$$ = computed(() => {
940
+ if (!this.isOpen$$() || !this.config.overlay.matchWidth)
941
+ return '';
942
+ return this.origin().nativeElement.getBoundingClientRect().width;
943
+ }, ...(ngDevMode ? [{ debugName: "width$$" }] : []));
944
+ this.scrollStrategy$$ = computed(() => this.scrollStrategies[this.scrollStrategy()](), ...(ngDevMode ? [{ debugName: "scrollStrategy$$" }] : []));
945
+ effect(() => this.applyZIndex(this.isOpen$$()));
946
+ }
947
+ close(event) {
948
+ if (event && this.origin().nativeElement.contains(event.target))
311
949
  return;
312
- }
313
- this.focusedOptionIndex$$.update((currentIndex) => {
314
- if (event instanceof PointerEvent) {
315
- return this.isValidOption(options.at(index)) ? index : currentIndex;
316
- }
317
- return this.findNextValidIndex(options, currentIndex, index);
318
- });
319
- if (event instanceof KeyboardEvent) {
320
- this.scrollToFocused();
321
- }
950
+ this.state.close();
322
951
  }
323
- computeFilteredOptions() {
324
- let options = this.options$$();
325
- if (isNil(options)) {
326
- return null;
327
- }
328
- if (this.itemsShow() > 0) {
329
- options = options.slice(0, this.itemsShow());
330
- }
331
- return options;
952
+ canShowHint() {
953
+ const hasContent = this.hintSlot$$() !== null || isNonEmptyString(this.hintMessage());
954
+ return (this.showHint() &&
955
+ hasContent &&
956
+ isNil(this.state.options$$()) &&
957
+ this.state.query$$().length <= this.minQueryLength());
332
958
  }
333
- computeCanShowCreate() {
334
- if (!this.create()) {
335
- return false;
959
+ canShowEmpty() {
960
+ const hasContent = this.emptySlot$$() !== null || isNonEmptyString(this.emptyMessage());
961
+ return this.showEmpty() && isEmptyArray(this.state.options$$()) && hasContent;
962
+ }
963
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: PanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
964
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: PanelComponent, isStandalone: true, selector: "ss-yoda-panel", inputs: { origin: { classPropertyName: "origin", publicName: "origin", isSignal: true, isRequired: true, transformFunction: null }, listRender: { classPropertyName: "listRender", publicName: "listRender", isSignal: true, isRequired: false, transformFunction: null }, scrollStrategy: { classPropertyName: "scrollStrategy", publicName: "scrollStrategy", isSignal: true, isRequired: false, transformFunction: null }, panelClass: { classPropertyName: "panelClass", publicName: "panelClass", isSignal: true, isRequired: false, transformFunction: null }, scrollHeight: { classPropertyName: "scrollHeight", publicName: "scrollHeight", isSignal: true, isRequired: false, transformFunction: null }, showHint: { classPropertyName: "showHint", publicName: "showHint", isSignal: true, isRequired: false, transformFunction: null }, showEmpty: { classPropertyName: "showEmpty", publicName: "showEmpty", isSignal: true, isRequired: false, transformFunction: null }, minQueryLength: { classPropertyName: "minQueryLength", publicName: "minQueryLength", isSignal: true, isRequired: false, transformFunction: null }, hintMessage: { classPropertyName: "hintMessage", publicName: "hintMessage", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@let status = status$$();\n\n@if (listRender() === 'overlay') {\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOpen]=\"isOpen$$()\"\n [cdkConnectedOverlayWidth]=\"width$$()\"\n [cdkConnectedOverlayOrigin]=\"origin()\"\n [cdkConnectedOverlayPositions]=\"positions\"\n [cdkConnectedOverlayPanelClass]=\"panelClass()\"\n [cdkConnectedOverlayScrollStrategy]=\"scrollStrategy$$()\"\n (detach)=\"close()\"\n (overlayOutsideClick)=\"close($event)\"\n (positionChange)=\"onPositionChange($event)\"\n >\n <ng-container [ngTemplateOutlet]=\"layout\" />\n </ng-template>\n} @else if (isOpen$$()) {\n <ng-container [ngTemplateOutlet]=\"layout\" />\n}\n\n<ng-template #layout>\n <section\n class=\"yoda-panel\"\n [class.yoda-panel--above]=\"above$$()\"\n [class.yoda-panel--overlay]=\"listRender() === 'overlay'\"\n >\n @if (status === 'list' && headerSlot$$(); as header) {\n <header class=\"yoda-panel__header\">\n <ng-container [ngTemplateOutlet]=\"header\" />\n </header>\n }\n\n <div\n class=\"yoda-panel__content\"\n tabindex=\"-1\"\n [style.max-block-size]=\"scrollHeight()\"\n >\n @switch (status) {\n @case ('hint') {\n <div class=\"yoda-panel__message\">\n <ng-container *slotOutlet=\"hintSlot$$() ?? hintMessage(); let text\">\n <span>{{ text }}</span>\n </ng-container>\n </div>\n }\n\n @case ('empty') {\n <div class=\"yoda-panel__message\">\n <ng-container *slotOutlet=\"emptySlot$$() ?? emptyMessage(); let text\">\n <span>{{ text }}</span>\n </ng-container>\n </div>\n }\n\n @case ('list') {\n <ng-content select=\"ss-yoda-list\" />\n }\n }\n </div>\n\n @if (status === 'list' && footerSlot$$(); as footer) {\n <footer class=\"yoda-panel__footer\">\n <ng-container [ngTemplateOutlet]=\"footer\" />\n </footer>\n }\n </section>\n</ng-template>\n", styles: [":host{display:flex;flex-direction:column}.yoda-panel{display:flex;outline:none;overflow:hidden;flex-wrap:nowrap;flex-direction:column;color:var(--ss-yoda-panel-color, inherit);background:var(--ss-yoda-panel-background, #fff);margin-block-start:var(--ss-yoda-panel-offset, .25rem);border-radius:var(--ss-yoda-panel-radius, var(--ss-yoda-radius, 6px));border:1px solid var(--ss-yoda-panel-border-color, var(--ss-yoda-border-color, #d4d4d8))}.yoda-panel--overlay{min-inline-size:100%;box-shadow:var(--ss-yoda-panel-shadow, 0 4px 12px rgba(0, 0, 0, .12))}.yoda-panel--above{margin-block-start:0;margin-block-end:var(--ss-yoda-panel-offset, .25rem)}.yoda-panel__content{overflow:auto;outline:none}.yoda-panel__header,.yoda-panel__footer{display:flex;flex-direction:column;gap:var(--ss-yoda-gap, .5rem);color:var(--ss-yoda-muted-color, #71717a);font-size:var(--ss-yoda-small-font-size, .875em);padding:var(--ss-yoda-padding-y, .5rem) var(--ss-yoda-padding-x, .75rem)}.yoda-panel__header{border-block-end:1px solid var(--ss-yoda-separator-color, #e4e4e7)}.yoda-panel__footer{border-block-start:1px solid var(--ss-yoda-separator-color, #e4e4e7)}.yoda-panel__message{display:flex;align-items:center;gap:var(--ss-yoda-gap, .5rem);color:var(--ss-yoda-muted-color, #71717a);padding:var(--ss-yoda-padding-y, .5rem) var(--ss-yoda-padding-x, .75rem)}::ng-deep .cdk-overlay-container,::ng-deep .cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}::ng-deep .cdk-overlay-container{position:fixed;z-index:1000}::ng-deep .cdk-overlay-container:empty{display:none}::ng-deep .cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}::ng-deep .cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}::ng-deep .cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:transparent;opacity:0;touch-action:manipulation;z-index:1000;transition:opacity .4s cubic-bezier(.25,.8,.25,1)}@media (prefers-reduced-motion){::ng-deep .cdk-overlay-backdrop{transition-duration:1ms}}::ng-deep .cdk-overlay-backdrop-showing{opacity:1}@media (forced-colors: active){::ng-deep .cdk-overlay-backdrop-showing{opacity:.6}}::ng-deep .cdk-overlay-dark-backdrop{background:#00000052}::ng-deep .cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}::ng-deep .cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active ::ng-deep .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}::ng-deep .cdk-overlay-backdrop-noop-animation{transition:none}::ng-deep .cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}::ng-deep .cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i1.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: SlotOutletDirective, selector: "[slotOutlet]", inputs: ["slotOutlet", "slotOutletContext"], exportAs: ["slotOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
965
+ }
966
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: PanelComponent, decorators: [{
967
+ type: Component,
968
+ args: [{ selector: 'ss-yoda-panel', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet, OverlayModule, SlotOutletDirective], template: "@let status = status$$();\n\n@if (listRender() === 'overlay') {\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOpen]=\"isOpen$$()\"\n [cdkConnectedOverlayWidth]=\"width$$()\"\n [cdkConnectedOverlayOrigin]=\"origin()\"\n [cdkConnectedOverlayPositions]=\"positions\"\n [cdkConnectedOverlayPanelClass]=\"panelClass()\"\n [cdkConnectedOverlayScrollStrategy]=\"scrollStrategy$$()\"\n (detach)=\"close()\"\n (overlayOutsideClick)=\"close($event)\"\n (positionChange)=\"onPositionChange($event)\"\n >\n <ng-container [ngTemplateOutlet]=\"layout\" />\n </ng-template>\n} @else if (isOpen$$()) {\n <ng-container [ngTemplateOutlet]=\"layout\" />\n}\n\n<ng-template #layout>\n <section\n class=\"yoda-panel\"\n [class.yoda-panel--above]=\"above$$()\"\n [class.yoda-panel--overlay]=\"listRender() === 'overlay'\"\n >\n @if (status === 'list' && headerSlot$$(); as header) {\n <header class=\"yoda-panel__header\">\n <ng-container [ngTemplateOutlet]=\"header\" />\n </header>\n }\n\n <div\n class=\"yoda-panel__content\"\n tabindex=\"-1\"\n [style.max-block-size]=\"scrollHeight()\"\n >\n @switch (status) {\n @case ('hint') {\n <div class=\"yoda-panel__message\">\n <ng-container *slotOutlet=\"hintSlot$$() ?? hintMessage(); let text\">\n <span>{{ text }}</span>\n </ng-container>\n </div>\n }\n\n @case ('empty') {\n <div class=\"yoda-panel__message\">\n <ng-container *slotOutlet=\"emptySlot$$() ?? emptyMessage(); let text\">\n <span>{{ text }}</span>\n </ng-container>\n </div>\n }\n\n @case ('list') {\n <ng-content select=\"ss-yoda-list\" />\n }\n }\n </div>\n\n @if (status === 'list' && footerSlot$$(); as footer) {\n <footer class=\"yoda-panel__footer\">\n <ng-container [ngTemplateOutlet]=\"footer\" />\n </footer>\n }\n </section>\n</ng-template>\n", styles: [":host{display:flex;flex-direction:column}.yoda-panel{display:flex;outline:none;overflow:hidden;flex-wrap:nowrap;flex-direction:column;color:var(--ss-yoda-panel-color, inherit);background:var(--ss-yoda-panel-background, #fff);margin-block-start:var(--ss-yoda-panel-offset, .25rem);border-radius:var(--ss-yoda-panel-radius, var(--ss-yoda-radius, 6px));border:1px solid var(--ss-yoda-panel-border-color, var(--ss-yoda-border-color, #d4d4d8))}.yoda-panel--overlay{min-inline-size:100%;box-shadow:var(--ss-yoda-panel-shadow, 0 4px 12px rgba(0, 0, 0, .12))}.yoda-panel--above{margin-block-start:0;margin-block-end:var(--ss-yoda-panel-offset, .25rem)}.yoda-panel__content{overflow:auto;outline:none}.yoda-panel__header,.yoda-panel__footer{display:flex;flex-direction:column;gap:var(--ss-yoda-gap, .5rem);color:var(--ss-yoda-muted-color, #71717a);font-size:var(--ss-yoda-small-font-size, .875em);padding:var(--ss-yoda-padding-y, .5rem) var(--ss-yoda-padding-x, .75rem)}.yoda-panel__header{border-block-end:1px solid var(--ss-yoda-separator-color, #e4e4e7)}.yoda-panel__footer{border-block-start:1px solid var(--ss-yoda-separator-color, #e4e4e7)}.yoda-panel__message{display:flex;align-items:center;gap:var(--ss-yoda-gap, .5rem);color:var(--ss-yoda-muted-color, #71717a);padding:var(--ss-yoda-padding-y, .5rem) var(--ss-yoda-padding-x, .75rem)}::ng-deep .cdk-overlay-container,::ng-deep .cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}::ng-deep .cdk-overlay-container{position:fixed;z-index:1000}::ng-deep .cdk-overlay-container:empty{display:none}::ng-deep .cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}::ng-deep .cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}::ng-deep .cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:transparent;opacity:0;touch-action:manipulation;z-index:1000;transition:opacity .4s cubic-bezier(.25,.8,.25,1)}@media (prefers-reduced-motion){::ng-deep .cdk-overlay-backdrop{transition-duration:1ms}}::ng-deep .cdk-overlay-backdrop-showing{opacity:1}@media (forced-colors: active){::ng-deep .cdk-overlay-backdrop-showing{opacity:.6}}::ng-deep .cdk-overlay-dark-backdrop{background:#00000052}::ng-deep .cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}::ng-deep .cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active ::ng-deep .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}::ng-deep .cdk-overlay-backdrop-noop-animation{transition:none}::ng-deep .cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}::ng-deep .cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}\n"] }]
969
+ }], ctorParameters: () => [], propDecorators: { origin: [{ type: i0.Input, args: [{ isSignal: true, alias: "origin", required: true }] }], listRender: [{ type: i0.Input, args: [{ isSignal: true, alias: "listRender", required: false }] }], scrollStrategy: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollStrategy", required: false }] }], panelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelClass", required: false }] }], scrollHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollHeight", required: false }] }], showHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "showHint", required: false }] }], showEmpty: [{ type: i0.Input, args: [{ isSignal: true, alias: "showEmpty", required: false }] }], minQueryLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minQueryLength", required: false }] }], hintMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintMessage", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }] } });
970
+
971
+ /** Ключ ошибки в `control.errors` */
972
+ const REQUEST_ERROR = 'yodaRequest';
973
+ class Yoda extends BaseDirective {
974
+ constructor() {
975
+ super();
976
+ this.chain = inject(ChainService, { optional: true });
977
+ this.ngControl = inject(NgControl, { optional: true, self: true });
978
+ this.state = inject(StateService);
979
+ this.list = viewChild(ListComponent, ...(ngDevMode ? [{ debugName: "list" }] : []));
980
+ this.selection$$ = this.state.selected$$;
981
+ this.typed$$ = signal('', ...(ngDevMode ? [{ debugName: "typed$$" }] : []));
982
+ this.formDisabled$$ = signal(false, ...(ngDevMode ? [{ debugName: "formDisabled$$" }] : []));
983
+ this.control$$ = signal(null, ...(ngDevMode ? [{ debugName: "control$$" }] : []));
984
+ this.onTouched = noop;
985
+ this.onChange = noop;
986
+ this.lastValue = null;
987
+ this.flexBasis$$ = computed(() => {
988
+ const width = this.width();
989
+ return isNil(width) || !this.chainInline$$() ? null : `0 0 ${width}`;
990
+ }, ...(ngDevMode ? [{ debugName: "flexBasis$$" }] : []));
991
+ this.chainPending$$ = computed(() => this.chained$$() && isNil(this.parentValue$$()), ...(ngDevMode ? [{ debugName: "chainPending$$" }] : []));
992
+ this.chainInline$$ = computed(() => this.chain?.inline$$() ?? false, ...(ngDevMode ? [{ debugName: "chainInline$$" }] : []));
993
+ this.chainHidden$$ = computed(() => this.chainPending$$() && this.chain?.pending$$() === 'hide', ...(ngDevMode ? [{ debugName: "chainHidden$$" }] : []));
994
+ this.chainPosition$$ = computed(() => this.chainInline$$() ? (this.chain?.position(this) ?? null) : null, ...(ngDevMode ? [{ debugName: "chainPosition$$" }] : []));
995
+ this.chained$$ = computed(() => this.chain?.parentValue(this) !== undefined, ...(ngDevMode ? [{ debugName: "chained$$" }] : []));
996
+ this.chainDisabled$$ = computed(() => this.chainPending$$() && this.chain?.pending$$() === 'disable', ...(ngDevMode ? [{ debugName: "chainDisabled$$" }] : []));
997
+ this.isDisabled$$ = computed(() => this.disabled() || this.formDisabled$$() || this.chainDisabled$$(), ...(ngDevMode ? [{ debugName: "isDisabled$$" }] : []));
998
+ this.isLocked$$ = computed(() => this.isDisabled$$() || !!this.inputReadonly(), ...(ngDevMode ? [{ debugName: "isLocked$$" }] : []));
999
+ this.controlEvent$$ = toSignal(toObservable(this.control$$).pipe(switchMap((control) => control?.events ?? EMPTY)));
1000
+ this.hasRequestError$$ = computed(() => this.state.requestState$$().status === 'error', ...(ngDevMode ? [{ debugName: "hasRequestError$$" }] : []));
1001
+ this.invalid$$ = computed(() => {
1002
+ this.controlEvent$$();
1003
+ if (this.hasRequestError$$())
1004
+ return true;
1005
+ const control = this.control$$();
1006
+ return !!control?.invalid && (control.touched || control.dirty);
1007
+ }, ...(ngDevMode ? [{ debugName: "invalid$$" }] : []));
1008
+ this.parentValue$$ = computed(() => {
1009
+ const fromChain = this.chain?.parentValue(this);
1010
+ return fromChain === undefined ? this.parentValue() : fromChain;
1011
+ }, ...(ngDevMode ? [{ debugName: "parentValue$$" }] : []));
1012
+ this.requestOptions$$ = computed(() => ({
1013
+ url: this.apiUrl(),
1014
+ delay: this.delay(),
1015
+ action: this.action(),
1016
+ repository: this.repository(),
1017
+ transform: this.transformOptions(),
1018
+ minQueryLength: this.minQueryLength(),
1019
+ parent: this.parentValue$$() ?? undefined,
1020
+ }), ...(ngDevMode ? [{ debugName: "requestOptions$$" }] : []));
1021
+ this.canCreate$$ = computed(() => {
1022
+ if (!this.create() || this.isLocked$$())
1023
+ return false;
1024
+ return this.createMode() === 'always' || isEmptyArray(this.state.options$$());
1025
+ }, ...(ngDevMode ? [{ debugName: "canCreate$$" }] : []));
1026
+ this.createStartVisible$$ = computed(() => this.canCreate$$() && this.createPlace() === 'start', ...(ngDevMode ? [{ debugName: "createStartVisible$$" }] : []));
1027
+ this.createEndVisible$$ = computed(() => this.canCreate$$() && this.createPlace() === 'end', ...(ngDevMode ? [{ debugName: "createEndVisible$$" }] : []));
1028
+ this.clearVisible$$ = computed(() => this.showClear() && !this.isLocked$$() && isNonEmptyString(this.typed$$()), ...(ngDevMode ? [{ debugName: "clearVisible$$" }] : []));
1029
+ this.counterVisible$$ = computed(() => this.showCounter() && !this.isLocked$$() && isNonEmptyArray(this.state.options$$()), ...(ngDevMode ? [{ debugName: "counterVisible$$" }] : []));
1030
+ this.statusVisible$$ = computed(() => {
1031
+ if (this.isLocked$$())
1032
+ return false;
1033
+ const { status } = this.state.requestState$$();
1034
+ if (status === 'error' || this.isNative$$())
1035
+ return true;
1036
+ if (status === 'loading')
1037
+ return this.showLoader();
1038
+ return this.showToggle();
1039
+ }, ...(ngDevMode ? [{ debugName: "statusVisible$$" }] : []));
1040
+ this.createDisabled$$ = computed(() => this.state.requestState$$().status === 'loading' ||
1041
+ isShortQuery(this.typed$$(), this.minQueryLength()), ...(ngDevMode ? [{ debugName: "createDisabled$$" }] : []));
1042
+ this.errorText$$ = computed(() => this.state.requestState$$().status === 'error' ? (this.errorMessage() ?? null) : null, ...(ngDevMode ? [{ debugName: "errorText$$" }] : []));
1043
+ this.needsEagerLoad$$ = computed(() => {
1044
+ if (this.chained$$())
1045
+ return isDefined(this.parentValue$$());
1046
+ return this.isNative$$() || this.mode() === 'select';
1047
+ }, ...(ngDevMode ? [{ debugName: "needsEagerLoad$$" }] : []));
1048
+ if (this.ngControl) {
1049
+ this.ngControl.valueAccessor = this;
336
1050
  }
337
- if (this.createMode() === 'always') {
338
- return true;
1051
+ if (this.chain) {
1052
+ this.chain.register(this);
1053
+ inject(DestroyRef).onDestroy(() => this.chain?.unregister(this));
339
1054
  }
340
- return isEmptyArray(this.filteredOptions$$());
1055
+ afterNextRender(() => {
1056
+ this.control$$.set(this.ngControl?.control ?? null);
1057
+ if (this.autofocus())
1058
+ this.inputElement?.focus();
1059
+ });
1060
+ effect(() => this.eagerLoad());
1061
+ effect(() => this.emitOptionCreated(this.state.created$$()));
1062
+ effect(() => this.syncSelection(this.state.selected$$()));
1063
+ effect(() => this.autoSelectSingle(this.state.options$$()));
1064
+ effect(() => this.syncRequestError(this.hasRequestError$$()));
1065
+ effect(() => this.emitRequestError());
341
1066
  }
342
- computeCreatDisabled() {
343
- if (!this.create() || this.isLoading$$()) {
344
- return true;
1067
+ writeValue(value) {
1068
+ this.lastValue = value;
1069
+ if (isNil(value)) {
1070
+ this.typed$$.set('');
1071
+ return this.state.clear();
345
1072
  }
346
- return !this.isValidQuery(this.queryString$$());
1073
+ this.state.resolve(value, this.requestOptions$$());
347
1074
  }
348
- computeIconType() {
349
- if (this.isDisabled$$()) {
350
- return;
351
- }
352
- if (this.showLoading() && this.isLoading$$()) {
353
- return 'loading';
354
- }
355
- if (this.showClear() && this.queryString$$().length > 0) {
356
- return 'clear';
357
- }
358
- if (this.showDropdown()) {
359
- return 'default';
360
- }
1075
+ registerOnChange(onChange) {
1076
+ this.onChange = onChange;
361
1077
  }
362
- computeOptionsListStatus() {
363
- if (this.canShowHint(this.queryString$$())) {
364
- return 'hint';
365
- }
366
- if (this.canShowEmpty(this.filteredOptions$$())) {
367
- return 'empty';
368
- }
369
- if (isNonEmptyArray(this.filteredOptions$$())) {
370
- return 'list';
371
- }
372
- return null;
1078
+ registerOnTouched(onTouched) {
1079
+ this.onTouched = onTouched;
373
1080
  }
374
- focusFirstValidOption() {
375
- const options = this.filteredOptions$$();
376
- if (isNonEmptyArray(options)) {
377
- this.focusedOptionIndex$$.set(findFirstValidIndex(options, (option) => this.isValidOption(option)));
378
- }
1081
+ setDisabledState(isDisabled) {
1082
+ this.formDisabled$$.set(isDisabled);
379
1083
  }
380
- updateQueryString(value, emitEvent = true) {
381
- this.queryStringControl.patchValue(value, { emitEvent });
382
- this.queryString$$.set(this.normalizeQueryString(value));
1084
+ load(query = '', type) {
1085
+ this.state.load(query, this.requestOptions$$(), type);
383
1086
  }
384
- selectFocusedOption() {
385
- const option = this.getFocusedOption(this.focusedOptionIndex$$(), this.filteredOptions$$());
386
- if (isNil(option) || !this.isValidOption(option)) {
387
- return;
1087
+ clear() {
1088
+ this.typed$$.set('');
1089
+ if (this.mode() === 'select') {
1090
+ this.state.filter('', this.filterOption());
1091
+ this.state.select(null);
388
1092
  }
389
- this.updateSelectedOption(option);
390
- this.updateQueryString(option.label, false);
391
- this.overlayVisible$$.set(false);
392
- this.inputElementRef?.blur();
393
- }
394
- findNextValidIndex(options, start, step) {
395
- let nextIndex = limitIndex(start + step, options.length - 1, this.loopScroll());
396
- for (let i = 0; i < options.length; i++) {
397
- const item = options.at(nextIndex);
398
- if (this.isValidOption(item)) {
399
- return nextIndex;
400
- }
401
- nextIndex = limitIndex(nextIndex + step, options.length - 1, this.loopScroll());
402
- if (nextIndex === start) {
403
- break;
404
- }
1093
+ else {
1094
+ this.state.clear();
405
1095
  }
406
- return start;
1096
+ this.inputElement?.focus();
407
1097
  }
408
- isValidOption(option) {
409
- return isDefined(option) && !this.isDisabledOption(option) && this.canSelectGroupOption(option);
1098
+ close() {
1099
+ this.state.close();
410
1100
  }
411
- isDisabledOption(option) {
412
- return isFunction(this.disabledOptionFn) ? this.disabledOptionFn(option) : false;
1101
+ reset() {
1102
+ this.typed$$.set('');
1103
+ this.loadedParent = undefined;
1104
+ this.state.clear();
413
1105
  }
414
- canSelectGroupOption(option) {
415
- return !this.selectGroup() ? !option.groupHead : true;
1106
+ onInput(value) {
1107
+ this.typed$$.set(value);
1108
+ this.state.open();
1109
+ if (this.mode() === 'select') {
1110
+ if (this.state.selected$$()) {
1111
+ this.state.select(null);
1112
+ }
1113
+ return this.state.filter(value, this.filterOption());
1114
+ }
1115
+ this.state.queryChange(value, this.requestOptions$$());
416
1116
  }
417
- updateSelectedOption(option) {
418
- this.selectedOptions$$.set(option);
419
- this.onChange(option?.value ?? null);
420
- this.onValidationChange();
1117
+ onFocus() {
1118
+ if (this.isLocked$$())
1119
+ return;
1120
+ this.state.open();
421
1121
  }
422
- handleSearch(options) {
423
- this.overlayVisible$$.set(true);
424
- this.options$$.set(options);
425
- this.focusFirstValidOption();
426
- if (this.autoSelect() && options.length === 1) {
427
- this.selectFocusedOption();
1122
+ onAction(icon) {
1123
+ switch (icon) {
1124
+ case 'clear':
1125
+ return this.clear();
1126
+ case 'create':
1127
+ return this.createByQuery();
1128
+ case 'reload':
1129
+ return this.state.retry();
1130
+ case 'toggle':
1131
+ return this.state.toggle();
1132
+ default:
1133
+ return;
428
1134
  }
429
1135
  }
430
- prepareSearch(queryString) {
431
- this.touched$$.set(true);
432
- this.queryString$$.set(queryString);
433
- if (this.selectedOptions$$()) {
434
- this.updateSelectedOption(null);
1136
+ onArrow(event, step) {
1137
+ if (this.isLocked$$())
1138
+ return;
1139
+ if (!this.state.isOpen$$()) {
1140
+ this.state.open();
1141
+ return event.preventDefault();
435
1142
  }
436
- if (!this.overlayVisible$$()) {
437
- this.overlayVisible$$.set(true);
1143
+ if (this.list()?.moveFocus(step)) {
1144
+ event.preventDefault();
438
1145
  }
439
- if (queryString.length <= this.minQueryLength()) {
440
- this.options$$.set(null);
1146
+ }
1147
+ onEnter(event) {
1148
+ if (this.interactionBlocked())
1149
+ return;
1150
+ if (this.list()?.activateFocused()) {
1151
+ event.preventDefault();
441
1152
  }
442
1153
  }
443
- canShowHint(queryString) {
444
- return this.showHint() && !this.isValidQuery(queryString) && this.hasHintContent();
1154
+ onSelect(option) {
1155
+ this.state.select(option);
1156
+ this.state.close();
1157
+ this.inputElement?.blur();
445
1158
  }
446
- canShowEmpty(options) {
447
- return this.showEmpty() && isEmptyArray(options) && this.hasEmptyContent();
1159
+ onFocusOut(target) {
1160
+ if (target instanceof Node && this.host.nativeElement.contains(target))
1161
+ return;
1162
+ this.onTouched();
448
1163
  }
449
- hasHintContent() {
450
- return isDefined(this.hintContentRef()) || isNonEmptyString(this.hintMessage());
1164
+ createByQuery() {
1165
+ if (this.createDisabled$$())
1166
+ return;
1167
+ this.state.createByQuery(this.typed$$(), this.requestOptions$$());
451
1168
  }
452
- hasEmptyContent() {
453
- return isDefined(this.emptyContentRef()) || isNonEmptyString(this.emptyMessage());
1169
+ interactionBlocked() {
1170
+ return this.isLocked$$() || !this.state.isOpen$$();
454
1171
  }
455
- getFocusedOption(index, options) {
456
- if (isNil(options) || index < 0) {
457
- return null;
1172
+ syncSelection(selected) {
1173
+ if (isDefined(selected)) {
1174
+ this.typed$$.set(selected.label);
458
1175
  }
459
- return options.at(index) ?? null;
460
- }
461
- request(queryString, type) {
462
- this.isLoading$$.set(true);
463
- return this.yodaService
464
- .request({
465
- type,
466
- queryString,
467
- action: this.action(),
468
- apiUrl: this.apiUrl(),
469
- repository: this.repository(),
470
- })
471
- .pipe(map((data) => this.transformResponse(data)), map((options) => this.flattenOptions(options)), tap(() => this.isLoading$$.set(false)), catchError(() => {
472
- this.isLoading$$.set(false);
473
- return of([]);
474
- }));
1176
+ const value = selected?.value ?? null;
1177
+ if (value === this.lastValue)
1178
+ return;
1179
+ this.lastValue = value;
1180
+ this.onChange(value);
1181
+ this.selectionChanged.emit(selected);
1182
+ this.chain?.resetAfter(this);
475
1183
  }
476
- createByQuery() {
477
- if (this.isCreatDisabled$$()) {
1184
+ eagerLoad() {
1185
+ if (!this.needsEagerLoad$$())
478
1186
  return;
479
- }
480
- this.request(this.queryString$$(), 2 /* ActionType.Create */)
481
- .pipe(first(), tap((data) => this.updateWithSelection(data)))
482
- .subscribe();
1187
+ const parent = this.parentValue$$();
1188
+ if (this.loadedParent === parent)
1189
+ return;
1190
+ this.loadedParent = parent;
1191
+ this.load(isDefined(parent) ? String(parent) : this.preloadQuery(), this.preloadType());
483
1192
  }
484
- updateWithSelection(options) {
485
- if (isNil(options) || options.length === 0) {
1193
+ syncRequestError(hasError) {
1194
+ const control = this.control$$();
1195
+ if (isNil(control))
486
1196
  return;
1197
+ const errors = { ...(control.errors ?? {}) };
1198
+ if (hasError) {
1199
+ errors[REQUEST_ERROR] = true;
487
1200
  }
488
- this.options$$.update((state) => [...options, ...(state ?? [])]);
489
- this.focusFirstValidOption();
490
- this.selectFocusedOption();
491
- }
492
- transformResponse(data) {
493
- if (isFunction(this.transformOptionsFn)) {
494
- return this.transformOptionsFn(data);
1201
+ else {
1202
+ delete errors[REQUEST_ERROR];
495
1203
  }
496
- return data.map(([value, label, ...payload]) => ({ value, label, payload }));
497
- }
498
- flattenOptions(options) {
499
- return options.flatMap((item) => {
500
- if ('items' in item && isArray(item.items)) {
501
- const { items, ...options } = item;
502
- return [{ ...options, groupHead: true }, ...items];
503
- }
504
- return item;
505
- });
1204
+ control.setErrors(Object.keys(errors).length > 0 ? errors : null);
506
1205
  }
507
- normalizeQueryString(value) {
508
- return isString(value) ? value.trim() : '';
509
- }
510
- changeDisabledState(isDisabled) {
511
- return isDisabled ? this.queryStringControl.disable() : this.queryStringControl.enable();
1206
+ emitRequestError() {
1207
+ const state = this.state.requestState$$();
1208
+ if (state.status !== 'error')
1209
+ return;
1210
+ this.requestFailed.emit(state.error);
512
1211
  }
513
- markTouched() {
514
- if (this.touched$$()) {
515
- this.onTouched();
1212
+ emitOptionCreated(option) {
1213
+ if (isDefined(option)) {
1214
+ this.optionCreated.emit(option);
516
1215
  }
517
1216
  }
518
- scrollToFocused() {
519
- const index = this.focusedOptionIndex$$();
520
- const container = this.listRef()?.nativeElement;
521
- if (isNil(container) || index < 0) {
1217
+ autoSelectSingle(options) {
1218
+ if (!this.autoSelect() || options?.length !== 1)
522
1219
  return;
523
- }
524
- const listItem = container.querySelector(`li[data-index="${index}"]`);
525
- if (isNil(listItem) || !isFunction(listItem.scrollIntoView)) {
1220
+ const [option] = options;
1221
+ if (option.kind !== 'option')
526
1222
  return;
1223
+ this.state.select(option);
1224
+ if (this.autoSelectClose()) {
1225
+ this.state.close();
527
1226
  }
528
- const options = {
529
- behavior: 'auto',
530
- block: 'nearest',
531
- inline: 'nearest',
532
- };
533
- if (this.groupSticky()) {
534
- options.inline = 'center';
535
- options.block = 'center';
536
- }
537
- listItem.scrollIntoView(options);
538
1227
  }
539
1228
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: Yoda, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
540
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: Yoda, isStandalone: true, selector: "erp-yoda", inputs: { action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: false, transformFunction: null }, repository: { classPropertyName: "repository", publicName: "repository", isSignal: true, isRequired: false, transformFunction: null }, apiUrl: { classPropertyName: "apiUrl", publicName: "apiUrl", isSignal: true, isRequired: false, transformFunction: null }, hintMessage: { classPropertyName: "hintMessage", publicName: "hintMessage", isSignal: true, isRequired: false, transformFunction: null }, createMode: { classPropertyName: "createMode", publicName: "createMode", isSignal: true, isRequired: false, transformFunction: null }, scrollHeight: { classPropertyName: "scrollHeight", publicName: "scrollHeight", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, viewMode: { classPropertyName: "viewMode", publicName: "viewMode", isSignal: true, isRequired: false, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: true, isRequired: false, transformFunction: null }, create: { classPropertyName: "create", publicName: "create", isSignal: true, isRequired: false, transformFunction: null }, showHint: { classPropertyName: "showHint", publicName: "showHint", isSignal: true, isRequired: false, transformFunction: null }, showEmpty: { classPropertyName: "showEmpty", publicName: "showEmpty", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null }, showCreate: { classPropertyName: "showCreate", publicName: "showCreate", isSignal: true, isRequired: false, transformFunction: null }, loopScroll: { classPropertyName: "loopScroll", publicName: "loopScroll", isSignal: true, isRequired: false, transformFunction: null }, showLoading: { classPropertyName: "showLoading", publicName: "showLoading", isSignal: true, isRequired: false, transformFunction: null }, selectGroup: { classPropertyName: "selectGroup", publicName: "selectGroup", isSignal: true, isRequired: false, transformFunction: null }, groupSticky: { classPropertyName: "groupSticky", publicName: "groupSticky", isSignal: true, isRequired: false, transformFunction: null }, showDropdown: { classPropertyName: "showDropdown", publicName: "showDropdown", isSignal: true, isRequired: false, transformFunction: null }, autoSelect: { classPropertyName: "autoSelect", publicName: "autoSelect", isSignal: true, isRequired: false, transformFunction: null }, delay: { classPropertyName: "delay", publicName: "delay", isSignal: true, isRequired: false, transformFunction: null }, itemsShow: { classPropertyName: "itemsShow", publicName: "itemsShow", isSignal: true, isRequired: false, transformFunction: null }, minQueryLength: { classPropertyName: "minQueryLength", publicName: "minQueryLength", isSignal: true, isRequired: false, transformFunction: null }, disabledOption: { classPropertyName: "disabledOption", publicName: "disabledOption", isSignal: true, isRequired: false, transformFunction: null }, transformOptions: { classPropertyName: "transformOptions", publicName: "transformOptions", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keydown.tab": "hideOverlay()", "keydown.enter": "onSelectOption($event)", "keydown.arrowup": "moveFocus($event,-1)", "keydown.arrowdown": "moveFocus($event,1)" } }, providers: [
541
- {
542
- multi: true,
543
- useExisting: forwardRef(() => Yoda),
544
- provide: NG_VALUE_ACCESSOR,
545
- },
546
- {
547
- multi: true,
548
- useExisting: forwardRef(() => Yoda),
549
- provide: NG_VALIDATORS,
550
- },
551
- ], queries: [{ propertyName: "hintContentRef", first: true, predicate: ["hint"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "emptyContentRef", first: true, predicate: ["empty"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "headerContentRef", first: true, predicate: ["header"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "footerContentRef", first: true, predicate: ["footer"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "optionContentRef", first: true, predicate: ["option"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "groupOptionContentRef", first: true, predicate: ["groupOption"], descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "listRef", first: true, predicate: ["listRef"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@let optionsListStatus = optionsListStatus$$();\n\n<p-iconfield>\n @if (showCreate() && canShowCreate$$() && !isDisabled$$()) {\n <p-inputicon\n class=\"pi pi-plus action\"\n [class.action__disabled]=\"isCreatDisabled$$()\"\n (click)=\"actionIconClick($event, 'create')\"\n />\n }\n\n <input\n #inputRef\n pInputText\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n [class.ng-invalid.ng-dirty]=\"invalid$$()\"\n [attr.id]=\"id()\"\n [attr.name]=\"name()\"\n [attr.size]=\"inputSize()\"\n [attr.tabindex]=\"tabindex()\"\n [attr.required]=\"required()\"\n [attr.maxlength]=\"maxlength()\"\n [attr.minlength]=\"minlength()\"\n [attr.readonly]=\"inputReadonly()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.autocomplete]=\"autocomplete()\"\n [variant]=\"variant()\"\n [pAutoFocus]=\"autofocus()\"\n [formControl]=\"queryStringControl\"\n (focus)=\"inputFocus($event)\"\n />\n\n @if (viewMode() === 'overlay') {\n <p-overlay\n #overlay\n target=\"@parent\"\n [appendTo]=\"appendTo$$()\"\n [options]=\"overlayOptions()\"\n [visible]=\"overlayVisible$$()\"\n [showTransitionOptions]=\"overlayShowTransition()\"\n [hideTransitionOptions]=\"overlayHideTransition()\"\n (onHide)=\"hideOverlay()\"\n (onBeforeShow)=\"showOverlay()\"\n >\n <ng-container\n [ngTemplateOutlet]=\"listLayoutTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'overlay' }\"\n />\n </p-overlay>\n }\n\n <ng-container\n [ngTemplateOutlet]=\"inputIconTempate\"\n [ngTemplateOutletContext]=\"{ $implicit: iconType$$() }\"\n />\n</p-iconfield>\n\n@if (viewMode() === 'inline') {\n <ng-container\n [ngTemplateOutlet]=\"listLayoutTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'inline' }\"\n />\n}\n\n<ng-template\n #inputIconTempate\n let-type\n>\n @switch (type) {\n @case ('loading') {\n <p-inputicon\n class=\"pi pi-spinner pi-spin\"\n (click)=\"actionIconClick($event, type)\"\n />\n }\n\n @case ('clear') {\n <p-inputicon\n class=\"pi pi-times action\"\n (click)=\"actionIconClick($event, type)\"\n />\n }\n\n @case ('default') {\n <p-inputicon\n class=\"pi pi-angle-down action\"\n (click)=\"actionIconClick($event, type)\"\n />\n }\n }\n</ng-template>\n\n<ng-template\n #listLayoutTemplate\n let-layoutStyleClass\n>\n @let headerContent = headerContentRef();\n @let footerContent = footerContentRef();\n\n @if (optionsListStatus) {\n <section\n class=\"yoda-list-layout\"\n [class]=\"layoutStyleClass\"\n >\n @if (optionsListStatus === 'list' && headerContent) {\n <header>\n <ng-container [ngTemplateOutlet]=\"headerContent\" />\n </header>\n }\n\n <div\n class=\"yoda-list-layout__content\"\n tabindex=\"-1\"\n [style.max-block-size]=\"scrollHeight()\"\n >\n <ng-container [ngTemplateOutlet]=\"listTemplate\" />\n </div>\n\n @if (optionsListStatus === 'list' && footerContent) {\n <footer>\n <ng-container [ngTemplateOutlet]=\"footerContent\" />\n </footer>\n }\n </section>\n }\n</ng-template>\n\n<ng-template #listTemplate>\n <ul\n #listRef\n class=\"yoda-list\"\n role=\"listbox\"\n [class.list--group]=\"group()\"\n >\n @switch (optionsListStatus$$()) {\n @case ('hint') {\n @let hintTemplate = hintContentRef();\n <li class=\"yoda-list__option list__option--hint\">\n @if (hintTemplate) {\n <ng-container [ngTemplateOutlet]=\"hintTemplate\" />\n } @else {\n <span>{{ hintMessage() }}</span>\n }\n </li>\n }\n @case ('empty') {\n @let emptyTemplate = emptyContentRef();\n <li class=\"yoda-list__option yoda-list__option--empty\">\n @if (emptyTemplate) {\n <ng-container [ngTemplateOutlet]=\"emptyTemplate\" />\n } @else {\n <span>{{ emptyMessage() }}</span>\n }\n </li>\n }\n @case ('list') {\n @for (item of filteredOptions$$(); track item.value; let index = $index) {\n @let isGroupHead = group() && item.groupHead;\n @let isFocused = focusedOptionIndex$$() === index;\n @let isSelected = selectedOptions$$()?.value === item.value;\n\n <li\n class=\"yoda-list__option\"\n role=\"option\"\n [class.focus]=\"isFocused\"\n [class.select]=\"isSelected\"\n [class.group-head]=\"isGroupHead\"\n [class.group-head--sticky]=\"isGroupHead && groupSticky()\"\n [attr.data-index]=\"index\"\n (click)=\"onSelectOption($event)\"\n (pointerenter)=\"moveFocus($event, index)\"\n >\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{\n $implicit: item,\n template: isGroupHead ? groupOptionContentRef() : optionContentRef(),\n }\"\n />\n </li>\n }\n }\n }\n </ul>\n</ng-template>\n\n<ng-template\n #listItemTemplate\n let-item\n let-template=\"template\"\n>\n @if (template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"\n />\n } @else {\n {{ item?.label }}\n }\n</ng-template>\n", styles: ["::ng-deep :root{--yoda-overlay-layout-padding-y: .5rem;--yoda-overlay-color: var(--p-overlay-select-color);--yoda-overlay-border-color: var(--p-overlay-select-border-color);--yoda-overlay-border-radius: var(--p-overlay-select-border-radius);--yoda-overlay-shadow: var(--p-overlay-select-shadow);--yoda-list-gap: .125rem;--yoda-list-padding-x: .75rem;--yoda-list-padding-y: .5rem;--yoda-list-background: var(--p-overlay-select-background);--yoda-list-color: var(--p-text-color);--yoda-list-muted-color: var(--p-text-muted-color);--yoda-list-header-padding: var(--yoda-list-padding-y) var(--yoda-list-padding-x);--yoda-list-footer-padding: var(--yoda-list-padding-y) var(--yoda-list-padding-x);--yoda-list-option-padding: var(--yoda-list-padding-y) var(--yoda-list-padding-x);--yoda-list-group-option-padding: var(--yoda-list-padding-y) calc(var(--yoda-list-padding-x) * 2);--yoda-list-option-focus-color: var(--p-text-hover-color);--yoda-list-option-focus-background: var(--p-surface-100);--yoda-list-option-selected-color: var(--p-highlight-focus-color);--yoda-list-option-selected-background: var(--p-highlight-background);--yoda-list-option-focus-selected-background: var( --p-highlight-focus-background )}:host{inline-size:100%}:host input{inline-size:100%;text-overflow:ellipsis}:host input:disabled{cursor:not-allowed}:host p-inputicon.action{cursor:pointer}:host p-inputicon.action__disabled{cursor:not-allowed}:host.p-component p-iconfield,:host.p-component input{border-radius:inherit}.yoda-list{color:var(--yoda-list-color);margin:0;list-style-type:none;display:flex;flex-direction:column}.yoda-list--group .yoda-list__option{padding:var(--yoda-list-group-option-padding)}.yoda-list--group .yoda-list__option.group-head,.yoda-list--group .yoda-list__option.yoda-list__option--hint,.yoda-list--group .yoda-list__option.yoda-list__option--empty{padding:var(--yoda-list-option-padding)}.yoda-list--group .yoda-list__option.group-head--sticky{position:sticky;top:0}.yoda-list__option{padding:var(--yoda-list-option-padding)}.yoda-list__option--hint span,.yoda-list__option--empty span{color:var(--yoda-list-muted-color)}.yoda-list__option[role=option]{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;background:var(--yoda-list-background)}.yoda-list__option[role=option].focus{cursor:pointer;color:var(--yoda-list-option-focus-color);background:var(--yoda-list-option-focus-background)}.yoda-list__option[role=option].select{color:var(--yoda-list-option-selected-color);background:var(--yoda-list-option-selected-background)}.yoda-list__option[role=option].select.focus{background:var(--yoda-list-option-focus-selected-background)}.yoda-list-layout{display:flex;flex-direction:column;flex-wrap:nowrap;outline:none}.yoda-list-layout.overlay{min-inline-size:100%;max-inline-size:0;overflow:hidden;color:var(--yoda-overlay-color);background:var(--yoda-list-background);border:1px solid var(--yoda-overlay-border-color);border-radius:var(--yoda-overlay-border-radius);box-shadow:var(--yoda-overlay-shadow)}.yoda-list-layout.inline{width:100%;display:inline-flex}.yoda-list-layout header,.yoda-list-layout footer{display:flex;flex-direction:column;gap:var(--yoda-list-gap)}.yoda-list-layout header{padding:var(--yoda-list-header-padding)}.yoda-list-layout footer{padding:var(--yoda-list-footer-padding)}.yoda-list-layout__content{overflow:auto;outline:none}\n"], dependencies: [{ kind: "directive", type: AutoFocus, selector: "[pAutoFocus]", inputs: ["pAutoFocus"] }, { kind: "component", type: Overlay, selector: "p-overlay", inputs: ["hostName", "visible", "mode", "style", "styleClass", "contentStyle", "contentStyleClass", "target", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "listener", "responsive", "options", "appendTo", "hostAttrSelector"], outputs: ["visibleChange", "onBeforeShow", "onShow", "onBeforeHide", "onHide", "onAnimationStart", "onAnimationDone"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i1.InputText, selector: "[pInputText]", inputs: ["hostName", "ptInputText", "pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: IconFieldModule }, { kind: "component", type: i3.IconField, selector: "p-iconfield, p-iconField, p-icon-field", inputs: ["hostName", "iconPosition", "styleClass"] }, { kind: "ngmodule", type: InputIconModule }, { kind: "component", type: i4.InputIcon, selector: "p-inputicon, p-inputIcon", inputs: ["hostName", "styleClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1229
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: Yoda, isStandalone: true, selector: "ss-yoda", host: { listeners: { "keydown.escape": "close()", "keydown.tab": "close()", "keydown.enter": "onEnter($event)", "keydown.arrowdown": "onArrow($event, 1)", "keydown.arrowup": "onArrow($event, -1)", "focusout": "onFocusOut($event.relatedTarget)" }, properties: { "attr.data-size": "size()", "attr.data-variant": "variant()", "attr.data-separator": "separator()", "style.inline-size": "width()", "style.flex": "flexBasis$$()", "class.yoda--inline": "listRender() === \"inline\"", "class.yoda--disabled": "isDisabled$$()", "class.yoda--locked": "isLocked$$()", "class.yoda--chained": "chainInline$$()", "class.yoda--hidden": "chainHidden$$()", "attr.data-chain": "chainPosition$$()", "class.yoda--invalid": "invalid$$()" } }, providers: [StateService, SlotsService], viewQueries: [{ propertyName: "list", first: true, predicate: ListComponent, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"yoda__field\">\n @if (createStartVisible$$()) {\n <ss-yoda-action\n class=\"yoda__segment\"\n type=\"create\"\n [disabled]=\"createDisabled$$()\"\n (activated)=\"onAction($event)\"\n />\n }\n\n <div class=\"yoda__segment yoda__segment--input\">\n <input\n #inputRef\n class=\"yoda__input\"\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n [attr.id]=\"id()\"\n [attr.name]=\"name()\"\n [attr.size]=\"inputSize()\"\n [attr.tabindex]=\"tabindex()\"\n [attr.required]=\"required()\"\n [attr.minlength]=\"minlength()\"\n [attr.maxlength]=\"maxlength()\"\n [attr.readonly]=\"inputReadonly()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.autocomplete]=\"autocomplete()\"\n [attr.aria-expanded]=\"state.isOpen$$()\"\n [attr.aria-invalid]=\"invalid$$() || null\"\n [value]=\"typed$$()\"\n [disabled]=\"isDisabled$$()\"\n (focus)=\"onFocus()\"\n (input)=\"onInput(inputRef.value)\"\n />\n\n @if (counterVisible$$()) {\n <ss-yoda-action\n type=\"counter\"\n [itemsShow]=\"itemsShow()\"\n [selectGroup]=\"selectGroup()\"\n />\n }\n\n @if (clearVisible$$()) {\n <ss-yoda-action\n type=\"clear\"\n (activated)=\"onAction($event)\"\n />\n }\n </div>\n\n @if (createEndVisible$$()) {\n <ss-yoda-action\n class=\"yoda__segment\"\n type=\"create\"\n [disabled]=\"createDisabled$$()\"\n (activated)=\"onAction($event)\"\n />\n }\n\n @if (statusVisible$$()) {\n <div class=\"yoda__segment yoda__segment--status\">\n <ss-yoda-action\n type=\"state\"\n [native]=\"isNative$$()\"\n [errorText]=\"errorText$$()\"\n (activated)=\"onAction($event)\"\n />\n\n @if (isNative$$()) {\n <ss-yoda-native\n [disabled]=\"isLocked$$()\"\n [placeholder]=\"placeholder()\"\n />\n }\n </div>\n }\n</div>\n\n@if (!isNative$$()) {\n <ss-yoda-panel\n [origin]=\"host\"\n [showHint]=\"showHint()\"\n [showEmpty]=\"showEmpty()\"\n [listRender]=\"listRender()\"\n [panelClass]=\"panelClass()\"\n [hintMessage]=\"hintMessage()\"\n [scrollHeight]=\"scrollHeight()\"\n [emptyMessage]=\"emptyMessage()\"\n [scrollStrategy]=\"scrollStrategy()\"\n [minQueryLength]=\"minQueryLength()\"\n >\n <ss-yoda-list\n [showMore]=\"showMore()\"\n [itemsShow]=\"itemsShow()\"\n [loopScroll]=\"loopScroll()\"\n [moreMessage]=\"moreMessage()\"\n [selectGroup]=\"selectGroup()\"\n [groupSticky]=\"groupSticky()\"\n [showHighlight]=\"showHighlight()\"\n [disabledOption]=\"disabledOption()\"\n (selected)=\"onSelect($event)\"\n />\n </ss-yoda-panel>\n}\n", styles: [":host{display:flex;inline-size:100%;flex-direction:column;color:var(--ss-yoda-color, #18181b);font-size:var(--ss-yoda-font-size, 1rem)}.yoda__field{display:flex;position:relative;align-items:stretch;border-radius:var(--ss-yoda-radius, 6px);background:var(--ss-yoda-background, #fff);border:1px solid var(--ss-yoda-border-color, #d4d4d8)}:host(:not(.yoda--locked)) .yoda__field:focus-within{box-shadow:var(--ss-yoda-focus-ring-shadow, none);outline-offset:var(--ss-yoda-focus-ring-offset, 0);border-color:var(--ss-yoda-border-focus-color, #3b82f6);outline:var(--ss-yoda-focus-ring-width, 0) var(--ss-yoda-focus-ring-style, none) var(--ss-yoda-focus-ring-color, transparent)}:host([data-variant=fill]) .yoda__field{background:var(--ss-yoda-fill-background, #f4f4f5)}:host([data-size=small]){--ss-yoda-padding-y: var(--ss-yoda-sm-padding-y, .25rem);--ss-yoda-padding-x: var(--ss-yoda-sm-padding-x, .5rem);--ss-yoda-font-size: var(--ss-yoda-sm-font-size, .875rem)}:host([data-size=large]){--ss-yoda-padding-y: var(--ss-yoda-lg-padding-y, .75rem);--ss-yoda-padding-x: var(--ss-yoda-lg-padding-x, .75rem);--ss-yoda-font-size: var(--ss-yoda-lg-font-size, 1.125rem)}:host(.yoda--invalid) .yoda__field{border-color:var(--ss-yoda-border-invalid-color, #ef4444)}:host(.yoda--invalid) .yoda__field:focus-within{border-color:var(--ss-yoda-border-invalid-focus-color, #dc2626)}:host(.yoda--disabled){cursor:not-allowed;opacity:var(--ss-yoda-disabled-opacity, .6)}.yoda__segment{display:flex;flex:0 0 auto;align-items:center;justify-content:center;padding-inline:var(--ss-yoda-padding-x, .75rem)}.yoda__segment--input{flex:1 1 0;min-inline-size:0;justify-content:flex-start;gap:var(--ss-yoda-gap, .5rem)}.yoda__segment--status{position:relative}:host([data-separator=border]) .yoda__segment+.yoda__segment{border-inline-start:1px solid var(--ss-yoda-separator-color, #e4e4e7)}:host([data-separator=divider]) .yoda__segment+.yoda__segment{position:relative}:host([data-separator=divider]) .yoda__segment+.yoda__segment:before{content:\"\";inline-size:1px;position:absolute;inset-inline-start:0;inset-block:var(--ss-yoda-divider-inset, .375rem);background:var(--ss-yoda-separator-color, #e4e4e7)}.yoda__input{border:0;outline:0;flex:1 1 0;font:inherit;color:inherit;min-inline-size:0;text-overflow:ellipsis;background:transparent;padding-block:var(--ss-yoda-padding-y, .5rem)}.yoda__input::placeholder{color:var(--ss-yoda-muted-color, #a1a1aa)}.yoda__input:disabled{cursor:not-allowed}:host(.yoda--hidden){display:none}:host(.yoda--chained){flex:1 1 0}:host(.yoda--chained) .yoda__field{border-radius:0}:host(.yoda--chained:not([data-chain=first])){margin-inline-start:-1px}:host(.yoda--chained[data-chain=first]) .yoda__field,:host(.yoda--chained[data-chain=only]) .yoda__field{border-end-start-radius:var(--ss-yoda-radius, 6px);border-start-start-radius:var(--ss-yoda-radius, 6px)}:host(.yoda--chained[data-chain=last]) .yoda__field,:host(.yoda--chained[data-chain=only]) .yoda__field{border-end-end-radius:var(--ss-yoda-radius, 6px);border-start-end-radius:var(--ss-yoda-radius, 6px)}:host(.yoda--chained) .yoda__field:focus-within{z-index:1}\n"], dependencies: [{ kind: "component", type: ActionComponent, selector: "ss-yoda-action", inputs: ["type", "errorText", "selectGroup", "itemsShow", "disabled", "native"], outputs: ["activated"] }, { kind: "component", type: NativeComponent, selector: "ss-yoda-native", inputs: ["placeholder", "disabled"] }, { kind: "component", type: PanelComponent, selector: "ss-yoda-panel", inputs: ["origin", "listRender", "scrollStrategy", "panelClass", "scrollHeight", "showHint", "showEmpty", "minQueryLength", "hintMessage", "emptyMessage"] }, { kind: "component", type: ListComponent, selector: "ss-yoda-list", inputs: ["itemsShow", "moreMessage", "showMore", "showHighlight", "loopScroll", "selectGroup", "groupSticky", "disabledOption"], outputs: ["selected"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
552
1230
  }
553
1231
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: Yoda, decorators: [{
554
1232
  type: Component,
555
- args: [{ selector: 'erp-yoda', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
556
- AutoFocus,
557
- Overlay,
558
- InputTextModule,
559
- ReactiveFormsModule,
560
- NgTemplateOutlet,
561
- IconFieldModule,
562
- InputIconModule,
563
- ], providers: [
564
- {
565
- multi: true,
566
- useExisting: forwardRef(() => Yoda),
567
- provide: NG_VALUE_ACCESSOR,
568
- },
569
- {
570
- multi: true,
571
- useExisting: forwardRef(() => Yoda),
572
- provide: NG_VALIDATORS,
573
- },
574
- ], template: "@let optionsListStatus = optionsListStatus$$();\n\n<p-iconfield>\n @if (showCreate() && canShowCreate$$() && !isDisabled$$()) {\n <p-inputicon\n class=\"pi pi-plus action\"\n [class.action__disabled]=\"isCreatDisabled$$()\"\n (click)=\"actionIconClick($event, 'create')\"\n />\n }\n\n <input\n #inputRef\n pInputText\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n [class.ng-invalid.ng-dirty]=\"invalid$$()\"\n [attr.id]=\"id()\"\n [attr.name]=\"name()\"\n [attr.size]=\"inputSize()\"\n [attr.tabindex]=\"tabindex()\"\n [attr.required]=\"required()\"\n [attr.maxlength]=\"maxlength()\"\n [attr.minlength]=\"minlength()\"\n [attr.readonly]=\"inputReadonly()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.autocomplete]=\"autocomplete()\"\n [variant]=\"variant()\"\n [pAutoFocus]=\"autofocus()\"\n [formControl]=\"queryStringControl\"\n (focus)=\"inputFocus($event)\"\n />\n\n @if (viewMode() === 'overlay') {\n <p-overlay\n #overlay\n target=\"@parent\"\n [appendTo]=\"appendTo$$()\"\n [options]=\"overlayOptions()\"\n [visible]=\"overlayVisible$$()\"\n [showTransitionOptions]=\"overlayShowTransition()\"\n [hideTransitionOptions]=\"overlayHideTransition()\"\n (onHide)=\"hideOverlay()\"\n (onBeforeShow)=\"showOverlay()\"\n >\n <ng-container\n [ngTemplateOutlet]=\"listLayoutTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'overlay' }\"\n />\n </p-overlay>\n }\n\n <ng-container\n [ngTemplateOutlet]=\"inputIconTempate\"\n [ngTemplateOutletContext]=\"{ $implicit: iconType$$() }\"\n />\n</p-iconfield>\n\n@if (viewMode() === 'inline') {\n <ng-container\n [ngTemplateOutlet]=\"listLayoutTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'inline' }\"\n />\n}\n\n<ng-template\n #inputIconTempate\n let-type\n>\n @switch (type) {\n @case ('loading') {\n <p-inputicon\n class=\"pi pi-spinner pi-spin\"\n (click)=\"actionIconClick($event, type)\"\n />\n }\n\n @case ('clear') {\n <p-inputicon\n class=\"pi pi-times action\"\n (click)=\"actionIconClick($event, type)\"\n />\n }\n\n @case ('default') {\n <p-inputicon\n class=\"pi pi-angle-down action\"\n (click)=\"actionIconClick($event, type)\"\n />\n }\n }\n</ng-template>\n\n<ng-template\n #listLayoutTemplate\n let-layoutStyleClass\n>\n @let headerContent = headerContentRef();\n @let footerContent = footerContentRef();\n\n @if (optionsListStatus) {\n <section\n class=\"yoda-list-layout\"\n [class]=\"layoutStyleClass\"\n >\n @if (optionsListStatus === 'list' && headerContent) {\n <header>\n <ng-container [ngTemplateOutlet]=\"headerContent\" />\n </header>\n }\n\n <div\n class=\"yoda-list-layout__content\"\n tabindex=\"-1\"\n [style.max-block-size]=\"scrollHeight()\"\n >\n <ng-container [ngTemplateOutlet]=\"listTemplate\" />\n </div>\n\n @if (optionsListStatus === 'list' && footerContent) {\n <footer>\n <ng-container [ngTemplateOutlet]=\"footerContent\" />\n </footer>\n }\n </section>\n }\n</ng-template>\n\n<ng-template #listTemplate>\n <ul\n #listRef\n class=\"yoda-list\"\n role=\"listbox\"\n [class.list--group]=\"group()\"\n >\n @switch (optionsListStatus$$()) {\n @case ('hint') {\n @let hintTemplate = hintContentRef();\n <li class=\"yoda-list__option list__option--hint\">\n @if (hintTemplate) {\n <ng-container [ngTemplateOutlet]=\"hintTemplate\" />\n } @else {\n <span>{{ hintMessage() }}</span>\n }\n </li>\n }\n @case ('empty') {\n @let emptyTemplate = emptyContentRef();\n <li class=\"yoda-list__option yoda-list__option--empty\">\n @if (emptyTemplate) {\n <ng-container [ngTemplateOutlet]=\"emptyTemplate\" />\n } @else {\n <span>{{ emptyMessage() }}</span>\n }\n </li>\n }\n @case ('list') {\n @for (item of filteredOptions$$(); track item.value; let index = $index) {\n @let isGroupHead = group() && item.groupHead;\n @let isFocused = focusedOptionIndex$$() === index;\n @let isSelected = selectedOptions$$()?.value === item.value;\n\n <li\n class=\"yoda-list__option\"\n role=\"option\"\n [class.focus]=\"isFocused\"\n [class.select]=\"isSelected\"\n [class.group-head]=\"isGroupHead\"\n [class.group-head--sticky]=\"isGroupHead && groupSticky()\"\n [attr.data-index]=\"index\"\n (click)=\"onSelectOption($event)\"\n (pointerenter)=\"moveFocus($event, index)\"\n >\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{\n $implicit: item,\n template: isGroupHead ? groupOptionContentRef() : optionContentRef(),\n }\"\n />\n </li>\n }\n }\n }\n </ul>\n</ng-template>\n\n<ng-template\n #listItemTemplate\n let-item\n let-template=\"template\"\n>\n @if (template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"\n />\n } @else {\n {{ item?.label }}\n }\n</ng-template>\n", styles: ["::ng-deep :root{--yoda-overlay-layout-padding-y: .5rem;--yoda-overlay-color: var(--p-overlay-select-color);--yoda-overlay-border-color: var(--p-overlay-select-border-color);--yoda-overlay-border-radius: var(--p-overlay-select-border-radius);--yoda-overlay-shadow: var(--p-overlay-select-shadow);--yoda-list-gap: .125rem;--yoda-list-padding-x: .75rem;--yoda-list-padding-y: .5rem;--yoda-list-background: var(--p-overlay-select-background);--yoda-list-color: var(--p-text-color);--yoda-list-muted-color: var(--p-text-muted-color);--yoda-list-header-padding: var(--yoda-list-padding-y) var(--yoda-list-padding-x);--yoda-list-footer-padding: var(--yoda-list-padding-y) var(--yoda-list-padding-x);--yoda-list-option-padding: var(--yoda-list-padding-y) var(--yoda-list-padding-x);--yoda-list-group-option-padding: var(--yoda-list-padding-y) calc(var(--yoda-list-padding-x) * 2);--yoda-list-option-focus-color: var(--p-text-hover-color);--yoda-list-option-focus-background: var(--p-surface-100);--yoda-list-option-selected-color: var(--p-highlight-focus-color);--yoda-list-option-selected-background: var(--p-highlight-background);--yoda-list-option-focus-selected-background: var( --p-highlight-focus-background )}:host{inline-size:100%}:host input{inline-size:100%;text-overflow:ellipsis}:host input:disabled{cursor:not-allowed}:host p-inputicon.action{cursor:pointer}:host p-inputicon.action__disabled{cursor:not-allowed}:host.p-component p-iconfield,:host.p-component input{border-radius:inherit}.yoda-list{color:var(--yoda-list-color);margin:0;list-style-type:none;display:flex;flex-direction:column}.yoda-list--group .yoda-list__option{padding:var(--yoda-list-group-option-padding)}.yoda-list--group .yoda-list__option.group-head,.yoda-list--group .yoda-list__option.yoda-list__option--hint,.yoda-list--group .yoda-list__option.yoda-list__option--empty{padding:var(--yoda-list-option-padding)}.yoda-list--group .yoda-list__option.group-head--sticky{position:sticky;top:0}.yoda-list__option{padding:var(--yoda-list-option-padding)}.yoda-list__option--hint span,.yoda-list__option--empty span{color:var(--yoda-list-muted-color)}.yoda-list__option[role=option]{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;background:var(--yoda-list-background)}.yoda-list__option[role=option].focus{cursor:pointer;color:var(--yoda-list-option-focus-color);background:var(--yoda-list-option-focus-background)}.yoda-list__option[role=option].select{color:var(--yoda-list-option-selected-color);background:var(--yoda-list-option-selected-background)}.yoda-list__option[role=option].select.focus{background:var(--yoda-list-option-focus-selected-background)}.yoda-list-layout{display:flex;flex-direction:column;flex-wrap:nowrap;outline:none}.yoda-list-layout.overlay{min-inline-size:100%;max-inline-size:0;overflow:hidden;color:var(--yoda-overlay-color);background:var(--yoda-list-background);border:1px solid var(--yoda-overlay-border-color);border-radius:var(--yoda-overlay-border-radius);box-shadow:var(--yoda-overlay-shadow)}.yoda-list-layout.inline{width:100%;display:inline-flex}.yoda-list-layout header,.yoda-list-layout footer{display:flex;flex-direction:column;gap:var(--yoda-list-gap)}.yoda-list-layout header{padding:var(--yoda-list-header-padding)}.yoda-list-layout footer{padding:var(--yoda-list-footer-padding)}.yoda-list-layout__content{overflow:auto;outline:none}\n"] }]
575
- }], ctorParameters: () => [], propDecorators: { listRef: [{ type: i0.ViewChild, args: ['listRef', { isSignal: true }] }], hintContentRef: [{ type: i0.ContentChild, args: ['hint', { ...{ read: TemplateRef }, isSignal: true }] }], emptyContentRef: [{ type: i0.ContentChild, args: ['empty', { ...{ read: TemplateRef }, isSignal: true }] }], headerContentRef: [{ type: i0.ContentChild, args: ['header', { ...{ read: TemplateRef }, isSignal: true }] }], footerContentRef: [{ type: i0.ContentChild, args: ['footer', { ...{ read: TemplateRef }, isSignal: true }] }], optionContentRef: [{ type: i0.ContentChild, args: ['option', { ...{ read: TemplateRef }, isSignal: true }] }], groupOptionContentRef: [{ type: i0.ContentChild, args: ['groupOption', { ...{ read: TemplateRef }, isSignal: true }] }], action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: false }] }], repository: [{ type: i0.Input, args: [{ isSignal: true, alias: "repository", required: false }] }], apiUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "apiUrl", required: false }] }], hintMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "hintMessage", required: false }] }], createMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "createMode", required: false }] }], scrollHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollHeight", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], viewMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "viewMode", required: false }] }], group: [{ type: i0.Input, args: [{ isSignal: true, alias: "group", required: false }] }], create: [{ type: i0.Input, args: [{ isSignal: true, alias: "create", required: false }] }], showHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "showHint", required: false }] }], showEmpty: [{ type: i0.Input, args: [{ isSignal: true, alias: "showEmpty", required: false }] }], showClear: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClear", required: false }] }], showCreate: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCreate", required: false }] }], loopScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "loopScroll", required: false }] }], showLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLoading", required: false }] }], selectGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectGroup", required: false }] }], groupSticky: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupSticky", required: false }] }], showDropdown: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDropdown", required: false }] }], autoSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoSelect", required: false }] }], delay: [{ type: i0.Input, args: [{ isSignal: true, alias: "delay", required: false }] }], itemsShow: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsShow", required: false }] }], minQueryLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minQueryLength", required: false }] }], disabledOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledOption", required: false }] }], transformOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformOptions", required: false }] }], hideOverlay: [{
576
- type: HostListener,
577
- args: ['keydown.tab']
578
- }], onSelectOption: [{
579
- type: HostListener,
580
- args: ['keydown.enter', ['$event']]
581
- }], moveFocus: [{
582
- type: HostListener,
583
- args: ['keydown.arrowup', ['$event', '-1']]
584
- }, {
585
- type: HostListener,
586
- args: ['keydown.arrowdown', ['$event', '1']]
587
- }] } });
1233
+ args: [{ selector: 'ss-yoda', changeDetection: ChangeDetectionStrategy.OnPush, providers: [StateService, SlotsService], host: {
1234
+ '[attr.data-size]': 'size()',
1235
+ '[attr.data-variant]': 'variant()',
1236
+ '[attr.data-separator]': 'separator()',
1237
+ '[style.inline-size]': 'width()',
1238
+ '[style.flex]': 'flexBasis$$()',
1239
+ '[class.yoda--inline]': 'listRender() === "inline"',
1240
+ '[class.yoda--disabled]': 'isDisabled$$()',
1241
+ '[class.yoda--locked]': 'isLocked$$()',
1242
+ '[class.yoda--chained]': 'chainInline$$()',
1243
+ '[class.yoda--hidden]': 'chainHidden$$()',
1244
+ '[attr.data-chain]': 'chainPosition$$()',
1245
+ '[class.yoda--invalid]': 'invalid$$()',
1246
+ '(keydown.escape)': 'close()',
1247
+ '(keydown.tab)': 'close()',
1248
+ '(keydown.enter)': 'onEnter($event)',
1249
+ '(keydown.arrowdown)': 'onArrow($event, 1)',
1250
+ '(keydown.arrowup)': 'onArrow($event, -1)',
1251
+ '(focusout)': 'onFocusOut($event.relatedTarget)',
1252
+ }, imports: [ActionComponent, NativeComponent, PanelComponent, ListComponent], template: "<div class=\"yoda__field\">\n @if (createStartVisible$$()) {\n <ss-yoda-action\n class=\"yoda__segment\"\n type=\"create\"\n [disabled]=\"createDisabled$$()\"\n (activated)=\"onAction($event)\"\n />\n }\n\n <div class=\"yoda__segment yoda__segment--input\">\n <input\n #inputRef\n class=\"yoda__input\"\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n [attr.id]=\"id()\"\n [attr.name]=\"name()\"\n [attr.size]=\"inputSize()\"\n [attr.tabindex]=\"tabindex()\"\n [attr.required]=\"required()\"\n [attr.minlength]=\"minlength()\"\n [attr.maxlength]=\"maxlength()\"\n [attr.readonly]=\"inputReadonly()\"\n [attr.placeholder]=\"placeholder()\"\n [attr.autocomplete]=\"autocomplete()\"\n [attr.aria-expanded]=\"state.isOpen$$()\"\n [attr.aria-invalid]=\"invalid$$() || null\"\n [value]=\"typed$$()\"\n [disabled]=\"isDisabled$$()\"\n (focus)=\"onFocus()\"\n (input)=\"onInput(inputRef.value)\"\n />\n\n @if (counterVisible$$()) {\n <ss-yoda-action\n type=\"counter\"\n [itemsShow]=\"itemsShow()\"\n [selectGroup]=\"selectGroup()\"\n />\n }\n\n @if (clearVisible$$()) {\n <ss-yoda-action\n type=\"clear\"\n (activated)=\"onAction($event)\"\n />\n }\n </div>\n\n @if (createEndVisible$$()) {\n <ss-yoda-action\n class=\"yoda__segment\"\n type=\"create\"\n [disabled]=\"createDisabled$$()\"\n (activated)=\"onAction($event)\"\n />\n }\n\n @if (statusVisible$$()) {\n <div class=\"yoda__segment yoda__segment--status\">\n <ss-yoda-action\n type=\"state\"\n [native]=\"isNative$$()\"\n [errorText]=\"errorText$$()\"\n (activated)=\"onAction($event)\"\n />\n\n @if (isNative$$()) {\n <ss-yoda-native\n [disabled]=\"isLocked$$()\"\n [placeholder]=\"placeholder()\"\n />\n }\n </div>\n }\n</div>\n\n@if (!isNative$$()) {\n <ss-yoda-panel\n [origin]=\"host\"\n [showHint]=\"showHint()\"\n [showEmpty]=\"showEmpty()\"\n [listRender]=\"listRender()\"\n [panelClass]=\"panelClass()\"\n [hintMessage]=\"hintMessage()\"\n [scrollHeight]=\"scrollHeight()\"\n [emptyMessage]=\"emptyMessage()\"\n [scrollStrategy]=\"scrollStrategy()\"\n [minQueryLength]=\"minQueryLength()\"\n >\n <ss-yoda-list\n [showMore]=\"showMore()\"\n [itemsShow]=\"itemsShow()\"\n [loopScroll]=\"loopScroll()\"\n [moreMessage]=\"moreMessage()\"\n [selectGroup]=\"selectGroup()\"\n [groupSticky]=\"groupSticky()\"\n [showHighlight]=\"showHighlight()\"\n [disabledOption]=\"disabledOption()\"\n (selected)=\"onSelect($event)\"\n />\n </ss-yoda-panel>\n}\n", styles: [":host{display:flex;inline-size:100%;flex-direction:column;color:var(--ss-yoda-color, #18181b);font-size:var(--ss-yoda-font-size, 1rem)}.yoda__field{display:flex;position:relative;align-items:stretch;border-radius:var(--ss-yoda-radius, 6px);background:var(--ss-yoda-background, #fff);border:1px solid var(--ss-yoda-border-color, #d4d4d8)}:host(:not(.yoda--locked)) .yoda__field:focus-within{box-shadow:var(--ss-yoda-focus-ring-shadow, none);outline-offset:var(--ss-yoda-focus-ring-offset, 0);border-color:var(--ss-yoda-border-focus-color, #3b82f6);outline:var(--ss-yoda-focus-ring-width, 0) var(--ss-yoda-focus-ring-style, none) var(--ss-yoda-focus-ring-color, transparent)}:host([data-variant=fill]) .yoda__field{background:var(--ss-yoda-fill-background, #f4f4f5)}:host([data-size=small]){--ss-yoda-padding-y: var(--ss-yoda-sm-padding-y, .25rem);--ss-yoda-padding-x: var(--ss-yoda-sm-padding-x, .5rem);--ss-yoda-font-size: var(--ss-yoda-sm-font-size, .875rem)}:host([data-size=large]){--ss-yoda-padding-y: var(--ss-yoda-lg-padding-y, .75rem);--ss-yoda-padding-x: var(--ss-yoda-lg-padding-x, .75rem);--ss-yoda-font-size: var(--ss-yoda-lg-font-size, 1.125rem)}:host(.yoda--invalid) .yoda__field{border-color:var(--ss-yoda-border-invalid-color, #ef4444)}:host(.yoda--invalid) .yoda__field:focus-within{border-color:var(--ss-yoda-border-invalid-focus-color, #dc2626)}:host(.yoda--disabled){cursor:not-allowed;opacity:var(--ss-yoda-disabled-opacity, .6)}.yoda__segment{display:flex;flex:0 0 auto;align-items:center;justify-content:center;padding-inline:var(--ss-yoda-padding-x, .75rem)}.yoda__segment--input{flex:1 1 0;min-inline-size:0;justify-content:flex-start;gap:var(--ss-yoda-gap, .5rem)}.yoda__segment--status{position:relative}:host([data-separator=border]) .yoda__segment+.yoda__segment{border-inline-start:1px solid var(--ss-yoda-separator-color, #e4e4e7)}:host([data-separator=divider]) .yoda__segment+.yoda__segment{position:relative}:host([data-separator=divider]) .yoda__segment+.yoda__segment:before{content:\"\";inline-size:1px;position:absolute;inset-inline-start:0;inset-block:var(--ss-yoda-divider-inset, .375rem);background:var(--ss-yoda-separator-color, #e4e4e7)}.yoda__input{border:0;outline:0;flex:1 1 0;font:inherit;color:inherit;min-inline-size:0;text-overflow:ellipsis;background:transparent;padding-block:var(--ss-yoda-padding-y, .5rem)}.yoda__input::placeholder{color:var(--ss-yoda-muted-color, #a1a1aa)}.yoda__input:disabled{cursor:not-allowed}:host(.yoda--hidden){display:none}:host(.yoda--chained){flex:1 1 0}:host(.yoda--chained) .yoda__field{border-radius:0}:host(.yoda--chained:not([data-chain=first])){margin-inline-start:-1px}:host(.yoda--chained[data-chain=first]) .yoda__field,:host(.yoda--chained[data-chain=only]) .yoda__field{border-end-start-radius:var(--ss-yoda-radius, 6px);border-start-start-radius:var(--ss-yoda-radius, 6px)}:host(.yoda--chained[data-chain=last]) .yoda__field,:host(.yoda--chained[data-chain=only]) .yoda__field{border-end-end-radius:var(--ss-yoda-radius, 6px);border-start-end-radius:var(--ss-yoda-radius, 6px)}:host(.yoda--chained) .yoda__field:focus-within{z-index:1}\n"] }]
1253
+ }], ctorParameters: () => [], propDecorators: { list: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ListComponent), { isSignal: true }] }] } });
1254
+
1255
+ class YodaChain {
1256
+ constructor() {
1257
+ this.chain = inject(ChainService);
1258
+ this.inline = input(false, ...(ngDevMode ? [{ debugName: "inline", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
1259
+ this.pending = input('none', ...(ngDevMode ? [{ debugName: "pending" }] : []));
1260
+ effect(() => this.chain.setInline(this.inline()));
1261
+ effect(() => this.chain.setPending(this.pending()));
1262
+ }
1263
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaChain, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1264
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.18", type: YodaChain, isStandalone: true, selector: "ss-yoda-chain", inputs: { inline: { classPropertyName: "inline", publicName: "inline", isSignal: true, isRequired: false, transformFunction: null }, pending: { classPropertyName: "pending", publicName: "pending", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.yoda-chain--inline": "inline()" } }, providers: [ChainService], ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host{display:flex;flex-direction:column;gap:var(--ss-yoda-chain-gap, .75rem)}:host(.yoda-chain--inline){flex-direction:row;align-items:stretch;gap:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1265
+ }
1266
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaChain, decorators: [{
1267
+ type: Component,
1268
+ args: [{ selector: 'ss-yoda-chain', template: '<ng-content />', host: {
1269
+ '[class.yoda-chain--inline]': 'inline()',
1270
+ }, changeDetection: ChangeDetectionStrategy.OnPush, providers: [ChainService], styles: [":host{display:flex;flex-direction:column;gap:var(--ss-yoda-chain-gap, .75rem)}:host(.yoda-chain--inline){flex-direction:row;align-items:stretch;gap:0}\n"] }]
1271
+ }], ctorParameters: () => [], propDecorators: { inline: [{ type: i0.Input, args: [{ isSignal: true, alias: "inline", required: false }] }], pending: [{ type: i0.Input, args: [{ isSignal: true, alias: "pending", required: false }] }] } });
1272
+
1273
+ /** Настройка иконок: разметка `<svg…>` либо классы шрифта */
1274
+ const withIcons = defineKitFeature(0 /* FeatureKind.Icons */, (icons) => ({
1275
+ provide: ICONS,
1276
+ useFactory: () => ({ ...DEFAULT_ICONS, ...resolveMaybeFn(icons) }),
1277
+ }));
1278
+ /** Настройка текстов интерфейса */
1279
+ const withMessages = defineKitFeature(1 /* FeatureKind.Messages */, (messages) => ({
1280
+ provide: MESSAGES,
1281
+ useFactory: () => mergeMessages(resolveMaybeFn(messages)),
1282
+ }));
1283
+ /** Настройка расчета z-index оверлея */
1284
+ const withZIndex = defineKitFeature(2 /* FeatureKind.ZIndex */, (resolver) => ({
1285
+ provide: Z_INDEX,
1286
+ useValue: resolver,
1287
+ }));
1288
+ function provideYoda(config, ...features) {
1289
+ const providers = resolveConfigProviders(config, (data) => ({
1290
+ provide: CONFIG,
1291
+ useFactory: () => mergeConfig(resolveMaybeFn(data)),
1292
+ }));
1293
+ return makeEnvironmentProviders([...providers, ...collectFeatureProviders(config, ...features)]);
1294
+ }
1295
+ function mergeConfig(config) {
1296
+ return {
1297
+ ...DEFAULT_CONFIG,
1298
+ ...config,
1299
+ show: { ...DEFAULT_CONFIG.show, ...config.show },
1300
+ request: { ...DEFAULT_CONFIG.request, ...config.request },
1301
+ overlay: { ...DEFAULT_CONFIG.overlay, ...config.overlay },
1302
+ };
1303
+ }
1304
+ function mergeMessages(messages) {
1305
+ const actions = { ...DEFAULT_MESSAGES.actions };
1306
+ for (const key of objectKeys(actions)) {
1307
+ actions[key] = { ...actions[key], ...messages.actions?.[key] };
1308
+ }
1309
+ return { ...DEFAULT_MESSAGES, ...messages, actions };
1310
+ }
588
1311
 
589
1312
  /**
590
1313
  * Generated bundle index. Do not edit.
591
1314
  */
592
1315
 
593
- export { Yoda, provideYodaConfig };
1316
+ export { Yoda, YodaChain, RequestType as YodaRequestType, provideYoda, withIcons, withMessages, withZIndex };
594
1317
  //# sourceMappingURL=ui-yoda.mjs.map