@semcore/data-table 4.0.0-beta.0 → 4.0.0-beta.1
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.
- package/lib/cjs/Body.js +7 -8
- package/lib/cjs/Body.js.map +1 -1
- package/lib/cjs/DataTable.js +40 -40
- package/lib/cjs/DataTable.js.map +1 -1
- package/lib/cjs/Head.js +6 -7
- package/lib/cjs/Head.js.map +1 -1
- package/lib/es6/Body.js +6 -7
- package/lib/es6/Body.js.map +1 -1
- package/lib/es6/DataTable.js +40 -40
- package/lib/es6/DataTable.js.map +1 -1
- package/lib/es6/Head.js +6 -7
- package/lib/es6/Head.js.map +1 -1
- package/lib/types/Body.d.ts +5 -12
- package/lib/types/DataTable.d.ts +16 -16
- package/lib/types/Head.d.ts +1 -2
- package/lib/types/types.d.ts +7 -7
- package/lib/types/utils.d.ts +1 -3
- package/package.json +7 -8
package/lib/types/Body.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Component } from '@semcore/core';
|
|
3
3
|
import { RowData, Column, NestedCells, PropsLayer } from './types';
|
|
4
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
5
4
|
import syncScroll from '@semcore/utils/lib/syncScroll';
|
|
6
|
-
|
|
5
|
+
type AsProps = {
|
|
7
6
|
rows: NestedCells[];
|
|
8
7
|
columns: Column[];
|
|
9
8
|
$scrollRef: ReturnType<ReturnType<typeof syncScroll>>;
|
|
@@ -19,14 +18,14 @@ declare type AsProps = {
|
|
|
19
18
|
disabledScroll?: boolean;
|
|
20
19
|
uid?: string;
|
|
21
20
|
};
|
|
22
|
-
|
|
21
|
+
type State = {
|
|
23
22
|
rowHeight: number | undefined;
|
|
24
23
|
scrollAreaHeight: undefined | number;
|
|
25
24
|
scrollOffset: number;
|
|
26
25
|
};
|
|
27
26
|
declare class Body extends Component<AsProps, State> {
|
|
28
27
|
state: State;
|
|
29
|
-
firstRowRef: React.RefObject<
|
|
28
|
+
firstRowRef: React.RefObject<HTMLDivElement>;
|
|
30
29
|
firstRowResizeObserver: ResizeObserver | null;
|
|
31
30
|
getRowHeight: () => number | undefined;
|
|
32
31
|
renderCells(cells: NestedCells, rowData: RowData, dataIndex: number): React.ReactNode[];
|
|
@@ -37,14 +36,8 @@ declare class Body extends Component<AsProps, State> {
|
|
|
37
36
|
}): React.ReactNode;
|
|
38
37
|
renderRows(rows: NestedCells[], nested?: boolean): React.ReactNode[];
|
|
39
38
|
renderVirtualizedRows(rows: NestedCells[]): React.ReactNode[];
|
|
40
|
-
handleFirstRowResize:
|
|
41
|
-
|
|
42
|
-
cancel(): void;
|
|
43
|
-
};
|
|
44
|
-
handleScrollAreaResize: {
|
|
45
|
-
(...args: any[]): void;
|
|
46
|
-
cancel(): void;
|
|
47
|
-
};
|
|
39
|
+
handleFirstRowResize: (entries: ResizeObserverEntry[]) => void;
|
|
40
|
+
handleScrollAreaResize: (entries: ResizeObserverEntry[]) => void;
|
|
48
41
|
handleScrollAreaScroll: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
49
42
|
setupRowSizeObserver: () => void;
|
|
50
43
|
componentWillUnmount(): void;
|
package/lib/types/DataTable.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ import { Property } from 'csstype';
|
|
|
3
3
|
import { Component, PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';
|
|
4
4
|
import { BoxProps, FlexProps } from '@semcore/flex-box';
|
|
5
5
|
declare const ROW_GROUP: unique symbol;
|
|
6
|
-
export
|
|
6
|
+
export type DataTableData = {
|
|
7
7
|
[key: string]: unknown;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type DataTableSort<Columns extends string | number | symbol = string> = [
|
|
10
10
|
sortBy: Columns,
|
|
11
11
|
sortDirection: 'desc' | 'asc'
|
|
12
12
|
];
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
13
|
+
export type DataTableTheme = 'muted' | 'info' | 'success' | 'warning' | 'danger';
|
|
14
|
+
export type DataTableUse = 'primary' | 'secondary';
|
|
15
|
+
export type DataTableRow = DataTableCell[];
|
|
16
|
+
export type DataTableCell = {
|
|
17
17
|
/** Name of column */
|
|
18
18
|
name: string;
|
|
19
19
|
/** Data of column */
|
|
@@ -25,7 +25,7 @@ export interface IDataTableProps<DataTableData extends {
|
|
|
25
25
|
[key: string]: any;
|
|
26
26
|
}[] = UnknownProperties[]> extends DataTableProps<DataTableData> {
|
|
27
27
|
}
|
|
28
|
-
export
|
|
28
|
+
export type DataTableProps<DataTableData extends {
|
|
29
29
|
[key: string]: any;
|
|
30
30
|
}[] = UnknownProperties[]> = BoxProps & {
|
|
31
31
|
/** Theme for table
|
|
@@ -48,7 +48,7 @@ export declare type DataTableProps<DataTableData extends {
|
|
|
48
48
|
/** @deprecated */
|
|
49
49
|
export interface IDataTableHeadProps extends DataTableHeadProps, UnknownProperties {
|
|
50
50
|
}
|
|
51
|
-
export
|
|
51
|
+
export type DataTableHeadProps = BoxProps & {
|
|
52
52
|
/** Sticky header table
|
|
53
53
|
* @deprecated
|
|
54
54
|
* */
|
|
@@ -61,7 +61,7 @@ export declare type DataTableHeadProps = BoxProps & {
|
|
|
61
61
|
/** @deprecated */
|
|
62
62
|
export interface IDataTableColumnProps extends DataTableColumnProps, UnknownProperties {
|
|
63
63
|
}
|
|
64
|
-
export
|
|
64
|
+
export type DataTableColumnProps = FlexProps & {
|
|
65
65
|
/** Unique name column */
|
|
66
66
|
name?: string;
|
|
67
67
|
/** Enable sort for column also if you pass string you can set default sort */
|
|
@@ -83,7 +83,7 @@ export declare type DataTableColumnProps = FlexProps & {
|
|
|
83
83
|
/** @deprecated */
|
|
84
84
|
export interface IDataTableBodyProps extends DataTableBodyProps, UnknownProperties {
|
|
85
85
|
}
|
|
86
|
-
export
|
|
86
|
+
export type DataTableBodyProps = BoxProps & {
|
|
87
87
|
/** Rows table */
|
|
88
88
|
rows?: DataTableRow[];
|
|
89
89
|
/** When enabled, only visually acessable rows are rendered.
|
|
@@ -105,7 +105,7 @@ export declare type DataTableBodyProps = BoxProps & {
|
|
|
105
105
|
/** @deprecated */
|
|
106
106
|
export interface IDataTableRowProps extends DataTableRowProps, UnknownProperties {
|
|
107
107
|
}
|
|
108
|
-
export
|
|
108
|
+
export type DataTableRowProps = BoxProps & {
|
|
109
109
|
/** Theme for row */
|
|
110
110
|
theme?: DataTableTheme;
|
|
111
111
|
/** Displays row as active */
|
|
@@ -114,23 +114,23 @@ export declare type DataTableRowProps = BoxProps & {
|
|
|
114
114
|
/** @deprecated */
|
|
115
115
|
export interface IDataTableCellProps extends DataTableCellProps, UnknownProperties {
|
|
116
116
|
}
|
|
117
|
-
export
|
|
117
|
+
export type DataTableCellProps<Name extends string = string> = FlexProps & {
|
|
118
118
|
/** Unique name column or columns separated by / */
|
|
119
|
-
name:
|
|
119
|
+
name: Name;
|
|
120
120
|
/** Theme for cell */
|
|
121
121
|
theme?: DataTableTheme;
|
|
122
122
|
};
|
|
123
|
-
|
|
123
|
+
type DataTableCtx = {
|
|
124
124
|
getHeadProps: PropGetterFn;
|
|
125
125
|
getBodyProps: PropGetterFn;
|
|
126
126
|
};
|
|
127
|
-
|
|
127
|
+
type IntergalacticDataTableRowComponent = (<Data extends DataTableData[], Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.PropsRenderingResultComponentProps<Tag, DataTableRowProps, DataTableCtx & {
|
|
128
128
|
data: Data;
|
|
129
129
|
}, [
|
|
130
130
|
row: Data[0],
|
|
131
131
|
index: number
|
|
132
132
|
]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div'>;
|
|
133
|
-
|
|
133
|
+
type IntergalacticDataTableCellComponent = (<Data extends DataTableData[], Name extends string = string, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.PropsRenderingResultComponentProps<Tag, DataTableCellProps<Name>, DataTableCtx & {
|
|
134
134
|
data: Data;
|
|
135
135
|
}, [
|
|
136
136
|
row: Data[0],
|
package/lib/types/Head.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Component } from '@semcore/core';
|
|
3
3
|
import type { Column } from './types';
|
|
4
|
-
|
|
5
|
-
declare type AsProps = {
|
|
4
|
+
type AsProps = {
|
|
6
5
|
$onSortClick: (name: string, event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
7
6
|
$scrollRef: (instance: unknown) => void;
|
|
8
7
|
use: 'primary' | 'secondary';
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ROW_GROUP } from './DataTable';
|
|
3
3
|
import { Property } from 'csstype';
|
|
4
|
-
export
|
|
4
|
+
export type PseudoChildPropsGetter = (props: {
|
|
5
5
|
[propName: string]: unknown;
|
|
6
6
|
}, rowData: {
|
|
7
7
|
[columnName: string]: unknown;
|
|
8
8
|
}, index: number) => {
|
|
9
9
|
[propName: string]: unknown;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type PropsLayer = {
|
|
12
12
|
childrenPropsGetter?: PseudoChildPropsGetter;
|
|
13
13
|
[propName: string]: unknown;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type SortDirection = 'asc' | 'desc';
|
|
16
|
+
export type Column<Props extends {
|
|
17
17
|
[propName: string]: unknown;
|
|
18
18
|
} = {
|
|
19
19
|
[propName: string]: unknown;
|
|
@@ -54,11 +54,11 @@ export declare type Column<Props extends {
|
|
|
54
54
|
columns: Column[];
|
|
55
55
|
parentColumns: Column[];
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type Cell = Pick<Column, 'name' | 'fixed' | 'data'> & {
|
|
58
58
|
cssVar: string | string[];
|
|
59
59
|
cellPropsLayers: PropsLayer[];
|
|
60
60
|
};
|
|
61
|
-
export
|
|
61
|
+
export type RowData<Data extends {
|
|
62
62
|
[columnName: string]: unknown;
|
|
63
63
|
} = {
|
|
64
64
|
[columnName: string]: unknown;
|
|
@@ -66,6 +66,6 @@ export declare type RowData<Data extends {
|
|
|
66
66
|
name: string;
|
|
67
67
|
[ROW_GROUP]: RowData[];
|
|
68
68
|
}>;
|
|
69
|
-
export
|
|
69
|
+
export type NestedCells = (Cell | NestedCells)[] & {
|
|
70
70
|
flatRowData?: RowData;
|
|
71
71
|
};
|
package/lib/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { Column } from './types';
|
|
2
2
|
export declare const getScrollOffsetValue: (columns: Column[]) => [leftOffset: number, rightOffset: number];
|
|
3
|
-
export declare const flattenColumns: (columns: Column[]) => Column
|
|
4
|
-
[propName: string]: unknown;
|
|
5
|
-
}>[];
|
|
3
|
+
export declare const flattenColumns: (columns: Column[]) => Column[];
|
|
6
4
|
export declare const getFixedStyle: (cell: Pick<Column, 'name' | 'fixed'>, columns: Column[]) => [side: "left" | "right", style: string | number] | [side: undefined, style: undefined];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/data-table",
|
|
3
3
|
"description": "Semrush DataTable Component",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.1",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
"author": "UI-kit team <ui-kit-team@semrush.com>",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@semcore/flex-box": "5.0.0-beta.
|
|
13
|
-
"@semcore/icon": "4.0.0-beta.
|
|
14
|
-
"@semcore/scroll-area": "5.0.0-beta.
|
|
15
|
-
"@semcore/utils": "4.0.0-beta.
|
|
16
|
-
"resize-observer-polyfill": "^1.5"
|
|
12
|
+
"@semcore/flex-box": "5.0.0-beta.1",
|
|
13
|
+
"@semcore/icon": "4.0.0-beta.1",
|
|
14
|
+
"@semcore/scroll-area": "5.0.0-beta.1",
|
|
15
|
+
"@semcore/utils": "4.0.0-beta.1"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@types/react": "18.0.21",
|
|
@@ -32,11 +31,11 @@
|
|
|
32
31
|
"@semcore/spin-container": "*",
|
|
33
32
|
"@semcore/sticky": "*",
|
|
34
33
|
"@semcore/tooltip": "*",
|
|
35
|
-
"@types/node": "^
|
|
34
|
+
"@types/node": "^18.16.15",
|
|
36
35
|
"csstype": "3.0.8"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
|
-
"@semcore/core": "2.0.0-beta.
|
|
38
|
+
"@semcore/core": "2.0.0-beta.1",
|
|
40
39
|
"react": "16.8 - 18",
|
|
41
40
|
"react-dom": "16.8 - 18"
|
|
42
41
|
},
|