summaryrefslogtreecommitdiff
path: root/types/table.d.ts
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-03-25 15:55:45 +0900
committerjoonhoekim <26rote@gmail.com>2025-03-25 15:55:45 +0900
commit1a2241c40e10193c5ff7008a7b7b36cc1d855d96 (patch)
tree8a5587f10ca55b162d7e3254cb088b323a34c41b /types/table.d.ts
initial commit
Diffstat (limited to 'types/table.d.ts')
-rw-r--r--types/table.d.ts78
1 files changed, 78 insertions, 0 deletions
diff --git a/types/table.d.ts b/types/table.d.ts
new file mode 100644
index 00000000..207a0c19
--- /dev/null
+++ b/types/table.d.ts
@@ -0,0 +1,78 @@
+import type { ColumnSort, Row } from "@tanstack/react-table"
+import { type SQL } from "drizzle-orm"
+import { type z } from "zod"
+
+import { type DataTableConfig } from "@/config/data-table"
+import { type filterSchema } from "@/lib/parsers"
+
+export type Prettify<T> = {
+ [K in keyof T]: T[K]
+} & {}
+
+export type StringKeyOf<TData> = Extract<keyof TData, string>
+
+export interface SearchParams {
+ [key: string]: string | string[] | undefined
+}
+
+export interface Option {
+ label: string
+ value: string | number
+ icon?: React.ComponentType<{ className?: string }>
+ count?: number
+}
+
+export interface ExtendedColumnSort<TData> extends Omit<ColumnSort, "id"> {
+ id: StringKeyOf<TData>
+}
+
+export type ExtendedSortingState<TData> = ExtendedColumnSort<TData>[]
+
+export type ColumnType = DataTableConfig["columnTypes"][number]
+
+export type FilterOperator = DataTableConfig["globalOperators"][number]
+
+export type JoinOperator = DataTableConfig["joinOperators"][number]["value"]
+
+export interface DataTableFilterField<TData> {
+ id: StringKeyOf<TData>
+ label: string
+ placeholder?: string
+ options?: Option[]
+}
+
+export interface DataTableAdvancedFilterField<TData>
+ extends DataTableFilterField<TData> {
+ type: ColumnType
+}
+
+export type Filter<TData> = Prettify<
+ Omit<z.infer<typeof filterSchema>, "id"> & {
+ id: StringKeyOf<TData>
+ }
+>
+
+export interface DataTableRowAction<TData> {
+ row: Row<TData>
+ type: "responseDetail"|"signature"|"update" | "delete" | "user" | "pemission" | "invite" | "items" | "attachment" |"comments" | "open" | "select" | "files"
+}
+
+export interface QueryBuilderOpts {
+ where?: SQL
+ orderBy?: SQL
+ distinct?: boolean
+ nullish?: boolean
+}
+
+
+declare module '@tanstack/react-table' {
+ interface ColumnMeta<TData extends RowData, TValue> {
+ // Custom column meta properties
+ excelHeader?: string
+ group?: string
+ type?: string
+ paddingFactor?: number
+ minWidth?: number
+ maxWidth?: number
+ }
+}