jattac.libs.web.responsive-table 0.1.5 → 0.2.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.
@@ -7,4 +7,5 @@ export default interface IResponsiveTableColumnDefinition<TData> {
7
7
  onHeaderClick?: (id: string) => void;
8
8
  className?: string;
9
9
  };
10
+ getFilterableValue?: (data: TData) => string | number;
10
11
  }
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { IResponsiveTablePlugin, IPluginAPI } from './IResponsiveTablePlugin';
3
+ export declare class FilterPlugin<TData> implements IResponsiveTablePlugin<TData> {
4
+ id: string;
5
+ private filterText;
6
+ private api;
7
+ constructor();
8
+ onPluginInit: (api: IPluginAPI<TData>) => void;
9
+ renderHeader: () => React.JSX.Element | null;
10
+ processData: (data: TData[]) => TData[];
11
+ private handleFilterChange;
12
+ }
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { ColumnDefinition } from '../UI/ResponsiveTable';
3
+ export interface IResponsiveTablePlugin<TData> {
4
+ id: string;
5
+ renderHeader?: () => ReactNode;
6
+ renderFooter?: () => ReactNode;
7
+ processData?: (data: TData[]) => TData[];
8
+ onPluginInit?: (api: IPluginAPI<TData>) => void;
9
+ }
10
+ export interface IPluginAPI<TData> {
11
+ getData: () => TData[];
12
+ forceUpdate: () => void;
13
+ columnDefinitions: ColumnDefinition<TData>[];
14
+ getScrollableElement?: () => HTMLElement | null;
15
+ infiniteScrollProps?: {
16
+ enableInfiniteScroll?: boolean;
17
+ onLoadMore?: (currentData: TData[]) => Promise<TData[] | null>;
18
+ hasMore?: boolean;
19
+ loadingMoreComponent?: ReactNode;
20
+ noMoreDataComponent?: ReactNode;
21
+ };
22
+ filterProps?: {
23
+ showFilter?: boolean;
24
+ filterPlaceholder?: string;
25
+ };
26
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { IResponsiveTablePlugin, IPluginAPI } from './IResponsiveTablePlugin';
3
+ export declare class InfiniteScrollPlugin<TData> implements IResponsiveTablePlugin<TData> {
4
+ id: string;
5
+ private api;
6
+ private isLoadingMore;
7
+ constructor();
8
+ onPluginInit: (api: IPluginAPI<TData>) => void;
9
+ private attachScrollListener;
10
+ private handleScroll;
11
+ processData: (data: TData[]) => TData[];
12
+ renderFooter: () => string | number | true | Iterable<React.ReactNode> | React.JSX.Element | null;
13
+ }
@@ -1,6 +1,7 @@
1
1
  import React, { Component, ReactNode } from 'react';
2
2
  import IResponsiveTableColumnDefinition from '../Data/IResponsiveTableColumnDefinition';
3
3
  import IFooterRowDefinition from '../Data/IFooterRowDefinition';
4
+ import { IResponsiveTablePlugin } from '../Plugins/IResponsiveTablePlugin';
4
5
  export type ColumnDefinition<TData> = IResponsiveTableColumnDefinition<TData> | ((data: TData, rowIndex?: number) => IResponsiveTableColumnDefinition<TData>);
5
6
  interface IProps<TData> {
6
7
  columnDefinitions: ColumnDefinition<TData>[];
@@ -10,14 +11,31 @@ interface IProps<TData> {
10
11
  onRowClick?: (item: TData) => void;
11
12
  footerRows?: IFooterRowDefinition[];
12
13
  mobileBreakpoint?: number;
13
- isLoading?: boolean;
14
- animateOnLoad?: boolean;
14
+ plugins?: IResponsiveTablePlugin<TData>[];
15
+ infiniteScrollProps?: {
16
+ enableInfiniteScroll?: boolean;
17
+ onLoadMore?: (currentData: TData[]) => Promise<TData[] | null>;
18
+ hasMore?: boolean;
19
+ loadingMoreComponent?: ReactNode;
20
+ noMoreDataComponent?: ReactNode;
21
+ };
22
+ filterProps?: {
23
+ showFilter?: boolean;
24
+ filterPlaceholder?: string;
25
+ };
26
+ animationProps?: {
27
+ isLoading?: boolean;
28
+ animateOnLoad?: boolean;
29
+ };
15
30
  }
16
- interface IState {
31
+ interface IState<TData> {
17
32
  isMobile: boolean;
33
+ processedData: TData[];
34
+ isLoadingMore: boolean;
18
35
  }
19
- declare class ResponsiveTable<TData> extends Component<IProps<TData>, IState> {
36
+ declare class ResponsiveTable<TData> extends Component<IProps<TData>, IState<TData>> {
20
37
  private debouncedResize;
38
+ private tableContainerRef;
21
39
  constructor(props: IProps<TData>);
22
40
  private get mobileBreakpoint();
23
41
  private debounce;
@@ -27,6 +45,9 @@ declare class ResponsiveTable<TData> extends Component<IProps<TData>, IState> {
27
45
  private get noDataComponent();
28
46
  componentDidMount(): void;
29
47
  componentWillUnmount(): void;
48
+ componentDidUpdate(prevProps: IProps<TData>): void;
49
+ private initializePlugins;
50
+ private processData;
30
51
  handleResize: () => void;
31
52
  private getColumnDefinition;
32
53
  private getRawColumnDefinition;
@@ -39,6 +60,8 @@ declare class ResponsiveTable<TData> extends Component<IProps<TData>, IState> {
39
60
  private get skeletonView();
40
61
  private get mobileView();
41
62
  private get largeScreenView();
42
- render(): React.ReactNode;
63
+ private renderPluginHeaders;
64
+ private renderPluginFooters;
65
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
43
66
  }
44
67
  export default ResponsiveTable;
package/dist/index.d.ts CHANGED
@@ -2,5 +2,8 @@ import IFooterColumnDefinition from './Data/IFooterColumnDefinition';
2
2
  import IFooterRowDefinition from './Data/IFooterRowDefinition';
3
3
  import IResponsiveTableColumnDefinition from './Data/IResponsiveTableColumnDefinition';
4
4
  import ResponsiveTable, { ColumnDefinition } from './UI/ResponsiveTable';
5
- export { IResponsiveTableColumnDefinition, ColumnDefinition, IFooterColumnDefinition, IFooterRowDefinition };
5
+ import { FilterPlugin } from './Plugins/FilterPlugin';
6
+ import { InfiniteScrollPlugin } from './Plugins/InfiniteScrollPlugin';
7
+ import { IResponsiveTablePlugin } from './Plugins/IResponsiveTablePlugin';
8
+ export { IResponsiveTableColumnDefinition, ColumnDefinition, IFooterColumnDefinition, IFooterRowDefinition, FilterPlugin, InfiniteScrollPlugin, IResponsiveTablePlugin };
6
9
  export default ResponsiveTable;