@vaadin/form-layout 23.1.0-alpha1 → 23.1.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/form-layout",
3
- "version": "23.1.0-alpha1",
3
+ "version": "23.1.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,17 +34,17 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@polymer/polymer": "^3.0.0",
37
- "@vaadin/component-base": "23.1.0-alpha1",
38
- "@vaadin/vaadin-lumo-styles": "23.1.0-alpha1",
39
- "@vaadin/vaadin-material-styles": "23.1.0-alpha1",
40
- "@vaadin/vaadin-themable-mixin": "23.1.0-alpha1"
37
+ "@vaadin/component-base": "23.1.0-alpha4",
38
+ "@vaadin/vaadin-lumo-styles": "23.1.0-alpha4",
39
+ "@vaadin/vaadin-material-styles": "23.1.0-alpha4",
40
+ "@vaadin/vaadin-themable-mixin": "23.1.0-alpha4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@esm-bundle/chai": "^4.3.4",
44
- "@vaadin/custom-field": "23.1.0-alpha1",
44
+ "@vaadin/custom-field": "23.1.0-alpha4",
45
45
  "@vaadin/testing-helpers": "^0.3.2",
46
- "@vaadin/text-field": "23.1.0-alpha1",
47
- "sinon": "^9.2.1"
46
+ "@vaadin/text-field": "23.1.0-alpha4",
47
+ "sinon": "^13.0.2"
48
48
  },
49
- "gitHead": "5d0cdee069f866037c507265fafb4d0476795333"
49
+ "gitHead": "aacdb7fe09811894751f0378ff7fb66071892c71"
50
50
  }
@@ -177,10 +177,6 @@ class FormItem extends ThemableMixin(PolymerElement) {
177
177
  * @private
178
178
  */
179
179
  this.__fieldNode = null;
180
-
181
- // Ensure every instance has unique ID
182
- const uniqueId = (FormItem._uniqueLabelId = 1 + FormItem._uniqueLabelId || 0);
183
- this.__labelId = `label-${this.localName}-${uniqueId}`;
184
180
  }
185
181
 
186
182
  /**
@@ -244,7 +240,6 @@ class FormItem extends ThemableMixin(PolymerElement) {
244
240
  */
245
241
  __onLabelSlotChange() {
246
242
  if (this.__labelNode) {
247
- this.__labelNode.id = '';
248
243
  this.__labelNode = null;
249
244
 
250
245
  if (this.__fieldNode) {
@@ -255,7 +250,16 @@ class FormItem extends ThemableMixin(PolymerElement) {
255
250
  const newLabelNode = this.$.labelSlot.assignedElements()[0];
256
251
  if (newLabelNode) {
257
252
  this.__labelNode = newLabelNode;
258
- this.__labelNode.id = this.__labelId;
253
+
254
+ if (this.__labelNode.id) {
255
+ // The new label node already has an id. Let's use it.
256
+ this.__labelId = this.__labelNode.id;
257
+ } else {
258
+ // The new label node doesn't have an id yet. Generate a unique one.
259
+ const uniqueId = (FormItem._uniqueLabelId = 1 + FormItem._uniqueLabelId || 0);
260
+ this.__labelId = `label-${this.localName}-${uniqueId}`;
261
+ this.__labelNode.id = this.__labelId;
262
+ }
259
263
 
260
264
  if (this.__fieldNode) {
261
265
  this.__linkLabelToField(this.__fieldNode);
@@ -286,7 +290,7 @@ class FormItem extends ThemableMixin(PolymerElement) {
286
290
  if (fieldNodes.length > 1) {
287
291
  console.warn(
288
292
  `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.`
293
+ Please wrap fields with a <vaadin-custom-field> instead.`,
290
294
  );
291
295
  }
292
296
 
@@ -217,10 +217,10 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
217
217
  return [
218
218
  { minWidth: 0, columns: 1, labelsPosition: 'top' },
219
219
  { minWidth: '20em', columns: 1 },
220
- { minWidth: '40em', columns: 2 }
220
+ { minWidth: '40em', columns: 2 },
221
221
  ];
222
222
  },
223
- observer: '_responsiveStepsChanged'
223
+ observer: '_responsiveStepsChanged',
224
224
  },
225
225
 
226
226
  /**
@@ -228,7 +228,7 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
228
228
  * @private
229
229
  */
230
230
  _columnCount: {
231
- type: Number
231
+ type: Number,
232
232
  },
233
233
 
234
234
  /**
@@ -236,8 +236,8 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
236
236
  * @private
237
237
  */
238
238
  _labelsOnTop: {
239
- type: Boolean
240
- }
239
+ type: Boolean,
240
+ },
241
241
  };
242
242
  }
243
243
 
@@ -314,7 +314,7 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
314
314
  _getObservableNodes(nodeList) {
315
315
  const ignore = ['template', 'style', 'dom-repeat', 'dom-if'];
316
316
  return Array.from(nodeList).filter(
317
- (node) => node.nodeType === Node.ELEMENT_NODE && ignore.indexOf(node.localName.toLowerCase()) === -1
317
+ (node) => node.nodeType === Node.ELEMENT_NODE && ignore.indexOf(node.localName.toLowerCase()) === -1,
318
318
  );
319
319
  }
320
320
 
@@ -376,7 +376,7 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
376
376
 
377
377
  if (step.labelsPosition !== undefined && ['aside', 'top'].indexOf(step.labelsPosition) === -1) {
378
378
  throw new Error(
379
- `Invalid 'labelsPosition' value of ${step.labelsPosition}, 'aside' or 'top' string is required.`
379
+ `Invalid 'labelsPosition' value of ${step.labelsPosition}, 'aside' or 'top' string is required.`,
380
380
  );
381
381
  }
382
382
  });
@@ -389,7 +389,7 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
389
389
  this.responsiveSteps = [
390
390
  { minWidth: 0, columns: 1, labelsPosition: 'top' },
391
391
  { minWidth: '20em', columns: 1 },
392
- { minWidth: '40em', columns: 2 }
392
+ { minWidth: '40em', columns: 2 },
393
393
  ];
394
394
  }
395
395
  }
@@ -443,7 +443,7 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
443
443
  */
444
444
  updateStyles(properties = {}) {
445
445
  console.warn(
446
- `WARNING: Since Vaadin 23, updateStyles() is deprecated. Use the native element.style.setProperty API to set custom CSS property values.`
446
+ `WARNING: Since Vaadin 23, updateStyles() is deprecated. Use the native element.style.setProperty API to set custom CSS property values.`,
447
447
  );
448
448
 
449
449
  Object.entries(properties).forEach(([key, value]) => {
@@ -471,8 +471,8 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
471
471
  const columnSpacing = style.getPropertyValue('--vaadin-form-layout-column-spacing');
472
472
 
473
473
  const direction = style.direction;
474
- const marginStartProp = 'margin-' + (direction === 'ltr' ? 'left' : 'right');
475
- const marginEndProp = 'margin-' + (direction === 'ltr' ? 'right' : 'left');
474
+ const marginStartProp = `margin-${direction === 'ltr' ? 'left' : 'right'}`;
475
+ const marginEndProp = `margin-${direction === 'ltr' ? 'right' : 'left'}`;
476
476
 
477
477
  const containerWidth = this.offsetWidth;
478
478
 
@@ -520,7 +520,7 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
520
520
  const colspanRatio = (this._columnCount - col - colspan) / this._columnCount;
521
521
  child.style.setProperty(
522
522
  marginEndProp,
523
- `calc(${colspanRatio * containerWidth}px + ${colspanRatio} * ${columnSpacing})`
523
+ `calc(${colspanRatio * containerWidth}px + ${colspanRatio} * ${columnSpacing})`,
524
524
  );
525
525
  } else {
526
526
  child.style.removeProperty(marginEndProp);
@@ -42,5 +42,5 @@ registerStyles(
42
42
  color: var(--lumo-required-field-indicator-color, var(--lumo-error-text-color));
43
43
  }
44
44
  `,
45
- { moduleId: 'lumo-form-item' }
45
+ { moduleId: 'lumo-form-item' },
46
46
  );
@@ -8,5 +8,5 @@ registerStyles(
8
8
  --vaadin-form-layout-column-spacing: var(--lumo-space-l);
9
9
  }
10
10
  `,
11
- { moduleId: 'lumo-form-layout' }
11
+ { moduleId: 'lumo-form-layout' },
12
12
  );
@@ -24,5 +24,5 @@ registerStyles(
24
24
  color: var(--material-error-text-color);
25
25
  }
26
26
  `,
27
- { moduleId: 'material-form-item' }
27
+ { moduleId: 'material-form-item' },
28
28
  );