@vaadin/vaadin-combo-box 22.0.0-alpha1 → 22.0.0-alpha10

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/README.md CHANGED
@@ -1,12 +1,3 @@
1
- [![npm latest version](https://badgen.net/npm/v/@vaadin/vaadin-combo-box/latest)](https://www.npmjs.com/package/@vaadin/vaadin-combo-box)
2
- [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/vaadin/vaadin-combo-box)
3
- [![Build Status](https://travis-ci.org/vaadin/vaadin-combo-box.svg?branch=master)](https://travis-ci.org/vaadin/vaadin-combo-box)
4
- [![Coverage Status](https://coveralls.io/repos/github/vaadin/vaadin-combo-box/badge.svg?branch=master)](https://coveralls.io/github/vaadin/vaadin-combo-box?branch=master)
5
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/vaadin/web-components?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6
-
7
- [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-combo-box)
8
- [![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/vaadinvaadin-combo-box.svg)](https://vaadin.com/directory/component/vaadinvaadin-combo-box)
9
-
10
1
  # <vaadin-combo-box>
11
2
 
12
3
  [Live Demo ↗](https://vaadin.com/components/vaadin-combo-box/html-examples)
@@ -15,15 +6,24 @@
15
6
 
16
7
  [<vaadin-combo-box>](https://vaadin.com/components/vaadin-combo-box) is a Web Component combining a dropdown list with an input field for filtering the list of items, part of the [Vaadin components](https://vaadin.com/components).
17
8
 
9
+ [![npm version](https://badgen.net/npm/v/@vaadin/vaadin-combo-box)](https://www.npmjs.com/package/@vaadin/vaadin-combo-box)
10
+ [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-combo-box)
11
+ [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
12
+
18
13
  ```html
19
- <vaadin-combo-box label="User" placeholder="Please select" item-value-path="email" item-label-path="email"></vaadin-combo-box>
14
+ <vaadin-combo-box
15
+ label="User"
16
+ placeholder="Please select"
17
+ item-value-path="email"
18
+ item-label-path="email"
19
+ ></vaadin-combo-box>
20
20
 
21
21
  <script>
22
22
  const comboBox = document.querySelector('vaadin-combo-box');
23
23
 
24
24
  fetch('https://randomuser.me/api?results=100&inc=name,email')
25
- .then(res => res.json())
26
- .then(json => comboBox.items = json.results);
25
+ .then((res) => res.json())
26
+ .then((json) => (comboBox.items = json.results));
27
27
  </script>
28
28
  ```
29
29
 
@@ -67,46 +67,9 @@ To use the Material theme, import the correspondent file from the `theme/materia
67
67
  `vaadin-combo-box.js`
68
68
  `vaadin-combo-box-light.js`
69
69
 
70
-
71
- ## Running API docs and tests in a browser
72
-
73
- 1. Fork the `vaadin-combo-box` repository and clone it locally.
74
-
75
- 1. Make sure you have [node.js](https://nodejs.org/) 12.x installed.
76
-
77
- 1. Make sure you have [npm](https://www.npmjs.com/) installed.
78
-
79
- 1. When in the `vaadin-combo-box` directory, run `npm install` to install dependencies.
80
-
81
- 1. Run `npm start`, browser will automatically open the component API documentation.
82
-
83
- 1. You can also open visual tests, for example:
84
-
85
- - http://127.0.0.1:3000/test/visual/default.html
86
-
87
-
88
- ## Running tests from the command line
89
-
90
- 1. When in the `vaadin-combo-box` directory, run `npm test`
91
-
92
- ## Debugging tests in the browser
93
-
94
- 1. Run `npm run debug`, then choose manual mode (M) and open the link in browser.
95
-
96
- ## Following the coding style
97
-
98
- We are using [ESLint](http://eslint.org/) for linting JavaScript code. You can check if your code is following our standards by running `npm run lint`, which will automatically lint all `.js` files.
99
-
100
-
101
- ## Big Thanks
102
-
103
- Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com).
104
-
105
-
106
70
  ## Contributing
107
71
 
108
- To contribute to the component, please read [the guideline](https://github.com/vaadin/vaadin-core/blob/master/CONTRIBUTING.md) first.
109
-
72
+ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
110
73
 
111
74
  ## License
112
75
 
package/package.json CHANGED
@@ -1,9 +1,28 @@
1
1
  {
2
2
  "name": "@vaadin/vaadin-combo-box",
3
- "version": "22.0.0-alpha1",
3
+ "version": "22.0.0-alpha10",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "Web Component for displaying a list of items with filtering",
8
+ "license": "Apache-2.0",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/vaadin/web-components.git",
12
+ "directory": "packages/vaadin-combo-box"
13
+ },
14
+ "author": "Vaadin Ltd",
15
+ "homepage": "https://vaadin.com/components",
16
+ "bugs": {
17
+ "url": "https://github.com/vaadin/vaadin-combo-box/issues"
18
+ },
5
19
  "main": "vaadin-combo-box.js",
6
- "repository": "vaadin/vaadin-combo-box",
20
+ "files": [
21
+ "src",
22
+ "theme",
23
+ "vaadin-*.d.ts",
24
+ "vaadin-*.js"
25
+ ],
7
26
  "keywords": [
8
27
  "Vaadin",
9
28
  "combo-box",
@@ -11,43 +30,8 @@
11
30
  "web-component",
12
31
  "polymer"
13
32
  ],
14
- "author": "Vaadin Ltd",
15
- "license": "Apache-2.0",
16
- "bugs": {
17
- "url": "https://github.com/vaadin/vaadin-combo-box/issues"
18
- },
19
- "homepage": "https://vaadin.com/components",
20
- "files": [
21
- "vaadin-*.d.ts",
22
- "vaadin-*.js",
23
- "src",
24
- "theme"
25
- ],
26
33
  "dependencies": {
27
- "@polymer/iron-a11y-announcer": "^3.0.0",
28
- "@polymer/iron-list": "^3.0.0",
29
- "@polymer/iron-resizable-behavior": "^3.0.0",
30
- "@polymer/polymer": "^3.0.0",
31
- "@vaadin/vaadin-control-state-mixin": "^22.0.0-alpha1",
32
- "@vaadin/vaadin-element-mixin": "^22.0.0-alpha1",
33
- "@vaadin/vaadin-item": "^22.0.0-alpha1",
34
- "@vaadin/vaadin-lumo-styles": "^22.0.0-alpha1",
35
- "@vaadin/vaadin-material-styles": "^22.0.0-alpha1",
36
- "@vaadin/vaadin-overlay": "^22.0.0-alpha1",
37
- "@vaadin/vaadin-text-field": "^22.0.0-alpha1",
38
- "@vaadin/vaadin-themable-mixin": "^22.0.0-alpha1"
39
- },
40
- "devDependencies": {
41
- "@esm-bundle/chai": "4.3.0",
42
- "@polymer/iron-input": "^3.0.1",
43
- "@polymer/paper-input": "^3.0.0",
44
- "@vaadin/testing-helpers": "^0.2.1",
45
- "@vaadin/vaadin-dialog": "^22.0.0-alpha1",
46
- "@vaadin/vaadin-template-renderer": "^22.0.0-alpha1",
47
- "sinon": "^9.2.0"
48
- },
49
- "publishConfig": {
50
- "access": "public"
34
+ "@vaadin/combo-box": "22.0.0-alpha10"
51
35
  },
52
- "gitHead": "c9694d6549bff1f7fffb9ece26178e57fc228a51"
36
+ "gitHead": "6d3055383b9c3c8306ea34c6f2e2087e63c49348"
53
37
  }
@@ -1,100 +1,19 @@
1
- import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin';
2
-
3
- import { ComboBoxMixin } from './vaadin-combo-box-mixin';
4
-
5
- import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin';
6
-
7
- import { ComboBoxDefaultItem, ComboBoxEventMap } from './interfaces';
8
-
9
1
  /**
10
- * `<vaadin-combo-box-light>` is a customizable version of the `<vaadin-combo-box>` providing
11
- * only the dropdown functionality and leaving the input field definition to the user.
12
- *
13
- * The element has the same API as `<vaadin-combo-box>`.
14
- *
15
- * To create a custom input field, you need to add a child element which has a two-way
16
- * data-bindable property representing the input value. The property name is expected
17
- * to be `value` by default. See the example below for a simplest possible example
18
- * using a `<vaadin-text-field>` element.
19
- *
20
- * ```html
21
- * <vaadin-combo-box-light>
22
- * <vaadin-text-field>
23
- * </vaadin-text-field>
24
- * </vaadin-combo-box-light>
25
- * ```
26
- *
27
- * If you are using other custom input fields like `<iron-input>`, you
28
- * need to define the name of the bindable property with the `attrForValue` attribute.
29
- *
30
- * ```html
31
- * <vaadin-combo-box-light attr-for-value="bind-value">
32
- * <iron-input>
33
- * <input>
34
- * </iron-input>
35
- * </vaadin-combo-box-light>
36
- * ```
37
- *
38
- * In the next example you can see how to create a custom input field based
39
- * on a `<paper-input>` decorated with a custom `<iron-icon>` and
40
- * two `<paper-button>`s to act as the clear and toggle controls.
41
- *
42
- * ```html
43
- * <vaadin-combo-box-light>
44
- * <paper-input label="Elements" class="input">
45
- * <iron-icon icon="toll" slot="prefix"></iron-icon>
46
- * <paper-button slot="suffix" class="clear-button">Clear</paper-button>
47
- * <paper-button slot="suffix" class="toggle-button">Toggle</paper-button>
48
- * </paper-input>
49
- * </vaadin-combo-box-light>
50
- * ```
51
- *
52
- * @fires {Event} change - Fired when the user commits a value change.
53
- * @fires {CustomEvent} custom-value-set - Fired when the user sets a custom value.
54
- * @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
55
- * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
56
- * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
57
- * @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
58
- * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
59
5
  */
60
- declare class ComboBoxLightElement<TItem = ComboBoxDefaultItem> extends HTMLElement {
61
- readonly _propertyForValue: string;
62
-
63
- _inputElementValue: string;
64
-
65
- readonly focused: boolean;
66
-
67
- /**
68
- * Name of the two-way data-bindable property representing the
69
- * value of the custom input field.
70
- * @attr {string} attr-for-value
71
- */
72
- attrForValue: string;
6
+ import { ComboBoxDefaultItem } from '@vaadin/combo-box';
7
+ import { ComboBoxLight } from '@vaadin/combo-box/src/vaadin-combo-box-light.js';
73
8
 
74
- readonly inputElement: Element | undefined;
75
-
76
- addEventListener<K extends keyof ComboBoxEventMap<TItem>>(
77
- type: K,
78
- listener: (this: ComboBoxLightElement<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
79
- options?: boolean | AddEventListenerOptions
80
- ): void;
81
-
82
- removeEventListener<K extends keyof ComboBoxEventMap<TItem>>(
83
- type: K,
84
- listener: (this: ComboBoxLightElement<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
85
- options?: boolean | EventListenerOptions
86
- ): void;
87
- }
88
-
89
- interface ComboBoxLightElement<TItem = ComboBoxDefaultItem>
90
- extends ComboBoxDataProviderMixin<TItem>,
91
- ComboBoxMixin<TItem>,
92
- ThemableMixin {}
9
+ /**
10
+ * @deprecated Import `ComboBoxLight` from `@vaadin/combo-box/vaadin-combo-box-light` instead.
11
+ */
12
+ export type ComboBoxLightElement<TItem = ComboBoxDefaultItem> = ComboBoxLight<TItem>;
93
13
 
94
- declare global {
95
- interface HTMLElementTagNameMap {
96
- 'vaadin-combo-box-light': ComboBoxLightElement;
97
- }
98
- }
14
+ /**
15
+ * @deprecated Import `ComboBoxLight` from `@vaadin/combo-box/vaadin-combo-box-light` instead.
16
+ */
17
+ export const ComboBoxLightElement: typeof ComboBoxLight;
99
18
 
100
- export { ComboBoxLightElement };
19
+ export * from '@vaadin/combo-box/src/vaadin-combo-box-light.js';
@@ -3,204 +3,11 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
7
- import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
8
- import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
- import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
10
- import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
11
- import './vaadin-combo-box-dropdown-wrapper.js';
6
+ import { ComboBoxLight } from '@vaadin/combo-box/src/vaadin-combo-box-light.js';
12
7
 
13
8
  /**
14
- * `<vaadin-combo-box-light>` is a customizable version of the `<vaadin-combo-box>` providing
15
- * only the dropdown functionality and leaving the input field definition to the user.
16
- *
17
- * The element has the same API as `<vaadin-combo-box>`.
18
- *
19
- * To create a custom input field, you need to add a child element which has a two-way
20
- * data-bindable property representing the input value. The property name is expected
21
- * to be `value` by default. See the example below for a simplest possible example
22
- * using a `<vaadin-text-field>` element.
23
- *
24
- * ```html
25
- * <vaadin-combo-box-light>
26
- * <vaadin-text-field>
27
- * </vaadin-text-field>
28
- * </vaadin-combo-box-light>
29
- * ```
30
- *
31
- * If you are using other custom input fields like `<iron-input>`, you
32
- * need to define the name of the bindable property with the `attrForValue` attribute.
33
- *
34
- * ```html
35
- * <vaadin-combo-box-light attr-for-value="bind-value">
36
- * <iron-input>
37
- * <input>
38
- * </iron-input>
39
- * </vaadin-combo-box-light>
40
- * ```
41
- *
42
- * In the next example you can see how to create a custom input field based
43
- * on a `<paper-input>` decorated with a custom `<iron-icon>` and
44
- * two `<paper-button>`s to act as the clear and toggle controls.
45
- *
46
- * ```html
47
- * <vaadin-combo-box-light>
48
- * <paper-input label="Elements" class="input">
49
- * <iron-icon icon="toll" slot="prefix"></iron-icon>
50
- * <paper-button slot="suffix" class="clear-button">Clear</paper-button>
51
- * <paper-button slot="suffix" class="toggle-button">Toggle</paper-button>
52
- * </paper-input>
53
- * </vaadin-combo-box-light>
54
- * ```
55
- *
56
- * @fires {Event} change - Fired when the user commits a value change.
57
- * @fires {CustomEvent} custom-value-set - Fired when the user sets a custom value.
58
- * @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
59
- * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
60
- * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
61
- * @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
62
- * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
63
- *
64
- * @extends HTMLElement
65
- * @mixes ComboBoxDataProviderMixin
66
- * @mixes ComboBoxMixin
67
- * @mixes ThemableMixin
9
+ * @deprecated Import `ComboBoxLight` from `@vaadin/combo-box/vaadin-combo-box-light` instead.
68
10
  */
69
- class ComboBoxLightElement extends ThemableMixin(ComboBoxDataProviderMixin(ComboBoxMixin(PolymerElement))) {
70
- static get template() {
71
- return html`
72
- <style>
73
- :host([opened]) {
74
- pointer-events: auto;
75
- }
76
- </style>
11
+ export const ComboBoxLightElement = ComboBoxLight;
77
12
 
78
- <slot></slot>
79
-
80
- <vaadin-combo-box-dropdown-wrapper
81
- id="overlay"
82
- opened="[[opened]]"
83
- position-target="[[inputElement]]"
84
- renderer="[[renderer]]"
85
- _focused-index="[[_focusedIndex]]"
86
- _item-id-path="[[itemIdPath]]"
87
- _item-label-path="[[itemLabelPath]]"
88
- loading="[[loading]]"
89
- theme="[[theme]]"
90
- ></vaadin-combo-box-dropdown-wrapper>
91
- `;
92
- }
93
-
94
- static get is() {
95
- return 'vaadin-combo-box-light';
96
- }
97
-
98
- static get properties() {
99
- return {
100
- /**
101
- * Name of the two-way data-bindable property representing the
102
- * value of the custom input field.
103
- * @attr {string} attr-for-value
104
- * @type {string}
105
- */
106
- attrForValue: {
107
- type: String,
108
- value: 'value'
109
- },
110
-
111
- /**
112
- * @type {!Element | undefined}
113
- */
114
- inputElement: {
115
- type: Element,
116
- readOnly: true
117
- }
118
- };
119
- }
120
-
121
- constructor() {
122
- super();
123
- this._boundInputValueChanged = this._inputValueChanged.bind(this);
124
- this.__boundInputValueCommitted = this.__inputValueCommitted.bind(this);
125
- }
126
-
127
- /** @protected */
128
- ready() {
129
- super.ready();
130
- this._toggleElement = this.querySelector('.toggle-button');
131
- this._clearElement = this.querySelector('.clear-button');
132
-
133
- if (this._clearElement) {
134
- this._clearElement.addEventListener('mousedown', (e) => {
135
- e.preventDefault(); // Prevent native focus changes
136
- // _focusableElement is needed for paper-input
137
- (this.inputElement._focusableElement || this.inputElement).focus();
138
- });
139
- }
140
- }
141
-
142
- /**
143
- * @return {boolean}
144
- */
145
- get focused() {
146
- return this.getRootNode().activeElement === this.inputElement;
147
- }
148
-
149
- /** @protected */
150
- connectedCallback() {
151
- super.connectedCallback();
152
- const cssSelector = 'vaadin-text-field,iron-input,paper-input,.paper-input-input,.input';
153
- this._setInputElement(this.querySelector(cssSelector));
154
- this._revertInputValue();
155
- this.inputElement.addEventListener('input', this._boundInputValueChanged);
156
- this.inputElement.addEventListener('change', this.__boundInputValueCommitted);
157
- this._preventInputBlur();
158
- }
159
-
160
- /** @protected */
161
- disconnectedCallback() {
162
- super.disconnectedCallback();
163
- this.inputElement.removeEventListener('input', this._boundInputValueChanged);
164
- this.inputElement.removeEventListener('change', this.__boundInputValueCommitted);
165
- this._restoreInputBlur();
166
- }
167
-
168
- /** @private */
169
- __inputValueCommitted(e) {
170
- // Detect if the input was cleared (by clicking the clear button on a vaadin-text-field)
171
- // and propagate the value change to combo box value immediately.
172
- if (e.__fromClearButton) {
173
- this._clear();
174
- }
175
- }
176
-
177
- /**
178
- * @return {string}
179
- * @protected
180
- */
181
- get _propertyForValue() {
182
- return dashToCamelCase(this.attrForValue);
183
- }
184
-
185
- /**
186
- * @return {string}
187
- * @protected
188
- */
189
- get _inputElementValue() {
190
- return this.inputElement && this.inputElement[this._propertyForValue];
191
- }
192
-
193
- /**
194
- * @param {string} value
195
- * @protected
196
- */
197
- set _inputElementValue(value) {
198
- if (this.inputElement) {
199
- this.inputElement[this._propertyForValue] = value;
200
- }
201
- }
202
- }
203
-
204
- customElements.define(ComboBoxLightElement.is, ComboBoxLightElement);
205
-
206
- export { ComboBoxLightElement };
13
+ export * from '@vaadin/combo-box/src/vaadin-combo-box-light.js';