@addev-be/ui 0.2.2 → 0.2.6

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