@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.
Files changed (59) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +34 -0
  3. package/package.json +57 -0
  4. package/src/keyboard-controller.js +107 -0
  5. package/src/vaadin-dashboard-button.js +45 -0
  6. package/src/vaadin-dashboard-helpers.js +99 -0
  7. package/src/vaadin-dashboard-item-mixin.d.ts +20 -0
  8. package/src/vaadin-dashboard-item-mixin.js +355 -0
  9. package/src/vaadin-dashboard-layout-mixin.d.ts +28 -0
  10. package/src/vaadin-dashboard-layout-mixin.js +148 -0
  11. package/src/vaadin-dashboard-layout.d.ts +56 -0
  12. package/src/vaadin-dashboard-layout.js +70 -0
  13. package/src/vaadin-dashboard-section.d.ts +76 -0
  14. package/src/vaadin-dashboard-section.js +203 -0
  15. package/src/vaadin-dashboard-styles.js +143 -0
  16. package/src/vaadin-dashboard-widget.d.ts +101 -0
  17. package/src/vaadin-dashboard-widget.js +271 -0
  18. package/src/vaadin-dashboard.d.ts +290 -0
  19. package/src/vaadin-dashboard.js +489 -0
  20. package/src/widget-reorder-controller.js +247 -0
  21. package/src/widget-resize-controller.js +214 -0
  22. package/theme/lumo/vaadin-dashboard-button-styles.d.ts +2 -0
  23. package/theme/lumo/vaadin-dashboard-button-styles.js +8 -0
  24. package/theme/lumo/vaadin-dashboard-button.d.ts +1 -0
  25. package/theme/lumo/vaadin-dashboard-button.js +1 -0
  26. package/theme/lumo/vaadin-dashboard-layout-styles.d.ts +1 -0
  27. package/theme/lumo/vaadin-dashboard-layout-styles.js +11 -0
  28. package/theme/lumo/vaadin-dashboard-layout.d.ts +2 -0
  29. package/theme/lumo/vaadin-dashboard-layout.js +2 -0
  30. package/theme/lumo/vaadin-dashboard-section-styles.d.ts +5 -0
  31. package/theme/lumo/vaadin-dashboard-section-styles.js +22 -0
  32. package/theme/lumo/vaadin-dashboard-section.d.ts +3 -0
  33. package/theme/lumo/vaadin-dashboard-section.js +3 -0
  34. package/theme/lumo/vaadin-dashboard-styles.d.ts +1 -0
  35. package/theme/lumo/vaadin-dashboard-styles.js +16 -0
  36. package/theme/lumo/vaadin-dashboard-widget-styles.d.ts +9 -0
  37. package/theme/lumo/vaadin-dashboard-widget-styles.js +242 -0
  38. package/theme/lumo/vaadin-dashboard-widget.d.ts +3 -0
  39. package/theme/lumo/vaadin-dashboard-widget.js +3 -0
  40. package/theme/lumo/vaadin-dashboard.d.ts +4 -0
  41. package/theme/lumo/vaadin-dashboard.js +4 -0
  42. package/theme/material/vaadin-dashboard-layout.d.ts +1 -0
  43. package/theme/material/vaadin-dashboard-layout.js +1 -0
  44. package/theme/material/vaadin-dashboard-section.d.ts +1 -0
  45. package/theme/material/vaadin-dashboard-section.js +1 -0
  46. package/theme/material/vaadin-dashboard-widget.d.ts +1 -0
  47. package/theme/material/vaadin-dashboard-widget.js +1 -0
  48. package/theme/material/vaadin-dashboard.d.ts +3 -0
  49. package/theme/material/vaadin-dashboard.js +3 -0
  50. package/vaadin-dashboard-layout.d.ts +1 -0
  51. package/vaadin-dashboard-layout.js +3 -0
  52. package/vaadin-dashboard-section.d.ts +1 -0
  53. package/vaadin-dashboard-section.js +3 -0
  54. package/vaadin-dashboard-widget.d.ts +1 -0
  55. package/vaadin-dashboard-widget.js +3 -0
  56. package/vaadin-dashboard.d.ts +1 -0
  57. package/vaadin-dashboard.js +3 -0
  58. package/web-types.json +260 -0
  59. package/web-types.lit.json +146 -0
package/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ This program is available under Vaadin Commercial License and Service Terms.
2
+ See https://vaadin.com/commercial-license-and-service-terms for the full
3
+ license.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @vaadin/dashboard
2
+
3
+ A responsive, grid-based dashboard layout component
4
+
5
+ > ℹ️  A commercial Vaadin [subscription](https://vaadin.com/pricing) is required to use Dashboard in your project.
6
+
7
+ [Documentation + Live Demo ↗](https://vaadin.com/docs/latest/components/dashboard)
8
+
9
+ [![npm version](https://badgen.net/npm/v/@vaadin/dashboard)](https://www.npmjs.com/package/@vaadin/dashboard)
10
+
11
+ ## Installation
12
+
13
+ Install the component:
14
+
15
+ ```sh
16
+ npm i @vaadin/dashboard
17
+ ```
18
+
19
+ Once installed, import the component in your application:
20
+
21
+ ```js
22
+ import '@vaadin/dashboard';
23
+ ```
24
+
25
+ ## Contributing
26
+
27
+ Read the [contributing guide](https://vaadin.com/docs/latest/contributing) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
28
+
29
+ ## License
30
+
31
+ This program is available under Vaadin Commercial License and Service Terms. For license terms, see LICENSE.
32
+
33
+ Vaadin collects usage statistics at development time to improve this product.
34
+ For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@vaadin/dashboard",
3
+ "version": "24.6.0-alpha1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "vaadin-dashboard",
8
+ "license": "SEE LICENSE IN LICENSE",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/vaadin/web-components.git",
12
+ "directory": "packages/dashboard"
13
+ },
14
+ "author": "Vaadin Ltd",
15
+ "homepage": "https://vaadin.com/components",
16
+ "bugs": {
17
+ "url": "https://github.com/vaadin/web-components/issues"
18
+ },
19
+ "main": "vaadin-dashboard.js",
20
+ "module": "vaadin-dashboard.js",
21
+ "type": "module",
22
+ "files": [
23
+ "src",
24
+ "theme",
25
+ "vaadin-*.d.ts",
26
+ "vaadin-*.js",
27
+ "web-types.json",
28
+ "web-types.lit.json"
29
+ ],
30
+ "keywords": [
31
+ "Vaadin",
32
+ "dashboard",
33
+ "responsive",
34
+ "layout",
35
+ "web-components",
36
+ "web-component"
37
+ ],
38
+ "dependencies": {
39
+ "@open-wc/dedupe-mixin": "^1.3.0",
40
+ "@vaadin/button": "24.6.0-alpha1",
41
+ "@vaadin/component-base": "24.6.0-alpha1",
42
+ "@vaadin/vaadin-lumo-styles": "24.6.0-alpha1",
43
+ "@vaadin/vaadin-material-styles": "24.6.0-alpha1",
44
+ "@vaadin/vaadin-themable-mixin": "24.6.0-alpha1",
45
+ "lit": "^3.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@vaadin/chai-plugins": "24.6.0-alpha1",
49
+ "@vaadin/testing-helpers": "^1.0.0"
50
+ },
51
+ "cvdlName": "vaadin-dashboard",
52
+ "web-types": [
53
+ "web-types.json",
54
+ "web-types.lit.json"
55
+ ],
56
+ "gitHead": "ae1fb0e6e7ce925999051c6cc62ba8476264c63f"
57
+ }
@@ -0,0 +1,107 @@
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 { fireMove, fireRemove, fireResize } from './vaadin-dashboard-helpers.js';
12
+
13
+ /**
14
+ * A controller for managing widget/section keyboard interactions.
15
+ */
16
+ export class KeyboardController {
17
+ constructor(host) {
18
+ this.host = host;
19
+
20
+ host.addEventListener('focusout', (e) => this.__focusout(e));
21
+ host.addEventListener('focusin', (e) => this.__focusin(e));
22
+ host.addEventListener('keydown', (e) => this.__keydown(e));
23
+ }
24
+
25
+ /** @private */
26
+ __focusout(e) {
27
+ const focusOutElement = e.composedPath()[0];
28
+ const isHostVisible = !!this.host.offsetHeight;
29
+ const isFocusButtonHidden = getComputedStyle(focusOutElement).display === 'none';
30
+ if (isHostVisible && isFocusButtonHidden) {
31
+ this.host.__focusApply();
32
+ } else {
33
+ this.host.__exitMode();
34
+ this.host.__focused = false;
35
+ this.host.__selected = false;
36
+ }
37
+ }
38
+
39
+ /** @private */
40
+ __focusin(e) {
41
+ if (e.target === this.host) {
42
+ this.host.__focused = true;
43
+ }
44
+ }
45
+
46
+ /** @private */
47
+ __keydown(e) {
48
+ if (e.metaKey || e.ctrlKey || !this.host.__selected) {
49
+ return;
50
+ }
51
+
52
+ if (e.key === 'Backspace' || e.key === 'Delete') {
53
+ this.__delete(e);
54
+ } else if (e.key === 'Escape') {
55
+ this.__escape(e);
56
+ } else if (e.shiftKey && e.key.startsWith('Arrow')) {
57
+ this.__resize(e);
58
+ } else if (e.key.startsWith('Arrow')) {
59
+ this.__move(e);
60
+ }
61
+ }
62
+
63
+ /** @private */
64
+ __delete(e) {
65
+ e.preventDefault();
66
+ fireRemove(this.host);
67
+ }
68
+
69
+ /** @private */
70
+ __escape(e) {
71
+ e.preventDefault();
72
+ if (this.host.__moveMode || this.host.__resizeMode) {
73
+ this.host.__exitMode(true);
74
+ } else {
75
+ this.host.__selected = false;
76
+ this.host.focus();
77
+ }
78
+ }
79
+
80
+ /** @private */
81
+ __resize(e) {
82
+ const resizeMap = {
83
+ ArrowRight: [document.dir === 'rtl' ? -1 : 1, 0],
84
+ ArrowLeft: [document.dir === 'rtl' ? 1 : -1, 0],
85
+ ArrowDown: [0, 1],
86
+ ArrowUp: [0, -1],
87
+ };
88
+ if (resizeMap[e.key]) {
89
+ e.preventDefault();
90
+ fireResize(this.host, ...resizeMap[e.key]);
91
+ }
92
+ }
93
+
94
+ /** @private */
95
+ __move(e) {
96
+ const moveMap = {
97
+ ArrowRight: document.dir === 'rtl' ? -1 : 1,
98
+ ArrowLeft: document.dir === 'rtl' ? 1 : -1,
99
+ ArrowDown: 1,
100
+ ArrowUp: -1,
101
+ };
102
+ if (moveMap[e.key]) {
103
+ e.preventDefault();
104
+ fireMove(this.host, moveMap[e.key]);
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,45 @@
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 { buttonStyles, buttonTemplate } from '@vaadin/button/src/vaadin-button-base.js';
13
+ import { ButtonMixin } from '@vaadin/button/src/vaadin-button-mixin.js';
14
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
15
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
16
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
17
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
18
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
19
+
20
+ class DashboardButton extends ButtonMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
21
+ static get is() {
22
+ return 'vaadin-dashboard-button';
23
+ }
24
+
25
+ static get styles() {
26
+ return buttonStyles;
27
+ }
28
+
29
+ /** @protected */
30
+ render() {
31
+ return buttonTemplate(html);
32
+ }
33
+
34
+ /** @protected */
35
+ ready() {
36
+ super.ready();
37
+
38
+ this._tooltipController = new TooltipController(this);
39
+ this.addController(this._tooltipController);
40
+ }
41
+ }
42
+
43
+ defineCustomElement(DashboardButton);
44
+
45
+ export { DashboardButton };
@@ -0,0 +1,99 @@
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
+ export const WRAPPER_LOCAL_NAME = 'vaadin-dashboard-widget-wrapper';
12
+
13
+ // Wrapper properties that should be synchronized as widget/section attributes
14
+ export const SYNCHRONIZED_ATTRIBUTES = ['editable', 'dragging', 'first-child', 'last-child'];
15
+
16
+ /**
17
+ * Returns true if the given items are equal by reference or by id.
18
+ *
19
+ * @param {Object} a the first item
20
+ * @param {Object} b the second item
21
+ */
22
+ export function itemsEqual(a, b) {
23
+ if (a === b) {
24
+ return true;
25
+ }
26
+ if (a.id !== undefined && b.id !== undefined) {
27
+ return a.id === b.id;
28
+ }
29
+ return false;
30
+ }
31
+
32
+ /**
33
+ * Returns the array of items that contains the given item.
34
+ * Might be the dashboard items or the items of a section.
35
+ *
36
+ * @param {Object} item the item element
37
+ * @param {Object[]} items the root level items array
38
+ * @return {Object[]} the items array
39
+ */
40
+ export function getItemsArrayOfItem(item, items) {
41
+ if (items.some((i) => itemsEqual(i, item))) {
42
+ return items;
43
+ }
44
+ const parentItem = items.find((i) => i.items && getItemsArrayOfItem(item, i.items));
45
+ return parentItem ? parentItem.items : null;
46
+ }
47
+
48
+ /**
49
+ * Returns the item associated with the given element.
50
+ *
51
+ * @param {HTMLElement} element the element
52
+ */
53
+ export function getElementItem(element) {
54
+ const wrapper = element.closest(WRAPPER_LOCAL_NAME);
55
+ return wrapper && wrapper.__item;
56
+ }
57
+
58
+ /**
59
+ * Dispatches a custom event to notify about a move operation.
60
+ *
61
+ * @param {HTMLElement} element
62
+ * @param {Number} delta
63
+ */
64
+ export function fireMove(element, delta) {
65
+ element.dispatchEvent(
66
+ new CustomEvent('item-move', {
67
+ bubbles: true,
68
+ detail: { delta },
69
+ }),
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Dispatches a custom event to notify about a resize operation.
75
+ *
76
+ * @param {HTMLElement} element
77
+ * @param {Number} colspanDelta
78
+ * @param {Number} rowspanDelta
79
+ */
80
+ export function fireResize(element, colspanDelta, rowspanDelta) {
81
+ element.dispatchEvent(
82
+ new CustomEvent('item-resize', {
83
+ bubbles: true,
84
+ detail: {
85
+ colspanDelta,
86
+ rowspanDelta,
87
+ },
88
+ }),
89
+ );
90
+ }
91
+
92
+ /**
93
+ * Dispatches a custom event to notify about a remove operation.
94
+ *
95
+ * @param {HTMLElement} element
96
+ */
97
+ export function fireRemove(element) {
98
+ element.dispatchEvent(new CustomEvent('item-remove', { bubbles: true }));
99
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2000 - 2024 Vaadin Ltd.
4
+ *
5
+ * This program is available under Vaadin Commercial License and Service Terms.
6
+ *
7
+ *
8
+ * See https://vaadin.com/commercial-license-and-service-terms for the full
9
+ * license.
10
+ */
11
+ import type { Constructor } from '@open-wc/dedupe-mixin';
12
+
13
+ /**
14
+ * Shared functionality between widgets and sections
15
+ */
16
+ export declare function DashboardItemMixin<T extends Constructor<HTMLElement>>(
17
+ base: T,
18
+ ): Constructor<DashboardItemMixinClass> & T;
19
+
20
+ export declare class DashboardItemMixinClass {}