@vaadin/select 23.1.2 → 23.2.0-alpha3

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/select",
3
- "version": "23.1.2",
3
+ "version": "23.2.0-alpha3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,10 +20,10 @@
20
20
  "module": "vaadin-select.js",
21
21
  "type": "module",
22
22
  "files": [
23
+ "lit.d.ts",
24
+ "lit.js",
23
25
  "src",
24
26
  "theme",
25
- "lit.js",
26
- "lit.d.ts",
27
27
  "vaadin-*.d.ts",
28
28
  "vaadin-*.js"
29
29
  ],
@@ -36,25 +36,25 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@polymer/polymer": "^3.2.0",
39
- "@vaadin/button": "^23.1.2",
40
- "@vaadin/component-base": "^23.1.2",
41
- "@vaadin/field-base": "^23.1.2",
42
- "@vaadin/input-container": "^23.1.2",
43
- "@vaadin/item": "^23.1.2",
44
- "@vaadin/list-box": "^23.1.2",
45
- "@vaadin/lit-renderer": "^23.1.2",
46
- "@vaadin/vaadin-list-mixin": "^23.1.2",
47
- "@vaadin/vaadin-lumo-styles": "^23.1.2",
48
- "@vaadin/vaadin-material-styles": "^23.1.2",
49
- "@vaadin/vaadin-overlay": "^23.1.2",
50
- "@vaadin/vaadin-themable-mixin": "^23.1.2"
39
+ "@vaadin/button": "23.2.0-alpha3",
40
+ "@vaadin/component-base": "23.2.0-alpha3",
41
+ "@vaadin/field-base": "23.2.0-alpha3",
42
+ "@vaadin/input-container": "23.2.0-alpha3",
43
+ "@vaadin/item": "23.2.0-alpha3",
44
+ "@vaadin/list-box": "23.2.0-alpha3",
45
+ "@vaadin/lit-renderer": "23.2.0-alpha3",
46
+ "@vaadin/vaadin-list-mixin": "23.2.0-alpha3",
47
+ "@vaadin/vaadin-lumo-styles": "23.2.0-alpha3",
48
+ "@vaadin/vaadin-material-styles": "23.2.0-alpha3",
49
+ "@vaadin/vaadin-overlay": "23.2.0-alpha3",
50
+ "@vaadin/vaadin-themable-mixin": "23.2.0-alpha3"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@esm-bundle/chai": "^4.3.4",
54
- "@vaadin/polymer-legacy-adapter": "^23.1.2",
54
+ "@vaadin/polymer-legacy-adapter": "23.2.0-alpha3",
55
55
  "@vaadin/testing-helpers": "^0.3.2",
56
56
  "lit": "^2.0.0",
57
57
  "sinon": "^13.0.2"
58
58
  },
59
- "gitHead": "6fb205c6e9a761feadfb779dd5d7af96d3102e56"
59
+ "gitHead": "06e5875be93ca50da2846dafc65a8531010c0576"
60
60
  }
@@ -3,10 +3,10 @@
3
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 { TemplateResult } from 'lit';
7
- import { DirectiveResult } from 'lit/directive.js';
6
+ import type { TemplateResult } from 'lit';
7
+ import type { DirectiveResult } from 'lit/directive.js';
8
8
  import { LitRendererDirective } from '@vaadin/lit-renderer';
9
- import { Select } from '../vaadin-select.js';
9
+ import type { Select } from '../vaadin-select.js';
10
10
 
11
11
  export type SelectLitRenderer = (select: Select) => TemplateResult;
12
12
 
@@ -4,7 +4,6 @@
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 { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
8
7
  import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
9
8
  import { FieldMixin } from '@vaadin/field-base/src/field-mixin.js';
10
9
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -48,12 +47,19 @@ export type SelectInvalidChangedEvent = CustomEvent<{ value: boolean }>;
48
47
  */
49
48
  export type SelectValueChangedEvent = CustomEvent<{ value: string }>;
50
49
 
50
+ /**
51
+ * Fired whenever the field is validated.
52
+ */
53
+ export type SelectValidatedEvent = CustomEvent<{ valid: boolean }>;
54
+
51
55
  export interface SelectCustomEventMap {
52
56
  'opened-changed': SelectOpenedChangedEvent;
53
57
 
54
58
  'invalid-changed': SelectInvalidChangedEvent;
55
59
 
56
60
  'value-changed': SelectValueChangedEvent;
61
+
62
+ validated: SelectValidatedEvent;
57
63
  }
58
64
 
59
65
  export interface SelectEventMap extends HTMLElementEventMap, SelectCustomEventMap {
@@ -163,8 +169,9 @@ export interface SelectEventMap extends HTMLElementEventMap, SelectCustomEventMa
163
169
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
164
170
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
165
171
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
172
+ * @fires {CustomEvent} validated - Fired whenever the field is validated.
166
173
  */
167
- declare class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(ThemableMixin(HTMLElement))))) {
174
+ declare class Select extends DelegateFocusMixin(FieldMixin(ElementMixin(ThemableMixin(HTMLElement)))) {
168
175
  /**
169
176
  * An array containing items that will be rendered as the options of the select.
170
177
  *
@@ -11,8 +11,9 @@ import './vaadin-select-value-button.js';
11
11
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
12
12
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
13
13
  import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
14
- import { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
14
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
15
15
  import { processTemplates } from '@vaadin/component-base/src/templates.js';
16
+ import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
16
17
  import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
17
18
  import { FieldMixin } from '@vaadin/field-base/src/field-mixin.js';
18
19
  import { fieldShared } from '@vaadin/field-base/src/styles/field-shared-styles.js';
@@ -124,15 +125,15 @@ registerStyles('vaadin-select', [fieldShared, inputFieldContainer], { moduleId:
124
125
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
125
126
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
126
127
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
128
+ * @fires {CustomEvent} validated - Fired whenever the field is validated.
127
129
  *
128
130
  * @extends HTMLElement
129
131
  * @mixes ElementMixin
130
132
  * @mixes ThemableMixin
131
- * @mixes SlotMixin
132
133
  * @mixes FieldMixin
133
134
  * @mixes DelegateFocusMixin
134
135
  */
135
- class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(ThemableMixin(PolymerElement))))) {
136
+ class Select extends DelegateFocusMixin(FieldMixin(ElementMixin(ThemableMixin(PolymerElement)))) {
136
137
  static get is() {
137
138
  return 'vaadin-select';
138
139
  }
@@ -311,56 +312,23 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
311
312
  ];
312
313
  }
313
314
 
314
- /** @protected */
315
- get slots() {
316
- return {
317
- ...super.slots,
318
- value: () => {
319
- const button = document.createElement('vaadin-select-value-button');
320
- button.setAttribute('aria-haspopup', 'listbox');
321
- return button;
322
- },
323
- };
324
- }
325
-
326
315
  /** @protected */
327
316
  get _valueButton() {
328
- return this._getDirectSlotChild('value');
317
+ return this._valueButtonController && this._valueButtonController.node;
329
318
  }
330
319
 
331
320
  constructor() {
332
321
  super();
333
322
 
334
- // Ensure every instance has unique ID
335
- const uniqueId = (Select._uniqueSelectId = 1 + Select._uniqueSelectId || 0);
336
- this._fieldId = `${this.localName}-${uniqueId}`;
323
+ this._fieldId = `${this.localName}-${generateUniqueId()}`;
337
324
 
338
325
  this._boundOnKeyDown = this._onKeyDown.bind(this);
339
326
  }
340
327
 
341
- /** @protected */
342
- connectedCallback() {
343
- super.connectedCallback();
344
-
345
- if (this._valueButton) {
346
- this._valueButton.setAttribute('aria-labelledby', `${this._labelId} ${this._fieldId}`);
347
-
348
- this._updateAriaRequired(this.required);
349
- this._updateAriaExpanded(this.opened);
350
-
351
- this._setFocusElement(this._valueButton);
352
- this.ariaTarget = this._valueButton;
353
-
354
- this._valueButton.addEventListener('keydown', this._boundOnKeyDown);
355
- }
356
- }
357
-
358
328
  /** @protected */
359
329
  disconnectedCallback() {
360
330
  super.disconnectedCallback();
361
- if (this._valueButton) {
362
- this._valueButton.removeEventListener('keydown', this._boundOnKeyDown);
363
- }
331
+
364
332
  // Making sure the select is closed and removed from DOM after detaching the select.
365
333
  this.opened = false;
366
334
  }
@@ -372,6 +340,25 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
372
340
  this._overlayElement = this.shadowRoot.querySelector('vaadin-select-overlay');
373
341
  this._inputContainer = this.shadowRoot.querySelector('[part~="input-field"]');
374
342
 
343
+ this._valueButtonController = new SlotController(
344
+ this,
345
+ 'value',
346
+ () => document.createElement('vaadin-select-value-button'),
347
+ (host, btn) => {
348
+ this._setFocusElement(btn);
349
+ this.ariaTarget = btn;
350
+
351
+ btn.setAttribute('aria-haspopup', 'listbox');
352
+ btn.setAttribute('aria-labelledby', `${this._labelId} ${this._fieldId}`);
353
+
354
+ this._updateAriaRequired(host.required);
355
+ this._updateAriaExpanded(host.opened);
356
+
357
+ btn.addEventListener('keydown', this._boundOnKeyDown);
358
+ },
359
+ );
360
+ this.addController(this._valueButtonController);
361
+
375
362
  this.addController(
376
363
  new MediaQueryController(this._phoneMediaQuery, (matches) => {
377
364
  this._phone = matches;