@acorex/components 7.5.1 → 7.8.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/badge/lib/badge.component.d.ts +3 -3
- package/button/lib/button-item.component.d.ts +3 -1
- package/calendar/lib/calendar.component.d.ts +6 -4
- package/chips/lib/chips.component.d.ts +1 -1
- package/collapse/lib/collapse.component.d.ts +15 -2
- package/collapse/lib/collapse.module.d.ts +2 -1
- package/common/index.d.ts +1 -0
- package/common/lib/classes/datalist.class.d.ts +0 -31
- package/common/lib/classes/datasource.class.d.ts +55 -0
- package/common/lib/classes/styles.class.d.ts +1 -1
- package/common/lib/components/interactive-component.class.d.ts +1 -7
- package/common/lib/components/selection-base.component.class.d.ts +4 -6
- package/common/lib/directives/ripple.directive.d.ts +2 -1
- package/datetime-box/lib/datetime-box.component.d.ts +2 -1
- package/datetime-input/lib/datetime-input.component.d.ts +2 -1
- package/esm2022/action-sheet/lib/action-sheet.component.mjs +2 -2
- package/esm2022/alert/lib/alert.component.mjs +4 -5
- package/esm2022/avatar/lib/avatar.component.mjs +4 -4
- package/esm2022/badge/lib/badge.component.mjs +6 -6
- package/esm2022/button/lib/button-item.component.mjs +12 -3
- package/esm2022/button/lib/button.component.mjs +2 -2
- package/esm2022/button-group/lib/button-group.component.mjs +2 -2
- package/esm2022/calendar/lib/calendar.class.mjs +1 -58
- package/esm2022/calendar/lib/calendar.component.mjs +27 -16
- package/esm2022/chips/lib/chips.component.mjs +4 -4
- package/esm2022/collapse/lib/collapse-group.component.mjs +8 -4
- package/esm2022/collapse/lib/collapse.component.mjs +63 -15
- package/esm2022/collapse/lib/collapse.module.mjs +5 -4
- package/esm2022/color-box/lib/color-box.module.mjs +1 -1
- package/esm2022/common/index.mjs +2 -1
- package/esm2022/common/lib/classes/datalist.class.mjs +2 -41
- package/esm2022/common/lib/classes/datasource.class.mjs +106 -0
- package/esm2022/common/lib/classes/styles.class.mjs +1 -1
- package/esm2022/common/lib/components/interactive-component.class.mjs +13 -13
- package/esm2022/common/lib/components/selection-base.component.class.mjs +55 -27
- package/esm2022/common/lib/directives/ripple.directive.mjs +14 -8
- package/esm2022/datetime-box/lib/datetime-box.component.mjs +6 -3
- package/esm2022/datetime-input/lib/datetime-input.component.mjs +11 -4
- package/esm2022/datetime-picker/lib/datetime-picker.component.mjs +3 -3
- package/esm2022/list/lib/list.component.mjs +34 -60
- package/esm2022/menu/index.mjs +1 -2
- package/esm2022/menu/lib/class/root-menu.class.mjs +1 -1
- package/esm2022/menu/lib/menu-item/menu-item.component.mjs +60 -18
- package/esm2022/menu/lib/menu.component.mjs +37 -342
- package/esm2022/menu/lib/menu.module.mjs +3 -4
- package/esm2022/notification/lib/notification.component.mjs +2 -2
- package/esm2022/otp/lib/otp.component.mjs +4 -3
- package/esm2022/otp/lib/otp.module.mjs +4 -3
- package/esm2022/picker/lib/picker.component.mjs +2 -2
- package/esm2022/progress-bar/lib/progress-bar.component.mjs +2 -2
- package/esm2022/range-slider/lib/range-slider.component.mjs +2 -2
- package/esm2022/routing-progress/lib/routing-progress.component.mjs +3 -3
- package/esm2022/search-box/lib/search-box.component.mjs +5 -4
- package/esm2022/select-box/index.mjs +2 -2
- package/esm2022/select-box/lib/select-box.component.mjs +168 -308
- package/esm2022/select-box/lib/select-box.module.mjs +5 -6
- package/esm2022/selection-list/lib/selection-list.component.mjs +11 -1
- package/esm2022/side-menu/acorex-components-side-menu.mjs +5 -0
- package/esm2022/side-menu/index.mjs +4 -0
- package/esm2022/side-menu/lib/side-menu-item/side-menu-item.compoent.mjs +116 -0
- package/esm2022/side-menu/lib/side-menu.component.mjs +15 -0
- package/esm2022/side-menu/lib/side-menu.module.mjs +23 -0
- package/esm2022/skeleton/acorex-components-skeleton.mjs +5 -0
- package/esm2022/skeleton/index.mjs +3 -0
- package/esm2022/skeleton/lib/skeleton.component.mjs +24 -0
- package/esm2022/skeleton/lib/skeleton.module.mjs +18 -0
- package/esm2022/tabs/lib/tab-item.component.mjs +9 -2
- package/esm2022/tag/lib/tag.component.mjs +6 -12
- package/esm2022/toast/lib/toast.component.mjs +3 -3
- package/fesm2022/acorex-components-action-sheet.mjs +2 -2
- package/fesm2022/acorex-components-action-sheet.mjs.map +1 -1
- package/fesm2022/acorex-components-alert.mjs +3 -4
- package/fesm2022/acorex-components-alert.mjs.map +1 -1
- package/fesm2022/acorex-components-avatar.mjs +3 -3
- package/fesm2022/acorex-components-avatar.mjs.map +1 -1
- package/fesm2022/acorex-components-badge.mjs +5 -5
- package/fesm2022/acorex-components-badge.mjs.map +1 -1
- package/fesm2022/acorex-components-button-group.mjs +2 -2
- package/fesm2022/acorex-components-button-group.mjs.map +1 -1
- package/fesm2022/acorex-components-button.mjs +13 -4
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-calendar.mjs +27 -73
- package/fesm2022/acorex-components-calendar.mjs.map +1 -1
- package/fesm2022/acorex-components-chips.mjs +3 -3
- package/fesm2022/acorex-components-chips.mjs.map +1 -1
- package/fesm2022/acorex-components-collapse.mjs +74 -21
- package/fesm2022/acorex-components-collapse.mjs.map +1 -1
- package/fesm2022/acorex-components-color-box.mjs.map +1 -1
- package/fesm2022/acorex-components-common.mjs +161 -62
- package/fesm2022/acorex-components-common.mjs.map +1 -1
- package/fesm2022/acorex-components-datetime-box.mjs +5 -2
- package/fesm2022/acorex-components-datetime-box.mjs.map +1 -1
- package/fesm2022/acorex-components-datetime-input.mjs +10 -3
- package/fesm2022/acorex-components-datetime-input.mjs.map +1 -1
- package/fesm2022/acorex-components-datetime-picker.mjs +2 -2
- package/fesm2022/acorex-components-datetime-picker.mjs.map +1 -1
- package/fesm2022/acorex-components-list.mjs +33 -59
- package/fesm2022/acorex-components-list.mjs.map +1 -1
- package/fesm2022/acorex-components-menu.mjs +78 -381
- package/fesm2022/acorex-components-menu.mjs.map +1 -1
- package/fesm2022/acorex-components-notification.mjs +2 -2
- package/fesm2022/acorex-components-notification.mjs.map +1 -1
- package/fesm2022/acorex-components-otp.mjs +6 -4
- package/fesm2022/acorex-components-otp.mjs.map +1 -1
- package/fesm2022/acorex-components-picker.mjs +2 -2
- package/fesm2022/acorex-components-picker.mjs.map +1 -1
- package/fesm2022/acorex-components-progress-bar.mjs +2 -2
- package/fesm2022/acorex-components-progress-bar.mjs.map +1 -1
- package/fesm2022/acorex-components-range-slider.mjs +2 -2
- package/fesm2022/acorex-components-range-slider.mjs.map +1 -1
- package/fesm2022/acorex-components-routing-progress.mjs +2 -2
- package/fesm2022/acorex-components-routing-progress.mjs.map +1 -1
- package/fesm2022/acorex-components-search-box.mjs +4 -4
- package/fesm2022/acorex-components-search-box.mjs.map +1 -1
- package/fesm2022/acorex-components-select-box.mjs +96 -417
- package/fesm2022/acorex-components-select-box.mjs.map +1 -1
- package/fesm2022/acorex-components-selection-list.mjs +10 -0
- package/fesm2022/acorex-components-selection-list.mjs.map +1 -1
- package/fesm2022/acorex-components-side-menu.mjs +153 -0
- package/fesm2022/acorex-components-side-menu.mjs.map +1 -0
- package/fesm2022/acorex-components-skeleton.mjs +46 -0
- package/fesm2022/acorex-components-skeleton.mjs.map +1 -0
- package/fesm2022/acorex-components-tabs.mjs +8 -1
- package/fesm2022/acorex-components-tabs.mjs.map +1 -1
- package/fesm2022/acorex-components-tag.mjs +5 -11
- package/fesm2022/acorex-components-tag.mjs.map +1 -1
- package/fesm2022/acorex-components-toast.mjs +2 -2
- package/fesm2022/acorex-components-toast.mjs.map +1 -1
- package/list/lib/list.component.d.ts +11 -23
- package/menu/index.d.ts +0 -1
- package/menu/lib/class/root-menu.class.d.ts +2 -0
- package/menu/lib/menu-item/menu-item.component.d.ts +19 -6
- package/menu/lib/menu.component.d.ts +10 -40
- package/menu/lib/menu.module.d.ts +7 -8
- package/mixin/lib/base-components.class.d.ts +2 -2
- package/mixin/lib/base-menu-mixin.class.d.ts +5 -5
- package/mixin/lib/button-mixin.class.d.ts +2 -2
- package/mixin/lib/clickable-mixin.class.d.ts +2 -2
- package/mixin/lib/color-look-mixing.class.d.ts +2 -2
- package/mixin/lib/datalist-component.class.d.ts +10 -10
- package/mixin/lib/dropdown-mixin.class.d.ts +2 -2
- package/mixin/lib/interactive-mixin.class.d.ts +4 -4
- package/mixin/lib/mixin.class.d.ts +61 -61
- package/mixin/lib/page-component.class.d.ts +2 -2
- package/mixin/lib/selection-component.class.d.ts +2 -2
- package/mixin/lib/sizable-mixin.class.d.ts +2 -2
- package/mixin/lib/textbox-mixin.class.d.ts +2 -2
- package/mixin/lib/value-mixin.class.d.ts +8 -8
- package/otp/lib/otp.module.d.ts +2 -1
- package/package.json +13 -7
- package/search-box/lib/search-box.component.d.ts +2 -1
- package/select-box/index.d.ts +1 -1
- package/select-box/lib/select-box.component.d.ts +37 -59
- package/select-box/lib/select-box.module.d.ts +14 -15
- package/selection-list/lib/selection-list.component.d.ts +3 -0
- package/side-menu/README.md +3 -0
- package/side-menu/index.d.ts +3 -0
- package/side-menu/lib/side-menu-item/side-menu-item.compoent.d.ts +37 -0
- package/side-menu/lib/side-menu.component.d.ts +8 -0
- package/side-menu/lib/side-menu.module.d.ts +10 -0
- package/skeleton/README.md +3 -0
- package/skeleton/index.d.ts +2 -0
- package/skeleton/lib/skeleton.component.d.ts +8 -0
- package/skeleton/lib/skeleton.module.d.ts +8 -0
- package/tabs/lib/tab-item.component.d.ts +2 -1
- package/tag/lib/tag.component.d.ts +3 -4
- package/context-menu/README.md +0 -3
- package/context-menu/index.d.ts +0 -2
- package/context-menu/lib/context-menu.component.d.ts +0 -34
- package/context-menu/lib/context-menu.module.d.ts +0 -13
- package/esm2022/context-menu/acorex-components-context-menu.mjs +0 -5
- package/esm2022/context-menu/index.mjs +0 -3
- package/esm2022/context-menu/lib/context-menu.component.mjs +0 -262
- package/esm2022/context-menu/lib/context-menu.module.mjs +0 -26
- package/esm2022/menu/lib/menu2.component.mjs +0 -45
- package/esm2022/select-box/lib/select-box2.component.mjs +0 -191
- package/fesm2022/acorex-components-context-menu.mjs +0 -290
- package/fesm2022/acorex-components-context-menu.mjs.map +0 -1
- package/menu/lib/menu2.component.d.ts +0 -12
- package/select-box/lib/select-box2.component.d.ts +0 -44
@@ -1,7 +1,8 @@
|
|
1
1
|
import { flatten, clone } from 'lodash-es';
|
2
2
|
import * as i0 from '@angular/core';
|
3
3
|
import { Injectable, Directive, Host, Self, Optional, Input, Inject, NgModule, inject, ChangeDetectorRef, ElementRef, ViewContainerRef, EventEmitter, Output } from '@angular/core';
|
4
|
-
import
|
4
|
+
import _ from 'lodash';
|
5
|
+
import { Subject, fromEvent, noop, skip, distinctUntilChanged, debounceTime } from 'rxjs';
|
5
6
|
import { DOCUMENT } from '@angular/common';
|
6
7
|
import * as i1 from '@angular/platform-browser';
|
7
8
|
import { Observable } from 'rxjs/internal/Observable';
|
@@ -328,41 +329,105 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.9", ngImpor
|
|
328
329
|
}] });
|
329
330
|
|
330
331
|
class AXDateSource {
|
332
|
+
get totalCount() {
|
333
|
+
return this._totalCount;
|
334
|
+
}
|
335
|
+
;
|
336
|
+
get totalPages() {
|
337
|
+
return Math.floor(this.totalCount / this.config.pageSize);
|
338
|
+
}
|
339
|
+
;
|
340
|
+
get cachedItems() {
|
341
|
+
return this._cachedItems;
|
342
|
+
}
|
331
343
|
get items() {
|
332
344
|
return this._items;
|
333
345
|
}
|
346
|
+
get isLoading() {
|
347
|
+
return this._isLoading;
|
348
|
+
}
|
334
349
|
constructor(config) {
|
335
|
-
this.config = config;
|
336
350
|
this._totalCount = 0;
|
337
|
-
this._items =
|
351
|
+
this._items = [];
|
338
352
|
this.fetchedPages = new Set();
|
353
|
+
this._page = 0;
|
354
|
+
this.onChanged = new Subject();
|
355
|
+
this.onLoadingChanged = new Subject();
|
356
|
+
this._isLoading = false;
|
357
|
+
this.config = config;
|
358
|
+
this._cachedItems = new Array(this.config.pageSize);
|
359
|
+
this._items = new Array(0);
|
339
360
|
this._query = { skip: 0, take: this.config.pageSize };
|
340
|
-
this.loadingChanged = new BehaviorSubject(false);
|
341
|
-
this.dataStream = new BehaviorSubject(this._items);
|
342
361
|
}
|
343
|
-
|
362
|
+
load() {
|
363
|
+
const page = this._page;
|
344
364
|
if (this.fetchedPages.has(page)) {
|
345
365
|
return;
|
346
366
|
}
|
347
|
-
this.
|
367
|
+
this.setLoadingState(true);
|
348
368
|
this.fetchedPages.add(page);
|
349
369
|
this._query.skip = page * this.config.pageSize;
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
370
|
+
this.config.load({ ...this._query }).then(result => {
|
371
|
+
if (this._totalCount != result.total) {
|
372
|
+
this._cachedItems = new Array(result.total);
|
373
|
+
this._totalCount = result.total;
|
374
|
+
}
|
375
|
+
this._items = result.items;
|
376
|
+
this._cachedItems.splice(page * this.config.pageSize, this.config.pageSize, ...result.items);
|
377
|
+
const event = {
|
378
|
+
cachedItems: this.cachedItems,
|
379
|
+
items: this.items,
|
380
|
+
page: page,
|
381
|
+
totalCount: this.totalCount,
|
382
|
+
totalPages: this.totalPages
|
383
|
+
};
|
384
|
+
this.onChanged.next(event);
|
385
|
+
}).finally(() => {
|
386
|
+
this.setLoadingState(false);
|
387
|
+
});
|
388
|
+
}
|
389
|
+
setLoadingState(value) {
|
390
|
+
this._isLoading = value;
|
391
|
+
this.onLoadingChanged.next(this._isLoading);
|
392
|
+
}
|
393
|
+
setPage(page) {
|
394
|
+
if (this._page != page || this._items.length == 0) {
|
395
|
+
this._page = page;
|
396
|
+
this.load();
|
354
397
|
}
|
355
|
-
|
356
|
-
|
357
|
-
this.
|
398
|
+
}
|
399
|
+
filter(predicate = null) {
|
400
|
+
this.reset();
|
401
|
+
this._query.predicate = predicate;
|
402
|
+
this.load();
|
403
|
+
}
|
404
|
+
reset() {
|
405
|
+
this._query.predicate = null;
|
406
|
+
this._query.skip = 0;
|
407
|
+
this._cachedItems = new Array(this.config.pageSize);
|
408
|
+
this.fetchedPages.clear();
|
409
|
+
this._page = 0;
|
410
|
+
this._totalCount = 0;
|
411
|
+
}
|
412
|
+
find(key) {
|
413
|
+
const fromCache = this.cachedItems.find(c => (!this.config.key && c == key) || (c && this.config.key && c[this.config.key] == key));
|
414
|
+
if (fromCache)
|
415
|
+
return fromCache;
|
416
|
+
return this.config.byKey ? this.config.byKey(key) : null;
|
358
417
|
}
|
359
418
|
}
|
360
|
-
function convertArrayToDataSource(key,
|
419
|
+
function convertArrayToDataSource(items, options = { key: 'id', pageSize: 20 }) {
|
361
420
|
const config = {
|
362
|
-
key,
|
363
|
-
pageSize:
|
364
|
-
load: (e) =>
|
365
|
-
|
421
|
+
key: options.key,
|
422
|
+
pageSize: options.pageSize,
|
423
|
+
load: (e) => {
|
424
|
+
const result = e.predicate ? _.filter(items, e.predicate) : items;
|
425
|
+
return Promise.resolve({
|
426
|
+
items: result.slice(e.skip, e.skip + e.take),
|
427
|
+
total: result.length
|
428
|
+
});
|
429
|
+
},
|
430
|
+
byKey: (v) => Promise.resolve(items.find(c => c[options.key] == v))
|
366
431
|
};
|
367
432
|
return new AXDateSource(config);
|
368
433
|
}
|
@@ -640,12 +705,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.9", ngImpor
|
|
640
705
|
class AXRippleDirective {
|
641
706
|
constructor(el) {
|
642
707
|
this.el = el;
|
643
|
-
|
708
|
+
this.axRippleColor = 'rgb(0, 0, 0 , 0.1)';
|
709
|
+
el.nativeElement.addEventListener('click', this.createRipple.bind(this));
|
644
710
|
}
|
645
711
|
ngOnDestroy() {
|
646
|
-
this.el.nativeElement.removeEventListener('click', this.createRipple);
|
712
|
+
this.el.nativeElement.removeEventListener('click', this.createRipple.bind(this));
|
647
713
|
}
|
648
714
|
createRipple(event) {
|
715
|
+
this.el.nativeElement.style.overflow = 'hidden';
|
649
716
|
const element = event.currentTarget;
|
650
717
|
const rect = element.getBoundingClientRect();
|
651
718
|
const x = Math.floor(((event.clientX - rect.left) / (rect.right - rect.left)) * element.clientWidth);
|
@@ -656,22 +723,26 @@ class AXRippleDirective {
|
|
656
723
|
circle.style.width = circle.style.height = `${diameter}px`;
|
657
724
|
circle.style.left = `${x - radius}px`;
|
658
725
|
circle.style.top = `${y - radius}px`;
|
659
|
-
circle.
|
660
|
-
|
726
|
+
circle.style.backgroundColor = `${this.axRippleColor}`;
|
727
|
+
circle.classList.add('ax-ripple');
|
728
|
+
const ripple = element.getElementsByClassName('ax-ripple')[0];
|
661
729
|
if (ripple) {
|
662
730
|
ripple.remove();
|
731
|
+
// this.el.nativeElement.style.overflow = 'initial';
|
663
732
|
}
|
664
733
|
element.appendChild(circle);
|
665
734
|
}
|
666
735
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.9", ngImport: i0, type: AXRippleDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
667
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.9", type: AXRippleDirective, selector: "[axRipple]", ngImport: i0 }); }
|
736
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.9", type: AXRippleDirective, selector: "[axRipple]", inputs: { axRippleColor: "axRippleColor" }, ngImport: i0 }); }
|
668
737
|
}
|
669
738
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.9", ngImport: i0, type: AXRippleDirective, decorators: [{
|
670
739
|
type: Directive,
|
671
740
|
args: [{
|
672
741
|
selector: '[axRipple]',
|
673
742
|
}]
|
674
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }
|
743
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { axRippleColor: [{
|
744
|
+
type: Input
|
745
|
+
}] } });
|
675
746
|
|
676
747
|
class AXCommonModule {
|
677
748
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.9", ngImport: i0, type: AXCommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
@@ -863,11 +934,6 @@ class MXInteractiveComponent extends MXBaseComponent {
|
|
863
934
|
* @event
|
864
935
|
*/
|
865
936
|
this.onBlur = new EventEmitter();
|
866
|
-
/**
|
867
|
-
* Fires each time the user clicks the button.
|
868
|
-
* @event
|
869
|
-
*/
|
870
|
-
this.onClick = new EventEmitter();
|
871
937
|
}
|
872
938
|
registerOnTouched(fn) {
|
873
939
|
this.onTouchedCallback = fn;
|
@@ -924,13 +990,18 @@ class MXInteractiveComponent extends MXBaseComponent {
|
|
924
990
|
nativeEvent: e,
|
925
991
|
});
|
926
992
|
}
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
993
|
+
// /**
|
994
|
+
// * Fires each time the user clicks the button.
|
995
|
+
// * @event
|
996
|
+
// */
|
997
|
+
// onClick: EventEmitter<AXClickEvent> = new EventEmitter<AXClickEvent>();
|
998
|
+
// protected emitOnClickEvent(e: MouseEvent): void {
|
999
|
+
// this.onClick.emit({
|
1000
|
+
// component: this,
|
1001
|
+
// htmlElement: this.getHostElement(),
|
1002
|
+
// nativeEvent: e,
|
1003
|
+
// });
|
1004
|
+
// }
|
934
1005
|
focus() {
|
935
1006
|
AXHtmlUtil.focusElement(this.getHostElement());
|
936
1007
|
}
|
@@ -1282,10 +1353,10 @@ class MXSelectionValueComponent extends MXValueComponent {
|
|
1282
1353
|
super(...arguments);
|
1283
1354
|
this._valueField = 'id';
|
1284
1355
|
this._textField = 'text';
|
1285
|
-
this._hintField = 'hint';
|
1286
1356
|
this._disabledField = 'disabled';
|
1287
1357
|
this._multiple = false;
|
1288
1358
|
this._selectedItems = [];
|
1359
|
+
this._cacheList = [];
|
1289
1360
|
}
|
1290
1361
|
get valueField() {
|
1291
1362
|
return this._valueField;
|
@@ -1305,15 +1376,6 @@ class MXSelectionValueComponent extends MXValueComponent {
|
|
1305
1376
|
value: v,
|
1306
1377
|
});
|
1307
1378
|
}
|
1308
|
-
get hintField() {
|
1309
|
-
return this._hintField;
|
1310
|
-
}
|
1311
|
-
set hintField(v) {
|
1312
|
-
this.setOption({
|
1313
|
-
name: 'hintField',
|
1314
|
-
value: v,
|
1315
|
-
});
|
1316
|
-
}
|
1317
1379
|
get disabledField() {
|
1318
1380
|
return this._disabledField;
|
1319
1381
|
}
|
@@ -1336,41 +1398,78 @@ class MXSelectionValueComponent extends MXValueComponent {
|
|
1336
1398
|
return this._selectedItems || [];
|
1337
1399
|
}
|
1338
1400
|
internalSetValue(value) {
|
1339
|
-
const
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1401
|
+
const isArray = Array.isArray(value);
|
1402
|
+
if (value == null || (isArray && value.length == 0)) {
|
1403
|
+
return this.multiple ? [] : null;
|
1404
|
+
}
|
1405
|
+
const normalizedItems = isArray
|
1406
|
+
? this.normalizeItemsList(value, true)
|
1407
|
+
: this.normalizeItemsList([value], true);
|
1408
|
+
if (normalizedItems.length == 0) {
|
1409
|
+
return this.multiple ? [] : null;
|
1410
|
+
}
|
1411
|
+
const result = this.multiple
|
1412
|
+
? normalizedItems.map((c) => c[this.valueField])
|
1413
|
+
: normalizedItems[0][this.valueField];
|
1414
|
+
return result;
|
1343
1415
|
}
|
1344
1416
|
emitOnValueChangedEvent(oldValue, newValue) {
|
1345
1417
|
this._normalizeSelectedItems();
|
1346
1418
|
super.emitOnValueChangedEvent(oldValue, newValue);
|
1347
1419
|
}
|
1348
|
-
normalizeItemsList(items) {
|
1420
|
+
normalizeItemsList(items, findBykey = false) {
|
1349
1421
|
if (items == null)
|
1350
1422
|
return [];
|
1351
|
-
return items.filter((c) => c != null).map((i) => this.normalizeItem(i));
|
1423
|
+
return items.filter((c) => c != null).map((i) => this.normalizeItem(i, findBykey));
|
1352
1424
|
}
|
1353
|
-
normalizeItem(item) {
|
1425
|
+
normalizeItem(item, findBykey = false) {
|
1426
|
+
const complex = typeof item == 'object';
|
1427
|
+
const key = complex ? item[this.valueField] : `${item}`;
|
1428
|
+
const cacheKey = `k-${key}`;
|
1429
|
+
const hasText = !complex || item[this.textField] != null;
|
1430
|
+
//
|
1431
|
+
if (this._cacheList[cacheKey])
|
1432
|
+
return this._cacheList[cacheKey];
|
1433
|
+
//
|
1354
1434
|
const obj = {};
|
1355
|
-
if (
|
1435
|
+
if (complex && hasText) {
|
1356
1436
|
Object.assign(obj, item);
|
1357
1437
|
}
|
1358
|
-
else
|
1359
|
-
const existsItem = this.getItemByKey(
|
1360
|
-
if (existsItem)
|
1361
|
-
|
1438
|
+
else {
|
1439
|
+
const existsItem = findBykey ? this.getItemByKey(key) : null;
|
1440
|
+
if (existsItem && existsItem instanceof Promise) {
|
1441
|
+
obj[this.valueField] = key;
|
1442
|
+
obj[this.textField] = key;
|
1443
|
+
obj['isLoading'] = true;
|
1444
|
+
//
|
1445
|
+
existsItem.then((r) => {
|
1446
|
+
if (typeof r === 'object') {
|
1447
|
+
obj[this.valueField] = r[this.valueField];
|
1448
|
+
obj[this.textField] = r[this.textField];
|
1449
|
+
}
|
1450
|
+
else {
|
1451
|
+
obj[this.valueField] = obj[this.textField] = r || key;
|
1452
|
+
}
|
1453
|
+
}).finally(() => {
|
1454
|
+
obj['isLoading'] = false;
|
1455
|
+
this.cdr.markForCheck();
|
1456
|
+
});
|
1457
|
+
}
|
1458
|
+
else if (existsItem) {
|
1459
|
+
obj[this.valueField] = existsItem;
|
1460
|
+
}
|
1362
1461
|
else {
|
1363
1462
|
obj[this.valueField] = item;
|
1364
|
-
obj[this.textField] = item.toString();
|
1365
1463
|
}
|
1366
1464
|
}
|
1367
1465
|
if (!obj[this.textField]) {
|
1368
1466
|
obj[this.textField] = obj[this.valueField];
|
1369
1467
|
}
|
1468
|
+
this._cacheList[cacheKey] = obj;
|
1370
1469
|
return obj;
|
1371
1470
|
}
|
1372
1471
|
_normalizeSelectedItems() {
|
1373
|
-
const values = Array.isArray(this.value) ? this.value : this.value ? [this.value] : [];
|
1472
|
+
const values = Array.isArray(this.value) ? this.value : this.value != null ? [this.value] : [];
|
1374
1473
|
this._selectedItems = values.map((v) => this.normalizeItem(v));
|
1375
1474
|
}
|
1376
1475
|
unselectItems(...items) {
|
@@ -1419,7 +1518,7 @@ class MXSelectionValueComponent extends MXValueComponent {
|
|
1419
1518
|
}
|
1420
1519
|
getDisplayText(item) {
|
1421
1520
|
const normalizeItem = this.normalizeItem(item);
|
1422
|
-
return normalizeItem[this.textField];
|
1521
|
+
return normalizeItem['isLoading'] ? 'Loading...' : normalizeItem[this.textField];
|
1423
1522
|
}
|
1424
1523
|
getValue(item) {
|
1425
1524
|
const normalizeItem = this.normalizeItem(item);
|