@vaadin/dashboard 24.6.0-alpha1
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.
- package/LICENSE +3 -0
- package/README.md +34 -0
- package/package.json +57 -0
- package/src/keyboard-controller.js +107 -0
- package/src/vaadin-dashboard-button.js +45 -0
- package/src/vaadin-dashboard-helpers.js +99 -0
- package/src/vaadin-dashboard-item-mixin.d.ts +20 -0
- package/src/vaadin-dashboard-item-mixin.js +355 -0
- package/src/vaadin-dashboard-layout-mixin.d.ts +28 -0
- package/src/vaadin-dashboard-layout-mixin.js +148 -0
- package/src/vaadin-dashboard-layout.d.ts +56 -0
- package/src/vaadin-dashboard-layout.js +70 -0
- package/src/vaadin-dashboard-section.d.ts +76 -0
- package/src/vaadin-dashboard-section.js +203 -0
- package/src/vaadin-dashboard-styles.js +143 -0
- package/src/vaadin-dashboard-widget.d.ts +101 -0
- package/src/vaadin-dashboard-widget.js +271 -0
- package/src/vaadin-dashboard.d.ts +290 -0
- package/src/vaadin-dashboard.js +489 -0
- package/src/widget-reorder-controller.js +247 -0
- package/src/widget-resize-controller.js +214 -0
- package/theme/lumo/vaadin-dashboard-button-styles.d.ts +2 -0
- package/theme/lumo/vaadin-dashboard-button-styles.js +8 -0
- package/theme/lumo/vaadin-dashboard-button.d.ts +1 -0
- package/theme/lumo/vaadin-dashboard-button.js +1 -0
- package/theme/lumo/vaadin-dashboard-layout-styles.d.ts +1 -0
- package/theme/lumo/vaadin-dashboard-layout-styles.js +11 -0
- package/theme/lumo/vaadin-dashboard-layout.d.ts +2 -0
- package/theme/lumo/vaadin-dashboard-layout.js +2 -0
- package/theme/lumo/vaadin-dashboard-section-styles.d.ts +5 -0
- package/theme/lumo/vaadin-dashboard-section-styles.js +22 -0
- package/theme/lumo/vaadin-dashboard-section.d.ts +3 -0
- package/theme/lumo/vaadin-dashboard-section.js +3 -0
- package/theme/lumo/vaadin-dashboard-styles.d.ts +1 -0
- package/theme/lumo/vaadin-dashboard-styles.js +16 -0
- package/theme/lumo/vaadin-dashboard-widget-styles.d.ts +9 -0
- package/theme/lumo/vaadin-dashboard-widget-styles.js +242 -0
- package/theme/lumo/vaadin-dashboard-widget.d.ts +3 -0
- package/theme/lumo/vaadin-dashboard-widget.js +3 -0
- package/theme/lumo/vaadin-dashboard.d.ts +4 -0
- package/theme/lumo/vaadin-dashboard.js +4 -0
- package/theme/material/vaadin-dashboard-layout.d.ts +1 -0
- package/theme/material/vaadin-dashboard-layout.js +1 -0
- package/theme/material/vaadin-dashboard-section.d.ts +1 -0
- package/theme/material/vaadin-dashboard-section.js +1 -0
- package/theme/material/vaadin-dashboard-widget.d.ts +1 -0
- package/theme/material/vaadin-dashboard-widget.js +1 -0
- package/theme/material/vaadin-dashboard.d.ts +3 -0
- package/theme/material/vaadin-dashboard.js +3 -0
- package/vaadin-dashboard-layout.d.ts +1 -0
- package/vaadin-dashboard-layout.js +3 -0
- package/vaadin-dashboard-section.d.ts +1 -0
- package/vaadin-dashboard-section.js +3 -0
- package/vaadin-dashboard-widget.d.ts +1 -0
- package/vaadin-dashboard-widget.js +3 -0
- package/vaadin-dashboard.d.ts +1 -0
- package/vaadin-dashboard.js +3 -0
- package/web-types.json +260 -0
- package/web-types.lit.json +146 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2024 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import './vaadin-dashboard-button.js';
|
|
12
|
+
import { html } from 'lit';
|
|
13
|
+
import { FocusTrapController } from '@vaadin/a11y-base/src/focus-trap-controller.js';
|
|
14
|
+
import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
|
|
15
|
+
import { KeyboardController } from './keyboard-controller.js';
|
|
16
|
+
import { fireMove, fireRemove, fireResize } from './vaadin-dashboard-helpers.js';
|
|
17
|
+
import { dashboardWidgetAndSectionStyles } from './vaadin-dashboard-styles.js';
|
|
18
|
+
|
|
19
|
+
const DEFAULT_I18N = {
|
|
20
|
+
selectWidget: 'Select widget for editing',
|
|
21
|
+
selectSection: 'Select section for editing',
|
|
22
|
+
remove: 'Remove',
|
|
23
|
+
move: 'Move',
|
|
24
|
+
moveApply: 'Apply',
|
|
25
|
+
moveForward: 'Move Forward',
|
|
26
|
+
moveBackward: 'Move Backward',
|
|
27
|
+
resize: 'Resize',
|
|
28
|
+
resizeApply: 'Apply',
|
|
29
|
+
resizeShrinkWidth: 'Shrink width',
|
|
30
|
+
resizeGrowWidth: 'Grow width',
|
|
31
|
+
resizeShrinkHeight: 'Shrink height',
|
|
32
|
+
resizeGrowHeight: 'Grow height',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns a new object with the default i18n values
|
|
37
|
+
*/
|
|
38
|
+
export function getDefaultI18n() {
|
|
39
|
+
return { ...DEFAULT_I18N };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Shared functionality between widgets and sections
|
|
44
|
+
*
|
|
45
|
+
* @polymerMixin
|
|
46
|
+
* @mixes ResizeMixin
|
|
47
|
+
*/
|
|
48
|
+
export const DashboardItemMixin = (superClass) =>
|
|
49
|
+
class DashboardItemMixinClass extends ResizeMixin(superClass) {
|
|
50
|
+
static get styles() {
|
|
51
|
+
return dashboardWidgetAndSectionStyles;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static get properties() {
|
|
55
|
+
return {
|
|
56
|
+
/** @protected */
|
|
57
|
+
__i18n: {
|
|
58
|
+
type: Object,
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
/** @private */
|
|
62
|
+
__selected: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
reflectToAttribute: true,
|
|
65
|
+
attribute: 'selected',
|
|
66
|
+
observer: '__selectedChanged',
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
/** @private */
|
|
70
|
+
__focused: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
reflectToAttribute: true,
|
|
73
|
+
attribute: 'focused',
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/** @private */
|
|
77
|
+
__moveMode: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
reflectToAttribute: true,
|
|
80
|
+
attribute: 'move-mode',
|
|
81
|
+
observer: '__moveModeChanged',
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
/** @private */
|
|
85
|
+
__resizeMode: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
reflectToAttribute: true,
|
|
88
|
+
attribute: 'resize-mode',
|
|
89
|
+
observer: '__resizeModeChanged',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @private */
|
|
95
|
+
__renderDragHandle() {
|
|
96
|
+
return html`<vaadin-dashboard-button
|
|
97
|
+
id="drag-handle"
|
|
98
|
+
draggable="true"
|
|
99
|
+
class="drag-handle"
|
|
100
|
+
part="move-button"
|
|
101
|
+
theme="icon tertiary"
|
|
102
|
+
aria-label="${this.__i18n.move}"
|
|
103
|
+
title="${this.__i18n.move}"
|
|
104
|
+
tabindex="${this.__selected ? 0 : -1}"
|
|
105
|
+
@click="${() => this.__enterMoveMode()}"
|
|
106
|
+
>
|
|
107
|
+
<div class="icon"></div>
|
|
108
|
+
</vaadin-dashboard-button>`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** @private */
|
|
112
|
+
__renderRemoveButton() {
|
|
113
|
+
return html`<vaadin-dashboard-button
|
|
114
|
+
aria-label="${this.__i18n.remove}"
|
|
115
|
+
title="${this.__i18n.remove}"
|
|
116
|
+
id="remove-button"
|
|
117
|
+
part="remove-button"
|
|
118
|
+
theme="icon tertiary"
|
|
119
|
+
tabindex="${this.__selected ? 0 : -1}"
|
|
120
|
+
@click="${() => fireRemove(this)}"
|
|
121
|
+
>
|
|
122
|
+
<div class="icon"></div>
|
|
123
|
+
</vaadin-dashboard-button>`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** @private */
|
|
127
|
+
__renderFocusButton(i18nSelectTitleForEditingProperty) {
|
|
128
|
+
// To make the button draggable on Firefox, using a workaround from https://stackoverflow.com/a/55019027/3409629
|
|
129
|
+
return html`<label draggable="true" class="drag-handle" id="focus-button-wrapper">
|
|
130
|
+
<button
|
|
131
|
+
id="focus-button"
|
|
132
|
+
aria-label=${this.__i18n[i18nSelectTitleForEditingProperty]}
|
|
133
|
+
aria-describedby="title"
|
|
134
|
+
aria-pressed="${!!this.__selected}"
|
|
135
|
+
@click="${() => {
|
|
136
|
+
this.__selected = true;
|
|
137
|
+
}}"
|
|
138
|
+
></button>
|
|
139
|
+
</label>`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @private */
|
|
143
|
+
__renderResizeHandle() {
|
|
144
|
+
return html`<vaadin-dashboard-button
|
|
145
|
+
aria-label="${this.__i18n.resize}"
|
|
146
|
+
title="${this.__i18n.resize}"
|
|
147
|
+
id="resize-handle"
|
|
148
|
+
part="resize-button"
|
|
149
|
+
class="resize-handle"
|
|
150
|
+
theme="icon tertiary"
|
|
151
|
+
tabindex="${this.__selected ? 0 : -1}"
|
|
152
|
+
@click="${() => this.__enterResizeMode()}"
|
|
153
|
+
>
|
|
154
|
+
<div class="icon"></div>
|
|
155
|
+
</vaadin-dashboard-button>`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** @private */
|
|
159
|
+
__renderMoveControls() {
|
|
160
|
+
return html`<div
|
|
161
|
+
id="move-controls"
|
|
162
|
+
class="mode-controls"
|
|
163
|
+
.hidden="${!this.__moveMode}"
|
|
164
|
+
@pointerdown="${(e) => e.preventDefault()}"
|
|
165
|
+
>
|
|
166
|
+
<vaadin-dashboard-button
|
|
167
|
+
theme="primary icon"
|
|
168
|
+
aria-label="${this.__i18n.moveBackward}"
|
|
169
|
+
title="${this.__i18n.moveBackward}"
|
|
170
|
+
@click="${() => fireMove(this, -1)}"
|
|
171
|
+
id="move-backward"
|
|
172
|
+
part="move-backward-button"
|
|
173
|
+
>
|
|
174
|
+
<div class="icon"></div>
|
|
175
|
+
</vaadin-dashboard-button>
|
|
176
|
+
<vaadin-dashboard-button
|
|
177
|
+
theme="primary icon large"
|
|
178
|
+
aria-label="${this.__i18n.moveApply}"
|
|
179
|
+
title="${this.__i18n.moveApply}"
|
|
180
|
+
@click="${() => this.__exitMode(true)}"
|
|
181
|
+
id="move-apply"
|
|
182
|
+
part="move-apply-button"
|
|
183
|
+
>
|
|
184
|
+
<div class="icon"></div>
|
|
185
|
+
</vaadin-dashboard-button>
|
|
186
|
+
<vaadin-dashboard-button
|
|
187
|
+
theme="primary icon"
|
|
188
|
+
aria-label="${this.__i18n.moveForward}"
|
|
189
|
+
title="${this.__i18n.moveForward}"
|
|
190
|
+
@click="${() => fireMove(this, 1)}"
|
|
191
|
+
id="move-forward"
|
|
192
|
+
part="move-forward-button"
|
|
193
|
+
>
|
|
194
|
+
<div class="icon"></div>
|
|
195
|
+
</vaadin-dashboard-button>
|
|
196
|
+
</div>`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** @private */
|
|
200
|
+
__renderResizeControls() {
|
|
201
|
+
const hasMinRowHeight = getComputedStyle(this).getPropertyValue('--vaadin-dashboard-row-min-height');
|
|
202
|
+
|
|
203
|
+
return html`<div
|
|
204
|
+
id="resize-controls"
|
|
205
|
+
class="mode-controls"
|
|
206
|
+
.hidden="${!this.__resizeMode}"
|
|
207
|
+
@pointerdown="${(e) => e.preventDefault()}"
|
|
208
|
+
>
|
|
209
|
+
<vaadin-dashboard-button
|
|
210
|
+
theme="primary icon large"
|
|
211
|
+
aria-label="${this.__i18n.resizeApply}"
|
|
212
|
+
title="${this.__i18n.resizeApply}"
|
|
213
|
+
@click="${() => this.__exitMode(true)}"
|
|
214
|
+
id="resize-apply"
|
|
215
|
+
part="resize-apply-button"
|
|
216
|
+
>
|
|
217
|
+
<div class="icon"></div>
|
|
218
|
+
</vaadin-dashboard-button>
|
|
219
|
+
<vaadin-dashboard-button
|
|
220
|
+
theme="primary icon"
|
|
221
|
+
aria-label="${this.__i18n.resizeShrinkWidth}"
|
|
222
|
+
title="${this.__i18n.resizeShrinkWidth}"
|
|
223
|
+
@click="${() => fireResize(this, -1, 0)}"
|
|
224
|
+
id="resize-shrink-width"
|
|
225
|
+
part="resize-shrink-width-button"
|
|
226
|
+
>
|
|
227
|
+
<div class="icon"></div>
|
|
228
|
+
</vaadin-dashboard-button>
|
|
229
|
+
<vaadin-dashboard-button
|
|
230
|
+
theme="primary icon"
|
|
231
|
+
aria-label="${this.__i18n.resizeGrowWidth}"
|
|
232
|
+
title="${this.__i18n.resizeGrowWidth}"
|
|
233
|
+
@click="${() => fireResize(this, 1, 0)}"
|
|
234
|
+
id="resize-grow-width"
|
|
235
|
+
part="resize-grow-width-button"
|
|
236
|
+
>
|
|
237
|
+
<div class="icon"></div>
|
|
238
|
+
</vaadin-dashboard-button>
|
|
239
|
+
<vaadin-dashboard-button
|
|
240
|
+
theme="primary icon"
|
|
241
|
+
aria-label="${this.__i18n.resizeShrinkHeight}"
|
|
242
|
+
title="${this.__i18n.resizeShrinkHeight}"
|
|
243
|
+
@click="${() => fireResize(this, 0, -1)}"
|
|
244
|
+
id="resize-shrink-height"
|
|
245
|
+
part="resize-shrink-height-button"
|
|
246
|
+
.hidden="${!hasMinRowHeight}"
|
|
247
|
+
>
|
|
248
|
+
<div class="icon"></div>
|
|
249
|
+
</vaadin-dashboard-button>
|
|
250
|
+
<vaadin-dashboard-button
|
|
251
|
+
theme="primary icon"
|
|
252
|
+
aria-label="${this.__i18n.resizeGrowHeight}"
|
|
253
|
+
title="${this.__i18n.resizeGrowHeight}"
|
|
254
|
+
@click="${() => fireResize(this, 0, 1)}"
|
|
255
|
+
id="resize-grow-height"
|
|
256
|
+
part="resize-grow-height-button"
|
|
257
|
+
.hidden="${!hasMinRowHeight}"
|
|
258
|
+
>
|
|
259
|
+
<div class="icon"></div>
|
|
260
|
+
</vaadin-dashboard-button>
|
|
261
|
+
</div>`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
constructor() {
|
|
265
|
+
super();
|
|
266
|
+
this.__keyboardController = new KeyboardController(this);
|
|
267
|
+
this.__focusTrapController = new FocusTrapController(this);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** @protected */
|
|
271
|
+
ready() {
|
|
272
|
+
super.ready();
|
|
273
|
+
this.addController(this.__keyboardController);
|
|
274
|
+
this.addController(this.__focusTrapController);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** @private */
|
|
278
|
+
__selectedChanged(selected, oldSelected) {
|
|
279
|
+
if (!!selected === !!oldSelected) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
this.dispatchEvent(new CustomEvent('item-selected-changed', { bubbles: true, detail: { value: selected } }));
|
|
283
|
+
if (selected) {
|
|
284
|
+
this.__focusTrapController.trapFocus(this.$.focustrap);
|
|
285
|
+
} else {
|
|
286
|
+
this.__focusTrapController.releaseFocus();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
focus() {
|
|
291
|
+
if (this.hasAttribute('editable')) {
|
|
292
|
+
this.$['focus-button'].focus();
|
|
293
|
+
} else {
|
|
294
|
+
super.focus();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** @private */
|
|
299
|
+
__exitMode(focus) {
|
|
300
|
+
if (this.__moveMode) {
|
|
301
|
+
this.__moveMode = false;
|
|
302
|
+
if (focus) {
|
|
303
|
+
this.$['drag-handle'].focus();
|
|
304
|
+
this.__focusTrapController.trapFocus(this.$.focustrap);
|
|
305
|
+
}
|
|
306
|
+
} else if (this.__resizeMode) {
|
|
307
|
+
this.__resizeMode = false;
|
|
308
|
+
if (focus) {
|
|
309
|
+
this.$['resize-handle'].focus();
|
|
310
|
+
this.__focusTrapController.trapFocus(this.$.focustrap);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** @private */
|
|
316
|
+
__focusApply() {
|
|
317
|
+
if (this.__moveMode) {
|
|
318
|
+
this.$['move-apply'].focus();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** @private */
|
|
323
|
+
__enterMoveMode() {
|
|
324
|
+
this.__selected = true;
|
|
325
|
+
this.__moveMode = true;
|
|
326
|
+
requestAnimationFrame(() => {
|
|
327
|
+
this.__focusTrapController.trapFocus(this.$['move-controls']);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** @private */
|
|
332
|
+
__enterResizeMode() {
|
|
333
|
+
this.__selected = true;
|
|
334
|
+
this.__resizeMode = true;
|
|
335
|
+
requestAnimationFrame(() => {
|
|
336
|
+
this.__focusTrapController.trapFocus(this.$['resize-controls']);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** @private */
|
|
341
|
+
__moveModeChanged(moveMode, oldMoveMode) {
|
|
342
|
+
if (!!moveMode === !!oldMoveMode) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
this.dispatchEvent(new CustomEvent('item-move-mode-changed', { bubbles: true, detail: { value: moveMode } }));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** @private */
|
|
349
|
+
__resizeModeChanged(resizeMode, oldResizeMode) {
|
|
350
|
+
if (!!resizeMode === !!oldResizeMode) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this.dispatchEvent(new CustomEvent('item-resize-mode-changed', { bubbles: true, detail: { value: resizeMode } }));
|
|
354
|
+
}
|
|
355
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2024 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
12
|
+
import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A mixin to enable the dashboard layout functionality.
|
|
16
|
+
*/
|
|
17
|
+
export declare function DashboardLayoutMixin<T extends Constructor<HTMLElement>>(
|
|
18
|
+
base: T,
|
|
19
|
+
): Constructor<DashboardLayoutMixinClass> & Constructor<ResizeMixinClass> & T;
|
|
20
|
+
|
|
21
|
+
export declare class DashboardLayoutMixinClass {
|
|
22
|
+
/**
|
|
23
|
+
* Whether the dashboard layout is dense.
|
|
24
|
+
*
|
|
25
|
+
* @attr {boolean} dense-layout
|
|
26
|
+
*/
|
|
27
|
+
denseLayout: boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2024 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
|
|
12
|
+
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A mixin to enable the dashboard layout functionality
|
|
16
|
+
*
|
|
17
|
+
* @polymerMixin
|
|
18
|
+
* @mixes ResizeMixin
|
|
19
|
+
*/
|
|
20
|
+
export const DashboardLayoutMixin = (superClass) =>
|
|
21
|
+
class DashboardLayoutMixinClass extends ResizeMixin(superClass) {
|
|
22
|
+
static get styles() {
|
|
23
|
+
return css`
|
|
24
|
+
:host {
|
|
25
|
+
display: block;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:host([hidden]) {
|
|
30
|
+
display: none !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([dense-layout]) #grid {
|
|
34
|
+
grid-auto-flow: dense;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#grid {
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
--_vaadin-dashboard-default-spacing: 1rem;
|
|
40
|
+
--_vaadin-dashboard-spacing: max(
|
|
41
|
+
0px,
|
|
42
|
+
var(--vaadin-dashboard-spacing, var(--_vaadin-dashboard-default-spacing))
|
|
43
|
+
);
|
|
44
|
+
padding: var(--_vaadin-dashboard-spacing);
|
|
45
|
+
|
|
46
|
+
/* Default min and max column widths */
|
|
47
|
+
--_vaadin-dashboard-default-col-min-width: 25rem;
|
|
48
|
+
--_vaadin-dashboard-default-col-max-width: 1fr;
|
|
49
|
+
|
|
50
|
+
/* Effective min and max column widths */
|
|
51
|
+
--_vaadin-dashboard-col-min-width: var(
|
|
52
|
+
--vaadin-dashboard-col-min-width,
|
|
53
|
+
var(--_vaadin-dashboard-default-col-min-width)
|
|
54
|
+
);
|
|
55
|
+
--_vaadin-dashboard-col-max-width: var(
|
|
56
|
+
--vaadin-dashboard-col-max-width,
|
|
57
|
+
var(--_vaadin-dashboard-default-col-max-width)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
/* Effective max column count */
|
|
61
|
+
--_vaadin-dashboard-col-max-count: var(--vaadin-dashboard-col-max-count, var(--_vaadin-dashboard-col-count));
|
|
62
|
+
|
|
63
|
+
/* Effective column count */
|
|
64
|
+
--_vaadin-dashboard-effective-col-count: min(
|
|
65
|
+
var(--_vaadin-dashboard-col-count),
|
|
66
|
+
var(--_vaadin-dashboard-col-max-count)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
/* Effective row height */
|
|
70
|
+
--_vaadin-dashboard-row-height: minmax(var(--vaadin-dashboard-row-min-height, auto), auto);
|
|
71
|
+
|
|
72
|
+
display: grid;
|
|
73
|
+
overflow: auto;
|
|
74
|
+
height: 100%;
|
|
75
|
+
|
|
76
|
+
grid-template-columns: repeat(
|
|
77
|
+
var(--_vaadin-dashboard-effective-col-count, auto-fill),
|
|
78
|
+
minmax(var(--_vaadin-dashboard-col-min-width), var(--_vaadin-dashboard-col-max-width))
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
grid-auto-rows: var(--_vaadin-dashboard-row-height);
|
|
82
|
+
|
|
83
|
+
gap: var(--_vaadin-dashboard-spacing);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
::slotted(*) {
|
|
87
|
+
/* The grid-column value applied to children */
|
|
88
|
+
--_vaadin-dashboard-item-column: span
|
|
89
|
+
min(
|
|
90
|
+
var(--vaadin-dashboard-item-colspan, 1),
|
|
91
|
+
var(--_vaadin-dashboard-effective-col-count, var(--_vaadin-dashboard-col-count))
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
grid-column: var(--_vaadin-dashboard-item-column);
|
|
95
|
+
|
|
96
|
+
/* The grid-row value applied to children */
|
|
97
|
+
--_vaadin-dashboard-item-row: span var(--vaadin-dashboard-item-rowspan, 1);
|
|
98
|
+
grid-row: var(--_vaadin-dashboard-item-row);
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static get properties() {
|
|
104
|
+
return {
|
|
105
|
+
/**
|
|
106
|
+
* Whether the dashboard layout is dense.
|
|
107
|
+
*
|
|
108
|
+
* @attr {boolean} dense-layout
|
|
109
|
+
* @type {boolean}
|
|
110
|
+
*/
|
|
111
|
+
denseLayout: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
value: false,
|
|
114
|
+
reflectToAttribute: true,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** @protected */
|
|
120
|
+
ready() {
|
|
121
|
+
super.ready();
|
|
122
|
+
// Avoid flickering on the initial render
|
|
123
|
+
this._onResize();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @protected
|
|
128
|
+
* @override
|
|
129
|
+
*/
|
|
130
|
+
_onResize() {
|
|
131
|
+
// Update the grid width to match the host width. This is done programmatically to avoid
|
|
132
|
+
// flickering due to the asynchronous nature of ResizeObserver.
|
|
133
|
+
this.$.grid.style.width = `${this.offsetWidth}px`;
|
|
134
|
+
this.__updateColumnCount();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
__updateColumnCount() {
|
|
141
|
+
// Clear the previously computed column count
|
|
142
|
+
this.$.grid.style.removeProperty('--_vaadin-dashboard-col-count');
|
|
143
|
+
// Get the column count (with no colspans etc in effect)...
|
|
144
|
+
const columnCount = getComputedStyle(this.$.grid).gridTemplateColumns.split(' ').length;
|
|
145
|
+
// ...and set it as the new value
|
|
146
|
+
this.$.grid.style.setProperty('--_vaadin-dashboard-col-count', columnCount);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2024 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
import { DashboardLayoutMixin } from './vaadin-dashboard-layout-mixin.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A responsive, grid-based dashboard layout component
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <vaadin-dashboard-layout>
|
|
20
|
+
* <vaadin-dashboard-widget widget-title="Widget 1"></vaadin-dashboard-widget>
|
|
21
|
+
* <vaadin-dashboard-widget widget-title="Widget 2"></vaadin-dashboard-widget>
|
|
22
|
+
* <vaadin-dashboard-section section-title="Section">
|
|
23
|
+
* <vaadin-dashboard-widget widget-title="Widget in Section"></vaadin-dashboard-widget>
|
|
24
|
+
* </vaadin-dashboard-section>
|
|
25
|
+
* </vaadin-dashboard-layout>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ### Styling
|
|
29
|
+
*
|
|
30
|
+
* The following custom properties are available:
|
|
31
|
+
*
|
|
32
|
+
* Custom Property | Description
|
|
33
|
+
* ------------------------------------|-------------
|
|
34
|
+
* `--vaadin-dashboard-col-min-width` | minimum column width of the layout
|
|
35
|
+
* `--vaadin-dashboard-col-max-width` | maximum column width of the layout
|
|
36
|
+
* `--vaadin-dashboard-row-min-height` | minimum row height of the layout
|
|
37
|
+
* `--vaadin-dashboard-col-max-count` | maximum column count of the layout
|
|
38
|
+
* `--vaadin-dashboard-spacing` | spacing between child elements and space around its outer edges. Must be in length units (0 is not allowed, 0px is)
|
|
39
|
+
*
|
|
40
|
+
* The following state attributes are available for styling:
|
|
41
|
+
*
|
|
42
|
+
* Attribute | Description
|
|
43
|
+
* ---------------|-------------
|
|
44
|
+
* `dense-layout` | Set when the dashboard is in dense mode.
|
|
45
|
+
*
|
|
46
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
47
|
+
*/
|
|
48
|
+
declare class DashboardLayout extends DashboardLayoutMixin(ElementMixin(ThemableMixin(HTMLElement))) {}
|
|
49
|
+
|
|
50
|
+
declare global {
|
|
51
|
+
interface HTMLElementTagNameMap {
|
|
52
|
+
'vaadin-dashboard-layout': DashboardLayout;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { DashboardLayout };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2024 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import { html, LitElement } from 'lit';
|
|
12
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
15
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
|
+
import { DashboardLayoutMixin } from './vaadin-dashboard-layout-mixin.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A responsive, grid-based dashboard layout component
|
|
20
|
+
*
|
|
21
|
+
* ```html
|
|
22
|
+
* <vaadin-dashboard-layout>
|
|
23
|
+
* <vaadin-dashboard-widget widget-title="Widget 1"></vaadin-dashboard-widget>
|
|
24
|
+
* <vaadin-dashboard-widget widget-title="Widget 2"></vaadin-dashboard-widget>
|
|
25
|
+
* <vaadin-dashboard-section section-title="Section">
|
|
26
|
+
* <vaadin-dashboard-widget widget-title="Widget in Section"></vaadin-dashboard-widget>
|
|
27
|
+
* </vaadin-dashboard-section>
|
|
28
|
+
* </vaadin-dashboard-layout>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ### Styling
|
|
32
|
+
*
|
|
33
|
+
* The following custom properties are available:
|
|
34
|
+
*
|
|
35
|
+
* Custom Property | Description
|
|
36
|
+
* ------------------------------------|-------------
|
|
37
|
+
* `--vaadin-dashboard-col-min-width` | minimum column width of the layout
|
|
38
|
+
* `--vaadin-dashboard-col-max-width` | maximum column width of the layout
|
|
39
|
+
* `--vaadin-dashboard-row-min-height` | minimum row height of the layout
|
|
40
|
+
* `--vaadin-dashboard-col-max-count` | maximum column count of the layout
|
|
41
|
+
* `--vaadin-dashboard-spacing` | spacing between child elements and space around its outer edges. Must be in length units (0 is not allowed, 0px is)
|
|
42
|
+
*
|
|
43
|
+
* The following state attributes are available for styling:
|
|
44
|
+
*
|
|
45
|
+
* Attribute | Description
|
|
46
|
+
* ---------------|-------------
|
|
47
|
+
* `dense-layout` | Set when the dashboard is in dense mode.
|
|
48
|
+
*
|
|
49
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
50
|
+
*
|
|
51
|
+
* @customElement
|
|
52
|
+
* @extends HTMLElement
|
|
53
|
+
* @mixes DashboardLayoutMixin
|
|
54
|
+
* @mixes ElementMixin
|
|
55
|
+
* @mixes ThemableMixin
|
|
56
|
+
*/
|
|
57
|
+
class DashboardLayout extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
58
|
+
static get is() {
|
|
59
|
+
return 'vaadin-dashboard-layout';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @protected */
|
|
63
|
+
render() {
|
|
64
|
+
return html`<div id="grid"><slot></slot></div>`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
defineCustomElement(DashboardLayout);
|
|
69
|
+
|
|
70
|
+
export { DashboardLayout };
|