Skip to content

Commit

Permalink
Refactor #4432 - for OrganizationChart
Browse files Browse the repository at this point in the history
  • Loading branch information
habubey committed May 30, 2023
1 parent ff9d3fc commit 7772554
Show file tree
Hide file tree
Showing 8 changed files with 608 additions and 30 deletions.
153 changes: 153 additions & 0 deletions components/doc/common/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -28908,6 +28908,14 @@
"type": "ReactNode",
"default": "",
"description": "Used to get the child elements of the component."
},
{
"name": "pt",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughOptions",
"default": "",
"description": "Uses to pass attributes to DOM elements inside the component."
}
]
},
Expand Down Expand Up @@ -29038,6 +29046,143 @@
"interfaces": {
"description": "Defines the custom interfaces used by the module.",
"values": {
"OrganizationChartPassThroughMethodOptions": {
"description": "Custom passthrough(pt) option method.",
"relatedProp": "",
"props": [
{
"name": "props",
"optional": false,
"readonly": false,
"type": "OrganizationChartProps"
},
{
"name": "state",
"optional": false,
"readonly": false,
"type": "OrganizationChartState"
},
{
"name": "context",
"optional": false,
"readonly": false,
"type": "OrganizationChartContext"
}
],
"callbacks": []
},
"OrganizationChartPassThroughOptions": {
"description": "Custom passthrough(pt) options.",
"relatedProp": "pt",
"props": [
{
"name": "root",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLDivElement>>",
"description": "Uses to pass attributes to the root's DOM element."
},
{
"name": "table",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLTableCellElement>>",
"description": "Uses to pass attributes to the table's DOM element."
},
{
"name": "cell",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLTableCellElement>>",
"description": "Uses to pass attributes to the cell's DOM element."
},
{
"name": "node",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLDivElement>>",
"description": "Uses to pass attributes to the node's DOM element."
},
{
"name": "nodeToggler",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLAnchorElement>>",
"description": "Uses to pass attributes to the nodeToggler's DOM element."
},
{
"name": "nodeTogglerIcon",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLSpanElement> | SVGProps<SVGSVGElement>>",
"description": "Uses to pass attributes to the nodeTogglerIcon's DOM element."
},
{
"name": "lines",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLTableRowElement>>",
"description": "Uses to pass attributes to the lines's DOM element."
},
{
"name": "lineCell",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLTableCellElement>>",
"description": "Uses to pass attributes to the lineCell's DOM element."
},
{
"name": "lineDown",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLDivElement>>",
"description": "Uses to pass attributes to the lineDown's DOM element."
},
{
"name": "nodes",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLTableRowElement>>",
"description": "Uses to pass attributes to the nodes's DOM element."
},
{
"name": "nodeCell",
"optional": true,
"readonly": false,
"type": "OrganizationChartPassThroughType<HTMLAttributes<HTMLTableCellElement>>",
"description": "Uses to pass attributes to the nodeCell's DOM element."
}
],
"callbacks": []
},
"OrganizationChartState": {
"description": "Defines current inline state in OrganizationChart component.",
"relatedProp": "",
"props": [
{
"name": "expanded",
"optional": false,
"readonly": false,
"type": "boolean",
"description": "Current focus expanded of the node as a boolean."
}
],
"callbacks": []
},
"OrganizationChartContext": {
"description": "Defines current options in OrganizationChart component.",
"relatedProp": "",
"props": [
{
"name": "selected",
"optional": false,
"readonly": false,
"type": "boolean",
"description": "Current selection state of the node as a boolean."
}
],
"callbacks": []
},
"OrganizationChartNodeData": {
"description": "Custom organizationchart node data.",
"relatedProp": "",
Expand Down Expand Up @@ -29081,6 +29226,14 @@
"callbacks": []
}
}
},
"types": {
"description": "Defines the custom types used by the module.",
"values": {
"OrganizationChartPassThroughType": {
"values": "PassThroughType<T, OrganizationChartPassThroughMethodOptions>"
}
}
}
},
"overlaypanel": {
Expand Down
189 changes: 189 additions & 0 deletions components/doc/organizationchart/pt/ptdoc.js
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} />
</>
);
}
13 changes: 13 additions & 0 deletions components/doc/organizationchart/pt/wireframe.js
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>
</>
);
};
Loading

0 comments on commit 7772554

Please sign in to comment.