-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathListItemGroup.ts
107 lines (93 loc) · 2.67 KB
/
ListItemGroup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import type ListItemBase from "./ListItemBase.js";
// Template
import ListItemGroupTemplate from "./generated/templates/ListItemGroupTemplate.lit.js";
// Styles
import ListItemGroupCss from "./generated/themes/ListItemGroup.css.js";
import ListItemStandard from "./ListItemStandard.js";
import ListItemGroupHeader from "./ListItemGroupHeader.js";
/**
* @class
* ### Overview
* The `ui5-li-group` is a special list item, used only to create groups of list items.
*
* This is the item to use inside a `ui5-list`.
*
* ### ES6 Module Import
* `import "@ui5/webcomponents/dist/ListItemGroup.js";`
* @csspart header - Used to style the header item of the group
* @constructor
* @extends UI5Element
* @public
* @since 2.0.0
*/
@customElement({
tag: "ui5-li-group",
renderer: litRender,
languageAware: true,
template: ListItemGroupTemplate,
styles: [ListItemGroupCss],
dependencies: [ListItemStandard, ListItemGroupHeader],
})
class ListItemGroup extends UI5Element {
/**
* Defines the header text of the <code>ui5-li-group</code>.
* @public
* @default ""
*/
@property()
headerText!: string;
/**
* Defines the accessible name of the header.
* @public
* @default ""
*/
@property({ type: String })
headerAccessibleName!: string;
/**
* Defines the items of the <code>ui5-li-group</code>.
* @public
*/
@slot({
"default": true,
invalidateOnChildChange: true,
type: HTMLElement,
})
items!: Array<ListItemBase>;
/**
* Indicates whether the header is focused
* @private
*/
@property({ type: Boolean })
focused!: boolean;
/**
* Defines the header of the component.
*
* **Note:** Using this slot, the default header text of group and the value of `headerText` property will be overwritten.
* @public
*/
@slot({ type: HTMLElement })
header!: Array<ListItemBase>;
get groupHeaderItem() {
return this.shadowRoot!.querySelector<ListItemGroupHeader>("[ui5-li-group-header]")!;
}
get hasHeader(): boolean {
return !!this.headerText || this.hasFormattedHeader;
}
get hasFormattedHeader(): boolean {
return !!this.header.length;
}
get isListItemGroup() {
return true;
}
}
ListItemGroup.define();
const isInstanceOfListItemGroup = (object: any): object is ListItemGroup => {
return "isListItemGroup" in object;
};
export default ListItemGroup;
export { isInstanceOfListItemGroup };