Fix inputs

This commit is contained in:
1ilit 2025-05-04 21:56:10 +04:00
parent 75e3d4c8cc
commit ac15627237
5 changed files with 18 additions and 18 deletions

View File

@ -11,7 +11,6 @@ export default function SearchBar({ tables }) {
const treeData = useMemo(() => {
return tables.map(({ id, name: parentName, fields }, i) => {
console.log(fields)
const children = fields?.map(({ name }, j) => ({
tableId: id,
id: `${j}`,

View File

@ -18,11 +18,13 @@ export default function TableField({ data, tid, index }) {
const [editField, setEditField] = useState({});
return (
<div className="hover-1 my-2 flex gap-2 items-center" >
<div
id={`scroll_table_${tid}_input_${index}`}
className="hover-1 my-2 flex gap-2 items-center"
>
<DragHandle id={data.id} />
<div className="min-w-20 flex-1/3">
<Input
id={`scroll_table_${tid}_input_${index}`}
value={data.name}
validateStatus={data.name.trim() === "" ? "error" : "default"}
placeholder="Name"

View File

@ -65,13 +65,8 @@ export default function TableInfo({ data }) {
});
}}
afterChange={() => setSaveState(State.SAVING)}
renderItem={(item) => (
<TableField
key={"field_" + item.id}
data={item}
tid={data.id}
index={item.id}
/>
renderItem={(item, i) => (
<TableField data={item} tid={data.id} index={i} />
)}
/>
{data.indices.length > 0 && (

View File

@ -47,8 +47,9 @@ export default function TablesTab() {
accordion
>
<SortableList
type="table"
items={tables}
onChange={setTables}
onChange={(newTables) => setTables(newTables)}
afterChange={() => setSaveState(State.SAVING)}
renderItem={(item) => <TableListItem table={item} />}
/>

View File

@ -12,7 +12,13 @@ import {
} from "@dnd-kit/sortable";
import { SortableItem } from "./SortableItem";
export function SortableList({ items, onChange, afterChange, renderItem }) {
export function SortableList({
items,
onChange,
afterChange,
renderItem,
type = "",
}) {
const sensors = useSensors(useSensor(PointerSensor));
const handleDragEnd = (event) => {
@ -34,12 +40,9 @@ export function SortableList({ items, onChange, afterChange, renderItem }) {
onDragEnd={handleDragEnd}
>
<SortableContext items={items} strategy={verticalListSortingStrategy}>
{items.map((item) => (
<SortableItem
key={`sortable-item-${item.name ?? ""}-${item.id}`}
id={item.id}
>
{renderItem(item)}
{items.map((item, i) => (
<SortableItem id={item.id} key={`sortable-item-${type}-${item.id}`}>
{renderItem(item, i)}
</SortableItem>
))}
</SortableContext>