@addev-be/ui 0.14.1 → 0.14.2

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 (40) hide show
  1. package/assets/icons/floppy-disk.svg +1 -0
  2. package/package.json +2 -1
  3. package/src/Icons.tsx +2 -0
  4. package/src/components/data/DataGrid/DataGridCell.tsx +3 -3
  5. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +7 -12
  6. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +2 -2
  7. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +31 -30
  8. package/src/components/data/DataGrid/DataGridEditableCell/CheckboxEditableCell.tsx +38 -0
  9. package/src/components/data/DataGrid/DataGridEditableCell/DateEditableCell.tsx +39 -0
  10. package/src/components/data/DataGrid/DataGridEditableCell/NumberEditableCell.tsx +68 -0
  11. package/src/components/data/DataGrid/DataGridEditableCell/TextEditableCell.tsx +38 -0
  12. package/src/components/data/DataGrid/DataGridEditableCell/index.tsx +60 -0
  13. package/src/components/data/DataGrid/DataGridEditableCell/types.ts +14 -0
  14. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +13 -10
  15. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +27 -29
  16. package/src/components/data/DataGrid/DataGridFooter.tsx +3 -3
  17. package/src/components/data/DataGrid/DataGridHeader.tsx +52 -7
  18. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +16 -2
  19. package/src/components/data/DataGrid/DataGridRowTemplate.tsx +23 -16
  20. package/src/components/data/DataGrid/helpers/columns.tsx +238 -236
  21. package/src/components/data/DataGrid/hooks/index.ts +6 -7
  22. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +89 -16
  23. package/src/components/data/DataGrid/hooks/useDataGridChangedRows.ts +56 -0
  24. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +18 -19
  25. package/src/components/data/DataGrid/styles.ts +56 -1
  26. package/src/components/data/DataGrid/types.ts +69 -17
  27. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +240 -216
  28. package/src/components/data/SqlRequestDataGrid/index.tsx +58 -43
  29. package/src/components/data/SqlRequestDataGrid/types.ts +21 -6
  30. package/src/components/data/SqlRequestForeignList/index.tsx +157 -0
  31. package/src/components/data/SqlRequestForeignList/styles.ts +38 -0
  32. package/src/components/data/SqlRequestGrid/filters/FiltersSidebar.tsx +8 -4
  33. package/src/components/data/SqlRequestGrid/index.tsx +24 -18
  34. package/src/components/data/SqlRequestGrid/types.ts +25 -3
  35. package/src/components/data/index.ts +2 -0
  36. package/src/helpers/numbers.ts +37 -0
  37. package/src/services/index.ts +1 -0
  38. package/src/services/updateSqlRequests.ts +34 -0
  39. package/src/components/data/DataGrid/DataGridEditableCell.tsx +0 -43
  40. package/src/components/data/SqlRequestDataGrid/index.ts +0 -1
@@ -1,6 +1,14 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
 
3
- import { DataGridColumn, DataGridColumns, DataGridSettings } from '../types';
3
+ import {
4
+ DataGridCheckboxColumn,
5
+ DataGridColorColumn,
6
+ DataGridColumn,
7
+ DataGridDateColumn,
8
+ DataGridNumberColumn,
9
+ DataGridSettings,
10
+ DataGridTextColumn,
11
+ } from '../types';
4
12
  import { dateFilter, numberFilter, textFilter } from './filters';
5
13
  import {
6
14
  formatMoney,
@@ -22,298 +30,292 @@ export const buildExcelFormat = (decimals = 2, suffix = '') =>
22
30
  export const textColumn = <R extends Record<string, any>>(
23
31
  key: string,
24
32
  title: string,
25
- options?: Partial<DataGridColumn<R>>
26
- ): DataGridColumns<R> => ({
27
- [key]: {
28
- name: title,
29
- render: (row) => row[key] ?? '',
30
- getter: (row) => row[key] ?? '',
31
- sortGetter: (row) => row[key] ?? '',
32
- footer: (_, filteredRows) => `${filteredRows.length} éléments`,
33
- filter: textFilter(key),
34
- ...options,
35
- },
33
+ options?: Partial<DataGridTextColumn<R>>
34
+ ): DataGridTextColumn<R> => ({
35
+ key,
36
+ type: 'text',
37
+ name: title,
38
+ render: (row) => row[key] ?? '',
39
+ getter: (row) => row[key] ?? '',
40
+ sortGetter: (row) => row[key] ?? '',
41
+ footer: (_, filteredRows) => `${filteredRows.length} éléments`,
42
+ filter: textFilter(key),
43
+ ...options,
36
44
  });
37
45
 
38
46
  export const mailColumn = <R extends Record<string, any>>(
39
47
  key: string,
40
48
  title: string,
41
- options?: Partial<DataGridColumn<R>>
42
- ): DataGridColumns<R> => ({
43
- [key]: {
44
- name: title,
45
- render: (row) => (
46
- <a
47
- // className="text-blue-500 hover:text-blue-700"
48
- href={`mailto:${row[key]}`}
49
- >
50
- {row[key] ?? ''}
51
- </a>
52
- ),
53
- getter: (row) => row[key] ?? '',
54
- sortGetter: (row) => row[key] ?? '',
55
- footer: (_, filteredRows) => `${filteredRows.length} éléments`,
56
- filter: textFilter(key),
57
- ...options,
58
- },
49
+ options?: Partial<DataGridTextColumn<R>>
50
+ ): DataGridTextColumn<R> => ({
51
+ key,
52
+ type: 'text',
53
+ name: title,
54
+ render: (row) => <a href={`mailto:${row[key]}`}>{row[key] ?? ''}</a>,
55
+ getter: (row) => row[key] ?? '',
56
+ sortGetter: (row) => row[key] ?? '',
57
+ footer: (_, filteredRows) => `${filteredRows.length} éléments`,
58
+ filter: textFilter(key),
59
+ ...options,
59
60
  });
60
61
 
61
62
  export const phoneColumn = <R extends Record<string, any>>(
62
63
  key: string,
63
64
  title: string,
64
- options?: Partial<DataGridColumn<R>>
65
- ): DataGridColumns<R> => ({
66
- [key]: {
67
- name: title,
68
- render: (row) => (
69
- <a
70
- // className="text-blue-500 hover:text-blue-700"
71
- href={`tel:${row[key]}`}
72
- >
73
- {row[key] ?? ''}
74
- </a>
75
- ),
76
- getter: (row) => row[key] ?? '',
77
- sortGetter: (row) => row[key] ?? '',
78
- footer: (_, filteredRows) => `${filteredRows.length} éléments`,
79
- filter: textFilter(key),
80
- ...options,
81
- },
65
+ options?: Partial<DataGridTextColumn<R>>
66
+ ): DataGridTextColumn<R> => ({
67
+ key,
68
+ type: 'text',
69
+ name: title,
70
+ render: (row) => <a href={`tel:${row[key]}`}>{row[key] ?? ''}</a>,
71
+ getter: (row) => row[key] ?? '',
72
+ sortGetter: (row) => row[key] ?? '',
73
+ footer: (_, filteredRows) => `${filteredRows.length} éléments`,
74
+ filter: textFilter(key),
75
+ ...options,
82
76
  });
83
77
 
84
78
  export const dateColumn = <R extends Record<string, any>>(
85
79
  key: string,
86
80
  title: string,
87
- options?: Partial<DataGridColumn<R>>
88
- ): DataGridColumns<R> => ({
89
- [key]: {
90
- name: title,
91
- type: 'date',
92
- render: (row) => moment(row[key]).format('DD/MM/YYYY') ?? '',
93
- excelFormatter: () => 'dd/mm/yyyy',
94
- excelValue: (date) => moment(date).format('DD/MM/YYYY') ?? '',
95
- getter: (row) => row[key] ?? '',
96
- sortGetter: (row) => row[key] ?? '',
97
- footer: (_, filteredRows) => `${filteredRows.length} éléments`,
98
- filter: {
99
- ...dateFilter(key),
100
- renderer: (value) => moment(value).format('DD/MM/YYYY') ?? '',
101
- },
102
- ...options,
81
+ options?: Partial<DataGridDateColumn<R>>
82
+ ): DataGridDateColumn<R> => ({
83
+ key,
84
+ type: 'date',
85
+ name: title,
86
+ render: (row) => moment(row[key]).format('DD/MM/YYYY') ?? '',
87
+ excelOptions: {
88
+ formatter: () => 'dd/mm/yyyy',
89
+ valueGetter: (value) => moment(value).format('DD/MM/YYYY') ?? '',
103
90
  },
91
+ getter: (row) => row[key] ?? '',
92
+ sortGetter: (row) => row[key] ?? '',
93
+ footer: (_, filteredRows) => `${filteredRows.length} éléments`,
94
+ filter: {
95
+ ...dateFilter(key),
96
+ renderer: (value) => moment(value).format('DD/MM/YYYY') ?? '',
97
+ },
98
+ ...options,
104
99
  });
105
100
 
106
101
  export const dateTimeColumn = <R extends Record<string, any>>(
107
102
  key: string,
108
103
  title: string,
109
- options?: Partial<DataGridColumn<R>>
110
- ): DataGridColumns<R> => ({
111
- [key]: {
112
- name: title,
113
- type: 'date',
114
- render: (row) => moment(row[key]).format('DD/MM/YYYY HH:mm:ss') ?? '',
115
- excelFormatter: () => 'dd/mm/yyyy hh:mm:ss',
116
- excelValue: (date) => moment(date).format('DD/MM/YYYY HH:mm:ss') ?? '',
117
- getter: (row) => row[key] ?? '',
118
- sortGetter: (row) => row[key] ?? '',
119
- footer: (_, filteredRows) => `${filteredRows.length} éléments`,
120
- filter: {
121
- ...dateFilter(key),
122
- renderer: (value) => moment(value).format('DD/MM/YYYY HH:mm:ss') ?? '',
123
- },
124
- ...options,
104
+ options?: Partial<DataGridDateColumn<R>>
105
+ ): DataGridDateColumn<R> => ({
106
+ key,
107
+ type: 'date',
108
+ name: title,
109
+ render: (row) => moment(row[key]).format('DD/MM/YYYY HH:mm:ss') ?? '',
110
+ excelOptions: {
111
+ formatter: () => 'dd/mm/yyyy hh:mm:ss',
112
+ valueGetter: (value) => moment(value).format('DD/MM/YYYY HH:mm:ss') ?? '',
113
+ },
114
+ getter: (row) => row[key] ?? '',
115
+ sortGetter: (row) => row[key] ?? '',
116
+ footer: (_, filteredRows) => `${filteredRows.length} éléments`,
117
+ filter: {
118
+ ...dateFilter(key),
119
+ renderer: (value) => moment(value).format('DD/MM/YYYY HH:mm:ss') ?? '',
125
120
  },
121
+ ...options,
126
122
  });
127
123
 
128
124
  export const monthColumn = <R extends Record<string, any>>(
129
125
  key: string,
130
126
  title: string,
131
- options?: Partial<DataGridColumn<R>>
132
- ): DataGridColumns<R> => ({
133
- [key]: {
134
- name: title,
135
- render: (row) => (row[key] ? `${row[key]} mois ` : ''),
136
- getter: (row) => row[key] ?? '',
137
- sortGetter: (row) => row[key] ?? '',
138
- footer: (_, filteredRows) => `${filteredRows.length} éléments`,
139
- filter: textFilter(key),
140
- ...options,
141
- },
127
+ options?: Partial<DataGridTextColumn<R>>
128
+ ): DataGridTextColumn<R> => ({
129
+ key,
130
+ type: 'text',
131
+ name: title,
132
+ render: (row) => (row[key] ? `${row[key]} mois ` : ''),
133
+ getter: (row) => row[key] ?? '',
134
+ sortGetter: (row) => row[key] ?? '',
135
+ footer: (_, filteredRows) => `${filteredRows.length} éléments`,
136
+ filter: textFilter(key),
137
+ ...options,
142
138
  });
143
139
 
144
140
  export const numberColumn = <R extends Record<string, any>>(
145
141
  key: string,
146
142
  title: string,
147
143
  decimals = 2,
148
- options?: Partial<DataGridColumn<R>>
149
- ): DataGridColumns<R> => ({
150
- [key]: {
151
- name: title,
152
- render: (row) => formatNumber(row[key], decimals) ?? '',
153
- excelFormatter: () => buildExcelFormat(decimals),
154
- excelValue: (value) => formatNumberInvariant(value, decimals),
155
- getter: (row) => row[key] ?? '',
156
- sortGetter: (row) => row[key] ?? '',
157
- footer: {
158
- sum: (_, filteredRows) =>
159
- formatNumber(
160
- filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
161
- decimals
162
- ),
163
- average: (_, filteredRows) =>
164
- formatNumber(
165
- filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
166
- (filteredRows.length || 1),
167
- decimals
168
- ),
169
- count: (_, filteredRows) => `${filteredRows.length} éléments`,
170
- max: (_, filteredRows) =>
171
- formatNumber(
172
- Math.max(...filteredRows.map((row) => row[key] ?? 0)),
173
- decimals
174
- ),
175
- min: (_, filteredRows) =>
176
- formatNumber(
177
- Math.min(...filteredRows.map((row) => row[key] ?? 0)),
178
- decimals
179
- ),
180
- },
181
- filter: {
182
- ...numberFilter(key),
183
- renderer: (value) => formatNumber(value, decimals) ?? '',
184
- },
185
- ...options,
144
+ options?: Partial<DataGridNumberColumn<R>>
145
+ ): DataGridNumberColumn<R> => ({
146
+ key,
147
+ type: 'number',
148
+ name: title,
149
+ render: (row) => formatNumber(row[key], decimals) ?? '',
150
+ excelOptions: {
151
+ formatter: () => buildExcelFormat(decimals),
152
+ valueGetter: (value) => formatNumberInvariant(value, decimals),
186
153
  },
154
+ getter: (row) => row[key] ?? '',
155
+ sortGetter: (row) => row[key] ?? '',
156
+ footer: {
157
+ sum: (_, filteredRows) =>
158
+ formatNumber(
159
+ filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
160
+ decimals
161
+ ),
162
+ average: (_, filteredRows) =>
163
+ formatNumber(
164
+ filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
165
+ (filteredRows.length || 1),
166
+ decimals
167
+ ),
168
+ count: (_, filteredRows) => `${filteredRows.length} éléments`,
169
+ max: (_, filteredRows) =>
170
+ formatNumber(
171
+ Math.max(...filteredRows.map((row) => row[key] ?? 0)),
172
+ decimals
173
+ ),
174
+ min: (_, filteredRows) =>
175
+ formatNumber(
176
+ Math.min(...filteredRows.map((row) => row[key] ?? 0)),
177
+ decimals
178
+ ),
179
+ },
180
+ filter: {
181
+ ...numberFilter(key),
182
+ renderer: (value) => formatNumber(value, decimals) ?? '',
183
+ },
184
+ ...options,
187
185
  });
188
186
 
189
187
  export const moneyColumn = <R extends Record<string, any>>(
190
188
  key: string,
191
189
  title: string,
192
190
  decimals = 2,
193
- options?: Partial<DataGridColumn<R>>
194
- ): DataGridColumns<R> => ({
195
- [key]: {
196
- name: title,
197
- render: (row) => formatMoney(row[key], decimals) ?? '',
198
- excelFormatter: () => buildExcelFormat(decimals, ' '),
199
- excelValue: (value) => formatNumberInvariant(value, decimals),
200
- getter: (row) => row[key] ?? '',
201
- sortGetter: (row) => row[key] ?? '',
202
- filter: {
203
- ...numberFilter(key),
204
- renderer: (value) => formatMoney(value, decimals) ?? '',
205
- },
206
- footer: {
207
- sum: (_, filteredRows) =>
208
- formatMoney(
209
- filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
210
- decimals
211
- ),
212
- average: (_, filteredRows) =>
213
- formatMoney(
214
- filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
215
- (filteredRows.length || 1),
216
- decimals
217
- ),
218
- count: (_, filteredRows) => `${filteredRows.length} éléments`,
219
- max: (_, filteredRows) =>
220
- formatMoney(
221
- Math.max(...filteredRows.map((row) => row[key] ?? 0)),
222
- decimals
223
- ),
224
- min: (_, filteredRows) =>
225
- formatMoney(
226
- Math.min(...filteredRows.map((row) => row[key] ?? 0)),
227
- decimals
228
- ),
229
- },
230
- ...options,
191
+ options?: Partial<DataGridNumberColumn<R>>
192
+ ): DataGridNumberColumn<R> => ({
193
+ key,
194
+ type: 'number',
195
+ name: title,
196
+ render: (row) => formatMoney(row[key], decimals) ?? '',
197
+ excelOptions: {
198
+ formatter: () => buildExcelFormat(decimals, ' '),
199
+ valueGetter: (value) => formatNumberInvariant(value, decimals),
200
+ },
201
+ getter: (row) => row[key] ?? '',
202
+ sortGetter: (row) => row[key] ?? '',
203
+ filter: {
204
+ ...numberFilter(key),
205
+ renderer: (value) => formatMoney(value, decimals) ?? '',
231
206
  },
207
+ footer: {
208
+ sum: (_, filteredRows) =>
209
+ formatMoney(
210
+ filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
211
+ decimals
212
+ ),
213
+ average: (_, filteredRows) =>
214
+ formatMoney(
215
+ filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
216
+ (filteredRows.length || 1),
217
+ decimals
218
+ ),
219
+ count: (_, filteredRows) => `${filteredRows.length} éléments`,
220
+ max: (_, filteredRows) =>
221
+ formatMoney(
222
+ Math.max(...filteredRows.map((row) => row[key] ?? 0)),
223
+ decimals
224
+ ),
225
+ min: (_, filteredRows) =>
226
+ formatMoney(
227
+ Math.min(...filteredRows.map((row) => row[key] ?? 0)),
228
+ decimals
229
+ ),
230
+ },
231
+ ...options,
232
232
  });
233
233
 
234
234
  export const percentageColumn = <R extends Record<string, any>>(
235
235
  key: string,
236
236
  title: string,
237
237
  decimals = 2,
238
- options?: Partial<DataGridColumn<R>>
239
- ): DataGridColumns<R> => ({
240
- [key]: {
241
- name: title,
242
- render: (row) => formatPercentage(row[key]) ?? '',
243
- excelFormatter: () => buildExcelFormat(decimals, '%'),
244
- excelValue: (value) => formatNumberInvariant(value, decimals),
245
- getter: (row) => row[key] ?? '',
246
- sortGetter: (row) => row[key] ?? '',
247
- filter: numberFilter(key),
248
- footer: {
249
- average: (_, filteredRows) =>
250
- formatNumber(
251
- filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
252
- (filteredRows.length || 1),
253
- decimals
254
- ),
255
- count: (_, filteredRows) => `${filteredRows.length} éléments`,
256
- max: (_, filteredRows) =>
257
- formatNumber(
258
- Math.max(...filteredRows.map((row) => row[key] ?? 0)),
259
- decimals
260
- ),
261
- min: (_, filteredRows) =>
262
- formatNumber(
263
- Math.min(...filteredRows.map((row) => row[key] ?? 0)),
264
- decimals
265
- ),
266
- sum: (_, filteredRows) =>
267
- formatNumber(
268
- filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
269
- decimals
270
- ),
271
- },
272
- ...options,
238
+ options?: Partial<DataGridNumberColumn<R>>
239
+ ): DataGridNumberColumn<R> => ({
240
+ key,
241
+ type: 'number',
242
+ name: title,
243
+ render: (row) => formatPercentage(row[key]) ?? '',
244
+ excelOptions: {
245
+ formatter: () => buildExcelFormat(decimals, '%'),
246
+ valueGetter: (value) => formatNumberInvariant(value, decimals),
247
+ },
248
+ getter: (row) => row[key] ?? '',
249
+ sortGetter: (row) => row[key] ?? '',
250
+ filter: numberFilter(key),
251
+ footer: {
252
+ average: (_, filteredRows) =>
253
+ formatNumber(
254
+ filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
255
+ (filteredRows.length || 1),
256
+ decimals
257
+ ),
258
+ count: (_, filteredRows) => `${filteredRows.length} éléments`,
259
+ max: (_, filteredRows) =>
260
+ formatNumber(
261
+ Math.max(...filteredRows.map((row) => row[key] ?? 0)),
262
+ decimals
263
+ ),
264
+ min: (_, filteredRows) =>
265
+ formatNumber(
266
+ Math.min(...filteredRows.map((row) => row[key] ?? 0)),
267
+ decimals
268
+ ),
269
+ sum: (_, filteredRows) =>
270
+ formatNumber(
271
+ filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
272
+ decimals
273
+ ),
273
274
  },
275
+ ...options,
274
276
  });
275
277
 
276
278
  export const checkboxColumn = <R extends Record<string, any>>(
277
279
  key: string,
278
280
  title: string,
279
- options?: Partial<DataGridColumn<R>>
280
- ): DataGridColumns<R> => ({
281
- [key]: {
282
- name: title,
283
- render: (row) => (
284
- <>
285
- <input type="checkbox" checked={row[key]} readOnly />
286
- <span>{row[key] ? ' Oui' : ' Non'}</span>
287
- </>
288
- ),
289
- getter: (row) => row[key] ?? '',
290
- sortGetter: (row) => row[key] ?? '',
291
- filter: numberFilter(key),
292
- footer: {
293
- count: (_, filteredRows) => `${filteredRows.length} éléments`,
294
- checked: (_, filteredRows) =>
295
- `${filteredRows.filter((row) => !!row[key]).length} cochés`,
296
- unchecked: (_, filteredRows) =>
297
- `${filteredRows.filter((row) => !row[key]).length} décochés`,
298
- },
299
- ...options,
281
+ options?: Partial<DataGridCheckboxColumn<R>>
282
+ ): DataGridCheckboxColumn<R> => ({
283
+ key,
284
+ type: 'checkbox',
285
+ name: title,
286
+ render: (row) => (
287
+ <>
288
+ <input type="checkbox" checked={row[key]} readOnly />
289
+ <span>{row[key] ? ' Oui' : ' Non'}</span>
290
+ </>
291
+ ),
292
+ getter: (row) => row[key] ?? '',
293
+ sortGetter: (row) => row[key] ?? '',
294
+ filter: numberFilter(key),
295
+ footer: {
296
+ count: (_, filteredRows) => `${filteredRows.length} éléments`,
297
+ checked: (_, filteredRows) =>
298
+ `${filteredRows.filter((row) => !!row[key]).length} cochés`,
299
+ unchecked: (_, filteredRows) =>
300
+ `${filteredRows.filter((row) => !row[key]).length} décochés`,
300
301
  },
302
+ ...options,
301
303
  });
302
304
 
303
305
  export const colorColumn = <R extends Record<string, any>>(
304
306
  key: string,
305
307
  title: string,
306
- options?: Partial<DataGridColumn<R>>
307
- ): DataGridColumns<R> => ({
308
- [key]: {
309
- name: title,
310
- render: (row) => (
311
- <div style={{ backgroundColor: row[key] }}>{row[key] ?? ''}</div>
312
- ),
313
- getter: (row) => row[key] ?? '',
314
- sortGetter: (row) => row[key] ?? '',
315
- filter: textFilter(key),
316
- footer: (rows) => `${rows.length} éléments`,
317
- ...options,
318
- },
308
+ options?: Partial<DataGridColorColumn<R>>
309
+ ): DataGridColorColumn<R> => ({
310
+ key,
311
+ type: 'color',
312
+ name: title,
313
+ render: (row) => (
314
+ <div style={{ backgroundColor: row[key] }}>{row[key] ?? ''}</div>
315
+ ),
316
+ getter: (row) => row[key] ?? '',
317
+ sortGetter: (row) => row[key] ?? '',
318
+ filter: textFilter(key),
319
+ footer: (rows) => `${rows.length} éléments`,
320
+ ...options,
319
321
  });
@@ -2,11 +2,10 @@ import { DataGridColumns, DataGridContext } from '../types';
2
2
  import { useContext, useMemo } from 'react';
3
3
 
4
4
  import { isColumnVisible } from '../helpers/columns';
5
- import { pickBy } from 'lodash';
6
5
 
6
+ export { useDataGrid } from './useDataGrid';
7
7
  export { useDataGridCopy } from './useDataGridCopy';
8
8
  export { useDataGridSettings } from './useDataGridSettings';
9
- export { useDataGrid } from './useDataGrid';
10
9
 
11
10
  export const useDataGridContext = <R>(context: DataGridContext<R>) =>
12
11
  useContext(context);
@@ -14,8 +13,8 @@ export const useDataGridContext = <R>(context: DataGridContext<R>) =>
14
13
  export const useVisibleAndHiddenColumns = <R>(columns: DataGridColumns<R>) =>
15
14
  useMemo(
16
15
  () => [
17
- pickBy(columns, (col) => isColumnVisible(col)),
18
- pickBy(columns, (col) => !isColumnVisible(col)),
16
+ columns.filter(isColumnVisible),
17
+ columns.filter((col) => !isColumnVisible(col)),
19
18
  ],
20
19
  [columns]
21
20
  );
@@ -23,8 +22,8 @@ export const useVisibleAndHiddenColumns = <R>(columns: DataGridColumns<R>) =>
23
22
  export const useSortedColumns = <R>(columns: DataGridColumns<R>) =>
24
23
  useMemo(
25
24
  () =>
26
- Object.entries(columns)
27
- .filter(([, col]) => isColumnVisible(col))
28
- .sort((a, b) => (a[1].order ?? 0) - (b[1].order ?? 0)),
25
+ columns
26
+ .filter(isColumnVisible)
27
+ .sort((a, b) => (a.order ?? 0) - (b.order ?? 0)),
29
28
  [columns]
30
29
  );