import { React, useState, memo } from "react"; import { defaultTableTheme, sqlDataTypes, tableThemes } from "../data/data"; import { Collapse, Row, Col, Form, Button, Card, Popover, Checkbox, Select, AutoComplete, Toast, } from "@douyinfe/semi-ui"; import { IconMore, IconKeyStroked, IconColorPalette, IconDeleteStroked, IconCheckboxTick, IconPlus, IconSearch, } from "@douyinfe/semi-icons"; const TableOverview = memo(function TableOverView(props) { const [indexActiveKey, setIndexActiveKey] = useState(""); const [tableActiveKey, setTableActiveKey] = useState(""); const updateColor = (id, c) => { const updatedTables = [...props.tables]; updatedTables[id] = { ...updatedTables[id], color: c }; props.setTables(updatedTables); }; 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 handleChange = (value) => { setValue(value); }; return ( <>
} placeholder="Search..." emptyContent={
No tables found
} onSearch={(v) => handleStringSearch(v)} onChange={(v) => handleChange(v)} onSelect={(v) => { const { id, name } = props.tables.find((t) => t.name === v); setTableActiveKey(`${id}`); document .getElementById(`${name}_scroll_id`) .scrollIntoView({ behavior: "smooth" }); }} className="w-full" />
setTableActiveKey(k)} accordion > {props.tables.map((t, i) => (
{t.name}
} itemKey={`${t.id}`}> {t.fields.map((f, j) => (
{ props.setTables((prev) => { return prev.map((p, idx) => { if (idx === i) { return { ...p, fields: p.fields.map((field, index) => index === j ? { ...field, ...value.values } : field ), }; } return p; }); }); }} > { return { label: value, value: value, }; })} filter initValue={f.type} placeholder="Type" > { const updatedTables = [...props.tables]; updatedTables[i] = { ...updatedTables[i], fields: updatedTables[i].fields.map( (field, index) => index === j ? { ...field, ...value.values } : field ), }; props.setTables(updatedTables); }} >
{ const updatedTables = [...props.tables]; updatedTables[i].fields = updatedTables[ i ].fields.map((field, index) => index === j ? { ...field, [checkedValues.target.value]: checkedValues.target.checked, } : field ); props.setTables(updatedTables); }} >
{ const updatedTables = [...props.tables]; updatedTables[i].fields = updatedTables[ i ].fields.map((field, index) => index === j ? { ...field, [checkedValues.target.value]: checkedValues.target.checked, } : field ); props.setTables(updatedTables); }} >
} trigger="click" position="rightTop" showArrow >
))} {t.indices.length > 0 && ( setIndexActiveKey(itemKey)} > {t.indices.map((idx, k) => (