@semcore/data-table 16.0.0-prerelease.9 → 16.0.1-prerelease.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 +32 -2
  2. package/lib/cjs/components/Body/Body.js +439 -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 +195 -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 +252 -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 +263 -0
  17. package/lib/cjs/components/DataTable/DataTable.js +1025 -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 +311 -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 +116 -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 +207 -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 +180 -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 +45 -5
  38. package/lib/cjs/translations/en.json +6 -1
  39. package/lib/es6/components/Body/Body.js +432 -0
  40. package/lib/es6/components/Body/Body.js.map +1 -0
  41. package/lib/es6/components/Body/Body.types.js +2 -0
  42. package/lib/es6/components/Body/Body.types.js.map +1 -0
  43. package/lib/es6/components/Body/Cell.js +188 -0
  44. package/lib/es6/components/Body/Cell.js.map +1 -0
  45. package/lib/es6/components/Body/Cell.types.js +2 -0
  46. package/lib/es6/components/Body/Cell.types.js.map +1 -0
  47. package/lib/es6/components/Body/MergedCells.js +20 -0
  48. package/lib/es6/components/Body/MergedCells.js.map +1 -0
  49. package/lib/es6/components/Body/Row.js +245 -0
  50. package/lib/es6/components/Body/Row.js.map +1 -0
  51. package/lib/es6/components/Body/Row.types.js +2 -0
  52. package/lib/es6/components/Body/Row.types.js.map +1 -0
  53. package/lib/es6/components/Body/style.shadow.css +263 -0
  54. package/lib/es6/components/DataTable/DataTable.js +1013 -0
  55. package/lib/es6/components/DataTable/DataTable.js.map +1 -0
  56. package/lib/es6/components/DataTable/DataTable.types.js +2 -0
  57. package/lib/es6/components/DataTable/DataTable.types.js.map +1 -0
  58. package/lib/es6/components/DataTable/dataTable.shadow.css +17 -0
  59. package/lib/es6/components/Head/Column.js +304 -0
  60. package/lib/es6/components/Head/Column.js.map +1 -0
  61. package/lib/es6/components/Head/Column.types.js +2 -0
  62. package/lib/es6/components/Head/Column.types.js.map +1 -0
  63. package/lib/es6/components/Head/Group.js +109 -0
  64. package/lib/es6/components/Head/Group.js.map +1 -0
  65. package/lib/es6/components/Head/Group.type.js +2 -0
  66. package/lib/es6/components/Head/Group.type.js.map +1 -0
  67. package/lib/es6/components/Head/Head.js +201 -0
  68. package/lib/es6/components/Head/Head.js.map +1 -0
  69. package/lib/es6/components/Head/Head.types.js +2 -0
  70. package/lib/es6/components/Head/Head.types.js.map +1 -0
  71. package/lib/es6/components/Head/style.shadow.css +180 -0
  72. package/lib/es6/index.js +5 -2
  73. package/lib/es6/index.js.map +1 -1
  74. package/lib/es6/style/scroll-shadows.shadow.css +45 -5
  75. package/lib/es6/translations/en.json +6 -1
  76. package/lib/esm/components/Body/Body.mjs +394 -0
  77. package/lib/esm/components/Body/Cell.mjs +186 -0
  78. package/lib/esm/components/Body/MergedCells.mjs +23 -0
  79. package/lib/esm/components/Body/Row.mjs +224 -0
  80. package/lib/esm/components/Body/style.shadow.css +263 -0
  81. package/lib/esm/components/DataTable/DataTable.mjs +944 -0
  82. package/lib/esm/components/DataTable/dataTable.shadow.css +17 -0
  83. package/lib/esm/components/Head/Column.mjs +296 -0
  84. package/lib/esm/components/Head/Group.mjs +103 -0
  85. package/lib/esm/components/Head/Head.mjs +181 -0
  86. package/lib/esm/components/Head/style.shadow.css +180 -0
  87. package/lib/esm/index.mjs +8 -5
  88. package/lib/esm/style/scroll-shadows.shadow.css +47 -0
  89. package/lib/esm/translations/en.json.mjs +6 -1
  90. package/lib/types/components/Body/Body.d.ts +8 -0
  91. package/lib/types/components/Body/Body.types.d.ts +57 -0
  92. package/lib/types/components/Body/Cell.d.ts +3 -0
  93. package/lib/types/components/Body/Cell.types.d.ts +20 -0
  94. package/lib/types/components/Body/MergedCells.d.ts +14 -0
  95. package/lib/types/components/Body/Row.d.ts +3 -0
  96. package/lib/types/components/Body/Row.types.d.ts +43 -0
  97. package/lib/types/components/DataTable/DataTable.d.ts +13 -0
  98. package/lib/types/components/DataTable/DataTable.types.d.ts +125 -0
  99. package/lib/types/components/Head/Column.d.ts +30 -0
  100. package/lib/types/components/Head/Column.types.d.ts +71 -0
  101. package/lib/types/components/Head/Group.d.ts +15 -0
  102. package/lib/types/components/Head/Group.type.d.ts +16 -0
  103. package/lib/types/components/Head/Head.d.ts +98 -0
  104. package/lib/types/components/Head/Head.types.d.ts +40 -0
  105. package/lib/types/index.d.ts +10 -2
  106. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +5 -0
  107. package/package.json +11 -6
  108. package/vite.config.ts +0 -3
  109. package/lib/cjs/Body.js +0 -475
  110. package/lib/cjs/Body.js.map +0 -1
  111. package/lib/cjs/DataTable.js +0 -622
  112. package/lib/cjs/DataTable.js.map +0 -1
  113. package/lib/cjs/Head.js +0 -399
  114. package/lib/cjs/Head.js.map +0 -1
  115. package/lib/cjs/style/data-table.shadow.css +0 -394
  116. package/lib/cjs/types.js.map +0 -1
  117. package/lib/cjs/utils.js +0 -57
  118. package/lib/cjs/utils.js.map +0 -1
  119. package/lib/es6/Body.js +0 -468
  120. package/lib/es6/Body.js.map +0 -1
  121. package/lib/es6/DataTable.js +0 -614
  122. package/lib/es6/DataTable.js.map +0 -1
  123. package/lib/es6/Head.js +0 -391
  124. package/lib/es6/Head.js.map +0 -1
  125. package/lib/es6/style/data-table.shadow.css +0 -394
  126. package/lib/es6/types.js +0 -2
  127. package/lib/es6/types.js.map +0 -1
  128. package/lib/es6/utils.js +0 -48
  129. package/lib/es6/utils.js.map +0 -1
  130. package/lib/esm/Body.mjs +0 -427
  131. package/lib/esm/DataTable.mjs +0 -582
  132. package/lib/esm/Head.mjs +0 -369
  133. package/lib/esm/utils.mjs +0 -52
  134. package/lib/types/Body.d.ts +0 -61
  135. package/lib/types/DataTable.d.ts +0 -205
  136. package/lib/types/Head.d.ts +0 -45
  137. package/lib/types/types.d.ts +0 -73
  138. package/lib/types/utils.d.ts +0 -4
@@ -0,0 +1,180 @@
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='wide'] {
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
+ }
177
+
178
+ SHeadCheckboxCol {
179
+ cursor: pointer;
180
+ }
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,47 @@
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
+ &[leftScrollPadding] {
26
+ scroll-padding-left: var(--leftScrollPadding);
27
+ }
28
+ &[rightScrollPadding] {
29
+ scroll-padding-right: var(--rightScrollPadding);
30
+ }
31
+ }
32
+
33
+ SShadowVertical {
34
+ &:before {
35
+ display: none;
36
+ }
37
+ &:after {
38
+ z-index: 2;
39
+ }
40
+ }
41
+ SShadowHorizontal {
42
+ &:before,
43
+ &:after {
44
+ z-index: 2;
45
+ }
46
+ }
47
+ }
@@ -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,
@@ -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,57 @@
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?: 'wide';
56
+ getFixedStyle: (cell: Pick<DTColumn, 'name' | 'fixed'>) => [side: 'left' | 'right', style: string | number] | [side: undefined, style: undefined];
57
+ };
@@ -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,43 @@
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?: 'wide';
42
+ getFixedStyle: (cell: Pick<DTColumn, 'name' | 'fixed'>) => [side: 'left' | 'right', style: string | number] | [side: undefined, style: undefined];
43
+ };
@@ -0,0 +1,13 @@
1
+ import { DataTableProps, DataTableData, DataTableType } 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: DataTableType;
10
+ export declare const DataTableInternal: (<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[]>, "tag" | "children">) => import("@semcore/core").Intergalactic.InternalTypings.ComponentRenderingResults) & import("@semcore/core").Intergalactic.InternalTypings.ComponentAdditive<"div", "div", DataTableProps<any>, {}, {}> & {
11
+ Head: typeof Head;
12
+ Body: typeof Body;
13
+ };
@@ -0,0 +1,125 @@
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
+ export 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
+ export 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?: 'wide';
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
+ * Height of header in px. It's better to set it to improve performance with sticky header.
79
+ */
80
+ h?: number;
81
+ /**
82
+ * offset for sticky header
83
+ */
84
+ top?: number;
85
+ /** Enable scroll bar element in header */
86
+ withScrollBar?: boolean;
87
+ };
88
+ rowProps?: DataTableBodyProps['rowProps'];
89
+ renderCell?: DataTableBodyProps['renderCell'];
90
+ /**
91
+ * List of selected rows (indexes from data array)
92
+ */
93
+ selectedRows?: number[];
94
+ onSelectedRowsChange?: (selectedRows: number[], event?: React.SyntheticEvent<HTMLElement>, opts?: {
95
+ selectedRowIndex: number;
96
+ isSelected: boolean;
97
+ row: DTRow;
98
+ }) => void;
99
+ /**
100
+ * For custom empty data widget.
101
+ */
102
+ renderEmptyData?: () => React.ReactNode;
103
+ };
104
+ export type ColumnItemConfig = Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<'div' | typeof Tooltip, 'div', DataTableColumnProps, {}, [
105
+ ]>, 'children'> & {
106
+ children: React.ReactNode | React.FC;
107
+ };
108
+ export type ColumnGroupConfig = {
109
+ borders?: 'both' | 'left' | 'right';
110
+ fixed?: 'left' | 'right';
111
+ children: React.ReactNode;
112
+ columns: ColumnItemConfig[];
113
+ };
114
+ type ColumnsConfig = Array<ColumnItemConfig | ColumnGroupConfig>;
115
+ export type VirtualScroll = boolean | {
116
+ rowsBuffer?: number;
117
+ aproxRowsOnPage?: number;
118
+ } | {
119
+ rowHeight: number;
120
+ rowsBuffer?: number;
121
+ };
122
+ export type RowIndex = number;
123
+ export type ColIndex = number;
124
+ 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>>;
125
+ 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 {};
@@ -0,0 +1,71 @@
1
+ /// <reference types="react" />
2
+ import { ColumnGroupConfig, ColumnItemConfig, DataTableData, DataTableProps, DTUse, SortDirection } from '../DataTable/DataTable.types';
3
+ import { Property } from 'csstype';
4
+ export type CommonColumnType = {
5
+ /**
6
+ * Name of column for mapping with data
7
+ */
8
+ name: string;
9
+ /**
10
+ * Flag to define column as sortable
11
+ */
12
+ sortable?: boolean | SortDirection;
13
+ /**
14
+ * Fixes column to some side of table
15
+ */
16
+ fixed?: 'left' | 'right';
17
+ /**
18
+ * Adds vertical border(s)
19
+ */
20
+ borders?: 'both' | 'left' | 'right';
21
+ /**
22
+ * It manages the `flex-wrap` property
23
+ */
24
+ flexWrap?: boolean;
25
+ /**
26
+ * It manages the `align-items` property
27
+ */
28
+ alignItems?: Property.AlignItems;
29
+ /**
30
+ * It manages the `align-content` property
31
+ */
32
+ alignContent?: Property.AlignContent;
33
+ /**
34
+ * CSS `justify-content` property
35
+ */
36
+ justifyContent?: Property.JustifyContent;
37
+ };
38
+ export type DTColumn = ColumnItemConfig & CommonColumnType & {
39
+ /**
40
+ * Width for grid-template-columns
41
+ */
42
+ gtcWidth: string;
43
+ parent?: DTColumn | ColumnGroupConfig;
44
+ columns?: DTColumn[];
45
+ children?: React.ReactNode | React.FC;
46
+ gridArea?: string;
47
+ };
48
+ export type DataTableColumnProps = CommonColumnType & {
49
+ /**
50
+ * Value for grid-template-columns for current column
51
+ */
52
+ gtcWidth?: string;
53
+ /**
54
+ * Flag for change column size if sorted by it
55
+ */
56
+ changeSortSize?: boolean;
57
+ };
58
+ export type ColumnPropsInner<D extends DataTableData> = {
59
+ use: DTUse;
60
+ borders?: 'both' | 'left' | 'right';
61
+ sort?: DataTableProps<D>['sort'];
62
+ onSortChange?: DataTableProps<D>['onSortChange'];
63
+ uid: string;
64
+ parent?: DTColumn;
65
+ sortableColumnDescribeId: string;
66
+ columnIndex: number;
67
+ tableRef: React.RefObject<HTMLElement>;
68
+ gridTemplateColumns: string[];
69
+ gridTemplateAreas: string[];
70
+ sticky: boolean;
71
+ };
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { Component } from '@semcore/core';
3
+ import { DataTableGroupProps, GroupPropsInner } from './Group.type';
4
+ export declare class Group extends Component<DataTableGroupProps, {}, {}, typeof Group.enhance, GroupPropsInner> {
5
+ static displayName: string;
6
+ static style: {
7
+ [key: string]: string;
8
+ };
9
+ static enhance: readonly [(props: any) => {
10
+ uid: string;
11
+ }];
12
+ componentDidMount(): void;
13
+ get groupId(): string;
14
+ render(): React.ReactNode;
15
+ }