import { React, useState } from "react"; import { defaultTableTheme, sqlDataTypes, tableThemes } from "../data/data"; import { Collapse, Row, Col, Form, Button, Card, Popover, Checkbox, Select, AutoComplete, Toast, Empty, } from "@douyinfe/semi-ui"; import { IconMore, IconKeyStroked, IconColorPalette, IconDeleteStroked, IconCheckboxTick, IconPlus, IconSearch, } from "@douyinfe/semi-icons"; import { IllustrationNoContent, IllustrationNoContentDark, } from "@douyinfe/semi-illustrations"; export default function TableOverview(props) { const [indexActiveKey, setIndexActiveKey] = useState(""); const [tableActiveKey, setTableActiveKey] = useState(""); const [value, setValue] = useState(""); const [filteredResult, setFilteredResult] = useState( props.tables.map((t) => { return t.name; }) ); const handleStringSearch = (value) => { setFilteredResult( props.tables .map((t) => { return t.name; }) .filter((i) => i.includes(value)) ); }; const updatedField = (tid, fid, updatedValues) => { props.setTables((prev) => prev.map((table, i) => { if (tid === i) { return { ...table, fields: table.fields.map((field, j) => fid === j ? { ...field, ...updatedValues } : field ), }; } return table; }) ); }; const updateTable = (tid, updatedValues) => { props.setTables((prev) => prev.map((table, i) => { if (tid === i) { return { ...table, ...updatedValues, }; } return table; }) ); }; return ( <> } placeholder="Search..." emptyContent={
No tables found
} onSearch={(v) => handleStringSearch(v)} onChange={(v) => setValue(v)} onSelect={(v) => { const { id } = props.tables.find((t) => t.name === v); setTableActiveKey(`${id}`); document .getElementById(`scroll_table_${id}`) .scrollIntoView({ behavior: "smooth" }); }} className="w-full" />
setTableActiveKey(k)} accordion > {props.tables.length <= 0 ? (
} darkModeImage={ } title="No tables" description="Start building your diagram!" />
) : ( props.tables.map((t, i) => (
{t.name}
} itemKey={`${t.id}`}> {t.fields.map((f, j) => (
updatedField(i, j, value.values)} > { return { label: value, value: value, }; })} filter initValue={f.type} placeholder="Type" > updatedField(i, j, value.values) } >
updatedField(i, j, { [checkedValues.target.value]: checkedValues.target.checked, }) } >
updatedField(i, j, { [checkedValues.target.value]: checkedValues.target.checked, }) } >
} trigger="click" position="rightTop" showArrow >
))} {t.indices.length > 0 && ( setIndexActiveKey(itemKey)} > {t.indices.map((idx, k) => (