@kris701/ez-ui 1.3.18 → 1.4.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.
@@ -378,6 +378,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
378
378
 
379
379
  class EzUIDialog {
380
380
  layoutService;
381
+ header;
381
382
  content;
382
383
  size = 'm';
383
384
  title = '';
@@ -393,11 +394,16 @@ class EzUIDialog {
393
394
  this.layoutService = layoutService;
394
395
  }
395
396
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: EzUIDialog, deps: [{ token: EzUILayoutService }], target: i0.ɵɵFactoryTarget.Component });
396
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: EzUIDialog, isStandalone: true, selector: "ezui-dialog", inputs: { size: "size", title: "title", isLoading: "isLoading", showDialog: "showDialog", showSave: "showSave", showDelete: "showDelete" }, outputs: { onSaveItem: "onSaveItem", onDeleteItem: "onDeleteItem" }, queries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true }], ngImport: i0, template: `
397
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: EzUIDialog, isStandalone: true, selector: "ezui-dialog", inputs: { size: "size", title: "title", isLoading: "isLoading", showDialog: "showDialog", showSave: "showSave", showDelete: "showDelete" }, outputs: { onSaveItem: "onSaveItem", onDeleteItem: "onDeleteItem" }, queries: [{ propertyName: "header", first: true, predicate: ["header"], descendants: true }, { propertyName: "content", first: true, predicate: ["content"], descendants: true }], ngImport: i0, template: `
397
398
  <ng-template let-id="id" [tuiDialogOptions]="{size: size, appearance: layoutService.isDesktop() ? 'taiga compact' : 'fullscreen'}" [(tuiDialog)]="showDialog">
398
399
  <header tuiHeader>
399
400
  <hgroup tuiTitle>
401
+ @if(header){
402
+ <ng-container [ngTemplateOutlet]="header"></ng-container>
403
+ }
404
+ @else {
400
405
  <h2 [id]="id">{{title}}</h2>
406
+ }
401
407
  </hgroup>
402
408
  </header>
403
409
 
@@ -432,7 +438,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
432
438
  <ng-template let-id="id" [tuiDialogOptions]="{size: size, appearance: layoutService.isDesktop() ? 'taiga compact' : 'fullscreen'}" [(tuiDialog)]="showDialog">
433
439
  <header tuiHeader>
434
440
  <hgroup tuiTitle>
441
+ @if(header){
442
+ <ng-container [ngTemplateOutlet]="header"></ng-container>
443
+ }
444
+ @else {
435
445
  <h2 [id]="id">{{title}}</h2>
446
+ }
436
447
  </hgroup>
437
448
  </header>
438
449
 
@@ -452,7 +463,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
452
463
  }
453
464
  </ng-template>
454
465
  `, styles: [".dialog-footer{display:flex!important;flex-direction:row!important;gap:5px!important;margin-top:auto!important;margin-block-start:auto!important}\n"] }]
455
- }], ctorParameters: () => [{ type: EzUILayoutService }], propDecorators: { content: [{
466
+ }], ctorParameters: () => [{ type: EzUILayoutService }], propDecorators: { header: [{
467
+ type: ContentChild,
468
+ args: ['header', { static: false }]
469
+ }], content: [{
456
470
  type: ContentChild,
457
471
  args: ['content', { static: false }]
458
472
  }], size: [{
@@ -6875,6 +6889,7 @@ class EzUISideBarItem {
6875
6889
  tuiAsideItem
6876
6890
  tuiChevron
6877
6891
  type="button"
6892
+ (click)="item.expanded = !item.expanded;onItemClick.emit()"
6878
6893
  >
6879
6894
  {{item.label}}
6880
6895
 
@@ -6917,6 +6932,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
6917
6932
  tuiAsideItem
6918
6933
  tuiChevron
6919
6934
  type="button"
6935
+ (click)="item.expanded = !item.expanded;onItemClick.emit()"
6920
6936
  >
6921
6937
  {{item.label}}
6922
6938
 
@@ -7016,6 +7032,7 @@ class EzUISideBar {
7016
7032
  ...(ngDevMode ? [{ debugName: "haveMoved" }] : /* istanbul ignore next */ []));
7017
7033
  baseRoute = signal("/", /* @ts-ignore */
7018
7034
  ...(ngDevMode ? [{ debugName: "baseRoute" }] : /* istanbul ignore next */ []));
7035
+ openStateKey = "ezui-sidebar-state";
7019
7036
  constructor(layoutService, router) {
7020
7037
  this.layoutService = layoutService;
7021
7038
  this.router = router;
@@ -7028,17 +7045,79 @@ class EzUISideBar {
7028
7045
  this.initialize();
7029
7046
  }
7030
7047
  initialize() {
7031
- var sidebarItems = [...this.sidebarItems()];
7032
- var sidebarFooterItems = [...this.sidebarFooterItems()];
7048
+ let sidebarItems = [...this.sidebarItems()];
7049
+ let sidebarFooterItems = [...this.sidebarFooterItems()];
7033
7050
  this.hideEmptySections(sidebarItems);
7034
7051
  this.hideEmptySections(sidebarFooterItems);
7035
7052
  if (!this.haveMoved() && this.router.routerState.snapshot.url == this.baseRoute())
7036
7053
  this.gotoFirstPage(sidebarItems);
7037
7054
  this.setActiveRoute(sidebarItems);
7038
7055
  this.setActiveRoute(sidebarFooterItems);
7056
+ let stateStr = localStorage.getItem(this.openStateKey);
7057
+ if (stateStr) {
7058
+ let state = JSON.parse(stateStr);
7059
+ this.setOpenStates(sidebarItems, state.sidebar);
7060
+ this.setOpenStates(sidebarFooterItems, state.footer);
7061
+ }
7039
7062
  this.sidebarItems.set(sidebarItems);
7040
7063
  this.sidebarFooterItems.set(sidebarFooterItems);
7041
7064
  }
7065
+ saveState() {
7066
+ let state = {
7067
+ sidebar: this.getOpenStates(this.sidebarItems()),
7068
+ footer: this.getOpenStates(this.sidebarFooterItems())
7069
+ };
7070
+ console.log(state);
7071
+ localStorage.setItem(this.openStateKey, JSON.stringify(state));
7072
+ }
7073
+ getOpenStates(from) {
7074
+ let open = [];
7075
+ let index = 0;
7076
+ for (let item of from) {
7077
+ let subOpen = this.getOpenStatesRec(item);
7078
+ for (let value of subOpen) {
7079
+ if (value == "")
7080
+ open.push(index + "");
7081
+ else
7082
+ open.push(index + ";" + value);
7083
+ }
7084
+ index++;
7085
+ }
7086
+ return open;
7087
+ }
7088
+ getOpenStatesRec(from) {
7089
+ let open = [];
7090
+ if (from.items) {
7091
+ if (from.expanded)
7092
+ open.push("");
7093
+ let index = 0;
7094
+ for (let item of from.items) {
7095
+ let subOpen = this.getOpenStatesRec(item);
7096
+ for (let value of subOpen)
7097
+ open.push(index + ";" + value);
7098
+ index++;
7099
+ }
7100
+ }
7101
+ return open;
7102
+ }
7103
+ setOpenStates(from, state) {
7104
+ let index = 0;
7105
+ for (let item of from) {
7106
+ this.setOpenStatesRec(item, index + "", state);
7107
+ index++;
7108
+ }
7109
+ }
7110
+ setOpenStatesRec(from, fromIndex, state) {
7111
+ if (from.items) {
7112
+ if (state.includes(fromIndex))
7113
+ from.expanded = true;
7114
+ let index = 0;
7115
+ for (let item of from.items) {
7116
+ this.setOpenStatesRec(item, fromIndex + ";" + index, state);
7117
+ index++;
7118
+ }
7119
+ }
7120
+ }
7042
7121
  hideEmptySections(menu) {
7043
7122
  for (let item of menu) {
7044
7123
  if (item.items) {
@@ -7063,7 +7142,7 @@ class EzUISideBar {
7063
7142
  }
7064
7143
  }
7065
7144
  gotoFirstPage(menu) {
7066
- var first = menu.find((x) => x.visible == true);
7145
+ let first = menu.find((x) => x.visible == true);
7067
7146
  if (first) {
7068
7147
  if (first.items) {
7069
7148
  this.gotoFirstPage(first.items);
@@ -7079,12 +7158,12 @@ class EzUISideBar {
7079
7158
  @if(layoutService.isDesktop()){
7080
7159
  <aside style="height:100%" tuitheme="" [tuiNavigationAside]="layoutService.isMenuExpanded()">
7081
7160
  @for(item of sidebarItems(); track item){
7082
- <ezui-sidebar-item [item]="item"/>
7161
+ <ezui-sidebar-item [item]="item" (onItemClick)="saveState()"/>
7083
7162
  }
7084
7163
 
7085
7164
  <footer>
7086
7165
  @for(item of sidebarFooterItems(); track item){
7087
- <ezui-sidebar-item [item]="item"/>
7166
+ <ezui-sidebar-item [item]="item" (onItemClick)="saveState()"/>
7088
7167
  }
7089
7168
  </footer>
7090
7169
  </aside>
@@ -7092,12 +7171,12 @@ class EzUISideBar {
7092
7171
  @else {
7093
7172
  <aside style="height:100%" tuitheme="" [tuiNavigationAside]="true" [style.display]="layoutService.isMenuExpanded() ? '' : 'none'">
7094
7173
  @for(item of sidebarItems(); track item){
7095
- <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false)"/>
7174
+ <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false);saveState()"/>
7096
7175
  }
7097
7176
 
7098
7177
  <footer>
7099
7178
  @for(item of sidebarFooterItems(); track item){
7100
- <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false)"/>
7179
+ <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false);saveState()"/>
7101
7180
  }
7102
7181
  </footer>
7103
7182
  </aside>
@@ -7114,12 +7193,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
7114
7193
  @if(layoutService.isDesktop()){
7115
7194
  <aside style="height:100%" tuitheme="" [tuiNavigationAside]="layoutService.isMenuExpanded()">
7116
7195
  @for(item of sidebarItems(); track item){
7117
- <ezui-sidebar-item [item]="item"/>
7196
+ <ezui-sidebar-item [item]="item" (onItemClick)="saveState()"/>
7118
7197
  }
7119
7198
 
7120
7199
  <footer>
7121
7200
  @for(item of sidebarFooterItems(); track item){
7122
- <ezui-sidebar-item [item]="item"/>
7201
+ <ezui-sidebar-item [item]="item" (onItemClick)="saveState()"/>
7123
7202
  }
7124
7203
  </footer>
7125
7204
  </aside>
@@ -7127,12 +7206,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
7127
7206
  @else {
7128
7207
  <aside style="height:100%" tuitheme="" [tuiNavigationAside]="true" [style.display]="layoutService.isMenuExpanded() ? '' : 'none'">
7129
7208
  @for(item of sidebarItems(); track item){
7130
- <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false)"/>
7209
+ <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false);saveState()"/>
7131
7210
  }
7132
7211
 
7133
7212
  <footer>
7134
7213
  @for(item of sidebarFooterItems(); track item){
7135
- <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false)"/>
7214
+ <ezui-sidebar-item [item]="item" (onItemClick)="layoutService.isMenuExpanded.set(false);saveState()"/>
7136
7215
  }
7137
7216
  </footer>
7138
7217
  </aside>