@umbraco-ui/uui-combobox 1.1.0 → 1.2.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/custom-elements.json
CHANGED
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
"type": " boolean ",
|
|
18
18
|
"default": "\"false\""
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
"name": "closeLabel",
|
|
22
|
+
"description": "Specifies the button label for the close button in mobile mode",
|
|
23
|
+
"type": " string ",
|
|
24
|
+
"default": "\"\\\"Close\\\"\""
|
|
25
|
+
},
|
|
20
26
|
{
|
|
21
27
|
"name": "name",
|
|
22
28
|
"description": "This is a name property of the component.",
|
|
@@ -80,6 +86,13 @@
|
|
|
80
86
|
"type": " boolean ",
|
|
81
87
|
"default": "\"false\""
|
|
82
88
|
},
|
|
89
|
+
{
|
|
90
|
+
"name": "closeLabel",
|
|
91
|
+
"attribute": "closeLabel",
|
|
92
|
+
"description": "Specifies the button label for the close button in mobile mode",
|
|
93
|
+
"type": " string ",
|
|
94
|
+
"default": "\"\\\"Close\\\"\""
|
|
95
|
+
},
|
|
83
96
|
{
|
|
84
97
|
"name": "formAssociated",
|
|
85
98
|
"description": "This is a static class field indicating that the element is can be used inside a native form and participate in its events.\nIt may require a polyfill, check support here https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals.\nRead more about form controls here https://web.dev/more-capable-form-controls/",
|
package/lib/index.js
CHANGED
|
@@ -27,8 +27,13 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
this.open = false;
|
|
30
|
+
this.closeLabel = "Close";
|
|
30
31
|
this._displayValue = "";
|
|
31
32
|
this._search = "";
|
|
33
|
+
this._isPhone = false;
|
|
34
|
+
this._onPhoneChange = () => {
|
|
35
|
+
this._isPhone = this.phoneMediaQuery.matches;
|
|
36
|
+
};
|
|
32
37
|
this._onMouseDown = () => requestAnimationFrame(() => this._input.focus());
|
|
33
38
|
this._onBlur = () => requestAnimationFrame(() => {
|
|
34
39
|
var _a;
|
|
@@ -43,6 +48,12 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
43
48
|
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
|
|
44
49
|
this._open();
|
|
45
50
|
};
|
|
51
|
+
this._onSlotChange = () => {
|
|
52
|
+
var _a;
|
|
53
|
+
if (this.value && this.value !== ((_a = this._comboboxList) == null ? void 0 : _a.value)) {
|
|
54
|
+
this._updateValue(this.value);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
46
57
|
this._onChange = (e) => {
|
|
47
58
|
var _a;
|
|
48
59
|
e.stopImmediatePropagation();
|
|
@@ -152,6 +163,9 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
152
163
|
super.connectedCallback();
|
|
153
164
|
this.addEventListener("blur", this._onBlur);
|
|
154
165
|
this.addEventListener("mousedown", this._onMouseDown);
|
|
166
|
+
this.phoneMediaQuery = window.matchMedia("(max-width: 600px)");
|
|
167
|
+
this._onPhoneChange();
|
|
168
|
+
this.phoneMediaQuery.addEventListener("change", this._onPhoneChange);
|
|
155
169
|
demandCustomElement(this, "uui-icon");
|
|
156
170
|
demandCustomElement(this, "uui-input");
|
|
157
171
|
demandCustomElement(this, "uui-button");
|
|
@@ -163,6 +177,7 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
163
177
|
super.disconnectedCallback();
|
|
164
178
|
this.removeEventListener("blur", this._onBlur);
|
|
165
179
|
this.removeEventListener("mousedown", this._onMouseDown);
|
|
180
|
+
this.phoneMediaQuery.removeEventListener("change", this._onPhoneChange);
|
|
166
181
|
}
|
|
167
182
|
async firstUpdated() {
|
|
168
183
|
var _a;
|
|
@@ -174,37 +189,48 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
|
174
189
|
UUIComboboxListEvent.CHANGE,
|
|
175
190
|
this._onChange
|
|
176
191
|
);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.
|
|
180
|
-
|
|
192
|
+
this._comboboxList.addEventListener(
|
|
193
|
+
UUIComboboxListEvent.SLOT_CHANGE,
|
|
194
|
+
this._onSlotChange
|
|
195
|
+
);
|
|
196
|
+
await this.updateComplete;
|
|
197
|
+
this._updateValue(this.value);
|
|
181
198
|
}
|
|
182
199
|
}
|
|
183
200
|
_updateValue(value) {
|
|
184
|
-
var _a;
|
|
185
201
|
if (this._comboboxList) {
|
|
186
202
|
this._comboboxList.value = value;
|
|
187
|
-
|
|
203
|
+
requestAnimationFrame(
|
|
204
|
+
() => this._displayValue = this._comboboxList.displayValue || ""
|
|
205
|
+
);
|
|
188
206
|
}
|
|
189
207
|
}
|
|
190
208
|
getFormElement() {
|
|
191
209
|
return this._input;
|
|
192
210
|
}
|
|
193
211
|
render() {
|
|
194
|
-
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
212
|
+
if (this._isPhone && this.open) {
|
|
213
|
+
return html` <div id="phone-wrapper">
|
|
214
|
+
<uui-button label="close" look="primary" @click=${this._onClose}>
|
|
215
|
+
${this.closeLabel}
|
|
216
|
+
</uui-button>
|
|
199
217
|
${this._renderInput()} ${this._renderDropdown()}
|
|
200
|
-
</
|
|
201
|
-
|
|
218
|
+
</div>`;
|
|
219
|
+
} else {
|
|
220
|
+
return html`
|
|
221
|
+
<uui-popover
|
|
222
|
+
.open=${this.open}
|
|
223
|
+
.margin=${-1}
|
|
224
|
+
@close=${() => this._onClose()}>
|
|
225
|
+
${this._renderInput()} ${this._renderDropdown()}
|
|
226
|
+
</uui-popover>
|
|
227
|
+
`;
|
|
228
|
+
}
|
|
202
229
|
}
|
|
203
230
|
};
|
|
204
231
|
UUIComboboxElement.styles = [
|
|
205
232
|
css`
|
|
206
233
|
:host {
|
|
207
|
-
position: relative;
|
|
208
234
|
display: inline-block;
|
|
209
235
|
}
|
|
210
236
|
|
|
@@ -214,8 +240,9 @@ UUIComboboxElement.styles = [
|
|
|
214
240
|
}
|
|
215
241
|
|
|
216
242
|
#scroll-container {
|
|
217
|
-
max-height: var(--uui-combobox-popover-max-height, 500px);
|
|
218
243
|
overflow-y: auto;
|
|
244
|
+
width: 100%;
|
|
245
|
+
max-height: var(--uui-combobox-popover-max-height, 500px);
|
|
219
246
|
}
|
|
220
247
|
|
|
221
248
|
#dropdown {
|
|
@@ -240,14 +267,46 @@ UUIComboboxElement.styles = [
|
|
|
240
267
|
flex-shrink: 0;
|
|
241
268
|
margin-top: -1px;
|
|
242
269
|
}
|
|
270
|
+
|
|
271
|
+
#phone-wrapper {
|
|
272
|
+
position: fixed;
|
|
273
|
+
inset: 0;
|
|
274
|
+
display: flex;
|
|
275
|
+
flex-direction: column;
|
|
276
|
+
z-index: 1;
|
|
277
|
+
font-size: 1.1em;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
#phone-wrapper #dropdown {
|
|
281
|
+
display: flex;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
#phone-wrapper #combobox-input {
|
|
285
|
+
height: var(--uui-size-16,48px);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
#phone-wrapper > uui-button {
|
|
289
|
+
height: var(--uui-size-14,42px);
|
|
290
|
+
width: 100%;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
#phone-wrapper #scroll-container {
|
|
294
|
+
max-height: unset;
|
|
295
|
+
}
|
|
243
296
|
`
|
|
244
297
|
];
|
|
298
|
+
__decorateClass([
|
|
299
|
+
property({ attribute: "value", reflect: true })
|
|
300
|
+
], UUIComboboxElement.prototype, "value", 1);
|
|
245
301
|
__decorateClass([
|
|
246
302
|
property({ type: String })
|
|
247
303
|
], UUIComboboxElement.prototype, "search", 1);
|
|
248
304
|
__decorateClass([
|
|
249
305
|
property({ type: Boolean })
|
|
250
306
|
], UUIComboboxElement.prototype, "open", 2);
|
|
307
|
+
__decorateClass([
|
|
308
|
+
property({ type: String })
|
|
309
|
+
], UUIComboboxElement.prototype, "closeLabel", 2);
|
|
251
310
|
__decorateClass([
|
|
252
311
|
query("#combobox-input")
|
|
253
312
|
], UUIComboboxElement.prototype, "_input", 2);
|
|
@@ -263,6 +322,9 @@ __decorateClass([
|
|
|
263
322
|
__decorateClass([
|
|
264
323
|
state()
|
|
265
324
|
], UUIComboboxElement.prototype, "_search", 2);
|
|
325
|
+
__decorateClass([
|
|
326
|
+
state()
|
|
327
|
+
], UUIComboboxElement.prototype, "_isPhone", 2);
|
|
266
328
|
UUIComboboxElement = __decorateClass([
|
|
267
329
|
defineElement("uui-combobox")
|
|
268
330
|
], UUIComboboxElement);
|
|
@@ -28,19 +28,30 @@ export declare class UUIComboboxElement extends UUIComboboxElement_base {
|
|
|
28
28
|
* @default false
|
|
29
29
|
*/
|
|
30
30
|
open: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies the button label for the close button in mobile mode
|
|
33
|
+
* @type { string }
|
|
34
|
+
* @attr
|
|
35
|
+
* @default "Close"
|
|
36
|
+
*/
|
|
37
|
+
closeLabel: string;
|
|
31
38
|
private _input;
|
|
32
39
|
private _comboboxListElements?;
|
|
33
40
|
private _comboboxList;
|
|
41
|
+
private phoneMediaQuery;
|
|
34
42
|
private _displayValue;
|
|
35
43
|
private _search;
|
|
44
|
+
private _isPhone;
|
|
36
45
|
connectedCallback(): void;
|
|
37
46
|
disconnectedCallback(): void;
|
|
38
47
|
protected firstUpdated(): Promise<void>;
|
|
48
|
+
private _onPhoneChange;
|
|
39
49
|
private _updateValue;
|
|
40
50
|
protected getFormElement(): HTMLElement | undefined;
|
|
41
51
|
private _onMouseDown;
|
|
42
52
|
private _onBlur;
|
|
43
53
|
private _onInput;
|
|
54
|
+
private _onSlotChange;
|
|
44
55
|
private _onChange;
|
|
45
56
|
private _open;
|
|
46
57
|
private _onClose;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-combobox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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.
|
|
34
|
-
"@umbraco-ui/uui-button": "1.
|
|
35
|
-
"@umbraco-ui/uui-combobox-list": "1.
|
|
36
|
-
"@umbraco-ui/uui-icon": "1.
|
|
37
|
-
"@umbraco-ui/uui-scroll-container": "1.
|
|
33
|
+
"@umbraco-ui/uui-base": "1.1.0",
|
|
34
|
+
"@umbraco-ui/uui-button": "1.1.0",
|
|
35
|
+
"@umbraco-ui/uui-combobox-list": "1.1.0",
|
|
36
|
+
"@umbraco-ui/uui-icon": "1.1.0",
|
|
37
|
+
"@umbraco-ui/uui-scroll-container": "1.1.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": "5159a81e353c893c30073cdbf2fdd94306477d6e"
|
|
49
49
|
}
|