@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
@@ -0,0 +1,76 @@
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 { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
13
+ import { DashboardItemMixin } from './vaadin-dashboard-item-mixin.js';
14
+
15
+ /**
16
+ * A section component for use with the Dashboard component
17
+ *
18
+ * ```html
19
+ * <vaadin-dashboard-section section-title="Section Title">
20
+ * <vaadin-dashboard-widget widget-title="Widget 1"></vaadin-dashboard-widget>
21
+ * <vaadin-dashboard-widget widget-title="Widget 2"></vaadin-dashboard-widget>
22
+ * </vaadin-dashboard-section>
23
+ * ```
24
+ *
25
+ * #### Example
26
+ *
27
+ * ```html
28
+ * <vaadin-dashboard-section section-title="Section title">
29
+ * <vaadin-dashboard-widget widget-title="Widget 1"></vaadin-dashboard-widget>
30
+ * <vaadin-dashboard-widget widget-title="Widget 2"></vaadin-dashboard-widget>
31
+ * </vaadin-dashboard-section>
32
+ * ```
33
+ *
34
+ * ### Styling
35
+ *
36
+ * The following shadow DOM parts are available for styling:
37
+ *
38
+ * Part name | Description
39
+ * -----------------------|-------------
40
+ * `header` | The header of the section
41
+ * `title` | The title of the section
42
+ * `move-button` | The move button
43
+ * `remove-button` | The remove button
44
+ * `move-backward-button` | The move backward button when in move mode
45
+ * `move-forward-button` | The move forward button when in move mode
46
+ * `move-apply-button` | The apply button when in move mode
47
+ *
48
+ * The following state attributes are available for styling:
49
+ *
50
+ * Attribute | Description
51
+ * ---------------|-------------
52
+ * `selected` | Set when the element is selected.
53
+ * `focused` | Set when the element is focused.
54
+ * `move-mode` | Set when the element is being moved.
55
+ * `editable` | Set when the element is editable.
56
+ * `first-child` | Set when the element is the first child of the parent.
57
+ * `last-child` | Set when the element is the last child of the parent.
58
+ *
59
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
60
+ */
61
+ declare class DashboardSection extends DashboardItemMixin(ElementMixin(ThemableMixin(HTMLElement))) {
62
+ /**
63
+ * The title of the section
64
+ *
65
+ * @attr {string} section-title
66
+ */
67
+ sectionTitle: string | null | undefined;
68
+ }
69
+
70
+ declare global {
71
+ interface HTMLElementTagNameMap {
72
+ 'vaadin-dashboard-section': DashboardSection;
73
+ }
74
+ }
75
+
76
+ export { DashboardSection };
@@ -0,0 +1,203 @@
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 { DashboardItemMixin } from './vaadin-dashboard-item-mixin.js';
17
+ import { getDefaultI18n } from './vaadin-dashboard-item-mixin.js';
18
+ import { hasWidgetWrappers } from './vaadin-dashboard-styles.js';
19
+
20
+ /**
21
+ * A section component for use with the Dashboard component
22
+ *
23
+ * ```html
24
+ * <vaadin-dashboard-section section-title="Section Title">
25
+ * <vaadin-dashboard-widget widget-title="Widget 1"></vaadin-dashboard-widget>
26
+ * <vaadin-dashboard-widget widget-title="Widget 2"></vaadin-dashboard-widget>
27
+ * </vaadin-dashboard-section>
28
+ * ```
29
+ *
30
+ * #### Example
31
+ *
32
+ * ```html
33
+ * <vaadin-dashboard-section section-title="Section title">
34
+ * <vaadin-dashboard-widget widget-title="Widget 1"></vaadin-dashboard-widget>
35
+ * <vaadin-dashboard-widget widget-title="Widget 2"></vaadin-dashboard-widget>
36
+ * </vaadin-dashboard-section>
37
+ * ```
38
+ *
39
+ * ### Styling
40
+ *
41
+ * The following shadow DOM parts are available for styling:
42
+ *
43
+ * Part name | Description
44
+ * -----------------------|-------------
45
+ * `header` | The header of the section
46
+ * `title` | The title of the section
47
+ * `move-button` | The move button
48
+ * `remove-button` | The remove button
49
+ * `move-backward-button` | The move backward button when in move mode
50
+ * `move-forward-button` | The move forward button when in move mode
51
+ * `move-apply-button` | The apply button when in move mode
52
+ *
53
+ * The following state attributes are available for styling:
54
+ *
55
+ * Attribute | Description
56
+ * ---------------|-------------
57
+ * `selected` | Set when the element is selected.
58
+ * `focused` | Set when the element is focused.
59
+ * `move-mode` | Set when the element is being moved.
60
+ * `editable` | Set when the element is editable.
61
+ * `first-child` | Set when the element is the first child of the parent.
62
+ * `last-child` | Set when the element is the last child of the parent.
63
+ *
64
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
65
+ *
66
+ * @customElement
67
+ * @extends HTMLElement
68
+ * @mixes ElementMixin
69
+ * @mixes ThemableMixin
70
+ * @mixes DashboardItemMixin
71
+ */
72
+ class DashboardSection extends DashboardItemMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
73
+ static get is() {
74
+ return 'vaadin-dashboard-section';
75
+ }
76
+
77
+ static get styles() {
78
+ return [
79
+ css`
80
+ :host {
81
+ display: grid;
82
+ position: relative;
83
+ grid-template-columns: subgrid;
84
+ --_vaadin-dashboard-section-column: 1 / calc(var(--_vaadin-dashboard-effective-col-count) + 1);
85
+ grid-column: var(--_vaadin-dashboard-section-column) !important;
86
+ gap: var(--_vaadin-dashboard-spacing, 1rem);
87
+ /* Dashboard section header height */
88
+ --_vaadin-dashboard-section-header-height: minmax(0, auto);
89
+ grid-template-rows: var(--_vaadin-dashboard-section-header-height) repeat(
90
+ auto-fill,
91
+ var(--_vaadin-dashboard-row-height)
92
+ );
93
+ grid-auto-rows: var(--_vaadin-dashboard-row-height);
94
+ }
95
+
96
+ :host([hidden]) {
97
+ display: none !important;
98
+ }
99
+
100
+ ::slotted(*) {
101
+ --_vaadin-dashboard-title-level: 3;
102
+ --_vaadin-dashboard-item-column: span
103
+ min(
104
+ var(--vaadin-dashboard-item-colspan, 1),
105
+ var(--_vaadin-dashboard-effective-col-count, var(--_vaadin-dashboard-col-count))
106
+ );
107
+
108
+ grid-column: var(--_vaadin-dashboard-item-column);
109
+ --_vaadin-dashboard-item-row: span var(--vaadin-dashboard-item-rowspan, 1);
110
+ grid-row: var(--_vaadin-dashboard-item-row);
111
+ }
112
+
113
+ header {
114
+ grid-column: var(--_vaadin-dashboard-section-column);
115
+ }
116
+
117
+ :host::before {
118
+ z-index: 2 !important;
119
+ }
120
+ `,
121
+ hasWidgetWrappers,
122
+ super.styles,
123
+ ];
124
+ }
125
+
126
+ static get properties() {
127
+ return {
128
+ /**
129
+ * The object used to localize this component.
130
+ *
131
+ * To change the default localization, replace the entire
132
+ * `i18n` object with a custom one.
133
+ *
134
+ * The object has the following structure and default values:
135
+ * ```
136
+ * {
137
+ * selectSection: 'Select section for editing',
138
+ * remove: 'Remove',
139
+ * move: 'Move',
140
+ * moveApply: 'Apply',
141
+ * moveForward: 'Move Forward',
142
+ * moveBackward: 'Move Backward',
143
+ * }
144
+ * ```
145
+ * @private
146
+ */
147
+ __i18n: {
148
+ type: Object,
149
+ value: () => {
150
+ const i18n = getDefaultI18n();
151
+ return {
152
+ selectSection: i18n.selectSection,
153
+ remove: i18n.remove,
154
+ move: i18n.move,
155
+ moveApply: i18n.moveApply,
156
+ moveForward: i18n.moveForward,
157
+ moveBackward: i18n.moveBackward,
158
+ };
159
+ },
160
+ },
161
+
162
+ /**
163
+ * The title of the section
164
+ *
165
+ * @attr {string} section-title
166
+ * @type {string | null | undefined}
167
+ */
168
+ sectionTitle: {
169
+ type: String,
170
+ value: '',
171
+ },
172
+ };
173
+ }
174
+
175
+ /** @protected */
176
+ render() {
177
+ return html`
178
+ ${this.__renderFocusButton('selectSection')} ${this.__renderMoveControls()}
179
+
180
+ <div id="focustrap">
181
+ <header part="header">
182
+ ${this.__renderDragHandle()}
183
+ <h2 id="title" part="title">${this.sectionTitle}</h2>
184
+ ${this.__renderRemoveButton()}
185
+ </header>
186
+ </div>
187
+
188
+ <slot></slot>
189
+ `;
190
+ }
191
+
192
+ /** @protected */
193
+ ready() {
194
+ super.ready();
195
+ if (!this.hasAttribute('role')) {
196
+ this.setAttribute('role', 'section');
197
+ }
198
+ }
199
+ }
200
+
201
+ defineCustomElement(DashboardSection);
202
+
203
+ export { DashboardSection };
@@ -0,0 +1,143 @@
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 { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
+
13
+ export const hasWidgetWrappers = css`
14
+ ::slotted(vaadin-dashboard-widget-wrapper) {
15
+ display: contents;
16
+ }
17
+ `;
18
+
19
+ export const dashboardWidgetAndSectionStyles = css`
20
+ :host {
21
+ box-sizing: border-box;
22
+ /* Calculates the offset by which mode buttons that by default overflow the widget edges
23
+ should be shifted inwards based on a custom --vaadin-dashboard-spacing value */
24
+ --_mode-button-spacing-offset: calc(
25
+ max(0px, var(--_vaadin-dashboard-default-spacing) - var(--_vaadin-dashboard-spacing))
26
+ );
27
+ }
28
+
29
+ :host([dragging]) * {
30
+ visibility: hidden;
31
+ }
32
+
33
+ :host(:not([editable])) #drag-handle,
34
+ :host(:not([editable])) #remove-button,
35
+ :host(:not([editable])) #focus-button,
36
+ :host(:not([editable])) #focus-button-wrapper {
37
+ display: none;
38
+ }
39
+
40
+ #focustrap {
41
+ display: contents;
42
+ }
43
+
44
+ header {
45
+ display: flex;
46
+ overflow: hidden;
47
+ }
48
+
49
+ vaadin-dashboard-button {
50
+ z-index: 1;
51
+ }
52
+
53
+ #focus-button-wrapper,
54
+ #focus-button {
55
+ position: absolute;
56
+ inset: 0;
57
+ opacity: 0;
58
+ }
59
+
60
+ #focus-button {
61
+ pointer-events: none;
62
+ padding: 0;
63
+ border: none;
64
+ }
65
+
66
+ .mode-controls {
67
+ position: absolute;
68
+ inset: 0;
69
+ z-index: 2;
70
+ }
71
+
72
+ .mode-controls[hidden] {
73
+ display: none;
74
+ }
75
+
76
+ /* Move-mode buttons */
77
+ #move-backward,
78
+ #move-forward,
79
+ #move-apply {
80
+ position: absolute;
81
+ top: 50%;
82
+ }
83
+
84
+ #move-backward {
85
+ inset-inline-start: 0;
86
+ transform: translateY(-50%);
87
+ }
88
+
89
+ #move-forward {
90
+ inset-inline-end: 0;
91
+ transform: translateY(-50%);
92
+ }
93
+
94
+ #move-apply {
95
+ left: 50%;
96
+ transform: translate(-50%, -50%);
97
+ }
98
+
99
+ :host([first-child]) #move-backward,
100
+ :host([last-child]) #move-forward {
101
+ display: none;
102
+ }
103
+
104
+ /* Resize-mode buttons */
105
+ #resize-shrink-width,
106
+ #resize-shrink-height,
107
+ #resize-grow-width,
108
+ #resize-grow-height,
109
+ #resize-apply {
110
+ position: absolute;
111
+ }
112
+
113
+ #resize-shrink-width {
114
+ inset-inline-end: calc(0px + var(--_mode-button-spacing-offset));
115
+ top: 50%;
116
+ transform: translateY(-50%);
117
+ }
118
+
119
+ #resize-grow-width {
120
+ inset-inline-start: calc(100% - var(--_mode-button-spacing-offset));
121
+ top: 50%;
122
+ transform: translateY(-50%);
123
+ }
124
+
125
+ #resize-shrink-height {
126
+ bottom: calc(0px + var(--_mode-button-spacing-offset));
127
+ left: 50%;
128
+ transform: translateX(-50%);
129
+ }
130
+
131
+ #resize-grow-height {
132
+ top: calc(100% - var(--_mode-button-spacing-offset));
133
+ left: 50%;
134
+ transform: translateX(-50%);
135
+ }
136
+
137
+ #resize-apply {
138
+ left: 50%;
139
+ top: 50%;
140
+
141
+ transform: translate(-50%, -50%);
142
+ }
143
+ `;
@@ -0,0 +1,101 @@
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 { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
13
+ import { DashboardItemMixin } from './vaadin-dashboard-item-mixin.js';
14
+
15
+ /**
16
+ * A Widget component for use with the Dashboard component
17
+ *
18
+ * ```html
19
+ * <vaadin-dashboard-widget widget-title="Title">
20
+ * <span slot="header-content">Header</span>
21
+ * <div>Content</div>
22
+ * </vaadin-dashboard-widget>
23
+ * ```
24
+ *
25
+ * ### Customization
26
+ *
27
+ * You can configure the item by using `slot` names.
28
+ *
29
+ * Slot name | Description
30
+ * -----------------|-------------
31
+ * `header-content` | A slot for the widget header content.
32
+ *
33
+ * #### Example
34
+ *
35
+ * ```html
36
+ * <vaadin-dashboard-widget widget-title="Title">
37
+ * <span slot="header-content">Header</span>
38
+ * <div>Content</div>
39
+ * </vaadin-dashboard-widget>
40
+ * ```
41
+ *
42
+ * ### Styling
43
+ *
44
+ * The following shadow DOM parts are available for styling:
45
+ *
46
+ * Part name | Description
47
+ * ------------------------------|-------------
48
+ * `header` | The header of the widget
49
+ * `title` | The title of the widget
50
+ * `content` | The content of the widget
51
+ * `move-button` | The move button
52
+ * `remove-button` | The remove button
53
+ * `resize-button` | The resize button
54
+ * `move-backward-button` | The move backward button when in move mode
55
+ * `move-forward-button` | The move forward button when in move mode
56
+ * `move-apply-button` | The apply button when in move mode
57
+ * `resize-shrink-width-button` | The shrink width button when in resize mode
58
+ * `resize-grow-width-button` | The grow width button when in resize mode
59
+ * `resize-shrink-height-button` | The shrink height button when in resize mode
60
+ * `resize-grow-height-button` | The grow height button when in resize mode
61
+ * `resize-apply-button` | The apply button when in resize mode
62
+ *
63
+ * The following custom properties are available:
64
+ *
65
+ * Custom Property | Description
66
+ * ----------------------------------|-------------
67
+ * `--vaadin-dashboard-item-colspan` | colspan of the widget
68
+ * `--vaadin-dashboard-item-rowspan` | rowspan of the widget
69
+ *
70
+ * The following state attributes are available for styling:
71
+ *
72
+ * Attribute | Description
73
+ * ---------------|-------------
74
+ * `selected` | Set when the element is selected.
75
+ * `focused` | Set when the element is focused.
76
+ * `move-mode` | Set when the element is being moved.
77
+ * `resize-mode` | Set when the element is being resized.
78
+ * `resizing` | Set when the element is being resized.
79
+ * `dragging` | Set when the element is being dragged.
80
+ * `editable` | Set when the element is editable.
81
+ * `first-child` | Set when the element is the first child of the parent.
82
+ * `last-child` | Set when the element is the last child of the parent.
83
+ *
84
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
85
+ */
86
+ declare class DashboardWidget extends DashboardItemMixin(ElementMixin(ThemableMixin(HTMLElement))) {
87
+ /**
88
+ * The title of the widget
89
+ *
90
+ * @attr {string} widget-title
91
+ */
92
+ widgetTitle: string | null | undefined;
93
+ }
94
+
95
+ declare global {
96
+ interface HTMLElementTagNameMap {
97
+ 'vaadin-dashboard-widget': DashboardWidget;
98
+ }
99
+ }
100
+
101
+ export { DashboardWidget };