zek 19.0.16 → 19.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm2022/zek.mjs
CHANGED
|
@@ -20,6 +20,130 @@ var PrintType;
|
|
|
20
20
|
PrintType[PrintType["Pdf"] = 2] = "Pdf";
|
|
21
21
|
})(PrintType || (PrintType = {}));
|
|
22
22
|
|
|
23
|
+
class ObjectHelper {
|
|
24
|
+
static isDefined(value) {
|
|
25
|
+
return typeof value !== 'undefined' && value !== null;
|
|
26
|
+
}
|
|
27
|
+
static isObject(value) {
|
|
28
|
+
return this.isDefined(value) && typeof value === 'object';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if the object is a string or array before evaluating the length attribute.
|
|
32
|
+
* This avoids falsely rejecting objects that contain a custom length attribute.
|
|
33
|
+
* For example, the object {id: 1, length: 0, width: 0} should not be returned as empty.
|
|
34
|
+
*/
|
|
35
|
+
static isEmptyValue(value) {
|
|
36
|
+
return !this.isDefined(value) || ((typeof value === 'string' || Array.isArray(value)) && value.length === 0);
|
|
37
|
+
}
|
|
38
|
+
static isEmpty(obj) {
|
|
39
|
+
if (!this.isDefined(obj))
|
|
40
|
+
return true;
|
|
41
|
+
// if (typeof obj === 'undefined' || obj === null)
|
|
42
|
+
// return true;
|
|
43
|
+
for (const prop in obj) {
|
|
44
|
+
const v = obj[prop];
|
|
45
|
+
if (!this.isEmptyValue(v))
|
|
46
|
+
return false;
|
|
47
|
+
// if (typeof (obj[prop]) !== undefined && obj[prop] !== null && obj[prop] !== '') {
|
|
48
|
+
// return false;
|
|
49
|
+
// }
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated The method should not be used. please use deleteNullFields
|
|
55
|
+
*/
|
|
56
|
+
static deleteNullKeys(val) {
|
|
57
|
+
this.deleteNullFields(val);
|
|
58
|
+
}
|
|
59
|
+
static deleteNullFields(val) {
|
|
60
|
+
if (!val)
|
|
61
|
+
return;
|
|
62
|
+
for (let key in val) {
|
|
63
|
+
let tmp = val[key];
|
|
64
|
+
if (tmp === undefined || tmp === null) {
|
|
65
|
+
delete val[key];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return val;
|
|
69
|
+
}
|
|
70
|
+
static assignFields(target, source) {
|
|
71
|
+
let t = target;
|
|
72
|
+
let s = source;
|
|
73
|
+
for (const key of Object.keys(target)) {
|
|
74
|
+
let v = s[key];
|
|
75
|
+
if (typeof v !== 'undefined') {
|
|
76
|
+
t[key] = v;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
static deepCopy(value) {
|
|
82
|
+
// 1. Guard clause: if value is null or not an object, return it.
|
|
83
|
+
// (This handles primitives and breaks recursion)
|
|
84
|
+
if (!this.isObject(value))
|
|
85
|
+
return value;
|
|
86
|
+
// 2. Handle Arrays
|
|
87
|
+
if (Array.isArray(value)) {
|
|
88
|
+
return value.map(x => this.deepCopy(x));
|
|
89
|
+
}
|
|
90
|
+
// 3. Handle Objects
|
|
91
|
+
const output = {};
|
|
92
|
+
for (const key of Object.keys(value)) {
|
|
93
|
+
const v = value[key];
|
|
94
|
+
if (this.isObject(v)) {
|
|
95
|
+
output[key] = this.deepCopy(v);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
Object.assign(output, { [key]: v });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return output;
|
|
102
|
+
}
|
|
103
|
+
static deepEquals(a, b) {
|
|
104
|
+
// 1. Strict equality for primitives
|
|
105
|
+
if (a === b)
|
|
106
|
+
return true;
|
|
107
|
+
// 2. If one is null/undefined or types differ → not equal
|
|
108
|
+
if (a == null || b == null || typeof a !== typeof b)
|
|
109
|
+
return false;
|
|
110
|
+
// 3. Date comparison
|
|
111
|
+
if (a instanceof Date && b instanceof Date) {
|
|
112
|
+
return a.getTime() === b.getTime();
|
|
113
|
+
}
|
|
114
|
+
// 4. Arrays
|
|
115
|
+
if (Array.isArray(a)) {
|
|
116
|
+
if (!Array.isArray(b))
|
|
117
|
+
return false;
|
|
118
|
+
if (a.length !== b.length)
|
|
119
|
+
return false;
|
|
120
|
+
for (let i = 0; i < a.length; i++) {
|
|
121
|
+
if (!this.deepEquals(a[i], b[i]))
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
// 5. Objects
|
|
127
|
+
if (this.isObject(a)) {
|
|
128
|
+
if (!this.isObject(b))
|
|
129
|
+
return false;
|
|
130
|
+
const keysA = Object.keys(a);
|
|
131
|
+
const keysB = Object.keys(b);
|
|
132
|
+
if (keysA.length !== keysB.length)
|
|
133
|
+
return false;
|
|
134
|
+
for (const key of keysA) {
|
|
135
|
+
if (!keysB.includes(key))
|
|
136
|
+
return false;
|
|
137
|
+
if (!this.deepEquals(a[key], b[key]))
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
// 6. Fallback
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
23
147
|
// import { KeyPair } from "../models/key-pair.model";
|
|
24
148
|
// import { Tree } from "../models/tree.model";
|
|
25
149
|
class ArrayHelper {
|
|
@@ -114,11 +238,37 @@ class ArrayHelper {
|
|
|
114
238
|
}
|
|
115
239
|
return result;
|
|
116
240
|
}
|
|
117
|
-
static
|
|
241
|
+
static filterByKeyString(filterValue, key, array) {
|
|
118
242
|
if (typeof filterValue === 'undefined' || filterValue == null || (typeof key === 'string' && key.length === 0))
|
|
119
243
|
return array;
|
|
120
244
|
return array.filter(x => x !== undefined && x !== null && x[key] === filterValue);
|
|
121
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Filters an array based on whether the value derived by the keySelector
|
|
248
|
+
* equals the filterValue.
|
|
249
|
+
* @param filterValue The value to match.
|
|
250
|
+
* @param keySelector A function that takes an item of type T and returns the key value of type K.
|
|
251
|
+
* @param array The array of items to filter.
|
|
252
|
+
* @returns A new array containing only the items that match the filter criteria.
|
|
253
|
+
*/
|
|
254
|
+
static filterByKey(filterValue, keySelector, array) {
|
|
255
|
+
// 1. Handle edge cases: if filterValue is undefined or null, or the array is null/empty,
|
|
256
|
+
// return the array or an empty array, respectively.
|
|
257
|
+
if (typeof filterValue === 'undefined' || filterValue === null || !array) {
|
|
258
|
+
return array || [];
|
|
259
|
+
}
|
|
260
|
+
// 2. Filter the array using the keySelector for comparison
|
|
261
|
+
return array.filter((item) => {
|
|
262
|
+
// Ensure the item itself is not undefined or null before trying to get its key
|
|
263
|
+
if (!ObjectHelper.isDefined(item)) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
// Get the specific key value for the current item
|
|
267
|
+
const itemKey = keySelector(item);
|
|
268
|
+
// Return true if the item's key value strictly equals the filterValue
|
|
269
|
+
return itemKey === filterValue;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
122
272
|
static flatten(array, indent = 0) {
|
|
123
273
|
let result = [];
|
|
124
274
|
if (!Array.isArray(array)) {
|
|
@@ -996,130 +1146,6 @@ class FileHelper {
|
|
|
996
1146
|
}
|
|
997
1147
|
}
|
|
998
1148
|
|
|
999
|
-
class ObjectHelper {
|
|
1000
|
-
static isDefined(value) {
|
|
1001
|
-
return typeof value !== 'undefined' && value !== null;
|
|
1002
|
-
}
|
|
1003
|
-
static isObject(value) {
|
|
1004
|
-
return this.isDefined(value) && typeof value === 'object';
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* Check if the object is a string or array before evaluating the length attribute.
|
|
1008
|
-
* This avoids falsely rejecting objects that contain a custom length attribute.
|
|
1009
|
-
* For example, the object {id: 1, length: 0, width: 0} should not be returned as empty.
|
|
1010
|
-
*/
|
|
1011
|
-
static isEmptyValue(value) {
|
|
1012
|
-
return !this.isDefined(value) || ((typeof value === 'string' || Array.isArray(value)) && value.length === 0);
|
|
1013
|
-
}
|
|
1014
|
-
static isEmpty(obj) {
|
|
1015
|
-
if (!this.isDefined(obj))
|
|
1016
|
-
return true;
|
|
1017
|
-
// if (typeof obj === 'undefined' || obj === null)
|
|
1018
|
-
// return true;
|
|
1019
|
-
for (const prop in obj) {
|
|
1020
|
-
const v = obj[prop];
|
|
1021
|
-
if (!this.isEmptyValue(v))
|
|
1022
|
-
return false;
|
|
1023
|
-
// if (typeof (obj[prop]) !== undefined && obj[prop] !== null && obj[prop] !== '') {
|
|
1024
|
-
// return false;
|
|
1025
|
-
// }
|
|
1026
|
-
}
|
|
1027
|
-
return true;
|
|
1028
|
-
}
|
|
1029
|
-
/**
|
|
1030
|
-
* @deprecated The method should not be used. please use deleteNullFields
|
|
1031
|
-
*/
|
|
1032
|
-
static deleteNullKeys(val) {
|
|
1033
|
-
this.deleteNullFields(val);
|
|
1034
|
-
}
|
|
1035
|
-
static deleteNullFields(val) {
|
|
1036
|
-
if (!val)
|
|
1037
|
-
return;
|
|
1038
|
-
for (let key in val) {
|
|
1039
|
-
let tmp = val[key];
|
|
1040
|
-
if (tmp === undefined || tmp === null) {
|
|
1041
|
-
delete val[key];
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
return val;
|
|
1045
|
-
}
|
|
1046
|
-
static assignFields(target, source) {
|
|
1047
|
-
let t = target;
|
|
1048
|
-
let s = source;
|
|
1049
|
-
for (const key of Object.keys(target)) {
|
|
1050
|
-
let v = s[key];
|
|
1051
|
-
if (typeof v !== 'undefined') {
|
|
1052
|
-
t[key] = v;
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
return target;
|
|
1056
|
-
}
|
|
1057
|
-
static deepCopy(value) {
|
|
1058
|
-
// 1. Guard clause: if value is null or not an object, return it.
|
|
1059
|
-
// (This handles primitives and breaks recursion)
|
|
1060
|
-
if (!this.isObject(value))
|
|
1061
|
-
return value;
|
|
1062
|
-
// 2. Handle Arrays
|
|
1063
|
-
if (Array.isArray(value)) {
|
|
1064
|
-
return value.map(x => this.deepCopy(x));
|
|
1065
|
-
}
|
|
1066
|
-
// 3. Handle Objects
|
|
1067
|
-
const output = {};
|
|
1068
|
-
for (const key of Object.keys(value)) {
|
|
1069
|
-
const v = value[key];
|
|
1070
|
-
if (this.isObject(v)) {
|
|
1071
|
-
output[key] = this.deepCopy(v);
|
|
1072
|
-
}
|
|
1073
|
-
else {
|
|
1074
|
-
Object.assign(output, { [key]: v });
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
return output;
|
|
1078
|
-
}
|
|
1079
|
-
static deepEquals(a, b) {
|
|
1080
|
-
// 1. Strict equality for primitives
|
|
1081
|
-
if (a === b)
|
|
1082
|
-
return true;
|
|
1083
|
-
// 2. If one is null/undefined or types differ → not equal
|
|
1084
|
-
if (a == null || b == null || typeof a !== typeof b)
|
|
1085
|
-
return false;
|
|
1086
|
-
// 3. Date comparison
|
|
1087
|
-
if (a instanceof Date && b instanceof Date) {
|
|
1088
|
-
return a.getTime() === b.getTime();
|
|
1089
|
-
}
|
|
1090
|
-
// 4. Arrays
|
|
1091
|
-
if (Array.isArray(a)) {
|
|
1092
|
-
if (!Array.isArray(b))
|
|
1093
|
-
return false;
|
|
1094
|
-
if (a.length !== b.length)
|
|
1095
|
-
return false;
|
|
1096
|
-
for (let i = 0; i < a.length; i++) {
|
|
1097
|
-
if (!this.deepEquals(a[i], b[i]))
|
|
1098
|
-
return false;
|
|
1099
|
-
}
|
|
1100
|
-
return true;
|
|
1101
|
-
}
|
|
1102
|
-
// 5. Objects
|
|
1103
|
-
if (this.isObject(a)) {
|
|
1104
|
-
if (!this.isObject(b))
|
|
1105
|
-
return false;
|
|
1106
|
-
const keysA = Object.keys(a);
|
|
1107
|
-
const keysB = Object.keys(b);
|
|
1108
|
-
if (keysA.length !== keysB.length)
|
|
1109
|
-
return false;
|
|
1110
|
-
for (const key of keysA) {
|
|
1111
|
-
if (!keysB.includes(key))
|
|
1112
|
-
return false;
|
|
1113
|
-
if (!this.deepEquals(a[key], b[key]))
|
|
1114
|
-
return false;
|
|
1115
|
-
}
|
|
1116
|
-
return true;
|
|
1117
|
-
}
|
|
1118
|
-
// 6. Fallback
|
|
1119
|
-
return false;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
1149
|
class FilterHelper {
|
|
1124
1150
|
static isEmpty(obj) {
|
|
1125
1151
|
if (typeof obj === 'undefined' || obj === null)
|
|
@@ -4269,7 +4295,7 @@ class DateValueAccessor {
|
|
|
4269
4295
|
}
|
|
4270
4296
|
}
|
|
4271
4297
|
isReadOnly() {
|
|
4272
|
-
return this.el.nativeElement.disabled || this.el.nativeElement.readOnly;
|
|
4298
|
+
return this.el.nativeElement.disabled || this.el.nativeElement.readonly || this.el.nativeElement.readOnly;
|
|
4273
4299
|
}
|
|
4274
4300
|
//write from model to el.nativeElement
|
|
4275
4301
|
writeValue(value) {
|
|
@@ -4696,6 +4722,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
|
|
|
4696
4722
|
class ZekFileInput extends CoreUiComponent {
|
|
4697
4723
|
// @Input() model!: string[] | null;
|
|
4698
4724
|
onUpload = new EventEmitter();
|
|
4725
|
+
fileInput;
|
|
4699
4726
|
fileService = inject(FileService);
|
|
4700
4727
|
_uniqueId = `zek-file-input-${this.uniqueId}`;
|
|
4701
4728
|
/** The unique ID for the tag. */
|
|
@@ -4720,7 +4747,6 @@ class ZekFileInput extends CoreUiComponent {
|
|
|
4720
4747
|
set multiple(v) {
|
|
4721
4748
|
this._multiple = Convert.toBooleanProperty(v);
|
|
4722
4749
|
}
|
|
4723
|
-
// files: File[] | null = null;
|
|
4724
4750
|
clickInput() {
|
|
4725
4751
|
const el = document.getElementById(this.inputId);
|
|
4726
4752
|
if (el) {
|
|
@@ -4743,9 +4769,11 @@ class ZekFileInput extends CoreUiComponent {
|
|
|
4743
4769
|
this.onUpload.emit(data.value);
|
|
4744
4770
|
}
|
|
4745
4771
|
});
|
|
4772
|
+
if (this.fileInput)
|
|
4773
|
+
this.fileInput.nativeElement.value = '';
|
|
4746
4774
|
}
|
|
4747
4775
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: ZekFileInput, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
4748
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.6", type: ZekFileInput, isStandalone: true, selector: "zek-file-input", inputs: { id: "id", accept: "accept", multiple: "multiple" }, outputs: { onUpload: "onUpload" }, host: { properties: { "attr.id": "id" } }, providers: [FileService], usesInheritance: true, ngImport: i0, template: "<input type=\"file\" class=\"form-control\"\r\n name=\"{{inputId}}\"\r\n id=\"{{inputId}}\"\r\n [multiple]=\"multiple\" [accept]=\"accept\" [required]=\"required\" [disabled]=\"readonly\"\r\n #fileInput\r\n (change)=\"onFileInputChange($event)\" />", styles: [":host input[type=file]{display:none}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }] });
|
|
4776
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.6", type: ZekFileInput, isStandalone: true, selector: "zek-file-input", inputs: { id: "id", accept: "accept", multiple: "multiple" }, outputs: { onUpload: "onUpload" }, host: { properties: { "attr.id": "id" } }, providers: [FileService], viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<input type=\"file\" class=\"form-control\"\r\n name=\"{{inputId}}\"\r\n id=\"{{inputId}}\"\r\n [multiple]=\"multiple\" [accept]=\"accept\" [required]=\"required\" [disabled]=\"readonly\"\r\n #fileInput\r\n (change)=\"onFileInputChange($event)\" />", styles: [":host input[type=file]{display:none}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }] });
|
|
4749
4777
|
}
|
|
4750
4778
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: ZekFileInput, decorators: [{
|
|
4751
4779
|
type: Component,
|
|
@@ -4754,6 +4782,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
|
|
|
4754
4782
|
}, template: "<input type=\"file\" class=\"form-control\"\r\n name=\"{{inputId}}\"\r\n id=\"{{inputId}}\"\r\n [multiple]=\"multiple\" [accept]=\"accept\" [required]=\"required\" [disabled]=\"readonly\"\r\n #fileInput\r\n (change)=\"onFileInputChange($event)\" />", styles: [":host input[type=file]{display:none}\n"] }]
|
|
4755
4783
|
}], propDecorators: { onUpload: [{
|
|
4756
4784
|
type: Output
|
|
4785
|
+
}], fileInput: [{
|
|
4786
|
+
type: ViewChild,
|
|
4787
|
+
args: ['fileInput']
|
|
4757
4788
|
}], id: [{
|
|
4758
4789
|
type: Input
|
|
4759
4790
|
}], accept: [{
|
|
@@ -6590,7 +6621,7 @@ class ZekSelectMultiple extends CoreUiComponent {
|
|
|
6590
6621
|
let notUnique = [];
|
|
6591
6622
|
if (this.valueField) {
|
|
6592
6623
|
for (const currentValue of value) {
|
|
6593
|
-
const items = ArrayHelper.
|
|
6624
|
+
const items = ArrayHelper.filterByKeyString(currentValue, this.valueField, this._data);
|
|
6594
6625
|
notUnique = notUnique.concat(items);
|
|
6595
6626
|
}
|
|
6596
6627
|
}
|
|
@@ -6606,7 +6637,7 @@ class ZekSelectMultiple extends CoreUiComponent {
|
|
|
6606
6637
|
else {
|
|
6607
6638
|
if (Array.isArray(this._data)) {
|
|
6608
6639
|
if (this.valueField) {
|
|
6609
|
-
this._selected = ArrayHelper.
|
|
6640
|
+
this._selected = ArrayHelper.filterByKeyString(value, this.valueField, this._data);
|
|
6610
6641
|
}
|
|
6611
6642
|
else {
|
|
6612
6643
|
this._selected = this._data.filter(x => x === value);
|