@semcore/data-table 16.0.0-prerelease.9 → 16.0.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/lib/cjs/components/Body/Body.js +436 -0
  3. package/lib/cjs/components/Body/Body.js.map +1 -0
  4. package/lib/cjs/components/Body/Body.types.js +2 -0
  5. package/lib/cjs/components/Body/Body.types.js.map +1 -0
  6. package/lib/cjs/components/Body/Cell.js +194 -0
  7. package/lib/cjs/components/Body/Cell.js.map +1 -0
  8. package/lib/cjs/components/Body/Cell.types.js +2 -0
  9. package/lib/cjs/components/Body/Cell.types.js.map +1 -0
  10. package/lib/cjs/components/Body/MergedCells.js +29 -0
  11. package/lib/cjs/components/Body/MergedCells.js.map +1 -0
  12. package/lib/cjs/components/Body/Row.js +244 -0
  13. package/lib/cjs/components/Body/Row.js.map +1 -0
  14. package/lib/cjs/components/Body/Row.types.js +4 -0
  15. package/lib/cjs/components/Body/Row.types.js.map +1 -0
  16. package/lib/cjs/components/Body/style.shadow.css +257 -0
  17. package/lib/cjs/components/DataTable/DataTable.js +981 -0
  18. package/lib/cjs/components/DataTable/DataTable.js.map +1 -0
  19. package/lib/cjs/{types.js → components/DataTable/DataTable.types.js} +1 -1
  20. package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -0
  21. package/lib/cjs/components/DataTable/dataTable.shadow.css +17 -0
  22. package/lib/cjs/components/Head/Column.js +316 -0
  23. package/lib/cjs/components/Head/Column.js.map +1 -0
  24. package/lib/cjs/components/Head/Column.types.js +2 -0
  25. package/lib/cjs/components/Head/Column.types.js.map +1 -0
  26. package/lib/cjs/components/Head/Group.js +115 -0
  27. package/lib/cjs/components/Head/Group.js.map +1 -0
  28. package/lib/cjs/components/Head/Group.type.js +2 -0
  29. package/lib/cjs/components/Head/Group.type.js.map +1 -0
  30. package/lib/cjs/components/Head/Head.js +205 -0
  31. package/lib/cjs/components/Head/Head.js.map +1 -0
  32. package/lib/cjs/components/Head/Head.types.js +2 -0
  33. package/lib/cjs/components/Head/Head.types.js.map +1 -0
  34. package/lib/cjs/components/Head/style.shadow.css +176 -0
  35. package/lib/cjs/index.js +25 -15
  36. package/lib/cjs/index.js.map +1 -1
  37. package/lib/cjs/style/scroll-shadows.shadow.css +39 -5
  38. package/lib/cjs/translations/en.json +6 -1
  39. package/lib/cjs/utils.js +16 -7
  40. package/lib/cjs/utils.js.map +1 -1
  41. package/lib/es6/components/Body/Body.js +429 -0
  42. package/lib/es6/components/Body/Body.js.map +1 -0
  43. package/lib/es6/components/Body/Body.types.js +2 -0
  44. package/lib/es6/components/Body/Body.types.js.map +1 -0
  45. package/lib/es6/components/Body/Cell.js +187 -0
  46. package/lib/es6/components/Body/Cell.js.map +1 -0
  47. package/lib/es6/components/Body/Cell.types.js +2 -0
  48. package/lib/es6/components/Body/Cell.types.js.map +1 -0
  49. package/lib/es6/components/Body/MergedCells.js +20 -0
  50. package/lib/es6/components/Body/MergedCells.js.map +1 -0
  51. package/lib/es6/components/Body/Row.js +237 -0
  52. package/lib/es6/components/Body/Row.js.map +1 -0
  53. package/lib/es6/components/Body/Row.types.js +2 -0
  54. package/lib/es6/components/Body/Row.types.js.map +1 -0
  55. package/lib/es6/components/Body/style.shadow.css +257 -0
  56. package/lib/es6/components/DataTable/DataTable.js +970 -0
  57. package/lib/es6/components/DataTable/DataTable.js.map +1 -0
  58. package/lib/es6/components/DataTable/DataTable.types.js +2 -0
  59. package/lib/es6/components/DataTable/DataTable.types.js.map +1 -0
  60. package/lib/es6/components/DataTable/dataTable.shadow.css +17 -0
  61. package/lib/es6/components/Head/Column.js +309 -0
  62. package/lib/es6/components/Head/Column.js.map +1 -0
  63. package/lib/es6/components/Head/Column.types.js +2 -0
  64. package/lib/es6/components/Head/Column.types.js.map +1 -0
  65. package/lib/es6/components/Head/Group.js +108 -0
  66. package/lib/es6/components/Head/Group.js.map +1 -0
  67. package/lib/es6/components/Head/Group.type.js +2 -0
  68. package/lib/es6/components/Head/Group.type.js.map +1 -0
  69. package/lib/es6/components/Head/Head.js +199 -0
  70. package/lib/es6/components/Head/Head.js.map +1 -0
  71. package/lib/es6/components/Head/Head.types.js +2 -0
  72. package/lib/es6/components/Head/Head.types.js.map +1 -0
  73. package/lib/es6/components/Head/style.shadow.css +176 -0
  74. package/lib/es6/index.js +5 -2
  75. package/lib/es6/index.js.map +1 -1
  76. package/lib/es6/style/scroll-shadows.shadow.css +39 -5
  77. package/lib/es6/translations/en.json +6 -1
  78. package/lib/es6/utils.js +14 -6
  79. package/lib/es6/utils.js.map +1 -1
  80. package/lib/esm/components/Body/Body.mjs +392 -0
  81. package/lib/esm/components/Body/Cell.mjs +185 -0
  82. package/lib/esm/components/Body/MergedCells.mjs +23 -0
  83. package/lib/esm/components/Body/Row.mjs +218 -0
  84. package/lib/esm/components/Body/style.shadow.css +257 -0
  85. package/lib/esm/components/DataTable/DataTable.mjs +904 -0
  86. package/lib/esm/components/DataTable/dataTable.shadow.css +17 -0
  87. package/lib/esm/components/Head/Column.mjs +299 -0
  88. package/lib/esm/components/Head/Group.mjs +102 -0
  89. package/lib/esm/components/Head/Head.mjs +180 -0
  90. package/lib/esm/components/Head/style.shadow.css +176 -0
  91. package/lib/esm/index.mjs +8 -5
  92. package/lib/esm/style/scroll-shadows.shadow.css +41 -0
  93. package/lib/esm/translations/en.json.mjs +6 -1
  94. package/lib/esm/utils.mjs +6 -15
  95. package/lib/types/components/Body/Body.d.ts +8 -0
  96. package/lib/types/components/Body/Body.types.d.ts +56 -0
  97. package/lib/types/components/Body/Cell.d.ts +3 -0
  98. package/lib/types/components/Body/Cell.types.d.ts +20 -0
  99. package/lib/types/components/Body/MergedCells.d.ts +14 -0
  100. package/lib/types/components/Body/Row.d.ts +3 -0
  101. package/lib/types/components/Body/Row.types.d.ts +42 -0
  102. package/lib/types/components/DataTable/DataTable.d.ts +12 -0
  103. package/lib/types/components/DataTable/DataTable.types.d.ts +118 -0
  104. package/lib/types/components/Head/Column.d.ts +30 -0
  105. package/lib/types/components/Head/Column.types.d.ts +82 -0
  106. package/lib/types/components/Head/Group.d.ts +15 -0
  107. package/lib/types/components/Head/Group.type.d.ts +16 -0
  108. package/lib/types/components/Head/Head.d.ts +98 -0
  109. package/lib/types/components/Head/Head.types.d.ts +35 -0
  110. package/lib/types/index.d.ts +10 -2
  111. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +5 -0
  112. package/lib/types/utils.d.ts +8 -4
  113. package/package.json +11 -6
  114. package/vite.config.ts +0 -3
  115. package/lib/cjs/Body.js +0 -475
  116. package/lib/cjs/Body.js.map +0 -1
  117. package/lib/cjs/DataTable.js +0 -622
  118. package/lib/cjs/DataTable.js.map +0 -1
  119. package/lib/cjs/Head.js +0 -399
  120. package/lib/cjs/Head.js.map +0 -1
  121. package/lib/cjs/style/data-table.shadow.css +0 -394
  122. package/lib/cjs/types.js.map +0 -1
  123. package/lib/es6/Body.js +0 -468
  124. package/lib/es6/Body.js.map +0 -1
  125. package/lib/es6/DataTable.js +0 -614
  126. package/lib/es6/DataTable.js.map +0 -1
  127. package/lib/es6/Head.js +0 -391
  128. package/lib/es6/Head.js.map +0 -1
  129. package/lib/es6/style/data-table.shadow.css +0 -394
  130. package/lib/es6/types.js +0 -2
  131. package/lib/es6/types.js.map +0 -1
  132. package/lib/esm/Body.mjs +0 -427
  133. package/lib/esm/DataTable.mjs +0 -582
  134. package/lib/esm/Head.mjs +0 -369
  135. package/lib/types/Body.d.ts +0 -61
  136. package/lib/types/DataTable.d.ts +0 -205
  137. package/lib/types/Head.d.ts +0 -45
  138. package/lib/types/types.d.ts +0 -73
@@ -0,0 +1,176 @@
1
+ SHead, SGroupContainer {
2
+ display: contents;
3
+ }
4
+
5
+ SHead[sticky] SColumn, SHead[sticky] SGroup {
6
+ position: sticky;
7
+ top: 0;
8
+ z-index: 2;
9
+ }
10
+
11
+ SHead[sticky] SGroupContainer > SColumn {
12
+ position: sticky;
13
+ z-index: 2;
14
+ }
15
+
16
+ SHead[compact] SColumn {
17
+ padding: var(--intergalactic-spacing-3x, 12px) var(--intergalactic-spacing-2x, 8px);
18
+ }
19
+
20
+ SGroup, SColumn {
21
+ display: flex;
22
+ align-items: flex-start;
23
+ font-size: var(--intergalactic-fs-100, 12px);
24
+ color: var(--intergalactic-text-primary, #191b23);
25
+ box-sizing: border-box;
26
+ height: 100%;
27
+ position: relative;
28
+ transition: width calc(var(--intergalactic-duration-extra-fast, 100) * 1ms) ease-in-out, min-width calc(var(--intergalactic-duration-extra-fast, 100) * 1ms) ease-in-out, max-width calc(var(--intergalactic-duration-extra-fast, 100) * 1ms) ease-in-out;
29
+ overflow: hidden;
30
+ }
31
+
32
+ SGroup {
33
+ justify-content: center;
34
+ text-align: center;
35
+ background-color: var(--intergalactic-table-th-primary-cell, #f4f5f9);
36
+ }
37
+
38
+ SGroup[use='primary'] {
39
+ padding: var(--intergalactic-spacing-3x, 12px);
40
+
41
+ &:has(~ SColumn[visibleSort]) {
42
+ background-color: var(--intergalactic-table-th-primary-cell-hover, #e0e1e9);
43
+ }
44
+ }
45
+ SGroup[use='secondary'] {
46
+ padding: var(--intergalactic-spacing-2x, 8px);
47
+ }
48
+
49
+ SGroup[borders='both'], SColumn[borders='both'], SGroup[borders='left'], SColumn[borders='left'] {
50
+ border-left: 1px solid var(--intergalactic-border-secondary, #e0e1e9);
51
+ }
52
+
53
+ SGroup[borders='both'], SColumn[borders='both'], SGroup[borders='right'], SColumn[borders='right'] {
54
+ border-right: 1px solid var(--intergalactic-border-secondary, #e0e1e9);
55
+ }
56
+
57
+ SColumn[use='primary'] {
58
+ padding: var(--intergalactic-spacing-3x, 12px);
59
+ border-bottom: 1px solid var(--intergalactic-border-secondary, #e0e1e9);
60
+ background-color: var(--intergalactic-table-th-primary-cell, #f4f5f9);
61
+
62
+ SSortWrapper::before {
63
+ background: linear-gradient(
64
+ 270deg,
65
+ var(--intergalactic-table-th-primary-cell-hover, #e0e1e9) 67.5%,
66
+ rgba(224, 225, 233, 0) 105%
67
+ );
68
+ }
69
+
70
+ &[visibleSort] {
71
+ background-color: var(--intergalactic-table-th-primary-cell-hover, #e0e1e9);
72
+
73
+ SSortWrapper {
74
+ flex-basis: calc(var(--intergalactic-spacing-1x, 4px) + 16px);
75
+ opacity: 1;
76
+
77
+ &::before {
78
+ display: flex;
79
+ opacity: 1;
80
+ }
81
+ }
82
+
83
+ SSortButton {
84
+ display: flex;
85
+ opacity: 1;
86
+ }
87
+ }
88
+ }
89
+
90
+ SColumn[use='secondary'] {
91
+ padding: var(--intergalactic-spacing-2x, 8px);
92
+ border-bottom: 1px solid var(--intergalactic-border-table-accent, #a9abb6);
93
+ background-color: var(--intergalactic-table-th-secondary-cell, #ffffff);
94
+
95
+ SSortWrapper::before {
96
+ background: linear-gradient(
97
+ 270deg,
98
+ var(--intergalactic-table-th-secondary-cell, #ffffff) 67.5%,
99
+ rgba(255, 255, 255, 0) 105%
100
+ );
101
+ }
102
+
103
+ &[visibleSort] {
104
+ SSortWrapper {
105
+ flex-basis: calc(var(--intergalactic-spacing-1x, 4px) + 16px);
106
+ opacity: 1;
107
+
108
+ &::before {
109
+ display: flex;
110
+ opacity: 1;
111
+ }
112
+ }
113
+
114
+ SSortButton {
115
+ display: flex;
116
+ opacity: 1;
117
+ }
118
+ }
119
+ }
120
+
121
+ SColumn[gridArea], SGroup[gridArea], SGroupTitle[gridArea] {
122
+ grid-area: var(--gridArea);
123
+ }
124
+
125
+ SHead[sticky] SColumn[fixed], SHead SColumn[fixed], SHead[sticky] SGroup, SHead SGroup[fixed] {
126
+ position: sticky;
127
+ /* because up resizable */
128
+ z-index: 3;
129
+ }
130
+
131
+ SColumn[sortable]:hover {
132
+ cursor: pointer;
133
+ }
134
+
135
+ SSortWrapper {
136
+ align-items: center;
137
+ display: flex;
138
+ flex-shrink: 1;
139
+ position: relative;
140
+ flex-basis: 0;
141
+ min-height: 16px;
142
+ opacity: 0;
143
+ transition: all calc(var(--intergalactic-duration-extra-fast, 100) * 1ms) ease-in-out;
144
+ }
145
+
146
+ SSortWrapper:before {
147
+ display: none;
148
+ content: '';
149
+ position: absolute;
150
+ top: 0;
151
+ right: 0;
152
+ width: 20px;
153
+ height: 100%;
154
+ opacity: 0;
155
+ transition: opacity 0.3s ease;
156
+ }
157
+
158
+ SSortButton {
159
+ display: none;
160
+ fill: var(--intergalactic-icon-secondary-neutral-hover-active, #878992);
161
+ position: absolute;
162
+ top: calc(-1 * (1em * 1.25 - 16px));
163
+ right: 0;
164
+ margin-left: var(--intergalactic-spacing-1x, 4px);
165
+ opacity: 0;
166
+ transition: opacity 0.3s ease;
167
+ }
168
+
169
+ SHead[sideIndents='l'] {
170
+ SColumn:first-child {
171
+ padding-left: var(--intergalactic-spacing-5x, 20px);
172
+ }
173
+ SColumn:last-child {
174
+ padding-right: var(--intergalactic-spacing-5x, 20px);
175
+ }
176
+ }
package/lib/esm/index.mjs CHANGED
@@ -1,8 +1,11 @@
1
- import { ROW_GROUP, default as default2, wrapDataTable, wrapDataTableCell, wrapDataTableRow } from "./DataTable.mjs";
1
+ import { ACCORDION, DataTable, ROW_GROUP, UNIQ_ROW_KEY } from "./components/DataTable/DataTable.mjs";
2
+ var wrapDataTable = function wrapDataTable2(wrapper) {
3
+ return wrapper;
4
+ };
2
5
  export {
6
+ ACCORDION,
7
+ DataTable,
3
8
  ROW_GROUP,
4
- default2 as default,
5
- wrapDataTable,
6
- wrapDataTableCell,
7
- wrapDataTableRow
9
+ UNIQ_ROW_KEY,
10
+ wrapDataTable
8
11
  };
@@ -0,0 +1,41 @@
1
+ SScrollArea {
2
+ width: fit-content;
3
+
4
+ SContainer {
5
+ overflow: unset;
6
+
7
+ &[scrollDirection='both'] {
8
+ overflow: auto;
9
+ }
10
+ &[scrollDirection='horizontal'] {
11
+ overflow-x: auto;
12
+ overflow-y: unset;
13
+ }
14
+ &[scrollDirection='vertical'] {
15
+ overflow-x: unset;
16
+ overflow-y: auto;
17
+ }
18
+ &[loading] {
19
+ overflow: hidden;
20
+ }
21
+
22
+ &[headerHeight] {
23
+ scroll-padding-top: var(--headerHeight);
24
+ }
25
+ }
26
+
27
+ SShadowVertical {
28
+ &:before {
29
+ display: none;
30
+ }
31
+ &:after {
32
+ z-index: 2;
33
+ }
34
+ }
35
+ SShadowHorizontal {
36
+ &:before,
37
+ &:after {
38
+ z-index: 2;
39
+ }
40
+ }
41
+ }
@@ -1,6 +1,11 @@
1
1
  const sortableColumn = "Sortable";
2
2
  const en = {
3
- sortableColumn
3
+ sortableColumn,
4
+ "DataTable.Cell.AccordionToggle.expand:aria-label": "Show details",
5
+ "DataTable.Cell.AccordionToggle.collapse:aria-label": "Hide details",
6
+ "DataTable.Header.selectAllCheckbox:aria-label": "All items",
7
+ "DataTable.allItemsSelected:aria-live": "All items selected",
8
+ "DataTable.allItemsDeselected:aria-live": "All items deselected"
4
9
  };
5
10
  export {
6
11
  en as default,
package/lib/esm/utils.mjs CHANGED
@@ -1,22 +1,14 @@
1
1
  var getScrollOffsetValue = function getScrollOffsetValue2(columns) {
2
2
  return columns.reduce(function(acc, column) {
3
3
  if (column.fixed === "left") {
4
- acc[0] += column.width;
4
+ acc[0] += column.calculatedWidth;
5
5
  }
6
6
  if (column.fixed === "right") {
7
- acc[1] += column.width;
7
+ acc[1] += column.calculatedWidth;
8
8
  }
9
9
  return acc;
10
10
  }, [0, 0]);
11
11
  };
12
- var flattenColumns = function flattenColumns2(columns) {
13
- return columns.reduce(function(acc, column) {
14
- var hasNestedColumns = "columns" in column && column.columns.length > 0;
15
- var columns2 = hasNestedColumns ? flattenColumns2(column.columns) : [column];
16
- acc = acc.concat(columns2);
17
- return acc;
18
- }, []);
19
- };
20
12
  var getFixedStyle = function getFixedStyle2(cell, columns) {
21
13
  var side = cell.fixed;
22
14
  if (!side) return [void 0, void 0];
@@ -40,13 +32,12 @@ var getFixedStyle = function getFixedStyle2(cell, columns) {
40
32
  };
41
33
  var columnsFixed = columns.slice(startIndexSideMap[side], endIndexSideMap[side]);
42
34
  if (columnsFixed.length < 1) return [side, 0];
43
- var vars = columnsFixed.map(function(column) {
44
- return "var(--".concat(column.name, "_width)");
45
- });
46
- return [side, vars.length === 1 ? vars[0] : "calc(".concat(vars.join(" + "), ")")];
35
+ var sum = columnsFixed.reduce(function(acc, column) {
36
+ return acc + column.calculatedWidth;
37
+ }, 0);
38
+ return [side, "".concat(sum, "px")];
47
39
  };
48
40
  export {
49
- flattenColumns,
50
41
  getFixedStyle,
51
42
  getScrollOffsetValue
52
43
  };
@@ -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,56 @@
1
+ /// <reference types="react" />
2
+ import { DTRow } from './Row.types';
3
+ import { DTColumn } from '../Head/Column.types';
4
+ import { DTUse, VirtualScroll } from '../DataTable/DataTable.types';
5
+ import { Theme } from './Cell.types';
6
+ export type CellRenderProps = {
7
+ dataKey: string;
8
+ row: DTRow;
9
+ column: DTColumn;
10
+ rowIndex: number;
11
+ columnIndex: number;
12
+ columnName: string;
13
+ value: string | React.ReactElement;
14
+ defaultRender: () => React.ReactNode;
15
+ isMergedRows: boolean;
16
+ isMergedColumns: boolean;
17
+ };
18
+ export type DataTableBodyProps = {
19
+ renderCell?: (props: CellRenderProps) => React.ReactNode | (Record<string, any> & {
20
+ theme?: Theme;
21
+ });
22
+ rowProps?: (row: DTRow, rowIndex: number) => (Record<string, any> & {
23
+ theme?: Theme;
24
+ }) | undefined;
25
+ };
26
+ export type BodyPropsInner = DataTableBodyProps & {
27
+ rows: Array<DTRow | DTRow[]>;
28
+ flatRows: DTRow[];
29
+ columns: DTColumn[];
30
+ use: DTUse;
31
+ compact: boolean;
32
+ gridTemplateColumns: string[];
33
+ gridTemplateAreas: string[];
34
+ loading?: boolean;
35
+ headerHeight: number;
36
+ getI18nText: (key: string) => string;
37
+ expandedRows: Set<string>;
38
+ onExpandRow: (row: DTRow) => void;
39
+ spinnerRef: React.RefObject<HTMLDivElement>;
40
+ tableContainerRef: React.RefObject<HTMLDivElement>;
41
+ tableRef: React.RefObject<HTMLDivElement>;
42
+ scrollAreaRef: React.RefObject<HTMLDivElement>;
43
+ scrollTop: number;
44
+ scrollDirection: 'down' | 'up';
45
+ virtualScroll?: VirtualScroll;
46
+ hasGroups: boolean;
47
+ uid: string;
48
+ rowProps?: (row: DTRow, rowIndex: number) => Record<string, any> | undefined;
49
+ renderCell?: (props: CellRenderProps) => React.ReactNode | Record<string, any>;
50
+ onBackFromAccordion: (colIndex: number) => void;
51
+ stickyHeader?: boolean;
52
+ selectedRows?: number[];
53
+ onSelectRow?: (isSelect: boolean, selectedRowIndex: number, row: DTRow, event?: React.SyntheticEvent<HTMLElement>) => void;
54
+ renderEmptyData: () => React.ReactNode;
55
+ sideIndents?: 'l';
56
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Cell: import("@semcore/core/lib/coreFactory").ComponentType<unknown, {}, {}, {
2
+ [key: string]: (arg: unknown) => void;
3
+ }, null>;
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import { DTRow } from './Row.types';
3
+ import { DTUse } from '../DataTable/DataTable.types';
4
+ import { DTColumn } from '../Head/Column.types';
5
+ export type Theme = 'muted' | 'info' | 'success' | 'warning' | 'danger';
6
+ export type DataTableCellProps = {
7
+ id: string;
8
+ accordionId: string;
9
+ row: DTRow;
10
+ rowIndex: number;
11
+ column: DTColumn;
12
+ columnIndex: number;
13
+ gridRowIndex: number;
14
+ children?: React.ReactNode;
15
+ };
16
+ export type CellPropsInner = {
17
+ use: DTUse;
18
+ virtualScroll: boolean;
19
+ tableRef: React.RefObject<HTMLDivElement>;
20
+ };
@@ -0,0 +1,14 @@
1
+ export declare class MergedRowsCell {
2
+ readonly value: any;
3
+ readonly rowsCount: number;
4
+ constructor(value: any, rowsCount: number);
5
+ }
6
+ export declare class MergedColumnsCell {
7
+ readonly value: any;
8
+ readonly columnsCount: number;
9
+ readonly dataKey: string;
10
+ constructor(value: any, options: {
11
+ size: number;
12
+ dataKey: string;
13
+ });
14
+ }
@@ -0,0 +1,3 @@
1
+ export declare const Row: import("@semcore/core/lib/coreFactory").ComponentType<unknown, {}, {}, {
2
+ [key: string]: (arg: unknown) => void;
3
+ }, null>;
@@ -0,0 +1,42 @@
1
+ /// <reference types="react" />
2
+ import { DTValue, DTUse, DataTableData } from '../DataTable/DataTable.types';
3
+ import { DTColumn } from '../Head/Column.types';
4
+ import { MergedColumnsCell, MergedRowsCell } from './MergedCells';
5
+ import { ACCORDION, ROW_INDEX, UNIQ_ROW_KEY } from '../DataTable/DataTable';
6
+ export type DTRow = {
7
+ [UNIQ_ROW_KEY]: string;
8
+ [ROW_INDEX]: number;
9
+ [key: string]: DTValue | MergedRowsCell | MergedColumnsCell;
10
+ [ACCORDION]?: React.ReactNode | DataTableData | undefined;
11
+ };
12
+ export type DTRows = Array<DTRow | DTRow[]>;
13
+ export type DataTableRowProps = {
14
+ row: DTRow;
15
+ offset?: number;
16
+ };
17
+ export type RowPropsInner = JSX.IntrinsicElements['div'] & {
18
+ use: DTUse;
19
+ /**
20
+ * Expanded flag for rows with accordion
21
+ * @default false
22
+ */
23
+ expanded?: boolean;
24
+ columns: DTColumn[];
25
+ row: DTRow | DTRow[];
26
+ rows: DTRows;
27
+ rowIndex: number;
28
+ ariaRowIndex: number;
29
+ gridRowIndex: number;
30
+ expandedRows: Set<string>;
31
+ onExpandRow: (expandedRow: DTRow) => void;
32
+ gridTemplateAreas: string[];
33
+ gridTemplateColumns: string[];
34
+ accordionDataGridArea: string;
35
+ selectedRows?: number[];
36
+ onSelectRow?: (isSelect: boolean, selectedRowIndex: number, row: DTRow, event?: React.SyntheticEvent<HTMLElement>) => void;
37
+ inert?: '';
38
+ onBackFromAccordion: (colIndex: number) => void;
39
+ scrollAreaRef: React.RefObject<HTMLDivElement>;
40
+ uid: string;
41
+ sideIndents?: 'l';
42
+ };
@@ -0,0 +1,12 @@
1
+ import { DataTableProps, DataTableData } from './DataTable.types';
2
+ import { Head } from '../Head/Head';
3
+ import { Body } from '../Body/Body';
4
+ export declare const ACCORDION: unique symbol;
5
+ export declare const ROW_GROUP: unique symbol;
6
+ export declare const UNIQ_ROW_KEY: unique symbol;
7
+ export declare const SELECT_ALL: unique symbol;
8
+ export declare const ROW_INDEX: unique symbol;
9
+ export declare const DataTable: (<Data extends DataTableData, Tag extends import("@semcore/core").Intergalactic.InternalTypings.ComponentTag = "div">(props: import("@semcore/core").Intergalactic.InternalTypings.EfficientOmit<import("@semcore/core").Intergalactic.InternalTypings.ComponentProps<Tag, "div", DataTableProps<Data>, never, never[]>, "children" | "tag">) => import("@semcore/core").Intergalactic.InternalTypings.ComponentRenderingResults) & import("@semcore/core").Intergalactic.InternalTypings.ComponentAdditive<"div", "div", DataTableProps<any>, {}, {}> & {
10
+ Head: typeof Head;
11
+ Body: typeof Body;
12
+ };
@@ -0,0 +1,118 @@
1
+ /// <reference types="react" />
2
+ import { Intergalactic } from '@semcore/core';
3
+ import { BoxProps } from '@semcore/base-components';
4
+ import { ACCORDION, ROW_GROUP, UNIQ_ROW_KEY } from './DataTable';
5
+ import { DataTableColumnProps } from '../Head/Column.types';
6
+ import { DataTableBodyProps } from '../Body/Body.types';
7
+ import Tooltip from '@semcore/tooltip';
8
+ import { DTRow } from '../Body/Row.types';
9
+ /**
10
+ * Datatable must have an accessible name (aria-table-name).
11
+ * It should describe table content.
12
+ */
13
+ type DataTableAriaProps = Intergalactic.RequireAtLeastOne<{
14
+ 'aria-label'?: string;
15
+ 'aria-labelledby'?: string;
16
+ title?: string;
17
+ }>;
18
+ export type SortDirection = 'asc' | 'desc';
19
+ export type DataTableSort<Column> = [sortBy: Column, sortDirection: SortDirection];
20
+ export type DataTableChangeSort<Column> = (sort: [sortBy: Column, sortDirection: SortDirection], e?: React.SyntheticEvent) => void;
21
+ export type DataRowItem = {
22
+ [key: string]: DTValue | undefined;
23
+ [ACCORDION]?: React.ReactNode | DataTableData;
24
+ [ROW_GROUP]?: DataTableData;
25
+ [UNIQ_ROW_KEY]?: string;
26
+ };
27
+ export interface DTValue {
28
+ toString(): string;
29
+ [ACCORDION]?: React.ReactNode | DataTableData;
30
+ }
31
+ export type DataTableData = DataRowItem[];
32
+ export type DTUse = 'primary' | 'secondary';
33
+ type Sizes = Pick<BoxProps, 'w' | 'wMax' | 'wMin' | 'h' | 'hMax' | 'hMin'>;
34
+ export type DataTableProps<D extends DataTableData> = DataTableAriaProps & Sizes & {
35
+ /** Data for table */
36
+ data: D;
37
+ /** Count of total rows if table using virtual scroll. Needs for accessibility */
38
+ totalRows?: number;
39
+ /** Table theme according to visual hierarchy on the page
40
+ * @default primary
41
+ * */
42
+ use?: DTUse;
43
+ /** Active sort object */
44
+ sort?: DataTableSort<keyof D[0]>;
45
+ /** Handler call when request will change sort */
46
+ onSortChange?: DataTableChangeSort<keyof D[0]>;
47
+ /**
48
+ *
49
+ * @default auto
50
+ */
51
+ defaultGridTemplateColumnWidth?: 'auto' | '1fr';
52
+ /**
53
+ * Flag for compact view (fewer paddings)
54
+ */
55
+ compact?: boolean;
56
+ /**
57
+ * Size of paddings for the first and last columns in the table
58
+ */
59
+ sideIndents?: 'l';
60
+ /**
61
+ * Flag for showing spinner on table body
62
+ */
63
+ loading?: boolean;
64
+ children?: never;
65
+ /**
66
+ * Set of expanded rows (uniq id from them)
67
+ */
68
+ expandedRows?: Set<string>;
69
+ virtualScroll?: VirtualScroll;
70
+ columns: ColumnsConfig;
71
+ headerProps?: {
72
+ /**
73
+ * Sticky header
74
+ * @default false
75
+ */
76
+ sticky?: boolean;
77
+ /**
78
+ * offset for sticky header
79
+ */
80
+ top?: number;
81
+ /** Enable scroll bar element in header */
82
+ withScrollBar?: boolean;
83
+ };
84
+ rowProps?: DataTableBodyProps['rowProps'];
85
+ renderCell?: DataTableBodyProps['renderCell'];
86
+ /**
87
+ * List of selected rows (indexes from data array)
88
+ */
89
+ selectedRows?: number[];
90
+ onSelectedRowsChange?: (selectedRows: number[], event?: React.SyntheticEvent<HTMLElement>, opts?: {
91
+ selectedRowIndex: number;
92
+ isSelected: boolean;
93
+ row: DTRow;
94
+ }) => void;
95
+ renderEmptyData?: () => React.ReactNode;
96
+ };
97
+ export type ColumnItemConfig = Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<'div' | typeof Tooltip, 'div', DataTableColumnProps, {}, [
98
+ ]>, 'children'> & {
99
+ children: React.ReactNode | React.FC;
100
+ };
101
+ export type ColumnGroupConfig = {
102
+ borders?: 'both' | 'left' | 'right';
103
+ fixed?: 'left' | 'right';
104
+ children: React.ReactNode;
105
+ columns: ColumnItemConfig[];
106
+ };
107
+ type ColumnsConfig = Array<ColumnItemConfig | ColumnGroupConfig>;
108
+ export type VirtualScroll = boolean | {
109
+ rowsBuffer?: number;
110
+ aproxRowsOnPage?: number;
111
+ } | {
112
+ rowHeight: number;
113
+ rowsBuffer?: number;
114
+ };
115
+ export type RowIndex = number;
116
+ export type ColIndex = number;
117
+ 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>>;
118
+ export {};
@@ -0,0 +1,30 @@
1
+ import * as React from 'react';
2
+ import { Component } from '@semcore/core';
3
+ import { ColumnPropsInner, DataTableColumnProps } from './Column.types';
4
+ import type { DataTableData, SortDirection } from '../DataTable/DataTable.types';
5
+ type State = {
6
+ sortVisible: boolean;
7
+ };
8
+ export declare class Column<D extends DataTableData> extends Component<DataTableColumnProps, {}, {}, [
9
+ ], ColumnPropsInner<D>> {
10
+ static displayName: string;
11
+ static style: {
12
+ [key: string]: string;
13
+ };
14
+ lockedCell: [HTMLElement | null, boolean];
15
+ columnRef: React.RefObject<HTMLDivElement>;
16
+ sortWrapperRef: React.RefObject<HTMLDivElement>;
17
+ state: State;
18
+ componentDidMount(): void;
19
+ componentDidUpdate(prevProps: DataTableColumnProps & ColumnPropsInner<D>): void;
20
+ calculateActiveColumnMinWidth: () => number | null;
21
+ get defaultDirection(): SortDirection;
22
+ handleMouseEnter: () => void;
23
+ handleMouseLeave: () => void;
24
+ handleBlur: (e: React.FocusEvent<HTMLElement>) => void;
25
+ handleSortClick: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
26
+ handleKeyDown: (e: React.KeyboardEvent) => void;
27
+ handleFocusCell: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
28
+ render(): React.ReactNode;
29
+ }
30
+ export {};