@povio/ui 3.4.0-rc.18 → 3.4.0-rc.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,15 @@
1
- import { ColumnDef, ColumnOrderState, VisibilityState } from "@tanstack/react-table";
1
+ import { ColumnDef, ColumnOrderState, ColumnVisibilityState, RowData, StockFeatures } from "@tanstack/react-table";
2
2
  //#region src/components/table/ColumnConfig.d.ts
3
- interface ColumnConfigModalProps<TData, TValue> {
3
+ type ColumnDef$1<TData extends RowData, TValue = unknown> = ColumnDef<StockFeatures, TData, TValue>;
4
+ type VisibilityState = ColumnVisibilityState;
5
+ interface ColumnConfigModalProps<TData extends RowData, TValue> {
4
6
  isOpen: boolean;
5
7
  onClose: () => void;
6
- configColumns: ColumnDef<TData, TValue>[];
8
+ configColumns: ColumnDef$1<TData, TValue>[];
7
9
  visibleColumns: VisibilityState;
8
10
  onVisibilityChange: (visibleColumns: VisibilityState) => void;
9
11
  onOrderChange: (columnOrder: ColumnOrderState) => void;
10
12
  }
11
- declare function ColumnConfigModal<TData, TValue>({ isOpen, onClose, configColumns, visibleColumns, onVisibilityChange, onOrderChange }: ColumnConfigModalProps<TData, TValue>): import("react/jsx-runtime").JSX.Element | null;
13
+ declare function ColumnConfigModal<TData extends RowData, TValue>({ isOpen, onClose, configColumns, visibleColumns, onVisibilityChange, onOrderChange }: ColumnConfigModalProps<TData, TValue>): import("react/jsx-runtime").JSX.Element | null;
12
14
  //#endregion
13
15
  export { ColumnConfigModal, ColumnConfigModalProps };
@@ -1,11 +1,12 @@
1
1
  import { TableProps } from "./Table.js";
2
+ import { RowData } from "@tanstack/react-table";
2
3
  //#region src/components/table/InfiniteTable.d.ts
3
- interface InfiniteTableWrapperProps<T> extends Omit<InfiniteTableProps<T>, "columns"> {}
4
- interface InfiniteTableProps<T> extends TableProps<T> {
4
+ interface InfiniteTableWrapperProps<T extends RowData> extends Omit<InfiniteTableProps<T>, "columns"> {}
5
+ interface InfiniteTableProps<T extends RowData> extends TableProps<T> {
5
6
  hasNextPage: boolean;
6
7
  isFetchingNextPage?: boolean;
7
8
  fetchNextPage: () => void;
8
9
  }
9
- declare const InfiniteTable: <T>({ hasNextPage, isFetchingNextPage, fetchNextPage, ...rest }: InfiniteTableProps<T>) => import("react/jsx-runtime").JSX.Element;
10
+ declare const InfiniteTable: <T extends RowData>({ hasNextPage, isFetchingNextPage, fetchNextPage, ...rest }: InfiniteTableProps<T>) => import("react/jsx-runtime").JSX.Element;
10
11
  //#endregion
11
12
  export { InfiniteTable, InfiniteTableProps, InfiniteTableWrapperProps };
@@ -1,13 +1,13 @@
1
1
  import { TableProps } from "./Table.js";
2
2
  import { Dispatch, SetStateAction } from "react";
3
- import { PaginationState } from "@tanstack/react-table";
3
+ import { PaginationState, RowData } from "@tanstack/react-table";
4
4
  //#region src/components/table/PaginatedTable.d.ts
5
- interface PaginatedTableWrapperProps<T> extends Omit<PaginatedTableProps<T>, "columns"> {}
6
- interface PaginatedTableProps<T> extends TableProps<T> {
5
+ interface PaginatedTableWrapperProps<T extends RowData> extends Omit<PaginatedTableProps<T>, "columns"> {}
6
+ interface PaginatedTableProps<T extends RowData> extends TableProps<T> {
7
7
  totalItems: number;
8
8
  pagination: PaginationState;
9
9
  setPagination: Dispatch<SetStateAction<PaginationState>>;
10
10
  }
11
- declare const PaginatedTable: <T>({ pagination, setPagination, items, totalItems, ...rest }: PaginatedTableProps<T>) => import("react/jsx-runtime").JSX.Element;
11
+ declare const PaginatedTable: <T extends RowData>({ pagination, setPagination, items, totalItems, ...rest }: PaginatedTableProps<T>) => import("react/jsx-runtime").JSX.Element;
12
12
  //#endregion
13
13
  export { PaginatedTable, PaginatedTableProps, PaginatedTableWrapperProps };
@@ -1,16 +1,20 @@
1
1
  import { TableRowVariantProps } from "./table.cva.js";
2
2
  import { ComponentType, Dispatch, SetStateAction } from "react";
3
3
  import { DragEndEvent, UniqueIdentifier } from "@dnd-kit/core";
4
- import { ColumnDef, ColumnOrderState, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState } from "@tanstack/react-table";
4
+ import { ColumnDef, ColumnOrderState, ColumnVisibilityState, OnChangeFn, Row, RowData, RowSelectionState, SortingState, StockFeatures, Table } from "@tanstack/react-table";
5
5
  import { TFunction } from "i18next";
6
6
  //#region src/components/table/Table.d.ts
7
- type BulkSelectionActionsComponent<T> = ComponentType<{
8
- table: Table<T>;
7
+ type ColumnDef$1<TData extends RowData, TValue = unknown> = ColumnDef<StockFeatures, TData, TValue>;
8
+ type ReactTable<TData extends RowData> = Table<StockFeatures, TData>;
9
+ type Row$1<TData extends RowData> = Row<StockFeatures, TData>;
10
+ type VisibilityState = ColumnVisibilityState;
11
+ type BulkSelectionActionsComponent<T extends RowData> = ComponentType<{
12
+ table: ReactTable<T>;
9
13
  }>;
10
- interface TableWrapperProps<T> extends Omit<TableProps<T>, "columns"> {}
11
- interface TableProps<T> extends TableRowVariantProps {
14
+ interface TableWrapperProps<T extends RowData> extends Omit<TableProps<T>, "columns"> {}
15
+ interface TableProps<T extends RowData> extends TableRowVariantProps {
12
16
  items: T[];
13
- columns: ((t: TFunction) => ColumnDef<T>[]) | ColumnDef<T>[];
17
+ columns: ((t: TFunction) => ColumnDef$1<T>[]) | ColumnDef$1<T>[];
14
18
  showCellBorder?: boolean;
15
19
  onRowClick?: (row: T) => void;
16
20
  onDoubleClick?: (row: T) => void;
@@ -26,11 +30,11 @@ interface TableProps<T> extends TableRowVariantProps {
26
30
  onDragEnd?: (event: DragEndEvent) => void;
27
31
  onReorder?: (reorderedItems: T[]) => void;
28
32
  getRowId?: (row: T) => UniqueIdentifier;
29
- enableRowSelection?: boolean | ((row: Row<T>) => boolean);
30
- enableMultiRowSelection?: boolean | ((row: Row<T>) => boolean);
33
+ enableRowSelection?: boolean | ((row: Row$1<T>) => boolean);
34
+ enableMultiRowSelection?: boolean | ((row: Row$1<T>) => boolean);
31
35
  defaultSelectedRows?: RowSelectionState;
32
36
  onRowSelectionChange?: OnChangeFn<RowSelectionState>;
33
37
  }
34
- declare const Table$1: <T>({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection, defaultSelectedRows, onRowSelectionChange, ...props }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
38
+ declare const Table$1: <T extends RowData>({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection, defaultSelectedRows, onRowSelectionChange, ...props }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
35
39
  //#endregion
36
40
  export { BulkSelectionActionsComponent, Table$1 as Table, TableProps, TableWrapperProps };
@@ -14,9 +14,14 @@ import { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, us
14
14
  import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
15
15
  import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
16
16
  import { CSS } from "@dnd-kit/utilities";
17
- import { flexRender, getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
17
+ import { createPaginatedRowModel, createSortedRowModel, flexRender, stockFeatures, tableFeatures, useTable } from "@tanstack/react-table";
18
18
  import i18next from "i18next";
19
19
  //#region src/components/table/Table.tsx
20
+ const tableFeaturesConfig = tableFeatures({
21
+ ...stockFeatures,
22
+ sortedRowModel: createSortedRowModel(),
23
+ paginatedRowModel: createPaginatedRowModel()
24
+ });
20
25
  const CustomCellContext = (context) => {
21
26
  return {
22
27
  ...context,
@@ -81,9 +86,6 @@ const Table$1 = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, cl
81
86
  const tableDataCva = UIOverrides.useCva("table.dataCva", tableDataDefinition);
82
87
  const ref = useRef(null);
83
88
  const { listeners } = useTableNav();
84
- const getCoreRowModelCallback = useCallback(getCoreRowModel, []);
85
- const getSortedRowModelCallback = useCallback(getSortedRowModel, []);
86
- const getPaginationRowModelCallback = useCallback(getPaginationRowModel, []);
87
89
  const data = useMemo(() => items ?? [], [items]);
88
90
  const [internalSelectedRows, setInternalSelectedRows] = useState({});
89
91
  const { rowSelection, handleRowSelectionChange } = useMemo(() => {
@@ -117,7 +119,8 @@ const Table$1 = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, cl
117
119
  setIsSticky(entry.intersectionRatio < 1);
118
120
  }, []);
119
121
  const { ref: stickyRef } = useIntersectionObserver({ onIntersectionChange });
120
- const table = useReactTable({
122
+ const table = useTable({
123
+ features: tableFeaturesConfig,
121
124
  data,
122
125
  columns: tableColumns,
123
126
  state: {
@@ -127,9 +130,6 @@ const Table$1 = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, cl
127
130
  rowSelection
128
131
  },
129
132
  rowCount: items.length,
130
- getCoreRowModel: getCoreRowModelCallback(),
131
- getSortedRowModel: getSortedRowModelCallback(),
132
- getPaginationRowModel: getPaginationRowModelCallback(),
133
133
  manualPagination: true,
134
134
  onColumnOrderChange: setColumnOrder,
135
135
  onColumnVisibilityChange: setColumnVisibility,
@@ -1,25 +1,28 @@
1
1
  import { FieldPath } from "../components/inputs/shared/form.binding.js";
2
2
  import { ReactNode } from "react";
3
3
  import { z } from "zod";
4
- import { CellContext, ColumnDef, ColumnMeta } from "@tanstack/react-table";
4
+ import { CellContext, ColumnDef, ColumnMeta, RowData, StockFeatures } from "@tanstack/react-table";
5
5
  //#region src/helpers/dynamicColumns.d.ts
6
+ type CellContext$1<TData extends RowData, TValue> = CellContext<StockFeatures, TData, TValue>;
7
+ type ColumnDef$1<TData extends RowData, TValue = unknown> = ColumnDef<StockFeatures, TData, TValue>;
8
+ type ColumnMeta$1<TData extends RowData, TValue> = ColumnMeta<StockFeatures, TData, TValue>;
6
9
  type NestedTypeFromKey<T, K extends string> = K extends keyof T ? T[K] : K extends `${infer First}.${infer Rest}` ? First extends keyof T ? NestedTypeFromKey<T[First], Rest> : never : never;
7
10
  type SchemaType<TSchema extends z.ZodObject<any>> = z.infer<TSchema>;
8
11
  type SchemaKey<TSchema extends z.ZodObject<any>> = keyof SchemaType<TSchema>;
9
12
  type NestedSchemaKey<TSchema extends z.ZodObject<any>> = FieldPath<SchemaType<TSchema>>;
10
13
  type SchemaValue<TSchema extends z.ZodObject<any>> = SchemaType<TSchema>[SchemaKey<TSchema>];
11
- type ColumnMetaType<TSchema extends z.ZodObject<any>> = ColumnMeta<SchemaType<TSchema>, SchemaValue<TSchema>>;
14
+ type ColumnMetaType<TSchema extends z.ZodObject<any>> = ColumnMeta$1<SchemaType<TSchema>, SchemaValue<TSchema>>;
12
15
  type GetNestedValueType<TSchema extends z.ZodObject<any>, K extends string> = NestedTypeFromKey<SchemaType<TSchema>, K>;
13
16
  type NestedSchemaKeyOrString<TSchema extends z.ZodObject<any>> = NestedSchemaKey<TSchema> | (string & {});
14
- type DynamicColumnDef<TSchema extends z.ZodObject<any>, TValue = any> = Omit<ColumnDef<SchemaType<TSchema>, TValue>, "accessorKey" | "cell"> & {
15
- cell?: ((props: CellContext<SchemaType<TSchema>, TValue>) => any) | NestedSchemaKey<TSchema>;
17
+ type DynamicColumnDef<TSchema extends z.ZodObject<any>, TValue = any> = Omit<ColumnDef$1<SchemaType<TSchema>, TValue>, "accessorKey" | "cell"> & {
18
+ cell?: ((props: CellContext$1<SchemaType<TSchema>, TValue>) => any) | NestedSchemaKey<TSchema>;
16
19
  };
17
- type ColumnsConfig<TSchema extends z.ZodObject<any>> = { [K in NestedSchemaKey<TSchema>]?: DynamicColumnDef<TSchema, GetNestedValueType<TSchema, K>> | ((props: CellContext<SchemaType<TSchema>, GetNestedValueType<TSchema, K>>) => any) | NestedSchemaKey<TSchema> | boolean; };
18
- type CustomColumnDef<TSchema extends z.ZodObject<any>> = Omit<ColumnDef<SchemaType<TSchema>, any>, "accessorKey" | "cell"> & {
20
+ type ColumnsConfig<TSchema extends z.ZodObject<any>> = { [K in NestedSchemaKey<TSchema>]?: DynamicColumnDef<TSchema, GetNestedValueType<TSchema, K>> | ((props: CellContext$1<SchemaType<TSchema>, GetNestedValueType<TSchema, K>>) => any) | NestedSchemaKey<TSchema> | boolean; };
21
+ type CustomColumnDef<TSchema extends z.ZodObject<any>> = Omit<ColumnDef$1<SchemaType<TSchema>, any>, "accessorKey" | "cell"> & {
19
22
  accessorKey?: NestedSchemaKeyOrString<TSchema>;
20
- cell?: ((props: CellContext<SchemaType<TSchema>, any>) => any) | NestedSchemaKey<TSchema>;
23
+ cell?: ((props: CellContext$1<SchemaType<TSchema>, any>) => any) | NestedSchemaKey<TSchema>;
21
24
  };
22
- type CustomColumnsConfig<TSchema extends z.ZodObject<any>> = Record<string, CustomColumnDef<TSchema> | ((props: CellContext<SchemaType<TSchema>, undefined>) => any) | NestedSchemaKey<TSchema>>;
25
+ type CustomColumnsConfig<TSchema extends z.ZodObject<any>> = Record<string, CustomColumnDef<TSchema> | ((props: CellContext$1<SchemaType<TSchema>, undefined>) => any) | NestedSchemaKey<TSchema>>;
23
26
  interface DynamicColumnsOptions<TSchema extends z.ZodObject<any>> {
24
27
  columns?: ColumnsConfig<TSchema>;
25
28
  customColumns?: CustomColumnsConfig<TSchema>;
@@ -35,9 +38,9 @@ interface DynamicColumnsOptions<TSchema extends z.ZodObject<any>> {
35
38
  }
36
39
  interface DynamicColumnsParams<TSchema extends z.ZodObject<any>> {
37
40
  schema: TSchema;
38
- preset?: ColumnDef<SchemaType<TSchema>>[];
41
+ preset?: ColumnDef$1<SchemaType<TSchema>>[];
39
42
  options: DynamicColumnsOptions<TSchema>;
40
43
  }
41
- declare const dynamicColumns: <TSchema extends z.ZodObject<any>>({ schema, preset, options }: DynamicColumnsParams<TSchema>) => ColumnDef<SchemaType<TSchema>>[];
44
+ declare const dynamicColumns: <TSchema extends z.ZodObject<any>>({ schema, preset, options }: DynamicColumnsParams<TSchema>) => ColumnDef$1<SchemaType<TSchema>>[];
42
45
  //#endregion
43
46
  export { DynamicColumnsOptions, dynamicColumns };
@@ -1,15 +1,17 @@
1
- import { ColumnDef, ColumnOrderState, VisibilityState } from "@tanstack/react-table";
1
+ import { ColumnDef, ColumnOrderState, ColumnVisibilityState, RowData, StockFeatures } from "@tanstack/react-table";
2
2
  //#region src/hooks/useTableColumnConfig.d.ts
3
+ type ColumnDef$1<TData extends RowData, TValue = unknown> = ColumnDef<StockFeatures, TData, TValue>;
4
+ type VisibilityState = ColumnVisibilityState;
3
5
  interface UseTableColumnConfigOptions {
4
6
  visibleColumns?: VisibilityState;
5
7
  columnOrder?: ColumnOrderState;
6
8
  onVisibilityChange?: (value: VisibilityState) => void;
7
9
  onOrderChange?: (value: ColumnOrderState) => void;
8
10
  }
9
- declare function useTableColumnConfig<TData, TValue>(defaultColumns: ColumnDef<TData, TValue>[], options?: UseTableColumnConfigOptions): {
10
- configColumns: ColumnDef<TData, TValue>[];
11
- columns: ColumnDef<TData, TValue>[];
12
- visibleColumns: VisibilityState;
11
+ declare function useTableColumnConfig<TData extends RowData, TValue>(defaultColumns: ColumnDef$1<TData, TValue>[], options?: UseTableColumnConfigOptions): {
12
+ configColumns: ColumnDef$1<TData, TValue>[];
13
+ columns: ColumnDef$1<TData, TValue>[];
14
+ visibleColumns: ColumnVisibilityState;
13
15
  columnOrder: ColumnOrderState;
14
16
  onVisibilityChange: (value: VisibilityState) => void;
15
17
  onOrderChange: (value: ColumnOrderState) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "3.4.0-rc.18",
3
+ "version": "3.4.0-rc.19",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -680,7 +680,7 @@
680
680
  "@react-stately/datepicker": "^3.16.0",
681
681
  "@tanstack/react-form": "^1.33.2",
682
682
  "@tanstack/react-query": "^5.89.0",
683
- "@tanstack/react-table": "^8.21.3",
683
+ "@tanstack/react-table": "9.0.0",
684
684
  "@tiptap/core": "^3.19.0",
685
685
  "@tiptap/extension-color": "^3.19.0",
686
686
  "@tiptap/extension-heading": "^3.19.0",