@jooler/inputs 0.0.51 → 0.0.52
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/lib/ag-grid-select-mixin.mjs +73 -0
- package/esm2022/lib/choose-enum/choose-enum.component.mjs +57 -42
- package/esm2022/lib/choose-enum-renderer/choose-enum-renderer.component.mjs +35 -21
- package/esm2022/lib/enum-helper.model.mjs +14 -0
- package/fesm2022/inputs.mjs +153 -214
- package/fesm2022/inputs.mjs.map +1 -1
- package/lib/ag-grid-select-mixin.d.ts +22 -0
- package/lib/choose-enum/choose-enum.component.d.ts +12 -7
- package/lib/choose-enum-renderer/choose-enum-renderer.component.d.ts +7 -9
- package/lib/enum-helper.model.d.ts +8 -0
- package/package.json +1 -1
- package/esm2022/lib/custom-theme.mjs +0 -104
- package/esm2022/lib/models/enum-helper-functions.mjs +0 -57
- package/esm2022/lib/models/enum-helper.model.mjs +0 -2
- package/lib/custom-theme.d.ts +0 -8
- package/lib/models/enum-helper-functions.d.ts +0 -5
- package/lib/models/enum-helper.model.d.ts +0 -6
package/fesm2022/inputs.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { EventEmitter, forwardRef, Component, Input, Output, Injectable, Inject, Pipe, Directive, HostListener, NgModule } from '@angular/core';
|
|
3
3
|
import * as i2$1 from '@angular/forms';
|
|
4
4
|
import { NG_VALUE_ACCESSOR, NgModel, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
import * as i4 from '@jooler/shared-general-components';
|
|
6
|
+
import { EnumHelperBaseClass, SharedGeneralComponentsModule } from '@jooler/shared-general-components';
|
|
5
7
|
import * as i1 from '@angular/common';
|
|
6
8
|
import { CurrencyPipe, DecimalPipe, CommonModule } from '@angular/common';
|
|
7
9
|
import * as i2 from '@ng-select/ng-select';
|
|
8
10
|
import { NgSelectModule } from '@ng-select/ng-select';
|
|
9
|
-
import * as i4 from '@jooler/shared-general-components';
|
|
10
|
-
import { SharedGeneralComponentsModule } from '@jooler/shared-general-components';
|
|
11
11
|
import * as i2$2 from '@fortawesome/angular-fontawesome';
|
|
12
12
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
|
13
13
|
import * as i1$1 from '@angular/common/http';
|
|
@@ -17,166 +17,6 @@ import { AppMaterialModule } from '@jooler/app-material';
|
|
|
17
17
|
import * as i1$2 from '@angular/router';
|
|
18
18
|
import * as i3$1 from '@angular/material/menu';
|
|
19
19
|
|
|
20
|
-
class CustomTheme {
|
|
21
|
-
static $joolerBlue = [
|
|
22
|
-
'#e3ecfa',
|
|
23
|
-
'#b9cff2',
|
|
24
|
-
'#8aafea',
|
|
25
|
-
'#5b8ee1',
|
|
26
|
-
'#3876da',
|
|
27
|
-
'#155ed4',
|
|
28
|
-
'#1256cf',
|
|
29
|
-
'#0f4cc9',
|
|
30
|
-
'#0c42c3',
|
|
31
|
-
'#0631b9',
|
|
32
|
-
'#e3e8ff',
|
|
33
|
-
'#b0bfff',
|
|
34
|
-
'#7d95ff',
|
|
35
|
-
'#6481ff',
|
|
36
|
-
];
|
|
37
|
-
static $joolerTeal = [
|
|
38
|
-
'#b8dfd8',
|
|
39
|
-
'#89cabf',
|
|
40
|
-
'#59b5a5',
|
|
41
|
-
'#36a591',
|
|
42
|
-
'#12957e',
|
|
43
|
-
'#108d76',
|
|
44
|
-
'#0d826b',
|
|
45
|
-
'#0a7861',
|
|
46
|
-
'#05674e',
|
|
47
|
-
'#97ffe1',
|
|
48
|
-
'#64ffd2',
|
|
49
|
-
'#31ffc3',
|
|
50
|
-
'#18ffbc',
|
|
51
|
-
];
|
|
52
|
-
static $joolerRed = [
|
|
53
|
-
'#f5e0e1',
|
|
54
|
-
'#e5b3b3',
|
|
55
|
-
'#d48081',
|
|
56
|
-
'#c24d4e',
|
|
57
|
-
'#b52628',
|
|
58
|
-
'#a80002',
|
|
59
|
-
'#a00002',
|
|
60
|
-
'#970001',
|
|
61
|
-
'#8d0001',
|
|
62
|
-
'#7d0001',
|
|
63
|
-
'#ffaaaa',
|
|
64
|
-
'#ff7777',
|
|
65
|
-
'#ff4444',
|
|
66
|
-
'#ff2a2a',
|
|
67
|
-
];
|
|
68
|
-
static $joolerPink = [
|
|
69
|
-
'#fdeaf3',
|
|
70
|
-
'#fbcbe1',
|
|
71
|
-
'#f8a8ce',
|
|
72
|
-
'#f585ba',
|
|
73
|
-
'#f26aab',
|
|
74
|
-
'#f0509c',
|
|
75
|
-
'#ee4994',
|
|
76
|
-
'#ec408a',
|
|
77
|
-
'#e93780',
|
|
78
|
-
'#e5276e',
|
|
79
|
-
'#ffffff',
|
|
80
|
-
'#ffeef4',
|
|
81
|
-
'#ffbbd3',
|
|
82
|
-
'#ffa1c2',
|
|
83
|
-
];
|
|
84
|
-
static $joolerPurple = [
|
|
85
|
-
'#fcf6fd',
|
|
86
|
-
'#f7e8f9',
|
|
87
|
-
'#f1d8f5',
|
|
88
|
-
'#ebc8f1',
|
|
89
|
-
'#e7bdee',
|
|
90
|
-
'#e3b1eb',
|
|
91
|
-
'#e0aae9',
|
|
92
|
-
'#dca1e5',
|
|
93
|
-
'#d898e2',
|
|
94
|
-
'#d088dd',
|
|
95
|
-
'#ffffff',
|
|
96
|
-
'#ffffff',
|
|
97
|
-
'#ffffff',
|
|
98
|
-
'#fcecff',
|
|
99
|
-
];
|
|
100
|
-
static $joolerCombo = [
|
|
101
|
-
'#b9cff2',
|
|
102
|
-
'#b8dfd8',
|
|
103
|
-
'#ffaaaa',
|
|
104
|
-
'#fbcbe1',
|
|
105
|
-
'#f1d8f5',
|
|
106
|
-
'#8aafea',
|
|
107
|
-
'#97ffe1',
|
|
108
|
-
'#ff7777',
|
|
109
|
-
'#f585ba',
|
|
110
|
-
'#e7bdee',
|
|
111
|
-
'#6481ff',
|
|
112
|
-
'#18ffbc',
|
|
113
|
-
'#ff4444',
|
|
114
|
-
'#ffa1c2',
|
|
115
|
-
'#e0aae9',
|
|
116
|
-
'#1256cf',
|
|
117
|
-
'#108d76',
|
|
118
|
-
'#df0000',
|
|
119
|
-
'#ec408a',
|
|
120
|
-
'#d088dd',
|
|
121
|
-
];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
class EnumHelperBaseClass {
|
|
125
|
-
static getEnumOptionsFromEnumClass(enumClass, customColors, isAllCaps) {
|
|
126
|
-
let colors = CustomTheme.$joolerCombo;
|
|
127
|
-
if (customColors && customColors.length > 0) {
|
|
128
|
-
colors = customColors;
|
|
129
|
-
}
|
|
130
|
-
let stringValues = [];
|
|
131
|
-
let enumOption;
|
|
132
|
-
let enumOptions = [];
|
|
133
|
-
for (let item in enumClass) {
|
|
134
|
-
if (isNaN(Number(item))) {
|
|
135
|
-
let joinedString;
|
|
136
|
-
stringValues.push(item);
|
|
137
|
-
let splitStr = item.toLowerCase().split('_');
|
|
138
|
-
if (!isAllCaps) {
|
|
139
|
-
for (let i = 0; i < splitStr.length; i++) {
|
|
140
|
-
splitStr[i] =
|
|
141
|
-
splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
for (let i = 0; i < splitStr.length; i++) {
|
|
146
|
-
splitStr[i] = splitStr[i].toUpperCase();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
joinedString = splitStr.join(' ');
|
|
150
|
-
stringValues.splice(stringValues.indexOf(item), 1, joinedString);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
let repeatedColors = [];
|
|
154
|
-
let i = 0;
|
|
155
|
-
for (let label of stringValues) {
|
|
156
|
-
// in case the array of colors is smaller than the stringValues array, we repeat the the colors so that they are enough
|
|
157
|
-
repeatedColors.push(colors[stringValues.indexOf(label) % colors.length]);
|
|
158
|
-
enumOption = {
|
|
159
|
-
value: Object.keys(enumClass).map(Number)[i],
|
|
160
|
-
label: label,
|
|
161
|
-
color: repeatedColors[i],
|
|
162
|
-
};
|
|
163
|
-
enumOptions.push(enumOption);
|
|
164
|
-
i++;
|
|
165
|
-
}
|
|
166
|
-
return enumOptions;
|
|
167
|
-
}
|
|
168
|
-
static getLabelAndColorFromEnumValue(enumClass, enumValue, customColors) {
|
|
169
|
-
let enumOptions = EnumHelperBaseClass.getEnumOptionsFromEnumClass(enumClass, customColors);
|
|
170
|
-
let enumOption;
|
|
171
|
-
for (let item of enumOptions) {
|
|
172
|
-
if (enumValue == item.value) {
|
|
173
|
-
enumOption = enumOptions[enumOptions.indexOf(item)];
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return enumOption;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
20
|
class ChooseEnumComponent {
|
|
181
21
|
items;
|
|
182
22
|
appendTo = 'body';
|
|
@@ -184,13 +24,11 @@ class ChooseEnumComponent {
|
|
|
184
24
|
clearable = true;
|
|
185
25
|
customColors;
|
|
186
26
|
enumChoices;
|
|
187
|
-
virtualScroll = false;
|
|
188
27
|
getValuesArrayFromEnum = EnumHelperBaseClass.getEnumOptionsFromEnumClass;
|
|
189
|
-
|
|
28
|
+
valuesToDisable = [];
|
|
29
|
+
valuesToHide = [];
|
|
190
30
|
isChip = true;
|
|
191
31
|
isDropdownDisabled = false;
|
|
192
|
-
isItemHidden;
|
|
193
|
-
isItemDisabled;
|
|
194
32
|
isMultiple;
|
|
195
33
|
label = 'label';
|
|
196
34
|
labelTextAlign = 'left';
|
|
@@ -201,49 +39,63 @@ class ChooseEnumComponent {
|
|
|
201
39
|
percentWidth = false;
|
|
202
40
|
selectedItem;
|
|
203
41
|
width;
|
|
42
|
+
isReadOnly = false;
|
|
43
|
+
virtualScroll = false;
|
|
204
44
|
change = new EventEmitter();
|
|
205
45
|
close = new EventEmitter();
|
|
206
46
|
constructor() { }
|
|
207
|
-
|
|
47
|
+
ngOnInit() {
|
|
208
48
|
if (this.getValuesArrayFromEnum != null) {
|
|
209
49
|
this.items = this.getValuesArrayFromEnum(this.enumChoices, this.customColors, this.allowAllCapsValues);
|
|
210
50
|
}
|
|
211
|
-
if (this.
|
|
212
|
-
|
|
213
|
-
for (let index of this.indexesToDisable) {
|
|
214
|
-
this.items[index].disabled = true;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
51
|
+
if (this.valuesToDisable.length > 0) {
|
|
52
|
+
this.disabledItems();
|
|
217
53
|
}
|
|
218
|
-
if (this.
|
|
219
|
-
|
|
220
|
-
for (let index of this.indexesToDisable) {
|
|
221
|
-
let itemIndex = this.items.findIndex((item) => item.value == index);
|
|
222
|
-
this.items.splice(itemIndex, 1);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
54
|
+
if (this.valuesToHide.length > 0) {
|
|
55
|
+
this.hideItems();
|
|
225
56
|
}
|
|
57
|
+
this.sortAndReorderItems();
|
|
226
58
|
}
|
|
227
|
-
|
|
59
|
+
ngOnChanges() {
|
|
228
60
|
if (this.getValuesArrayFromEnum != null) {
|
|
229
61
|
this.items = this.getValuesArrayFromEnum(this.enumChoices, this.customColors, this.allowAllCapsValues);
|
|
230
62
|
}
|
|
231
|
-
if (this.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
63
|
+
if (this.valuesToDisable.length > 0) {
|
|
64
|
+
this.disabledItems();
|
|
65
|
+
}
|
|
66
|
+
if (this.valuesToHide.length > 0) {
|
|
67
|
+
this.hideItems();
|
|
68
|
+
}
|
|
69
|
+
this.sortAndReorderItems();
|
|
70
|
+
}
|
|
71
|
+
disabledItems() {
|
|
72
|
+
for (let value of this.valuesToDisable) {
|
|
73
|
+
let index = this.items.findIndex(enumOption => enumOption.value == value);
|
|
74
|
+
if (index >= 0) {
|
|
75
|
+
this.items[index].disabled = true;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw Error('Index was not found for an enum element in the valuesToDisable array provided.');
|
|
236
79
|
}
|
|
237
80
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
81
|
+
}
|
|
82
|
+
hideItems() {
|
|
83
|
+
for (let value of this.valuesToHide) {
|
|
84
|
+
let index = this.items.findIndex(enumOption => enumOption.value == value);
|
|
85
|
+
if (index >= 0) {
|
|
86
|
+
this.items.splice(index, 1);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw Error('Index was not found for an enum element in the valuesToHide array provided.');
|
|
244
90
|
}
|
|
245
91
|
}
|
|
246
92
|
}
|
|
93
|
+
sortAndReorderItems() {
|
|
94
|
+
const nonDisabledItems = this.items.filter(item => !item.disabled);
|
|
95
|
+
const disabledItems = this.items.filter(item => item.disabled);
|
|
96
|
+
nonDisabledItems.sort((a, b) => a.label.localeCompare(b.label));
|
|
97
|
+
this.items = [...nonDisabledItems, ...disabledItems];
|
|
98
|
+
}
|
|
247
99
|
writeValue(type) {
|
|
248
100
|
if (type != undefined) {
|
|
249
101
|
this.selectedItem = type;
|
|
@@ -265,6 +117,7 @@ class ChooseEnumComponent {
|
|
|
265
117
|
this.close.emit();
|
|
266
118
|
}
|
|
267
119
|
onSelectedItemChanged() {
|
|
120
|
+
this.propogateTouch();
|
|
268
121
|
this.propagateChange(this.selectedItem);
|
|
269
122
|
this.change.emit(this.selectedItem);
|
|
270
123
|
}
|
|
@@ -273,6 +126,7 @@ class ChooseEnumComponent {
|
|
|
273
126
|
}
|
|
274
127
|
clear() {
|
|
275
128
|
this.selectedItem = null;
|
|
129
|
+
this.propogateTouch();
|
|
276
130
|
}
|
|
277
131
|
setStyles() {
|
|
278
132
|
let style = {
|
|
@@ -288,17 +142,18 @@ class ChooseEnumComponent {
|
|
|
288
142
|
textAlign: this.labelTextAlign,
|
|
289
143
|
fontWeight: this.labelTextFontWeight,
|
|
290
144
|
fontSize: this.labelTextFontSize + 'rem',
|
|
145
|
+
padding: '0.4rem',
|
|
291
146
|
};
|
|
292
147
|
return style;
|
|
293
148
|
}
|
|
294
149
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChooseEnumComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
295
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ChooseEnumComponent, selector: "choose-enum", inputs: { appendTo: "appendTo", allowAllCapsValues: "allowAllCapsValues", clearable: "clearable", customColors: "customColors", enumChoices: "enumChoices",
|
|
150
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ChooseEnumComponent, selector: "choose-enum", inputs: { appendTo: "appendTo", allowAllCapsValues: "allowAllCapsValues", clearable: "clearable", customColors: "customColors", enumChoices: "enumChoices", getValuesArrayFromEnum: "getValuesArrayFromEnum", valuesToDisable: "valuesToDisable", valuesToHide: "valuesToHide", isChip: "isChip", isDropdownDisabled: "isDropdownDisabled", isMultiple: "isMultiple", label: "label", labelTextAlign: "labelTextAlign", labelTextFontWeight: "labelTextFontWeight", labelTextFontSize: "labelTextFontSize", paddingTop: "paddingTop", placeholder: "placeholder", percentWidth: "percentWidth", selectedItem: "selectedItem", width: "width", isReadOnly: "isReadOnly", virtualScroll: "virtualScroll" }, outputs: { change: "change", close: "close" }, providers: [
|
|
296
151
|
{
|
|
297
152
|
provide: NG_VALUE_ACCESSOR,
|
|
298
153
|
useExisting: forwardRef(() => ChooseEnumComponent),
|
|
299
154
|
multi: true,
|
|
300
155
|
},
|
|
301
|
-
], usesOnChanges: true, ngImport: i0, template: "<div
|
|
156
|
+
], usesOnChanges: true, ngImport: i0, template: "<div>\r\n <ng-select [ngStyle]=\"setStyles()\" (blur)=\"updateBlur()\" bindLabel=\"label\" bindValue=\"value\" [items]=\"items\"\r\n [virtualScroll]=\"virtualScroll\" [placeholder]=\"placeholder\" (change)=\"onSelectedItemChanged()\"\r\n [(ngModel)]=\"selectedItem\" [multiple]=\"isMultiple\" [disabled]=\"isDropdownDisabled\" [readonly]=\"isReadOnly\"\r\n [clearable]=\"clearable\" (clear)=\"clear()\" [appendTo]=\"appendTo\" dropdownPosition=\"bottom\">\r\n <ng-template ng-label-tmp let-item=\"item\" let-clear=\"clear\">\r\n <ng-container *ngIf=\"isChip\">\r\n <ng-container [ngTemplateOutlet]=\"chip\"\r\n [ngTemplateOutletContext]=\"{ item: item, showCross: clearable, clear: clear }\">\r\n </ng-container>\r\n </ng-container>\r\n <div [ngStyle]=\"setLabelStyle()\" *ngIf=\"!isChip\">{{ item.label }}</div>\r\n </ng-template>\r\n <ng-template ng-option-tmp let-item=\"item\" let-index=\"index\" let-search=\"searchTerm\" let-clear=\"clear\">\r\n <div [ngClass]=\"{ disabled: item.disabled }\">\r\n <div *ngIf=\"isChip\" class=\"chip\">\r\n <ng-container [ngTemplateOutlet]=\"chip\"\r\n [ngTemplateOutletContext]=\"{ item: item, showCross: false, clear: clear }\">\r\n </ng-container>\r\n </div>\r\n <div [ngStyle]=\"setLabelStyle()\" *ngIf=\"!isChip\">{{ item.label }}</div>\r\n </div>\r\n </ng-template>\r\n </ng-select>\r\n</div>\r\n\r\n<ng-template #chip let-showCross=\"showCross\" let-item=\"item\" let-clear=\"clear\">\r\n <ng-chip [enumClass]=\"enumChoices\" [withCross]=\"showCross\" [enumValue]=\"item.value\" [customColors]=\"customColors\"\r\n [item]=\"item\" [clear]=\"clear\">\r\n </ng-chip>\r\n</ng-template>", styles: [".disabled{cursor:not-allowed}.disabled .chip{filter:opacity(.3)}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i2.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "deselectOnClick"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }, { kind: "directive", type: i2.NgOptionTemplateDirective, selector: "[ng-option-tmp]" }, { kind: "directive", type: i2.NgLabelTemplateDirective, selector: "[ng-label-tmp]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i4.NgChipComponent, selector: "ng-chip", inputs: ["backgroundColor", "size", "clear", "customColors", "enumClass", "enumValue", "inputType", "item", "isClickable", "label", "width", "withCross"] }] });
|
|
302
157
|
}
|
|
303
158
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChooseEnumComponent, decorators: [{
|
|
304
159
|
type: Component,
|
|
@@ -308,7 +163,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
308
163
|
useExisting: forwardRef(() => ChooseEnumComponent),
|
|
309
164
|
multi: true,
|
|
310
165
|
},
|
|
311
|
-
], template: "<div
|
|
166
|
+
], template: "<div>\r\n <ng-select [ngStyle]=\"setStyles()\" (blur)=\"updateBlur()\" bindLabel=\"label\" bindValue=\"value\" [items]=\"items\"\r\n [virtualScroll]=\"virtualScroll\" [placeholder]=\"placeholder\" (change)=\"onSelectedItemChanged()\"\r\n [(ngModel)]=\"selectedItem\" [multiple]=\"isMultiple\" [disabled]=\"isDropdownDisabled\" [readonly]=\"isReadOnly\"\r\n [clearable]=\"clearable\" (clear)=\"clear()\" [appendTo]=\"appendTo\" dropdownPosition=\"bottom\">\r\n <ng-template ng-label-tmp let-item=\"item\" let-clear=\"clear\">\r\n <ng-container *ngIf=\"isChip\">\r\n <ng-container [ngTemplateOutlet]=\"chip\"\r\n [ngTemplateOutletContext]=\"{ item: item, showCross: clearable, clear: clear }\">\r\n </ng-container>\r\n </ng-container>\r\n <div [ngStyle]=\"setLabelStyle()\" *ngIf=\"!isChip\">{{ item.label }}</div>\r\n </ng-template>\r\n <ng-template ng-option-tmp let-item=\"item\" let-index=\"index\" let-search=\"searchTerm\" let-clear=\"clear\">\r\n <div [ngClass]=\"{ disabled: item.disabled }\">\r\n <div *ngIf=\"isChip\" class=\"chip\">\r\n <ng-container [ngTemplateOutlet]=\"chip\"\r\n [ngTemplateOutletContext]=\"{ item: item, showCross: false, clear: clear }\">\r\n </ng-container>\r\n </div>\r\n <div [ngStyle]=\"setLabelStyle()\" *ngIf=\"!isChip\">{{ item.label }}</div>\r\n </div>\r\n </ng-template>\r\n </ng-select>\r\n</div>\r\n\r\n<ng-template #chip let-showCross=\"showCross\" let-item=\"item\" let-clear=\"clear\">\r\n <ng-chip [enumClass]=\"enumChoices\" [withCross]=\"showCross\" [enumValue]=\"item.value\" [customColors]=\"customColors\"\r\n [item]=\"item\" [clear]=\"clear\">\r\n </ng-chip>\r\n</ng-template>", styles: [".disabled{cursor:not-allowed}.disabled .chip{filter:opacity(.3)}\n"] }]
|
|
312
167
|
}], ctorParameters: function () { return []; }, propDecorators: { appendTo: [{
|
|
313
168
|
type: Input
|
|
314
169
|
}], allowAllCapsValues: [{
|
|
@@ -319,20 +174,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
319
174
|
type: Input
|
|
320
175
|
}], enumChoices: [{
|
|
321
176
|
type: Input
|
|
322
|
-
}], virtualScroll: [{
|
|
323
|
-
type: Input
|
|
324
177
|
}], getValuesArrayFromEnum: [{
|
|
325
178
|
type: Input
|
|
326
|
-
}],
|
|
179
|
+
}], valuesToDisable: [{
|
|
180
|
+
type: Input
|
|
181
|
+
}], valuesToHide: [{
|
|
327
182
|
type: Input
|
|
328
183
|
}], isChip: [{
|
|
329
184
|
type: Input
|
|
330
185
|
}], isDropdownDisabled: [{
|
|
331
186
|
type: Input
|
|
332
|
-
}], isItemHidden: [{
|
|
333
|
-
type: Input
|
|
334
|
-
}], isItemDisabled: [{
|
|
335
|
-
type: Input
|
|
336
187
|
}], isMultiple: [{
|
|
337
188
|
type: Input
|
|
338
189
|
}], label: [{
|
|
@@ -353,6 +204,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
353
204
|
type: Input
|
|
354
205
|
}], width: [{
|
|
355
206
|
type: Input
|
|
207
|
+
}], isReadOnly: [{
|
|
208
|
+
type: Input
|
|
209
|
+
}], virtualScroll: [{
|
|
210
|
+
type: Input
|
|
356
211
|
}], change: [{
|
|
357
212
|
type: Output
|
|
358
213
|
}], close: [{
|
|
@@ -380,32 +235,116 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
380
235
|
type: Input
|
|
381
236
|
}] } });
|
|
382
237
|
|
|
383
|
-
class
|
|
238
|
+
class AgGridSelectMixin {
|
|
384
239
|
params;
|
|
385
|
-
formControlValue;
|
|
386
240
|
key;
|
|
387
|
-
|
|
241
|
+
value;
|
|
388
242
|
rowId;
|
|
389
|
-
|
|
243
|
+
isEdit;
|
|
244
|
+
index;
|
|
245
|
+
arrayKey = 'entries';
|
|
246
|
+
rowLevelFG;
|
|
247
|
+
width;
|
|
248
|
+
selectedItemId;
|
|
390
249
|
agInit(params) {
|
|
250
|
+
this.initializeRenderer(params);
|
|
251
|
+
}
|
|
252
|
+
initializeRenderer(params) {
|
|
391
253
|
this.params = params;
|
|
392
|
-
this.
|
|
254
|
+
this.width = params.width;
|
|
393
255
|
this.key = params.context.createKey(params.columnApi, params.column);
|
|
256
|
+
this.value = params.value;
|
|
257
|
+
this.rowId = params.node.id;
|
|
258
|
+
this.index = params.node.rowIndex;
|
|
259
|
+
if (params.context.arrayKey) {
|
|
260
|
+
this.arrayKey = params.context.arrayKey;
|
|
261
|
+
}
|
|
262
|
+
this.setRowLevelFG();
|
|
263
|
+
}
|
|
264
|
+
setRowLevelFG() {
|
|
265
|
+
this.index = this.params.node.rowIndex;
|
|
266
|
+
let tableFG = this.params.context.formGroup;
|
|
267
|
+
let fa = tableFG.get(this.arrayKey);
|
|
268
|
+
let rowLevelFG = fa.at(this.index);
|
|
269
|
+
this.rowLevelFG = rowLevelFG;
|
|
270
|
+
}
|
|
271
|
+
getFormControl() {
|
|
272
|
+
let fc = this.rowLevelFG.get(this.key);
|
|
273
|
+
return fc;
|
|
274
|
+
}
|
|
275
|
+
updateValue(params, value) {
|
|
276
|
+
this.setRowLevelFG();
|
|
277
|
+
this.getFormControl().setValue(value);
|
|
278
|
+
let rowNode = params.node;
|
|
279
|
+
rowNode.setDataValue(this.key, value);
|
|
280
|
+
}
|
|
281
|
+
// $event here is an object.
|
|
282
|
+
onSelection($event) {
|
|
283
|
+
this.selectedItemId = $event?.id;
|
|
284
|
+
this.updateValue(this.params, $event?.id);
|
|
285
|
+
if (this.params.onSelection instanceof Function) {
|
|
286
|
+
const params = {
|
|
287
|
+
object: $event,
|
|
288
|
+
rowData: this.params.node.data,
|
|
289
|
+
value: $event.id,
|
|
290
|
+
rowNode: this.params.node,
|
|
291
|
+
};
|
|
292
|
+
this.params.onSelection(params);
|
|
293
|
+
}
|
|
394
294
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
295
|
+
onEnumSelected($event) {
|
|
296
|
+
this.updateValue(this.params, $event);
|
|
297
|
+
if (this.params.onSelection instanceof Function) {
|
|
298
|
+
const params = {
|
|
299
|
+
rowData: this.params.node.data,
|
|
300
|
+
value: $event,
|
|
301
|
+
rowNode: this.params.node,
|
|
302
|
+
};
|
|
303
|
+
this.params.onSelection(params);
|
|
304
|
+
}
|
|
399
305
|
}
|
|
400
|
-
refresh(
|
|
306
|
+
refresh(param) {
|
|
401
307
|
return false;
|
|
402
308
|
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
class ChooseEnumRendererComponent extends AgGridSelectMixin {
|
|
312
|
+
valuesToDisable = [];
|
|
313
|
+
valuesToHide = [];
|
|
314
|
+
isChip = true;
|
|
315
|
+
clearable = true;
|
|
316
|
+
constructor() {
|
|
317
|
+
super();
|
|
318
|
+
}
|
|
319
|
+
agInit(params) {
|
|
320
|
+
super.agInit(params);
|
|
321
|
+
if (params.valuesToDisable != null) {
|
|
322
|
+
this.valuesToDisable = params.valuesToDisable;
|
|
323
|
+
}
|
|
324
|
+
if (params.valuesToHide != null) {
|
|
325
|
+
this.valuesToHide = params.valuesToHide;
|
|
326
|
+
}
|
|
327
|
+
if (params.isChip != null) {
|
|
328
|
+
this.isChip = params.isChip;
|
|
329
|
+
}
|
|
330
|
+
if (params.clearable != null) {
|
|
331
|
+
this.clearable = params.clearable;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
get showError() {
|
|
335
|
+
if (this.rowLevelFG.get(this.key).errors && this.rowLevelFG.get(this.key).touched) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
403
342
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChooseEnumRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
404
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ChooseEnumRendererComponent, selector: "choose-enum-renderer", ngImport: i0, template: "<choose-enum [
|
|
343
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ChooseEnumRendererComponent, selector: "choose-enum-renderer", usesInheritance: true, ngImport: i0, template: "<div class=\"all\" [ngClass]=\"{ single: !showError, double: showError }\" *ngIf=\"rowLevelFG\" [formGroup]=\"rowLevelFG\">\r\n <choose-enum [clearable]=\"clearable\" [formControlName]=\"key\" [appendTo]=\"'body'\" [label]=\"params.label\"\r\n [labelTextAlign]=\"params.labelTextAlign\" [labelTextFontWeight]=\"params.labelTextFontWeight\"\r\n [labelTextFontSize]=\"params.labelTextFontSize\" [selectedItem]=\"params.value\" [valuesToHide]=\"valuesToHide\"\r\n [valuesToDisable]=\"valuesToDisable\" [isDropdownDisabled]=\"params.isDropdownDisabled\"\r\n [enumChoices]=\"params.enumChoices\" [placeholder]=\"params.placeholder\" [width]=\"params.width\" [isChip]=\"isChip\"\r\n [paddingTop]=\"params.paddingTop\" [customColors]=\"params.customColors\" (change)=\"onEnumSelected($event)\">\r\n </choose-enum>\r\n</div>", styles: [".all{display:grid;gap:.5rem;align-items:center;margin:auto}.single{grid-template-columns:auto}.double{grid-template-columns:auto max-content}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: ChooseEnumComponent, selector: "choose-enum", inputs: ["appendTo", "allowAllCapsValues", "clearable", "customColors", "enumChoices", "getValuesArrayFromEnum", "valuesToDisable", "valuesToHide", "isChip", "isDropdownDisabled", "isMultiple", "label", "labelTextAlign", "labelTextFontWeight", "labelTextFontSize", "paddingTop", "placeholder", "percentWidth", "selectedItem", "width", "isReadOnly", "virtualScroll"], outputs: ["change", "close"] }] });
|
|
405
344
|
}
|
|
406
345
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChooseEnumRendererComponent, decorators: [{
|
|
407
346
|
type: Component,
|
|
408
|
-
args: [{ selector: 'choose-enum-renderer', template: "<choose-enum [
|
|
347
|
+
args: [{ selector: 'choose-enum-renderer', template: "<div class=\"all\" [ngClass]=\"{ single: !showError, double: showError }\" *ngIf=\"rowLevelFG\" [formGroup]=\"rowLevelFG\">\r\n <choose-enum [clearable]=\"clearable\" [formControlName]=\"key\" [appendTo]=\"'body'\" [label]=\"params.label\"\r\n [labelTextAlign]=\"params.labelTextAlign\" [labelTextFontWeight]=\"params.labelTextFontWeight\"\r\n [labelTextFontSize]=\"params.labelTextFontSize\" [selectedItem]=\"params.value\" [valuesToHide]=\"valuesToHide\"\r\n [valuesToDisable]=\"valuesToDisable\" [isDropdownDisabled]=\"params.isDropdownDisabled\"\r\n [enumChoices]=\"params.enumChoices\" [placeholder]=\"params.placeholder\" [width]=\"params.width\" [isChip]=\"isChip\"\r\n [paddingTop]=\"params.paddingTop\" [customColors]=\"params.customColors\" (change)=\"onEnumSelected($event)\">\r\n </choose-enum>\r\n</div>", styles: [".all{display:grid;gap:.5rem;align-items:center;margin:auto}.single{grid-template-columns:auto}.double{grid-template-columns:auto max-content}\n"] }]
|
|
409
348
|
}], ctorParameters: function () { return []; } });
|
|
410
349
|
|
|
411
350
|
// import { environment } from '../../environments/environment';
|