-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ui5-input): suggestions refactoring (#9092)
BREAKING CHANGE: remove `type`, `description`, `icon`, `iconEnd`, `image` from `ui5-suggestion-item` and introduce `ui5-suggestion-item-custom` `ui5-suggestion-item`: - `type` property is removed, use `ui5-suggestion-item-custom` instead. - `description` property is removed, use `ui5-suggestion-item-custom` instead. - `icon` property is removed, use `ui5-suggestion-item-custom` instead. - `iconEnd` property is removed, use `ui5-suggestion-item-custom` instead. - `image` property is removed, use `ui5-suggestion-item-custom` instead. `ui5-suggestion-group-item`: - renamed to `ui5-suggestion-item-group` - `text` is removed, use `headerText` instead `ui5-suggestion-item-custom`: - custom suggestion item with open content similar to `ui5-li-custom` - to be used for custom scenarios - to highlight custom items use `@ui5/webcomponents-base/dist/util/generateHighlightedMarkup.js` All suggestion items are now physical items and can be overstyled. Grouping now works with via nesting: e.g. ```js <ui5-input show-suggestions> <ui5-suggestion-item-group header-text="Group 1"> <ui5-suggestion-item text="Group Item 1"></ui5-suggestion-item> </ui5-suggestion-item-group> </ui5-input> ``` Related to #8461, #7890
- Loading branch information
Showing
32 changed files
with
1,066 additions
and
670 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 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 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,14 @@ | ||
{{>include "./ListItemBase.hbs"}} | ||
|
||
{{#*inline "listItemContent"}} | ||
<div part="content" id="content" class="ui5-li-content"> | ||
<div class="ui5-li-text-wrapper"> | ||
<span part="title" class="ui5-li-title"> | ||
{{{markupText}}} | ||
</span> | ||
{{#if additionalText}} | ||
<span part="additional-text" class="ui5-li-additional-text">{{additionalText}}</span> | ||
{{/if}} | ||
</div> | ||
</div> | ||
{{/inline}} |
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 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,5 @@ | ||
{{>include "./ListItemBase.hbs"}} | ||
|
||
{{#*inline "listItemContent"}} | ||
<slot></slot> | ||
{{/inline}} |
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,55 @@ | ||
import property from "@ui5/webcomponents-base/dist/decorators/property.js"; | ||
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js"; | ||
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js"; | ||
import type { IInputSuggestionItemSelectable } from "./Input.js"; | ||
import ListItemBase from "./ListItemBase.js"; | ||
|
||
// Template | ||
import SuggestionItemCustomTemplate from "./generated/templates/SuggestionItemCustomTemplate.lit.js"; | ||
|
||
// styles | ||
import styles from "./generated/themes/SuggestionItemCustom.css.js"; | ||
|
||
/** | ||
* @class | ||
* The `ui5-suggestion-item-custom` is type of suggestion item, | ||
* that can be used to place suggestion items with custom content in the input. | ||
* The text property is considered only for autocomplete. | ||
* In case the user needs highlighting functionality, check "@ui5/webcomponents-base/dist/util/generateHighlightedMarkup.js" | ||
* | ||
* @constructor | ||
* @extends ListItemBase | ||
* @public | ||
* @implements { IInputSuggestionItemSelectable } | ||
* @since 2.0.0 | ||
*/ | ||
@customElement({ | ||
tag: "ui5-suggestion-item-custom", | ||
template: SuggestionItemCustomTemplate, | ||
styles: [ | ||
ListItemBase.styles, | ||
styles, | ||
], | ||
}) | ||
class SuggestionItemCustom extends ListItemBase implements IInputSuggestionItemSelectable { | ||
/** | ||
* Defines the text of the `ui5-suggestion-item-custom`. | ||
* **Note:** The text property is considered only for autocomplete. | ||
* @default "" | ||
* @public | ||
*/ | ||
@property() | ||
text = ""; | ||
|
||
/** | ||
* Defines the content of the component. | ||
* | ||
* @public | ||
*/ | ||
@slot({ type: Node, "default": true, invalidateOnChildChange: true }) | ||
content!: Array<Node>; | ||
} | ||
|
||
SuggestionItemCustom.define(); | ||
|
||
export default SuggestionItemCustom; |
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 @@ | ||
{{>include "./ListItemGroup.hbs"}} |
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,33 @@ | ||
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js"; | ||
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js"; | ||
import type SuggestionListItem from "./SuggestionListItem.js"; | ||
import ListItemGroup from "./ListItemGroup.js"; | ||
|
||
/** | ||
* @class | ||
* The `ui5-suggestion-item-group` is type of suggestion item, | ||
* that can be used to split the `ui5-input` suggestions into groups. | ||
* @constructor | ||
* @extends ListItemGroup | ||
* @public | ||
* @since 2.0.0 | ||
*/ | ||
@customElement({ | ||
tag: "ui5-suggestion-item-group", | ||
}) | ||
class SuggestionItemGroup extends ListItemGroup { | ||
/** | ||
* Defines the items of the <code>ui5-suggestion-item-group</code>. | ||
* @public | ||
*/ | ||
@slot({ | ||
"default": true, | ||
invalidateOnChildChange: true, | ||
type: HTMLElement, | ||
}) | ||
items!: Array<SuggestionListItem>; | ||
} | ||
|
||
SuggestionItemGroup.define(); | ||
|
||
export default SuggestionItemGroup; |
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
Oops, something went wrong.