mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-03 23:11:00 +02:00
Squashed 'ai-context/workbench-ui/' content from commit 32e36a5c
git-subtree-dir: ai-context/workbench-ui git-subtree-split: 32e36a5c2131e429a7081cfaf67dabad3193cda3
This commit is contained in:
commit
a8390532f7
310 changed files with 56430 additions and 0 deletions
68
src/model/knowledge-core-table.tsx
Normal file
68
src/model/knowledge-core-table.tsx
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { createColumnHelper } from "@tanstack/react-table";
|
||||
import { Checkbox } from "@chakra-ui/react";
|
||||
|
||||
/**
|
||||
* Knowledge core data structure for the knowledge core table
|
||||
* Represents a single knowledge core with its metadata and properties
|
||||
*/
|
||||
export type KnowledgeCore = {
|
||||
id: string; // Unique identifier for the knowledge core
|
||||
};
|
||||
|
||||
// Create a column helper instance for type-safe column definitions
|
||||
export const columnHelper = createColumnHelper<KnowledgeCore>();
|
||||
|
||||
/**
|
||||
* Helper function to determine the selection state of the table header
|
||||
* checkbox
|
||||
* Returns the appropriate state for the "select all" checkbox
|
||||
* @param {Object} table - React Table instance
|
||||
* @returns {boolean|string} - true if all selected, "indeterminate" if some
|
||||
* selected, false if none
|
||||
*/
|
||||
const selectionState = (table) => {
|
||||
if (table.getIsAllRowsSelected()) return true;
|
||||
if (table.getIsSomeRowsSelected()) return "indeterminate";
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Column definitions for the flow table
|
||||
* Defines how each column should be rendered and what data it displays
|
||||
*/
|
||||
export const columns = [
|
||||
// Selection column - provides row selection functionality with checkboxes
|
||||
columnHelper.display({
|
||||
id: "select",
|
||||
header: ({ table }) => (
|
||||
// Header checkbox for selecting/deselecting all rows
|
||||
<Checkbox.Root
|
||||
size="sm"
|
||||
variant="solid"
|
||||
checked={selectionState(table)}
|
||||
onChange={table.getToggleAllRowsSelectedHandler()}
|
||||
>
|
||||
<Checkbox.HiddenInput />
|
||||
<Checkbox.Control />
|
||||
</Checkbox.Root>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
// Individual row checkbox for selecting/deselecting single rows
|
||||
<Checkbox.Root
|
||||
size="sm"
|
||||
variant="solid"
|
||||
checked={row.getIsSelected()}
|
||||
onChange={row.getToggleSelectedHandler()}
|
||||
>
|
||||
<Checkbox.HiddenInput />
|
||||
<Checkbox.Control />
|
||||
</Checkbox.Root>
|
||||
),
|
||||
}),
|
||||
|
||||
// ID column - displays the flow ID
|
||||
columnHelper.accessor("id", {
|
||||
header: "ID",
|
||||
cell: (info) => info.getValue(),
|
||||
}),
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue