@umbraco-ui/uui-combobox 0.1.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/LICENSE +21 -0
- package/README.md +31 -0
- package/custom-elements.json +172 -0
- package/lib/UUIComboboxEvent.d.ts +6 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +278 -0
- package/lib/uui-combobox-async-example.d.ts +10 -0
- package/lib/uui-combobox.element.d.ts +60 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 uui-app
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# uui-combobox
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Umbraco style combo-box component.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### ES imports
|
|
10
|
+
|
|
11
|
+
```zsh
|
|
12
|
+
npm i @umbraco-ui/uui-combobox
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Import the registration of `<uui-combobox>` via:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import '@umbraco-ui/uui-combobox';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
When looking to leverage the `UUIComboboxElement` base class as a type and/or for extension purposes, do so via:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { UUIComboboxElement } from '@umbraco-ui/uui-combobox';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<uui-combobox></uui-combobox>
|
|
31
|
+
```
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "experimental",
|
|
3
|
+
"tags": [
|
|
4
|
+
{
|
|
5
|
+
"name": "uui-combobox",
|
|
6
|
+
"path": "./lib/uui-combobox.element.ts",
|
|
7
|
+
"attributes": [
|
|
8
|
+
{
|
|
9
|
+
"name": "search",
|
|
10
|
+
"description": "The search input.",
|
|
11
|
+
"type": " string ",
|
|
12
|
+
"default": "\"\\\"\\\"\""
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "open",
|
|
16
|
+
"description": "Specifies if the popover should be open.",
|
|
17
|
+
"type": " boolean ",
|
|
18
|
+
"default": "\"false\""
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "name",
|
|
22
|
+
"description": "This is a name property of the component.",
|
|
23
|
+
"type": "string",
|
|
24
|
+
"default": "\"''\""
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "value",
|
|
28
|
+
"description": "Value of this form control.",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"default": "\"''\""
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "pristine",
|
|
34
|
+
"description": "Determines wether the form control has been touched or interacted with, this determines wether the validation-status of this form control should be made visible.",
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"default": "\"false\""
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "required",
|
|
40
|
+
"description": "Apply validation rule for requiring a value of this form control.",
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"default": "\"false\""
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "required-message",
|
|
46
|
+
"description": "Required validation message.",
|
|
47
|
+
"type": "string",
|
|
48
|
+
"default": "\"This field is required\""
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "error",
|
|
52
|
+
"description": "Apply custom error on this input.",
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"default": "false"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "error-message",
|
|
58
|
+
"description": "Custom error message.",
|
|
59
|
+
"type": "string",
|
|
60
|
+
"default": "\"This field is invalid\""
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"properties": [
|
|
64
|
+
{
|
|
65
|
+
"name": "styles",
|
|
66
|
+
"type": "CSSResult[]",
|
|
67
|
+
"default": "[null]"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "search",
|
|
71
|
+
"attribute": "search",
|
|
72
|
+
"description": "The search input.",
|
|
73
|
+
"type": " string ",
|
|
74
|
+
"default": "\"\\\"\\\"\""
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "open",
|
|
78
|
+
"attribute": "open",
|
|
79
|
+
"description": "Specifies if the popover should be open.",
|
|
80
|
+
"type": " boolean ",
|
|
81
|
+
"default": "\"false\""
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "formAssociated",
|
|
85
|
+
"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/",
|
|
86
|
+
"type": "boolean",
|
|
87
|
+
"default": "true"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "name",
|
|
91
|
+
"attribute": "name",
|
|
92
|
+
"description": "This is a name property of the component.",
|
|
93
|
+
"type": "string",
|
|
94
|
+
"default": "\"''\""
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "value",
|
|
98
|
+
"attribute": "value",
|
|
99
|
+
"description": "Value of this form control.",
|
|
100
|
+
"type": "string",
|
|
101
|
+
"default": "\"''\""
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "pristine",
|
|
105
|
+
"attribute": "pristine",
|
|
106
|
+
"description": "Determines wether the form control has been touched or interacted with, this determines wether the validation-status of this form control should be made visible.",
|
|
107
|
+
"type": "boolean",
|
|
108
|
+
"default": "\"false\""
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "required",
|
|
112
|
+
"attribute": "required",
|
|
113
|
+
"description": "Apply validation rule for requiring a value of this form control.",
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"default": "\"false\""
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "requiredMessage",
|
|
119
|
+
"attribute": "required-message",
|
|
120
|
+
"description": "Required validation message.",
|
|
121
|
+
"type": "string",
|
|
122
|
+
"default": "\"This field is required\""
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "error",
|
|
126
|
+
"attribute": "error",
|
|
127
|
+
"description": "Apply custom error on this input.",
|
|
128
|
+
"type": "boolean",
|
|
129
|
+
"default": "false"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "errorMessage",
|
|
133
|
+
"attribute": "error-message",
|
|
134
|
+
"description": "Custom error message.",
|
|
135
|
+
"type": "string",
|
|
136
|
+
"default": "\"This field is invalid\""
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "validity",
|
|
140
|
+
"type": "ValidityState"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "validationMessage"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"events": [
|
|
147
|
+
{
|
|
148
|
+
"name": "input",
|
|
149
|
+
"description": "fires when search input is changed"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "change",
|
|
153
|
+
"description": "fires when selection is changed"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"slots": [
|
|
157
|
+
{
|
|
158
|
+
"name": "default",
|
|
159
|
+
"description": "for uui-combobox-list-options"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "input-prepend",
|
|
163
|
+
"description": "prepend for the uui-input"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "input-append",
|
|
167
|
+
"description": "append for the uui-input"
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
2
|
+
import { UUIComboboxElement } from './uui-combobox.element';
|
|
3
|
+
export declare class UUIComboboxEvent extends UUIEvent<UUIComboboxElement> {
|
|
4
|
+
static readonly SEARCH: string;
|
|
5
|
+
static readonly CHANGE: string;
|
|
6
|
+
}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
|
|
2
|
+
import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils';
|
|
3
|
+
import { property, query, queryAssignedElements, state } from 'lit/decorators.js';
|
|
4
|
+
import { LitElement, html, css } from 'lit';
|
|
5
|
+
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
6
|
+
import { UUIComboboxListEvent } from '@umbraco-ui/uui-combobox-list/lib';
|
|
7
|
+
import { FormControlMixin } from '@umbraco-ui/uui-base/lib/mixins';
|
|
8
|
+
import { iconRemove } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs';
|
|
9
|
+
|
|
10
|
+
class UUIComboboxEvent extends UUIEvent {
|
|
11
|
+
}
|
|
12
|
+
UUIComboboxEvent.SEARCH = "search";
|
|
13
|
+
UUIComboboxEvent.CHANGE = "change";
|
|
14
|
+
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
17
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
18
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
19
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
20
|
+
if (decorator = decorators[i])
|
|
21
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
22
|
+
if (kind && result)
|
|
23
|
+
__defProp(target, key, result);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
let UUIComboboxElement = class extends FormControlMixin(LitElement) {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.open = false;
|
|
30
|
+
this._displayValue = "";
|
|
31
|
+
this._search = "";
|
|
32
|
+
this._onMouseDown = () => requestAnimationFrame(() => this._input.focus());
|
|
33
|
+
this._onBlur = () => requestAnimationFrame(() => {
|
|
34
|
+
if (document.activeElement !== this) {
|
|
35
|
+
this._close();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
this._onInput = (e) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
e.stopImmediatePropagation();
|
|
41
|
+
this.search = e.target.value;
|
|
42
|
+
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
|
|
43
|
+
this._open();
|
|
44
|
+
};
|
|
45
|
+
this._onChange = (e) => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
e.stopImmediatePropagation();
|
|
48
|
+
this.value = ((_a = this._comboboxList) == null ? void 0 : _a.value) || "";
|
|
49
|
+
this._displayValue = ((_b = this._comboboxList) == null ? void 0 : _b.displayValue) || "";
|
|
50
|
+
this.search = this.value ? this.search : "";
|
|
51
|
+
this._close();
|
|
52
|
+
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.CHANGE));
|
|
53
|
+
};
|
|
54
|
+
this._open = () => {
|
|
55
|
+
if (this.open)
|
|
56
|
+
return;
|
|
57
|
+
this.open = true;
|
|
58
|
+
};
|
|
59
|
+
this._close = () => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (!this.open)
|
|
62
|
+
return;
|
|
63
|
+
this.open = false;
|
|
64
|
+
this._displayValue = ((_a = this._comboboxList) == null ? void 0 : _a.displayValue) || "";
|
|
65
|
+
this._input.value = this._displayValue;
|
|
66
|
+
this.search = "";
|
|
67
|
+
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
|
|
68
|
+
};
|
|
69
|
+
this._onKeyDown = (e) => {
|
|
70
|
+
if (this.open === false && e.key === "Enter") {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
e.stopImmediatePropagation();
|
|
73
|
+
}
|
|
74
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
75
|
+
this._open();
|
|
76
|
+
}
|
|
77
|
+
if (e.key === "Escape" || e.key === "Enter") {
|
|
78
|
+
this._close();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this._clear = (e) => {
|
|
82
|
+
if (e.key && e.key !== "Enter")
|
|
83
|
+
return;
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
e.stopImmediatePropagation();
|
|
86
|
+
this._displayValue = "";
|
|
87
|
+
this._input.value = this._displayValue;
|
|
88
|
+
this.search = "";
|
|
89
|
+
this.value = "";
|
|
90
|
+
this._comboboxList.value = this.value;
|
|
91
|
+
this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.CHANGE));
|
|
92
|
+
};
|
|
93
|
+
this._renderInput = () => {
|
|
94
|
+
return html` <uui-input
|
|
95
|
+
slot="trigger"
|
|
96
|
+
id="combobox-input"
|
|
97
|
+
label="combobox-input"
|
|
98
|
+
type="text"
|
|
99
|
+
.value=${this._displayValue}
|
|
100
|
+
.placeholder=${this._displayValue}
|
|
101
|
+
autocomplete="off"
|
|
102
|
+
@click=${this._open}
|
|
103
|
+
@input=${this._onInput}
|
|
104
|
+
@keydown=${this._onKeyDown}>
|
|
105
|
+
<slot name="input-prepend" slot="prepend"></slot>
|
|
106
|
+
${this._renderClearButton()} ${this._renderCaret()}
|
|
107
|
+
<slot name="input-append" slot="append"></slot>
|
|
108
|
+
</uui-input>`;
|
|
109
|
+
};
|
|
110
|
+
this._renderCaret = () => {
|
|
111
|
+
return html`<svg id="caret" slot="append" viewBox="0 0 512 512">
|
|
112
|
+
<path d="M 255.125 400.35 L 88.193 188.765 H 422.055 Z"></path>
|
|
113
|
+
</svg>`;
|
|
114
|
+
};
|
|
115
|
+
this._renderClearButton = () => {
|
|
116
|
+
return html`<uui-button
|
|
117
|
+
id="clear-button"
|
|
118
|
+
class=${this.value || this.search ? "--show" : ""}
|
|
119
|
+
@click=${this._clear}
|
|
120
|
+
@keydown=${this._clear}
|
|
121
|
+
label="clear"
|
|
122
|
+
slot="append"
|
|
123
|
+
compact
|
|
124
|
+
style="height: 100%; --uui-button-padding-top-factor:0; --uui-button-padding-bottom-factor:0;">
|
|
125
|
+
<uui-icon name="remove" .fallback=${iconRemove.strings[0]}></uui-icon>
|
|
126
|
+
</uui-button>`;
|
|
127
|
+
};
|
|
128
|
+
this._renderDropdown = () => {
|
|
129
|
+
return html`<div id="dropdown" slot="popover">
|
|
130
|
+
<uui-scroll-container id="scroll-container">
|
|
131
|
+
<slot></slot>
|
|
132
|
+
</uui-scroll-container>
|
|
133
|
+
</div>`;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
get value() {
|
|
137
|
+
return this._value;
|
|
138
|
+
}
|
|
139
|
+
set value(newValue) {
|
|
140
|
+
super.value = newValue;
|
|
141
|
+
if (typeof newValue === "string") {
|
|
142
|
+
this._updateValue(newValue);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
get search() {
|
|
146
|
+
return this._search;
|
|
147
|
+
}
|
|
148
|
+
set search(newValue) {
|
|
149
|
+
if (this.search === newValue)
|
|
150
|
+
return;
|
|
151
|
+
const oldValue = this._search;
|
|
152
|
+
this._search = newValue;
|
|
153
|
+
this.requestUpdate("search", oldValue);
|
|
154
|
+
}
|
|
155
|
+
connectedCallback() {
|
|
156
|
+
super.connectedCallback();
|
|
157
|
+
this.addEventListener("blur", this._onBlur);
|
|
158
|
+
this.addEventListener("mousedown", this._onMouseDown);
|
|
159
|
+
demandCustomElement(this, "uui-icon");
|
|
160
|
+
demandCustomElement(this, "uui-input");
|
|
161
|
+
demandCustomElement(this, "uui-button");
|
|
162
|
+
demandCustomElement(this, "uui-combobox-list");
|
|
163
|
+
demandCustomElement(this, "uui-scroll-container");
|
|
164
|
+
}
|
|
165
|
+
disconnectedCallback() {
|
|
166
|
+
super.disconnectedCallback();
|
|
167
|
+
this.removeEventListener("blur", this._onBlur);
|
|
168
|
+
this.removeEventListener("mousedown", this._onMouseDown);
|
|
169
|
+
}
|
|
170
|
+
async firstUpdated() {
|
|
171
|
+
var _a;
|
|
172
|
+
const list = (_a = this._comboboxListElements) == null ? void 0 : _a[0];
|
|
173
|
+
if (list) {
|
|
174
|
+
this._comboboxList = list;
|
|
175
|
+
this._comboboxList.for = this;
|
|
176
|
+
this._comboboxList.addEventListener(UUIComboboxListEvent.CHANGE, this._onChange);
|
|
177
|
+
if (typeof this.value === "string") {
|
|
178
|
+
await this.updateComplete;
|
|
179
|
+
this._updateValue(this.value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
_updateValue(value) {
|
|
184
|
+
var _a;
|
|
185
|
+
if (this._comboboxList) {
|
|
186
|
+
this._comboboxList.value = value;
|
|
187
|
+
this._displayValue = ((_a = this._comboboxList) == null ? void 0 : _a.displayValue) || "";
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
getFormElement() {
|
|
191
|
+
return this._input;
|
|
192
|
+
}
|
|
193
|
+
render() {
|
|
194
|
+
return html`
|
|
195
|
+
<uui-popover
|
|
196
|
+
.open=${this.open}
|
|
197
|
+
.margin=${-1}
|
|
198
|
+
@close=${() => this._close()}>
|
|
199
|
+
${this._renderInput()} ${this._renderDropdown()}
|
|
200
|
+
</uui-popover>
|
|
201
|
+
`;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
UUIComboboxElement.styles = [
|
|
205
|
+
css`
|
|
206
|
+
:host {
|
|
207
|
+
position: relative;
|
|
208
|
+
display: inline-block;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#combobox-input {
|
|
212
|
+
width: 100%;
|
|
213
|
+
border-radius: var(--uui-size-1,3px);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#scroll-container {
|
|
217
|
+
max-height: var(--uui-combobox-popover-max-height, 500px);
|
|
218
|
+
overflow-y: auto;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#dropdown {
|
|
222
|
+
overflow: hidden;
|
|
223
|
+
z-index: -1;
|
|
224
|
+
background-color: var(--uui-combobox-popover-background-color, white);
|
|
225
|
+
border: 1px solid var(--uui-interface-border,#c4c4c4);
|
|
226
|
+
border-radius: var(--uui-border-radius,3px);
|
|
227
|
+
width: 100%;
|
|
228
|
+
height: 100%;
|
|
229
|
+
box-sizing: border-box;
|
|
230
|
+
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));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#clear-button {
|
|
234
|
+
pointer-events: none;
|
|
235
|
+
opacity: 0;
|
|
236
|
+
transition: opacity 120ms;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
#clear-button.--show {
|
|
240
|
+
pointer-events: auto;
|
|
241
|
+
opacity: 1;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
#caret {
|
|
245
|
+
margin-right: var(--uui-size-3, 9px);
|
|
246
|
+
display: flex;
|
|
247
|
+
width: 1.15em;
|
|
248
|
+
flex-shrink: 0;
|
|
249
|
+
margin-top: -1px;
|
|
250
|
+
}
|
|
251
|
+
`
|
|
252
|
+
];
|
|
253
|
+
__decorateClass([
|
|
254
|
+
property({ type: String })
|
|
255
|
+
], UUIComboboxElement.prototype, "search", 1);
|
|
256
|
+
__decorateClass([
|
|
257
|
+
property({ type: Boolean })
|
|
258
|
+
], UUIComboboxElement.prototype, "open", 2);
|
|
259
|
+
__decorateClass([
|
|
260
|
+
query("#combobox-input")
|
|
261
|
+
], UUIComboboxElement.prototype, "_input", 2);
|
|
262
|
+
__decorateClass([
|
|
263
|
+
queryAssignedElements({
|
|
264
|
+
flatten: true,
|
|
265
|
+
selector: "uui-combobox-list"
|
|
266
|
+
})
|
|
267
|
+
], UUIComboboxElement.prototype, "_comboboxListElements", 2);
|
|
268
|
+
__decorateClass([
|
|
269
|
+
state()
|
|
270
|
+
], UUIComboboxElement.prototype, "_displayValue", 2);
|
|
271
|
+
__decorateClass([
|
|
272
|
+
state()
|
|
273
|
+
], UUIComboboxElement.prototype, "_search", 2);
|
|
274
|
+
UUIComboboxElement = __decorateClass([
|
|
275
|
+
defineElement("uui-combobox")
|
|
276
|
+
], UUIComboboxElement);
|
|
277
|
+
|
|
278
|
+
export { UUIComboboxElement, UUIComboboxEvent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class UUIComboboxAsyncExampleElement extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
_options: any[];
|
|
5
|
+
_loading: boolean;
|
|
6
|
+
_filterValue: string;
|
|
7
|
+
private _fetchData;
|
|
8
|
+
private _handleSearch;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const UUIComboboxElement_base: (new (...args: any[]) => import("@umbraco-ui/uui-base/lib/mixins").FormControlMixinInterface) & typeof LitElement;
|
|
3
|
+
/**
|
|
4
|
+
* @element uui-combobox
|
|
5
|
+
* @fires {UUIComboboxEvent} input - fires when search input is changed
|
|
6
|
+
* @fires {UUIComboboxEvent} change - fires when selection is changed
|
|
7
|
+
* @slot default - for uui-combobox-list-options
|
|
8
|
+
* @slot input-prepend - prepend for the uui-input
|
|
9
|
+
* @slot input-append - append for the uui-input
|
|
10
|
+
* @description - Filterable combobox
|
|
11
|
+
*/
|
|
12
|
+
export declare class UUIComboboxElement extends UUIComboboxElement_base {
|
|
13
|
+
static styles: import("lit").CSSResult[];
|
|
14
|
+
get value(): FormDataEntryValue | FormData;
|
|
15
|
+
set value(newValue: FormDataEntryValue | FormData);
|
|
16
|
+
/**
|
|
17
|
+
* The search input.
|
|
18
|
+
* @type { string }
|
|
19
|
+
* @attr
|
|
20
|
+
* @default ""
|
|
21
|
+
*/
|
|
22
|
+
get search(): string;
|
|
23
|
+
set search(newValue: string);
|
|
24
|
+
/**
|
|
25
|
+
* Specifies if the popover should be open.
|
|
26
|
+
* @type { boolean }
|
|
27
|
+
* @attr
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
open: boolean;
|
|
31
|
+
private _input;
|
|
32
|
+
private _comboboxListElements?;
|
|
33
|
+
private _comboboxList;
|
|
34
|
+
private _displayValue;
|
|
35
|
+
private _search;
|
|
36
|
+
connectedCallback(): void;
|
|
37
|
+
disconnectedCallback(): void;
|
|
38
|
+
protected firstUpdated(): Promise<void>;
|
|
39
|
+
private _updateValue;
|
|
40
|
+
protected getFormElement(): HTMLElement | undefined;
|
|
41
|
+
private _onMouseDown;
|
|
42
|
+
private _onBlur;
|
|
43
|
+
private _onInput;
|
|
44
|
+
private _onChange;
|
|
45
|
+
private _open;
|
|
46
|
+
private _close;
|
|
47
|
+
private _onKeyDown;
|
|
48
|
+
private _clear;
|
|
49
|
+
private _renderInput;
|
|
50
|
+
private _renderCaret;
|
|
51
|
+
private _renderClearButton;
|
|
52
|
+
private _renderDropdown;
|
|
53
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
54
|
+
}
|
|
55
|
+
declare global {
|
|
56
|
+
interface HTMLElementTagNameMap {
|
|
57
|
+
'uui-combobox': UUIComboboxElement;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@umbraco-ui/uui-combobox",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Umbraco",
|
|
7
|
+
"Custom elements",
|
|
8
|
+
"Web components",
|
|
9
|
+
"UI",
|
|
10
|
+
"Lit",
|
|
11
|
+
"Combo box"
|
|
12
|
+
],
|
|
13
|
+
"description": "Umbraco UI combo-box component",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/umbraco/Umbraco.UI.git",
|
|
17
|
+
"directory": "packages/uui-combobox"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/umbraco/Umbraco.UI/issues"
|
|
21
|
+
},
|
|
22
|
+
"main": "./lib/index.js",
|
|
23
|
+
"module": "./lib/index.js",
|
|
24
|
+
"types": "./lib/index.d.ts",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"customElements": "custom-elements.json",
|
|
27
|
+
"files": [
|
|
28
|
+
"lib/**/*.d.ts",
|
|
29
|
+
"lib/**/*.js",
|
|
30
|
+
"custom-elements.json"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@umbraco-ui/uui-base": "0.2.0",
|
|
34
|
+
"@umbraco-ui/uui-button": "0.3.0",
|
|
35
|
+
"@umbraco-ui/uui-combobox-list": "0.1.0",
|
|
36
|
+
"@umbraco-ui/uui-icon": "0.2.0",
|
|
37
|
+
"@umbraco-ui/uui-scroll-container": "0.2.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
|
|
41
|
+
"clean": "tsc --build --clean && rimraf dist lib/*.js lib/**/*.js custom-elements.json",
|
|
42
|
+
"analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://uui.umbraco.com/?path=/story/uui-combobox",
|
|
48
|
+
"gitHead": "5494b55e03c9fb3ba8f160e693d3ce59c02d21cd"
|
|
49
|
+
}
|