@popmenu/table 0.45.0 → 0.47.0

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 (63) hide show
  1. package/build/components/ColumnFilterChip/ColumnFilterChip.d.ts +9 -0
  2. package/build/components/ColumnFilterChip/index.d.ts +1 -0
  3. package/build/components/ColumnFilterResetButton/ColumnFilterResetButton.d.ts +3 -0
  4. package/build/components/ColumnFilterResetButton/index.d.ts +1 -0
  5. package/build/components/FilterPanel/FilterControl/FilterControl.d.ts +3 -0
  6. package/build/components/FilterPanel/FilterControl/SelectFilter/SelectFilter.d.ts +5 -0
  7. package/build/components/FilterPanel/FilterControl/SelectFilter/SelectFilterStyles.d.ts +1 -0
  8. package/build/components/FilterPanel/FilterControl/SelectFilter/index.d.ts +1 -0
  9. package/build/components/FilterPanel/FilterControl/index.d.ts +1 -0
  10. package/build/components/FilterPanel/FilterPanel.d.ts +2 -0
  11. package/build/components/FilterPanel/FilterPanelProps.d.ts +11 -0
  12. package/build/components/FilterPanel/Panel/Panel.d.ts +7 -0
  13. package/build/components/FilterPanel/Panel/PanelStyles.d.ts +1 -0
  14. package/build/components/FilterPanel/Panel/index.d.ts +1 -0
  15. package/build/components/FilterPanel/Trigger/Trigger.d.ts +7 -0
  16. package/build/components/FilterPanel/Trigger/TriggerStyles.d.ts +1 -0
  17. package/build/components/FilterPanel/Trigger/index.d.ts +1 -0
  18. package/build/components/FilterPanel/index.d.ts +1 -0
  19. package/build/components/GlobalFilter/GlobalFilterStyles.d.ts +1 -0
  20. package/build/components/RowActions/RowActions.d.ts +3 -0
  21. package/build/components/RowActions/RowActionsProps.d.ts +11 -0
  22. package/build/components/RowActions/index.d.ts +2 -0
  23. package/build/components/Table/Table.d.ts +16 -2
  24. package/build/components/Table/TableProps.d.ts +28 -40
  25. package/build/components/Table/TableStyles.d.ts +1 -1
  26. package/build/components/Table/index.d.ts +1 -1
  27. package/build/components/TableBody/TableBody.d.ts +4 -2
  28. package/build/components/TableBody/index.d.ts +1 -1
  29. package/build/components/TableCell/TableCell.d.ts +4 -2
  30. package/build/components/TableCell/index.d.ts +1 -1
  31. package/build/components/TableContext/index.d.ts +3 -0
  32. package/build/components/TableFooter/TableFooter.d.ts +4 -2
  33. package/build/components/TableFooter/index.d.ts +1 -1
  34. package/build/components/TableHeader/TableHeader.d.ts +4 -2
  35. package/build/components/TableHeader/index.d.ts +1 -1
  36. package/build/components/TableHeaderCell/TableHeaderCell.d.ts +2 -2
  37. package/build/components/TableHeaderCell/TableHeaderCellProps.d.ts +5 -7
  38. package/build/components/TableHeaderCell/TableHeaderCellStyles.d.ts +3 -1
  39. package/build/components/TableHeaderCell/index.d.ts +2 -1
  40. package/build/components/TableHeaderRow/TableHeaderRow.d.ts +4 -2
  41. package/build/components/TableHeaderRow/index.d.ts +1 -1
  42. package/build/components/TableRow/TableRow.d.ts +4 -2
  43. package/build/components/TableRow/index.d.ts +1 -1
  44. package/build/components/index.d.ts +10 -1
  45. package/build/hooks/index.d.ts +1 -1
  46. package/build/hooks/useColumnFilters.d.ts +9 -0
  47. package/build/index.d.ts +0 -1
  48. package/build/index.es.js +2560 -397
  49. package/build/index.es.js.map +1 -1
  50. package/build/index.js +2575 -396
  51. package/build/index.js.map +1 -1
  52. package/build/util/coercedValueIncludesString.d.ts +2 -0
  53. package/build/util/getTableMinHeight.d.ts +2 -0
  54. package/build/util/index.d.ts +2 -0
  55. package/build/util/validateRowAction.d.ts +2 -0
  56. package/package.json +4 -4
  57. package/build/components/Table/util/makeColumns.d.ts +0 -7
  58. package/build/components/TableActionsCell/TableActionsCell.d.ts +0 -3
  59. package/build/components/TableActionsCell/TableActionsCellProps.d.ts +0 -10
  60. package/build/components/TableActionsCell/index.d.ts +0 -2
  61. package/build/hooks/useManualPagination/index.d.ts +0 -1
  62. package/build/hooks/useManualPagination/useManualPagination.d.ts +0 -5
  63. package/build/hooks/useManualPagination/useManualPaginationTypes.d.ts +0 -52
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { ColumnFilter } from '@tanstack/react-table';
3
+ interface ColumnFilterChipProps {
4
+ columnFilter: ColumnFilter;
5
+ label: [string, string];
6
+ onClick: (columnFilter: ColumnFilter) => void;
7
+ }
8
+ export declare const ColumnFilterChip: (props: ColumnFilterChipProps) => JSX.Element;
9
+ export {};
@@ -0,0 +1 @@
1
+ export { ColumnFilterChip } from './ColumnFilterChip';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '@popmenu/admin-ui';
3
+ export declare const ColumnFilterResetButton: (props: ButtonProps) => JSX.Element;
@@ -0,0 +1 @@
1
+ export { ColumnFilterResetButton } from './ColumnFilterResetButton';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { ColumnFilter } from '../FilterPanelProps';
3
+ export declare const FilterControl: (props: ColumnFilter) => JSX.Element;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { ColumnFilter } from '../../FilterPanelProps';
3
+ export declare const SelectFilter: (props: Pick<ColumnFilter, "options" | "columnId"> & {
4
+ multiple: boolean;
5
+ }) => JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
@@ -0,0 +1 @@
1
+ export { SelectFilter } from './SelectFilter';
@@ -0,0 +1 @@
1
+ export { FilterControl } from './FilterControl';
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const FilterPanel: () => JSX.Element;
@@ -0,0 +1,11 @@
1
+ export declare type ColumnFilterInput = 'text' | 'number' | 'radio' | 'select' | 'multi-select';
2
+ export declare type ColumnFilter = {
3
+ columnId: string;
4
+ input: ColumnFilterInput;
5
+ min?: number;
6
+ max?: number;
7
+ options: Array<{
8
+ label: string;
9
+ value: string | number;
10
+ }>;
11
+ };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ declare type PanelProps = {
3
+ anchorEl: null | Element;
4
+ onClose: () => void;
5
+ };
6
+ export declare const Panel: (props: PanelProps) => JSX.Element;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
@@ -0,0 +1 @@
1
+ export { Panel } from './Panel';
@@ -0,0 +1,7 @@
1
+ import { SyntheticEvent } from 'react';
2
+ declare type FitlerPanelTriggerProps = {
3
+ onClick: (event: SyntheticEvent) => void;
4
+ label?: string;
5
+ };
6
+ export declare const Trigger: (props: FitlerPanelTriggerProps) => JSX.Element;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"root">;
@@ -0,0 +1 @@
1
+ export { Trigger } from './Trigger';
@@ -0,0 +1 @@
1
+ export { FilterPanel } from './FilterPanel';
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"root">;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { RowActionsProps } from './RowActionsProps';
3
+ export declare const RowActions: (props: RowActionsProps) => JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { FC, SVGProps } from 'react';
2
+ import { CellContext } from '@tanstack/react-table';
3
+ export interface RowAction {
4
+ icon: FC<SVGProps<SVGSVGElement>>;
5
+ label: string;
6
+ onClick: (props: CellContext<any, any>) => void;
7
+ }
8
+ export interface RowActionsProps {
9
+ context: CellContext<any, any>;
10
+ actions: Array<RowAction>;
11
+ }
@@ -0,0 +1,2 @@
1
+ export { RowActions } from './RowActions';
2
+ export { RowActionsProps } from './RowActionsProps';
@@ -1,3 +1,17 @@
1
- import { FC } from 'react';
1
+ /// <reference types="react" />
2
2
  import { TableProps } from './TableProps';
3
- export declare const Table: FC<TableProps>;
3
+ declare const defaultTableProps: {
4
+ fullWidth: boolean;
5
+ sortable: boolean;
6
+ searchable: boolean;
7
+ };
8
+ declare type DefaultTableProps = TableProps & typeof defaultTableProps;
9
+ export declare const Table: {
10
+ (props: DefaultTableProps): JSX.Element;
11
+ defaultProps: {
12
+ fullWidth: boolean;
13
+ sortable: boolean;
14
+ searchable: boolean;
15
+ };
16
+ };
17
+ export {};
@@ -1,44 +1,32 @@
1
- import React from 'react';
2
- import { Cell, Column, TableInstance, UsePaginationOptions } from 'react-table';
3
- import { GlobalFilterProps } from '../GlobalFilter';
4
- export interface TableProps {
5
- /** Configurations for each individual column. */
6
- columns: Array<Column & {
7
- accessor: string;
8
- }>;
9
- /** A table's data set. */
10
- data: Array<Record<string, unknown>>;
11
- /** Actions that can be performed on any given row. */
12
- actions?: Record<string, {
13
- icon?: string | React.FC<React.SVGProps<SVGSVGElement>>;
14
- label: string;
15
- action: (cell: Cell) => void;
16
- }>;
17
- /** Styles the table to maintain the height of a fully populated page (entries in a table, not the window). */
18
- fullHeight?: boolean;
19
- /** Styles the table to take up its containers full width. */
1
+ import { Column, ColumnFiltersState, PaginationState } from '@tanstack/react-table';
2
+ import { Dispatch, SetStateAction } from 'react';
3
+ export interface ColumnFilter {
4
+ id: string;
5
+ value: unknown;
6
+ }
7
+ export interface TableProps<T = unknown> {
8
+ /** List of objects representing the rows of a Table. */
9
+ data: Array<T>;
10
+ /** List of column definitions. */
11
+ columns: Array<Column<T>>;
12
+ /** Controls table loading state. */
13
+ loading?: boolean;
14
+ /** Forces a table to take up the width of its container when true. */
20
15
  fullWidth?: boolean;
21
- /** Enables global filter as search. */
16
+ /** Adds a global filter to the table. for uncontrolled global filtering only. */
22
17
  searchable?: boolean;
23
- /** Enables sortability for columns. */
18
+ /** Makes columns sortable. For uncontrolled sorting only. */
24
19
  sortable?: boolean;
25
- /** Sets loading state. When true, Will render a CircularProgress when true and not rows. */
26
- loading?: boolean;
27
- /** A short message for users when the data set does not produce any rows. */
28
- emptyMessage?: string;
29
- /** An image to be displayed with the empty message. */
30
- EmptyImage?: () => React.ReactNode;
31
- /** Props applied to the global search input component. Extends [TextField props](https://v4.mui.com/api/text-field/). */
32
- GlobalFilterProps?: Omit<GlobalFilterProps, 'value' | 'setValue'>;
33
- /** Callback for managing pagination events. */
34
- onPaginate?: (pageIndex: number, instance: TableInstance) => void;
35
- /** Callback for managing pagination events. */
36
- paginationOptions?: UsePaginationOptions<Record<string, unknown>> & Partial<{
37
- initialState: Partial<{
38
- pageSize: number;
39
- pageIndex: number;
40
- }>;
41
- }>;
42
- /** Added to the main parameter of the useTable hook. */
43
- tableOptions?: Record<string, unknown>;
20
+ /** Pagination state. Expects the result of a React useState hook. Used only for manual pagination. */
21
+ paginationState?: [PaginationState, Dispatch<SetStateAction<PaginationState>>];
22
+ /** GlobalFiltering state. Expects the result of a React useState hook. Used only for manual filtering. */
23
+ globalFilterState?: [string, Dispatch<SetStateAction<string>>];
24
+ /** Filtering state. Expects the result of a React useState hook. Used only for manual filtering. */
25
+ filterState?: [ColumnFiltersState, Dispatch<SetStateAction<Array<ColumnFilter>>>];
26
+ /** Filtering state. Expects the result of a React useState hook. Used only for manual filtering. */
27
+ visibilityState?: [Record<string, boolean>, Dispatch<SetStateAction<Record<string, boolean>>>];
28
+ /** Number of pages. Used only for manual pagination. */
29
+ pageCount?: number;
30
+ /** A React Component to be rendered when the data set is empty. */
31
+ Empty?: () => JSX.Element;
44
32
  }
@@ -1,2 +1,2 @@
1
1
  import { TableProps } from './TableProps';
2
- export declare const useTableStyles: (props: TableProps) => import("@material-ui/styles").ClassNameMap<string>;
2
+ export declare const useStyles: (props: TableProps<unknown>) => import("@material-ui/styles").ClassNameMap<string>;
@@ -1,2 +1,2 @@
1
- export { Table as default } from './Table';
1
+ export { Table } from './Table';
2
2
  export { TableProps } from './TableProps';
@@ -1,2 +1,4 @@
1
- import { FC } from 'react';
2
- export declare const TableBody: FC;
1
+ import { HTMLAttributes, PropsWithChildren } from 'react';
2
+ declare type TableBodyProps = PropsWithChildren<HTMLAttributes<HTMLTableSectionElement>>;
3
+ export declare const TableBody: (props: TableBodyProps) => JSX.Element;
4
+ export {};
@@ -1 +1 @@
1
- export { TableBody as default } from './TableBody';
1
+ export { TableBody } from './TableBody';
@@ -1,2 +1,4 @@
1
- import { FC } from 'react';
2
- export declare const TableCell: FC;
1
+ import { HTMLAttributes, PropsWithChildren } from 'react';
2
+ declare type TableCellProps = PropsWithChildren<HTMLAttributes<HTMLTableCellElement>>;
3
+ export declare const TableCell: (props: TableCellProps) => JSX.Element;
4
+ export {};
@@ -1 +1 @@
1
- export { TableCell as default } from './TableCell';
1
+ export { TableCell } from './TableCell';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { Table } from '@tanstack/react-table';
3
+ export declare const TableContext: import("react").Context<Table<any>>;
@@ -1,2 +1,4 @@
1
- import { FC } from 'react';
2
- export declare const TableFooter: FC;
1
+ import { HTMLAttributes, PropsWithChildren } from 'react';
2
+ declare type TableFooterProps = PropsWithChildren<HTMLAttributes<HTMLDivElement>>;
3
+ export declare const TableFooter: (props: TableFooterProps) => JSX.Element;
4
+ export {};
@@ -1 +1 @@
1
- export { TableFooter as default } from './TableFooter';
1
+ export { TableFooter } from './TableFooter';
@@ -1,2 +1,4 @@
1
- import { FC } from 'react';
2
- export declare const TableHeader: FC;
1
+ import { HTMLAttributes, PropsWithChildren } from 'react';
2
+ declare type TableHeadProps = PropsWithChildren<HTMLAttributes<HTMLTableSectionElement>>;
3
+ export declare const TableHeader: (props: TableHeadProps) => JSX.Element;
4
+ export {};
@@ -1 +1 @@
1
- export { TableHeader as default } from './TableHeader';
1
+ export { TableHeader } from './TableHeader';
@@ -1,3 +1,3 @@
1
- import { FC } from 'react';
1
+ /// <reference types="react" />
2
2
  import { TableHeaderCellProps } from './TableHeaderCellProps';
3
- export declare const TableHeaderCell: FC<TableHeaderCellProps>;
3
+ export declare const TableHeaderCell: (props: TableHeaderCellProps) => JSX.Element;
@@ -1,8 +1,6 @@
1
- import { Column } from 'react-table';
2
- import { TableProps } from '../Table';
3
- export interface TableHeaderCellProps {
4
- column: Column & {
5
- isActionColumn: boolean;
6
- };
7
- tableProps: TableProps;
1
+ import { HeaderContext } from '@tanstack/react-table';
2
+ import { PropsWithChildren, HTMLAttributes } from 'react';
3
+ export declare type ChildrenAndAttributes = PropsWithChildren<HTMLAttributes<HTMLTableCellElement>>;
4
+ export interface TableHeaderCellProps extends ChildrenAndAttributes {
5
+ context: HeaderContext<unknown, unknown>;
8
6
  }
@@ -1,2 +1,4 @@
1
1
  import { TableHeaderCellProps } from './TableHeaderCellProps';
2
- export declare const useTableHeaderCellStyles: (props: TableHeaderCellProps) => import("@material-ui/styles").ClassNameMap<string>;
2
+ export declare const useStyles: (props: TableHeaderCellProps & {
3
+ sortable: boolean;
4
+ }) => import("@material-ui/styles").ClassNameMap<string>;
@@ -1 +1,2 @@
1
- export { TableHeaderCell as default } from './TableHeaderCell';
1
+ export { TableHeaderCell } from './TableHeaderCell';
2
+ export { TableHeaderCellProps } from './TableHeaderCellProps';
@@ -1,2 +1,4 @@
1
- import { FC } from 'react';
2
- export declare const TableHeaderRow: FC;
1
+ import { PropsWithChildren, HTMLAttributes } from 'react';
2
+ declare type TableHaderRowProps = PropsWithChildren<HTMLAttributes<HTMLTableRowElement>>;
3
+ export declare const TableHeaderRow: (props: TableHaderRowProps) => JSX.Element;
4
+ export {};
@@ -1 +1 @@
1
- export { TableHeaderRow as default } from './TableHeaderRow';
1
+ export { TableHeaderRow } from './TableHeaderRow';
@@ -1,2 +1,4 @@
1
- import { FC } from 'react';
2
- export declare const TableRow: FC;
1
+ import { HTMLAttributes, PropsWithChildren } from 'react';
2
+ declare type TableRowProps = PropsWithChildren<HTMLAttributes<HTMLTableRowElement>>;
3
+ export declare const TableRow: (props: TableRowProps) => JSX.Element;
4
+ export {};
@@ -1 +1 @@
1
- export { TableRow as default } from './TableRow';
1
+ export { TableRow } from './TableRow';
@@ -1 +1,10 @@
1
- export { default as Table, TableProps } from './Table';
1
+ export { Table, TableProps } from './Table';
2
+ export { RowActions, RowActionsProps } from './RowActions';
3
+ export { GlobalFilter } from './GlobalFilter';
4
+ export { TableBody } from './TableBody';
5
+ export { TableCell } from './TableCell';
6
+ export { TableFooter } from './TableFooter';
7
+ export { TableHeader } from './TableHeader';
8
+ export { TableHeaderCell, TableHeaderCellProps } from './TableHeaderCell';
9
+ export { TableHeaderRow } from './TableHeaderRow';
10
+ export { TableRow } from './TableRow';
@@ -1 +1 @@
1
- export { useManualPagination } from './useManualPagination';
1
+ export { useColumnFilters } from './useColumnFilters';
@@ -0,0 +1,9 @@
1
+ import { ColumnFilter, Table } from '@tanstack/react-table';
2
+ export declare const useColumnFilters: (table: Table<unknown>) => {
3
+ selectedColumnFilters: ColumnFilter[];
4
+ columnFilters: any[];
5
+ hasColumnFilters: boolean;
6
+ deselectColumnFilter: (columnFilter: ColumnFilter) => void;
7
+ formatSelectedFilterText: (columnFilter: ColumnFilter) => [string, string];
8
+ resetColumnFilters: (defaultState?: boolean | undefined) => void;
9
+ };
package/build/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from './components';
2
- export * from './hooks';