forked from EightfoldAI/octuple
-
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.
feat: table: add table component (EightfoldAI#193)
* chore: table: initial commit adds table and its dependencies * chore: table: module name change and stories file * feat: table: adds tree, empty, motion and list virtualization components also adds numerous deps * chore: table: commit ahead of merge * chore: git: add lfs * chore: lfs: removes large snap ahead of commit * Create .gitattributes * chore: table: merge with latest * chore: ts: adds some typings * chore: table: fixes some linter errors * chore: table: fix linter errors * chore: table: fix linter errors and exclude ts classes from css modules * chore: table: fix linter errors part three * chore: table: linter fix attempt three using updated imports * chore: table: linter fix attempt four using updated webpack config * chore: table: compiler and linter fix attempt using updated tsx * chore: table: removes renamed files * chore: table: reverts renamed files * chore: table: update reat import in usestate * chore: table: updates import type name * chore: table: removes default exports from motion hooks * chore: imports: removes more defaults * chore: table: removes more defaults and updates exports in usestate * chore: table: adds type and updates casing in a path * chore: table: updates casing in remaining error paths * chore: table: revert renamed dir to fix compilation path * chore: table: update capitalization of import path * chore: table: reverts some updates to fix build * chore: table: address pr feedback, remove lodash and adds theming * chore: lfs: adds gitattributes file to pr ahead of merge * chore: table: revert type property order change
- Loading branch information
1 parent
a007990
commit 77c9e6c
Showing
249 changed files
with
33,286 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; } | ||
git lfs post-checkout "$@" |
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,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; } | ||
git lfs post-commit "$@" |
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,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; } | ||
git lfs post-merge "$@" |
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,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; } | ||
git lfs pre-push "$@" |
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 |
---|---|---|
@@ -1,7 +1,26 @@ | ||
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap" rel="stylesheet"> | ||
<link | ||
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap" | ||
rel="stylesheet" | ||
/> | ||
|
||
<style> | ||
html, body { | ||
html, | ||
body { | ||
font-family: 'Source Sans Pro', sans-serif; | ||
} | ||
|
||
.virtual-table .table-container:before, | ||
.virtual-table .table-container:after { | ||
display: none; | ||
} | ||
.virtual-table-cell { | ||
background: white; | ||
border-bottom: 1px solid #d9dce1; | ||
box-sizing: border-box; | ||
overflow: hidden; | ||
padding: 16px; | ||
} | ||
.grouped-th { | ||
border-bottom: none !important; | ||
} | ||
</style> |
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
Git LFS file not shown
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,56 @@ | ||
import React from 'react'; | ||
|
||
export const DefaultEmptyImg = (): JSX.Element => { | ||
return ( | ||
<svg | ||
className={'empty-image-default'} | ||
width="200" | ||
height="184" | ||
viewBox="0 0 200 184" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M39.0718 177.839C21.8078 171.861 3.66074 162.325 0.510726 150.175C-2.63929 138.025 9.18787 123.359 24.8068 115.637C40.5358 108.029 59.9069 107.449 71.9662 102.257C83.9156 96.9498 88.5731 86.9309 99.9189 77.9985C111.265 69.066 129.299 61.2199 140.372 64.9517C151.555 68.798 155.648 84.2069 164.716 96.6426C173.785 109.078 187.68 118.625 194.904 131.657C202.237 144.804 202.768 161.422 189.061 166.219C175.355 171.016 147.3 163.877 128.36 165.625C109.569 167.288 99.7624 177.823 86.4541 181.955C73.2954 186.004 56.4854 183.734 39.0718 177.839Z" | ||
fill="#EBF7FF" | ||
/> | ||
<path d="M26 108L38.5 59H160.5L174 108V154H26V108Z" fill="white" /> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M118.495 108.258C118.495 117.504 110.214 123.333 99.9993 123.333C89.7843 123.333 81.5034 117.504 81.5034 108.258C81.5034 107.958 81.5121 105.994 81.5293 105.698H46.666L60.2683 72.6258C60.8547 71.0563 62.4813 70 64.3116 70H135.687C137.517 70 139.144 71.0563 139.73 72.6258L153.333 105.698H118.469C118.487 105.994 118.495 107.958 118.495 108.258Z" | ||
fill="#B0F3FE" | ||
/> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M152.505 59.9999L47.4938 60.0006C43.6128 60.0006 40.0926 62.6542 38.7909 66.7166L27.5922 101.666L74.0905 101.666C78.722 101.666 83.0934 103.873 86.0399 107.654L92.9658 116.542C96.6469 121.266 103.355 121.266 107.037 116.542L113.962 107.654C116.909 103.873 121.28 101.666 125.912 101.666L172.408 101.666L161.208 66.7158C159.906 62.6534 156.386 59.9999 152.505 59.9999ZM173.651 108.333L125.912 108.333C123.217 108.333 120.638 109.615 118.876 111.876L111.95 120.763C105.729 128.747 94.2733 128.747 88.0518 120.763L81.126 111.876C79.3647 109.615 76.7854 108.333 74.0906 108.333L26.3492 108.333L26.3493 143.333C26.3493 148.934 30.548 153.333 35.5634 153.333L164.436 153.333C169.452 153.333 173.65 148.934 173.651 143.333L173.651 108.333ZM47.4937 53.3339L152.505 53.3333C159.195 53.3332 165.081 57.8972 167.226 64.5898L180 104.454L180 143.333C180 152.46 173.105 159.999 164.436 159.999L35.5635 160C26.8946 160 20.0001 152.46 20 143.333L20 104.454L32.7731 64.5908C34.9176 57.898 40.804 53.334 47.4937 53.3339Z" | ||
fill="#8ED0FA" | ||
/> | ||
<rect | ||
x="93.334" | ||
width="13.3333" | ||
height="40" | ||
rx="6.66667" | ||
fill="#B0F3FE" | ||
/> | ||
<rect | ||
x="46.666" | ||
y="6.66675" | ||
width="13.3333" | ||
height="40" | ||
rx="6.66667" | ||
transform="rotate(-30 46.666 6.66675)" | ||
fill="#B0F3FE" | ||
/> | ||
<rect | ||
x="141.666" | ||
width="13.3333" | ||
height="40" | ||
rx="6.66667" | ||
transform="rotate(30 141.666 0)" | ||
fill="#B0F3FE" | ||
/> | ||
</svg> | ||
); | ||
}; |
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,149 @@ | ||
import React from 'react'; | ||
import { useRef } from 'react'; | ||
import { | ||
DomWrapper, | ||
findDOMNode, | ||
fillRef, | ||
mergeClasses, | ||
} from '../../shared/utilities'; | ||
import { getTransitionName } from './util/motion'; | ||
import type { CSSMotionProps } from './CSSMotion.types'; | ||
import { STATUS_NONE, STEP_PREPARE, STEP_START } from './CSSMotion.types'; | ||
import { useStatus } from './hooks/useStatus'; | ||
import { isActive } from './hooks/useStepQueue'; | ||
|
||
export function genCSSMotion(): React.ForwardRefExoticComponent< | ||
CSSMotionProps & { ref?: React.Ref<any> } | ||
> { | ||
const CSSMotion = React.forwardRef<any, CSSMotionProps>((props, ref) => { | ||
const { | ||
// Default config | ||
visible = true, | ||
removeOnLeave = true, | ||
|
||
forceRender, | ||
children, | ||
motionName, | ||
leavedClassName, | ||
eventProps, | ||
} = props; | ||
|
||
// Ref to the react node, it may be a HTMLElement | ||
const nodeRef = useRef<any>(); | ||
// Ref to the dom wrapper in case ref can not pass to HTMLElement | ||
const wrapperNodeRef = useRef(); | ||
|
||
function getDomElement() { | ||
try { | ||
// Here we're avoiding call for findDOMNode since it's deprecated | ||
// in strict mode. We're calling it only when node ref is not | ||
// an instance of DOM HTMLElement. Otherwise use | ||
// findDOMNode as a final resort | ||
return nodeRef.current instanceof HTMLElement | ||
? nodeRef.current | ||
: findDOMNode<HTMLElement>(wrapperNodeRef.current); | ||
} catch (e) { | ||
// Only happen when `motionDeadline` trigger but element removed. | ||
return null; | ||
} | ||
} | ||
|
||
const [status, statusStep, statusStyle, mergedVisible] = useStatus( | ||
visible, | ||
getDomElement, | ||
props | ||
); | ||
|
||
// Record whether content has rendered | ||
// Will return null for un-rendered even when `removeOnLeave={false}` | ||
const renderedRef = React.useRef(mergedVisible); | ||
if (mergedVisible) { | ||
renderedRef.current = true; | ||
} | ||
|
||
// ====================== Refs ====================== | ||
const setNodeRef = React.useCallback( | ||
(node: any) => { | ||
nodeRef.current = node; | ||
fillRef(ref, node); | ||
}, | ||
[ref] | ||
); | ||
|
||
// ===================== Render ===================== | ||
let motionChildren: React.ReactNode; | ||
const mergedProps = { ...eventProps, visible }; | ||
|
||
if (!children) { | ||
// No children | ||
motionChildren = null; | ||
} else if (status === STATUS_NONE) { | ||
// Stable children | ||
if (mergedVisible) { | ||
motionChildren = children({ ...mergedProps }, setNodeRef); | ||
} else if (!removeOnLeave && renderedRef.current) { | ||
motionChildren = children( | ||
{ ...mergedProps, className: leavedClassName }, | ||
setNodeRef | ||
); | ||
} else if (forceRender) { | ||
motionChildren = children( | ||
{ ...mergedProps, style: { display: 'none' } }, | ||
setNodeRef | ||
); | ||
} else { | ||
motionChildren = null; | ||
} | ||
} else { | ||
// In motion | ||
let statusSuffix: string; | ||
if (statusStep === STEP_PREPARE) { | ||
statusSuffix = 'prepare'; | ||
} else if (isActive(statusStep)) { | ||
statusSuffix = 'active'; | ||
} else if (statusStep === STEP_START) { | ||
statusSuffix = 'start'; | ||
} | ||
|
||
motionChildren = children( | ||
{ | ||
...mergedProps, | ||
className: mergeClasses([ | ||
getTransitionName(motionName, status), | ||
{ | ||
[getTransitionName( | ||
motionName, | ||
`${status}-${statusSuffix}` | ||
)]: statusSuffix, | ||
}, | ||
{ | ||
[motionName as string]: | ||
typeof motionName === 'string', | ||
}, | ||
]), | ||
style: statusStyle, | ||
}, | ||
setNodeRef | ||
); | ||
} | ||
|
||
// Auto inject ref if child node not have `ref` props | ||
if (React.isValidElement(motionChildren)) { | ||
const { ref: originNodeRef } = motionChildren as any; | ||
|
||
if (!originNodeRef) { | ||
motionChildren = React.cloneElement(motionChildren, { | ||
ref: setNodeRef, | ||
}); | ||
} | ||
} | ||
|
||
return <DomWrapper ref={wrapperNodeRef}>{motionChildren}</DomWrapper>; | ||
}); | ||
|
||
CSSMotion.displayName = 'CSSMotion'; | ||
|
||
return CSSMotion; | ||
} | ||
|
||
export default genCSSMotion(); |
Oops, something went wrong.