-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ui5-select): migrate to tsx template (#10469)
- Loading branch information
Showing
5 changed files
with
178 additions
and
135 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import type Select from "./Select.js"; | ||
import List from "./List.js"; | ||
import Button from "./Button.js"; | ||
import ResponsivePopover from "./ResponsivePopover.js"; | ||
import Popover from "./Popover.js"; | ||
import Icon from "./Icon.js"; | ||
import decline from "@ui5/webcomponents-icons/dist/decline.js"; | ||
|
||
export default function SelectPopoverTemplate(this: Select) { | ||
return ( | ||
<> | ||
{this.options.length > 0 && | ||
<ResponsivePopover | ||
class={{ | ||
"ui5-select-popover": true, | ||
...this.classes.popover | ||
}} | ||
part="popover" | ||
style={this.styles.responsivePopover} | ||
placement="Bottom" | ||
horizontalAlign="Start" | ||
hideArrow={true} | ||
preventInitialFocus={true} | ||
onOpen={this._afterOpen} | ||
onBeforeOpen={this._beforeOpen} | ||
onClose={this._afterClose} | ||
onKeyDown={this._onkeydown} | ||
> | ||
{this._isPhone && | ||
<div slot="header" class="ui5-responsive-popover-header"> | ||
<div class="row"> | ||
<span>{this._headerTitleText}</span> | ||
<Button | ||
class="ui5-responsive-popover-close-btn" | ||
icon={decline} | ||
design="Transparent" | ||
onClick={this._toggleRespPopover} /> | ||
</div> | ||
|
||
{this.hasValueStateText && | ||
<div class={{ | ||
"row": true, | ||
"ui5-select-value-state-dialog-header": true, | ||
...this.classes.popoverValueState | ||
}}> | ||
{valueStateMessage.call(this)} | ||
</div> | ||
} | ||
</div> | ||
} | ||
|
||
{!this._isPhone && this.hasValueStateText && | ||
<div | ||
class={this.classes.popoverValueState} | ||
style={this.styles.responsivePopoverHeader}> | ||
<Icon | ||
class="ui5-input-value-state-message-icon" | ||
name={this._valueStateMessageInputIcon} /> | ||
{valueStateMessage.call(this)} | ||
</div> | ||
} | ||
|
||
<List | ||
separators="None" | ||
onMouseDown={this._itemMousedown} | ||
onItemClick={this._handleItemPress} | ||
> | ||
<slot></slot> | ||
</List> | ||
</ResponsivePopover> | ||
} | ||
|
||
{this.shouldOpenValueStateMessagePopover && | ||
<Popover | ||
part="popover" | ||
class="ui5-valuestatemessage-popover" | ||
preventInitialFocus={true} | ||
preventFocusRestore={true} | ||
hideArrow={true} | ||
placement="Bottom" | ||
horizontalAlign="Start" | ||
> | ||
<div | ||
class={this.classes.popoverValueState} | ||
style={this.styles.popoverHeader}> | ||
<Icon | ||
class="ui5-input-value-state-message-icon" | ||
name={this._valueStateMessageInputIcon} /> | ||
{valueStateMessage.call(this)} | ||
</div> | ||
</Popover> | ||
} | ||
</> | ||
); | ||
} | ||
|
||
function valueStateMessage(this: Select) { | ||
return ( | ||
<> | ||
{this.shouldDisplayDefaultValueStateMessage | ||
? this.valueStateText | ||
: <slot name="valueStateMessage"></slot> | ||
} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type Select from "./Select.js"; | ||
import Icon from "./Icon.js"; | ||
import slimArrowDown from "@ui5/webcomponents-icons/dist/slim-arrow-down.js"; | ||
import SelectPopoverTemplate from "./SelectPopoverTemplate.js"; | ||
|
||
export default function SelectTemplate(this: Select) { | ||
return ( | ||
<> | ||
<div | ||
class={{ | ||
"ui5-select-root": true, | ||
"ui5-input-focusable-element": true, | ||
}} | ||
id={`${this._id}-select`} | ||
onClick={this._onclick} | ||
> | ||
{this.selectedOptionIcon && | ||
<Icon | ||
mode="Decorative" | ||
class="ui5-select-option-icon" | ||
name={this.selectedOptionIcon} /> | ||
} | ||
|
||
<div | ||
class="ui5-select-label-root" | ||
data-sap-focus-ref | ||
tabindex={this._effectiveTabIndex} | ||
role="combobox" | ||
aria-haspopup="listbox" | ||
aria-label={this.ariaLabelText} | ||
aria-describedby={this.valueStateTextId} | ||
aria-disabled={this.isDisabled} | ||
aria-required={this.required} | ||
aria-readonly={this.readonly} | ||
aria-expanded={this._isPickerOpen} | ||
aria-roledescription={this._ariaRoleDescription} | ||
onKeyDown={this._onkeydown} | ||
onKeyPress={this._handleKeyboardNavigation} | ||
onKeyUp={this._onkeyup} | ||
onFocusIn={this._onfocusin} | ||
onFocusOut={this._onfocusout} | ||
> | ||
{this.hasCustomLabel | ||
? <slot name="label"></slot> | ||
: this.text | ||
} | ||
</div> | ||
|
||
{!this.readonly && | ||
<Icon | ||
name={slimArrowDown} | ||
class={{ | ||
"inputIcon": true, | ||
"inputIcon--pressed": this._iconPressed, | ||
}} /> | ||
} | ||
|
||
{this.hasValueState && | ||
<span id={`${this._id}-valueStateDesc`} class="ui5-hidden-text"> | ||
{this.valueStateText} | ||
</span> | ||
} | ||
</div> | ||
|
||
{SelectPopoverTemplate.call(this)} | ||
</> | ||
); | ||
} |