@nexterajs/app-kit 0.0.1

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.
@@ -0,0 +1,1012 @@
1
+ import { FormGroup, FormControl } from '@angular/forms';
2
+ import * as i0 from '@angular/core';
3
+ import { computed, Pipe, Input, Directive, HostListener, inject, Injector, EnvironmentInjector, ApplicationRef, RendererFactory2, createComponent, Injectable } from '@angular/core';
4
+ import { TemplatePortal } from '@angular/cdk/portal';
5
+ import * as i1 from '@angular/cdk/overlay';
6
+ import { Subject } from 'rxjs';
7
+
8
+ class BooleanOperator {
9
+ static NOT_INCLUDE = 'NIN';
10
+ static INCLUDE = 'IN';
11
+ static EQUALS = '=';
12
+ static NOT_EQUAL = '!=';
13
+ }
14
+ class ValueOperator {
15
+ static NOT_INCLUDE = 'NIN';
16
+ static INCLUDE = 'IN';
17
+ static EQUALS = '=';
18
+ static NOT_EQUAL = '!=';
19
+ }
20
+ class ConditionType {
21
+ static GROUP = 'GROUP';
22
+ static SINGLE = 'SINGLE';
23
+ }
24
+ class ConditionOperator {
25
+ static AND = 'AND';
26
+ static OR = 'OR';
27
+ }
28
+ class ConditionEvaluator {
29
+ static evaluate(data, condition) {
30
+ if (condition.type === ConditionType.SINGLE) {
31
+ return this.evaluateSingle(data, condition);
32
+ }
33
+ if (condition.type === ConditionType.GROUP && condition.children) {
34
+ return this.evaluateGroup(data, condition);
35
+ }
36
+ return false;
37
+ }
38
+ static evaluateSingle(data, condition) {
39
+ const { key, valueOperator, value } = condition;
40
+ if (!key || !valueOperator)
41
+ return false;
42
+ const actualValue = data[key];
43
+ switch (valueOperator) {
44
+ case ValueOperator.EQUALS:
45
+ return actualValue === value;
46
+ case ValueOperator.NOT_EQUAL:
47
+ return actualValue !== value;
48
+ case ValueOperator.INCLUDE:
49
+ return Array.isArray(value) ? value.includes(actualValue) : false;
50
+ case ValueOperator.NOT_INCLUDE:
51
+ return Array.isArray(value) ? !value.includes(actualValue) : false;
52
+ default:
53
+ return false;
54
+ }
55
+ }
56
+ static evaluateGroup(data, condition) {
57
+ const { children = [], groupOperator } = condition;
58
+ if (groupOperator === ConditionOperator.AND) {
59
+ return children.every(child => this.evaluate(data, child));
60
+ }
61
+ if (groupOperator === ConditionOperator.OR) {
62
+ return children.some(child => this.evaluate(data, child));
63
+ }
64
+ return false;
65
+ }
66
+ }
67
+
68
+ class MappedLov {
69
+ map = {};
70
+ constructor(initial) {
71
+ if (initial) {
72
+ this.map = initial;
73
+ }
74
+ }
75
+ get(key) {
76
+ return this.map[key] ?? [];
77
+ }
78
+ set(key, value) {
79
+ this.map[key] = value;
80
+ }
81
+ has(key) {
82
+ return key in this.map;
83
+ }
84
+ getRawMap() {
85
+ return Object.fromEntries(this.keys.map(k => [k, this.get(k)]));
86
+ }
87
+ constructorKeys;
88
+ get keys() {
89
+ return [...this.constructorKeys];
90
+ }
91
+ }
92
+
93
+ class ValueChangeEvent {
94
+ static ADD_DAYS = 'ADD_DAYS';
95
+ static ADD_MONTHS = 'ADD_MONTHS';
96
+ static ADD_YEARS = 'ADD_YEARS';
97
+ static GET_DEFAULT_VALUE_REINS = 'GET_DEFAULT_VALUE_REINS';
98
+ }
99
+ class LayoutType {
100
+ static DIVIDER = 'DIVIDER';
101
+ static CONTAINER = 'CONTAINER';
102
+ static GRID_ITEM = 'GRID_ITEM';
103
+ static GRID_CONTAINER = 'GRID_CONTAINER';
104
+ }
105
+
106
+ class DataType {
107
+ static TXT = 'TXT';
108
+ static TXM = 'TXM';
109
+ static NUM = 'NUM';
110
+ static DTE = 'DTE';
111
+ static LNK = 'LNK';
112
+ static TXA = 'TXA';
113
+ static ACT = 'ACT';
114
+ static LOV = 'LOV';
115
+ static LOM = 'LOM';
116
+ static CHK = 'CHK';
117
+ static HTM = 'HTM';
118
+ static GRD = 'GRD';
119
+ static IMG = 'IMG';
120
+ static DRD = 'DRD';
121
+ static DYN = 'DYN';
122
+ }
123
+
124
+ class ActionCode {
125
+ static LIST = 'LST';
126
+ static VIEW = 'VIE';
127
+ static CREATE = 'CRT';
128
+ static VALIDATE = 'VAL';
129
+ static FINALIZE = 'FIN';
130
+ static APPROVAL = 'APP';
131
+ static MODIFY = 'MOD';
132
+ static DELETE = 'DEL';
133
+ static CANCEL = 'CAN';
134
+ static EXTEND_DUE_DATE = 'EXD';
135
+ static CONFIRM = 'CON';
136
+ static BINDING = 'BIN';
137
+ static REVERSE = 'REV';
138
+ static CALCULATE = 'CAL';
139
+ static SEND_FOR_APPROVAL = 'STA';
140
+ static PLACEMENT = 'PLA';
141
+ static DIVIDER = 'divider';
142
+ static RUN = 'RUN';
143
+ static ACTIVATED = 'ACT';
144
+ static TERMINATED = 'TRM';
145
+ static RESET_PASS = 'RST';
146
+ static LOCK = 'LOC';
147
+ static UNLOCK = 'UNL';
148
+ static POSTING = 'POS';
149
+ static UNPOSTING = 'UNP';
150
+ static EXTRACT = 'EXT';
151
+ static BIND = 'BND';
152
+ static NEW = 'NEW';
153
+ static ADD_SUB_TREATY = 'ADD_SUB_TREATY';
154
+ static CORRECTION = 'COR';
155
+ static CONVERT_TO_PROPOSAL = 'PRO';
156
+ static DOWNLOAD = 'PRV';
157
+ static SEND = 'SND';
158
+ static ISSUE = 'ISS';
159
+ static REACTIVATE = 'RAC';
160
+ static PRINT = 'PRT';
161
+ static TERMINATE = 'TRM';
162
+ static ADD_TO_PAYMENT = 'ADD_TO_PAYMENT';
163
+ static ROLLBACK = 'ROL';
164
+ }
165
+ const ACTION_MAPPER = {
166
+ [ActionCode.CREATE]: getActionNew,
167
+ [ActionCode.VIEW]: getActionView,
168
+ [ActionCode.MODIFY]: getActionModify,
169
+ [ActionCode.DELETE]: getActionDelete,
170
+ [ActionCode.VALIDATE]: getActionValidate,
171
+ [ActionCode.EXTRACT]: getActionExtract,
172
+ [ActionCode.ADD_TO_PAYMENT]: getActionAddToPayment,
173
+ [ActionCode.ACTIVATED]: getActionActivated,
174
+ [ActionCode.TERMINATED]: getActionTerminate,
175
+ [ActionCode.RESET_PASS]: getActionResetPassword,
176
+ [ActionCode.LOCK]: getActionLock,
177
+ [ActionCode.UNLOCK]: getActionUnlock,
178
+ };
179
+ function getActionView(disabled = false) {
180
+ return {
181
+ value: ActionCode.VIEW,
182
+ text: 'View',
183
+ icon: 'eye',
184
+ disabled,
185
+ };
186
+ }
187
+ function getActionRollback(disabled = false) {
188
+ return {
189
+ value: ActionCode.ROLLBACK,
190
+ text: 'Rollback',
191
+ icon: 'undo',
192
+ disabled,
193
+ };
194
+ }
195
+ function getActionNew(disabled = false) {
196
+ return {
197
+ value: ActionCode.NEW,
198
+ text: 'New',
199
+ icon: 'add',
200
+ disabled,
201
+ };
202
+ }
203
+ function getActionSend(disabled = false) {
204
+ return {
205
+ value: ActionCode.SEND,
206
+ text: 'Send to Ceding',
207
+ icon: 'swap_horiz',
208
+ disabled,
209
+ };
210
+ }
211
+ function getActionAddSubTreaty(disabled = false) {
212
+ return {
213
+ value: ActionCode.ADD_SUB_TREATY,
214
+ text: 'Add Sub Treaty',
215
+ icon: 'add',
216
+ disabled,
217
+ };
218
+ }
219
+ function getActionCorrection(disabled = false) {
220
+ return {
221
+ value: ActionCode.CORRECTION,
222
+ text: 'Correction',
223
+ icon: 'list',
224
+ disabled,
225
+ };
226
+ }
227
+ function getActionConvertToProposal(disabled = false) {
228
+ return {
229
+ value: ActionCode.CONVERT_TO_PROPOSAL,
230
+ text: 'Convert to Proposal',
231
+ icon: 'published_with_changes',
232
+ disabled,
233
+ };
234
+ }
235
+ function getActionBind(disabled = false) {
236
+ return {
237
+ value: ActionCode.BIND,
238
+ text: 'Bind',
239
+ icon: 'done',
240
+ disabled,
241
+ };
242
+ }
243
+ function getActionPosting(disabled = false) {
244
+ return {
245
+ value: ActionCode.POSTING,
246
+ text: 'Posting',
247
+ icon: 'redo',
248
+ disabled,
249
+ };
250
+ }
251
+ function getActionExtract(disabled = false) {
252
+ return {
253
+ value: ActionCode.EXTRACT,
254
+ text: 'Extract',
255
+ icon: 'functions',
256
+ disabled,
257
+ };
258
+ }
259
+ function getActionUnposting(disabled = false) {
260
+ return {
261
+ value: ActionCode.UNPOSTING,
262
+ text: 'UnPosting',
263
+ icon: 'undo',
264
+ disabled,
265
+ };
266
+ }
267
+ function getActionRun(disabled = false) {
268
+ return {
269
+ value: ActionCode.RUN,
270
+ text: 'Run',
271
+ icon: 'done',
272
+ disabled,
273
+ };
274
+ }
275
+ function getActionValidate(disabled = false) {
276
+ return {
277
+ value: ActionCode.VALIDATE,
278
+ text: 'Validate',
279
+ icon: 'done',
280
+ disabled,
281
+ };
282
+ }
283
+ function getActionAddToPayment(disabled = false) {
284
+ return {
285
+ value: ActionCode.ADD_TO_PAYMENT,
286
+ text: 'Add to Payment',
287
+ icon: 'done',
288
+ disabled,
289
+ };
290
+ }
291
+ function getActionIssue(disabled = false) {
292
+ return {
293
+ value: ActionCode.ISSUE,
294
+ text: 'Issue',
295
+ icon: 'done',
296
+ disabled,
297
+ };
298
+ }
299
+ function getActionReactivate(disabled = false) {
300
+ return {
301
+ value: ActionCode.REACTIVATE,
302
+ text: 'Reactivate',
303
+ icon: 'done',
304
+ disabled,
305
+ };
306
+ }
307
+ function getActionDownload(disabled = false) {
308
+ return {
309
+ value: ActionCode.DOWNLOAD,
310
+ text: 'Preview',
311
+ icon: 'download',
312
+ disabled,
313
+ };
314
+ }
315
+ function getActionFinalize(disabled = false) {
316
+ return {
317
+ value: ActionCode.FINALIZE,
318
+ text: 'Finalize',
319
+ icon: 'timeline',
320
+ disabled,
321
+ };
322
+ }
323
+ function getActionSendForApproval(disabled = false, text = 'Send for Approval') {
324
+ return {
325
+ value: ActionCode.SEND_FOR_APPROVAL,
326
+ text,
327
+ icon: 'send',
328
+ disabled,
329
+ };
330
+ }
331
+ function getActionPlacement(disabled = false, text = 'Placement') {
332
+ return {
333
+ value: ActionCode.PLACEMENT,
334
+ text,
335
+ icon: 'swap_horiz',
336
+ disabled,
337
+ };
338
+ }
339
+ function getActionCalculate(disabled = false) {
340
+ return {
341
+ value: ActionCode.CALCULATE,
342
+ text: 'Calculate',
343
+ icon: 'calculate',
344
+ disabled,
345
+ };
346
+ }
347
+ function getActionConfirm(disabled = false) {
348
+ return {
349
+ value: ActionCode.CONFIRM,
350
+ text: 'Confirmation',
351
+ icon: 'star',
352
+ disabled,
353
+ };
354
+ }
355
+ function getActionBinding(disabled = false) {
356
+ return {
357
+ value: ActionCode.BINDING,
358
+ text: 'Binding',
359
+ icon: 'star',
360
+ disabled,
361
+ };
362
+ }
363
+ function getActionReverse(disabled = false) {
364
+ return {
365
+ value: ActionCode.REVERSE,
366
+ text: 'Reverse',
367
+ icon: 'undo',
368
+ disabled,
369
+ };
370
+ }
371
+ function getActionDelete(disabled = false) {
372
+ return {
373
+ value: ActionCode.DELETE,
374
+ text: 'Delete',
375
+ icon: 'delete',
376
+ disabled,
377
+ };
378
+ }
379
+ function getActionCancel(disabled = false) {
380
+ return {
381
+ value: ActionCode.CANCEL,
382
+ text: 'Cancel',
383
+ icon: 'close',
384
+ disabled,
385
+ };
386
+ }
387
+ function getActionExtendDueDate(disabled = false) {
388
+ return {
389
+ value: ActionCode.EXTEND_DUE_DATE,
390
+ text: 'Extend Due Date',
391
+ icon: 'autorenew',
392
+ disabled,
393
+ };
394
+ }
395
+ function getActionApproval(disabled = false) {
396
+ return {
397
+ value: ActionCode.APPROVAL,
398
+ text: 'Approval',
399
+ icon: 'done_all',
400
+ disabled,
401
+ };
402
+ }
403
+ function getActionPrint(disabled = false) {
404
+ return {
405
+ value: ActionCode.PRINT,
406
+ text: 'Print',
407
+ icon: 'print',
408
+ disabled,
409
+ };
410
+ }
411
+ function getActionDivider() {
412
+ return {
413
+ value: ActionCode.VALIDATE,
414
+ text: 'Validate',
415
+ icon: 'done',
416
+ disabled: true,
417
+ };
418
+ }
419
+ function getActionModify(disabled = false) {
420
+ return {
421
+ value: ActionCode.MODIFY,
422
+ text: 'Modify',
423
+ icon: 'edit',
424
+ disabled,
425
+ };
426
+ }
427
+ function getActionActivated(disabled = false) {
428
+ return {
429
+ value: ActionCode.ACTIVATED,
430
+ text: 'Activate',
431
+ icon: 'done',
432
+ disabled,
433
+ };
434
+ }
435
+ function getActionTerminated(disabled = false) {
436
+ return {
437
+ value: ActionCode.TERMINATED,
438
+ text: 'Terminate',
439
+ icon: 'close',
440
+ disabled,
441
+ };
442
+ }
443
+ function getActionResetPassword(disabled = false) {
444
+ return {
445
+ value: ActionCode.RESET_PASS,
446
+ text: 'Reset Password',
447
+ icon: 'settings_backup_restore',
448
+ disabled,
449
+ };
450
+ }
451
+ function getActionLock(disabled = false) {
452
+ return {
453
+ value: ActionCode.LOCK,
454
+ text: 'Lock',
455
+ icon: 'lock',
456
+ disabled,
457
+ };
458
+ }
459
+ function getActionUnlock(disabled = false) {
460
+ return {
461
+ value: ActionCode.UNLOCK,
462
+ text: 'Unlock',
463
+ icon: 'done',
464
+ disabled,
465
+ };
466
+ }
467
+ function getActionTerminate(disabled = false, text = 'Terminate') {
468
+ return {
469
+ value: ActionCode.TERMINATE,
470
+ text,
471
+ icon: 'close',
472
+ disabled,
473
+ };
474
+ }
475
+
476
+ class PageMode {
477
+ static VIEW = 'View';
478
+ static MODIFY = 'Modify';
479
+ static ADD = 'New';
480
+ }
481
+
482
+ function extractGridItems(layoutItems, existingGridItems = []) {
483
+ layoutItems.forEach((item) => {
484
+ if (item.gridItem) {
485
+ existingGridItems.push(item.gridItem);
486
+ }
487
+ if (item.children?.length > 0) {
488
+ extractGridItems(item.children, existingGridItems);
489
+ }
490
+ });
491
+ return existingGridItems;
492
+ }
493
+ function createFormGroup(gridItems, module, lov) {
494
+ const formGroup = new FormGroup({});
495
+ gridItems.forEach(gridItem => {
496
+ const validators = [];
497
+ // if (gridItem.required) {
498
+ // validators.push(Validators.required);
499
+ // }
500
+ let value = null;
501
+ if (gridItem.dataType === DataType.CHK) {
502
+ value = false;
503
+ }
504
+ const formControl = new FormControl(value, validators);
505
+ if (gridItem.fixedValue !== null && gridItem.fixedValue !== undefined) {
506
+ formControl.setValue(gridItem.fixedValue);
507
+ // formControl.removeValidators(Validators.required);
508
+ }
509
+ formGroup.addControl(gridItem.id, formControl);
510
+ });
511
+ gridItems.forEach(gridItem => {
512
+ if (gridItem?.lovDependency) {
513
+ const dependencies = Array.isArray(gridItem.lovDependency) ? gridItem.lovDependency : [gridItem.lovDependency];
514
+ lov[gridItem.lov] = [];
515
+ dependencies.forEach(dep => {
516
+ const depControl = formGroup.get(dep.dependentTo);
517
+ if (!depControl)
518
+ return;
519
+ depControl.valueChanges
520
+ .subscribe(() => {
521
+ lov[gridItem.lov] = lov['all'].filter((l) => {
522
+ if (l.lovType !== gridItem.lov)
523
+ return false;
524
+ return dependencies.every(d => {
525
+ const depValue = formGroup.get(d.dependentTo)?.value;
526
+ return depValue == null || l[d.filterKey]?.split(',').includes(depValue);
527
+ });
528
+ });
529
+ const currentFormControl = formGroup.get(gridItem.id);
530
+ const currentValue = currentFormControl.value;
531
+ const currentLov = lov[gridItem.lov];
532
+ if (gridItem.dataType === DataType.LOM) {
533
+ const newValue = currentValue?.filter(v => currentLov.some(l => l.lovCode === v));
534
+ currentFormControl.setValue(newValue);
535
+ }
536
+ else {
537
+ if (!currentLov.find(l => l.lovCode === currentValue)) {
538
+ currentFormControl.patchValue(null);
539
+ }
540
+ }
541
+ });
542
+ });
543
+ }
544
+ });
545
+ if (module.id) {
546
+ const idValue = module.id.endsWith("ID") ? 0 : null;
547
+ formGroup.addControl(module.id, new FormControl(idValue));
548
+ }
549
+ return formGroup;
550
+ }
551
+
552
+ function removeEmptyObject(obj) {
553
+ const result = {};
554
+ Object.entries(obj).forEach(([k, v]) => {
555
+ if (v !== null && v !== '') {
556
+ result[k] = v;
557
+ }
558
+ });
559
+ return result;
560
+ }
561
+ function filterQueryParams(obj) {
562
+ obj = cloneDeep(obj);
563
+ obj = removeEmptyObject(obj);
564
+ const result = {};
565
+ Object.entries(obj).forEach(([k, v]) => {
566
+ if (isArray(v)) {
567
+ let temp = '';
568
+ v.forEach((e, i) => {
569
+ temp += e;
570
+ if (v.length - 1 !== i) {
571
+ temp += `,`;
572
+ }
573
+ });
574
+ result[k] = temp;
575
+ }
576
+ else if (v instanceof Date) {
577
+ result[k] = toDateString(v);
578
+ }
579
+ else {
580
+ result[k] = v;
581
+ }
582
+ });
583
+ return result;
584
+ }
585
+ function cloneDeep(value, visited = new WeakMap()) {
586
+ // Handle primitive types and functions
587
+ if (value === null || typeof value !== 'object')
588
+ return value;
589
+ // Handle circular references
590
+ if (visited.has(value))
591
+ return visited.get(value);
592
+ // Clone array
593
+ if (isArray(value)) {
594
+ const arrCopy = [];
595
+ visited.set(value, arrCopy);
596
+ for (let i = 0; i < value.length; i++) {
597
+ arrCopy[i] = cloneDeep(value[i], visited);
598
+ }
599
+ return arrCopy;
600
+ }
601
+ // Clone object
602
+ const objCopy = {};
603
+ visited.set(value, objCopy);
604
+ for (const key in value) {
605
+ if (value.hasOwnProperty(key)) {
606
+ objCopy[key] = cloneDeep(value[key], visited);
607
+ }
608
+ }
609
+ return objCopy;
610
+ }
611
+ function isArray(value) {
612
+ return Object.prototype.toString.call(value) === '[object Array]';
613
+ }
614
+ function arrayToString(input) {
615
+ let temp = '';
616
+ input.forEach((e, i) => {
617
+ temp += e;
618
+ if (input.length - 1 !== i) {
619
+ temp += `,`;
620
+ }
621
+ });
622
+ return temp;
623
+ }
624
+ function downloadFile(data, fileName = 'excel.xlsx') {
625
+ let blob = new Blob([data]);
626
+ let url = window.URL.createObjectURL(blob);
627
+ const a = document.createElement('a');
628
+ a.href = url;
629
+ a.download = fileName;
630
+ a.click();
631
+ }
632
+ function previewPDF(data, fileName = 'report.pdf') {
633
+ let blob = new Blob([data], { type: 'application/pdf' });
634
+ let url = window.URL.createObjectURL(blob);
635
+ window.open(url, '_blank');
636
+ }
637
+ function constructUrlWithQueryParams(baseUrl, queryParams) {
638
+ const queryString = Object.keys(queryParams).map((key) => key + '=' + queryParams[key]).join('&');
639
+ return `${baseUrl}?${queryString}`;
640
+ }
641
+ function toDateString(date) {
642
+ return date.toDateString();
643
+ }
644
+
645
+ function mapLov(input, lov) {
646
+ const result = {};
647
+ Object.keys(input).forEach(key => {
648
+ result[key] = lov.filter(l => l.lovType === input[key]);
649
+ });
650
+ result['all'] = lov;
651
+ return result;
652
+ }
653
+ function mapOriginalLov(lov) {
654
+ const result = lov.reduce((acc, item) => {
655
+ const key = item.lovType; // The property to group by
656
+ if (!acc[key]) {
657
+ acc[key] = []; // Initialize the group if it doesn't exist
658
+ }
659
+ acc[key].push(item); // Add the current item to the group
660
+ return acc;
661
+ }, {});
662
+ result['all'] = lov;
663
+ return result;
664
+ }
665
+
666
+ class ModeSignalHelper {
667
+ isView;
668
+ isModify;
669
+ isAdd;
670
+ constructor(mode) {
671
+ // Destructuring the returned object from the helper method
672
+ const { isView, isModify, isAdd } = ModeSignalHelper.createModeSignals(mode);
673
+ this.isView = isView;
674
+ this.isModify = isModify;
675
+ this.isAdd = isAdd;
676
+ }
677
+ /**
678
+ * Generates computed signals for the provided mode signal.
679
+ */
680
+ static createModeSignals(mode) {
681
+ const isView = computed(() => mode() === PageMode.VIEW || mode() === 'detail', /* @ts-ignore */
682
+ ...(ngDevMode ? [{ debugName: "isView" }] : /* istanbul ignore next */ []));
683
+ const isModify = computed(() => mode() === PageMode.MODIFY || mode() === 'modify', /* @ts-ignore */
684
+ ...(ngDevMode ? [{ debugName: "isModify" }] : /* istanbul ignore next */ []));
685
+ const isAdd = computed(() => mode() === PageMode.ADD, /* @ts-ignore */
686
+ ...(ngDevMode ? [{ debugName: "isAdd" }] : /* istanbul ignore next */ []));
687
+ return { isView: isView, isModify, isAdd };
688
+ }
689
+ }
690
+
691
+ function sortSequence(a, b) {
692
+ // First compare by sequenceNo
693
+ if (a.sequenceNo < b.sequenceNo)
694
+ return -1;
695
+ if (a.sequenceNo > b.sequenceNo)
696
+ return 1;
697
+ // If sequenceNo is the same, compare by lovName
698
+ if (a.lovName < b.lovName)
699
+ return -1;
700
+ if (a.lovName > b.lovName)
701
+ return 1;
702
+ // If both sequenceNo and lovName are the same
703
+ return 0;
704
+ }
705
+
706
+ function trackChanges(oldArray, newArray, keysToCompare, idKey) {
707
+ let result = [];
708
+ // Helper function to create a unique key based on specific fields
709
+ function createKey(item, keys) {
710
+ return keys
711
+ .map(key => {
712
+ let value = item[key];
713
+ if (Array.isArray(value)) {
714
+ return value.slice().sort().join('+'); // Sort and join array elements using '+'
715
+ }
716
+ return value;
717
+ })
718
+ .join('|');
719
+ }
720
+ // Convert old and new arrays to maps for easier comparison
721
+ let oldMap = new Map(oldArray.map(item => [createKey(item, keysToCompare), item]));
722
+ let newMap = new Map(newArray.map(item => [createKey(item, keysToCompare), item]));
723
+ // Track deleted and unchanged/modified items
724
+ for (let [key, oldItem] of oldMap) {
725
+ const modifiedValue = checkExist(newMap, idKey, oldItem[idKey]);
726
+ if (!newMap.has(key)) {
727
+ if (modifiedValue) {
728
+ result.push({ ...modifiedValue, action: 'MOD' }); // Deleted
729
+ }
730
+ else {
731
+ result.push({ ...oldItem, action: 'DEL' }); // Deleted
732
+ }
733
+ }
734
+ }
735
+ // Track created items
736
+ for (let [key, newItem] of newMap) {
737
+ if (!oldMap.has(key) && !newItem[idKey]) {
738
+ result.push({ ...newItem, action: 'CRT' }); // Created
739
+ }
740
+ }
741
+ return result;
742
+ }
743
+ function checkExist(myMap, idKey, value) {
744
+ if (!value) {
745
+ return false;
746
+ }
747
+ for (let [key, myItem] of myMap) {
748
+ if (myItem[idKey] === value) {
749
+ return myItem;
750
+ }
751
+ }
752
+ return false;
753
+ }
754
+
755
+ class ActionCodePipe {
756
+ actionMapper = ACTION_MAPPER;
757
+ transform(value) {
758
+ if (this.actionMapper.hasOwnProperty(value)) {
759
+ return this.actionMapper[value].text;
760
+ }
761
+ return value;
762
+ }
763
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
764
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.1.5", ngImport: i0, type: ActionCodePipe, isStandalone: true, name: "actionCode" });
765
+ }
766
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ActionCodePipe, decorators: [{
767
+ type: Pipe,
768
+ args: [{
769
+ name: 'actionCode'
770
+ }]
771
+ }] });
772
+
773
+ class NullPipe {
774
+ transform(value) {
775
+ try {
776
+ if (value === null || value === undefined || (Array.isArray(value) && value.length === 0) || value === '') {
777
+ return "-";
778
+ }
779
+ else {
780
+ return value;
781
+ }
782
+ }
783
+ catch (e) {
784
+ return '-';
785
+ }
786
+ }
787
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: NullPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
788
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.1.5", ngImport: i0, type: NullPipe, isStandalone: true, name: "null" });
789
+ }
790
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: NullPipe, decorators: [{
791
+ type: Pipe,
792
+ args: [{
793
+ name: 'null',
794
+ standalone: true
795
+ }]
796
+ }] });
797
+
798
+ class BadgeDirective {
799
+ el;
800
+ renderer;
801
+ nxeBadge = ''; // Badge text
802
+ badgeColor = 'red'; // Default badge color
803
+ badgePosition = 'top-right';
804
+ badgeElement = null;
805
+ constructor(el, renderer) {
806
+ this.el = el;
807
+ this.renderer = renderer;
808
+ }
809
+ ngOnChanges() {
810
+ this.updateBadge();
811
+ }
812
+ updateBadge() {
813
+ if (this.badgeElement) {
814
+ this.renderer.removeChild(this.el.nativeElement, this.badgeElement);
815
+ }
816
+ if (!this.nxeBadge)
817
+ return;
818
+ this.badgeElement = this.renderer.createElement('div');
819
+ this.renderer.addClass(this.badgeElement, 'nxe-badge');
820
+ this.renderer.setStyle(this.badgeElement, 'z-index', 999);
821
+ this.renderer.setStyle(this.badgeElement, 'background', this.badgeColor);
822
+ this.renderer.setProperty(this.badgeElement, 'innerText', this.nxeBadge.toString());
823
+ this.applyPosition();
824
+ this.renderer.appendChild(this.el.nativeElement, this.badgeElement);
825
+ }
826
+ applyPosition() {
827
+ const positionStyles = {
828
+ 'top-right': 'top: 0; right: 0;',
829
+ 'top-left': 'top: 0; left: 0;',
830
+ 'bottom-right': 'bottom: 0; right: 0;',
831
+ 'bottom-left': 'bottom: 0; left: 0;',
832
+ };
833
+ if (this.badgeElement) {
834
+ this.renderer.setStyle(this.badgeElement, 'position', 'absolute');
835
+ this.renderer.setStyle(this.badgeElement, 'transform', 'translate(50%, -50%)');
836
+ this.renderer.setAttribute(this.badgeElement, 'style', positionStyles[this.badgePosition]);
837
+ }
838
+ }
839
+ ngAfterViewInit() {
840
+ if (this.el) {
841
+ this.renderer.setStyle(this.el.nativeElement, 'position', 'relative');
842
+ }
843
+ }
844
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: BadgeDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
845
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.5", type: BadgeDirective, isStandalone: true, selector: "[nxeBadge]", inputs: { nxeBadge: "nxeBadge", badgeColor: "badgeColor", badgePosition: "badgePosition" }, usesOnChanges: true, ngImport: i0 });
846
+ }
847
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: BadgeDirective, decorators: [{
848
+ type: Directive,
849
+ args: [{
850
+ selector: '[nxeBadge]'
851
+ }]
852
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { nxeBadge: [{
853
+ type: Input
854
+ }], badgeColor: [{
855
+ type: Input
856
+ }], badgePosition: [{
857
+ type: Input
858
+ }] } });
859
+
860
+ class NxeMenu {
861
+ el;
862
+ overlay;
863
+ viewContainerRef;
864
+ menuTemplate;
865
+ overlayRef = null;
866
+ constructor(el, overlay, viewContainerRef) {
867
+ this.el = el;
868
+ this.overlay = overlay;
869
+ this.viewContainerRef = viewContainerRef;
870
+ }
871
+ toggleMenu(event) {
872
+ event.stopPropagation();
873
+ if (this.overlayRef) {
874
+ this.closeMenu();
875
+ }
876
+ else {
877
+ this.openMenu();
878
+ }
879
+ }
880
+ onClickOutside(event) {
881
+ if (this.overlayRef && !this.el.nativeElement.contains(event.target)) {
882
+ this.closeMenu();
883
+ }
884
+ }
885
+ openMenu() {
886
+ const positionStrategy = this.overlay
887
+ .position()
888
+ .flexibleConnectedTo(this.el.nativeElement)
889
+ .withPositions([
890
+ { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
891
+ { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
892
+ ]);
893
+ this.overlayRef = this.overlay.create({ positionStrategy });
894
+ // Fix: Use TemplatePortal instead of ComponentPortal
895
+ const portal = new TemplatePortal(this.menuTemplate, this.viewContainerRef);
896
+ this.overlayRef.attach(portal);
897
+ }
898
+ closeMenu() {
899
+ this.overlayRef?.detach();
900
+ this.overlayRef = null;
901
+ }
902
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: NxeMenu, deps: [{ token: i0.ElementRef }, { token: i1.Overlay }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
903
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.5", type: NxeMenu, isStandalone: true, selector: "[nxeMenu]", inputs: { menuTemplate: ["nxeMenu", "menuTemplate"] }, host: { listeners: { "click": "toggleMenu($event)", "document:click": "onClickOutside($event)" } }, ngImport: i0 });
904
+ }
905
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: NxeMenu, decorators: [{
906
+ type: Directive,
907
+ args: [{
908
+ selector: '[nxeMenu]',
909
+ }]
910
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.Overlay }, { type: i0.ViewContainerRef }], propDecorators: { menuTemplate: [{
911
+ type: Input,
912
+ args: ['nxeMenu']
913
+ }], toggleMenu: [{
914
+ type: HostListener,
915
+ args: ['click', ['$event']]
916
+ }], onClickOutside: [{
917
+ type: HostListener,
918
+ args: ['document:click', ['$event']]
919
+ }] } });
920
+
921
+ /**
922
+ * Opens a component in a centred, click-to-dismiss backdrop and resolves when it closes.
923
+ *
924
+ * Ported from nextera-library with one required change: `ComponentFactoryResolver` and
925
+ * `resolveComponentFactory()` are Ivy-era shims that no longer exist in Angular 22, so
926
+ * instantiation goes through `createComponent()` instead. The behaviour is the same —
927
+ * the component is created outside any view, attached to the ApplicationRef so it takes
928
+ * part in change detection, and appended to the backdrop element.
929
+ *
930
+ * `data` is assigned onto the instance before the view is attached, so the component sees
931
+ * its inputs on first render rather than one cycle late.
932
+ */
933
+ class NxeModalService {
934
+ injector = inject(Injector);
935
+ environmentInjector = inject(EnvironmentInjector);
936
+ applicationRef = inject(ApplicationRef);
937
+ renderer = inject(RendererFactory2).createRenderer(null, null);
938
+ componentRef;
939
+ backdropElement;
940
+ closeSubject;
941
+ open(component, data) {
942
+ this.closeSubject = new Subject();
943
+ this.createBackdrop();
944
+ const componentRef = createComponent(component, {
945
+ environmentInjector: this.environmentInjector,
946
+ elementInjector: this.injector,
947
+ });
948
+ if (data) {
949
+ Object.assign(componentRef.instance, data);
950
+ }
951
+ this.applicationRef.attachView(componentRef.hostView);
952
+ this.renderer.appendChild(this.backdropElement, componentRef.location.nativeElement);
953
+ this.componentRef = componentRef;
954
+ return this.closeSubject.asObservable();
955
+ }
956
+ close(result) {
957
+ if (this.componentRef) {
958
+ this.applicationRef.detachView(this.componentRef.hostView);
959
+ this.componentRef.destroy();
960
+ this.componentRef = undefined;
961
+ }
962
+ if (this.backdropElement) {
963
+ this.renderer.removeChild(document.body, this.backdropElement);
964
+ this.backdropElement = undefined;
965
+ }
966
+ this.closeSubject?.next(result);
967
+ this.closeSubject?.complete();
968
+ }
969
+ createBackdrop() {
970
+ const el = this.renderer.createElement('div');
971
+ this.renderer.addClass(el, 'modal-backdrop');
972
+ const style = {
973
+ position: 'fixed',
974
+ top: '0',
975
+ left: '0',
976
+ width: '100%',
977
+ height: '100%',
978
+ background: 'rgba(0, 0, 0, 0.5)',
979
+ 'z-index': '1000',
980
+ display: 'flex',
981
+ 'align-items': 'center',
982
+ 'justify-content': 'center',
983
+ };
984
+ for (const [prop, value] of Object.entries(style)) {
985
+ this.renderer.setStyle(el, prop, value);
986
+ }
987
+ this.renderer.listen(el, 'click', () => this.close());
988
+ document.body.appendChild(el);
989
+ this.backdropElement = el;
990
+ }
991
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: NxeModalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
992
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: NxeModalService, providedIn: 'root' });
993
+ }
994
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: NxeModalService, decorators: [{
995
+ type: Injectable,
996
+ args: [{ providedIn: 'root' }]
997
+ }] });
998
+
999
+ // @nexterajs/app-kit — public API.
1000
+ //
1001
+ // The metadata-driven application framework that used to ship inside nextera-library:
1002
+ // module/page metadata, action constants, and the pure helpers built on them. It is
1003
+ // deliberately separate from @nexterajs/ui — this half is coupled to a specific backend
1004
+ // shape, and an app that only wants components should not have to take it.
1005
+ /* Module metadata — the shape a module declares its pages with */
1006
+
1007
+ /**
1008
+ * Generated bundle index. Do not edit.
1009
+ */
1010
+
1011
+ export { ACTION_MAPPER, ActionCode, ActionCodePipe, BadgeDirective, BooleanOperator, ConditionEvaluator, ConditionOperator, ConditionType, DataType, LayoutType, MappedLov, ModeSignalHelper, NullPipe, NxeMenu, NxeModalService, PageMode, ValueChangeEvent, ValueOperator, arrayToString, constructUrlWithQueryParams, createFormGroup, downloadFile, extractGridItems, filterQueryParams, getActionActivated, getActionAddSubTreaty, getActionAddToPayment, getActionApproval, getActionBind, getActionBinding, getActionCalculate, getActionCancel, getActionConfirm, getActionConvertToProposal, getActionCorrection, getActionDelete, getActionDivider, getActionDownload, getActionExtendDueDate, getActionExtract, getActionFinalize, getActionIssue, getActionLock, getActionModify, getActionNew, getActionPlacement, getActionPosting, getActionPrint, getActionReactivate, getActionResetPassword, getActionReverse, getActionRollback, getActionRun, getActionSend, getActionSendForApproval, getActionTerminate, getActionTerminated, getActionUnlock, getActionUnposting, getActionValidate, getActionView, mapLov, mapOriginalLov, previewPDF, removeEmptyObject, sortSequence, toDateString, trackChanges };
1012
+ //# sourceMappingURL=nexterajs-app-kit.mjs.map