Skip to content

feat: add columns resizable options #2935

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

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
1 change: 1 addition & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
href="assets/styles/salesforce-lightning-design-system.css"
type="text/css" />
<link rel="stylesheet" href="assets/styles/override.css" type="text/css" />
<link rel="stylesheet" href="assets/styles/table.css" type="text/css" />
<style>
html {
background-color: transparent;
Expand Down
70 changes: 70 additions & 0 deletions assets/styles/table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.slds-table-column-resizer{
border-left: 1px solid #0176d3;
}

.grip-handle:hover, .grip-handle-active{
border-left: 1px solid #0176d3;
}

.grip-handle:hover:before, .grip-handle-active:before{
background-color: #0176d3;
width: .25rem;
height: 100%;
content: " ";
position: absolute;
height: 33px;
right: -1.4px;
}

.grip-handle:active:before{
background-color: #0176d3;
width: .25rem;
height: 100%;
content: " ";
position: absolute;
height: 33px;
right: -1.4px;
}

.grip-handle .grip-resizable {
background-color: #0176d3;
width: 1px;
height: 100vh;
opacity: 0;
}

.slds-table_fixed-layout .grip-handle {
position: absolute;
z-index: 9;
background-color: #0176d3;
width: 1px;
height: 100vh;
opacity: 0;
top: -33px;
z-index: 9;
}

.slds-table_fixed-layout .grip-container {
position: absolute;
}

.slds-table_header-fixed_container .grip-handle {
position: absolute;
top: -33px;
z-index: 9;
}

.slds-table_header-fixed_container .grip-container {
position: absolute;
}

.slds-table th:focus .slds-cell-fixed, .slds-table th.slds-has-focus .slds-cell-fixed, .slds-table [role="gridcell"]:focus , .slds-table [role="gridcell"].slds-has-focus{
box-shadow: #0070d2 0 0 0 1px inset;
}

th > div > .slds-truncate {
padding-left: 0.5rem;
padding-right: 0.5rem;
padding: 0.25rem 0.5rem;
height: 2rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ exports[`DOM snapshots SLDSCard Custom Header 1`] = `
aria-label="Opportunity Name"
aria-sort="none"
className=""
id="SLDSDataTableExample-1-name-th"
onFocus={[Function]}
onKeyDown={[Function]}
scope="col"
Expand Down Expand Up @@ -360,6 +361,7 @@ exports[`DOM snapshots SLDSCard Custom Heading 1`] = `
aria-label="Opportunity Name"
aria-sort="none"
className=""
id="SLDSDataTableExample-1-name-th"
onFocus={[Function]}
onKeyDown={[Function]}
scope="col"
Expand Down Expand Up @@ -571,6 +573,7 @@ exports[`DOM snapshots SLDSCard Doc site Related List With Table 1`] = `
aria-label="Opportunity Name"
aria-sort="none"
className=""
id="DataTableExample-1-name-th"
onFocus={[Function]}
onKeyDown={[Function]}
scope="col"
Expand Down Expand Up @@ -969,6 +972,7 @@ exports[`DOM snapshots SLDSCard w/ Items 1`] = `
aria-label="Opportunity Name"
aria-sort="none"
className=""
id="SLDSDataTableExample-1-name-th"
onFocus={[Function]}
onKeyDown={[Function]}
scope="col"
Expand Down Expand Up @@ -1098,6 +1102,7 @@ exports[`DOM snapshots SLDSCard w/o Header 1`] = `
aria-label="Opportunity Name"
aria-sort="none"
className=""
id="SLDSDataTableExample-1-name-th"
onFocus={[Function]}
onKeyDown={[Function]}
scope="col"
Expand Down
153 changes: 153 additions & 0 deletions components/component-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5251,13 +5251,41 @@
"data-table": {
"description": "DataTables support the display of structured data in rows and columns with an HTML table. To sort, filter or paginate the table, simply update the data passed in the items to the table and it will re-render itself appropriately. The table will throw a sort event as needed, and helper components for paging and filtering are coming soon.\n\nNOTE: for horizontal scrolling with `fixedHeader`-enabled DataTables, see the `style` property description",
"methods": [
{
"name": "onResize",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "getId",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "getFixedHeader",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "getKeyboardNavigation",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "getFixedLayout",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "getFirstInteractiveElement",
"docblock": null,
Expand Down Expand Up @@ -5310,6 +5338,13 @@
],
"returns": null
},
{
"name": "repositionResizers",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "resizeFixedHeaders",
"docblock": null,
Expand Down Expand Up @@ -5341,6 +5376,34 @@
],
"returns": null
},
{
"name": "isResizable",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "resizeGrips",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "enableResize",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "disableResize",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "changeActiveCell",
"docblock": null,
Expand Down Expand Up @@ -5395,6 +5458,30 @@
"params": [],
"returns": null
},
{
"name": "displaceByArrowKey",
"docblock": null,
"modifiers": [],
"params": [
{
"name": "factor",
"type": null
}
],
"returns": null
},
{
"name": "makeGripVisible",
"docblock": null,
"modifiers": [],
"params": [
{
"name": "newIndex",
"type": null
}
],
"returns": null
},
{
"name": "handleKeyDownLeft",
"docblock": null,
Expand Down Expand Up @@ -5423,6 +5510,50 @@
"params": [],
"returns": null
},
{
"name": "moveNext",
"docblock": null,
"modifiers": [],
"params": [
{
"name": "event",
"type": null
},
{
"name": "rowIndex",
"type": null
},
{
"name": "columnIndex",
"type": null
}
],
"returns": null
},
{
"name": "handleNextActionable",
"docblock": null,
"modifiers": [],
"params": [
{
"name": "event",
"type": null
}
],
"returns": null
},
{
"name": "handleKeyTabPress",
"docblock": null,
"modifiers": [],
"params": [
{
"name": "event",
"type": null
}
],
"returns": null
},
{
"name": "registerInteractiveElement",
"docblock": null,
Expand Down Expand Up @@ -5732,6 +5863,28 @@
},
"required": false,
"description": "A variant which removes horizontal padding. CSS class will be removed if `fixedLayout==true`."
},
"resizable": {
"type": {
"name": "bool"
},
"required": false,
"description": "A variant which allows column dividers to be grabbed with the mouse. This feature needs\n`@salesforce/design-system-react/assets/styles/table.css` to be loaded.",
"defaultValue": {
"value": "false",
"computed": false
}
},
"resizerOptions": {
"type": {
"name": "object"
},
"required": false,
"description": "Object with properties to be used in case of resizable: true\n\nresizeMode: It is used to set how the resize method works. Those are the possible values: 'fit', 'flex' and 'overflow'\ndisable: It is used for disable the resize functionality, default is false\ndisabledColumns: Array of indexes for the columns to be disabled\nwidths: An array of column widths to set the initial width.\nonResize: Callback function to be fired when the user has ended dragging a column",
"defaultValue": {
"value": "{\n\tresizeMode: 'flex',\n\tdraggingClass: 'slds-table-column-resizer',\n}",
"computed": false
}
}
},
"route": "data-tables",
Expand Down
Loading