-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor #4432 - for OrganizationChart
- Loading branch information
Showing
8 changed files
with
608 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
import { useState } from 'react'; | ||
import { OrganizationChart } from '../../../lib/organizationchart/OrganizationChart'; | ||
import { DocSectionCode } from '../../common/docsectioncode'; | ||
import { DocSectionText } from '../../common/docsectiontext'; | ||
|
||
export function PTDoc(props) { | ||
const [selection, setSelection] = useState([]); | ||
const [data] = useState([ | ||
{ | ||
label: 'Argentina', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'Argentina', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'Argentina' | ||
}, | ||
{ | ||
label: 'Croatia' | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'France', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'France' | ||
}, | ||
{ | ||
label: 'Morocco' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]); | ||
|
||
const code = { | ||
basic: ` | ||
<OrganizationChart | ||
value={data} | ||
selectionMode="single" | ||
selection={selection} | ||
onSelectionChange={(e) => setSelection(e.data)} | ||
pt={{ | ||
node: ({ context }) => ({ | ||
className: context.selected ? 'border-orange-400 border-round-sm' : 'border-primary-400 border-round-sm' | ||
}) | ||
}} | ||
/> | ||
`, | ||
javascript: ` | ||
import React, { useState } from 'react'; | ||
import { OrganizationChart } from 'primereact/organizationchart'; | ||
export default function PTDemo() { | ||
const [selection, setSelection] = useState([]); | ||
const [data] = useState([ | ||
{ | ||
label: 'Argentina', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'Argentina', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'Argentina' | ||
}, | ||
{ | ||
label: 'Croatia' | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'France', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'France' | ||
}, | ||
{ | ||
label: 'Morocco' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]); | ||
return ( | ||
<div className="card overflow-x-auto"> | ||
<OrganizationChart | ||
value={data} | ||
selectionMode="single" | ||
selection={selection} | ||
onSelectionChange={(e) => setSelection(e.data)} | ||
pt={{ | ||
node: ({ context }) => ({ | ||
className: context.selected ? 'border-orange-400 border-round-sm' : 'border-primary-400 border-round-sm' | ||
}) | ||
}} | ||
/> | ||
</div> | ||
) | ||
} | ||
`, | ||
typescript: ` | ||
import React, { useState } from 'react'; | ||
import { OrganizationChart } from 'primereact/organizationchart'; | ||
import { TreeNode } from 'primereact/treenode'; | ||
export default function PTDemo() { | ||
const [selection, setSelection] = useState<TreeNode[]>([]); | ||
const [data] = useState<TreeNode>([ | ||
{ | ||
label: 'Argentina', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'Argentina', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'Argentina' | ||
}, | ||
{ | ||
label: 'Croatia' | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'France', | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: 'France' | ||
}, | ||
{ | ||
label: 'Morocco' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]); | ||
return ( | ||
<div className="card overflow-x-auto"> | ||
<OrganizationChart | ||
value={data} | ||
selectionMode="single" | ||
selection={selection} | ||
onSelectionChange={(e) => setSelection(e.data)} | ||
pt={{ | ||
node: ({ context }) => ({ | ||
className: context.selected ? 'border-orange-400 border-round-sm' : 'border-primary-400 border-round-sm' | ||
}) | ||
}} | ||
/> | ||
</div> | ||
) | ||
} | ||
` | ||
}; | ||
|
||
return ( | ||
<> | ||
<DocSectionText {...props}></DocSectionText> | ||
<div className="card overflow-x-auto"> | ||
<OrganizationChart | ||
value={data} | ||
selectionMode="single" | ||
selection={selection} | ||
onSelectionChange={(e) => setSelection(e.data)} | ||
pt={{ | ||
node: ({ context }) => ({ | ||
className: context.selected ? 'border-orange-400 border-round-sm' : 'border-primary-400 border-round-sm' | ||
}) | ||
}} | ||
/> | ||
</div> | ||
<DocSectionCode code={code} /> | ||
</> | ||
); | ||
} |
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,13 @@ | ||
import React from 'react'; | ||
import { DocSectionText } from '../../common/docsectiontext'; | ||
|
||
export const Wireframe = (props) => { | ||
return ( | ||
<> | ||
<DocSectionText {...props} /> | ||
<div> | ||
<img className="w-full" src="https://primefaces.org/cdn/primereact/images/pt/wireframe-placeholder.jpg" alt="organizationchart" /> | ||
</div> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.