@umbraco-ui/uui-combobox 1.6.0-rc.1 → 1.6.0-rc.2

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.
@@ -192,6 +192,12 @@
192
192
  "name": "input-append",
193
193
  "description": "append for the uui-input"
194
194
  }
195
+ ],
196
+ "cssProperties": [
197
+ {
198
+ "name": "--uui-dropdown-width",
199
+ "description": "overwrite the dropdown width"
200
+ }
195
201
  ]
196
202
  }
197
203
  ]
package/lib/index.js CHANGED
@@ -42,83 +42,112 @@ var __decorateClass = (decorators, target, key, kind) => {
42
42
  __defProp(target, key, result);
43
43
  return result;
44
44
  };
45
+ var __accessCheck = (obj, member, msg) => {
46
+ if (!member.has(obj))
47
+ throw TypeError("Cannot " + msg);
48
+ };
49
+ var __privateGet = (obj, member, getter) => {
50
+ __accessCheck(obj, member, "read from private field");
51
+ return getter ? getter.call(obj) : member.get(obj);
52
+ };
53
+ var __privateAdd = (obj, member, value) => {
54
+ if (member.has(obj))
55
+ throw TypeError("Cannot add the same private member more than once");
56
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
57
+ };
58
+ var __privateSet = (obj, member, value, setter) => {
59
+ __accessCheck(obj, member, "write to private field");
60
+ setter ? setter.call(obj, value) : member.set(obj, value);
61
+ return value;
62
+ };
63
+ var __privateMethod = (obj, member, method) => {
64
+ __accessCheck(obj, member, "access private method");
65
+ return method;
66
+ };
67
+ var _comboboxList, _phoneMediaQuery, _onPhoneChange, _updateValue, updateValue_fn, _onMouseDown, _onBlur, _onInput, _onSlotChange, _onChange, _onToggle, _onOpen, _onClose, _onKeyDown, _onClear, _renderInput, _renderClearButton, _renderDropdown;
45
68
  let UUIComboboxElement = class extends FormControlMixin(LitElement) {
46
69
  constructor() {
47
70
  super(...arguments);
48
- this.open = false;
71
+ __privateAdd(this, _updateValue);
49
72
  this.closeLabel = "Close";
50
73
  this.disabled = false;
74
+ __privateAdd(this, _comboboxList, void 0);
75
+ __privateAdd(this, _phoneMediaQuery, void 0);
51
76
  this._displayValue = "";
52
77
  this._search = "";
53
78
  this._isPhone = false;
54
- this._onPhoneChange = () => {
55
- this._isPhone = this.phoneMediaQuery.matches;
56
- };
57
- this._onMouseDown = () => requestAnimationFrame(() => this._input.focus());
58
- this._onBlur = () => requestAnimationFrame(() => {
79
+ this._isOpen = false;
80
+ __privateAdd(this, _onPhoneChange, () => {
81
+ this._isPhone = __privateGet(this, _phoneMediaQuery).matches;
82
+ });
83
+ __privateAdd(this, _onMouseDown, () => requestAnimationFrame(() => this._inputElement.focus()));
84
+ __privateAdd(this, _onBlur, () => requestAnimationFrame(() => {
59
85
  var _a;
60
86
  if (!((_a = this.shadowRoot) == null ? void 0 : _a.activeElement)) {
61
- this._onClose();
87
+ __privateGet(this, _onClose).call(this);
62
88
  }
63
- });
64
- this._onInput = (e) => {
89
+ }));
90
+ __privateAdd(this, _onInput, (e) => {
65
91
  e.preventDefault();
66
92
  e.stopImmediatePropagation();
67
93
  this.search = e.target.value;
68
94
  this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
69
- this._open();
70
- };
71
- this._onSlotChange = () => {
95
+ __privateGet(this, _onOpen).call(this);
96
+ });
97
+ __privateAdd(this, _onSlotChange, () => {
72
98
  var _a;
73
- if (this.value && this.value !== ((_a = this._comboboxList) == null ? void 0 : _a.value)) {
74
- this._updateValue(this.value);
99
+ if (this.value && this.value !== ((_a = __privateGet(this, _comboboxList)) == null ? void 0 : _a.value)) {
100
+ __privateMethod(this, _updateValue, updateValue_fn).call(this, this.value);
75
101
  }
76
- };
77
- this._onChange = () => {
102
+ });
103
+ __privateAdd(this, _onChange, () => {
78
104
  var _a;
79
- this.value = ((_a = this._comboboxList) == null ? void 0 : _a.value) || "";
105
+ this.value = ((_a = __privateGet(this, _comboboxList)) == null ? void 0 : _a.value) || "";
80
106
  this.search = this.value ? this.search : "";
81
- this._onClose();
107
+ __privateGet(this, _onClose).call(this);
82
108
  this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.CHANGE));
83
- };
84
- this._open = () => {
109
+ });
110
+ __privateAdd(this, _onToggle, () => {
111
+ this.open = !this.open;
112
+ });
113
+ __privateAdd(this, _onOpen, () => {
85
114
  if (this.open)
86
115
  return;
87
116
  this.open = true;
88
- };
89
- this._onClose = () => {
117
+ });
118
+ __privateAdd(this, _onClose, () => {
90
119
  if (!this.open)
91
120
  return;
92
121
  this.open = false;
93
122
  this.search = "";
94
- this._input.value = this._displayValue;
123
+ this._inputElement.value = this._displayValue;
95
124
  this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
96
- };
97
- this._onKeyDown = (e) => {
125
+ });
126
+ __privateAdd(this, _onKeyDown, (e) => {
98
127
  if (this.open === false && e.key === "Enter") {
99
128
  e.preventDefault();
100
129
  e.stopImmediatePropagation();
101
130
  }
102
131
  if (e.key === "ArrowUp" || e.key === "ArrowDown") {
103
- this._open();
132
+ __privateGet(this, _onOpen).call(this);
104
133
  }
105
134
  if (e.key === "Escape" || e.key === "Enter") {
106
- this._onClose();
135
+ __privateGet(this, _onClose).call(this);
107
136
  }
108
- };
109
- this._onClear = (e) => {
137
+ });
138
+ __privateAdd(this, _onClear, (e) => {
110
139
  if (e.key && e.key !== "Enter")
111
140
  return;
112
141
  e.preventDefault();
113
142
  e.stopImmediatePropagation();
114
143
  this.value = "";
115
144
  this.search = "";
116
- this._input.value = this._displayValue;
117
- this._input.focus();
145
+ this._inputElement.value = this._displayValue;
146
+ this._inputElement.focus();
118
147
  this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.SEARCH));
119
148
  this.dispatchEvent(new UUIComboboxEvent(UUIComboboxEvent.CHANGE));
120
- };
121
- this._renderInput = () => {
149
+ });
150
+ __privateAdd(this, _renderInput, () => {
122
151
  return html` <uui-input
123
152
  slot="trigger"
124
153
  id="combobox-input"
@@ -127,45 +156,44 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
127
156
  .value=${this._displayValue}
128
157
  autocomplete="off"
129
158
  .disabled=${this.disabled}
130
- @click=${this._open}
131
- @input=${this._onInput}
132
- @keydown=${this._onKeyDown}>
159
+ popovertarget="combobox-popover"
160
+ @click=${__privateGet(this, _onToggle)}
161
+ @input=${__privateGet(this, _onInput)}
162
+ @keydown=${__privateGet(this, _onKeyDown)}>
133
163
  <slot name="input-prepend" slot="prepend"></slot>
134
- ${this.disabled ? "" : this._renderClearButton()} ${this._renderCaret()}
164
+ ${this.disabled ? "" : __privateGet(this, _renderClearButton).call(this)}
165
+ <div id="expand-symbol-wrapper" slot="append">
166
+ <uui-symbol-expand .open=${this._isOpen}></uui-symbol-expand>
167
+ </div>
135
168
  <slot name="input-append" slot="append"></slot>
136
169
  </uui-input>`;
137
- };
138
- this._renderCaret = () => {
139
- return html`<svg id="caret" slot="append" viewBox="0 0 512 512">
140
- <path d="M 255.125 400.35 L 88.193 188.765 H 422.055 Z"></path>
141
- </svg>`;
142
- };
143
- this._renderClearButton = () => {
170
+ });
171
+ __privateAdd(this, _renderClearButton, () => {
144
172
  return this.value || this.search ? html`<uui-button
145
173
  id="clear-button"
146
- @click=${this._onClear}
147
- @keydown=${this._onClear}
174
+ @click=${__privateGet(this, _onClear)}
175
+ @keydown=${__privateGet(this, _onClear)}
148
176
  label="clear"
149
177
  slot="append"
150
178
  compact
151
179
  style="height: 100%;">
152
180
  <uui-icon name="remove" .fallback=${iconRemove.strings[0]}></uui-icon>
153
181
  </uui-button>` : "";
154
- };
155
- this._renderDropdown = () => {
156
- return html`<div id="dropdown" slot="popover">
182
+ });
183
+ __privateAdd(this, _renderDropdown, () => {
184
+ return html`<div id="dropdown">
157
185
  <uui-scroll-container tabindex="-1" id="scroll-container">
158
186
  <slot></slot>
159
187
  </uui-scroll-container>
160
188
  </div>`;
161
- };
189
+ });
162
190
  }
163
191
  get value() {
164
192
  return this._value;
165
193
  }
166
194
  set value(newValue) {
167
195
  if (typeof newValue === "string") {
168
- this._updateValue(newValue);
196
+ __privateMethod(this, _updateValue, updateValue_fn).call(this, newValue);
169
197
  }
170
198
  super.value = newValue;
171
199
  }
@@ -179,75 +207,112 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
179
207
  this._search = newValue;
180
208
  this.requestUpdate("search", oldValue);
181
209
  }
210
+ get open() {
211
+ return this._isOpen;
212
+ }
213
+ set open(newValue) {
214
+ const oldValue = newValue;
215
+ this._isOpen = newValue;
216
+ const popover = this._comboboxPopoverElement;
217
+ if (popover) {
218
+ if (newValue) {
219
+ const width = this._inputElement.offsetWidth;
220
+ popover.style.setProperty("--popover-width", `${width}px`);
221
+ popover.showPopover();
222
+ } else {
223
+ popover.hidePopover();
224
+ }
225
+ }
226
+ this.requestUpdate("open", oldValue);
227
+ }
182
228
  connectedCallback() {
183
229
  super.connectedCallback();
184
- this.addEventListener("blur", this._onBlur);
185
- this.addEventListener("mousedown", this._onMouseDown);
186
- this.phoneMediaQuery = window.matchMedia("(max-width: 600px)");
187
- this._onPhoneChange();
188
- this.phoneMediaQuery.addEventListener("change", this._onPhoneChange);
230
+ this.addEventListener("blur", __privateGet(this, _onBlur));
231
+ this.addEventListener("mousedown", __privateGet(this, _onMouseDown));
232
+ __privateSet(this, _phoneMediaQuery, window.matchMedia("(max-width: 600px)"));
233
+ __privateGet(this, _onPhoneChange).call(this);
234
+ __privateGet(this, _phoneMediaQuery).addEventListener("change", __privateGet(this, _onPhoneChange));
189
235
  demandCustomElement(this, "uui-icon");
190
236
  demandCustomElement(this, "uui-input");
191
237
  demandCustomElement(this, "uui-button");
192
238
  demandCustomElement(this, "uui-combobox-list");
193
239
  demandCustomElement(this, "uui-scroll-container");
194
- demandCustomElement(this, "uui-popover");
240
+ demandCustomElement(this, "uui-popover-container");
241
+ demandCustomElement(this, "uui-symbol-expand");
195
242
  }
196
243
  disconnectedCallback() {
197
244
  super.disconnectedCallback();
198
- this.removeEventListener("blur", this._onBlur);
199
- this.removeEventListener("mousedown", this._onMouseDown);
200
- this.phoneMediaQuery.removeEventListener("change", this._onPhoneChange);
245
+ this.removeEventListener("blur", __privateGet(this, _onBlur));
246
+ this.removeEventListener("mousedown", __privateGet(this, _onMouseDown));
247
+ __privateGet(this, _phoneMediaQuery).removeEventListener("change", __privateGet(this, _onPhoneChange));
201
248
  }
202
249
  async firstUpdated() {
203
250
  var _a;
204
251
  const list = (_a = this._comboboxListElements) == null ? void 0 : _a[0];
205
252
  if (list) {
206
- this._comboboxList = list;
207
- this._comboboxList.for = this;
208
- this._comboboxList.addEventListener(
253
+ __privateSet(this, _comboboxList, list);
254
+ __privateGet(this, _comboboxList).for = this;
255
+ __privateGet(this, _comboboxList).addEventListener(
209
256
  UUIComboboxListEvent.CHANGE,
210
- this._onChange
257
+ __privateGet(this, _onChange)
211
258
  );
212
- this._comboboxList.addEventListener(
259
+ __privateGet(this, _comboboxList).addEventListener(
213
260
  UUIComboboxListEvent.INNER_SLOT_CHANGE,
214
- this._onSlotChange
261
+ __privateGet(this, _onSlotChange)
215
262
  );
216
263
  await this.updateComplete;
217
- this._updateValue(this.value);
218
- }
219
- }
220
- _updateValue(value) {
221
- if (this._comboboxList) {
222
- this._comboboxList.value = value;
223
- requestAnimationFrame(
224
- () => this._displayValue = this._comboboxList.displayValue || ""
225
- );
264
+ __privateMethod(this, _updateValue, updateValue_fn).call(this, this.value);
226
265
  }
227
266
  }
228
267
  getFormElement() {
229
- return this._input;
268
+ return this._inputElement;
230
269
  }
231
270
  render() {
232
271
  if (this._isPhone && this.open) {
233
272
  return html` <div id="phone-wrapper">
234
- <uui-button label="close" look="primary" @click=${this._onClose}>
273
+ <uui-button label="close" look="primary" @click=${__privateGet(this, _onClose)}>
235
274
  ${this.closeLabel}
236
275
  </uui-button>
237
- ${this._renderInput()} ${this._renderDropdown()}
276
+ ${__privateGet(this, _renderInput).call(this)} ${__privateGet(this, _renderDropdown).call(this)}
238
277
  </div>`;
239
278
  } else {
240
279
  return html`
241
- <uui-popover
242
- .open=${this.open}
243
- .margin=${-1}
244
- @close=${() => this._onClose()}>
245
- ${this._renderInput()} ${this._renderDropdown()}
246
- </uui-popover>
280
+ ${__privateGet(this, _renderInput).call(this)}
281
+ <uui-popover-container
282
+ id="combobox-popover"
283
+ popover="manual"
284
+ placement="bottom-end">
285
+ ${__privateGet(this, _renderDropdown).call(this)}
286
+ </uui-popover-container>
247
287
  `;
248
288
  }
249
289
  }
250
290
  };
291
+ _comboboxList = new WeakMap();
292
+ _phoneMediaQuery = new WeakMap();
293
+ _onPhoneChange = new WeakMap();
294
+ _updateValue = new WeakSet();
295
+ updateValue_fn = function(value) {
296
+ if (__privateGet(this, _comboboxList)) {
297
+ __privateGet(this, _comboboxList).value = value;
298
+ requestAnimationFrame(
299
+ () => this._displayValue = __privateGet(this, _comboboxList).displayValue || ""
300
+ );
301
+ }
302
+ };
303
+ _onMouseDown = new WeakMap();
304
+ _onBlur = new WeakMap();
305
+ _onInput = new WeakMap();
306
+ _onSlotChange = new WeakMap();
307
+ _onChange = new WeakMap();
308
+ _onToggle = new WeakMap();
309
+ _onOpen = new WeakMap();
310
+ _onClose = new WeakMap();
311
+ _onKeyDown = new WeakMap();
312
+ _onClear = new WeakMap();
313
+ _renderInput = new WeakMap();
314
+ _renderClearButton = new WeakMap();
315
+ _renderDropdown = new WeakMap();
251
316
  UUIComboboxElement.styles = [
252
317
  css`
253
318
  :host {
@@ -259,11 +324,21 @@ UUIComboboxElement.styles = [
259
324
  border-radius: var(--uui-size-1,3px);
260
325
  }
261
326
 
327
+ #combobox-popover {
328
+ width: var(--uui-dropdown-width, var(--popover-width, inherit));
329
+ }
330
+
262
331
  #scroll-container {
263
332
  overflow-y: auto;
264
333
  width: 100%;
265
334
  max-height: var(--uui-combobox-popover-max-height, 500px);
266
335
  }
336
+ #expand-symbol-wrapper {
337
+ height: 100%;
338
+ padding-right: var(--uui-size-space-3,9px);
339
+ display: flex;
340
+ justify-content: center;
341
+ }
267
342
 
268
343
  #dropdown {
269
344
  overflow: hidden;
@@ -280,14 +355,6 @@ UUIComboboxElement.styles = [
280
355
  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));
281
356
  }
282
357
 
283
- #caret {
284
- margin-right: var(--uui-size-3, 9px);
285
- display: flex;
286
- width: 1.15em;
287
- flex-shrink: 0;
288
- margin-top: -1px;
289
- }
290
-
291
358
  :host([disabled]) #caret {
292
359
  fill: var(--uui-color-disabled-contrast,#c4c4c4);
293
360
  }
@@ -327,7 +394,7 @@ __decorateClass([
327
394
  ], UUIComboboxElement.prototype, "search", 1);
328
395
  __decorateClass([
329
396
  property({ type: Boolean })
330
- ], UUIComboboxElement.prototype, "open", 2);
397
+ ], UUIComboboxElement.prototype, "open", 1);
331
398
  __decorateClass([
332
399
  property({ type: String })
333
400
  ], UUIComboboxElement.prototype, "closeLabel", 2);
@@ -336,7 +403,10 @@ __decorateClass([
336
403
  ], UUIComboboxElement.prototype, "disabled", 2);
337
404
  __decorateClass([
338
405
  query("#combobox-input")
339
- ], UUIComboboxElement.prototype, "_input", 2);
406
+ ], UUIComboboxElement.prototype, "_inputElement", 2);
407
+ __decorateClass([
408
+ query("#combobox-popover")
409
+ ], UUIComboboxElement.prototype, "_comboboxPopoverElement", 2);
340
410
  __decorateClass([
341
411
  queryAssignedElements({
342
412
  flatten: true,
@@ -352,6 +422,9 @@ __decorateClass([
352
422
  __decorateClass([
353
423
  state()
354
424
  ], UUIComboboxElement.prototype, "_isPhone", 2);
425
+ __decorateClass([
426
+ state()
427
+ ], UUIComboboxElement.prototype, "_isOpen", 2);
355
428
  UUIComboboxElement = __decorateClass([
356
429
  defineElement("uui-combobox")
357
430
  ], UUIComboboxElement);
@@ -7,9 +7,11 @@ declare const UUIComboboxElement_base: (new (...args: any[]) => import("@umbraco
7
7
  * @slot - for uui-combobox-list-options
8
8
  * @slot input-prepend - prepend for the uui-input
9
9
  * @slot input-append - append for the uui-input
10
+ * @cssprop --uui-dropdown-width - overwrite the dropdown width
10
11
  * @description - Filterable combobox
11
12
  */
12
13
  export declare class UUIComboboxElement extends UUIComboboxElement_base {
14
+ #private;
13
15
  get value(): FormDataEntryValue | FormData;
14
16
  set value(newValue: FormDataEntryValue | FormData);
15
17
  /**
@@ -26,7 +28,8 @@ export declare class UUIComboboxElement extends UUIComboboxElement_base {
26
28
  * @attr
27
29
  * @default false
28
30
  */
29
- open: boolean;
31
+ get open(): boolean;
32
+ set open(newValue: boolean);
30
33
  /**
31
34
  * Specifies the button label for the close button in mobile mode
32
35
  * @type { string }
@@ -41,32 +44,17 @@ export declare class UUIComboboxElement extends UUIComboboxElement_base {
41
44
  * @default false
42
45
  */
43
46
  disabled: boolean;
44
- private _input;
47
+ private _inputElement;
48
+ private _comboboxPopoverElement?;
45
49
  private _comboboxListElements?;
46
- private _comboboxList;
47
- private phoneMediaQuery;
48
50
  private _displayValue;
49
51
  private _search;
50
52
  private _isPhone;
53
+ private _isOpen;
51
54
  connectedCallback(): void;
52
55
  disconnectedCallback(): void;
53
56
  protected firstUpdated(): Promise<void>;
54
- private _onPhoneChange;
55
- private _updateValue;
56
57
  protected getFormElement(): HTMLElement | undefined;
57
- private _onMouseDown;
58
- private _onBlur;
59
- private _onInput;
60
- private _onSlotChange;
61
- private _onChange;
62
- private _open;
63
- private _onClose;
64
- private _onKeyDown;
65
- private _onClear;
66
- private _renderInput;
67
- private _renderCaret;
68
- private _renderClearButton;
69
- private _renderDropdown;
70
58
  render(): import("lit-html").TemplateResult<1>;
71
59
  static styles: import("lit").CSSResult[];
72
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-ui/uui-combobox",
3
- "version": "1.6.0-rc.1",
3
+ "version": "1.6.0-rc.2",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Umbraco",
@@ -30,11 +30,13 @@
30
30
  "custom-elements.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@umbraco-ui/uui-base": "1.6.0-rc.1",
34
- "@umbraco-ui/uui-button": "1.6.0-rc.1",
35
- "@umbraco-ui/uui-combobox-list": "1.6.0-rc.1",
36
- "@umbraco-ui/uui-icon": "1.6.0-rc.1",
37
- "@umbraco-ui/uui-scroll-container": "1.6.0-rc.1"
33
+ "@umbraco-ui/uui-base": "1.6.0-rc.2",
34
+ "@umbraco-ui/uui-button": "1.6.0-rc.2",
35
+ "@umbraco-ui/uui-combobox-list": "1.6.0-rc.2",
36
+ "@umbraco-ui/uui-icon": "1.6.0-rc.2",
37
+ "@umbraco-ui/uui-popover-container": "1.6.0-rc.2",
38
+ "@umbraco-ui/uui-scroll-container": "1.6.0-rc.2",
39
+ "@umbraco-ui/uui-symbol-expand": "1.6.0-rc.2"
38
40
  },
39
41
  "scripts": {
40
42
  "build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
@@ -45,5 +47,5 @@
45
47
  "access": "public"
46
48
  },
47
49
  "homepage": "https://uui.umbraco.com/?path=/story/uui-combobox",
48
- "gitHead": "9708ccbac569560b716431080c782c5531c66ea5"
50
+ "gitHead": "5d4eefce4744802ab5bc40055b1a3136f0afc520"
49
51
  }