generated from abelflopes/lerna-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a97731
commit 92e1e11
Showing
4 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.sortable_header { | ||
cursor: pointer; | ||
} | ||
|
||
.sortable_header_icon { | ||
margin-left: 10px; | ||
vertical-align: text-bottom; | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/components/data-table/src/utils/component-to-text.tsx
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,18 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom/server"; | ||
|
||
/** Extract text only from component markup */ | ||
|
||
export const componentToText = (component: NonNullable<React.ReactNode>): string | undefined => { | ||
let text = ""; | ||
// eslint-disable-next-line react/jsx-no-useless-fragment -- needed to be received as a react node by react dom server | ||
const html = ReactDOM.renderToString(<>{component}</>); | ||
const el = document.createElement("span"); | ||
el.innerHTML = html; | ||
|
||
if (el.textContent && el.textContent.length > 0) { | ||
text = el.textContent; | ||
} | ||
|
||
return text.trim().length > 0 ? text : undefined; | ||
}; |