🐛 fix(parameterComponent): fix syntax error in refHtml.current assignment
🐛 fix(parameterComponent): fix classNames usage in span element 🐛 fix(parameterComponent): remove unnecessary line break element 🐛 fix(parameterComponent): fix className usage in span element 🐛 fix(ShadTooltipComponent): add className prop to TooltipContent component 🐛 fix(utils): fix syntax error in groupByFamily function ✨ feat(parameterComponent): add support for grouping and displaying multiple types in parameterComponent ✨ feat(utils): add support for grouping and filtering data in groupByFamily function
This commit is contained in:
parent
cd1cb854e7
commit
4f33f02d4f
3 changed files with 92 additions and 43 deletions
|
|
@ -85,7 +85,8 @@ export default function ParameterComponent({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const groupedObj = groupByFamily(myData, tooltipTitle, left, data.type);
|
const groupedObj = groupByFamily(myData, tooltipTitle, left, data.type);
|
||||||
|
|
||||||
refHtml.current = groupedObj.map((item, i) => (
|
refHtml.current = groupedObj.map((item, i) => {
|
||||||
|
return (
|
||||||
<span
|
<span
|
||||||
key={getRandomKeyByssmm() + item.family + i}
|
key={getRandomKeyByssmm() + item.family + i}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
@ -102,7 +103,7 @@ export default function ParameterComponent({
|
||||||
</div>
|
</div>
|
||||||
<span className="ps-2 text-gray-950">
|
<span className="ps-2 text-gray-950">
|
||||||
{nodeNames[item.family] ?? ""}{" "}
|
{nodeNames[item.family] ?? ""}{" "}
|
||||||
<span className={classNames(left ? "hidden" : "")}>
|
<span>
|
||||||
{" "}
|
{" "}
|
||||||
-
|
-
|
||||||
{item.type.split(", ").length > 2
|
{item.type.split(", ").length > 2
|
||||||
|
|
@ -113,14 +114,15 @@ export default function ParameterComponent({
|
||||||
? el
|
? el
|
||||||
: (el += `, `)}
|
: (el += `, `)}
|
||||||
</span>
|
</span>
|
||||||
{i % 2 === 0 && i > 0 && <br />}
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))
|
))
|
||||||
: item.type}
|
: item.type}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
));
|
);
|
||||||
|
});
|
||||||
|
|
||||||
}, [tooltipTitle]);
|
}, [tooltipTitle]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -145,6 +147,7 @@ export default function ParameterComponent({
|
||||||
<></>
|
<></>
|
||||||
) : (
|
) : (
|
||||||
<ShadTooltip
|
<ShadTooltip
|
||||||
|
class="max-w-[40vw] max-h-[10vh] overflow-auto custom-scroll"
|
||||||
delayDuration={0}
|
delayDuration={0}
|
||||||
content={refHtml.current}
|
content={refHtml.current}
|
||||||
side={left ? "left" : "right"}
|
side={left ? "left" : "right"}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ const ShadTooltip = (props) => {
|
||||||
side={props.side}
|
side={props.side}
|
||||||
avoidCollisions={false}
|
avoidCollisions={false}
|
||||||
sticky="always"
|
sticky="always"
|
||||||
|
className={props.class}
|
||||||
>
|
>
|
||||||
{props.content}
|
{props.content}
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
|
|
|
||||||
|
|
@ -841,7 +841,9 @@ export function updateIds(newFlow, getNodeId) {
|
||||||
export function groupByFamily(data, baseClasses, left, type) {
|
export function groupByFamily(data, baseClasses, left, type) {
|
||||||
let parentOutput: string;
|
let parentOutput: string;
|
||||||
let arrOfParent: string[] = [];
|
let arrOfParent: string[] = [];
|
||||||
let arrOfType: { family: string; type: string }[] = [];
|
let arrOfType: { family: string; type: string; component: string }[] = [];
|
||||||
|
let arrOfLength: { length: number; type: string; }[] = [];
|
||||||
|
let lastType = "";
|
||||||
Object.keys(data).map((d) => {
|
Object.keys(data).map((d) => {
|
||||||
Object.keys(data[d]).map((n) => {
|
Object.keys(data[d]).map((n) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -855,6 +857,15 @@ export function groupByFamily(data, baseClasses, left, type) {
|
||||||
if (n === type) {
|
if (n === type) {
|
||||||
parentOutput = d;
|
parentOutput = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (d !== lastType) {
|
||||||
|
arrOfLength.push({
|
||||||
|
length: Object.keys(data[d]).length,
|
||||||
|
type: d
|
||||||
|
});
|
||||||
|
|
||||||
|
lastType = d;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
@ -870,6 +881,7 @@ export function groupByFamily(data, baseClasses, left, type) {
|
||||||
arrOfType.push({
|
arrOfType.push({
|
||||||
family: d,
|
family: d,
|
||||||
type: data,
|
type: data,
|
||||||
|
component: n
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -880,6 +892,7 @@ export function groupByFamily(data, baseClasses, left, type) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(left == false){
|
||||||
let groupedBy = arrOfType.filter((object, index, self) => {
|
let groupedBy = arrOfType.filter((object, index, self) => {
|
||||||
const foundIndex = self.findIndex(
|
const foundIndex = self.findIndex(
|
||||||
(o) => o.family === object.family && o.type === object.type
|
(o) => o.family === object.family && o.type === object.type
|
||||||
|
|
@ -893,7 +906,7 @@ export function groupByFamily(data, baseClasses, left, type) {
|
||||||
if (existingGroup) {
|
if (existingGroup) {
|
||||||
existingGroup.type += `, ${item.type}`;
|
existingGroup.type += `, ${item.type}`;
|
||||||
} else {
|
} else {
|
||||||
result.push({ family: item.family, type: item.type });
|
result.push({ family: item.family, type: item.type, component: item.component });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (left == false) {
|
if (left == false) {
|
||||||
|
|
@ -903,6 +916,38 @@ export function groupByFamily(data, baseClasses, left, type) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}, []);
|
}, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
const groupedArray = [];
|
||||||
|
const groupedData = {};
|
||||||
|
|
||||||
|
arrOfType.forEach((item) => {
|
||||||
|
const { family, type, component } = item;
|
||||||
|
const key = `${family}-${type}`;
|
||||||
|
|
||||||
|
if (!groupedData[key]) {
|
||||||
|
groupedData[key] = { family, type, component: [component] };
|
||||||
|
} else {
|
||||||
|
groupedData[key].component.push(component);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const key in groupedData) {
|
||||||
|
groupedArray.push(groupedData[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedArray.forEach((object, index, self) => {
|
||||||
|
const findObj = arrOfLength.find(x => x.type == object.family);
|
||||||
|
if(object.component.length == findObj.length){
|
||||||
|
self[index]['type'] = object.type;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
self[index]['type'] = object.component.join(', ');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return groupedArray
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildTweaks(flow) {
|
export function buildTweaks(flow) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue