@addev-be/ui 0.2.13 → 0.2.15
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.
- package/dist/Icons.d.ts +3 -1
- package/dist/Icons.js +5 -1
- package/dist/components/data/DataGrid/{FilterValuesScroller.d.ts → DataGridFilterMenu/FilterValuesScroller.d.ts} +1 -1
- package/dist/components/data/DataGrid/{FilterValuesScroller.js → DataGridFilterMenu/FilterValuesScroller.js} +6 -9
- package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +3 -3
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +9 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.js +12 -2
- package/dist/components/data/DataGrid/FilterModalContent/index.js +18 -9
- package/dist/components/data/DataGrid/helpers/columns.d.ts +1 -0
- package/dist/components/data/DataGrid/helpers/columns.js +7 -6
- package/dist/components/data/DataGrid/helpers/filters.d.ts +1 -0
- package/dist/components/data/DataGrid/helpers/filters.js +71 -2
- package/dist/components/data/DataGrid/hooks/useDataGrid.js +2 -1
- package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +2 -0
- package/dist/components/data/DataGrid/styles.d.ts +0 -9
- package/dist/components/data/DataGrid/styles.js +2 -12
- package/dist/components/data/DataGrid/types.d.ts +2 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +6 -6
- package/dist/helpers/numbers.d.ts +1 -0
- package/dist/helpers/numbers.js +9 -1
- package/dist/services/globalSearch.d.ts +13 -0
- package/dist/services/globalSearch.js +8 -0
- package/package.json +18 -12
- package/dist/components/data/DataGrid/AdvancedRequestDataGrid.d.ts +0 -9
- package/dist/components/data/DataGrid/AdvancedRequestDataGrid.js +0 -171
- package/dist/components/data/DataGrid/helpers/advancedRequests.d.ts +0 -12
- package/dist/components/data/DataGrid/helpers/advancedRequests.js +0 -53
- package/eslint.config.js +0 -28
- package/src/Icons.tsx +0 -108
- package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +0 -93
- package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +0 -262
- package/src/components/data/AdvancedRequestDataGrid/helpers/index.ts +0 -2
- package/src/components/data/AdvancedRequestDataGrid/index.tsx +0 -267
- package/src/components/data/AdvancedRequestDataGrid/types.ts +0 -47
- package/src/components/data/DataGrid/DataGridCell.tsx +0 -73
- package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +0 -14
- package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +0 -59
- package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +0 -181
- package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +0 -104
- package/src/components/data/DataGrid/DataGridEditableCell.tsx +0 -43
- package/src/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.tsx +0 -120
- package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +0 -75
- package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +0 -360
- package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +0 -96
- package/src/components/data/DataGrid/DataGridFooter.tsx +0 -42
- package/src/components/data/DataGrid/DataGridHeader.tsx +0 -126
- package/src/components/data/DataGrid/DataGridHeaderCell.tsx +0 -132
- package/src/components/data/DataGrid/FilterModalContent/index.tsx +0 -136
- package/src/components/data/DataGrid/FilterModalContent/styles.ts +0 -22
- package/src/components/data/DataGrid/VirtualScroller.tsx +0 -46
- package/src/components/data/DataGrid/helpers/columns.tsx +0 -295
- package/src/components/data/DataGrid/helpers/filters.ts +0 -287
- package/src/components/data/DataGrid/helpers/index.ts +0 -2
- package/src/components/data/DataGrid/hooks/index.ts +0 -30
- package/src/components/data/DataGrid/hooks/useDataGrid.tsx +0 -306
- package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +0 -175
- package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +0 -48
- package/src/components/data/DataGrid/index.tsx +0 -140
- package/src/components/data/DataGrid/styles.ts +0 -323
- package/src/components/data/DataGrid/types.ts +0 -267
- package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +0 -277
- package/src/components/data/SqlRequestDataGrid/helpers/index.ts +0 -2
- package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +0 -16
- package/src/components/data/SqlRequestDataGrid/index.tsx +0 -347
- package/src/components/data/SqlRequestDataGrid/types.ts +0 -47
- package/src/components/data/index.ts +0 -8
- package/src/components/forms/Button.tsx +0 -99
- package/src/components/forms/IconButton.tsx +0 -56
- package/src/components/forms/IndeterminateCheckbox.tsx +0 -46
- package/src/components/forms/Select.tsx +0 -40
- package/src/components/forms/index.ts +0 -5
- package/src/components/forms/styles.ts +0 -20
- package/src/components/index.ts +0 -3
- package/src/components/layout/Dropdown/index.tsx +0 -79
- package/src/components/layout/Dropdown/styles.ts +0 -44
- package/src/components/layout/Loading/index.tsx +0 -29
- package/src/components/layout/Loading/styles.ts +0 -29
- package/src/components/layout/Modal/index.tsx +0 -51
- package/src/components/layout/Modal/styles.ts +0 -110
- package/src/components/layout/index.ts +0 -3
- package/src/components/ui/ContextMenu/index.tsx +0 -79
- package/src/components/ui/ContextMenu/styles.ts +0 -119
- package/src/config/index.ts +0 -14
- package/src/helpers/dates.ts +0 -9
- package/src/helpers/getScrollbarSize.ts +0 -14
- package/src/helpers/numbers.ts +0 -26
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useElementSize.ts +0 -24
- package/src/hooks/useWindowSize.ts +0 -20
- package/src/index.ts +0 -7
- package/src/providers/PortalsProvider/index.tsx +0 -54
- package/src/providers/PortalsProvider/styles.ts +0 -27
- package/src/providers/SettingsProvider/index.tsx +0 -70
- package/src/providers/ThemeProvider/ThemeProvider.ts +0 -55
- package/src/providers/ThemeProvider/defaultTheme.ts +0 -444
- package/src/providers/ThemeProvider/index.ts +0 -3
- package/src/providers/ThemeProvider/types.ts +0 -123
- package/src/providers/UiProviders/index.tsx +0 -65
- package/src/providers/UiProviders/styles.ts +0 -10
- package/src/providers/hooks.ts +0 -8
- package/src/providers/index.ts +0 -5
- package/src/services/HttpService.ts +0 -80
- package/src/services/WebSocketService.ts +0 -147
- package/src/services/advancedRequests.ts +0 -101
- package/src/services/base.ts +0 -31
- package/src/services/globalSearch.ts +0 -27
- package/src/services/hooks.ts +0 -23
- package/src/services/index.ts +0 -2
- package/src/services/sqlRequests.ts +0 -110
- package/src/styles/animations.scss +0 -30
- package/src/styles/index.scss +0 -42
- package/src/typings.d.ts +0 -6
- package/tsconfig.json +0 -18
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,267 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
import { SqlRequestDataGridColumn, SqlRequestDataGridColumns } from '../types';
|
|
4
|
-
import {
|
|
5
|
-
buildExcelFormat,
|
|
6
|
-
numberFilter,
|
|
7
|
-
textFilter,
|
|
8
|
-
} from '../../DataGrid/helpers';
|
|
9
|
-
import {
|
|
10
|
-
formatMoney,
|
|
11
|
-
formatNumber,
|
|
12
|
-
formatNumberInvariant,
|
|
13
|
-
formatPercentage,
|
|
14
|
-
} from '../../../../helpers/numbers';
|
|
15
|
-
|
|
16
|
-
import { formatDate } from '../../../../helpers/dates';
|
|
17
|
-
|
|
18
|
-
export const sqlTextColumn = <R extends Record<string, any>>(
|
|
19
|
-
key: string,
|
|
20
|
-
title: string,
|
|
21
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
22
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
23
|
-
[key]: {
|
|
24
|
-
name: title,
|
|
25
|
-
render: (row) => row[key] ?? '',
|
|
26
|
-
getter: (row) => row[key] ?? '',
|
|
27
|
-
sortGetter: (row) => row[key] ?? '',
|
|
28
|
-
filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
|
|
29
|
-
...options,
|
|
30
|
-
footer: (rows) => `${rows[0][key]} éléments`,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Creates a column with a composed value from multiple fields,
|
|
36
|
-
* and filtered by a text filter on the first field
|
|
37
|
-
*/
|
|
38
|
-
export const sqlComposedColumn = <R extends Record<string, any>>(
|
|
39
|
-
key: string,
|
|
40
|
-
title: string,
|
|
41
|
-
fields: string[],
|
|
42
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
43
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
44
|
-
[key]: {
|
|
45
|
-
field: {
|
|
46
|
-
fieldAlias: key,
|
|
47
|
-
operator: 'jsonObject',
|
|
48
|
-
operands: fields.flatMap((field) => [
|
|
49
|
-
{ constantValue: field },
|
|
50
|
-
{ fieldName: field },
|
|
51
|
-
]),
|
|
52
|
-
},
|
|
53
|
-
name: title,
|
|
54
|
-
render: (row) => row[key] ?? '',
|
|
55
|
-
getter: (row) => row[key] ?? '',
|
|
56
|
-
sortGetter: (row) => row[key] ?? '',
|
|
57
|
-
filter: {
|
|
58
|
-
...textFilter(fields[0]),
|
|
59
|
-
getter: (value) => value[fields[0]] ?? 0,
|
|
60
|
-
},
|
|
61
|
-
filterField: fields[0],
|
|
62
|
-
sortField: fields[0],
|
|
63
|
-
footer: (rows) => `${rows[0][key]} éléments`,
|
|
64
|
-
...options,
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
export const sqlMailColumn = <R extends Record<string, any>>(
|
|
69
|
-
key: string,
|
|
70
|
-
title: string,
|
|
71
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
72
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
73
|
-
[key]: {
|
|
74
|
-
name: title,
|
|
75
|
-
render: (row) => <a href={`mailto:${row[key]}`}>{row[key] ?? ''}</a>,
|
|
76
|
-
getter: (row) => row[key] ?? '',
|
|
77
|
-
sortGetter: (row) => row[key] ?? '',
|
|
78
|
-
filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
|
|
79
|
-
footer: (rows) => `${rows[0][key]} éléments`,
|
|
80
|
-
...options,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
export const sqlPhoneColumn = <R extends Record<string, any>>(
|
|
85
|
-
key: string,
|
|
86
|
-
title: string,
|
|
87
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
88
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
89
|
-
[key]: {
|
|
90
|
-
name: title,
|
|
91
|
-
render: (row) => <a href={`tel:${row[key]}`}>{row[key] ?? ''}</a>,
|
|
92
|
-
getter: (row) => row[key] ?? '',
|
|
93
|
-
sortGetter: (row) => row[key] ?? '',
|
|
94
|
-
filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
|
|
95
|
-
footer: (rows) => `${rows[0][key]} éléments`,
|
|
96
|
-
...options,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
export const sqlDateColumn = <R extends Record<string, any>>(
|
|
101
|
-
key: string,
|
|
102
|
-
title: string,
|
|
103
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
104
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
105
|
-
[key]: {
|
|
106
|
-
name: title,
|
|
107
|
-
type: 'date',
|
|
108
|
-
render: (row) => formatDate(row[key]),
|
|
109
|
-
getter: (row) => row[key] ?? '',
|
|
110
|
-
sortGetter: (row) => row[key] ?? '',
|
|
111
|
-
excelFormatter: () => 'dd/mm/yyyy',
|
|
112
|
-
excelValue: (value) => formatDate(value, 'YYYY-MM-DD'),
|
|
113
|
-
filter: {
|
|
114
|
-
...textFilter(key),
|
|
115
|
-
getter: (value) => value[key] ?? '',
|
|
116
|
-
formatter: (value) => formatDate(value),
|
|
117
|
-
renderer: (value) => formatDate(value),
|
|
118
|
-
},
|
|
119
|
-
footer: (rows) => `${rows[0][key]} éléments`,
|
|
120
|
-
...options,
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
export const sqlMonthColumn = <R extends Record<string, any>>(
|
|
125
|
-
key: string,
|
|
126
|
-
title: string,
|
|
127
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
128
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
129
|
-
[key]: {
|
|
130
|
-
name: title,
|
|
131
|
-
render: (row) => (row[key] ? `${row[key]} mois ` : ''),
|
|
132
|
-
getter: (row) => row[key] ?? '',
|
|
133
|
-
sortGetter: (row) => row[key] ?? '',
|
|
134
|
-
filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
|
|
135
|
-
footer: (rows) => `${rows[0][key]} éléments`,
|
|
136
|
-
...options,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
export const sqlNumberColumn = <R extends Record<string, any>>(
|
|
141
|
-
key: string,
|
|
142
|
-
title: string,
|
|
143
|
-
decimals = 2,
|
|
144
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
145
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
146
|
-
[key]: {
|
|
147
|
-
name: title,
|
|
148
|
-
render: (row) => formatNumber(row[key], decimals) ?? '',
|
|
149
|
-
excelFormatter: () => buildExcelFormat(decimals),
|
|
150
|
-
excelValue: (value) => formatNumberInvariant(value, decimals),
|
|
151
|
-
getter: (row) => row[key] ?? '',
|
|
152
|
-
sortGetter: (row) => row[key] ?? '',
|
|
153
|
-
filter: {
|
|
154
|
-
...numberFilter(key),
|
|
155
|
-
getter: (value) => value[key] ?? 0,
|
|
156
|
-
renderer: (value) => formatNumber(value, decimals) ?? '',
|
|
157
|
-
},
|
|
158
|
-
footer: {
|
|
159
|
-
sum: null,
|
|
160
|
-
avg: null,
|
|
161
|
-
count: null,
|
|
162
|
-
max: null,
|
|
163
|
-
min: null,
|
|
164
|
-
},
|
|
165
|
-
...options,
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
export const sqlMoneyColumn = <R extends Record<string, any>>(
|
|
170
|
-
key: string,
|
|
171
|
-
title: string,
|
|
172
|
-
decimals = 2,
|
|
173
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
174
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
175
|
-
[key]: {
|
|
176
|
-
name: title,
|
|
177
|
-
type: 'number',
|
|
178
|
-
render: (row) => formatMoney(row[key], decimals) ?? '',
|
|
179
|
-
excelFormatter: () => buildExcelFormat(decimals, ' €'),
|
|
180
|
-
excelValue: (value) => formatNumberInvariant(value, decimals),
|
|
181
|
-
getter: (row) => row[key] ?? '',
|
|
182
|
-
sortGetter: (row) => row[key] ?? '',
|
|
183
|
-
filter: {
|
|
184
|
-
...numberFilter(key),
|
|
185
|
-
getter: (value) => value[key] ?? 0,
|
|
186
|
-
renderer: (value) => formatMoney(value, decimals) ?? '',
|
|
187
|
-
},
|
|
188
|
-
footer: {
|
|
189
|
-
sum: null,
|
|
190
|
-
avg: null,
|
|
191
|
-
count: null,
|
|
192
|
-
max: null,
|
|
193
|
-
min: null,
|
|
194
|
-
},
|
|
195
|
-
...options,
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
export const sqlPercentageColumn = <R extends Record<string, any>>(
|
|
200
|
-
key: string,
|
|
201
|
-
title: string,
|
|
202
|
-
decimals = 2,
|
|
203
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
204
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
205
|
-
[key]: {
|
|
206
|
-
name: title,
|
|
207
|
-
render: (row) => formatPercentage(row[key]) ?? '',
|
|
208
|
-
excelFormatter: () => buildExcelFormat(decimals, '%'),
|
|
209
|
-
excelValue: (value) => formatNumberInvariant(value, decimals),
|
|
210
|
-
getter: (row) => row[key] ?? '',
|
|
211
|
-
sortGetter: (row) => row[key] ?? '',
|
|
212
|
-
filter: {
|
|
213
|
-
...numberFilter(key),
|
|
214
|
-
getter: (value) => value[key] ?? 0,
|
|
215
|
-
renderer: (value) => formatPercentage(value, decimals) ?? '',
|
|
216
|
-
},
|
|
217
|
-
...options,
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
export const sqlCheckboxColumn = <R extends Record<string, any>>(
|
|
222
|
-
key: string,
|
|
223
|
-
title: string,
|
|
224
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
225
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
226
|
-
[key]: {
|
|
227
|
-
name: title,
|
|
228
|
-
render: (row) => (
|
|
229
|
-
<>
|
|
230
|
-
<input type="checkbox" checked={row[key]} />
|
|
231
|
-
<span>{row[key] ? ' Oui' : ' Non'}</span>
|
|
232
|
-
</>
|
|
233
|
-
),
|
|
234
|
-
getter: (row) => row[key] ?? '',
|
|
235
|
-
sortGetter: (row) => row[key] ?? '',
|
|
236
|
-
filter: { ...numberFilter(key), getter: (value) => value[key] ?? 0 },
|
|
237
|
-
footer: (rows) => `${rows[0][key]} éléments`,
|
|
238
|
-
...options,
|
|
239
|
-
},
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
export const sqlColorColumn = <R extends Record<string, any>>(
|
|
243
|
-
key: string,
|
|
244
|
-
title: string,
|
|
245
|
-
options?: Partial<SqlRequestDataGridColumn<R>>
|
|
246
|
-
): SqlRequestDataGridColumns<R> => ({
|
|
247
|
-
[key]: {
|
|
248
|
-
name: title,
|
|
249
|
-
render: (row) => (
|
|
250
|
-
<div
|
|
251
|
-
style={{ position: 'absolute', inset: 0, backgroundColor: row[key] }}
|
|
252
|
-
>
|
|
253
|
-
|
|
254
|
-
</div>
|
|
255
|
-
),
|
|
256
|
-
excelValue: () => '',
|
|
257
|
-
excelBackgroundColor: (value) => value,
|
|
258
|
-
getter: (row) => row[key] ?? '',
|
|
259
|
-
sortGetter: (row) => row[key] ?? '',
|
|
260
|
-
filter: {
|
|
261
|
-
...textFilter(key),
|
|
262
|
-
getter: (value) => value[key] ?? '',
|
|
263
|
-
renderer: (value) => (
|
|
264
|
-
<div
|
|
265
|
-
style={{
|
|
266
|
-
backgroundColor: value,
|
|
267
|
-
width: 'var(--space-16)',
|
|
268
|
-
height: '1em',
|
|
269
|
-
}}
|
|
270
|
-
>
|
|
271
|
-
|
|
272
|
-
</div>
|
|
273
|
-
),
|
|
274
|
-
},
|
|
275
|
-
...options,
|
|
276
|
-
},
|
|
277
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
import { ConditionDTO } from '../../../../services/sqlRequests';
|
|
4
|
-
import { SqlRequestDataGridFilters } from '../types';
|
|
5
|
-
import _ from 'lodash';
|
|
6
|
-
|
|
7
|
-
export const convertSqlFiltersToConditions = (
|
|
8
|
-
filters: SqlRequestDataGridFilters
|
|
9
|
-
): Record<string, ConditionDTO> =>
|
|
10
|
-
_.mapValues(filters, (filter, columnKey) => ({
|
|
11
|
-
field: columnKey,
|
|
12
|
-
operator: filter.operator,
|
|
13
|
-
value: ['inArray', 'inRange'].includes(filter.operator)
|
|
14
|
-
? filter.values
|
|
15
|
-
: _.castArray<string | number | null>(filter.values)[0],
|
|
16
|
-
}));
|