@sevtech/kit 21.3.2 → 21.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.d.ts +61 -18
- package/fesm2022/browser.mjs +131 -49
- package/fesm2022/browser.mjs.map +1 -1
- package/fesm2022/ui-yoda.mjs +21 -8
- package/fesm2022/ui-yoda.mjs.map +1 -1
- package/package.json +1 -1
- package/ui/yoda/index.d.ts +4 -2
package/fesm2022/ui-yoda.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { isDefined, isFunction, isString, isArray, isNonEmptyString, isNil, isNo
|
|
|
7
7
|
import { NgTemplateOutlet } from '@angular/common';
|
|
8
8
|
import { SlotOutletDirective, HighlightPipe } from '@sevtech/kit/ui';
|
|
9
9
|
import { cssDimensionAttribute, htmlBooleanAttribute, defineKitFeature, resolveConfigProviders, collectFeatureProviders } from '@sevtech/kit/ng-misc';
|
|
10
|
-
import {
|
|
10
|
+
import { injectBreakpoint } from '@sevtech/kit/browser';
|
|
11
11
|
import { HttpErrorResponse, HttpClient } from '@angular/common/http';
|
|
12
12
|
import * as i1 from '@angular/cdk/overlay';
|
|
13
13
|
import { ScrollStrategyOptions, OverlayContainer, OverlayModule } from '@angular/cdk/overlay';
|
|
@@ -252,6 +252,7 @@ class StateService {
|
|
|
252
252
|
this.selectedSource = signal(null, ...(ngDevMode ? [{ debugName: "selectedSource" }] : []));
|
|
253
253
|
this.createdSource = signal(null, ...(ngDevMode ? [{ debugName: "createdSource" }] : []));
|
|
254
254
|
this.matchSource = signal(matchByLabel, ...(ngDevMode ? [{ debugName: "matchSource" }] : []));
|
|
255
|
+
this.blank = null;
|
|
255
256
|
this.query$$ = this.querySource.asReadonly();
|
|
256
257
|
this.selected$$ = this.selectedSource.asReadonly();
|
|
257
258
|
this.isOpen$$ = this.openSource.asReadonly();
|
|
@@ -289,8 +290,14 @@ class StateService {
|
|
|
289
290
|
this.fetch$.next(buildRequest(query, type, 'options', options));
|
|
290
291
|
}
|
|
291
292
|
resolve(value, options) {
|
|
293
|
+
/* Стор обязан совпасть с формой до ответа: иначе поле показывает прошлый выбор, а цепочка не видит родителя */
|
|
294
|
+
this.blank = buildBlankOption(value);
|
|
295
|
+
this.select(this.blank);
|
|
292
296
|
this.fetch$.next(buildRequest(value.toString(), RequestType.Get, 'selection', options));
|
|
293
297
|
}
|
|
298
|
+
isBlank(option) {
|
|
299
|
+
return isDefined(option) && option === this.blank;
|
|
300
|
+
}
|
|
294
301
|
createByQuery(query, options) {
|
|
295
302
|
this.create$.next(buildRequest(query, RequestType.Create, 'selection', options));
|
|
296
303
|
}
|
|
@@ -384,6 +391,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
|
|
|
384
391
|
function buildRequest(query, type, target, options) {
|
|
385
392
|
return { ...options, type, query, target };
|
|
386
393
|
}
|
|
394
|
+
function buildBlankOption(value) {
|
|
395
|
+
return { kind: 'option', label: '', value };
|
|
396
|
+
}
|
|
387
397
|
function matchByLabel(option, query) {
|
|
388
398
|
return option.label.toLowerCase().includes(query);
|
|
389
399
|
}
|
|
@@ -515,7 +525,7 @@ class BaseDirective extends SlotDirective {
|
|
|
515
525
|
this.config = inject(CONFIG);
|
|
516
526
|
this.messages = inject(MESSAGES);
|
|
517
527
|
this.host = inject(ElementRef);
|
|
518
|
-
this.isMobile$$ =
|
|
528
|
+
this.isMobile$$ = injectBreakpoint('Mobile');
|
|
519
529
|
this.inputRef = viewChild('inputRef', ...(ngDevMode ? [{ debugName: "inputRef" }] : []));
|
|
520
530
|
/** Имя репозитория */
|
|
521
531
|
this.repository = input(...(ngDevMode ? [undefined, { debugName: "repository" }] : []));
|
|
@@ -1151,8 +1161,6 @@ class Yoda extends BaseDirective {
|
|
|
1151
1161
|
this.typed$$.set('');
|
|
1152
1162
|
return this.state.clear();
|
|
1153
1163
|
}
|
|
1154
|
-
/* Стор обязан совпасть с формой до ответа и эффект примет пустоту за очистку */
|
|
1155
|
-
this.state.select({ kind: 'option', value, label: '' });
|
|
1156
1164
|
this.state.resolve(value, this.requestOptions$$());
|
|
1157
1165
|
}
|
|
1158
1166
|
registerOnChange(onChange) {
|
|
@@ -1260,12 +1268,17 @@ class Yoda extends BaseDirective {
|
|
|
1260
1268
|
this.typed$$.set((this.labelToInput() && selected.optionLabel) || selected.label);
|
|
1261
1269
|
}
|
|
1262
1270
|
const value = selected?.value ?? null;
|
|
1263
|
-
|
|
1271
|
+
const changed = value !== this.lastValue;
|
|
1272
|
+
if (changed) {
|
|
1273
|
+
this.lastValue = value;
|
|
1274
|
+
this.onChange(value);
|
|
1275
|
+
this.chain?.resetAfter(this);
|
|
1276
|
+
}
|
|
1277
|
+
if (this.state.isBlank(selected))
|
|
1278
|
+
return;
|
|
1279
|
+
if (!changed && isNil(selected))
|
|
1264
1280
|
return;
|
|
1265
|
-
this.lastValue = value;
|
|
1266
|
-
this.onChange(value);
|
|
1267
1281
|
this.selectionChanged.emit(selected);
|
|
1268
|
-
this.chain?.resetAfter(this);
|
|
1269
1282
|
}
|
|
1270
1283
|
eagerLoad() {
|
|
1271
1284
|
if (!this.needsEagerLoad$$())
|