@@ -35,9 +35,12 @@ type ExampleAction = {
35
35
<button (click)="open()" kbq-button>open</button>
36
36
37
37
<ng-template let-data>
38
- <div class="example-counter">Selected: {{ data.length }}</div>
39
- <kbq-divider class="example-divider-vertical" [vertical]="true" />
40
38
<div #kbqOverflowItems="kbqOverflowItems" kbqOverflowItems>
39
+ <div [kbqOverflowItem]="action.Counter" order="99">
40
+ <div class="example-counter">Selected: {{ data.length }}</div>
41
+ <kbq-divider class="example-divider-vertical" [vertical]="true" />
42
+ </div>
43
+
41
44
@for (action of actions; track action.id) {
42
45
<button
43
46
[kbqOverflowItem]="action.id"
@@ -50,25 +53,28 @@ type ExampleAction = {
50
53
{{ action.id }}
51
54
</button>
52
55
}
53
- <div kbqOverflowItemsResult>
54
- <button [kbqDropdownTriggerFor]="dropdown" color="contrast" kbq-button>
56
+
57
+ @let hiddenItemIDs = kbqOverflowItems.hiddenItemIDs();
58
+ <!-- ignores when only action.Counter is hidden -->
59
+ @if (hiddenItemIDs.size > 1) {
60
+ <button [kbqDropdownTriggerFor]="dropdown" kbqOverflowItemsResult color="contrast" kbq-button>
55
61
<i kbq-icon="kbq-ellipsis-vertical_16"></i>
56
62
</button>
63
+ }
57
64
58
- <kbq-dropdown #dropdown="kbqDropdown">
59
- <div class="example-counter-dropdown">Selected: {{ data.length }}</div>
60
- <kbq-divider />
61
-
62
- @for (action of actions; track action.id) {
63
- @if (kbqOverflowItems.hiddenItemIDs().has(action.id)) {
64
- <button (click)="onAction(action)" kbq-dropdown-item>
65
- <i [class]="action.icon" kbq-icon></i>
66
- {{ action.id }}
67
- </button>
68
- }
65
+ <kbq-dropdown #dropdown="kbqDropdown">
66
+ <div class="example-counter-dropdown">Selected: {{ data.length }}</div>
67
+ <kbq-divider />
68
+
69
+ @for (action of actions; track action.id) {
70
+ @if (hiddenItemIDs.has(action.id)) {
71
+ <button (click)="onAction(action)" kbq-dropdown-item>
72
+ <i [class]="action.icon" kbq-icon></i>
73
+ {{ action.id }}
74
+ </button>
69
75
}
70
- </kbq-dropdown>
71
- </div >
76
+ }
77
+ </kbq-dropdown >
72
78
</div>
73
79
</ng-template>
74
80
` ,
@@ -78,18 +84,12 @@ type ExampleAction = {
78
84
align-items: center;
79
85
justify-content: center;
80
86
height: 64px;
81
- resize: horizontal;
82
- max-width: 100%;
83
- min-width: 110px;
84
87
overflow: hidden;
85
- container-type: inline-size;
88
+ }
86
89
87
- @container (width < 498px) {
88
- .example-counter,
89
- .example-counter + .example-divider-vertical {
90
- display: none;
91
- }
92
- }
90
+ .kbq-overflow-item {
91
+ display: flex;
92
+ align-items: center;
93
93
}
94
94
95
95
.example-counter {
@@ -113,35 +113,29 @@ type ExampleAction = {
113
113
height: var(--kbq-actions-panel-vertical-divider-height) !important;
114
114
margin: var(--kbq-actions-panel-vertical-divider-margin);
115
115
}
116
-
117
- .kbq-button,
118
- .kbq-dropdown-trigger {
119
- margin: var(--kbq-size-border-width);
120
- }
121
116
` ,
122
117
changeDetection : ChangeDetectionStrategy . OnPush
123
118
} )
124
119
export class ExampleActionsPanel {
125
- readonly actions : ExampleAction [ ] = [
120
+ protected readonly actions : ExampleAction [ ] = [
126
121
{ id : 'Responsible' , icon : 'kbq-user_16' } ,
127
122
{ id : 'Status' , icon : 'kbq-arrow-right-s_16' } ,
128
123
{ id : 'Archive' , icon : 'kbq-box-archive-arrow-down_16' }
129
124
] ;
130
- readonly actionsPanel = inject ( KbqActionsPanel , { self : true } ) ;
131
- readonly elementRef = inject ( ElementRef ) ;
132
- readonly templateRef = viewChild . required ( TemplateRef ) ;
133
- actionsPanelRef : KbqActionsPanelRef | null ;
134
- readonly toast = inject ( KbqToastService ) ;
125
+ protected readonly action = { Counter : 'counter' } ;
126
+
127
+ private readonly actionsPanel = inject ( KbqActionsPanel , { self : true } ) ;
128
+ private readonly elementRef = inject ( ElementRef ) ;
129
+ private readonly templateRef = viewChild . required ( TemplateRef ) ;
130
+ private actionsPanelRef : KbqActionsPanelRef | null ;
131
+ private readonly toast = inject ( KbqToastService ) ;
135
132
136
133
constructor ( ) {
137
134
afterNextRender ( ( ) => this . open ( ) ) ;
138
135
}
139
136
140
- open ( ) : void {
137
+ protected open ( ) : void {
141
138
this . actionsPanelRef = this . actionsPanel . open ( this . templateRef ( ) , {
142
- width : '100%' ,
143
- maxWidth : 498 ,
144
- minWidth : 106 ,
145
139
data : { length : 5 } ,
146
140
overlayContainer : this . elementRef
147
141
} ) ;
@@ -156,7 +150,7 @@ export class ExampleActionsPanel {
156
150
} ) ;
157
151
}
158
152
159
- onAction ( action : ExampleAction ) : void {
153
+ protected onAction ( action : ExampleAction ) : void {
160
154
this . toast . show ( { title : `Action initiated ${ action . id } ` } ) ;
161
155
}
162
156
}
@@ -170,15 +164,20 @@ export class ExampleActionsPanel {
170
164
selector : 'actions-panel-adaptive-example' ,
171
165
template : `
172
166
<div>First, the number of records is hidden</div>
173
- <example-actions-panel [style.width.px]="395 " />
167
+ <example-actions-panel [style.width.px]="450 " />
174
168
175
169
<div>Then, the actions are hidden under the dropdown menu</div>
176
- <example-actions-panel [style.width.px]="329 " />
170
+ <example-actions-panel [style.width.px]="370 " />
177
171
178
172
<div>Everything is hidden under the dropdown menu</div>
179
- <example-actions-panel [style.width.px]="106 " />
173
+ <example-actions-panel [style.width.px]="210 " />
180
174
` ,
181
175
styles : `
176
+ :host {
177
+ min-width: 480px;
178
+ display: block;
179
+ }
180
+
182
181
div {
183
182
color: var(--kbq-foreground-contrast-secondary);
184
183
margin: var(--kbq-size-s) var(--kbq-size-s) 0;
0 commit comments