@vaadin/form-layout 23.0.0-alpha2 → 23.0.0-beta1

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/form-layout",
3
- "version": "23.0.0-alpha2",
3
+ "version": "23.0.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "main": "vaadin-form-layout.js",
20
20
  "module": "vaadin-form-layout.js",
21
+ "type": "module",
21
22
  "files": [
22
23
  "src",
23
24
  "theme",
@@ -32,19 +33,18 @@
32
33
  "polymer"
33
34
  ],
34
35
  "dependencies": {
35
- "@polymer/iron-resizable-behavior": "^3.0.0",
36
36
  "@polymer/polymer": "^3.0.0",
37
- "@vaadin/component-base": "23.0.0-alpha2",
38
- "@vaadin/vaadin-lumo-styles": "23.0.0-alpha2",
39
- "@vaadin/vaadin-material-styles": "23.0.0-alpha2",
40
- "@vaadin/vaadin-themable-mixin": "23.0.0-alpha2"
37
+ "@vaadin/component-base": "23.0.0-beta1",
38
+ "@vaadin/vaadin-lumo-styles": "23.0.0-beta1",
39
+ "@vaadin/vaadin-material-styles": "23.0.0-beta1",
40
+ "@vaadin/vaadin-themable-mixin": "23.0.0-beta1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@esm-bundle/chai": "^4.3.4",
44
- "@vaadin/custom-field": "23.0.0-alpha2",
44
+ "@vaadin/custom-field": "23.0.0-beta1",
45
45
  "@vaadin/testing-helpers": "^0.3.2",
46
- "@vaadin/text-field": "23.0.0-alpha2",
46
+ "@vaadin/text-field": "23.0.0-beta1",
47
47
  "sinon": "^9.2.1"
48
48
  },
49
- "gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
49
+ "gitHead": "467244b76021176c109df675799b07029b293e58"
50
50
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -9,7 +9,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
9
9
  * `<vaadin-form-item>` is a Web Component providing labelled form item wrapper
10
10
  * for using inside `<vaadin-form-layout>`.
11
11
  *
12
- * `<vaadin-form-item>` accepts any number of children as the input content,
12
+ * `<vaadin-form-item>` accepts a single child as the input content,
13
13
  * and also has a separate named `label` slot:
14
14
  *
15
15
  * ```html
@@ -19,19 +19,6 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
19
19
  * </vaadin-form-item>
20
20
  * ```
21
21
  *
22
- * Any content can be used. For instance, you can have multiple input elements
23
- * with surrounding text. The label can be an element of any type:
24
- *
25
- * ```html
26
- * <vaadin-form-item>
27
- * <span slot="label">Date of Birth</span>
28
- * <input placeholder="YYYY" size="4"> -
29
- * <input placeholder="MM" size="2"> -
30
- * <input placeholder="DD" size="2"><br>
31
- * <em>Example: 1900-01-01</em>
32
- * </vaadin-form-item>
33
- * ```
34
- *
35
22
  * The label is optional and can be omitted:
36
23
  *
37
24
  * ```html
@@ -58,7 +45,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
58
45
  * ### Input Width
59
46
  *
60
47
  * By default, `<vaadin-form-item>` does not manipulate the width of the slotted
61
- * input elements. Optionally you can stretch the child input element to fill
48
+ * input element. Optionally you can stretch the child input element to fill
62
49
  * the available width for the input content by adding the `full-width` class:
63
50
  *
64
51
  * ```html
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
@@ -11,7 +11,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
11
11
  * `<vaadin-form-item>` is a Web Component providing labelled form item wrapper
12
12
  * for using inside `<vaadin-form-layout>`.
13
13
  *
14
- * `<vaadin-form-item>` accepts any number of children as the input content,
14
+ * `<vaadin-form-item>` accepts a single child as the input content,
15
15
  * and also has a separate named `label` slot:
16
16
  *
17
17
  * ```html
@@ -21,19 +21,6 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
21
21
  * </vaadin-form-item>
22
22
  * ```
23
23
  *
24
- * Any content can be used. For instance, you can have multiple input elements
25
- * with surrounding text. The label can be an element of any type:
26
- *
27
- * ```html
28
- * <vaadin-form-item>
29
- * <span slot="label">Date of Birth</span>
30
- * <input placeholder="YYYY" size="4"> -
31
- * <input placeholder="MM" size="2"> -
32
- * <input placeholder="DD" size="2"><br>
33
- * <em>Example: 1900-01-01</em>
34
- * </vaadin-form-item>
35
- * ```
36
- *
37
24
  * The label is optional and can be omitted:
38
25
  *
39
26
  * ```html
@@ -60,7 +47,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
60
47
  * ### Input Width
61
48
  *
62
49
  * By default, `<vaadin-form-item>` does not manipulate the width of the slotted
63
- * input elements. Optionally you can stretch the child input element to fill
50
+ * input element. Optionally you can stretch the child input element to fill
64
51
  * the available width for the input content by adding the `full-width` class:
65
52
  *
66
53
  * ```html
@@ -295,7 +282,15 @@ class FormItem extends ThemableMixin(PolymerElement) {
295
282
  this.__fieldNode = null;
296
283
  }
297
284
 
298
- const newFieldNode = this.$.contentSlot.assignedElements().find((field) => {
285
+ const fieldNodes = this.$.contentSlot.assignedElements();
286
+ if (fieldNodes.length > 1) {
287
+ console.warn(
288
+ `WARNING: Since Vaadin 23, placing multiple fields directly to a <vaadin-form-item> is deprecated.
289
+ Please wrap fields with a <vaadin-custom-field> instead.`
290
+ );
291
+ }
292
+
293
+ const newFieldNode = fieldNodes.find((field) => {
299
294
  return !!this.__getValidateFunction(field);
300
295
  });
301
296
  if (newFieldNode) {
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
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
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
9
 
9
10
  export type FormLayoutLabelsPosition = 'aside' | 'top';
@@ -104,7 +105,7 @@ export type FormLayoutResponsiveStep = {
104
105
  * ---|---|---
105
106
  * `--vaadin-form-layout-column-spacing` | Length of the spacing between columns | `2em`
106
107
  */
107
- declare class FormLayout extends ElementMixin(ThemableMixin(HTMLElement)) {
108
+ declare class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(HTMLElement))) {
108
109
  /**
109
110
  * Allows specifying a responsive behavior with the number of columns
110
111
  * and the label position depending on the layout width.
@@ -146,8 +147,16 @@ declare class FormLayout extends ElementMixin(ThemableMixin(HTMLElement)) {
146
147
 
147
148
  /**
148
149
  * Set custom CSS property values and update the layout.
150
+ *
151
+ * @deprecated Since Vaadin 23, `updateStyles()` is deprecated.
152
+ * Use the native element.style.setProperty API to set custom CSS property values.
149
153
  */
150
154
  updateStyles(properties?: { [key: string]: string }): void;
155
+
156
+ /**
157
+ * Update the layout.
158
+ */
159
+ protected _updateLayout(): void;
151
160
  }
152
161
 
153
162
  declare global {
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
7
- import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
8
6
  import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
9
- import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
10
7
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
11
8
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
9
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
12
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
11
 
14
12
  /**
@@ -104,8 +102,9 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
104
102
  * @extends HTMLElement
105
103
  * @mixes ElementMixin
106
104
  * @mixes ThemableMixin
105
+ * @mixes ResizeMixin
107
106
  */
108
- class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizableBehavior], PolymerElement))) {
107
+ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))) {
109
108
  static get template() {
110
109
  return html`
111
110
  <style>
@@ -243,7 +242,7 @@ class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizabl
243
242
  }
244
243
 
245
244
  static get observers() {
246
- return ['_invokeUpdateStyles(_columnCount, _labelsOnTop)'];
245
+ return ['_invokeUpdateLayout(_columnCount, _labelsOnTop)'];
247
246
  }
248
247
 
249
248
  /** @protected */
@@ -254,13 +253,12 @@ class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizabl
254
253
  // `super.ready()`, because `super.ready()` invokes property observers,
255
254
  // and the observer for `responsiveSteps` does CSS value validation.
256
255
  this._styleElement = document.createElement('style');
257
- this.root.appendChild(this._styleElement);
256
+ this.appendChild(this._styleElement);
258
257
  // Ensure there is a child text node in the style element
259
258
  this._styleElement.textContent = ' ';
260
259
 
261
260
  super.ready();
262
261
 
263
- this.addEventListener('iron-resize', this._selectResponsiveStep);
264
262
  this.addEventListener('animationend', this.__onAnimationEnd);
265
263
  }
266
264
 
@@ -268,8 +266,8 @@ class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizabl
268
266
  connectedCallback() {
269
267
  super.connectedCallback();
270
268
 
271
- beforeNextRender(this, this._selectResponsiveStep);
272
- beforeNextRender(this, this.updateStyles);
269
+ requestAnimationFrame(() => this._selectResponsiveStep());
270
+ requestAnimationFrame(() => this._updateLayout());
273
271
 
274
272
  this._observeChildrenColspanChange();
275
273
  }
@@ -293,7 +291,7 @@ class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizabl
293
291
  mutation.type === 'attributes' &&
294
292
  (mutation.attributeName === 'colspan' || mutation.attributeName === 'hidden')
295
293
  ) {
296
- this.updateStyles();
294
+ this._updateLayout();
297
295
  }
298
296
  });
299
297
  });
@@ -307,7 +305,7 @@ class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizabl
307
305
  });
308
306
 
309
307
  if (addedNodes.length > 0 || removedNodes.length > 0) {
310
- this.updateStyles();
308
+ this._updateLayout();
311
309
  }
312
310
  });
313
311
  }
@@ -433,18 +431,33 @@ class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizabl
433
431
  }
434
432
 
435
433
  /** @private */
436
- _invokeUpdateStyles() {
437
- this.updateStyles();
434
+ _invokeUpdateLayout() {
435
+ this._updateLayout();
438
436
  }
439
437
 
440
438
  /**
441
439
  * Set custom CSS property values and update the layout.
442
- * @param {Object<string, string>=} properties
443
- * @protected
440
+ *
441
+ * @deprecated Since Vaadin 23, `updateStyles()` is deprecated.
442
+ * Use the native element.style.setProperty API to set custom CSS property values.
444
443
  */
445
- updateStyles(properties) {
446
- super.updateStyles(properties);
444
+ updateStyles(properties = {}) {
445
+ console.warn(
446
+ `WARNING: Since Vaadin 23, updateStyles() is deprecated. Use the native element.style.setProperty API to set custom CSS property values.`
447
+ );
448
+
449
+ Object.entries(properties).forEach(([key, value]) => {
450
+ this.style.setProperty(key, value);
451
+ });
447
452
 
453
+ this._updateLayout();
454
+ }
455
+
456
+ /**
457
+ * Update the layout.
458
+ * @protected
459
+ */
460
+ _updateLayout() {
448
461
  /*
449
462
  The item width formula:
450
463
 
@@ -525,6 +538,14 @@ class FormLayout extends ElementMixin(ThemableMixin(mixinBehaviors([IronResizabl
525
538
  }
526
539
  });
527
540
  }
541
+
542
+ /**
543
+ * @protected
544
+ * @override
545
+ */
546
+ _onResize() {
547
+ this._selectResponsiveStep();
548
+ }
528
549
  }
529
550
 
530
551
  customElements.define(FormLayout.is, FormLayout);