import { React, useState } from "react"; import { defaultTableTheme, sqlDataTypes, tableThemes } from "../data/data"; import { Collapse, Input, 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"; export default function TableOverview(props) { const [indexActiveKey, setIndexActiveKey] = useState(""); const [indexActiveKeyTable, setIndexActiveKeyTable] = 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); setIndexActiveKeyTable([`${id}`]); document .getElementById(`${name}_scroll_id`) .scrollIntoView({ behavior: "smooth" }); }} className="w-full" />
setIndexActiveKeyTable(k)} > {props.tables.map((t, i) => (
} itemKey={`${t.id}`} > {t.fields.map((f, j) => (
{ const updatedTables = [...props.tables]; updatedTables[i].fields = updatedTables[i].fields.map( (field, index) => index === j ? { ...field, ...value.values } : field ); props.setTables(updatedTables); }} > { return { label: value, value: value, }; })} filter initValue={f.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) => (