@acorex/components 7.8.0 → 7.8.2
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/esm2022/button/lib/button.component.mjs +2 -2
- package/esm2022/list/lib/list.component.mjs +10 -8
- package/esm2022/otp/lib/otp.component.mjs +2 -2
- package/esm2022/select-box/lib/select-box.component.mjs +7 -6
- package/fesm2022/acorex-components-button.mjs +2 -2
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-list.mjs +9 -7
- package/fesm2022/acorex-components-list.mjs.map +1 -1
- package/fesm2022/acorex-components-otp.mjs +2 -2
- package/fesm2022/acorex-components-otp.mjs.map +1 -1
- package/fesm2022/acorex-components-select-box.mjs +6 -5
- package/fesm2022/acorex-components-select-box.mjs.map +1 -1
- package/list/lib/list.component.d.ts +1 -2
- package/package.json +1 -7
- package/select-box/lib/select-box.component.d.ts +0 -1
- package/esm2022/mixin/acorex-components-mixin.mjs +0 -5
- package/esm2022/mixin/index.mjs +0 -17
- package/esm2022/mixin/lib/base-components.class.mjs +0 -110
- package/esm2022/mixin/lib/base-menu-mixin.class.mjs +0 -137
- package/esm2022/mixin/lib/button-mixin.class.mjs +0 -66
- package/esm2022/mixin/lib/clickable-mixin.class.mjs +0 -24
- package/esm2022/mixin/lib/color-look-mixing.class.mjs +0 -43
- package/esm2022/mixin/lib/constratctor.mjs +0 -2
- package/esm2022/mixin/lib/datalist-component.class.mjs +0 -155
- package/esm2022/mixin/lib/datalist.class.mjs +0 -46
- package/esm2022/mixin/lib/dropdown-mixin.class.mjs +0 -95
- package/esm2022/mixin/lib/interactive-mixin.class.mjs +0 -84
- package/esm2022/mixin/lib/mixin.class.mjs +0 -26
- package/esm2022/mixin/lib/page-component.class.mjs +0 -11
- package/esm2022/mixin/lib/selection-component.class.mjs +0 -180
- package/esm2022/mixin/lib/sizable-mixin.class.mjs +0 -16
- package/esm2022/mixin/lib/textbox-mixin.class.mjs +0 -67
- package/esm2022/mixin/lib/value-mixin.class.mjs +0 -227
- package/fesm2022/acorex-components-mixin.mjs +0 -1268
- package/fesm2022/acorex-components-mixin.mjs.map +0 -1
- package/mixin/README.md +0 -3
- package/mixin/index.d.ts +0 -16
- package/mixin/lib/base-components.class.d.ts +0 -84
- package/mixin/lib/base-menu-mixin.class.d.ts +0 -53
- package/mixin/lib/button-mixin.class.d.ts +0 -53
- package/mixin/lib/clickable-mixin.class.d.ts +0 -36
- package/mixin/lib/color-look-mixing.class.d.ts +0 -42
- package/mixin/lib/constratctor.d.ts +0 -4
- package/mixin/lib/datalist-component.class.d.ts +0 -59
- package/mixin/lib/datalist.class.d.ts +0 -49
- package/mixin/lib/dropdown-mixin.class.d.ts +0 -47
- package/mixin/lib/interactive-mixin.class.d.ts +0 -63
- package/mixin/lib/mixin.class.d.ts +0 -680
- package/mixin/lib/page-component.class.d.ts +0 -28
- package/mixin/lib/selection-component.class.d.ts +0 -61
- package/mixin/lib/sizable-mixin.class.d.ts +0 -34
- package/mixin/lib/textbox-mixin.class.d.ts +0 -66
- package/mixin/lib/value-mixin.class.d.ts +0 -64
@@ -1,1268 +0,0 @@
|
|
1
|
-
import * as i0 from '@angular/core';
|
2
|
-
import { Injectable, Inject, EventEmitter } from '@angular/core';
|
3
|
-
import { unionBy, flatMapDeep, clone } from 'lodash-es';
|
4
|
-
import { defer, Subject, BehaviorSubject, combineLatest } from 'rxjs';
|
5
|
-
import { finalize, switchMap, startWith, share, map } from 'rxjs/operators';
|
6
|
-
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
7
|
-
|
8
|
-
class AXBaseComponent {
|
9
|
-
/**
|
10
|
-
* A token that specifies the layout direction of component.
|
11
|
-
*/
|
12
|
-
//rtl: boolean;
|
13
|
-
#rtl;
|
14
|
-
get rtl() {
|
15
|
-
if (this.#rtl)
|
16
|
-
return this.#rtl;
|
17
|
-
else
|
18
|
-
return (this._getHostElement()?.classList?.contains('ax-rtl') ||
|
19
|
-
window.getComputedStyle(this._getHostElement(), null)?.getPropertyValue('direction') === 'rtl');
|
20
|
-
}
|
21
|
-
set rtl(value) {
|
22
|
-
this.#rtl = value;
|
23
|
-
}
|
24
|
-
#elementRef;
|
25
|
-
/**
|
26
|
-
* @ignore
|
27
|
-
*/
|
28
|
-
constructor(...args) {
|
29
|
-
this.id = `AX${Math.round(Math.random() * Math.pow(10, 10))}`;
|
30
|
-
this.#elementRef = args[0];
|
31
|
-
this._cdr = args[1];
|
32
|
-
}
|
33
|
-
ngOnInit() {
|
34
|
-
this._isInited = true;
|
35
|
-
this._onInternalInit();
|
36
|
-
}
|
37
|
-
ngAfterViewInit() {
|
38
|
-
this._isRendered = true;
|
39
|
-
this._onInternalViewInit();
|
40
|
-
}
|
41
|
-
ngOnDestroy() {
|
42
|
-
this._onInternalDestroy();
|
43
|
-
}
|
44
|
-
//TODO: check why every time called _getHostElement function
|
45
|
-
_getHostElement() {
|
46
|
-
//TODO: check elementRef retrun 0
|
47
|
-
return this.#elementRef?.nativeElement;
|
48
|
-
}
|
49
|
-
_getInnerElement() {
|
50
|
-
return this._getHostElement().firstElementChild;
|
51
|
-
}
|
52
|
-
_onInternalInit() {
|
53
|
-
//TODO: check Cannot set properties of undefined (setting '__axContext__')
|
54
|
-
if (this._getHostElement()) {
|
55
|
-
this._getHostElement().__axContext__ = this;
|
56
|
-
}
|
57
|
-
this._applyRtl();
|
58
|
-
this.onInit();
|
59
|
-
}
|
60
|
-
_onInternalViewInit() {
|
61
|
-
this.onViewInit();
|
62
|
-
}
|
63
|
-
_onInternalDestroy() {
|
64
|
-
this.onDestroy();
|
65
|
-
}
|
66
|
-
onInit() { }
|
67
|
-
onViewInit() { }
|
68
|
-
onDestroy() { }
|
69
|
-
_applyRtl() {
|
70
|
-
if (this.rtl) {
|
71
|
-
this._getHostElement().classList.add('ax-rtl');
|
72
|
-
}
|
73
|
-
}
|
74
|
-
_onOptionChanging(option) {
|
75
|
-
return option?.value;
|
76
|
-
}
|
77
|
-
_onOptionChanged(option) { }
|
78
|
-
_setOption(option) {
|
79
|
-
const oldValue = this[option.name];
|
80
|
-
const newValue = this._onOptionChanging({
|
81
|
-
name: option.name,
|
82
|
-
value: option.value,
|
83
|
-
});
|
84
|
-
//TODO : check real changes
|
85
|
-
if (option.beforeCallback)
|
86
|
-
option.beforeCallback(oldValue, newValue);
|
87
|
-
if (oldValue != newValue) {
|
88
|
-
this[`_${option.name}`] = option.value;
|
89
|
-
this._onOptionChanged({ name: option.name, newValue, oldValue });
|
90
|
-
const emitter = this[`${option.name}Change`];
|
91
|
-
if (emitter)
|
92
|
-
emitter.emit(newValue);
|
93
|
-
}
|
94
|
-
if (option.afterCallback)
|
95
|
-
option.afterCallback(oldValue, newValue);
|
96
|
-
}
|
97
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.9", ngImport: i0, type: AXBaseComponent, deps: [{ token: Array }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
98
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.9", ngImport: i0, type: AXBaseComponent }); }
|
99
|
-
}
|
100
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.9", ngImport: i0, type: AXBaseComponent, decorators: [{
|
101
|
-
type: Injectable
|
102
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
103
|
-
type: Inject,
|
104
|
-
args: [Array]
|
105
|
-
}] }]; } });
|
106
|
-
function _BaseComponenetMixin(Base) {
|
107
|
-
return class extends Base {
|
108
|
-
constructor(...args) {
|
109
|
-
super(...args);
|
110
|
-
}
|
111
|
-
};
|
112
|
-
}
|
113
|
-
const BASE_INPUTS = ['rtl'];
|
114
|
-
const BASE_OUTPUT = [];
|
115
|
-
|
116
|
-
function _BaseMenuComponentMixin(Base) {
|
117
|
-
return class extends Base {
|
118
|
-
#isLoading;
|
119
|
-
#loadedItems;
|
120
|
-
constructor(...args) {
|
121
|
-
super(...args);
|
122
|
-
this.textField = 'text';
|
123
|
-
this.valueField = 'id';
|
124
|
-
this.#isLoading = false;
|
125
|
-
this.#loadedItems = [];
|
126
|
-
this.disableField = 'disabled';
|
127
|
-
this.iconField = 'icon';
|
128
|
-
this.openMode = 'click';
|
129
|
-
this.displayMode = 'sidemenu';
|
130
|
-
this.dividerField = 'divider';
|
131
|
-
this.onMenuItemClick = new EventEmitter();
|
132
|
-
this.#items = [];
|
133
|
-
}
|
134
|
-
#items;
|
135
|
-
get items() {
|
136
|
-
return this.#items;
|
137
|
-
}
|
138
|
-
set items(v) {
|
139
|
-
if (Array.isArray(v)) {
|
140
|
-
this.#items = v;
|
141
|
-
}
|
142
|
-
else if (typeof v === 'function') {
|
143
|
-
this.#items = v;
|
144
|
-
}
|
145
|
-
else {
|
146
|
-
this.#items = [];
|
147
|
-
}
|
148
|
-
}
|
149
|
-
get displayItems() {
|
150
|
-
if (Array.isArray(this.items)) {
|
151
|
-
return this.#items || [];
|
152
|
-
}
|
153
|
-
else if (typeof this.#items == 'function') {
|
154
|
-
return this.#loadedItems || [];
|
155
|
-
}
|
156
|
-
return [];
|
157
|
-
}
|
158
|
-
get isLoading() {
|
159
|
-
return this.#isLoading;
|
160
|
-
}
|
161
|
-
_formatData(v) {
|
162
|
-
return unionBy(v.map((o, i) => {
|
163
|
-
if (typeof o == 'object')
|
164
|
-
return o;
|
165
|
-
else {
|
166
|
-
const no = {};
|
167
|
-
no[this.valueField] = o;
|
168
|
-
no[Array.isArray(this.textField) ? this.textField[0] : this.textField] = o;
|
169
|
-
return no;
|
170
|
-
}
|
171
|
-
}), this.valueField);
|
172
|
-
}
|
173
|
-
_findNode(parentId, _children, source) {
|
174
|
-
if (source.length > 0) {
|
175
|
-
source.forEach((element) => {
|
176
|
-
if (element[this.valueField] == parentId) {
|
177
|
-
element.children = _children;
|
178
|
-
}
|
179
|
-
else {
|
180
|
-
if (element?.children)
|
181
|
-
this._findNode(parentId, _children, element.children);
|
182
|
-
}
|
183
|
-
});
|
184
|
-
}
|
185
|
-
}
|
186
|
-
_fetchData(parentId, searchText) {
|
187
|
-
return new Promise((resolve) => {
|
188
|
-
if (this.#isLoading) {
|
189
|
-
return;
|
190
|
-
}
|
191
|
-
if (this.#items) {
|
192
|
-
this.#isLoading = true;
|
193
|
-
this.#items({
|
194
|
-
parentId: parentId,
|
195
|
-
searchQuery: searchText,
|
196
|
-
})
|
197
|
-
.then((c) => {
|
198
|
-
if (Array.isArray(c)) {
|
199
|
-
if (parentId) {
|
200
|
-
resolve(this._findNode(parentId, c, this.displayItems));
|
201
|
-
}
|
202
|
-
else {
|
203
|
-
resolve((this.#loadedItems = c));
|
204
|
-
}
|
205
|
-
}
|
206
|
-
this._cdr.markForCheck();
|
207
|
-
})
|
208
|
-
.finally(() => {
|
209
|
-
this.#isLoading = false;
|
210
|
-
});
|
211
|
-
}
|
212
|
-
});
|
213
|
-
}
|
214
|
-
_onInternalInit() {
|
215
|
-
if (typeof this.#items == 'function') {
|
216
|
-
this._fetchData();
|
217
|
-
}
|
218
|
-
super._onInternalInit();
|
219
|
-
}
|
220
|
-
_getItemDisplayTextTemplte(item) {
|
221
|
-
if (item)
|
222
|
-
return Array.isArray(this.textField)
|
223
|
-
? this.textField.map((c) => item[c]).join(',')
|
224
|
-
: item[this.textField];
|
225
|
-
else
|
226
|
-
return 'Loading...';
|
227
|
-
}
|
228
|
-
refresh() {
|
229
|
-
this._fetchData();
|
230
|
-
}
|
231
|
-
};
|
232
|
-
}
|
233
|
-
const BASEMENU_INPUTS = [
|
234
|
-
'textField',
|
235
|
-
'valueField',
|
236
|
-
'items',
|
237
|
-
'parentId',
|
238
|
-
'iconField',
|
239
|
-
'tooltip',
|
240
|
-
'opened',
|
241
|
-
'active',
|
242
|
-
'visibleField',
|
243
|
-
'disableField',
|
244
|
-
'hasChildField',
|
245
|
-
'openMode',
|
246
|
-
'displayMode',
|
247
|
-
'dividerField',
|
248
|
-
];
|
249
|
-
const BASEMENU_OUTPUT = ['onMenuItemClick'];
|
250
|
-
|
251
|
-
function _ButtonComponentMixin(Base) {
|
252
|
-
return class extends Base {
|
253
|
-
/**
|
254
|
-
* Defines the primary text to show inside the button.
|
255
|
-
*/
|
256
|
-
get text() {
|
257
|
-
return this._text;
|
258
|
-
}
|
259
|
-
set text(v) {
|
260
|
-
this._setOption({
|
261
|
-
name: 'text',
|
262
|
-
value: v,
|
263
|
-
afterCallback: () => {
|
264
|
-
this._cdr.markForCheck();
|
265
|
-
},
|
266
|
-
});
|
267
|
-
}
|
268
|
-
/**
|
269
|
-
* Provides visual styling that indicates if the Button is active
|
270
|
-
*/
|
271
|
-
get toggleable() {
|
272
|
-
return this._toggleable;
|
273
|
-
}
|
274
|
-
set toggleable(value) {
|
275
|
-
this._setOption({
|
276
|
-
name: 'toggleable',
|
277
|
-
value,
|
278
|
-
});
|
279
|
-
}
|
280
|
-
/**
|
281
|
-
* Indicates if the Button is selected or not
|
282
|
-
*/
|
283
|
-
get selected() {
|
284
|
-
return this._selected;
|
285
|
-
}
|
286
|
-
set selected(value) {
|
287
|
-
this._setOption({
|
288
|
-
name: 'selected',
|
289
|
-
value,
|
290
|
-
afterCallback: () => {
|
291
|
-
this._cdr.markForCheck();
|
292
|
-
},
|
293
|
-
});
|
294
|
-
}
|
295
|
-
constructor(...args) {
|
296
|
-
super(...args);
|
297
|
-
this.toggleableChange = new EventEmitter();
|
298
|
-
this._toggleable = false;
|
299
|
-
this.selectedChange = new EventEmitter();
|
300
|
-
this._selected = false;
|
301
|
-
}
|
302
|
-
get _classes() {
|
303
|
-
const cssClasses = {
|
304
|
-
'ax-button-icon': !this.text,
|
305
|
-
'ax-state-disabled': this['disabled'],
|
306
|
-
'ax-state-selected': this.selected,
|
307
|
-
};
|
308
|
-
cssClasses[`ax-${this['color'] || 'default'}${this['look'] ? '-' + this['look'] : '-default'}`] = true;
|
309
|
-
return cssClasses;
|
310
|
-
}
|
311
|
-
};
|
312
|
-
}
|
313
|
-
const BUTTON_INPUTS = ['text', 'toggleable', 'selected'];
|
314
|
-
const BUTTON_OUTPUT = ['onBlur', 'onFocus', 'onClick', 'selectedChange', 'toggleableChange'];
|
315
|
-
|
316
|
-
function _ClickableComponenetMixin(Base) {
|
317
|
-
return class extends Base {
|
318
|
-
_emitOnClickEvent(e) {
|
319
|
-
this.onClick.emit({
|
320
|
-
component: this,
|
321
|
-
htmlElement: this._getHostElement(),
|
322
|
-
nativeEvent: e,
|
323
|
-
});
|
324
|
-
}
|
325
|
-
/**
|
326
|
-
* @ignore
|
327
|
-
*/
|
328
|
-
constructor(...args) {
|
329
|
-
super(...args);
|
330
|
-
/**
|
331
|
-
* Fires each time the user clicks the button.
|
332
|
-
* @event
|
333
|
-
*/
|
334
|
-
this.onClick = new EventEmitter();
|
335
|
-
}
|
336
|
-
};
|
337
|
-
}
|
338
|
-
|
339
|
-
function _ColorLookComponentMixin(Base) {
|
340
|
-
return class extends Base {
|
341
|
-
constructor(...args) {
|
342
|
-
super(...args);
|
343
|
-
this.colorChange = new EventEmitter();
|
344
|
-
this._color = 'ghost';
|
345
|
-
this.lookChange = new EventEmitter();
|
346
|
-
this._look = 'solid';
|
347
|
-
}
|
348
|
-
/**
|
349
|
-
* Predefined color schemes
|
350
|
-
*/
|
351
|
-
get color() {
|
352
|
-
return this._color;
|
353
|
-
}
|
354
|
-
set color(value) {
|
355
|
-
this._setOption({
|
356
|
-
name: 'color',
|
357
|
-
value,
|
358
|
-
afterCallback: () => {
|
359
|
-
this._cdr.markForCheck();
|
360
|
-
},
|
361
|
-
});
|
362
|
-
}
|
363
|
-
/**
|
364
|
-
* Predefined look schemes
|
365
|
-
*/
|
366
|
-
get look() {
|
367
|
-
return this._look;
|
368
|
-
}
|
369
|
-
set look(value) {
|
370
|
-
this._setOption({
|
371
|
-
name: 'look',
|
372
|
-
value,
|
373
|
-
afterCallback: () => {
|
374
|
-
this._cdr.markForCheck();
|
375
|
-
},
|
376
|
-
});
|
377
|
-
}
|
378
|
-
};
|
379
|
-
}
|
380
|
-
|
381
|
-
function _DatalistComponenetMixin(Base) {
|
382
|
-
return class extends Base {
|
383
|
-
#currentPage;
|
384
|
-
#isLoading;
|
385
|
-
#loadedItems;
|
386
|
-
#flatItems;
|
387
|
-
#totalItems;
|
388
|
-
#isLazy;
|
389
|
-
get totalCount() {
|
390
|
-
return this.#totalItems;
|
391
|
-
}
|
392
|
-
get isLazy() {
|
393
|
-
return this.#isLazy;
|
394
|
-
}
|
395
|
-
get loadedCount() {
|
396
|
-
return this.#loadedItems?.length || 0;
|
397
|
-
}
|
398
|
-
constructor(...args) {
|
399
|
-
super(...args);
|
400
|
-
this.valueField = 'id';
|
401
|
-
this.textField = 'text';
|
402
|
-
this.pageSize = 10;
|
403
|
-
this.#currentPage = 0;
|
404
|
-
this.#isLoading = false;
|
405
|
-
this.#loadedItems = [];
|
406
|
-
this.#flatItems = [];
|
407
|
-
this.#totalItems = 0;
|
408
|
-
this.#isLazy = false;
|
409
|
-
this.#items = [];
|
410
|
-
}
|
411
|
-
#items;
|
412
|
-
get items() {
|
413
|
-
return this.#items;
|
414
|
-
}
|
415
|
-
set items(v) {
|
416
|
-
if (Array.isArray(v)) {
|
417
|
-
this.#items = this._formatData(v);
|
418
|
-
this._onDataLoaded();
|
419
|
-
this.#generateFlatItems();
|
420
|
-
}
|
421
|
-
else if (typeof v === 'function') {
|
422
|
-
this.#isLazy = true;
|
423
|
-
this.#items = v;
|
424
|
-
}
|
425
|
-
else {
|
426
|
-
this.#items = [];
|
427
|
-
this._onDataLoaded();
|
428
|
-
this.#generateFlatItems();
|
429
|
-
}
|
430
|
-
}
|
431
|
-
get displayItems() {
|
432
|
-
if (Array.isArray(this.items)) {
|
433
|
-
return (this.#items || []);
|
434
|
-
}
|
435
|
-
else if (typeof this.#items == 'function') {
|
436
|
-
return this.#loadedItems || [];
|
437
|
-
}
|
438
|
-
return [];
|
439
|
-
}
|
440
|
-
get flatItems() {
|
441
|
-
return this.#flatItems || [];
|
442
|
-
}
|
443
|
-
get isLoading() {
|
444
|
-
return this.#isLoading;
|
445
|
-
}
|
446
|
-
_formatData(v) {
|
447
|
-
return unionBy(v.map((o, i) => {
|
448
|
-
if (typeof o == 'object')
|
449
|
-
return o;
|
450
|
-
else {
|
451
|
-
const no = {};
|
452
|
-
no[this.valueField] = o;
|
453
|
-
no[Array.isArray(this.textField) ? this.textField[0] : this.textField] = o;
|
454
|
-
return no;
|
455
|
-
}
|
456
|
-
}), this.valueField);
|
457
|
-
// return v.map((o, i) => {
|
458
|
-
// if (typeof o == 'object')
|
459
|
-
// return o
|
460
|
-
// else {
|
461
|
-
// const no: any = {};
|
462
|
-
// no[this.valueField] = o;
|
463
|
-
// no[Array.isArray(this.textField) ? this.textField[0] : this.textField] = o;
|
464
|
-
// return no;
|
465
|
-
// }
|
466
|
-
// });
|
467
|
-
}
|
468
|
-
_fetchData(opts) {
|
469
|
-
const skip = this.#currentPage * this.pageSize, take = this.pageSize;
|
470
|
-
if ((this.loadedCount >= this.totalCount && this.totalCount != 0) ||
|
471
|
-
this.#isLoading ||
|
472
|
-
!this.#isLazy ||
|
473
|
-
skip > this.totalCount) {
|
474
|
-
return;
|
475
|
-
}
|
476
|
-
if (this.#items) {
|
477
|
-
this.#isLoading = true;
|
478
|
-
const fetchFn = this.#items;
|
479
|
-
fetchFn({ skip, take, searchQuery: opts?.searchQuery })
|
480
|
-
.then((c) => {
|
481
|
-
if (Array.isArray(c)) {
|
482
|
-
this.#loadedItems = this._formatData(c);
|
483
|
-
this.#totalItems = c.length;
|
484
|
-
}
|
485
|
-
else {
|
486
|
-
this.#totalItems = c.total || c.items?.length || 0;
|
487
|
-
this.#loadedItems = [...new Set(this.#loadedItems.concat(this._formatData(c.items)))];
|
488
|
-
this.#currentPage++;
|
489
|
-
}
|
490
|
-
this._cdr.markForCheck();
|
491
|
-
})
|
492
|
-
.finally(() => {
|
493
|
-
this.#isLoading = false;
|
494
|
-
this._onDataLoaded();
|
495
|
-
this.#generateFlatItems();
|
496
|
-
});
|
497
|
-
}
|
498
|
-
}
|
499
|
-
_onDataLoaded() { }
|
500
|
-
#generateFlatItems() {
|
501
|
-
const flattenFn = (item) => {
|
502
|
-
return [item, flatMapDeep(item.children, flattenFn)];
|
503
|
-
};
|
504
|
-
this.#flatItems = flatMapDeep(this.displayItems, flattenFn);
|
505
|
-
}
|
506
|
-
_getItemDisplayTextTemplte(item) {
|
507
|
-
if (item)
|
508
|
-
return Array.isArray(this.textField)
|
509
|
-
? this.textField.map((c) => item[c]).join(',')
|
510
|
-
: item[this.textField];
|
511
|
-
else
|
512
|
-
return 'Loading...';
|
513
|
-
}
|
514
|
-
_trackByFunction(item) {
|
515
|
-
if (!item)
|
516
|
-
return null;
|
517
|
-
return item[this.valueField];
|
518
|
-
}
|
519
|
-
refresh() {
|
520
|
-
this.empty();
|
521
|
-
this._fetchData();
|
522
|
-
}
|
523
|
-
empty() {
|
524
|
-
this.#isLoading = false;
|
525
|
-
this.#currentPage = 0;
|
526
|
-
if (this.#loadedItems) {
|
527
|
-
this.#loadedItems.length = 0;
|
528
|
-
}
|
529
|
-
}
|
530
|
-
};
|
531
|
-
}
|
532
|
-
const DATALIST_INPUTS = ['pageSize', 'valueField', 'textField', 'items'];
|
533
|
-
const DATALIST_OUTPUT = [];
|
534
|
-
|
535
|
-
function prepare(callback) {
|
536
|
-
return (source) => defer(() => {
|
537
|
-
callback();
|
538
|
-
return source;
|
539
|
-
});
|
540
|
-
}
|
541
|
-
function indicate(indicator) {
|
542
|
-
return (source) => source.pipe(prepare(() => indicator.next(true)), finalize(() => indicator.next(false)));
|
543
|
-
}
|
544
|
-
class AXPaginatedDataSource {
|
545
|
-
constructor(endpoint, initialSort, initialQuery, take = 20) {
|
546
|
-
this.endpoint = endpoint;
|
547
|
-
this.take = take;
|
548
|
-
this.pageNumber = new Subject();
|
549
|
-
this.loading = new Subject();
|
550
|
-
this.loading$ = this.loading.asObservable();
|
551
|
-
this.query = new BehaviorSubject(initialQuery);
|
552
|
-
this.sort = new BehaviorSubject(initialSort);
|
553
|
-
const param$ = combineLatest([this.query, this.sort]);
|
554
|
-
this.page$ = param$.pipe(switchMap(([query, sort]) => this.pageNumber.pipe(startWith(0), switchMap((page) => this.endpoint({
|
555
|
-
take,
|
556
|
-
skip: page * take,
|
557
|
-
sort,
|
558
|
-
}, query).pipe(indicate(this.loading))))), share());
|
559
|
-
}
|
560
|
-
sortBy(sort) {
|
561
|
-
const lastSort = this.sort.getValue();
|
562
|
-
const nextSort = { ...lastSort, ...sort };
|
563
|
-
this.sort.next(nextSort);
|
564
|
-
}
|
565
|
-
queryBy(query) {
|
566
|
-
const lastQuery = this.query.getValue();
|
567
|
-
const nextQuery = { ...lastQuery, ...query };
|
568
|
-
this.query.next(nextQuery);
|
569
|
-
}
|
570
|
-
fetch(page) {
|
571
|
-
this.pageNumber.next(page);
|
572
|
-
}
|
573
|
-
connect() {
|
574
|
-
return this.page$.pipe(map((page) => page.items));
|
575
|
-
}
|
576
|
-
disconnect() { }
|
577
|
-
}
|
578
|
-
|
579
|
-
function _DropdownComponenetMixin(Base) {
|
580
|
-
class Mixin extends Base {
|
581
|
-
_emitOnOpenedEvent() {
|
582
|
-
this.onOpened.emit({
|
583
|
-
component: this,
|
584
|
-
htmlElement: this._getHostElement(),
|
585
|
-
});
|
586
|
-
}
|
587
|
-
_emitOnClosedEvent() {
|
588
|
-
this.onClosed.emit({
|
589
|
-
component: this,
|
590
|
-
htmlElement: this._getHostElement(),
|
591
|
-
});
|
592
|
-
}
|
593
|
-
onInit() {
|
594
|
-
super.onInit();
|
595
|
-
this.popover.onOpened.subscribe(this.onOpened);
|
596
|
-
this.popover.onClosed.subscribe(this.onClosed);
|
597
|
-
}
|
598
|
-
onViewInit() {
|
599
|
-
// wait for documentElement
|
600
|
-
setTimeout(() => {
|
601
|
-
if (this.position.length == 0) {
|
602
|
-
const a = 0;
|
603
|
-
const offset = Number(getComputedStyle(document.documentElement).getPropertyValue('--ax-base-size').replace('px', ''));
|
604
|
-
const list = [
|
605
|
-
{
|
606
|
-
originX: 'start',
|
607
|
-
originY: 'bottom',
|
608
|
-
overlayX: 'start',
|
609
|
-
overlayY: 'top',
|
610
|
-
offsetY: offset,
|
611
|
-
},
|
612
|
-
{
|
613
|
-
originX: 'start',
|
614
|
-
originY: 'top',
|
615
|
-
overlayX: 'start',
|
616
|
-
overlayY: 'bottom',
|
617
|
-
offsetY: -offset,
|
618
|
-
},
|
619
|
-
{
|
620
|
-
originX: 'end',
|
621
|
-
originY: 'bottom',
|
622
|
-
overlayX: 'end',
|
623
|
-
overlayY: 'top',
|
624
|
-
offsetY: offset,
|
625
|
-
},
|
626
|
-
{
|
627
|
-
originX: 'end',
|
628
|
-
originY: 'top',
|
629
|
-
overlayX: 'end',
|
630
|
-
overlayY: 'bottom',
|
631
|
-
offsetY: -offset,
|
632
|
-
},
|
633
|
-
];
|
634
|
-
this.position.push(...list);
|
635
|
-
}
|
636
|
-
}, 500);
|
637
|
-
}
|
638
|
-
toggle() {
|
639
|
-
if (this['disabled'] !== true) {
|
640
|
-
this.popover.toggle();
|
641
|
-
}
|
642
|
-
}
|
643
|
-
close() {
|
644
|
-
if (!this.isOpen || this['disabled']) {
|
645
|
-
return;
|
646
|
-
}
|
647
|
-
this.popover.close();
|
648
|
-
this?.focus();
|
649
|
-
}
|
650
|
-
open() {
|
651
|
-
if (this.isOpen || this['disabled']) {
|
652
|
-
return;
|
653
|
-
}
|
654
|
-
this.popover.open();
|
655
|
-
this.popover.focus();
|
656
|
-
}
|
657
|
-
get isOpen() {
|
658
|
-
return this.popover?.isOpen;
|
659
|
-
}
|
660
|
-
constructor(...args) {
|
661
|
-
super(...args);
|
662
|
-
this.readonly = false;
|
663
|
-
this.onOpened = new EventEmitter();
|
664
|
-
this.onClosed = new EventEmitter();
|
665
|
-
this.position = [];
|
666
|
-
}
|
667
|
-
}
|
668
|
-
return Mixin;
|
669
|
-
}
|
670
|
-
const DROPDOWN_INPUTS = ['isOpen', 'fitParent', 'dropdownWidth', 'position'];
|
671
|
-
const DROPDOWN_OUTPUT = ['onOpened', 'onClosed'];
|
672
|
-
|
673
|
-
function _InteractiveComponenetMixin(Base) {
|
674
|
-
class Mixin extends Base {
|
675
|
-
#disabled;
|
676
|
-
/**
|
677
|
-
* If set to true, it disables the component.
|
678
|
-
*/
|
679
|
-
get disabled() {
|
680
|
-
return this.#disabled;
|
681
|
-
}
|
682
|
-
set disabled(value) {
|
683
|
-
value = this._onOptionChanging({ name: 'disabled', value: value });
|
684
|
-
if (value != this.disabled) {
|
685
|
-
const oldValue = this.disabled;
|
686
|
-
this.#disabled = coerceBooleanProperty(value);
|
687
|
-
this._onOptionChanged({ name: 'disabled', oldValue, newValue: value });
|
688
|
-
this._cdr.markForCheck();
|
689
|
-
}
|
690
|
-
}
|
691
|
-
#tabIndex;
|
692
|
-
/**
|
693
|
-
* Specifies the tabindex of the component.
|
694
|
-
*/
|
695
|
-
get tabIndex() {
|
696
|
-
return this.disabled ? -1 : this.#tabIndex;
|
697
|
-
}
|
698
|
-
set tabIndex(value) {
|
699
|
-
this.#tabIndex = value != null ? coerceNumberProperty(value) : 0;
|
700
|
-
}
|
701
|
-
_emitOnFocusEvent(e) {
|
702
|
-
this.onFocus.emit({
|
703
|
-
component: this,
|
704
|
-
htmlElement: this._getHostElement(),
|
705
|
-
nativeEvent: e,
|
706
|
-
});
|
707
|
-
}
|
708
|
-
_emitOnBlurEvent(e) {
|
709
|
-
this.onBlur.emit({
|
710
|
-
component: this,
|
711
|
-
htmlElement: this._getHostElement(),
|
712
|
-
nativeEvent: e,
|
713
|
-
});
|
714
|
-
}
|
715
|
-
/**
|
716
|
-
* Focuses the component.
|
717
|
-
*/
|
718
|
-
focus() {
|
719
|
-
const list = ['button', 'input', '[href]', 'select', 'textarea', '[tabindex]'].map((c) => c + ':not([tabindex="-1"])');
|
720
|
-
const focusable = this._getHostElement().querySelector(list.join(', '));
|
721
|
-
if (focusable) {
|
722
|
-
focusable.focus();
|
723
|
-
}
|
724
|
-
}
|
725
|
-
/**
|
726
|
-
* Check component is focused or has any focused element.
|
727
|
-
*/
|
728
|
-
hasFocus() {
|
729
|
-
return this._getHostElement().matches(':focus-within') || this._getHostElement().matches(':focus');
|
730
|
-
}
|
731
|
-
/**
|
732
|
-
* @ignore
|
733
|
-
*/
|
734
|
-
constructor(...args) {
|
735
|
-
super(...args);
|
736
|
-
this.#disabled = false;
|
737
|
-
this.#tabIndex = 0;
|
738
|
-
/**
|
739
|
-
* Fires each time the component gets focused.
|
740
|
-
* @event
|
741
|
-
*/
|
742
|
-
this.onFocus = new EventEmitter();
|
743
|
-
/**
|
744
|
-
* Fires each time the component gets blurred.
|
745
|
-
* @event
|
746
|
-
*/
|
747
|
-
this.onBlur = new EventEmitter();
|
748
|
-
}
|
749
|
-
}
|
750
|
-
return Mixin;
|
751
|
-
}
|
752
|
-
const INTERACTIVE_INPUTS = ['disabled', 'tabIndex'];
|
753
|
-
const INTERACTIVE_OUTPUT = ['onBlur', 'onFocus'];
|
754
|
-
|
755
|
-
function _SelectionComponenetMixin(Base) {
|
756
|
-
return class extends Base {
|
757
|
-
/**
|
758
|
-
* Defines the primary text to show inside the button.
|
759
|
-
*/
|
760
|
-
get items() {
|
761
|
-
return [];
|
762
|
-
}
|
763
|
-
get displayItems() {
|
764
|
-
return [];
|
765
|
-
}
|
766
|
-
get flatItems() {
|
767
|
-
return [];
|
768
|
-
}
|
769
|
-
constructor(...args) {
|
770
|
-
super(...args);
|
771
|
-
this.valueField = 'id';
|
772
|
-
this.textField = 'text';
|
773
|
-
this.disabledField = 'disabled';
|
774
|
-
this.multiple = false;
|
775
|
-
this.selectionMode = 'value';
|
776
|
-
this.valueChange = new EventEmitter();
|
777
|
-
this.onValueChanged = new EventEmitter();
|
778
|
-
}
|
779
|
-
_onInternalInit() {
|
780
|
-
super._onInternalInit();
|
781
|
-
}
|
782
|
-
get value() {
|
783
|
-
return this._value;
|
784
|
-
}
|
785
|
-
set value(v) {
|
786
|
-
v = this._internalSetValue(v);
|
787
|
-
if (v !== this._value) {
|
788
|
-
const oldValue = clone(this._value);
|
789
|
-
if (this.multiple) {
|
790
|
-
this._value = Array.isArray(v) ? v : v ? [v] : [];
|
791
|
-
}
|
792
|
-
else {
|
793
|
-
this._value = Array.isArray(v) ? v[0] : v;
|
794
|
-
}
|
795
|
-
this._renderSelection();
|
796
|
-
this.valueChange.emit(this._value);
|
797
|
-
this.onValueChanged.emit({
|
798
|
-
component: this,
|
799
|
-
htmlElement: this._getHostElement(),
|
800
|
-
isUserInteraction: false,
|
801
|
-
oldValue,
|
802
|
-
value: this._value,
|
803
|
-
selectedKeys: this.selectedItems.map((c) => c[this.valueField]),
|
804
|
-
selectedItems: this.selectedItems.slice(),
|
805
|
-
});
|
806
|
-
if (v == null || v == undefined || v == '') {
|
807
|
-
this._setState('clear');
|
808
|
-
}
|
809
|
-
else {
|
810
|
-
if (this._isInited) {
|
811
|
-
this.validate();
|
812
|
-
}
|
813
|
-
}
|
814
|
-
}
|
815
|
-
}
|
816
|
-
get selectedItems() {
|
817
|
-
return this._selectedItems || [];
|
818
|
-
}
|
819
|
-
_renderSelection() {
|
820
|
-
const func = () => {
|
821
|
-
if (this.value == null || this.value == undefined) {
|
822
|
-
return [];
|
823
|
-
}
|
824
|
-
const items = this.flatItems;
|
825
|
-
if (items.length > 0) {
|
826
|
-
return items.filter((i) => {
|
827
|
-
if (Array.isArray(this.value)) {
|
828
|
-
return this.value.some((ii) => {
|
829
|
-
if (typeof ii === 'object') {
|
830
|
-
return i[this.valueField] === ii[this.valueField];
|
831
|
-
}
|
832
|
-
else {
|
833
|
-
return i[this.valueField] === ii;
|
834
|
-
}
|
835
|
-
});
|
836
|
-
}
|
837
|
-
else {
|
838
|
-
if (typeof this.value === 'object') {
|
839
|
-
return i[this.valueField] === this.value[this.valueField];
|
840
|
-
}
|
841
|
-
else {
|
842
|
-
return i[this.valueField] === this.value;
|
843
|
-
}
|
844
|
-
}
|
845
|
-
});
|
846
|
-
}
|
847
|
-
if (Array.isArray(this.value)) {
|
848
|
-
return this.value.map((ii) => {
|
849
|
-
if (typeof ii === 'object') {
|
850
|
-
return ii;
|
851
|
-
}
|
852
|
-
else {
|
853
|
-
const fake = {};
|
854
|
-
fake[this.valueField] = this.value;
|
855
|
-
fake[this.textField] = this.value;
|
856
|
-
return fake;
|
857
|
-
}
|
858
|
-
});
|
859
|
-
}
|
860
|
-
else {
|
861
|
-
if (typeof this.value === 'object') {
|
862
|
-
return [this.value];
|
863
|
-
}
|
864
|
-
else {
|
865
|
-
const fake = {};
|
866
|
-
fake[this.valueField] = this.value;
|
867
|
-
fake[this.textField] = this.value;
|
868
|
-
return [fake];
|
869
|
-
}
|
870
|
-
}
|
871
|
-
};
|
872
|
-
this._selectedItems = func();
|
873
|
-
}
|
874
|
-
_getItemByDataMode(item) {
|
875
|
-
return this.selectionMode === 'item' ? item : item[this.valueField];
|
876
|
-
}
|
877
|
-
_getItemValue(item) {
|
878
|
-
return typeof item === 'object' ? item[this.valueField] : item;
|
879
|
-
}
|
880
|
-
unselectItems(...items) {
|
881
|
-
if (!items || items.length === 0) {
|
882
|
-
this.value = null;
|
883
|
-
}
|
884
|
-
else if (Array.isArray(this.value)) {
|
885
|
-
this.value = this.value.filter((c) => !items.some((d) => this._getItemValue(c) === this._getItemValue(d)));
|
886
|
-
}
|
887
|
-
else {
|
888
|
-
this.value = null;
|
889
|
-
}
|
890
|
-
}
|
891
|
-
selectItems(...items) {
|
892
|
-
if (items && items.length) {
|
893
|
-
if (this.multiple) {
|
894
|
-
this.value = (this.value || []).concat(items.map((c) => this._getItemByDataMode(c)));
|
895
|
-
}
|
896
|
-
else {
|
897
|
-
this.value = this._getItemByDataMode(items[0]);
|
898
|
-
}
|
899
|
-
}
|
900
|
-
}
|
901
|
-
toggleSelect(...items) {
|
902
|
-
if (items && items.length) {
|
903
|
-
items.forEach((item) => {
|
904
|
-
if (this.multiple) {
|
905
|
-
this.isItemSelected(item) ? this.unselectItems(item) : this.selectItems(item);
|
906
|
-
}
|
907
|
-
else {
|
908
|
-
this.selectItems(item);
|
909
|
-
}
|
910
|
-
});
|
911
|
-
}
|
912
|
-
}
|
913
|
-
isItemSelected(item) {
|
914
|
-
return this.selectedItems.some((c) => c[this.valueField] === item[this.valueField]);
|
915
|
-
}
|
916
|
-
isItemDisabled(item) {
|
917
|
-
return (coerceBooleanProperty(item[this.disabledField]) === true ||
|
918
|
-
(this.disabledCallback ? this.disabledCallback({ item, index: -1 }) : false));
|
919
|
-
}
|
920
|
-
};
|
921
|
-
}
|
922
|
-
const SELECTION_INPUTS = [
|
923
|
-
'valueField',
|
924
|
-
'textField',
|
925
|
-
'disabledField',
|
926
|
-
'disabledCallback',
|
927
|
-
'multiple',
|
928
|
-
'selectionMode',
|
929
|
-
];
|
930
|
-
const SELECTION_OUTPUT = ['onValueChanged', 'valueChanged'];
|
931
|
-
|
932
|
-
function _SizableComponenetMixin(Base) {
|
933
|
-
return class extends Base {
|
934
|
-
/**
|
935
|
-
* @ignore
|
936
|
-
*/
|
937
|
-
constructor(...args) {
|
938
|
-
super(...args.slice(0, 2));
|
939
|
-
}
|
940
|
-
_onInternalInit() {
|
941
|
-
super._onInternalInit();
|
942
|
-
}
|
943
|
-
};
|
944
|
-
}
|
945
|
-
const SIZABLE_INPUTS = ['size'];
|
946
|
-
const SIZABLE_OUTPUT = [];
|
947
|
-
|
948
|
-
function _TextboxComponenetMixin(Base) {
|
949
|
-
return class extends Base {
|
950
|
-
_emitOnKeydownEvent(e) {
|
951
|
-
this.onKeyDown.emit({
|
952
|
-
component: this,
|
953
|
-
nativeEvent: e,
|
954
|
-
});
|
955
|
-
this._setUserInteraction();
|
956
|
-
}
|
957
|
-
_emitOnKeyupEvent(e) {
|
958
|
-
this.onKeyUp.emit({
|
959
|
-
component: this,
|
960
|
-
nativeEvent: e,
|
961
|
-
});
|
962
|
-
this._setUserInteraction();
|
963
|
-
}
|
964
|
-
_emitOnKeypressEvent(e) {
|
965
|
-
this.onKeyPress.emit({
|
966
|
-
component: this,
|
967
|
-
nativeEvent: e,
|
968
|
-
});
|
969
|
-
this._setUserInteraction();
|
970
|
-
}
|
971
|
-
/**
|
972
|
-
* @ignore
|
973
|
-
*/
|
974
|
-
constructor(...args) {
|
975
|
-
super(...args.slice(0, 2));
|
976
|
-
/**
|
977
|
-
* A string value that specifies the type of text box.
|
978
|
-
*/
|
979
|
-
this.type = 'text';
|
980
|
-
/**
|
981
|
-
* A string value that specifies the placeholder of text box.
|
982
|
-
*/
|
983
|
-
this.placeholder = '';
|
984
|
-
/**
|
985
|
-
* Fires each time the user press a key.
|
986
|
-
* @event
|
987
|
-
*/
|
988
|
-
this.onKeyDown = new EventEmitter();
|
989
|
-
/**
|
990
|
-
* Fires each time the user press a key.
|
991
|
-
* @event
|
992
|
-
*/
|
993
|
-
this.onKeyUp = new EventEmitter();
|
994
|
-
/**
|
995
|
-
* Fires each time the user press a key.
|
996
|
-
* @event
|
997
|
-
*/
|
998
|
-
this.onKeyPress = new EventEmitter();
|
999
|
-
}
|
1000
|
-
};
|
1001
|
-
}
|
1002
|
-
const TEXTBOX_INPUTS = [
|
1003
|
-
'placeholder',
|
1004
|
-
'maxLength',
|
1005
|
-
'allowNull',
|
1006
|
-
'type',
|
1007
|
-
'autoComplete',
|
1008
|
-
'readonly',
|
1009
|
-
'value',
|
1010
|
-
'name',
|
1011
|
-
];
|
1012
|
-
const TEXTBOX_OUTPUT = ['valueChange', 'onValueChanged'];
|
1013
|
-
|
1014
|
-
function _ValueComponenetMixin(Base) {
|
1015
|
-
return class extends Base {
|
1016
|
-
#readonly;
|
1017
|
-
/**
|
1018
|
-
* If set to true, user cannot change the value of component.
|
1019
|
-
*/
|
1020
|
-
get readonly() {
|
1021
|
-
return this.#readonly;
|
1022
|
-
}
|
1023
|
-
set readonly(value) {
|
1024
|
-
this.#readonly = coerceBooleanProperty(value);
|
1025
|
-
}
|
1026
|
-
#allowNull;
|
1027
|
-
get allowNull() {
|
1028
|
-
return this.#allowNull;
|
1029
|
-
}
|
1030
|
-
set allowNull(value) {
|
1031
|
-
this.#allowNull = coerceBooleanProperty(value);
|
1032
|
-
}
|
1033
|
-
#name;
|
1034
|
-
get name() {
|
1035
|
-
return this.#name;
|
1036
|
-
}
|
1037
|
-
set name(value) {
|
1038
|
-
this.#name = value;
|
1039
|
-
}
|
1040
|
-
#isUserInteraction;
|
1041
|
-
get isUserInteraction() {
|
1042
|
-
return this.#isUserInteraction;
|
1043
|
-
}
|
1044
|
-
#value;
|
1045
|
-
get value() {
|
1046
|
-
return this._internalGetValue();
|
1047
|
-
}
|
1048
|
-
set value(v) {
|
1049
|
-
v = this._internalSetValue(v);
|
1050
|
-
//if (!this._isInited ) {
|
1051
|
-
const old = clone(this.value);
|
1052
|
-
// TODO: check real equality
|
1053
|
-
if (v != old) {
|
1054
|
-
this.#value = v;
|
1055
|
-
this._emitOnValueChangedEvent(old, this.value);
|
1056
|
-
this._cdr.markForCheck();
|
1057
|
-
if (v == null || v == undefined || v == '' || (Array.isArray(v) && v.length == 0)) {
|
1058
|
-
this._setState('clear');
|
1059
|
-
}
|
1060
|
-
// else {
|
1061
|
-
// if (this._isInited) {
|
1062
|
-
// this.validate();
|
1063
|
-
// }
|
1064
|
-
// }
|
1065
|
-
}
|
1066
|
-
this.#isUserInteraction = false;
|
1067
|
-
//}
|
1068
|
-
}
|
1069
|
-
#state;
|
1070
|
-
get state() {
|
1071
|
-
return this.#state;
|
1072
|
-
}
|
1073
|
-
set state(value) {
|
1074
|
-
this._setState(value);
|
1075
|
-
this.stateChange.emit(value);
|
1076
|
-
}
|
1077
|
-
_emitOnValueChangedEvent(oldValue, newValue) {
|
1078
|
-
this.valueChange.emit(newValue);
|
1079
|
-
this.onValueChanged.emit({
|
1080
|
-
component: this,
|
1081
|
-
value: newValue,
|
1082
|
-
oldValue: oldValue,
|
1083
|
-
name: this.name,
|
1084
|
-
isUserInteraction: this.isUserInteraction,
|
1085
|
-
});
|
1086
|
-
this._onValueChanged(oldValue, this.#value);
|
1087
|
-
this.#isUserInteraction = false;
|
1088
|
-
}
|
1089
|
-
_internalSetValue(value) {
|
1090
|
-
return this._setValue(value);
|
1091
|
-
}
|
1092
|
-
_internalGetValue() {
|
1093
|
-
return this._getValue(this.#value);
|
1094
|
-
}
|
1095
|
-
_setValue(value) {
|
1096
|
-
return value;
|
1097
|
-
}
|
1098
|
-
_getValue(value) {
|
1099
|
-
return value;
|
1100
|
-
}
|
1101
|
-
_setUserInteraction() {
|
1102
|
-
this.#isUserInteraction = true;
|
1103
|
-
}
|
1104
|
-
setUserInteraction() {
|
1105
|
-
this.#isUserInteraction = true;
|
1106
|
-
}
|
1107
|
-
_onValueChanged(oldValue, newValue) { }
|
1108
|
-
_onInternalInit() {
|
1109
|
-
this._getHostElement().setAttribute('ax-form-input', 'true');
|
1110
|
-
super._onInternalInit();
|
1111
|
-
}
|
1112
|
-
_onInternalViewInit() {
|
1113
|
-
this._checkRequired();
|
1114
|
-
super._onInternalViewInit();
|
1115
|
-
}
|
1116
|
-
_onInternalDestroy() {
|
1117
|
-
super.onDestroy();
|
1118
|
-
}
|
1119
|
-
clear() {
|
1120
|
-
this.value = null;
|
1121
|
-
}
|
1122
|
-
_checkRequired() {
|
1123
|
-
const isRequired = Array.from(this._getHostElement().querySelectorAll('ax-validation-rule')).some((c) => c.__axContext__.enabled && c.__axContext__.rule == 'required');
|
1124
|
-
//
|
1125
|
-
if (isRequired) {
|
1126
|
-
const container = this._getHostElement().classList.contains('ax-editor-container')
|
1127
|
-
? this._getHostElement()
|
1128
|
-
: this._getHostElement().querySelector('.ax-editor-container');
|
1129
|
-
const formField = container?.closest('.ax-form-field');
|
1130
|
-
const label = formField?.querySelector('ax-label')?.__axContext__;
|
1131
|
-
if (label)
|
1132
|
-
label.required = true;
|
1133
|
-
}
|
1134
|
-
}
|
1135
|
-
validate() {
|
1136
|
-
const rules = Array.from(this._getHostElement().querySelectorAll('ax-validation-rule')).filter((c) => c.__axContext__.enabled);
|
1137
|
-
//
|
1138
|
-
if (!rules || rules.length === 0) {
|
1139
|
-
this._setState('clear');
|
1140
|
-
return Promise.resolve({
|
1141
|
-
result: true,
|
1142
|
-
value: this.value,
|
1143
|
-
name: this.name,
|
1144
|
-
id: this.id,
|
1145
|
-
});
|
1146
|
-
}
|
1147
|
-
return new Promise((resolve) => {
|
1148
|
-
Promise.all(rules
|
1149
|
-
.filter((c) => typeof c?.validate === 'function')
|
1150
|
-
.map((c) => {
|
1151
|
-
return c.validate(this.value);
|
1152
|
-
})).then((d) => {
|
1153
|
-
const error = d.find((c) => c.result === false);
|
1154
|
-
if (error) {
|
1155
|
-
this._setState('error', error.message);
|
1156
|
-
resolve({
|
1157
|
-
result: false,
|
1158
|
-
value: this.value,
|
1159
|
-
message: error.message,
|
1160
|
-
name: this.name,
|
1161
|
-
id: this.id,
|
1162
|
-
});
|
1163
|
-
}
|
1164
|
-
else {
|
1165
|
-
this._setState('success');
|
1166
|
-
resolve({
|
1167
|
-
result: true,
|
1168
|
-
value: this.value,
|
1169
|
-
name: this.name,
|
1170
|
-
id: this.id,
|
1171
|
-
});
|
1172
|
-
}
|
1173
|
-
});
|
1174
|
-
});
|
1175
|
-
}
|
1176
|
-
/**
|
1177
|
-
* @ignore
|
1178
|
-
*/
|
1179
|
-
constructor(...args) {
|
1180
|
-
super(...args);
|
1181
|
-
/**
|
1182
|
-
* Fires each time the user press a key.
|
1183
|
-
* @event
|
1184
|
-
*/
|
1185
|
-
this.onValueChanged = new EventEmitter();
|
1186
|
-
this.valueChange = new EventEmitter();
|
1187
|
-
this.stateChange = new EventEmitter();
|
1188
|
-
this.#readonly = false;
|
1189
|
-
this.#allowNull = true;
|
1190
|
-
this.#isUserInteraction = false;
|
1191
|
-
this.#state = 'clear';
|
1192
|
-
}
|
1193
|
-
_setState(state, ...args) {
|
1194
|
-
const container = this._getHostElement().classList.contains('ax-editor-container')
|
1195
|
-
? this._getHostElement()
|
1196
|
-
: this._getHostElement().querySelector('.ax-editor-container');
|
1197
|
-
const formField = container?.closest('.ax-form-field');
|
1198
|
-
const label = formField?.querySelector('ax-label') || formField?.querySelector('label');
|
1199
|
-
let target = container || this._getInnerElement();
|
1200
|
-
if (target?.querySelector('.ax-error-container')) {
|
1201
|
-
target = target.querySelector('.ax-error-container');
|
1202
|
-
}
|
1203
|
-
const parent = target?.parentElement;
|
1204
|
-
if (!target || !parent)
|
1205
|
-
return;
|
1206
|
-
switch (state) {
|
1207
|
-
case 'clear':
|
1208
|
-
this.#state = 'clear';
|
1209
|
-
if (parent.querySelector('span.ax-error-message')) {
|
1210
|
-
parent.removeChild(parent.querySelector('span.ax-error-message'));
|
1211
|
-
}
|
1212
|
-
label?.classList.remove('ax-state-error');
|
1213
|
-
target.classList.remove('ax-state-error', 'ax-state-success');
|
1214
|
-
break;
|
1215
|
-
case 'success':
|
1216
|
-
this._setState('clear');
|
1217
|
-
target.classList.add('ax-state-success');
|
1218
|
-
this.#state = 'success';
|
1219
|
-
break;
|
1220
|
-
case 'error':
|
1221
|
-
this._setState('clear');
|
1222
|
-
if (args[0]) {
|
1223
|
-
const span = document.createElement('span');
|
1224
|
-
span.innerText = args[0];
|
1225
|
-
span.classList.add('ax-error-message');
|
1226
|
-
parent.appendChild(span);
|
1227
|
-
}
|
1228
|
-
label?.classList.add('ax-state-error');
|
1229
|
-
target.classList.add('ax-state-error');
|
1230
|
-
this.#state = 'error';
|
1231
|
-
break;
|
1232
|
-
}
|
1233
|
-
this._cdr.markForCheck();
|
1234
|
-
}
|
1235
|
-
};
|
1236
|
-
}
|
1237
|
-
|
1238
|
-
const AXBaseComponentMixin = _BaseComponenetMixin(AXBaseComponent);
|
1239
|
-
const AXSizableComponentMixin = _SizableComponenetMixin(_BaseComponenetMixin(AXBaseComponent));
|
1240
|
-
const AXInteractiveComponenetMixin = _SizableComponenetMixin(_InteractiveComponenetMixin(AXBaseComponent));
|
1241
|
-
const AXBaseClickableMixin = _InteractiveComponenetMixin(_ClickableComponenetMixin(AXBaseComponent));
|
1242
|
-
const AXBaseButtonMixin = _SizableComponenetMixin(_InteractiveComponenetMixin(_ClickableComponenetMixin(_ColorLookComponentMixin(_ButtonComponentMixin(AXBaseComponent)))));
|
1243
|
-
const AXBaseValueComponentMixin = _InteractiveComponenetMixin(_ValueComponenetMixin(AXBaseComponent));
|
1244
|
-
const AXBaseTextBoxMixin = _SizableComponenetMixin(_InteractiveComponenetMixin(_ValueComponenetMixin(_TextboxComponenetMixin(AXBaseComponent))));
|
1245
|
-
const AXBaseSelectionValueMixin = _SizableComponenetMixin(_InteractiveComponenetMixin(_DatalistComponenetMixin(_SelectionComponenetMixin(_ValueComponenetMixin(AXBaseComponent)))));
|
1246
|
-
const AXBaseValueDropdownMixin = _InteractiveComponenetMixin(_DropdownComponenetMixin(_DatalistComponenetMixin(_ValueComponenetMixin(AXBaseComponent))));
|
1247
|
-
const AXBaseSelectionDropdownMixin = _DropdownComponenetMixin(AXBaseSelectionValueMixin);
|
1248
|
-
const AXBaseDropdownMixin = _SizableComponenetMixin(_InteractiveComponenetMixin(_DropdownComponenetMixin(AXBaseComponent)));
|
1249
|
-
const AXBaseMenuMixin = _BaseMenuComponentMixin(AXBaseComponent);
|
1250
|
-
const AXAvatarMixin = _ColorLookComponentMixin(AXBaseComponent);
|
1251
|
-
|
1252
|
-
function _PageComponenetMixin(Base) {
|
1253
|
-
return class extends Base {
|
1254
|
-
/**
|
1255
|
-
* @ignore
|
1256
|
-
*/
|
1257
|
-
constructor(...args) {
|
1258
|
-
super(...args.slice(0, 2));
|
1259
|
-
}
|
1260
|
-
};
|
1261
|
-
}
|
1262
|
-
|
1263
|
-
/**
|
1264
|
-
* Generated bundle index. Do not edit.
|
1265
|
-
*/
|
1266
|
-
|
1267
|
-
export { AXAvatarMixin, AXBaseButtonMixin, AXBaseClickableMixin, AXBaseComponent, AXBaseComponentMixin, AXBaseDropdownMixin, AXBaseMenuMixin, AXBaseSelectionDropdownMixin, AXBaseSelectionValueMixin, AXBaseTextBoxMixin, AXBaseValueComponentMixin, AXBaseValueDropdownMixin, AXInteractiveComponenetMixin, AXPaginatedDataSource, AXSizableComponentMixin, BASEMENU_INPUTS, BASEMENU_OUTPUT, BASE_INPUTS, BASE_OUTPUT, BUTTON_INPUTS, BUTTON_OUTPUT, DATALIST_INPUTS, DATALIST_OUTPUT, DROPDOWN_INPUTS, DROPDOWN_OUTPUT, INTERACTIVE_INPUTS, INTERACTIVE_OUTPUT, SELECTION_INPUTS, SELECTION_OUTPUT, SIZABLE_INPUTS, SIZABLE_OUTPUT, TEXTBOX_INPUTS, TEXTBOX_OUTPUT, _BaseComponenetMixin, _BaseMenuComponentMixin, _ButtonComponentMixin, _ClickableComponenetMixin, _ColorLookComponentMixin, _DatalistComponenetMixin, _DropdownComponenetMixin, _InteractiveComponenetMixin, _PageComponenetMixin, _SelectionComponenetMixin, _SizableComponenetMixin, _TextboxComponenetMixin, _ValueComponenetMixin, indicate, prepare };
|
1268
|
-
//# sourceMappingURL=acorex-components-mixin.mjs.map
|