@acorex/platform 19.4.9 → 19.4.10

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.
@@ -1,7 +1,7 @@
1
1
  import { signalStore, withState, withComputed, withMethods, patchState } from '@ngrx/signals';
2
2
  import { get, isPlainObject, set, isArray, merge, isNil, isObjectLike, transform, isEmpty, cloneDeep, isEqual, isUndefined, endsWith, startsWith, includes, lte, gte, lt, gt, orderBy } from 'lodash-es';
3
3
  import * as i0 from '@angular/core';
4
- import { computed, InjectionToken, inject, Injectable, input, effect, Directive, EventEmitter, HostListener, Output, ViewContainerRef, ElementRef, signal, Pipe, provideAppInitializer } from '@angular/core';
4
+ import { computed, InjectionToken, inject, Injectable, input, effect, Directive, EventEmitter, HostListener, Output, ViewContainerRef, ElementRef, provideAppInitializer, signal, Pipe } from '@angular/core';
5
5
  import { Subject, interval } from 'rxjs';
6
6
  import { AXCalendarService } from '@acorex/core/date-time';
7
7
  import { startWith, map } from 'rxjs/operators';
@@ -856,358 +856,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
856
856
  args: [{ providedIn: 'root' }]
857
857
  }] });
858
858
 
859
- class AXPCountdownPipe {
859
+ class AXPAppStartUpService {
860
860
  constructor() {
861
- this.calendarService = inject(AXCalendarService);
862
- this.countdownSignal = signal(this.setupTimer());
863
- this.targetDate = 0;
864
- this.prevValue = 0;
861
+ this.tasks = [];
865
862
  }
866
- transform(value) {
867
- if (this.prevValue != value) {
868
- this.prevValue = value;
869
- const expireTime = this.calendarService.calendar.add(new Date(), 'second', value).date;
870
- this.updateTargetDate(expireTime.toISOString());
871
- }
872
- return this.countdownSignal();
863
+ registerTask(task) {
864
+ this.tasks.push(task);
873
865
  }
874
- setupTimer() {
875
- return interval(1000).pipe(startWith(0), map(() => {
876
- const diff = this.targetDate - new Date().getTime();
877
- if (diff < 0) {
878
- return "Time's up!";
879
- }
880
- const times = [86400, 3600, 60, 1].map((seconds) => Math.floor((diff / 1000 / seconds) % (seconds === 1 ? 60 : 24)));
881
- const labels = ['d', 'h', 'm', 's'];
882
- return times
883
- .map((t, i) => (t > 0 || i === 3 ? `${t}${labels[i]}` : ''))
884
- .join(' ')
885
- .trim();
886
- }));
866
+ async runAllTasks() {
867
+ for (const task of this.tasks.sort((a, b) => a.priority - b.priority)) {
868
+ console.log(`Running "${task.statusText}" with priority "${task.priority}"`);
869
+ this.updateStatus(task.statusText);
870
+ await task.run();
871
+ }
887
872
  }
888
- updateTargetDate(value) {
889
- this.targetDate = new Date(value).getTime();
873
+ updateStatus(status) {
874
+ const loadingText = document.querySelector('#loadingText');
875
+ if (loadingText) {
876
+ loadingText.innerHTML = status;
877
+ }
890
878
  }
891
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPCountdownPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
892
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.10", ngImport: i0, type: AXPCountdownPipe, isStandalone: true, name: "countdown", pure: false }); }
879
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPAppStartUpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
880
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPAppStartUpService, providedIn: 'root' }); }
893
881
  }
894
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPCountdownPipe, decorators: [{
895
- type: Pipe,
882
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPAppStartUpService, decorators: [{
883
+ type: Injectable,
896
884
  args: [{
897
- name: 'countdown',
898
- pure: false,
899
- standalone: true,
885
+ providedIn: 'root',
900
886
  }]
901
887
  }] });
902
-
903
- const loggingEnabled = false; // Set to true to enable logging, false to disable
904
- function applyCondition(item, condition) {
905
- const rawValue = condition.field ? get(item, condition.field) : null;
906
- const itemValue = typeof rawValue === 'string' ? rawValue.toLowerCase() : rawValue;
907
- const conditionValue = typeof condition.value === 'string' ? condition.value.toLowerCase() : condition.value;
908
- // Conditional Logging for debugging
909
- if (loggingEnabled) {
910
- console.log('Condition:', condition);
911
- console.log('Item Value:', itemValue);
912
- console.log('Condition Value:', conditionValue);
913
- }
914
- let result;
915
- const valueToCompare = isNil(condition.field) || condition.field === '' ? conditionValue : itemValue;
916
- const conditionType = condition?.operator?.type;
917
- if (!conditionType) {
918
- return true;
919
- }
920
- switch (conditionType) {
921
- case 'equal':
922
- result = isEqual(valueToCompare, conditionValue);
923
- if (loggingEnabled) {
924
- console.log('Equal check result:', result);
925
- }
926
- break;
927
- case 'notEqual':
928
- result = !isEqual(valueToCompare, conditionValue);
929
- if (loggingEnabled) {
930
- console.log('Not equal check result:', result);
931
- }
932
- break;
933
- case 'greaterThan':
934
- result = gt(valueToCompare, conditionValue);
935
- if (loggingEnabled) {
936
- console.log('Greater than check result:', result);
937
- }
938
- break;
939
- case 'lessThan':
940
- result = lt(valueToCompare, conditionValue);
941
- if (loggingEnabled) {
942
- console.log('Less than check result:', result);
943
- }
944
- break;
945
- case 'greaterThanOrEqual':
946
- result = gte(valueToCompare, conditionValue);
947
- if (loggingEnabled) {
948
- console.log('Greater than or equal check result:', result);
949
- }
950
- break;
951
- case 'lessThanOrEqual':
952
- result = lte(valueToCompare, conditionValue);
953
- if (loggingEnabled) {
954
- console.log('Less than or equal check result:', result);
955
- }
956
- break;
957
- case 'contains':
958
- if (typeof valueToCompare === 'string') {
959
- result = includes(valueToCompare, conditionValue);
960
- }
961
- else if (Array.isArray(valueToCompare)) {
962
- result = includes(valueToCompare.map((val) => val.toString().toLowerCase()), conditionValue);
963
- }
964
- else {
965
- result = false;
966
- }
967
- if (loggingEnabled) {
968
- console.log('Contains check result:', result);
969
- }
970
- break;
971
- case 'notContains':
972
- if (typeof valueToCompare === 'string') {
973
- result = !includes(valueToCompare, conditionValue);
974
- }
975
- else if (Array.isArray(valueToCompare)) {
976
- result = !includes(valueToCompare.map((val) => val.toString().toLowerCase()), conditionValue);
977
- }
978
- else {
979
- result = false;
980
- }
981
- if (loggingEnabled) {
982
- console.log('Not contains check result:', result);
983
- }
984
- break;
985
- case 'startsWith':
986
- result = typeof valueToCompare === 'string' && startsWith(valueToCompare, conditionValue);
987
- if (loggingEnabled) {
988
- console.log('Starts with check result:', result);
989
- }
990
- break;
991
- case 'endsWith':
992
- result = typeof valueToCompare === 'string' && endsWith(valueToCompare, conditionValue);
993
- if (loggingEnabled) {
994
- console.log('Ends with check result:', result);
995
- }
996
- break;
997
- case 'isEmpty':
998
- result = isEmpty(valueToCompare);
999
- if (loggingEnabled) {
1000
- console.log('Is empty check result:', result);
1001
- }
1002
- break;
1003
- case 'isNull':
1004
- result = isNil(valueToCompare);
1005
- if (loggingEnabled) {
1006
- console.log('Is null check result:', result);
1007
- }
1008
- break;
1009
- case 'isNotEmpty':
1010
- result = !isEmpty(valueToCompare);
1011
- if (loggingEnabled) {
1012
- console.log('Is not empty check result:', result);
1013
- }
1014
- break;
1015
- case 'between':
1016
- result = !isNil(valueToCompare) && valueToCompare >= condition.value.from && valueToCompare <= condition.value.to;
1017
- if (loggingEnabled) {
1018
- console.log('Between check result:', result);
1019
- }
1020
- break;
1021
- default:
1022
- result = true;
1023
- if (loggingEnabled) {
1024
- console.log('Default case, returning true');
1025
- }
1026
- }
1027
- return result;
888
+ function initAppFactory(appInitService) {
889
+ return () => appInitService.runAllTasks();
1028
890
  }
1029
- function applyFilterArray(dataArray, filters, logic = 'and') {
1030
- if (filters && filters.length) {
1031
- return dataArray.filter((item) => {
1032
- if (logic === 'and') {
1033
- return filters.every((f) => {
1034
- return f.filters ? applyFilterArray([item], f.filters, f.logic).length > 0 : applyCondition(item, f);
1035
- });
1036
- }
1037
- else {
1038
- // logic === 'or'
1039
- return filters.some((f) => {
1040
- return f.filters ? applyFilterArray([item], f.filters, f.logic).length > 0 : applyCondition(item, f);
1041
- });
1042
- }
1043
- });
1044
- }
1045
- else {
1046
- return dataArray;
891
+ const AXPAppStartUpProvider = provideAppInitializer(() => {
892
+ const initializerFn = initAppFactory(inject(AXPAppStartUpService));
893
+ return initializerFn();
894
+ });
895
+
896
+ function getNestedKeys(obj, prefix = '') {
897
+ let keys = [];
898
+ for (const key in obj) {
899
+ if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
900
+ keys = [...keys, ...getNestedKeys(obj[key], prefix + key + '.')];
901
+ }
902
+ else {
903
+ keys.push(prefix + key);
904
+ }
1047
905
  }
906
+ return keys;
1048
907
  }
1049
- function applySortArray(dataArray, sorts) {
1050
- if (sorts && sorts.length > 0) {
1051
- const sortFields = sorts.map((s) => s.field);
1052
- const sortOrders = sorts.map((s) => s.dir);
1053
- return orderBy(dataArray, sortFields, sortOrders);
908
+
909
+ class AXPImageUrlLogoConfig {
910
+ constructor(url, width, height) {
911
+ this.url = url;
912
+ this.width = width;
913
+ this.height = height;
1054
914
  }
1055
- else
1056
- return dataArray;
1057
915
  }
1058
- function applyPagination(dataArray, skip, take) {
1059
- return dataArray.slice(skip, skip + take);
1060
- }
1061
- async function applyQueryArray(dataArray, query) {
1062
- let result = [...dataArray];
1063
- // Apply filtering
1064
- if (query.filter) {
1065
- result = applyFilterArray(result, [query.filter], query.filter.logic ?? 'and');
1066
- }
1067
- // Store total count before pagination
1068
- const total = result.length;
1069
- // Apply sorting
1070
- if (query.sort && query.sort.length > 0) {
1071
- result = applySortArray(result, query.sort);
1072
- }
1073
- // Apply pagination
1074
- result = applyPagination(result, query.skip, query.take);
1075
- return {
1076
- items: result,
1077
- total,
1078
- };
1079
- }
1080
-
1081
- /**
1082
- * Service for applying and resetting text highlighting within specified HTML elements.
1083
- */
1084
- class AXHighlightService {
1085
- constructor() { }
1086
- /**
1087
- * Highlights all occurrences of a search value within the elements matching the provided query selector.
1088
- *
1089
- * @param querySelector - CSS selector to identify target elements.
1090
- * @param searchValue - Text to search and highlight.
1091
- */
1092
- highlight(querySelector, searchValue) {
1093
- this.clear();
1094
- if (!querySelector || !searchValue) {
1095
- return;
1096
- }
1097
- this.querySelector = querySelector;
1098
- this.searchValue = searchValue;
1099
- const elements = document.querySelectorAll(querySelector);
1100
- elements.forEach((element) => {
1101
- this.applyHighlight(element);
1102
- });
1103
- }
1104
- /**
1105
- * Resets all highlighted text within the elements matching the previously used query selector.
1106
- */
1107
- clear() {
1108
- const elements = document.querySelectorAll(`${this.querySelector} .ax-highlight-text`);
1109
- elements.forEach((element) => {
1110
- let combinedText = '';
1111
- element.querySelectorAll('span').forEach((span) => {
1112
- combinedText += span.textContent;
1113
- });
1114
- const mergedSpan = document.createElement('span');
1115
- mergedSpan.textContent = combinedText;
1116
- element?.parentNode?.replaceChild(mergedSpan, element);
1117
- });
1118
- }
1119
- /**
1120
- * Applies highlighting to a specific element by matching text against the search value.
1121
- *
1122
- * @param element - The HTML element to apply highlights to.
1123
- */
1124
- applyHighlight(element) {
1125
- const searchRegex = new RegExp(`(${this.searchValue})`, 'gi');
1126
- this.recursivelyHighlight(element, searchRegex);
1127
- }
1128
- /**
1129
- * Recursively applies highlighting to text nodes within an element.
1130
- *
1131
- * @param element - The current node being processed.
1132
- * @param searchRegex - Regular expression for matching text to highlight.
1133
- */
1134
- recursivelyHighlight(element, searchRegex) {
1135
- const childNodes = Array.from(element.childNodes);
1136
- childNodes.forEach((node) => {
1137
- if (node.nodeType === Node.TEXT_NODE) {
1138
- const textContent = node.textContent || '';
1139
- if (textContent.match(searchRegex)) {
1140
- const highlightedHTML = this.createHighlightedHTML(textContent, searchRegex);
1141
- const tempContainer = document.createElement('div');
1142
- tempContainer.innerHTML = highlightedHTML;
1143
- const fragment = document.createDocumentFragment();
1144
- Array.from(tempContainer.childNodes).forEach((child) => fragment.appendChild(child));
1145
- node.replaceWith(fragment);
1146
- }
1147
- }
1148
- else if (node.nodeType === Node.ELEMENT_NODE) {
1149
- this.recursivelyHighlight(node, searchRegex);
1150
- }
1151
- });
1152
- }
1153
- /**
1154
- * Generates the HTML structure for highlighted text.
1155
- *
1156
- * @param textContent - The original text content to process.
1157
- * @param searchRegex - Regular expression for matching text to highlight.
1158
- * @returns A string of HTML with highlighted portions wrapped in span elements.
1159
- */
1160
- createHighlightedHTML(textContent, searchRegex) {
1161
- let parts = [];
1162
- let match;
1163
- let lastIndex = 0;
1164
- let resultHTML = '<span class="ax-highlight-text">';
1165
- while ((match = searchRegex.exec(textContent)) !== null) {
1166
- if (match.index > lastIndex) {
1167
- resultHTML += `<span>${textContent.slice(lastIndex, match.index)}</span>`;
1168
- }
1169
- resultHTML += `<span class="ax-highlight">${match[0]}</span>`;
1170
- lastIndex = searchRegex.lastIndex;
1171
- }
1172
- if (lastIndex < textContent.length) {
1173
- resultHTML += `<span>${textContent.slice(lastIndex)}</span>`;
1174
- }
1175
- resultHTML += '</span>';
1176
- return resultHTML;
1177
- }
1178
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXHighlightService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1179
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXHighlightService, providedIn: 'root' }); }
1180
- }
1181
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXHighlightService, decorators: [{
1182
- type: Injectable,
1183
- args: [{
1184
- providedIn: 'root',
1185
- }]
1186
- }], ctorParameters: () => [] });
1187
-
1188
- function getNestedKeys(obj, prefix = '') {
1189
- let keys = [];
1190
- for (const key in obj) {
1191
- if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
1192
- keys = [...keys, ...getNestedKeys(obj[key], prefix + key + '.')];
1193
- }
1194
- else {
1195
- keys.push(prefix + key);
1196
- }
1197
- }
1198
- return keys;
1199
- }
1200
-
1201
- class AXPImageUrlLogoConfig {
1202
- constructor(url, width, height) {
1203
- this.url = url;
1204
- this.width = width;
1205
- this.height = height;
1206
- }
1207
- }
1208
- class AXPComponentLogoConfig {
1209
- constructor(component) {
1210
- this.component = component;
916
+ class AXPComponentLogoConfig {
917
+ constructor(component) {
918
+ this.component = component;
1211
919
  }
1212
920
  }
1213
921
 
@@ -1512,74 +1220,338 @@ const AXPSystemActions = Object.freeze({
1512
1220
  }
1513
1221
  });
1514
1222
 
1515
- class AXPAppStartUpService {
1223
+ class AXPCountdownPipe {
1516
1224
  constructor() {
1517
- this.tasks = [];
1518
- }
1519
- registerTask(task) {
1520
- this.tasks.push(task);
1225
+ this.calendarService = inject(AXCalendarService);
1226
+ this.countdownSignal = signal(this.setupTimer());
1227
+ this.targetDate = 0;
1228
+ this.prevValue = 0;
1521
1229
  }
1522
- async runAllTasks() {
1523
- for (const task of this.tasks.sort((a, b) => a.priority - b.priority)) {
1524
- console.log(`Running "${task.statusText}" with priority "${task.priority}"`);
1525
- this.updateStatus(task.statusText);
1526
- await task.run();
1230
+ transform(value) {
1231
+ if (this.prevValue != value) {
1232
+ this.prevValue = value;
1233
+ const expireTime = this.calendarService.calendar.add(new Date(), 'second', value).date;
1234
+ this.updateTargetDate(expireTime.toISOString());
1527
1235
  }
1236
+ return this.countdownSignal();
1528
1237
  }
1529
- updateStatus(status) {
1530
- const loadingText = document.querySelector('#loadingText');
1531
- if (loadingText) {
1532
- loadingText.innerHTML = status;
1533
- }
1238
+ setupTimer() {
1239
+ return interval(1000).pipe(startWith(0), map(() => {
1240
+ const diff = this.targetDate - new Date().getTime();
1241
+ if (diff < 0) {
1242
+ return "Time's up!";
1243
+ }
1244
+ const times = [86400, 3600, 60, 1].map((seconds) => Math.floor((diff / 1000 / seconds) % (seconds === 1 ? 60 : 24)));
1245
+ const labels = ['d', 'h', 'm', 's'];
1246
+ return times
1247
+ .map((t, i) => (t > 0 || i === 3 ? `${t}${labels[i]}` : ''))
1248
+ .join(' ')
1249
+ .trim();
1250
+ }));
1534
1251
  }
1535
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPAppStartUpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1536
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPAppStartUpService, providedIn: 'root' }); }
1252
+ updateTargetDate(value) {
1253
+ this.targetDate = new Date(value).getTime();
1254
+ }
1255
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPCountdownPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1256
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.10", ngImport: i0, type: AXPCountdownPipe, isStandalone: true, name: "countdown", pure: false }); }
1537
1257
  }
1538
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPAppStartUpService, decorators: [{
1539
- type: Injectable,
1258
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXPCountdownPipe, decorators: [{
1259
+ type: Pipe,
1540
1260
  args: [{
1541
- providedIn: 'root',
1261
+ name: 'countdown',
1262
+ pure: false,
1263
+ standalone: true,
1542
1264
  }]
1543
1265
  }] });
1544
- function initAppFactory(appInitService) {
1545
- return () => appInitService.runAllTasks();
1546
- }
1547
- const AXPAppStartUpProvider = provideAppInitializer(() => {
1548
- const initializerFn = initAppFactory(inject(AXPAppStartUpService));
1549
- return initializerFn();
1550
- });
1551
1266
 
1552
- class AXPIconResolver {
1267
+ const loggingEnabled = false; // Set to true to enable logging, false to disable
1268
+ function applyCondition(item, condition) {
1269
+ const rawValue = condition.field ? get(item, condition.field) : null;
1270
+ const itemValue = typeof rawValue === 'string' ? rawValue.toLowerCase() : rawValue;
1271
+ const conditionValue = typeof condition.value === 'string' ? condition.value.toLowerCase() : condition.value;
1272
+ // Conditional Logging for debugging
1273
+ if (loggingEnabled) {
1274
+ console.log('Condition:', condition);
1275
+ console.log('Item Value:', itemValue);
1276
+ console.log('Condition Value:', conditionValue);
1277
+ }
1278
+ let result;
1279
+ const valueToCompare = isNil(condition.field) || condition.field === '' ? conditionValue : itemValue;
1280
+ const conditionType = condition?.operator?.type;
1281
+ if (!conditionType) {
1282
+ return true;
1283
+ }
1284
+ switch (conditionType) {
1285
+ case 'equal':
1286
+ result = isEqual(valueToCompare, conditionValue);
1287
+ if (loggingEnabled) {
1288
+ console.log('Equal check result:', result);
1289
+ }
1290
+ break;
1291
+ case 'notEqual':
1292
+ result = !isEqual(valueToCompare, conditionValue);
1293
+ if (loggingEnabled) {
1294
+ console.log('Not equal check result:', result);
1295
+ }
1296
+ break;
1297
+ case 'greaterThan':
1298
+ result = gt(valueToCompare, conditionValue);
1299
+ if (loggingEnabled) {
1300
+ console.log('Greater than check result:', result);
1301
+ }
1302
+ break;
1303
+ case 'lessThan':
1304
+ result = lt(valueToCompare, conditionValue);
1305
+ if (loggingEnabled) {
1306
+ console.log('Less than check result:', result);
1307
+ }
1308
+ break;
1309
+ case 'greaterThanOrEqual':
1310
+ result = gte(valueToCompare, conditionValue);
1311
+ if (loggingEnabled) {
1312
+ console.log('Greater than or equal check result:', result);
1313
+ }
1314
+ break;
1315
+ case 'lessThanOrEqual':
1316
+ result = lte(valueToCompare, conditionValue);
1317
+ if (loggingEnabled) {
1318
+ console.log('Less than or equal check result:', result);
1319
+ }
1320
+ break;
1321
+ case 'contains':
1322
+ if (typeof valueToCompare === 'string') {
1323
+ result = includes(valueToCompare, conditionValue);
1324
+ }
1325
+ else if (Array.isArray(valueToCompare)) {
1326
+ result = includes(valueToCompare.map((val) => val.toString().toLowerCase()), conditionValue);
1327
+ }
1328
+ else {
1329
+ result = false;
1330
+ }
1331
+ if (loggingEnabled) {
1332
+ console.log('Contains check result:', result);
1333
+ }
1334
+ break;
1335
+ case 'notContains':
1336
+ if (typeof valueToCompare === 'string') {
1337
+ result = !includes(valueToCompare, conditionValue);
1338
+ }
1339
+ else if (Array.isArray(valueToCompare)) {
1340
+ result = !includes(valueToCompare.map((val) => val.toString().toLowerCase()), conditionValue);
1341
+ }
1342
+ else {
1343
+ result = false;
1344
+ }
1345
+ if (loggingEnabled) {
1346
+ console.log('Not contains check result:', result);
1347
+ }
1348
+ break;
1349
+ case 'startsWith':
1350
+ result = typeof valueToCompare === 'string' && startsWith(valueToCompare, conditionValue);
1351
+ if (loggingEnabled) {
1352
+ console.log('Starts with check result:', result);
1353
+ }
1354
+ break;
1355
+ case 'endsWith':
1356
+ result = typeof valueToCompare === 'string' && endsWith(valueToCompare, conditionValue);
1357
+ if (loggingEnabled) {
1358
+ console.log('Ends with check result:', result);
1359
+ }
1360
+ break;
1361
+ case 'isEmpty':
1362
+ result = isEmpty(valueToCompare);
1363
+ if (loggingEnabled) {
1364
+ console.log('Is empty check result:', result);
1365
+ }
1366
+ break;
1367
+ case 'isNull':
1368
+ result = isNil(valueToCompare);
1369
+ if (loggingEnabled) {
1370
+ console.log('Is null check result:', result);
1371
+ }
1372
+ break;
1373
+ case 'isNotEmpty':
1374
+ result = !isEmpty(valueToCompare);
1375
+ if (loggingEnabled) {
1376
+ console.log('Is not empty check result:', result);
1377
+ }
1378
+ break;
1379
+ case 'between':
1380
+ result = !isNil(valueToCompare) && valueToCompare >= condition.value.from && valueToCompare <= condition.value.to;
1381
+ if (loggingEnabled) {
1382
+ console.log('Between check result:', result);
1383
+ }
1384
+ break;
1385
+ default:
1386
+ result = true;
1387
+ if (loggingEnabled) {
1388
+ console.log('Default case, returning true');
1389
+ }
1390
+ }
1391
+ return result;
1553
1392
  }
1554
- const AXP_ICON_RESOLVER = new InjectionToken('AXP_ICON_RESOLVER', {
1555
- factory: () => {
1556
- return new AXPIconResolverDefault();
1393
+ function applyFilterArray(dataArray, filters, logic = 'and') {
1394
+ if (filters && filters.length) {
1395
+ return dataArray.filter((item) => {
1396
+ if (logic === 'and') {
1397
+ return filters.every((f) => {
1398
+ return f.filters ? applyFilterArray([item], f.filters, f.logic).length > 0 : applyCondition(item, f);
1399
+ });
1400
+ }
1401
+ else {
1402
+ // logic === 'or'
1403
+ return filters.some((f) => {
1404
+ return f.filters ? applyFilterArray([item], f.filters, f.logic).length > 0 : applyCondition(item, f);
1405
+ });
1406
+ }
1407
+ });
1557
1408
  }
1558
- });
1559
- class AXPIconResolverDefault extends AXPIconResolver {
1560
- async resolve(icon) {
1561
- return icon;
1409
+ else {
1410
+ return dataArray;
1562
1411
  }
1563
1412
  }
1413
+ function applySortArray(dataArray, sorts) {
1414
+ if (sorts && sorts.length > 0) {
1415
+ const sortFields = sorts.map((s) => s.field);
1416
+ const sortOrders = sorts.map((s) => s.dir);
1417
+ return orderBy(dataArray, sortFields, sortOrders);
1418
+ }
1419
+ else
1420
+ return dataArray;
1421
+ }
1422
+ function applyPagination(dataArray, skip, take) {
1423
+ return dataArray.slice(skip, skip + take);
1424
+ }
1425
+ async function applyQueryArray(dataArray, query) {
1426
+ let result = [...dataArray];
1427
+ // Apply filtering
1428
+ if (query.filter) {
1429
+ result = applyFilterArray(result, [query.filter], query.filter.logic ?? 'and');
1430
+ }
1431
+ // Store total count before pagination
1432
+ const total = result.length;
1433
+ // Apply sorting
1434
+ if (query.sort && query.sort.length > 0) {
1435
+ result = applySortArray(result, query.sort);
1436
+ }
1437
+ // Apply pagination
1438
+ result = applyPagination(result, query.skip, query.take);
1439
+ return {
1440
+ items: result,
1441
+ total,
1442
+ };
1443
+ }
1564
1444
 
1565
- class AXPIconResolverService {
1566
- constructor() {
1567
- this.iconResolver = inject(AXP_ICON_RESOLVER);
1568
- this.cache = new Map();
1445
+ /**
1446
+ * Service for applying and resetting text highlighting within specified HTML elements.
1447
+ */
1448
+ class AXHighlightService {
1449
+ constructor() { }
1450
+ /**
1451
+ * Highlights all occurrences of a search value within the elements matching the provided query selector.
1452
+ *
1453
+ * @param querySelector - CSS selector to identify target elements.
1454
+ * @param searchValue - Text to search and highlight.
1455
+ */
1456
+ highlight(querySelector, searchValue) {
1457
+ this.clear();
1458
+ if (!querySelector || !searchValue) {
1459
+ return;
1460
+ }
1461
+ this.querySelector = querySelector;
1462
+ this.searchValue = searchValue;
1463
+ const elements = document.querySelectorAll(querySelector);
1464
+ elements.forEach((element) => {
1465
+ this.applyHighlight(element);
1466
+ });
1467
+ }
1468
+ /**
1469
+ * Resets all highlighted text within the elements matching the previously used query selector.
1470
+ */
1471
+ clear() {
1472
+ const elements = document.querySelectorAll(`${this.querySelector} .ax-highlight-text`);
1473
+ elements.forEach((element) => {
1474
+ let combinedText = '';
1475
+ element.querySelectorAll('span').forEach((span) => {
1476
+ combinedText += span.textContent;
1477
+ });
1478
+ const mergedSpan = document.createElement('span');
1479
+ mergedSpan.textContent = combinedText;
1480
+ element?.parentNode?.replaceChild(mergedSpan, element);
1481
+ });
1482
+ }
1483
+ /**
1484
+ * Applies highlighting to a specific element by matching text against the search value.
1485
+ *
1486
+ * @param element - The HTML element to apply highlights to.
1487
+ */
1488
+ applyHighlight(element) {
1489
+ const searchRegex = new RegExp(`(${this.searchValue})`, 'gi');
1490
+ this.recursivelyHighlight(element, searchRegex);
1569
1491
  }
1570
- async resolve(icon) {
1571
- if (this.cache.has(icon)) {
1572
- return this.cache.get(icon);
1492
+ /**
1493
+ * Recursively applies highlighting to text nodes within an element.
1494
+ *
1495
+ * @param element - The current node being processed.
1496
+ * @param searchRegex - Regular expression for matching text to highlight.
1497
+ */
1498
+ recursivelyHighlight(element, searchRegex) {
1499
+ const childNodes = Array.from(element.childNodes);
1500
+ childNodes.forEach((node) => {
1501
+ if (node.nodeType === Node.TEXT_NODE) {
1502
+ const textContent = node.textContent || '';
1503
+ if (textContent.match(searchRegex)) {
1504
+ const highlightedHTML = this.createHighlightedHTML(textContent, searchRegex);
1505
+ const tempContainer = document.createElement('div');
1506
+ tempContainer.innerHTML = highlightedHTML;
1507
+ const fragment = document.createDocumentFragment();
1508
+ Array.from(tempContainer.childNodes).forEach((child) => fragment.appendChild(child));
1509
+ node.replaceWith(fragment);
1510
+ }
1511
+ }
1512
+ else if (node.nodeType === Node.ELEMENT_NODE) {
1513
+ this.recursivelyHighlight(node, searchRegex);
1514
+ }
1515
+ });
1516
+ }
1517
+ /**
1518
+ * Generates the HTML structure for highlighted text.
1519
+ *
1520
+ * @param textContent - The original text content to process.
1521
+ * @param searchRegex - Regular expression for matching text to highlight.
1522
+ * @returns A string of HTML with highlighted portions wrapped in span elements.
1523
+ */
1524
+ createHighlightedHTML(textContent, searchRegex) {
1525
+ let parts = [];
1526
+ let match;
1527
+ let lastIndex = 0;
1528
+ let resultHTML = '<span class="ax-highlight-text">';
1529
+ while ((match = searchRegex.exec(textContent)) !== null) {
1530
+ if (match.index > lastIndex) {
1531
+ resultHTML += `<span>${textContent.slice(lastIndex, match.index)}</span>`;
1532
+ }
1533
+ resultHTML += `<span class="ax-highlight">${match[0]}</span>`;
1534
+ lastIndex = searchRegex.lastIndex;
1535
+ }
1536
+ if (lastIndex < textContent.length) {
1537
+ resultHTML += `<span>${textContent.slice(lastIndex)}</span>`;
1573
1538
  }
1574
- const resolved = await this.iconResolver.resolve(icon);
1575
- this.cache.set(icon, resolved);
1576
- return resolved;
1539
+ resultHTML += '</span>';
1540
+ return resultHTML;
1577
1541
  }
1542
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXHighlightService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1543
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXHighlightService, providedIn: 'root' }); }
1578
1544
  }
1545
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXHighlightService, decorators: [{
1546
+ type: Injectable,
1547
+ args: [{
1548
+ providedIn: 'root',
1549
+ }]
1550
+ }], ctorParameters: () => [] });
1579
1551
 
1580
1552
  /**
1581
1553
  * Generated bundle index. Do not edit.
1582
1554
  */
1583
1555
 
1584
- export { AXHighlightService, AXPAppStartUpProvider, AXPAppStartUpService, AXPBroadcastEventService, AXPComponentLogoConfig, AXPContentCheckerDirective, AXPContextChangeEvent, AXPContextStore, AXPCountdownPipe, AXPDataGenerator, AXPDataSourceDefinitionProviderService, AXPDblClickDirective, AXPElementDataDirective, AXPExpressionEvaluatorScopeProviderContext, AXPExpressionEvaluatorScopeProviderService, AXPExpressionEvaluatorService, AXPGridLayoutDirective, AXPIconResolver, AXPIconResolverDefault, AXPIconResolverService, AXPImageUrlLogoConfig, AXPPlatformScope, AXPSystemActions, AXP_DATASOURCE_DEFINITION_PROVIDER, AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER, AXP_ICON_RESOLVER, applyFilterArray, applyPagination, applyQueryArray, applySortArray, cleanDeep, extractNestedFieldsWildcard, extractValue, getNestedKeys, getSmart, objectKeyValueTransforms, resolvePlatformScopeKey, resolvePlatformScopeName, setSmart };
1556
+ export { AXHighlightService, AXPAppStartUpProvider, AXPAppStartUpService, AXPBroadcastEventService, AXPComponentLogoConfig, AXPContentCheckerDirective, AXPContextChangeEvent, AXPContextStore, AXPCountdownPipe, AXPDataGenerator, AXPDataSourceDefinitionProviderService, AXPDblClickDirective, AXPElementDataDirective, AXPExpressionEvaluatorScopeProviderContext, AXPExpressionEvaluatorScopeProviderService, AXPExpressionEvaluatorService, AXPGridLayoutDirective, AXPImageUrlLogoConfig, AXPPlatformScope, AXPSystemActions, AXP_DATASOURCE_DEFINITION_PROVIDER, AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER, applyFilterArray, applyPagination, applyQueryArray, applySortArray, cleanDeep, extractNestedFieldsWildcard, extractValue, getNestedKeys, getSmart, objectKeyValueTransforms, resolvePlatformScopeKey, resolvePlatformScopeName, setSmart };
1585
1557
  //# sourceMappingURL=acorex-platform-core.mjs.map