@vaadin/custom-field 24.5.0-rc1 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/custom-field",
3
- "version": "24.5.0-rc1",
3
+ "version": "24.6.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,32 +38,32 @@
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
40
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/a11y-base": "24.5.0-rc1",
42
- "@vaadin/component-base": "24.5.0-rc1",
43
- "@vaadin/field-base": "24.5.0-rc1",
44
- "@vaadin/vaadin-lumo-styles": "24.5.0-rc1",
45
- "@vaadin/vaadin-material-styles": "24.5.0-rc1",
46
- "@vaadin/vaadin-themable-mixin": "24.5.0-rc1",
41
+ "@vaadin/a11y-base": "24.6.0-alpha1",
42
+ "@vaadin/component-base": "24.6.0-alpha1",
43
+ "@vaadin/field-base": "24.6.0-alpha1",
44
+ "@vaadin/vaadin-lumo-styles": "24.6.0-alpha1",
45
+ "@vaadin/vaadin-material-styles": "24.6.0-alpha1",
46
+ "@vaadin/vaadin-themable-mixin": "24.6.0-alpha1",
47
47
  "lit": "^3.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@vaadin/chai-plugins": "24.5.0-rc1",
51
- "@vaadin/combo-box": "24.5.0-rc1",
52
- "@vaadin/date-picker": "24.5.0-rc1",
53
- "@vaadin/email-field": "24.5.0-rc1",
54
- "@vaadin/form-layout": "24.5.0-rc1",
55
- "@vaadin/number-field": "24.5.0-rc1",
56
- "@vaadin/password-field": "24.5.0-rc1",
57
- "@vaadin/select": "24.5.0-rc1",
50
+ "@vaadin/chai-plugins": "24.6.0-alpha1",
51
+ "@vaadin/combo-box": "24.6.0-alpha1",
52
+ "@vaadin/date-picker": "24.6.0-alpha1",
53
+ "@vaadin/email-field": "24.6.0-alpha1",
54
+ "@vaadin/form-layout": "24.6.0-alpha1",
55
+ "@vaadin/number-field": "24.6.0-alpha1",
56
+ "@vaadin/password-field": "24.6.0-alpha1",
57
+ "@vaadin/select": "24.6.0-alpha1",
58
58
  "@vaadin/testing-helpers": "^1.0.0",
59
- "@vaadin/text-area": "24.5.0-rc1",
60
- "@vaadin/text-field": "24.5.0-rc1",
61
- "@vaadin/time-picker": "24.5.0-rc1",
59
+ "@vaadin/text-area": "24.6.0-alpha1",
60
+ "@vaadin/text-field": "24.6.0-alpha1",
61
+ "@vaadin/time-picker": "24.6.0-alpha1",
62
62
  "sinon": "^18.0.0"
63
63
  },
64
64
  "web-types": [
65
65
  "web-types.json",
66
66
  "web-types.lit.json"
67
67
  ],
68
- "gitHead": "a8ae853ab69d7938cf507843784f1551a2eeb972"
68
+ "gitHead": "ae1fb0e6e7ce925999051c6cc62ba8476264c63f"
69
69
  }
@@ -65,6 +65,7 @@ export const CustomFieldMixin = (superClass) =>
65
65
  inputs: {
66
66
  type: Array,
67
67
  readOnly: true,
68
+ observer: '__inputsChanged',
68
69
  },
69
70
 
70
71
  /**
@@ -190,6 +191,21 @@ export const CustomFieldMixin = (superClass) =>
190
191
  return true;
191
192
  }
192
193
 
194
+ /**
195
+ * Override an observer from `FieldMixin`
196
+ * to validate when required is removed.
197
+ *
198
+ * @protected
199
+ * @override
200
+ */
201
+ _requiredChanged(required) {
202
+ super._requiredChanged(required);
203
+
204
+ if (required === false) {
205
+ this.validate();
206
+ }
207
+ }
208
+
193
209
  /**
194
210
  * @param {KeyboardEvent} e
195
211
  * @protected
@@ -249,7 +265,20 @@ export const CustomFieldMixin = (superClass) =>
249
265
  /** @private */
250
266
  __setInputsFromSlot() {
251
267
  this._setInputs(this.__getInputsFromSlot());
252
- this.__setValue();
268
+ }
269
+
270
+ /** @private */
271
+ __inputsChanged(inputs, oldInputs) {
272
+ if (inputs.length === 0) {
273
+ return;
274
+ }
275
+
276
+ // When inputs are first initialized, apply value set with property.
277
+ if (this.value && this.value !== '\t' && (!oldInputs || oldInputs.length === 0)) {
278
+ this.__applyInputsValue(this.value);
279
+ } else {
280
+ this.__setValue();
281
+ }
253
282
  }
254
283
 
255
284
  /** @private */
@@ -259,24 +288,31 @@ export const CustomFieldMixin = (superClass) =>
259
288
 
260
289
  /** @private */
261
290
  __valueChanged(value, oldValue) {
291
+ this.__toggleHasValue(value);
292
+
262
293
  if (this.__settingValue || !this.inputs) {
263
294
  return;
264
295
  }
265
296
 
266
- this.__toggleHasValue(value);
297
+ this.__applyInputsValue(value);
267
298
 
299
+ if (oldValue !== undefined) {
300
+ this.validate();
301
+ }
302
+ }
303
+
304
+ /** @private */
305
+ __applyInputsValue(value) {
268
306
  const parseFn = this.parseValue || defaultParseValue;
269
307
  const valuesArray = parseFn.apply(this, [value]);
308
+
270
309
  if (!valuesArray || valuesArray.length === 0) {
271
310
  console.warn('Value parser has not provided values array');
272
311
  return;
273
312
  }
274
313
 
275
- this.inputs.forEach((input, id) => {
276
- input.value = valuesArray[id];
314
+ this.inputs.forEach((input, idx) => {
315
+ input.value = valuesArray[idx];
277
316
  });
278
- if (oldValue !== undefined) {
279
- this.validate();
280
- }
281
317
  }
282
318
  };
@@ -33,6 +33,7 @@ export type CustomFieldValidatedEvent = CustomEvent<{ valid: boolean }>;
33
33
 
34
34
  /**
35
35
  * Fired on Tab keydown triggered from the internal inputs, meaning focus will not leave the inputs.
36
+ * @deprecated
36
37
  */
37
38
  export type CustomFieldInternalTabEvent = Event & {
38
39
  target: CustomField;
@@ -91,7 +92,6 @@ export interface CustomFieldEventMap extends HTMLElementEventMap, CustomFieldCus
91
92
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
92
93
  *
93
94
  * @fires {Event} change - Fired when the user commits a value change for any of the internal inputs.
94
- * @fires {Event} internal-tab - Fired on Tab keydown triggered from the internal inputs, meaning focus will not leave the inputs.
95
95
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
96
96
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
97
97
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
@@ -51,7 +51,6 @@ registerStyles('vaadin-custom-field', customFieldStyles, { moduleId: 'vaadin-cus
51
51
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
52
52
  *
53
53
  * @fires {Event} change - Fired when the user commits a value change for any of the internal inputs.
54
- * @fires {Event} internal-tab - Fired on Tab keydown triggered from the internal inputs, meaning focus will not leave the inputs.
55
54
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
56
55
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
57
56
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/custom-field",
4
- "version": "24.5.0-rc1",
4
+ "version": "24.6.0-alpha1",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -100,7 +100,7 @@
100
100
  },
101
101
  {
102
102
  "name": "value",
103
- "description": "The value of the field. When wrapping several inputs, it will contain `\\t`\n(Tab character) as a delimiter indicating parts intended to be used as the\ncorresponding inputs values.\nUse the [`formatValue`](https://cdn.vaadin.com/vaadin-web-components/24.5.0-rc1/#/elements/vaadin-custom-field#property-formatValue)\nand [`parseValue`](https://cdn.vaadin.com/vaadin-web-components/24.5.0-rc1/#/elements/vaadin-custom-field#property-parseValue)\nproperties to customize this behavior.",
103
+ "description": "The value of the field. When wrapping several inputs, it will contain `\\t`\n(Tab character) as a delimiter indicating parts intended to be used as the\ncorresponding inputs values.\nUse the [`formatValue`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha1/#/elements/vaadin-custom-field#property-formatValue)\nand [`parseValue`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha1/#/elements/vaadin-custom-field#property-parseValue)\nproperties to customize this behavior.",
104
104
  "value": {
105
105
  "type": [
106
106
  "string",
@@ -213,7 +213,7 @@
213
213
  },
214
214
  {
215
215
  "name": "value",
216
- "description": "The value of the field. When wrapping several inputs, it will contain `\\t`\n(Tab character) as a delimiter indicating parts intended to be used as the\ncorresponding inputs values.\nUse the [`formatValue`](https://cdn.vaadin.com/vaadin-web-components/24.5.0-rc1/#/elements/vaadin-custom-field#property-formatValue)\nand [`parseValue`](https://cdn.vaadin.com/vaadin-web-components/24.5.0-rc1/#/elements/vaadin-custom-field#property-parseValue)\nproperties to customize this behavior.",
216
+ "description": "The value of the field. When wrapping several inputs, it will contain `\\t`\n(Tab character) as a delimiter indicating parts intended to be used as the\ncorresponding inputs values.\nUse the [`formatValue`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha1/#/elements/vaadin-custom-field#property-formatValue)\nand [`parseValue`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha1/#/elements/vaadin-custom-field#property-parseValue)\nproperties to customize this behavior.",
217
217
  "value": {
218
218
  "type": [
219
219
  "string",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/custom-field",
4
- "version": "24.5.0-rc1",
4
+ "version": "24.6.0-alpha1",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -77,7 +77,7 @@
77
77
  },
78
78
  {
79
79
  "name": ".value",
80
- "description": "The value of the field. When wrapping several inputs, it will contain `\\t`\n(Tab character) as a delimiter indicating parts intended to be used as the\ncorresponding inputs values.\nUse the [`formatValue`](https://cdn.vaadin.com/vaadin-web-components/24.5.0-rc1/#/elements/vaadin-custom-field#property-formatValue)\nand [`parseValue`](https://cdn.vaadin.com/vaadin-web-components/24.5.0-rc1/#/elements/vaadin-custom-field#property-parseValue)\nproperties to customize this behavior.",
80
+ "description": "The value of the field. When wrapping several inputs, it will contain `\\t`\n(Tab character) as a delimiter indicating parts intended to be used as the\ncorresponding inputs values.\nUse the [`formatValue`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha1/#/elements/vaadin-custom-field#property-formatValue)\nand [`parseValue`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-alpha1/#/elements/vaadin-custom-field#property-parseValue)\nproperties to customize this behavior.",
81
81
  "value": {
82
82
  "kind": "expression"
83
83
  }