2022-01-14 04:25:47 +00:00
|
|
|
<template>
|
2022-04-23 19:28:48 +00:00
|
|
|
<component :is="nodesComp" />
|
|
|
|
<component v-if="leftNodesComp" :is="leftNodesComp" />
|
|
|
|
<component v-if="rightNodesComp" :is="rightNodesComp" />
|
2022-03-20 18:57:45 +00:00
|
|
|
<Links v-if="branches" :links="unref(branches)" />
|
2022-01-14 04:25:47 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-23 19:28:48 +00:00
|
|
|
<script lang="tsx">
|
2022-03-04 03:39:48 +00:00
|
|
|
import "components/common/table.css";
|
2022-03-20 18:57:45 +00:00
|
|
|
import { GenericTreeNode, TreeBranch } from "features/trees/tree";
|
2022-04-23 19:28:48 +00:00
|
|
|
import { coerceComponent, processedPropType, renderJSX, unwrapRef } from "util/vue";
|
|
|
|
import { Component, defineComponent, shallowRef, toRefs, unref, watchEffect } from "vue";
|
2022-03-20 18:57:45 +00:00
|
|
|
import Links from "features/links/Links.vue";
|
2022-04-23 19:28:48 +00:00
|
|
|
import { jsx } from "features/feature";
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
nodes: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<GenericTreeNode[][]>(Array),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
leftSideNodes: processedPropType<GenericTreeNode[]>(Array),
|
2022-03-20 18:57:45 +00:00
|
|
|
rightSideNodes: processedPropType<GenericTreeNode[]>(Array),
|
|
|
|
branches: processedPropType<TreeBranch[]>(Array)
|
2022-01-25 04:25:34 +00:00
|
|
|
},
|
2022-04-23 19:28:48 +00:00
|
|
|
components: { Links },
|
|
|
|
setup(props) {
|
|
|
|
const { nodes, leftSideNodes, rightSideNodes } = toRefs(props);
|
|
|
|
|
|
|
|
const nodesComp = shallowRef<Component | "">();
|
|
|
|
watchEffect(() => {
|
|
|
|
const currNodes = unwrapRef(nodes);
|
|
|
|
nodesComp.value = coerceComponent(
|
|
|
|
jsx(() => (
|
|
|
|
<>
|
|
|
|
{currNodes.map(row => (
|
2022-04-24 18:41:37 +00:00
|
|
|
<span class="row tree-row" style="margin: 50px auto;">
|
|
|
|
{row.map(renderJSX)}
|
|
|
|
</span>
|
2022-04-23 19:28:48 +00:00
|
|
|
))}
|
|
|
|
</>
|
|
|
|
))
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
const leftNodesComp = shallowRef<Component | "">();
|
|
|
|
watchEffect(() => {
|
|
|
|
const currNodes = unwrapRef(leftSideNodes);
|
|
|
|
leftNodesComp.value = currNodes
|
|
|
|
? coerceComponent(
|
|
|
|
jsx(() => (
|
|
|
|
<span class="left-side-nodes small">{currNodes.map(renderJSX)}</span>
|
|
|
|
))
|
|
|
|
)
|
|
|
|
: "";
|
|
|
|
});
|
|
|
|
|
|
|
|
const rightNodesComp = shallowRef<Component | "">();
|
|
|
|
watchEffect(() => {
|
|
|
|
const currNodes = unwrapRef(rightSideNodes);
|
|
|
|
rightNodesComp.value = currNodes
|
|
|
|
? coerceComponent(
|
|
|
|
jsx(() => <span class="side-nodes small">{currNodes.map(renderJSX)}</span>)
|
|
|
|
)
|
|
|
|
: "";
|
|
|
|
});
|
2022-02-27 19:49:34 +00:00
|
|
|
|
|
|
|
return {
|
2022-04-23 19:28:48 +00:00
|
|
|
unref,
|
|
|
|
nodesComp,
|
|
|
|
leftNodesComp,
|
|
|
|
rightNodesComp
|
2022-02-27 19:49:34 +00:00
|
|
|
};
|
2022-01-25 04:25:34 +00:00
|
|
|
}
|
2022-01-25 04:23:30 +00:00
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.left-side-nodes {
|
|
|
|
position: absolute;
|
|
|
|
left: 15px;
|
|
|
|
top: 65px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.side-nodes {
|
|
|
|
position: absolute;
|
|
|
|
right: 15px;
|
|
|
|
top: 65px;
|
|
|
|
}
|
2022-04-23 19:28:48 +00:00
|
|
|
|
2022-04-24 18:41:37 +00:00
|
|
|
.left-side-nodes :deep(.treeNode),
|
|
|
|
.side-nodes :deep(.treeNode) {
|
|
|
|
margin: 20px auto;
|
|
|
|
}
|
|
|
|
|
2022-04-23 19:28:48 +00:00
|
|
|
.small :deep(.treeNode) {
|
|
|
|
height: 60px;
|
|
|
|
width: 60px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.small :deep(.treeNode) > *:first-child {
|
|
|
|
font-size: 30px;
|
|
|
|
}
|
2022-01-14 04:25:47 +00:00
|
|
|
</style>
|