@vaadin/select 23.1.0-beta1 → 23.1.0-beta2
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/lit.d.ts +1 -0
- package/lit.js +1 -0
- package/package.json +17 -14
- package/src/lit/renderer-directives.d.ts +59 -0
- package/src/lit/renderer-directives.js +60 -0
- package/src/vaadin-select.js +2 -2
package/lit.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/lit/renderer-directives.js';
|
package/lit.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/lit/renderer-directives.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/select",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
24
|
"theme",
|
|
25
|
+
"lit.js",
|
|
26
|
+
"lit.d.ts",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js"
|
|
27
29
|
],
|
|
@@ -34,24 +36,25 @@
|
|
|
34
36
|
],
|
|
35
37
|
"dependencies": {
|
|
36
38
|
"@polymer/polymer": "^3.2.0",
|
|
37
|
-
"@vaadin/button": "23.1.0-
|
|
38
|
-
"@vaadin/component-base": "23.1.0-
|
|
39
|
-
"@vaadin/field-base": "23.1.0-
|
|
40
|
-
"@vaadin/input-container": "23.1.0-
|
|
41
|
-
"@vaadin/item": "23.1.0-
|
|
42
|
-
"@vaadin/list-box": "23.1.0-
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/vaadin-
|
|
45
|
-
"@vaadin/vaadin-
|
|
46
|
-
"@vaadin/vaadin-
|
|
47
|
-
"@vaadin/vaadin-
|
|
39
|
+
"@vaadin/button": "23.1.0-beta2",
|
|
40
|
+
"@vaadin/component-base": "23.1.0-beta2",
|
|
41
|
+
"@vaadin/field-base": "23.1.0-beta2",
|
|
42
|
+
"@vaadin/input-container": "23.1.0-beta2",
|
|
43
|
+
"@vaadin/item": "23.1.0-beta2",
|
|
44
|
+
"@vaadin/list-box": "23.1.0-beta2",
|
|
45
|
+
"@vaadin/lit-renderer": "23.1.0-beta2",
|
|
46
|
+
"@vaadin/vaadin-list-mixin": "23.1.0-beta2",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta2",
|
|
49
|
+
"@vaadin/vaadin-overlay": "23.1.0-beta2",
|
|
50
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"@esm-bundle/chai": "^4.3.4",
|
|
51
|
-
"@vaadin/polymer-legacy-adapter": "23.1.0-
|
|
54
|
+
"@vaadin/polymer-legacy-adapter": "23.1.0-beta2",
|
|
52
55
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
53
56
|
"lit": "^2.0.0",
|
|
54
57
|
"sinon": "^13.0.2"
|
|
55
58
|
},
|
|
56
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
|
|
57
60
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { TemplateResult } from 'lit';
|
|
7
|
+
import { DirectiveResult } from 'lit/directive.js';
|
|
8
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
9
|
+
import { Select } from '../vaadin-select.js';
|
|
10
|
+
|
|
11
|
+
export type SelectLitRenderer = (select: Select) => TemplateResult;
|
|
12
|
+
|
|
13
|
+
export class SelectRendererDirective extends LitRendererDirective<Select, SelectLitRenderer> {
|
|
14
|
+
/**
|
|
15
|
+
* Adds the renderer callback to the select.
|
|
16
|
+
*/
|
|
17
|
+
addRenderer(): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs the renderer callback on the select.
|
|
21
|
+
*/
|
|
22
|
+
runRenderer(): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Removes the renderer callback from the select.
|
|
26
|
+
*/
|
|
27
|
+
removeRenderer(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A Lit directive for populating the content of the `<vaadin-select-overlay>` element.
|
|
32
|
+
*
|
|
33
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the select
|
|
34
|
+
* via the `renderer` property. The renderer is called once to populate the content when assigned
|
|
35
|
+
* and whenever a single dependency or an array of dependencies changes.
|
|
36
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
37
|
+
*
|
|
38
|
+
* Dependencies can be a single value or an array of values.
|
|
39
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
40
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
41
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
42
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
43
|
+
* equality.
|
|
44
|
+
*
|
|
45
|
+
* Example of usage:
|
|
46
|
+
* ```js
|
|
47
|
+
* `<vaadin-select
|
|
48
|
+
* ${selectRenderer((select) => html`...`)}
|
|
49
|
+
* ></vaadin-select>`
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param renderer the renderer callback that returns a Lit template.
|
|
53
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
54
|
+
* which trigger a re-render when changed.
|
|
55
|
+
*/
|
|
56
|
+
export declare function selectRenderer(
|
|
57
|
+
renderer: SelectLitRenderer,
|
|
58
|
+
dependencies?: unknown,
|
|
59
|
+
): DirectiveResult<typeof SelectRendererDirective>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { directive } from 'lit/directive.js';
|
|
7
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
8
|
+
|
|
9
|
+
export class SelectRendererDirective extends LitRendererDirective {
|
|
10
|
+
/**
|
|
11
|
+
* Adds the renderer callback to the select.
|
|
12
|
+
*/
|
|
13
|
+
addRenderer() {
|
|
14
|
+
this.element.renderer = (root, select) => {
|
|
15
|
+
this.renderRenderer(root, select);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs the renderer callback on the select.
|
|
21
|
+
*/
|
|
22
|
+
runRenderer() {
|
|
23
|
+
this.element.requestContentUpdate();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Removes the renderer callback from the select.
|
|
28
|
+
*/
|
|
29
|
+
removeRenderer() {
|
|
30
|
+
this.element.renderer = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A Lit directive for populating the content of the `<vaadin-select-overlay>` element.
|
|
36
|
+
*
|
|
37
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the select
|
|
38
|
+
* via the `renderer` property. The renderer is called once to populate the content when assigned
|
|
39
|
+
* and whenever a single dependency or an array of dependencies changes.
|
|
40
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
41
|
+
*
|
|
42
|
+
* Dependencies can be a single value or an array of values.
|
|
43
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
44
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
45
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
46
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
47
|
+
* equality.
|
|
48
|
+
*
|
|
49
|
+
* Example of usage:
|
|
50
|
+
* ```js
|
|
51
|
+
* `<vaadin-select
|
|
52
|
+
* ${selectRenderer((select) => html`...`)}
|
|
53
|
+
* ></vaadin-select>`
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param renderer the renderer callback that returns a Lit template.
|
|
57
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
58
|
+
* which trigger a re-render when changed.
|
|
59
|
+
*/
|
|
60
|
+
export const selectRenderer = directive(SelectRendererDirective);
|
package/src/vaadin-select.js
CHANGED
|
@@ -593,12 +593,12 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
|
|
|
593
593
|
labelItem = selected.cloneNode(true);
|
|
594
594
|
}
|
|
595
595
|
|
|
596
|
-
//
|
|
596
|
+
// Store reference to the original item
|
|
597
597
|
labelItem._sourceItem = selected;
|
|
598
598
|
|
|
599
599
|
this.__appendValueItemElement(labelItem);
|
|
600
600
|
|
|
601
|
-
//
|
|
601
|
+
// Ensure the item gets proper styles
|
|
602
602
|
labelItem.selected = true;
|
|
603
603
|
}
|
|
604
604
|
|