@umbraco-ui/uui-combobox 1.0.0 → 1.1.1

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.
@@ -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
@@ -1,11 +1,11 @@
1
+ import { FormControlMixin } from '@umbraco-ui/uui-base/lib/mixins';
1
2
  import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
2
3
  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
4
  import { UUIComboboxListEvent } from '@umbraco-ui/uui-combobox-list/lib';
7
- import { FormControlMixin } from '@umbraco-ui/uui-base/lib/mixins';
8
5
  import { iconRemove } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs';
6
+ import { LitElement, html, css } from 'lit';
7
+ import { property, query, queryAssignedElements, state } from 'lit/decorators.js';
8
+ import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
9
9
 
10
10
  class UUIComboboxEvent extends UUIEvent {
11
11
  }
@@ -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;
@@ -152,16 +157,21 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
152
157
  super.connectedCallback();
153
158
  this.addEventListener("blur", this._onBlur);
154
159
  this.addEventListener("mousedown", this._onMouseDown);
160
+ this.phoneMediaQuery = window.matchMedia("(max-width: 600px)");
161
+ this._onPhoneChange();
162
+ this.phoneMediaQuery.addEventListener("change", this._onPhoneChange);
155
163
  demandCustomElement(this, "uui-icon");
156
164
  demandCustomElement(this, "uui-input");
157
165
  demandCustomElement(this, "uui-button");
158
166
  demandCustomElement(this, "uui-combobox-list");
159
167
  demandCustomElement(this, "uui-scroll-container");
168
+ demandCustomElement(this, "uui-popover");
160
169
  }
161
170
  disconnectedCallback() {
162
171
  super.disconnectedCallback();
163
172
  this.removeEventListener("blur", this._onBlur);
164
173
  this.removeEventListener("mousedown", this._onMouseDown);
174
+ this.phoneMediaQuery.removeEventListener("change", this._onPhoneChange);
165
175
  }
166
176
  async firstUpdated() {
167
177
  var _a;
@@ -190,20 +200,28 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
190
200
  return this._input;
191
201
  }
192
202
  render() {
193
- return html`
194
- <uui-popover
195
- .open=${this.open}
196
- .margin=${-1}
197
- @close=${() => this._onClose()}>
203
+ if (this._isPhone && this.open) {
204
+ return html` <div id="phone-wrapper">
205
+ <uui-button label="close" look="primary" @click=${this._onClose}>
206
+ ${this.closeLabel}
207
+ </uui-button>
198
208
  ${this._renderInput()} ${this._renderDropdown()}
199
- </uui-popover>
200
- `;
209
+ </div>`;
210
+ } else {
211
+ return html`
212
+ <uui-popover
213
+ .open=${this.open}
214
+ .margin=${-1}
215
+ @close=${() => this._onClose()}>
216
+ ${this._renderInput()} ${this._renderDropdown()}
217
+ </uui-popover>
218
+ `;
219
+ }
201
220
  }
202
221
  };
203
222
  UUIComboboxElement.styles = [
204
223
  css`
205
224
  :host {
206
- position: relative;
207
225
  display: inline-block;
208
226
  }
209
227
 
@@ -213,8 +231,9 @@ UUIComboboxElement.styles = [
213
231
  }
214
232
 
215
233
  #scroll-container {
216
- max-height: var(--uui-combobox-popover-max-height, 500px);
217
234
  overflow-y: auto;
235
+ width: 100%;
236
+ max-height: var(--uui-combobox-popover-max-height, 500px);
218
237
  }
219
238
 
220
239
  #dropdown {
@@ -239,6 +258,32 @@ UUIComboboxElement.styles = [
239
258
  flex-shrink: 0;
240
259
  margin-top: -1px;
241
260
  }
261
+
262
+ #phone-wrapper {
263
+ position: fixed;
264
+ inset: 0;
265
+ display: flex;
266
+ flex-direction: column;
267
+ z-index: 1;
268
+ font-size: 1.1em;
269
+ }
270
+
271
+ #phone-wrapper #dropdown {
272
+ display: flex;
273
+ }
274
+
275
+ #phone-wrapper #combobox-input {
276
+ height: var(--uui-size-16,48px);
277
+ }
278
+
279
+ #phone-wrapper > uui-button {
280
+ height: var(--uui-size-14,42px);
281
+ width: 100%;
282
+ }
283
+
284
+ #phone-wrapper #scroll-container {
285
+ max-height: unset;
286
+ }
242
287
  `
243
288
  ];
244
289
  __decorateClass([
@@ -247,6 +292,9 @@ __decorateClass([
247
292
  __decorateClass([
248
293
  property({ type: Boolean })
249
294
  ], UUIComboboxElement.prototype, "open", 2);
295
+ __decorateClass([
296
+ property({ type: String })
297
+ ], UUIComboboxElement.prototype, "closeLabel", 2);
250
298
  __decorateClass([
251
299
  query("#combobox-input")
252
300
  ], UUIComboboxElement.prototype, "_input", 2);
@@ -262,6 +310,9 @@ __decorateClass([
262
310
  __decorateClass([
263
311
  state()
264
312
  ], UUIComboboxElement.prototype, "_search", 2);
313
+ __decorateClass([
314
+ state()
315
+ ], UUIComboboxElement.prototype, "_isPhone", 2);
265
316
  UUIComboboxElement = __decorateClass([
266
317
  defineElement("uui-combobox")
267
318
  ], UUIComboboxElement);
@@ -28,14 +28,24 @@ 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;
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.1.1",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Umbraco",
@@ -45,5 +45,5 @@
45
45
  "access": "public"
46
46
  },
47
47
  "homepage": "https://uui.umbraco.com/?path=/story/uui-combobox",
48
- "gitHead": "ffb9cef00262b9f36177adcca9675b4893c0045e"
48
+ "gitHead": "be41090c074658278069302f78f668ad362521fe"
49
49
  }