aloha-vue 2.80.1 → 2.82.0

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 (41) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/aloha-vue.css +7 -0
  3. package/dist/aloha-vue.css.map +1 -1
  4. package/dist/aloha-vue.es.js +361 -24
  5. package/dist/aloha-vue.umd.js +17 -17
  6. package/package.json +1 -1
  7. package/scss/components/AMenu.scss +634 -627
  8. package/src/AMenu/AMenu.js +592 -581
  9. package/src/AMenu/__tests__/AMenu.test.js +54 -0
  10. package/src/AMenu/compositionAPI/SearchAPI.js +45 -2
  11. package/src/AMenu/compositionAPI/__tests__/SearchAPI.test.js +108 -0
  12. package/src/ui/ACheckbox/ACheckbox.js +6 -0
  13. package/src/ui/ACheckbox/ACheckboxItem/ACheckboxItem.js +6 -0
  14. package/src/ui/ADatepicker/ADatepicker.js +6 -0
  15. package/src/ui/ADatepickerRange/ADatepickerRange.js +6 -1
  16. package/src/ui/AFieldset/AFieldset.js +7 -1
  17. package/src/ui/AForm/AForm.js +6 -0
  18. package/src/ui/AFormElement/AFormElement.js +5 -0
  19. package/src/ui/AFormReadonly/AFormReadonly.js +1 -1
  20. package/src/ui/AGroup/AGroup.js +8 -1
  21. package/src/ui/AInput/AInput.js +6 -0
  22. package/src/ui/AInputCurrency/AInputCurrency.js +6 -0
  23. package/src/ui/AInputFile/AInputFile.js +40 -5
  24. package/src/ui/AInputNumber/AInputNumber.js +6 -0
  25. package/src/ui/AInputNumberRange/AInputNumberRange.js +6 -1
  26. package/src/ui/AJson/AJson.js +6 -0
  27. package/src/ui/AMultiselectOrdered/AMultiselectOrdered.js +30 -24
  28. package/src/ui/AOneCheckbox/AOneCheckbox.js +6 -0
  29. package/src/ui/ARadio/ARadio.js +6 -0
  30. package/src/ui/ARadio/ARadioItem/ARadioItem.js +6 -0
  31. package/src/ui/ARouterLinkConfig/ARouterLinkConfig.js +7 -0
  32. package/src/ui/ASelect/ASelect.js +6 -0
  33. package/src/ui/ASelectIcon/ASelectIcon.js +16 -11
  34. package/src/ui/ASelectStyle/ASelectStyle.js +16 -11
  35. package/src/ui/ASlider/ASlider.js +6 -0
  36. package/src/ui/ASwitch/ASwitch.js +11 -5
  37. package/src/ui/ATemplate/ATemplate.js +7 -2
  38. package/src/ui/ATextarea/ATextarea.js +6 -0
  39. package/src/ui/AValidatedJson/AValidatedJson.js +10 -2
  40. package/src/ui/AValidatedJson/AValidatedJsonItem/AValidatedJsonItem.js +6 -0
  41. package/src/ui/__tests__/ReadonlyValueParentClass.test.js +217 -0
@@ -1,581 +1,592 @@
1
- import {
2
- computed,
3
- h,
4
- onBeforeUnmount,
5
- onMounted,
6
- provide,
7
- ref,
8
- Teleport,
9
- toRef,
10
- watch,
11
- } from "vue";
12
-
13
- import AButton from "../AButton/AButton";
14
- import AInput from "../ui/AInput/AInput";
15
- import AMenuButtonToggle from "./AMenuButtonToggle/AMenuButtonToggle";
16
- import AMenuPanel from "./AMenuPanel/AMenuPanel";
17
- import AMenuSearchPanel from "./AMenuSearchPanel/AMenuSearchPanel";
18
- import ATranslation from "../ATranslation/ATranslation";
19
- import AVerticalScroll from "../AVerticalScroll/AVerticalScroll";
20
-
21
- import AMenuBlockerClickAPI from "./compositionAPI/AMenuBlockerClickAPI";
22
- import BackdropAPI from "./compositionAPI/BackdropAPI";
23
- import CheckRoutesAPI from "./compositionAPI/CheckRoutesAPI";
24
- import DataAPI from "./compositionAPI/DataAPI";
25
- import KeydownAPI from "./compositionAPI/KeydownAPI";
26
- import LinkClickAPI from "./compositionAPI/LinkClickAPI";
27
- import MenuAttributesAPI from "./compositionAPI/MenuAttributesAPI";
28
- import PanelMainAPI from "./compositionAPI/PanelMainAPI";
29
- import PanelsAPI from "./compositionAPI/PanelsAPI";
30
- import PopoverAPI from "./compositionAPI/PopoverAPI";
31
- import ResizeAPI from "./compositionAPI/ResizeAPI";
32
- import SearchAPI from "./compositionAPI/SearchAPI";
33
- import SearchBtnAPI from "./compositionAPI/SearchBtnAPI";
34
- import ToggleAPI from "./AMenuButtonToggle/compositionAPI/ToggleAPI";
35
-
36
- import {
37
- uniqueId,
38
- } from "lodash-es";
39
-
40
- const Search = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
41
- <path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"/>
42
- </svg>`;
43
-
44
- const DROPDOWN_BUTTON_WIDTH = 34;
45
- const BREADCRUMBS_PADDINGS = 20;
46
-
47
- export default {
48
- name: "AMenu",
49
- provide() {
50
- return {
51
- keySlot: computed(() => this.keySlot),
52
- };
53
- },
54
- props: {
55
- breadcrumbsLinkClass: {
56
- type: [String, Object],
57
- required: false,
58
- default: "a_btn a_btn_link",
59
- },
60
- breadcrumbsTruncatedDropdownProps: {
61
- type: Object,
62
- required: false,
63
- default: () => ({}),
64
- },
65
- breadcrumbsTruncatedOffset: {
66
- type: Number,
67
- required: false,
68
- default: () => DROPDOWN_BUTTON_WIDTH + BREADCRUMBS_PADDINGS,
69
- },
70
- buttonToggleClass: {
71
- type: [String, Object],
72
- required: false,
73
- default: "a_btn a_btn_transparent_secondary a_btn_small",
74
- },
75
- buttonToggleProps: {
76
- type: Object,
77
- required: false,
78
- default: () => ({}),
79
- },
80
- canChangeBodyClass: {
81
- type: Boolean,
82
- required: false,
83
- default: true,
84
- },
85
- compareUrlCallback: {
86
- type: Function,
87
- required: false,
88
- default: undefined,
89
- },
90
- data: {
91
- type: Array,
92
- required: false,
93
- default: () => [],
94
- },
95
- hasSearch: {
96
- type: Boolean,
97
- required: false,
98
- default: true,
99
- },
100
- isBackdropMobileClickable: {
101
- type: Boolean,
102
- required: false,
103
- default: true,
104
- },
105
- isBlockerClickable: {
106
- type: Boolean,
107
- required: false,
108
- },
109
- isBodyFocusAfterClick: {
110
- type: Boolean,
111
- required: false,
112
- default: true,
113
- },
114
- isBreadcrumbsTruncated: {
115
- type: Boolean,
116
- required: false,
117
- default: false,
118
- },
119
- isLinkTruncated: {
120
- type: Boolean,
121
- required: false,
122
- default: true,
123
- },
124
- isMenuOpenInitial: {
125
- type: Boolean,
126
- required: false,
127
- default: true,
128
- },
129
- isSearchBreadcrumbsTruncated: {
130
- type: Boolean,
131
- required: false,
132
- default: true,
133
- },
134
- isTranslated: {
135
- type: Boolean,
136
- required: false,
137
- },
138
- keyChildren: {
139
- type: String,
140
- required: false,
141
- default: undefined,
142
- },
143
- keyGroup: {
144
- type: String,
145
- required: false,
146
- default: "group",
147
- },
148
- keyIcon: {
149
- type: String,
150
- required: false,
151
- default: "icon",
152
- },
153
- keyId: {
154
- type: String,
155
- required: false,
156
- default: "id",
157
- },
158
- keyLabel: {
159
- type: String,
160
- required: false,
161
- default: "label",
162
- },
163
- keyLabelCallback: {
164
- type: Function,
165
- required: false,
166
- default: undefined,
167
- },
168
- keyParent: {
169
- type: String,
170
- required: false,
171
- default: "parent",
172
- },
173
- keySlot: {
174
- type: String,
175
- required: false,
176
- default: undefined,
177
- },
178
- menuId: {
179
- type: String,
180
- required: false,
181
- default: () => uniqueId("a_menu_"),
182
- },
183
- onlyMobile: {
184
- type: Boolean,
185
- required: false,
186
- default: false,
187
- },
188
- selectorClose: {
189
- type: [String, Array],
190
- required: false,
191
- default: undefined,
192
- },
193
- selectorCloseIds: {
194
- type: [String, Array],
195
- required: false,
196
- default: undefined,
197
- },
198
- showCountChildren: {
199
- type: Boolean,
200
- required: false,
201
- default: true,
202
- },
203
- useBackdropMobile: {
204
- type: Boolean,
205
- required: false,
206
- default: true,
207
- },
208
- useEscapeForMobile: {
209
- type: Boolean,
210
- required: false,
211
- default: true,
212
- },
213
- },
214
- setup(props) {
215
- const isLinkTruncated = toRef(props, "isLinkTruncated");
216
- const showCountChildren = toRef(props, "showCountChildren");
217
- const breadcrumbsTruncatedOffset = toRef(props, "breadcrumbsTruncatedOffset");
218
-
219
- const isMounted = ref(false);
220
-
221
- const {
222
- dataKeyById,
223
- dataProParent,
224
- } = DataAPI(props);
225
-
226
- const {
227
- isSearchActive,
228
- itemsWithSearch,
229
- modelSearch,
230
- resetSearch,
231
- searchInputId,
232
- styleSearchPanelMain,
233
- updateModelSearch,
234
- } = SearchAPI(props, {
235
- dataKeyById,
236
- });
237
-
238
- const {
239
- closeAllPanels,
240
- isSubMenuOpen,
241
- panelParentsOpen,
242
- setDefaultMenu,
243
- togglePanel,
244
- } = PanelsAPI(props, {
245
- dataKeyById,
246
- resetSearch,
247
- });
248
-
249
- const {
250
- closeMenu,
251
- isMenuOpen,
252
- removeBodyClasses,
253
- toggleMenu,
254
- } = ToggleAPI(props);
255
-
256
- const {
257
- isDesktopSubMenuVisibleWhenMenuClosed,
258
- menuRef,
259
- removeListenerForKeydownDesktop,
260
- removeListenerForKeydownMobile,
261
- setListenerForKeydownDesktop,
262
- setListenerForKeydownMobile,
263
- } = KeydownAPI(props, {
264
- closeMenu,
265
- isMenuOpen,
266
- isSubMenuOpen,
267
- panelParentsOpen,
268
- togglePanel,
269
- });
270
-
271
- const {
272
- clickOnSearchBtn,
273
- keydownOnSearchBtn,
274
- } = SearchBtnAPI({
275
- searchInputId,
276
- toggleMenu,
277
- });
278
-
279
- const {
280
- attributesMenuClick,
281
- attributesMobile,
282
- headerId,
283
- } = MenuAttributesAPI(props, {
284
- isMenuOpen,
285
- toggleMenu,
286
- });
287
-
288
- const {
289
- destroyEventBusUpdateViewOnResize,
290
- initEventBusUpdateViewOnResize,
291
- initMenuOpenOrClose,
292
- isMenuInitialized,
293
- isMobileWidth,
294
- } = ResizeAPI(props, {
295
- removeListenerForKeydownMobile,
296
- toggleMenu,
297
- });
298
-
299
- const {
300
- clickMenuLink,
301
- isMenuLinkClicked,
302
- } = LinkClickAPI(props, {
303
- closeAllPanels,
304
- isMenuOpen,
305
- isMobileWidth,
306
- resetSearch,
307
- toggleMenu,
308
- });
309
-
310
- const {
311
- attributesBlockerClick,
312
- } = AMenuBlockerClickAPI(props, {
313
- closeAllPanels,
314
- });
315
-
316
- const {
317
- activeRoutesIds,
318
- checkAllRoutes,
319
- currentRoute,
320
- } = CheckRoutesAPI(props, {
321
- dataKeyById,
322
- dataProParent,
323
- isMenuLinkClicked,
324
- isMenuOpen,
325
- panelParentsOpen,
326
- });
327
-
328
- const {
329
- destroyPopover,
330
- startPopper,
331
- } = PopoverAPI(props, {
332
- menuRef,
333
- isMenuOpen,
334
- panelParentsOpen,
335
- });
336
-
337
- const {
338
- isLeastOnePanelOpenAndMenuClosed,
339
- } = PanelMainAPI({
340
- isMenuOpen,
341
- panelParentsOpen,
342
- });
343
-
344
- const {
345
- clickAttributesBackdrop,
346
- isBackdropVisible,
347
- } = BackdropAPI(props, {
348
- isMenuOpen,
349
- isMobileWidth,
350
- toggleMenu,
351
- });
352
-
353
- watch(currentRoute, () => {
354
- checkAllRoutes();
355
- }, {
356
- immediate: true,
357
- deep: true,
358
- });
359
-
360
- watch(isMenuOpen, newValue => {
361
- if (!isMenuInitialized.value) {
362
- return;
363
- }
364
- resetSearch();
365
- closeAllPanels();
366
- if (newValue) {
367
- destroyPopover();
368
- setListenerForKeydownMobile();
369
- } else {
370
- removeListenerForKeydownMobile();
371
- }
372
- });
373
-
374
- watch(panelParentsOpen, () => {
375
- startPopper();
376
- }, {
377
- deep: true,
378
- });
379
-
380
- watch(isDesktopSubMenuVisibleWhenMenuClosed, newValue => {
381
- if (newValue) {
382
- setListenerForKeydownDesktop();
383
- } else {
384
- removeListenerForKeydownDesktop();
385
- }
386
- });
387
-
388
- provide("activeRoutesIds", computed(() => activeRoutesIds.value));
389
- provide("clickMenuLink", clickMenuLink);
390
- provide("isLinkTruncated", computed(() => isLinkTruncated.value));
391
- provide("isMenuOpen", computed(() => isMenuOpen.value));
392
- provide("panelParentsOpen", panelParentsOpen);
393
- provide("showCountChildren", computed(() => showCountChildren.value));
394
- provide("togglePanel", togglePanel);
395
- provide("breadcrumbsTruncatedOffset", computed(() => breadcrumbsTruncatedOffset.value));
396
-
397
- onMounted(() => {
398
- isMounted.value = true;
399
- initMenuOpenOrClose();
400
- initEventBusUpdateViewOnResize();
401
- });
402
-
403
- onBeforeUnmount(() => {
404
- removeBodyClasses();
405
- destroyEventBusUpdateViewOnResize();
406
- destroyPopover();
407
- removeListenerForKeydownDesktop();
408
- removeListenerForKeydownMobile();
409
- });
410
-
411
- return {
412
- activeRoutesIds,
413
- attributesBlockerClick,
414
- attributesMenuClick,
415
- attributesMobile,
416
- checkAllRoutes,
417
- clickAttributesBackdrop,
418
- clickOnSearchBtn,
419
- dataKeyById,
420
- dataProParent,
421
- headerId,
422
- isBackdropVisible,
423
- isLeastOnePanelOpenAndMenuClosed,
424
- isMenuOpen,
425
- isMobileWidth,
426
- isMounted,
427
- isSearchActive,
428
- isSubMenuOpen,
429
- itemsWithSearch,
430
- keydownOnSearchBtn,
431
- menuRef,
432
- modelSearch,
433
- panelParentsOpen,
434
- removeBodyClasses,
435
- searchInputId,
436
- setDefaultMenu,
437
- styleSearchPanelMain,
438
- toggleMenu,
439
- togglePanel,
440
- updateModelSearch,
441
- };
442
- },
443
- render() {
444
- if (!this.isMounted) {
445
- return null;
446
- }
447
-
448
- return h("nav", {
449
- ref: "menuRef",
450
- id: this.menuId,
451
- "aria-labelledby": this.headerId,
452
- class: [
453
- "a_menu",
454
- {
455
- a_menu_sub_open: this.isSubMenuOpen,
456
- a_menu_open: this.isMenuOpen,
457
- a_menu_close: !this.isMenuOpen,
458
- a_menu_only_mobile: this.onlyMobile,
459
- a_menu_mobile: this.isMobileWidth || this.onlyMobile,
460
- },
461
- ],
462
- ...this.attributesMobile,
463
- ...this.attributesMenuClick,
464
- }, [
465
- h("div", {
466
- class: "a_menu__navbar_top",
467
- }, [
468
- h(AMenuButtonToggle, {
469
- buttonToggleProps: this.buttonToggleProps,
470
- canChangeBodyClass: this.canChangeBodyClass,
471
- class: this.buttonToggleClass,
472
- insideMenu: true,
473
- menuId: this.menuId,
474
- selectorClose: this.selectorClose,
475
- selectorCloseIds: this.selectorCloseIds,
476
- }),
477
- this.$slots.menuSearch && this.$slots.menuSearch(),
478
- this.hasSearch && h(AInput, {
479
- id: this.searchInputId,
480
- class: "a_menu__navbar_top__search",
481
- modelValue: this.modelSearch,
482
- label: "_A_MENU_2_SEARCH_",
483
- "onUpdate:modelValue": this.updateModelSearch,
484
- }),
485
- ]),
486
- h("div", {
487
- class: "a_menu__panels__main",
488
- style: this.styleSearchPanelMain,
489
- }, [
490
- h("div", {
491
- class: "a_menu__navbar_top_sub",
492
- }, [
493
- h(ATranslation, {
494
- id: this.headerId,
495
- class: "a_menu__navbar_top_sub__text",
496
- tag: "strong",
497
- text: "_A_MENU_2_MAIN_MENU_",
498
- }),
499
- this.hasSearch && h(AButton, {
500
- role: "button",
501
- tabindex: 0,
502
- tag: "a",
503
- class: "a_menu__navbar_top_sub__search a_menu__link a_menu__link_btn",
504
- iconLeft: Search,
505
- iconClass: "a_menu__link__icon",
506
- title: "_A_MENU_2_OPEN_SEARCH_",
507
- textScreenReader: "_A_MENU_2_OPEN_SEARCH_",
508
- onClick: this.clickOnSearchBtn,
509
- onKeydown: this.keydownOnSearchBtn,
510
- }),
511
- ]),
512
- h(AVerticalScroll, {
513
- class: {
514
- a_menu__vertical_scroll_hidden: this.isLeastOnePanelOpenAndMenuClosed,
515
- },
516
- disabled: this.isMenuOpen || this.isLeastOnePanelOpenAndMenuClosed,
517
- }, () => [
518
- h(AMenuPanel, {
519
- attributesBlockerClick: this.attributesBlockerClick,
520
- dataKeyById: this.dataKeyById,
521
- dataProParentChildren: this.dataProParent.children,
522
- isBreadcrumbsTruncated: this.isBreadcrumbsTruncated,
523
- isPanelMain: true,
524
- isSearchActive: this.isSearchActive,
525
- keyGroup: this.keyGroup,
526
- keyIcon: this.keyIcon,
527
- menuId: this.menuId,
528
- paneIndex: "00",
529
- panelItems: this.dataProParent.main,
530
- panelParentsOpen: this.panelParentsOpen,
531
- }, this.$slots),
532
- ]),
533
- h("div", {
534
- class: "a_menu__panels",
535
- }, [
536
- Object.keys(this.dataProParent.children).map((key, paneIndex) => {
537
- return h(AMenuPanel, {
538
- key,
539
- attributesBlockerClick: {},
540
- breadcrumbsLinkClass: this.breadcrumbsLinkClass,
541
- breadcrumbsTruncatedDropdownProps: this.breadcrumbsTruncatedDropdownProps,
542
- dataKeyById: this.dataKeyById,
543
- dataProParentChildren: this.dataProParent.children,
544
- isBreadcrumbsTruncated: this.isBreadcrumbsTruncated,
545
- isSearchActive: this.isSearchActive,
546
- keyGroup: this.keyGroup,
547
- keyIcon: this.keyIcon,
548
- menuId: this.menuId,
549
- paneIndex,
550
- panelItems: this.dataProParent.children[key],
551
- panelParentsOpen: this.panelParentsOpen,
552
- parentId: key,
553
- }, this.$slots);
554
- }),
555
- ]),
556
- ]),
557
- h(AMenuSearchPanel, {
558
- breadcrumbsLinkClass: this.breadcrumbsLinkClass,
559
- breadcrumbsTruncatedDropdownProps: this.breadcrumbsTruncatedDropdownProps,
560
- dataProParentChildren: this.dataProParent.children,
561
- isSearchActive: this.isSearchActive,
562
- isSearchBreadcrumbsTruncated: this.isSearchBreadcrumbsTruncated,
563
- itemsWithSearch: this.itemsWithSearch,
564
- menuId: this.menuId,
565
- modelSearch: this.modelSearch,
566
- }, this.$slots),
567
-
568
- this.isBackdropVisible
569
- ? h(Teleport, {
570
- to: "body",
571
- }, [
572
- h("div", {
573
- class: "a_menu__backdrop a_backdrop a_backdrop_fade",
574
- "aria-hidden": true,
575
- ...this.clickAttributesBackdrop,
576
- }),
577
- ])
578
- : "",
579
- ]);
580
- },
581
- };
1
+ import {
2
+ computed,
3
+ h,
4
+ onBeforeUnmount,
5
+ onMounted,
6
+ provide,
7
+ ref,
8
+ Teleport,
9
+ toRef,
10
+ watch,
11
+ } from "vue";
12
+
13
+ import AButton from "../AButton/AButton";
14
+ import AInput from "../ui/AInput/AInput";
15
+ import AMenuButtonToggle from "./AMenuButtonToggle/AMenuButtonToggle";
16
+ import AMenuPanel from "./AMenuPanel/AMenuPanel";
17
+ import AMenuSearchPanel from "./AMenuSearchPanel/AMenuSearchPanel";
18
+ import ATranslation from "../ATranslation/ATranslation";
19
+ import AVerticalScroll from "../AVerticalScroll/AVerticalScroll";
20
+
21
+ import AMenuBlockerClickAPI from "./compositionAPI/AMenuBlockerClickAPI";
22
+ import BackdropAPI from "./compositionAPI/BackdropAPI";
23
+ import CheckRoutesAPI from "./compositionAPI/CheckRoutesAPI";
24
+ import DataAPI from "./compositionAPI/DataAPI";
25
+ import KeydownAPI from "./compositionAPI/KeydownAPI";
26
+ import LinkClickAPI from "./compositionAPI/LinkClickAPI";
27
+ import MenuAttributesAPI from "./compositionAPI/MenuAttributesAPI";
28
+ import PanelMainAPI from "./compositionAPI/PanelMainAPI";
29
+ import PanelsAPI from "./compositionAPI/PanelsAPI";
30
+ import PopoverAPI from "./compositionAPI/PopoverAPI";
31
+ import ResizeAPI from "./compositionAPI/ResizeAPI";
32
+ import SearchAPI from "./compositionAPI/SearchAPI";
33
+ import SearchBtnAPI from "./compositionAPI/SearchBtnAPI";
34
+ import ToggleAPI from "./AMenuButtonToggle/compositionAPI/ToggleAPI";
35
+
36
+ import {
37
+ uniqueId,
38
+ } from "lodash-es";
39
+
40
+ const Search = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
41
+ <path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"/>
42
+ </svg>`;
43
+
44
+ const DROPDOWN_BUTTON_WIDTH = 34;
45
+ const BREADCRUMBS_PADDINGS = 20;
46
+
47
+ export default {
48
+ name: "AMenu",
49
+ provide() {
50
+ return {
51
+ keySlot: computed(() => this.keySlot),
52
+ };
53
+ },
54
+ props: {
55
+ breadcrumbsLinkClass: {
56
+ type: [String, Object],
57
+ required: false,
58
+ default: "a_btn a_btn_link",
59
+ },
60
+ breadcrumbsTruncatedDropdownProps: {
61
+ type: Object,
62
+ required: false,
63
+ default: () => ({}),
64
+ },
65
+ breadcrumbsTruncatedOffset: {
66
+ type: Number,
67
+ required: false,
68
+ default: () => DROPDOWN_BUTTON_WIDTH + BREADCRUMBS_PADDINGS,
69
+ },
70
+ buttonToggleClass: {
71
+ type: [String, Object],
72
+ required: false,
73
+ default: "a_btn a_btn_transparent_secondary a_btn_small",
74
+ },
75
+ buttonToggleProps: {
76
+ type: Object,
77
+ required: false,
78
+ default: () => ({}),
79
+ },
80
+ canChangeBodyClass: {
81
+ type: Boolean,
82
+ required: false,
83
+ default: true,
84
+ },
85
+ compareUrlCallback: {
86
+ type: Function,
87
+ required: false,
88
+ default: undefined,
89
+ },
90
+ data: {
91
+ type: Array,
92
+ required: false,
93
+ default: () => [],
94
+ },
95
+ hasSearch: {
96
+ type: Boolean,
97
+ required: false,
98
+ default: true,
99
+ },
100
+ isBackdropMobileClickable: {
101
+ type: Boolean,
102
+ required: false,
103
+ default: true,
104
+ },
105
+ isBlockerClickable: {
106
+ type: Boolean,
107
+ required: false,
108
+ },
109
+ isBodyFocusAfterClick: {
110
+ type: Boolean,
111
+ required: false,
112
+ default: true,
113
+ },
114
+ isBreadcrumbsTruncated: {
115
+ type: Boolean,
116
+ required: false,
117
+ default: false,
118
+ },
119
+ isInline: {
120
+ type: Boolean,
121
+ required: false,
122
+ default: false,
123
+ },
124
+ isLinkTruncated: {
125
+ type: Boolean,
126
+ required: false,
127
+ default: true,
128
+ },
129
+ isMenuOpenInitial: {
130
+ type: Boolean,
131
+ required: false,
132
+ default: true,
133
+ },
134
+ isSearchBreadcrumbsTruncated: {
135
+ type: Boolean,
136
+ required: false,
137
+ default: true,
138
+ },
139
+ isTranslated: {
140
+ type: Boolean,
141
+ required: false,
142
+ },
143
+ keyChildren: {
144
+ type: String,
145
+ required: false,
146
+ default: undefined,
147
+ },
148
+ keyGroup: {
149
+ type: String,
150
+ required: false,
151
+ default: "group",
152
+ },
153
+ keyIcon: {
154
+ type: String,
155
+ required: false,
156
+ default: "icon",
157
+ },
158
+ keyId: {
159
+ type: String,
160
+ required: false,
161
+ default: "id",
162
+ },
163
+ keyLabel: {
164
+ type: String,
165
+ required: false,
166
+ default: "label",
167
+ },
168
+ keyLabelCallback: {
169
+ type: Function,
170
+ required: false,
171
+ default: undefined,
172
+ },
173
+ keyParent: {
174
+ type: String,
175
+ required: false,
176
+ default: "parent",
177
+ },
178
+ keySlot: {
179
+ type: String,
180
+ required: false,
181
+ default: undefined,
182
+ },
183
+ menuId: {
184
+ type: String,
185
+ required: false,
186
+ default: () => uniqueId("a_menu_"),
187
+ },
188
+ onlyMobile: {
189
+ type: Boolean,
190
+ required: false,
191
+ default: false,
192
+ },
193
+ searchInDom: {
194
+ type: Boolean,
195
+ required: false,
196
+ default: false,
197
+ },
198
+ selectorClose: {
199
+ type: [String, Array],
200
+ required: false,
201
+ default: undefined,
202
+ },
203
+ selectorCloseIds: {
204
+ type: [String, Array],
205
+ required: false,
206
+ default: undefined,
207
+ },
208
+ showCountChildren: {
209
+ type: Boolean,
210
+ required: false,
211
+ default: true,
212
+ },
213
+ useBackdropMobile: {
214
+ type: Boolean,
215
+ required: false,
216
+ default: true,
217
+ },
218
+ useEscapeForMobile: {
219
+ type: Boolean,
220
+ required: false,
221
+ default: true,
222
+ },
223
+ },
224
+ setup(props) {
225
+ const isLinkTruncated = toRef(props, "isLinkTruncated");
226
+ const showCountChildren = toRef(props, "showCountChildren");
227
+ const breadcrumbsTruncatedOffset = toRef(props, "breadcrumbsTruncatedOffset");
228
+
229
+ const isMounted = ref(false);
230
+
231
+ const {
232
+ dataKeyById,
233
+ dataProParent,
234
+ } = DataAPI(props);
235
+
236
+ const {
237
+ isSearchActive,
238
+ itemsWithSearch,
239
+ modelSearch,
240
+ resetSearch,
241
+ searchInputId,
242
+ styleSearchPanelMain,
243
+ updateModelSearch,
244
+ } = SearchAPI(props, {
245
+ dataKeyById,
246
+ });
247
+
248
+ const {
249
+ closeAllPanels,
250
+ isSubMenuOpen,
251
+ panelParentsOpen,
252
+ setDefaultMenu,
253
+ togglePanel,
254
+ } = PanelsAPI(props, {
255
+ dataKeyById,
256
+ resetSearch,
257
+ });
258
+
259
+ const {
260
+ closeMenu,
261
+ isMenuOpen,
262
+ removeBodyClasses,
263
+ toggleMenu,
264
+ } = ToggleAPI(props);
265
+
266
+ const {
267
+ isDesktopSubMenuVisibleWhenMenuClosed,
268
+ menuRef,
269
+ removeListenerForKeydownDesktop,
270
+ removeListenerForKeydownMobile,
271
+ setListenerForKeydownDesktop,
272
+ setListenerForKeydownMobile,
273
+ } = KeydownAPI(props, {
274
+ closeMenu,
275
+ isMenuOpen,
276
+ isSubMenuOpen,
277
+ panelParentsOpen,
278
+ togglePanel,
279
+ });
280
+
281
+ const {
282
+ clickOnSearchBtn,
283
+ keydownOnSearchBtn,
284
+ } = SearchBtnAPI({
285
+ searchInputId,
286
+ toggleMenu,
287
+ });
288
+
289
+ const {
290
+ attributesMenuClick,
291
+ attributesMobile,
292
+ headerId,
293
+ } = MenuAttributesAPI(props, {
294
+ isMenuOpen,
295
+ toggleMenu,
296
+ });
297
+
298
+ const {
299
+ destroyEventBusUpdateViewOnResize,
300
+ initEventBusUpdateViewOnResize,
301
+ initMenuOpenOrClose,
302
+ isMenuInitialized,
303
+ isMobileWidth,
304
+ } = ResizeAPI(props, {
305
+ removeListenerForKeydownMobile,
306
+ toggleMenu,
307
+ });
308
+
309
+ const {
310
+ clickMenuLink,
311
+ isMenuLinkClicked,
312
+ } = LinkClickAPI(props, {
313
+ closeAllPanels,
314
+ isMenuOpen,
315
+ isMobileWidth,
316
+ resetSearch,
317
+ toggleMenu,
318
+ });
319
+
320
+ const {
321
+ attributesBlockerClick,
322
+ } = AMenuBlockerClickAPI(props, {
323
+ closeAllPanels,
324
+ });
325
+
326
+ const {
327
+ activeRoutesIds,
328
+ checkAllRoutes,
329
+ currentRoute,
330
+ } = CheckRoutesAPI(props, {
331
+ dataKeyById,
332
+ dataProParent,
333
+ isMenuLinkClicked,
334
+ isMenuOpen,
335
+ panelParentsOpen,
336
+ });
337
+
338
+ const {
339
+ destroyPopover,
340
+ startPopper,
341
+ } = PopoverAPI(props, {
342
+ menuRef,
343
+ isMenuOpen,
344
+ panelParentsOpen,
345
+ });
346
+
347
+ const {
348
+ isLeastOnePanelOpenAndMenuClosed,
349
+ } = PanelMainAPI({
350
+ isMenuOpen,
351
+ panelParentsOpen,
352
+ });
353
+
354
+ const {
355
+ clickAttributesBackdrop,
356
+ isBackdropVisible,
357
+ } = BackdropAPI(props, {
358
+ isMenuOpen,
359
+ isMobileWidth,
360
+ toggleMenu,
361
+ });
362
+
363
+ watch(currentRoute, () => {
364
+ checkAllRoutes();
365
+ }, {
366
+ immediate: true,
367
+ deep: true,
368
+ });
369
+
370
+ watch(isMenuOpen, newValue => {
371
+ if (!isMenuInitialized.value) {
372
+ return;
373
+ }
374
+ resetSearch();
375
+ closeAllPanels();
376
+ if (newValue) {
377
+ destroyPopover();
378
+ setListenerForKeydownMobile();
379
+ } else {
380
+ removeListenerForKeydownMobile();
381
+ }
382
+ });
383
+
384
+ watch(panelParentsOpen, () => {
385
+ startPopper();
386
+ }, {
387
+ deep: true,
388
+ });
389
+
390
+ watch(isDesktopSubMenuVisibleWhenMenuClosed, newValue => {
391
+ if (newValue) {
392
+ setListenerForKeydownDesktop();
393
+ } else {
394
+ removeListenerForKeydownDesktop();
395
+ }
396
+ });
397
+
398
+ provide("activeRoutesIds", computed(() => activeRoutesIds.value));
399
+ provide("clickMenuLink", clickMenuLink);
400
+ provide("isLinkTruncated", computed(() => isLinkTruncated.value));
401
+ provide("isMenuOpen", computed(() => isMenuOpen.value));
402
+ provide("panelParentsOpen", panelParentsOpen);
403
+ provide("showCountChildren", computed(() => showCountChildren.value));
404
+ provide("togglePanel", togglePanel);
405
+ provide("breadcrumbsTruncatedOffset", computed(() => breadcrumbsTruncatedOffset.value));
406
+
407
+ onMounted(() => {
408
+ isMounted.value = true;
409
+ initMenuOpenOrClose();
410
+ initEventBusUpdateViewOnResize();
411
+ });
412
+
413
+ onBeforeUnmount(() => {
414
+ removeBodyClasses();
415
+ destroyEventBusUpdateViewOnResize();
416
+ destroyPopover();
417
+ removeListenerForKeydownDesktop();
418
+ removeListenerForKeydownMobile();
419
+ });
420
+
421
+ return {
422
+ activeRoutesIds,
423
+ attributesBlockerClick,
424
+ attributesMenuClick,
425
+ attributesMobile,
426
+ checkAllRoutes,
427
+ clickAttributesBackdrop,
428
+ clickOnSearchBtn,
429
+ dataKeyById,
430
+ dataProParent,
431
+ headerId,
432
+ isBackdropVisible,
433
+ isLeastOnePanelOpenAndMenuClosed,
434
+ isMenuOpen,
435
+ isMobileWidth,
436
+ isMounted,
437
+ isSearchActive,
438
+ isSubMenuOpen,
439
+ itemsWithSearch,
440
+ keydownOnSearchBtn,
441
+ menuRef,
442
+ modelSearch,
443
+ panelParentsOpen,
444
+ removeBodyClasses,
445
+ searchInputId,
446
+ setDefaultMenu,
447
+ styleSearchPanelMain,
448
+ toggleMenu,
449
+ togglePanel,
450
+ updateModelSearch,
451
+ };
452
+ },
453
+ render() {
454
+ if (!this.isMounted) {
455
+ return null;
456
+ }
457
+
458
+ return h("nav", {
459
+ ref: "menuRef",
460
+ id: this.menuId,
461
+ "aria-labelledby": this.headerId,
462
+ class: [
463
+ "a_menu",
464
+ {
465
+ a_menu_inline: this.isInline,
466
+ a_menu_sub_open: this.isSubMenuOpen,
467
+ a_menu_open: this.isMenuOpen,
468
+ a_menu_close: !this.isMenuOpen,
469
+ a_menu_only_mobile: this.onlyMobile,
470
+ a_menu_mobile: this.isMobileWidth || this.onlyMobile,
471
+ },
472
+ ],
473
+ ...this.attributesMobile,
474
+ ...this.attributesMenuClick,
475
+ }, [
476
+ h("div", {
477
+ class: "a_menu__navbar_top",
478
+ }, [
479
+ h(AMenuButtonToggle, {
480
+ buttonToggleProps: this.buttonToggleProps,
481
+ canChangeBodyClass: this.canChangeBodyClass,
482
+ class: this.buttonToggleClass,
483
+ insideMenu: true,
484
+ menuId: this.menuId,
485
+ selectorClose: this.selectorClose,
486
+ selectorCloseIds: this.selectorCloseIds,
487
+ }),
488
+ this.$slots.menuSearch && this.$slots.menuSearch(),
489
+ this.hasSearch && h(AInput, {
490
+ id: this.searchInputId,
491
+ class: "a_menu__navbar_top__search",
492
+ modelValue: this.modelSearch,
493
+ label: "_A_MENU_2_SEARCH_",
494
+ "onUpdate:modelValue": this.updateModelSearch,
495
+ }),
496
+ ]),
497
+ h("div", {
498
+ class: "a_menu__panels__main",
499
+ style: this.styleSearchPanelMain,
500
+ }, [
501
+ h("div", {
502
+ class: "a_menu__navbar_top_sub",
503
+ }, [
504
+ h(ATranslation, {
505
+ id: this.headerId,
506
+ class: "a_menu__navbar_top_sub__text",
507
+ tag: "strong",
508
+ text: "_A_MENU_2_MAIN_MENU_",
509
+ }),
510
+ this.hasSearch && h(AButton, {
511
+ role: "button",
512
+ tabindex: 0,
513
+ tag: "a",
514
+ class: "a_menu__navbar_top_sub__search a_menu__link a_menu__link_btn",
515
+ iconLeft: Search,
516
+ iconClass: "a_menu__link__icon",
517
+ title: "_A_MENU_2_OPEN_SEARCH_",
518
+ textScreenReader: "_A_MENU_2_OPEN_SEARCH_",
519
+ onClick: this.clickOnSearchBtn,
520
+ onKeydown: this.keydownOnSearchBtn,
521
+ }),
522
+ ]),
523
+ h(AVerticalScroll, {
524
+ class: {
525
+ a_menu__vertical_scroll_hidden: this.isLeastOnePanelOpenAndMenuClosed,
526
+ },
527
+ disabled: this.isMenuOpen || this.isLeastOnePanelOpenAndMenuClosed,
528
+ }, () => [
529
+ h(AMenuPanel, {
530
+ attributesBlockerClick: this.attributesBlockerClick,
531
+ dataKeyById: this.dataKeyById,
532
+ dataProParentChildren: this.dataProParent.children,
533
+ isBreadcrumbsTruncated: this.isBreadcrumbsTruncated,
534
+ isPanelMain: true,
535
+ isSearchActive: this.isSearchActive,
536
+ keyGroup: this.keyGroup,
537
+ keyIcon: this.keyIcon,
538
+ menuId: this.menuId,
539
+ paneIndex: "00",
540
+ panelItems: this.dataProParent.main,
541
+ panelParentsOpen: this.panelParentsOpen,
542
+ }, this.$slots),
543
+ ]),
544
+ h("div", {
545
+ class: "a_menu__panels",
546
+ }, [
547
+ Object.keys(this.dataProParent.children).map((key, paneIndex) => {
548
+ return h(AMenuPanel, {
549
+ key,
550
+ attributesBlockerClick: {},
551
+ breadcrumbsLinkClass: this.breadcrumbsLinkClass,
552
+ breadcrumbsTruncatedDropdownProps: this.breadcrumbsTruncatedDropdownProps,
553
+ dataKeyById: this.dataKeyById,
554
+ dataProParentChildren: this.dataProParent.children,
555
+ isBreadcrumbsTruncated: this.isBreadcrumbsTruncated,
556
+ isSearchActive: this.isSearchActive,
557
+ keyGroup: this.keyGroup,
558
+ keyIcon: this.keyIcon,
559
+ menuId: this.menuId,
560
+ paneIndex,
561
+ panelItems: this.dataProParent.children[key],
562
+ panelParentsOpen: this.panelParentsOpen,
563
+ parentId: key,
564
+ }, this.$slots);
565
+ }),
566
+ ]),
567
+ ]),
568
+ h(AMenuSearchPanel, {
569
+ breadcrumbsLinkClass: this.breadcrumbsLinkClass,
570
+ breadcrumbsTruncatedDropdownProps: this.breadcrumbsTruncatedDropdownProps,
571
+ dataProParentChildren: this.dataProParent.children,
572
+ isSearchActive: this.isSearchActive,
573
+ isSearchBreadcrumbsTruncated: this.isSearchBreadcrumbsTruncated,
574
+ itemsWithSearch: this.itemsWithSearch,
575
+ menuId: this.menuId,
576
+ modelSearch: this.modelSearch,
577
+ }, this.$slots),
578
+
579
+ this.isBackdropVisible
580
+ ? h(Teleport, {
581
+ to: "body",
582
+ }, [
583
+ h("div", {
584
+ class: "a_menu__backdrop a_backdrop a_backdrop_fade",
585
+ "aria-hidden": true,
586
+ ...this.clickAttributesBackdrop,
587
+ }),
588
+ ])
589
+ : "",
590
+ ]);
591
+ },
592
+ };