@umbraco-ui/uui-combobox 1.1.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
@@ -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,6 +157,9 @@ 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");
@@ -163,6 +171,7 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
163
171
  super.disconnectedCallback();
164
172
  this.removeEventListener("blur", this._onBlur);
165
173
  this.removeEventListener("mousedown", this._onMouseDown);
174
+ this.phoneMediaQuery.removeEventListener("change", this._onPhoneChange);
166
175
  }
167
176
  async firstUpdated() {
168
177
  var _a;
@@ -191,20 +200,28 @@ let UUIComboboxElement = class extends FormControlMixin(LitElement) {
191
200
  return this._input;
192
201
  }
193
202
  render() {
194
- return html`
195
- <uui-popover
196
- .open=${this.open}
197
- .margin=${-1}
198
- @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>
199
208
  ${this._renderInput()} ${this._renderDropdown()}
200
- </uui-popover>
201
- `;
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
+ }
202
220
  }
203
221
  };
204
222
  UUIComboboxElement.styles = [
205
223
  css`
206
224
  :host {
207
- position: relative;
208
225
  display: inline-block;
209
226
  }
210
227
 
@@ -214,8 +231,9 @@ UUIComboboxElement.styles = [
214
231
  }
215
232
 
216
233
  #scroll-container {
217
- max-height: var(--uui-combobox-popover-max-height, 500px);
218
234
  overflow-y: auto;
235
+ width: 100%;
236
+ max-height: var(--uui-combobox-popover-max-height, 500px);
219
237
  }
220
238
 
221
239
  #dropdown {
@@ -240,6 +258,32 @@ UUIComboboxElement.styles = [
240
258
  flex-shrink: 0;
241
259
  margin-top: -1px;
242
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
+ }
243
287
  `
244
288
  ];
245
289
  __decorateClass([
@@ -248,6 +292,9 @@ __decorateClass([
248
292
  __decorateClass([
249
293
  property({ type: Boolean })
250
294
  ], UUIComboboxElement.prototype, "open", 2);
295
+ __decorateClass([
296
+ property({ type: String })
297
+ ], UUIComboboxElement.prototype, "closeLabel", 2);
251
298
  __decorateClass([
252
299
  query("#combobox-input")
253
300
  ], UUIComboboxElement.prototype, "_input", 2);
@@ -263,6 +310,9 @@ __decorateClass([
263
310
  __decorateClass([
264
311
  state()
265
312
  ], UUIComboboxElement.prototype, "_search", 2);
313
+ __decorateClass([
314
+ state()
315
+ ], UUIComboboxElement.prototype, "_isPhone", 2);
266
316
  UUIComboboxElement = __decorateClass([
267
317
  defineElement("uui-combobox")
268
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.1.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": "6bd054ecff37c2b7ddfe2beed0f83bf29c58501d"
48
+ "gitHead": "be41090c074658278069302f78f668ad362521fe"
49
49
  }