@vaadin/board 22.0.2 → 23.0.0-alpha4

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/board",
3
- "version": "22.0.2",
3
+ "version": "23.0.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "main": "vaadin-board.js",
20
20
  "module": "vaadin-board.js",
21
+ "type": "module",
21
22
  "files": [
22
23
  "src",
23
24
  "theme",
@@ -35,9 +36,8 @@
35
36
  "polymer"
36
37
  ],
37
38
  "dependencies": {
38
- "@polymer/iron-resizable-behavior": "^3.0.0",
39
39
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/component-base": "^22.0.2",
40
+ "@vaadin/component-base": "23.0.0-alpha4",
41
41
  "@vaadin/vaadin-license-checker": "^2.1.0"
42
42
  },
43
43
  "devDependencies": {
@@ -45,5 +45,5 @@
45
45
  "@vaadin/testing-helpers": "^0.3.2",
46
46
  "sinon": "^9.2.1"
47
47
  },
48
- "gitHead": "df21370c4a655a38eac11f79686021ab3b0887ad"
48
+ "gitHead": "81e2deee5147bb7c1f4884760f4598613306f1fb"
49
49
  }
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2021 Vaadin Ltd
3
+ * Copyright (c) 2017 - 2022 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
6
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
7
8
 
8
9
  /**
9
10
  * `<vaadin-board-row>` is a web component that together with `<vaadin-board>` component allows
@@ -39,12 +40,14 @@ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
39
40
  * `--vaadin-board-width-small` | Determines the width where mode changes from `small` to `medium` | `600px`
40
41
  * `--vaadin-board-width-medium` | Determines the width where mode changes from `medium` to `large` | `960px`
41
42
  */
42
- declare class BoardRow extends ElementMixin(HTMLElement) {
43
+ declare class BoardRow extends ResizeMixin(ElementMixin(HTMLElement)) {
43
44
  /**
44
45
  * Redraws the row, if necessary.
45
46
  *
46
47
  * In most cases, a board row will redraw itself if your reconfigure it.
47
- * If you dynamically change CSS which affects the row, then you need to call this method.
48
+ * If you dynamically change breakpoints
49
+ * `--vaadin-board-width-small` or `--vaadin-board-width-medium`,
50
+ * then you need to call this method.
48
51
  */
49
52
  redraw(): void;
50
53
  }
@@ -1,15 +1,13 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2021 Vaadin Ltd
3
+ * Copyright (c) 2017 - 2022 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 { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
7
6
  import { DomIf } from '@polymer/polymer/lib/elements/dom-if.js';
8
7
  import { DomRepeat } from '@polymer/polymer/lib/elements/dom-repeat.js';
9
- import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
10
- import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
11
8
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
12
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
13
11
 
14
12
  const CLASSES = {
15
13
  SMALL: 'small',
@@ -53,8 +51,9 @@ const CLASSES = {
53
51
  *
54
52
  * @extends HTMLElement
55
53
  * @mixes ElementMixin
54
+ * @mixes ResizeMixin
56
55
  */
57
- class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], PolymerElement)) {
56
+ class BoardRow extends ResizeMixin(ElementMixin(PolymerElement)) {
58
57
  static get template() {
59
58
  return html`
60
59
  <style>
@@ -82,7 +81,6 @@ class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], Poly
82
81
 
83
82
  constructor() {
84
83
  super();
85
- this._onIronResize = this._onIronResize.bind(this);
86
84
  this._oldWidth = 0;
87
85
  this._oldBreakpoints = { smallSize: 600, mediumSize: 960 };
88
86
  this._oldFlexBasis = [];
@@ -91,26 +89,14 @@ class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], Poly
91
89
  /** @protected */
92
90
  ready() {
93
91
  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
- });
92
+
93
+ this.$.insertionPoint.addEventListener('slotchange', () => this.redraw());
108
94
  }
109
95
 
110
96
  /** @protected */
111
97
  connectedCallback() {
112
98
  super.connectedCallback();
113
- afterNextRender(this, this._onIronResize);
99
+ this._onResize();
114
100
  }
115
101
 
116
102
  /**
@@ -177,7 +163,7 @@ class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], Poly
177
163
  let spaceLeft = 4;
178
164
  let returnBoardCols = [];
179
165
  nodes.forEach((node, i) => {
180
- spaceLeft = spaceLeft - boardCols[i];
166
+ spaceLeft -= boardCols[i];
181
167
  });
182
168
 
183
169
  if (spaceLeft < 0) {
@@ -203,9 +189,9 @@ class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], Poly
203
189
  _removeExtraNodesFromDOM(boardCols, nodes) {
204
190
  let isErrorReported = false;
205
191
  let spaceLeft = 4;
206
- let returnNodes = [];
192
+ const returnNodes = [];
207
193
  nodes.forEach((node, i) => {
208
- spaceLeft = spaceLeft - boardCols[i];
194
+ spaceLeft -= boardCols[i];
209
195
  if (spaceLeft < 0) {
210
196
  if (!isErrorReported) {
211
197
  isErrorReported = true;
@@ -223,14 +209,19 @@ class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], Poly
223
209
  * Redraws the row, if necessary.
224
210
  *
225
211
  * 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.
212
+ * If you dynamically change breakpoints
213
+ * --vaadin-board-width-small or --vaadin-board-width-medium,
214
+ * then you need to call this method.
227
215
  */
228
216
  redraw() {
229
217
  this._recalculateFlexBasis(true);
230
218
  }
231
219
 
232
- /** @private */
233
- _onIronResize() {
220
+ /**
221
+ * @protected
222
+ * @override
223
+ */
224
+ _onResize() {
234
225
  this._recalculateFlexBasis(false);
235
226
  }
236
227
 
@@ -245,7 +236,7 @@ class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], Poly
245
236
  breakpoints.mediumSize != this._oldBreakpoints.mediumSize
246
237
  ) {
247
238
  const nodes = this.$.insertionPoint.assignedNodes({ flatten: true });
248
- const isElementNode = function (node) {
239
+ const isElementNode = (node) => {
249
240
  return !(node.nodeType === node.TEXT_NODE || node instanceof DomRepeat || node instanceof DomIf);
250
241
  };
251
242
  const filteredNodes = nodes.filter(isElementNode);
@@ -253,7 +244,7 @@ class BoardRow extends ElementMixin(mixinBehaviors([IronResizableBehavior], Poly
253
244
  const boardCols = this._parseBoardCols(filteredNodes);
254
245
  const colsInRow = boardCols.reduce((a, b) => a + b, 0);
255
246
  this._removeExtraNodesFromDOM(boardCols, filteredNodes).forEach((e, i) => {
256
- let newFlexBasis = this._calculateFlexBasis(boardCols[i], width, colsInRow, breakpoints);
247
+ const newFlexBasis = this._calculateFlexBasis(boardCols[i], width, colsInRow, breakpoints);
257
248
  if (forceResize || !this._oldFlexBasis[i] || this._oldFlexBasis[i] != newFlexBasis) {
258
249
  this._oldFlexBasis[i] = newFlexBasis;
259
250
  e.style.flexBasis = newFlexBasis;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2021 Vaadin Ltd
3
+ * Copyright (c) 2017 - 2022 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
6
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
@@ -28,8 +28,9 @@ declare class Board extends ElementMixin(HTMLElement) {
28
28
  /**
29
29
  * Redraws the board and all rows inside it, if necessary.
30
30
  *
31
- * In most cases, board will redraw itself if your reconfigure it. If you dynamically change CSS
32
- * which affects this element, then you need to call this method.
31
+ * In most cases, board will redraw itself if your reconfigure it. If you dynamically change
32
+ * breakpoints `--vaadin-board-width-small` or `--vaadin-board-width-medium`,
33
+ * then you need to call this method.
33
34
  */
34
35
  redraw(): void;
35
36
  }
@@ -1,14 +1,13 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2021 Vaadin Ltd
3
+ * Copyright (c) 2017 - 2022 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
6
  import '@vaadin/vaadin-license-checker/vaadin-license-checker.js';
7
7
  import './vaadin-board-row.js';
8
- import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
9
- import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
10
8
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
11
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
+ import { BoardRow } from './vaadin-board-row.js';
12
11
 
13
12
  /**
14
13
  * `<vaadin-board>` is a web component to create flexible responsive layouts
@@ -32,7 +31,7 @@ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
32
31
  * @extends HTMLElement
33
32
  * @mixes ElementMixin
34
33
  */
35
- class Board extends ElementMixin(mixinBehaviors([IronResizableBehavior], PolymerElement)) {
34
+ class Board extends ElementMixin(PolymerElement) {
36
35
  static get template() {
37
36
  return html`
38
37
  <style>
@@ -65,11 +64,12 @@ class Board extends ElementMixin(mixinBehaviors([IronResizableBehavior], Polymer
65
64
  /**
66
65
  * Redraws the board and all rows inside it, if necessary.
67
66
  *
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.
67
+ * In most cases, board will redraw itself if your reconfigure it. If you dynamically change
68
+ * breakpoints `--vaadin-board-width-small` or `--vaadin-board-width-medium`,
69
+ * then you need to call this method.
70
70
  */
71
71
  redraw() {
72
- this.notifyResize();
72
+ [...this.querySelectorAll('*')].filter((node) => node instanceof BoardRow).forEach((row) => row.redraw());
73
73
  }
74
74
  }
75
75