@addev-be/ui 0.2.16 → 0.2.18

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 (88) hide show
  1. package/eslint.config.js +28 -0
  2. package/package.json +13 -20
  3. package/src/Icons.tsx +108 -0
  4. package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +93 -0
  5. package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +262 -0
  6. package/src/components/data/AdvancedRequestDataGrid/helpers/index.ts +2 -0
  7. package/src/components/data/AdvancedRequestDataGrid/index.tsx +267 -0
  8. package/src/components/data/AdvancedRequestDataGrid/types.ts +47 -0
  9. package/src/components/data/DataGrid/DataGridCell.tsx +73 -0
  10. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +14 -0
  11. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +59 -0
  12. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +181 -0
  13. package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +104 -0
  14. package/src/components/data/DataGrid/DataGridEditableCell.tsx +43 -0
  15. package/src/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.tsx +120 -0
  16. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +75 -0
  17. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +360 -0
  18. package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +96 -0
  19. package/src/components/data/DataGrid/DataGridFooter.tsx +42 -0
  20. package/src/components/data/DataGrid/DataGridHeader.tsx +126 -0
  21. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +132 -0
  22. package/src/components/data/DataGrid/FilterModalContent/index.tsx +136 -0
  23. package/src/components/data/DataGrid/FilterModalContent/styles.ts +22 -0
  24. package/src/components/data/DataGrid/VirtualScroller.tsx +46 -0
  25. package/src/components/data/DataGrid/helpers/columns.tsx +295 -0
  26. package/src/components/data/DataGrid/helpers/filters.ts +287 -0
  27. package/src/components/data/DataGrid/helpers/index.ts +2 -0
  28. package/src/components/data/DataGrid/hooks/index.ts +30 -0
  29. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +306 -0
  30. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +175 -0
  31. package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +48 -0
  32. package/src/components/data/DataGrid/index.tsx +140 -0
  33. package/src/components/data/DataGrid/styles.ts +323 -0
  34. package/src/components/data/DataGrid/types.ts +267 -0
  35. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +277 -0
  36. package/src/components/data/SqlRequestDataGrid/helpers/index.ts +2 -0
  37. package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +16 -0
  38. package/src/components/data/SqlRequestDataGrid/index.tsx +347 -0
  39. package/src/components/data/SqlRequestDataGrid/types.ts +47 -0
  40. package/src/components/data/index.ts +8 -0
  41. package/src/components/forms/Button.tsx +99 -0
  42. package/src/components/forms/IconButton.tsx +56 -0
  43. package/src/components/forms/IndeterminateCheckbox.tsx +46 -0
  44. package/src/components/forms/Select.tsx +40 -0
  45. package/src/components/forms/index.ts +5 -0
  46. package/src/components/forms/styles.ts +20 -0
  47. package/src/components/index.ts +3 -0
  48. package/src/components/layout/Dropdown/index.tsx +79 -0
  49. package/src/components/layout/Dropdown/styles.ts +44 -0
  50. package/src/components/layout/Loading/index.tsx +29 -0
  51. package/src/components/layout/Loading/styles.ts +29 -0
  52. package/src/components/layout/Modal/index.tsx +51 -0
  53. package/src/components/layout/Modal/styles.ts +110 -0
  54. package/src/components/layout/index.ts +3 -0
  55. package/src/components/ui/ContextMenu/index.tsx +79 -0
  56. package/src/components/ui/ContextMenu/styles.ts +119 -0
  57. package/src/config/index.ts +14 -0
  58. package/src/helpers/dates.ts +9 -0
  59. package/src/helpers/getScrollbarSize.ts +14 -0
  60. package/src/helpers/numbers.ts +26 -0
  61. package/src/hooks/index.ts +2 -0
  62. package/src/hooks/useElementSize.ts +24 -0
  63. package/src/hooks/useWindowSize.ts +20 -0
  64. package/src/index.ts +7 -0
  65. package/src/providers/PortalsProvider/index.tsx +54 -0
  66. package/src/providers/PortalsProvider/styles.ts +27 -0
  67. package/src/providers/SettingsProvider/index.tsx +70 -0
  68. package/src/providers/ThemeProvider/ThemeProvider.ts +55 -0
  69. package/src/providers/ThemeProvider/defaultTheme.ts +444 -0
  70. package/src/providers/ThemeProvider/index.ts +3 -0
  71. package/src/providers/ThemeProvider/types.ts +123 -0
  72. package/src/providers/UiProviders/index.tsx +65 -0
  73. package/src/providers/UiProviders/styles.ts +10 -0
  74. package/src/providers/hooks.ts +8 -0
  75. package/src/providers/index.ts +5 -0
  76. package/src/services/HttpService.ts +80 -0
  77. package/src/services/WebSocketService.ts +147 -0
  78. package/src/services/advancedRequests.ts +101 -0
  79. package/src/services/base.ts +31 -0
  80. package/src/services/globalSearch.ts +27 -0
  81. package/src/services/hooks.ts +23 -0
  82. package/src/services/index.ts +2 -0
  83. package/src/services/sqlRequests.ts +110 -0
  84. package/src/styles/animations.scss +30 -0
  85. package/src/styles/index.scss +42 -0
  86. package/src/typings.d.ts +6 -0
  87. package/tsconfig.json +18 -0
  88. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,323 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ import { ThemeColor } from '../../../providers/ThemeProvider/types';
4
+
5
+ export const VIRTUAL_SCROLL_TOLERANCE = 20;
6
+ export const TOOLBAR_HEIGHT = 40;
7
+ export const DEFAULT_HEADER_ROW_HEIGHT = 40;
8
+ export const DEFAULT_FOOTER_ROW_HEIGHT = 40;
9
+ export const DEFAULT_ROW_HEIGHT = 32;
10
+
11
+ export const TopPaddingRow = styled.div``;
12
+ export const BottomPaddingRow = styled.div``;
13
+
14
+ export const VirtualScrollerContainer = styled.div<{
15
+ $height: number;
16
+ }>`
17
+ position: relative;
18
+ overflow: visible;
19
+ height: ${({ $height }) => `${$height}px`};
20
+ `;
21
+ export const VirtualScrollerRowsContainer = styled.div.attrs<{
22
+ $gridTemplateColumns: string;
23
+ $topPadding: number;
24
+ $rowHeight?: number;
25
+ }>(({ $gridTemplateColumns, $topPadding, $rowHeight = DEFAULT_ROW_HEIGHT }) => {
26
+ const rowHeightValue = `${$rowHeight}px`;
27
+ return {
28
+ style: {
29
+ top: `${$topPadding}px`,
30
+ gridTemplateColumns: $gridTemplateColumns,
31
+ gridAutoRows: rowHeightValue,
32
+ },
33
+ };
34
+ })`
35
+ display: grid;
36
+ position: absolute;
37
+
38
+ ${TopPaddingRow} {
39
+ grid-column-start: 1;
40
+ grid-column-end: -1;
41
+ grid-row: 1;
42
+ }
43
+ ${BottomPaddingRow} {
44
+ grid-column-start: 1;
45
+ grid-column-end: -1;
46
+ grid-row: -1;
47
+ }
48
+ `;
49
+
50
+ export const DataGridResizeGrip = styled.div<{ $headerColor?: ThemeColor }>`
51
+ position: absolute;
52
+ top: 0;
53
+ right: 0;
54
+ width: var(--space-1);
55
+ height: 100%;
56
+
57
+ ${({ $headerColor }) =>
58
+ $headerColor
59
+ ? css`
60
+ background-color: var(--color-${$headerColor}-400);
61
+ &:hover,
62
+ &.active {
63
+ background-color: var(--color-${$headerColor}-500);
64
+ }
65
+ `
66
+ : css`
67
+ background-color: var(--color-neutral-400);
68
+ &:hover,
69
+ &.active {
70
+ background-color: var(--color-neutral-500);
71
+ }
72
+ `}
73
+
74
+ cursor: col-resize;
75
+ display: none;
76
+ `;
77
+
78
+ type DataGridHeaderCellContainerProps = {
79
+ $isResizing?: boolean;
80
+ $headerColor?: ThemeColor;
81
+ };
82
+
83
+ export const DataGridHeaderCellContainer = styled.div<DataGridHeaderCellContainerProps>`
84
+ position: relative;
85
+ display: flex;
86
+ align-items: center;
87
+ flex-wrap: nowrap;
88
+ gap: var(--space-1);
89
+ padding: 0 0.75rem;
90
+ height: 100%;
91
+ font-weight: var(--font-bold);
92
+ line-height: 1.5rem;
93
+ z-index: ${({ $isResizing }) => ($isResizing ? 1 : 0)};
94
+
95
+ ${({ $headerColor }) =>
96
+ $headerColor
97
+ ? css`
98
+ background-color: var(--color-${$headerColor}-200);
99
+ color: var(--color-${$headerColor}-950);
100
+ &:hover {
101
+ background-color: var(--color-${$headerColor}-300);
102
+ }
103
+
104
+ & > button {
105
+ background-color: var(--color-${$headerColor}-400);
106
+ border-color: var(--color-${$headerColor}-500);
107
+ &:hover {
108
+ background-color: var(--color-${$headerColor}-500);
109
+ border-color: var(--color-${$headerColor}-600);
110
+ }
111
+ }
112
+ & > button.danger {
113
+ background-color: var(--color-red-400);
114
+ border-color: var(--color-red-500);
115
+ &:hover {
116
+ background-color: var(--color-red-500);
117
+ border-color: var(--color-red-600);
118
+ }
119
+ }
120
+ `
121
+ : css`
122
+ background-color: var(--color-neutral-200);
123
+ color: var(--color-neutral-950);
124
+ &:hover {
125
+ background-color: var(--color-neutral-300);
126
+ }
127
+ `}
128
+
129
+ &:hover {
130
+ ${DataGridResizeGrip} {
131
+ display: block;
132
+ }
133
+ }
134
+
135
+ & > span {
136
+ display: inline-block;
137
+ text-overflow: ellipsis;
138
+ overflow: hidden;
139
+ white-space: nowrap;
140
+ flex: 1;
141
+ font-weight: bold;
142
+ }
143
+ `;
144
+ DataGridHeaderCellContainer.displayName = 'DataGridHeaderCellContainer';
145
+
146
+ export const DataGridCell = styled.div`
147
+ position: relative;
148
+ padding: 0 var(--space-3);
149
+ overflow: hidden;
150
+ text-overflow: ellipsis;
151
+ white-space: nowrap;
152
+ border-right: 1px solid var(--color-neutral-200);
153
+ border-bottom: 1px solid var(--color-neutral-200);
154
+ `;
155
+ DataGridCell.displayName = 'DataGridCell';
156
+
157
+ export const DataGridToolsRow = styled.div`
158
+ grid-column-start: 1;
159
+ grid-column-end: -1;
160
+ grid-row: 1;
161
+ display: flex;
162
+ gap: var(--space-1);
163
+ padding: 0 var(--space-1);
164
+ align-items: center;
165
+ background-color: var(--color-neutral-200);
166
+ position: sticky;
167
+ top: 0;
168
+ left: 0;
169
+ z-index: 10;
170
+ `;
171
+ DataGridToolsRow.displayName = 'DataGridToolsRow';
172
+
173
+ export const DataGridContainer = styled.div<{
174
+ $headerRowHeight?: number;
175
+ $rowHeight?: number;
176
+ $rowsCount: number;
177
+ $showToolsHeader?: boolean;
178
+ $withFooter?: boolean;
179
+ }>`
180
+ display: grid;
181
+ width: 100%;
182
+ height: 100%;
183
+ background-color: var(--color-neutral-50);
184
+ font-size: var(--text-base);
185
+ overflow: scroll;
186
+ grid-template-rows: ${({
187
+ $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT,
188
+ $withFooter = false,
189
+ }) =>
190
+ `${TOOLBAR_HEIGHT}px ${$headerRowHeight}px auto ${
191
+ $withFooter ? DEFAULT_FOOTER_ROW_HEIGHT + 'px' : ''
192
+ }`};
193
+
194
+ ${DataGridToolsRow} {
195
+ height: ${TOOLBAR_HEIGHT}px;
196
+ }
197
+ ${DataGridHeaderCellContainer} {
198
+ position: sticky;
199
+ top: ${({ $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT }) =>
200
+ `${$headerRowHeight}px`};
201
+ height: ${({ $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT }) =>
202
+ `${$headerRowHeight}px`};
203
+ }
204
+ ${DataGridCell} {
205
+ height: ${({ $rowHeight = DEFAULT_ROW_HEIGHT }) => `${$rowHeight}px`};
206
+ line-height: ${({ $rowHeight = DEFAULT_ROW_HEIGHT }) => `${$rowHeight}px`};
207
+ }
208
+
209
+ ${VirtualScrollerContainer} {
210
+ grid-column-start: 1;
211
+ grid-column-end: -1;
212
+ grid-row: 3;
213
+ }
214
+ `;
215
+ DataGridContainer.displayName = 'DataGridContainer';
216
+
217
+ type DataGridHeaderOrFooterRowProps = {
218
+ $headerRowHeight?: number;
219
+ $headerColor?: ThemeColor;
220
+ $gridTemplateColumns: string;
221
+ };
222
+
223
+ const dataGridHeaderOrFooterRowCss = css<DataGridHeaderOrFooterRowProps>`
224
+ display: grid;
225
+ grid-template-rows: ${({ $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT }) =>
226
+ `${$headerRowHeight}px`};
227
+ z-index: 10;
228
+ position: sticky;
229
+ align-items: center;
230
+
231
+ ${({ $headerColor }) =>
232
+ $headerColor
233
+ ? css`
234
+ background-color: var(--color-${$headerColor}-100);
235
+ color: var(--color-${$headerColor}-900);
236
+ `
237
+ : css`
238
+ background-color: var(--color-neutral-200);
239
+ color: var(--color-neutral-900);
240
+ `}
241
+ `;
242
+
243
+ export const DataGridHeaderRow = styled.div.attrs<DataGridHeaderOrFooterRowProps>(
244
+ ({ $gridTemplateColumns }) => ({
245
+ style: {
246
+ gridTemplateColumns: $gridTemplateColumns,
247
+ },
248
+ })
249
+ )`
250
+ ${dataGridHeaderOrFooterRowCss}
251
+ top: ${TOOLBAR_HEIGHT}px;
252
+ `;
253
+ DataGridHeaderRow.displayName = 'DataGridHeaderRow';
254
+
255
+ export const DataGridFooterRow = styled.div.attrs<DataGridHeaderOrFooterRowProps>(
256
+ ({ $gridTemplateColumns }) => ({
257
+ style: {
258
+ gridTemplateColumns: $gridTemplateColumns,
259
+ },
260
+ })
261
+ )`
262
+ ${dataGridHeaderOrFooterRowCss}
263
+ bottom: 0;
264
+ `;
265
+ DataGridFooterRow.displayName = 'DataGridFooterRow';
266
+
267
+ export const DataGridRow = styled.div`
268
+ display: contents;
269
+ `;
270
+ DataGridRow.displayName = 'DataGridRow';
271
+
272
+ export const LoadingCell = styled(DataGridCell)`
273
+ padding: var(--space-2);
274
+ box-sizing: border-box;
275
+
276
+ &.animate-pulse > div {
277
+ background-color: var(--color-neutral-200);
278
+ border-radius: var(--rounded-full);
279
+ width: 100%;
280
+ height: 100%;
281
+ }
282
+ `;
283
+ LoadingCell.displayName = 'LoadingCell';
284
+
285
+ const selectionCellStyle = css`
286
+ display: flex;
287
+ align-items: center;
288
+ justify-content: center;
289
+ width: var(--space-8);
290
+ padding: 0 var(--space-1);
291
+ cursor: pointer;
292
+
293
+ & > input[type='checkbox'] {
294
+ height: var(--space-4);
295
+ width: var(--space-4);
296
+ border-radius: var(--rounded-sm);
297
+ border: 1px solid var(--color-neutral-300);
298
+ color: var(--color-primary-600);
299
+ }
300
+ `;
301
+
302
+ export const SelectionCell = styled(DataGridCell)`
303
+ ${selectionCellStyle}
304
+ `;
305
+ SelectionCell.displayName = 'SelectionCell';
306
+
307
+ export const HeaderSelectionCell = styled(DataGridHeaderCellContainer)`
308
+ ${selectionCellStyle}
309
+ `;
310
+ HeaderSelectionCell.displayName = 'HeaderSelectionCell';
311
+
312
+ export const ResizeBackdrop = styled.div.attrs({
313
+ className: 'ResizeBackdrop',
314
+ })`
315
+ position: fixed;
316
+ top: 0;
317
+ left: 0;
318
+ right: 0;
319
+ bottom: 0;
320
+ background-color: rgba(0, 0, 0, 0);
321
+ cursor: col-resize;
322
+ `;
323
+ ResizeBackdrop.displayName = 'ResizeBackdrop';
@@ -0,0 +1,267 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import * as t from 'io-ts';
4
+
5
+ import {
6
+ CSSProperties,
7
+ Context,
8
+ Dispatch,
9
+ FC,
10
+ MouseEvent,
11
+ MouseEventHandler,
12
+ ReactNode,
13
+ SetStateAction,
14
+ } from 'react';
15
+
16
+ import { SettingsContextProps } from '../../../providers/SettingsProvider';
17
+ import { ThemeColor } from '../../../providers/ThemeProvider/types';
18
+
19
+ export type DataGridCellFC = FC<{
20
+ onDoubleClick?: MouseEventHandler;
21
+ style?: CSSProperties;
22
+ }>;
23
+
24
+ export type DataGridFooterPredefinedFunction =
25
+ | 'average'
26
+ | 'avg'
27
+ | 'count'
28
+ | 'max'
29
+ | 'min'
30
+ | 'sum';
31
+ export type DataGridFooterFunction<R> = (
32
+ allRows: R[],
33
+ filteredRows: R[],
34
+ selectedRows: R[]
35
+ ) => ReactNode;
36
+
37
+ export type DataGridColumn<R> = {
38
+ component?: DataGridCellFC;
39
+ editable?: boolean;
40
+ excelFormatter?: (value: any) => string;
41
+ excelBackgroundColor?: (value: any) => string;
42
+ excelValue?: (value: any) => string;
43
+ filter?: DataGridFilter;
44
+ footer?:
45
+ | DataGridFooterFunction<R>
46
+ | Record<string, DataGridFooterFunction<R> | null>;
47
+ getter?: (row: R) => string | number;
48
+ name: string;
49
+ order?: number;
50
+ propertyName?: keyof R;
51
+ render?: (row: R, column: DataGridColumn<R>) => ReactNode | string;
52
+ resizable?: boolean;
53
+ sortGetter?: (row: R) => string | number;
54
+ type?: 'text' | 'number' | 'date';
55
+ width?: number;
56
+ settingsContext?: Context<SettingsContextProps>;
57
+ };
58
+
59
+ export type DataGridColumns<R> = Record<string, DataGridColumn<R>>;
60
+
61
+ export type DataGridFilters = Record<
62
+ string,
63
+ DataGridFilter<DataGridFilterType>
64
+ >;
65
+
66
+ export type DataGridProps<R> = {
67
+ name?: string;
68
+ className?: string;
69
+ rows: R[];
70
+ columns: DataGridColumns<R>;
71
+ rowKey: keyof R | ((row: R) => string);
72
+ selectable?: boolean;
73
+ editable?: boolean;
74
+ onRowDoubleClick?: (row: R, e: MouseEvent) => void;
75
+ onSelectionChange?: (keys: string[]) => void;
76
+ getAllIds?: () => Promise<string[]>;
77
+ onFiltersChanged?: (filters: DataGridFilters) => void;
78
+ onSortsChanged?: (sorts: Record<string, DataGridSort>) => void;
79
+ onVisibleRowsChange?: (startIndex: number, length: number) => void;
80
+ onCellEdited?: (row: R, columnKey: string, value: any) => void;
81
+ rowClassNameGetter?: (row: R | null) => {
82
+ className?: string;
83
+ style?: CSSProperties;
84
+ };
85
+ headerRowHeight?: number;
86
+ rowHeight?: number;
87
+ filter?: boolean;
88
+ sort?: boolean;
89
+ initialSorts?: Record<string, DataGridSort>;
90
+ initialFooters?: Record<string, string>;
91
+ onFootersChanged?: (footers: Record<string, string>) => void;
92
+ filterValuesLoader?: (
93
+ columnKey: string
94
+ ) => Promise<(string | number | null)[]>;
95
+ // copyTableHandler?: (
96
+ // includeHeaders?: boolean,
97
+ // includeFooters?: boolean
98
+ // ) => Promise<void>;
99
+ loadCopyRows?: () => Promise<R[]>;
100
+ refresh?: () => void;
101
+ headerColor?: ThemeColor;
102
+ };
103
+
104
+ export type DataGridContextProps<R> = DataGridProps<R> & {
105
+ editingCell?: [number, number];
106
+ setEditingCell: Dispatch<SetStateAction<[number, number]>>;
107
+ sortedRows: R[];
108
+ selectedRows: R[];
109
+ selectedKeys: string[];
110
+ setSelectedKeys: (selection: string[]) => void;
111
+ sorts?: Record<string, DataGridSort>;
112
+ setSorts: (sorts: Record<string, DataGridSort>) => void;
113
+ filters?: DataGridFilters;
114
+ setFilters: Dispatch<SetStateAction<DataGridFilters>>;
115
+ footers?: Record<string, string>;
116
+ setFooters: Dispatch<SetStateAction<Record<string, string>>>;
117
+ footerFunctions?: Record<string, DataGridFooterFunction<R>>;
118
+ visibleColumns: DataGridColumnKeyValuePair<R>[];
119
+ copyTable: (
120
+ includeHeaders?: boolean,
121
+ includeFooters?: boolean
122
+ ) => Promise<void>;
123
+ setColumnWidth: (key: string, width: number) => void;
124
+ saveSettings: (newSettings?: DataGridSettings) => void;
125
+ settings: DataGridSettings;
126
+ setSettings: Dispatch<SetStateAction<DataGridSettings>>;
127
+ visibleRows: R[];
128
+ scrollableRef: React.RefObject<HTMLDivElement>;
129
+ onScroll: (e: React.UIEvent<HTMLDivElement>) => void;
130
+ index: number;
131
+ length: number;
132
+ rowKeyGetter: (row: R) => string;
133
+ gridTemplateColumns: string;
134
+ };
135
+
136
+ export type DataGridContext<R> = Context<DataGridContextProps<R>>;
137
+
138
+ export const dataGridSettingCodec = t.partial(
139
+ {
140
+ width: t.number,
141
+ order: t.number,
142
+ },
143
+ 'DataGridSetting'
144
+ );
145
+ export const dataGridSettingsCodec = t.record(
146
+ t.string,
147
+ dataGridSettingCodec,
148
+ 'DataGridSettings'
149
+ );
150
+ export const dataGridSettingsByNameCodec = t.record(
151
+ t.string,
152
+ dataGridSettingsCodec,
153
+ 'DataGridSettingsByName'
154
+ );
155
+
156
+ export type DataGridSetting = t.TypeOf<typeof dataGridSettingCodec>;
157
+ export type DataGridSettings = t.TypeOf<typeof dataGridSettingsCodec>;
158
+ export type DataGridSettingsByName = t.TypeOf<
159
+ typeof dataGridSettingsByNameCodec
160
+ >;
161
+ export type DataGridSettingsTuple = [string, DataGridSetting];
162
+ export type DataGridSettingsArray = DataGridSettingsTuple[];
163
+ export type DataGridColumnKeyValuePair<R> = [string, DataGridColumn<R>];
164
+
165
+ export type DataGridCellProps<R> = {
166
+ row: R;
167
+ rowIndex: number;
168
+ columnKey: string;
169
+ columnIndex: number;
170
+ column: DataGridColumn<R>;
171
+ context: DataGridContext<R>;
172
+ className?: string;
173
+ style?: CSSProperties;
174
+ };
175
+
176
+ export type DataGridHeaderCellProps<R> = {
177
+ columnKey: string;
178
+ columnIndex: number;
179
+ column: DataGridColumn<R>;
180
+ context: DataGridContext<R>;
181
+ onFilterButtonClicked?: (columnKey: string) => void;
182
+ isFilterOpen?: boolean;
183
+ };
184
+
185
+ export type DataGridSort = 'asc' | 'desc';
186
+
187
+ export type DataGridFilterPredicate<T> = (valueToVerify: T) => boolean;
188
+ export type DataGridFilterPredicateBuilder<T> = (
189
+ ...filterValues: T[]
190
+ ) => DataGridFilterPredicate<T>;
191
+
192
+ export type DataGridFilterOperators<K extends string, T> = {
193
+ [key in K]: DataGridFilterPredicateBuilder<T>;
194
+ };
195
+
196
+ export type DataGridFilterPredicates = {
197
+ date: DataGridFilterOperators<
198
+ 'before' | 'after' | 'equals' | 'notEquals' | 'inRange' | 'inArray',
199
+ string
200
+ >;
201
+ text: DataGridFilterOperators<
202
+ | 'contains'
203
+ | 'notContains'
204
+ | 'equals'
205
+ | 'notEquals'
206
+ | 'startsWith'
207
+ | 'endsWith'
208
+ | 'inArray',
209
+ string
210
+ >;
211
+ number: DataGridFilterOperators<
212
+ | 'equals'
213
+ | 'notEquals'
214
+ | 'lessThan'
215
+ | 'lessThanOrEqual'
216
+ | 'greaterThan'
217
+ | 'greaterThanOrEqual'
218
+ | 'inRange'
219
+ | 'inArray',
220
+ number
221
+ >;
222
+ };
223
+
224
+ export type DataGridFilterType = keyof DataGridFilterPredicates;
225
+ export type DataGridFilterDataType<T extends DataGridFilterType> =
226
+ DataGridFilterPredicates[T] extends DataGridFilterOperators<string, infer U>
227
+ ? U
228
+ : never;
229
+
230
+ export type DataGridFilterGetter<T extends DataGridFilterType> = (
231
+ value: any
232
+ ) => DataGridFilterDataType<T> | null;
233
+ export type DataGridFilterRenderer = (value: any) => ReactNode;
234
+ export type DataGridFilterFormatter = (value: any) => string;
235
+
236
+ export type DataGridFilterOperator<T extends DataGridFilterType> =
237
+ DataGridFilterPredicates[T] extends DataGridFilterOperators<infer K, any>
238
+ ? K
239
+ : never;
240
+
241
+ export type DataGridFilter<T extends string = DataGridFilterType> =
242
+ T extends DataGridFilterType
243
+ ? {
244
+ type: T;
245
+ operator: DataGridFilterOperator<T>;
246
+ getter: DataGridFilterGetter<T>;
247
+ renderer?: DataGridFilterRenderer;
248
+ formatter?: DataGridFilterFormatter;
249
+ values: (DataGridFilterDataType<T> | null)[];
250
+ }
251
+ : never;
252
+
253
+ export type DataGridFilterGroup = {
254
+ name: string;
255
+ displayValue: DataGridFilterValue;
256
+ values?: DataGridFilterValue[];
257
+ groups?: DataGridFilterGroup[];
258
+ };
259
+
260
+ export type DataGridFilterValue = string | number | null;
261
+
262
+ export type DataGridFilterCheckbox = {
263
+ displayValue: ReactNode;
264
+ title: string;
265
+ values: DataGridFilterValue[];
266
+ level: number;
267
+ };