Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(table): add part for the cell in the expanded row of the table. add visible for overflow. #789

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ We recommend fitting your content within the table’s natural size whenever pos

## Properties

| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | -------------------- |
| `colSpan` | `col-span` | In case that automatic count of columns does not work, user can manually set this one. Take in mind that expandable control is column too | `number` | `null` |
| `expanded` | `expanded` | Sets isExpanded state to true or false externally | `boolean` | `undefined` |
| `overflow` | `overflow` | Controls the overflow behavior of the expandable row content | `"auto" \| "hidden"` | `'auto'` |
| `rowId` | `row-id` | ID for the table row. Randomly generated if not specified. | `string` | `generateUniqueId()` |
| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | -------------------- |
| `colSpan` | `col-span` | In case that automatic count of columns does not work, user can manually set this one. Take in mind that expandable control is column too | `number` | `null` |
| `expanded` | `expanded` | Sets isExpanded state to true or false externally | `boolean` | `undefined` |
| `overflow` | `overflow` | Controls the overflow behavior of the expandable row content | `"auto" \| "hidden" \| "visible"` | `'auto'` |
| `rowId` | `row-id` | ID for the table row. Randomly generated if not specified. | `string` | `generateUniqueId()` |


## Events
Expand Down Expand Up @@ -101,10 +101,11 @@ Type: `Promise<void>`

## Shadow Parts

| Part | Description |
| -------------- | ------------------------------------------- |
| `"expand-row"` | Selector for the expanded row of the table. |
| `"row"` | Selector for the main row of the table. |
| Part | Description |
| ------------------- | ------------------------------------------------------- |
| `"expand-row"` | Selector for the expanded row of the table. |
| `"expand-row-cell"` | Selector for the cell in the expanded row of the table. |
| `"row"` | Selector for the main row of the table. |


----------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
padding: 16px 16px 16px 66px;
color: var(--tds-table-color);
}

.tds-table__cell-expand--overflow-visible {
overflow: visible;
}

.tds-table__cell-expand--overflow-hidden {
overflow: hidden;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const relevantTableProps: InternalTdsTablePropChange['changed'] = [

* @part row - Selector for the main row of the table.
* @part expand-row - Selector for the expanded row of the table.
* @part expand-row-cell - Selector for the cell in the expanded row of the table.
*/

@Component({
Expand All @@ -46,7 +47,7 @@ export class TdsTableBodyRowExpandable {
@Prop({ reflect: true }) expanded: boolean;

/** Controls the overflow behavior of the expandable row content */
@Prop({ reflect: true }) overflow: 'auto' | 'hidden' = 'auto';
@Prop({ reflect: true }) overflow: 'auto' | 'hidden' | 'visible' = 'auto';

/** Sets isExpanded state to true or false internally */
@State() isExpanded: boolean = false;
Expand Down Expand Up @@ -175,7 +176,11 @@ export class TdsTableBodyRowExpandable {
}}
part="row"
>
<td class="tds-table__cell tds-table__cell--expand">
<td
class={{
'tds-table__cell-expand': true,
}}
>
<label class="tds-table__expand-control-container">
<input
class="tds-table__expand-input"
Expand Down Expand Up @@ -205,7 +210,15 @@ export class TdsTableBodyRowExpandable {
}}
part="expand-row"
>
<td class="tds-table__cell-expand" colSpan={this.columnsNumber}>
<td
class={{
'tds-table__cell-expand': true,
'tds-table__cell-expand--overflow-hidden': this.overflow === 'hidden',
'tds-table__cell-expand--overflow-visible': this.overflow === 'visible',
}}
part="expand-row-cell"
colSpan={this.columnsNumber}
>
<div
style={{
overflow: this.overflow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export default {
control: {
type: 'radio',
},
options: ['auto', 'hidden'],
options: ['auto', 'hidden', 'visible'],
table: {
defaultValue: { summary: 'auto' },
},
},
},
args: {
Expand All @@ -144,7 +147,7 @@ export default {
column2Width: '',
column3Width: '',
column4Width: '',
overflow: 'scroll',
overflow: 'auto',
},
};

Expand Down Expand Up @@ -213,7 +216,9 @@ const ExpandableRowTemplate = ({
<tds-body-cell cell-value="Demo overflow 4" cell-key="mileage"></tds-body-cell>
<div slot="expand-row">
<!-- Demo block: Overflow solution for Expanded Rows (Not Recommended). -->
<div style="background-color: red; width: 900px; height: 100px;">Not Recommended</div>
<div style="background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet); width: 900px; height: 100px; color: white; text-shadow: 1px 1px 2px black;">
This is an example of a long sentence that demonstrates how content can overflow the boundaries of its container, especially when the container has a fixed width and the content is too large to fit within it.
</div>
<!-- end of demo block -->
</div>
</tds-table-body-row-expandable>
Expand All @@ -224,7 +229,7 @@ const ExpandableRowTemplate = ({
<script>

tableRowElementAll = document.querySelectorAll("tds-table-body-row-expandable");

for (let i = 0; i < tableRowElementAll.length; i++) {
tableRowElementAll[i].addEventListener("tdsChange", (event) => {
console.log("Row with id: ", event.detail.rowId, " is ", event.detail.isExpanded);
Expand Down
Loading