@semcore/data-table 3.0.8 → 3.1.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.
- package/CHANGELOG.md +18 -0
- package/README.md +67 -0
- package/lib/cjs/Body.js +8 -7
- package/lib/cjs/Body.js.map +1 -1
- package/lib/cjs/DataTable.js +38 -39
- package/lib/cjs/DataTable.js.map +1 -1
- package/lib/cjs/Head.js +6 -6
- package/lib/cjs/Head.js.map +1 -1
- package/lib/cjs/style/data-table.shadow.css +3 -1
- package/lib/es6/Body.js +8 -7
- package/lib/es6/Body.js.map +1 -1
- package/lib/es6/DataTable.js +39 -40
- package/lib/es6/DataTable.js.map +1 -1
- package/lib/es6/Head.js +6 -6
- package/lib/es6/Head.js.map +1 -1
- package/lib/es6/style/data-table.shadow.css +3 -1
- package/lib/types/Body.d.ts +1 -0
- package/lib/types/DataTable.d.ts +4 -0
- package/package.json +2 -2
- package/src/Body.tsx +4 -2
- package/src/DataTable.tsx +10 -9
- package/src/Head.tsx +1 -1
- package/src/style/data-table.shadow.css +3 -1
package/src/DataTable.tsx
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import createComponent, { Component,
|
|
2
|
+
import createComponent, { Component, PropGetterFn, Root, sstyled } from '@semcore/core';
|
|
3
3
|
import { Box, IBoxProps, IFlexProps } from '@semcore/flex-box';
|
|
4
4
|
import syncScroll from '@semcore/utils/lib/syncScroll';
|
|
5
5
|
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
6
6
|
import fire from '@semcore/utils/lib/fire';
|
|
7
7
|
import { flattenColumns } from './utils';
|
|
8
8
|
import type {
|
|
9
|
+
Column,
|
|
10
|
+
NestedCells,
|
|
11
|
+
PropsLayer,
|
|
12
|
+
PseudoChildPropsGetter,
|
|
9
13
|
RowData,
|
|
10
14
|
SortDirection,
|
|
11
|
-
PseudoChildPropsGetter,
|
|
12
|
-
PropsLayer,
|
|
13
|
-
NestedCells,
|
|
14
|
-
Column,
|
|
15
15
|
} from './types';
|
|
16
16
|
import Head from './Head';
|
|
17
17
|
import Body from './Body';
|
|
@@ -117,6 +117,10 @@ export interface IDataTableBodyProps extends IBoxProps {
|
|
|
117
117
|
* @default { tollerance: 2 }
|
|
118
118
|
*/
|
|
119
119
|
virtualScroll?: boolean | { tollerance?: number; rowHeight?: number };
|
|
120
|
+
/**
|
|
121
|
+
* Called every time user scrolls area
|
|
122
|
+
*/
|
|
123
|
+
onScroll?: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
export interface IDataTableRowProps extends IBoxProps {
|
|
@@ -230,7 +234,6 @@ class RootDefinitionTable extends Component<AsProps> {
|
|
|
230
234
|
}
|
|
231
235
|
|
|
232
236
|
const column = this.columns.find((column) => column.name === name);
|
|
233
|
-
|
|
234
237
|
columnsChildren.push({
|
|
235
238
|
get width() {
|
|
236
239
|
return this.props.ref.current?.getBoundingClientRect().width || 0;
|
|
@@ -301,7 +304,7 @@ class RootDefinitionTable extends Component<AsProps> {
|
|
|
301
304
|
}
|
|
302
305
|
});
|
|
303
306
|
|
|
304
|
-
|
|
307
|
+
return {
|
|
305
308
|
columns: this.columns,
|
|
306
309
|
rows: this.dataToRows(data, cellPropsLayers),
|
|
307
310
|
uniqueKey,
|
|
@@ -309,8 +312,6 @@ class RootDefinitionTable extends Component<AsProps> {
|
|
|
309
312
|
rowPropsLayers,
|
|
310
313
|
$scrollRef: this.scrollBodyRef,
|
|
311
314
|
};
|
|
312
|
-
|
|
313
|
-
return result;
|
|
314
315
|
}
|
|
315
316
|
|
|
316
317
|
dataToRows(data: RowData[], cellPropsLayers: { [columnName: string]: PropsLayer[] }) {
|
package/src/Head.tsx
CHANGED
|
@@ -105,8 +105,8 @@ class Head extends Component<AsProps> {
|
|
|
105
105
|
|
|
106
106
|
render() {
|
|
107
107
|
const SHead = Root;
|
|
108
|
-
const { Children, styles, columnsChildren, onResize, $scrollRef, sticky } = this.asProps;
|
|
109
108
|
const SHeadWrapper = Box;
|
|
109
|
+
const { Children, styles, columnsChildren, onResize, $scrollRef, sticky } = this.asProps;
|
|
110
110
|
|
|
111
111
|
this.columns = flattenColumns(columnsChildren);
|
|
112
112
|
|