@vaadin/dashboard 24.7.0-alpha1 → 24.7.0-alpha10
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/package.json +10 -9
- package/src/keyboard-controller.js +1 -1
- package/src/vaadin-dashboard-button.js +1 -1
- package/src/vaadin-dashboard-helpers.js +1 -1
- package/src/vaadin-dashboard-item-mixin.d.ts +1 -1
- package/src/vaadin-dashboard-item-mixin.js +1 -1
- package/src/vaadin-dashboard-layout-mixin.d.ts +1 -1
- package/src/vaadin-dashboard-layout-mixin.js +1 -1
- package/src/vaadin-dashboard-layout.d.ts +1 -1
- package/src/vaadin-dashboard-layout.js +1 -1
- package/src/vaadin-dashboard-section.d.ts +1 -1
- package/src/vaadin-dashboard-section.js +11 -10
- package/src/vaadin-dashboard-styles.js +1 -1
- package/src/vaadin-dashboard-widget.d.ts +1 -1
- package/src/vaadin-dashboard-widget.js +2 -4
- package/src/vaadin-dashboard.d.ts +11 -11
- package/src/vaadin-dashboard.js +74 -59
- package/src/widget-reorder-controller.js +1 -1
- package/src/widget-resize-controller.js +1 -1
- package/theme/lumo/vaadin-dashboard-section-styles.js +3 -3
- package/theme/lumo/vaadin-dashboard-widget-styles.js +33 -28
- package/web-types.json +11 -13
- package/web-types.lit.json +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/dashboard",
|
|
3
|
-
"version": "24.7.0-
|
|
3
|
+
"version": "24.7.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,21 +37,22 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/button": "24.7.0-
|
|
41
|
-
"@vaadin/component-base": "24.7.0-
|
|
42
|
-
"@vaadin/vaadin-lumo-styles": "24.7.0-
|
|
43
|
-
"@vaadin/vaadin-material-styles": "24.7.0-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "24.7.0-
|
|
40
|
+
"@vaadin/button": "24.7.0-alpha10",
|
|
41
|
+
"@vaadin/component-base": "24.7.0-alpha10",
|
|
42
|
+
"@vaadin/vaadin-lumo-styles": "24.7.0-alpha10",
|
|
43
|
+
"@vaadin/vaadin-material-styles": "24.7.0-alpha10",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "24.7.0-alpha10",
|
|
45
45
|
"lit": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@vaadin/chai-plugins": "24.7.0-
|
|
49
|
-
"@vaadin/
|
|
48
|
+
"@vaadin/chai-plugins": "24.7.0-alpha10",
|
|
49
|
+
"@vaadin/test-runner-commands": "24.7.0-alpha10",
|
|
50
|
+
"@vaadin/testing-helpers": "^1.1.0"
|
|
50
51
|
},
|
|
51
52
|
"cvdlName": "vaadin-dashboard",
|
|
52
53
|
"web-types": [
|
|
53
54
|
"web-types.json",
|
|
54
55
|
"web-types.lit.json"
|
|
55
56
|
],
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "c0f8933df2a6a40648d3fb9cfbae6bbf86a8aa90"
|
|
57
58
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2000 -
|
|
3
|
+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
4
|
*
|
|
5
5
|
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
6
|
*
|
|
@@ -151,15 +151,7 @@ class DashboardSection extends DashboardItemMixin(ElementMixin(ThemableMixin(Pol
|
|
|
151
151
|
__i18n: {
|
|
152
152
|
type: Object,
|
|
153
153
|
value: () => {
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
selectSection: i18n.selectSection,
|
|
157
|
-
remove: i18n.remove,
|
|
158
|
-
move: i18n.move,
|
|
159
|
-
moveApply: i18n.moveApply,
|
|
160
|
-
moveForward: i18n.moveForward,
|
|
161
|
-
moveBackward: i18n.moveBackward,
|
|
162
|
-
};
|
|
154
|
+
return getDefaultI18n();
|
|
163
155
|
},
|
|
164
156
|
},
|
|
165
157
|
|
|
@@ -173,6 +165,12 @@ class DashboardSection extends DashboardItemMixin(ElementMixin(ThemableMixin(Pol
|
|
|
173
165
|
type: String,
|
|
174
166
|
value: '',
|
|
175
167
|
},
|
|
168
|
+
|
|
169
|
+
/** @private */
|
|
170
|
+
__childCount: {
|
|
171
|
+
type: Number,
|
|
172
|
+
value: 0,
|
|
173
|
+
},
|
|
176
174
|
};
|
|
177
175
|
}
|
|
178
176
|
|
|
@@ -191,7 +189,10 @@ class DashboardSection extends DashboardItemMixin(ElementMixin(ThemableMixin(Pol
|
|
|
191
189
|
</header>
|
|
192
190
|
</div>
|
|
193
191
|
|
|
192
|
+
<!-- Default slot is used by <vaadin-dashboard-layout> -->
|
|
194
193
|
<slot></slot>
|
|
194
|
+
<!-- Named slots are used by <vaadin-dashboard> -->
|
|
195
|
+
${[...Array(this.__childCount)].map((_, index) => html`<slot name="slot-${index}"></slot>`)}
|
|
195
196
|
`;
|
|
196
197
|
}
|
|
197
198
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2000 -
|
|
3
|
+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
4
|
*
|
|
5
5
|
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
6
|
*
|
|
@@ -180,9 +180,7 @@ class DashboardWidget extends DashboardItemMixin(ElementMixin(ThemableMixin(Poly
|
|
|
180
180
|
__i18n: {
|
|
181
181
|
type: Object,
|
|
182
182
|
value: () => {
|
|
183
|
-
|
|
184
|
-
delete i18n.selectSection;
|
|
185
|
-
return i18n;
|
|
183
|
+
return getDefaultI18n();
|
|
186
184
|
},
|
|
187
185
|
},
|
|
188
186
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2000 -
|
|
3
|
+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
4
|
*
|
|
5
5
|
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
6
|
*
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import './vaadin-dashboard-widget.js';
|
|
12
12
|
import './vaadin-dashboard-section.js';
|
|
13
13
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
|
+
import type { I18nMixin, PartialI18n } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
14
15
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
|
|
15
16
|
import { DashboardLayoutMixin } from './vaadin-dashboard-layout-mixin.js';
|
|
16
17
|
|
|
@@ -68,7 +69,7 @@ export type DashboardRenderer<TItem extends DashboardItem> = (
|
|
|
68
69
|
* Fired when an item was moved
|
|
69
70
|
*/
|
|
70
71
|
export type DashboardItemMovedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
71
|
-
item: TItem
|
|
72
|
+
item: TItem | DashboardSectionItem<TItem>;
|
|
72
73
|
|
|
73
74
|
items: Array<TItem | DashboardSectionItem<TItem>>;
|
|
74
75
|
|
|
@@ -97,7 +98,7 @@ export type DashboardItemRemovedEvent<TItem extends DashboardItem> = CustomEvent
|
|
|
97
98
|
* Fired when an item selected state changed
|
|
98
99
|
*/
|
|
99
100
|
export type DashboardItemSelectedChangedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
100
|
-
item: TItem
|
|
101
|
+
item: TItem | DashboardSectionItem<TItem>;
|
|
101
102
|
value: boolean;
|
|
102
103
|
}>;
|
|
103
104
|
|
|
@@ -105,7 +106,7 @@ export type DashboardItemSelectedChangedEvent<TItem extends DashboardItem> = Cus
|
|
|
105
106
|
* Fired when an item move mode changed
|
|
106
107
|
*/
|
|
107
108
|
export type DashboardItemMoveModeChangedEvent<TItem extends DashboardItem> = CustomEvent<{
|
|
108
|
-
item: TItem
|
|
109
|
+
item: TItem | DashboardSectionItem<TItem>;
|
|
109
110
|
value: boolean;
|
|
110
111
|
}>;
|
|
111
112
|
|
|
@@ -133,7 +134,7 @@ export interface DashboardCustomEventMap<TItem extends DashboardItem> {
|
|
|
133
134
|
|
|
134
135
|
export type DashboardEventMap<TItem extends DashboardItem> = DashboardCustomEventMap<TItem> & HTMLElementEventMap;
|
|
135
136
|
|
|
136
|
-
export
|
|
137
|
+
export type DashboardI18n = PartialI18n<{
|
|
137
138
|
selectWidget: string;
|
|
138
139
|
selectSection: string;
|
|
139
140
|
remove: string;
|
|
@@ -147,7 +148,7 @@ export interface DashboardI18n {
|
|
|
147
148
|
moveApply: string;
|
|
148
149
|
moveForward: string;
|
|
149
150
|
moveBackward: string;
|
|
150
|
-
}
|
|
151
|
+
}>;
|
|
151
152
|
|
|
152
153
|
/**
|
|
153
154
|
* A responsive, grid-based dashboard layout component
|
|
@@ -217,7 +218,7 @@ export interface DashboardI18n {
|
|
|
217
218
|
* @fires {CustomEvent} dashboard-item-resize-mode-changed - Fired when an item resize mode changed
|
|
218
219
|
*/
|
|
219
220
|
declare class Dashboard<TItem extends DashboardItem = DashboardItem> extends DashboardLayoutMixin(
|
|
220
|
-
ElementMixin(ThemableMixin(HTMLElement)),
|
|
221
|
+
I18nMixin({} as DashboardI18n, ElementMixin(ThemableMixin(HTMLElement))),
|
|
221
222
|
) {
|
|
222
223
|
/**
|
|
223
224
|
* An array containing the items of the dashboard
|
|
@@ -243,10 +244,9 @@ declare class Dashboard<TItem extends DashboardItem = DashboardItem> extends Das
|
|
|
243
244
|
editable: boolean;
|
|
244
245
|
|
|
245
246
|
/**
|
|
246
|
-
* The object used to localize this component.
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* `i18n` object with a custom one.
|
|
247
|
+
* The object used to localize this component. To change the default
|
|
248
|
+
* localization, replace this with an object that provides all properties, or
|
|
249
|
+
* just the individual properties you want to change.
|
|
250
250
|
*
|
|
251
251
|
* The object has the following structure and default values:
|
|
252
252
|
* ```
|
package/src/vaadin-dashboard.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2000 -
|
|
3
|
+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
4
|
*
|
|
5
5
|
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
6
|
*
|
|
@@ -13,6 +13,7 @@ import './vaadin-dashboard-section.js';
|
|
|
13
13
|
import { html, LitElement } from 'lit';
|
|
14
14
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
15
15
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
16
|
+
import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
16
17
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
17
18
|
import { css, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
18
19
|
import {
|
|
@@ -100,9 +101,12 @@ import { WidgetResizeController } from './widget-resize-controller.js';
|
|
|
100
101
|
* @extends HTMLElement
|
|
101
102
|
* @mixes ElementMixin
|
|
102
103
|
* @mixes DashboardLayoutMixin
|
|
104
|
+
* @mixes I18nMixin
|
|
103
105
|
* @mixes ThemableMixin
|
|
104
106
|
*/
|
|
105
|
-
class Dashboard extends DashboardLayoutMixin(
|
|
107
|
+
class Dashboard extends DashboardLayoutMixin(
|
|
108
|
+
I18nMixin(getDefaultI18n(), ElementMixin(ThemableMixin(PolylitMixin(LitElement)))),
|
|
109
|
+
) {
|
|
106
110
|
static get is() {
|
|
107
111
|
return 'vaadin-dashboard';
|
|
108
112
|
}
|
|
@@ -162,44 +166,49 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
162
166
|
type: Boolean,
|
|
163
167
|
},
|
|
164
168
|
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
* `i18n` object with a custom one.
|
|
170
|
-
*
|
|
171
|
-
* The object has the following structure and default values:
|
|
172
|
-
* ```
|
|
173
|
-
* {
|
|
174
|
-
* selectSection: 'Select section for editing',
|
|
175
|
-
* selectWidget: 'Select widget for editing',
|
|
176
|
-
* remove: 'Remove',
|
|
177
|
-
* resize: 'Resize',
|
|
178
|
-
* resizeApply: 'Apply',
|
|
179
|
-
* resizeShrinkWidth: 'Shrink width',
|
|
180
|
-
* resizeGrowWidth: 'Grow width',
|
|
181
|
-
* resizeShrinkHeight: 'Shrink height',
|
|
182
|
-
* resizeGrowHeight: 'Grow height',
|
|
183
|
-
* move: 'Move',
|
|
184
|
-
* moveApply: 'Apply',
|
|
185
|
-
* moveForward: 'Move Forward',
|
|
186
|
-
* moveBackward: 'Move Backward',
|
|
187
|
-
* }
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
i18n: {
|
|
191
|
-
type: Object,
|
|
192
|
-
value: () => {
|
|
193
|
-
return {
|
|
194
|
-
...getDefaultI18n(),
|
|
195
|
-
};
|
|
196
|
-
},
|
|
169
|
+
/** @private */
|
|
170
|
+
__childCount: {
|
|
171
|
+
type: Number,
|
|
172
|
+
value: 0,
|
|
197
173
|
},
|
|
198
174
|
};
|
|
199
175
|
}
|
|
200
176
|
|
|
201
177
|
static get observers() {
|
|
202
|
-
return ['__itemsOrRendererChanged(items, renderer, editable,
|
|
178
|
+
return ['__itemsOrRendererChanged(items, renderer, editable, __effectiveI18n)'];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The object used to localize this component. To change the default
|
|
183
|
+
* localization, replace this with an object that provides all properties, or
|
|
184
|
+
* just the individual properties you want to change.
|
|
185
|
+
*
|
|
186
|
+
* The object has the following structure and default values:
|
|
187
|
+
* ```
|
|
188
|
+
* {
|
|
189
|
+
* selectSection: 'Select section for editing',
|
|
190
|
+
* selectWidget: 'Select widget for editing',
|
|
191
|
+
* remove: 'Remove',
|
|
192
|
+
* resize: 'Resize',
|
|
193
|
+
* resizeApply: 'Apply',
|
|
194
|
+
* resizeShrinkWidth: 'Shrink width',
|
|
195
|
+
* resizeGrowWidth: 'Grow width',
|
|
196
|
+
* resizeShrinkHeight: 'Shrink height',
|
|
197
|
+
* resizeGrowHeight: 'Grow height',
|
|
198
|
+
* move: 'Move',
|
|
199
|
+
* moveApply: 'Apply',
|
|
200
|
+
* moveForward: 'Move Forward',
|
|
201
|
+
* moveBackward: 'Move Backward',
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
* @return {!DashboardI18n}
|
|
205
|
+
*/
|
|
206
|
+
get i18n() {
|
|
207
|
+
return super.i18n;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
set i18n(value) {
|
|
211
|
+
super.i18n = value;
|
|
203
212
|
}
|
|
204
213
|
|
|
205
214
|
constructor() {
|
|
@@ -221,11 +230,14 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
221
230
|
|
|
222
231
|
/** @protected */
|
|
223
232
|
render() {
|
|
224
|
-
return html`<div id="grid"
|
|
233
|
+
return html`<div id="grid">
|
|
234
|
+
${[...Array(this.__childCount)].map((_, index) => html`<slot name="slot-${index}"></slot>`)}
|
|
235
|
+
</div>`;
|
|
225
236
|
}
|
|
226
237
|
|
|
227
238
|
/** @private */
|
|
228
239
|
__itemsOrRendererChanged(items, renderer) {
|
|
240
|
+
this.__childCount = items ? items.length : 0;
|
|
229
241
|
this.__renderItemWrappers(items || []);
|
|
230
242
|
|
|
231
243
|
this.querySelectorAll(WRAPPER_LOCAL_NAME).forEach((wrapper) => {
|
|
@@ -248,7 +260,7 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
248
260
|
SYNCHRONIZED_ATTRIBUTES.forEach((attr) => {
|
|
249
261
|
wrapper.firstElementChild.toggleAttribute(attr, !!wrapper[attr]);
|
|
250
262
|
});
|
|
251
|
-
wrapper.firstElementChild.__i18n = this.
|
|
263
|
+
wrapper.firstElementChild.__i18n = this.__effectiveI18n;
|
|
252
264
|
}
|
|
253
265
|
});
|
|
254
266
|
}
|
|
@@ -257,38 +269,25 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
257
269
|
__renderItemWrappers(items, hostElement = this) {
|
|
258
270
|
// Get all the wrappers in the host element
|
|
259
271
|
let wrappers = [...hostElement.children].filter((el) => el.localName === WRAPPER_LOCAL_NAME);
|
|
260
|
-
let previousWrapper = null;
|
|
261
272
|
|
|
262
273
|
const focusedWrapper = wrappers.find((wrapper) => wrapper.querySelector(':focus'));
|
|
263
274
|
const focusedWrapperWillBeRemoved = focusedWrapper && !this.__isActiveWrapper(focusedWrapper);
|
|
264
275
|
const wrapperClosestToRemovedFocused =
|
|
265
276
|
focusedWrapperWillBeRemoved && this.__getClosestActiveWrapper(focusedWrapper);
|
|
266
277
|
|
|
267
|
-
items.forEach((item) => {
|
|
278
|
+
items.forEach((item, index) => {
|
|
268
279
|
// Find the wrapper for the item or create a new one
|
|
269
280
|
const wrapper = wrappers.find((el) => itemsEqual(getElementItem(el), item)) || this.__createWrapper(item);
|
|
270
281
|
wrappers = wrappers.filter((el) => el !== wrapper);
|
|
282
|
+
if (!wrapper.isConnected) {
|
|
283
|
+
hostElement.appendChild(wrapper);
|
|
284
|
+
}
|
|
271
285
|
|
|
272
286
|
// Update the wrapper style
|
|
273
287
|
this.__updateWrapper(wrapper, item);
|
|
274
288
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
// Append the wrapper after the previous one if it's not already there
|
|
278
|
-
if (wrapper.previousElementSibling !== previousWrapper) {
|
|
279
|
-
previousWrapper.after(wrapper);
|
|
280
|
-
}
|
|
281
|
-
} else if (hostElement.firstChild) {
|
|
282
|
-
// Insert the wrapper as the first child of the host element if it's not already there
|
|
283
|
-
if (wrapper !== hostElement.firstChild) {
|
|
284
|
-
hostElement.insertBefore(wrapper, hostElement.firstChild);
|
|
285
|
-
}
|
|
286
|
-
} else {
|
|
287
|
-
// Append the wrapper to the empty host element
|
|
288
|
-
hostElement.appendChild(wrapper);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
previousWrapper = wrapper;
|
|
289
|
+
// Update the wrapper slot
|
|
290
|
+
wrapper.slot = `slot-${index}`;
|
|
292
291
|
|
|
293
292
|
// Render section if the item has subitems
|
|
294
293
|
if (item.items) {
|
|
@@ -304,9 +303,10 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
SYNCHRONIZED_ATTRIBUTES.forEach((attr) => section.toggleAttribute(attr, !!wrapper[attr]));
|
|
307
|
-
section.__i18n = this.
|
|
306
|
+
section.__i18n = this.__effectiveI18n;
|
|
308
307
|
|
|
309
308
|
// Render the subitems
|
|
309
|
+
section.__childCount = item.items.length;
|
|
310
310
|
this.__renderItemWrappers(item.items, section);
|
|
311
311
|
}
|
|
312
312
|
});
|
|
@@ -368,12 +368,26 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
368
368
|
return getItemsArrayOfItem(getElementItem(wrapper), this.items);
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Parses the slot name to get the index of the item in the dashboard
|
|
373
|
+
* For example, slot name "slot-12" will return 12
|
|
374
|
+
* @private
|
|
375
|
+
*/
|
|
376
|
+
__parseSlotIndex(slotName) {
|
|
377
|
+
return parseInt(slotName.split('-')[1]);
|
|
378
|
+
}
|
|
379
|
+
|
|
371
380
|
/** @private */
|
|
372
381
|
__getClosestActiveWrapper(wrapper) {
|
|
373
382
|
if (!wrapper || this.__isActiveWrapper(wrapper)) {
|
|
374
383
|
return wrapper;
|
|
375
384
|
}
|
|
376
385
|
|
|
386
|
+
// Sibling wrappers sorted by their slot name
|
|
387
|
+
const siblingWrappers = [...wrapper.parentElement.children].sort((a, b) => {
|
|
388
|
+
return this.__parseSlotIndex(a.slot) - this.__parseSlotIndex(b.slot);
|
|
389
|
+
});
|
|
390
|
+
|
|
377
391
|
// Starting from the given wrapper element, iterates through the siblings in the given direction
|
|
378
392
|
// to find the closest wrapper that represents an item in the dashboard's items array
|
|
379
393
|
const findSiblingWrapper = (wrapper, dir) => {
|
|
@@ -381,7 +395,8 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
381
395
|
if (this.__isActiveWrapper(wrapper)) {
|
|
382
396
|
return wrapper;
|
|
383
397
|
}
|
|
384
|
-
|
|
398
|
+
const currentIndex = siblingWrappers.indexOf(wrapper);
|
|
399
|
+
wrapper = dir === 1 ? siblingWrappers[currentIndex + 1] : siblingWrappers[currentIndex - 1];
|
|
385
400
|
}
|
|
386
401
|
};
|
|
387
402
|
|
|
@@ -412,7 +427,7 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
|
|
|
412
427
|
wrapper.dragging = this.__widgetReorderController.draggedItem === item;
|
|
413
428
|
wrapper['first-child'] = item === getItemsArrayOfItem(item, this.items)[0];
|
|
414
429
|
wrapper['last-child'] = item === getItemsArrayOfItem(item, this.items).slice(-1)[0];
|
|
415
|
-
wrapper.i18n = this.
|
|
430
|
+
wrapper.i18n = this.__effectiveI18n;
|
|
416
431
|
}
|
|
417
432
|
|
|
418
433
|
/** @private */
|
|
@@ -64,9 +64,9 @@ const section = css`
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
:host([dragging]) {
|
|
67
|
-
background: var(--
|
|
68
|
-
outline: var(--
|
|
69
|
-
box-shadow: 0 0 0 var(--_section-outline-offset) var(--
|
|
67
|
+
background: var(--_vaadin-dashboard-drop-target-background-color);
|
|
68
|
+
outline: var(--_vaadin-dashboard-drop-target-border);
|
|
69
|
+
box-shadow: 0 0 0 var(--_section-outline-offset) var(--_vaadin-dashboard-drop-target-background-color);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/* Accessible move mode controls */
|
|
@@ -4,32 +4,37 @@ import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
|
4
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
5
5
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
6
|
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
7
|
-
import { addGlobalThemeStyles } from '@vaadin/vaadin-themable-mixin/register-styles';
|
|
8
7
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
8
|
|
|
10
|
-
/* Global styles */
|
|
11
|
-
const dashboardWidgetProps = css`
|
|
12
|
-
html {
|
|
13
|
-
--vaadin-dashboard-widget-background: var(--lumo-base-color);
|
|
14
|
-
--vaadin-dashboard-widget-border-radius: var(--lumo-border-radius-l);
|
|
15
|
-
--vaadin-dashboard-widget-border-width: 1px;
|
|
16
|
-
--vaadin-dashboard-widget-border-color: var(--lumo-contrast-20pct);
|
|
17
|
-
--vaadin-dashboard-widget-shadow: 0 0 0 0 transparent;
|
|
18
|
-
--vaadin-dashboard-widget-editable-shadow: var(--lumo-box-shadow-s);
|
|
19
|
-
--vaadin-dashboard-widget-selected-shadow: 0 2px 4px -1px var(--lumo-primary-color-10pct),
|
|
20
|
-
0 3px 12px -1px var(--lumo-primary-color-50pct);
|
|
21
|
-
--vaadin-dashboard-drop-target-background-color: var(--lumo-primary-color-10pct);
|
|
22
|
-
--vaadin-dashboard-drop-target-border: 1px dashed var(--lumo-primary-color-50pct);
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
addGlobalThemeStyles('dashboard-widget-props', dashboardWidgetProps);
|
|
26
|
-
|
|
27
9
|
/* Styles shared between widgets and sections */
|
|
28
10
|
const dashboardWidgetAndSection = css`
|
|
29
11
|
/* stylelint-disable rule-empty-line-before */
|
|
30
12
|
/* stylelint-disable length-zero-no-unit */
|
|
31
13
|
|
|
32
14
|
:host {
|
|
15
|
+
--_vaadin-dashboard-widget-background: var(--vaadin-dashboard-widget-background, var(--lumo-base-color));
|
|
16
|
+
--_vaadin-dashboard-widget-border-radius: var(--vaadin-dashboard-widget-border-radius, var(--lumo-border-radius-l));
|
|
17
|
+
--_vaadin-dashboard-widget-border-width: var(--vaadin-dashboard-widget-border-width, 1px);
|
|
18
|
+
--_vaadin-dashboard-widget-border-color: var(--vaadin-dashboard-widget-border-color, var(--lumo-contrast-20pct));
|
|
19
|
+
--_vaadin-dashboard-widget-shadow: var(--vaadin-dashboard-widget-shadow, 0 0 0 0 transparent);
|
|
20
|
+
--_vaadin-dashboard-widget-editable-shadow: var(
|
|
21
|
+
--vaadin-dashboard-widget-editable-shadow,
|
|
22
|
+
var(--lumo-box-shadow-s)
|
|
23
|
+
);
|
|
24
|
+
--_vaadin-dashboard-widget-selected-shadow: var(
|
|
25
|
+
--vaadin-dashboard-widget-selected-shadow,
|
|
26
|
+
0 2px 4px -1px var(--lumo-primary-color-10pct),
|
|
27
|
+
0 3px 12px -1px var(--lumo-primary-color-50pct)
|
|
28
|
+
);
|
|
29
|
+
--_vaadin-dashboard-drop-target-background-color: var(
|
|
30
|
+
--vaadin-dashboard-drop-target-background-color,
|
|
31
|
+
var(--lumo-primary-color-10pct)
|
|
32
|
+
);
|
|
33
|
+
--_vaadin-dashboard-drop-target-border: var(
|
|
34
|
+
--vaadin-dashboard-drop-target-border,
|
|
35
|
+
1px dashed var(--lumo-primary-color-50pct)
|
|
36
|
+
);
|
|
37
|
+
|
|
33
38
|
color: var(--lumo-body-text-color);
|
|
34
39
|
font-family: var(--lumo-font-family);
|
|
35
40
|
font-size: var(--lumo-font-size-m);
|
|
@@ -137,17 +142,17 @@ const dashboardWidgetAndSection = css`
|
|
|
137
142
|
/* Widget styles */
|
|
138
143
|
const dashboardWidget = css`
|
|
139
144
|
:host {
|
|
140
|
-
background: var(--
|
|
141
|
-
border-radius: var(--
|
|
142
|
-
--_border-shadow: 0 0 0 var(--
|
|
143
|
-
--_shadow: var(--
|
|
145
|
+
background: var(--_vaadin-dashboard-widget-background);
|
|
146
|
+
border-radius: var(--_vaadin-dashboard-widget-border-radius);
|
|
147
|
+
--_border-shadow: 0 0 0 var(--_vaadin-dashboard-widget-border-width) var(--_vaadin-dashboard-widget-border-color);
|
|
148
|
+
--_shadow: var(--_vaadin-dashboard-widget-shadow);
|
|
144
149
|
box-shadow: var(--_shadow), var(--_border-shadow);
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
/* Widget states */
|
|
148
153
|
|
|
149
154
|
:host([editable]) {
|
|
150
|
-
--_shadow: var(--
|
|
155
|
+
--_shadow: var(--_vaadin-dashboard-widget-editable-shadow);
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
:host([focused]) {
|
|
@@ -155,19 +160,19 @@ const dashboardWidget = css`
|
|
|
155
160
|
}
|
|
156
161
|
|
|
157
162
|
:host([selected]) {
|
|
158
|
-
--_shadow: var(--
|
|
163
|
+
--_shadow: var(--_vaadin-dashboard-widget-selected-shadow);
|
|
159
164
|
background: var(--lumo-primary-color-10pct);
|
|
160
165
|
}
|
|
161
166
|
|
|
162
167
|
:host([dragging]) {
|
|
163
168
|
box-shadow: none;
|
|
164
|
-
background: var(--
|
|
165
|
-
border: var(--
|
|
169
|
+
background: var(--_vaadin-dashboard-drop-target-background-color);
|
|
170
|
+
border: var(--_vaadin-dashboard-drop-target-border);
|
|
166
171
|
}
|
|
167
172
|
|
|
168
173
|
:host([resizing])::after {
|
|
169
|
-
background: var(--
|
|
170
|
-
border: var(--
|
|
174
|
+
background: var(--_vaadin-dashboard-drop-target-background-color);
|
|
175
|
+
border: var(--_vaadin-dashboard-drop-target-border);
|
|
171
176
|
}
|
|
172
177
|
|
|
173
178
|
/* Widget parts */
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/dashboard",
|
|
4
|
-
"version": "24.7.0-
|
|
4
|
+
"version": "24.7.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"name": "vaadin-dashboard",
|
|
139
|
-
"description": "A responsive, grid-based dashboard layout component\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-
|
|
139
|
+
"description": "A responsive, grid-based dashboard layout component\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/elements/vaadin-dashboard#property-renderer) property.\n\nThe widgets and the sections will be generated and configured based on the renderer and the items provided.\n\n```html\n<vaadin-dashboard></vaadin-dashboard>\n```\n```js\nconst dashboard = document.querySelector('vaadin-dashboard');\n\ndashboard.items = [\n { title: 'Widget 1 title', content: 'Text 1', rowspan: 2 },\n { title: 'Widget 2 title', content: 'Text 2', colspan: 2 },\n {\n title: 'Section title',\n items: [{ title: 'Widget in section title', content: 'Text 3' }]\n },\n // ... more items\n];\n\ndashboard.renderer = (root, _dashboard, { item }) => {\n const widget = root.firstElementChild || document.createElement('vaadin-dashboard-widget');\n if (!root.contains(widget)) {\n root.appendChild(widget);\n }\n widget.widgetTitle = item.title;\n widget.textContent = item.content;\n};\n```\n\n### Styling\n\nThe following custom properties are available:\n\nCustom Property | Description\n------------------------------------|-------------\n`--vaadin-dashboard-col-min-width` | minimum column width of the dashboard\n`--vaadin-dashboard-col-max-width` | maximum column width of the dashboard\n`--vaadin-dashboard-row-min-height` | minimum row height of the dashboard\n`--vaadin-dashboard-col-max-count` | maximum column count of the dashboard\n`--vaadin-dashboard-gap` | gap between child elements. Must be in length units (0 is not allowed, 0px is)\n`--vaadin-dashboard-padding` | space around the dashboard's outer edges. Must be in length units (0 is not allowed, 0px is)\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`editable` | Set when the dashboard is editable.\n`dense-layout` | Set when the dashboard is in dense mode.\n`item-selected`| Set when an item is selected.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
140
140
|
"attributes": [
|
|
141
141
|
{
|
|
142
142
|
"name": "dense-layout",
|
|
@@ -181,6 +181,15 @@
|
|
|
181
181
|
]
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
|
+
{
|
|
185
|
+
"name": "i18n",
|
|
186
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following structure and default values:\n```\n{\n selectSection: 'Select section for editing',\n selectWidget: 'Select widget for editing',\n remove: 'Remove',\n resize: 'Resize',\n resizeApply: 'Apply',\n resizeShrinkWidth: 'Shrink width',\n resizeGrowWidth: 'Grow width',\n resizeShrinkHeight: 'Shrink height',\n resizeGrowHeight: 'Grow height',\n move: 'Move',\n moveApply: 'Apply',\n moveForward: 'Move Forward',\n moveBackward: 'Move Backward',\n}\n```",
|
|
187
|
+
"value": {
|
|
188
|
+
"type": [
|
|
189
|
+
"DashboardI18n"
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
},
|
|
184
193
|
{
|
|
185
194
|
"name": "items",
|
|
186
195
|
"description": "An array containing the items of the dashboard",
|
|
@@ -213,17 +222,6 @@
|
|
|
213
222
|
"undefined"
|
|
214
223
|
]
|
|
215
224
|
}
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
"name": "i18n",
|
|
219
|
-
"description": "The object used to localize this component.\n\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nThe object has the following structure and default values:\n```\n{\n selectSection: 'Select section for editing',\n selectWidget: 'Select widget for editing',\n remove: 'Remove',\n resize: 'Resize',\n resizeApply: 'Apply',\n resizeShrinkWidth: 'Shrink width',\n resizeGrowWidth: 'Grow width',\n resizeShrinkHeight: 'Shrink height',\n resizeGrowHeight: 'Grow height',\n move: 'Move',\n moveApply: 'Apply',\n moveForward: 'Move Forward',\n moveBackward: 'Move Backward',\n}\n```",
|
|
220
|
-
"value": {
|
|
221
|
-
"type": [
|
|
222
|
-
"Object",
|
|
223
|
-
"null",
|
|
224
|
-
"undefined"
|
|
225
|
-
]
|
|
226
|
-
}
|
|
227
225
|
}
|
|
228
226
|
],
|
|
229
227
|
"events": [
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/dashboard",
|
|
4
|
-
"version": "24.7.0-
|
|
4
|
+
"version": "24.7.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"name": "vaadin-dashboard",
|
|
61
|
-
"description": "A responsive, grid-based dashboard layout component\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-
|
|
61
|
+
"description": "A responsive, grid-based dashboard layout component\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/elements/vaadin-dashboard#property-renderer) property.\n\nThe widgets and the sections will be generated and configured based on the renderer and the items provided.\n\n```html\n<vaadin-dashboard></vaadin-dashboard>\n```\n```js\nconst dashboard = document.querySelector('vaadin-dashboard');\n\ndashboard.items = [\n { title: 'Widget 1 title', content: 'Text 1', rowspan: 2 },\n { title: 'Widget 2 title', content: 'Text 2', colspan: 2 },\n {\n title: 'Section title',\n items: [{ title: 'Widget in section title', content: 'Text 3' }]\n },\n // ... more items\n];\n\ndashboard.renderer = (root, _dashboard, { item }) => {\n const widget = root.firstElementChild || document.createElement('vaadin-dashboard-widget');\n if (!root.contains(widget)) {\n root.appendChild(widget);\n }\n widget.widgetTitle = item.title;\n widget.textContent = item.content;\n};\n```\n\n### Styling\n\nThe following custom properties are available:\n\nCustom Property | Description\n------------------------------------|-------------\n`--vaadin-dashboard-col-min-width` | minimum column width of the dashboard\n`--vaadin-dashboard-col-max-width` | maximum column width of the dashboard\n`--vaadin-dashboard-row-min-height` | minimum row height of the dashboard\n`--vaadin-dashboard-col-max-count` | maximum column count of the dashboard\n`--vaadin-dashboard-gap` | gap between child elements. Must be in length units (0 is not allowed, 0px is)\n`--vaadin-dashboard-padding` | space around the dashboard's outer edges. Must be in length units (0 is not allowed, 0px is)\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`editable` | Set when the dashboard is editable.\n`dense-layout` | Set when the dashboard is in dense mode.\n`item-selected`| Set when an item is selected.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
62
62
|
"extension": true,
|
|
63
63
|
"attributes": [
|
|
64
64
|
{
|
|
@@ -76,22 +76,22 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
"name": ".
|
|
80
|
-
"description": "
|
|
79
|
+
"name": ".i18n",
|
|
80
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following structure and default values:\n```\n{\n selectSection: 'Select section for editing',\n selectWidget: 'Select widget for editing',\n remove: 'Remove',\n resize: 'Resize',\n resizeApply: 'Apply',\n resizeShrinkWidth: 'Shrink width',\n resizeGrowWidth: 'Grow width',\n resizeShrinkHeight: 'Shrink height',\n resizeGrowHeight: 'Grow height',\n move: 'Move',\n moveApply: 'Apply',\n moveForward: 'Move Forward',\n moveBackward: 'Move Backward',\n}\n```",
|
|
81
81
|
"value": {
|
|
82
82
|
"kind": "expression"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
"name": ".
|
|
87
|
-
"description": "
|
|
86
|
+
"name": ".items",
|
|
87
|
+
"description": "An array containing the items of the dashboard",
|
|
88
88
|
"value": {
|
|
89
89
|
"kind": "expression"
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
|
-
"name": ".
|
|
94
|
-
"description": "
|
|
93
|
+
"name": ".renderer",
|
|
94
|
+
"description": "Custom function for rendering a widget for each dashboard item.\nPlacing something else than a widget in the wrapper is not supported.\nReceives three arguments:\n\n- `root` The container for the widget.\n- `dashboard` The reference to the `<vaadin-dashboard>` element.\n- `model` The object with the properties related with the rendered\n item, contains:\n - `model.item` The item.",
|
|
95
95
|
"value": {
|
|
96
96
|
"kind": "expression"
|
|
97
97
|
}
|