@fuentis/phoenix-ui 0.0.9-alpha.407 → 0.0.9-alpha.409

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.
@@ -7,7 +7,7 @@ import { TooltipModule } from 'primeng/tooltip';
7
7
  import * as i2 from 'primeng/button';
8
8
  import { ButtonModule } from 'primeng/button';
9
9
  import * as i1 from '@angular/router';
10
- import { RouterLink, RouterLinkActive, RouterModule, Router, NavigationEnd } from '@angular/router';
10
+ import { NavigationEnd, RouterLink, RouterLinkActive, RouterModule, Router } from '@angular/router';
11
11
  import * as i2$1 from '@ngx-translate/core';
12
12
  import { TranslateModule, TranslateService } from '@ngx-translate/core';
13
13
  import * as i8 from 'primeng/tag';
@@ -16,6 +16,7 @@ import * as i7 from 'primeng/menu';
16
16
  import { MenuModule } from 'primeng/menu';
17
17
  import * as i9 from 'primeng/divider';
18
18
  import { DividerModule } from 'primeng/divider';
19
+ import { filter } from 'rxjs/operators';
19
20
  import * as i3$1 from 'primeng/api';
20
21
  import { MessageService, FilterMatchMode } from 'primeng/api';
21
22
  import * as i4 from 'primeng/accordion';
@@ -126,28 +127,67 @@ class SidebarItemComponent {
126
127
  item;
127
128
  classname = '';
128
129
  sliderClick = new EventEmitter();
130
+ active = false;
131
+ constructor(router) {
132
+ this.router = router;
133
+ }
134
+ ngOnInit() {
135
+ this.updateActive();
136
+ this.router.events
137
+ .pipe(filter((e) => e instanceof NavigationEnd))
138
+ .subscribe(() => this.updateActive());
139
+ }
140
+ ngOnChanges(_) {
141
+ this.updateActive();
142
+ }
143
+ updateActive() {
144
+ if (!this.item) {
145
+ this.active = false;
146
+ return;
147
+ }
148
+ let url = this.router.url.split('?')[0];
149
+ const hashIdx = url.indexOf('#');
150
+ if (hashIdx >= 0) {
151
+ url = url.substring(hashIdx + 1) || '/';
152
+ }
153
+ if (url.length > 1 && url.endsWith('/')) {
154
+ url = url.slice(0, -1);
155
+ }
156
+ const basePath = (this.item.basePath || this.item.basepath);
157
+ const path = this.item.path;
158
+ const matchPath = (p) => {
159
+ if (p.length > 1 && p.endsWith('/'))
160
+ p = p.slice(0, -1);
161
+ return url === p || url.startsWith(p + '/');
162
+ };
163
+ if (basePath && typeof basePath === 'string') {
164
+ this.active = matchPath(basePath);
165
+ }
166
+ else if (path && typeof path === 'string') {
167
+ this.active = matchPath(path);
168
+ }
169
+ else {
170
+ this.active = false;
171
+ }
172
+ }
129
173
  onSliderClick($event, menu) {
130
174
  $event.stopPropagation();
131
175
  $event.preventDefault();
132
176
  menu.toggle($event);
133
177
  }
134
178
  onSliderItemsClick(event) {
135
- console.log(event);
136
179
  this.sliderClick.emit(event);
137
180
  }
138
- constructor(router) {
139
- this.router = router;
140
- }
141
- ngOnChanges(changes) { }
142
181
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SidebarItemComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
143
182
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: SidebarItemComponent, isStandalone: true, selector: "pho-sidebar-item", inputs: { item: "item", classname: "classname" }, outputs: { sliderClick: "sliderClick" }, usesOnChanges: true, ngImport: i0, template: `
144
183
  @if(item.path === '/dashboard'){
145
184
  <li class="list-none flex align-items-center border-bottom-1 border-200">
146
185
  <a
147
- class="p-button no-underline w-full justify-content-between surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
186
+ class="p-button no-underline w-full justify-content-between surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
148
187
  [attr.data-cy]="'navigation-side-navigation-item-' + item.label"
149
188
  [routerLink]="item?.disabled ? null : item.path"
150
189
  routerLinkActive="active-link"
190
+ [class.active-link]="active"
151
191
  [ngClass]="[
152
192
  classname,
153
193
  item?.disabled ? 'opacity-50 cursor-not-allowed' : ''
@@ -170,6 +210,7 @@ class SidebarItemComponent {
170
210
  [disabled]="item.disabledConfig"
171
211
  />
172
212
  </a>
213
+
173
214
  <p-menu
174
215
  styleClass="w-20rem"
175
216
  appendTo="body"
@@ -182,6 +223,7 @@ class SidebarItemComponent {
182
223
  item.label | translate
183
224
  }}</span>
184
225
  </ng-template>
226
+
185
227
  <ng-template pTemplate="item" let-item>
186
228
  <a
187
229
  (click)="onSliderItemsClick(item)"
@@ -191,14 +233,10 @@ class SidebarItemComponent {
191
233
  >
192
234
  <div class="flex justify-content-between w-full">
193
235
  <div>
194
- @if(item.icon){
195
- <i [class]="item.icon"> </i>
196
- }
236
+ @if(item.icon){ <i [class]="item.icon"></i> }
197
237
  <span class="ml-2">{{ item.title | translate }}</span>
198
238
  </div>
199
- @if(item.activated){
200
- <i class=" pi pi-check"></i>
201
- }
239
+ @if(item.activated){ <i class="pi pi-check"></i> }
202
240
  </div>
203
241
  </a>
204
242
  </ng-template>
@@ -218,41 +256,29 @@ class SidebarItemComponent {
218
256
  </li>
219
257
 
220
258
  } @else {
221
- <li
222
- class="list-none flex align-items-center "
223
- [pTooltip]="item?.tooltip | translate"
224
- >
259
+ <li class="list-none flex align-items-center " [pTooltip]="item?.tooltip | translate">
225
260
  <a
226
261
  [attr.data-cy]="'navigation-side-navigation-item-' + item.label"
227
262
  [routerLink]="item?.disabled ? null : item.path"
228
263
  routerLinkActive="active-link"
264
+ [class.active-link]="active"
229
265
  [ngClass]="[
230
266
  classname,
231
267
  item?.disabled ? 'opacity-50 cursor-not-allowed' : ''
232
268
  ]"
233
- class="p-button no-underline w-full justify-content-start surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
269
+ class="p-button no-underline w-full justify-content-start surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
234
270
  [style.pointer-events]="item?.disabled ? 'none' : 'auto'"
235
271
  >
236
- <div
237
- class="flex justify-content-between w-full "
238
- style="margin-left: 24px; "
239
- >
272
+ <div class="flex justify-content-between w-full" style="margin-left: 24px;">
240
273
  <span style="font-size:13px" class="text-primary white-space-nowrap">
241
- {{ item.label | translate }}</span
242
- >
274
+ {{ item.label | translate }}
275
+ </span>
276
+
243
277
  @if(item.tag){
244
- <p-tag
245
- [style]="{ fontSize: '9px', padding: '2px 6px' }"
246
- severity="danger"
247
- [value]="item.tag"
248
- />
249
- } @if(item.lock){
250
- <p-tag
251
- [style]="{ fontSize: '9px', paddingRight: '3px' }"
252
- severity="warn"
253
- icon="pi pi-lock
254
- "
255
- />
278
+ <p-tag [style]="{ fontSize: '9px', padding: '2px 6px' }" severity="danger" [value]="item.tag" />
279
+ }
280
+ @if(item.lock){
281
+ <p-tag [style]="{ fontSize: '9px', paddingRight: '3px' }" severity="warn" icon="pi pi-lock" />
256
282
  }
257
283
  </div>
258
284
  </a>
@@ -262,7 +288,7 @@ class SidebarItemComponent {
262
288
  }
263
289
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: SidebarItemComponent, decorators: [{
264
290
  type: Component,
265
- args: [{ selector: 'pho-sidebar-item', standalone: true, imports: [
291
+ args: [{ selector: 'pho-sidebar-item', standalone: true, encapsulation: ViewEncapsulation.None, imports: [
266
292
  CommonModule,
267
293
  ButtonModule,
268
294
  RouterLink,
@@ -272,14 +298,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
272
298
  MenuModule,
273
299
  TagModule,
274
300
  DividerModule,
275
- ], encapsulation: ViewEncapsulation.None, template: `
301
+ ], template: `
276
302
  @if(item.path === '/dashboard'){
277
303
  <li class="list-none flex align-items-center border-bottom-1 border-200">
278
304
  <a
279
- class="p-button no-underline w-full justify-content-between surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
305
+ class="p-button no-underline w-full justify-content-between surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
280
306
  [attr.data-cy]="'navigation-side-navigation-item-' + item.label"
281
307
  [routerLink]="item?.disabled ? null : item.path"
282
308
  routerLinkActive="active-link"
309
+ [class.active-link]="active"
283
310
  [ngClass]="[
284
311
  classname,
285
312
  item?.disabled ? 'opacity-50 cursor-not-allowed' : ''
@@ -302,6 +329,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
302
329
  [disabled]="item.disabledConfig"
303
330
  />
304
331
  </a>
332
+
305
333
  <p-menu
306
334
  styleClass="w-20rem"
307
335
  appendTo="body"
@@ -314,6 +342,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
314
342
  item.label | translate
315
343
  }}</span>
316
344
  </ng-template>
345
+
317
346
  <ng-template pTemplate="item" let-item>
318
347
  <a
319
348
  (click)="onSliderItemsClick(item)"
@@ -323,14 +352,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
323
352
  >
324
353
  <div class="flex justify-content-between w-full">
325
354
  <div>
326
- @if(item.icon){
327
- <i [class]="item.icon"> </i>
328
- }
355
+ @if(item.icon){ <i [class]="item.icon"></i> }
329
356
  <span class="ml-2">{{ item.title | translate }}</span>
330
357
  </div>
331
- @if(item.activated){
332
- <i class=" pi pi-check"></i>
333
- }
358
+ @if(item.activated){ <i class="pi pi-check"></i> }
334
359
  </div>
335
360
  </a>
336
361
  </ng-template>
@@ -350,41 +375,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
350
375
  </li>
351
376
 
352
377
  } @else {
353
- <li
354
- class="list-none flex align-items-center "
355
- [pTooltip]="item?.tooltip | translate"
356
- >
378
+ <li class="list-none flex align-items-center " [pTooltip]="item?.tooltip | translate">
357
379
  <a
358
380
  [attr.data-cy]="'navigation-side-navigation-item-' + item.label"
359
381
  [routerLink]="item?.disabled ? null : item.path"
360
382
  routerLinkActive="active-link"
383
+ [class.active-link]="active"
361
384
  [ngClass]="[
362
385
  classname,
363
386
  item?.disabled ? 'opacity-50 cursor-not-allowed' : ''
364
387
  ]"
365
- class="p-button no-underline w-full justify-content-start surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
388
+ class="p-button no-underline w-full justify-content-start surface-0 hover:surface-100 border-none overflow-hidden bg-transparent sidebaritem"
366
389
  [style.pointer-events]="item?.disabled ? 'none' : 'auto'"
367
390
  >
368
- <div
369
- class="flex justify-content-between w-full "
370
- style="margin-left: 24px; "
371
- >
391
+ <div class="flex justify-content-between w-full" style="margin-left: 24px;">
372
392
  <span style="font-size:13px" class="text-primary white-space-nowrap">
373
- {{ item.label | translate }}</span
374
- >
393
+ {{ item.label | translate }}
394
+ </span>
395
+
375
396
  @if(item.tag){
376
- <p-tag
377
- [style]="{ fontSize: '9px', padding: '2px 6px' }"
378
- severity="danger"
379
- [value]="item.tag"
380
- />
381
- } @if(item.lock){
382
- <p-tag
383
- [style]="{ fontSize: '9px', paddingRight: '3px' }"
384
- severity="warn"
385
- icon="pi pi-lock
386
- "
387
- />
397
+ <p-tag [style]="{ fontSize: '9px', padding: '2px 6px' }" severity="danger" [value]="item.tag" />
398
+ }
399
+ @if(item.lock){
400
+ <p-tag [style]="{ fontSize: '9px', paddingRight: '3px' }" severity="warn" icon="pi pi-lock" />
388
401
  }
389
402
  </div>
390
403
  </a>