@semcore/data-table 16.0.0-prerelease.13 → 16.0.0-prerelease.14
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 +476 -0
- package/lib/cjs/Body.js.map +1 -0
- package/lib/cjs/DataTable.js +622 -0
- package/lib/cjs/DataTable.js.map +1 -0
- package/lib/cjs/Head.js +399 -0
- package/lib/cjs/Head.js.map +1 -0
- package/lib/cjs/components/Body/Body.js +216 -0
- package/lib/cjs/components/Body/Body.js.map +1 -0
- package/lib/cjs/components/Body/Body.types.js +2 -0
- package/lib/cjs/components/Body/Body.types.js.map +1 -0
- package/lib/cjs/components/Body/Cell.js +133 -0
- package/lib/cjs/components/Body/Cell.js.map +1 -0
- package/lib/cjs/components/Body/Cell.types.js +2 -0
- package/lib/cjs/components/Body/Cell.types.js.map +1 -0
- package/lib/cjs/components/Body/MergedCells.js +27 -0
- package/lib/cjs/components/Body/MergedCells.js.map +1 -0
- package/lib/cjs/components/Body/Row.js +212 -0
- package/lib/cjs/components/Body/Row.js.map +1 -0
- package/lib/cjs/components/Body/Row.types.js +2 -0
- package/lib/cjs/components/Body/Row.types.js.map +1 -0
- package/lib/cjs/components/Body/style.shadow.css +190 -0
- package/lib/cjs/components/DataTable/DataTable.js +565 -0
- package/lib/cjs/components/DataTable/DataTable.js.map +1 -0
- package/lib/cjs/components/DataTable/DataTable.types.js +2 -0
- package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -0
- package/lib/cjs/components/DataTable/dataTable.shadow.css +14 -0
- package/lib/cjs/components/Head/Column.js +277 -0
- package/lib/cjs/components/Head/Column.js.map +1 -0
- package/lib/cjs/components/Head/Column.types.js +2 -0
- package/lib/cjs/components/Head/Column.types.js.map +1 -0
- package/lib/cjs/components/Head/Group.js +98 -0
- package/lib/cjs/components/Head/Group.js.map +1 -0
- package/lib/cjs/components/Head/Group.type.js +2 -0
- package/lib/cjs/components/Head/Group.type.js.map +1 -0
- package/lib/cjs/components/Head/Head.js +152 -0
- package/lib/cjs/components/Head/Head.js.map +1 -0
- package/lib/cjs/components/Head/Head.types.js +2 -0
- package/lib/cjs/components/Head/Head.types.js.map +1 -0
- package/lib/cjs/components/Head/style.shadow.css +165 -0
- package/lib/cjs/index.js +42 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/style/data-table.shadow.css +394 -0
- package/lib/cjs/style/scroll-shadows.shadow.css +11 -0
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +39 -0
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -0
- package/lib/cjs/translations/de.json +3 -0
- package/lib/cjs/translations/en.json +5 -0
- package/lib/cjs/translations/es.json +3 -0
- package/lib/cjs/translations/fr.json +3 -0
- package/lib/cjs/translations/it.json +3 -0
- package/lib/cjs/translations/ja.json +3 -0
- package/lib/cjs/translations/ko.json +3 -0
- package/lib/cjs/translations/nl.json +3 -0
- package/lib/cjs/translations/pl.json +3 -0
- package/lib/cjs/translations/pt.json +3 -0
- package/lib/cjs/translations/sv.json +3 -0
- package/lib/cjs/translations/tr.json +3 -0
- package/lib/cjs/translations/vi.json +3 -0
- package/lib/cjs/translations/zh.json +3 -0
- package/lib/cjs/types.js +4 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/cjs/utils.js +66 -0
- package/lib/cjs/utils.js.map +1 -0
- package/lib/es6/Body.js +469 -0
- package/lib/es6/Body.js.map +1 -0
- package/lib/es6/DataTable.js +614 -0
- package/lib/es6/DataTable.js.map +1 -0
- package/lib/es6/Head.js +391 -0
- package/lib/es6/Head.js.map +1 -0
- package/lib/es6/components/Body/Body.js +209 -0
- package/lib/es6/components/Body/Body.js.map +1 -0
- package/lib/es6/components/Body/Body.types.js +2 -0
- package/lib/es6/components/Body/Body.types.js.map +1 -0
- package/lib/es6/components/Body/Cell.js +126 -0
- package/lib/es6/components/Body/Cell.js.map +1 -0
- package/lib/es6/components/Body/Cell.types.js +2 -0
- package/lib/es6/components/Body/Cell.types.js.map +1 -0
- package/lib/es6/components/Body/MergedCells.js +18 -0
- package/lib/es6/components/Body/MergedCells.js.map +1 -0
- package/lib/es6/components/Body/Row.js +205 -0
- package/lib/es6/components/Body/Row.js.map +1 -0
- package/lib/es6/components/Body/Row.types.js +2 -0
- package/lib/es6/components/Body/Row.types.js.map +1 -0
- package/lib/es6/components/Body/style.shadow.css +190 -0
- package/lib/es6/components/DataTable/DataTable.js +558 -0
- package/lib/es6/components/DataTable/DataTable.js.map +1 -0
- package/lib/es6/components/DataTable/DataTable.types.js +2 -0
- package/lib/es6/components/DataTable/DataTable.types.js.map +1 -0
- package/lib/es6/components/DataTable/dataTable.shadow.css +14 -0
- package/lib/es6/components/Head/Column.js +270 -0
- package/lib/es6/components/Head/Column.js.map +1 -0
- package/lib/es6/components/Head/Column.types.js +2 -0
- package/lib/es6/components/Head/Column.types.js.map +1 -0
- package/lib/es6/components/Head/Group.js +91 -0
- package/lib/es6/components/Head/Group.js.map +1 -0
- package/lib/es6/components/Head/Group.type.js +2 -0
- package/lib/es6/components/Head/Group.type.js.map +1 -0
- package/lib/es6/components/Head/Head.js +145 -0
- package/lib/es6/components/Head/Head.js.map +1 -0
- package/lib/es6/components/Head/Head.types.js +2 -0
- package/lib/es6/components/Head/Head.types.js.map +1 -0
- package/lib/es6/components/Head/style.shadow.css +165 -0
- package/lib/es6/index.js +5 -0
- package/lib/es6/index.js.map +1 -0
- package/lib/es6/style/data-table.shadow.css +394 -0
- package/lib/es6/style/scroll-shadows.shadow.css +11 -0
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +31 -0
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -0
- package/lib/es6/translations/de.json +3 -0
- package/lib/es6/translations/en.json +5 -0
- package/lib/es6/translations/es.json +3 -0
- package/lib/es6/translations/fr.json +3 -0
- package/lib/es6/translations/it.json +3 -0
- package/lib/es6/translations/ja.json +3 -0
- package/lib/es6/translations/ko.json +3 -0
- package/lib/es6/translations/nl.json +3 -0
- package/lib/es6/translations/pl.json +3 -0
- package/lib/es6/translations/pt.json +3 -0
- package/lib/es6/translations/sv.json +3 -0
- package/lib/es6/translations/tr.json +3 -0
- package/lib/es6/translations/vi.json +3 -0
- package/lib/es6/translations/zh.json +3 -0
- package/lib/es6/types.js +2 -0
- package/lib/es6/types.js.map +1 -0
- package/lib/es6/utils.js +56 -0
- package/lib/es6/utils.js.map +1 -0
- package/lib/esm/components/Body/Body.mjs +1 -1
- package/lib/esm/components/Body/Row.mjs +1 -1
- package/lib/types/Body.d.ts +61 -0
- package/lib/types/DataTable.d.ts +205 -0
- package/lib/types/Head.d.ts +45 -0
- package/lib/types/components/Body/Body.d.ts +8 -0
- package/lib/types/components/Body/Body.types.d.ts +31 -0
- package/lib/types/components/Body/Cell.d.ts +3 -0
- package/lib/types/components/Body/Cell.types.d.ts +14 -0
- package/lib/types/components/Body/MergedCells.d.ts +10 -0
- package/lib/types/components/Body/Row.d.ts +3 -0
- package/lib/types/components/Body/Row.types.d.ts +24 -0
- package/lib/types/components/DataTable/DataTable.d.ts +9 -0
- package/lib/types/components/DataTable/DataTable.types.d.ts +50 -0
- package/lib/types/components/Head/Column.d.ts +26 -0
- package/lib/types/components/Head/Column.types.d.ts +80 -0
- package/lib/types/components/Head/Group.d.ts +12 -0
- package/lib/types/components/Head/Group.type.d.ts +10 -0
- package/lib/types/components/Head/Head.d.ts +8 -0
- package/lib/types/components/Head/Head.types.d.ts +26 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +46 -0
- package/lib/types/types.d.ts +73 -0
- package/lib/types/utils.d.ts +8 -0
- package/package.json +7 -6
package/lib/es6/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["ROW_GROUP"],"sources":["../../src/types.ts"],"sourcesContent":["import React from 'react';\nimport { ROW_GROUP } from './DataTable';\nimport { Property } from 'csstype';\nimport { FlexProps } from '@semcore/flex-box';\n\nexport type PseudoChildPropsGetter = (\n props: { [propName: string]: unknown },\n rowData: { [columnName: string]: unknown },\n index: number,\n) => { [propName: string]: unknown };\nexport type PropsLayer = {\n childrenPropsGetter?: PseudoChildPropsGetter;\n [propName: string]: unknown;\n};\n\nexport type SortDirection = 'asc' | 'desc';\nexport type Column<\n Props extends { [propName: string]: unknown } = { [propName: string]: unknown },\n> = {\n name: string;\n active: boolean;\n width: number;\n fixed?: 'left' | 'right';\n resizable?: boolean;\n sortable?: boolean | SortDirection;\n sortDirection: SortDirection;\n varWidth: string;\n setVar: boolean;\n data?: unknown;\n vBorders?: boolean;\n borderLeft?: boolean;\n borderRight?: boolean;\n props: {\n name: string;\n ref: React.RefObject<HTMLElement>;\n } & FlexProps &\n Partial<{\n flex: Property.Flex;\n onClick: (event: React.MouseEvent) => void;\n onKeyDown: (event: React.KeyboardEvent) => void;\n forwardRef: React.Ref<HTMLElement>;\n style: React.CSSProperties;\n fixed: 'left' | 'right';\n resizable: boolean;\n sortable: boolean | SortDirection;\n sortDirection: SortDirection;\n vBorders: boolean;\n borderLeft: Property.BorderLeft;\n borderRight: Property.BorderLeft;\n changeSortSize?: boolean;\n sortSizeRecalculation?: boolean;\n }> &\n Props;\n columns: Column[];\n parentColumns: Column[];\n};\nexport type Cell = Pick<Column, 'name' | 'fixed' | 'data'> & {\n cssVar: string | string[];\n cellPropsLayers: PropsLayer[];\n};\nexport type RowData<\n Data extends { [columnName: string]: unknown } = { [columnName: string]: unknown },\n> = Data &\n Partial<{\n name: string;\n [ROW_GROUP]: RowData[];\n }>;\nexport type NestedCells = (Cell | NestedCells)[] & { flatRowData?: RowData };\n\nexport type RowIndex = number;\nexport type ColIndex = number;\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,aAAa"}
|
package/lib/es6/utils.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export var getScrollOffsetValue = function getScrollOffsetValue(columns) {
|
|
2
|
+
return columns.reduce(function (acc, column) {
|
|
3
|
+
if (column.fixed === 'left') {
|
|
4
|
+
acc[0] += column.calculatedWidth;
|
|
5
|
+
}
|
|
6
|
+
if (column.fixed === 'right') {
|
|
7
|
+
acc[1] += column.calculatedWidth;
|
|
8
|
+
}
|
|
9
|
+
return acc;
|
|
10
|
+
}, [0, 0]);
|
|
11
|
+
};
|
|
12
|
+
var cssVarReg = /[:;\W]/g;
|
|
13
|
+
export var createCssVarForWidth = function createCssVarForWidth(name) {
|
|
14
|
+
return "--".concat(name.replace(cssVarReg, '_'), "_width");
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* todo: Remove after v16
|
|
19
|
+
*/
|
|
20
|
+
export var flattenColumns = function flattenColumns(columns) {
|
|
21
|
+
return columns.reduce(function (acc, column) {
|
|
22
|
+
var hasNestedColumns = 'columns' in column && column.columns.length > 0;
|
|
23
|
+
var columns = hasNestedColumns ? flattenColumns(column.columns) : [column];
|
|
24
|
+
acc = acc.concat(columns);
|
|
25
|
+
return acc;
|
|
26
|
+
}, []);
|
|
27
|
+
};
|
|
28
|
+
export var getFixedStyle = function getFixedStyle(cell, columns) {
|
|
29
|
+
var side = cell.fixed;
|
|
30
|
+
if (!side) return [undefined, undefined];
|
|
31
|
+
var names = cell.name.split('/');
|
|
32
|
+
var nameSideMap = {
|
|
33
|
+
left: names[0],
|
|
34
|
+
right: names[names.length - 1]
|
|
35
|
+
};
|
|
36
|
+
var name = nameSideMap[side];
|
|
37
|
+
var index = columns.findIndex(function (column) {
|
|
38
|
+
return column.name === name;
|
|
39
|
+
});
|
|
40
|
+
if (index === -1) return [undefined, undefined];
|
|
41
|
+
var startIndexSideMap = {
|
|
42
|
+
left: 0,
|
|
43
|
+
right: index + 1
|
|
44
|
+
};
|
|
45
|
+
var endIndexSideMap = {
|
|
46
|
+
left: index,
|
|
47
|
+
right: columns.length
|
|
48
|
+
};
|
|
49
|
+
var columnsFixed = columns.slice(startIndexSideMap[side], endIndexSideMap[side]);
|
|
50
|
+
if (columnsFixed.length < 1) return [side, 0];
|
|
51
|
+
var sum = columnsFixed.reduce(function (acc, column) {
|
|
52
|
+
return acc + column.calculatedWidth;
|
|
53
|
+
}, 0);
|
|
54
|
+
return [side, "".concat(sum, "px")];
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getScrollOffsetValue","columns","reduce","acc","column","fixed","calculatedWidth","cssVarReg","createCssVarForWidth","name","concat","replace","flattenColumns","hasNestedColumns","length","getFixedStyle","cell","side","undefined","names","split","nameSideMap","left","right","index","findIndex","startIndexSideMap","endIndexSideMap","columnsFixed","slice","sum"],"sources":["../../src/utils.ts"],"sourcesContent":["import type { DTColumn } from './components/Head/Column.types';\n\nexport const getScrollOffsetValue = (columns: DTColumn[]) =>\n columns.reduce(\n (acc, column) => {\n if (column.fixed === 'left') {\n acc[0] += column.calculatedWidth;\n }\n if (column.fixed === 'right') {\n acc[1] += column.calculatedWidth;\n }\n return acc;\n },\n [0, 0] as [leftOffset: number, rightOffset: number],\n );\n\nconst cssVarReg = /[:;\\W]/g;\n\nexport const createCssVarForWidth = (name: string) => {\n return `--${name.replace(cssVarReg, '_')}_width`;\n};\n\n/**\n * todo: Remove after v16\n */\nexport const flattenColumns = (columns: any[]) =>\n columns.reduce((acc, column) => {\n const hasNestedColumns = 'columns' in column && column.columns.length > 0;\n const columns: any[] = hasNestedColumns ? flattenColumns(column.columns) : [column];\n acc = acc.concat(columns);\n return acc;\n }, [] as any[]);\n\nexport const getFixedStyle = (\n cell: Pick<DTColumn, 'name' | 'fixed'>,\n columns: DTColumn[],\n): [side: 'left' | 'right', style: string | number] | [side: undefined, style: undefined] => {\n const side = cell.fixed;\n if (!side) return [undefined, undefined];\n const names = cell.name.split('/');\n const nameSideMap = {\n left: names[0],\n right: names[names.length - 1],\n };\n const name = nameSideMap[side];\n const index = columns.findIndex((column) => column.name === name);\n\n if (index === -1) return [undefined, undefined];\n\n const startIndexSideMap = {\n left: 0,\n right: index + 1,\n };\n const endIndexSideMap = {\n left: index,\n right: columns.length,\n };\n const columnsFixed = columns.slice(startIndexSideMap[side], endIndexSideMap[side]);\n\n if (columnsFixed.length < 1) return [side, 0];\n\n const sum = columnsFixed.reduce((acc, column) => acc + column.calculatedWidth, 0);\n return [side, `${sum}px`];\n};\n"],"mappings":"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"}
|
|
@@ -12,7 +12,7 @@ import { Box } from "@semcore/base-components";
|
|
|
12
12
|
import { Row } from "./Row.mjs";
|
|
13
13
|
import { Cell } from "./Cell.mjs";
|
|
14
14
|
import { MergedRowsCell, MergedColumnsCell } from "./MergedCells.mjs";
|
|
15
|
-
import { ACCORDION } from "
|
|
15
|
+
import { ACCORDION } from "../DataTable/DataTable.mjs";
|
|
16
16
|
import ChevronRightM from "@semcore/icon/ChevronRight/m";
|
|
17
17
|
import { ButtonLink } from "@semcore/button";
|
|
18
18
|
import Spin from "@semcore/spin";
|
|
@@ -13,7 +13,7 @@ import { Box, Collapse } from "@semcore/base-components";
|
|
|
13
13
|
import { Body } from "./Body.mjs";
|
|
14
14
|
import { getFixedStyle } from "../../utils.mjs";
|
|
15
15
|
import { MergedColumnsCell, MergedRowsCell } from "./MergedCells.mjs";
|
|
16
|
-
import { ACCORDION } from "
|
|
16
|
+
import { ACCORDION } from "../DataTable/DataTable.mjs";
|
|
17
17
|
var style = (
|
|
18
18
|
/*__reshadow_css_start__*/
|
|
19
19
|
(sstyled.insert(
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Component } from '@semcore/core';
|
|
3
|
+
import { RowData, Column, NestedCells, PropsLayer, Cell } from './types';
|
|
4
|
+
import syncScroll from '@semcore/core/lib/utils/syncScroll';
|
|
5
|
+
type AsProps = {
|
|
6
|
+
rows: NestedCells[][];
|
|
7
|
+
columns: Column[];
|
|
8
|
+
$scrollRef: ReturnType<ReturnType<typeof syncScroll>>;
|
|
9
|
+
onResize: ResizeObserverCallback;
|
|
10
|
+
onScroll?: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
11
|
+
rowPropsLayers: PropsLayer[];
|
|
12
|
+
use: 'primary' | 'secondary';
|
|
13
|
+
uniqueKey: string;
|
|
14
|
+
virtualScroll?: boolean | {
|
|
15
|
+
tollerance?: number;
|
|
16
|
+
rowHeight?: number;
|
|
17
|
+
};
|
|
18
|
+
renderRows?: (props: {
|
|
19
|
+
rows: NestedCells[][];
|
|
20
|
+
columns: Column[];
|
|
21
|
+
renderRow: (row: Cell[], details: {
|
|
22
|
+
dataIndex: number;
|
|
23
|
+
nested: boolean;
|
|
24
|
+
}) => React.ReactNode;
|
|
25
|
+
}) => React.ReactNode;
|
|
26
|
+
disabledScroll?: boolean;
|
|
27
|
+
uid?: string;
|
|
28
|
+
animationsDisabled?: boolean;
|
|
29
|
+
scrollContainerRef: React.Ref<HTMLDivElement>;
|
|
30
|
+
};
|
|
31
|
+
type State = {
|
|
32
|
+
rowHeight: number | undefined;
|
|
33
|
+
scrollAreaHeight: undefined | number;
|
|
34
|
+
scrollOffset: number;
|
|
35
|
+
};
|
|
36
|
+
declare class Body extends Component<AsProps, {}, State> {
|
|
37
|
+
state: State;
|
|
38
|
+
scrollContainerRef: React.RefObject<HTMLDivElement>;
|
|
39
|
+
firstRowRef: React.RefObject<HTMLDivElement>;
|
|
40
|
+
firstRowResizeObserver: ResizeObserver | null;
|
|
41
|
+
lockedCell: [HTMLElement | null, boolean];
|
|
42
|
+
getRowHeight: () => number | undefined;
|
|
43
|
+
handleKeyDown: (e: React.KeyboardEvent) => void;
|
|
44
|
+
onFocusCell: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
|
|
45
|
+
renderCells(cells: NestedCells, rowData: RowData, dataIndex: number): (string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | null | undefined)[];
|
|
46
|
+
renderRow(cells: NestedCells, { dataIndex, topOffset, nested, }: {
|
|
47
|
+
dataIndex: number;
|
|
48
|
+
topOffset?: number;
|
|
49
|
+
nested: boolean;
|
|
50
|
+
}): React.ReactNode;
|
|
51
|
+
renderRows(rows: NestedCells[], nested?: boolean): React.ReactNode[];
|
|
52
|
+
renderVirtualizedRows(rows: NestedCells[]): React.ReactNode[];
|
|
53
|
+
handleFirstRowResize: (entries: ResizeObserverEntry[]) => void;
|
|
54
|
+
handleScrollAreaResize: (entries: ResizeObserverEntry[]) => void;
|
|
55
|
+
handleScrollAreaScroll: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
56
|
+
setupRowSizeObserver: () => void;
|
|
57
|
+
handleBodyTransitionEnd: () => void;
|
|
58
|
+
componentWillUnmount(): void;
|
|
59
|
+
render(): JSX.Element;
|
|
60
|
+
}
|
|
61
|
+
export default Body;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Property } from 'csstype';
|
|
3
|
+
import { Component, PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';
|
|
4
|
+
import { BoxProps, FlexProps } from '@semcore/flex-box';
|
|
5
|
+
import type { Column } from './types';
|
|
6
|
+
declare const ROW_GROUP: unique symbol;
|
|
7
|
+
export type DataTableData = {
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type DataTableSort<Column = string> = [sortBy: Column, sortDirection: 'desc' | 'asc'];
|
|
11
|
+
export type DataTableTheme = 'muted' | 'info' | 'success' | 'warning' | 'danger';
|
|
12
|
+
export type DataTableUse = 'primary' | 'secondary';
|
|
13
|
+
export type DataTableRow = DataTableCell[];
|
|
14
|
+
export type DataTableCell = {
|
|
15
|
+
/** Name of column */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Data of column */
|
|
18
|
+
data: React.ReactNode;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Datatable must have an accessible name (aria-table-name).
|
|
23
|
+
* It should describe table content.
|
|
24
|
+
*/
|
|
25
|
+
type DataTableAriaProps = Intergalactic.RequireAtLeastOne<{
|
|
26
|
+
'aria-label'?: string;
|
|
27
|
+
'aria-labelledby'?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** @deprecated */
|
|
31
|
+
export interface IDataTableProps<DataTableData extends {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}[] = UnknownProperties[]> extends Omit<DataTableProps<DataTableData>, keyof DataTableAriaProps> {
|
|
34
|
+
}
|
|
35
|
+
export type DataTableProps<DataTableData extends {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}[] = UnknownProperties[]> = BoxProps & {
|
|
38
|
+
/** Table theme according to visual hierarchy on the page
|
|
39
|
+
* @default primary
|
|
40
|
+
* */
|
|
41
|
+
use?: DataTableUse;
|
|
42
|
+
/** Data for table */
|
|
43
|
+
data?: DataTableData;
|
|
44
|
+
/** Active sort object */
|
|
45
|
+
sort?: DataTableSort<keyof DataTableData[0]>;
|
|
46
|
+
/** Handler call when request will change sort */
|
|
47
|
+
onSortChange?: (sort: DataTableSort<keyof DataTableData[0]>, e?: React.SyntheticEvent) => void;
|
|
48
|
+
/** Field name in one data entity that is unique accross all dataset
|
|
49
|
+
* @default id
|
|
50
|
+
*/
|
|
51
|
+
uniqueKey?: keyof DataTableData[0];
|
|
52
|
+
/** Make cells compact by changing left and right paddings to smaller ones*/
|
|
53
|
+
compact?: boolean;
|
|
54
|
+
/** Count of total rows if table using virtual scroll. Needs for accessibility */
|
|
55
|
+
totalRows?: number;
|
|
56
|
+
} & DataTableAriaProps;
|
|
57
|
+
/** @deprecated */
|
|
58
|
+
export interface IDataTableHeadProps extends DataTableHeadProps, UnknownProperties {
|
|
59
|
+
}
|
|
60
|
+
export type DataTableHeadProps = BoxProps & {
|
|
61
|
+
/** Sticky table header
|
|
62
|
+
* @deprecated
|
|
63
|
+
* */
|
|
64
|
+
sticky?: boolean;
|
|
65
|
+
/** Hidden header */
|
|
66
|
+
hidden?: boolean;
|
|
67
|
+
/** Disabled scroll (as action) */
|
|
68
|
+
disabledScroll?: boolean;
|
|
69
|
+
/** Enable scroll bar element in header */
|
|
70
|
+
withScrollBar?: boolean;
|
|
71
|
+
/** Disables column width change animation **/
|
|
72
|
+
animationsDisabled?: boolean;
|
|
73
|
+
};
|
|
74
|
+
/** @deprecated */
|
|
75
|
+
export interface IDataTableColumnProps extends DataTableColumnProps, UnknownProperties {
|
|
76
|
+
}
|
|
77
|
+
export type DataTableColumnProps = FlexProps & {
|
|
78
|
+
/** Unique column name */
|
|
79
|
+
name?: string;
|
|
80
|
+
/** Enable sorting for column. And if you are passing a string, you can also set the default sorting */
|
|
81
|
+
sortable?: boolean | 'desc' | 'asc';
|
|
82
|
+
/** Enable resize for column
|
|
83
|
+
* @ignore */
|
|
84
|
+
resizable?: boolean;
|
|
85
|
+
/** Fix column on the left o right side of the table */
|
|
86
|
+
fixed?: 'left' | 'right';
|
|
87
|
+
/** Fields to control the size of the column */
|
|
88
|
+
flex?: Property.Flex | 'inherit';
|
|
89
|
+
/** Add vertical border to the column */
|
|
90
|
+
vBorders?: boolean;
|
|
91
|
+
/** Add vertical border to the right side of the cell */
|
|
92
|
+
borderRight?: boolean;
|
|
93
|
+
/** Add vertical border to the left side of the cell */
|
|
94
|
+
borderLeft?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Enable changing column width with sort icon
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
changeSortSize?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Enable column to use as a column for recalculation width
|
|
102
|
+
* @default false (By default used first column with maximum width)
|
|
103
|
+
*/
|
|
104
|
+
sortSizeRecalculation?: boolean;
|
|
105
|
+
};
|
|
106
|
+
/** @deprecated */
|
|
107
|
+
export interface IDataTableBodyProps extends DataTableBodyProps, UnknownProperties {
|
|
108
|
+
}
|
|
109
|
+
export type DataTableBodyProps = BoxProps & {
|
|
110
|
+
/** Rows table */
|
|
111
|
+
rows?: DataTableRow[];
|
|
112
|
+
/** When enabled, only visually acessable rows are rendered.
|
|
113
|
+
* `tollerance` property controls how many rows outside of viewport are render.
|
|
114
|
+
* `rowHeight` fixes the rows height if it has known. If not provided, first row node height is measured.
|
|
115
|
+
* @default { tollerance: 2 }
|
|
116
|
+
*/
|
|
117
|
+
virtualScroll?: boolean | {
|
|
118
|
+
tollerance?: number;
|
|
119
|
+
rowHeight?: number;
|
|
120
|
+
};
|
|
121
|
+
/** Allows to redefine rows renderning for a very deep and even fragile customization like building custom virtual scrolling */
|
|
122
|
+
renderRows?: (props: {
|
|
123
|
+
rows: DataTableRow[];
|
|
124
|
+
columns: Column[];
|
|
125
|
+
renderRow: (row: DataTableRow, details: {
|
|
126
|
+
dataIndex: number;
|
|
127
|
+
}) => React.ReactNode;
|
|
128
|
+
}) => React.ReactNode;
|
|
129
|
+
/**
|
|
130
|
+
* Called every time user scrolls area
|
|
131
|
+
*/
|
|
132
|
+
onScroll?: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
133
|
+
/** Disabled scroll */
|
|
134
|
+
disabledScroll?: boolean;
|
|
135
|
+
/** Disables column width change animation **/
|
|
136
|
+
animationsDisabled?: boolean;
|
|
137
|
+
/** Ref for table body container */
|
|
138
|
+
scrollContainerRef?: React.Ref<HTMLDivElement>;
|
|
139
|
+
};
|
|
140
|
+
/** @deprecated */
|
|
141
|
+
export interface IDataTableRowProps extends DataTableRowProps, UnknownProperties {
|
|
142
|
+
}
|
|
143
|
+
export type DataTableRowProps = BoxProps & {
|
|
144
|
+
/** Theme for row */
|
|
145
|
+
theme?: DataTableTheme;
|
|
146
|
+
/** Sets row state to active*/
|
|
147
|
+
active?: boolean;
|
|
148
|
+
};
|
|
149
|
+
/** @deprecated */
|
|
150
|
+
export interface IDataTableCellProps extends DataTableCellProps, UnknownProperties {
|
|
151
|
+
}
|
|
152
|
+
export type DataTableCellProps<Name extends string = string> = FlexProps & {
|
|
153
|
+
/** Unique name for column or columns separated by / */
|
|
154
|
+
name: Name;
|
|
155
|
+
/** Theme for cell */
|
|
156
|
+
theme?: DataTableTheme;
|
|
157
|
+
};
|
|
158
|
+
type DataTableCtx = {
|
|
159
|
+
getHeadProps: PropGetterFn;
|
|
160
|
+
getBodyProps: PropGetterFn;
|
|
161
|
+
};
|
|
162
|
+
type IntergalacticDataTableComponent<PropsExtending extends {} = {}> = (<Data extends DataTableData[], Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', DataTableProps<Data> & PropsExtending, DataTableCtx, never>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableProps>;
|
|
163
|
+
type IntergalacticDataTableRowComponent<PropsExtending extends {} = {}> = (<Data extends DataTableData[], Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.PropsRenderingResultComponentProps<Tag, DataTableRowProps & {
|
|
164
|
+
/**
|
|
165
|
+
* That property is ONLY used for the component strict typings. In the component runtime `data` prop set on `<DataTable>...</DataTable> is used.
|
|
166
|
+
*/
|
|
167
|
+
data?: Data;
|
|
168
|
+
} & PropsExtending, DataTableCtx & {
|
|
169
|
+
data: Data;
|
|
170
|
+
}, [
|
|
171
|
+
row: Data[0],
|
|
172
|
+
index: number
|
|
173
|
+
]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableRowProps>;
|
|
174
|
+
type IntergalacticDataTableCellComponent<PropsExtending extends {} = {}> = (<Data extends DataTableData[] = [], Name extends string = string, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.PropsRenderingResultComponentProps<Tag, DataTableCellProps<Name> & {
|
|
175
|
+
/**
|
|
176
|
+
* That property is ONLY used for the componenct strict typings. In the component runtime `data` prop set on `<DataTable>...</DataTable> is used.
|
|
177
|
+
*/
|
|
178
|
+
data?: Data;
|
|
179
|
+
} & PropsExtending, DataTableCtx & {
|
|
180
|
+
data: Data;
|
|
181
|
+
}, [
|
|
182
|
+
row: Data[0],
|
|
183
|
+
index: number
|
|
184
|
+
]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableCellProps>;
|
|
185
|
+
declare const DefinitionTable: (<Data extends DataTableData[], Tag extends Intergalactic.InternalTypings.ComponentTag = "div">(props: Intergalactic.InternalTypings.ComponentProps<Tag, "div", DataTableProps<Data> & {}, DataTableCtx, never>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<"div", "div", DataTableProps<UnknownProperties[]>, {}, {}> & {
|
|
186
|
+
Head: Intergalactic.Component<'div', DataTableHeadProps>;
|
|
187
|
+
Body: Intergalactic.Component<'div', DataTableBodyProps>;
|
|
188
|
+
Column: Intergalactic.Component<'div', DataTableColumnProps>;
|
|
189
|
+
Row: IntergalacticDataTableRowComponent;
|
|
190
|
+
Cell: IntergalacticDataTableCellComponent;
|
|
191
|
+
};
|
|
192
|
+
export { ROW_GROUP };
|
|
193
|
+
export default DefinitionTable;
|
|
194
|
+
export declare const wrapDataTable: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticDataTableComponent<{}>>, "ref" | "tag"> & {
|
|
195
|
+
ref: React.Ref<any>;
|
|
196
|
+
tag: Intergalactic.InternalTypings.ComponentTag;
|
|
197
|
+
} & PropsExtending) => React.ReactNode) => IntergalacticDataTableComponent<PropsExtending>;
|
|
198
|
+
export declare const wrapDataTableRow: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticDataTableRowComponent<{}>>, "ref" | "tag"> & {
|
|
199
|
+
ref: React.Ref<any>;
|
|
200
|
+
tag: Intergalactic.InternalTypings.ComponentTag;
|
|
201
|
+
} & PropsExtending) => React.ReactNode) => IntergalacticDataTableRowComponent<PropsExtending>;
|
|
202
|
+
export declare const wrapDataTableCell: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticDataTableCellComponent<{}>>, "ref" | "tag"> & {
|
|
203
|
+
ref: React.Ref<any>;
|
|
204
|
+
tag: Intergalactic.InternalTypings.ComponentTag;
|
|
205
|
+
} & PropsExtending) => React.ReactNode) => IntergalacticDataTableCellComponent<PropsExtending>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Component } from '@semcore/core';
|
|
3
|
+
import { Column } from './types';
|
|
4
|
+
export declare const SORT_ICON_WIDTH = 20;
|
|
5
|
+
type AsProps = {
|
|
6
|
+
$onSortClick: (name: string, event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
7
|
+
$scrollRef: (instance: unknown) => void;
|
|
8
|
+
use: 'primary' | 'secondary';
|
|
9
|
+
columnsChildren: Column[];
|
|
10
|
+
onResize: ResizeObserverCallback;
|
|
11
|
+
sticky: boolean;
|
|
12
|
+
['data-ui-name']: string;
|
|
13
|
+
uid?: string;
|
|
14
|
+
withScrollBar?: boolean;
|
|
15
|
+
animationsDisabled?: boolean;
|
|
16
|
+
getI18nText?: (str: string) => string;
|
|
17
|
+
};
|
|
18
|
+
declare class Head extends Component<AsProps> {
|
|
19
|
+
columns: any[];
|
|
20
|
+
static displayName: string;
|
|
21
|
+
headCellMap: Map<number, HTMLElement | null>;
|
|
22
|
+
lockedCell: [HTMLElement | null, boolean];
|
|
23
|
+
sortWrapperRefs: Map<Node, boolean>;
|
|
24
|
+
defaultWidths: Map<HTMLElement, {
|
|
25
|
+
minWidth: number;
|
|
26
|
+
maxWidth: number | null;
|
|
27
|
+
computedWidth: number;
|
|
28
|
+
useForRecalculation: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
sortableColumnDescribeId(): string;
|
|
31
|
+
handleKeyDown: (e: React.KeyboardEvent) => void;
|
|
32
|
+
onFocusCell: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
|
|
33
|
+
bindHandlerSortClick: (name: string) => (event: React.MouseEvent) => void;
|
|
34
|
+
bindHandlerKeyDown: (name: string) => (event: React.KeyboardEvent) => void;
|
|
35
|
+
makeSortRefHandler: (active: boolean) => (ref: HTMLElement | null) => void;
|
|
36
|
+
makeColumnRefHandler: (column: Column, index: number) => (ref: HTMLElement | null) => void;
|
|
37
|
+
componentDidUpdate(): void;
|
|
38
|
+
changeMaxNodeWidth: (diff: number, exceptNode: HTMLElement) => void;
|
|
39
|
+
backToColumnDefaults: (node: HTMLElement) => void;
|
|
40
|
+
calculateActiveColumnMinWidth: (node: HTMLElement) => void;
|
|
41
|
+
renderColumns(columns: Column[], width: number): React.ReactNode[];
|
|
42
|
+
renderColumn(column: Column, width: number): React.ReactNode;
|
|
43
|
+
render(): React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
export default Head;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Component, Intergalactic } from '@semcore/core';
|
|
2
|
+
import { DataTableBodyProps } from './Body.types';
|
|
3
|
+
import { DataTableRowProps } from './Row.types';
|
|
4
|
+
import { DataTableCellProps } from './Cell.types';
|
|
5
|
+
export declare const Body: (<Tag extends Intergalactic.InternalTypings.ComponentTag = "div", Props extends DataTableBodyProps = DataTableBodyProps>(props: Intergalactic.InternalTypings.ComponentProps<Tag, "div", Props, {}, never[]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<"div", Intergalactic.InternalTypings.ComponentTag, DataTableBodyProps, {}, never[]> & {
|
|
6
|
+
Row: Intergalactic.Component<'div', DataTableRowProps>;
|
|
7
|
+
Cell: Intergalactic.Component<'div', DataTableCellProps>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DTRow } from './Row.types';
|
|
3
|
+
import { DTColumn } from '../Head/Column.types';
|
|
4
|
+
import { DTUse } from '../DataTable/DataTable.types';
|
|
5
|
+
type CellRenderProps = {
|
|
6
|
+
name: string;
|
|
7
|
+
row: DTRow;
|
|
8
|
+
column: DTColumn;
|
|
9
|
+
rowIndex: number;
|
|
10
|
+
columnIndex: number;
|
|
11
|
+
value: string | number | boolean;
|
|
12
|
+
defaultRender: () => React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export type DataTableBodyProps = {
|
|
15
|
+
renderCell?: (props: CellRenderProps) => React.ReactNode;
|
|
16
|
+
expandedRows?: number[];
|
|
17
|
+
};
|
|
18
|
+
export type BodyPropsInner = {
|
|
19
|
+
rows: DTRow[];
|
|
20
|
+
columns: DTColumn[];
|
|
21
|
+
use: DTUse;
|
|
22
|
+
scrollRef: (ref: HTMLDivElement) => void;
|
|
23
|
+
headerRows: number;
|
|
24
|
+
compact: boolean;
|
|
25
|
+
gridTemplateColumns: string[];
|
|
26
|
+
gridTemplateAreas: string[];
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
headerHeight: number;
|
|
29
|
+
getI18nText: (key: string) => string;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DTRow } from './Row.types';
|
|
2
|
+
import { DTUse } from '../DataTable/DataTable.types';
|
|
3
|
+
import { DTColumn, CommonColumnType } from '../Head/Column.types';
|
|
4
|
+
export type DataTableCellProps = CommonColumnType & {
|
|
5
|
+
name: string;
|
|
6
|
+
row: DTRow;
|
|
7
|
+
columnIndex: number;
|
|
8
|
+
column: DTColumn;
|
|
9
|
+
rowIndex: number;
|
|
10
|
+
gridArea?: string;
|
|
11
|
+
};
|
|
12
|
+
export type CellPropsInner = {
|
|
13
|
+
use: DTUse;
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class MergedRowsCell {
|
|
2
|
+
readonly value: any;
|
|
3
|
+
readonly rowsCount: number;
|
|
4
|
+
constructor(value: any, size: number);
|
|
5
|
+
}
|
|
6
|
+
export declare class MergedColumnsCell {
|
|
7
|
+
readonly value: any;
|
|
8
|
+
readonly columnsCount: number;
|
|
9
|
+
constructor(value: any, size: number);
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DTValue, DTKey, DTUse } from '../DataTable/DataTable.types';
|
|
2
|
+
import { DTColumn } from '../Head/Column.types';
|
|
3
|
+
import { MergedColumnsCell, MergedRowsCell } from './MergedCells';
|
|
4
|
+
export type DTRow = Record<DTKey, DTValue | MergedRowsCell | MergedColumnsCell>;
|
|
5
|
+
export type DataTableRowProps = {
|
|
6
|
+
columns: DTColumn[];
|
|
7
|
+
row: DTRow;
|
|
8
|
+
rows: DTRow[];
|
|
9
|
+
rowIndex: number;
|
|
10
|
+
headerRows: number;
|
|
11
|
+
expandedRows?: number[];
|
|
12
|
+
onExpandRow?: (expandedRowIndex: number) => void;
|
|
13
|
+
};
|
|
14
|
+
export type RowPropsInner = {
|
|
15
|
+
use: DTUse;
|
|
16
|
+
/**
|
|
17
|
+
* Expanded flag for rows with accordion
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
expanded?: boolean;
|
|
21
|
+
gridTemplateAreas: string;
|
|
22
|
+
gridTemplateColumns: string;
|
|
23
|
+
accordionDataGridArea: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Intergalactic } from '@semcore/core';
|
|
2
|
+
import { DataTableProps } from './DataTable.types';
|
|
3
|
+
import { Head } from '../Head/Head';
|
|
4
|
+
import { Body } from '../Body/Body';
|
|
5
|
+
export declare const ACCORDION: unique symbol;
|
|
6
|
+
export declare const DataTable: (<Tag extends Intergalactic.InternalTypings.ComponentTag = "div", Props extends DataTableProps = DataTableProps>(props: Intergalactic.InternalTypings.ComponentProps<Tag, "div", Props, {}, never[]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<"div", Intergalactic.InternalTypings.ComponentTag, DataTableProps, {}, never[]> & {
|
|
7
|
+
Head: typeof Head;
|
|
8
|
+
Body: typeof Body;
|
|
9
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Intergalactic } from '@semcore/core';
|
|
3
|
+
import { BoxProps } from '@semcore/base-components';
|
|
4
|
+
/**
|
|
5
|
+
* Datatable must have an accessible name (aria-table-name).
|
|
6
|
+
* It should describe table content.
|
|
7
|
+
*/
|
|
8
|
+
type DataTableAriaProps = Intergalactic.RequireAtLeastOne<{
|
|
9
|
+
'aria-label'?: string;
|
|
10
|
+
'aria-labelledby'?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type SortDirection = 'asc' | 'desc';
|
|
14
|
+
export type DataTableSort<Column = string> = [sortBy: Column, sortDirection: SortDirection];
|
|
15
|
+
export type DTKey = string | symbol;
|
|
16
|
+
export type DTValue = string | number | boolean;
|
|
17
|
+
export type DataTableData = Array<Record<DTKey, any>>;
|
|
18
|
+
export type DTUse = 'primary' | 'secondary';
|
|
19
|
+
type Sizes = Pick<BoxProps, 'w' | 'wMax' | 'wMin' | 'h' | 'hMax' | 'hMin'>;
|
|
20
|
+
export type DataTableProps = DataTableAriaProps & Sizes & {
|
|
21
|
+
/** Data for table */
|
|
22
|
+
data: DataTableData;
|
|
23
|
+
/** Count of total rows if table using virtual scroll. Needs for accessibility */
|
|
24
|
+
totalRows?: number;
|
|
25
|
+
/** Table theme according to visual hierarchy on the page
|
|
26
|
+
* @default primary
|
|
27
|
+
* */
|
|
28
|
+
use?: DTUse;
|
|
29
|
+
/** Active sort object */
|
|
30
|
+
sort?: DataTableSort;
|
|
31
|
+
/** Handler call when request will change sort */
|
|
32
|
+
onSortChange?: (sort: DataTableSort, e?: React.SyntheticEvent) => void;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @default auto
|
|
36
|
+
*/
|
|
37
|
+
defaultGridTemplateColumnWidth?: 'auto' | '1fr';
|
|
38
|
+
/**
|
|
39
|
+
* Flag for compact view (less paddings)
|
|
40
|
+
*/
|
|
41
|
+
compact?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Flag for showing spinner on table body
|
|
44
|
+
*/
|
|
45
|
+
loading?: boolean;
|
|
46
|
+
children?: any;
|
|
47
|
+
};
|
|
48
|
+
export type RowIndex = number;
|
|
49
|
+
export type ColIndex = number;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Component } from '@semcore/core';
|
|
3
|
+
import { ColumnPropsInner, DataTableColumnProps } from './Column.types';
|
|
4
|
+
type State = {
|
|
5
|
+
sortVisible: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare class Column extends Component<DataTableColumnProps, {}, {}, [], ColumnPropsInner> {
|
|
8
|
+
static displayName: string;
|
|
9
|
+
static style: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
lockedCell: [HTMLElement | null, boolean];
|
|
13
|
+
columnRef: React.RefObject<HTMLDivElement>;
|
|
14
|
+
sortWrapperRef: React.RefObject<HTMLDivElement>;
|
|
15
|
+
state: State;
|
|
16
|
+
componentDidUpdate(prevProps: DataTableColumnProps & ColumnPropsInner): void;
|
|
17
|
+
calculateActiveColumnMinWidth: () => number | null;
|
|
18
|
+
handleMouseEnter: () => void;
|
|
19
|
+
handleMouseLeave: () => void;
|
|
20
|
+
handleBlur: () => void;
|
|
21
|
+
handleSortClick: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
|
|
22
|
+
handleKeyDown: (e: React.KeyboardEvent) => void;
|
|
23
|
+
handleFocusCell: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
|
|
24
|
+
render(): React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export {};
|