@@ -2,6 +2,7 @@ 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
4
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js" ;
5
+ import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
5
6
import getEffectiveAriaLabelText from "@ui5/webcomponents-base/dist/util/getEffectiveAriaLabelText.js" ;
6
7
import "@ui5/webcomponents-icons/dist/icons/slim-arrow-down.js" ;
7
8
import "@ui5/webcomponents-icons/dist/icons/decline.js" ;
@@ -20,6 +21,7 @@ import {
20
21
VALUE_STATE_SUCCESS ,
21
22
VALUE_STATE_ERROR ,
22
23
VALUE_STATE_WARNING ,
24
+ VALUE_STATE_INFORMATION ,
23
25
INPUT_SUGGESTIONS_TITLE ,
24
26
ICON_ACCESSIBLE_NAME ,
25
27
} from "./generated/i18n/i18n-defaults.js" ;
@@ -32,9 +34,11 @@ import ComboBoxPopoverTemplate from "./generated/templates/ComboBoxPopoverTempla
32
34
import ComboBoxCss from "./generated/themes/ComboBox.css.js" ;
33
35
import ComboBoxPopoverCss from "./generated/themes/ComboBoxPopover.css.js" ;
34
36
import ResponsivePopoverCommonCss from "./generated/themes/ResponsivePopoverCommon.css.js" ;
37
+ import ValueStateMessageCss from "./generated/themes/ValueStateMessage.css.js" ;
35
38
36
39
import ComboBoxItem from "./ComboBoxItem.js" ;
37
40
import Icon from "./Icon.js" ;
41
+ import Popover from "./Popover.js" ;
38
42
import ResponsivePopover from "./ResponsivePopover.js" ;
39
43
import List from "./List.js" ;
40
44
import BusyIndicator from "./BusyIndicator.js" ;
@@ -218,6 +222,12 @@ const metadata = {
218
222
_filteredItems : {
219
223
type : Object ,
220
224
} ,
225
+
226
+ _listWidth : {
227
+ type : Integer ,
228
+ defaultValue : 0 ,
229
+ noAttribute : true ,
230
+ } ,
221
231
} ,
222
232
managedSlots : true ,
223
233
slots : /** @lends sap.ui.webcomponents.main.ComboBox.prototype */ {
@@ -240,6 +250,23 @@ const metadata = {
240
250
type : HTMLElement ,
241
251
listenFor : { include : [ "*" ] } ,
242
252
} ,
253
+
254
+ /**
255
+ * Defines the value state message that will be displayed as pop up under the <code>ui5-combobox</code>.
256
+ * <br><br>
257
+ *
258
+ * <b>Note:</b> If not specified, a default text (in the respective language) will be displayed.
259
+ * <br>
260
+ * <b>Note:</b> The <code>valueStateMessage</code> would be displayed,
261
+ * when the <code>ui5-select</code> is in <code>Information</code>, <code>Warning</code> or <code>Error</code> value state.
262
+ * @type {HTMLElement[] }
263
+ * @since 1.0.0-rc.9
264
+ * @slot
265
+ * @public
266
+ */
267
+ valueStateMessage : {
268
+ type : HTMLElement ,
269
+ } ,
243
270
} ,
244
271
events : /** @lends sap.ui.webcomponents.main.ComboBox.prototype */ {
245
272
/**
@@ -314,7 +341,7 @@ class ComboBox extends UI5Element {
314
341
}
315
342
316
343
static get staticAreaStyles ( ) {
317
- return [ ResponsivePopoverCommonCss , ComboBoxPopoverCss ] ;
344
+ return [ ResponsivePopoverCommonCss , ValueStateMessageCss , ComboBoxPopoverCss ] ;
318
345
}
319
346
320
347
static get template ( ) {
@@ -379,6 +406,9 @@ class ComboBox extends UI5Element {
379
406
}
380
407
381
408
this . _itemFocused = false ;
409
+
410
+ this . toggleValueStatePopover ( this . shouldOpenValueStateMessagePopover ) ;
411
+ this . storeResponsivePopoverWidth ( ) ;
382
412
}
383
413
384
414
shouldClosePopover ( ) {
@@ -425,6 +455,35 @@ class ComboBox extends UI5Element {
425
455
}
426
456
}
427
457
458
+ storeResponsivePopoverWidth ( ) {
459
+ if ( this . open && ! this . _listWidth ) {
460
+ this . _listWidth = this . responsivePopover . offsetWidth ;
461
+ }
462
+ }
463
+
464
+ toggleValueStatePopover ( open ) {
465
+ if ( open ) {
466
+ this . openValueStatePopover ( ) ;
467
+ } else {
468
+ this . closeValueStatePopover ( ) ;
469
+ }
470
+ }
471
+
472
+ async openValueStatePopover ( ) {
473
+ this . popover = await this . _getPopover ( ) ;
474
+ this . popover && this . popover . openBy ( this ) ;
475
+ }
476
+
477
+ async closeValueStatePopover ( ) {
478
+ this . popover = await this . _getPopover ( ) ;
479
+ this . popover && this . popover . close ( ) ;
480
+ }
481
+
482
+ async _getPopover ( ) {
483
+ const staticAreaItem = await this . getStaticAreaItemDomRef ( ) ;
484
+ return staticAreaItem . querySelector ( ".ui5-valuestatemessage-popover" ) ;
485
+ }
486
+
428
487
_resetFilter ( ) {
429
488
this . _filteredItems = this . _filterItems ( "" ) ;
430
489
this . _selectMatchingItem ( ) ;
@@ -627,10 +686,18 @@ class ComboBox extends UI5Element {
627
686
return this . valueState !== ValueState . None ;
628
687
}
629
688
689
+ get hasValueStateText ( ) {
690
+ return this . hasValueState && this . valueState !== ValueState . Success ;
691
+ }
692
+
630
693
get valueStateText ( ) {
631
694
return this . valueStateTextMappings [ this . valueState ] ;
632
695
}
633
696
697
+ get valueStateMessageText ( ) {
698
+ return this . getSlottedNodes ( "valueStateMessage" ) . map ( el => el . cloneNode ( true ) ) ;
699
+ }
700
+
634
701
get valueStateTextId ( ) {
635
702
return this . hasValueState ? `${ this . _id } -valueStateDesc` : undefined ;
636
703
}
@@ -640,13 +707,27 @@ class ComboBox extends UI5Element {
640
707
"Success" : this . i18nBundle . getText ( VALUE_STATE_SUCCESS ) ,
641
708
"Error" : this . i18nBundle . getText ( VALUE_STATE_ERROR ) ,
642
709
"Warning" : this . i18nBundle . getText ( VALUE_STATE_WARNING ) ,
710
+ "Information" : this . i18nBundle . getText ( VALUE_STATE_INFORMATION ) ,
643
711
} ;
644
712
}
645
713
714
+ get shouldOpenValueStateMessagePopover ( ) {
715
+ return this . focused && this . hasValueStateText && ! this . _iconPressed
716
+ && ! this . open && ! this . _isPhone ;
717
+ }
718
+
719
+ get shouldDisplayDefaultValueStateMessage ( ) {
720
+ return ! this . valueStateMessage . length && this . hasValueStateText ;
721
+ }
722
+
646
723
get open ( ) {
647
724
return this . responsivePopover ? this . responsivePopover . opened : false ;
648
725
}
649
726
727
+ get _isPhone ( ) {
728
+ return isPhone ( ) ;
729
+ }
730
+
650
731
get itemTabIndex ( ) {
651
732
return undefined ;
652
733
}
@@ -655,10 +736,36 @@ class ComboBox extends UI5Element {
655
736
return getEffectiveAriaLabelText ( this ) ;
656
737
}
657
738
739
+ get styles ( ) {
740
+ return {
741
+ popoverHeader : {
742
+ "width" : `${ this . offsetWidth } px` ,
743
+ } ,
744
+ suggestionPopoverHeader : {
745
+ "display" : this . _listWidth === 0 ? "none" : "inline-block" ,
746
+ "width" : `${ this . _listWidth } px` ,
747
+ "padding" : "0.5625rem 1rem" ,
748
+ } ,
749
+ } ;
750
+ }
751
+
752
+ get classes ( ) {
753
+ return {
754
+ popoverValueState : {
755
+ "ui5-valuestatemessage-root" : true ,
756
+ "ui5-valuestatemessage--success" : this . valueState === ValueState . Success ,
757
+ "ui5-valuestatemessage--error" : this . valueState === ValueState . Error ,
758
+ "ui5-valuestatemessage--warning" : this . valueState === ValueState . Warning ,
759
+ "ui5-valuestatemessage--information" : this . valueState === ValueState . Information ,
760
+ } ,
761
+ } ;
762
+ }
763
+
658
764
static async onDefine ( ) {
659
765
await Promise . all ( [
660
766
ComboBoxItem . define ( ) ,
661
767
Icon . define ( ) ,
768
+ Popover . define ( ) ,
662
769
ResponsivePopover . define ( ) ,
663
770
List . define ( ) ,
664
771
BusyIndicator . define ( ) ,
0 commit comments