zek 17.3.97 → 17.3.118

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
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, inject, InjectionToken, Inject, Directive, EventEmitter, Input, Output, ViewChild, Pipe, Component, forwardRef, NgModule, HostListener, ViewEncapsulation, ChangeDetectionStrategy, Optional } from '@angular/core';
2
+ import { Injectable, inject, InjectionToken, Inject, Directive, EventEmitter, Input, Output, ViewChild, HostListener, Pipe, Component, forwardRef, NgModule, ViewEncapsulation, ChangeDetectionStrategy, Optional } from '@angular/core';
3
3
  import * as i1 from '@angular/router';
4
4
  import { Router, NavigationStart, ActivatedRoute, RouterModule } from '@angular/router';
5
5
  import { Subject, of, tap, catchError, firstValueFrom, interval, BehaviorSubject, timer } from 'rxjs';
@@ -7,12 +7,12 @@ import * as i2 from '@ngx-translate/core';
7
7
  import { TranslateService, TranslateModule } from '@ngx-translate/core';
8
8
  import * as i1$1 from '@angular/common/http';
9
9
  import { HttpParams, HttpHeaders, HTTP_INTERCEPTORS } from '@angular/common/http';
10
+ import { debounceTime, finalize, map, takeWhile } from 'rxjs/operators';
10
11
  import * as i1$2 from '@angular/common';
11
12
  import { CommonModule, DatePipe } from '@angular/common';
12
13
  import * as i2$1 from '@angular/forms';
13
14
  import { NG_VALUE_ACCESSOR, FormsModule, NG_VALIDATORS } from '@angular/forms';
14
15
  import * as i1$3 from '@angular/platform-browser';
15
- import { finalize, map, takeWhile } from 'rxjs/operators';
16
16
 
17
17
  var PrintType;
18
18
  (function (PrintType) {
@@ -99,53 +99,74 @@ class ArrayHelper {
99
99
  }
100
100
  static flatten(array, indent = 0) {
101
101
  let result = [];
102
- // If the input is an array of trees, we process each one
103
- if (Array.isArray(array)) {
104
- for (const item of array) {
105
- result = result.concat(this.flatten(item, indent));
102
+ if (!Array.isArray(array)) {
103
+ const flattenedItem = {
104
+ ...array, // shallow copy the current item
105
+ indent, // add the current indent level
106
+ count: Array.isArray(array.children) ? array.children.length : 0 // set count based on children
107
+ };
108
+ delete flattenedItem.children;
109
+ delete flattenedItem.childrenIds;
110
+ result.push(flattenedItem);
111
+ if (flattenedItem.count) {
112
+ result.push(...this.flatten(array.children, indent + 1)); // Use spread operator for efficiency
106
113
  }
114
+ return result;
107
115
  }
108
116
  else {
109
- // Add the current tree node to the result
110
- const item = Object.assign({}, array);
111
- item.indent = indent;
112
- item.count = Array.isArray(array.children)
113
- ? array.children.length
114
- : 0;
115
- delete item.children;
116
- delete item.childrenIds;
117
- result.push(item);
118
- // If there are children, recursively flatten them
119
- if (Array.isArray(array.children)) {
120
- for (const child of array.children) {
121
- result = result.concat(this.flatten(child, indent + 1));
122
- }
117
+ for (const item of array) {
118
+ result.push(...this.flatten(item, indent));
123
119
  }
124
120
  }
125
121
  return result;
126
122
  }
123
+ /**
124
+ * @deprecated use flattenDropDownList2
125
+ */
127
126
  static flattenDropDownList(tree, indent = 0) {
128
127
  let result = [];
129
128
  // If the input is an array of trees, we process each one
130
- if (Array.isArray(tree)) {
131
- for (const item of tree) {
132
- result = result.concat(this.flattenDropDownList(item, indent));
129
+ if (!Array.isArray(tree)) {
130
+ // Add the current tree node to the result
131
+ let item = {
132
+ key: tree.key,
133
+ value: ' '.repeat(indent) + tree.value,
134
+ indent: indent,
135
+ count: Array.isArray(tree.children) ? tree.children.length : 0
136
+ };
137
+ result.push(item);
138
+ // If there are children, recursively flatten them
139
+ if (Array.isArray(tree.children)) {
140
+ result.push(...this.flattenDropDownList(tree.children, indent + 1)); // Use spread operator for efficiency
133
141
  }
134
142
  }
135
143
  else {
144
+ for (const item of tree) {
145
+ result.push(...this.flattenDropDownList(item, indent));
146
+ }
147
+ }
148
+ return result;
149
+ }
150
+ static flattenTreeNodeDropDownList(tree, indent = 0) {
151
+ let result = [];
152
+ // If the input is an array of trees, we process each one
153
+ if (!Array.isArray(tree)) {
136
154
  // Add the current tree node to the result
137
155
  let item = {
138
- key: tree.key,
139
- value: ' '.repeat(indent) + tree.value,
156
+ id: tree.id,
157
+ name: ' '.repeat(indent) + tree.name,
140
158
  indent: indent,
141
159
  count: Array.isArray(tree.children) ? tree.children.length : 0
142
160
  };
143
161
  result.push(item);
144
162
  // If there are children, recursively flatten them
145
163
  if (Array.isArray(tree.children)) {
146
- for (const child of tree.children) {
147
- result = result.concat(this.flattenDropDownList(child, indent + 1));
148
- }
164
+ result.push(...this.flattenTreeNodeDropDownList(tree.children, indent + 1)); // Use spread operator for efficiency
165
+ }
166
+ }
167
+ else {
168
+ for (const item of tree) {
169
+ result.push(...this.flattenTreeNodeDropDownList(item, indent));
149
170
  }
150
171
  }
151
172
  return result;
@@ -170,6 +191,49 @@ class ArrayHelper {
170
191
  static enumToKeyPairExArray(value) {
171
192
  return this.enumToKeyPairBaseArray(value);
172
193
  }
194
+ /**
195
+ * Method to create a tree from a flat array of nodes
196
+ * @param array
197
+ * @param safe if tue and some nodes not have parent thand adds as a root node. if false than thoose nodes skipped.
198
+ * @returns
199
+ */
200
+ static createTree(array, safe = true) {
201
+ const tree = [];
202
+ // Map to store nodes by their id for easy access
203
+ const map = {};
204
+ // Step 1: Loop over the array to build the nodes
205
+ for (const item of array) {
206
+ const node = {
207
+ id: item.id,
208
+ parentId: item.parentId ?? null,
209
+ name: item.name ?? null,
210
+ children: null
211
+ };
212
+ map[node.id] = node;
213
+ }
214
+ for (const item of array) {
215
+ const node = map[item.id];
216
+ // Step 2: Check if it's a root or child and assign to parent or tree
217
+ if (typeof node.parentId === 'undefined' || node.parentId === null) {
218
+ // Root node, add directly to the tree
219
+ tree.push(node);
220
+ }
221
+ else {
222
+ // Non-root node, find its parent and add to its children
223
+ let parentNode = map[node.parentId];
224
+ if (parentNode) {
225
+ if (!Array.isArray(parentNode.children))
226
+ parentNode.children = [];
227
+ parentNode.children.push(node);
228
+ }
229
+ else if (safe) {
230
+ //if save=true and parent node not exists, then we add as a root node
231
+ tree.push(node);
232
+ }
233
+ }
234
+ }
235
+ return tree;
236
+ }
173
237
  }
174
238
 
175
239
  class Base64Helper {
@@ -1355,6 +1419,38 @@ const firstBy = (function () {
1355
1419
  return tb;
1356
1420
  })();
1357
1421
 
1422
+ class IntervalHelper {
1423
+ static { this._timeouts = []; }
1424
+ static create(callback, ms) {
1425
+ const id = setInterval(() => {
1426
+ callback();
1427
+ }, ms);
1428
+ const timeout = {
1429
+ id: +id,
1430
+ callback: callback.toString(),
1431
+ interval: ms,
1432
+ createdAt: new Date()
1433
+ };
1434
+ this._timeouts.push(timeout);
1435
+ return timeout;
1436
+ }
1437
+ static clear(id) {
1438
+ const index = this._timeouts.findIndex(x => x.id === id);
1439
+ if (index !== -1) {
1440
+ clearInterval(id);
1441
+ this._timeouts.splice(index, 1);
1442
+ return true;
1443
+ }
1444
+ return false;
1445
+ }
1446
+ static clearAll() {
1447
+ for (const timeout of this._timeouts) {
1448
+ this.clear(timeout.id);
1449
+ }
1450
+ this._timeouts = [];
1451
+ }
1452
+ }
1453
+
1358
1454
  class TmpHelper {
1359
1455
  static { this._obj = {}; }
1360
1456
  static get(key, remove = true) {
@@ -1456,32 +1552,24 @@ class AuthService {
1456
1552
  }
1457
1553
  _starTimer() {
1458
1554
  this._stopTimer();
1459
- let interval = this.getExpired().getTime() - new Date().getTime();
1555
+ let interval = this.getExpired().getTime() - new Date().getTime() + 1000;
1460
1556
  if (interval < 1000)
1461
1557
  interval = 1000;
1462
1558
  if (interval > 0 && this._user) {
1463
- this._refreshTimerId = setInterval(() => {
1464
- this.emitOnRefreshToken();
1559
+ this._timerId = setTimeout(() => {
1560
+ this._onTick();
1465
1561
  }, interval);
1466
- if (this._user) {
1467
- this._timerId = setInterval(() => {
1468
- this._onTick();
1469
- }, 1000);
1470
- }
1471
1562
  }
1472
1563
  }
1473
1564
  _stopTimer() {
1474
1565
  if (typeof this._timerId === 'number') {
1475
- clearInterval(this._timerId);
1566
+ clearTimeout(this._timerId);
1476
1567
  }
1477
1568
  }
1478
1569
  _onTick() {
1479
1570
  const newValue = this._isAuthenticated;
1480
- if (this._auth !== newValue) {
1481
- this._auth = newValue;
1482
- if (!newValue) {
1483
- this.logout();
1484
- }
1571
+ if (this._auth !== newValue && !newValue) {
1572
+ this.logout();
1485
1573
  }
1486
1574
  }
1487
1575
  _starRefreshTokenTimer() {
@@ -1539,11 +1627,13 @@ class AuthService {
1539
1627
  }
1540
1628
  }
1541
1629
  this._user = user;
1542
- //if old value was false and we set true then we need to emit
1543
- if (!this._auth) {
1544
- this._auth = true;
1545
- this.emitOnSignedIn();
1546
- }
1630
+ // if (!this._auth) {
1631
+ // this._auth = true;
1632
+ // this.emitOnSignedIn();
1633
+ // }
1634
+ this._auth = true;
1635
+ this.emitOnSignedIn();
1636
+ //restart timers for new timeouts
1547
1637
  this._starTimer();
1548
1638
  this._starRefreshTokenTimer();
1549
1639
  }
@@ -2726,6 +2816,9 @@ class PagedList {
2726
2816
  }
2727
2817
  }
2728
2818
 
2819
+ /**
2820
+ * @deprecated use ITreeNode
2821
+ */
2729
2822
  class Tree extends KeyPairChecked {
2730
2823
  }
2731
2824
 
@@ -3040,6 +3133,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
3040
3133
  args: ['disapproveModal', { static: false }]
3041
3134
  }] } });
3042
3135
 
3136
+ class ZekDelayedInputDirective {
3137
+ constructor() {
3138
+ this._inputSubject$ = new Subject();
3139
+ this.delayedInput = new EventEmitter();
3140
+ this._delay = 500;
3141
+ }
3142
+ get delay() {
3143
+ return this._delay;
3144
+ }
3145
+ set delay(v) {
3146
+ const tmp = MathHelper.clamp(Convert.toNumber(v), 1, 3600000);
3147
+ if (this._delay !== tmp) {
3148
+ this._delay = tmp;
3149
+ }
3150
+ }
3151
+ ngOnInit() {
3152
+ this.initSubscription();
3153
+ }
3154
+ initSubscription() {
3155
+ // Emit values after the specified debounce time
3156
+ this._inputSubject$.pipe(debounceTime(this.delay)).subscribe((value) => {
3157
+ this.delayedInput.emit(value);
3158
+ });
3159
+ }
3160
+ // ngOnChanges(changes: SimpleChanges) {
3161
+ // if (changes['delayTime']) {
3162
+ // // Reset the subscription when delayTime changes
3163
+ // this._inputSubject$ = new Subject<string>(); // Replace the Subject
3164
+ // this.initSubscription(); // Reinitialize with the new delayTime
3165
+ // }
3166
+ // }
3167
+ onInput(value) {
3168
+ this._inputSubject$.next(value); // Push new value to the Subject
3169
+ }
3170
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ZekDelayedInputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
3171
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.4", type: ZekDelayedInputDirective, isStandalone: true, selector: "[zek-delayed-input]", inputs: { delay: "delay" }, outputs: { delayedInput: "delayedInput" }, host: { listeners: { "input": "onInput($event.target.value)" } }, ngImport: i0 }); }
3172
+ }
3173
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ZekDelayedInputDirective, decorators: [{
3174
+ type: Directive,
3175
+ args: [{
3176
+ standalone: true,
3177
+ selector: '[zek-delayed-input]'
3178
+ }]
3179
+ }], propDecorators: { delayedInput: [{
3180
+ type: Output
3181
+ }], delay: [{
3182
+ type: Input
3183
+ }], onInput: [{
3184
+ type: HostListener,
3185
+ args: ['input', ['$event.target.value']]
3186
+ }] } });
3187
+
3043
3188
  class AgePipe {
3044
3189
  transform(value, now) {
3045
3190
  if (typeof value === 'undefined' || value === null || value === '' || value !== value)
@@ -3100,15 +3245,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
3100
3245
  type: Input
3101
3246
  }] } });
3102
3247
 
3103
- function clamp$1(v, min = 10, max = 3600000) {
3104
- return Math.max(min, Math.min(max, v));
3105
- }
3106
3248
  class ZekToast {
3107
3249
  get delay() {
3108
3250
  return this._delay;
3109
3251
  }
3110
3252
  set delay(v) {
3111
- const tmp = clamp$1(Convert.toNumber(v) || 0);
3253
+ const tmp = MathHelper.clamp(Convert.toNumber(v) || 0, 10, 3600000);
3112
3254
  if (this._delay !== tmp) {
3113
3255
  this._delay = tmp;
3114
3256
  }
@@ -5519,9 +5661,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
5519
5661
  args: ['modelChange']
5520
5662
  }] } });
5521
5663
 
5522
- function clamp(v, min = 0, max = 100) {
5523
- return Math.max(min, Math.min(max, v));
5524
- }
5525
5664
  class ZekProgress {
5526
5665
  constructor() {
5527
5666
  this._value = 0;
@@ -5537,7 +5676,7 @@ class ZekProgress {
5537
5676
  return this._value;
5538
5677
  }
5539
5678
  set value(v) {
5540
- const tmp = clamp(Convert.toNumber(v) || 0);
5679
+ const tmp = MathHelper.clamp(Convert.toNumber(v) || 0, 0, 100);
5541
5680
  if (this._value !== tmp) {
5542
5681
  this._value = tmp;
5543
5682
  }
@@ -7289,5 +7428,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
7289
7428
  * Generated bundle index. Do not edit.
7290
7429
  */
7291
7430
 
7292
- export { API_BASE_URL, AgePipe, Alert, AlertService, ArrayHelper, AuthService, Base64Helper, BaseAlert, BaseComponent, BaseService, BitwiseHelper, BootstrapHelper, CacheHelper, Color, ComponentType, Convert, CoreComponent, CoreUiComponent, CrudService, CssHelper, CustomHttpParamEncoder, DATE_FORMAT, DateHelper, DateValueAccessor, DatepickerModule, EditBase, EditBaseComponent, EditComponent, EditFormComponent, ErrorHelper, ExcelHelper, FileHelper, FileService, FilterBase, FilterHelper, GOOGLE_CLIENT_ID, Gender, HtmlHelper, HttpErrorHandler, JwtHelper, KeyPair, KeyPairChecked, KeyPairEx, KeyPairRequired, LANGUAGE, ListBase, ListBaseComponent, MATCH_VALIDATOR, MatchValidator, MathHelper, Month, ObjectHelper, OverlapHelper, PagedList, Pager, PagerHelper, PeriodRelation, PrintType, RANGE_VALIDATOR, RECAPTCHA_SITE_KEY, RandomHelper, RangeValidator, ReCaptchaService, RecaptchaModule, StorageHelper, StringHelper, TimeHelper, TimeModule, TimePipe, TimerService, TmpHelper, Toast, Tree, UrlHelper, ValidEventArgs, ValidationHelper, Validators, ValidatorsModule, WebApiClient, WebApiModule, ZekAlert, ZekApproveModal, ZekAutoComplete, ZekButtonBrowse, ZekButtonBrowseModalBase, ZekButtonBrowseModalToolbar, ZekButtonBrowseModule, ZekCallbackPipe, ZekCard, ZekCountdown, ZekDateAgoPipe, ZekDeleteModal, ZekDisapproveModal, ZekEditToolbar, ZekFieldValidator, ZekFileInput, ZekFileSizePipe, ZekFileViewer, ZekFilterModal, ZekGoogleLoginButton, ZekGoogleLoginModule, ZekGridToolbar, ZekGridToolbarBar, ZekListToolbar, ZekLoading, ZekLoadingModule, ZekLocalToUtcModule, ZekLocalToUtcPipe, ZekModal, ZekModalModule, ZekNumericDirective, ZekPageTitle, ZekPager, ZekPassword, ZekProgress, ZekRadio, ZekReadOnlyDirective, ZekRestoreModal, ZekSafePipe, ZekSelect2, ZekSelect2Multiple, ZekSelectMultiple, ZekSort, ZekSortButtonGroup, ZekSubmitModal, ZekSumModal, ZekTag, ZekToast, ZekTooltip, ZekUtcToLocalModule, ZekUtcToLocalPipe, ZekValidation, ZekWizard, ZekWizard2, firstBy, handler, matchValidator, nullValidator, rangeValidator, zekAuthGuard };
7431
+ export { API_BASE_URL, AgePipe, Alert, AlertService, ArrayHelper, AuthService, Base64Helper, BaseAlert, BaseComponent, BaseService, BitwiseHelper, BootstrapHelper, CacheHelper, Color, ComponentType, Convert, CoreComponent, CoreUiComponent, CrudService, CssHelper, CustomHttpParamEncoder, DATE_FORMAT, DateHelper, DateValueAccessor, DatepickerModule, EditBase, EditBaseComponent, EditComponent, EditFormComponent, ErrorHelper, ExcelHelper, FileHelper, FileService, FilterBase, FilterHelper, GOOGLE_CLIENT_ID, Gender, HtmlHelper, HttpErrorHandler, IntervalHelper, JwtHelper, KeyPair, KeyPairChecked, KeyPairEx, KeyPairRequired, LANGUAGE, ListBase, ListBaseComponent, MATCH_VALIDATOR, MatchValidator, MathHelper, Month, ObjectHelper, OverlapHelper, PagedList, Pager, PagerHelper, PeriodRelation, PrintType, RANGE_VALIDATOR, RECAPTCHA_SITE_KEY, RandomHelper, RangeValidator, ReCaptchaService, RecaptchaModule, StorageHelper, StringHelper, TimeHelper, TimeModule, TimePipe, TimerService, TmpHelper, Toast, Tree, UrlHelper, ValidEventArgs, ValidationHelper, Validators, ValidatorsModule, WebApiClient, WebApiModule, ZekAlert, ZekApproveModal, ZekAutoComplete, ZekButtonBrowse, ZekButtonBrowseModalBase, ZekButtonBrowseModalToolbar, ZekButtonBrowseModule, ZekCallbackPipe, ZekCard, ZekCountdown, ZekDateAgoPipe, ZekDelayedInputDirective, ZekDeleteModal, ZekDisapproveModal, ZekEditToolbar, ZekFieldValidator, ZekFileInput, ZekFileSizePipe, ZekFileViewer, ZekFilterModal, ZekGoogleLoginButton, ZekGoogleLoginModule, ZekGridToolbar, ZekGridToolbarBar, ZekListToolbar, ZekLoading, ZekLoadingModule, ZekLocalToUtcModule, ZekLocalToUtcPipe, ZekModal, ZekModalModule, ZekNumericDirective, ZekPageTitle, ZekPager, ZekPassword, ZekProgress, ZekRadio, ZekReadOnlyDirective, ZekRestoreModal, ZekSafePipe, ZekSelect2, ZekSelect2Multiple, ZekSelectMultiple, ZekSort, ZekSortButtonGroup, ZekSubmitModal, ZekSumModal, ZekTag, ZekToast, ZekTooltip, ZekUtcToLocalModule, ZekUtcToLocalPipe, ZekValidation, ZekWizard, ZekWizard2, firstBy, handler, matchValidator, nullValidator, rangeValidator, zekAuthGuard };
7293
7432
  //# sourceMappingURL=zek.mjs.map