@umbraco-ui/uui-combobox 1.8.0 → 1.9.0-rc.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 +13 -0
- package/lib/index.js +32 -42
- package/lib/uui-combobox.element.d.ts +7 -0
- package/package.json +9 -9
package/custom-elements.json
CHANGED
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"type": "boolean",
|
|
30
30
|
"default": "\"false\""
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
"name": "readonly",
|
|
34
|
+
"description": "Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.",
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"default": "\"false\""
|
|
37
|
+
},
|
|
32
38
|
{
|
|
33
39
|
"name": "name",
|
|
34
40
|
"description": "This is a name property of the component.",
|
|
@@ -101,6 +107,13 @@
|
|
|
101
107
|
"type": "boolean",
|
|
102
108
|
"default": "\"false\""
|
|
103
109
|
},
|
|
110
|
+
{
|
|
111
|
+
"name": "readonly",
|
|
112
|
+
"attribute": "readonly",
|
|
113
|
+
"description": "Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.",
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"default": "\"false\""
|
|
116
|
+
},
|
|
104
117
|
{
|
|
105
118
|
"name": "styles",
|
|
106
119
|
"type": "CSSResult[]",
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
|
|
|
3
3
|
import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils';
|
|
4
4
|
import { UUIComboboxListEvent } from '@umbraco-ui/uui-combobox-list/lib';
|
|
5
5
|
import { iconRemove } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs';
|
|
6
|
-
import { LitElement, html, css } from 'lit';
|
|
6
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
7
7
|
import { property, query, queryAssignedElements, state } from 'lit/decorators.js';
|
|
8
8
|
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
9
9
|
|
|
@@ -20,46 +20,32 @@ UUIComboboxEvent.CHANGE = "change";
|
|
|
20
20
|
|
|
21
21
|
var __defProp = Object.defineProperty;
|
|
22
22
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
23
|
+
var __typeError = (msg) => {
|
|
24
|
+
throw TypeError(msg);
|
|
25
|
+
};
|
|
23
26
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
24
27
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
25
28
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
26
29
|
if (decorator = decorators[i])
|
|
27
30
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
28
|
-
if (kind && result)
|
|
29
|
-
__defProp(target, key, result);
|
|
31
|
+
if (kind && result) __defProp(target, key, result);
|
|
30
32
|
return result;
|
|
31
33
|
};
|
|
32
|
-
var __accessCheck = (obj, member, msg) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
39
|
-
};
|
|
40
|
-
var __privateAdd = (obj, member, value) => {
|
|
41
|
-
if (member.has(obj))
|
|
42
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
43
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
44
|
-
};
|
|
45
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
46
|
-
__accessCheck(obj, member, "write to private field");
|
|
47
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
48
|
-
return value;
|
|
49
|
-
};
|
|
50
|
-
var __privateMethod = (obj, member, method) => {
|
|
51
|
-
__accessCheck(obj, member, "access private method");
|
|
52
|
-
return method;
|
|
53
|
-
};
|
|
54
|
-
var _comboboxList, _phoneMediaQuery, _onPhoneChange, _updateValue, updateValue_fn, _onMouseDown, _onBlur, _onInput, _onSlotChange, _onChange, _onToggle, _onOpen, _onClose, _onKeyDown, _onClear, _renderInput, _renderClearButton, _renderDropdown;
|
|
34
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
35
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
36
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
37
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
38
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
39
|
+
var _comboboxList, _phoneMediaQuery, _onPhoneChange, _UUIComboboxElement_instances, updateValue_fn, _onMouseDown, _onBlur, _onInput, _onSlotChange, _onChange, _onToggle, _onOpen, _onClose, _onKeyDown, _onClear, _renderInput, _renderClearButton, _renderDropdown;
|
|
55
40
|
let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
56
41
|
constructor() {
|
|
57
42
|
super(...arguments);
|
|
58
|
-
__privateAdd(this,
|
|
43
|
+
__privateAdd(this, _UUIComboboxElement_instances);
|
|
59
44
|
this.closeLabel = "Close";
|
|
60
45
|
this.disabled = false;
|
|
61
|
-
|
|
62
|
-
__privateAdd(this,
|
|
46
|
+
this.readonly = false;
|
|
47
|
+
__privateAdd(this, _comboboxList);
|
|
48
|
+
__privateAdd(this, _phoneMediaQuery);
|
|
63
49
|
this._displayValue = "";
|
|
64
50
|
this._search = "";
|
|
65
51
|
this._isPhone = false;
|
|
@@ -82,7 +68,7 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
82
68
|
});
|
|
83
69
|
__privateAdd(this, _onSlotChange, () => {
|
|
84
70
|
if (this.value && this.value !== __privateGet(this, _comboboxList)?.value) {
|
|
85
|
-
__privateMethod(this,
|
|
71
|
+
__privateMethod(this, _UUIComboboxElement_instances, updateValue_fn).call(this, this.value);
|
|
86
72
|
}
|
|
87
73
|
});
|
|
88
74
|
__privateAdd(this, _onChange, () => {
|
|
@@ -92,16 +78,16 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
92
78
|
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.CHANGE));
|
|
93
79
|
});
|
|
94
80
|
__privateAdd(this, _onToggle, () => {
|
|
81
|
+
if (this.readonly) return;
|
|
95
82
|
this.open = !this.open;
|
|
96
83
|
});
|
|
97
84
|
__privateAdd(this, _onOpen, () => {
|
|
98
|
-
if (this.open)
|
|
99
|
-
|
|
85
|
+
if (this.open) return;
|
|
86
|
+
if (this.readonly) return;
|
|
100
87
|
this.open = true;
|
|
101
88
|
});
|
|
102
89
|
__privateAdd(this, _onClose, () => {
|
|
103
|
-
if (!this.open)
|
|
104
|
-
return;
|
|
90
|
+
if (!this.open) return;
|
|
105
91
|
this.open = false;
|
|
106
92
|
this.search = "";
|
|
107
93
|
this._input.value = this._displayValue;
|
|
@@ -120,8 +106,7 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
120
106
|
}
|
|
121
107
|
});
|
|
122
108
|
__privateAdd(this, _onClear, (e) => {
|
|
123
|
-
if (e.key && e.key !== "Enter")
|
|
124
|
-
return;
|
|
109
|
+
if (e.key && e.key !== "Enter") return;
|
|
125
110
|
e.preventDefault();
|
|
126
111
|
e.stopImmediatePropagation();
|
|
127
112
|
this.value = "";
|
|
@@ -140,12 +125,13 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
140
125
|
.value=${this._displayValue}
|
|
141
126
|
autocomplete="off"
|
|
142
127
|
.disabled=${this.disabled}
|
|
128
|
+
.readonly=${this.readonly}
|
|
143
129
|
popovertarget="combobox-popover"
|
|
144
130
|
@click=${__privateGet(this, _onToggle)}
|
|
145
131
|
@input=${__privateGet(this, _onInput)}
|
|
146
132
|
@keydown=${__privateGet(this, _onKeyDown)}>
|
|
147
133
|
<slot name="input-prepend" slot="prepend"></slot>
|
|
148
|
-
${
|
|
134
|
+
${__privateGet(this, _renderClearButton).call(this)}
|
|
149
135
|
<div id="expand-symbol-wrapper" slot="append">
|
|
150
136
|
<uui-symbol-expand .open=${this._isOpen}></uui-symbol-expand>
|
|
151
137
|
</div>
|
|
@@ -153,6 +139,8 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
153
139
|
</uui-input>`;
|
|
154
140
|
});
|
|
155
141
|
__privateAdd(this, _renderClearButton, () => {
|
|
142
|
+
if (this.disabled) return nothing;
|
|
143
|
+
if (this.readonly) return nothing;
|
|
156
144
|
return this.value || this.search ? html`<uui-button
|
|
157
145
|
id="clear-button"
|
|
158
146
|
@click=${__privateGet(this, _onClear)}
|
|
@@ -177,7 +165,7 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
177
165
|
}
|
|
178
166
|
set value(newValue) {
|
|
179
167
|
if (typeof newValue === "string") {
|
|
180
|
-
__privateMethod(this,
|
|
168
|
+
__privateMethod(this, _UUIComboboxElement_instances, updateValue_fn).call(this, newValue);
|
|
181
169
|
}
|
|
182
170
|
super.value = newValue;
|
|
183
171
|
}
|
|
@@ -185,8 +173,7 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
185
173
|
return this._search;
|
|
186
174
|
}
|
|
187
175
|
set search(newValue) {
|
|
188
|
-
if (this.search === newValue)
|
|
189
|
-
return;
|
|
176
|
+
if (this.search === newValue) return;
|
|
190
177
|
const oldValue = this._search;
|
|
191
178
|
this._search = newValue;
|
|
192
179
|
this.requestUpdate("search", oldValue);
|
|
@@ -244,7 +231,7 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
244
231
|
__privateGet(this, _onSlotChange)
|
|
245
232
|
);
|
|
246
233
|
await this.updateComplete;
|
|
247
|
-
__privateMethod(this,
|
|
234
|
+
__privateMethod(this, _UUIComboboxElement_instances, updateValue_fn).call(this, this.value);
|
|
248
235
|
}
|
|
249
236
|
}
|
|
250
237
|
getFormElement() {
|
|
@@ -286,7 +273,7 @@ let UUIComboboxElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
286
273
|
_comboboxList = new WeakMap();
|
|
287
274
|
_phoneMediaQuery = new WeakMap();
|
|
288
275
|
_onPhoneChange = new WeakMap();
|
|
289
|
-
|
|
276
|
+
_UUIComboboxElement_instances = new WeakSet();
|
|
290
277
|
updateValue_fn = function(value) {
|
|
291
278
|
if (__privateGet(this, _comboboxList)) {
|
|
292
279
|
__privateGet(this, _comboboxList).value = value;
|
|
@@ -396,6 +383,9 @@ __decorateClass([
|
|
|
396
383
|
__decorateClass([
|
|
397
384
|
property({ type: Boolean, reflect: true })
|
|
398
385
|
], UUIComboboxElement.prototype, "disabled", 2);
|
|
386
|
+
__decorateClass([
|
|
387
|
+
property({ type: Boolean, reflect: true })
|
|
388
|
+
], UUIComboboxElement.prototype, "readonly", 2);
|
|
399
389
|
__decorateClass([
|
|
400
390
|
query("#combobox-input")
|
|
401
391
|
], UUIComboboxElement.prototype, "_input", 2);
|
|
@@ -44,6 +44,13 @@ export declare class UUIComboboxElement extends UUIComboboxElement_base {
|
|
|
44
44
|
* @default false
|
|
45
45
|
*/
|
|
46
46
|
disabled: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
|
|
49
|
+
* @type {boolean}
|
|
50
|
+
* @attr
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
readonly: boolean;
|
|
47
54
|
private _input;
|
|
48
55
|
private _comboboxPopoverElement?;
|
|
49
56
|
private _comboboxListElements?;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-combobox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,13 +30,13 @@
|
|
|
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-popover-container": "1.
|
|
38
|
-
"@umbraco-ui/uui-scroll-container": "1.
|
|
39
|
-
"@umbraco-ui/uui-symbol-expand": "1.
|
|
33
|
+
"@umbraco-ui/uui-base": "1.9.0-rc.0",
|
|
34
|
+
"@umbraco-ui/uui-button": "1.9.0-rc.0",
|
|
35
|
+
"@umbraco-ui/uui-combobox-list": "1.9.0-rc.0",
|
|
36
|
+
"@umbraco-ui/uui-icon": "1.9.0-rc.0",
|
|
37
|
+
"@umbraco-ui/uui-popover-container": "1.9.0-rc.0",
|
|
38
|
+
"@umbraco-ui/uui-scroll-container": "1.9.0-rc.0",
|
|
39
|
+
"@umbraco-ui/uui-symbol-expand": "1.9.0-rc.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "npm run analyze && tsc --build && rollup -c rollup.config.js",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-combobox",
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "e3e398e07b6ff9874aa0656cb7767df42f58a4ce"
|
|
51
51
|
}
|