@addev-be/ui 0.2.5 → 0.2.7

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 (166) hide show
  1. package/assets/icons/arrow-down-1-9.svg +1 -0
  2. package/assets/icons/arrow-down-a-z.svg +1 -1
  3. package/assets/icons/arrow-down-big-small.svg +1 -0
  4. package/assets/icons/arrow-up-9-1.svg +1 -0
  5. package/assets/icons/arrow-up-big-small.svg +1 -0
  6. package/assets/icons/arrow-up-z-a.svg +1 -1
  7. package/assets/icons/check.svg +1 -1
  8. package/assets/icons/chevron-down.svg +1 -0
  9. package/assets/icons/down.svg +1 -1
  10. package/assets/icons/ellipsis.svg +1 -0
  11. package/assets/icons/filter-full.svg +1 -1
  12. package/assets/icons/filter.svg +1 -1
  13. package/assets/icons/hashtag.svg +1 -1
  14. package/assets/icons/image-slash.svg +1 -1
  15. package/assets/icons/left.svg +1 -1
  16. package/assets/icons/magnifier.svg +1 -1
  17. package/assets/icons/phone.svg +1 -1
  18. package/assets/icons/right.svg +1 -1
  19. package/assets/icons/sigma.svg +1 -0
  20. package/assets/icons/spinner-third.svg +1 -1
  21. package/assets/icons/table-columns.svg +1 -1
  22. package/assets/icons/table-footer-slash.svg +5 -0
  23. package/assets/icons/table-footer.svg +4 -0
  24. package/assets/icons/table.svg +1 -0
  25. package/assets/icons/tally.svg +1 -0
  26. package/assets/icons/up.svg +1 -1
  27. package/assets/icons/user-tie.svg +1 -1
  28. package/assets/icons/x-bar.svg +4 -0
  29. package/dist/Icons.d.ts +13 -1
  30. package/dist/Icons.js +25 -1
  31. package/dist/components/data/AdvancedRequestDataGrid/index.js +3 -3
  32. package/dist/components/data/DataGrid/AdvancedRequestDataGrid.d.ts +1 -2
  33. package/dist/components/data/DataGrid/AdvancedRequestDataGrid.js +3 -5
  34. package/dist/components/data/DataGrid/DataGridCell.d.ts +1 -1
  35. package/dist/components/data/DataGrid/DataGridCell.js +5 -5
  36. package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.js +2 -1
  37. package/dist/components/data/DataGrid/DataGridEditableCell.js +2 -7
  38. package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +90 -10
  39. package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +3 -9
  40. package/dist/components/data/DataGrid/DataGridFilterMenu/styles.js +10 -37
  41. package/dist/components/data/DataGrid/DataGridFooter.d.ts +1 -1
  42. package/dist/components/data/DataGrid/DataGridFooter.js +35 -22
  43. package/dist/components/data/DataGrid/DataGridHeader.js +1 -3
  44. package/dist/components/data/DataGrid/DataGridHeaderCell.js +8 -23
  45. package/dist/components/data/DataGrid/FilterModalContent/index.d.ts +5 -5
  46. package/dist/components/data/DataGrid/FilterModalContent/index.js +11 -9
  47. package/dist/components/data/DataGrid/FilterValuesScroller.d.ts +8 -7
  48. package/dist/components/data/DataGrid/FilterValuesScroller.js +5 -6
  49. package/dist/components/data/DataGrid/helpers/columns.d.ts +1 -1
  50. package/dist/components/data/DataGrid/helpers/columns.js +72 -20
  51. package/dist/components/data/DataGrid/helpers/filters.d.ts +4 -3
  52. package/dist/components/data/DataGrid/helpers/filters.js +13 -5
  53. package/dist/components/data/DataGrid/hooks/useDataGrid.d.ts +1 -1
  54. package/dist/components/data/DataGrid/hooks/useDataGrid.js +60 -30
  55. package/dist/components/data/DataGrid/hooks/useDataGridCopy.d.ts +2 -2
  56. package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +41 -40
  57. package/dist/components/data/DataGrid/hooks/useDataGridSettings.js +0 -1
  58. package/dist/components/data/DataGrid/index.d.ts +4 -2
  59. package/dist/components/data/DataGrid/index.js +38 -17
  60. package/dist/components/data/DataGrid/styles.d.ts +12 -5
  61. package/dist/components/data/DataGrid/styles.js +31 -18
  62. package/dist/components/data/DataGrid/types.d.ts +28 -16
  63. package/dist/components/data/SqlRequestDataGrid/helpers/columns.d.ts +1 -1
  64. package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +30 -19
  65. package/dist/components/data/SqlRequestDataGrid/index.js +125 -37
  66. package/dist/components/data/SqlRequestDataGrid/types.d.ts +1 -0
  67. package/dist/components/data/index.d.ts +2 -0
  68. package/dist/components/data/index.js +2 -0
  69. package/dist/components/ui/ContextMenu/index.d.ts +11 -0
  70. package/dist/components/ui/ContextMenu/index.js +58 -0
  71. package/dist/components/ui/ContextMenu/styles.d.ts +18 -0
  72. package/dist/components/ui/ContextMenu/styles.js +56 -0
  73. package/dist/helpers/dates.d.ts +2 -0
  74. package/dist/helpers/dates.js +13 -0
  75. package/dist/services/advancedRequests.d.ts +1 -1
  76. package/dist/services/sqlRequests.d.ts +9 -4
  77. package/dist/services/sqlRequests.js +1 -0
  78. package/package.json +1 -1
  79. package/src/Icons.tsx +104 -80
  80. package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +93 -93
  81. package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +262 -262
  82. package/src/components/data/AdvancedRequestDataGrid/helpers/index.ts +2 -2
  83. package/src/components/data/AdvancedRequestDataGrid/index.tsx +267 -269
  84. package/src/components/data/AdvancedRequestDataGrid/types.ts +47 -47
  85. package/src/components/data/DataGrid/DataGridCell.tsx +73 -73
  86. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +14 -14
  87. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +59 -58
  88. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +181 -181
  89. package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +104 -104
  90. package/src/components/data/DataGrid/DataGridEditableCell.tsx +43 -54
  91. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +75 -75
  92. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +364 -190
  93. package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +49 -100
  94. package/src/components/data/DataGrid/DataGridFooter.tsx +42 -64
  95. package/src/components/data/DataGrid/DataGridHeader.tsx +126 -126
  96. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +132 -167
  97. package/src/components/data/DataGrid/FilterModalContent/index.tsx +124 -125
  98. package/src/components/data/DataGrid/FilterModalContent/styles.ts +22 -22
  99. package/src/components/data/DataGrid/FilterValuesScroller.tsx +133 -131
  100. package/src/components/data/DataGrid/VirtualScroller.tsx +46 -46
  101. package/src/components/data/DataGrid/helpers/columns.tsx +287 -196
  102. package/src/components/data/DataGrid/helpers/filters.ts +220 -207
  103. package/src/components/data/DataGrid/helpers/index.ts +2 -2
  104. package/src/components/data/DataGrid/hooks/index.ts +30 -30
  105. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +305 -264
  106. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +170 -165
  107. package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +48 -48
  108. package/src/components/data/DataGrid/index.tsx +139 -132
  109. package/src/components/data/DataGrid/styles.ts +347 -326
  110. package/src/components/data/DataGrid/types.ts +260 -240
  111. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +259 -224
  112. package/src/components/data/SqlRequestDataGrid/helpers/index.ts +2 -2
  113. package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +16 -16
  114. package/src/components/data/SqlRequestDataGrid/index.tsx +347 -252
  115. package/src/components/data/SqlRequestDataGrid/types.ts +47 -47
  116. package/src/components/data/index.ts +8 -8
  117. package/src/components/forms/Button.tsx +99 -99
  118. package/src/components/forms/IconButton.tsx +56 -56
  119. package/src/components/forms/IndeterminateCheckbox.tsx +46 -46
  120. package/src/components/forms/Select.tsx +40 -40
  121. package/src/components/forms/index.ts +5 -5
  122. package/src/components/forms/styles.ts +20 -20
  123. package/src/components/index.ts +3 -3
  124. package/src/components/layout/Dropdown/index.tsx +79 -79
  125. package/src/components/layout/Dropdown/styles.ts +44 -44
  126. package/src/components/layout/Loading/index.tsx +29 -29
  127. package/src/components/layout/Loading/styles.ts +29 -29
  128. package/src/components/layout/Modal/index.tsx +51 -51
  129. package/src/components/layout/Modal/styles.ts +110 -110
  130. package/src/components/layout/index.ts +3 -3
  131. package/src/components/ui/ContextMenu/index.tsx +73 -0
  132. package/src/components/ui/ContextMenu/styles.ts +115 -0
  133. package/src/config/index.ts +14 -14
  134. package/src/helpers/dates.ts +9 -9
  135. package/src/helpers/getScrollbarSize.ts +14 -14
  136. package/src/helpers/numbers.ts +20 -20
  137. package/src/hooks/index.ts +2 -2
  138. package/src/hooks/useElementSize.ts +24 -24
  139. package/src/hooks/useWindowSize.ts +20 -20
  140. package/src/index.ts +7 -7
  141. package/src/providers/PortalsProvider/index.tsx +54 -54
  142. package/src/providers/PortalsProvider/styles.ts +27 -27
  143. package/src/providers/SettingsProvider/index.tsx +70 -70
  144. package/src/providers/ThemeProvider/ThemeProvider.ts +55 -55
  145. package/src/providers/ThemeProvider/defaultTheme.ts +444 -444
  146. package/src/providers/ThemeProvider/index.ts +3 -3
  147. package/src/providers/ThemeProvider/types.ts +123 -123
  148. package/src/providers/UiProviders/index.tsx +65 -65
  149. package/src/providers/UiProviders/styles.ts +10 -10
  150. package/src/providers/hooks.ts +8 -8
  151. package/src/providers/index.ts +5 -5
  152. package/src/services/HttpService.ts +80 -80
  153. package/src/services/WebSocketService.ts +147 -147
  154. package/src/services/advancedRequests.ts +101 -101
  155. package/src/services/base.ts +31 -31
  156. package/src/services/hooks.ts +23 -23
  157. package/src/services/index.ts +2 -2
  158. package/src/services/sqlRequests.ts +110 -99
  159. package/src/styles/animations.scss +30 -30
  160. package/src/styles/index.scss +42 -42
  161. package/src/typings.d.ts +6 -6
  162. package/tsconfig.tsbuildinfo +1 -1
  163. package/dist/components/data/DataGrid/helpers.d.ts +0 -28
  164. package/dist/components/data/DataGrid/helpers.js +0 -436
  165. package/dist/config/types.d.ts +0 -11
  166. package/dist/config/types.js +0 -2
@@ -1,240 +1,260 @@
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 MysqlJsonObject = Record<string, string | number | null>;
20
-
21
- export type DataGridCellFC = FC<{
22
- onDoubleClick?: MouseEventHandler;
23
- style?: CSSProperties;
24
- }>;
25
-
26
- export type DataGridColumn<R> = {
27
- component?: DataGridCellFC;
28
- editable?: boolean;
29
- excelFormatter?: (value: any) => string;
30
- excelValue?: (value: any) => string;
31
- filter?: DataGridFilter;
32
- footer?: (allRows: R[], filteredRows: R[], selectedRows: R[]) => ReactNode;
33
- footerClassName?: string;
34
- getter?: (row: R) => string | number | MysqlJsonObject;
35
- headerClassName?: string;
36
- name: string;
37
- order?: number;
38
- propertyName?: keyof R;
39
- render?: (row: R, column: DataGridColumn<R>) => ReactNode | string;
40
- resizable?: boolean;
41
- sortGetter?: (row: R) => string | number;
42
- type?: 'text' | 'number' | 'date';
43
- width?: number;
44
- settingsContext?: Context<SettingsContextProps>;
45
- };
46
-
47
- export type DataGridColumns<R> = Record<string, DataGridColumn<R>>;
48
-
49
- export type DataGridFilters = Record<
50
- string,
51
- DataGridFilter<DataGridFilterType>
52
- >;
53
-
54
- export type DataGridProps<R> = {
55
- name?: string;
56
- className?: string;
57
- rows: R[];
58
- columns: DataGridColumns<R>;
59
- rowKey: keyof R | ((row: R) => string);
60
- selectable?: boolean;
61
- editable?: boolean;
62
- onRowDoubleClick?: (row: R, e: MouseEvent) => void;
63
- onSelectionChange?: (keys: string[]) => void;
64
- getAllIds?: () => Promise<string[]>;
65
- onFiltersChanged?: (filters: DataGridFilters) => void;
66
- onSortsChanged?: (sorts: Record<string, DataGridSort>) => void;
67
- onVisibleRowsChange?: (startIndex: number, length: number) => void;
68
- onCellEdited?: (row: R, columnKey: string, value: any) => void;
69
- rowClassNameGetter?: (row: R | null) => {
70
- className?: string;
71
- style?: CSSProperties;
72
- };
73
- headerRowHeight?: number;
74
- rowHeight?: number;
75
- filter?: boolean;
76
- sort?: boolean;
77
- initialSorts?: Record<string, DataGridSort>;
78
- filterValuesLoader?: (
79
- columnKey: string
80
- ) => Promise<(string | number | null | MysqlJsonObject)[]>;
81
- // copyTableHandler?: (
82
- // includeHeaders?: boolean,
83
- // includeFooters?: boolean
84
- // ) => Promise<void>;
85
- loadCopyRows?: () => Promise<R[]>;
86
- refresh?: () => void;
87
- headerColor?: ThemeColor;
88
- };
89
-
90
- export type DataGridContextProps<R> = DataGridProps<R> & {
91
- editingCell?: [number, number];
92
- setEditingCell: Dispatch<SetStateAction<[number, number]>>;
93
- sortedRows: R[];
94
- selectedRows: R[];
95
- selectedKeys: string[];
96
- setSelectedKeys: (selection: string[]) => void;
97
- sorts?: Record<string, DataGridSort>;
98
- setSorts: (sorts: Record<string, DataGridSort>) => void;
99
- filters?: DataGridFilters;
100
- setFilters: Dispatch<SetStateAction<DataGridFilters>>;
101
- visibleColumns: DataGridColumnKeyValuePair<R>[];
102
- copyTable: (
103
- includeHeaders?: boolean,
104
- includeFooters?: boolean
105
- ) => Promise<void>;
106
- setColumnWidth: (key: string, width: number) => void;
107
- saveSettings: (newSettings?: DataGridSettings) => void;
108
- settings: DataGridSettings;
109
- setSettings: Dispatch<SetStateAction<DataGridSettings>>;
110
- visibleRows: R[];
111
- scrollableRef: React.RefObject<HTMLDivElement>;
112
- onScroll: (e: React.UIEvent<HTMLDivElement>) => void;
113
- index: number;
114
- length: number;
115
- rowKeyGetter: (row: R) => string;
116
- gridTemplateColumns: string;
117
- };
118
-
119
- export type DataGridContext<R> = Context<DataGridContextProps<R>>;
120
-
121
- export const dataGridSettingCodec = t.partial(
122
- {
123
- width: t.number,
124
- order: t.number,
125
- },
126
- 'DataGridSetting'
127
- );
128
- export const dataGridSettingsCodec = t.record(
129
- t.string,
130
- dataGridSettingCodec,
131
- 'DataGridSettings'
132
- );
133
- export const dataGridSettingsByNameCodec = t.record(
134
- t.string,
135
- dataGridSettingsCodec,
136
- 'DataGridSettingsByName'
137
- );
138
-
139
- export type DataGridSetting = t.TypeOf<typeof dataGridSettingCodec>;
140
- export type DataGridSettings = t.TypeOf<typeof dataGridSettingsCodec>;
141
- export type DataGridSettingsByName = t.TypeOf<
142
- typeof dataGridSettingsByNameCodec
143
- >;
144
- export type DataGridSettingsTuple = [string, DataGridSetting];
145
- export type DataGridSettingsArray = DataGridSettingsTuple[];
146
- export type DataGridColumnKeyValuePair<R> = [string, DataGridColumn<R>];
147
-
148
- export type DataGridCellProps<R> = {
149
- row: R;
150
- rowIndex: number;
151
- columnKey: string;
152
- columnIndex: number;
153
- column: DataGridColumn<R>;
154
- context: DataGridContext<R>;
155
- className?: string;
156
- style?: CSSProperties;
157
- };
158
-
159
- export type DataGridHeaderCellProps<R> = {
160
- columnKey: string;
161
- columnIndex: number;
162
- column: DataGridColumn<R>;
163
- context: DataGridContext<R>;
164
- onFilterButtonClicked?: (columnKey: string) => void;
165
- isFilterOpen?: boolean;
166
- };
167
-
168
- export type DataGridSort = 'asc' | 'desc';
169
-
170
- export type DataGridFilterPredicate<T> = (valueToVerify: T) => boolean;
171
- export type DataGridFilterPredicateBuilder<T> = (
172
- ...filterValues: T[]
173
- ) => DataGridFilterPredicate<T>;
174
-
175
- export type DataGridFilterOperators<K extends string, T> = {
176
- [key in K]: DataGridFilterPredicateBuilder<T>;
177
- };
178
-
179
- export type DataGridFilterPredicates = {
180
- text: DataGridFilterOperators<
181
- | 'contains'
182
- | 'notContains'
183
- | 'equals'
184
- | 'notEquals'
185
- | 'startsWith'
186
- | 'endsWith'
187
- | 'inArray',
188
- string
189
- >;
190
- number: DataGridFilterOperators<
191
- | 'equals'
192
- | 'notEquals'
193
- | 'lessThan'
194
- | 'lessThanOrEqual'
195
- | 'greaterThan'
196
- | 'greaterThanOrEqual'
197
- | 'inRange'
198
- | 'inArray',
199
- number
200
- >;
201
- };
202
-
203
- export type DataGridFilterType = keyof DataGridFilterPredicates;
204
- export type DataGridFilterDataType<T extends DataGridFilterType> =
205
- DataGridFilterPredicates[T] extends DataGridFilterOperators<string, infer U>
206
- ? U
207
- : never;
208
-
209
- export type DataGridFilterGetter<T extends DataGridFilterType> = (
210
- value: any
211
- ) => DataGridFilterDataType<T> | null;
212
- export type DataGridFilterFormatter = (value: any) => ReactNode;
213
-
214
- export type DataGridFilterOperator<T extends DataGridFilterType> =
215
- DataGridFilterPredicates[T] extends DataGridFilterOperators<infer K, any>
216
- ? K
217
- : never;
218
-
219
- export type DataGridFilter<T extends string = DataGridFilterType> =
220
- T extends DataGridFilterType
221
- ? {
222
- type: T;
223
- operator: DataGridFilterOperator<T>;
224
- getter: DataGridFilterGetter<T>;
225
- formatter?: DataGridFilterFormatter;
226
- values: (DataGridFilterDataType<T> | null)[];
227
- }
228
- : never;
229
-
230
- export type DataGridFilterGroup<R> = {
231
- name: string;
232
- values?: R[];
233
- groups?: DataGridFilterGroup<R>[];
234
- };
235
-
236
- export type DataGridFilterCheckbox<R extends string | number | null> = {
237
- displayValue: string | null;
238
- values: R[];
239
- level: number;
240
- };
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
+ | 'count'
27
+ | 'max'
28
+ | 'min'
29
+ | 'sum';
30
+ export type DataGridFooterFunction<R> = (
31
+ allRows: R[],
32
+ filteredRows: R[],
33
+ selectedRows: R[]
34
+ ) => ReactNode;
35
+
36
+ export type DataGridColumn<R> = {
37
+ component?: DataGridCellFC;
38
+ editable?: boolean;
39
+ excelFormatter?: (value: any) => string;
40
+ excelValue?: (value: any) => string;
41
+ filter?: DataGridFilter;
42
+ footer?:
43
+ | DataGridFooterFunction<R>
44
+ | Record<string, DataGridFooterFunction<R> | null>;
45
+ getter?: (row: R) => string | number;
46
+ name: string;
47
+ order?: number;
48
+ propertyName?: keyof R;
49
+ render?: (row: R, column: DataGridColumn<R>) => ReactNode | string;
50
+ resizable?: boolean;
51
+ sortGetter?: (row: R) => string | number;
52
+ type?: 'text' | 'number' | 'date';
53
+ width?: number;
54
+ settingsContext?: Context<SettingsContextProps>;
55
+ };
56
+
57
+ export type DataGridColumns<R> = Record<string, DataGridColumn<R>>;
58
+
59
+ export type DataGridFilters = Record<
60
+ string,
61
+ DataGridFilter<DataGridFilterType>
62
+ >;
63
+
64
+ export type DataGridProps<R> = {
65
+ name?: string;
66
+ className?: string;
67
+ rows: R[];
68
+ columns: DataGridColumns<R>;
69
+ rowKey: keyof R | ((row: R) => string);
70
+ selectable?: boolean;
71
+ editable?: boolean;
72
+ onRowDoubleClick?: (row: R, e: MouseEvent) => void;
73
+ onSelectionChange?: (keys: string[]) => void;
74
+ getAllIds?: () => Promise<string[]>;
75
+ onFiltersChanged?: (filters: DataGridFilters) => void;
76
+ onSortsChanged?: (sorts: Record<string, DataGridSort>) => void;
77
+ onVisibleRowsChange?: (startIndex: number, length: number) => void;
78
+ onCellEdited?: (row: R, columnKey: string, value: any) => void;
79
+ rowClassNameGetter?: (row: R | null) => {
80
+ className?: string;
81
+ style?: CSSProperties;
82
+ };
83
+ headerRowHeight?: number;
84
+ rowHeight?: number;
85
+ filter?: boolean;
86
+ sort?: boolean;
87
+ initialSorts?: Record<string, DataGridSort>;
88
+ initialFooters?: Record<string, string>;
89
+ onFootersChanged?: (footers: Record<string, string>) => void;
90
+ filterValuesLoader?: (
91
+ columnKey: string
92
+ ) => Promise<(string | number | null)[]>;
93
+ // copyTableHandler?: (
94
+ // includeHeaders?: boolean,
95
+ // includeFooters?: boolean
96
+ // ) => Promise<void>;
97
+ loadCopyRows?: () => Promise<R[]>;
98
+ refresh?: () => void;
99
+ headerColor?: ThemeColor;
100
+ };
101
+
102
+ export type DataGridContextProps<R> = DataGridProps<R> & {
103
+ editingCell?: [number, number];
104
+ setEditingCell: Dispatch<SetStateAction<[number, number]>>;
105
+ sortedRows: R[];
106
+ selectedRows: R[];
107
+ selectedKeys: string[];
108
+ setSelectedKeys: (selection: string[]) => void;
109
+ sorts?: Record<string, DataGridSort>;
110
+ setSorts: (sorts: Record<string, DataGridSort>) => void;
111
+ filters?: DataGridFilters;
112
+ setFilters: Dispatch<SetStateAction<DataGridFilters>>;
113
+ footers?: Record<string, string>;
114
+ setFooters: Dispatch<SetStateAction<Record<string, string>>>;
115
+ footerFunctions?: Record<string, DataGridFooterFunction<R>>;
116
+ visibleColumns: DataGridColumnKeyValuePair<R>[];
117
+ copyTable: (
118
+ includeHeaders?: boolean,
119
+ includeFooters?: boolean
120
+ ) => Promise<void>;
121
+ setColumnWidth: (key: string, width: number) => void;
122
+ saveSettings: (newSettings?: DataGridSettings) => void;
123
+ settings: DataGridSettings;
124
+ setSettings: Dispatch<SetStateAction<DataGridSettings>>;
125
+ visibleRows: R[];
126
+ scrollableRef: React.RefObject<HTMLDivElement>;
127
+ onScroll: (e: React.UIEvent<HTMLDivElement>) => void;
128
+ index: number;
129
+ length: number;
130
+ rowKeyGetter: (row: R) => string;
131
+ gridTemplateColumns: string;
132
+ };
133
+
134
+ export type DataGridContext<R> = Context<DataGridContextProps<R>>;
135
+
136
+ export const dataGridSettingCodec = t.partial(
137
+ {
138
+ width: t.number,
139
+ order: t.number,
140
+ },
141
+ 'DataGridSetting'
142
+ );
143
+ export const dataGridSettingsCodec = t.record(
144
+ t.string,
145
+ dataGridSettingCodec,
146
+ 'DataGridSettings'
147
+ );
148
+ export const dataGridSettingsByNameCodec = t.record(
149
+ t.string,
150
+ dataGridSettingsCodec,
151
+ 'DataGridSettingsByName'
152
+ );
153
+
154
+ export type DataGridSetting = t.TypeOf<typeof dataGridSettingCodec>;
155
+ export type DataGridSettings = t.TypeOf<typeof dataGridSettingsCodec>;
156
+ export type DataGridSettingsByName = t.TypeOf<
157
+ typeof dataGridSettingsByNameCodec
158
+ >;
159
+ export type DataGridSettingsTuple = [string, DataGridSetting];
160
+ export type DataGridSettingsArray = DataGridSettingsTuple[];
161
+ export type DataGridColumnKeyValuePair<R> = [string, DataGridColumn<R>];
162
+
163
+ export type DataGridCellProps<R> = {
164
+ row: R;
165
+ rowIndex: number;
166
+ columnKey: string;
167
+ columnIndex: number;
168
+ column: DataGridColumn<R>;
169
+ context: DataGridContext<R>;
170
+ className?: string;
171
+ style?: CSSProperties;
172
+ };
173
+
174
+ export type DataGridHeaderCellProps<R> = {
175
+ columnKey: string;
176
+ columnIndex: number;
177
+ column: DataGridColumn<R>;
178
+ context: DataGridContext<R>;
179
+ onFilterButtonClicked?: (columnKey: string) => void;
180
+ isFilterOpen?: boolean;
181
+ };
182
+
183
+ export type DataGridSort = 'asc' | 'desc';
184
+
185
+ export type DataGridFilterPredicate<T> = (valueToVerify: T) => boolean;
186
+ export type DataGridFilterPredicateBuilder<T> = (
187
+ ...filterValues: T[]
188
+ ) => DataGridFilterPredicate<T>;
189
+
190
+ export type DataGridFilterOperators<K extends string, T> = {
191
+ [key in K]: DataGridFilterPredicateBuilder<T>;
192
+ };
193
+
194
+ export type DataGridFilterPredicates = {
195
+ text: DataGridFilterOperators<
196
+ | 'contains'
197
+ | 'notContains'
198
+ | 'equals'
199
+ | 'notEquals'
200
+ | 'startsWith'
201
+ | 'endsWith'
202
+ | 'inArray',
203
+ string
204
+ >;
205
+ number: DataGridFilterOperators<
206
+ | 'equals'
207
+ | 'notEquals'
208
+ | 'lessThan'
209
+ | 'lessThanOrEqual'
210
+ | 'greaterThan'
211
+ | 'greaterThanOrEqual'
212
+ | 'inRange'
213
+ | 'inArray',
214
+ number
215
+ >;
216
+ };
217
+
218
+ export type DataGridFilterType = keyof DataGridFilterPredicates;
219
+ export type DataGridFilterDataType<T extends DataGridFilterType> =
220
+ DataGridFilterPredicates[T] extends DataGridFilterOperators<string, infer U>
221
+ ? U
222
+ : never;
223
+
224
+ export type DataGridFilterGetter<T extends DataGridFilterType> = (
225
+ value: any
226
+ ) => DataGridFilterDataType<T> | null;
227
+ export type DataGridFilterRenderer = (value: any) => ReactNode;
228
+ export type DataGridFilterFormatter = (value: any) => string;
229
+
230
+ export type DataGridFilterOperator<T extends DataGridFilterType> =
231
+ DataGridFilterPredicates[T] extends DataGridFilterOperators<infer K, any>
232
+ ? K
233
+ : never;
234
+
235
+ export type DataGridFilter<T extends string = DataGridFilterType> =
236
+ T extends DataGridFilterType
237
+ ? {
238
+ type: T;
239
+ operator: DataGridFilterOperator<T>;
240
+ getter: DataGridFilterGetter<T>;
241
+ renderer?: DataGridFilterRenderer;
242
+ formatter?: DataGridFilterFormatter;
243
+ values: (DataGridFilterDataType<T> | null)[];
244
+ }
245
+ : never;
246
+
247
+ export type DataGridFilterGroup = {
248
+ name: string;
249
+ values?: (string | number | null)[];
250
+ groups?: DataGridFilterGroup[];
251
+ };
252
+
253
+ export type DataGridFilterValue = string | number | null;
254
+
255
+ export type DataGridFilterCheckbox = {
256
+ displayValue: ReactNode;
257
+ title: string;
258
+ value: DataGridFilterValue;
259
+ level: number;
260
+ };