gantri-components 2.34.0-beta.5 → 2.34.0-beta.7

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,3 +1,3 @@
1
- import { BaseDataType } from '../../table.types';
1
+ import { BaseTableDataType } from '../../table.types';
2
2
  import { TableFooterProps } from './table-footer.types';
3
- export declare const TableFooter: <DataType extends BaseDataType>(props: TableFooterProps<DataType>) => JSX.Element;
3
+ export declare const TableFooter: <DataType extends BaseTableDataType>(props: TableFooterProps<DataType>) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { Table } from '@tanstack/react-table';
2
- import { BaseDataType } from '../../table.types';
3
- export type TableFooterProps<DataType extends BaseDataType> = {
2
+ import { BaseTableDataType } from '../../table.types';
3
+ export type TableFooterProps<DataType extends BaseTableDataType> = {
4
4
  table: Table<DataType>;
5
5
  };
@@ -1,3 +1,3 @@
1
- import { BaseDataType } from '../../table.types';
1
+ import { BaseTableDataType } from '../../table.types';
2
2
  import { TableHeaderProps } from './table-header.types';
3
- export declare const TableHeader: <DataType extends BaseDataType>(props: TableHeaderProps<DataType>) => JSX.Element;
3
+ export declare const TableHeader: <DataType extends BaseTableDataType>(props: TableHeaderProps<DataType>) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { Table } from '@tanstack/react-table';
2
- import { BaseDataType, GetHeaderCellProps } from '../../table.types';
3
- export type TableHeaderProps<DataType extends BaseDataType> = {
2
+ import { BaseTableDataType, GetHeaderCellProps } from '../../table.types';
3
+ export type TableHeaderProps<DataType extends BaseTableDataType> = {
4
4
  getHeaderCellProps: GetHeaderCellProps<DataType> | undefined;
5
5
  table: Table<DataType>;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { BaseDataType } from '../../../../table.types';
2
+ import { BaseTableDataType } from '../../../../table.types';
3
3
  import { UseDragAndDropProps } from './use-drag-and-drop.types';
4
- export declare const useDragAndDrop: <DataType extends BaseDataType>(props: UseDragAndDropProps<DataType>) => {
4
+ export declare const useDragAndDrop: <DataType extends BaseTableDataType>(props: UseDragAndDropProps<DataType>) => {
5
5
  dragAndDropRef: import("react").RefObject<HTMLTableRowElement>;
6
6
  isDragging: boolean;
7
7
  };
@@ -1,6 +1,6 @@
1
1
  import { Row } from '@tanstack/react-table';
2
- import { BaseDataType } from '../../../../table.types';
3
- export interface UseDragAndDropProps<DataType extends BaseDataType> {
2
+ import { BaseTableDataType } from '../../../../table.types';
3
+ export interface UseDragAndDropProps<DataType extends BaseTableDataType> {
4
4
  enableReordering: boolean;
5
5
  handleOnReorder: () => Promise<void>;
6
6
  index: number;
@@ -1,3 +1,3 @@
1
- import { BaseDataType } from '../../table.types';
1
+ import { BaseTableDataType } from '../../table.types';
2
2
  import { TableRowProps } from './table-row.types';
3
- export declare const TableRow: <DataType extends BaseDataType>(props: TableRowProps<DataType>) => JSX.Element;
3
+ export declare const TableRow: <DataType extends BaseTableDataType>(props: TableRowProps<DataType>) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { Row } from '@tanstack/react-table';
2
- import { BaseDataType, CustomRowProps, GetCellProps, OnRowClick } from '../../table.types';
3
- export interface TableRowProps<DataType extends BaseDataType> {
2
+ import { BaseTableDataType, CustomRowProps, GetCellProps, OnRowClick } from '../../table.types';
3
+ export interface TableRowProps<DataType extends BaseTableDataType> {
4
4
  customRowProps: CustomRowProps;
5
5
  enableReordering: boolean;
6
6
  getCellProps: GetCellProps<DataType> | undefined;
@@ -1,3 +1,3 @@
1
- import { BaseDataType } from '../../table.types';
1
+ import { BaseTableDataType } from '../../table.types';
2
2
  /** If an index does not contain an `id` value, one is added using uuid. */
3
- export declare const addMissingIds: <DataType extends BaseDataType>(data: DataType[]) => DataType[];
3
+ export declare const addMissingIds: <DataType extends BaseTableDataType>(data: DataType[]) => DataType[];
@@ -1,5 +1,5 @@
1
- import { BaseDataType, TableProps } from './table.types';
1
+ import { BaseTableDataType, TableProps } from './table.types';
2
2
  export declare const Table: {
3
- <DataType extends BaseDataType>(props: TableProps<DataType>): JSX.Element;
3
+ <DataType extends BaseTableDataType>(props: TableProps<DataType>): JSX.Element;
4
4
  defaultProps: import("./table.types").TableDefaultProps;
5
5
  };
@@ -3,15 +3,16 @@ import { HTMLAttributes, MouseEvent } from 'react';
3
3
  import { PagingProps } from '../paging/paging.types';
4
4
  import { CustomActionProps, FiltersProps, SearchProps } from './components/table-actions-wrapper';
5
5
  import { SortProps } from './components/table-actions-wrapper/components/sort/sort.types';
6
- export interface BaseDataType {
7
- [key: string]: unknown;
8
- id?: string | number;
9
- subRows?: BaseDataType[];
10
- }
11
- export interface TableProps<DataType extends BaseDataType> extends Partial<TableDefaultProps> {
6
+ export type BaseTableDataType = Record<any, any>;
7
+ export interface TableProps<DataType extends BaseTableDataType> extends Partial<TableDefaultProps> {
12
8
  className?: string;
13
9
  columns: ColumnDef<DataType, any>[];
14
10
  customAction?: CustomActionProps;
11
+ /**
12
+ * For each index, if no `id` key exists, one will be assigned.
13
+ *
14
+ * To create collapsable rows, optionally provide the index with a `subRows` key. It should be an array of objects matching the expected data type.
15
+ */
15
16
  data: DataType[];
16
17
  enableReordering?: boolean;
17
18
  filters?: FiltersProps;
@@ -29,10 +30,10 @@ export interface TableProps<DataType extends BaseDataType> extends Partial<Table
29
30
  export interface TableDefaultProps {
30
31
  stickyFirstColumn: boolean;
31
32
  }
32
- export type GetHeaderCellProps<DataType extends BaseDataType> = (cell: Header<DataType, unknown>) => CustomCellProps;
33
- export type GetRowProps<DataType extends BaseDataType> = (row: Row<DataType>, rows: Row<DataType>[]) => CustomRowProps;
34
- export type GetCellProps<DataType extends BaseDataType> = (cell: Cell<DataType, unknown>) => CustomCellProps;
35
- export type OnRowClick<DataType extends BaseDataType> = (data: Row<DataType>, event: MouseEvent<HTMLTableRowElement>) => void;
33
+ export type GetHeaderCellProps<DataType extends BaseTableDataType> = (cell: Header<DataType, unknown>) => CustomCellProps;
34
+ export type GetRowProps<DataType extends BaseTableDataType> = (row: Row<DataType>, rows: Row<DataType>[]) => CustomRowProps;
35
+ export type GetCellProps<DataType extends BaseTableDataType> = (cell: Cell<DataType, unknown>) => CustomCellProps;
36
+ export type OnRowClick<DataType extends BaseTableDataType> = (data: Row<DataType>, event: MouseEvent<HTMLTableRowElement>) => void;
36
37
  export interface CustomRowProps extends Record<string, unknown>, HTMLAttributes<HTMLTableRowElement> {
37
38
  status?: RowStatusValue | undefined;
38
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantri-components",
3
- "version": "2.34.0-beta.5",
3
+ "version": "2.34.0-beta.7",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "umd": "dist/index.umd.js",
@@ -64,6 +64,7 @@
64
64
  "@storybook/testing-library": "^0.0.13",
65
65
  "@storybook/theming": "^6.5.12",
66
66
  "@svgr/cli": "^6.2.1",
67
+ "@tanstack/react-table": "^8.9.1",
67
68
  "@testing-library/dom": "^8.17.1",
68
69
  "@testing-library/jest-dom": "^5.16.5",
69
70
  "@testing-library/react": "^12.1.5",
@@ -126,7 +127,6 @@
126
127
  },
127
128
  "dependencies": {
128
129
  "@cloudinary/url-gen": "^1.7.0",
129
- "@tanstack/react-table": "^8.9.1",
130
130
  "@types/lodash": "^4.14.182",
131
131
  "@types/react-dom": "^17.0.17",
132
132
  "formik": "^2.2.9",