gantri-components 2.40.0-beta.6 → 2.40.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.
Files changed (26) hide show
  1. package/dist/components/table/components/custom-columns-wrapper/custom-columns-wrapper.d.ts +2 -2
  2. package/dist/components/table/components/custom-columns-wrapper/custom-columns-wrapper.types.d.ts +6 -6
  3. package/dist/components/table/components/custom-columns-wrapper/helpers/get-custom-column-initial-visibility/get-custom-column-initial-visibility.d.ts +29 -0
  4. package/dist/components/table/components/custom-columns-wrapper/helpers/get-custom-column-options/get-custom-column-options.d.ts +2 -2
  5. package/dist/components/table/components/custom-columns-wrapper/helpers/get-custom-column-options/get-custom-column-options.types.d.ts +3 -3
  6. package/dist/components/table/components/table-actions-wrapper/hooks/use-confirm-interaction/use-confirm-interaction.d.ts +2 -2
  7. package/dist/components/table/components/table-actions-wrapper/hooks/use-confirm-interaction/use-confirm-interaction.types.d.ts +2 -2
  8. package/dist/components/table/components/table-actions-wrapper/table-actions-wrapper.d.ts +2 -2
  9. package/dist/components/table/components/table-actions-wrapper/table-actions-wrapper.types.d.ts +5 -5
  10. package/dist/components/table/components/table-footer/table-footer.d.ts +2 -2
  11. package/dist/components/table/components/table-footer/table-footer.types.d.ts +2 -2
  12. package/dist/components/table/components/table-header/table-header.d.ts +2 -2
  13. package/dist/components/table/components/table-header/table-header.types.d.ts +3 -3
  14. package/dist/components/table/components/table-row/hooks/use-drag-and-drop/use-drag-and-drop.d.ts +2 -2
  15. package/dist/components/table/components/table-row/hooks/use-drag-and-drop/use-drag-and-drop.types.d.ts +2 -2
  16. package/dist/components/table/components/table-row/table-row.d.ts +2 -2
  17. package/dist/components/table/components/table-row/table-row.types.d.ts +4 -4
  18. package/dist/components/table/helpers/add-missing-ids/add-missing-ids.d.ts +3 -2
  19. package/dist/components/table/helpers/add-missing-ids/add-missing-ids.types.d.ts +4 -0
  20. package/dist/components/table/index.d.ts +1 -0
  21. package/dist/components/table/table.d.ts +2 -2
  22. package/dist/components/table/table.types.d.ts +15 -15
  23. package/dist/index.cjs.js +1 -1
  24. package/dist/index.esm.js +1 -1
  25. package/dist/index.umd.js +1 -1
  26. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { RowData } from '@tanstack/react-table';
2
2
  import { CustomColumnsWrapperProps } from './custom-columns-wrapper.types';
3
- export declare const CustomColumnsWrapper: <DataType extends RowData<{
3
+ export declare const CustomColumnsWrapper: <TData extends RowData<{
4
4
  [key: string]: unknown;
5
5
  id?: string | number | undefined;
6
6
  subRows?: any[] | undefined;
7
- }>>(props: CustomColumnsWrapperProps<DataType>) => JSX.Element;
7
+ }>>(props: CustomColumnsWrapperProps<TData>) => JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import { RowData, Table } from '@tanstack/react-table';
2
2
  import { PropsWithChildren } from 'react';
3
- export interface CustomColumnsProps<DataType extends RowData> {
4
- disabledColumns: (keyof DataType | string)[];
5
- hiddenColumns: (keyof DataType | string)[];
3
+ export interface CustomColumnsProps<TData extends RowData> {
4
+ disabledColumns: (keyof TData | string)[];
5
+ hiddenColumns: (keyof TData | string)[];
6
6
  onUpdateHiddenColumns: (columnsToHide: string[]) => Promise<void>;
7
7
  }
8
8
  export interface CustomColumnOption {
@@ -12,8 +12,8 @@ export interface CustomColumnOption {
12
12
  onChange: (event: unknown) => void;
13
13
  value: string;
14
14
  }
15
- export type CustomColumnsWrapperProps<DataType extends RowData> = PropsWithChildren<{
16
- customColumns: CustomColumnsProps<DataType> | undefined;
17
- table: Table<DataType>;
15
+ export type CustomColumnsWrapperProps<TData extends RowData> = PropsWithChildren<{
16
+ customColumns: CustomColumnsProps<TData> | undefined;
17
+ table: Table<TData>;
18
18
  tableContainerEl: HTMLDivElement | null;
19
19
  }>;
@@ -1 +1,30 @@
1
+ /**
2
+ * Used to mark the starting hidden columns when using custom columns.
3
+ *
4
+ * @example
5
+ * const [hiddenColumns, setHiddenColumns] = useState<string[]>(STARTING_HIDDEN_COLUMNS);
6
+ * const initialColumnVisibility = getCustomColumnInitialVisibility(hiddenColumns);
7
+ * const [columnVisibility, setColumnVisibility] = useState(initialColumnVisibility);
8
+ *
9
+ * return (
10
+ * <TableComponent
11
+ * data={tableData}
12
+ * columns={tableColumns}
13
+ * options={{
14
+ * state: {
15
+ * columnVisibility,
16
+ * },
17
+ * onColumnVisibilityChange: setColumnVisibility,
18
+ * }}
19
+ * customColumns={{
20
+ * disabledColumns: [DISABLED_COLUMNS],
21
+ * onUpdateHiddenColumns: async columns => {
22
+ * // REQUEST API HIDE COLUMNS
23
+ * setHiddenColumns(columns);
24
+ * },
25
+ * hiddenColumns: hiddenColumns,
26
+ * }}
27
+ * />
28
+ * )
29
+ */
1
30
  export declare const getCustomColumnInitialVisibility: (hiddenColumns: string[]) => {};
@@ -1,8 +1,8 @@
1
1
  import { RowData } from '@tanstack/react-table';
2
2
  import { CustomColumnOption } from '../../custom-columns-wrapper.types';
3
3
  import { GetCustomColumnOptionsArgs } from './get-custom-column-options.types';
4
- export declare const getCustomColumnOptions: <DataType extends RowData<{
4
+ export declare const getCustomColumnOptions: <TData extends RowData<{
5
5
  [key: string]: unknown;
6
6
  id?: string | number | undefined;
7
7
  subRows?: any[] | undefined;
8
- }>>(args: GetCustomColumnOptionsArgs<DataType>) => CustomColumnOption[];
8
+ }>>(args: GetCustomColumnOptionsArgs<TData>) => CustomColumnOption[];
@@ -1,6 +1,6 @@
1
1
  import { RowData, Table } from '@tanstack/react-table';
2
2
  import { CustomColumnsProps } from '../../custom-columns-wrapper.types';
3
- export interface GetCustomColumnOptionsArgs<DataType extends RowData> {
4
- customColumns: CustomColumnsProps<DataType> | undefined;
5
- table: Table<DataType>;
3
+ export interface GetCustomColumnOptionsArgs<TData extends RowData> {
4
+ customColumns: CustomColumnsProps<TData> | undefined;
5
+ table: Table<TData>;
6
6
  }
@@ -1,10 +1,10 @@
1
1
  import { RowData } from '@tanstack/react-table';
2
2
  import { UseConfirmInteractionProps, OnConfirmInteraction } from './use-confirm-interaction.types';
3
- export declare const useConfirmInteraction: <DataType extends RowData<{
3
+ export declare const useConfirmInteraction: <TData extends RowData<{
4
4
  [key: string]: unknown;
5
5
  id?: string | number | undefined;
6
6
  subRows?: any[] | undefined;
7
- }>>(props: UseConfirmInteractionProps<DataType>) => {
7
+ }>>(props: UseConfirmInteractionProps<TData>) => {
8
8
  /** Not necessary for `onConfirmInteraction`. Only provided in case additional logic is needed. */
9
9
  confirmAllInteractions: boolean;
10
10
  /** If applicable, renders a discard selections confirmation modal when called. */
@@ -1,6 +1,6 @@
1
1
  import { RowData, Table } from '@tanstack/react-table';
2
2
  export type TableInteraction = 'FOCUS_SEARCH' | 'OPEN_FILTERS' | 'OPEN_SORT' | 'USE_PAGING' | 'CUSTOM_ACTION';
3
- export interface UseConfirmInteractionProps<DataType extends RowData> {
4
- table: Table<DataType>;
3
+ export interface UseConfirmInteractionProps<TData extends RowData> {
4
+ table: Table<TData>;
5
5
  }
6
6
  export type OnConfirmInteraction = (interaction: TableInteraction) => Promise<boolean>;
@@ -2,8 +2,8 @@ import React, { PropsWithChildren } from 'react';
2
2
  import { RowData } from '@tanstack/react-table';
3
3
  import { TableActionsWrapperProps } from './table-actions-wrapper.types';
4
4
  /** Wraps the table with relevant components for paging, filters, sort, and table actions. */
5
- export declare const TableActionsWrapper: <DataType extends RowData<{
5
+ export declare const TableActionsWrapper: <TData extends RowData<{
6
6
  [key: string]: unknown;
7
7
  id?: string | number | undefined;
8
8
  subRows?: any[] | undefined;
9
- }>>(props: React.PropsWithChildren<TableActionsWrapperProps<DataType>>) => JSX.Element;
9
+ }>>(props: React.PropsWithChildren<TableActionsWrapperProps<TData>>) => JSX.Element;
@@ -15,19 +15,19 @@ export interface SearchProps {
15
15
  placeholder?: string;
16
16
  value: string;
17
17
  }
18
- export interface CustomActionProps<DataType extends RowData> {
18
+ export interface CustomActionProps<TData extends RowData> {
19
19
  Component: JSXElementConstructor<{
20
20
  onConfirmInteraction: () => Promise<boolean>;
21
- table: Table<DataType>;
21
+ table: Table<TData>;
22
22
  }>;
23
23
  position: 'left' | 'right' | 'bottom';
24
24
  }
25
- export interface TableActionsWrapperProps<DataType extends RowData> {
25
+ export interface TableActionsWrapperProps<TData extends RowData> {
26
26
  className: string | undefined;
27
- customAction: CustomActionProps<DataType> | undefined;
27
+ customAction: CustomActionProps<TData> | undefined;
28
28
  filters: FiltersProps | undefined;
29
29
  paging: PagingProps | undefined;
30
30
  search: SearchProps | undefined;
31
31
  sorting: SortProps | undefined;
32
- table: Table<DataType>;
32
+ table: Table<TData>;
33
33
  }
@@ -1,7 +1,7 @@
1
1
  import { RowData } from '@tanstack/react-table';
2
2
  import { TableFooterProps } from './table-footer.types';
3
- export declare const TableFooter: <DataType extends RowData<{
3
+ export declare const TableFooter: <TData extends RowData<{
4
4
  [key: string]: unknown;
5
5
  id?: string | number | undefined;
6
6
  subRows?: any[] | undefined;
7
- }>>(props: TableFooterProps<DataType>) => JSX.Element;
7
+ }>>(props: TableFooterProps<TData>) => JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import { RowData, Table } from '@tanstack/react-table';
2
- export type TableFooterProps<DataType extends RowData> = {
3
- table: Table<DataType>;
2
+ export type TableFooterProps<TData extends RowData> = {
3
+ table: Table<TData>;
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import { RowData } from '@tanstack/react-table';
2
2
  import { TableHeaderProps } from './table-header.types';
3
- export declare const TableHeader: <DataType extends RowData<{
3
+ export declare const TableHeader: <TData extends RowData<{
4
4
  [key: string]: unknown;
5
5
  id?: string | number | undefined;
6
6
  subRows?: any[] | undefined;
7
- }>>(props: TableHeaderProps<DataType>) => JSX.Element;
7
+ }>>(props: TableHeaderProps<TData>) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { RowData, Table } from '@tanstack/react-table';
2
2
  import { GetHeaderCellProps } from '../../table.types';
3
- export type TableHeaderProps<DataType extends RowData> = {
4
- getHeaderCellProps: GetHeaderCellProps<DataType> | undefined;
5
- table: Table<DataType>;
3
+ export type TableHeaderProps<TData extends RowData> = {
4
+ getHeaderCellProps: GetHeaderCellProps<TData> | undefined;
5
+ table: Table<TData>;
6
6
  };
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { RowData } from '@tanstack/react-table';
3
3
  import { UseDragAndDropProps } from './use-drag-and-drop.types';
4
- export declare const useDragAndDrop: <DataType extends RowData<{
4
+ export declare const useDragAndDrop: <TData extends RowData<{
5
5
  [key: string]: unknown;
6
6
  id?: string | number | undefined;
7
7
  subRows?: any[] | undefined;
8
- }>>(props: UseDragAndDropProps<DataType>) => {
8
+ }>>(props: UseDragAndDropProps<TData>) => {
9
9
  dragAndDropRef: import("react").RefObject<HTMLTableRowElement>;
10
10
  isDragging: boolean;
11
11
  };
@@ -1,9 +1,9 @@
1
1
  import { Row, RowData } from '@tanstack/react-table';
2
- export interface UseDragAndDropProps<DataType extends RowData> {
2
+ export interface UseDragAndDropProps<TData extends RowData> {
3
3
  enableReordering: boolean;
4
4
  handleOnReorder: () => Promise<void>;
5
5
  index: number;
6
6
  isSubRow: boolean;
7
7
  moveRow: (startIndex: number, endIndex: number) => void;
8
- row: Row<DataType>;
8
+ row: Row<TData>;
9
9
  }
@@ -1,7 +1,7 @@
1
1
  import { RowData } from '@tanstack/react-table';
2
2
  import { TableRowProps } from './table-row.types';
3
- export declare const TableRow: <DataType extends RowData<{
3
+ export declare const TableRow: <TData extends RowData<{
4
4
  [key: string]: unknown;
5
5
  id?: string | number | undefined;
6
6
  subRows?: any[] | undefined;
7
- }>>(props: TableRowProps<DataType>) => JSX.Element;
7
+ }>>(props: TableRowProps<TData>) => JSX.Element;
@@ -1,12 +1,12 @@
1
1
  import { Row, RowData } from '@tanstack/react-table';
2
2
  import { CustomRowProps, GetCellProps, OnRowClick } from '../../table.types';
3
- export interface TableRowProps<DataType extends RowData> {
3
+ export interface TableRowProps<TData extends RowData> {
4
4
  customRowProps: CustomRowProps;
5
5
  enableReordering: boolean;
6
- getCellProps: GetCellProps<DataType> | undefined;
6
+ getCellProps: GetCellProps<TData> | undefined;
7
7
  handleOnReorder: () => Promise<void>;
8
8
  index: number;
9
9
  moveRow: (startIndex: number, endIndex: number) => void;
10
- onRowClick?: OnRowClick<DataType>;
11
- row: Row<DataType>;
10
+ onRowClick?: OnRowClick<TData>;
11
+ row: Row<TData>;
12
12
  }
@@ -1,7 +1,8 @@
1
1
  import { RowData } from '@tanstack/react-table';
2
+ import { TDataWithId } from './add-missing-ids.types';
2
3
  /** If an index does not contain an `id` value, one is added using uuid. */
3
- export declare const addMissingIds: <DataType extends RowData<{
4
+ export declare const addMissingIds: <TData extends RowData<{
4
5
  [key: string]: unknown;
5
6
  id?: string | number | undefined;
6
7
  subRows?: any[] | undefined;
7
- }>>(data: DataType[]) => DataType[];
8
+ }>>(data: TData[]) => TDataWithId<TData>[];
@@ -0,0 +1,4 @@
1
+ import { RowData } from '@tanstack/react-table';
2
+ export type TDataWithId<TData extends RowData> = TData & {
3
+ id: number | string;
4
+ };
@@ -2,3 +2,4 @@ export * from './table';
2
2
  export * from './table.types';
3
3
  export * from './components/table-row/table-row.constants';
4
4
  export * from './components/custom-columns-wrapper/helpers/get-custom-column-initial-visibility';
5
+ export * from './helpers';
@@ -2,10 +2,10 @@ import { RowData } from '@tanstack/react-table';
2
2
  import { TableProps } from './table.types';
3
3
  /** Official docs: https://tanstack.com/table/v8/docs/guide/overview */
4
4
  export declare const Table: {
5
- <DataType extends RowData<{
5
+ <TData extends RowData<{
6
6
  [key: string]: unknown;
7
7
  id?: string | number | undefined;
8
8
  subRows?: any[] | undefined;
9
- }>>(props: TableProps<DataType>): JSX.Element;
9
+ }>>(props: TableProps<TData>): JSX.Element;
10
10
  defaultProps: import("./table.types").TableDefaultProps;
11
11
  };
@@ -4,29 +4,29 @@ import { PagingProps } from './components/table-actions-wrapper/components/pagin
4
4
  import { CustomActionProps, FiltersProps, SearchProps } from './components/table-actions-wrapper/table-actions-wrapper.types';
5
5
  import { SortProps } from './components/table-actions-wrapper/components/sort/sort.types';
6
6
  import { CustomColumnsProps } from './components/custom-columns-wrapper/custom-columns-wrapper.types';
7
- export interface TableProps<DataType extends RowData> extends Partial<TableDefaultProps> {
7
+ export interface TableProps<TData extends RowData> extends Partial<TableDefaultProps> {
8
8
  className?: string;
9
- columns: ColumnDef<DataType, any>[];
10
- customAction?: CustomActionProps<DataType>;
11
- customColumns?: CustomColumnsProps<DataType>;
9
+ columns: ColumnDef<TData, any>[];
10
+ customAction?: CustomActionProps<TData>;
11
+ customColumns?: CustomColumnsProps<TData>;
12
12
  /**
13
13
  * For each index, if no `id` key exists, one will be assigned.
14
14
  *
15
15
  * To create collapsable rows, optionally provide the index with a `subRows` key. It should be an array of objects matching the expected data type.
16
16
  */
17
- data: DataType[];
17
+ data: TData[];
18
18
  filters?: FiltersProps;
19
- getCellProps?: GetCellProps<DataType>;
20
- getHeaderCellProps?: GetHeaderCellProps<DataType>;
19
+ getCellProps?: GetCellProps<TData>;
20
+ getHeaderCellProps?: GetHeaderCellProps<TData>;
21
21
  /** Include `status` in the returned value to set the row status color. */
22
- getRowProps?: GetRowProps<DataType>;
23
- onRowClick?: OnRowClick<DataType>;
22
+ getRowProps?: GetRowProps<TData>;
23
+ onRowClick?: OnRowClick<TData>;
24
24
  /** Any options provided are passed to `useReactTable` and may override default values. */
25
- options?: Partial<TableOptions<DataType>>;
25
+ options?: Partial<TableOptions<TData>>;
26
26
  paging?: PagingProps;
27
27
  reordering?: {
28
28
  enable: boolean;
29
- onReorder: (data: DataType[]) => Promise<void>;
29
+ onReorder: (data: TData[]) => Promise<void>;
30
30
  };
31
31
  search?: SearchProps;
32
32
  sorting?: SortProps;
@@ -34,13 +34,13 @@ export interface TableProps<DataType extends RowData> extends Partial<TableDefau
34
34
  export interface TableDefaultProps {
35
35
  stickyFirstColumn: boolean;
36
36
  }
37
- export type GetHeaderCellProps<DataType extends RowData> = (cell?: Header<DataType, unknown>) => CustomCellProps;
38
- export type GetRowProps<DataType extends RowData> = (row?: Row<DataType>, rows?: Row<DataType>[]) => CustomRowProps;
37
+ export type GetHeaderCellProps<TData extends RowData> = (cell?: Header<TData, unknown>) => CustomCellProps;
38
+ export type GetRowProps<TData extends RowData> = (row?: Row<TData>, rows?: Row<TData>[]) => CustomRowProps;
39
39
  export interface CustomRowProps extends Record<string, unknown>, HTMLAttributes<HTMLTableRowElement> {
40
40
  status?: RowStatusValue | undefined;
41
41
  }
42
42
  export type RowStatusValue = 'handled' | 'next' | 'error' | 'warning';
43
- export type GetCellProps<DataType extends RowData> = (cell?: Cell<DataType, unknown>) => CustomCellProps;
44
- export type OnRowClick<DataType extends RowData> = (data: Row<DataType>, event: MouseEvent<HTMLTableRowElement>) => void;
43
+ export type GetCellProps<TData extends RowData> = (cell?: Cell<TData, unknown>) => CustomCellProps;
44
+ export type OnRowClick<TData extends RowData> = (data: Row<TData>, event: MouseEvent<HTMLTableRowElement>) => void;
45
45
  export interface CustomCellProps extends Record<string, unknown>, HTMLAttributes<HTMLTableCellElement> {
46
46
  }