@vaadin/dashboard 25.0.3 → 25.1.0-alpha2

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": "25.0.3",
3
+ "version": "25.1.0-alpha2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,23 +36,24 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@open-wc/dedupe-mixin": "^1.3.0",
39
- "@vaadin/a11y-base": "~25.0.3",
40
- "@vaadin/button": "~25.0.3",
41
- "@vaadin/component-base": "~25.0.3",
42
- "@vaadin/vaadin-themable-mixin": "~25.0.3",
39
+ "@vaadin/a11y-base": "25.1.0-alpha2",
40
+ "@vaadin/button": "25.1.0-alpha2",
41
+ "@vaadin/component-base": "25.1.0-alpha2",
42
+ "@vaadin/vaadin-themable-mixin": "25.1.0-alpha2",
43
43
  "lit": "^3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@vaadin/aura": "~25.0.3",
47
- "@vaadin/chai-plugins": "~25.0.3",
48
- "@vaadin/test-runner-commands": "~25.0.3",
46
+ "@vaadin/aura": "25.1.0-alpha2",
47
+ "@vaadin/chai-plugins": "25.1.0-alpha2",
48
+ "@vaadin/test-runner-commands": "25.1.0-alpha2",
49
49
  "@vaadin/testing-helpers": "^2.0.0",
50
- "@vaadin/vaadin-lumo-styles": "~25.0.3"
50
+ "@vaadin/vaadin-lumo-styles": "25.1.0-alpha2",
51
+ "sinon": "^21.0.0"
51
52
  },
52
53
  "cvdlName": "vaadin-dashboard",
53
54
  "web-types": [
54
55
  "web-types.json",
55
56
  "web-types.lit.json"
56
57
  ],
57
- "gitHead": "a4b57a083b721045770f1f3700edd699872cd7fb"
58
+ "gitHead": "dfeb6e14643ec923e5505ca645f7354c6dc170ec"
58
59
  }
@@ -85,6 +85,17 @@ export type DashboardItemResizedEvent<TItem extends DashboardItem> = CustomEvent
85
85
  items: Array<TItem | DashboardSectionItem<TItem>>;
86
86
  }>;
87
87
 
88
+ /**
89
+ * Fired before an item is removed. Calling preventDefault() on the event will cancel the removal.
90
+ */
91
+ export type DashboardItemBeforeRemoveEvent<TItem extends DashboardItem> = CustomEvent<{
92
+ item: TItem | DashboardSectionItem<TItem>;
93
+
94
+ items: Array<TItem | DashboardSectionItem<TItem>>;
95
+
96
+ section: DashboardSectionItem<TItem> | undefined;
97
+ }>;
98
+
88
99
  /**
89
100
  * Fired when an item was removed
90
101
  */
@@ -92,6 +103,8 @@ export type DashboardItemRemovedEvent<TItem extends DashboardItem> = CustomEvent
92
103
  item: TItem | DashboardSectionItem<TItem>;
93
104
 
94
105
  items: Array<TItem | DashboardSectionItem<TItem>>;
106
+
107
+ section: DashboardSectionItem<TItem> | undefined;
95
108
  }>;
96
109
 
97
110
  /**
@@ -123,6 +136,8 @@ export interface DashboardCustomEventMap<TItem extends DashboardItem> {
123
136
 
124
137
  'dashboard-item-resized': DashboardItemResizedEvent<TItem>;
125
138
 
139
+ 'dashboard-item-before-remove': DashboardItemBeforeRemoveEvent<TItem>;
140
+
126
141
  'dashboard-item-removed': DashboardItemRemovedEvent<TItem>;
127
142
 
128
143
  'dashboard-item-selected-changed': DashboardItemSelectedChangedEvent<TItem>;
@@ -93,6 +93,7 @@ import { WidgetResizeController } from './widget-resize-controller.js';
93
93
  *
94
94
  * @fires {CustomEvent} dashboard-item-moved - Fired when an item was moved
95
95
  * @fires {CustomEvent} dashboard-item-resized - Fired when an item was resized
96
+ * @fires {CustomEvent} dashboard-item-before-remove - Fired before an item is removed. Calling preventDefault() on the event will cancel the removal.
96
97
  * @fires {CustomEvent} dashboard-item-removed - Fired when an item was removed
97
98
  * @fires {CustomEvent} dashboard-item-selected-changed - Fired when an item selected state changed
98
99
  * @fires {CustomEvent} dashboard-item-move-mode-changed - Fired when an item move mode changed
@@ -427,12 +428,25 @@ class Dashboard extends DashboardLayoutMixin(
427
428
  e.stopImmediatePropagation();
428
429
  const item = getElementItem(e.target);
429
430
  const items = getItemsArrayOfItem(item, this.items);
431
+ const section = this.items.find((i) => i.items && i.items.includes(item));
432
+
433
+ // Fire before-remove event
434
+ const beforeRemoveEvent = new CustomEvent('dashboard-item-before-remove', {
435
+ cancelable: true,
436
+ detail: { item, items: this.items, section },
437
+ });
438
+ this.dispatchEvent(beforeRemoveEvent);
439
+
440
+ // Check if removal was prevented
441
+ if (beforeRemoveEvent.defaultPrevented) {
442
+ return;
443
+ }
444
+
445
+ // Proceed with removal
430
446
  items.splice(items.indexOf(item), 1);
431
447
  this.items = [...this.items];
432
448
  this.toggleAttribute('item-selected', false);
433
- this.dispatchEvent(
434
- new CustomEvent('dashboard-item-removed', { cancelable: true, detail: { item, items: this.items } }),
435
- );
449
+ this.dispatchEvent(new CustomEvent('dashboard-item-removed', { detail: { item, items: this.items, section } }));
436
450
  }
437
451
 
438
452
  /** @private */
@@ -516,6 +530,12 @@ class Dashboard extends DashboardLayoutMixin(
516
530
  * @event dashboard-item-resized
517
531
  */
518
532
 
533
+ /**
534
+ * Fired before an item is removed
535
+ *
536
+ * @event dashboard-item-before-remove
537
+ */
538
+
519
539
  /**
520
540
  * Fired when an item was removed
521
541
  *
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": "25.0.3",
4
+ "version": "25.1.0-alpha2",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -158,7 +158,7 @@
158
158
  },
159
159
  {
160
160
  "name": "vaadin-dashboard",
161
- "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/25.0.3/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/25.0.3/#/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.",
161
+ "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/25.1.0-alpha2/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/25.1.0-alpha2/#/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.",
162
162
  "attributes": [
163
163
  {
164
164
  "name": "dense-layout",
@@ -278,6 +278,10 @@
278
278
  }
279
279
  ],
280
280
  "events": [
281
+ {
282
+ "name": "dashboard-item-before-remove",
283
+ "description": "Fired before an item is removed"
284
+ },
281
285
  {
282
286
  "name": "dashboard-item-move-mode-changed",
283
287
  "description": "Fired when an item move mode changed"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/dashboard",
4
- "version": "25.0.3",
4
+ "version": "25.1.0-alpha2",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -65,7 +65,7 @@
65
65
  },
66
66
  {
67
67
  "name": "vaadin-dashboard",
68
- "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/25.0.3/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/25.0.3/#/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.",
68
+ "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/25.1.0-alpha2/#/elements/vaadin-dashboard#property-items) property.\nSet a renderer function to the [`renderer`](https://cdn.vaadin.com/vaadin-web-components/25.1.0-alpha2/#/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.",
69
69
  "extension": true,
70
70
  "attributes": [
71
71
  {
@@ -110,6 +110,13 @@
110
110
  "kind": "expression"
111
111
  }
112
112
  },
113
+ {
114
+ "name": "@dashboard-item-before-remove",
115
+ "description": "Fired before an item is removed",
116
+ "value": {
117
+ "kind": "expression"
118
+ }
119
+ },
113
120
  {
114
121
  "name": "@dashboard-item-move-mode-changed",
115
122
  "description": "Fired when an item move mode changed",