@acorex/components 18.9.8 → 18.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, Injectable, inject, input, output, afterNextRender, Component, ViewChild, ContentChildren, HostBinding, HostListener, ViewEncapsulation, NgModule } from '@angular/core';
2
+ import { signal, Injectable, inject, input, output, afterNextRender, effect, Component, ViewEncapsulation, ViewChild, ContentChildren, HostBinding, HostListener, NgModule } from '@angular/core';
3
3
  import { MXInteractiveComponent, MXBaseComponent } from '@acorex/components/common';
4
4
  import * as i1 from '@acorex/components/popover';
5
5
  import { AXPopoverComponent, AXPopoverModule } from '@acorex/components/popover';
6
6
  import { BehaviorSubject } from 'rxjs';
7
+ import * as i1$1 from '@acorex/components/decorators';
7
8
  import { AXDecoratorModule } from '@acorex/components/decorators';
9
+ import { AXButtonModule } from '@acorex/components/button';
8
10
  import { AXLoadingModule } from '@acorex/components/loading';
9
11
  import { AXTranslationModule } from '@acorex/core/translation';
10
12
  import { OverlayModule } from '@angular/cdk/overlay';
@@ -20,6 +22,10 @@ class AXRootMenu {
20
22
  class AXMenuService {
21
23
  constructor() {
22
24
  this.activeMenus$ = new BehaviorSubject([]);
25
+ this.rightOverflow = signal(0);
26
+ this.leftOverflow = signal(0);
27
+ this.overflowElements = signal([]);
28
+ this.notOverflowElements = signal([]);
23
29
  }
24
30
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
25
31
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuService, providedIn: 'root' }); }
@@ -39,42 +45,43 @@ class AXMenuItemComponent extends MXInteractiveComponent {
39
45
  /** @ignore */
40
46
  constructor() {
41
47
  super();
48
+ this.service = inject(AXMenuService);
42
49
  /**
43
- * Injects the `AXMenuService` for managing menu interactions.
44
- */
50
+ * Injects the `AXMenuService` for managing menu interactions.
51
+ */
45
52
  this.menuService = inject(AXMenuService);
46
53
  /**
47
- * The vertical offset for positioning, initialized to 0.
48
- */
54
+ * The vertical offset for positioning, initialized to 0.
55
+ */
49
56
  this.offsetY = signal(0);
50
57
  /**
51
- * The horizontal offset for positioning, initialized to 0.
52
- */
58
+ * The horizontal offset for positioning, initialized to 0.
59
+ */
53
60
  this.offsetX = signal(0);
54
61
  /**
55
- * The text content, initialized to an empty string.
56
- */
62
+ * The text content, initialized to an empty string.
63
+ */
57
64
  this.text = input();
58
65
  /**
59
- * Indicates whether the item is active.
60
- */
66
+ * Indicates whether the item is active.
67
+ */
61
68
  this.active = input();
62
69
  /**
63
- * Emitted when the active state changes.
64
- */
70
+ * Emitted when the active state changes.
71
+ */
65
72
  this.activeChange = output();
66
73
  /**
67
- * Emitted when the element is clicked.
68
- */
74
+ * Emitted when the element is clicked.
75
+ */
69
76
  this.onClick = output();
70
77
  /**
71
- * Indicates whether the component is a root menu item.
72
- * @defaultValue false
73
- */
78
+ * Indicates whether the component is a root menu item.
79
+ * @defaultValue false
80
+ */
74
81
  this.isRoot = false;
75
82
  /**
76
- * Injects the root menu service.
77
- */
83
+ * Injects the root menu service.
84
+ */
78
85
  this.rootMenu = inject(AXRootMenu);
79
86
  afterNextRender(() => {
80
87
  this.children.forEach((c) => {
@@ -84,19 +91,25 @@ class AXMenuItemComponent extends MXInteractiveComponent {
84
91
  this.offsetX.set(this.isRoot ? 0 : 4);
85
92
  this.getPlacement();
86
93
  });
94
+ effect(() => {
95
+ if (!this.getHostElement().getClientRects()[0]?.right)
96
+ return;
97
+ //add overflow items to array
98
+ if (this.getHostElement().getClientRects()[0]?.right > this.service.rightOverflow() ||
99
+ this.getHostElement().getClientRects()[0]?.left < this.service.leftOverflow()) {
100
+ this.service.overflowElements.update((prev) => [...prev, this.getHostElement()]);
101
+ }
102
+ else {
103
+ this.service.notOverflowElements.update((prev) => [...prev, this.getHostElement()]);
104
+ }
105
+ }, { allowSignalWrites: true });
87
106
  }
88
107
  /**
89
- * Closes the popover if it is open.
90
- */
108
+ * Closes the popover if it is open.
109
+ */
91
110
  close() {
92
111
  this.popover?.close();
93
112
  }
94
- // @HostListener('mouseleave', ['$event'])
95
- // private onMouseHover(e: MouseEvent) {
96
- // this.children.forEach((c) => {
97
- // c.close();
98
- // });
99
- // }
100
113
  /** @ignore */
101
114
  _handleOnOpened() {
102
115
  this.parent.children.forEach((c) => {
@@ -115,8 +128,8 @@ class AXMenuItemComponent extends MXInteractiveComponent {
115
128
  });
116
129
  }
117
130
  /**
118
- * Returns the icon based on the orientation of the root menu.
119
- */
131
+ * Returns the icon based on the orientation of the root menu.
132
+ */
120
133
  getIcon() {
121
134
  if (this.rootMenu.orientation() == 'vertical') {
122
135
  return 'ax-icon-arrow-right';
@@ -126,8 +139,8 @@ class AXMenuItemComponent extends MXInteractiveComponent {
126
139
  }
127
140
  }
128
141
  /**
129
- * Determines the placement based on the root menu's orientation: 'bottom-start' for horizontal root, 'end-top' otherwise.
130
- */
142
+ * Determines the placement based on the root menu's orientation: 'bottom-start' for horizontal root, 'end-top' otherwise.
143
+ */
131
144
  getPlacement() {
132
145
  switch (this.rootMenu.orientation()) {
133
146
  case 'horizontal':
@@ -169,11 +182,11 @@ class AXMenuItemComponent extends MXInteractiveComponent {
169
182
  }
170
183
  }
171
184
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
172
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: AXMenuItemComponent, selector: "ax-menu-item", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeChange: "activeChange", onClick: "onClick" }, host: { attributes: { "ngSkipHydration": "true" }, listeners: { "click": "__hostClick($event)" }, properties: { "class": "this.__hostClass" } }, queries: [{ propertyName: "children", predicate: AXMenuItemComponent }], viewQueries: [{ propertyName: "popover", first: true, predicate: AXPopoverComponent, descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-menu-item-start-side\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <div class=\"ax-menu-item-text\">{{ text() }}</div>\n</div>\n<ng-content select=\"ax-suffix\"></ng-content>\n@if(children.length){\n<i class=\"ax-icon ax-icon-solid {{ getIcon() }} ax-menu-item-child-icon\"></i>\n}\n<ax-popover #popover [closeOn]=\"'clickOut'\" [openOn]=\"rootMenu.openOn()\" [target]=\"getHostElement()\"\n [offsetY]=\"offsetY()\" [offsetX]=\"offsetX()\" [placement]=\"getPlacement()\" (onOpened)=\"_handleOnOpened()\"\n (onClosed)=\"_handleOnClosed()\">\n <div class=\"ax-menu-item-children ax-parent-{{ this.rootMenu.orientation() }}\">\n <ng-content select=\"ax-menu-item\"></ng-content>\n </div>\n</ax-popover>", dependencies: [{ kind: "component", type: i1.AXPopoverComponent, selector: "ax-popover", inputs: ["offsetX", "offsetY", "target", "placement", "content", "openOn", "closeOn", "hasBackdrop", "openAfter", "closeAfter", "backdropClass", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }] }); }
185
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: AXMenuItemComponent, selector: "ax-menu-item", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeChange: "activeChange", onClick: "onClick" }, host: { attributes: { "ngSkipHydration": "true" }, listeners: { "click": "__hostClick($event)" }, properties: { "class": "this.__hostClass" } }, queries: [{ propertyName: "children", predicate: AXMenuItemComponent }], viewQueries: [{ propertyName: "popover", first: true, predicate: AXPopoverComponent, descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-menu-item-start-side\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <p class=\"ax-menu-item-text\">{{ text() }}</p>\n</div>\n<ng-content select=\"ax-suffix\"></ng-content>\n@if (children.length) {\n <i class=\"ax-icon ax-icon-solid {{ getIcon() }} ax-menu-item-child-icon\"></i>\n}\n\n<ax-popover\n #popover\n [closeOn]=\"'clickOut'\"\n [openOn]=\"rootMenu.openOn()\"\n [target]=\"getHostElement()\"\n [offsetY]=\"offsetY()\"\n [offsetX]=\"offsetX()\"\n [placement]=\"getPlacement()\"\n (onOpened)=\"_handleOnOpened()\"\n (onClosed)=\"_handleOnClosed()\"\n>\n <div class=\"ax-menu-item-children ax-parent-{{ this.rootMenu.orientation() }}\">\n <ng-content select=\"ax-menu-item\"></ng-content>\n </div>\n</ax-popover>\n", styles: [".ax-menu-item-text{white-space:nowrap}\n"], dependencies: [{ kind: "component", type: i1.AXPopoverComponent, selector: "ax-popover", inputs: ["offsetX", "offsetY", "target", "placement", "content", "openOn", "closeOn", "hasBackdrop", "openAfter", "closeAfter", "backdropClass", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }], encapsulation: i0.ViewEncapsulation.None }); }
173
186
  }
174
187
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuItemComponent, decorators: [{
175
188
  type: Component,
176
- args: [{ selector: 'ax-menu-item', inputs: ['disabled'], host: { ngSkipHydration: 'true' }, template: "<div class=\"ax-menu-item-start-side\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <div class=\"ax-menu-item-text\">{{ text() }}</div>\n</div>\n<ng-content select=\"ax-suffix\"></ng-content>\n@if(children.length){\n<i class=\"ax-icon ax-icon-solid {{ getIcon() }} ax-menu-item-child-icon\"></i>\n}\n<ax-popover #popover [closeOn]=\"'clickOut'\" [openOn]=\"rootMenu.openOn()\" [target]=\"getHostElement()\"\n [offsetY]=\"offsetY()\" [offsetX]=\"offsetX()\" [placement]=\"getPlacement()\" (onOpened)=\"_handleOnOpened()\"\n (onClosed)=\"_handleOnClosed()\">\n <div class=\"ax-menu-item-children ax-parent-{{ this.rootMenu.orientation() }}\">\n <ng-content select=\"ax-menu-item\"></ng-content>\n </div>\n</ax-popover>" }]
189
+ args: [{ selector: 'ax-menu-item', inputs: ['disabled'], host: { ngSkipHydration: 'true' }, encapsulation: ViewEncapsulation.None, template: "<div class=\"ax-menu-item-start-side\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <p class=\"ax-menu-item-text\">{{ text() }}</p>\n</div>\n<ng-content select=\"ax-suffix\"></ng-content>\n@if (children.length) {\n <i class=\"ax-icon ax-icon-solid {{ getIcon() }} ax-menu-item-child-icon\"></i>\n}\n\n<ax-popover\n #popover\n [closeOn]=\"'clickOut'\"\n [openOn]=\"rootMenu.openOn()\"\n [target]=\"getHostElement()\"\n [offsetY]=\"offsetY()\"\n [offsetX]=\"offsetX()\"\n [placement]=\"getPlacement()\"\n (onOpened)=\"_handleOnOpened()\"\n (onClosed)=\"_handleOnClosed()\"\n>\n <div class=\"ax-menu-item-children ax-parent-{{ this.rootMenu.orientation() }}\">\n <ng-content select=\"ax-menu-item\"></ng-content>\n </div>\n</ax-popover>\n", styles: [".ax-menu-item-text{white-space:nowrap}\n"] }]
177
190
  }], ctorParameters: () => [], propDecorators: { popover: [{
178
191
  type: ViewChild,
179
192
  args: [AXPopoverComponent]
@@ -194,9 +207,62 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
194
207
  */
195
208
  class AXMenuComponent extends MXBaseComponent {
196
209
  constructor() {
197
- super(...arguments);
210
+ super();
198
211
  this.orientation = input('horizontal');
199
212
  this.openOn = input('toggle');
213
+ this.service = inject(AXMenuService);
214
+ this.menuHeight = signal('');
215
+ this.isMenuOpen = signal(false);
216
+ afterNextRender(() => {
217
+ //add menu container border for detect overflow happen
218
+ this.menuHeight.set(`${this.getHostElement()?.getClientRects()[0]?.height}px`);
219
+ this.service.rightOverflow.set(this.getHostElement().querySelector('.ax-menu-item-container')?.getClientRects()[0]?.right);
220
+ this.service.leftOverflow.set(this.getHostElement().querySelector('.ax-menu-item-container')?.getClientRects()[0]?.left);
221
+ });
222
+ let resizeTimer;
223
+ window.addEventListener('resize', () => {
224
+ //add menu container border for detect overflow happen
225
+ clearTimeout(resizeTimer);
226
+ if (!this.getHostElement())
227
+ return;
228
+ resizeTimer = setTimeout(() => {
229
+ this.service.rightOverflow.set(this.getHostElement().querySelector('.ax-menu-item-container').getClientRects()[0].right);
230
+ this.service.leftOverflow.set(this.getHostElement().querySelector('.ax-menu-item-container').getClientRects()[0].left);
231
+ this.service.notOverflowElements.set([]);
232
+ this.service.overflowElements.set([]);
233
+ this.isMenuOpen.set(false);
234
+ }, 200);
235
+ });
236
+ effect(() => {
237
+ //rearrange items base on menu state
238
+ const overflowMenu = this.getHostElement().querySelector('.overflowMenu');
239
+ const originalMenu = this.getHostElement().querySelector('.originalMenu');
240
+ const injectContainer = this.getHostElement().querySelector('.ax-overflow-menu-container');
241
+ const injectContainer2 = this.getHostElement().querySelector('.ax-menu-item-container');
242
+ if (this.isMenuOpen()) {
243
+ overflowMenu?.remove();
244
+ const axMenu = document.createElement('ax-menu');
245
+ axMenu.classList.add('overflowMenu');
246
+ this.service.overflowElements().forEach((item) => {
247
+ axMenu.appendChild(item);
248
+ });
249
+ injectContainer.appendChild(axMenu);
250
+ }
251
+ else {
252
+ originalMenu?.remove();
253
+ overflowMenu?.remove();
254
+ const axMenu = document.createElement('ax-menu');
255
+ axMenu.classList.add('originalMenu');
256
+ const allItems = [...this.service.overflowElements(), ...this.service.notOverflowElements()];
257
+ allItems.forEach((item) => {
258
+ axMenu.appendChild(item);
259
+ });
260
+ injectContainer2.appendChild(axMenu);
261
+ }
262
+ });
263
+ }
264
+ showMenuHandler() {
265
+ this.isMenuOpen.update((prev) => !prev);
200
266
  }
201
267
  /** @ignore */
202
268
  ngAfterViewInit() {
@@ -207,10 +273,10 @@ class AXMenuComponent extends MXBaseComponent {
207
273
  }
208
274
  /** @ignore */
209
275
  get __hostClass() {
210
- return `ax-orientation-${this.orientation()}`;
276
+ return `ax-orientation-${this.orientation()} main-menu`;
211
277
  }
212
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
213
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.0", type: AXMenuComponent, selector: "ax-menu", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, openOn: { classPropertyName: "openOn", publicName: "openOn", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.__hostClass" } }, providers: [
278
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
279
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: AXMenuComponent, selector: "ax-menu", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, openOn: { classPropertyName: "openOn", publicName: "openOn", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.__hostClass" } }, providers: [
214
280
  {
215
281
  provide: AXRootMenu,
216
282
  useExisting: AXMenuComponent,
@@ -218,11 +284,51 @@ class AXMenuComponent extends MXBaseComponent {
218
284
  {
219
285
  provide: AXMenuService,
220
286
  },
221
- ], queries: [{ propertyName: "children", predicate: AXMenuItemComponent }], usesInheritance: true, ngImport: i0, template: `<ng-content select="ax-menu-item,ng-container"></ng-content>`, isInline: true, styles: ["ax-menu{width:100%;font-size:.875rem;line-height:1.25rem;color:inherit}ax-menu.ax-orientation-horizontal{display:flex}ax-menu.ax-orientation-horizontal ax-menu-item:not(ax-menu.ax-orientation-horizontal ax-menu-item:last-child){margin-inline-end:1rem}ax-menu.ax-orientation-vertical{display:flex;flex-direction:column}ax-menu.ax-orientation-vertical ax-menu-item{justify-content:space-between}ax-menu.ax-orientation-vertical ax-menu-item:not(ax-menu.ax-orientation-vertical ax-menu-item:last-child){margin-bottom:1rem}ax-menu ax-menu-item:hover:not(ax-menu ax-menu-item:hover.ax-state-disabled){color:rgba(var(--ax-color-primary-500))}ax-menu-item{position:relative;display:flex;align-items:center;gap:.5rem;font-size:.875rem;line-height:1.25rem;font-weight:500;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;justify-content:space-between;color:rgba(var(--ax-color-text-default))}ax-menu-item:not(ax-menu-item.ax-state-disabled){cursor:pointer}ax-menu-item .ax-menu-item-start-side{display:flex;align-items:center;gap:.5rem}ax-menu-item.ax-state-disabled{cursor:not-allowed;opacity:.5}ax-menu-item.ax-state-selected{color:rgba(var(--ax-color-primary-500))}ax-menu-item .ax-menu-item-child-icon{width:fit-content;line-height:1}ax-menu-item ax-popover{position:absolute}.ax-menu-item-children{padding-top:.5rem;padding-bottom:.5rem}.ax-menu-item-children:not(.ax-menu-item-children:empty){display:flex;min-width:12rem;flex-direction:column;border-radius:var(--ax-rounded-border-default);border-width:1px;border-color:rgba(var(--ax-color-border-default));background-color:rgba(var(--ax-color-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item{padding:.5rem 1rem;font-size:.875rem;line-height:1.25rem}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled){background-color:rgba(var(--ax-color-on-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-suffix{opacity:1}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-suffix{opacity:.75}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item .ax-menu-item-text{flex:1 1 0%}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon:before{-moz-transform:scale(1,-1);-webkit-transform:scale(1,-1);-o-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scaleY(-1)}.ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}\n"], encapsulation: i0.ViewEncapsulation.None }); }
287
+ ], queries: [{ propertyName: "children", predicate: AXMenuItemComponent }], usesInheritance: true, ngImport: i0, template: `
288
+ <div class="ax-main-menu-container">
289
+ <div
290
+ [style]="{ width: this.service.overflowElements().length !== 0 ? '90%' : '100%' }"
291
+ class="ax-menu-item-container"
292
+ >
293
+ <ng-content select="ax-menu-item,ng-container"></ng-content>
294
+ </div>
295
+ @if (this.service.overflowElements().length !== 0) {
296
+ <div class="ax-show-truncate-menu">
297
+ <button (click)="showMenuHandler()" tabindex="0" type="button">
298
+ <ax-icon class="ax-icon ax-icon-more-horizontal ng-star-inserted ax-text-xl"></ax-icon>
299
+ </button>
300
+ </div>
301
+ }
302
+ </div>
303
+
304
+ @if (this.service.overflowElements().length !== 0) {
305
+ <div [style]="{ top: menuHeight() }" class="ax-overflow-menu-container ax-menu-item-children"></div>
306
+ }
307
+ `, isInline: true, styles: ["ax-menu{width:100%;font-size:.875rem;line-height:1.25rem;color:inherit;position:relative}ax-menu .ax-main-menu-container{display:flex;align-items:center;width:100%;overflow:hidden}ax-menu .ax-menu-item-container{display:flex;overflow:hidden}ax-menu .originalMenu{display:flex;overflow:hidden;width:100%}ax-menu .ax-show-truncate-menu{position:absolute;right:0;width:10%}ax-menu .ax-overflow-menu-container{position:absolute;right:0}ax-menu.ax-orientation-horizontal{display:flex}ax-menu.ax-orientation-horizontal ax-menu-item:not(ax-menu.ax-orientation-horizontal ax-menu-item:last-child){margin-inline-end:1rem}ax-menu.ax-orientation-vertical{display:flex;flex-direction:column}ax-menu.ax-orientation-vertical ax-menu-item{justify-content:space-between}ax-menu.ax-orientation-vertical ax-menu-item:not(ax-menu.ax-orientation-vertical ax-menu-item:last-child){margin-bottom:1rem}ax-menu ax-menu-item:hover:not(ax-menu ax-menu-item:hover.ax-state-disabled){color:rgba(var(--ax-color-primary-500))}ax-menu-item{position:relative;display:flex;align-items:center;gap:.5rem;font-size:.875rem;line-height:1.25rem;font-weight:500;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;justify-content:space-between;color:rgba(var(--ax-color-text-default))}ax-menu-item:not(ax-menu-item.ax-state-disabled){cursor:pointer}ax-menu-item .ax-menu-item-start-side{display:flex;align-items:center;gap:.5rem}ax-menu-item.ax-state-disabled{cursor:not-allowed;opacity:.5}ax-menu-item.ax-state-selected{color:rgba(var(--ax-color-primary-500))}ax-menu-item .ax-menu-item-child-icon{width:fit-content;line-height:1}ax-menu-item ax-popover{position:absolute}.ax-menu-item-children{padding-top:.5rem;padding-bottom:.5rem}.ax-menu-item-children:not(.ax-menu-item-children:empty){display:flex;min-width:12rem;flex-direction:column;border-radius:var(--ax-rounded-border-default);border-width:1px;border-color:rgba(var(--ax-color-border-default));background-color:rgba(var(--ax-color-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item{padding:.5rem 1rem;font-size:.875rem;line-height:1.25rem}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled){background-color:rgba(var(--ax-color-on-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-suffix{opacity:1}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-suffix{opacity:.75}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item .ax-menu-item-text{flex:1 1 0%}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon:before{-moz-transform:scale(1,-1);-webkit-transform:scale(1,-1);-o-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scaleY(-1)}.ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}\n"], dependencies: [{ kind: "component", type: i1$1.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }], encapsulation: i0.ViewEncapsulation.None }); }
222
308
  }
223
309
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuComponent, decorators: [{
224
310
  type: Component,
225
- args: [{ selector: 'ax-menu', template: `<ng-content select="ax-menu-item,ng-container"></ng-content>`, encapsulation: ViewEncapsulation.None, providers: [
311
+ args: [{ selector: 'ax-menu', template: `
312
+ <div class="ax-main-menu-container">
313
+ <div
314
+ [style]="{ width: this.service.overflowElements().length !== 0 ? '90%' : '100%' }"
315
+ class="ax-menu-item-container"
316
+ >
317
+ <ng-content select="ax-menu-item,ng-container"></ng-content>
318
+ </div>
319
+ @if (this.service.overflowElements().length !== 0) {
320
+ <div class="ax-show-truncate-menu">
321
+ <button (click)="showMenuHandler()" tabindex="0" type="button">
322
+ <ax-icon class="ax-icon ax-icon-more-horizontal ng-star-inserted ax-text-xl"></ax-icon>
323
+ </button>
324
+ </div>
325
+ }
326
+ </div>
327
+
328
+ @if (this.service.overflowElements().length !== 0) {
329
+ <div [style]="{ top: menuHeight() }" class="ax-overflow-menu-container ax-menu-item-children"></div>
330
+ }
331
+ `, encapsulation: ViewEncapsulation.None, providers: [
226
332
  {
227
333
  provide: AXRootMenu,
228
334
  useExisting: AXMenuComponent,
@@ -230,8 +336,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
230
336
  {
231
337
  provide: AXMenuService,
232
338
  },
233
- ], styles: ["ax-menu{width:100%;font-size:.875rem;line-height:1.25rem;color:inherit}ax-menu.ax-orientation-horizontal{display:flex}ax-menu.ax-orientation-horizontal ax-menu-item:not(ax-menu.ax-orientation-horizontal ax-menu-item:last-child){margin-inline-end:1rem}ax-menu.ax-orientation-vertical{display:flex;flex-direction:column}ax-menu.ax-orientation-vertical ax-menu-item{justify-content:space-between}ax-menu.ax-orientation-vertical ax-menu-item:not(ax-menu.ax-orientation-vertical ax-menu-item:last-child){margin-bottom:1rem}ax-menu ax-menu-item:hover:not(ax-menu ax-menu-item:hover.ax-state-disabled){color:rgba(var(--ax-color-primary-500))}ax-menu-item{position:relative;display:flex;align-items:center;gap:.5rem;font-size:.875rem;line-height:1.25rem;font-weight:500;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;justify-content:space-between;color:rgba(var(--ax-color-text-default))}ax-menu-item:not(ax-menu-item.ax-state-disabled){cursor:pointer}ax-menu-item .ax-menu-item-start-side{display:flex;align-items:center;gap:.5rem}ax-menu-item.ax-state-disabled{cursor:not-allowed;opacity:.5}ax-menu-item.ax-state-selected{color:rgba(var(--ax-color-primary-500))}ax-menu-item .ax-menu-item-child-icon{width:fit-content;line-height:1}ax-menu-item ax-popover{position:absolute}.ax-menu-item-children{padding-top:.5rem;padding-bottom:.5rem}.ax-menu-item-children:not(.ax-menu-item-children:empty){display:flex;min-width:12rem;flex-direction:column;border-radius:var(--ax-rounded-border-default);border-width:1px;border-color:rgba(var(--ax-color-border-default));background-color:rgba(var(--ax-color-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item{padding:.5rem 1rem;font-size:.875rem;line-height:1.25rem}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled){background-color:rgba(var(--ax-color-on-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-suffix{opacity:1}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-suffix{opacity:.75}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item .ax-menu-item-text{flex:1 1 0%}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon:before{-moz-transform:scale(1,-1);-webkit-transform:scale(1,-1);-o-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scaleY(-1)}.ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}\n"] }]
234
- }], propDecorators: { children: [{
339
+ ], styles: ["ax-menu{width:100%;font-size:.875rem;line-height:1.25rem;color:inherit;position:relative}ax-menu .ax-main-menu-container{display:flex;align-items:center;width:100%;overflow:hidden}ax-menu .ax-menu-item-container{display:flex;overflow:hidden}ax-menu .originalMenu{display:flex;overflow:hidden;width:100%}ax-menu .ax-show-truncate-menu{position:absolute;right:0;width:10%}ax-menu .ax-overflow-menu-container{position:absolute;right:0}ax-menu.ax-orientation-horizontal{display:flex}ax-menu.ax-orientation-horizontal ax-menu-item:not(ax-menu.ax-orientation-horizontal ax-menu-item:last-child){margin-inline-end:1rem}ax-menu.ax-orientation-vertical{display:flex;flex-direction:column}ax-menu.ax-orientation-vertical ax-menu-item{justify-content:space-between}ax-menu.ax-orientation-vertical ax-menu-item:not(ax-menu.ax-orientation-vertical ax-menu-item:last-child){margin-bottom:1rem}ax-menu ax-menu-item:hover:not(ax-menu ax-menu-item:hover.ax-state-disabled){color:rgba(var(--ax-color-primary-500))}ax-menu-item{position:relative;display:flex;align-items:center;gap:.5rem;font-size:.875rem;line-height:1.25rem;font-weight:500;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;justify-content:space-between;color:rgba(var(--ax-color-text-default))}ax-menu-item:not(ax-menu-item.ax-state-disabled){cursor:pointer}ax-menu-item .ax-menu-item-start-side{display:flex;align-items:center;gap:.5rem}ax-menu-item.ax-state-disabled{cursor:not-allowed;opacity:.5}ax-menu-item.ax-state-selected{color:rgba(var(--ax-color-primary-500))}ax-menu-item .ax-menu-item-child-icon{width:fit-content;line-height:1}ax-menu-item ax-popover{position:absolute}.ax-menu-item-children{padding-top:.5rem;padding-bottom:.5rem}.ax-menu-item-children:not(.ax-menu-item-children:empty){display:flex;min-width:12rem;flex-direction:column;border-radius:var(--ax-rounded-border-default);border-width:1px;border-color:rgba(var(--ax-color-border-default));background-color:rgba(var(--ax-color-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item{padding:.5rem 1rem;font-size:.875rem;line-height:1.25rem}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled){background-color:rgba(var(--ax-color-on-surface))}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover:not(.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item:hover.ax-state-disabled) ax-suffix{opacity:1}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-prefix,.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item ax-suffix{opacity:.75}.ax-menu-item-children:not(.ax-menu-item-children:empty) ax-menu-item .ax-menu-item-text{flex:1 1 0%}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}html[dir=rtl] .ax-parent-horizontal .ax-menu-item-child-icon:before{-moz-transform:scale(1,-1);-webkit-transform:scale(1,-1);-o-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scaleY(-1)}.ax-parent-horizontal .ax-menu-item-child-icon{transform:rotate(-90deg)}\n"] }]
340
+ }], ctorParameters: () => [], propDecorators: { children: [{
235
341
  type: ContentChildren,
236
342
  args: [AXMenuItemComponent]
237
343
  }], __hostClass: [{
@@ -243,14 +349,14 @@ const COMPONENT = [AXMenuItemComponent, AXMenuComponent];
243
349
  const MODULES = [AXDecoratorModule, AXLoadingModule, AXTranslationModule, OverlayModule, AXPopoverModule];
244
350
  class AXMenuModule {
245
351
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
246
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.0", ngImport: i0, type: AXMenuModule, declarations: [AXMenuItemComponent, AXMenuComponent], imports: [CommonModule, AXDecoratorModule, AXLoadingModule, AXTranslationModule, OverlayModule, AXPopoverModule], exports: [AXMenuItemComponent, AXMenuComponent] }); }
247
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuModule, imports: [CommonModule, MODULES] }); }
352
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.0", ngImport: i0, type: AXMenuModule, declarations: [AXMenuItemComponent, AXMenuComponent], imports: [CommonModule, AXDecoratorModule, AXLoadingModule, AXTranslationModule, OverlayModule, AXPopoverModule, AXButtonModule], exports: [AXMenuItemComponent, AXMenuComponent] }); }
353
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuModule, imports: [CommonModule, MODULES, AXButtonModule] }); }
248
354
  }
249
355
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMenuModule, decorators: [{
250
356
  type: NgModule,
251
357
  args: [{
252
358
  declarations: [...COMPONENT],
253
- imports: [CommonModule, ...MODULES],
359
+ imports: [CommonModule, ...MODULES, AXButtonModule],
254
360
  exports: [...COMPONENT],
255
361
  providers: [],
256
362
  }]
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-components-menu.mjs","sources":["../../../../libs/components/menu/src/lib/class/root-menu.class.ts","../../../../libs/components/menu/src/lib/menu.service.ts","../../../../libs/components/menu/src/lib/menu-item/menu-item.component.ts","../../../../libs/components/menu/src/lib/menu-item/menu-item.component.html","../../../../libs/components/menu/src/lib/menu.component.ts","../../../../libs/components/menu/src/lib/menu.module.ts","../../../../libs/components/menu/src/acorex-components-menu.ts"],"sourcesContent":["import { AXOrientation } from '@acorex/components/common';\nimport { WritableSignal, signal } from '@angular/core';\nimport { AXMenuPopoverTrigger } from './popover.class';\nexport class AXRootMenu {\n orientation: WritableSignal<AXOrientation> = signal('horizontal');\n openOn: WritableSignal<AXMenuPopoverTrigger> = signal('toggle');\n}\n","import { Injectable } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\nimport { AXMenuItemComponent } from './menu-item/menu-item.component';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXMenuService {\n activeMenus$: BehaviorSubject<AXMenuItemComponent[]> = new BehaviorSubject<AXMenuItemComponent[]>([]);\n}\n","import { AXClickEvent, MXInteractiveComponent } from '@acorex/components/common';\nimport { AXPopoverComponent } from '@acorex/components/popover';\nimport {\n Component,\n ContentChildren,\n HostBinding,\n HostListener,\n QueryList,\n ViewChild,\n afterNextRender,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { AXRootMenu } from '../class/root-menu.class';\nimport { AXMenuService } from '../menu.service';\n\n/**\n * Represents a menu item component used within an `ax-menu`.\n * @category Components\n */\n@Component({\n selector: 'ax-menu-item',\n inputs: ['disabled'],\n templateUrl: './menu-item.component.html',\n host: { ngSkipHydration: 'true' },\n})\nexport class AXMenuItemComponent extends MXInteractiveComponent {\n\n /** @ignore */\n @ViewChild(AXPopoverComponent)\n\n /** @ignore */\n private popover: AXPopoverComponent;\n\n /**\n * Injects the `AXMenuService` for managing menu interactions.\n */\n menuService = inject(AXMenuService);\n\n /**\n * The vertical offset for positioning, initialized to 0.\n */\n offsetY = signal(0);\n\n /**\n * The horizontal offset for positioning, initialized to 0.\n */\n offsetX = signal(0);\n\n /**\n * The text content, initialized to an empty string.\n */\n text = input<string>();\n\n /**\n * Indicates whether the item is active.\n */\n active = input<boolean>();\n\n /**\n * Emitted when the active state changes.\n */\n activeChange = output<boolean>();\n\n /**\n * Emitted when the element is clicked.\n */\n onClick = output<AXClickEvent>();\n\n /**\n * Indicates whether the component is a root menu item.\n * @defaultValue false\n */\n isRoot = false;\n\n /**\n * The parent menu item component, if any.\n */\n parent?: AXMenuItemComponent;\n\n /**\n * Injects the root menu service.\n */\n rootMenu = inject(AXRootMenu);\n\n /** @ignore */\n @ContentChildren(AXMenuItemComponent)\n children: QueryList<AXMenuItemComponent>;\n\n /** @ignore */\n constructor() {\n super();\n afterNextRender(() => {\n this.children.forEach((c) => {\n c.parent = this;\n });\n\n this.offsetY.set(this.isRoot ? 8 : 0);\n this.offsetX.set(this.isRoot ? 0 : 4);\n\n this.getPlacement();\n });\n }\n\n /**\n * Closes the popover if it is open.\n */\n close() {\n this.popover?.close();\n }\n\n // @HostListener('mouseleave', ['$event'])\n // private onMouseHover(e: MouseEvent) {\n // this.children.forEach((c) => {\n // c.close();\n // });\n // }\n\n /** @ignore */\n _handleOnOpened() {\n this.parent.children.forEach((c) => {\n if (c != this) {\n c.close();\n }\n });\n if (this.children.length) {\n this.menuService.activeMenus$.next(this.menuService.activeMenus$.getValue().concat(this));\n }\n }\n\n /** @ignore */\n _handleOnClosed() {\n this.children.forEach((c) => {\n c.close();\n });\n }\n\n /**\n * Returns the icon based on the orientation of the root menu.\n */\n getIcon() {\n if (this.rootMenu.orientation() == 'vertical') {\n return 'ax-icon-arrow-right';\n } else {\n return 'ax-icon-arrow-down';\n }\n }\n\n /**\n * Determines the placement based on the root menu's orientation: 'bottom-start' for horizontal root, 'end-top' otherwise.\n */\n getPlacement() {\n switch (this.rootMenu.orientation()) {\n case 'horizontal':\n if (this.isRoot) {\n return 'bottom-start';\n } else {\n return 'end-top';\n }\n break;\n case 'vertical':\n if (this.isRoot) {\n return 'end-top';\n } else {\n return 'end-top';\n }\n break;\n default:\n return 'bottom-start';\n }\n }\n\n /** @ignore */\n @HostBinding('class')\n get __hostClass(): string[] {\n return [`${this.disabled ? 'ax-state-disabled' : ''}`, `${this.active() ? 'ax-state-active' : ''}`];\n }\n\n /** @ignore */\n @HostListener('click', ['$event'])\n private __hostClick(e: MouseEvent) {\n if (!this.disabled) {\n this.onClick.emit({\n component: this,\n htmlElement: this.getHostElement(),\n nativeEvent: e,\n });\n if (!this.children.length) {\n this.menuService.activeMenus$.subscribe((c) => c.forEach((x) => x.close())).unsubscribe();\n this.menuService.activeMenus$.next([]);\n }\n }\n }\n}\n","<div class=\"ax-menu-item-start-side\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <div class=\"ax-menu-item-text\">{{ text() }}</div>\n</div>\n<ng-content select=\"ax-suffix\"></ng-content>\n@if(children.length){\n<i class=\"ax-icon ax-icon-solid {{ getIcon() }} ax-menu-item-child-icon\"></i>\n}\n<ax-popover #popover [closeOn]=\"'clickOut'\" [openOn]=\"rootMenu.openOn()\" [target]=\"getHostElement()\"\n [offsetY]=\"offsetY()\" [offsetX]=\"offsetX()\" [placement]=\"getPlacement()\" (onOpened)=\"_handleOnOpened()\"\n (onClosed)=\"_handleOnClosed()\">\n <div class=\"ax-menu-item-children ax-parent-{{ this.rootMenu.orientation() }}\">\n <ng-content select=\"ax-menu-item\"></ng-content>\n </div>\n</ax-popover>","import { AXOrientation, MXBaseComponent } from '@acorex/components/common';\nimport { AfterViewInit, Component, ContentChildren, HostBinding, QueryList, ViewEncapsulation, input } from '@angular/core';\nimport { AXMenuPopoverTrigger } from './class/popover.class';\nimport { AXRootMenu } from './class/root-menu.class';\nimport { AXMenuItemComponent } from './menu-item/menu-item.component';\nimport { AXMenuService } from './menu.service';\n\n/**\n * Represents a menu component that displays menu items.\n * @category Components\n */\n@Component({\n selector: 'ax-menu',\n template: `<ng-content select=\"ax-menu-item,ng-container\"></ng-content>`,\n styleUrls: ['./menu.component.scss'],\n encapsulation: ViewEncapsulation.None,\n providers: [\n {\n provide: AXRootMenu,\n useExisting: AXMenuComponent,\n },\n {\n provide: AXMenuService,\n },\n ],\n})\nexport class AXMenuComponent extends MXBaseComponent implements AfterViewInit {\n orientation = input<AXOrientation>('horizontal');\n openOn = input<AXMenuPopoverTrigger>('toggle');\n\n /** @ignore */\n @ContentChildren(AXMenuItemComponent)\n children: QueryList<AXMenuItemComponent>;\n\n /** @ignore */\n ngAfterViewInit() {\n this.children.forEach((c) => {\n c.isRoot = true;\n c.parent = this as unknown as AXMenuItemComponent;\n });\n }\n\n /** @ignore */\n @HostBinding('class')\n get __hostClass(): string {\n return `ax-orientation-${this.orientation()}`;\n }\n}\n","import { AXDecoratorModule } from '@acorex/components/decorators';\nimport { AXLoadingModule } from '@acorex/components/loading';\nimport { AXPopoverModule } from '@acorex/components/popover';\nimport { AXTranslationModule } from '@acorex/core/translation';\nimport { OverlayModule } from '@angular/cdk/overlay';\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { AXMenuItemComponent } from './menu-item/menu-item.component';\nimport { AXMenuComponent } from './menu.component';\n\nconst COMPONENT = [AXMenuItemComponent, AXMenuComponent];\nconst MODULES = [AXDecoratorModule, AXLoadingModule, AXTranslationModule, OverlayModule, AXPopoverModule];\n\n@NgModule({\n declarations: [...COMPONENT],\n imports: [CommonModule, ...MODULES],\n exports: [...COMPONENT],\n providers: [],\n})\nexport class AXMenuModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;MAGa,UAAU,CAAA;AAAvB,IAAA,WAAA,GAAA;AACE,QAAA,IAAA,CAAA,WAAW,GAAkC,MAAM,CAAC,YAAY,CAAC,CAAC;AAClE,QAAA,IAAA,CAAA,MAAM,GAAyC,MAAM,CAAC,QAAQ,CAAC,CAAC;KACjE;AAAA;;MCCY,aAAa,CAAA;AAH1B,IAAA,WAAA,GAAA;AAIE,QAAA,IAAA,CAAA,YAAY,GAA2C,IAAI,eAAe,CAAwB,EAAE,CAAC,CAAC;AACvG,KAAA;8GAFY,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;AAAb,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cAFZ,MAAM,EAAA,CAAA,CAAA,EAAA;;2FAEP,aAAa,EAAA,UAAA,EAAA,CAAA;kBAHzB,UAAU;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ib/class/root-menu.class.ts","../../../../libs/components/menu/src/lib/menu.service.ts","../../../../libs/components/menu/src/lib/menu-item/menu-item.component.ts","../../../../libs/components/menu/src/lib/menu-item/menu-item.component.html","../../../../libs/components/menu/src/lib/menu.component.ts","../../../../libs/components/menu/src/lib/menu.module.ts","../../../../libs/components/menu/src/acorex-components-menu.ts"],"sourcesContent":["import { AXOrientation } from '@acorex/components/common';\nimport { WritableSignal, signal } from '@angular/core';\nimport { AXMenuPopoverTrigger } from './popover.class';\nexport class AXRootMenu {\n orientation: WritableSignal<AXOrientation> = signal('horizontal');\n openOn: WritableSignal<AXMenuPopoverTrigger> = signal('toggle');\n}\n","import { Injectable, signal } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\nimport { AXMenuItemComponent } from './menu-item/menu-item.component';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXMenuService {\n activeMenus$: BehaviorSubject<AXMenuItemComponent[]> = new BehaviorSubject<AXMenuItemComponent[]>([]);\n\n rightOverflow = signal<number>(0);\n leftOverflow = signal<number>(0);\n overflowElements = signal<HTMLElement[]>([]);\n notOverflowElements = signal<HTMLElement[]>([]);\n}\n","import { AXClickEvent, MXInteractiveComponent } from '@acorex/components/common';\nimport { AXPopoverComponent } from '@acorex/components/popover';\nimport {\n Component,\n ContentChildren,\n HostBinding,\n HostListener,\n QueryList,\n ViewChild,\n ViewEncapsulation,\n afterNextRender,\n effect,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { AXRootMenu } from '../class/root-menu.class';\nimport { AXMenuService } from '../menu.service';\n\n/**\n * Represents a menu item component used within an `ax-menu`.\n * @category Components\n */\n@Component({\n selector: 'ax-menu-item',\n inputs: ['disabled'],\n templateUrl: './menu-item.component.html',\n host: { ngSkipHydration: 'true' },\n styles: `\n .ax-menu-item-text {\n white-space: nowrap;\n }\n `,\n encapsulation: ViewEncapsulation.None,\n})\nexport class AXMenuItemComponent extends MXInteractiveComponent {\n service = inject(AXMenuService);\n\n /** @ignore */\n @ViewChild(AXPopoverComponent)\n\n /** @ignore */\n private popover: AXPopoverComponent;\n\n /**\n * Injects the `AXMenuService` for managing menu interactions.\n */\n menuService = inject(AXMenuService);\n\n /**\n * The vertical offset for positioning, initialized to 0.\n */\n offsetY = signal(0);\n\n /**\n * The horizontal offset for positioning, initialized to 0.\n */\n offsetX = signal(0);\n\n /**\n * The text content, initialized to an empty string.\n */\n text = input<string>();\n\n /**\n * Indicates whether the item is active.\n */\n active = input<boolean>();\n\n /**\n * Emitted when the active state changes.\n */\n activeChange = output<boolean>();\n\n /**\n * Emitted when the element is clicked.\n */\n onClick = output<AXClickEvent>();\n\n /**\n * Indicates whether the component is a root menu item.\n * @defaultValue false\n */\n isRoot = false;\n\n /**\n * The parent menu item component, if any.\n */\n parent?: AXMenuItemComponent;\n\n /**\n * Injects the root menu service.\n */\n rootMenu = inject(AXRootMenu);\n\n /** @ignore */\n @ContentChildren(AXMenuItemComponent)\n children: QueryList<AXMenuItemComponent>;\n\n /** @ignore */\n constructor() {\n super();\n\n afterNextRender(() => {\n this.children.forEach((c) => {\n c.parent = this;\n });\n\n this.offsetY.set(this.isRoot ? 8 : 0);\n this.offsetX.set(this.isRoot ? 0 : 4);\n\n this.getPlacement();\n });\n\n effect(\n () => {\n if (!this.getHostElement().getClientRects()[0]?.right) return;\n //add overflow items to array\n if (\n this.getHostElement().getClientRects()[0]?.right > this.service.rightOverflow() ||\n this.getHostElement().getClientRects()[0]?.left < this.service.leftOverflow()\n ) {\n this.service.overflowElements.update((prev) => [...prev, this.getHostElement()]);\n } else {\n this.service.notOverflowElements.update((prev) => [...prev, this.getHostElement()]);\n }\n },\n { allowSignalWrites: true },\n );\n }\n\n /**\n * Closes the popover if it is open.\n */\n close() {\n this.popover?.close();\n }\n\n /** @ignore */\n _handleOnOpened() {\n this.parent.children.forEach((c) => {\n if (c != this) {\n c.close();\n }\n });\n if (this.children.length) {\n this.menuService.activeMenus$.next(this.menuService.activeMenus$.getValue().concat(this));\n }\n }\n\n /** @ignore */\n _handleOnClosed() {\n this.children.forEach((c) => {\n c.close();\n });\n }\n\n /**\n * Returns the icon based on the orientation of the root menu.\n */\n getIcon() {\n if (this.rootMenu.orientation() == 'vertical') {\n return 'ax-icon-arrow-right';\n } else {\n return 'ax-icon-arrow-down';\n }\n }\n\n /**\n * Determines the placement based on the root menu's orientation: 'bottom-start' for horizontal root, 'end-top' otherwise.\n */\n getPlacement() {\n switch (this.rootMenu.orientation()) {\n case 'horizontal':\n if (this.isRoot) {\n return 'bottom-start';\n } else {\n return 'end-top';\n }\n break;\n case 'vertical':\n if (this.isRoot) {\n return 'end-top';\n } else {\n return 'end-top';\n }\n break;\n default:\n return 'bottom-start';\n }\n }\n\n /** @ignore */\n @HostBinding('class')\n get __hostClass(): string[] {\n return [`${this.disabled ? 'ax-state-disabled' : ''}`, `${this.active() ? 'ax-state-active' : ''}`];\n }\n\n /** @ignore */\n @HostListener('click', ['$event'])\n private __hostClick(e: MouseEvent) {\n if (!this.disabled) {\n this.onClick.emit({\n component: this,\n htmlElement: this.getHostElement(),\n nativeEvent: e,\n });\n if (!this.children.length) {\n this.menuService.activeMenus$.subscribe((c) => c.forEach((x) => x.close())).unsubscribe();\n this.menuService.activeMenus$.next([]);\n }\n }\n }\n}\n","<div class=\"ax-menu-item-start-side\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <p class=\"ax-menu-item-text\">{{ text() }}</p>\n</div>\n<ng-content select=\"ax-suffix\"></ng-content>\n@if (children.length) {\n <i class=\"ax-icon ax-icon-solid {{ getIcon() }} ax-menu-item-child-icon\"></i>\n}\n\n<ax-popover\n #popover\n [closeOn]=\"'clickOut'\"\n [openOn]=\"rootMenu.openOn()\"\n [target]=\"getHostElement()\"\n [offsetY]=\"offsetY()\"\n [offsetX]=\"offsetX()\"\n [placement]=\"getPlacement()\"\n (onOpened)=\"_handleOnOpened()\"\n (onClosed)=\"_handleOnClosed()\"\n>\n <div class=\"ax-menu-item-children ax-parent-{{ this.rootMenu.orientation() }}\">\n <ng-content select=\"ax-menu-item\"></ng-content>\n </div>\n</ax-popover>\n","import { AXOrientation, MXBaseComponent } from '@acorex/components/common';\nimport {\n afterNextRender,\n AfterViewInit,\n Component,\n ContentChildren,\n effect,\n HostBinding,\n inject,\n input,\n QueryList,\n signal,\n ViewEncapsulation,\n} from '@angular/core';\nimport { AXMenuPopoverTrigger } from './class/popover.class';\nimport { AXRootMenu } from './class/root-menu.class';\nimport { AXMenuItemComponent } from './menu-item/menu-item.component';\nimport { AXMenuService } from './menu.service';\n\n/**\n * Represents a menu component that displays menu items.\n * @category Components\n */\n@Component({\n selector: 'ax-menu',\n template: `\n <div class=\"ax-main-menu-container\">\n <div\n [style]=\"{ width: this.service.overflowElements().length !== 0 ? '90%' : '100%' }\"\n class=\"ax-menu-item-container\"\n >\n <ng-content select=\"ax-menu-item,ng-container\"></ng-content>\n </div>\n @if (this.service.overflowElements().length !== 0) {\n <div class=\"ax-show-truncate-menu\">\n <button (click)=\"showMenuHandler()\" tabindex=\"0\" type=\"button\">\n <ax-icon class=\"ax-icon ax-icon-more-horizontal ng-star-inserted ax-text-xl\"></ax-icon>\n </button>\n </div>\n }\n </div>\n\n @if (this.service.overflowElements().length !== 0) {\n <div [style]=\"{ top: menuHeight() }\" class=\"ax-overflow-menu-container ax-menu-item-children\"></div>\n }\n `,\n styleUrls: ['./menu.component.scss'],\n encapsulation: ViewEncapsulation.None,\n providers: [\n {\n provide: AXRootMenu,\n useExisting: AXMenuComponent,\n },\n {\n provide: AXMenuService,\n },\n ],\n})\nexport class AXMenuComponent extends MXBaseComponent implements AfterViewInit {\n orientation = input<AXOrientation>('horizontal');\n openOn = input<AXMenuPopoverTrigger>('toggle');\n service = inject(AXMenuService);\n menuHeight = signal<string>('');\n isMenuOpen = signal(false);\n\n /** @ignore */\n @ContentChildren(AXMenuItemComponent)\n children: QueryList<AXMenuItemComponent>;\n\n constructor() {\n super();\n\n afterNextRender(() => {\n //add menu container border for detect overflow happen\n this.menuHeight.set(`${this.getHostElement()?.getClientRects()[0]?.height}px`);\n this.service.rightOverflow.set(\n this.getHostElement().querySelector('.ax-menu-item-container')?.getClientRects()[0]?.right,\n );\n this.service.leftOverflow.set(\n this.getHostElement().querySelector('.ax-menu-item-container')?.getClientRects()[0]?.left,\n );\n });\n\n let resizeTimer;\n\n window.addEventListener('resize', () => {\n //add menu container border for detect overflow happen\n clearTimeout(resizeTimer);\n if (!this.getHostElement()) return;\n resizeTimer = setTimeout(() => {\n this.service.rightOverflow.set(\n this.getHostElement().querySelector('.ax-menu-item-container').getClientRects()[0].right,\n );\n this.service.leftOverflow.set(\n this.getHostElement().querySelector('.ax-menu-item-container').getClientRects()[0].left,\n );\n this.service.notOverflowElements.set([]);\n this.service.overflowElements.set([]);\n this.isMenuOpen.set(false);\n }, 200);\n });\n\n effect(() => {\n //rearrange items base on menu state\n const overflowMenu = this.getHostElement().querySelector('.overflowMenu');\n const originalMenu = this.getHostElement().querySelector('.originalMenu');\n const injectContainer = this.getHostElement().querySelector('.ax-overflow-menu-container');\n const injectContainer2 = this.getHostElement().querySelector('.ax-menu-item-container');\n\n if (this.isMenuOpen()) {\n overflowMenu?.remove();\n const axMenu = document.createElement('ax-menu');\n axMenu.classList.add('overflowMenu');\n this.service.overflowElements().forEach((item) => {\n axMenu.appendChild(item);\n });\n injectContainer.appendChild(axMenu);\n } else {\n originalMenu?.remove();\n overflowMenu?.remove();\n const axMenu = document.createElement('ax-menu');\n axMenu.classList.add('originalMenu');\n const allItems = [...this.service.overflowElements(), ...this.service.notOverflowElements()];\n allItems.forEach((item) => {\n axMenu.appendChild(item);\n });\n\n injectContainer2.appendChild(axMenu);\n }\n });\n }\n\n showMenuHandler() {\n this.isMenuOpen.update((prev) => !prev);\n }\n\n /** @ignore */\n ngAfterViewInit() {\n this.children.forEach((c) => {\n c.isRoot = true;\n c.parent = this as unknown as AXMenuItemComponent;\n });\n }\n\n /** @ignore */\n @HostBinding('class')\n get __hostClass(): string {\n return `ax-orientation-${this.orientation()} main-menu`;\n }\n}\n","import { AXButtonModule } from '@acorex/components/button';\nimport { AXDecoratorModule } from '@acorex/components/decorators';\nimport { AXLoadingModule } from '@acorex/components/loading';\nimport { AXPopoverModule } from '@acorex/components/popover';\nimport { AXTranslationModule } from '@acorex/core/translation';\nimport { OverlayModule } from '@angular/cdk/overlay';\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { AXMenuItemComponent } from './menu-item/menu-item.component';\nimport { AXMenuComponent } from './menu.component';\n\nconst COMPONENT = [AXMenuItemComponent, AXMenuComponent];\nconst MODULES = [AXDecoratorModule, AXLoadingModule, AXTranslationModule, OverlayModule, AXPopoverModule];\n\n@NgModule({\n declarations: [...COMPONENT],\n imports: [CommonModule, ...MODULES, AXButtonModule],\n exports: [...COMPONENT],\n providers: [],\n})\nexport class AXMenuModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;;;;;;MAGa,UAAU,CAAA;AAAvB,IAAA,WAAA,GAAA;AACE,QAAA,IAAA,CAAA,WAAW,GAAkC,MAAM,CAAC,YAAY,CAAC,CAAC;AAClE,QAAA,IAAA,CAAA,MAAM,GAAyC,MAAM,CAAC,QAAQ,CAAC,CAAC;KACjE;AAAA;;MCCY,aAAa,CAAA;AAH1B,IAAA,WAAA,GAAA;AAIE,QAAA,IAAA,CAAA,YAAY,GAA2C,IAAI,eAAe,CAAwB,EAAE,CAAC,CAAC;AAEtG,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAS,CAAC,CAAC,CAAC;AAClC,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAS,CAAC,CAAC,CAAC;AACjC,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAgB,EAAE,CAAC,CAAC;AAC7C,QAAA,IAAA,CAAA,mBAAmB,GAAG,MAAM,CAAgB,EAAE,CAAC,CAAC;AACjD,KAAA;8GAPY,aAAa,EAAA,IAAA,EAAA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GAAG,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,CAAC,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;MAQ7F,YAAY,CAAA;8GAAZ,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA,EAAA;+GAAZ,YAAY,EAAA,YAAA,EAAA,CATN,mBAAmB,EAAE,eAAe,aAK3C,YAAY,EAJP,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,eAAe,EAIlE,cAAc,CAAA,EAAA,OAAA,EAAA,CALjC,mBAAmB,EAAE,eAAe,CAAA,EAAA,CAAA,CAAA,EAAA;AAS1C,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,EAJb,OAAA,EAAA,CAAA,YAAY,EAAK,OAAO,EAAE,cAAc,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAIvC,YAAY,EAAA,UAAA,EAAA,CAAA;kBANxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;oBAC5B,OAAO,EAAE,CAAC,YAAY,EAAE,GAAG,OAAO,EAAE,cAAc,CAAC;AACnD,oBAAA,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC;AACvB,oBAAA,SAAS,EAAE,EAAE;AACd,iBAAA,CAAA;;;ACnBD;;AAEG;;;;"}
@@ -1,18 +1,16 @@
1
+ import { generateQRCode } from '@acorex/cdk/qrcode';
1
2
  import { AXValuableComponent } from '@acorex/components/common';
2
3
  import * as i0 from '@angular/core';
3
- import { input, signal, viewChild, effect, forwardRef, Component, ViewEncapsulation, ChangeDetectionStrategy, NgModule } from '@angular/core';
4
+ import { input, signal, viewChild, computed, effect, forwardRef, Component, ViewEncapsulation, ChangeDetectionStrategy, NgModule } from '@angular/core';
4
5
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
5
- import QRCode from 'qrcode';
6
6
  import { CommonModule } from '@angular/common';
7
7
 
8
8
  function debounce(func, delay) {
9
9
  let timeoutId;
10
10
  return function (...args) {
11
- // Clear the existing timeout if there is one
12
11
  if (timeoutId) {
13
12
  clearTimeout(timeoutId);
14
13
  }
15
- // Set a new timeout
16
14
  timeoutId = setTimeout(() => {
17
15
  func(...args);
18
16
  }, delay);
@@ -20,9 +18,6 @@ function debounce(func, delay) {
20
18
  }
21
19
 
22
20
  class AXQrcodeComponent {
23
- /**
24
- * @ignore
25
- */
26
21
  constructor() {
27
22
  /**
28
23
  * @description Value of QR code
@@ -68,58 +63,40 @@ class AXQrcodeComponent {
68
63
  * @ignore
69
64
  */
70
65
  this.svg = viewChild('svg');
66
+ /**
67
+ * @ignore
68
+ */
69
+ this.calculateLogoSize = computed(() => {
70
+ switch (this.level()) {
71
+ case 'L':
72
+ return Math.sqrt((5 / 100) * (this.size() * this.size()));
73
+ case 'M':
74
+ return Math.sqrt((8 / 100) * (this.size() * this.size()));
75
+ case 'Q':
76
+ return Math.sqrt((11 / 100) * (this.size() * this.size()));
77
+ case 'H':
78
+ return Math.sqrt((14 / 100) * (this.size() * this.size()));
79
+ }
80
+ });
71
81
  effect(() => {
72
- this.generateQRCode();
82
+ this.generate();
73
83
  }, {
74
84
  allowSignalWrites: true,
75
85
  });
76
86
  }
77
- // ngOnChanges(): void {
78
- // const debunce = debounce(this.generateQRCode, 500);
79
- // debunce();
80
- // }
81
87
  ngAfterViewInit() {
82
- this.generateQRCode();
88
+ this.generate();
83
89
  }
84
- generateQRCode() {
85
- if (!this.content())
86
- return;
87
- const options = {
88
- margin: 0,
89
- width: this.size(),
90
- errorCorrectionLevel: this.level(),
91
- color: {
92
- dark: this.color(),
93
- light: this.backgroundColor(),
94
- },
95
- };
96
- if (this.outputType() === 'canvas') {
97
- QRCode.toCanvas(this.canvas().nativeElement, this.content(), options, (error) => {
98
- if (error) {
99
- console.error(error);
100
- }
101
- });
102
- }
103
- else if (this.outputType() === 'svg') {
104
- QRCode.toString(this.content(), { ...options, type: 'svg' }, (error, svgString) => {
105
- if (error) {
106
- console.error(error);
107
- }
108
- else {
109
- this.svg().nativeElement.innerHTML = svgString;
110
- }
111
- });
112
- }
113
- else {
114
- QRCode.toDataURL(this.content(), options, (error, url) => {
115
- if (error) {
116
- console.error(error);
117
- }
118
- else {
119
- this.qrCodeUrl.set(url);
120
- }
121
- });
122
- }
90
+ generate() {
91
+ generateQRCode(this.content(), this.size(), this.level(), this.color(), this.backgroundColor(), this.outputType(), this.canvas()?.nativeElement, this.svg()?.nativeElement)
92
+ .then((result) => {
93
+ if (this.outputType() === 'url') {
94
+ this.qrCodeUrl.set(result);
95
+ }
96
+ })
97
+ .catch((error) => {
98
+ console.error(error);
99
+ });
123
100
  }
124
101
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXQrcodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
125
102
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: AXQrcodeComponent, selector: "ax-qrcode", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, level: { classPropertyName: "level", publicName: "level", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, backgroundColor: { classPropertyName: "backgroundColor", publicName: "backgroundColor", isSignal: true, isRequired: false, transformFunction: null }, outputType: { classPropertyName: "outputType", publicName: "outputType", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
@@ -129,7 +106,7 @@ class AXQrcodeComponent {
129
106
  useExisting: forwardRef(() => AXQrcodeComponent),
130
107
  multi: true,
131
108
  },
132
- ], viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }, { propertyName: "svg", first: true, predicate: ["svg"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"qrcode\"></div>\n@if (outputType() === 'canvas') {\n <canvas #canvas></canvas>\n} @else if (outputType() === 'svg') {\n <div #svg></div>\n} @else {\n <img [src]=\"qrCodeUrl()\" alt=\"QR Code\" #img />\n}\n", styles: [".qrcode{width:fit-content;height:fit-content;border:1px solid black}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
109
+ ], viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }, { propertyName: "svg", first: true, predicate: ["svg"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"qrcode\">\n @if (outputType() === 'canvas') {\n <canvas #canvas></canvas>\n } @else if (outputType() === 'svg') {\n <div #svg></div>\n } @else {\n <img [src]=\"qrCodeUrl()\" alt=\"QR Code\" />\n }\n <div class=\"logo-container\" [style.width.px]=\"calculateLogoSize()\" [style.height.px]=\"calculateLogoSize()\">\n <ng-content select=\"img\"></ng-content>\n </div>\n</div>\n", styles: [".qrcode{position:relative}.qrcode .logo-container{position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:50%;transform:translate(-50%,-50%)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
133
110
  }
134
111
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXQrcodeComponent, decorators: [{
135
112
  type: Component,
@@ -140,7 +117,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
140
117
  useExisting: forwardRef(() => AXQrcodeComponent),
141
118
  multi: true,
142
119
  },
143
- ], template: "<div class=\"qrcode\"></div>\n@if (outputType() === 'canvas') {\n <canvas #canvas></canvas>\n} @else if (outputType() === 'svg') {\n <div #svg></div>\n} @else {\n <img [src]=\"qrCodeUrl()\" alt=\"QR Code\" #img />\n}\n", styles: [".qrcode{width:fit-content;height:fit-content;border:1px solid black}\n"] }]
120
+ ], template: "<div class=\"qrcode\">\n @if (outputType() === 'canvas') {\n <canvas #canvas></canvas>\n } @else if (outputType() === 'svg') {\n <div #svg></div>\n } @else {\n <img [src]=\"qrCodeUrl()\" alt=\"QR Code\" />\n }\n <div class=\"logo-container\" [style.width.px]=\"calculateLogoSize()\" [style.height.px]=\"calculateLogoSize()\">\n <ng-content select=\"img\"></ng-content>\n </div>\n</div>\n", styles: [".qrcode{position:relative}.qrcode .logo-container{position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:50%;transform:translate(-50%,-50%)}\n"] }]
144
121
  }], ctorParameters: () => [] });
145
122
 
146
123
  class QrcodeModule {