MCPcopy Create free account
hub / github.com/UI5/webcomponents / TableCell

Class TableCell

packages/main/src/TableCell.ts:28–98  ·  view source on GitHub ↗

* @class * * ### Overview * * The `ui5-table-cell` represents a cell inside of a `ui5-table`. * It is tightly coupled to the `ui5-table` and thus should only be used in the table component. * * ### ES6 Module Import * * `import @ui5/webcomponents/dist/TableCell.js;` * * @constructor * @e

Source from the content-addressed store, hash-verified

26 * @public
27 */
28@customElement({
29 tag: "ui5-table-cell",
30 styles: [TableCellBase.styles, TableCellStyles],
31 template: TableCellTemplate,
32})
33class TableCell extends TableCellBase {
34 /**
35 * Defines whether the cell is visually merged with the cell directly above it.
36 *
37 * This is useful if consecutive cells in a column have the same value and should visually appear as a single merged cell.
38 * Although the cell is visually merged with the previous one, its content must still be provided for accessibility purposes.
39 * **Note:** This feature is disabled when cells are rendered as a popin, and should remain `false` for interactive cell content.
40 *
41 * @default false
42 * @since 2.21.0
43 * @public
44 */
45 @property({ type: Boolean })
46 merged = false;
47
48 @query("#popin-header")
49 _popinHeader?: HTMLElement;
50
51 @query("#popin-content")
52 _popinContent?: HTMLElement;
53
54 onBeforeRendering() {
55 super.onBeforeRendering();
56 if (this.horizontalAlign) {
57 this.style.textAlign = this.horizontalAlign;
58 this.style.justifyContent = this.horizontalAlign;
59 } else if (this._headerCell) {
60 this.style.textAlign = `var(--halign-${this._headerCell._id})`;
61 this.style.justifyContent = `var(--halign-${this._headerCell._id})`;
62 }
63 }
64
65 _injectHeaderNodes(ref: HTMLElement | null) {
66 if (ref && !ref.hasChildNodes()) {
67 ref.replaceChildren(...this._popinHeaderNodes);
68 }
69 }
70
71 get _headerCell() {
72 const row = this.parentElement as TableRow | null;
73 const table = row?.parentElement as Table | null;
74 const index = row?.cells?.indexOf(this) ?? -1;
75
76 return (index !== -1) ? table?.headerRow?.[0]?.cells?.[index] : null;
77 }
78
79 get _popinHeaderNodes() {
80 const nodes: Node[] = [];
81 const headerCell = this._headerCell;
82 if (headerCell) {
83 if (headerCell.popinText) {
84 nodes.push(document.createTextNode(headerCell.popinText));
85 } else {

Callers

nothing calls this directly

Calls 3

customElementFunction · 0.85
propertyFunction · 0.85
queryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…