1
1
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
2
2
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
3
3
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
4
+ import { isPhone } from "@ui5/webcomponents-base/dist/Device.js" ;
4
5
import "@ui5/webcomponents-icons/dist/icons/slim-arrow-down.js" ;
6
+ import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
5
7
import { isBackSpace , isDelete , isShow } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js" ;
6
8
import * as Filters from "./ComboBoxFilters.js" ;
7
9
8
- // Styles
10
+ import {
11
+ INPUT_SUGGESTIONS_TITLE ,
12
+ } from "./generated/i18n/i18n-defaults.js" ;
13
+
14
+ // Templates
9
15
import ComboBoxTemplate from "./generated/templates/ComboBoxTemplate.lit.js" ;
10
16
import ComboBoxPopoverTemplate from "./generated/templates/ComboBoxPopoverTemplate.lit.js" ;
17
+
18
+ // Styles
11
19
import ComboBoxCss from "./generated/themes/ComboBox.css.js" ;
12
20
import ComboBoxPopoverCss from "./generated/themes/ComboBoxPopover.css.js" ;
21
+ import ResponsivePopoverCommonCss from "./generated/themes/ResponsivePopoverCommon.css.js" ;
22
+
13
23
import ComboBoxItem from "./ComboBoxItem.js" ;
14
24
import Icon from "./Icon.js" ;
15
- import Popover from "./Popover .js" ;
25
+ import ResponsivePopover from "./ResponsivePopover .js" ;
16
26
import List from "./List.js" ;
17
27
import BusyIndicator from "./BusyIndicator.js" ;
18
28
import StandardListItem from "./StandardListItem.js" ;
@@ -249,6 +259,10 @@ class ComboBox extends UI5Element {
249
259
return ComboBoxCss ;
250
260
}
251
261
262
+ static get staticAreaStyles ( ) {
263
+ return [ ComboBoxPopoverCss , ResponsivePopoverCommonCss ] ;
264
+ }
265
+
252
266
static get template ( ) {
253
267
return ComboBoxTemplate ;
254
268
}
@@ -257,15 +271,12 @@ class ComboBox extends UI5Element {
257
271
return ComboBoxPopoverTemplate ;
258
272
}
259
273
260
- static get staticAreaStyles ( ) {
261
- return ComboBoxPopoverCss ;
262
- }
263
-
264
274
constructor ( props ) {
265
275
super ( props ) ;
266
276
267
277
this . _filteredItems = [ ] ;
268
278
this . _initialRendering = true ;
279
+ this . i18nBundle = getI18nBundle ( "@ui5/webcomponents" ) ;
269
280
}
270
281
271
282
onBeforeRendering ( ) {
@@ -288,7 +299,10 @@ class ComboBox extends UI5Element {
288
299
}
289
300
290
301
onAfterRendering ( ) {
291
- this . _width = this . getBoundingClientRect ( ) . width ;
302
+ if ( isPhone ( ) && this . _respPopover . opened ) {
303
+ // Set initial focus to the native input
304
+ this . inner . focus ( ) ;
305
+ }
292
306
}
293
307
294
308
_focusin ( event ) {
@@ -311,13 +325,18 @@ class ComboBox extends UI5Element {
311
325
312
326
_afterClosePopover ( ) {
313
327
this . _iconPressed = false ;
328
+
329
+ // close device's keyboard and prevent further typing
330
+ if ( isPhone ( ) ) {
331
+ this . blur ( ) ;
332
+ }
314
333
}
315
334
316
- _togglePopover ( ) {
317
- if ( this . popover . opened ) {
318
- this . popover . close ( ) ;
335
+ _toggleRespPopover ( ) {
336
+ if ( this . _respPopover . opened ) {
337
+ this . _respPopover . close ( ) ;
319
338
} else {
320
- this . popover . openBy ( this ) ;
339
+ this . _respPopover . open ( this ) ;
321
340
}
322
341
}
323
342
@@ -330,7 +349,7 @@ class ComboBox extends UI5Element {
330
349
this . inner . focus ( ) ;
331
350
this . _resetFilter ( ) ;
332
351
333
- this . _togglePopover ( ) ;
352
+ this . _toggleRespPopover ( ) ;
334
353
}
335
354
336
355
_input ( event ) {
@@ -344,7 +363,7 @@ class ComboBox extends UI5Element {
344
363
this . filterValue = value ;
345
364
this . fireEvent ( "input" ) ;
346
365
347
- this . popover . openBy ( this ) ;
366
+ this . _respPopover . open ( this ) ;
348
367
}
349
368
350
369
_startsWithMatchingItems ( str ) {
@@ -357,10 +376,20 @@ class ComboBox extends UI5Element {
357
376
if ( isShow ( event ) && ! this . readonly && ! this . disabled ) {
358
377
event . preventDefault ( ) ;
359
378
this . _resetFilter ( ) ;
360
- this . _togglePopover ( ) ;
379
+ this . _toggleRespPopover ( ) ;
380
+ }
381
+ }
382
+
383
+ _click ( event ) {
384
+ if ( isPhone ( ) && ! this . readonly ) {
385
+ this . _respPopover . open ( this ) ;
361
386
}
362
387
}
363
388
389
+ _closeRespPopover ( ) {
390
+ this . _respPopover . close ( ) ;
391
+ }
392
+
364
393
_filterItems ( str ) {
365
394
return ( Filters [ this . filter ] || Filters . StartsWithPerTerm ) ( str , this . items ) ;
366
395
}
@@ -402,6 +431,7 @@ class ComboBox extends UI5Element {
402
431
const listItem = event . detail . item ;
403
432
404
433
this . _tempValue = listItem . mappedItem . text ;
434
+ this . filterValue = this . _tempValue ;
405
435
406
436
this . _filteredItems . map ( item => {
407
437
item . selected = ( item === listItem . mappedItem ) ;
@@ -410,15 +440,7 @@ class ComboBox extends UI5Element {
410
440
} ) ;
411
441
412
442
this . _inputChange ( ) ;
413
- this . popover . close ( ) ;
414
- }
415
-
416
- get styles ( ) {
417
- return {
418
- popover : {
419
- "min-width" : `${ this . _width } px` ,
420
- } ,
421
- } ;
443
+ this . _respPopover . close ( ) ;
422
444
}
423
445
424
446
get _filteredItems ( ) {
@@ -427,12 +449,16 @@ class ComboBox extends UI5Element {
427
449
} ) ;
428
450
}
429
451
452
+ get _headerTitleText ( ) {
453
+ return this . i18nBundle . getText ( INPUT_SUGGESTIONS_TITLE ) ;
454
+ }
455
+
430
456
get inner ( ) {
431
- return this . shadowRoot . querySelector ( "[inner-input]" ) ;
457
+ return isPhone ( ) ? this . _respPopover . querySelector ( ".ui5-input-inner-phone" ) : this . shadowRoot . querySelector ( "[inner-input]" ) ;
432
458
}
433
459
434
- get popover ( ) {
435
- return this . getStaticAreaItemDomRef ( ) . querySelector ( "ui5-popover" ) ;
460
+ get _respPopover ( ) {
461
+ return this . getStaticAreaItemDomRef ( ) . querySelector ( "ui5-responsive- popover" ) ;
436
462
}
437
463
438
464
get editable ( ) {
@@ -443,7 +469,7 @@ class ComboBox extends UI5Element {
443
469
await Promise . all ( [
444
470
ComboBoxItem . define ( ) ,
445
471
Icon . define ( ) ,
446
- Popover . define ( ) ,
472
+ ResponsivePopover . define ( ) ,
447
473
List . define ( ) ,
448
474
BusyIndicator . define ( ) ,
449
475
StandardListItem . define ( ) ,
0 commit comments