@vaadin/vaadin-board 22.0.0-alpha4 → 22.0.0-alpha8

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,10 +1,29 @@
1
1
  {
2
2
  "name": "@vaadin/vaadin-board",
3
- "version": "22.0.0-alpha4",
3
+ "version": "22.0.0-alpha8",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "Polymer element to create flexible responsive layouts and build nice looking dashboard.",
8
+ "license": "https://raw.githubusercontent.com/vaadin/vaadin-board/master/LICENSE.txt",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/vaadin/web-components.git",
12
+ "directory": "packages/vaadin-board"
13
+ },
14
+ "author": "Vaadin Ltd",
15
+ "homepage": "https://vaadin.com/components",
16
+ "bugs": {
17
+ "url": "https://github.com/vaadin/vaadin-board/issues"
18
+ },
5
19
  "main": "vaadin-board.js",
6
20
  "module": "vaadin-board.js",
7
- "repository": "vaadin/vaadin-board",
21
+ "files": [
22
+ "src",
23
+ "theme",
24
+ "vaadin-*.d.ts",
25
+ "vaadin-*.js"
26
+ ],
8
27
  "keywords": [
9
28
  "Vaadin",
10
29
  "Board",
@@ -15,31 +34,8 @@
15
34
  "web-component",
16
35
  "polymer"
17
36
  ],
18
- "author": "Vaadin Ltd",
19
- "license": "https://raw.githubusercontent.com/vaadin/vaadin-board/master/LICENSE.txt",
20
- "bugs": {
21
- "url": "https://github.com/vaadin/vaadin-board/issues"
22
- },
23
- "homepage": "https://vaadin.com/components",
24
- "files": [
25
- "vaadin-*.d.ts",
26
- "vaadin-*.js",
27
- "src",
28
- "theme"
29
- ],
30
37
  "dependencies": {
31
- "@polymer/iron-resizable-behavior": "^3.0.0",
32
- "@polymer/polymer": "^3.0.0",
33
- "@vaadin/vaadin-element-mixin": "^22.0.0-alpha4",
34
- "@vaadin/vaadin-license-checker": "^2.1.0"
35
- },
36
- "devDependencies": {
37
- "@esm-bundle/chai": "^4.3.4",
38
- "@vaadin/testing-helpers": "^0.2.1",
39
- "sinon": "^9.2.1"
40
- },
41
- "publishConfig": {
42
- "access": "public"
38
+ "@vaadin/board": "22.0.0-alpha8"
43
39
  },
44
- "gitHead": "86c025abd605d5a4a3c0ae36eb07c34704cee1f2"
40
+ "gitHead": "c24468526298ee26ad7f7280b59f6c8789e1f75f"
45
41
  }
@@ -1,53 +1,18 @@
1
- import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2021 Vaadin Ltd
4
+ * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
+ */
6
+ import { BoardRow } from '@vaadin/board/src/vaadin-board-row.js';
2
7
 
3
8
  /**
4
- * `<vaadin-board-row>` is a web component that together with `<vaadin-board>` component allows
5
- * to create flexible responsive layouts and build nice looking dashboard.
6
- *
7
- * Each row can contain up to four elements (fewer if colspan is used) and is automatically responsive.
8
- * The row changes between `large`, `medium` and `small` modes depending on the available width and
9
- * the set breakpoints.
10
- *
11
- * In `large` mode, typically all content is shown side-by-side, in `medium` half of the content is
12
- * side by side and in `small` mode, content is laid out vertically.
13
- *
14
- * The breakpoints can be set using custom CSS properties.
15
- * By default the breakpoints are `small: <600px`, `medium: < 960px`, `large >= 960px`.
16
- *
17
- * ```html
18
- * <vaadin-board>
19
- * <vaadin-board-row>
20
- * <div>This could be chart 1</div>
21
- * <div>This could be chart 2</div>
22
- * <div>This could be chart 3</div>
23
- * <div>This could be chart 4</div>
24
- * </vaadin-board-row>
25
- * </vaadin-board>
26
- * ```
27
- *
28
- * ### Styling
29
- *
30
- * The following custom properties are available for styling:
31
- *
32
- * Custom property | Description | Default
33
- * ----------------|-------------|-------------
34
- * `--vaadin-board-width-small` | Determines the width where mode changes from `small` to `medium` | `600px`
35
- * `--vaadin-board-width-medium` | Determines the width where mode changes from `medium` to `large` | `960px`
9
+ * @deprecated Import `BoardRow` from `@vaadin/board/vaadin-board-row` instead.
36
10
  */
37
- declare class BoardRowElement extends ElementMixin(HTMLElement) {
38
- /**
39
- * Redraws the row, if necessary.
40
- *
41
- * In most cases, a board row will redraw itself if your reconfigure it.
42
- * If you dynamically change CSS which affects the row, then you need to call this method.
43
- */
44
- redraw(): void;
45
- }
11
+ export type BoardRowElement = BoardRow;
46
12
 
47
- declare global {
48
- interface HTMLElementTagNameMap {
49
- 'vaadin-board-row': BoardRowElement;
50
- }
51
- }
13
+ /**
14
+ * @deprecated Import `BoardRow` from `@vaadin/board/vaadin-board-row` instead.
15
+ */
16
+ export const BoardRowElement: typeof BoardRow;
52
17
 
53
- export { BoardRowElement };
18
+ export * from '@vaadin/board/src/vaadin-board-row.js';
@@ -3,292 +3,11 @@
3
3
  * Copyright (c) 2017 - 2021 Vaadin Ltd
4
4
  * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
5
  */
6
- import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
7
- import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
8
- import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
9
- import { DomRepeat } from '@polymer/polymer/lib/elements/dom-repeat.js';
10
- import { DomIf } from '@polymer/polymer/lib/elements/dom-if.js';
11
- import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
12
- import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
13
-
14
- const CLASSES = {
15
- SMALL: 'small',
16
- MEDIUM: 'medium',
17
- LARGE: 'large'
18
- };
6
+ import { BoardRow } from '@vaadin/board/src/vaadin-board-row.js';
19
7
 
20
8
  /**
21
- * `<vaadin-board-row>` is a web component that together with `<vaadin-board>` component allows
22
- * to create flexible responsive layouts and build nice looking dashboard.
23
- *
24
- * Each row can contain up to four elements (fewer if colspan is used) and is automatically responsive.
25
- * The row changes between `large`, `medium` and `small` modes depending on the available width and
26
- * the set breakpoints.
27
- *
28
- * In `large` mode, typically all content is shown side-by-side, in `medium` half of the content is
29
- * side by side and in `small` mode, content is laid out vertically.
30
- *
31
- * The breakpoints can be set using custom CSS properties.
32
- * By default the breakpoints are `small: <600px`, `medium: < 960px`, `large >= 960px`.
33
- *
34
- * ```html
35
- * <vaadin-board>
36
- * <vaadin-board-row>
37
- * <div>This could be chart 1</div>
38
- * <div>This could be chart 2</div>
39
- * <div>This could be chart 3</div>
40
- * <div>This could be chart 4</div>
41
- * </vaadin-board-row>
42
- * </vaadin-board>
43
- * ```
44
- *
45
- * ### Styling
46
- *
47
- * The following custom properties are available for styling:
48
- *
49
- * Custom property | Description | Default
50
- * ----------------|-------------|-------------
51
- * `--vaadin-board-width-small` | Determines the width where mode changes from `small` to `medium` | `600px`
52
- * `--vaadin-board-width-medium` | Determines the width where mode changes from `medium` to `large` | `960px`
53
- *
54
- * @extends HTMLElement
55
- * @mixes ElementMixin
9
+ * @deprecated Import `BoardRow` from `@vaadin/board/vaadin-board-row` instead.
56
10
  */
57
- class BoardRowElement extends ElementMixin(mixinBehaviors([IronResizableBehavior], PolymerElement)) {
58
- static get template() {
59
- return html`
60
- <style>
61
- :host {
62
- display: flex;
63
- flex-flow: row wrap;
64
- align-items: stretch;
65
- --small-size: var(--vaadin-board-width-small, 600px);
66
- --medium-size: var(--vaadin-board-width-medium, 960px);
67
- }
68
-
69
- :host ::slotted(*) {
70
- box-sizing: border-box;
71
- flex-grow: 1;
72
- overflow: hidden;
73
- }
74
- </style>
75
- <slot id="insertionPoint"></slot>
76
- `;
77
- }
78
-
79
- static get is() {
80
- return 'vaadin-board-row';
81
- }
82
-
83
- constructor() {
84
- super();
85
- this._onIronResize = this._onIronResize.bind(this);
86
- this._oldWidth = 0;
87
- this._oldBreakpoints = { smallSize: 600, mediumSize: 960 };
88
- this._oldFlexBasis = [];
89
- }
90
-
91
- /** @protected */
92
- ready() {
93
- super.ready();
94
- this.addEventListener('iron-resize', this._onIronResize, true);
95
- this.$.insertionPoint.addEventListener('slotchange', this.redraw.bind(this));
96
- afterNextRender(this, function () {
97
- //force this as an interested resizable of parent
98
- this.dispatchEvent(
99
- new CustomEvent('iron-request-resize-notifications', {
100
- node: this,
101
- bubbles: true,
102
- cancelable: true,
103
- composed: true,
104
- detail: {}
105
- })
106
- );
107
- });
108
- }
109
-
110
- /** @protected */
111
- connectedCallback() {
112
- super.connectedCallback();
113
- afterNextRender(this, this._onIronResize);
114
- }
115
-
116
- /**
117
- * Adds styles for board row based on width.
118
- * @private
119
- */
120
- _addStyleNames(width, breakpoints) {
121
- if (width < breakpoints.smallSize) {
122
- this.classList.add(CLASSES.SMALL);
123
- this.classList.remove(CLASSES.MEDIUM);
124
- this.classList.remove(CLASSES.LARGE);
125
- } else if (width < breakpoints.mediumSize) {
126
- this.classList.remove(CLASSES.SMALL);
127
- this.classList.add(CLASSES.MEDIUM);
128
- this.classList.remove(CLASSES.LARGE);
129
- } else {
130
- this.classList.remove(CLASSES.SMALL);
131
- this.classList.remove(CLASSES.MEDIUM);
132
- this.classList.add(CLASSES.LARGE);
133
- }
134
- }
135
-
136
- /**
137
- * Calculates flex basis based on colSpan, width and breakpoints.
138
- * @param {number} colSpan colspan value of the row
139
- * @param {number} width width of the row in px
140
- * @param {number} colsInRow number of columns in the row
141
- * @param {object} breakpoints object with smallSize and mediumSize number properties, which tells
142
- * where the row should switch rendering size in pixels.
143
- * @private
144
- */
145
- _calculateFlexBasis(colSpan, width, colsInRow, breakpoints) {
146
- if (width < breakpoints.smallSize) {
147
- colsInRow = 1;
148
- } else if (width < breakpoints.mediumSize && colsInRow == 4) {
149
- colsInRow = 2;
150
- }
151
- let flexBasis = (colSpan / colsInRow) * 100;
152
- flexBasis = flexBasis > 100 ? 100 : flexBasis;
153
- return flexBasis + '%';
154
- }
155
-
156
- /** @private */
157
- _reportError() {
158
- const errorMessage = 'The column configuration is not valid; column count should add up to 3 or 4.';
159
- console.warn(errorMessage, 'check: \r\n' + this.outerHTML);
160
- }
161
-
162
- /**
163
- * Parses board-cols from DOM.
164
- * If there is not enough space in the row drop board cols.
165
- * @param {!Array<!Node>} nodes array of nodes
166
- * @return {!Array<number>} array of boardCols
167
- * @private
168
- */
169
- _parseBoardCols(nodes) {
170
- const boardCols = nodes.map((node) => {
171
- if (node.getAttribute('board-cols')) {
172
- return parseInt(node.getAttribute('board-cols'));
173
- }
174
- return 1;
175
- });
176
-
177
- let spaceLeft = 4;
178
- let returnBoardCols = [];
179
- nodes.forEach((node, i) => {
180
- spaceLeft = spaceLeft - boardCols[i];
181
- });
182
-
183
- if (spaceLeft < 0) {
184
- this._reportError();
185
- boardCols.forEach((node, i) => {
186
- returnBoardCols[i] = 1;
187
- });
188
- } else {
189
- returnBoardCols = boardCols.slice(0);
190
- }
191
-
192
- return returnBoardCols;
193
- }
194
-
195
- /**
196
- * If there is not enough space in the row.
197
- * Extra items are dropped from DOM.
198
- * @param {!Array<number>} boardCols array of board-cols for every node
199
- * @param {!Array<!Node>} nodes array of nodes
200
- * @return {!Array<!Node>} filtered array of nodes
201
- * @private
202
- */
203
- _removeExtraNodesFromDOM(boardCols, nodes) {
204
- let isErrorReported = false;
205
- let spaceLeft = 4;
206
- let returnNodes = [];
207
- nodes.forEach((node, i) => {
208
- spaceLeft = spaceLeft - boardCols[i];
209
- if (spaceLeft < 0) {
210
- if (!isErrorReported) {
211
- isErrorReported = true;
212
- this._reportError();
213
- }
214
- this.removeChild(node);
215
- } else {
216
- returnNodes[i] = node;
217
- }
218
- });
219
- return returnNodes;
220
- }
221
-
222
- /**
223
- * Redraws the row, if necessary.
224
- *
225
- * In most cases, a board row will redraw itself if your reconfigure it.
226
- * If you dynamically change CSS which affects the row, then you need to call this method.
227
- */
228
- redraw() {
229
- this._recalculateFlexBasis(true);
230
- }
231
-
232
- /** @private */
233
- _onIronResize() {
234
- this._recalculateFlexBasis(false);
235
- }
236
-
237
- /** @private */
238
- _recalculateFlexBasis(forceResize) {
239
- const width = this.getBoundingClientRect().width;
240
- const breakpoints = this._measureBreakpointsInPx();
241
- if (
242
- forceResize ||
243
- width != this._oldWidth ||
244
- breakpoints.smallSize != this._oldBreakpoints.smallSize ||
245
- breakpoints.mediumSize != this._oldBreakpoints.mediumSize
246
- ) {
247
- const nodes = this.$.insertionPoint.assignedNodes({ flatten: true });
248
- const isElementNode = function (node) {
249
- return !(node.nodeType === node.TEXT_NODE || node instanceof DomRepeat || node instanceof DomIf);
250
- };
251
- const filteredNodes = nodes.filter(isElementNode);
252
- this._addStyleNames(width, breakpoints);
253
- const boardCols = this._parseBoardCols(filteredNodes);
254
- const colsInRow = boardCols.reduce((a, b) => a + b, 0);
255
- this._removeExtraNodesFromDOM(boardCols, filteredNodes).forEach((e, i) => {
256
- let newFlexBasis = this._calculateFlexBasis(boardCols[i], width, colsInRow, breakpoints);
257
- if (forceResize || !this._oldFlexBasis[i] || this._oldFlexBasis[i] != newFlexBasis) {
258
- this._oldFlexBasis[i] = newFlexBasis;
259
- e.style.flexBasis = newFlexBasis;
260
- }
261
- });
262
- this._oldWidth = width;
263
- this._oldBreakpoints = breakpoints;
264
- }
265
- }
266
-
267
- /**
268
- * Measure the breakpoints in pixels.
269
- *
270
- * The breakpoints for `small` and `medium` can be given in any unit: `px`, `em`, `in` etc.
271
- * We need to know them in `px` so that they are comparable with the actual size.
272
- *
273
- * @return {object} object with smallSize and mediumSize number properties, which tells
274
- * where the row should switch rendering size in pixels.
275
- * @private
276
- */
277
- _measureBreakpointsInPx() {
278
- // Convert minWidth to px units for comparison
279
- const breakpoints = {};
280
- const tmpStyleProp = 'background-position';
281
- const smallSize = getComputedStyle(this).getPropertyValue('--small-size');
282
- const mediumSize = getComputedStyle(this).getPropertyValue('--medium-size');
283
- this.style.setProperty(tmpStyleProp, smallSize);
284
- breakpoints.smallSize = parseFloat(getComputedStyle(this).getPropertyValue(tmpStyleProp));
285
- this.style.setProperty(tmpStyleProp, mediumSize);
286
- breakpoints.mediumSize = parseFloat(getComputedStyle(this).getPropertyValue(tmpStyleProp));
287
- this.style.removeProperty(tmpStyleProp);
288
- return breakpoints;
289
- }
290
- }
291
-
292
- customElements.define(BoardRowElement.is, BoardRowElement);
11
+ export const BoardRowElement = BoardRow;
293
12
 
294
- export { BoardRowElement };
13
+ export * from '@vaadin/board/src/vaadin-board-row.js';
@@ -1,40 +1,18 @@
1
- import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
2
-
3
1
  /**
4
- * `<vaadin-board>` is a web component to create flexible responsive layouts
5
- * and build nice looking dashboards.
6
- *
7
- * A `<vaadin-board>` is built using `<vaadin-board-row>` elements containing your child elements.
8
- * Each board row consists of four columns, and can contain up to four elements. Using column spans
9
- * you can tune the layout to your liking.
10
- *
11
- * ```html
12
- * <vaadin-board>
13
- * <vaadin-board-row>
14
- * <div>This could be chart 1</div>
15
- * <div>This could be chart 2</div>
16
- * <div>This could be chart 3</div>
17
- * <div>This could be chart 4</div>
18
- * </vaadin-board-row>
19
- * </vaadin-board>
20
- * ```
2
+ * @license
3
+ * Copyright (c) 2017 - 2021 Vaadin Ltd
4
+ * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
21
5
  */
22
- declare class BoardElement extends ElementMixin(HTMLElement) {
23
- static _finalizeClass(): void;
6
+ import { Board } from '@vaadin/board/src/vaadin-board.js';
24
7
 
25
- /**
26
- * Redraws the board and all rows inside it, if necessary.
27
- *
28
- * In most cases, board will redraw itself if your reconfigure it. If you dynamically change CSS
29
- * which affects this element, then you need to call this method.
30
- */
31
- redraw(): void;
32
- }
8
+ /**
9
+ * @deprecated Import `Board` from `@vaadin/board` instead.
10
+ */
11
+ export type BoardElement = Board;
33
12
 
34
- declare global {
35
- interface HTMLElementTagNameMap {
36
- 'vaadin-board': BoardElement;
37
- }
38
- }
13
+ /**
14
+ * @deprecated Import `Board` from `@vaadin/board` instead.
15
+ */
16
+ export const BoardElement: typeof Board;
39
17
 
40
- export { BoardElement };
18
+ export * from '@vaadin/board/src/vaadin-board.js';
@@ -3,76 +3,11 @@
3
3
  * Copyright (c) 2017 - 2021 Vaadin Ltd
4
4
  * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
5
  */
6
- import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
7
- import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
8
- import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
9
- import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
10
- import '@vaadin/vaadin-license-checker/vaadin-license-checker.js';
11
- import './vaadin-board-row.js';
6
+ import { Board } from '@vaadin/board/src/vaadin-board.js';
12
7
 
13
8
  /**
14
- * `<vaadin-board>` is a web component to create flexible responsive layouts
15
- * and build nice looking dashboards.
16
- *
17
- * A `<vaadin-board>` is built using `<vaadin-board-row>` elements containing your child elements.
18
- * Each board row consists of four columns, and can contain up to four elements. Using column spans
19
- * you can tune the layout to your liking.
20
- *
21
- * ```html
22
- * <vaadin-board>
23
- * <vaadin-board-row>
24
- * <div>This could be chart 1</div>
25
- * <div>This could be chart 2</div>
26
- * <div>This could be chart 3</div>
27
- * <div>This could be chart 4</div>
28
- * </vaadin-board-row>
29
- * </vaadin-board>
30
- * ```
31
- *
32
- * @extends HTMLElement
33
- * @mixes ElementMixin
9
+ * @deprecated Import `Board` from `@vaadin/board` instead.
34
10
  */
35
- class BoardElement extends ElementMixin(mixinBehaviors([IronResizableBehavior], PolymerElement)) {
36
- static get template() {
37
- return html`
38
- <style>
39
- :host {
40
- display: block;
41
- }
42
- </style>
43
- <slot></slot>
44
- `;
45
- }
11
+ export const BoardElement = Board;
46
12
 
47
- static get is() {
48
- return 'vaadin-board';
49
- }
50
-
51
- /**
52
- * @protected
53
- */
54
- static _finalizeClass() {
55
- super._finalizeClass();
56
-
57
- const devModeCallback = window.Vaadin.developmentModeCallback;
58
- const licenseChecker = devModeCallback && devModeCallback['vaadin-license-checker'];
59
- /* c8 ignore next 3 */
60
- if (typeof licenseChecker === 'function') {
61
- licenseChecker(BoardElement);
62
- }
63
- }
64
-
65
- /**
66
- * Redraws the board and all rows inside it, if necessary.
67
- *
68
- * In most cases, board will redraw itself if your reconfigure it. If you dynamically change CSS
69
- * which affects this element, then you need to call this method.
70
- */
71
- redraw() {
72
- this.notifyResize();
73
- }
74
- }
75
-
76
- customElements.define(BoardElement.is, BoardElement);
77
-
78
- export { BoardElement };
13
+ export * from '@vaadin/board/src/vaadin-board.js';
@@ -1 +1 @@
1
- import '../../src/vaadin-board-row.js';
1
+ import '@vaadin/board/theme/lumo/vaadin-board-row.js';
@@ -1,2 +1 @@
1
- import './vaadin-board-row.js';
2
- import '../../src/vaadin-board.js';
1
+ import '@vaadin/board/theme/lumo/vaadin-board.js';
@@ -1 +1 @@
1
- import '../../src/vaadin-board-row.js';
1
+ import '@vaadin/board/theme/material/vaadin-board-row.js';
@@ -1,2 +1 @@
1
- import './vaadin-board-row.js';
2
- import '../../src/vaadin-board.js';
1
+ import '@vaadin/board/theme/material/vaadin-board.js';