@acorex/platform 21.0.0-next.71 → 21.0.0-next.72
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/acorex-platform-auth.mjs +10 -2
- package/fesm2022/acorex-platform-auth.mjs.map +1 -1
- package/fesm2022/{acorex-platform-common-common-settings.provider-Bi1RYif5.mjs → acorex-platform-common-common-settings.provider-Ytey9uhY.mjs} +15 -1
- package/fesm2022/acorex-platform-common-common-settings.provider-Ytey9uhY.mjs.map +1 -0
- package/fesm2022/acorex-platform-common.mjs +3792 -1679
- package/fesm2022/acorex-platform-common.mjs.map +1 -1
- package/fesm2022/acorex-platform-core.mjs +1112 -103
- package/fesm2022/acorex-platform-core.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-builder.mjs +53 -170
- package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-components.mjs +70 -46
- package/fesm2022/acorex-platform-layout-components.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-designer.mjs +199 -126
- package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
- package/fesm2022/{acorex-platform-layout-entity-attachments-page.component-D8iQnT-R.mjs → acorex-platform-layout-entity-attachments-page.component-B0EkdqvH.mjs} +6 -1
- package/fesm2022/acorex-platform-layout-entity-attachments-page.component-B0EkdqvH.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-entity.mjs +341 -418
- package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-views.mjs +675 -301
- package/fesm2022/acorex-platform-layout-views.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-widget-core.mjs +115 -74
- package/fesm2022/acorex-platform-layout-widget-core.mjs.map +1 -1
- package/fesm2022/{acorex-platform-layout-widgets-tabular-data-edit-popup.component-BcpRkpJp.mjs → acorex-platform-layout-widgets-tabular-data-edit-popup.component-DjpZU6gz.mjs} +2 -2
- package/fesm2022/{acorex-platform-layout-widgets-tabular-data-edit-popup.component-BcpRkpJp.mjs.map → acorex-platform-layout-widgets-tabular-data-edit-popup.component-DjpZU6gz.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-layout-widgets-tabular-data-view-popup.component-DQtK4lxl.mjs → acorex-platform-layout-widgets-tabular-data-view-popup.component-gX-3Kx9I.mjs} +2 -2
- package/fesm2022/{acorex-platform-layout-widgets-tabular-data-view-popup.component-DQtK4lxl.mjs.map → acorex-platform-layout-widgets-tabular-data-view-popup.component-gX-3Kx9I.mjs.map} +1 -1
- package/fesm2022/acorex-platform-layout-widgets.mjs +184 -655
- package/fesm2022/acorex-platform-layout-widgets.mjs.map +1 -1
- package/fesm2022/acorex-platform-themes-default-error-401.component-B1nsdpTY.mjs +48 -0
- package/fesm2022/acorex-platform-themes-default-error-401.component-B1nsdpTY.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-error-404.component-D4UvRe8u.mjs +42 -0
- package/fesm2022/acorex-platform-themes-default-error-404.component-D4UvRe8u.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default.mjs +76 -32
- package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
- package/package.json +1 -1
- package/types/acorex-platform-auth.d.ts +2 -0
- package/types/acorex-platform-common.d.ts +891 -259
- package/types/acorex-platform-core.d.ts +284 -40
- package/types/acorex-platform-layout-builder.d.ts +10 -22
- package/types/acorex-platform-layout-components.d.ts +9 -7
- package/types/acorex-platform-layout-entity.d.ts +37 -41
- package/types/acorex-platform-layout-views.d.ts +125 -67
- package/types/acorex-platform-layout-widget-core.d.ts +53 -61
- package/types/acorex-platform-layout-widgets.d.ts +33 -20
- package/types/acorex-platform-themes-default.d.ts +14 -4
- package/fesm2022/acorex-platform-common-common-settings.provider-Bi1RYif5.mjs.map +0 -1
- package/fesm2022/acorex-platform-layout-entity-attachments-page.component-D8iQnT-R.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-error-401.component-C7EYJzSr.mjs +0 -31
- package/fesm2022/acorex-platform-themes-default-error-401.component-C7EYJzSr.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-error-404.component-7MVLMwIa.mjs +0 -25
- package/fesm2022/acorex-platform-themes-default-error-404.component-7MVLMwIa.mjs.map +0 -1
|
@@ -2,11 +2,14 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, inject, Injectable, Directive, computed, Injector, ChangeDetectionStrategy, Component, input, ElementRef, ViewContainerRef, signal, effect, runInInjectionContext, Optional, Inject, NgModule, EventEmitter, HostListener, Output, provideAppInitializer, Pipe } from '@angular/core';
|
|
3
3
|
import { AXTranslationService, resolveMultiLanguageString } from '@acorex/core/translation';
|
|
4
4
|
import { AXDataSource } from '@acorex/cdk/common';
|
|
5
|
-
import {
|
|
5
|
+
import { isPlainObject, get, set, isNil, isEmpty, isArray, merge, isObjectLike, transform, isEqual, differenceWith, union, cloneDeep, has, sortBy, isUndefined, endsWith, startsWith, includes, lte, gte, lt, gt, orderBy } from 'lodash-es';
|
|
6
6
|
import { signalStore, withState, withComputed, withMethods, patchState } from '@ngrx/signals';
|
|
7
7
|
import * as i1 from '@acorex/components/skeleton';
|
|
8
8
|
import { AXSkeletonModule } from '@acorex/components/skeleton';
|
|
9
9
|
import { Subject, interval, fromEvent } from 'rxjs';
|
|
10
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
11
|
+
import { DOCUMENT } from '@angular/common';
|
|
12
|
+
import { AXLocaleService } from '@acorex/core/locale';
|
|
10
13
|
import { AXCalendarService } from '@acorex/core/date-time';
|
|
11
14
|
import { startWith, map, debounceTime } from 'rxjs/operators';
|
|
12
15
|
|
|
@@ -705,6 +708,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
705
708
|
type: Directive
|
|
706
709
|
}] });
|
|
707
710
|
|
|
711
|
+
//#region ---- Locale map shape ----
|
|
712
|
+
/** Per-locale string map (`{ 'en-US': '...', 'fa-IR': '...' }`). */
|
|
713
|
+
function isLocaleStringMap(value) {
|
|
714
|
+
if (!isPlainObject(value)) {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
const entries = Object.values(value);
|
|
718
|
+
if (entries.length === 0) {
|
|
719
|
+
return false;
|
|
720
|
+
}
|
|
721
|
+
return entries.every((entry) => entry === null || entry === undefined || typeof entry === 'string');
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Use locale-map read/write when the option is on or live/saved data is already a map.
|
|
725
|
+
* Auto-enables when API data is a map but the editor option was left off.
|
|
726
|
+
*/
|
|
727
|
+
function shouldUseLocaleMapShape(localeMapOptionEnabled, current, saved) {
|
|
728
|
+
return localeMapOptionEnabled || isLocaleStringMap(current) || isLocaleStringMap(saved);
|
|
729
|
+
}
|
|
730
|
+
/** Updates one locale entry; preserves sibling locales from current or saved map. */
|
|
731
|
+
function buildLocaleTextMapValue(current, saved, lang, input) {
|
|
732
|
+
const seed = isLocaleStringMap(current)
|
|
733
|
+
? { ...current }
|
|
734
|
+
: isLocaleStringMap(saved)
|
|
735
|
+
? { ...saved }
|
|
736
|
+
: {};
|
|
737
|
+
seed[lang] = input ?? '';
|
|
738
|
+
for (const key of Object.keys(seed)) {
|
|
739
|
+
if ((seed[key] ?? '').trim() === '') {
|
|
740
|
+
delete seed[key];
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return Object.keys(seed).length === 0 ? null : seed;
|
|
744
|
+
}
|
|
745
|
+
//#endregion
|
|
746
|
+
|
|
708
747
|
function extractNestedFieldsWildcard(obj, basePath, fields) {
|
|
709
748
|
const result = {};
|
|
710
749
|
if (fields.length === 1 && fields[0] === '*') {
|
|
@@ -966,13 +1005,296 @@ function getDetailedChanges(obj1, obj2) {
|
|
|
966
1005
|
function getEnumValues(enumType) {
|
|
967
1006
|
return Object.entries(enumType).map(([key, value]) => ({ id: value, title: key }));
|
|
968
1007
|
}
|
|
969
|
-
|
|
1008
|
+
//#region ---- Form value equality (dirty / baseline) ----
|
|
1009
|
+
/** Whether a value uses the multi-language text widget shape (string or locale map). */
|
|
1010
|
+
function isMultiLanguageFormShape(value) {
|
|
1011
|
+
if (value === null || value === undefined) {
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
if (typeof value === 'string') {
|
|
1015
|
+
return true;
|
|
1016
|
+
}
|
|
1017
|
+
return isLocaleStringMap(value);
|
|
1018
|
+
}
|
|
1019
|
+
/** Drops empty/whitespace locale entries from a multi-language map. */
|
|
1020
|
+
function normalizeLocaleStringMap(value) {
|
|
1021
|
+
const normalized = {};
|
|
1022
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1023
|
+
if (typeof entry !== 'string') {
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
const trimmed = entry.trim();
|
|
1027
|
+
if (trimmed !== '') {
|
|
1028
|
+
normalized[key] = trimmed;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return Object.keys(normalized).length === 0 ? null : normalized;
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Compares multi-language field values (plain string vs locale map) for dirty/baseline checks.
|
|
1035
|
+
* Returns `null` when either side is not a multi-language shape (caller uses generic normalization).
|
|
1036
|
+
*/
|
|
1037
|
+
function compareMultiLanguageFormValues(a, b) {
|
|
1038
|
+
if (!isMultiLanguageFormShape(a) || !isMultiLanguageFormShape(b)) {
|
|
1039
|
+
return null;
|
|
1040
|
+
}
|
|
1041
|
+
const normalizeScalar = (value) => {
|
|
1042
|
+
if (value === null || value === undefined) {
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
if (typeof value === 'string') {
|
|
1046
|
+
const trimmed = value.trim();
|
|
1047
|
+
return trimmed === '' ? null : trimmed;
|
|
1048
|
+
}
|
|
1049
|
+
if (isLocaleStringMap(value)) {
|
|
1050
|
+
return normalizeLocaleStringMap(value);
|
|
1051
|
+
}
|
|
1052
|
+
return null;
|
|
1053
|
+
};
|
|
1054
|
+
const left = normalizeScalar(a);
|
|
1055
|
+
const right = normalizeScalar(b);
|
|
1056
|
+
if (left === null && right === null) {
|
|
1057
|
+
return true;
|
|
1058
|
+
}
|
|
1059
|
+
if (left === null || right === null) {
|
|
1060
|
+
return false;
|
|
1061
|
+
}
|
|
1062
|
+
if (typeof left === 'string' && typeof right === 'string') {
|
|
1063
|
+
return left === right;
|
|
1064
|
+
}
|
|
1065
|
+
if (typeof left === 'string' && typeof right === 'object') {
|
|
1066
|
+
const values = Object.values(right);
|
|
1067
|
+
return values.length > 0 && values.every((text) => text === left);
|
|
1068
|
+
}
|
|
1069
|
+
if (typeof right === 'string' && typeof left === 'object') {
|
|
1070
|
+
const values = Object.values(left);
|
|
1071
|
+
return values.length > 0 && values.every((text) => text === right);
|
|
1072
|
+
}
|
|
1073
|
+
if (typeof left !== 'object' || typeof right !== 'object') {
|
|
1074
|
+
return false;
|
|
1075
|
+
}
|
|
1076
|
+
const leftMap = left;
|
|
1077
|
+
const rightMap = right;
|
|
1078
|
+
const leftKeys = Object.keys(leftMap).sort();
|
|
1079
|
+
const rightKeys = Object.keys(rightMap).sort();
|
|
1080
|
+
if (leftKeys.length !== rightKeys.length) {
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
return leftKeys.every((key) => leftMap[key] === rightMap[key]);
|
|
1084
|
+
}
|
|
1085
|
+
/** Lookup/select filter-mode payload: `{ value, displayText?, operation }`. */
|
|
1086
|
+
function isFilterFormShape(value) {
|
|
1087
|
+
if (!isPlainObject(value)) {
|
|
1088
|
+
return false;
|
|
1089
|
+
}
|
|
1090
|
+
const record = value;
|
|
1091
|
+
return 'value' in record && 'operation' in record;
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Compares filter-mode widget values by selection identity; ignores derived `displayText`.
|
|
1095
|
+
*/
|
|
1096
|
+
function compareFilterFormValues(a, b) {
|
|
1097
|
+
if (!isFilterFormShape(a) || !isFilterFormShape(b)) {
|
|
1098
|
+
return null;
|
|
1099
|
+
}
|
|
1100
|
+
const left = a;
|
|
1101
|
+
const right = b;
|
|
1102
|
+
if (!isFormValueEqual(left['value'], right['value'])) {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
const opLeft = get(left, 'operation.type');
|
|
1106
|
+
const opRight = get(right, 'operation.type');
|
|
1107
|
+
if (opLeft !== undefined || opRight !== undefined) {
|
|
1108
|
+
return opLeft === opRight;
|
|
1109
|
+
}
|
|
1110
|
+
return true;
|
|
1111
|
+
}
|
|
1112
|
+
function isReferenceScalar(value) {
|
|
1113
|
+
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
1114
|
+
}
|
|
1115
|
+
/** Scalar id or `{ id }` identity used by lookup/select widgets. */
|
|
1116
|
+
function getReferenceId(value) {
|
|
1117
|
+
if (isNil(value)) {
|
|
1118
|
+
return undefined;
|
|
1119
|
+
}
|
|
1120
|
+
if (isReferenceScalar(value)) {
|
|
1121
|
+
return value;
|
|
1122
|
+
}
|
|
1123
|
+
if (isPlainObject(value)) {
|
|
1124
|
+
const id = get(value, 'id');
|
|
1125
|
+
if (!isNil(id)) {
|
|
1126
|
+
return id;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
return undefined;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Compares scalar selection ids to full lookup/select items (`5` vs `{ id: 5, ... }`).
|
|
1133
|
+
* Does not apply when both sides are objects — those use structural compare so field edits stay dirty.
|
|
1134
|
+
*/
|
|
1135
|
+
function compareReferenceFormValues(a, b) {
|
|
1136
|
+
const refA = getReferenceId(a);
|
|
1137
|
+
const refB = getReferenceId(b);
|
|
1138
|
+
if (refA === undefined || refB === undefined) {
|
|
1139
|
+
return null;
|
|
1140
|
+
}
|
|
1141
|
+
const aIsScalar = isReferenceScalar(a);
|
|
1142
|
+
const bIsScalar = isReferenceScalar(b);
|
|
1143
|
+
if (!aIsScalar && !bIsScalar) {
|
|
1144
|
+
return null;
|
|
1145
|
+
}
|
|
1146
|
+
return isEqual(normalizeFormValue(refA), normalizeFormValue(refB));
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Semantic equality for lookup/select values when restoring saved baseline shape.
|
|
1150
|
+
* Compares by selection identity (id), including two full items with the same id.
|
|
1151
|
+
*/
|
|
1152
|
+
function isSelectionValueEqual(a, b) {
|
|
1153
|
+
const filterEqual = compareFilterFormValues(a, b);
|
|
1154
|
+
if (filterEqual !== null) {
|
|
1155
|
+
return filterEqual;
|
|
1156
|
+
}
|
|
1157
|
+
const refA = getReferenceId(a);
|
|
1158
|
+
const refB = getReferenceId(b);
|
|
1159
|
+
if (refA !== undefined && refB !== undefined) {
|
|
1160
|
+
return isEqual(normalizeFormValue(refA), normalizeFormValue(refB));
|
|
1161
|
+
}
|
|
1162
|
+
return isFormValueEqual(a, b);
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Stable sort key for order-insensitive array comparison (after normalization).
|
|
1166
|
+
*/
|
|
1167
|
+
function formValueSortKey(value) {
|
|
1168
|
+
if (value === null) {
|
|
1169
|
+
return '\0';
|
|
1170
|
+
}
|
|
1171
|
+
if (typeof value === 'number') {
|
|
1172
|
+
return `n:${value}`;
|
|
1173
|
+
}
|
|
1174
|
+
if (typeof value === 'boolean') {
|
|
1175
|
+
return `b:${value}`;
|
|
1176
|
+
}
|
|
1177
|
+
if (typeof value === 'string') {
|
|
1178
|
+
return `s:${value}`;
|
|
1179
|
+
}
|
|
1180
|
+
try {
|
|
1181
|
+
return `j:${JSON.stringify(value)}`;
|
|
1182
|
+
}
|
|
1183
|
+
catch {
|
|
1184
|
+
return `u:${String(value)}`;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Sorts normalized array items so order does not affect dirty checks.
|
|
1189
|
+
*/
|
|
1190
|
+
function sortNormalizedArrayItems(items) {
|
|
1191
|
+
return [...items].sort((a, b) => formValueSortKey(a).localeCompare(formValueSortKey(b)));
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Normalizes a form/context value for semantic baseline comparison.
|
|
1195
|
+
*
|
|
1196
|
+
* Rules:
|
|
1197
|
+
* - `null`, `undefined`, whitespace-only strings, and empty arrays → `null` (empty)
|
|
1198
|
+
* - Numeric strings → numbers (`"5"` and `5` match)
|
|
1199
|
+
* - Arrays → elements normalized; empty/all-empty → `null`; otherwise sorted (order ignored)
|
|
1200
|
+
* - Plain objects → keys sorted; `null`/empty nested values omitted
|
|
1201
|
+
* - `Date` → epoch milliseconds
|
|
1202
|
+
*/
|
|
1203
|
+
function normalizeFormValue(value) {
|
|
1204
|
+
if (value === undefined || value === null) {
|
|
1205
|
+
return null;
|
|
1206
|
+
}
|
|
1207
|
+
if (typeof value === 'string') {
|
|
1208
|
+
const trimmed = value.trim();
|
|
1209
|
+
if (trimmed === '') {
|
|
1210
|
+
return null;
|
|
1211
|
+
}
|
|
1212
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
1213
|
+
const num = Number(trimmed);
|
|
1214
|
+
if (!Number.isNaN(num)) {
|
|
1215
|
+
return num;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
return trimmed;
|
|
1219
|
+
}
|
|
1220
|
+
if (typeof value === 'number') {
|
|
1221
|
+
return Number.isNaN(value) ? null : value;
|
|
1222
|
+
}
|
|
1223
|
+
if (typeof value === 'boolean') {
|
|
1224
|
+
return value;
|
|
1225
|
+
}
|
|
1226
|
+
if (value instanceof Date) {
|
|
1227
|
+
return value.getTime();
|
|
1228
|
+
}
|
|
1229
|
+
if (isArray(value)) {
|
|
1230
|
+
const normalizedItems = value
|
|
1231
|
+
.map((item) => normalizeFormValue(item))
|
|
1232
|
+
.filter((item) => item !== null);
|
|
1233
|
+
if (normalizedItems.length === 0) {
|
|
1234
|
+
return null;
|
|
1235
|
+
}
|
|
1236
|
+
return sortNormalizedArrayItems(normalizedItems);
|
|
1237
|
+
}
|
|
1238
|
+
if (isPlainObject(value)) {
|
|
1239
|
+
const record = value;
|
|
1240
|
+
if (isLocaleStringMap(record)) {
|
|
1241
|
+
return normalizeLocaleStringMap(record);
|
|
1242
|
+
}
|
|
1243
|
+
const normalized = {};
|
|
1244
|
+
for (const key of Object.keys(record).sort()) {
|
|
1245
|
+
const next = normalizeFormValue(record[key]);
|
|
1246
|
+
if (next !== null) {
|
|
1247
|
+
normalized[key] = next;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return normalized;
|
|
1251
|
+
}
|
|
1252
|
+
return value;
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Semantic equality for dirty-state and baseline checks.
|
|
1256
|
+
* Prefer over lodash `isEqual` when comparing user-edited form/context data to a saved baseline.
|
|
1257
|
+
*
|
|
1258
|
+
* Arrays: `[]`, `null`, and all-empty lists are equivalent; non-empty arrays compare as multisets (order ignored).
|
|
1259
|
+
*/
|
|
1260
|
+
function isFormValueEqual(a, b) {
|
|
1261
|
+
const multiLanguageEqual = compareMultiLanguageFormValues(a, b);
|
|
1262
|
+
if (multiLanguageEqual !== null) {
|
|
1263
|
+
return multiLanguageEqual;
|
|
1264
|
+
}
|
|
1265
|
+
const filterEqual = compareFilterFormValues(a, b);
|
|
1266
|
+
if (filterEqual !== null) {
|
|
1267
|
+
return filterEqual;
|
|
1268
|
+
}
|
|
1269
|
+
const referenceEqual = compareReferenceFormValues(a, b);
|
|
1270
|
+
if (referenceEqual !== null) {
|
|
1271
|
+
return referenceEqual;
|
|
1272
|
+
}
|
|
1273
|
+
if (isArray(a) && isArray(b)) {
|
|
1274
|
+
// Empty repeater rows normalize away; raw length must differ before multiset compare.
|
|
1275
|
+
if (a.length !== b.length) {
|
|
1276
|
+
return false;
|
|
1277
|
+
}
|
|
1278
|
+
return isEqual(normalizeFormValue(a), normalizeFormValue(b));
|
|
1279
|
+
}
|
|
1280
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1281
|
+
const left = a;
|
|
1282
|
+
const right = b;
|
|
1283
|
+
const keys = new Set([...Object.keys(left), ...Object.keys(right)]);
|
|
1284
|
+
for (const key of keys) {
|
|
1285
|
+
if (!isFormValueEqual(left[key], right[key])) {
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
return true;
|
|
1290
|
+
}
|
|
1291
|
+
return isEqual(normalizeFormValue(a), normalizeFormValue(b));
|
|
1292
|
+
}
|
|
970
1293
|
/**
|
|
971
1294
|
* Returns whether `current` differs from the saved/clean `baseline` snapshot.
|
|
972
|
-
* Used by entity details pages, layout-builder dialogs, and {@link AXPContextStore}.
|
|
973
1295
|
*/
|
|
974
1296
|
function isFormContextDirty(current, baseline) {
|
|
975
|
-
return !
|
|
1297
|
+
return !isFormValueEqual(current, baseline);
|
|
976
1298
|
}
|
|
977
1299
|
/**
|
|
978
1300
|
* Clones a context object for use as a dirty-tracking baseline.
|
|
@@ -980,66 +1302,55 @@ function isFormContextDirty(current, baseline) {
|
|
|
980
1302
|
function captureFormContextBaseline(context) {
|
|
981
1303
|
return cloneDeep(context);
|
|
982
1304
|
}
|
|
1305
|
+
//#endregion
|
|
983
1306
|
|
|
984
1307
|
class AXPContextChangeEvent {
|
|
985
1308
|
}
|
|
986
1309
|
//#endregion
|
|
987
1310
|
//#region ---- Context signal store ----
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
initialSnapshot: {}, // Snapshot of the first initialized state
|
|
995
|
-
previousSnapshot: {}, // Snapshot of the previous state
|
|
996
|
-
userDirtyPaths: [], // Paths changed by user interaction
|
|
1311
|
+
const AXPContextStore = signalStore(withState(() => ({
|
|
1312
|
+
data: {},
|
|
1313
|
+
state: 'initiated',
|
|
1314
|
+
/** Last committed / saved baseline — discard reverts to this snapshot. */
|
|
1315
|
+
savedSnapshot: {},
|
|
1316
|
+
previousSnapshot: {},
|
|
997
1317
|
lastChange: {
|
|
998
1318
|
state: 'initiated',
|
|
999
|
-
},
|
|
1000
|
-
})),
|
|
1001
|
-
// Computed Signals
|
|
1002
|
-
withComputed(({ data, state, lastChange, initialSnapshot, previousSnapshot, userDirtyPaths }) => ({
|
|
1319
|
+
},
|
|
1320
|
+
})), withComputed(({ data, state, lastChange, savedSnapshot, previousSnapshot }) => ({
|
|
1003
1321
|
isChanged: computed(() => state() === 'changed'),
|
|
1004
1322
|
isReset: computed(() => state() === 'restored'),
|
|
1005
1323
|
isInitiated: computed(() => state() === 'initiated'),
|
|
1006
1324
|
isEmpty: computed(() => Object.keys(data()).length === 0),
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
changeEvent: computed(() => lastChange()), // Reactive last change event
|
|
1013
|
-
})),
|
|
1014
|
-
// Methods for State Management
|
|
1015
|
-
withMethods((store) => {
|
|
1016
|
-
const markUserDirtyPath = (path) => {
|
|
1017
|
-
const normalized = path?.trim();
|
|
1018
|
-
if (!normalized) {
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
const current = store.userDirtyPaths();
|
|
1022
|
-
if (current.includes(normalized)) {
|
|
1023
|
-
return;
|
|
1024
|
-
}
|
|
1025
|
-
patchState(store, { userDirtyPaths: [...current, normalized] });
|
|
1026
|
-
};
|
|
1027
|
-
const clearUserDirtyPaths = () => {
|
|
1028
|
-
if (store.userDirtyPaths().length === 0) {
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
patchState(store, { userDirtyPaths: [] });
|
|
1032
|
-
};
|
|
1033
|
-
const resolvePatchOptions = (second) => {
|
|
1034
|
-
if (typeof second === 'boolean') {
|
|
1035
|
-
return { skipDirtyTracking: second };
|
|
1325
|
+
isSavedCommitted: computed(() => !isEmpty(savedSnapshot())),
|
|
1326
|
+
isDirty: computed(() => {
|
|
1327
|
+
const saved = savedSnapshot();
|
|
1328
|
+
if (isEmpty(saved)) {
|
|
1329
|
+
return false;
|
|
1036
1330
|
}
|
|
1037
|
-
return
|
|
1038
|
-
}
|
|
1331
|
+
return isFormContextDirty(data(), saved);
|
|
1332
|
+
}),
|
|
1333
|
+
snapshot: computed(() => cloneDeep(data())),
|
|
1334
|
+
saved: computed(() => cloneDeep(savedSnapshot())),
|
|
1335
|
+
/** @deprecated Use {@link saved} — only saved baseline is tracked. */
|
|
1336
|
+
initial: computed(() => cloneDeep(savedSnapshot())),
|
|
1337
|
+
previous: computed(() => cloneDeep(previousSnapshot())),
|
|
1338
|
+
changeEvent: computed(() => lastChange()),
|
|
1339
|
+
})), withMethods((store) => {
|
|
1039
1340
|
const updateValue = (path, value, options) => {
|
|
1040
1341
|
const currentData = cloneDeep(store.data());
|
|
1041
1342
|
const oldValue = getSmart(currentData, path);
|
|
1042
|
-
|
|
1343
|
+
const hasSaved = !isEmpty(store.savedSnapshot());
|
|
1344
|
+
const savedAtPath = hasSaved ? getSmart(store.savedSnapshot(), path) : undefined;
|
|
1345
|
+
if (hasSaved && isSelectionValueEqual(value, savedAtPath) && !isEqual(value, savedAtPath)) {
|
|
1346
|
+
value = cloneDeep(savedAtPath);
|
|
1347
|
+
}
|
|
1348
|
+
const isArrayLengthChange = Array.isArray(value) && (!Array.isArray(oldValue) || value.length !== oldValue.length);
|
|
1349
|
+
if (!isArrayLengthChange && isEqual(oldValue, value)) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
const shouldNormalizeSavedShape = hasSaved && isSelectionValueEqual(value, savedAtPath) && !isEqual(oldValue, value);
|
|
1353
|
+
if (!isArrayLengthChange && isFormValueEqual(oldValue, value) && !shouldNormalizeSavedShape) {
|
|
1043
1354
|
return;
|
|
1044
1355
|
}
|
|
1045
1356
|
const origin = options?.origin ?? 'system';
|
|
@@ -1058,14 +1369,11 @@ withMethods((store) => {
|
|
|
1058
1369
|
state: 'changed',
|
|
1059
1370
|
lastChange: changeEvent,
|
|
1060
1371
|
});
|
|
1061
|
-
if (origin === 'user') {
|
|
1062
|
-
markUserDirtyPath(path);
|
|
1063
|
-
}
|
|
1064
1372
|
};
|
|
1065
1373
|
const applyObjectPaths = (obj, options, prefix = '') => {
|
|
1066
1374
|
for (const [key, value] of Object.entries(obj ?? {})) {
|
|
1067
1375
|
const path = prefix ? `${prefix}.${key}` : key;
|
|
1068
|
-
if (value !== null &&
|
|
1376
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
1069
1377
|
applyObjectPaths(value, options, path);
|
|
1070
1378
|
}
|
|
1071
1379
|
else {
|
|
@@ -1073,58 +1381,54 @@ withMethods((store) => {
|
|
|
1073
1381
|
}
|
|
1074
1382
|
}
|
|
1075
1383
|
};
|
|
1384
|
+
const revertToSaved = () => {
|
|
1385
|
+
const savedData = store.saved();
|
|
1386
|
+
const changeEvent = {
|
|
1387
|
+
oldValue: cloneDeep(store.data()),
|
|
1388
|
+
newValue: cloneDeep(savedData),
|
|
1389
|
+
path: '',
|
|
1390
|
+
state: 'restored',
|
|
1391
|
+
data: savedData,
|
|
1392
|
+
};
|
|
1393
|
+
patchState(store, {
|
|
1394
|
+
previousSnapshot: store.snapshot(),
|
|
1395
|
+
data: savedData,
|
|
1396
|
+
state: 'restored',
|
|
1397
|
+
lastChange: changeEvent,
|
|
1398
|
+
});
|
|
1399
|
+
};
|
|
1076
1400
|
return {
|
|
1077
|
-
// Update a specific value
|
|
1078
1401
|
update(path, value, options) {
|
|
1079
1402
|
updateValue(path, value, options);
|
|
1080
1403
|
},
|
|
1081
1404
|
applyObjectPaths,
|
|
1082
|
-
patch(context,
|
|
1083
|
-
const options = resolvePatchOptions(second);
|
|
1405
|
+
patch(context, options) {
|
|
1084
1406
|
const currentData = cloneDeep(store.data());
|
|
1085
1407
|
const updatedData = { ...currentData, ...context };
|
|
1086
|
-
const origin = options.origin ?? 'system';
|
|
1087
1408
|
const changeEvent = {
|
|
1088
1409
|
state: 'patch',
|
|
1089
1410
|
data: updatedData,
|
|
1090
|
-
origin,
|
|
1091
1411
|
};
|
|
1092
1412
|
const syncedSnapshot = cloneDeep(updatedData);
|
|
1093
1413
|
patchState(store, {
|
|
1094
|
-
...(options
|
|
1095
|
-
? {
|
|
1414
|
+
...(options?.updateSaved
|
|
1415
|
+
? { savedSnapshot: syncedSnapshot, previousSnapshot: syncedSnapshot }
|
|
1096
1416
|
: { previousSnapshot: store.snapshot() }),
|
|
1097
1417
|
data: updatedData,
|
|
1098
1418
|
state: 'changed',
|
|
1099
1419
|
lastChange: changeEvent,
|
|
1100
1420
|
});
|
|
1101
|
-
if (!options.skipDirtyTracking && origin === 'user') {
|
|
1102
|
-
Object.keys(context).forEach((key) => markUserDirtyPath(key));
|
|
1103
|
-
}
|
|
1104
1421
|
},
|
|
1105
|
-
|
|
1422
|
+
/** Reverts live data to the last saved snapshot. */
|
|
1423
|
+
revertToSaved,
|
|
1106
1424
|
reset() {
|
|
1107
|
-
|
|
1108
|
-
const changeEvent = {
|
|
1109
|
-
oldValue: cloneDeep(store.data()), // Current data becomes old value
|
|
1110
|
-
newValue: cloneDeep(initialData), // Reset to the initial state
|
|
1111
|
-
path: '',
|
|
1112
|
-
state: 'restored',
|
|
1113
|
-
data: initialData,
|
|
1114
|
-
};
|
|
1115
|
-
patchState(store, {
|
|
1116
|
-
previousSnapshot: store.snapshot(), // Save the previous state
|
|
1117
|
-
data: initialData,
|
|
1118
|
-
state: 'restored',
|
|
1119
|
-
lastChange: changeEvent,
|
|
1120
|
-
userDirtyPaths: [],
|
|
1121
|
-
});
|
|
1425
|
+
revertToSaved();
|
|
1122
1426
|
},
|
|
1123
|
-
|
|
1427
|
+
/** Loads live data; saved baseline is committed separately via {@link commitSaved}. */
|
|
1124
1428
|
set(initialData) {
|
|
1125
1429
|
const currentData = store.data();
|
|
1126
|
-
if (
|
|
1127
|
-
return;
|
|
1430
|
+
if (isFormValueEqual(currentData, initialData)) {
|
|
1431
|
+
return;
|
|
1128
1432
|
}
|
|
1129
1433
|
const changeEvent = {
|
|
1130
1434
|
oldValue: null,
|
|
@@ -1134,33 +1438,43 @@ withMethods((store) => {
|
|
|
1134
1438
|
data: initialData,
|
|
1135
1439
|
};
|
|
1136
1440
|
patchState(store, {
|
|
1137
|
-
|
|
1138
|
-
previousSnapshot: store.snapshot(), // Save the current state as the previous
|
|
1441
|
+
previousSnapshot: store.snapshot(),
|
|
1139
1442
|
data: initialData,
|
|
1140
1443
|
state: 'initiated',
|
|
1141
1444
|
lastChange: changeEvent,
|
|
1142
|
-
userDirtyPaths: [],
|
|
1143
1445
|
});
|
|
1144
1446
|
},
|
|
1145
|
-
// Get a specific value
|
|
1146
1447
|
getValue(path) {
|
|
1147
1448
|
return getSmart(store.data(), path);
|
|
1148
1449
|
},
|
|
1149
|
-
|
|
1450
|
+
getSavedValue(path) {
|
|
1451
|
+
return getSmart(store.savedSnapshot(), path);
|
|
1452
|
+
},
|
|
1150
1453
|
hasValue(path) {
|
|
1151
1454
|
return has(store.data(), path);
|
|
1152
1455
|
},
|
|
1153
|
-
/** Marks the current data as the
|
|
1154
|
-
|
|
1456
|
+
/** Marks the current data as the saved baseline. */
|
|
1457
|
+
commitSaved() {
|
|
1155
1458
|
const snapshot = cloneDeep(store.data());
|
|
1156
1459
|
patchState(store, {
|
|
1157
|
-
|
|
1460
|
+
savedSnapshot: snapshot,
|
|
1158
1461
|
previousSnapshot: snapshot,
|
|
1159
1462
|
state: 'initiated',
|
|
1160
|
-
|
|
1463
|
+
lastChange: {
|
|
1464
|
+
state: 'initiated',
|
|
1465
|
+
data: snapshot,
|
|
1466
|
+
},
|
|
1467
|
+
});
|
|
1468
|
+
},
|
|
1469
|
+
/** Merges parent-bound entity fields without resetting the saved baseline. */
|
|
1470
|
+
applyParentBind(merged) {
|
|
1471
|
+
if (isFormValueEqual(store.data(), merged)) {
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
patchState(store, {
|
|
1475
|
+
data: merged,
|
|
1161
1476
|
});
|
|
1162
1477
|
},
|
|
1163
|
-
clearUserDirtyPaths,
|
|
1164
1478
|
};
|
|
1165
1479
|
}));
|
|
1166
1480
|
//#endregion
|
|
@@ -2325,6 +2639,709 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
2325
2639
|
args: [{ providedIn: 'root' }]
|
|
2326
2640
|
}] });
|
|
2327
2641
|
|
|
2642
|
+
//#region ---- Types ----
|
|
2643
|
+
/** Priority tier — higher values win when multiple bindings match. */
|
|
2644
|
+
var AXPKeyboardShortcutPriority;
|
|
2645
|
+
(function (AXPKeyboardShortcutPriority) {
|
|
2646
|
+
AXPKeyboardShortcutPriority[AXPKeyboardShortcutPriority["Global"] = 0] = "Global";
|
|
2647
|
+
AXPKeyboardShortcutPriority[AXPKeyboardShortcutPriority["Page"] = 10] = "Page";
|
|
2648
|
+
AXPKeyboardShortcutPriority[AXPKeyboardShortcutPriority["Panel"] = 20] = "Panel";
|
|
2649
|
+
AXPKeyboardShortcutPriority[AXPKeyboardShortcutPriority["Modal"] = 100] = "Modal";
|
|
2650
|
+
})(AXPKeyboardShortcutPriority || (AXPKeyboardShortcutPriority = {}));
|
|
2651
|
+
//#endregion
|
|
2652
|
+
|
|
2653
|
+
//#region ---- Overlay Layer DOM Utilities ----
|
|
2654
|
+
/** Acorex overlay root (modal shell, popup, dialog). */
|
|
2655
|
+
const AX_OVERLAY_CONTAINER_SELECTOR = '.ax-overlay-container';
|
|
2656
|
+
/** Anchored widget panel inside an overlay (select, date picker, dropdown). */
|
|
2657
|
+
const AX_OVERLAY_PANE_SELECTOR = '.ax-overlay-pane';
|
|
2658
|
+
/**
|
|
2659
|
+
* True when a visible overlay layer is foreground (modal, popup, widget popover/picker).
|
|
2660
|
+
*/
|
|
2661
|
+
function hasForegroundOverlayLayer(document) {
|
|
2662
|
+
if (getVisibleAnchoredOverlayPanes(document).length > 0) {
|
|
2663
|
+
return true;
|
|
2664
|
+
}
|
|
2665
|
+
return getVisibleOverlayContainers(document).length > 0;
|
|
2666
|
+
}
|
|
2667
|
+
/**
|
|
2668
|
+
* Returns visible anchored overlay panes (widget popovers/pickers).
|
|
2669
|
+
*/
|
|
2670
|
+
function getVisibleAnchoredOverlayPanes(document) {
|
|
2671
|
+
return Array.from(document.querySelectorAll(AX_OVERLAY_PANE_SELECTOR)).filter(isVisibleOverlayElement);
|
|
2672
|
+
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Visible anchored panes that are not contained by `excludeContainer` (e.g. dialog shell).
|
|
2675
|
+
*/
|
|
2676
|
+
function getNestedVisibleOverlayPanes(document, excludeContainer) {
|
|
2677
|
+
return getVisibleAnchoredOverlayPanes(document).filter((pane) => !excludeContainer?.contains(pane));
|
|
2678
|
+
}
|
|
2679
|
+
/**
|
|
2680
|
+
* Collects visible overlay containers in stacking order (later / higher z-index wins).
|
|
2681
|
+
*/
|
|
2682
|
+
function getVisibleOverlayContainers(document) {
|
|
2683
|
+
return Array.from(document.querySelectorAll(AX_OVERLAY_CONTAINER_SELECTOR))
|
|
2684
|
+
.filter(isVisibleOverlayElement)
|
|
2685
|
+
.sort(compareOverlayStackOrder);
|
|
2686
|
+
}
|
|
2687
|
+
/** Topmost visible overlay container, if any. */
|
|
2688
|
+
function getTopVisibleOverlayContainer(document) {
|
|
2689
|
+
const containers = getVisibleOverlayContainers(document);
|
|
2690
|
+
return containers.length ? containers[containers.length - 1] : null;
|
|
2691
|
+
}
|
|
2692
|
+
/** Nearest overlay container ancestor of `element`. */
|
|
2693
|
+
function findOverlayContainerAncestor(element) {
|
|
2694
|
+
return element.closest(AX_OVERLAY_CONTAINER_SELECTOR);
|
|
2695
|
+
}
|
|
2696
|
+
/**
|
|
2697
|
+
* Returns true when the overlay element is rendered and visible in the viewport.
|
|
2698
|
+
*/
|
|
2699
|
+
function isVisibleOverlayElement(element) {
|
|
2700
|
+
if (!(element instanceof HTMLElement)) {
|
|
2701
|
+
return false;
|
|
2702
|
+
}
|
|
2703
|
+
const style = getComputedStyle(element);
|
|
2704
|
+
if (style.display === 'none' || style.visibility === 'hidden' || Number(style.opacity) === 0) {
|
|
2705
|
+
return false;
|
|
2706
|
+
}
|
|
2707
|
+
const rect = element.getBoundingClientRect();
|
|
2708
|
+
return rect.width > 0 && rect.height > 0;
|
|
2709
|
+
}
|
|
2710
|
+
function compareOverlayStackOrder(a, b) {
|
|
2711
|
+
const za = Number(getComputedStyle(a).zIndex) || 0;
|
|
2712
|
+
const zb = Number(getComputedStyle(b).zIndex) || 0;
|
|
2713
|
+
if (za !== zb) {
|
|
2714
|
+
return za - zb;
|
|
2715
|
+
}
|
|
2716
|
+
const position = a.compareDocumentPosition(b);
|
|
2717
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
2718
|
+
return -1;
|
|
2719
|
+
}
|
|
2720
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
2721
|
+
return 1;
|
|
2722
|
+
}
|
|
2723
|
+
return 0;
|
|
2724
|
+
}
|
|
2725
|
+
//#endregion
|
|
2726
|
+
|
|
2727
|
+
//#region ---- Imports ----
|
|
2728
|
+
const HORIZONTAL_DIRECTIONAL_KEY_MIRRORS = {
|
|
2729
|
+
arrowleft: 'arrowright',
|
|
2730
|
+
arrowright: 'arrowleft',
|
|
2731
|
+
left: 'right',
|
|
2732
|
+
right: 'left',
|
|
2733
|
+
'[': ']',
|
|
2734
|
+
']': '[',
|
|
2735
|
+
};
|
|
2736
|
+
/** Maps a horizontal direction key to its RTL semantic counterpart. */
|
|
2737
|
+
function mirrorHorizontalDirectionalKey(key) {
|
|
2738
|
+
const normalized = normalizeShortcutToken(key);
|
|
2739
|
+
return HORIZONTAL_DIRECTIONAL_KEY_MIRRORS[normalized] ?? normalized;
|
|
2740
|
+
}
|
|
2741
|
+
/** True when the chord's primary key is a horizontal direction key (`←`/`→`, `[`/`]`). */
|
|
2742
|
+
function isHorizontalDirectionalShortcutKey(key) {
|
|
2743
|
+
return normalizeShortcutToken(key) in HORIZONTAL_DIRECTIONAL_KEY_MIRRORS;
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2746
|
+
* Resolves direction behavior for a chord.
|
|
2747
|
+
* Horizontal direction keys default to `semantic`; others default to `physical`.
|
|
2748
|
+
* An explicit binding value always wins.
|
|
2749
|
+
*/
|
|
2750
|
+
function resolveEffectiveDirectionBehavior(chord, explicit) {
|
|
2751
|
+
if (explicit === 'physical' || explicit === 'semantic') {
|
|
2752
|
+
return explicit;
|
|
2753
|
+
}
|
|
2754
|
+
const { key } = parseKeyboardShortcutChord(chord);
|
|
2755
|
+
return isHorizontalDirectionalShortcutKey(key) ? 'semantic' : 'physical';
|
|
2756
|
+
}
|
|
2757
|
+
/** Resolves the key the user presses for a semantically registered chord in RTL. */
|
|
2758
|
+
function resolveSemanticDirectionalKey(storedKey, rtl) {
|
|
2759
|
+
const normalized = normalizeShortcutToken(storedKey);
|
|
2760
|
+
if (!rtl) {
|
|
2761
|
+
return normalized;
|
|
2762
|
+
}
|
|
2763
|
+
return mirrorHorizontalDirectionalKey(normalized);
|
|
2764
|
+
}
|
|
2765
|
+
/** Chord string with directional key mirrored for RTL display/matching when semantic. */
|
|
2766
|
+
function resolveDisplayShortcutChord(chord, isRtl, explicitDirectionBehavior) {
|
|
2767
|
+
const directionBehavior = resolveEffectiveDirectionBehavior(chord, explicitDirectionBehavior);
|
|
2768
|
+
const parts = chord
|
|
2769
|
+
.trim()
|
|
2770
|
+
.split('+')
|
|
2771
|
+
.map((part) => part.trim())
|
|
2772
|
+
.filter(Boolean);
|
|
2773
|
+
if (parts.length === 0) {
|
|
2774
|
+
return chord;
|
|
2775
|
+
}
|
|
2776
|
+
const keyPart = parts.pop() ?? '';
|
|
2777
|
+
const rtl = directionBehavior === 'semantic' && isRtl;
|
|
2778
|
+
const resolvedKey = resolveSemanticDirectionalKey(keyPart, rtl);
|
|
2779
|
+
return [...parts, resolvedKey].join('+');
|
|
2780
|
+
}
|
|
2781
|
+
const MODIFIER_ALIASES = {
|
|
2782
|
+
ctrl: 'ctrl',
|
|
2783
|
+
control: 'ctrl',
|
|
2784
|
+
shift: 'shift',
|
|
2785
|
+
alt: 'alt',
|
|
2786
|
+
option: 'alt',
|
|
2787
|
+
meta: 'meta',
|
|
2788
|
+
cmd: 'meta',
|
|
2789
|
+
command: 'meta',
|
|
2790
|
+
win: 'meta',
|
|
2791
|
+
};
|
|
2792
|
+
const KEY_DISPLAY_MAC = {
|
|
2793
|
+
ctrl: '⌃',
|
|
2794
|
+
control: '⌃',
|
|
2795
|
+
shift: '⇧',
|
|
2796
|
+
alt: '⌥',
|
|
2797
|
+
option: '⌥',
|
|
2798
|
+
meta: '⌘',
|
|
2799
|
+
cmd: '⌘',
|
|
2800
|
+
command: '⌘',
|
|
2801
|
+
win: '⌘',
|
|
2802
|
+
enter: '↵',
|
|
2803
|
+
escape: 'Esc',
|
|
2804
|
+
esc: 'Esc',
|
|
2805
|
+
home: 'Home',
|
|
2806
|
+
arrowleft: '←',
|
|
2807
|
+
arrowright: '→',
|
|
2808
|
+
arrowup: '↑',
|
|
2809
|
+
arrowdown: '↓',
|
|
2810
|
+
pageup: 'PgUp',
|
|
2811
|
+
pagedown: 'PgDn',
|
|
2812
|
+
backspace: '⌫',
|
|
2813
|
+
delete: '⌦',
|
|
2814
|
+
space: 'Space',
|
|
2815
|
+
};
|
|
2816
|
+
/**
|
|
2817
|
+
* Parses a shortcut chord such as `Enter`, `Escape`, or `ctrl+shift+s`.
|
|
2818
|
+
*/
|
|
2819
|
+
function parseKeyboardShortcutChord(chord) {
|
|
2820
|
+
const parts = chord
|
|
2821
|
+
.trim()
|
|
2822
|
+
.toLowerCase()
|
|
2823
|
+
.split('+')
|
|
2824
|
+
.map((part) => part.trim())
|
|
2825
|
+
.filter(Boolean);
|
|
2826
|
+
const key = normalizeShortcutToken(parts.pop() ?? '');
|
|
2827
|
+
const parsed = {
|
|
2828
|
+
ctrl: false,
|
|
2829
|
+
shift: false,
|
|
2830
|
+
alt: false,
|
|
2831
|
+
meta: false,
|
|
2832
|
+
key,
|
|
2833
|
+
};
|
|
2834
|
+
for (const part of parts) {
|
|
2835
|
+
const alias = MODIFIER_ALIASES[part];
|
|
2836
|
+
if (alias) {
|
|
2837
|
+
parsed[alias] = true;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
return parsed;
|
|
2841
|
+
}
|
|
2842
|
+
/**
|
|
2843
|
+
* Returns true when the keyboard event matches the given chord.
|
|
2844
|
+
* On macOS, `ctrl+*` chords also match `meta+*` for common platform shortcuts.
|
|
2845
|
+
*/
|
|
2846
|
+
function matchesKeyboardShortcutChord(event, chord, options) {
|
|
2847
|
+
const parsed = parseKeyboardShortcutChord(chord);
|
|
2848
|
+
const mac = isMacPlatform();
|
|
2849
|
+
const directionBehavior = resolveEffectiveDirectionBehavior(chord, options?.directionBehavior);
|
|
2850
|
+
if (!matchesShortcutModifiers(parsed, event, mac)) {
|
|
2851
|
+
return false;
|
|
2852
|
+
}
|
|
2853
|
+
const actualKey = normalizeShortcutEventKey(event);
|
|
2854
|
+
const expectedKey = normalizeShortcutToken(parsed.key);
|
|
2855
|
+
const rtlSemantic = directionBehavior === 'semantic' &&
|
|
2856
|
+
options?.isRtl === true &&
|
|
2857
|
+
isHorizontalDirectionalShortcutKey(expectedKey);
|
|
2858
|
+
if (rtlSemantic) {
|
|
2859
|
+
return actualKey === mirrorHorizontalDirectionalKey(expectedKey);
|
|
2860
|
+
}
|
|
2861
|
+
return actualKey === expectedKey;
|
|
2862
|
+
}
|
|
2863
|
+
/**
|
|
2864
|
+
* Matches modifier keys for a parsed chord.
|
|
2865
|
+
* `ctrl+alt` chords also accept AltGraph (Windows) so layout-produced characters still match physical keys.
|
|
2866
|
+
*/
|
|
2867
|
+
function matchesShortcutModifiers(parsed, event, mac) {
|
|
2868
|
+
if (parsed.shift !== event.shiftKey) {
|
|
2869
|
+
return false;
|
|
2870
|
+
}
|
|
2871
|
+
const altGraph = hasAltGraphModifier(event);
|
|
2872
|
+
if (parsed.ctrl && parsed.alt) {
|
|
2873
|
+
if (altGraph) {
|
|
2874
|
+
return true;
|
|
2875
|
+
}
|
|
2876
|
+
return event.ctrlKey && event.altKey;
|
|
2877
|
+
}
|
|
2878
|
+
if (parsed.alt !== event.altKey) {
|
|
2879
|
+
return false;
|
|
2880
|
+
}
|
|
2881
|
+
if (parsed.meta) {
|
|
2882
|
+
if (!event.metaKey) {
|
|
2883
|
+
return false;
|
|
2884
|
+
}
|
|
2885
|
+
return true;
|
|
2886
|
+
}
|
|
2887
|
+
if (parsed.ctrl) {
|
|
2888
|
+
if (mac) {
|
|
2889
|
+
return event.metaKey || event.ctrlKey;
|
|
2890
|
+
}
|
|
2891
|
+
return event.ctrlKey;
|
|
2892
|
+
}
|
|
2893
|
+
if (event.ctrlKey || event.metaKey) {
|
|
2894
|
+
return false;
|
|
2895
|
+
}
|
|
2896
|
+
return true;
|
|
2897
|
+
}
|
|
2898
|
+
function hasAltGraphModifier(event) {
|
|
2899
|
+
return typeof event.getModifierState === 'function' && event.getModifierState('AltGraph');
|
|
2900
|
+
}
|
|
2901
|
+
/**
|
|
2902
|
+
* Formats one chord for UI display (OS-aware modifier symbols).
|
|
2903
|
+
*/
|
|
2904
|
+
function formatKeyboardShortcutChord(chord, options) {
|
|
2905
|
+
const directionBehavior = resolveEffectiveDirectionBehavior(chord, options?.directionBehavior);
|
|
2906
|
+
const resolvedChord = options?.skipDirectionResolve
|
|
2907
|
+
? chord
|
|
2908
|
+
: resolveDisplayShortcutChord(chord, options?.isRtl === true, directionBehavior);
|
|
2909
|
+
const mac = isMacPlatform();
|
|
2910
|
+
const parts = resolvedChord
|
|
2911
|
+
.trim()
|
|
2912
|
+
.split('+')
|
|
2913
|
+
.map((part) => part.trim())
|
|
2914
|
+
.filter(Boolean);
|
|
2915
|
+
if (parts.length === 0) {
|
|
2916
|
+
return '';
|
|
2917
|
+
}
|
|
2918
|
+
const keyPart = normalizeShortcutToken(parts.pop() ?? '');
|
|
2919
|
+
const modifierParts = parts.map((part) => formatShortcutPart(part.toLowerCase(), mac));
|
|
2920
|
+
const keyDisplay = formatShortcutPart(keyPart, mac);
|
|
2921
|
+
if (mac) {
|
|
2922
|
+
return [...modifierParts, keyDisplay].join('');
|
|
2923
|
+
}
|
|
2924
|
+
return [...modifierParts, keyDisplay].join('+');
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* Formats multiple chords as a single display string (e.g. `← / PgUp`).
|
|
2928
|
+
*/
|
|
2929
|
+
function formatKeyboardShortcutChords(chords, options) {
|
|
2930
|
+
return chords.map((chord) => formatKeyboardShortcutChord(chord, options)).join(' / ');
|
|
2931
|
+
}
|
|
2932
|
+
/** Maps a chord to `ax-kbd-item` key parts (modifiers + display symbols). */
|
|
2933
|
+
function chordToKbdItemKeys(chord, options) {
|
|
2934
|
+
const directionBehavior = resolveEffectiveDirectionBehavior(chord, options?.directionBehavior);
|
|
2935
|
+
const resolvedChord = options?.skipDirectionResolve
|
|
2936
|
+
? chord
|
|
2937
|
+
: resolveDisplayShortcutChord(chord, options?.isRtl === true, directionBehavior);
|
|
2938
|
+
const mac = isMacPlatform();
|
|
2939
|
+
const symbolKeys = {
|
|
2940
|
+
arrowleft: '←',
|
|
2941
|
+
arrowright: '→',
|
|
2942
|
+
arrowup: '↑',
|
|
2943
|
+
arrowdown: '↓',
|
|
2944
|
+
pageup: 'PgUp',
|
|
2945
|
+
pagedown: 'PgDn',
|
|
2946
|
+
enter: '↵',
|
|
2947
|
+
escape: 'Esc',
|
|
2948
|
+
esc: 'Esc',
|
|
2949
|
+
space: 'Space',
|
|
2950
|
+
'[': '[',
|
|
2951
|
+
']': ']',
|
|
2952
|
+
};
|
|
2953
|
+
return resolvedChord
|
|
2954
|
+
.trim()
|
|
2955
|
+
.split('+')
|
|
2956
|
+
.map((part) => part.trim())
|
|
2957
|
+
.filter(Boolean)
|
|
2958
|
+
.map((part) => {
|
|
2959
|
+
const normalized = part.toLowerCase();
|
|
2960
|
+
if (mac && (normalized === 'ctrl' || normalized === 'control')) {
|
|
2961
|
+
return '⌘';
|
|
2962
|
+
}
|
|
2963
|
+
return symbolKeys[normalized] ?? part;
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
/**
|
|
2967
|
+
* When focus is in a native edit control, avoid stealing plain key shortcuts.
|
|
2968
|
+
*/
|
|
2969
|
+
function isKeyboardTargetInsideEditableField(target) {
|
|
2970
|
+
if (!(target instanceof HTMLElement)) {
|
|
2971
|
+
return false;
|
|
2972
|
+
}
|
|
2973
|
+
if (target.isContentEditable) {
|
|
2974
|
+
return true;
|
|
2975
|
+
}
|
|
2976
|
+
const field = target.closest('input, textarea, select');
|
|
2977
|
+
if (!field || field.disabled) {
|
|
2978
|
+
return false;
|
|
2979
|
+
}
|
|
2980
|
+
if (field instanceof HTMLInputElement) {
|
|
2981
|
+
const type = field.type;
|
|
2982
|
+
if (type === 'hidden' ||
|
|
2983
|
+
type === 'checkbox' ||
|
|
2984
|
+
type === 'radio' ||
|
|
2985
|
+
type === 'button' ||
|
|
2986
|
+
type === 'submit' ||
|
|
2987
|
+
type === 'reset' ||
|
|
2988
|
+
type === 'file' ||
|
|
2989
|
+
field.readOnly) {
|
|
2990
|
+
return false;
|
|
2991
|
+
}
|
|
2992
|
+
return true;
|
|
2993
|
+
}
|
|
2994
|
+
if (field instanceof HTMLTextAreaElement) {
|
|
2995
|
+
return !field.readOnly;
|
|
2996
|
+
}
|
|
2997
|
+
return true;
|
|
2998
|
+
}
|
|
2999
|
+
/**
|
|
3000
|
+
* Returns true when Esc should close an open widget overlay first (select, date picker, popover, modal).
|
|
3001
|
+
* Used by the global shortcut registry so page-level Esc bindings do not swallow overlay dismiss.
|
|
3002
|
+
*/
|
|
3003
|
+
function shouldDeferEscapeToOpenOverlay(document) {
|
|
3004
|
+
return hasForegroundOverlayLayer(document);
|
|
3005
|
+
}
|
|
3006
|
+
function isMacPlatform() {
|
|
3007
|
+
if (typeof navigator === 'undefined') {
|
|
3008
|
+
return false;
|
|
3009
|
+
}
|
|
3010
|
+
return /Mac|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
3011
|
+
}
|
|
3012
|
+
function normalizeShortcutToken(key) {
|
|
3013
|
+
const normalized = key.trim().toLowerCase();
|
|
3014
|
+
if (normalized === 'esc') {
|
|
3015
|
+
return 'escape';
|
|
3016
|
+
}
|
|
3017
|
+
if (normalized === 'left') {
|
|
3018
|
+
return 'arrowleft';
|
|
3019
|
+
}
|
|
3020
|
+
if (normalized === 'right') {
|
|
3021
|
+
return 'arrowright';
|
|
3022
|
+
}
|
|
3023
|
+
if (normalized === 'up') {
|
|
3024
|
+
return 'arrowup';
|
|
3025
|
+
}
|
|
3026
|
+
if (normalized === 'down') {
|
|
3027
|
+
return 'arrowdown';
|
|
3028
|
+
}
|
|
3029
|
+
if (normalized === '[' || normalized === 'bracketleft') {
|
|
3030
|
+
return '[';
|
|
3031
|
+
}
|
|
3032
|
+
if (normalized === ']' || normalized === 'bracketright') {
|
|
3033
|
+
return ']';
|
|
3034
|
+
}
|
|
3035
|
+
return normalized;
|
|
3036
|
+
}
|
|
3037
|
+
function normalizeShortcutEventKey(event) {
|
|
3038
|
+
if (event.key === 'Enter') {
|
|
3039
|
+
return 'enter';
|
|
3040
|
+
}
|
|
3041
|
+
if (event.key === 'Escape') {
|
|
3042
|
+
return 'escape';
|
|
3043
|
+
}
|
|
3044
|
+
if (event.key === 'Home') {
|
|
3045
|
+
return 'home';
|
|
3046
|
+
}
|
|
3047
|
+
if (event.key === ' ') {
|
|
3048
|
+
return 'space';
|
|
3049
|
+
}
|
|
3050
|
+
if (event.key === '[' || event.code === 'BracketLeft') {
|
|
3051
|
+
return '[';
|
|
3052
|
+
}
|
|
3053
|
+
if (event.key === ']' || event.code === 'BracketRight') {
|
|
3054
|
+
return ']';
|
|
3055
|
+
}
|
|
3056
|
+
const codeMatch = event.code.match(/^Key([A-Z])$/);
|
|
3057
|
+
if (codeMatch) {
|
|
3058
|
+
return codeMatch[1].toLowerCase();
|
|
3059
|
+
}
|
|
3060
|
+
const digitMatch = event.code.match(/^Digit([0-9])$/);
|
|
3061
|
+
if (digitMatch) {
|
|
3062
|
+
return digitMatch[1];
|
|
3063
|
+
}
|
|
3064
|
+
if (event.key.length === 1) {
|
|
3065
|
+
return event.key.toLowerCase();
|
|
3066
|
+
}
|
|
3067
|
+
const fnMatch = event.code.match(/^F(\d+)$/);
|
|
3068
|
+
if (fnMatch) {
|
|
3069
|
+
return `f${fnMatch[1]}`;
|
|
3070
|
+
}
|
|
3071
|
+
return event.key.toLowerCase();
|
|
3072
|
+
}
|
|
3073
|
+
function formatShortcutPart(part, mac) {
|
|
3074
|
+
const normalized = normalizeShortcutToken(part);
|
|
3075
|
+
if (mac && KEY_DISPLAY_MAC[normalized]) {
|
|
3076
|
+
return KEY_DISPLAY_MAC[normalized];
|
|
3077
|
+
}
|
|
3078
|
+
if (!mac && MODIFIER_ALIASES[normalized]) {
|
|
3079
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
3080
|
+
}
|
|
3081
|
+
if (KEY_DISPLAY_MAC[normalized]) {
|
|
3082
|
+
return KEY_DISPLAY_MAC[normalized];
|
|
3083
|
+
}
|
|
3084
|
+
if (normalized.length === 1) {
|
|
3085
|
+
return normalized.toUpperCase();
|
|
3086
|
+
}
|
|
3087
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
3088
|
+
}
|
|
3089
|
+
//#endregion
|
|
3090
|
+
|
|
3091
|
+
//#region ---- Keyboard Shortcut Declaration Utilities ----
|
|
3092
|
+
/**
|
|
3093
|
+
* Normalizes a declarative shortcut (`'ctrl+s'` or `{ keys: 'home', allowInEditableFields: false }`).
|
|
3094
|
+
*/
|
|
3095
|
+
function normalizeKeyboardShortcut(shortcut) {
|
|
3096
|
+
if (typeof shortcut === 'string') {
|
|
3097
|
+
const chord = shortcut.trim();
|
|
3098
|
+
if (!chord) {
|
|
3099
|
+
return undefined;
|
|
3100
|
+
}
|
|
3101
|
+
return { keys: [chord] };
|
|
3102
|
+
}
|
|
3103
|
+
return normalizeKeyboardShortcutConfig(shortcut);
|
|
3104
|
+
}
|
|
3105
|
+
/**
|
|
3106
|
+
* Normalizes an array of declarative shortcuts. Empty or invalid entries are skipped.
|
|
3107
|
+
*/
|
|
3108
|
+
function normalizeKeyboardShortcuts(shortcuts) {
|
|
3109
|
+
if (!shortcuts?.length) {
|
|
3110
|
+
return [];
|
|
3111
|
+
}
|
|
3112
|
+
const result = [];
|
|
3113
|
+
for (const shortcut of shortcuts) {
|
|
3114
|
+
const normalized = normalizeKeyboardShortcut(shortcut);
|
|
3115
|
+
if (normalized) {
|
|
3116
|
+
result.push(normalized);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
return result;
|
|
3120
|
+
}
|
|
3121
|
+
/** Returns the first chord from declarative shortcuts (for UI hints such as `ax-kbd`). */
|
|
3122
|
+
function getPrimaryKeyboardShortcutChord(shortcuts) {
|
|
3123
|
+
return normalizeKeyboardShortcuts(shortcuts)[0]?.keys[0];
|
|
3124
|
+
}
|
|
3125
|
+
function normalizeKeyboardShortcutConfig(shortcut) {
|
|
3126
|
+
const keys = Array.isArray(shortcut.keys) ? shortcut.keys : [shortcut.keys];
|
|
3127
|
+
const normalizedKeys = keys.map((chord) => chord.trim()).filter(Boolean);
|
|
3128
|
+
if (normalizedKeys.length === 0) {
|
|
3129
|
+
return undefined;
|
|
3130
|
+
}
|
|
3131
|
+
return {
|
|
3132
|
+
keys: normalizedKeys,
|
|
3133
|
+
allowInEditableFields: shortcut.allowInEditableFields,
|
|
3134
|
+
when: shortcut.when,
|
|
3135
|
+
directionBehavior: shortcut.directionBehavior,
|
|
3136
|
+
};
|
|
3137
|
+
}
|
|
3138
|
+
//#endregion
|
|
3139
|
+
|
|
3140
|
+
//#region ---- Imports ----
|
|
3141
|
+
//#endregion
|
|
3142
|
+
class AXPKeyboardShortcutRegistry {
|
|
3143
|
+
constructor() {
|
|
3144
|
+
//#region ---- Services & Dependencies ----
|
|
3145
|
+
this.document = inject(DOCUMENT);
|
|
3146
|
+
this.localeService = inject(AXLocaleService);
|
|
3147
|
+
this.activeProfile = toSignal(this.localeService.profileChanged$, {
|
|
3148
|
+
initialValue: this.localeService.activeProfile(),
|
|
3149
|
+
});
|
|
3150
|
+
this.registrations = signal([], ...(ngDevMode ? [{ debugName: "registrations" }] : /* istanbul ignore next */ []));
|
|
3151
|
+
this.helpDialogHandler = null;
|
|
3152
|
+
this.listenerAttached = false;
|
|
3153
|
+
//#endregion
|
|
3154
|
+
//#region ---- Computed Properties ----
|
|
3155
|
+
/** Active shortcut entries for the help dialog. */
|
|
3156
|
+
this.helpEntries = computed(() => {
|
|
3157
|
+
this.activeProfile();
|
|
3158
|
+
return this.buildHelpEntries();
|
|
3159
|
+
}, ...(ngDevMode ? [{ debugName: "helpEntries" }] : /* istanbul ignore next */ []));
|
|
3160
|
+
this.onDocumentKeyDown = (event) => {
|
|
3161
|
+
if (event.key === 'Escape' && shouldDeferEscapeToOpenOverlay(this.document)) {
|
|
3162
|
+
return;
|
|
3163
|
+
}
|
|
3164
|
+
if (event.key === 'F1') {
|
|
3165
|
+
event.preventDefault();
|
|
3166
|
+
event.stopImmediatePropagation();
|
|
3167
|
+
if (hasForegroundOverlayLayer(this.document)) {
|
|
3168
|
+
return;
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
const candidates = this.resolveActiveCandidates(event);
|
|
3172
|
+
if (candidates.length === 0) {
|
|
3173
|
+
return;
|
|
3174
|
+
}
|
|
3175
|
+
const match = candidates[0];
|
|
3176
|
+
event.preventDefault();
|
|
3177
|
+
event.stopImmediatePropagation();
|
|
3178
|
+
void match.binding.handler(event);
|
|
3179
|
+
};
|
|
3180
|
+
}
|
|
3181
|
+
//#endregion
|
|
3182
|
+
//#region ---- Public Methods ----
|
|
3183
|
+
/**
|
|
3184
|
+
* Registers a scope of shortcuts. Unregisters automatically when `owner` is destroyed.
|
|
3185
|
+
*/
|
|
3186
|
+
register(options) {
|
|
3187
|
+
const { owner, ...registrationOptions } = options;
|
|
3188
|
+
const registrationId = `${options.id}-${this.createRegistrationId()}`;
|
|
3189
|
+
const entry = {
|
|
3190
|
+
...registrationOptions,
|
|
3191
|
+
registrationId,
|
|
3192
|
+
priority: options.priority ?? 0,
|
|
3193
|
+
};
|
|
3194
|
+
this.registrations.update((items) => [
|
|
3195
|
+
...items.filter((item) => item.id !== options.id),
|
|
3196
|
+
entry,
|
|
3197
|
+
]);
|
|
3198
|
+
this.ensureListener();
|
|
3199
|
+
owner.onDestroy(() => {
|
|
3200
|
+
this.unregister(registrationId);
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Wires the F1 help dialog opener (provided by platform/common).
|
|
3205
|
+
*/
|
|
3206
|
+
setHelpDialogHandler(handler) {
|
|
3207
|
+
this.helpDialogHandler = handler;
|
|
3208
|
+
this.ensureHelpShortcutRegistered();
|
|
3209
|
+
}
|
|
3210
|
+
/** OS-aware display string for UI hints. */
|
|
3211
|
+
formatDisplayKeys(chords) {
|
|
3212
|
+
return formatKeyboardShortcutChords(chords, { isRtl: this.isRtlProfile() });
|
|
3213
|
+
}
|
|
3214
|
+
//#endregion
|
|
3215
|
+
//#region ---- Private Methods ----
|
|
3216
|
+
ensureHelpShortcutRegistered() {
|
|
3217
|
+
const alreadyRegistered = this.registrations().some((entry) => entry.id === 'system:keyboard-shortcuts-help');
|
|
3218
|
+
if (alreadyRegistered || !this.helpDialogHandler) {
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3221
|
+
const handler = this.helpDialogHandler;
|
|
3222
|
+
const entry = {
|
|
3223
|
+
registrationId: 'system:keyboard-shortcuts-help',
|
|
3224
|
+
id: 'system:keyboard-shortcuts-help',
|
|
3225
|
+
priority: -1,
|
|
3226
|
+
scope: '@general:keyboard-shortcuts.groups.system',
|
|
3227
|
+
shortcuts: [
|
|
3228
|
+
{
|
|
3229
|
+
keys: ['f1'],
|
|
3230
|
+
title: '@general:keyboard-shortcuts.help-action',
|
|
3231
|
+
allowInEditableFields: true,
|
|
3232
|
+
handler: () => {
|
|
3233
|
+
void handler();
|
|
3234
|
+
},
|
|
3235
|
+
},
|
|
3236
|
+
],
|
|
3237
|
+
};
|
|
3238
|
+
this.registrations.update((items) => [...items, entry]);
|
|
3239
|
+
this.ensureListener();
|
|
3240
|
+
}
|
|
3241
|
+
createRegistrationId() {
|
|
3242
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
3243
|
+
return crypto.randomUUID();
|
|
3244
|
+
}
|
|
3245
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
3246
|
+
}
|
|
3247
|
+
unregister(registrationId) {
|
|
3248
|
+
this.registrations.update((items) => items.filter((item) => item.registrationId !== registrationId));
|
|
3249
|
+
}
|
|
3250
|
+
ensureListener() {
|
|
3251
|
+
if (this.listenerAttached || typeof this.document === 'undefined') {
|
|
3252
|
+
return;
|
|
3253
|
+
}
|
|
3254
|
+
this.document.addEventListener('keydown', this.onDocumentKeyDown, true);
|
|
3255
|
+
this.listenerAttached = true;
|
|
3256
|
+
}
|
|
3257
|
+
resolveActiveCandidates(event) {
|
|
3258
|
+
const editable = isKeyboardTargetInsideEditableField(event.target);
|
|
3259
|
+
const candidates = [];
|
|
3260
|
+
for (const registration of this.registrations()) {
|
|
3261
|
+
if (!this.isRegistrationActive(registration)) {
|
|
3262
|
+
continue;
|
|
3263
|
+
}
|
|
3264
|
+
const priority = registration.priority ?? 0;
|
|
3265
|
+
for (const binding of registration.shortcuts) {
|
|
3266
|
+
if (binding.when && !binding.when()) {
|
|
3267
|
+
continue;
|
|
3268
|
+
}
|
|
3269
|
+
if (editable && !binding.allowInEditableFields) {
|
|
3270
|
+
continue;
|
|
3271
|
+
}
|
|
3272
|
+
for (const chord of binding.keys) {
|
|
3273
|
+
const directionBehavior = resolveEffectiveDirectionBehavior(chord, binding.directionBehavior);
|
|
3274
|
+
if (!matchesKeyboardShortcutChord(event, chord, {
|
|
3275
|
+
directionBehavior,
|
|
3276
|
+
isRtl: this.isRtlProfile(),
|
|
3277
|
+
})) {
|
|
3278
|
+
continue;
|
|
3279
|
+
}
|
|
3280
|
+
candidates.push({
|
|
3281
|
+
priority,
|
|
3282
|
+
registration,
|
|
3283
|
+
binding,
|
|
3284
|
+
chord,
|
|
3285
|
+
});
|
|
3286
|
+
break;
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
return candidates.sort((a, b) => b.priority - a.priority);
|
|
3291
|
+
}
|
|
3292
|
+
isRegistrationActive(registration) {
|
|
3293
|
+
if (registration.when && !registration.when()) {
|
|
3294
|
+
return false;
|
|
3295
|
+
}
|
|
3296
|
+
const element = registration.elementRef?.nativeElement;
|
|
3297
|
+
if (element && !this.document.contains(element)) {
|
|
3298
|
+
return false;
|
|
3299
|
+
}
|
|
3300
|
+
return true;
|
|
3301
|
+
}
|
|
3302
|
+
isRtlProfile() {
|
|
3303
|
+
return this.activeProfile()?.i18nMeta?.rtl === true;
|
|
3304
|
+
}
|
|
3305
|
+
buildHelpEntries() {
|
|
3306
|
+
const entries = [];
|
|
3307
|
+
const isRtl = this.isRtlProfile();
|
|
3308
|
+
for (const registration of this.registrations()) {
|
|
3309
|
+
if (!this.isRegistrationActive(registration)) {
|
|
3310
|
+
continue;
|
|
3311
|
+
}
|
|
3312
|
+
if (registration.id === 'system:keyboard-shortcuts-help') {
|
|
3313
|
+
continue;
|
|
3314
|
+
}
|
|
3315
|
+
const priority = registration.priority ?? 0;
|
|
3316
|
+
for (const binding of registration.shortcuts) {
|
|
3317
|
+
const displayChords = binding.keys.map((chord) => {
|
|
3318
|
+
const directionBehavior = resolveEffectiveDirectionBehavior(chord, binding.directionBehavior);
|
|
3319
|
+
return resolveDisplayShortcutChord(chord, isRtl, directionBehavior);
|
|
3320
|
+
});
|
|
3321
|
+
entries.push({
|
|
3322
|
+
registrationId: registration.registrationId,
|
|
3323
|
+
bindingTitle: binding.title,
|
|
3324
|
+
chords: [...binding.keys],
|
|
3325
|
+
displayChords,
|
|
3326
|
+
displayKeys: formatKeyboardShortcutChords(displayChords, { skipDirectionResolve: true }),
|
|
3327
|
+
scope: registration.scope,
|
|
3328
|
+
group: binding.group ?? registration.group,
|
|
3329
|
+
priority,
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
return entries.sort((a, b) => b.priority - a.priority || a.bindingTitle.localeCompare(b.bindingTitle));
|
|
3334
|
+
}
|
|
3335
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPKeyboardShortcutRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3336
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPKeyboardShortcutRegistry, providedIn: 'root' }); }
|
|
3337
|
+
}
|
|
3338
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPKeyboardShortcutRegistry, decorators: [{
|
|
3339
|
+
type: Injectable,
|
|
3340
|
+
args: [{
|
|
3341
|
+
providedIn: 'root',
|
|
3342
|
+
}]
|
|
3343
|
+
}] });
|
|
3344
|
+
|
|
2328
3345
|
//#region ---- Imports ----
|
|
2329
3346
|
//#endregion
|
|
2330
3347
|
|
|
@@ -2684,6 +3701,8 @@ class AXPAppStartUpService {
|
|
|
2684
3701
|
this.translationService = inject(AXTranslationService);
|
|
2685
3702
|
this.tasks = [];
|
|
2686
3703
|
}
|
|
3704
|
+
//#endregion
|
|
3705
|
+
//#region ---- Public Methods ----
|
|
2687
3706
|
registerTask(task) {
|
|
2688
3707
|
this.tasks.push(task);
|
|
2689
3708
|
}
|
|
@@ -3990,16 +5009,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
3990
5009
|
|
|
3991
5010
|
const loggingEnabled = false; // Set to true to enable logging, false to disable
|
|
3992
5011
|
//#region ---- Multilingual string helpers ----
|
|
3993
|
-
/**
|
|
3994
|
-
* Per-locale string map as produced by multilingual editors (e.g. `{ "en-US": "...", "fa-IR": "..." }`).
|
|
3995
|
-
*/
|
|
3996
|
-
function isLocaleStringMap(value) {
|
|
3997
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value) || value instanceof Date) {
|
|
3998
|
-
return false;
|
|
3999
|
-
}
|
|
4000
|
-
const values = Object.values(value);
|
|
4001
|
-
return values.length > 0 && values.every((v) => typeof v === 'string');
|
|
4002
|
-
}
|
|
4003
5012
|
/**
|
|
4004
5013
|
* Lowercased text for client-side filtering: plain string or all locale values joined.
|
|
4005
5014
|
*/
|
|
@@ -4724,5 +5733,5 @@ function generateKebabCase(title) {
|
|
|
4724
5733
|
* Generated bundle index. Do not edit.
|
|
4725
5734
|
*/
|
|
4726
5735
|
|
|
4727
|
-
export { AXHighlightService, AXPActivityLogProvider, AXPActivityLogService, AXPAppStartUpProvider, AXPAppStartUpService, AXPBroadcastEventService, AXPCatalogScopeDefinitionProviderService, AXPCatalogScopeDefinitionsDataSourceDefinition, AXPColorPaletteProvider, AXPColorPaletteService, AXPColumnWidthService, AXPComponentLogoConfig, AXPComponentSlot, AXPComponentSlotDirective, AXPComponentSlotModule, AXPComponentSlotRegistryService, AXPContentCheckerDirective, AXPContextChangeEvent, AXPContextDefinitionProviderService, AXPContextStore, AXPCountdownPipe, AXPDataGenerator, AXPDataSourceDefinitionProviderService, AXPDblClickDirective, AXPDefaultColorPalettesProvider, AXPDeviceService, AXPDeviceType, AXPDistributedEventListenerService, AXPElementDataDirective, AXPExportTemplateToken, AXPExpressionEvaluatorScopeProviderContext, AXPExpressionEvaluatorScopeProviderService, AXPExpressionEvaluatorService, AXPFeatureDefinitionProviderContext, AXPGridLayoutDirective, AXPHookService, AXPIconLogoConfig, AXPImageUrlLogoConfig, AXPModuleManifestModule, AXPModuleManifestRegistry, AXPModuleManifestsDataSourceDefinition, AXPPlatformScope, AXPScreenSize, AXPSystemActionType, AXPSystemActions, AXPTagProvider, AXPTagService, AXP_ACTIVITY_LOG_PROVIDER, AXP_CATALOG_SCOPE_DEFINITION_PROVIDER, AXP_COLOR_PALETTE_PROVIDER, AXP_COLUMN_WIDTH_PROVIDER, AXP_CONTEXT_DEFINITION_PROVIDER, AXP_DATASOURCE_DEFINITION_PROVIDER, AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER, AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER, AXP_FEATURE_DEFINITION_PROVIDER, AXP_MODULE_MANIFEST_PROVIDER, AXP_SESSION_SERVICE, AXP_TAG_PROVIDER, MODULE_MANIFESTS_DATASOURCE_NAME, PLATFORM_CATALOG_SCOPES_DATASOURCE_NAME, applyFilterArray, applyPagination, applyQueryArray, applySortArray, applySystemActionDefault, captureFormContextBaseline, cleanDeep, coerceUnknownToBoolean, coerceUnknownToDate, coerceUnknownToFiniteNumber, coerceUnknownToTrimmedString, compareMultiLanguageStrings, containsHtmlMarkup, createProviderWithInjectionContext, defaultColumnWidthProvider, extractNestedFieldsWildcard, extractTextFromHtml, extractValue, generateKebabCase, getActionButton, getChangedPaths, getDetailedChanges, getEnumValues, getNestedKeys, getSmart, getSystemActions, isFormContextDirty, normalizeDefinitionCategories, objectKeyValueTransforms, provideLazyProvider, resolveActionLook, resolvePlatformScopeKey, resolvePlatformScopeName, searchInMultiLanguageString, setSmart, sortByMultiLanguageString, unwrapValueProperty };
|
|
5736
|
+
export { AXHighlightService, AXPActivityLogProvider, AXPActivityLogService, AXPAppStartUpProvider, AXPAppStartUpService, AXPBroadcastEventService, AXPCatalogScopeDefinitionProviderService, AXPCatalogScopeDefinitionsDataSourceDefinition, AXPColorPaletteProvider, AXPColorPaletteService, AXPColumnWidthService, AXPComponentLogoConfig, AXPComponentSlot, AXPComponentSlotDirective, AXPComponentSlotModule, AXPComponentSlotRegistryService, AXPContentCheckerDirective, AXPContextChangeEvent, AXPContextDefinitionProviderService, AXPContextStore, AXPCountdownPipe, AXPDataGenerator, AXPDataSourceDefinitionProviderService, AXPDblClickDirective, AXPDefaultColorPalettesProvider, AXPDeviceService, AXPDeviceType, AXPDistributedEventListenerService, AXPElementDataDirective, AXPExportTemplateToken, AXPExpressionEvaluatorScopeProviderContext, AXPExpressionEvaluatorScopeProviderService, AXPExpressionEvaluatorService, AXPFeatureDefinitionProviderContext, AXPGridLayoutDirective, AXPHookService, AXPIconLogoConfig, AXPImageUrlLogoConfig, AXPKeyboardShortcutPriority, AXPKeyboardShortcutRegistry, AXPModuleManifestModule, AXPModuleManifestRegistry, AXPModuleManifestsDataSourceDefinition, AXPPlatformScope, AXPScreenSize, AXPSystemActionType, AXPSystemActions, AXPTagProvider, AXPTagService, AXP_ACTIVITY_LOG_PROVIDER, AXP_CATALOG_SCOPE_DEFINITION_PROVIDER, AXP_COLOR_PALETTE_PROVIDER, AXP_COLUMN_WIDTH_PROVIDER, AXP_CONTEXT_DEFINITION_PROVIDER, AXP_DATASOURCE_DEFINITION_PROVIDER, AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER, AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER, AXP_FEATURE_DEFINITION_PROVIDER, AXP_MODULE_MANIFEST_PROVIDER, AXP_SESSION_SERVICE, AXP_TAG_PROVIDER, AX_OVERLAY_CONTAINER_SELECTOR, AX_OVERLAY_PANE_SELECTOR, MODULE_MANIFESTS_DATASOURCE_NAME, PLATFORM_CATALOG_SCOPES_DATASOURCE_NAME, applyFilterArray, applyPagination, applyQueryArray, applySortArray, applySystemActionDefault, buildLocaleTextMapValue, captureFormContextBaseline, chordToKbdItemKeys, cleanDeep, coerceUnknownToBoolean, coerceUnknownToDate, coerceUnknownToFiniteNumber, coerceUnknownToTrimmedString, compareMultiLanguageStrings, containsHtmlMarkup, createProviderWithInjectionContext, defaultColumnWidthProvider, extractNestedFieldsWildcard, extractTextFromHtml, extractValue, findOverlayContainerAncestor, formatKeyboardShortcutChord, formatKeyboardShortcutChords, generateKebabCase, getActionButton, getChangedPaths, getDetailedChanges, getEnumValues, getNestedKeys, getNestedVisibleOverlayPanes, getPrimaryKeyboardShortcutChord, getSmart, getSystemActions, getTopVisibleOverlayContainer, getVisibleAnchoredOverlayPanes, getVisibleOverlayContainers, hasForegroundOverlayLayer, isFormContextDirty, isFormValueEqual, isHorizontalDirectionalShortcutKey, isKeyboardTargetInsideEditableField, isLocaleStringMap, isMacPlatform, isSelectionValueEqual, isVisibleOverlayElement, matchesKeyboardShortcutChord, mirrorHorizontalDirectionalKey, normalizeDefinitionCategories, normalizeKeyboardShortcut, normalizeKeyboardShortcuts, objectKeyValueTransforms, parseKeyboardShortcutChord, provideLazyProvider, resolveActionLook, resolveDisplayShortcutChord, resolveEffectiveDirectionBehavior, resolvePlatformScopeKey, resolvePlatformScopeName, resolveSemanticDirectionalKey, searchInMultiLanguageString, setSmart, shouldDeferEscapeToOpenOverlay, shouldUseLocaleMapShape, sortByMultiLanguageString, unwrapValueProperty };
|
|
4728
5737
|
//# sourceMappingURL=acorex-platform-core.mjs.map
|