@umbraco-ui/uui-combobox 1.0.0-rc.1 → 1.0.0
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/lib/index.js +30 -42
- package/lib/uui-combobox.element.d.ts +2 -2
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -31,8 +31,9 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
31
31
|
this._search = "";
|
|
32
32
|
this._onMouseDown = () => requestAnimationFrame(() => this._input.focus());
|
|
33
33
|
this._onBlur = () => requestAnimationFrame(() => {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
if (!((_a = this.shadowRoot) == null ? void 0 : _a.activeElement)) {
|
|
36
|
+
this._onClose();
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
39
|
this._onInput = (e) => {
|
|
@@ -43,12 +44,11 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
43
44
|
this._open();
|
|
44
45
|
};
|
|
45
46
|
this._onChange = (e) => {
|
|
46
|
-
var _a
|
|
47
|
+
var _a;
|
|
47
48
|
e.stopImmediatePropagation();
|
|
48
49
|
this.value = ((_a = this._comboboxList) == null ? void 0 : _a.value) || "";
|
|
49
|
-
this._displayValue = ((_b = this._comboboxList) == null ? void 0 : _b.displayValue) || "";
|
|
50
50
|
this.search = this.value ? this.search : "";
|
|
51
|
-
this.
|
|
51
|
+
this._onClose();
|
|
52
52
|
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.CHANGE));
|
|
53
53
|
};
|
|
54
54
|
this._open = () => {
|
|
@@ -56,14 +56,12 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
56
56
|
return;
|
|
57
57
|
this.open = true;
|
|
58
58
|
};
|
|
59
|
-
this.
|
|
60
|
-
var _a;
|
|
59
|
+
this._onClose = () => {
|
|
61
60
|
if (!this.open)
|
|
62
61
|
return;
|
|
63
62
|
this.open = false;
|
|
64
|
-
this._displayValue = ((_a = this._comboboxList) == null ? void 0 : _a.displayValue) || "";
|
|
65
|
-
this._input.value = this._displayValue;
|
|
66
63
|
this.search = "";
|
|
64
|
+
this._input.value = this._displayValue;
|
|
67
65
|
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
|
|
68
66
|
};
|
|
69
67
|
this._onKeyDown = (e) => {
|
|
@@ -75,19 +73,19 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
75
73
|
this._open();
|
|
76
74
|
}
|
|
77
75
|
if (e.key === "Escape" || e.key === "Enter") {
|
|
78
|
-
this.
|
|
76
|
+
this._onClose();
|
|
79
77
|
}
|
|
80
78
|
};
|
|
81
|
-
this.
|
|
79
|
+
this._onClear = (e) => {
|
|
82
80
|
if (e.key && e.key !== "Enter")
|
|
83
81
|
return;
|
|
84
82
|
e.preventDefault();
|
|
85
83
|
e.stopImmediatePropagation();
|
|
86
|
-
this._displayValue = "";
|
|
87
|
-
this._input.value = this._displayValue;
|
|
88
|
-
this.search = "";
|
|
89
84
|
this.value = "";
|
|
90
|
-
this.
|
|
85
|
+
this.search = "";
|
|
86
|
+
this._input.value = this._displayValue;
|
|
87
|
+
this._input.focus();
|
|
88
|
+
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
|
|
91
89
|
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.CHANGE));
|
|
92
90
|
};
|
|
93
91
|
this._renderInput = () => {
|
|
@@ -97,7 +95,6 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
97
95
|
label="combobox-input"
|
|
98
96
|
type="text"
|
|
99
97
|
.value=${this._displayValue}
|
|
100
|
-
.placeholder=${this._displayValue}
|
|
101
98
|
autocomplete="off"
|
|
102
99
|
@click=${this._open}
|
|
103
100
|
@input=${this._onInput}
|
|
@@ -113,21 +110,20 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
113
110
|
</svg>`;
|
|
114
111
|
};
|
|
115
112
|
this._renderClearButton = () => {
|
|
116
|
-
return html`<uui-button
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
</uui-button>`;
|
|
113
|
+
return this.value || this.search ? html`<uui-button
|
|
114
|
+
id="clear-button"
|
|
115
|
+
@click=${this._onClear}
|
|
116
|
+
@keydown=${this._onClear}
|
|
117
|
+
label="clear"
|
|
118
|
+
slot="append"
|
|
119
|
+
compact
|
|
120
|
+
style="height: 100%;">
|
|
121
|
+
<uui-icon name="remove" .fallback=${iconRemove.strings[0]}></uui-icon>
|
|
122
|
+
</uui-button>` : "";
|
|
127
123
|
};
|
|
128
124
|
this._renderDropdown = () => {
|
|
129
125
|
return html`<div id="dropdown" slot="popover">
|
|
130
|
-
<uui-scroll-container id="scroll-container">
|
|
126
|
+
<uui-scroll-container tabindex="-1" id="scroll-container">
|
|
131
127
|
<slot></slot>
|
|
132
128
|
</uui-scroll-container>
|
|
133
129
|
</div>`;
|
|
@@ -137,10 +133,10 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
137
133
|
return this._value;
|
|
138
134
|
}
|
|
139
135
|
set value(newValue) {
|
|
140
|
-
super.value = newValue;
|
|
141
136
|
if (typeof newValue === "string") {
|
|
142
137
|
this._updateValue(newValue);
|
|
143
138
|
}
|
|
139
|
+
super.value = newValue;
|
|
144
140
|
}
|
|
145
141
|
get search() {
|
|
146
142
|
return this._search;
|
|
@@ -173,7 +169,10 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
173
169
|
if (list) {
|
|
174
170
|
this._comboboxList = list;
|
|
175
171
|
this._comboboxList.for = this;
|
|
176
|
-
this._comboboxList.addEventListener(
|
|
172
|
+
this._comboboxList.addEventListener(
|
|
173
|
+
UUIComboboxListEvent.CHANGE,
|
|
174
|
+
this._onChange
|
|
175
|
+
);
|
|
177
176
|
if (typeof this.value === "string") {
|
|
178
177
|
await this.updateComplete;
|
|
179
178
|
this._updateValue(this.value);
|
|
@@ -195,7 +194,7 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
195
194
|
<uui-popover
|
|
196
195
|
.open=${this.open}
|
|
197
196
|
.margin=${-1}
|
|
198
|
-
@close=${() => this.
|
|
197
|
+
@close=${() => this._onClose()}>
|
|
199
198
|
${this._renderInput()} ${this._renderDropdown()}
|
|
200
199
|
</uui-popover>
|
|
201
200
|
`;
|
|
@@ -233,17 +232,6 @@ UUIComboboxElement.styles = [
|
|
|
233
232
|
box-shadow: var(--uui-shadow-depth-3,0 10px 20px rgba(0,0,0,0.19) , 0 6px 6px rgba(0,0,0,0.23));
|
|
234
233
|
}
|
|
235
234
|
|
|
236
|
-
#clear-button {
|
|
237
|
-
pointer-events: none;
|
|
238
|
-
opacity: 0;
|
|
239
|
-
transition: opacity 120ms;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
#clear-button.--show {
|
|
243
|
-
pointer-events: auto;
|
|
244
|
-
opacity: 1;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
235
|
#caret {
|
|
248
236
|
margin-right: var(--uui-size-3, 9px);
|
|
249
237
|
display: flex;
|
|
@@ -43,9 +43,9 @@ export declare class UUIComboboxElement extends UUIComboboxElement_base {
|
|
|
43
43
|
private _onInput;
|
|
44
44
|
private _onChange;
|
|
45
45
|
private _open;
|
|
46
|
-
private
|
|
46
|
+
private _onClose;
|
|
47
47
|
private _onKeyDown;
|
|
48
|
-
private
|
|
48
|
+
private _onClear;
|
|
49
49
|
private _renderInput;
|
|
50
50
|
private _renderCaret;
|
|
51
51
|
private _renderClearButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-combobox",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"custom-elements.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@umbraco-ui/uui-base": "1.0.0
|
|
34
|
-
"@umbraco-ui/uui-button": "1.0.0
|
|
35
|
-
"@umbraco-ui/uui-combobox-list": "1.0.0
|
|
36
|
-
"@umbraco-ui/uui-icon": "1.0.0
|
|
37
|
-
"@umbraco-ui/uui-scroll-container": "1.0.0
|
|
33
|
+
"@umbraco-ui/uui-base": "1.0.0",
|
|
34
|
+
"@umbraco-ui/uui-button": "1.0.0",
|
|
35
|
+
"@umbraco-ui/uui-combobox-list": "1.0.0",
|
|
36
|
+
"@umbraco-ui/uui-icon": "1.0.0",
|
|
37
|
+
"@umbraco-ui/uui-scroll-container": "1.0.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-combobox",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ffb9cef00262b9f36177adcca9675b4893c0045e"
|
|
49
49
|
}
|