zek 19.0.14 → 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 filterByKey(filterValue, key, array) {
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,86 +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
- if (!this.isObject(value))
1059
- return value;
1060
- let output = {};
1061
- if (Array.isArray(value)) {
1062
- output = value.map(x => this.deepCopy(x));
1063
- }
1064
- else {
1065
- Object.keys(value).forEach((key) => {
1066
- const v = value[key];
1067
- if (this.isObject(v)) {
1068
- output[key] = this.deepCopy(v);
1069
- }
1070
- else {
1071
- Object.assign(output, { [key]: v });
1072
- }
1073
- });
1074
- }
1075
- return output;
1076
- }
1077
- }
1078
-
1079
1149
  class FilterHelper {
1080
1150
  static isEmpty(obj) {
1081
1151
  if (typeof obj === 'undefined' || obj === null)
@@ -2837,6 +2907,12 @@ class IdName {
2837
2907
  }
2838
2908
  class IdNameChecked extends IdName {
2839
2909
  checked;
2910
+ constructor(init) {
2911
+ super();
2912
+ if (init) {
2913
+ Object.assign(this, init);
2914
+ }
2915
+ }
2840
2916
  }
2841
2917
 
2842
2918
  class KeyPair {
@@ -4219,7 +4295,7 @@ class DateValueAccessor {
4219
4295
  }
4220
4296
  }
4221
4297
  isReadOnly() {
4222
- return this.el.nativeElement.disabled || this.el.nativeElement.readOnly;
4298
+ return this.el.nativeElement.disabled || this.el.nativeElement.readonly || this.el.nativeElement.readOnly;
4223
4299
  }
4224
4300
  //write from model to el.nativeElement
4225
4301
  writeValue(value) {
@@ -4646,6 +4722,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
4646
4722
  class ZekFileInput extends CoreUiComponent {
4647
4723
  // @Input() model!: string[] | null;
4648
4724
  onUpload = new EventEmitter();
4725
+ fileInput;
4649
4726
  fileService = inject(FileService);
4650
4727
  _uniqueId = `zek-file-input-${this.uniqueId}`;
4651
4728
  /** The unique ID for the tag. */
@@ -4670,7 +4747,6 @@ class ZekFileInput extends CoreUiComponent {
4670
4747
  set multiple(v) {
4671
4748
  this._multiple = Convert.toBooleanProperty(v);
4672
4749
  }
4673
- // files: File[] | null = null;
4674
4750
  clickInput() {
4675
4751
  const el = document.getElementById(this.inputId);
4676
4752
  if (el) {
@@ -4693,9 +4769,11 @@ class ZekFileInput extends CoreUiComponent {
4693
4769
  this.onUpload.emit(data.value);
4694
4770
  }
4695
4771
  });
4772
+ if (this.fileInput)
4773
+ this.fileInput.nativeElement.value = '';
4696
4774
  }
4697
4775
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: ZekFileInput, deps: null, target: i0.ɵɵFactoryTarget.Component });
4698
- 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 }] });
4699
4777
  }
4700
4778
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: ZekFileInput, decorators: [{
4701
4779
  type: Component,
@@ -4704,6 +4782,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
4704
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"] }]
4705
4783
  }], propDecorators: { onUpload: [{
4706
4784
  type: Output
4785
+ }], fileInput: [{
4786
+ type: ViewChild,
4787
+ args: ['fileInput']
4707
4788
  }], id: [{
4708
4789
  type: Input
4709
4790
  }], accept: [{
@@ -6540,7 +6621,7 @@ class ZekSelectMultiple extends CoreUiComponent {
6540
6621
  let notUnique = [];
6541
6622
  if (this.valueField) {
6542
6623
  for (const currentValue of value) {
6543
- const items = ArrayHelper.filterByKey(currentValue, this.valueField, this._data);
6624
+ const items = ArrayHelper.filterByKeyString(currentValue, this.valueField, this._data);
6544
6625
  notUnique = notUnique.concat(items);
6545
6626
  }
6546
6627
  }
@@ -6556,7 +6637,7 @@ class ZekSelectMultiple extends CoreUiComponent {
6556
6637
  else {
6557
6638
  if (Array.isArray(this._data)) {
6558
6639
  if (this.valueField) {
6559
- this._selected = ArrayHelper.filterByKey(value, this.valueField, this._data);
6640
+ this._selected = ArrayHelper.filterByKeyString(value, this.valueField, this._data);
6560
6641
  }
6561
6642
  else {
6562
6643
  this._selected = this._data.filter(x => x === value);