@uuv/assistant 2.72.0 → 2.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/launcher/conf.json +1 -1
  2. package/dist/launcher/uuv-assistant.js +30 -19
  3. package/dist/src/Commons.d.ts +60 -0
  4. package/dist/src/Commons.js +55 -0
  5. package/dist/src/helper/css-helper.d.ts +47 -0
  6. package/dist/src/helper/css-helper.js +83 -0
  7. package/dist/src/helper/highlight/highlight-helper.d.ts +13 -0
  8. package/dist/src/helper/highlight/highlight-helper.js +51 -0
  9. package/dist/src/helper/highlight/inspector-dom.d.ts +7 -0
  10. package/dist/src/helper/highlight/inspector-dom.js +158 -0
  11. package/dist/src/helper/highlight/tooltip-helper.d.ts +2 -0
  12. package/dist/src/helper/highlight/tooltip-helper.js +67 -0
  13. package/dist/src/helper/index.d.ts +1 -0
  14. package/dist/src/helper/index.js +17 -0
  15. package/dist/src/helper/informative-nodes-helper.d.ts +38 -0
  16. package/dist/src/helper/informative-nodes-helper.js +250 -0
  17. package/dist/src/helper/keyboard-navigation-helper.d.ts +21 -0
  18. package/dist/src/helper/keyboard-navigation-helper.js +151 -0
  19. package/dist/src/helper/layer-helper.d.ts +12 -0
  20. package/dist/src/helper/layer-helper.js +149 -0
  21. package/dist/src/helper/result-display-helper.d.ts +2 -0
  22. package/dist/src/helper/result-display-helper.js +20 -0
  23. package/dist/src/helper/result-script-helper.d.ts +1 -0
  24. package/dist/src/helper/result-script-helper.js +30 -0
  25. package/dist/src/helper/selection-helper.d.ts +26 -0
  26. package/dist/src/helper/selection-helper.js +92 -0
  27. package/dist/src/index.d.ts +3 -0
  28. package/dist/src/index.js +19 -0
  29. package/dist/src/service/abstract-component-service.d.ts +21 -0
  30. package/dist/src/service/abstract-component-service.js +107 -0
  31. package/dist/src/service/dialog-service.d.ts +22 -0
  32. package/dist/src/service/dialog-service.js +90 -0
  33. package/dist/src/service/form-completion-service.d.ts +23 -0
  34. package/dist/src/service/form-completion-service.js +72 -0
  35. package/dist/src/service/index.d.ts +4 -0
  36. package/dist/src/service/index.js +20 -0
  37. package/dist/src/service/table-and-grid-service.d.ts +17 -0
  38. package/dist/src/service/table-and-grid-service.js +87 -0
  39. package/dist/src/translator/abstract-translator.d.ts +29 -0
  40. package/dist/src/translator/abstract-translator.js +137 -0
  41. package/dist/src/translator/click-translator.d.ts +21 -0
  42. package/dist/src/translator/click-translator.js +60 -0
  43. package/dist/src/translator/expect-translator.d.ts +23 -0
  44. package/dist/src/translator/expect-translator.js +157 -0
  45. package/dist/src/translator/index.d.ts +8 -0
  46. package/dist/src/translator/index.js +24 -0
  47. package/dist/src/translator/keyboard-navigation-translator.d.ts +19 -0
  48. package/dist/src/translator/keyboard-navigation-translator.js +42 -0
  49. package/dist/src/translator/model.d.ts +38 -0
  50. package/dist/src/translator/model.js +31 -0
  51. package/dist/src/translator/textual-translator.d.ts +15 -0
  52. package/dist/src/translator/textual-translator.js +64 -0
  53. package/dist/src/translator/type-translator.d.ts +24 -0
  54. package/dist/src/translator/type-translator.js +121 -0
  55. package/dist/src/translator/within-translator.d.ts +19 -0
  56. package/dist/src/translator/within-translator.js +42 -0
  57. package/dist/uuv-assistant-resources.bundle.js +104 -99
  58. package/package.json +22 -4
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Software Name : UUV
3
+ *
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * This software is distributed under the MIT License,
7
+ * see the "LICENSE" file for more details
8
+ *
9
+ * Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
10
+ * Software description: Make test writing fast, understandable by any human
11
+ * understanding English or French.
12
+ */
13
+ export declare class InformativeNodesHelper {
14
+ private readonly TAGS_WITH_NATIVE_ACCESSIBILITY_DATA;
15
+ private readonly INTERESTING_TAGS;
16
+ private readonly candidatesWithNativeAccessibleData;
17
+ private readonly candidatesWithCustomAccessibleData;
18
+ constructor();
19
+ /**
20
+ * Trouve l'élément parent le plus pertinent pour l'analyse d'accessibilité
21
+ * @param {HTMLElement} element - L'élément de départ
22
+ * @returns {HTMLElement|null} - L'élément parent pertinent ou null si non trouvé
23
+ */
24
+ findRelevantAccessibilityParent(element: any): HTMLElement | null;
25
+ extractContextForElement(element: Element): {
26
+ parentElement: HTMLElement | null;
27
+ htmlContext: string;
28
+ siblingText: string;
29
+ };
30
+ getSiblingsFragment(element: Element, maxSiblings?: number): string;
31
+ private extractInterestingChildren;
32
+ private isStructuralOnly;
33
+ private findInformativeElements;
34
+ getAvailableNodes(): Element[];
35
+ getAvailableChildren(node: HTMLElement | Element): Promise<Element[]>;
36
+ private hasInformativeAttributes;
37
+ getDialogName(node: Element): string | null;
38
+ }
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ /**
3
+ * Software Name : UUV
4
+ *
5
+ * SPDX-License-Identifier: MIT
6
+ *
7
+ * This software is distributed under the MIT License,
8
+ * see the "LICENSE" file for more details
9
+ *
10
+ * Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
11
+ * Software description: Make test writing fast, understandable by any human
12
+ * understanding English or French.
13
+ */
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.InformativeNodesHelper = void 0;
25
+ class InformativeNodesHelper {
26
+ constructor() {
27
+ this.TAGS_WITH_NATIVE_ACCESSIBILITY_DATA = [
28
+ "article",
29
+ "aside",
30
+ "button",
31
+ "details",
32
+ "dialog",
33
+ "fieldset",
34
+ "figure",
35
+ "form",
36
+ "footer",
37
+ "h1",
38
+ "h2",
39
+ "h3",
40
+ "h4",
41
+ "h5",
42
+ "h6",
43
+ "header",
44
+ "hr",
45
+ "img",
46
+ "input",
47
+ "label",
48
+ "li",
49
+ "main",
50
+ "menu",
51
+ "nav",
52
+ "ol",
53
+ "ul",
54
+ "option",
55
+ "progress",
56
+ "section",
57
+ "select",
58
+ "summary",
59
+ "table",
60
+ "textarea",
61
+ "tbody",
62
+ "thead",
63
+ "tfoot",
64
+ "td",
65
+ "th",
66
+ "tr",
67
+ ];
68
+ // fIXME SSE transformer en role
69
+ this.INTERESTING_TAGS = ["P", "H1", "H2", "H3", "H4", "H5", "H6", "BUTTON", "A", "LABEL", "STRONG", "DIV", "SPANz"];
70
+ this.candidatesWithNativeAccessibleData = document.querySelectorAll(this.TAGS_WITH_NATIVE_ACCESSIBILITY_DATA.join(","));
71
+ this.candidatesWithCustomAccessibleData = this.findInformativeElements(document);
72
+ }
73
+ /**
74
+ * Trouve l'élément parent le plus pertinent pour l'analyse d'accessibilité
75
+ * @param {HTMLElement} element - L'élément de départ
76
+ * @returns {HTMLElement|null} - L'élément parent pertinent ou null si non trouvé
77
+ */
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ findRelevantAccessibilityParent(element) {
80
+ if (!element || !(element instanceof HTMLElement)) {
81
+ return null;
82
+ }
83
+ // Éléments considérés comme pertinents pour l'accessibilité (par ordre de priorité)
84
+ const relevantElements = [
85
+ // Éléments sectionnels et structurels
86
+ "section", "article", "aside", "nav", "main", "header", "footer",
87
+ // Éléments de contenu
88
+ "p", "div", "span",
89
+ // Éléments de liste
90
+ "ul", "ol", "li", "dl", "dt", "dd",
91
+ // Éléments de formulaire
92
+ "form", "fieldset", "legend",
93
+ // Éléments de tableau
94
+ "table", "thead", "tbody", "tfoot", "tr", "td", "th",
95
+ // Autres éléments structurels
96
+ "blockquote", "figure", "figcaption", "details", "summary"
97
+ ];
98
+ // Éléments avec des rôles ARIA pertinents
99
+ const relevantAriaRoles = [
100
+ "banner", "navigation", "main", "complementary", "contentinfo",
101
+ "region", "article", "section", "group", "list", "listitem",
102
+ "table", "row", "cell", "columnheader", "rowheader",
103
+ "form", "search", "dialog", "alertdialog", "alert"
104
+ ];
105
+ let currentElement = element.parentElement;
106
+ let bestMatch = null;
107
+ let bestPriority = Infinity;
108
+ while (currentElement) {
109
+ const tagName = currentElement.tagName.toLowerCase();
110
+ const role = currentElement.getAttribute("role");
111
+ // Vérifier si l'élément a un rôle ARIA pertinent
112
+ if (role && relevantAriaRoles.includes(role)) {
113
+ const priority = relevantAriaRoles.indexOf(role);
114
+ if (priority < bestPriority) {
115
+ bestMatch = currentElement;
116
+ bestPriority = priority;
117
+ }
118
+ }
119
+ // Vérifier si l'élément est dans notre liste d'éléments pertinents
120
+ const elementIndex = relevantElements.indexOf(tagName);
121
+ if (elementIndex !== -1 && elementIndex < bestPriority) {
122
+ bestMatch = currentElement;
123
+ bestPriority = elementIndex;
124
+ }
125
+ // Vérifier les attributs d'accessibilité importants
126
+ if (currentElement.hasAttribute("aria-label") ||
127
+ currentElement.hasAttribute("aria-labelledby") ||
128
+ currentElement.hasAttribute("aria-describedby")) {
129
+ // Donner une priorité plus élevée aux éléments avec des labels d'accessibilité
130
+ const accessibilityPriority = bestPriority - 0.5;
131
+ if (accessibilityPriority < bestPriority) {
132
+ bestMatch = currentElement;
133
+ bestPriority = accessibilityPriority;
134
+ }
135
+ }
136
+ // Arrêter la recherche si on trouve un élément très pertinent
137
+ if (["section", "article", "main", "nav", "form"].includes(tagName) ||
138
+ (role && ["main", "navigation", "banner", "contentinfo"].includes(role))) {
139
+ break;
140
+ }
141
+ currentElement = currentElement.parentElement;
142
+ }
143
+ return bestMatch;
144
+ }
145
+ extractContextForElement(element) {
146
+ var _a, _b;
147
+ const siblingText = Array.from(((_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.childNodes) || [])
148
+ .filter((n) => {
149
+ var _a;
150
+ const isTextNode = n.nodeType === 3;
151
+ return isTextNode && ((_a = n.textContent) === null || _a === void 0 ? void 0 : _a.trim());
152
+ })
153
+ .map((n) => { var _a; return (_a = n.textContent) === null || _a === void 0 ? void 0 : _a.trim(); })
154
+ .join(" ");
155
+ let fragment = this.getSiblingsFragment(element, 1);
156
+ const prev = (_b = element.parentElement) === null || _b === void 0 ? void 0 : _b.previousElementSibling;
157
+ if (prev && this.INTERESTING_TAGS.includes(prev.tagName)) {
158
+ fragment = prev.outerHTML + "\n" + fragment;
159
+ }
160
+ return {
161
+ parentElement: element.parentElement,
162
+ htmlContext: element.parentElement.outerHTML,
163
+ siblingText,
164
+ };
165
+ }
166
+ getSiblingsFragment(element, maxSiblings = 1) {
167
+ const parent = element.parentElement;
168
+ if (!parent) {
169
+ return element.outerHTML;
170
+ }
171
+ const children = Array.from(parent.children);
172
+ const index = children.indexOf(element);
173
+ const beforeEls = children.slice(Math.max(0, index - maxSiblings), index);
174
+ const afterEls = children.slice(index + 1, index + 1 + maxSiblings);
175
+ function processElement(informativeNodesHelper, el) {
176
+ if (informativeNodesHelper.INTERESTING_TAGS.includes(el.tagName)) {
177
+ return el.outerHTML;
178
+ }
179
+ if (informativeNodesHelper.isStructuralOnly(el)) {
180
+ return informativeNodesHelper.extractInterestingChildren(el).join("\n");
181
+ }
182
+ return "";
183
+ }
184
+ const before = beforeEls.map(value => processElement(this, value)).filter(Boolean);
185
+ const after = afterEls.map(value => processElement(this, value)).filter(Boolean);
186
+ return [...before, element.outerHTML, ...after].join("\n");
187
+ }
188
+ extractInterestingChildren(el) {
189
+ const collected = [];
190
+ for (const child of Array.from(el.children)) {
191
+ if (this.INTERESTING_TAGS.includes(child.tagName)) {
192
+ collected.push(child.outerHTML);
193
+ }
194
+ else if (this.isStructuralOnly(child)) {
195
+ collected.push(...this.extractInterestingChildren(child));
196
+ }
197
+ }
198
+ return collected;
199
+ }
200
+ isStructuralOnly(el) {
201
+ const tag = el.tagName;
202
+ const isStructuralTag = ["DIV", "SPAN", "SECTION", "MAIN", "BODY"].includes(tag);
203
+ return isStructuralTag && !this.hasInformativeAttributes(el);
204
+ }
205
+ findInformativeElements(root) {
206
+ const query = `*${this.TAGS_WITH_NATIVE_ACCESSIBILITY_DATA.map(tag => `:not(${tag})`).join("")}`;
207
+ const nodes = root.querySelectorAll(query);
208
+ const informative = [...nodes].filter(el => this.hasInformativeAttributes(el));
209
+ const children = [...nodes].flatMap(el => Array.from(el.children));
210
+ return [...informative, ...children];
211
+ }
212
+ getAvailableNodes() {
213
+ return [...this.candidatesWithNativeAccessibleData, ...this.candidatesWithCustomAccessibleData];
214
+ }
215
+ getAvailableChildren(node) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ if (node.children.length === 1) {
218
+ return this.getAvailableChildren(node.children[0]);
219
+ }
220
+ return this.findInformativeElements(node);
221
+ });
222
+ }
223
+ hasInformativeAttributes(node) {
224
+ for (const attr of Array.from(node.attributes)) {
225
+ const name = attr.name.toLowerCase();
226
+ const isAccessibilityAttr = name === "role" ||
227
+ name === "alt" ||
228
+ name === "title" ||
229
+ name === "tabindex" ||
230
+ name === "lang" ||
231
+ name === "scope" ||
232
+ name === "for" ||
233
+ name.startsWith("aria-");
234
+ const isTechnicalAttr = name === "data-testid";
235
+ if (isAccessibilityAttr || isTechnicalAttr) {
236
+ return true;
237
+ }
238
+ }
239
+ return false;
240
+ }
241
+ getDialogName(node) {
242
+ var _a, _b, _c;
243
+ const idAccessibleName = node.getAttribute("aria-labelledby");
244
+ if (idAccessibleName) {
245
+ return (_b = (_a = document.getElementById(idAccessibleName)) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : null;
246
+ }
247
+ return (_c = node.getAttribute("aria-label")) !== null && _c !== void 0 ? _c : node.getAttribute("title");
248
+ }
249
+ }
250
+ exports.InformativeNodesHelper = InformativeNodesHelper;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Software Name : UUV
3
+ *
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * This software is distributed under the MIT License,
7
+ * see the "LICENSE" file for more details
8
+ *
9
+ * Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
10
+ * Software description: Make test writing fast, understandable by any human
11
+ * understanding English or French.
12
+ */
13
+ import { FocusableElement } from "tabbable";
14
+ import { AdditionalLayerEnum, ResultSentence } from "../Commons";
15
+ export interface KeyboardNavigation {
16
+ current: FocusableElement[];
17
+ expected: FocusableElement[];
18
+ }
19
+ export declare function switchKeyboardLayer(keyboardLayer: ShadowRoot, layer: AdditionalLayerEnum, elements: FocusableElement[]): void;
20
+ export declare function getKeyboardNavigation(): Promise<KeyboardNavigation>;
21
+ export declare function buildResultSentence(focusableElements: FocusableElement[]): Promise<ResultSentence[]>;
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ /**
3
+ * Software Name : UUV
4
+ *
5
+ * SPDX-License-Identifier: MIT
6
+ *
7
+ * This software is distributed under the MIT License,
8
+ * see the "LICENSE" file for more details
9
+ *
10
+ * Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
11
+ * Software description: Make test writing fast, understandable by any human
12
+ * understanding English or French.
13
+ */
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || (function () {
31
+ var ownKeys = function(o) {
32
+ ownKeys = Object.getOwnPropertyNames || function (o) {
33
+ var ar = [];
34
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
+ return ar;
36
+ };
37
+ return ownKeys(o);
38
+ };
39
+ return function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ })();
47
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
48
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
49
+ return new (P || (P = Promise))(function (resolve, reject) {
50
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
51
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
52
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
53
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
54
+ });
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.switchKeyboardLayer = switchKeyboardLayer;
58
+ exports.getKeyboardNavigation = getKeyboardNavigation;
59
+ exports.buildResultSentence = buildResultSentence;
60
+ const tabbable_1 = require("tabbable");
61
+ const Commons_1 = require("../Commons");
62
+ const LayerHelper = __importStar(require("./layer-helper"));
63
+ const model_1 = require("../translator/model");
64
+ const keyboard_navigation_translator_1 = require("../translator/keyboard-navigation-translator");
65
+ const highlight_helper_1 = require("./highlight/highlight-helper");
66
+ const translator = new keyboard_navigation_translator_1.KeyboardNavigationTranslator();
67
+ function switchKeyboardLayer(keyboardLayer, layer, elements) {
68
+ const htmlElements = elements.map(el => el);
69
+ if (layer === Commons_1.AdditionalLayerEnum.CURRENT_NAVIGATION) {
70
+ LayerHelper.removeLayerToShadowDom(keyboardLayer, Commons_1.AdditionalLayerEnum.EXPECTED_NAVIGATION);
71
+ LayerHelper.addLayerToShadowDom(keyboardLayer, Commons_1.AdditionalLayerEnum.CURRENT_NAVIGATION);
72
+ LayerHelper.buildLayer(keyboardLayer, Commons_1.AdditionalLayerEnum.CURRENT_NAVIGATION, htmlElements, buildAdditionalStyle(htmlElements), false, true);
73
+ }
74
+ else {
75
+ LayerHelper.removeLayerToShadowDom(keyboardLayer, Commons_1.AdditionalLayerEnum.CURRENT_NAVIGATION);
76
+ LayerHelper.addLayerToShadowDom(keyboardLayer, Commons_1.AdditionalLayerEnum.EXPECTED_NAVIGATION);
77
+ LayerHelper.buildLayer(keyboardLayer, Commons_1.AdditionalLayerEnum.EXPECTED_NAVIGATION, htmlElements, buildAdditionalStyle(htmlElements), false, true);
78
+ }
79
+ }
80
+ function getKeyboardNavigation() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const currentKeyboardFocusableElements = (0, tabbable_1.tabbable)(document.body, {});
83
+ return {
84
+ current: currentKeyboardFocusableElements,
85
+ expected: extractExpectedKeyboardNavigation(currentKeyboardFocusableElements)
86
+ };
87
+ });
88
+ }
89
+ function buildResultSentence(focusableElements) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const sentences = [];
92
+ const startKeyboardNavigationSentence = translator.getSentenceFromKey("key.given.keyboard.startNavigationFromTheTop");
93
+ if (startKeyboardNavigationSentence) {
94
+ sentences.push(model_1.StepCaseEnum.AND + startKeyboardNavigationSentence.wording);
95
+ }
96
+ const promises = focusableElements.map((node) => __awaiter(this, void 0, void 0, function* () {
97
+ const focusBySelectorControlSentence = translator.getSentenceFromKey("key.then.element.withSelectorFocused");
98
+ const focusByRoleAndNameControlSentence = translator.getSentenceFromKey("key.then.element.withRoleAndNameFocused");
99
+ if (focusBySelectorControlSentence && focusByRoleAndNameControlSentence) {
100
+ const result = yield translator.translate(node);
101
+ result.sentences.forEach((element) => {
102
+ sentences.push(element);
103
+ });
104
+ }
105
+ else {
106
+ console.error("sentences next focus element or check focused element is undefined");
107
+ }
108
+ return Promise.resolve("");
109
+ }));
110
+ yield Promise.all(promises);
111
+ return sentences.map((elem, key) => {
112
+ return {
113
+ key: key,
114
+ result: elem
115
+ };
116
+ });
117
+ });
118
+ }
119
+ function buildAdditionalStyle(elements) {
120
+ let completeStyle = "";
121
+ if (elements) {
122
+ elements.forEach((element, index) => {
123
+ completeStyle = `${completeStyle}
124
+
125
+ #element-border-${index}:has(~ #order-${index}:hover), #element-border-${index}:has(~ #order-content-${index}:hover) {
126
+ stroke-width: ${highlight_helper_1.HIGHLIGHT_ORANGE_PROPS.width};
127
+ stroke: ${highlight_helper_1.HIGHLIGHT_ORANGE_PROPS.borderColor};
128
+ fill: transparent;
129
+ }
130
+
131
+ .line:has(~ #order-${index}:hover), .navigation-line:has(~ #order-content-${index}:hover) {
132
+ stroke: grey;
133
+ }
134
+ `;
135
+ });
136
+ }
137
+ return completeStyle;
138
+ }
139
+ function extractExpectedKeyboardNavigation(currentKeyboardFocusableElements) {
140
+ return [...currentKeyboardFocusableElements].sort((a, b) => {
141
+ const leftRect = a.getBoundingClientRect();
142
+ const rightRect = b.getBoundingClientRect();
143
+ if (leftRect.y < rightRect.y) {
144
+ return -1;
145
+ }
146
+ if (leftRect.y === rightRect.y && leftRect.x < rightRect.x) {
147
+ return -1;
148
+ }
149
+ return 1;
150
+ });
151
+ }
@@ -0,0 +1,12 @@
1
+ import { AdditionalLayerEnum } from "../Commons";
2
+ export interface Point {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ export declare const ORDER_PROPS: {
7
+ radius: number;
8
+ linkWith: number;
9
+ };
10
+ export declare function buildLayer(layerShadowRoot: ShadowRoot, layer: AdditionalLayerEnum, elements: HTMLElement[], additionalStyle: string, isFullWith: boolean, displayLinkBetweenElements: boolean, displayNavigationOrder?: boolean): void;
11
+ export declare function addLayerToShadowDom(dom: ShadowRoot, layer: AdditionalLayerEnum): void;
12
+ export declare function removeLayerToShadowDom(dom: ShadowRoot, layer: AdditionalLayerEnum): void;
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ORDER_PROPS = void 0;
4
+ exports.buildLayer = buildLayer;
5
+ exports.addLayerToShadowDom = addLayerToShadowDom;
6
+ exports.removeLayerToShadowDom = removeLayerToShadowDom;
7
+ const Commons_1 = require("../Commons");
8
+ const highlight_helper_1 = require("./highlight/highlight-helper");
9
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
10
+ exports.ORDER_PROPS = {
11
+ radius: 12,
12
+ linkWith: 4,
13
+ };
14
+ function buildBasicLayerStyle(isFullWith) {
15
+ const remaningWidth = isFullWith ? 0 : Commons_1.UUV_ASSISTANT_BAR_WIDTH;
16
+ return `
17
+ .uvv-assistant-additional-layer-svg {
18
+ z-index: 2147483527;
19
+ position: absolute;
20
+ top: 0;
21
+ min-width: calc(100vw - ${remaningWidth}px);
22
+ width: ${document.body.getBoundingClientRect().width - remaningWidth}px;
23
+ min-height: 100vh;
24
+ height: ${document.body.getBoundingClientRect().height + 50}px;
25
+ background-color: rgba(128, 128, 128, 0.65);
26
+ }
27
+
28
+ .element-border {
29
+ fill: transparent;
30
+ }
31
+
32
+ .order {
33
+ fill: black;
34
+ cursor: pointer;
35
+ }
36
+
37
+ .order-content {
38
+ fill: white;
39
+ cursor: pointer;
40
+ }
41
+
42
+ .line {
43
+ stroke: black;
44
+ stroke-width: ${exports.ORDER_PROPS.linkWith};
45
+ }
46
+ `;
47
+ }
48
+ function buildCompleteStyle(additionalStyle, isFullWith) {
49
+ return `${buildBasicLayerStyle(isFullWith)}
50
+ ${additionalStyle}
51
+ `;
52
+ }
53
+ function drawHighlight(layerContainer, targetElement, order) {
54
+ const highlightArea = document.createElementNS(SVG_NAMESPACE, "rect");
55
+ highlightArea.setAttribute("class", "element-border");
56
+ highlightArea.setAttribute("id", `element-border-${order}`);
57
+ highlightArea.setAttribute("width", `${targetElement.getBoundingClientRect().width + (highlight_helper_1.HIGHLIGHT_ORANGE_PROPS.width * 2)}`);
58
+ highlightArea.setAttribute("height", `${targetElement.getBoundingClientRect().height + (highlight_helper_1.HIGHLIGHT_ORANGE_PROPS.width * 2)}`);
59
+ highlightArea.setAttribute("x", `${window.scrollX + targetElement.getBoundingClientRect().x - highlight_helper_1.HIGHLIGHT_ORANGE_PROPS.width}`);
60
+ highlightArea.setAttribute("y", `${window.scrollY + targetElement.getBoundingClientRect().y - highlight_helper_1.HIGHLIGHT_ORANGE_PROPS.width}`);
61
+ layerContainer.append(highlightArea);
62
+ }
63
+ function drawNavigationOrder(layerContainer, targetElement, order) {
64
+ const x = window.scrollX +
65
+ targetElement.getBoundingClientRect().x +
66
+ targetElement.getBoundingClientRect().width;
67
+ const y = window.scrollY + targetElement.getBoundingClientRect().y;
68
+ const orderIndicatorContainer = document.createElementNS(SVG_NAMESPACE, "circle");
69
+ orderIndicatorContainer.setAttribute("class", "order");
70
+ orderIndicatorContainer.setAttribute("id", `order-${order}`);
71
+ orderIndicatorContainer.setAttribute("r", `${exports.ORDER_PROPS.radius}`);
72
+ orderIndicatorContainer.setAttribute("cx", `${x}`);
73
+ orderIndicatorContainer.setAttribute("cy", `${y}`);
74
+ const orderIndicatorContent = document.createElementNS(SVG_NAMESPACE, "text");
75
+ orderIndicatorContent.innerHTML = `${order + 1}`;
76
+ orderIndicatorContent.setAttribute("class", "order-content");
77
+ orderIndicatorContent.setAttribute("id", `order-content-${order}`);
78
+ orderIndicatorContent.setAttribute("text-anchor", "middle");
79
+ orderIndicatorContent.setAttribute("alignment-baseline", "central");
80
+ orderIndicatorContent.setAttribute("x", `${x}`);
81
+ orderIndicatorContent.setAttribute("y", `${y}`);
82
+ layerContainer.append(orderIndicatorContainer);
83
+ layerContainer.append(orderIndicatorContent);
84
+ }
85
+ function drawLinkBetweenElement(layerContainer, startPoint, endPoint) {
86
+ const linkBetweenNode = document.createElementNS(SVG_NAMESPACE, "line");
87
+ linkBetweenNode.setAttribute("class", "line");
88
+ linkBetweenNode.setAttribute("x1", `${startPoint.x}`);
89
+ linkBetweenNode.setAttribute("y1", `${startPoint.y}`);
90
+ linkBetweenNode.setAttribute("x2", `${endPoint.x}`);
91
+ linkBetweenNode.setAttribute("y2", `${endPoint.y}`);
92
+ layerContainer.append(linkBetweenNode);
93
+ }
94
+ function getMiddlePoint(previousElement) {
95
+ return {
96
+ x: window.scrollX +
97
+ previousElement.getBoundingClientRect().x +
98
+ previousElement.getBoundingClientRect().width,
99
+ y: window.scrollY + previousElement.getBoundingClientRect().y,
100
+ };
101
+ }
102
+ function initSvgElement(layerShadowRoot, layer, additionalStyle, isFullWith) {
103
+ const completeStyle = buildCompleteStyle(additionalStyle, isFullWith);
104
+ const layerShadowRootElement = layerShadowRoot.querySelector(`#${layer.toString()}`);
105
+ if (layerShadowRootElement) {
106
+ layerShadowRootElement.innerHTML = `
107
+ <style>
108
+ ${completeStyle}
109
+ </style>
110
+ <svg xmlns="http://www.w3.org/2000/svg" id="${layer.toString()}-svg" class="uvv-assistant-additional-layer-svg">
111
+ </svg>
112
+ `;
113
+ }
114
+ }
115
+ function buildLayer(layerShadowRoot, layer, elements, additionalStyle, isFullWith, displayLinkBetweenElements, displayNavigationOrder = true) {
116
+ initSvgElement(layerShadowRoot, layer, additionalStyle, isFullWith);
117
+ const layerContainer = layerShadowRoot.querySelector(`#${layer.toString()}-svg`);
118
+ if (layerContainer) {
119
+ if (displayLinkBetweenElements) {
120
+ elements.forEach((currentElement, index, allElements) => {
121
+ if (index > 0) {
122
+ const startPoint = getMiddlePoint(allElements[index - 1]);
123
+ const endPoint = getMiddlePoint(currentElement);
124
+ drawLinkBetweenElement(layerContainer, startPoint, endPoint);
125
+ }
126
+ });
127
+ }
128
+ elements.forEach((currentElement, index) => {
129
+ drawHighlight(layerContainer, currentElement, index);
130
+ if (displayNavigationOrder) {
131
+ drawNavigationOrder(layerContainer, currentElement, index);
132
+ }
133
+ });
134
+ }
135
+ }
136
+ function addLayerToShadowDom(dom, layer) {
137
+ const newLayer = document.createElement("div");
138
+ newLayer.setAttribute("id", layer.toString());
139
+ newLayer.setAttribute("class", "uvv-assistant-additional-layer");
140
+ if (!dom.getElementById(layer.toString())) {
141
+ dom.appendChild(newLayer);
142
+ }
143
+ }
144
+ function removeLayerToShadowDom(dom, layer) {
145
+ const layerToRemove = dom.getElementById(layer.toString());
146
+ if (layerToRemove) {
147
+ dom.removeChild(layerToRemove);
148
+ }
149
+ }
@@ -0,0 +1,2 @@
1
+ import { Extension } from "@uiw/react-codemirror";
2
+ export declare function buildUuvGutter(): Extension;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildUuvGutter = buildUuvGutter;
4
+ const react_codemirror_1 = require("@uiw/react-codemirror");
5
+ const uuvA11yWarningMarker = new class extends react_codemirror_1.GutterMarker {
6
+ toDOM() {
7
+ const marker = document.createElement("div");
8
+ marker.innerHTML = "<div class='uuv-gutter-warning'>⚠️</div>";
9
+ marker.setAttribute("title", "Accessibility role and name must be defined");
10
+ return marker;
11
+ }
12
+ }();
13
+ function buildUuvGutter() {
14
+ return (0, react_codemirror_1.gutter)({
15
+ lineMarker(view, line) {
16
+ const value = view.state.doc.lineAt(line.from).text;
17
+ return value.includes("selector") ? uuvA11yWarningMarker : null;
18
+ }
19
+ });
20
+ }
@@ -0,0 +1 @@
1
+ export declare function buildResultingScript(featureName: string, scenarioName: string, generatedScriptStep: string[], baseUrl: string): string;