@addev-be/ui 0.2.5 → 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 (133) 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/DataGrid/AdvancedRequestDataGrid.d.ts +1 -2
  18. package/dist/components/data/DataGrid/AdvancedRequestDataGrid.js +3 -5
  19. package/dist/components/data/DataGrid/DataGridCell.d.ts +1 -1
  20. package/dist/components/data/DataGrid/DataGridCell.js +5 -5
  21. package/dist/components/data/DataGrid/DataGridEditableCell.js +2 -7
  22. package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +10 -8
  23. package/dist/components/data/DataGrid/DataGridFooter.js +4 -14
  24. package/dist/components/data/DataGrid/DataGridHeader.js +1 -3
  25. package/dist/components/data/DataGrid/DataGridHeaderCell.js +6 -5
  26. package/dist/components/data/DataGrid/FilterModalContent/index.d.ts +5 -5
  27. package/dist/components/data/DataGrid/FilterModalContent/index.js +11 -9
  28. package/dist/components/data/DataGrid/FilterValuesScroller.d.ts +8 -7
  29. package/dist/components/data/DataGrid/FilterValuesScroller.js +5 -6
  30. package/dist/components/data/DataGrid/helpers/columns.js +1 -4
  31. package/dist/components/data/DataGrid/helpers/filters.d.ts +4 -3
  32. package/dist/components/data/DataGrid/helpers/filters.js +13 -5
  33. package/dist/components/data/DataGrid/hooks/useDataGrid.js +2 -2
  34. package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +0 -1
  35. package/dist/components/data/DataGrid/hooks/useDataGridSettings.js +0 -1
  36. package/dist/components/data/DataGrid/index.js +16 -5
  37. package/dist/components/data/DataGrid/styles.d.ts +4 -1
  38. package/dist/components/data/DataGrid/styles.js +11 -8
  39. package/dist/components/data/DataGrid/types.d.ts +20 -15
  40. package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +7 -9
  41. package/dist/components/data/SqlRequestDataGrid/index.js +34 -18
  42. package/dist/components/data/SqlRequestDataGrid/types.d.ts +1 -0
  43. package/dist/components/data/index.d.ts +2 -0
  44. package/dist/components/data/index.js +2 -0
  45. package/dist/helpers/dates.d.ts +2 -0
  46. package/dist/helpers/dates.js +13 -0
  47. package/package.json +1 -1
  48. package/src/Icons.tsx +80 -80
  49. package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +93 -93
  50. package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +262 -262
  51. package/src/components/data/AdvancedRequestDataGrid/helpers/index.ts +2 -2
  52. package/src/components/data/AdvancedRequestDataGrid/index.tsx +269 -269
  53. package/src/components/data/AdvancedRequestDataGrid/types.ts +47 -47
  54. package/src/components/data/DataGrid/DataGridCell.tsx +73 -73
  55. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +14 -14
  56. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +58 -58
  57. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +181 -181
  58. package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +104 -104
  59. package/src/components/data/DataGrid/DataGridEditableCell.tsx +43 -54
  60. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +75 -75
  61. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +200 -190
  62. package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +100 -100
  63. package/src/components/data/DataGrid/DataGridFooter.tsx +44 -64
  64. package/src/components/data/DataGrid/DataGridHeader.tsx +126 -126
  65. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +167 -167
  66. package/src/components/data/DataGrid/FilterModalContent/index.tsx +124 -125
  67. package/src/components/data/DataGrid/FilterModalContent/styles.ts +22 -22
  68. package/src/components/data/DataGrid/FilterValuesScroller.tsx +133 -131
  69. package/src/components/data/DataGrid/VirtualScroller.tsx +46 -46
  70. package/src/components/data/DataGrid/helpers/columns.tsx +196 -196
  71. package/src/components/data/DataGrid/helpers/filters.ts +220 -207
  72. package/src/components/data/DataGrid/helpers/index.ts +2 -2
  73. package/src/components/data/DataGrid/hooks/index.ts +30 -30
  74. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +264 -264
  75. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +165 -165
  76. package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +48 -48
  77. package/src/components/data/DataGrid/index.tsx +132 -132
  78. package/src/components/data/DataGrid/styles.ts +326 -326
  79. package/src/components/data/DataGrid/types.ts +241 -240
  80. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +224 -224
  81. package/src/components/data/SqlRequestDataGrid/helpers/index.ts +2 -2
  82. package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +16 -16
  83. package/src/components/data/SqlRequestDataGrid/index.tsx +252 -252
  84. package/src/components/data/SqlRequestDataGrid/types.ts +47 -47
  85. package/src/components/data/index.ts +8 -8
  86. package/src/components/forms/Button.tsx +99 -99
  87. package/src/components/forms/IconButton.tsx +56 -56
  88. package/src/components/forms/IndeterminateCheckbox.tsx +46 -46
  89. package/src/components/forms/Select.tsx +40 -40
  90. package/src/components/forms/index.ts +5 -5
  91. package/src/components/forms/styles.ts +20 -20
  92. package/src/components/index.ts +3 -3
  93. package/src/components/layout/Dropdown/index.tsx +79 -79
  94. package/src/components/layout/Dropdown/styles.ts +44 -44
  95. package/src/components/layout/Loading/index.tsx +29 -29
  96. package/src/components/layout/Loading/styles.ts +29 -29
  97. package/src/components/layout/Modal/index.tsx +51 -51
  98. package/src/components/layout/Modal/styles.ts +110 -110
  99. package/src/components/layout/index.ts +3 -3
  100. package/src/config/index.ts +14 -14
  101. package/src/helpers/dates.ts +9 -9
  102. package/src/helpers/getScrollbarSize.ts +14 -14
  103. package/src/helpers/numbers.ts +20 -20
  104. package/src/hooks/index.ts +2 -2
  105. package/src/hooks/useElementSize.ts +24 -24
  106. package/src/hooks/useWindowSize.ts +20 -20
  107. package/src/index.ts +7 -7
  108. package/src/providers/PortalsProvider/index.tsx +54 -54
  109. package/src/providers/PortalsProvider/styles.ts +27 -27
  110. package/src/providers/SettingsProvider/index.tsx +70 -70
  111. package/src/providers/ThemeProvider/ThemeProvider.ts +55 -55
  112. package/src/providers/ThemeProvider/defaultTheme.ts +444 -444
  113. package/src/providers/ThemeProvider/index.ts +3 -3
  114. package/src/providers/ThemeProvider/types.ts +123 -123
  115. package/src/providers/UiProviders/index.tsx +65 -65
  116. package/src/providers/UiProviders/styles.ts +10 -10
  117. package/src/providers/hooks.ts +8 -8
  118. package/src/providers/index.ts +5 -5
  119. package/src/services/HttpService.ts +80 -80
  120. package/src/services/WebSocketService.ts +147 -147
  121. package/src/services/advancedRequests.ts +101 -101
  122. package/src/services/base.ts +31 -31
  123. package/src/services/hooks.ts +23 -23
  124. package/src/services/index.ts +2 -2
  125. package/src/services/sqlRequests.ts +99 -99
  126. package/src/styles/animations.scss +30 -30
  127. package/src/styles/index.scss +42 -42
  128. package/src/typings.d.ts +6 -6
  129. package/tsconfig.tsbuildinfo +1 -1
  130. package/dist/components/data/DataGrid/helpers.d.ts +0 -28
  131. package/dist/components/data/DataGrid/helpers.js +0 -436
  132. package/dist/config/types.d.ts +0 -11
  133. package/dist/config/types.js +0 -2
@@ -1,240 +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
- 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 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
+ };