@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,271 @@
|
|
|
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 { css, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
|
+
import { SYNCHRONIZED_ATTRIBUTES, WRAPPER_LOCAL_NAME } from './vaadin-dashboard-helpers.js';
|
|
17
|
+
import { DashboardItemMixin } from './vaadin-dashboard-item-mixin.js';
|
|
18
|
+
import { getDefaultI18n } from './vaadin-dashboard-item-mixin.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A Widget component for use with the Dashboard component
|
|
22
|
+
*
|
|
23
|
+
* ```html
|
|
24
|
+
* <vaadin-dashboard-widget widget-title="Title">
|
|
25
|
+
* <span slot="header-content">Header</span>
|
|
26
|
+
* <div>Content</div>
|
|
27
|
+
* </vaadin-dashboard-widget>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ### Customization
|
|
31
|
+
*
|
|
32
|
+
* You can configure the item by using `slot` names.
|
|
33
|
+
*
|
|
34
|
+
* Slot name | Description
|
|
35
|
+
* -----------------|-------------
|
|
36
|
+
* `header-content` | A slot for the widget header content.
|
|
37
|
+
*
|
|
38
|
+
* #### Example
|
|
39
|
+
*
|
|
40
|
+
* ```html
|
|
41
|
+
* <vaadin-dashboard-widget widget-title="Title">
|
|
42
|
+
* <span slot="header-content">Header</span>
|
|
43
|
+
* <div>Content</div>
|
|
44
|
+
* </vaadin-dashboard-widget>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ### Styling
|
|
48
|
+
*
|
|
49
|
+
* The following shadow DOM parts are available for styling:
|
|
50
|
+
*
|
|
51
|
+
* Part name | Description
|
|
52
|
+
* ------------------------------|-------------
|
|
53
|
+
* `header` | The header of the widget
|
|
54
|
+
* `title` | The title of the widget
|
|
55
|
+
* `content` | The content of the widget
|
|
56
|
+
* `move-button` | The move button
|
|
57
|
+
* `remove-button` | The remove button
|
|
58
|
+
* `resize-button` | The resize button
|
|
59
|
+
* `move-backward-button` | The move backward button when in move mode
|
|
60
|
+
* `move-forward-button` | The move forward button when in move mode
|
|
61
|
+
* `move-apply-button` | The apply button when in move mode
|
|
62
|
+
* `resize-shrink-width-button` | The shrink width button when in resize mode
|
|
63
|
+
* `resize-grow-width-button` | The grow width button when in resize mode
|
|
64
|
+
* `resize-shrink-height-button` | The shrink height button when in resize mode
|
|
65
|
+
* `resize-grow-height-button` | The grow height button when in resize mode
|
|
66
|
+
* `resize-apply-button` | The apply button when in resize mode
|
|
67
|
+
*
|
|
68
|
+
* The following custom properties are available:
|
|
69
|
+
*
|
|
70
|
+
* Custom Property | Description
|
|
71
|
+
* ----------------------------------|-------------
|
|
72
|
+
* `--vaadin-dashboard-item-colspan` | colspan of the widget
|
|
73
|
+
* `--vaadin-dashboard-item-rowspan` | rowspan of the widget
|
|
74
|
+
*
|
|
75
|
+
* The following state attributes are available for styling:
|
|
76
|
+
*
|
|
77
|
+
* Attribute | Description
|
|
78
|
+
* ---------------|-------------
|
|
79
|
+
* `selected` | Set when the element is selected.
|
|
80
|
+
* `focused` | Set when the element is focused.
|
|
81
|
+
* `move-mode` | Set when the element is being moved.
|
|
82
|
+
* `resize-mode` | Set when the element is being resized.
|
|
83
|
+
* `resizing` | Set when the element is being resized.
|
|
84
|
+
* `dragging` | Set when the element is being dragged.
|
|
85
|
+
* `editable` | Set when the element is editable.
|
|
86
|
+
* `first-child` | Set when the element is the first child of the parent.
|
|
87
|
+
* `last-child` | Set when the element is the last child of the parent.
|
|
88
|
+
*
|
|
89
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
90
|
+
*
|
|
91
|
+
* @customElement
|
|
92
|
+
* @extends HTMLElement
|
|
93
|
+
* @mixes ElementMixin
|
|
94
|
+
* @mixes ThemableMixin
|
|
95
|
+
* @mixes DashboardItemMixin
|
|
96
|
+
*/
|
|
97
|
+
class DashboardWidget extends DashboardItemMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
98
|
+
static get is() {
|
|
99
|
+
return 'vaadin-dashboard-widget';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static get styles() {
|
|
103
|
+
return [
|
|
104
|
+
css`
|
|
105
|
+
:host {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: column;
|
|
108
|
+
grid-column: var(--_vaadin-dashboard-item-column);
|
|
109
|
+
grid-row: var(--_vaadin-dashboard-item-row);
|
|
110
|
+
position: relative;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:host([hidden]) {
|
|
114
|
+
display: none !important;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
:host(:not([editable])) #resize-handle {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#content {
|
|
122
|
+
flex: 1;
|
|
123
|
+
overflow: hidden;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#resize-handle {
|
|
127
|
+
position: absolute;
|
|
128
|
+
bottom: 0;
|
|
129
|
+
inset-inline-end: 0;
|
|
130
|
+
z-index: 1;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host([resizing])::after {
|
|
135
|
+
content: '';
|
|
136
|
+
z-index: 2;
|
|
137
|
+
position: absolute;
|
|
138
|
+
inset-inline-start: 0;
|
|
139
|
+
top: 0;
|
|
140
|
+
width: var(--_vaadin-dashboard-widget-resizer-width, 0);
|
|
141
|
+
height: var(--_vaadin-dashboard-widget-resizer-height, 0);
|
|
142
|
+
background: rgba(0, 0, 0, 0.1);
|
|
143
|
+
}
|
|
144
|
+
`,
|
|
145
|
+
super.styles,
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static get properties() {
|
|
150
|
+
return {
|
|
151
|
+
/**
|
|
152
|
+
* The object used to localize this component.
|
|
153
|
+
*
|
|
154
|
+
* To change the default localization, replace the entire
|
|
155
|
+
* `i18n` object with a custom one.
|
|
156
|
+
*
|
|
157
|
+
* The object has the following structure and default values:
|
|
158
|
+
* ```
|
|
159
|
+
* {
|
|
160
|
+
* selectWidget: 'Select widget for editing',
|
|
161
|
+
* remove: 'Remove',
|
|
162
|
+
* resize: 'Resize',
|
|
163
|
+
* resizeApply: 'Apply',
|
|
164
|
+
* resizeShrinkWidth: 'Shrink width',
|
|
165
|
+
* resizeGrowWidth: 'Grow width',
|
|
166
|
+
* resizeShrinkHeight: 'Shrink height',
|
|
167
|
+
* resizeGrowHeight: 'Grow height',
|
|
168
|
+
* move: 'Move',
|
|
169
|
+
* moveApply: 'Apply',
|
|
170
|
+
* moveForward: 'Move Forward',
|
|
171
|
+
* moveBackward: 'Move Backward',
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
__i18n: {
|
|
177
|
+
type: Object,
|
|
178
|
+
value: () => {
|
|
179
|
+
const i18n = getDefaultI18n();
|
|
180
|
+
delete i18n.selectSection;
|
|
181
|
+
return i18n;
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The title of the widget.
|
|
187
|
+
*
|
|
188
|
+
* @attr {string} widget-title
|
|
189
|
+
* @type {string | null | undefined}
|
|
190
|
+
*/
|
|
191
|
+
widgetTitle: {
|
|
192
|
+
type: String,
|
|
193
|
+
value: '',
|
|
194
|
+
observer: '__onWidgetTitleChanged',
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
/* @private */
|
|
198
|
+
__nestedHeadingLevel: {
|
|
199
|
+
type: Boolean,
|
|
200
|
+
value: false,
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** @protected */
|
|
206
|
+
render() {
|
|
207
|
+
return html`
|
|
208
|
+
${this.__renderFocusButton('selectWidget')} ${this.__renderMoveControls()} ${this.__renderResizeControls()}
|
|
209
|
+
|
|
210
|
+
<div id="focustrap">
|
|
211
|
+
<header part="header">
|
|
212
|
+
${this.__renderDragHandle()}
|
|
213
|
+
${this.__nestedHeadingLevel
|
|
214
|
+
? html`<h3 id="title" part="title" .hidden=${!this.widgetTitle}>${this.widgetTitle}</h3>`
|
|
215
|
+
: html`<h2 id="title" part="title" .hidden=${!this.widgetTitle}>${this.widgetTitle}</h2>`}
|
|
216
|
+
<slot name="header-content"></slot>
|
|
217
|
+
${this.__renderRemoveButton()}
|
|
218
|
+
</header>
|
|
219
|
+
|
|
220
|
+
${this.__renderResizeHandle()}
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
<div id="content" part="content">
|
|
224
|
+
<slot></slot>
|
|
225
|
+
</div>
|
|
226
|
+
`;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** @protected */
|
|
230
|
+
connectedCallback() {
|
|
231
|
+
super.connectedCallback();
|
|
232
|
+
|
|
233
|
+
const wrapper = this.closest(WRAPPER_LOCAL_NAME);
|
|
234
|
+
if (wrapper) {
|
|
235
|
+
SYNCHRONIZED_ATTRIBUTES.forEach((attr) => {
|
|
236
|
+
this.toggleAttribute(attr, !!wrapper[attr]);
|
|
237
|
+
});
|
|
238
|
+
this.__i18n = wrapper.i18n;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const undefinedAncestor = this.closest('*:not(:defined)');
|
|
242
|
+
if (undefinedAncestor) {
|
|
243
|
+
customElements.whenDefined(undefinedAncestor.localName).then(() => queueMicrotask(() => this.__updateTitle()));
|
|
244
|
+
} else {
|
|
245
|
+
this.__updateTitle();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** @protected */
|
|
250
|
+
ready() {
|
|
251
|
+
super.ready();
|
|
252
|
+
if (!this.hasAttribute('role')) {
|
|
253
|
+
this.setAttribute('role', 'article');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** @private */
|
|
258
|
+
__onWidgetTitleChanged() {
|
|
259
|
+
this.__updateTitle();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** @private */
|
|
263
|
+
__updateTitle() {
|
|
264
|
+
const titleLevel = getComputedStyle(this).getPropertyValue('--_vaadin-dashboard-title-level');
|
|
265
|
+
this.__nestedHeadingLevel = titleLevel === '3';
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
defineCustomElement(DashboardWidget);
|
|
270
|
+
|
|
271
|
+
export { DashboardWidget };
|
|
@@ -0,0 +1,290 @@
|
|
|
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-widget.js';
|
|
12
|
+
import './vaadin-dashboard-section.js';
|
|
13
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
|
|
15
|
+
import { DashboardLayoutMixin } from './vaadin-dashboard-layout-mixin.js';
|
|
16
|
+
|
|
17
|
+
export interface DashboardItem {
|
|
18
|
+
/**
|
|
19
|
+
* The id of the item.
|
|
20
|
+
* The identifier should be unique among the dashboard items.
|
|
21
|
+
* If a unique identifier is not provided, reassigning new item instances
|
|
22
|
+
* to the dashboard while a widget is focused may cause the focus to be lost.
|
|
23
|
+
*/
|
|
24
|
+
id?: unknown;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The column span of the item
|
|
28
|
+
*/
|
|
29
|
+
colspan?: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The row span of the item
|
|
33
|
+
*/
|
|
34
|
+
rowspan?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface DashboardSectionItem<TItem extends DashboardItem> {
|
|
38
|
+
/**
|
|
39
|
+
* The id of the item.
|
|
40
|
+
* The identifier should be unique among the dashboard items.
|
|
41
|
+
* If a unique identifier is not provided, reassigning new item instances
|
|
42
|
+
* to the dashboard while a widget is focused may cause the focus to be lost.
|
|
43
|
+
*/
|
|
44
|
+
id?: unknown;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The title of the section
|
|
48
|
+
*/
|
|
49
|
+
title?: string | null;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The items of the section
|
|
53
|
+
*/
|
|
54
|
+
items: TItem[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface DashboardItemModel<TItem> {
|
|
58
|
+
item: TItem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type DashboardRenderer<TItem extends DashboardItem> = (
|
|
62
|
+
root: HTMLElement,
|
|
63
|
+
owner: Dashboard<TItem>,
|
|
64
|
+
model: DashboardItemModel<TItem>,
|
|
65
|
+
) => void;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Fired when an item was moved
|
|
69
|
+
*/
|
|
70
|
+
export type DashboardItemMovedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
71
|
+
item: TItem;
|
|
72
|
+
|
|
73
|
+
items: Array<TItem | DashboardSectionItem<TItem>>;
|
|
74
|
+
|
|
75
|
+
section: DashboardSectionItem<TItem> | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Fired when an item was resized
|
|
80
|
+
*/
|
|
81
|
+
export type DashboardItemResizedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
82
|
+
item: TItem;
|
|
83
|
+
|
|
84
|
+
items: Array<TItem | DashboardSectionItem<TItem>>;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Fired when an item was removed
|
|
89
|
+
*/
|
|
90
|
+
export type DashboardItemRemovedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
91
|
+
item: TItem | DashboardSectionItem<TItem>;
|
|
92
|
+
|
|
93
|
+
items: Array<TItem | DashboardSectionItem<TItem>>;
|
|
94
|
+
}>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Fired when an item selected state changed
|
|
98
|
+
*/
|
|
99
|
+
export type DashboardItemSelectedChangedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
100
|
+
item: TItem;
|
|
101
|
+
value: boolean;
|
|
102
|
+
}>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Fired when an item move mode changed
|
|
106
|
+
*/
|
|
107
|
+
export type DashboardItemMoveModeChangedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
108
|
+
item: TItem;
|
|
109
|
+
value: boolean;
|
|
110
|
+
}>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Fired when an item resize mode changed
|
|
114
|
+
*/
|
|
115
|
+
export type DashboardItemResizeModeChangedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
116
|
+
item: TItem;
|
|
117
|
+
value: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
|
|
120
|
+
export interface DashboardCustomEventMap<TItem extends DashboardItem> {
|
|
121
|
+
'dashboard-item-moved': DashboardItemMovedEvent<TItem>;
|
|
122
|
+
|
|
123
|
+
'dashboard-item-resized': DashboardItemResizedEvent<TItem>;
|
|
124
|
+
|
|
125
|
+
'dashboard-item-removed': DashboardItemRemovedEvent<TItem>;
|
|
126
|
+
|
|
127
|
+
'dashboard-item-selected-changed': DashboardItemSelectedChangedEvent<TItem>;
|
|
128
|
+
|
|
129
|
+
'dashboard-item-move-mode-changed': DashboardItemMoveModeChangedEvent<TItem>;
|
|
130
|
+
|
|
131
|
+
'dashboard-item-resize-mode-changed': DashboardItemResizeModeChangedEvent<TItem>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type DashboardEventMap<TItem extends DashboardItem> = DashboardCustomEventMap<TItem> & HTMLElementEventMap;
|
|
135
|
+
|
|
136
|
+
export interface DashboardI18n {
|
|
137
|
+
selectWidget: string;
|
|
138
|
+
selectSection: string;
|
|
139
|
+
remove: string;
|
|
140
|
+
resize: string;
|
|
141
|
+
resizeApply: string;
|
|
142
|
+
resizeShrinkWidth: string;
|
|
143
|
+
resizeGrowWidth: string;
|
|
144
|
+
resizeShrinkHeight: string;
|
|
145
|
+
resizeGrowHeight: string;
|
|
146
|
+
move: string;
|
|
147
|
+
moveApply: string;
|
|
148
|
+
moveForward: string;
|
|
149
|
+
moveBackward: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* A responsive, grid-based dashboard layout component
|
|
154
|
+
*
|
|
155
|
+
* ### Quick Start
|
|
156
|
+
*
|
|
157
|
+
* Assign an array to the [`items`](#/elements/vaadin-dashboard#property-items) property.
|
|
158
|
+
* Set a renderer function to the [`renderer`](#/elements/vaadin-dashboard#property-renderer) property.
|
|
159
|
+
*
|
|
160
|
+
* The widgets and the sections will be generated and configured based on the renderer and the items provided.
|
|
161
|
+
*
|
|
162
|
+
* ```html
|
|
163
|
+
* <vaadin-dashboard></vaadin-dashboard>
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* ```js
|
|
167
|
+
* const dashboard = document.querySelector('vaadin-dashboard');
|
|
168
|
+
*
|
|
169
|
+
* dashboard.items = [
|
|
170
|
+
* { title: 'Widget 1 title', content: 'Text 1', rowspan: 2 },
|
|
171
|
+
* { title: 'Widget 2 title', content: 'Text 2', colspan: 2 },
|
|
172
|
+
* {
|
|
173
|
+
* title: 'Section title',
|
|
174
|
+
* items: [{ title: 'Widget in section title', content: 'Text 3' }]
|
|
175
|
+
* },
|
|
176
|
+
* // ... more items
|
|
177
|
+
* ];
|
|
178
|
+
*
|
|
179
|
+
* dashboard.renderer = (root, _dashboard, { item }) => {
|
|
180
|
+
* const widget = root.firstElementChild || document.createElement('vaadin-dashboard-widget');
|
|
181
|
+
* if (!root.contains(widget)) {
|
|
182
|
+
* root.appendChild(widget);
|
|
183
|
+
* }
|
|
184
|
+
* widget.widgetTitle = item.title;
|
|
185
|
+
* widget.textContent = item.content;
|
|
186
|
+
* };
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* ### Styling
|
|
190
|
+
*
|
|
191
|
+
* The following custom properties are available:
|
|
192
|
+
*
|
|
193
|
+
* Custom Property | Description
|
|
194
|
+
* ------------------------------------|-------------
|
|
195
|
+
* `--vaadin-dashboard-col-min-width` | minimum column width of the dashboard
|
|
196
|
+
* `--vaadin-dashboard-col-max-width` | maximum column width of the dashboard
|
|
197
|
+
* `--vaadin-dashboard-row-min-height` | minimum row height of the dashboard
|
|
198
|
+
* `--vaadin-dashboard-col-max-count` | maximum column count of the dashboard
|
|
199
|
+
* `--vaadin-dashboard-spacing` | spacing between child elements and space around its outer edges. Must be in length units (0 is not allowed, 0px is)
|
|
200
|
+
*
|
|
201
|
+
* The following state attributes are available for styling:
|
|
202
|
+
*
|
|
203
|
+
* Attribute | Description
|
|
204
|
+
* ---------------|-------------
|
|
205
|
+
* `editable` | Set when the dashboard is editable.
|
|
206
|
+
* `dense-layout` | Set when the dashboard is in dense mode.
|
|
207
|
+
* `item-selected`| Set when an item is selected.
|
|
208
|
+
*
|
|
209
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
210
|
+
*
|
|
211
|
+
* @fires {CustomEvent} dashboard-item-moved - Fired when an item was moved
|
|
212
|
+
* @fires {CustomEvent} dashboard-item-resized - Fired when an item was resized
|
|
213
|
+
* @fires {CustomEvent} dashboard-item-removed - Fired when an item was removed
|
|
214
|
+
* @fires {CustomEvent} dashboard-item-selected-changed - Fired when an item selected state changed
|
|
215
|
+
* @fires {CustomEvent} dashboard-item-move-mode-changed - Fired when an item move mode changed
|
|
216
|
+
* @fires {CustomEvent} dashboard-item-resize-mode-changed - Fired when an item resize mode changed
|
|
217
|
+
*/
|
|
218
|
+
declare class Dashboard<TItem extends DashboardItem = DashboardItem> extends DashboardLayoutMixin(
|
|
219
|
+
ElementMixin(ThemableMixin(HTMLElement)),
|
|
220
|
+
) {
|
|
221
|
+
/**
|
|
222
|
+
* An array containing the items of the dashboard
|
|
223
|
+
*/
|
|
224
|
+
items: Array<TItem | DashboardSectionItem<TItem>>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Custom function for rendering a widget for each dashboard item.
|
|
228
|
+
* Placing something else than a widget in the wrapper is not supported.
|
|
229
|
+
* Receives three arguments:
|
|
230
|
+
*
|
|
231
|
+
* - `root` The container for the widget.
|
|
232
|
+
* - `dashboard` The reference to the `<vaadin-dashboard>` element.
|
|
233
|
+
* - `model` The object with the properties related with the rendered
|
|
234
|
+
* item, contains:
|
|
235
|
+
* - `model.item` The item.
|
|
236
|
+
*/
|
|
237
|
+
renderer: DashboardRenderer<TItem> | null | undefined;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Whether the dashboard is editable.
|
|
241
|
+
*/
|
|
242
|
+
editable: boolean;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The object used to localize this component.
|
|
246
|
+
*
|
|
247
|
+
* To change the default localization, replace the entire
|
|
248
|
+
* `i18n` object with a custom one.
|
|
249
|
+
*
|
|
250
|
+
* The object has the following structure and default values:
|
|
251
|
+
* ```
|
|
252
|
+
* {
|
|
253
|
+
* selectSection: 'Select section for editing',
|
|
254
|
+
* selectWidget: 'Select widget for editing',
|
|
255
|
+
* remove: 'Remove',
|
|
256
|
+
* resize: 'Resize',
|
|
257
|
+
* resizeApply: 'Apply',
|
|
258
|
+
* resizeShrinkWidth: 'Shrink width',
|
|
259
|
+
* resizeGrowWidth: 'Grow width',
|
|
260
|
+
* resizeShrinkHeight: 'Shrink height',
|
|
261
|
+
* resizeGrowHeight: 'Grow height',
|
|
262
|
+
* move: 'Move',
|
|
263
|
+
* moveApply: 'Apply',
|
|
264
|
+
* moveForward: 'Move Forward',
|
|
265
|
+
* moveBackward: 'Move Backward',
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
i18n: DashboardI18n;
|
|
270
|
+
|
|
271
|
+
addEventListener<K extends keyof DashboardEventMap<TItem>>(
|
|
272
|
+
type: K,
|
|
273
|
+
listener: (this: Dashboard, ev: DashboardEventMap<TItem>[K]) => void,
|
|
274
|
+
options?: AddEventListenerOptions | boolean,
|
|
275
|
+
): void;
|
|
276
|
+
|
|
277
|
+
removeEventListener<K extends keyof DashboardEventMap<TItem>>(
|
|
278
|
+
type: K,
|
|
279
|
+
listener: (this: Dashboard, ev: DashboardEventMap<TItem>[K]) => void,
|
|
280
|
+
options?: EventListenerOptions | boolean,
|
|
281
|
+
): void;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare global {
|
|
285
|
+
interface HTMLElementTagNameMap {
|
|
286
|
+
'vaadin-dashboard': Dashboard<DashboardItem>;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export { Dashboard };
|