1
1
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
2
2
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
3
+ import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js" ;
3
4
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
4
5
import {
5
6
isShow ,
@@ -9,6 +10,7 @@ import {
9
10
isLeft ,
10
11
isRight ,
11
12
} from "@ui5/webcomponents-base/dist/Keys.js" ;
13
+ import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
12
14
import "@ui5/webcomponents-icons/dist/icons/slim-arrow-down.js" ;
13
15
import { isIE , isPhone } from "@ui5/webcomponents-base/dist/Device.js" ;
14
16
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
@@ -32,6 +34,7 @@ import {
32
34
TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS ,
33
35
INPUT_SUGGESTIONS_TITLE ,
34
36
ICON_ACCESSIBLE_NAME ,
37
+ MULTICOMBOBOX_DIALOG_OK_BUTTON ,
35
38
} from "./generated/i18n/i18n-defaults.js" ;
36
39
37
40
// Templates
@@ -41,6 +44,7 @@ import MultiComboBoxPopoverTemplate from "./generated/templates/MultiComboBoxPop
41
44
// Styles
42
45
import styles from "./generated/themes/MultiComboBox.css.js" ;
43
46
import ResponsivePopoverCommonCss from "./generated/themes/ResponsivePopoverCommon.css.js" ;
47
+ import ValueStateMessageCss from "./generated/themes/ValueStateMessage.css.js" ;
44
48
45
49
/**
46
50
* @public
@@ -82,6 +86,22 @@ const metadata = {
82
86
type : HTMLElement ,
83
87
} ,
84
88
89
+ /**
90
+ * Defines the value state message that will be displayed as pop up under the <code>ui5-multicombobox</code>.
91
+ * <br><br>
92
+ *
93
+ * <b>Note:</b> If not specified, a default text (in the respective language) will be displayed.
94
+ * <br>
95
+ * <b>Note:</b> The <code>valueStateMessage</code> would be displayed,
96
+ * when the <code>ui5-select</code> is in <code>Information</code>, <code>Warning</code> or <code>Error</code> value state.
97
+ * @type {HTMLElement[] }
98
+ * @since 1.0.0-rc.9
99
+ * @slot
100
+ * @public
101
+ */
102
+ valueStateMessage : {
103
+ type : HTMLElement ,
104
+ } ,
85
105
} ,
86
106
properties : /** @lends sap.ui.webcomponents.main.MultiComboBox.prototype */ {
87
107
/**
@@ -205,6 +225,22 @@ const metadata = {
205
225
_rootFocused : {
206
226
type : Boolean ,
207
227
} ,
228
+
229
+ _iconPressed : {
230
+ type : Boolean ,
231
+ noAttribute : true ,
232
+ } ,
233
+
234
+ _inputWidth : {
235
+ type : Integer ,
236
+ noAttribute : true ,
237
+ } ,
238
+
239
+ _listWidth : {
240
+ type : Integer ,
241
+ defaultValue : 0 ,
242
+ noAttribute : true ,
243
+ } ,
208
244
} ,
209
245
events : /** @lends sap.ui.webcomponents.main.MultiComboBox.prototype */ {
210
246
/**
@@ -319,7 +355,7 @@ class MultiComboBox extends UI5Element {
319
355
}
320
356
321
357
static get staticAreaStyles ( ) {
322
- return ResponsivePopoverCommonCss ;
358
+ return [ ResponsivePopoverCommonCss , ValueStateMessageCss ] ;
323
359
}
324
360
325
361
static get dependencies ( ) {
@@ -344,6 +380,19 @@ class MultiComboBox extends UI5Element {
344
380
this . _deleting = false ;
345
381
this . _validationTimeout = null ;
346
382
this . i18nBundle = getI18nBundle ( "@ui5/webcomponents" ) ;
383
+ this . _handleResizeBound = this . _handleResize . bind ( this ) ;
384
+ }
385
+
386
+ onEnterDOM ( ) {
387
+ ResizeHandler . register ( this , this . _handleResizeBound ) ;
388
+ }
389
+
390
+ onExitDOM ( ) {
391
+ ResizeHandler . deregister ( this , this . _handleResizeBound ) ;
392
+ }
393
+
394
+ _handleResize ( ) {
395
+ this . _inputWidth = this . offsetWidth ;
347
396
}
348
397
349
398
_inputChange ( ) {
@@ -605,6 +654,7 @@ class MultiComboBox extends UI5Element {
605
654
this . blur ( ) ;
606
655
}
607
656
657
+ this . _iconPressed = false ;
608
658
this . filterSelected = false ;
609
659
}
610
660
@@ -622,14 +672,51 @@ class MultiComboBox extends UI5Element {
622
672
623
673
async onAfterRendering ( ) {
624
674
await this . _getRespPopover ( ) ;
675
+ await this . _getList ( ) ;
676
+
677
+ this . toggle ( this . shouldDisplayOnlyValueStateMessage ) ;
678
+ this . storeResponsivePopoverWidth ( ) ;
625
679
}
626
680
627
- get valueStateTextMappings ( ) {
628
- return {
629
- "Success" : this . i18nBundle . getText ( VALUE_STATE_SUCCESS ) ,
630
- "Error" : this . i18nBundle . getText ( VALUE_STATE_ERROR ) ,
631
- "Warning" : this . i18nBundle . getText ( VALUE_STATE_WARNING ) ,
632
- } ;
681
+ get _isPhone ( ) {
682
+ return isPhone ( ) ;
683
+ }
684
+
685
+ _onIconMousedown ( ) {
686
+ this . _iconPressed = true ;
687
+ }
688
+
689
+ storeResponsivePopoverWidth ( ) {
690
+ if ( this . open && ! this . _listWidth ) {
691
+ this . _listWidth = this . list . offsetWidth ;
692
+ }
693
+ }
694
+
695
+ toggle ( isToggled ) {
696
+ if ( isToggled && ! this . open ) {
697
+ this . openPopover ( ) ;
698
+ } else {
699
+ this . closePopover ( ) ;
700
+ }
701
+ }
702
+
703
+ async openPopover ( ) {
704
+ const popover = await this . _getPopover ( ) ;
705
+
706
+ if ( popover ) {
707
+ popover . openBy ( this ) ;
708
+ }
709
+ }
710
+
711
+ async closePopover ( ) {
712
+ const popover = await this . _getPopover ( ) ;
713
+
714
+ popover && popover . close ( ) ;
715
+ }
716
+
717
+ async _getPopover ( ) {
718
+ const staticAreaItem = await this . getStaticAreaItemDomRef ( ) ;
719
+ return staticAreaItem . querySelector ( "[ui5-popover]" ) ;
633
720
}
634
721
635
722
get _tokenizer ( ) {
@@ -674,6 +761,10 @@ class MultiComboBox extends UI5Element {
674
761
return this . valueState !== ValueState . None ;
675
762
}
676
763
764
+ get hasValueStateMessage ( ) {
765
+ return this . hasValueState && this . valueState !== ValueState . Success ;
766
+ }
767
+
677
768
get valueStateText ( ) {
678
769
return this . valueStateTextMappings [ this . valueState ] ;
679
770
}
@@ -682,6 +773,26 @@ class MultiComboBox extends UI5Element {
682
773
return this . hasValueState ? `${ this . _id } -valueStateDesc` : undefined ;
683
774
}
684
775
776
+ get valueStateMessageText ( ) {
777
+ return this . getSlottedNodes ( "valueStateMessage" ) . map ( el => el . cloneNode ( true ) ) ;
778
+ }
779
+
780
+ get shouldDisplayDefaultValueStateMessage ( ) {
781
+ return ! this . valueStateMessage . length && this . hasValueStateMessage ;
782
+ }
783
+
784
+ get shouldDisplayOnlyValueStateMessage ( ) {
785
+ return this . _rootFocused && this . hasValueStateMessage && ! this . _iconPressed ;
786
+ }
787
+
788
+ get valueStateTextMappings ( ) {
789
+ return {
790
+ "Success" : this . i18nBundle . getText ( VALUE_STATE_SUCCESS ) ,
791
+ "Error" : this . i18nBundle . getText ( VALUE_STATE_ERROR ) ,
792
+ "Warning" : this . i18nBundle . getText ( VALUE_STATE_WARNING ) ,
793
+ } ;
794
+ }
795
+
685
796
get _innerInput ( ) {
686
797
if ( isPhone ( ) ) {
687
798
if ( this . allItemsPopover . opened ) {
@@ -700,10 +811,40 @@ class MultiComboBox extends UI5Element {
700
811
return this . i18nBundle . getText ( ICON_ACCESSIBLE_NAME ) ;
701
812
}
702
813
814
+ get _dialogOkButton ( ) {
815
+ return this . i18nBundle . getText ( MULTICOMBOBOX_DIALOG_OK_BUTTON ) ;
816
+ }
817
+
703
818
get _tokenizerExpanded ( ) {
704
819
return this . _rootFocused || this . open ;
705
820
}
706
821
822
+ get classes ( ) {
823
+ return {
824
+ popoverValueState : {
825
+ "ui5-valuestatemessage-root" : true ,
826
+ "ui5-valuestatemessage--success" : this . valueState === ValueState . Success ,
827
+ "ui5-valuestatemessage--error" : this . valueState === ValueState . Error ,
828
+ "ui5-valuestatemessage--warning" : this . valueState === ValueState . Warning ,
829
+ "ui5-valuestatemessage--information" : this . valueState === ValueState . Information ,
830
+ } ,
831
+ } ;
832
+ }
833
+
834
+ get styles ( ) {
835
+ return {
836
+ popoverValueStateMessage : {
837
+ "width" : `${ this . _listWidth } px` ,
838
+ "min-height" : "2.5rem" ,
839
+ "padding" : "0.5625rem 1rem" ,
840
+ "display" : this . _listWidth === 0 ? "none" : "inline-block" ,
841
+ } ,
842
+ popoverHeader : {
843
+ "width" : `${ this . _inputWidth } px` ,
844
+ } ,
845
+ } ;
846
+ }
847
+
707
848
static async onDefine ( ) {
708
849
await fetchI18nBundle ( "@ui5/webcomponents" ) ;
709
850
}
0 commit comments