@semcore/data-table 16.0.7 → 16.1.0-prerelease.2

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 (70) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/lib/cjs/components/Body/Body.js +143 -103
  3. package/lib/cjs/components/Body/Body.js.map +1 -1
  4. package/lib/cjs/components/Body/Body.types.js.map +1 -1
  5. package/lib/cjs/components/Body/Cell.js +69 -46
  6. package/lib/cjs/components/Body/Cell.js.map +1 -1
  7. package/lib/cjs/components/Body/Cell.types.js.map +1 -1
  8. package/lib/cjs/components/Body/Row.js +46 -43
  9. package/lib/cjs/components/Body/Row.js.map +1 -1
  10. package/lib/cjs/components/Body/Row.types.js.map +1 -1
  11. package/lib/cjs/components/Body/style.shadow.css +68 -13
  12. package/lib/cjs/components/DataTable/DataTable.js +188 -109
  13. package/lib/cjs/components/DataTable/DataTable.js.map +1 -1
  14. package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -1
  15. package/lib/cjs/components/Head/Column.js +39 -25
  16. package/lib/cjs/components/Head/Column.js.map +1 -1
  17. package/lib/cjs/components/Head/Column.types.js.map +1 -1
  18. package/lib/cjs/components/Head/Group.js +43 -31
  19. package/lib/cjs/components/Head/Group.js.map +1 -1
  20. package/lib/cjs/components/Head/Group.type.js.map +1 -1
  21. package/lib/cjs/components/Head/Head.js +41 -30
  22. package/lib/cjs/components/Head/Head.js.map +1 -1
  23. package/lib/cjs/components/Head/Head.types.js.map +1 -1
  24. package/lib/cjs/components/Head/style.shadow.css +64 -3
  25. package/lib/cjs/style/scroll-shadows.shadow.css +7 -12
  26. package/lib/es6/components/Body/Body.js +144 -104
  27. package/lib/es6/components/Body/Body.js.map +1 -1
  28. package/lib/es6/components/Body/Body.types.js.map +1 -1
  29. package/lib/es6/components/Body/Cell.js +69 -46
  30. package/lib/es6/components/Body/Cell.js.map +1 -1
  31. package/lib/es6/components/Body/Cell.types.js.map +1 -1
  32. package/lib/es6/components/Body/Row.js +47 -44
  33. package/lib/es6/components/Body/Row.js.map +1 -1
  34. package/lib/es6/components/Body/Row.types.js.map +1 -1
  35. package/lib/es6/components/Body/style.shadow.css +68 -13
  36. package/lib/es6/components/DataTable/DataTable.js +187 -108
  37. package/lib/es6/components/DataTable/DataTable.js.map +1 -1
  38. package/lib/es6/components/DataTable/DataTable.types.js.map +1 -1
  39. package/lib/es6/components/Head/Column.js +39 -25
  40. package/lib/es6/components/Head/Column.js.map +1 -1
  41. package/lib/es6/components/Head/Column.types.js.map +1 -1
  42. package/lib/es6/components/Head/Group.js +43 -31
  43. package/lib/es6/components/Head/Group.js.map +1 -1
  44. package/lib/es6/components/Head/Group.type.js.map +1 -1
  45. package/lib/es6/components/Head/Head.js +41 -30
  46. package/lib/es6/components/Head/Head.js.map +1 -1
  47. package/lib/es6/components/Head/Head.types.js.map +1 -1
  48. package/lib/es6/components/Head/style.shadow.css +64 -3
  49. package/lib/es6/style/scroll-shadows.shadow.css +7 -12
  50. package/lib/esm/components/Body/Body.mjs +97 -64
  51. package/lib/esm/components/Body/Cell.mjs +67 -47
  52. package/lib/esm/components/Body/Row.mjs +48 -45
  53. package/lib/esm/components/Body/style.shadow.css +68 -13
  54. package/lib/esm/components/DataTable/DataTable.mjs +133 -66
  55. package/lib/esm/components/Head/Column.mjs +40 -26
  56. package/lib/esm/components/Head/Group.mjs +43 -32
  57. package/lib/esm/components/Head/Head.mjs +39 -31
  58. package/lib/esm/components/Head/style.shadow.css +64 -3
  59. package/lib/esm/style/scroll-shadows.shadow.css +7 -12
  60. package/lib/types/components/Body/Body.d.ts +6 -7
  61. package/lib/types/components/Body/Body.types.d.ts +27 -19
  62. package/lib/types/components/Body/Cell.types.d.ts +12 -5
  63. package/lib/types/components/Body/Row.types.d.ts +20 -18
  64. package/lib/types/components/DataTable/DataTable.d.ts +1 -0
  65. package/lib/types/components/DataTable/DataTable.types.d.ts +29 -14
  66. package/lib/types/components/Head/Column.d.ts +3 -3
  67. package/lib/types/components/Head/Column.types.d.ts +11 -4
  68. package/lib/types/components/Head/Group.type.d.ts +2 -0
  69. package/lib/types/components/Head/Head.types.d.ts +12 -8
  70. package/package.json +22 -22
@@ -4,6 +4,7 @@ import { Head } from '../Head/Head';
4
4
  export declare const ACCORDION: unique symbol;
5
5
  export declare const ROW_GROUP: unique symbol;
6
6
  export declare const UNIQ_ROW_KEY: unique symbol;
7
+ export declare const IS_EMPTY_DATA_ROW: unique symbol;
7
8
  export declare const SELECT_ALL: unique symbol;
8
9
  export declare const ROW_INDEX: unique symbol;
9
10
  export declare const DataTable: DataTableType;
@@ -1,9 +1,10 @@
1
1
  import type { BoxProps } from '@semcore/base-components';
2
2
  import type { Intergalactic } from '@semcore/core';
3
3
  import type Tooltip from '@semcore/tooltip';
4
+ import type * as React from 'react';
4
5
  import type { ACCORDION, ROW_GROUP, UNIQ_ROW_KEY } from './DataTable';
5
6
  import type { DataTableBodyProps } from '../Body/Body.types';
6
- import type { DTRow, UniqRowKey } from '../Body/Row.types';
7
+ import type { DTRow } from '../Body/Row.types';
7
8
  import type { DataTableColumnProps } from '../Head/Column.types';
8
9
  import type { DataTableHeadProps } from '../Head/Head.types';
9
10
  /**
@@ -22,7 +23,7 @@ export type DataRowItem = {
22
23
  [key: string]: DTValue | undefined | null;
23
24
  [ACCORDION]?: React.ReactNode | DataTableData;
24
25
  [ROW_GROUP]?: DataTableData;
25
- [UNIQ_ROW_KEY]?: UniqRowKey;
26
+ [UNIQ_ROW_KEY]?: string;
26
27
  };
27
28
  export interface DTValue {
28
29
  toString(): string;
@@ -31,9 +32,9 @@ export interface DTValue {
31
32
  export type DataTableData = DataRowItem[];
32
33
  export type DTUse = 'primary' | 'secondary';
33
34
  export type Sizes = Pick<BoxProps, 'w' | 'wMax' | 'wMin' | 'h' | 'hMax' | 'hMin'>;
34
- export type DataTableProps<D extends DataTableData> = DataTableAriaProps & Sizes & {
35
+ export type DataTableProps<Data extends DataTableData, UniqKey extends keyof Data[number], UniqKeyType extends Data[number][UniqKey]> = DataTableAriaProps & Sizes & {
35
36
  /** Data for table */
36
- data: D;
37
+ data: Data;
37
38
  /** Count of total rows if table using virtual scroll. Needs for accessibility */
38
39
  totalRows?: number;
39
40
  /** Table theme according to visual hierarchy on the page
@@ -41,9 +42,9 @@ export type DataTableProps<D extends DataTableData> = DataTableAriaProps & Sizes
41
42
  * */
42
43
  use?: DTUse;
43
44
  /** Active sort object */
44
- sort?: DataTableSort<keyof D[0]>;
45
+ sort?: DataTableSort<keyof Data[0]>;
45
46
  /** Handler call when request will change sort */
46
- onSortChange?: DataTableChangeSort<keyof D[0]>;
47
+ onSortChange?: DataTableChangeSort<keyof Data[0]>;
47
48
  /**
48
49
  * Value to describe width for each column. Could be overridden in the column.gtcWidth property.
49
50
  * Use `auto` to automatically fit the table to the content,
@@ -67,34 +68,48 @@ export type DataTableProps<D extends DataTableData> = DataTableAriaProps & Sizes
67
68
  /**
68
69
  * Set of expanded rows (uniq id from them)
69
70
  */
70
- expandedRows?: Set<string>;
71
+ expandedRows?: Set<UniqKeyType>;
71
72
  virtualScroll?: VirtualScroll;
72
73
  columns: ColumnsConfig;
73
74
  headerProps?: DataTableHeadProps;
74
- rowProps?: DataTableBodyProps['rowProps'];
75
- renderCell?: DataTableBodyProps['renderCell'];
75
+ rowProps?: DataTableBodyProps<UniqKeyType>['rowProps'];
76
+ renderCell?: DataTableBodyProps<UniqKeyType>['renderCell'];
76
77
  /**
77
78
  * Name of a unique key for each row data item
78
79
  */
79
- uniqueRowKey?: keyof D[number];
80
+ uniqueRowKey?: UniqKey;
80
81
  /**
81
82
  * List of selected rows (uniqIds from a data array)
82
83
  */
83
- selectedRows?: UniqRowKey[];
84
- onSelectedRowsChange?: (selectedRows: UniqRowKey[], event?: React.SyntheticEvent<HTMLElement>, opts?: {
84
+ selectedRows?: UniqKeyType[];
85
+ onSelectedRowsChange?: (selectedRows: UniqKeyType[], event?: React.SyntheticEvent<HTMLElement>, opts?: {
85
86
  selectedRowIndex: number;
86
87
  isSelected: boolean;
87
- row: DTRow;
88
+ row: DTRow<UniqKeyType>;
88
89
  }) => void;
89
90
  /**
90
91
  * For custom empty data widget.
91
92
  */
92
93
  renderEmptyData?: () => React.ReactNode;
94
+ /**
95
+ * For adding an overlay over table cells.
96
+ */
97
+ renderCellOverlay?: () => React.ReactNode;
93
98
  /**
94
99
  * Duration for collapse/expand accordion rows in tables in ms.
95
100
  * @default 200
96
101
  */
97
102
  accordionDuration?: number | [number, number];
103
+ /**
104
+ * Whether multiple accordion items can be open at a time, or only one.
105
+ * @default 'independent'
106
+ */
107
+ accordionMode?: 'toggle' | 'independent';
108
+ /**
109
+ * Handle open/close accordion.
110
+ * Work only with table-in-table accordions. In accordions with custom components use mount/unmount hooks in components.
111
+ */
112
+ onAccordionToggle?: (type: 'open' | 'close', uniqRowKey: UniqKeyType, rowIndex: number) => void;
98
113
  };
99
114
  export type ColumnItemConfig = Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<'div' | typeof Tooltip, 'div', DataTableColumnProps, {}, [
100
115
  ]>, 'children'> & {
@@ -120,5 +135,5 @@ export type VirtualScroll = boolean | {
120
135
  };
121
136
  export type RowIndex = number;
122
137
  export type ColIndex = number;
123
- export type DataTableType = (<Data extends DataTableData, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<Tag, 'div', DataTableProps<Data>>, 'tag' | 'children'>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableProps<any>>;
138
+ export type DataTableType = (<Data extends DataTableData, UniqKey extends keyof Data[number] = keyof Data[number], UniqKeyType extends Data[number][UniqKey] = Data[number][UniqKey], Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<Tag, 'div', DataTableProps<Data, UniqKey, UniqKeyType>>, 'tag' | 'children'>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableProps<any, any, any>>;
124
139
  export {};
@@ -5,8 +5,8 @@ import type { DataTableData, SortDirection } from '../DataTable/DataTable.types'
5
5
  type State = {
6
6
  sortVisible: boolean;
7
7
  };
8
- export declare class Column<D extends DataTableData> extends Component<DataTableColumnProps, {}, {}, [
9
- ], ColumnPropsInner<D>> {
8
+ export declare class Column<Data extends DataTableData, UniqKey extends keyof Data[number], UniqKeyType extends Data[number][UniqKey]> extends Component<DataTableColumnProps, {}, {}, [
9
+ ], ColumnPropsInner<Data, UniqKey, UniqKeyType>> {
10
10
  static displayName: string;
11
11
  static style: {
12
12
  [key: string]: string;
@@ -16,7 +16,7 @@ export declare class Column<D extends DataTableData> extends Component<DataTable
16
16
  sortWrapperRef: React.RefObject<HTMLDivElement>;
17
17
  state: State;
18
18
  componentDidMount(): void;
19
- componentDidUpdate(prevProps: DataTableColumnProps & ColumnPropsInner<D>): void;
19
+ componentDidUpdate(prevProps: DataTableColumnProps & ColumnPropsInner<Data, UniqKey, UniqKeyType>): void;
20
20
  changeTemplateColumnBySort(): void;
21
21
  calculateActiveColumnMinWidth: () => number | null;
22
22
  get defaultDirection(): SortDirection;
@@ -1,4 +1,5 @@
1
1
  import type { Property } from 'csstype';
2
+ import type { BodyPropsInner } from '../Body/Body.types';
2
3
  import type { CellPropsInner } from '../Body/Cell.types';
3
4
  import type { ColumnGroupConfig, ColumnItemConfig, DataTableData, DataTableProps, DTUse, SortDirection } from '../DataTable/DataTable.types';
4
5
  export type CommonColumnType = {
@@ -34,6 +35,10 @@ export type CommonColumnType = {
34
35
  * CSS `justify-content` property
35
36
  */
36
37
  justifyContent?: Property.JustifyContent;
38
+ /**
39
+ * CSS `text-align` property
40
+ */
41
+ textAlign?: Property.TextAlign;
37
42
  };
38
43
  export type DTColumn = ColumnItemConfig & CommonColumnType & {
39
44
  /**
@@ -44,6 +49,7 @@ export type DTColumn = ColumnItemConfig & CommonColumnType & {
44
49
  columns?: DTColumn[];
45
50
  children?: React.ReactNode | React.FC;
46
51
  gridArea?: string;
52
+ showShadowVertical?: boolean;
47
53
  };
48
54
  export type DataTableColumnProps = CommonColumnType & {
49
55
  /**
@@ -55,11 +61,11 @@ export type DataTableColumnProps = CommonColumnType & {
55
61
  */
56
62
  changeSortSize?: boolean;
57
63
  };
58
- export type ColumnPropsInner<D extends DataTableData> = {
64
+ export type ColumnPropsInner<Data extends DataTableData, UniqKey extends keyof Data[number], UniqKeyType extends Data[number][UniqKey]> = {
59
65
  use: DTUse;
60
66
  borders?: 'both' | 'left' | 'right';
61
- sort?: DataTableProps<D>['sort'];
62
- onSortChange?: DataTableProps<D>['onSortChange'];
67
+ sort?: DataTableProps<Data, UniqKey, UniqKeyType>['sort'];
68
+ onSortChange?: DataTableProps<Data, UniqKey, UniqKeyType>['onSortChange'];
63
69
  uid: string;
64
70
  parent?: DTColumn;
65
71
  sortableColumnDescribeId: string;
@@ -68,5 +74,6 @@ export type ColumnPropsInner<D extends DataTableData> = {
68
74
  gridTemplateColumns: string[];
69
75
  gridTemplateAreas: string[];
70
76
  sticky: boolean;
71
- onClick: CellPropsInner['onClick'];
77
+ onClick: CellPropsInner<UniqKeyType>['onClick'];
78
+ shadowVertical?: BodyPropsInner<UniqKeyType>['shadowVertical'];
72
79
  };
@@ -1,5 +1,6 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { DataTableColumnProps, DTColumn } from './Column.types';
3
+ import type { BodyPropsInner } from '../Body/Body.types';
3
4
  import type { DTUse } from '../DataTable/DataTable.types';
4
5
  export type DataTableGroupProps = {
5
6
  title: React.ReactNode;
@@ -13,4 +14,5 @@ export type GroupPropsInner = {
13
14
  use: DTUse;
14
15
  withConfig: boolean;
15
16
  getFixedStyle: (cell: Pick<DTColumn, 'name' | 'fixed'>) => [side: 'left' | 'right', style: string | number] | [side: undefined, style: undefined];
17
+ shadowVertical?: BodyPropsInner<any>['shadowVertical'];
16
18
  };
@@ -1,6 +1,7 @@
1
1
  import type { DTColumn } from './Column.types';
2
+ import type { BodyPropsInner } from '../Body/Body.types';
2
3
  import type { CellPropsInner } from '../Body/Cell.types';
3
- import type { DTRow, UniqRowKey } from '../Body/Row.types';
4
+ import type { DTRow } from '../Body/Row.types';
4
5
  import type { DataTableData, DataTableProps, DTUse } from '../DataTable/DataTable.types';
5
6
  export type DataTableHeadProps = {
6
7
  /**
@@ -20,26 +21,29 @@ export type DataTableHeadProps = {
20
21
  withScrollBar?: boolean;
21
22
  /** Animation duration for a top property. When it's set adds animation for top changes */
22
23
  animationDuration?: number;
24
+ /** Outer ref for the header */
25
+ ref?: React.Ref<HTMLDivElement>;
23
26
  };
24
- export type HeadPropsInner<D extends DataTableData> = {
27
+ export type HeadPropsInner<Data extends DataTableData, UniqKey extends keyof Data[number], UniqKeyType extends Data[number][UniqKey]> = {
25
28
  use: DTUse;
26
29
  tableRef: React.RefObject<HTMLElement>;
27
30
  columns: DTColumn[];
28
31
  treeColumns: DTColumn[];
29
32
  compact: boolean;
30
- sort?: DataTableProps<D>['sort'];
31
- onSortChange?: DataTableProps<D>['onSortChange'];
33
+ sort?: DataTableProps<Data, UniqKey, UniqKeyType>['sort'];
34
+ onSortChange?: DataTableProps<Data, UniqKey, UniqKeyType>['onSortChange'];
32
35
  getI18nText: (key: string) => string;
33
36
  uid: string;
34
- ref: React.RefObject<HTMLDivElement>;
37
+ ref: React.Ref<HTMLDivElement>;
35
38
  gridAreaGroupMap: Map<number, string>;
36
39
  gridTemplateColumns: string[];
37
40
  gridTemplateAreas: string[];
38
41
  sideIndents?: 'wide';
39
42
  totalRows: number;
40
- selectedRows?: UniqRowKey[];
43
+ selectedRows?: UniqKeyType[];
41
44
  onChangeSelectAll?: (value: boolean, event?: React.SyntheticEvent<HTMLElement>) => void;
42
- flatRows: DTRow[];
45
+ flatRows: DTRow<UniqKeyType>[];
43
46
  getFixedStyle: (cell: Pick<DTColumn, 'name' | 'fixed'>) => [side: 'left' | 'right', style: string | number] | [side: undefined, style: undefined];
44
- onCellClick: CellPropsInner['onClick'];
47
+ onCellClick: CellPropsInner<UniqKeyType>['onClick'];
48
+ shadowVertical?: BodyPropsInner<UniqKeyType>['shadowVertical'];
45
49
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/data-table",
3
3
  "description": "Semrush DataTable Component",
4
- "version": "16.0.7",
4
+ "version": "16.1.0-prerelease.2",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,34 +14,34 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/icon": "16.4.0",
18
- "@semcore/button": "16.0.5",
19
- "@semcore/checkbox": "16.0.5",
20
- "@semcore/flex-box": "16.0.5",
21
- "@semcore/scroll-area": "16.0.5",
22
- "@semcore/spin": "16.0.5",
23
- "@semcore/tooltip": "16.0.5",
24
- "@semcore/widget-empty": "16.0.5"
17
+ "@semcore/icon": "16.5.0-prerelease.2",
18
+ "@semcore/button": "16.0.6-prerelease.2",
19
+ "@semcore/checkbox": "16.1.0-prerelease.2",
20
+ "@semcore/flex-box": "16.0.6-prerelease.2",
21
+ "@semcore/scroll-area": "16.0.6-prerelease.2",
22
+ "@semcore/spin": "16.0.6-prerelease.2",
23
+ "@semcore/tooltip": "16.0.6-prerelease.2",
24
+ "@semcore/widget-empty": "16.0.6-prerelease.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "18.16.15",
28
28
  "csstype": "3.1.3",
29
29
  "@semcore/testing-utils": "1.0.0",
30
- "@semcore/base-trigger": "16.2.4",
31
- "@semcore/typography": "16.1.5",
32
- "@semcore/accordion": "16.3.0",
33
- "@semcore/dropdown-menu": "16.1.6",
34
- "@semcore/divider": "16.0.5",
35
- "@semcore/skeleton": "16.0.5",
36
- "@semcore/portal": "16.0.5",
37
- "@semcore/spin-container": "16.0.5",
38
- "@semcore/progress-bar": "16.0.5",
39
- "@semcore/spin": "16.0.5",
40
- "@semcore/tooltip": "16.0.5",
41
- "@semcore/base-components": "16.1.2"
30
+ "@semcore/dropdown-menu": "16.1.7-prerelease.2",
31
+ "@semcore/base-trigger": "16.3.0-prerelease.2",
32
+ "@semcore/typography": "16.2.0-prerelease.2",
33
+ "@semcore/accordion": "16.4.0-prerelease.2",
34
+ "@semcore/divider": "16.0.6-prerelease.2",
35
+ "@semcore/portal": "16.0.6-prerelease.2",
36
+ "@semcore/progress-bar": "16.0.6-prerelease.2",
37
+ "@semcore/skeleton": "16.0.6-prerelease.2",
38
+ "@semcore/spin": "16.0.6-prerelease.2",
39
+ "@semcore/spin-container": "16.0.6-prerelease.2",
40
+ "@semcore/base-components": "16.2.0-prerelease.2",
41
+ "@semcore/tooltip": "16.0.6-prerelease.2"
42
42
  },
43
43
  "peerDependencies": {
44
- "@semcore/base-components": "^16.0.0"
44
+ "@semcore/base-components": "^16.2.0-prerelease.2"
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",