@vaadin/select 24.2.0-dev.f254716fe → 24.3.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/select",
3
- "version": "24.2.0-dev.f254716fe",
3
+ "version": "24.3.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -47,22 +47,22 @@
47
47
  "dependencies": {
48
48
  "@open-wc/dedupe-mixin": "^1.3.0",
49
49
  "@polymer/polymer": "^3.2.0",
50
- "@vaadin/a11y-base": "24.2.0-dev.f254716fe",
51
- "@vaadin/button": "24.2.0-dev.f254716fe",
52
- "@vaadin/component-base": "24.2.0-dev.f254716fe",
53
- "@vaadin/field-base": "24.2.0-dev.f254716fe",
54
- "@vaadin/input-container": "24.2.0-dev.f254716fe",
55
- "@vaadin/item": "24.2.0-dev.f254716fe",
56
- "@vaadin/list-box": "24.2.0-dev.f254716fe",
57
- "@vaadin/lit-renderer": "24.2.0-dev.f254716fe",
58
- "@vaadin/overlay": "24.2.0-dev.f254716fe",
59
- "@vaadin/vaadin-lumo-styles": "24.2.0-dev.f254716fe",
60
- "@vaadin/vaadin-material-styles": "24.2.0-dev.f254716fe",
61
- "@vaadin/vaadin-themable-mixin": "24.2.0-dev.f254716fe"
50
+ "@vaadin/a11y-base": "24.3.0-alpha1",
51
+ "@vaadin/button": "24.3.0-alpha1",
52
+ "@vaadin/component-base": "24.3.0-alpha1",
53
+ "@vaadin/field-base": "24.3.0-alpha1",
54
+ "@vaadin/input-container": "24.3.0-alpha1",
55
+ "@vaadin/item": "24.3.0-alpha1",
56
+ "@vaadin/list-box": "24.3.0-alpha1",
57
+ "@vaadin/lit-renderer": "24.3.0-alpha1",
58
+ "@vaadin/overlay": "24.3.0-alpha1",
59
+ "@vaadin/vaadin-lumo-styles": "24.3.0-alpha1",
60
+ "@vaadin/vaadin-material-styles": "24.3.0-alpha1",
61
+ "@vaadin/vaadin-themable-mixin": "24.3.0-alpha1"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@esm-bundle/chai": "^4.3.4",
65
- "@vaadin/testing-helpers": "^0.4.3",
65
+ "@vaadin/testing-helpers": "^0.5.0",
66
66
  "lit": "^2.0.0",
67
67
  "sinon": "^13.0.2"
68
68
  },
@@ -70,5 +70,5 @@
70
70
  "web-types.json",
71
71
  "web-types.lit.json"
72
72
  ],
73
- "gitHead": "da54950b9f8c14c6451ede0d426e16a489c7fb9b"
73
+ "gitHead": "9ca6f3ca220a777e8eea181a1f5717e39a732240"
74
74
  }
@@ -5,7 +5,10 @@
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import type { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
8
+ import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
+ import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
8
10
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
11
+ import type { TabindexMixinClass } from '@vaadin/a11y-base/src/tabindex-mixin.js';
9
12
  import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
10
13
  import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
11
14
  import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
@@ -17,11 +20,14 @@ export declare function SelectBaseMixin<T extends Constructor<HTMLElement>>(
17
20
  base: T,
18
21
  ): Constructor<DelegateFocusMixinClass> &
19
22
  Constructor<DelegateStateMixinClass> &
23
+ Constructor<DisabledMixinClass> &
20
24
  Constructor<FieldMixinClass> &
25
+ Constructor<FocusMixinClass> &
21
26
  Constructor<KeyboardMixinClass> &
22
27
  Constructor<LabelMixinClass> &
23
28
  Constructor<OverlayClassMixinClass> &
24
29
  Constructor<SelectBaseMixinClass> &
30
+ Constructor<TabindexMixinClass> &
25
31
  Constructor<ValidateMixinClass> &
26
32
  T;
27
33
 
@@ -96,6 +102,15 @@ export declare class SelectBaseMixinClass {
96
102
  */
97
103
  readonly: boolean;
98
104
 
105
+ /**
106
+ * Whether the field is dirty.
107
+ *
108
+ * The field is automatically marked as dirty once the user triggers
109
+ * a `change` event. Additionally, the field can be manually marked
110
+ * as dirty by setting the property to `true`.
111
+ */
112
+ dirty: boolean;
113
+
99
114
  /**
100
115
  * Requests an update for the content of the select.
101
116
  * While performing the update, it invokes the renderer passed in the `renderer` property.
@@ -127,6 +127,19 @@ export const SelectBaseMixin = (superClass) =>
127
127
  reflectToAttribute: true,
128
128
  },
129
129
 
130
+ /**
131
+ * Whether the field is dirty.
132
+ *
133
+ * The field is automatically marked as dirty once the user triggers
134
+ * a `change` event. Additionally, the field can be manually marked
135
+ * as dirty by setting the property to `true`.
136
+ */
137
+ dirty: {
138
+ type: Boolean,
139
+ value: false,
140
+ notify: true,
141
+ },
142
+
130
143
  /** @private */
131
144
  _phone: Boolean,
132
145
 
@@ -190,6 +203,7 @@ export const SelectBaseMixin = (superClass) =>
190
203
 
191
204
  this._tooltipController = new TooltipController(this);
192
205
  this._tooltipController.setPosition('top');
206
+ this._tooltipController.setAriaTarget(this.focusElement);
193
207
  this.addController(this._tooltipController);
194
208
  }
195
209
 
@@ -259,8 +273,7 @@ export const SelectBaseMixin = (superClass) =>
259
273
  menuElement.addEventListener(
260
274
  'click',
261
275
  () => {
262
- this.__userInteraction = true;
263
- this.opened = false;
276
+ this.__dispatchChangePending = true;
264
277
  },
265
278
  true,
266
279
  );
@@ -281,8 +294,10 @@ export const SelectBaseMixin = (superClass) =>
281
294
  _valueChanged(value, oldValue) {
282
295
  this.toggleAttribute('has-value', Boolean(value));
283
296
 
284
- // Validate only if `value` changes after initialization.
285
- if (oldValue !== undefined) {
297
+ // Skip validation during initialization and when
298
+ // a change event is scheduled, as validation will be
299
+ // triggered by `__dispatchChange()` in that case.
300
+ if (oldValue !== undefined && !this.__dispatchChangePending) {
286
301
  this.validate();
287
302
  }
288
303
  }
@@ -322,7 +337,7 @@ export const SelectBaseMixin = (superClass) =>
322
337
  const currentIdx = selected !== undefined ? selected : -1;
323
338
  const newIdx = this._menuElement._searchKey(currentIdx, e.key);
324
339
  if (newIdx >= 0) {
325
- this.__userInteraction = true;
340
+ this.__dispatchChangePending = true;
326
341
 
327
342
  // Announce the value selected with the first letter shortcut
328
343
  this._updateAriaLive(true);
@@ -371,7 +386,13 @@ export const SelectBaseMixin = (superClass) =>
371
386
  if (this._openedWithFocusRing) {
372
387
  this.setAttribute('focus-ring', '');
373
388
  }
374
- this.validate();
389
+
390
+ // Skip validation when a change event is scheduled, as validation
391
+ // will be triggered by `__dispatchChange()` in that case.
392
+ // Also, skip validation when closed on Escape or Tab keys.
393
+ if (!this.__dispatchChangePending && !this._keyboardActive) {
394
+ this.validate();
395
+ }
375
396
  }
376
397
  }
377
398
 
@@ -441,6 +462,9 @@ export const SelectBaseMixin = (superClass) =>
441
462
  itemElement.removeAttribute('tabindex');
442
463
  itemElement.removeAttribute('aria-selected');
443
464
  itemElement.removeAttribute('role');
465
+ itemElement.removeAttribute('focused');
466
+ itemElement.removeAttribute('focus-ring');
467
+ itemElement.removeAttribute('active');
444
468
  itemElement.setAttribute('id', this._itemId);
445
469
  }
446
470
 
@@ -508,10 +532,9 @@ export const SelectBaseMixin = (superClass) =>
508
532
  if (!this._valueChanging) {
509
533
  this._selectedChanging = true;
510
534
  this.value = selected.value || '';
511
- if (this.__userInteraction) {
535
+ if (this.__dispatchChangePending) {
512
536
  this.opened = false;
513
- this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
514
- this.__userInteraction = false;
537
+ this.__dispatchChange();
515
538
  }
516
539
  delete this._selectedChanging;
517
540
  }
@@ -600,4 +623,18 @@ export const SelectBaseMixin = (superClass) =>
600
623
  listBox.appendChild(this.__createItemElement(item));
601
624
  });
602
625
  }
626
+
627
+ /** @private */
628
+ async __dispatchChange() {
629
+ // Wait for the update complete to guarantee that value-changed is fired
630
+ // before validated and change events when using the Lit version of the component.
631
+ if (this.updateComplete) {
632
+ await this.updateComplete;
633
+ }
634
+
635
+ this.dirty = true;
636
+ this.validate();
637
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
638
+ this.__dispatchChangePending = false;
639
+ }
603
640
  };
@@ -4,6 +4,7 @@
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';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
7
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8
9
  import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
9
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -11,6 +12,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
11
12
  /**
12
13
  * An element used internally by `<vaadin-select>`. Not intended to be used separately.
13
14
  *
15
+ * @customElement
14
16
  * @extends HTMLElement
15
17
  * @mixes DirMixin
16
18
  * @mixes ItemMixin
@@ -48,6 +50,6 @@ class SelectItem extends ItemMixin(ThemableMixin(DirMixin(PolymerElement))) {
48
50
  }
49
51
  }
50
52
 
51
- customElements.define(SelectItem.is, SelectItem);
53
+ defineCustomElement(SelectItem);
52
54
 
53
55
  export { SelectItem };
@@ -6,12 +6,14 @@
6
6
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
7
  import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
8
8
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
9
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
10
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
10
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
12
 
12
13
  /**
13
14
  * An element used internally by `<vaadin-select>`. Not intended to be used separately.
14
15
  *
16
+ * @customElement
15
17
  * @extends HTMLElement
16
18
  * @mixes ControllerMixin
17
19
  * @mixes DirMixin
@@ -76,4 +78,4 @@ class SelectListBox extends ListMixin(ThemableMixin(DirMixin(ControllerMixin(Pol
76
78
  }
77
79
  }
78
80
 
79
- customElements.define(SelectListBox.is, SelectListBox);
81
+ defineCustomElement(SelectListBox);
@@ -4,6 +4,7 @@
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';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
7
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8
9
  import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
9
10
  import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
@@ -30,6 +31,7 @@ registerStyles('vaadin-select-overlay', [overlayStyles, selectOverlayStyles], {
30
31
  /**
31
32
  * An element used internally by `<vaadin-select>`. Not intended to be used separately.
32
33
  *
34
+ * @customElement
33
35
  * @extends HTMLElement
34
36
  * @mixes DirMixin
35
37
  * @mixes OverlayMixin
@@ -69,4 +71,4 @@ export class SelectOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableM
69
71
  }
70
72
  }
71
73
 
72
- customElements.define(SelectOverlay.is, SelectOverlay);
74
+ defineCustomElement(SelectOverlay);
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
7
  import { ButtonMixin } from '@vaadin/button/src/vaadin-button-mixin.js';
8
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
9
  import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
10
  import { valueButton } from './vaadin-select-value-button-styles.js';
10
11
 
@@ -13,6 +14,7 @@ registerStyles('vaadin-select-value-button', valueButton, { moduleId: 'vaadin-se
13
14
  /**
14
15
  * An element used internally by `<vaadin-select>`. Not intended to be used separately.
15
16
  *
17
+ * @customElement
16
18
  * @extends HTMLElement
17
19
  * @mixes ButtonMixin
18
20
  * @mixes ThemableMixin
@@ -34,4 +36,4 @@ class SelectValueButton extends ButtonMixin(ThemableMixin(PolymerElement)) {
34
36
  }
35
37
  }
36
38
 
37
- customElements.define(SelectValueButton.is, SelectValueButton);
39
+ defineCustomElement(SelectValueButton);
@@ -41,6 +41,11 @@ export type SelectOpenedChangedEvent = CustomEvent<{ value: boolean }>;
41
41
  */
42
42
  export type SelectInvalidChangedEvent = CustomEvent<{ value: boolean }>;
43
43
 
44
+ /**
45
+ * Fired when the `dirty` property changes.
46
+ */
47
+ export type SelectDirtyChangedEvent = CustomEvent<{ value: boolean }>;
48
+
44
49
  /**
45
50
  * Fired when the `value` property changes.
46
51
  */
@@ -56,6 +61,8 @@ export interface SelectCustomEventMap {
56
61
 
57
62
  'invalid-changed': SelectInvalidChangedEvent;
58
63
 
64
+ 'dirty-changed': SelectDirtyChangedEvent;
65
+
59
66
  'value-changed': SelectValueChangedEvent;
60
67
 
61
68
  validated: SelectValidatedEvent;
@@ -167,6 +174,7 @@ export interface SelectEventMap extends HTMLElementEventMap, SelectCustomEventMa
167
174
  * @fires {Event} change - Fired when the user commits a value change.
168
175
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
169
176
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
177
+ * @fires {CustomEvent} dirty-changed - Fired when the `dirty` property changes.
170
178
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
171
179
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
172
180
  */
@@ -10,6 +10,7 @@ import './vaadin-select-overlay.js';
10
10
  import './vaadin-select-value-button.js';
11
11
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
12
12
  import { screenReaderOnly } from '@vaadin/a11y-base/src/styles/sr-only-styles.js';
13
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
13
14
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
14
15
  import { processTemplates } from '@vaadin/component-base/src/templates.js';
15
16
  import { fieldShared } from '@vaadin/field-base/src/styles/field-shared-styles.js';
@@ -126,6 +127,7 @@ registerStyles('vaadin-select', [fieldShared, inputFieldContainer, screenReaderO
126
127
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
127
128
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
128
129
  *
130
+ * @customElement
129
131
  * @extends HTMLElement
130
132
  * @mixes ElementMixin
131
133
  * @mixes SelectBaseMixin
@@ -139,6 +141,10 @@ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolymerElement))
139
141
  static get template() {
140
142
  return html`
141
143
  <style>
144
+ :host {
145
+ position: relative;
146
+ }
147
+
142
148
  ::slotted([slot='value']) {
143
149
  flex-grow: 1;
144
150
  }
@@ -228,6 +234,6 @@ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolymerElement))
228
234
  */
229
235
  }
230
236
 
231
- customElements.define(Select.is, Select);
237
+ defineCustomElement(Select);
232
238
 
233
239
  export { Select };
package/web-types.json ADDED
@@ -0,0 +1,418 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/select",
4
+ "version": "24.3.0-alpha1",
5
+ "description-markup": "markdown",
6
+ "contributions": {
7
+ "html": {
8
+ "elements": [
9
+ {
10
+ "name": "vaadin-select",
11
+ "description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc' },\n { label: 'Rating: high to low', value: 'rating-desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-----------------------------|-----------\n`opened` | Set when the select is open | :host\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
+ "attributes": [
13
+ {
14
+ "name": "disabled",
15
+ "description": "If true, the user cannot interact with this element.",
16
+ "value": {
17
+ "type": [
18
+ "boolean",
19
+ "null",
20
+ "undefined"
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "name": "autofocus",
26
+ "description": "Specify that this control should have input focus when the page loads.",
27
+ "value": {
28
+ "type": [
29
+ "boolean",
30
+ "null",
31
+ "undefined"
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "name": "label",
37
+ "description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
38
+ "value": {
39
+ "type": [
40
+ "string",
41
+ "null",
42
+ "undefined"
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "name": "invalid",
48
+ "description": "Set to true when the field is invalid.",
49
+ "value": {
50
+ "type": [
51
+ "boolean",
52
+ "null",
53
+ "undefined"
54
+ ]
55
+ }
56
+ },
57
+ {
58
+ "name": "required",
59
+ "description": "Specifies that the user must fill in a value.",
60
+ "value": {
61
+ "type": [
62
+ "boolean",
63
+ "null",
64
+ "undefined"
65
+ ]
66
+ }
67
+ },
68
+ {
69
+ "name": "error-message",
70
+ "description": "Error to show when the field is invalid.",
71
+ "value": {
72
+ "type": [
73
+ "string",
74
+ "null",
75
+ "undefined"
76
+ ]
77
+ }
78
+ },
79
+ {
80
+ "name": "helper-text",
81
+ "description": "String used for the helper text.",
82
+ "value": {
83
+ "type": [
84
+ "string",
85
+ "null",
86
+ "undefined"
87
+ ]
88
+ }
89
+ },
90
+ {
91
+ "name": "accessible-name",
92
+ "description": "String used to label the component to screen reader users.",
93
+ "value": {
94
+ "type": [
95
+ "string",
96
+ "null",
97
+ "undefined"
98
+ ]
99
+ }
100
+ },
101
+ {
102
+ "name": "accessible-name-ref",
103
+ "description": "Id of the element used as label of the component to screen reader users.",
104
+ "value": {
105
+ "type": [
106
+ "string",
107
+ "null",
108
+ "undefined"
109
+ ]
110
+ }
111
+ },
112
+ {
113
+ "name": "overlay-class",
114
+ "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
115
+ "value": {
116
+ "type": [
117
+ "string",
118
+ "null",
119
+ "undefined"
120
+ ]
121
+ }
122
+ },
123
+ {
124
+ "name": "opened",
125
+ "description": "Set when the select is open",
126
+ "value": {
127
+ "type": [
128
+ "boolean"
129
+ ]
130
+ }
131
+ },
132
+ {
133
+ "name": "value",
134
+ "description": "The `value` property of the selected item, or an empty string\nif no item is selected.\nOn change or initialization, the component finds the item which matches the\nvalue and displays it.\nIf no value is provided to the component, it selects the first item without\nvalue or empty value.\nHint: If you do not want to select any item by default, you can either set all\nthe values of inner vaadin-items, or set the vaadin-select value to\nan inexistent value in the items list.",
135
+ "value": {
136
+ "type": [
137
+ "string"
138
+ ]
139
+ }
140
+ },
141
+ {
142
+ "name": "name",
143
+ "description": "The name of this element.",
144
+ "value": {
145
+ "type": [
146
+ "string",
147
+ "null",
148
+ "undefined"
149
+ ]
150
+ }
151
+ },
152
+ {
153
+ "name": "placeholder",
154
+ "description": "A hint to the user of what can be entered in the control.\nThe placeholder will be displayed in the case that there\nis no item selected, or the selected item has an empty\nstring label, or the selected item has no label and it's\nDOM content is empty.",
155
+ "value": {
156
+ "type": [
157
+ "string",
158
+ "null",
159
+ "undefined"
160
+ ]
161
+ }
162
+ },
163
+ {
164
+ "name": "readonly",
165
+ "description": "When present, it specifies that the element is read-only.",
166
+ "value": {
167
+ "type": [
168
+ "boolean"
169
+ ]
170
+ }
171
+ },
172
+ {
173
+ "name": "dirty",
174
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\na `change` event. Additionally, the field can be manually marked\nas dirty by setting the property to `true`.",
175
+ "value": {
176
+ "type": [
177
+ "boolean",
178
+ "null",
179
+ "undefined"
180
+ ]
181
+ }
182
+ },
183
+ {
184
+ "name": "theme",
185
+ "description": "The theme variants to apply to the component.",
186
+ "value": {
187
+ "type": [
188
+ "string",
189
+ "null",
190
+ "undefined"
191
+ ]
192
+ }
193
+ }
194
+ ],
195
+ "js": {
196
+ "properties": [
197
+ {
198
+ "name": "disabled",
199
+ "description": "If true, the user cannot interact with this element.",
200
+ "value": {
201
+ "type": [
202
+ "boolean",
203
+ "null",
204
+ "undefined"
205
+ ]
206
+ }
207
+ },
208
+ {
209
+ "name": "autofocus",
210
+ "description": "Specify that this control should have input focus when the page loads.",
211
+ "value": {
212
+ "type": [
213
+ "boolean",
214
+ "null",
215
+ "undefined"
216
+ ]
217
+ }
218
+ },
219
+ {
220
+ "name": "label",
221
+ "description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
222
+ "value": {
223
+ "type": [
224
+ "string",
225
+ "null",
226
+ "undefined"
227
+ ]
228
+ }
229
+ },
230
+ {
231
+ "name": "invalid",
232
+ "description": "Set to true when the field is invalid.",
233
+ "value": {
234
+ "type": [
235
+ "boolean",
236
+ "null",
237
+ "undefined"
238
+ ]
239
+ }
240
+ },
241
+ {
242
+ "name": "required",
243
+ "description": "Specifies that the user must fill in a value.",
244
+ "value": {
245
+ "type": [
246
+ "boolean",
247
+ "null",
248
+ "undefined"
249
+ ]
250
+ }
251
+ },
252
+ {
253
+ "name": "errorMessage",
254
+ "description": "Error to show when the field is invalid.",
255
+ "value": {
256
+ "type": [
257
+ "string",
258
+ "null",
259
+ "undefined"
260
+ ]
261
+ }
262
+ },
263
+ {
264
+ "name": "helperText",
265
+ "description": "String used for the helper text.",
266
+ "value": {
267
+ "type": [
268
+ "string",
269
+ "null",
270
+ "undefined"
271
+ ]
272
+ }
273
+ },
274
+ {
275
+ "name": "accessibleName",
276
+ "description": "String used to label the component to screen reader users.",
277
+ "value": {
278
+ "type": [
279
+ "string",
280
+ "null",
281
+ "undefined"
282
+ ]
283
+ }
284
+ },
285
+ {
286
+ "name": "accessibleNameRef",
287
+ "description": "Id of the element used as label of the component to screen reader users.",
288
+ "value": {
289
+ "type": [
290
+ "string",
291
+ "null",
292
+ "undefined"
293
+ ]
294
+ }
295
+ },
296
+ {
297
+ "name": "overlayClass",
298
+ "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
299
+ "value": {
300
+ "type": [
301
+ "string",
302
+ "null",
303
+ "undefined"
304
+ ]
305
+ }
306
+ },
307
+ {
308
+ "name": "items",
309
+ "description": "An array containing items that will be rendered as the options of the select.\n\n#### Example\n```js\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc' },\n { label: 'Rating: high to low', value: 'rating-desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\nNote: each item is rendered by default as the internal `<vaadin-select-item>` that is an extension of `<vaadin-item>`.\nTo render the item with a custom component, provide a tag name by the `component` property.",
310
+ "value": {
311
+ "type": [
312
+ "Array.<SelectItem>"
313
+ ]
314
+ }
315
+ },
316
+ {
317
+ "name": "opened",
318
+ "description": "Set when the select is open",
319
+ "value": {
320
+ "type": [
321
+ "boolean"
322
+ ]
323
+ }
324
+ },
325
+ {
326
+ "name": "renderer",
327
+ "description": "Custom function for rendering the content of the `<vaadin-select>`.\nReceives two arguments:\n\n- `root` The `<vaadin-select-overlay>` internal container\n DOM element. Append your content to it.\n- `select` The reference to the `<vaadin-select>` element.",
328
+ "value": {
329
+ "type": [
330
+ "SelectRenderer",
331
+ "undefined"
332
+ ]
333
+ }
334
+ },
335
+ {
336
+ "name": "value",
337
+ "description": "The `value` property of the selected item, or an empty string\nif no item is selected.\nOn change or initialization, the component finds the item which matches the\nvalue and displays it.\nIf no value is provided to the component, it selects the first item without\nvalue or empty value.\nHint: If you do not want to select any item by default, you can either set all\nthe values of inner vaadin-items, or set the vaadin-select value to\nan inexistent value in the items list.",
338
+ "value": {
339
+ "type": [
340
+ "string"
341
+ ]
342
+ }
343
+ },
344
+ {
345
+ "name": "name",
346
+ "description": "The name of this element.",
347
+ "value": {
348
+ "type": [
349
+ "string",
350
+ "null",
351
+ "undefined"
352
+ ]
353
+ }
354
+ },
355
+ {
356
+ "name": "placeholder",
357
+ "description": "A hint to the user of what can be entered in the control.\nThe placeholder will be displayed in the case that there\nis no item selected, or the selected item has an empty\nstring label, or the selected item has no label and it's\nDOM content is empty.",
358
+ "value": {
359
+ "type": [
360
+ "string",
361
+ "null",
362
+ "undefined"
363
+ ]
364
+ }
365
+ },
366
+ {
367
+ "name": "readonly",
368
+ "description": "When present, it specifies that the element is read-only.",
369
+ "value": {
370
+ "type": [
371
+ "boolean"
372
+ ]
373
+ }
374
+ },
375
+ {
376
+ "name": "dirty",
377
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\na `change` event. Additionally, the field can be manually marked\nas dirty by setting the property to `true`.",
378
+ "value": {
379
+ "type": [
380
+ "boolean",
381
+ "null",
382
+ "undefined"
383
+ ]
384
+ }
385
+ }
386
+ ],
387
+ "events": [
388
+ {
389
+ "name": "validated",
390
+ "description": "Fired whenever the field is validated."
391
+ },
392
+ {
393
+ "name": "change",
394
+ "description": "Fired when the user commits a value change."
395
+ },
396
+ {
397
+ "name": "invalid-changed",
398
+ "description": "Fired when the `invalid` property changes."
399
+ },
400
+ {
401
+ "name": "opened-changed",
402
+ "description": "Fired when the `opened` property changes."
403
+ },
404
+ {
405
+ "name": "value-changed",
406
+ "description": "Fired when the `value` property changes."
407
+ },
408
+ {
409
+ "name": "dirty-changed",
410
+ "description": "Fired when the `dirty` property changes."
411
+ }
412
+ ]
413
+ }
414
+ }
415
+ ]
416
+ }
417
+ }
418
+ }
@@ -0,0 +1,195 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/select",
4
+ "version": "24.3.0-alpha1",
5
+ "description-markup": "markdown",
6
+ "framework": "lit",
7
+ "framework-config": {
8
+ "enable-when": {
9
+ "node-packages": [
10
+ "lit"
11
+ ]
12
+ }
13
+ },
14
+ "contributions": {
15
+ "html": {
16
+ "elements": [
17
+ {
18
+ "name": "vaadin-select",
19
+ "description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc' },\n { label: 'Rating: high to low', value: 'rating-desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-----------------------------|-----------\n`opened` | Set when the select is open | :host\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha1/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
20
+ "extension": true,
21
+ "attributes": [
22
+ {
23
+ "name": "?disabled",
24
+ "description": "If true, the user cannot interact with this element.",
25
+ "value": {
26
+ "kind": "expression"
27
+ }
28
+ },
29
+ {
30
+ "name": "?autofocus",
31
+ "description": "Specify that this control should have input focus when the page loads.",
32
+ "value": {
33
+ "kind": "expression"
34
+ }
35
+ },
36
+ {
37
+ "name": "?invalid",
38
+ "description": "Set to true when the field is invalid.",
39
+ "value": {
40
+ "kind": "expression"
41
+ }
42
+ },
43
+ {
44
+ "name": "?required",
45
+ "description": "Specifies that the user must fill in a value.",
46
+ "value": {
47
+ "kind": "expression"
48
+ }
49
+ },
50
+ {
51
+ "name": "?opened",
52
+ "description": "Set when the select is open",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ },
57
+ {
58
+ "name": "?readonly",
59
+ "description": "When present, it specifies that the element is read-only.",
60
+ "value": {
61
+ "kind": "expression"
62
+ }
63
+ },
64
+ {
65
+ "name": "?dirty",
66
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\na `change` event. Additionally, the field can be manually marked\nas dirty by setting the property to `true`.",
67
+ "value": {
68
+ "kind": "expression"
69
+ }
70
+ },
71
+ {
72
+ "name": ".label",
73
+ "description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
74
+ "value": {
75
+ "kind": "expression"
76
+ }
77
+ },
78
+ {
79
+ "name": ".errorMessage",
80
+ "description": "Error to show when the field is invalid.",
81
+ "value": {
82
+ "kind": "expression"
83
+ }
84
+ },
85
+ {
86
+ "name": ".helperText",
87
+ "description": "String used for the helper text.",
88
+ "value": {
89
+ "kind": "expression"
90
+ }
91
+ },
92
+ {
93
+ "name": ".accessibleName",
94
+ "description": "String used to label the component to screen reader users.",
95
+ "value": {
96
+ "kind": "expression"
97
+ }
98
+ },
99
+ {
100
+ "name": ".accessibleNameRef",
101
+ "description": "Id of the element used as label of the component to screen reader users.",
102
+ "value": {
103
+ "kind": "expression"
104
+ }
105
+ },
106
+ {
107
+ "name": ".overlayClass",
108
+ "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
109
+ "value": {
110
+ "kind": "expression"
111
+ }
112
+ },
113
+ {
114
+ "name": ".items",
115
+ "description": "An array containing items that will be rendered as the options of the select.\n\n#### Example\n```js\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc' },\n { label: 'Rating: high to low', value: 'rating-desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\nNote: each item is rendered by default as the internal `<vaadin-select-item>` that is an extension of `<vaadin-item>`.\nTo render the item with a custom component, provide a tag name by the `component` property.",
116
+ "value": {
117
+ "kind": "expression"
118
+ }
119
+ },
120
+ {
121
+ "name": ".renderer",
122
+ "description": "Custom function for rendering the content of the `<vaadin-select>`.\nReceives two arguments:\n\n- `root` The `<vaadin-select-overlay>` internal container\n DOM element. Append your content to it.\n- `select` The reference to the `<vaadin-select>` element.",
123
+ "value": {
124
+ "kind": "expression"
125
+ }
126
+ },
127
+ {
128
+ "name": ".value",
129
+ "description": "The `value` property of the selected item, or an empty string\nif no item is selected.\nOn change or initialization, the component finds the item which matches the\nvalue and displays it.\nIf no value is provided to the component, it selects the first item without\nvalue or empty value.\nHint: If you do not want to select any item by default, you can either set all\nthe values of inner vaadin-items, or set the vaadin-select value to\nan inexistent value in the items list.",
130
+ "value": {
131
+ "kind": "expression"
132
+ }
133
+ },
134
+ {
135
+ "name": ".name",
136
+ "description": "The name of this element.",
137
+ "value": {
138
+ "kind": "expression"
139
+ }
140
+ },
141
+ {
142
+ "name": ".placeholder",
143
+ "description": "A hint to the user of what can be entered in the control.\nThe placeholder will be displayed in the case that there\nis no item selected, or the selected item has an empty\nstring label, or the selected item has no label and it's\nDOM content is empty.",
144
+ "value": {
145
+ "kind": "expression"
146
+ }
147
+ },
148
+ {
149
+ "name": "@validated",
150
+ "description": "Fired whenever the field is validated.",
151
+ "value": {
152
+ "kind": "expression"
153
+ }
154
+ },
155
+ {
156
+ "name": "@change",
157
+ "description": "Fired when the user commits a value change.",
158
+ "value": {
159
+ "kind": "expression"
160
+ }
161
+ },
162
+ {
163
+ "name": "@invalid-changed",
164
+ "description": "Fired when the `invalid` property changes.",
165
+ "value": {
166
+ "kind": "expression"
167
+ }
168
+ },
169
+ {
170
+ "name": "@opened-changed",
171
+ "description": "Fired when the `opened` property changes.",
172
+ "value": {
173
+ "kind": "expression"
174
+ }
175
+ },
176
+ {
177
+ "name": "@value-changed",
178
+ "description": "Fired when the `value` property changes.",
179
+ "value": {
180
+ "kind": "expression"
181
+ }
182
+ },
183
+ {
184
+ "name": "@dirty-changed",
185
+ "description": "Fired when the `dirty` property changes.",
186
+ "value": {
187
+ "kind": "expression"
188
+ }
189
+ }
190
+ ]
191
+ }
192
+ ]
193
+ }
194
+ }
195
+ }