@sevtech/kit 21.0.0 → 21.1.1
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.
- package/fesm2022/browser.mjs +5 -1
- package/fesm2022/browser.mjs.map +1 -1
- package/fesm2022/localization.mjs +4 -8
- package/fesm2022/localization.mjs.map +1 -1
- package/fesm2022/misc.mjs +110 -7
- package/fesm2022/misc.mjs.map +1 -1
- package/fesm2022/ng-misc.mjs +20 -3
- package/fesm2022/ng-misc.mjs.map +1 -1
- package/fesm2022/ui-yoda.mjs +1211 -466
- package/fesm2022/ui-yoda.mjs.map +1 -1
- package/fesm2022/ui.mjs +254 -3
- package/fesm2022/ui.mjs.map +1 -1
- package/misc/index.d.ts +95 -4
- package/ng-misc/index.d.ts +36 -2
- package/package.json +10 -10
- package/ui/index.d.ts +125 -3
- package/ui/yoda/index.d.ts +440 -148
- package/ui/yoda/primeng.scss +58 -0
package/fesm2022/ui-yoda.mjs
CHANGED
|
@@ -1,594 +1,1339 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, Injectable,
|
|
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
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
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
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
factory: () =>
|
|
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
|
+
const LABEL_FORMATTERS = createToken('[YODA]: сборка подписей опций', {});
|
|
111
|
+
|
|
112
|
+
var RequestType;
|
|
113
|
+
(function (RequestType) {
|
|
114
|
+
RequestType[RequestType["Get"] = 0] = "Get";
|
|
115
|
+
RequestType[RequestType["Search"] = 1] = "Search";
|
|
116
|
+
RequestType[RequestType["Create"] = 2] = "Create";
|
|
117
|
+
})(RequestType || (RequestType = {}));
|
|
46
118
|
|
|
47
|
-
class
|
|
119
|
+
class ApiService {
|
|
48
120
|
constructor() {
|
|
49
121
|
this.config = inject(CONFIG);
|
|
122
|
+
this.formatters = inject(LABEL_FORMATTERS);
|
|
50
123
|
this.httpClient = inject(HttpClient);
|
|
51
124
|
}
|
|
52
|
-
request(
|
|
53
|
-
const
|
|
54
|
-
return this.httpClient
|
|
55
|
-
params
|
|
56
|
-
|
|
57
|
-
});
|
|
125
|
+
request(data) {
|
|
126
|
+
const { url, params } = this.resolveEndpoint(data);
|
|
127
|
+
return this.httpClient
|
|
128
|
+
.get(url, { params })
|
|
129
|
+
.pipe(map((rows) => this.parseResponse(rows, data)));
|
|
58
130
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
131
|
+
resolveEndpoint(data) {
|
|
132
|
+
const params = toRequestParams(data);
|
|
133
|
+
if (isFunction(data.url)) {
|
|
134
|
+
return { url: data.url(params) };
|
|
62
135
|
}
|
|
63
|
-
if (
|
|
64
|
-
|
|
136
|
+
if (isString(data.url)) {
|
|
137
|
+
return { url: data.url, params: this.config.request.paramsMapper(params) };
|
|
65
138
|
}
|
|
66
|
-
|
|
139
|
+
if (params.action && params.repository) {
|
|
140
|
+
return { url: this.config.request.apiUrl, params: this.config.request.paramsMapper(params) };
|
|
141
|
+
}
|
|
142
|
+
throw new Error('[YODA]: provide either `url` or both `action` and `repository`');
|
|
143
|
+
}
|
|
144
|
+
parseResponse(rows, data) {
|
|
145
|
+
if (!isArray(rows))
|
|
146
|
+
throw new Error('[YODA]: expected array in response');
|
|
147
|
+
if (isFunction(data.transform))
|
|
148
|
+
return flattenOptions(data.transform(rows));
|
|
149
|
+
const formatLabel = resolveFormatter(data, this.formatters);
|
|
150
|
+
return rows.map((row) => parseResponseRaw(row, formatLabel));
|
|
67
151
|
}
|
|
68
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type:
|
|
69
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type:
|
|
152
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
153
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiService, providedIn: 'root' }); }
|
|
70
154
|
}
|
|
71
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type:
|
|
155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiService, decorators: [{
|
|
72
156
|
type: Injectable,
|
|
73
157
|
args: [{
|
|
74
158
|
providedIn: 'root',
|
|
75
159
|
}]
|
|
76
160
|
}] });
|
|
161
|
+
function resolveFormatter({ action, repository }, formatters) {
|
|
162
|
+
if (!isString(action))
|
|
163
|
+
return undefined;
|
|
164
|
+
if (isString(repository)) {
|
|
165
|
+
return formatters[`${repository}:${action}`] ?? formatters[action];
|
|
166
|
+
}
|
|
167
|
+
return formatters[action];
|
|
168
|
+
}
|
|
169
|
+
function flattenOptions(options) {
|
|
170
|
+
return options.flatMap((option, index) => {
|
|
171
|
+
if (!isGroupOption(option))
|
|
172
|
+
return toFlatOption(option);
|
|
173
|
+
const { items, ...group } = option;
|
|
174
|
+
const id = `group-${index}`;
|
|
175
|
+
return [{ ...group, id, kind: 'group' }, ...items.map((item) => toFlatOption(item, id))];
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function isGroupOption(option) {
|
|
179
|
+
return 'items' in option && isArray(option.items);
|
|
180
|
+
}
|
|
181
|
+
function parseResponseRaw(row, formatLabel) {
|
|
182
|
+
const [value, label, ...payload] = row;
|
|
183
|
+
return {
|
|
184
|
+
value,
|
|
185
|
+
payload,
|
|
186
|
+
kind: 'option',
|
|
187
|
+
label: isFunction(formatLabel) ? formatLabel(...row) : label,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function toRequestParams({ action, repository, type, query, parent }) {
|
|
191
|
+
return { action, repository, type, query, parent };
|
|
192
|
+
}
|
|
193
|
+
function toFlatOption(item, parent) {
|
|
194
|
+
return { ...item, kind: 'option', parent };
|
|
195
|
+
}
|
|
77
196
|
|
|
78
|
-
class
|
|
79
|
-
|
|
80
|
-
|
|
197
|
+
class StateService {
|
|
198
|
+
constructor() {
|
|
199
|
+
this.api = inject(ApiService);
|
|
200
|
+
this.search$ = new Subject();
|
|
201
|
+
this.create$ = new Subject();
|
|
202
|
+
this.fetch$ = new Subject();
|
|
203
|
+
this.querySource = signal('', ...(ngDevMode ? [{ debugName: "querySource" }] : []));
|
|
204
|
+
this.filterSource = signal('', ...(ngDevMode ? [{ debugName: "filterSource" }] : []));
|
|
205
|
+
this.openSource = signal(false, ...(ngDevMode ? [{ debugName: "openSource" }] : []));
|
|
206
|
+
this.stateSource = signal({ status: 'idle' }, ...(ngDevMode ? [{ debugName: "stateSource" }] : []));
|
|
207
|
+
this.optionsSource = signal(null, ...(ngDevMode ? [{ debugName: "optionsSource" }] : []));
|
|
208
|
+
this.selectedSource = signal(null, ...(ngDevMode ? [{ debugName: "selectedSource" }] : []));
|
|
209
|
+
this.createdSource = signal(null, ...(ngDevMode ? [{ debugName: "createdSource" }] : []));
|
|
210
|
+
this.matchSource = signal(matchByLabel, ...(ngDevMode ? [{ debugName: "matchSource" }] : []));
|
|
211
|
+
this.query$$ = this.querySource.asReadonly();
|
|
212
|
+
this.selected$$ = this.selectedSource.asReadonly();
|
|
213
|
+
this.isOpen$$ = this.openSource.asReadonly();
|
|
214
|
+
this.requestState$$ = this.stateSource.asReadonly();
|
|
215
|
+
this.created$$ = this.createdSource.asReadonly();
|
|
216
|
+
this.options$$ = computed(() => {
|
|
217
|
+
const options = this.optionsSource();
|
|
218
|
+
const query = this.filterSource().trim().toLowerCase();
|
|
219
|
+
if (isNil(options) || query.length === 0)
|
|
220
|
+
return options;
|
|
221
|
+
return filterOptions(options, query, this.matchSource());
|
|
222
|
+
}, ...(ngDevMode ? [{ debugName: "options$$" }] : []));
|
|
223
|
+
this.search$
|
|
224
|
+
.pipe(debounce(({ delay }) => timer(delay)), filter((request) => shouldSearch(request, this.querySource())), tap(({ query }) => this.querySource.set(query)), switchMap((request) => this.executeRequest(request, true)), takeUntilDestroyed())
|
|
225
|
+
.subscribe();
|
|
226
|
+
this.fetch$
|
|
227
|
+
.pipe(switchMap((request) => this.executeRequest(request)), takeUntilDestroyed())
|
|
228
|
+
.subscribe();
|
|
229
|
+
this.create$
|
|
230
|
+
.pipe(exhaustMap((request) => this.executeRequest(request)), takeUntilDestroyed())
|
|
231
|
+
.subscribe();
|
|
232
|
+
}
|
|
233
|
+
queryChange(query, options) {
|
|
234
|
+
const value = query.trim();
|
|
235
|
+
if (this.selectedSource()) {
|
|
236
|
+
this.select(null);
|
|
237
|
+
}
|
|
238
|
+
this.open();
|
|
239
|
+
if (isShortQuery(value, options.minQueryLength)) {
|
|
240
|
+
this.clearOptions();
|
|
241
|
+
}
|
|
242
|
+
this.search$.next(buildRequest(value, RequestType.Search, 'options', options));
|
|
243
|
+
}
|
|
244
|
+
load(query, options, type = RequestType.Get) {
|
|
245
|
+
this.fetch$.next(buildRequest(query, type, 'options', options));
|
|
246
|
+
}
|
|
247
|
+
resolve(value, options) {
|
|
248
|
+
this.fetch$.next(buildRequest(value.toString(), RequestType.Get, 'selection', options));
|
|
81
249
|
}
|
|
250
|
+
createByQuery(query, options) {
|
|
251
|
+
this.create$.next(buildRequest(query, RequestType.Create, 'selection', options));
|
|
252
|
+
}
|
|
253
|
+
retry() {
|
|
254
|
+
const state = this.stateSource();
|
|
255
|
+
if (state.status !== 'error')
|
|
256
|
+
return;
|
|
257
|
+
if (state.request.type === RequestType.Create) {
|
|
258
|
+
return this.create$.next(state.request);
|
|
259
|
+
}
|
|
260
|
+
this.fetch$.next(state.request);
|
|
261
|
+
}
|
|
262
|
+
select(option) {
|
|
263
|
+
this.selectedSource.set(option);
|
|
264
|
+
}
|
|
265
|
+
filter(query, match) {
|
|
266
|
+
this.filterSource.set(query);
|
|
267
|
+
this.querySource.set(query.trim());
|
|
268
|
+
this.matchSource.set(match ?? matchByLabel);
|
|
269
|
+
}
|
|
270
|
+
clear() {
|
|
271
|
+
this.filterSource.set('');
|
|
272
|
+
this.selectedSource.set(null);
|
|
273
|
+
this.stateSource.set({ status: 'idle' });
|
|
274
|
+
this.clearOptions();
|
|
275
|
+
}
|
|
276
|
+
clearOptions() {
|
|
277
|
+
this.optionsSource.set(null);
|
|
278
|
+
this.querySource.set('');
|
|
279
|
+
}
|
|
280
|
+
open() {
|
|
281
|
+
this.openSource.set(true);
|
|
282
|
+
}
|
|
283
|
+
close() {
|
|
284
|
+
this.openSource.set(false);
|
|
285
|
+
}
|
|
286
|
+
toggle() {
|
|
287
|
+
this.openSource() ? this.close() : this.open();
|
|
288
|
+
}
|
|
289
|
+
apply(request, options, fromSearch) {
|
|
290
|
+
this.stateSource.set({ status: 'idle' });
|
|
291
|
+
if (request.target === 'options') {
|
|
292
|
+
return this.applyOptions(request, options, fromSearch);
|
|
293
|
+
}
|
|
294
|
+
this.applySelection(request, options);
|
|
295
|
+
}
|
|
296
|
+
executeRequest(request, fromSearch = false) {
|
|
297
|
+
return defer(() => {
|
|
298
|
+
this.stateSource.set({ status: 'loading' });
|
|
299
|
+
return this.api.request(request);
|
|
300
|
+
}).pipe(tap((options) => this.apply(request, options, fromSearch)), catchError((error) => {
|
|
301
|
+
this.stateSource.set({ status: 'error', request, error });
|
|
302
|
+
return EMPTY;
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
applyOptions(request, options, fromSearch) {
|
|
306
|
+
if (fromSearch && request.query !== this.querySource())
|
|
307
|
+
return;
|
|
308
|
+
this.optionsSource.set(options);
|
|
309
|
+
}
|
|
310
|
+
applySelection(request, [option]) {
|
|
311
|
+
if (isNil(option))
|
|
312
|
+
return;
|
|
313
|
+
if (request.type === RequestType.Create) {
|
|
314
|
+
this.optionsSource.update((current) => [option, ...(current ?? [])]);
|
|
315
|
+
this.createdSource.set(option);
|
|
316
|
+
}
|
|
317
|
+
this.select(option);
|
|
318
|
+
}
|
|
319
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
320
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StateService }); }
|
|
321
|
+
}
|
|
322
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StateService, decorators: [{
|
|
323
|
+
type: Injectable
|
|
324
|
+
}], ctorParameters: () => [] });
|
|
325
|
+
function buildRequest(query, type, target, options) {
|
|
326
|
+
return { ...options, type, query, target };
|
|
327
|
+
}
|
|
328
|
+
function matchByLabel(option, query) {
|
|
329
|
+
return option.label.toLowerCase().includes(query);
|
|
330
|
+
}
|
|
331
|
+
function isShortQuery(query, minQueryLength) {
|
|
332
|
+
return query.length === 0 || query.length < minQueryLength;
|
|
333
|
+
}
|
|
334
|
+
function shouldSearch(request, query) {
|
|
335
|
+
if (isShortQuery(request.query, request.minQueryLength))
|
|
336
|
+
return false;
|
|
337
|
+
return request.query !== query;
|
|
338
|
+
}
|
|
339
|
+
function filterOptions(options, query, match) {
|
|
340
|
+
const result = [];
|
|
341
|
+
let group = null;
|
|
342
|
+
for (const option of options) {
|
|
343
|
+
if (option.kind === 'group') {
|
|
344
|
+
group = option;
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (!match(option, query))
|
|
348
|
+
continue;
|
|
349
|
+
if (group) {
|
|
350
|
+
result.push(group);
|
|
351
|
+
group = null;
|
|
352
|
+
}
|
|
353
|
+
result.push(option);
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
class SlotsService {
|
|
82
359
|
constructor() {
|
|
360
|
+
this.source = null;
|
|
361
|
+
}
|
|
362
|
+
init(slots) {
|
|
363
|
+
this.source = slots;
|
|
364
|
+
}
|
|
365
|
+
get(name) {
|
|
366
|
+
if (!this.source)
|
|
367
|
+
return null;
|
|
368
|
+
return this.source[`${name}Ref`]() ?? null;
|
|
369
|
+
}
|
|
370
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
371
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotsService }); }
|
|
372
|
+
}
|
|
373
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotsService, decorators: [{
|
|
374
|
+
type: Injectable
|
|
375
|
+
}] });
|
|
376
|
+
|
|
377
|
+
class ChainService {
|
|
378
|
+
constructor() {
|
|
379
|
+
this.links$$ = signal([], ...(ngDevMode ? [{ debugName: "links$$" }] : []));
|
|
380
|
+
this.inlineSource$$ = signal(false, ...(ngDevMode ? [{ debugName: "inlineSource$$" }] : []));
|
|
381
|
+
this.pendingSource$$ = signal('none', ...(ngDevMode ? [{ debugName: "pendingSource$$" }] : []));
|
|
382
|
+
this.inline$$ = this.inlineSource$$.asReadonly();
|
|
383
|
+
this.pending$$ = this.pendingSource$$.asReadonly();
|
|
384
|
+
}
|
|
385
|
+
setInline(inline) {
|
|
386
|
+
this.inlineSource$$.set(inline);
|
|
387
|
+
}
|
|
388
|
+
setPending(pending) {
|
|
389
|
+
this.pendingSource$$.set(pending);
|
|
390
|
+
}
|
|
391
|
+
position(link) {
|
|
392
|
+
const links = this.links$$();
|
|
393
|
+
const index = links.indexOf(link);
|
|
394
|
+
if (index < 0 || links.length <= 1)
|
|
395
|
+
return 'only';
|
|
396
|
+
if (index === 0)
|
|
397
|
+
return 'first';
|
|
398
|
+
return index === links.length - 1 ? 'last' : 'middle';
|
|
399
|
+
}
|
|
400
|
+
register(link) {
|
|
401
|
+
this.links$$.update((links) => [...links, link]);
|
|
402
|
+
}
|
|
403
|
+
unregister(link) {
|
|
404
|
+
this.links$$.update((links) => links.filter((item) => item !== link));
|
|
405
|
+
}
|
|
406
|
+
parentValue(link) {
|
|
407
|
+
const links = this.links$$();
|
|
408
|
+
const index = links.indexOf(link);
|
|
409
|
+
if (index <= 0)
|
|
410
|
+
return undefined;
|
|
411
|
+
return links[index - 1].selection$$()?.value ?? null;
|
|
412
|
+
}
|
|
413
|
+
resetAfter(link) {
|
|
414
|
+
const links = this.links$$();
|
|
415
|
+
const index = links.indexOf(link);
|
|
416
|
+
if (index < 0)
|
|
417
|
+
return;
|
|
418
|
+
links.slice(index + 1).forEach((item) => item.reset());
|
|
419
|
+
}
|
|
420
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ChainService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
421
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ChainService }); }
|
|
422
|
+
}
|
|
423
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ChainService, decorators: [{
|
|
424
|
+
type: Injectable
|
|
425
|
+
}] });
|
|
426
|
+
|
|
427
|
+
class SlotDirective {
|
|
428
|
+
constructor() {
|
|
429
|
+
this.slotsService = inject(SlotsService);
|
|
430
|
+
this.createIconRef = contentChild('createIcon', ...(ngDevMode ? [{ debugName: "createIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
431
|
+
this.clearIconRef = contentChild('clearIcon', ...(ngDevMode ? [{ debugName: "clearIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
432
|
+
this.toggleIconRef = contentChild('toggleIcon', ...(ngDevMode ? [{ debugName: "toggleIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
433
|
+
this.loaderIconRef = contentChild('loaderIcon', ...(ngDevMode ? [{ debugName: "loaderIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
434
|
+
this.reloadIconRef = contentChild('reloadIcon', ...(ngDevMode ? [{ debugName: "reloadIconRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
435
|
+
this.counterRef = contentChild('counter', ...(ngDevMode ? [{ debugName: "counterRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
436
|
+
this.optionRef = contentChild('option', ...(ngDevMode ? [{ debugName: "optionRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
437
|
+
this.groupRef = contentChild('group', ...(ngDevMode ? [{ debugName: "groupRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
438
|
+
this.hintRef = contentChild('hint', ...(ngDevMode ? [{ debugName: "hintRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
439
|
+
this.emptyRef = contentChild('empty', ...(ngDevMode ? [{ debugName: "emptyRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
440
|
+
this.headerRef = contentChild('header', ...(ngDevMode ? [{ debugName: "headerRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
441
|
+
this.footerRef = contentChild('footer', ...(ngDevMode ? [{ debugName: "footerRef", read: TemplateRef }] : [{ read: TemplateRef }]));
|
|
442
|
+
this.slotsService.init(this);
|
|
443
|
+
}
|
|
444
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
445
|
+
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 }); }
|
|
446
|
+
}
|
|
447
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: SlotDirective, decorators: [{
|
|
448
|
+
type: Directive
|
|
449
|
+
}], 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 }] }] } });
|
|
450
|
+
|
|
451
|
+
const nativeTransform = (value) => (value === 'auto' ? 'auto' : booleanAttribute(value));
|
|
452
|
+
const itemsShowTransform = (value) => isNil(value) || value === '' ? null : numberAttribute(value);
|
|
453
|
+
class BaseDirective extends SlotDirective {
|
|
454
|
+
constructor() {
|
|
455
|
+
super(...arguments);
|
|
83
456
|
this.config = inject(CONFIG);
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
457
|
+
this.messages = inject(MESSAGES);
|
|
458
|
+
this.host = inject(ElementRef);
|
|
459
|
+
this.isMobile$$ = inject(IS_MOBILE_BREAKPOINT);
|
|
460
|
+
this.inputRef = viewChild('inputRef', ...(ngDevMode ? [{ debugName: "inputRef" }] : []));
|
|
461
|
+
/** Имя репозитория */
|
|
462
|
+
this.repository = input(...(ngDevMode ? [undefined, { debugName: "repository" }] : []));
|
|
463
|
+
/** Действие репозитория */
|
|
464
|
+
this.action = input(...(ngDevMode ? [undefined, { debugName: "action" }] : []));
|
|
465
|
+
/** Свой эндпоинт вместо общего. Функции достаётся весь набор параметров запроса */
|
|
466
|
+
this.apiUrl = input(...(ngDevMode ? [undefined, { debugName: "apiUrl" }] : []));
|
|
467
|
+
/** Преобразует сырой ответ. Вложенные `items` превращаются в группы */
|
|
468
|
+
this.transformOptions = input(...(ngDevMode ? [undefined, { debugName: "transformOptions" }] : []));
|
|
469
|
+
/** Дебаунс поиска, мс */
|
|
470
|
+
this.delay = input(this.config.request.delay, ...(ngDevMode ? [{ debugName: "delay", transform: numberAttribute }] : [{ transform: numberAttribute }]));
|
|
471
|
+
/** Запрос уходит начиная с этой длины. Пустая строка не ищется никогда */
|
|
472
|
+
this.minQueryLength = input(this.config.request.minQueryLength, ...(ngDevMode ? [{ debugName: "minQueryLength", transform: numberAttribute }] : [{
|
|
473
|
+
transform: numberAttribute,
|
|
474
|
+
}]));
|
|
475
|
+
/** Что уходит в `qs` разовой загрузки списка — она нужна режиму `select` и нативному пикеру, которые догружать по клику не умеют */
|
|
476
|
+
this.preloadQuery = input('', ...(ngDevMode ? [{ debugName: "preloadQuery" }] : []));
|
|
477
|
+
/** Индекс разовой загрузки. В легаси это `fetchDefaultsIndex` */
|
|
478
|
+
this.preloadType = input(RequestType.Get, ...(ngDevMode ? [{ debugName: "preloadType" }] : []));
|
|
479
|
+
/** `select` грузит список один раз и дальше фильтрует его локально */
|
|
480
|
+
this.mode = input(this.config.mode, ...(ngDevMode ? [{ debugName: "mode" }] : []));
|
|
481
|
+
/** Прозрачный `<select>` поверх стрелки; `auto` по мобильному брейкпоинту */
|
|
482
|
+
this.native = input(this.config.native, ...(ngDevMode ? [{ debugName: "native", transform: nativeTransform }] : [{ transform: nativeTransform }]));
|
|
483
|
+
/** Решение конкретного места в вёрстке: `inline` двигает поток под полем */
|
|
484
|
+
this.listRender = input('overlay', ...(ngDevMode ? [{ debugName: "listRender" }] : []));
|
|
485
|
+
/** Сколько строк рисовать; `null` - показать все */
|
|
486
|
+
this.itemsShow = input(this.config.itemsShow, ...(ngDevMode ? [{ debugName: "itemsShow", transform: itemsShowTransform }] : [{
|
|
487
|
+
transform: itemsShowTransform,
|
|
488
|
+
}]));
|
|
489
|
+
/** Высота области прокрутки списка; `null` - без ограничения */
|
|
490
|
+
this.scrollHeight = input(this.config.scrollHeight, ...(ngDevMode ? [{ debugName: "scrollHeight", transform: cssDimensionAttribute }] : [{ transform: cssDimensionAttribute }]));
|
|
491
|
+
/** Перекидывать ли стрелками с последней опции на первую */
|
|
492
|
+
this.loopScroll = input(this.config.loopScroll, ...(ngDevMode ? [{ debugName: "loopScroll", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
493
|
+
/** Делает заголовок группы выбираемой опцией */
|
|
494
|
+
this.selectGroup = input(false, ...(ngDevMode ? [{ debugName: "selectGroup", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
495
|
+
/** Прилепляет заголовок группы к верху списка при прокрутке */
|
|
496
|
+
this.groupSticky = input(false, ...(ngDevMode ? [{ debugName: "groupSticky", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
497
|
+
/** Предикат для определения отключённых опций */
|
|
498
|
+
this.disabledOption = input(...(ngDevMode ? [undefined, { debugName: "disabledOption" }] : []));
|
|
499
|
+
/** Предикат для фильтрации опций в режиме `select` */
|
|
500
|
+
this.filterOption = input(...(ngDevMode ? [undefined, { debugName: "filterOption" }] : []));
|
|
501
|
+
/** Выбрать результат, если он пришёл единственным */
|
|
502
|
+
this.autoSelect = input(this.config.autoSelect, ...(ngDevMode ? [{ debugName: "autoSelect", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
503
|
+
/** Закрывать ли список после автовыбора */
|
|
504
|
+
this.autoSelectClose = input(this.config.autoSelectClose, ...(ngDevMode ? [{ debugName: "autoSelectClose", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
505
|
+
/** Включает кнопку `+`, которая отправляет введённый текст запросом на создание */
|
|
506
|
+
this.create = input(false, ...(ngDevMode ? [{ debugName: "create", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
507
|
+
/** `empty` - показывать кнопку, только когда ничего не нашлось */
|
|
508
|
+
this.createMode = input(this.config.createMode, ...(ngDevMode ? [{ debugName: "createMode" }] : []));
|
|
509
|
+
/** С какой стороны поля стоит кнопка `+` */
|
|
510
|
+
this.createPlace = input(this.config.createPlace, ...(ngDevMode ? [{ debugName: "createPlace" }] : []));
|
|
511
|
+
/** Показывать подсказку, пока списка ещё нет */
|
|
512
|
+
this.showHint = input(this.config.show.hint, ...(ngDevMode ? [{ debugName: "showHint", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
513
|
+
/** Показывать сообщение о пустой выдаче */
|
|
514
|
+
this.showEmpty = input(this.config.show.empty, ...(ngDevMode ? [{ debugName: "showEmpty", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
515
|
+
/** Показывать последнюю строку, разворачивающую список дальше */
|
|
516
|
+
this.showMore = input(this.config.show.more, ...(ngDevMode ? [{ debugName: "showMore", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
517
|
+
/** Показывать крестик, который очищает поле ввода */
|
|
518
|
+
this.showClear = input(this.config.show.clear, ...(ngDevMode ? [{ debugName: "showClear", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
519
|
+
/** Показывать счётчик совпадений если список опций не пустой */
|
|
520
|
+
this.showCounter = input(this.config.show.counter, ...(ngDevMode ? [{ debugName: "showCounter", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
521
|
+
/** Подсветка совпадений */
|
|
522
|
+
this.showHighlight = input(this.config.show.highlight, ...(ngDevMode ? [{ debugName: "showHighlight", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
523
|
+
/** Показывать стрелку */
|
|
524
|
+
this.showToggle = input(this.config.show.toggle, ...(ngDevMode ? [{ debugName: "showToggle", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
525
|
+
/** Показывать спиннер вместо стрелки на время запроса */
|
|
526
|
+
this.showLoader = input(this.config.show.loader, ...(ngDevMode ? [{ debugName: "showLoader", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
527
|
+
/** Текст подсказки, если не задан слот `#hint` */
|
|
528
|
+
this.hintMessage = input(this.messages.hint, ...(ngDevMode ? [{ debugName: "hintMessage" }] : []));
|
|
529
|
+
/** Текст пустой выдачи, если не задан слот `#empty` */
|
|
530
|
+
this.emptyMessage = input(this.messages.empty, ...(ngDevMode ? [{ debugName: "emptyMessage" }] : []));
|
|
531
|
+
/** Подпись строки, разворачивающей список */
|
|
532
|
+
this.moreMessage = input(this.messages.more, ...(ngDevMode ? [{ debugName: "moreMessage" }] : []));
|
|
533
|
+
/** Тултип иконки повтора. Без него берётся текст из `withMessages` */
|
|
534
|
+
this.errorMessage = input(...(ngDevMode ? [undefined, { debugName: "errorMessage" }] : []));
|
|
535
|
+
/** Размер поля */
|
|
536
|
+
this.size = input(this.config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
537
|
+
/** Заливка или рамка */
|
|
538
|
+
this.variant = input(this.config.variant, ...(ngDevMode ? [{ debugName: "variant" }] : []));
|
|
539
|
+
/** Чем отделять сегменты поля друг от друга */
|
|
540
|
+
this.separator = input(this.config.separator, ...(ngDevMode ? [{ debugName: "separator" }] : []));
|
|
541
|
+
/** Ширина поля */
|
|
542
|
+
this.width = input(null, ...(ngDevMode ? [{ debugName: "width", transform: cssDimensionAttribute }] : [{
|
|
543
|
+
transform: cssDimensionAttribute,
|
|
544
|
+
}]));
|
|
545
|
+
/** Класс панели оверлея */
|
|
546
|
+
this.panelClass = input(this.config.overlay.panelClass, ...(ngDevMode ? [{ debugName: "panelClass" }] : []));
|
|
547
|
+
/** Что делать с панелью, когда страница прокручивается под ней */
|
|
548
|
+
this.scrollStrategy = input(this.config.overlay.scrollStrategy, ...(ngDevMode ? [{ debugName: "scrollStrategy" }] : []));
|
|
549
|
+
/** Идентификатор `<input>` - нужен внешнему `<label for>` */
|
|
86
550
|
this.id = input(...(ngDevMode ? [undefined, { debugName: "id" }] : []));
|
|
551
|
+
/** Имя поля при нативной отправке формы */
|
|
87
552
|
this.name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : []));
|
|
553
|
+
/** Текст в пустом поле */
|
|
88
554
|
this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
|
|
89
|
-
|
|
555
|
+
/** По умолчанию `off`: подсказки браузера перекрывают собой список */
|
|
90
556
|
this.autocomplete = input('off', ...(ngDevMode ? [{ debugName: "autocomplete" }] : []));
|
|
91
|
-
|
|
557
|
+
/** Блокирует поле вне реактивной формы; в форме этим распоряжается контрол */
|
|
92
558
|
this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
559
|
+
/** Ставит фокус в поле после первой отрисовки */
|
|
93
560
|
this.autofocus = input(false, ...(ngDevMode ? [{ debugName: "autofocus", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
561
|
+
/** Проставляет атрибут на `<input>` */
|
|
94
562
|
this.required = input(undefined, ...(ngDevMode ? [{ debugName: "required", transform: htmlBooleanAttribute }] : [{ transform: htmlBooleanAttribute }]));
|
|
563
|
+
/** Ведёт себя как `disabled`, но поле остаётся в таб-порядке */
|
|
95
564
|
this.inputReadonly = input(undefined, ...(ngDevMode ? [{ debugName: "inputReadonly", alias: 'readonly', transform: htmlBooleanAttribute }] : [{ alias: 'readonly', transform: htmlBooleanAttribute }]));
|
|
565
|
+
/** Порядок обхода по Tab */
|
|
96
566
|
this.tabindex = input(undefined, ...(ngDevMode ? [{ debugName: "tabindex", transform: numberAttribute }] : [{ transform: numberAttribute }]));
|
|
567
|
+
/** Ограничение длины ввода */
|
|
97
568
|
this.minlength = input(undefined, ...(ngDevMode ? [{ debugName: "minlength", transform: numberAttribute }] : [{ transform: numberAttribute }]));
|
|
569
|
+
/** Ограничение длины ввода */
|
|
98
570
|
this.maxlength = input(undefined, ...(ngDevMode ? [{ debugName: "maxlength", transform: numberAttribute }] : [{ transform: numberAttribute }]));
|
|
571
|
+
/** Атрибут `size` у `<input>`. Ширину самого поля задаёт `width` */
|
|
99
572
|
this.inputSize = input(undefined, ...(ngDevMode ? [{ debugName: "inputSize", transform: numberAttribute }] : [{ transform: numberAttribute }]));
|
|
100
|
-
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
inputRef
|
|
573
|
+
/** Значение родителя вручную — для случаев вне `ss-yoda-chain` */
|
|
574
|
+
this.parentValue = input(null, ...(ngDevMode ? [{ debugName: "parentValue" }] : []));
|
|
575
|
+
/** Сменился выбор, включая сброс в `null` */
|
|
576
|
+
this.selectionChanged = output();
|
|
577
|
+
/** Создание по кнопке `+` прошло успешно */
|
|
578
|
+
this.optionCreated = output();
|
|
579
|
+
/** Запрос упал */
|
|
580
|
+
this.requestFailed = output();
|
|
581
|
+
this.isNative$$ = computed(() => {
|
|
582
|
+
const native = this.native();
|
|
583
|
+
return native === 'auto' ? this.isMobile$$() : native;
|
|
584
|
+
}, ...(ngDevMode ? [{ debugName: "isNative$$" }] : []));
|
|
585
|
+
}
|
|
586
|
+
get inputElement() {
|
|
587
|
+
return this.inputRef()?.nativeElement ?? null;
|
|
115
588
|
}
|
|
116
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type:
|
|
117
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.3.18", type:
|
|
589
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: BaseDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
590
|
+
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
591
|
}
|
|
119
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type:
|
|
592
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: BaseDirective, decorators: [{
|
|
120
593
|
type: Directive
|
|
121
|
-
}],
|
|
594
|
+
}], 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
595
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
596
|
+
const WHITESPACE = /\s+/;
|
|
597
|
+
const MARKUP = /^\s*</;
|
|
598
|
+
class IconDirective {
|
|
599
|
+
constructor() {
|
|
600
|
+
this.icons = inject(ICONS);
|
|
601
|
+
this.renderer = inject(Renderer2);
|
|
602
|
+
this.element = inject(ElementRef).nativeElement;
|
|
603
|
+
this.type = input.required(...(ngDevMode ? [{ debugName: "type", alias: 'ssYodaIcon' }] : [{ alias: 'ssYodaIcon' }]));
|
|
604
|
+
this.classNames = [];
|
|
605
|
+
this.node = null;
|
|
606
|
+
effect(() => this.render(this.type()));
|
|
126
607
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
608
|
+
render(type) {
|
|
609
|
+
this.clear();
|
|
610
|
+
if (isNil(type))
|
|
611
|
+
return;
|
|
612
|
+
const glyph = this.icons[type] ?? '';
|
|
613
|
+
const isMarkup = MARKUP.test(glyph);
|
|
614
|
+
this.addClass(type, isMarkup ? [] : glyph.trim().split(WHITESPACE));
|
|
615
|
+
if (isMarkup) {
|
|
616
|
+
this.addNode(glyph);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
clear() {
|
|
620
|
+
this.classNames.forEach((token) => this.renderer.removeClass(this.element, token));
|
|
621
|
+
this.classNames = [];
|
|
622
|
+
if (this.node) {
|
|
623
|
+
this.renderer.removeChild(this.element, this.node);
|
|
624
|
+
this.node = null;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
addClass(type, classList) {
|
|
628
|
+
const tokens = ['yoda-icon', `yoda-icon--${type}`, ...classList];
|
|
629
|
+
for (const token of tokens) {
|
|
630
|
+
const item = token.trim();
|
|
631
|
+
if (item) {
|
|
632
|
+
this.classNames.push(item);
|
|
633
|
+
this.renderer.addClass(this.element, item);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
addNode(markup) {
|
|
638
|
+
if (!isNonEmptyString(markup))
|
|
639
|
+
return;
|
|
640
|
+
const template = this.renderer.createElement('template');
|
|
641
|
+
template.innerHTML = markup;
|
|
642
|
+
this.node = template.content.firstElementChild;
|
|
643
|
+
if (!this.node)
|
|
644
|
+
return;
|
|
645
|
+
this.renderer.appendChild(this.element, this.node);
|
|
132
646
|
}
|
|
133
|
-
|
|
647
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: IconDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
648
|
+
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
649
|
}
|
|
650
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: IconDirective, decorators: [{
|
|
651
|
+
type: Directive,
|
|
652
|
+
args: [{
|
|
653
|
+
selector: '[ssYodaIcon]',
|
|
654
|
+
}]
|
|
655
|
+
}], ctorParameters: () => [], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "ssYodaIcon", required: true }] }] } });
|
|
135
656
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
657
|
+
class ActionComponent {
|
|
658
|
+
constructor() {
|
|
659
|
+
this.messages = inject(MESSAGES);
|
|
660
|
+
this.slots = inject(SlotsService);
|
|
661
|
+
this.state = inject(StateService);
|
|
662
|
+
this.type = input.required(...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
663
|
+
this.errorText = input(null, ...(ngDevMode ? [{ debugName: "errorText" }] : []));
|
|
664
|
+
this.selectGroup = input(false, ...(ngDevMode ? [{ debugName: "selectGroup", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
665
|
+
this.itemsShow = input(null, ...(ngDevMode ? [{ debugName: "itemsShow" }] : []));
|
|
666
|
+
this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
667
|
+
this.native = input(false, ...(ngDevMode ? [{ debugName: "native", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
668
|
+
this.activated = output();
|
|
669
|
+
this.config$$ = computed(() => this.resolveConfig(), ...(ngDevMode ? [{ debugName: "config$$" }] : []));
|
|
670
|
+
this.slot$$ = computed(() => {
|
|
671
|
+
const { icon } = this.config$$();
|
|
672
|
+
return this.slots.get(isDefined(icon) ? `${icon}Icon` : 'counter');
|
|
673
|
+
}, ...(ngDevMode ? [{ debugName: "slot$$" }] : []));
|
|
674
|
+
this.icon$$ = computed(() => (this.slot$$() ? null : this.config$$().icon), ...(ngDevMode ? [{ debugName: "icon$$" }] : []));
|
|
675
|
+
this.count$$ = computed(() => {
|
|
676
|
+
const options = this.state.options$$() ?? [];
|
|
677
|
+
return this.selectGroup()
|
|
678
|
+
? options.length
|
|
679
|
+
: options.filter((option) => option.kind === 'option').length;
|
|
680
|
+
}, ...(ngDevMode ? [{ debugName: "count$$" }] : []));
|
|
681
|
+
}
|
|
682
|
+
counterText() {
|
|
683
|
+
const total = this.count$$();
|
|
684
|
+
const limit = this.itemsShow();
|
|
685
|
+
if (total <= 0)
|
|
686
|
+
return null;
|
|
687
|
+
return isDefined(limit) && total > limit ? `${limit}+` : String(total);
|
|
688
|
+
}
|
|
689
|
+
activate(icon) {
|
|
690
|
+
if (isDefined(icon)) {
|
|
691
|
+
this.activated.emit(icon);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
resolveConfig() {
|
|
695
|
+
switch (this.type()) {
|
|
696
|
+
case 'counter':
|
|
697
|
+
return this.toConfig(null, { interactive: false, text: this.counterText() });
|
|
698
|
+
case 'clear':
|
|
699
|
+
return this.toConfig('clear');
|
|
700
|
+
case 'create':
|
|
701
|
+
return this.toConfig('create');
|
|
702
|
+
case 'state':
|
|
703
|
+
return this.resolveStateConfig();
|
|
704
|
+
}
|
|
150
705
|
}
|
|
706
|
+
resolveStateConfig() {
|
|
707
|
+
const { status } = this.state.requestState$$();
|
|
708
|
+
if (status === 'error') {
|
|
709
|
+
const view = this.toConfig('reload');
|
|
710
|
+
return { ...view, title: this.errorText() ?? view.title };
|
|
711
|
+
}
|
|
712
|
+
if (status === 'loading') {
|
|
713
|
+
return this.toConfig('loader', { interactive: false });
|
|
714
|
+
}
|
|
715
|
+
const canOpen = isNonEmptyArray(this.state.options$$()) && !this.native();
|
|
716
|
+
return this.toConfig('toggle', { interactive: canOpen });
|
|
717
|
+
}
|
|
718
|
+
toConfig(icon, patch = {}) {
|
|
719
|
+
const { label, title } = isDefined(icon) ? this.messages.actions[icon] : {};
|
|
720
|
+
return {
|
|
721
|
+
icon,
|
|
722
|
+
text: null,
|
|
723
|
+
interactive: true,
|
|
724
|
+
label: label ?? null,
|
|
725
|
+
title: title ?? null,
|
|
726
|
+
...patch,
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
730
|
+
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 }); }
|
|
731
|
+
}
|
|
732
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ActionComponent, decorators: [{
|
|
733
|
+
type: Component,
|
|
734
|
+
args: [{ selector: 'ss-yoda-action', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
735
|
+
'[class]': "'yoda-action--' + type()",
|
|
736
|
+
}, 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"] }]
|
|
737
|
+
}], 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"] }] } });
|
|
738
|
+
|
|
739
|
+
const MORE_ROW = { kind: 'more' };
|
|
740
|
+
class ListComponent {
|
|
151
741
|
constructor() {
|
|
152
|
-
|
|
153
|
-
this.
|
|
742
|
+
this.slots = inject(SlotsService);
|
|
743
|
+
this.state = inject(StateService);
|
|
154
744
|
this.listRef = viewChild('listRef', ...(ngDevMode ? [{ debugName: "listRef" }] : []));
|
|
155
|
-
this.
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
158
|
-
this.
|
|
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 }]));
|
|
745
|
+
this.itemsShow = input(null, ...(ngDevMode ? [{ debugName: "itemsShow" }] : []));
|
|
746
|
+
this.moreMessage = input(...(ngDevMode ? [undefined, { debugName: "moreMessage" }] : []));
|
|
747
|
+
this.showMore = input(false, ...(ngDevMode ? [{ debugName: "showMore", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
748
|
+
this.showHighlight = input(false, ...(ngDevMode ? [{ debugName: "showHighlight", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
175
749
|
this.loopScroll = input(true, ...(ngDevMode ? [{ debugName: "loopScroll", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
176
|
-
this.showLoading = input(true, ...(ngDevMode ? [{ debugName: "showLoading", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
177
750
|
this.selectGroup = input(false, ...(ngDevMode ? [{ debugName: "selectGroup", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
178
751
|
this.groupSticky = input(false, ...(ngDevMode ? [{ debugName: "groupSticky", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
179
|
-
this.
|
|
180
|
-
this.
|
|
181
|
-
this.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.
|
|
185
|
-
|
|
752
|
+
this.disabledOption = input(...(ngDevMode ? [undefined, { debugName: "disabledOption" }] : []));
|
|
753
|
+
this.selected = output();
|
|
754
|
+
this.query$$ = this.state.query$$;
|
|
755
|
+
this.optionSlot$$ = computed(() => this.slots.get('option'), ...(ngDevMode ? [{ debugName: "optionSlot$$" }] : []));
|
|
756
|
+
this.groupSlot$$ = computed(() => this.slots.get('group'), ...(ngDevMode ? [{ debugName: "groupSlot$$" }] : []));
|
|
757
|
+
this.options$$ = computed(() => this.state.options$$() ?? [], ...(ngDevMode ? [{ debugName: "options$$" }] : []));
|
|
758
|
+
this.limit$$ = linkedSignal(...(ngDevMode ? [{ debugName: "limit$$", source: () => this.options$$(),
|
|
759
|
+
computation: () => this.itemsShow() }] : [{
|
|
760
|
+
source: () => this.options$$(),
|
|
761
|
+
computation: () => this.itemsShow(),
|
|
186
762
|
}]));
|
|
187
|
-
this.
|
|
188
|
-
|
|
763
|
+
this.visible$$ = computed(() => {
|
|
764
|
+
const options = this.options$$();
|
|
765
|
+
const limit = this.limit$$();
|
|
766
|
+
return isNil(limit) ? options : options.slice(0, limit);
|
|
767
|
+
}, ...(ngDevMode ? [{ debugName: "visible$$" }] : []));
|
|
768
|
+
this.hasMore$$ = computed(() => this.showMore() && this.visible$$().length < this.options$$().length, ...(ngDevMode ? [{ debugName: "hasMore$$" }] : []));
|
|
769
|
+
this.rows$$ = computed(() => {
|
|
770
|
+
const visible = this.visible$$();
|
|
771
|
+
return this.hasMore$$() ? [...visible, MORE_ROW] : visible;
|
|
772
|
+
}, ...(ngDevMode ? [{ debugName: "rows$$" }] : []));
|
|
773
|
+
this.hasGroups$$ = computed(() => this.options$$().some((option) => option.kind === 'group'), ...(ngDevMode ? [{ debugName: "hasGroups$$" }] : []));
|
|
774
|
+
this.focusedIndex$$ = linkedSignal(...(ngDevMode ? [{ debugName: "focusedIndex$$", source: () => this.options$$(),
|
|
775
|
+
computation: () => this.rows$$().findIndex((row) => this.isSelectable(row)) }] : [{
|
|
776
|
+
source: () => this.options$$(),
|
|
777
|
+
computation: () => this.rows$$().findIndex((row) => this.isSelectable(row)),
|
|
189
778
|
}]));
|
|
190
|
-
|
|
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;
|
|
779
|
+
effect(() => this.scrollToFocused(this.focusedIndex$$()));
|
|
226
780
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
781
|
+
moveFocus(step) {
|
|
782
|
+
const rows = this.rows$$();
|
|
783
|
+
if (isEmptyArray(rows))
|
|
784
|
+
return false;
|
|
785
|
+
const start = this.focusedIndex$$();
|
|
786
|
+
const next = this.findNextValid(rows, start, step);
|
|
787
|
+
if (next === start)
|
|
788
|
+
return false;
|
|
789
|
+
this.focusedIndex$$.set(next);
|
|
790
|
+
return true;
|
|
232
791
|
}
|
|
233
|
-
|
|
234
|
-
|
|
792
|
+
activateFocused() {
|
|
793
|
+
const row = this.rows$$().at(this.focusedIndex$$());
|
|
794
|
+
if (isNil(row) || !this.isSelectable(row))
|
|
795
|
+
return false;
|
|
796
|
+
this.activate(row);
|
|
797
|
+
return true;
|
|
235
798
|
}
|
|
236
|
-
|
|
237
|
-
if (
|
|
799
|
+
activate(row) {
|
|
800
|
+
if (!this.isSelectable(row))
|
|
238
801
|
return;
|
|
802
|
+
if (row.kind === 'more')
|
|
803
|
+
return this.expand();
|
|
804
|
+
this.selected.emit(row);
|
|
805
|
+
}
|
|
806
|
+
focus(index, row) {
|
|
807
|
+
if (this.isSelectable(row)) {
|
|
808
|
+
this.focusedIndex$$.set(index);
|
|
239
809
|
}
|
|
240
|
-
this.request(value, 0 /* ActionType.Get */)
|
|
241
|
-
.pipe(first(), tap((data) => this.updateWithSelection(data)))
|
|
242
|
-
.subscribe();
|
|
243
810
|
}
|
|
244
|
-
|
|
245
|
-
|
|
811
|
+
isSelected(row) {
|
|
812
|
+
if (row.kind === 'more' || isNil(row.value))
|
|
813
|
+
return false;
|
|
814
|
+
return this.state.selected$$()?.value === row.value;
|
|
246
815
|
}
|
|
247
|
-
|
|
248
|
-
|
|
816
|
+
isSelectable(row) {
|
|
817
|
+
if (row.kind === 'more')
|
|
818
|
+
return true;
|
|
819
|
+
if (row.kind === 'group' && !this.selectGroup())
|
|
820
|
+
return false;
|
|
821
|
+
const isDisabled = this.disabledOption();
|
|
822
|
+
return isFunction(isDisabled) ? !isDisabled(row) : true;
|
|
249
823
|
}
|
|
250
|
-
|
|
251
|
-
this.
|
|
824
|
+
expand() {
|
|
825
|
+
const step = this.itemsShow();
|
|
826
|
+
if (isNil(step))
|
|
827
|
+
return;
|
|
828
|
+
const next = this.visible$$().length;
|
|
829
|
+
this.limit$$.update((limit) => (limit ?? step) + step);
|
|
830
|
+
this.focusedIndex$$.set(next);
|
|
252
831
|
}
|
|
253
|
-
|
|
254
|
-
|
|
832
|
+
findNextValid(rows, start, step) {
|
|
833
|
+
const max = rows.length - 1;
|
|
834
|
+
let next = limitIndex(start + step, max, this.loopScroll());
|
|
835
|
+
for (let attempt = 0; attempt <= max; attempt++) {
|
|
836
|
+
if (this.isSelectable(rows[next]))
|
|
837
|
+
return next;
|
|
838
|
+
next = limitIndex(next + step, max, this.loopScroll());
|
|
839
|
+
if (next === start)
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
return start;
|
|
255
843
|
}
|
|
256
|
-
|
|
257
|
-
|
|
844
|
+
scrollToFocused(index) {
|
|
845
|
+
const container = this.listRef()?.nativeElement;
|
|
846
|
+
if (isNil(container) || index < 0)
|
|
258
847
|
return;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this.inputElementRef.focus();
|
|
263
|
-
}
|
|
264
|
-
switch (type) {
|
|
265
|
-
case 'clear':
|
|
266
|
-
return this.clear();
|
|
267
|
-
case 'create':
|
|
268
|
-
return this.createByQuery();
|
|
269
|
-
}
|
|
848
|
+
container
|
|
849
|
+
.querySelector(`li[data-index="${index}"]`)
|
|
850
|
+
?.scrollIntoView({ behavior: 'auto', block: 'nearest', inline: 'nearest' });
|
|
270
851
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
852
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
853
|
+
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 }); }
|
|
854
|
+
}
|
|
855
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ListComponent, decorators: [{
|
|
856
|
+
type: Component,
|
|
857
|
+
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"] }]
|
|
858
|
+
}], 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"] }] } });
|
|
859
|
+
function limitIndex(index, max, circular) {
|
|
860
|
+
if (circular) {
|
|
861
|
+
return index < 0 ? max : index > max ? 0 : index;
|
|
274
862
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
863
|
+
return Math.max(0, Math.min(index, max));
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
class NativeComponent {
|
|
867
|
+
constructor() {
|
|
868
|
+
this.state = inject(StateService);
|
|
869
|
+
this.selectRef = viewChild('nativeRef', ...(ngDevMode ? [{ debugName: "selectRef" }] : []));
|
|
870
|
+
this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
|
|
871
|
+
this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
872
|
+
this.groups$$ = computed(() => {
|
|
873
|
+
const result = [];
|
|
874
|
+
let current = null;
|
|
875
|
+
for (const option of this.state.options$$() ?? []) {
|
|
876
|
+
if (option.kind === 'group') {
|
|
877
|
+
current = { label: option.label, items: [] };
|
|
878
|
+
result.push(current);
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
if (isNil(current)) {
|
|
882
|
+
current = { label: null, items: [] };
|
|
883
|
+
result.push(current);
|
|
884
|
+
}
|
|
885
|
+
current.items.push(option);
|
|
886
|
+
}
|
|
887
|
+
return result;
|
|
888
|
+
}, ...(ngDevMode ? [{ debugName: "groups$$" }] : []));
|
|
889
|
+
effect(() => this.syncValue(this.groups$$()));
|
|
278
890
|
}
|
|
279
|
-
|
|
280
|
-
this.
|
|
281
|
-
this.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
inputFocus(event) {
|
|
285
|
-
event.preventDefault();
|
|
286
|
-
event.stopPropagation();
|
|
287
|
-
if (this.overlayVisible$$()) {
|
|
288
|
-
return;
|
|
891
|
+
syncValue(_) {
|
|
892
|
+
const selected = this.state.selected$$();
|
|
893
|
+
const select = this.selectRef()?.nativeElement;
|
|
894
|
+
if (select) {
|
|
895
|
+
select.value = String(selected?.value ?? '');
|
|
289
896
|
}
|
|
290
|
-
if (this.inputReadonly() || this.isDisabled$$() || isNil(this.optionsListStatus$$())) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
this.overlayVisible$$.set(true);
|
|
294
897
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
898
|
+
select(value, options) {
|
|
899
|
+
const option = options.find((item) => item.kind === 'option' && String(item.value) === value);
|
|
900
|
+
if (isDefined(option)) {
|
|
901
|
+
this.state.select(option);
|
|
298
902
|
}
|
|
299
|
-
event.stopPropagation();
|
|
300
|
-
event.preventDefault();
|
|
301
|
-
this.selectFocusedOption();
|
|
302
903
|
}
|
|
303
|
-
|
|
304
|
-
|
|
904
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: NativeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
905
|
+
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 }); }
|
|
906
|
+
}
|
|
907
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: NativeComponent, decorators: [{
|
|
908
|
+
type: Component,
|
|
909
|
+
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"] }]
|
|
910
|
+
}], 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 }] }] } });
|
|
911
|
+
|
|
912
|
+
class PanelComponent {
|
|
913
|
+
applyZIndex(isOpen) {
|
|
914
|
+
if (!isOpen)
|
|
305
915
|
return;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
916
|
+
const container = this.overlayContainer.getContainerElement();
|
|
917
|
+
container.style.zIndex = String(this.zIndex(this.config.overlay.zIndex));
|
|
918
|
+
}
|
|
919
|
+
onPositionChange({ connectionPair }) {
|
|
920
|
+
this.above$$.set(connectionPair.overlayY === 'bottom');
|
|
921
|
+
}
|
|
922
|
+
constructor() {
|
|
923
|
+
this.config = inject(CONFIG);
|
|
924
|
+
this.slots = inject(SlotsService);
|
|
925
|
+
this.state = inject(StateService);
|
|
926
|
+
this.scrollStrategies = inject(ScrollStrategyOptions);
|
|
927
|
+
this.overlayContainer = inject(OverlayContainer);
|
|
928
|
+
this.zIndex = inject(Z_INDEX);
|
|
929
|
+
this.origin = input.required(...(ngDevMode ? [{ debugName: "origin" }] : []));
|
|
930
|
+
this.listRender = input('overlay', ...(ngDevMode ? [{ debugName: "listRender" }] : []));
|
|
931
|
+
this.scrollStrategy = input('reposition', ...(ngDevMode ? [{ debugName: "scrollStrategy" }] : []));
|
|
932
|
+
this.panelClass = input('', ...(ngDevMode ? [{ debugName: "panelClass" }] : []));
|
|
933
|
+
this.scrollHeight = input('200px', ...(ngDevMode ? [{ debugName: "scrollHeight" }] : []));
|
|
934
|
+
this.showHint = input(true, ...(ngDevMode ? [{ debugName: "showHint", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
935
|
+
this.showEmpty = input(true, ...(ngDevMode ? [{ debugName: "showEmpty", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
936
|
+
this.minQueryLength = input(0, ...(ngDevMode ? [{ debugName: "minQueryLength", transform: numberAttribute }] : [{ transform: numberAttribute }]));
|
|
937
|
+
this.hintMessage = input(...(ngDevMode ? [undefined, { debugName: "hintMessage" }] : []));
|
|
938
|
+
this.emptyMessage = input(...(ngDevMode ? [undefined, { debugName: "emptyMessage" }] : []));
|
|
939
|
+
this.hintSlot$$ = computed(() => this.slots.get('hint'), ...(ngDevMode ? [{ debugName: "hintSlot$$" }] : []));
|
|
940
|
+
this.emptySlot$$ = computed(() => this.slots.get('empty'), ...(ngDevMode ? [{ debugName: "emptySlot$$" }] : []));
|
|
941
|
+
this.headerSlot$$ = computed(() => this.slots.get('header'), ...(ngDevMode ? [{ debugName: "headerSlot$$" }] : []));
|
|
942
|
+
this.footerSlot$$ = computed(() => this.slots.get('footer'), ...(ngDevMode ? [{ debugName: "footerSlot$$" }] : []));
|
|
943
|
+
this.isOpen$$ = computed(() => this.state.isOpen$$() && this.status$$() !== null, ...(ngDevMode ? [{ debugName: "isOpen$$" }] : []));
|
|
944
|
+
this.status$$ = computed(() => {
|
|
945
|
+
if (this.canShowHint())
|
|
946
|
+
return 'hint';
|
|
947
|
+
if (this.canShowEmpty())
|
|
948
|
+
return 'empty';
|
|
949
|
+
return isNonEmptyArray(this.state.options$$()) ? 'list' : null;
|
|
950
|
+
}, ...(ngDevMode ? [{ debugName: "status$$" }] : []));
|
|
951
|
+
this.positions = [
|
|
952
|
+
CONNECTED_POSITION_BELOW,
|
|
953
|
+
CONNECTED_POSITION_ABOVE,
|
|
954
|
+
];
|
|
955
|
+
this.above$$ = signal(false, ...(ngDevMode ? [{ debugName: "above$$" }] : []));
|
|
956
|
+
this.width$$ = computed(() => {
|
|
957
|
+
if (!this.isOpen$$() || !this.config.overlay.matchWidth)
|
|
958
|
+
return '';
|
|
959
|
+
return this.origin().nativeElement.getBoundingClientRect().width;
|
|
960
|
+
}, ...(ngDevMode ? [{ debugName: "width$$" }] : []));
|
|
961
|
+
this.scrollStrategy$$ = computed(() => this.scrollStrategies[this.scrollStrategy()](), ...(ngDevMode ? [{ debugName: "scrollStrategy$$" }] : []));
|
|
962
|
+
effect(() => this.applyZIndex(this.isOpen$$()));
|
|
963
|
+
}
|
|
964
|
+
close(event) {
|
|
965
|
+
if (event && this.origin().nativeElement.contains(event.target))
|
|
311
966
|
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
|
-
}
|
|
967
|
+
this.state.close();
|
|
322
968
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
options = options.slice(0, this.itemsShow());
|
|
330
|
-
}
|
|
331
|
-
return options;
|
|
969
|
+
canShowHint() {
|
|
970
|
+
const hasContent = this.hintSlot$$() !== null || isNonEmptyString(this.hintMessage());
|
|
971
|
+
return (this.showHint() &&
|
|
972
|
+
hasContent &&
|
|
973
|
+
isNil(this.state.options$$()) &&
|
|
974
|
+
this.state.query$$().length <= this.minQueryLength());
|
|
332
975
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
976
|
+
canShowEmpty() {
|
|
977
|
+
const hasContent = this.emptySlot$$() !== null || isNonEmptyString(this.emptyMessage());
|
|
978
|
+
return this.showEmpty() && isEmptyArray(this.state.options$$()) && hasContent;
|
|
979
|
+
}
|
|
980
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: PanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
981
|
+
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 }); }
|
|
982
|
+
}
|
|
983
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: PanelComponent, decorators: [{
|
|
984
|
+
type: Component,
|
|
985
|
+
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"] }]
|
|
986
|
+
}], 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 }] }] } });
|
|
987
|
+
|
|
988
|
+
/** Ключ ошибки в `control.errors` */
|
|
989
|
+
const REQUEST_ERROR = 'yodaRequest';
|
|
990
|
+
class Yoda extends BaseDirective {
|
|
991
|
+
constructor() {
|
|
992
|
+
super();
|
|
993
|
+
this.chain = inject(ChainService, { optional: true });
|
|
994
|
+
this.ngControl = inject(NgControl, { optional: true, self: true });
|
|
995
|
+
this.state = inject(StateService);
|
|
996
|
+
this.list = viewChild(ListComponent, ...(ngDevMode ? [{ debugName: "list" }] : []));
|
|
997
|
+
this.selection$$ = this.state.selected$$;
|
|
998
|
+
this.typed$$ = signal('', ...(ngDevMode ? [{ debugName: "typed$$" }] : []));
|
|
999
|
+
this.formDisabled$$ = signal(false, ...(ngDevMode ? [{ debugName: "formDisabled$$" }] : []));
|
|
1000
|
+
this.control$$ = signal(null, ...(ngDevMode ? [{ debugName: "control$$" }] : []));
|
|
1001
|
+
this.onTouched = noop;
|
|
1002
|
+
this.onChange = noop;
|
|
1003
|
+
this.lastValue = null;
|
|
1004
|
+
this.flexBasis$$ = computed(() => {
|
|
1005
|
+
const width = this.width();
|
|
1006
|
+
return isNil(width) || !this.chainInline$$() ? null : `0 0 ${width}`;
|
|
1007
|
+
}, ...(ngDevMode ? [{ debugName: "flexBasis$$" }] : []));
|
|
1008
|
+
this.chainPending$$ = computed(() => this.chained$$() && isNil(this.parentValue$$()), ...(ngDevMode ? [{ debugName: "chainPending$$" }] : []));
|
|
1009
|
+
this.chainInline$$ = computed(() => this.chain?.inline$$() ?? false, ...(ngDevMode ? [{ debugName: "chainInline$$" }] : []));
|
|
1010
|
+
this.chainHidden$$ = computed(() => this.chainPending$$() && this.chain?.pending$$() === 'hide', ...(ngDevMode ? [{ debugName: "chainHidden$$" }] : []));
|
|
1011
|
+
this.chainPosition$$ = computed(() => this.chainInline$$() ? (this.chain?.position(this) ?? null) : null, ...(ngDevMode ? [{ debugName: "chainPosition$$" }] : []));
|
|
1012
|
+
this.chained$$ = computed(() => this.chain?.parentValue(this) !== undefined, ...(ngDevMode ? [{ debugName: "chained$$" }] : []));
|
|
1013
|
+
this.chainDisabled$$ = computed(() => this.chainPending$$() && this.chain?.pending$$() === 'disable', ...(ngDevMode ? [{ debugName: "chainDisabled$$" }] : []));
|
|
1014
|
+
this.isDisabled$$ = computed(() => this.disabled() || this.formDisabled$$() || this.chainDisabled$$(), ...(ngDevMode ? [{ debugName: "isDisabled$$" }] : []));
|
|
1015
|
+
this.isLocked$$ = computed(() => this.isDisabled$$() || !!this.inputReadonly(), ...(ngDevMode ? [{ debugName: "isLocked$$" }] : []));
|
|
1016
|
+
this.controlEvent$$ = toSignal(toObservable(this.control$$).pipe(switchMap((control) => control?.events ?? EMPTY)));
|
|
1017
|
+
this.hasRequestError$$ = computed(() => this.state.requestState$$().status === 'error', ...(ngDevMode ? [{ debugName: "hasRequestError$$" }] : []));
|
|
1018
|
+
this.invalid$$ = computed(() => {
|
|
1019
|
+
this.controlEvent$$();
|
|
1020
|
+
if (this.hasRequestError$$())
|
|
1021
|
+
return true;
|
|
1022
|
+
const control = this.control$$();
|
|
1023
|
+
return !!control?.invalid && (control.touched || control.dirty);
|
|
1024
|
+
}, ...(ngDevMode ? [{ debugName: "invalid$$" }] : []));
|
|
1025
|
+
this.parentValue$$ = computed(() => {
|
|
1026
|
+
const fromChain = this.chain?.parentValue(this);
|
|
1027
|
+
return fromChain === undefined ? this.parentValue() : fromChain;
|
|
1028
|
+
}, ...(ngDevMode ? [{ debugName: "parentValue$$" }] : []));
|
|
1029
|
+
this.requestOptions$$ = computed(() => ({
|
|
1030
|
+
url: this.apiUrl(),
|
|
1031
|
+
delay: this.delay(),
|
|
1032
|
+
action: this.action(),
|
|
1033
|
+
repository: this.repository(),
|
|
1034
|
+
transform: this.transformOptions(),
|
|
1035
|
+
minQueryLength: this.minQueryLength(),
|
|
1036
|
+
parent: this.parentValue$$() ?? undefined,
|
|
1037
|
+
}), ...(ngDevMode ? [{ debugName: "requestOptions$$" }] : []));
|
|
1038
|
+
this.canCreate$$ = computed(() => {
|
|
1039
|
+
if (!this.create() || this.isLocked$$())
|
|
1040
|
+
return false;
|
|
1041
|
+
return this.createMode() === 'always' || isEmptyArray(this.state.options$$());
|
|
1042
|
+
}, ...(ngDevMode ? [{ debugName: "canCreate$$" }] : []));
|
|
1043
|
+
this.createStartVisible$$ = computed(() => this.canCreate$$() && this.createPlace() === 'start', ...(ngDevMode ? [{ debugName: "createStartVisible$$" }] : []));
|
|
1044
|
+
this.createEndVisible$$ = computed(() => this.canCreate$$() && this.createPlace() === 'end', ...(ngDevMode ? [{ debugName: "createEndVisible$$" }] : []));
|
|
1045
|
+
this.clearVisible$$ = computed(() => this.showClear() && !this.isLocked$$() && isNonEmptyString(this.typed$$()), ...(ngDevMode ? [{ debugName: "clearVisible$$" }] : []));
|
|
1046
|
+
this.counterVisible$$ = computed(() => this.showCounter() && !this.isLocked$$() && isNonEmptyArray(this.state.options$$()), ...(ngDevMode ? [{ debugName: "counterVisible$$" }] : []));
|
|
1047
|
+
this.statusVisible$$ = computed(() => {
|
|
1048
|
+
if (this.isLocked$$())
|
|
1049
|
+
return false;
|
|
1050
|
+
const { status } = this.state.requestState$$();
|
|
1051
|
+
if (status === 'error' || this.isNative$$())
|
|
1052
|
+
return true;
|
|
1053
|
+
if (status === 'loading')
|
|
1054
|
+
return this.showLoader();
|
|
1055
|
+
return this.showToggle();
|
|
1056
|
+
}, ...(ngDevMode ? [{ debugName: "statusVisible$$" }] : []));
|
|
1057
|
+
this.createDisabled$$ = computed(() => this.state.requestState$$().status === 'loading' ||
|
|
1058
|
+
isShortQuery(this.typed$$(), this.minQueryLength()), ...(ngDevMode ? [{ debugName: "createDisabled$$" }] : []));
|
|
1059
|
+
this.errorText$$ = computed(() => this.state.requestState$$().status === 'error' ? (this.errorMessage() ?? null) : null, ...(ngDevMode ? [{ debugName: "errorText$$" }] : []));
|
|
1060
|
+
this.needsEagerLoad$$ = computed(() => {
|
|
1061
|
+
if (this.chained$$())
|
|
1062
|
+
return isDefined(this.parentValue$$());
|
|
1063
|
+
return this.isNative$$() || this.mode() === 'select';
|
|
1064
|
+
}, ...(ngDevMode ? [{ debugName: "needsEagerLoad$$" }] : []));
|
|
1065
|
+
if (this.ngControl) {
|
|
1066
|
+
this.ngControl.valueAccessor = this;
|
|
336
1067
|
}
|
|
337
|
-
if (this.
|
|
338
|
-
|
|
1068
|
+
if (this.chain) {
|
|
1069
|
+
this.chain.register(this);
|
|
1070
|
+
inject(DestroyRef).onDestroy(() => this.chain?.unregister(this));
|
|
339
1071
|
}
|
|
340
|
-
|
|
1072
|
+
afterNextRender(() => {
|
|
1073
|
+
this.control$$.set(this.ngControl?.control ?? null);
|
|
1074
|
+
if (this.autofocus())
|
|
1075
|
+
this.inputElement?.focus();
|
|
1076
|
+
});
|
|
1077
|
+
effect(() => this.eagerLoad());
|
|
1078
|
+
effect(() => this.emitOptionCreated(this.state.created$$()));
|
|
1079
|
+
effect(() => this.syncSelection(this.state.selected$$()));
|
|
1080
|
+
effect(() => this.autoSelectSingle(this.state.options$$()));
|
|
1081
|
+
effect(() => this.syncRequestError(this.hasRequestError$$()));
|
|
1082
|
+
effect(() => this.emitRequestError());
|
|
341
1083
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
1084
|
+
writeValue(value) {
|
|
1085
|
+
this.lastValue = value;
|
|
1086
|
+
if (isNil(value)) {
|
|
1087
|
+
this.typed$$.set('');
|
|
1088
|
+
return this.state.clear();
|
|
345
1089
|
}
|
|
346
|
-
|
|
1090
|
+
this.state.resolve(value, this.requestOptions$$());
|
|
347
1091
|
}
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
}
|
|
1092
|
+
registerOnChange(onChange) {
|
|
1093
|
+
this.onChange = onChange;
|
|
361
1094
|
}
|
|
362
|
-
|
|
363
|
-
|
|
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;
|
|
1095
|
+
registerOnTouched(onTouched) {
|
|
1096
|
+
this.onTouched = onTouched;
|
|
373
1097
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (isNonEmptyArray(options)) {
|
|
377
|
-
this.focusedOptionIndex$$.set(findFirstValidIndex(options, (option) => this.isValidOption(option)));
|
|
378
|
-
}
|
|
1098
|
+
setDisabledState(isDisabled) {
|
|
1099
|
+
this.formDisabled$$.set(isDisabled);
|
|
379
1100
|
}
|
|
380
|
-
|
|
381
|
-
this.
|
|
382
|
-
this.queryString$$.set(this.normalizeQueryString(value));
|
|
1101
|
+
load(query = '', type) {
|
|
1102
|
+
this.state.load(query, this.requestOptions$$(), type);
|
|
383
1103
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (
|
|
387
|
-
|
|
1104
|
+
clear() {
|
|
1105
|
+
this.typed$$.set('');
|
|
1106
|
+
if (this.mode() === 'select') {
|
|
1107
|
+
this.state.filter('', this.filterOption());
|
|
1108
|
+
this.state.select(null);
|
|
388
1109
|
}
|
|
389
|
-
|
|
390
|
-
|
|
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
|
-
}
|
|
1110
|
+
else {
|
|
1111
|
+
this.state.clear();
|
|
405
1112
|
}
|
|
406
|
-
|
|
1113
|
+
this.inputElement?.focus();
|
|
407
1114
|
}
|
|
408
|
-
|
|
409
|
-
|
|
1115
|
+
close() {
|
|
1116
|
+
this.state.close();
|
|
410
1117
|
}
|
|
411
|
-
|
|
412
|
-
|
|
1118
|
+
reset() {
|
|
1119
|
+
this.typed$$.set('');
|
|
1120
|
+
this.loadedParent = undefined;
|
|
1121
|
+
this.state.clear();
|
|
413
1122
|
}
|
|
414
|
-
|
|
415
|
-
|
|
1123
|
+
onInput(value) {
|
|
1124
|
+
this.typed$$.set(value);
|
|
1125
|
+
this.state.open();
|
|
1126
|
+
if (this.mode() === 'select') {
|
|
1127
|
+
if (this.state.selected$$()) {
|
|
1128
|
+
this.state.select(null);
|
|
1129
|
+
}
|
|
1130
|
+
return this.state.filter(value, this.filterOption());
|
|
1131
|
+
}
|
|
1132
|
+
this.state.queryChange(value, this.requestOptions$$());
|
|
416
1133
|
}
|
|
417
|
-
|
|
418
|
-
this.
|
|
419
|
-
|
|
420
|
-
this.
|
|
1134
|
+
onFocus() {
|
|
1135
|
+
if (this.isLocked$$())
|
|
1136
|
+
return;
|
|
1137
|
+
this.state.open();
|
|
421
1138
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
1139
|
+
onAction(icon) {
|
|
1140
|
+
switch (icon) {
|
|
1141
|
+
case 'clear':
|
|
1142
|
+
return this.clear();
|
|
1143
|
+
case 'create':
|
|
1144
|
+
return this.createByQuery();
|
|
1145
|
+
case 'reload':
|
|
1146
|
+
return this.state.retry();
|
|
1147
|
+
case 'toggle':
|
|
1148
|
+
return this.state.toggle();
|
|
1149
|
+
default:
|
|
1150
|
+
return;
|
|
428
1151
|
}
|
|
429
1152
|
}
|
|
430
|
-
|
|
431
|
-
this.
|
|
432
|
-
|
|
433
|
-
if (this.
|
|
434
|
-
this.
|
|
1153
|
+
onArrow(event, step) {
|
|
1154
|
+
if (this.isLocked$$())
|
|
1155
|
+
return;
|
|
1156
|
+
if (!this.state.isOpen$$()) {
|
|
1157
|
+
this.state.open();
|
|
1158
|
+
return event.preventDefault();
|
|
435
1159
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
1160
|
+
if (this.list()?.moveFocus(step)) {
|
|
1161
|
+
event.preventDefault();
|
|
438
1162
|
}
|
|
439
|
-
|
|
440
|
-
|
|
1163
|
+
}
|
|
1164
|
+
onEnter(event) {
|
|
1165
|
+
if (this.interactionBlocked())
|
|
1166
|
+
return;
|
|
1167
|
+
if (this.list()?.activateFocused()) {
|
|
1168
|
+
event.preventDefault();
|
|
441
1169
|
}
|
|
442
1170
|
}
|
|
443
|
-
|
|
444
|
-
|
|
1171
|
+
onSelect(option) {
|
|
1172
|
+
this.state.select(option);
|
|
1173
|
+
this.state.close();
|
|
1174
|
+
this.inputElement?.blur();
|
|
445
1175
|
}
|
|
446
|
-
|
|
447
|
-
|
|
1176
|
+
onFocusOut(target) {
|
|
1177
|
+
if (target instanceof Node && this.host.nativeElement.contains(target))
|
|
1178
|
+
return;
|
|
1179
|
+
this.onTouched();
|
|
448
1180
|
}
|
|
449
|
-
|
|
450
|
-
|
|
1181
|
+
createByQuery() {
|
|
1182
|
+
if (this.createDisabled$$())
|
|
1183
|
+
return;
|
|
1184
|
+
this.state.createByQuery(this.typed$$(), this.requestOptions$$());
|
|
451
1185
|
}
|
|
452
|
-
|
|
453
|
-
return
|
|
1186
|
+
interactionBlocked() {
|
|
1187
|
+
return this.isLocked$$() || !this.state.isOpen$$();
|
|
454
1188
|
}
|
|
455
|
-
|
|
456
|
-
if (
|
|
457
|
-
|
|
1189
|
+
syncSelection(selected) {
|
|
1190
|
+
if (isDefined(selected)) {
|
|
1191
|
+
this.typed$$.set(selected.label);
|
|
458
1192
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
this.
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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
|
-
}));
|
|
1193
|
+
const value = selected?.value ?? null;
|
|
1194
|
+
if (value === this.lastValue)
|
|
1195
|
+
return;
|
|
1196
|
+
this.lastValue = value;
|
|
1197
|
+
this.onChange(value);
|
|
1198
|
+
this.selectionChanged.emit(selected);
|
|
1199
|
+
this.chain?.resetAfter(this);
|
|
475
1200
|
}
|
|
476
|
-
|
|
477
|
-
if (this.
|
|
1201
|
+
eagerLoad() {
|
|
1202
|
+
if (!this.needsEagerLoad$$())
|
|
478
1203
|
return;
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
1204
|
+
const parent = this.parentValue$$();
|
|
1205
|
+
if (this.loadedParent === parent)
|
|
1206
|
+
return;
|
|
1207
|
+
this.loadedParent = parent;
|
|
1208
|
+
this.load(isDefined(parent) ? String(parent) : this.preloadQuery(), this.preloadType());
|
|
483
1209
|
}
|
|
484
|
-
|
|
485
|
-
|
|
1210
|
+
syncRequestError(hasError) {
|
|
1211
|
+
const control = this.control$$();
|
|
1212
|
+
if (isNil(control))
|
|
486
1213
|
return;
|
|
1214
|
+
const errors = { ...(control.errors ?? {}) };
|
|
1215
|
+
if (hasError) {
|
|
1216
|
+
errors[REQUEST_ERROR] = true;
|
|
487
1217
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
this.selectFocusedOption();
|
|
491
|
-
}
|
|
492
|
-
transformResponse(data) {
|
|
493
|
-
if (isFunction(this.transformOptionsFn)) {
|
|
494
|
-
return this.transformOptionsFn(data);
|
|
1218
|
+
else {
|
|
1219
|
+
delete errors[REQUEST_ERROR];
|
|
495
1220
|
}
|
|
496
|
-
|
|
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
|
-
});
|
|
1221
|
+
control.setErrors(Object.keys(errors).length > 0 ? errors : null);
|
|
506
1222
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
1223
|
+
emitRequestError() {
|
|
1224
|
+
const state = this.state.requestState$$();
|
|
1225
|
+
if (state.status !== 'error')
|
|
1226
|
+
return;
|
|
1227
|
+
this.requestFailed.emit(state.error);
|
|
512
1228
|
}
|
|
513
|
-
|
|
514
|
-
if (
|
|
515
|
-
this.
|
|
1229
|
+
emitOptionCreated(option) {
|
|
1230
|
+
if (isDefined(option)) {
|
|
1231
|
+
this.optionCreated.emit(option);
|
|
516
1232
|
}
|
|
517
1233
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const container = this.listRef()?.nativeElement;
|
|
521
|
-
if (isNil(container) || index < 0) {
|
|
1234
|
+
autoSelectSingle(options) {
|
|
1235
|
+
if (!this.autoSelect() || options?.length !== 1)
|
|
522
1236
|
return;
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (isNil(listItem) || !isFunction(listItem.scrollIntoView)) {
|
|
1237
|
+
const [option] = options;
|
|
1238
|
+
if (option.kind !== 'option')
|
|
526
1239
|
return;
|
|
1240
|
+
this.state.select(option);
|
|
1241
|
+
if (this.autoSelectClose()) {
|
|
1242
|
+
this.state.close();
|
|
527
1243
|
}
|
|
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
1244
|
}
|
|
539
1245
|
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: "
|
|
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 }); }
|
|
1246
|
+
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
1247
|
}
|
|
553
1248
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: Yoda, decorators: [{
|
|
554
1249
|
type: Component,
|
|
555
|
-
args: [{ selector: '
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
], template: "
|
|
575
|
-
}], ctorParameters: () => [], propDecorators: {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
1250
|
+
args: [{ selector: 'ss-yoda', changeDetection: ChangeDetectionStrategy.OnPush, providers: [StateService, SlotsService], host: {
|
|
1251
|
+
'[attr.data-size]': 'size()',
|
|
1252
|
+
'[attr.data-variant]': 'variant()',
|
|
1253
|
+
'[attr.data-separator]': 'separator()',
|
|
1254
|
+
'[style.inline-size]': 'width()',
|
|
1255
|
+
'[style.flex]': 'flexBasis$$()',
|
|
1256
|
+
'[class.yoda--inline]': 'listRender() === "inline"',
|
|
1257
|
+
'[class.yoda--disabled]': 'isDisabled$$()',
|
|
1258
|
+
'[class.yoda--locked]': 'isLocked$$()',
|
|
1259
|
+
'[class.yoda--chained]': 'chainInline$$()',
|
|
1260
|
+
'[class.yoda--hidden]': 'chainHidden$$()',
|
|
1261
|
+
'[attr.data-chain]': 'chainPosition$$()',
|
|
1262
|
+
'[class.yoda--invalid]': 'invalid$$()',
|
|
1263
|
+
'(keydown.escape)': 'close()',
|
|
1264
|
+
'(keydown.tab)': 'close()',
|
|
1265
|
+
'(keydown.enter)': 'onEnter($event)',
|
|
1266
|
+
'(keydown.arrowdown)': 'onArrow($event, 1)',
|
|
1267
|
+
'(keydown.arrowup)': 'onArrow($event, -1)',
|
|
1268
|
+
'(focusout)': 'onFocusOut($event.relatedTarget)',
|
|
1269
|
+
}, 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"] }]
|
|
1270
|
+
}], ctorParameters: () => [], propDecorators: { list: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ListComponent), { isSignal: true }] }] } });
|
|
1271
|
+
|
|
1272
|
+
class YodaChain {
|
|
1273
|
+
constructor() {
|
|
1274
|
+
this.chain = inject(ChainService);
|
|
1275
|
+
this.inline = input(false, ...(ngDevMode ? [{ debugName: "inline", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
1276
|
+
this.pending = input('none', ...(ngDevMode ? [{ debugName: "pending" }] : []));
|
|
1277
|
+
effect(() => this.chain.setInline(this.inline()));
|
|
1278
|
+
effect(() => this.chain.setPending(this.pending()));
|
|
1279
|
+
}
|
|
1280
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaChain, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1281
|
+
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 }); }
|
|
1282
|
+
}
|
|
1283
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: YodaChain, decorators: [{
|
|
1284
|
+
type: Component,
|
|
1285
|
+
args: [{ selector: 'ss-yoda-chain', template: '<ng-content />', host: {
|
|
1286
|
+
'[class.yoda-chain--inline]': 'inline()',
|
|
1287
|
+
}, 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"] }]
|
|
1288
|
+
}], ctorParameters: () => [], propDecorators: { inline: [{ type: i0.Input, args: [{ isSignal: true, alias: "inline", required: false }] }], pending: [{ type: i0.Input, args: [{ isSignal: true, alias: "pending", required: false }] }] } });
|
|
1289
|
+
|
|
1290
|
+
/** Настройка иконок: разметка `<svg…>` либо классы шрифта */
|
|
1291
|
+
const withIcons = defineKitFeature(0 /* FeatureKind.Icons */, (icons) => ({
|
|
1292
|
+
provide: ICONS,
|
|
1293
|
+
useFactory: () => ({ ...DEFAULT_ICONS, ...resolveMaybeFn(icons) }),
|
|
1294
|
+
}));
|
|
1295
|
+
/** Настройка текстов интерфейса */
|
|
1296
|
+
const withMessages = defineKitFeature(1 /* FeatureKind.Messages */, (messages) => ({
|
|
1297
|
+
provide: MESSAGES,
|
|
1298
|
+
useFactory: () => mergeMessages(resolveMaybeFn(messages)),
|
|
1299
|
+
}));
|
|
1300
|
+
/** Настройка расчета z-index оверлея */
|
|
1301
|
+
const withZIndex = defineKitFeature(2 /* FeatureKind.ZIndex */, (resolver) => ({
|
|
1302
|
+
provide: Z_INDEX,
|
|
1303
|
+
useValue: resolver,
|
|
1304
|
+
}));
|
|
1305
|
+
/** Сборка подписи опции по экшену или репозиторию и экшену в формате (`repository:action`): колонки приходят как есть */
|
|
1306
|
+
const withLabelFormatters = defineKitFeature(3 /* FeatureKind.LabelFormatters */, (formatters) => ({
|
|
1307
|
+
provide: LABEL_FORMATTERS,
|
|
1308
|
+
useFactory: () => resolveMaybeFn(formatters),
|
|
1309
|
+
}));
|
|
1310
|
+
function provideYoda(config, ...features) {
|
|
1311
|
+
const providers = resolveConfigProviders(config, (data) => ({
|
|
1312
|
+
provide: CONFIG,
|
|
1313
|
+
useFactory: () => mergeConfig(resolveMaybeFn(data)),
|
|
1314
|
+
}));
|
|
1315
|
+
return makeEnvironmentProviders([...providers, ...collectFeatureProviders(config, ...features)]);
|
|
1316
|
+
}
|
|
1317
|
+
function mergeConfig(config) {
|
|
1318
|
+
return {
|
|
1319
|
+
...DEFAULT_CONFIG,
|
|
1320
|
+
...config,
|
|
1321
|
+
show: { ...DEFAULT_CONFIG.show, ...config.show },
|
|
1322
|
+
request: { ...DEFAULT_CONFIG.request, ...config.request },
|
|
1323
|
+
overlay: { ...DEFAULT_CONFIG.overlay, ...config.overlay },
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
function mergeMessages(messages) {
|
|
1327
|
+
const actions = { ...DEFAULT_MESSAGES.actions };
|
|
1328
|
+
for (const key of objectKeys(actions)) {
|
|
1329
|
+
actions[key] = { ...actions[key], ...messages.actions?.[key] };
|
|
1330
|
+
}
|
|
1331
|
+
return { ...DEFAULT_MESSAGES, ...messages, actions };
|
|
1332
|
+
}
|
|
588
1333
|
|
|
589
1334
|
/**
|
|
590
1335
|
* Generated bundle index. Do not edit.
|
|
591
1336
|
*/
|
|
592
1337
|
|
|
593
|
-
export { Yoda,
|
|
1338
|
+
export { Yoda, YodaChain, RequestType as YodaRequestType, provideYoda, withIcons, withLabelFormatters, withMessages, withZIndex };
|
|
594
1339
|
//# sourceMappingURL=ui-yoda.mjs.map
|