@vaadin/dashboard 24.6.0-alpha8 → 24.6.0-alpha9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/dashboard",
3
- "version": "24.6.0-alpha8",
3
+ "version": "24.6.0-alpha9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,15 +37,15 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
- "@vaadin/button": "24.6.0-alpha8",
41
- "@vaadin/component-base": "24.6.0-alpha8",
42
- "@vaadin/vaadin-lumo-styles": "24.6.0-alpha8",
43
- "@vaadin/vaadin-material-styles": "24.6.0-alpha8",
44
- "@vaadin/vaadin-themable-mixin": "24.6.0-alpha8",
40
+ "@vaadin/button": "24.6.0-alpha9",
41
+ "@vaadin/component-base": "24.6.0-alpha9",
42
+ "@vaadin/vaadin-lumo-styles": "24.6.0-alpha9",
43
+ "@vaadin/vaadin-material-styles": "24.6.0-alpha9",
44
+ "@vaadin/vaadin-themable-mixin": "24.6.0-alpha9",
45
45
  "lit": "^3.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@vaadin/chai-plugins": "24.6.0-alpha8",
48
+ "@vaadin/chai-plugins": "24.6.0-alpha9",
49
49
  "@vaadin/testing-helpers": "^1.0.0"
50
50
  },
51
51
  "cvdlName": "vaadin-dashboard",
@@ -53,5 +53,5 @@
53
53
  "web-types.json",
54
54
  "web-types.lit.json"
55
55
  ],
56
- "gitHead": "a11e1510c4caa08775b202714f5fc1198c22132a"
56
+ "gitHead": "e303d77ba20c3089c9998be9a318733d9ec5b53c"
57
57
  }
@@ -22,6 +22,10 @@ class DashboardButton extends ButtonMixin(ElementMixin(ThemableMixin(PolylitMixi
22
22
  return 'vaadin-dashboard-button';
23
23
  }
24
24
 
25
+ static get experimental() {
26
+ return 'dashboardComponent';
27
+ }
28
+
25
29
  static get styles() {
26
30
  return buttonStyles;
27
31
  }
@@ -59,6 +59,14 @@ class DashboardLayout extends DashboardLayoutMixin(ElementMixin(ThemableMixin(Po
59
59
  return 'vaadin-dashboard-layout';
60
60
  }
61
61
 
62
+ static get experimental() {
63
+ return 'dashboardComponent';
64
+ }
65
+
66
+ static get cvdlName() {
67
+ return 'vaadin-dashboard';
68
+ }
69
+
62
70
  /** @protected */
63
71
  render() {
64
72
  return html`<div id="grid"><slot></slot></div>`;
@@ -74,6 +74,10 @@ class DashboardSection extends DashboardItemMixin(ElementMixin(ThemableMixin(Pol
74
74
  return 'vaadin-dashboard-section';
75
75
  }
76
76
 
77
+ static get experimental() {
78
+ return 'dashboardComponent';
79
+ }
80
+
77
81
  static get styles() {
78
82
  return [
79
83
  css`
@@ -99,6 +99,10 @@ class DashboardWidget extends DashboardItemMixin(ElementMixin(ThemableMixin(Poly
99
99
  return 'vaadin-dashboard-widget';
100
100
  }
101
101
 
102
+ static get experimental() {
103
+ return 'dashboardComponent';
104
+ }
105
+
102
106
  static get styles() {
103
107
  return [
104
108
  css`
@@ -106,6 +106,10 @@ class Dashboard extends DashboardLayoutMixin(ElementMixin(ThemableMixin(PolylitM
106
106
  return 'vaadin-dashboard';
107
107
  }
108
108
 
109
+ static get experimental() {
110
+ return 'dashboardComponent';
111
+ }
112
+
109
113
  static get cvdlName() {
110
114
  return 'vaadin-dashboard';
111
115
  }
@@ -11,6 +11,7 @@
11
11
  import { getElementItem, getItemsArrayOfItem, itemsEqual, WRAPPER_LOCAL_NAME } from './vaadin-dashboard-helpers.js';
12
12
 
13
13
  const REORDER_EVENT_TIMEOUT = 200;
14
+ const REORDER_MOVE_THRESHOLD = 10;
14
15
 
15
16
  /**
16
17
  * A controller to widget reordering inside a dashboard.
@@ -64,6 +65,29 @@ export class WidgetReorderController {
64
65
  return;
65
66
  }
66
67
 
68
+ // The location against which we measure the drag distance
69
+ this.__startX ||= e.clientX;
70
+ this.__startY ||= e.clientY;
71
+
72
+ // Delta values for the current drag event
73
+ const currentDx = e.clientX - (this.__previousX || e.clientX);
74
+ const currentDy = e.clientY - (this.__previousY || e.clientY);
75
+ this.__previousX = e.clientX;
76
+ this.__previousY = e.clientY;
77
+
78
+ if (currentDx && this.__dx && Math.sign(currentDx) !== Math.sign(this.__dx)) {
79
+ // If the direction of the drag changes, reset the start position
80
+ this.__startX = e.clientX;
81
+ }
82
+ if (currentDy && this.__dy && Math.sign(currentDy) !== Math.sign(this.__dy)) {
83
+ // If the direction of the drag changes, reset the start position
84
+ this.__startY = e.clientY;
85
+ }
86
+
87
+ // The delta values for the drag event against the start position
88
+ this.__dx = e.clientX - this.__startX;
89
+ this.__dy = e.clientY - this.__startY;
90
+
67
91
  e.preventDefault();
68
92
  e.dataTransfer.dropEffect = 'move';
69
93
 
@@ -88,7 +112,15 @@ export class WidgetReorderController {
88
112
  }
89
113
 
90
114
  // Check if the dragged element is dragged enough over the target element
91
- if (!this.__reordering && this.__isDraggedOver(draggedElement, targetElement, e.clientX, e.clientY)) {
115
+ if (
116
+ !this.__reordering &&
117
+ this.__isDraggedOver(draggedElement, targetElement, {
118
+ x: e.clientX,
119
+ y: e.clientY,
120
+ dx: this.__dx,
121
+ dy: this.__dy,
122
+ })
123
+ ) {
92
124
  // Prevent reordering multiple times in quick succession
93
125
  this.__reordering = true;
94
126
  setTimeout(() => {
@@ -109,6 +141,13 @@ export class WidgetReorderController {
109
141
  return;
110
142
  }
111
143
 
144
+ this.__previousX = null;
145
+ this.__previousY = null;
146
+ this.__startX = null;
147
+ this.__startY = null;
148
+ this.__dx = null;
149
+ this.__dy = null;
150
+
112
151
  // If the originally dragged element is restored to the DOM (as a direct child of the host),
113
152
  // to make sure "dragend" event gets dispatched, remove it to avoid duplicates
114
153
  if (this.__draggedElement.parentElement === this.host) {
@@ -169,21 +208,21 @@ export class WidgetReorderController {
169
208
  * of the drag event.
170
209
  * @private
171
210
  */
172
- __isDraggedOver(draggedElement, targetElement, x, y) {
211
+ __isDraggedOver(draggedElement, targetElement, { x, y, dx, dy }) {
173
212
  const draggedPos = draggedElement.getBoundingClientRect();
174
213
  const targetPos = targetElement.getBoundingClientRect();
175
214
  if (draggedPos.top >= targetPos.bottom) {
176
215
  // target is on a row above the dragged widget
177
- return y < targetPos.top + targetPos.height / 2;
216
+ return y < targetPos.bottom && dy < -REORDER_MOVE_THRESHOLD;
178
217
  } else if (draggedPos.bottom <= targetPos.top) {
179
218
  // target is on a row below the dragged widget
180
- return y > targetPos.top + targetPos.height / 2;
219
+ return y > targetPos.top && dy > REORDER_MOVE_THRESHOLD;
181
220
  } else if (draggedPos.left >= targetPos.right) {
182
221
  // target is on a column to the left of the dragged widget
183
- return x < targetPos.left + targetPos.width / 2;
222
+ return x < targetPos.right && dx < -REORDER_MOVE_THRESHOLD;
184
223
  } else if (draggedPos.right <= targetPos.left) {
185
224
  // target is on a column to the right of the dragged widget
186
- return x > targetPos.left + targetPos.width / 2;
225
+ return x > targetPos.left && dx > REORDER_MOVE_THRESHOLD;
187
226
  }
188
227
  }
189
228
 
@@ -2,7 +2,7 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
2
2
 
3
3
  export const dashboardLayoutStyles = css`
4
4
  #grid {
5
- --_vaadin-dashboard-default-spacing: var(--lumo-space-xl);
5
+ --_vaadin-dashboard-default-spacing: var(--lumo-space-l);
6
6
  }
7
7
  `;
8
8
 
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.6.0-alpha8",
4
+ "version": "24.6.0-alpha9",
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.6.0-alpha8/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha8/#/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-spacing` | spacing between child elements and space around its 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.",
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.6.0-alpha9/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha9/#/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-spacing` | spacing between child elements and space around its 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",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/dashboard",
4
- "version": "24.6.0-alpha8",
4
+ "version": "24.6.0-alpha9",
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.6.0-alpha8/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha8/#/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-spacing` | spacing between child elements and space around its 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.",
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.6.0-alpha9/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha9/#/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-spacing` | spacing between child elements and space around its 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
  {