Skip to content

Commit

Permalink
Re-export tanstack imports
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfheij-sil committed Jul 19, 2024
1 parent fcae883 commit 3d8a465
Show file tree
Hide file tree
Showing 8 changed files with 654 additions and 629 deletions.
327 changes: 165 additions & 162 deletions lib/platform-bible-react/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.cjs.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions lib/platform-bible-react/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as SelectPrimitive from '@radix-ui/react-select';
import * as SliderPrimitive from '@radix-ui/react-slider';
import * as SwitchPrimitives from '@radix-ui/react-switch';
import * as TabsPrimitive from '@radix-ui/react-tabs';
import { ColumnDef, Row, Table as tsTable } from '@tanstack/react-table';
import { ColumnDef as TSColumnDef, Row as TSRow, Table as TSTable } from '@tanstack/react-table';
import { VariantProps } from 'class-variance-authority';
import React$1 from 'react';
import { ChangeEvent, ChangeEventHandler, FocusEventHandler, MouseEvent as MouseEvent$1, MouseEventHandler, MutableRefObject, PropsWithChildren, ReactNode, SyntheticEvent } from 'react';
Expand Down Expand Up @@ -154,13 +154,16 @@ export type BookChapterControlProps = {
handleSubmit: (scrRef: ScriptureReference) => void;
};
export declare function BookChapterControl({ scrRef, handleSubmit }: BookChapterControlProps): import("react/jsx-runtime").JSX.Element;
export type ColumnDef<TData, TValue = unknown> = TSColumnDef<TData, TValue>;
export type RowContents<TData> = TSRow<TData>;
export type TableContents<TData> = TSTable<TData>;
export interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
enablePagination?: boolean;
showPaginationControls?: boolean;
showColumnVisibilityControls?: boolean;
onRowClickHandler?: (row: Row<TData>, table: tsTable<TData>) => void;
onRowClickHandler?: (row: RowContents<TData>, table: TableContents<TData>) => void;
}
export declare function DataTable<TData, TValue>({ columns, data, enablePagination, showPaginationControls, showColumnVisibilityControls, onRowClickHandler, }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
export declare const buttonVariants: (props?: ({
Expand Down
907 changes: 455 additions & 452 deletions lib/platform-bible-react/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { useState } from 'react';

import {
ColumnDef,
ColumnDef as TSColumnDef,
ColumnFiltersState,
Row,
SortingState,
VisibilityState,
flexRender,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
getSortedRowModel,
Row as TSRow,
SortDirection as TSSortDirection,
SortingState,
Table as TSTable,
useReactTable,
Table as tsTable,
VisibilityState,
} from '@tanstack/react-table';

import {
Expand All @@ -27,13 +28,18 @@ import { Button } from '@/components/shadcn-ui/button';
import DataTablePagination from './data-table-pagination.component';
import DataTableViewOptions from './data-table-column-toggle.component';

export type ColumnDef<TData, TValue = unknown> = TSColumnDef<TData, TValue>;
export type RowContents<TData> = TSRow<TData>;
export type TableContents<TData> = TSTable<TData>;
export type SortDirection = TSSortDirection;

interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
enablePagination?: boolean;
showPaginationControls?: boolean;
showColumnVisibilityControls?: boolean;
onRowClickHandler?: (row: Row<TData>, table: tsTable<TData>) => void;
onRowClickHandler?: (row: RowContents<TData>, table: TableContents<TData>) => void;
}

function DataTable<TData, TValue>({
Expand Down Expand Up @@ -71,7 +77,7 @@ function DataTable<TData, TValue>({
return (
<div>
{showColumnVisibilityControls && <DataTableViewOptions table={table} />}
<div className="pr-twp">
<div className="pr-twp pr-font-sans">
<Table>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import {
CircleXIcon,
CircleHelpIcon,
} from 'lucide-react';
import { ColumnDef, Row, SortDirection, Table } from '@tanstack/react-table';
import { LanguageStrings } from 'platform-bible-utils';
import { Button } from '@/components/shadcn-ui/button';
import DataTable from '@/components/advanced-components/data-table/data-table.component';
import DataTable, {
ColumnDef,
RowContents,
SortDirection,
TableContents,
} from '@/components/advanced-components/data-table/data-table.component';

export type Status = true | false | undefined;

Expand Down Expand Up @@ -160,7 +164,10 @@ function InventoryDataTable({
const countLabel = localizedStrings['%webView_inventory_table_header_count%'];
const statusLabel = localizedStrings['%webView_inventory_table_header_status%'];

const rowClickHandler = (row: Row<CharacterData>, table: Table<CharacterData>) => {
const rowClickHandler = (
row: RowContents<CharacterData>,
table: TableContents<CharacterData>,
) => {
table.toggleAllRowsSelected(false); // this is pretty hacky, and also prevents us from selecting multiple rows
row.toggleSelected(undefined);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ColumnDef, SortDirection } from '@tanstack/react-table';
import {
ColumnDef,
SortDirection,
} from '@/components/advanced-components/data-table/data-table.component';
import { Button } from '../../..';

type MyDataType = {
Expand Down

0 comments on commit 3d8a465

Please sign in to comment.