@addev-be/ui 0.14.4 → 0.15.0
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/assets/icons/table.svg +1 -1
- package/dist/Icons.d.ts +49 -0
- package/dist/Icons.js +128 -0
- package/dist/components/auth/LoginForm.d.ts +2 -0
- package/dist/components/auth/LoginForm.js +48 -0
- package/dist/components/auth/LoginPage.d.ts +2 -0
- package/dist/components/auth/LoginPage.js +9 -0
- package/dist/components/auth/PasswordRecoveryForm.d.ts +2 -0
- package/dist/components/auth/PasswordRecoveryForm.js +24 -0
- package/dist/components/auth/PasswordResetForm.d.ts +2 -0
- package/dist/components/auth/PasswordResetForm.js +56 -0
- package/dist/components/auth/index.d.ts +4 -0
- package/dist/components/auth/index.js +20 -0
- package/dist/components/auth/styles.d.ts +3 -0
- package/dist/components/auth/styles.js +16 -0
- package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.d.ts +14 -0
- package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.js +76 -0
- package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.d.ts +22 -0
- package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.js +156 -0
- package/dist/components/data/AdvancedRequestDataGrid/helpers/index.d.ts +2 -0
- package/dist/components/data/AdvancedRequestDataGrid/helpers/index.js +18 -0
- package/dist/components/data/AdvancedRequestDataGrid/index.d.ts +2 -0
- package/dist/components/data/AdvancedRequestDataGrid/index.js +215 -0
- package/dist/components/data/AdvancedRequestDataGrid/types.d.ts +21 -0
- package/dist/components/data/AdvancedRequestDataGrid/types.js +2 -0
- package/dist/components/data/DataGrid/DataGridCell.d.ts +2 -0
- package/dist/components/data/DataGrid/DataGridCell.js +59 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/helpers.d.ts +2 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/helpers.js +24 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.d.ts +6 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.js +38 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/index.d.ts +15 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/index.js +111 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/styles.d.ts +22 -0
- package/dist/components/data/DataGrid/DataGridColumnsModal/styles.js +54 -0
- package/dist/components/data/DataGrid/DataGridEditableCell.d.ts +2 -0
- package/dist/components/data/DataGrid/DataGridEditableCell.js +27 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.d.ts +13 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.js +71 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/hooks.d.ts +9 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/hooks.js +52 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/index.d.ts +9 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +221 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +18 -0
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.js +31 -0
- package/dist/components/data/DataGrid/DataGridFooter.d.ts +4 -0
- package/dist/components/data/DataGrid/DataGridFooter.js +44 -0
- package/dist/components/data/DataGrid/DataGridHeader.d.ts +4 -0
- package/dist/components/data/DataGrid/DataGridHeader.js +119 -0
- package/dist/components/data/DataGrid/DataGridHeaderCell.d.ts +2 -0
- package/dist/components/data/DataGrid/DataGridHeaderCell.js +84 -0
- package/dist/components/data/DataGrid/DataGridRowTemplate.d.ts +3 -0
- package/dist/components/data/DataGrid/DataGridRowTemplate.js +71 -0
- package/dist/components/data/DataGrid/FilterModalContent/index.d.ts +7 -0
- package/dist/components/data/DataGrid/FilterModalContent/index.js +117 -0
- package/dist/components/data/DataGrid/FilterModalContent/styles.d.ts +3 -0
- package/dist/components/data/DataGrid/FilterModalContent/styles.js +15 -0
- package/dist/components/data/DataGrid/helpers/columns.d.ts +14 -0
- package/dist/components/data/DataGrid/helpers/columns.js +176 -0
- package/dist/components/data/DataGrid/helpers/filters.d.ts +18 -0
- package/dist/components/data/DataGrid/helpers/filters.js +334 -0
- package/dist/components/data/DataGrid/helpers/index.d.ts +2 -0
- package/dist/components/data/DataGrid/helpers/index.js +18 -0
- package/dist/components/data/DataGrid/hooks/index.d.ts +7 -0
- package/dist/components/data/DataGrid/hooks/index.js +34 -0
- package/dist/components/data/DataGrid/hooks/useDataGrid.d.ts +2 -0
- package/dist/components/data/DataGrid/hooks/useDataGrid.js +241 -0
- package/dist/components/data/DataGrid/hooks/useDataGridCopy.d.ts +4 -0
- package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +163 -0
- package/dist/components/data/DataGrid/hooks/useDataGridSettings.d.ts +16 -0
- package/dist/components/data/DataGrid/hooks/useDataGridSettings.js +43 -0
- package/dist/components/data/DataGrid/index.d.ts +8 -0
- package/dist/components/data/DataGrid/index.js +63 -0
- package/dist/components/data/DataGrid/styles.d.ts +47 -0
- package/dist/components/data/DataGrid/styles.js +111 -0
- package/dist/components/data/DataGrid/types.d.ts +172 -0
- package/dist/components/data/DataGrid/types.js +34 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.d.ts +17 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +136 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/index.d.ts +2 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/index.js +18 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/sqlRequests.d.ts +3 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/sqlRequests.js +18 -0
- package/dist/components/data/SqlRequestDataGrid/index.d.ts +13 -0
- package/dist/components/data/SqlRequestDataGrid/index.js +309 -0
- package/dist/components/data/SqlRequestDataGrid/types.d.ts +21 -0
- package/dist/components/data/SqlRequestDataGrid/types.js +2 -0
- package/dist/components/data/SqlRequestGrid/helpers/index.d.ts +1 -0
- package/dist/components/data/SqlRequestGrid/helpers/index.js +17 -0
- package/dist/components/data/SqlRequestGrid/helpers/sqlRequests.d.ts +3 -0
- package/dist/components/data/SqlRequestGrid/helpers/sqlRequests.js +18 -0
- package/dist/components/data/SqlRequestGrid/index.d.ts +4 -0
- package/dist/components/data/SqlRequestGrid/index.js +145 -0
- package/dist/components/data/SqlRequestGrid/styles.d.ts +16 -0
- package/dist/components/data/SqlRequestGrid/styles.js +33 -0
- package/dist/components/data/SqlRequestGrid/types.d.ts +30 -0
- package/dist/components/data/SqlRequestGrid/types.js +3 -0
- package/dist/components/data/VirtualScroller/hooks.d.ts +18 -0
- package/dist/components/data/VirtualScroller/hooks.js +50 -0
- package/dist/components/data/VirtualScroller/index.d.ts +14 -0
- package/dist/components/data/VirtualScroller/index.js +58 -0
- package/dist/components/data/VirtualScroller/styles.d.ts +16 -0
- package/dist/components/data/VirtualScroller/styles.js +39 -0
- package/dist/components/data/VirtualScroller/types.d.ts +6 -0
- package/dist/components/data/VirtualScroller/types.js +3 -0
- package/dist/components/data/index.d.ts +13 -0
- package/dist/components/data/index.js +29 -0
- package/dist/components/forms/Button.d.ts +10 -0
- package/dist/components/forms/Button.js +70 -0
- package/dist/components/forms/IconButton.d.ts +7 -0
- package/dist/components/forms/IconButton.js +64 -0
- package/dist/components/forms/IndeterminateCheckbox.d.ts +8 -0
- package/dist/components/forms/IndeterminateCheckbox.js +41 -0
- package/dist/components/forms/Select.d.ts +10 -0
- package/dist/components/forms/Select.js +49 -0
- package/dist/components/forms/VerticalLabel.d.ts +6 -0
- package/dist/components/forms/VerticalLabel.js +32 -0
- package/dist/components/forms/index.d.ts +5 -0
- package/dist/components/forms/index.js +21 -0
- package/dist/components/forms/styles.d.ts +7 -0
- package/dist/components/forms/styles.js +39 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +22 -0
- package/dist/components/layout/Dropdown/index.d.ts +11 -0
- package/dist/components/layout/Dropdown/index.js +85 -0
- package/dist/components/layout/Dropdown/styles.d.ts +14 -0
- package/dist/components/layout/Dropdown/styles.js +48 -0
- package/dist/components/layout/Loading/index.d.ts +6 -0
- package/dist/components/layout/Loading/index.js +42 -0
- package/dist/components/layout/Loading/styles.d.ts +6 -0
- package/dist/components/layout/Loading/styles.js +18 -0
- package/dist/components/layout/Modal/index.d.ts +16 -0
- package/dist/components/layout/Modal/index.js +67 -0
- package/dist/components/layout/Modal/styles.d.ts +34 -0
- package/dist/components/layout/Modal/styles.js +56 -0
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.js +19 -0
- package/dist/components/search/HighlightedText.d.ts +5 -0
- package/dist/components/search/HighlightedText.js +43 -0
- package/dist/components/search/QuickSearchBar.d.ts +6 -0
- package/dist/components/search/QuickSearchBar.js +69 -0
- package/dist/components/search/QuickSearchResults.d.ts +8 -0
- package/dist/components/search/QuickSearchResults.js +70 -0
- package/dist/components/search/index.d.ts +5 -0
- package/dist/components/search/index.js +25 -0
- package/dist/components/search/styles.d.ts +28 -0
- package/dist/components/search/styles.js +40 -0
- package/dist/components/search/types.d.ts +21 -0
- package/dist/components/search/types.js +2 -0
- package/dist/components/ui/Card/index.d.ts +8 -0
- package/dist/components/ui/Card/index.js +34 -0
- package/dist/components/ui/Card/styles.d.ts +9 -0
- package/dist/components/ui/Card/styles.js +21 -0
- package/dist/components/ui/ContextMenu/index.d.ts +11 -0
- package/dist/components/ui/ContextMenu/index.js +63 -0
- package/dist/components/ui/ContextMenu/styles.d.ts +18 -0
- package/dist/components/ui/ContextMenu/styles.js +56 -0
- package/dist/components/ui/Message/index.d.ts +9 -0
- package/dist/components/ui/Message/index.js +53 -0
- package/dist/components/ui/Message/styles.d.ts +9 -0
- package/dist/components/ui/Message/styles.js +41 -0
- package/dist/components/ui/index.d.ts +3 -0
- package/dist/components/ui/index.js +19 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.js +2 -0
- package/dist/helpers/dates.d.ts +3 -0
- package/dist/helpers/dates.js +19 -0
- package/dist/helpers/getScrollbarSize.d.ts +1 -0
- package/dist/helpers/getScrollbarSize.js +17 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/numbers.d.ts +4 -0
- package/dist/helpers/numbers.js +39 -0
- package/dist/helpers/text.d.ts +2 -0
- package/dist/helpers/text.js +18 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +18 -0
- package/dist/hooks/useElementSize.d.ts +4 -0
- package/dist/hooks/useElementSize.js +23 -0
- package/dist/hooks/useWindowSize.d.ts +4 -0
- package/dist/hooks/useWindowSize.js +19 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +22 -0
- package/dist/providers/AuthenticationProvider/helpers.d.ts +1 -0
- package/dist/providers/AuthenticationProvider/helpers.js +6 -0
- package/dist/providers/AuthenticationProvider/index.d.ts +23 -0
- package/dist/providers/AuthenticationProvider/index.js +221 -0
- package/dist/providers/LoadingProvider/index.d.ts +7 -0
- package/dist/providers/LoadingProvider/index.js +26 -0
- package/dist/providers/PortalsProvider/index.d.ts +10 -0
- package/dist/providers/PortalsProvider/index.js +46 -0
- package/dist/providers/PortalsProvider/styles.d.ts +9 -0
- package/dist/providers/PortalsProvider/styles.js +21 -0
- package/dist/providers/SettingsProvider/index.d.ts +8 -0
- package/dist/providers/SettingsProvider/index.js +54 -0
- package/dist/providers/ThemeProvider/ThemeProvider.d.ts +7 -0
- package/dist/providers/ThemeProvider/ThemeProvider.js +51 -0
- package/dist/providers/ThemeProvider/defaultTheme.d.ts +2 -0
- package/dist/providers/ThemeProvider/defaultTheme.js +417 -0
- package/dist/providers/ThemeProvider/index.d.ts +3 -0
- package/dist/providers/ThemeProvider/index.js +22 -0
- package/dist/providers/ThemeProvider/types.d.ts +24 -0
- package/dist/providers/ThemeProvider/types.js +2 -0
- package/dist/providers/UiProviders/index.d.ts +12 -0
- package/dist/providers/UiProviders/index.js +62 -0
- package/dist/providers/UiProviders/styles.d.ts +3 -0
- package/dist/providers/UiProviders/styles.js +13 -0
- package/dist/providers/hooks.d.ts +5 -0
- package/dist/providers/hooks.js +19 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.js +21 -0
- package/dist/services/HttpService.d.ts +10 -0
- package/dist/services/HttpService.js +125 -0
- package/dist/services/WebSocketService.d.ts +23 -0
- package/dist/services/WebSocketService.js +125 -0
- package/dist/services/advancedRequests.d.ts +41 -0
- package/dist/services/advancedRequests.js +13 -0
- package/dist/services/base.d.ts +14 -0
- package/dist/services/base.js +7 -0
- package/dist/services/globalSearch.d.ts +13 -0
- package/dist/services/globalSearch.js +8 -0
- package/dist/services/hooks.d.ts +3 -0
- package/dist/services/hooks.js +29 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.js +27 -0
- package/dist/services/requests/auth.d.ts +63 -0
- package/dist/services/requests/auth.js +28 -0
- package/dist/services/requests/userProfiles.d.ts +40 -0
- package/dist/services/requests/userProfiles.js +20 -0
- package/dist/services/requests/users.d.ts +84 -0
- package/dist/services/requests/users.js +20 -0
- package/dist/services/sqlRequests.d.ts +45 -0
- package/dist/services/sqlRequests.js +11 -0
- package/dist/services/types/auth.d.ts +87 -0
- package/dist/services/types/auth.js +72 -0
- package/dist/services/types/base.d.ts +6 -0
- package/dist/services/types/base.js +31 -0
- package/dist/services/types/userProfiles.d.ts +64 -0
- package/dist/services/types/userProfiles.js +68 -0
- package/dist/services/types/users.d.ts +118 -0
- package/dist/services/types/users.js +83 -0
- package/package.json +1 -1
- package/src/components/data/DataGrid/DataGridEditableCell/index.tsx +54 -9
- package/src/components/data/DataGrid/DataGridEditableCell/types.ts +5 -4
- package/src/components/data/DataGrid/helpers/columns.tsx +202 -139
- package/src/components/data/DataGrid/hooks/useDataGrid.tsx +0 -33
- package/src/components/data/DataGrid/types.ts +36 -11
- package/src/components/data/SqlRequestDataGrid/SqlRequestForeignListEditableCell.tsx +16 -0
- package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +41 -0
- package/src/components/data/SqlRequestDataGrid/types.ts +9 -1
- package/src/components/data/SqlRequestForeignList/index.tsx +118 -74
- package/src/components/data/SqlRequestForeignList/types.ts +31 -0
- package/src/components/data/SqlRequestGrid/filters/FiltersSidebar.tsx +3 -3
- package/src/components/forms/Form/Select.tsx +35 -17
- package/src/components/forms/Select.tsx +20 -25
- package/src/components/layout/Dropdown/index.tsx +10 -9
- package/src/components/ui/Avatar/styles.ts +61 -61
- package/src/components/ui/Label.tsx +90 -90
- package/src/providers/TrackingProvider/hooks.ts +14 -14
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
DataGridColumn,
|
|
7
7
|
DataGridDateColumn,
|
|
8
8
|
DataGridNumberColumn,
|
|
9
|
+
DataGridSelectColumn,
|
|
9
10
|
DataGridSettings,
|
|
10
11
|
DataGridTextColumn,
|
|
11
12
|
} from '../types';
|
|
@@ -17,6 +18,12 @@ import {
|
|
|
17
18
|
formatPercentage,
|
|
18
19
|
} from '../../../../helpers/numbers';
|
|
19
20
|
|
|
21
|
+
import { CheckboxEditableCell } from '../DataGridEditableCell/CheckboxEditableCell';
|
|
22
|
+
import { DateEditableCell } from '../DataGridEditableCell/DateEditableCell';
|
|
23
|
+
import { NumberEditableCell } from '../DataGridEditableCell/NumberEditableCell';
|
|
24
|
+
import { Select } from '../../../forms/Form/Select';
|
|
25
|
+
import { TextEditableCell } from '../DataGridEditableCell/TextEditableCell';
|
|
26
|
+
import { forwardRef } from 'react';
|
|
20
27
|
import moment from 'moment';
|
|
21
28
|
import { repeat } from 'lodash';
|
|
22
29
|
|
|
@@ -30,7 +37,7 @@ export const buildExcelFormat = (decimals = 2, suffix = '') =>
|
|
|
30
37
|
export const textColumn = <R extends Record<string, any>>(
|
|
31
38
|
key: string,
|
|
32
39
|
title: string,
|
|
33
|
-
|
|
40
|
+
otherOptions?: Partial<DataGridTextColumn<R>>
|
|
34
41
|
): DataGridTextColumn<R> => ({
|
|
35
42
|
key,
|
|
36
43
|
type: 'text',
|
|
@@ -40,13 +47,14 @@ export const textColumn = <R extends Record<string, any>>(
|
|
|
40
47
|
sortGetter: (row) => row[key] ?? '',
|
|
41
48
|
footer: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
42
49
|
filter: textFilter(key),
|
|
43
|
-
|
|
50
|
+
editComponent: TextEditableCell,
|
|
51
|
+
...otherOptions,
|
|
44
52
|
});
|
|
45
53
|
|
|
46
54
|
export const mailColumn = <R extends Record<string, any>>(
|
|
47
55
|
key: string,
|
|
48
56
|
title: string,
|
|
49
|
-
|
|
57
|
+
otherOptions?: Partial<DataGridTextColumn<R>>
|
|
50
58
|
): DataGridTextColumn<R> => ({
|
|
51
59
|
key,
|
|
52
60
|
type: 'text',
|
|
@@ -56,13 +64,14 @@ export const mailColumn = <R extends Record<string, any>>(
|
|
|
56
64
|
sortGetter: (row) => row[key] ?? '',
|
|
57
65
|
footer: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
58
66
|
filter: textFilter(key),
|
|
59
|
-
|
|
67
|
+
editComponent: TextEditableCell,
|
|
68
|
+
...otherOptions,
|
|
60
69
|
});
|
|
61
70
|
|
|
62
71
|
export const phoneColumn = <R extends Record<string, any>>(
|
|
63
72
|
key: string,
|
|
64
73
|
title: string,
|
|
65
|
-
|
|
74
|
+
otherOptions?: Partial<DataGridTextColumn<R>>
|
|
66
75
|
): DataGridTextColumn<R> => ({
|
|
67
76
|
key,
|
|
68
77
|
type: 'text',
|
|
@@ -72,13 +81,14 @@ export const phoneColumn = <R extends Record<string, any>>(
|
|
|
72
81
|
sortGetter: (row) => row[key] ?? '',
|
|
73
82
|
footer: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
74
83
|
filter: textFilter(key),
|
|
75
|
-
|
|
84
|
+
editComponent: TextEditableCell,
|
|
85
|
+
...otherOptions,
|
|
76
86
|
});
|
|
77
87
|
|
|
78
88
|
export const dateColumn = <R extends Record<string, any>>(
|
|
79
89
|
key: string,
|
|
80
90
|
title: string,
|
|
81
|
-
|
|
91
|
+
otherOptions?: Partial<DataGridDateColumn<R>>
|
|
82
92
|
): DataGridDateColumn<R> => ({
|
|
83
93
|
key,
|
|
84
94
|
type: 'date',
|
|
@@ -95,13 +105,14 @@ export const dateColumn = <R extends Record<string, any>>(
|
|
|
95
105
|
...dateFilter(key),
|
|
96
106
|
renderer: (value) => moment(value).format('DD/MM/YYYY') ?? '',
|
|
97
107
|
},
|
|
98
|
-
|
|
108
|
+
editComponent: DateEditableCell,
|
|
109
|
+
...otherOptions,
|
|
99
110
|
});
|
|
100
111
|
|
|
101
112
|
export const dateTimeColumn = <R extends Record<string, any>>(
|
|
102
113
|
key: string,
|
|
103
114
|
title: string,
|
|
104
|
-
|
|
115
|
+
otherOptions?: Partial<DataGridDateColumn<R>>
|
|
105
116
|
): DataGridDateColumn<R> => ({
|
|
106
117
|
key,
|
|
107
118
|
type: 'date',
|
|
@@ -118,13 +129,14 @@ export const dateTimeColumn = <R extends Record<string, any>>(
|
|
|
118
129
|
...dateFilter(key),
|
|
119
130
|
renderer: (value) => moment(value).format('DD/MM/YYYY HH:mm:ss') ?? '',
|
|
120
131
|
},
|
|
121
|
-
|
|
132
|
+
editComponent: DateEditableCell,
|
|
133
|
+
...otherOptions,
|
|
122
134
|
});
|
|
123
135
|
|
|
124
136
|
export const monthColumn = <R extends Record<string, any>>(
|
|
125
137
|
key: string,
|
|
126
138
|
title: string,
|
|
127
|
-
|
|
139
|
+
otherOptions?: Partial<DataGridTextColumn<R>>
|
|
128
140
|
): DataGridTextColumn<R> => ({
|
|
129
141
|
key,
|
|
130
142
|
type: 'text',
|
|
@@ -134,151 +146,168 @@ export const monthColumn = <R extends Record<string, any>>(
|
|
|
134
146
|
sortGetter: (row) => row[key] ?? '',
|
|
135
147
|
footer: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
136
148
|
filter: textFilter(key),
|
|
137
|
-
...
|
|
149
|
+
...otherOptions,
|
|
138
150
|
});
|
|
139
151
|
|
|
140
152
|
export const numberColumn = <R extends Record<string, any>>(
|
|
141
153
|
key: string,
|
|
142
154
|
title: string,
|
|
143
155
|
decimals = 2,
|
|
144
|
-
|
|
145
|
-
): DataGridNumberColumn<R> =>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
156
|
+
otherOptions?: Partial<DataGridNumberColumn<R>>
|
|
157
|
+
): DataGridNumberColumn<R> => {
|
|
158
|
+
const column: DataGridNumberColumn<R> = {
|
|
159
|
+
key,
|
|
160
|
+
type: 'number',
|
|
161
|
+
name: title,
|
|
162
|
+
render: (row) => formatNumber(row[key], decimals) ?? '',
|
|
163
|
+
excelOptions: {
|
|
164
|
+
formatter: () => buildExcelFormat(decimals),
|
|
165
|
+
valueGetter: (value) => formatNumberInvariant(value, decimals),
|
|
166
|
+
},
|
|
167
|
+
getter: (row) => row[key] ?? '',
|
|
168
|
+
sortGetter: (row) => row[key] ?? '',
|
|
169
|
+
footer: {
|
|
170
|
+
sum: (_, filteredRows) =>
|
|
171
|
+
formatNumber(
|
|
172
|
+
filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
|
|
173
|
+
decimals
|
|
174
|
+
),
|
|
175
|
+
average: (_, filteredRows) =>
|
|
176
|
+
formatNumber(
|
|
177
|
+
filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
|
|
178
|
+
(filteredRows.length || 1),
|
|
179
|
+
decimals
|
|
180
|
+
),
|
|
181
|
+
count: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
182
|
+
max: (_, filteredRows) =>
|
|
183
|
+
formatNumber(
|
|
184
|
+
Math.max(...filteredRows.map((row) => row[key] ?? 0)),
|
|
185
|
+
decimals
|
|
186
|
+
),
|
|
187
|
+
min: (_, filteredRows) =>
|
|
188
|
+
formatNumber(
|
|
189
|
+
Math.min(...filteredRows.map((row) => row[key] ?? 0)),
|
|
190
|
+
decimals
|
|
191
|
+
),
|
|
192
|
+
},
|
|
193
|
+
filter: {
|
|
194
|
+
...numberFilter(key),
|
|
195
|
+
renderer: (value) => formatNumber(value, decimals) ?? '',
|
|
196
|
+
},
|
|
197
|
+
editComponent: forwardRef((props, ref) => (
|
|
198
|
+
<NumberEditableCell<R>
|
|
199
|
+
ref={ref}
|
|
200
|
+
decimals={column.decimals}
|
|
201
|
+
currency={column.currency}
|
|
202
|
+
{...props}
|
|
203
|
+
/>
|
|
204
|
+
)),
|
|
205
|
+
...otherOptions,
|
|
206
|
+
};
|
|
207
|
+
return column;
|
|
208
|
+
};
|
|
186
209
|
|
|
187
210
|
export const moneyColumn = <R extends Record<string, any>>(
|
|
188
211
|
key: string,
|
|
189
212
|
title: string,
|
|
190
213
|
decimals = 2,
|
|
191
|
-
|
|
192
|
-
): DataGridNumberColumn<R> =>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
214
|
+
otherOptions?: Partial<DataGridNumberColumn<R>>
|
|
215
|
+
): DataGridNumberColumn<R> => {
|
|
216
|
+
const column: DataGridNumberColumn<R> = {
|
|
217
|
+
key,
|
|
218
|
+
type: 'number',
|
|
219
|
+
name: title,
|
|
220
|
+
render: (row) => formatMoney(row[key], decimals) ?? '',
|
|
221
|
+
excelOptions: {
|
|
222
|
+
formatter: () => buildExcelFormat(decimals, ' €'),
|
|
223
|
+
valueGetter: (value) => formatNumberInvariant(value, decimals),
|
|
224
|
+
},
|
|
225
|
+
getter: (row) => row[key] ?? '',
|
|
226
|
+
sortGetter: (row) => row[key] ?? '',
|
|
227
|
+
filter: {
|
|
228
|
+
...numberFilter(key),
|
|
229
|
+
renderer: (value) => formatMoney(value, decimals) ?? '',
|
|
230
|
+
},
|
|
231
|
+
footer: {
|
|
232
|
+
sum: (_, filteredRows) =>
|
|
233
|
+
formatMoney(
|
|
234
|
+
filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
|
|
235
|
+
decimals
|
|
236
|
+
),
|
|
237
|
+
average: (_, filteredRows) =>
|
|
238
|
+
formatMoney(
|
|
239
|
+
filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
|
|
240
|
+
(filteredRows.length || 1),
|
|
241
|
+
decimals
|
|
242
|
+
),
|
|
243
|
+
count: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
244
|
+
max: (_, filteredRows) =>
|
|
245
|
+
formatMoney(
|
|
246
|
+
Math.max(...filteredRows.map((row) => row[key] ?? 0)),
|
|
247
|
+
decimals
|
|
248
|
+
),
|
|
249
|
+
min: (_, filteredRows) =>
|
|
250
|
+
formatMoney(
|
|
251
|
+
Math.min(...filteredRows.map((row) => row[key] ?? 0)),
|
|
252
|
+
decimals
|
|
253
|
+
),
|
|
254
|
+
},
|
|
255
|
+
...otherOptions,
|
|
256
|
+
};
|
|
257
|
+
return column;
|
|
258
|
+
};
|
|
233
259
|
|
|
234
260
|
export const percentageColumn = <R extends Record<string, any>>(
|
|
235
261
|
key: string,
|
|
236
262
|
title: string,
|
|
237
263
|
decimals = 2,
|
|
238
|
-
|
|
239
|
-
): DataGridNumberColumn<R> =>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
264
|
+
otherOptions?: Partial<DataGridNumberColumn<R>>
|
|
265
|
+
): DataGridNumberColumn<R> => {
|
|
266
|
+
const column: DataGridNumberColumn<R> = {
|
|
267
|
+
key,
|
|
268
|
+
type: 'number',
|
|
269
|
+
name: title,
|
|
270
|
+
render: (row) => formatPercentage(row[key]) ?? '',
|
|
271
|
+
excelOptions: {
|
|
272
|
+
formatter: () => buildExcelFormat(decimals, '%'),
|
|
273
|
+
valueGetter: (value) => formatNumberInvariant(value, decimals),
|
|
274
|
+
},
|
|
275
|
+
getter: (row) => row[key] ?? '',
|
|
276
|
+
sortGetter: (row) => row[key] ?? '',
|
|
277
|
+
filter: numberFilter(key),
|
|
278
|
+
footer: {
|
|
279
|
+
average: (_, filteredRows) =>
|
|
280
|
+
formatNumber(
|
|
281
|
+
filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0) /
|
|
282
|
+
(filteredRows.length || 1),
|
|
283
|
+
decimals
|
|
284
|
+
),
|
|
285
|
+
count: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
286
|
+
max: (_, filteredRows) =>
|
|
287
|
+
formatNumber(
|
|
288
|
+
Math.max(...filteredRows.map((row) => row[key] ?? 0)),
|
|
289
|
+
decimals
|
|
290
|
+
),
|
|
291
|
+
min: (_, filteredRows) =>
|
|
292
|
+
formatNumber(
|
|
293
|
+
Math.min(...filteredRows.map((row) => row[key] ?? 0)),
|
|
294
|
+
decimals
|
|
295
|
+
),
|
|
296
|
+
sum: (_, filteredRows) =>
|
|
297
|
+
formatNumber(
|
|
298
|
+
filteredRows.reduce((acc, row) => acc + (row[key] ?? 0), 0),
|
|
299
|
+
decimals
|
|
300
|
+
),
|
|
301
|
+
},
|
|
302
|
+
...otherOptions,
|
|
303
|
+
};
|
|
304
|
+
return column;
|
|
305
|
+
};
|
|
277
306
|
|
|
278
307
|
export const checkboxColumn = <R extends Record<string, any>>(
|
|
279
308
|
key: string,
|
|
280
309
|
title: string,
|
|
281
|
-
|
|
310
|
+
otherOptions?: Partial<DataGridCheckboxColumn<R>>
|
|
282
311
|
): DataGridCheckboxColumn<R> => ({
|
|
283
312
|
key,
|
|
284
313
|
type: 'checkbox',
|
|
@@ -299,13 +328,47 @@ export const checkboxColumn = <R extends Record<string, any>>(
|
|
|
299
328
|
unchecked: (_, filteredRows) =>
|
|
300
329
|
`${filteredRows.filter((row) => !row[key]).length} décochés`,
|
|
301
330
|
},
|
|
302
|
-
|
|
331
|
+
editComponent: CheckboxEditableCell,
|
|
332
|
+
...otherOptions,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
export const selectColumn = <R extends Record<string, any>, T>(
|
|
336
|
+
key: string,
|
|
337
|
+
title: string,
|
|
338
|
+
items: T[],
|
|
339
|
+
itemKey: (item: T | null) => string,
|
|
340
|
+
itemLabel: (item: T | null) => string,
|
|
341
|
+
otherOptions?: Partial<DataGridSelectColumn<R, T>>
|
|
342
|
+
): DataGridSelectColumn<R, T> => ({
|
|
343
|
+
key,
|
|
344
|
+
type: 'select',
|
|
345
|
+
name: title,
|
|
346
|
+
render: (row) => itemLabel(row[key]) ?? '',
|
|
347
|
+
getter: (row) => row[key] ?? null,
|
|
348
|
+
sortGetter: (row) => itemLabel(row[key]) ?? '',
|
|
349
|
+
footer: (_, filteredRows) => `${filteredRows.length} éléments`,
|
|
350
|
+
filter: textFilter(key),
|
|
351
|
+
items,
|
|
352
|
+
itemKey,
|
|
353
|
+
itemLabel,
|
|
354
|
+
editComponent: forwardRef(({ value, onChange, onClose }, ref) => (
|
|
355
|
+
<Select
|
|
356
|
+
ref={ref}
|
|
357
|
+
items={items}
|
|
358
|
+
itemKey={itemKey}
|
|
359
|
+
itemLabel={itemLabel}
|
|
360
|
+
value={value}
|
|
361
|
+
onChange={onChange}
|
|
362
|
+
onBlur={() => onClose(true)}
|
|
363
|
+
/>
|
|
364
|
+
)),
|
|
365
|
+
...otherOptions,
|
|
303
366
|
});
|
|
304
367
|
|
|
305
368
|
export const colorColumn = <R extends Record<string, any>>(
|
|
306
369
|
key: string,
|
|
307
370
|
title: string,
|
|
308
|
-
|
|
371
|
+
otherOptions?: Partial<DataGridColorColumn<R>>
|
|
309
372
|
): DataGridColorColumn<R> => ({
|
|
310
373
|
key,
|
|
311
374
|
type: 'color',
|
|
@@ -317,5 +380,5 @@ export const colorColumn = <R extends Record<string, any>>(
|
|
|
317
380
|
sortGetter: (row) => row[key] ?? '',
|
|
318
381
|
filter: textFilter(key),
|
|
319
382
|
footer: (rows) => `${rows.length} éléments`,
|
|
320
|
-
...
|
|
383
|
+
...otherOptions,
|
|
321
384
|
});
|
|
@@ -151,37 +151,6 @@ export const useDataGrid = <R,>(
|
|
|
151
151
|
clearChangedRows,
|
|
152
152
|
} = useDataGridChangedRows<R>(onRowAdded);
|
|
153
153
|
|
|
154
|
-
const onCellEdited = useCallback(
|
|
155
|
-
(row: R, columnKey: string, value: any) => {
|
|
156
|
-
setEditingCell([-1, -1]);
|
|
157
|
-
const column = columns.find((col) => col.key === columnKey);
|
|
158
|
-
const rowIndex = rows.findIndex(
|
|
159
|
-
(r) => rowKeyGetter(r) === rowKeyGetter(row)
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
// If row and column are valid
|
|
163
|
-
if (rowIndex >= 0 && column) {
|
|
164
|
-
// Update the row with the new value
|
|
165
|
-
const partialRow: Partial<R> = {};
|
|
166
|
-
partialRow[columnKey as keyof R] = value;
|
|
167
|
-
const newRow = { ...row, ...partialRow };
|
|
168
|
-
const rowKey = rowKeyGetter(newRow);
|
|
169
|
-
|
|
170
|
-
// Update the edited rows state
|
|
171
|
-
editRow(rowKey, partialRow);
|
|
172
|
-
|
|
173
|
-
// Update the rows
|
|
174
|
-
const newRows = [...rows];
|
|
175
|
-
newRows[rowIndex] = newRow;
|
|
176
|
-
setRows?.(newRows);
|
|
177
|
-
|
|
178
|
-
// Call the onRowEdited callback if provided
|
|
179
|
-
// onRowEdited?.(newRow, columnKey, value);
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
[columns, editRow, rowKeyGetter, rows, setRows]
|
|
183
|
-
);
|
|
184
|
-
|
|
185
154
|
/** ROWS SORTING **/
|
|
186
155
|
|
|
187
156
|
const [sorts, setSorts] = useState<Record<string, DataGridSort>>(
|
|
@@ -301,7 +270,6 @@ export const useDataGrid = <R,>(
|
|
|
301
270
|
setFilters,
|
|
302
271
|
editingCell,
|
|
303
272
|
setEditingCell,
|
|
304
|
-
onCellEdited,
|
|
305
273
|
copyTable,
|
|
306
274
|
setColumnWidth,
|
|
307
275
|
settings,
|
|
@@ -340,7 +308,6 @@ export const useDataGrid = <R,>(
|
|
|
340
308
|
sorts,
|
|
341
309
|
filters,
|
|
342
310
|
editingCell,
|
|
343
|
-
onCellEdited,
|
|
344
311
|
copyTable,
|
|
345
312
|
setColumnWidth,
|
|
346
313
|
settings,
|
|
@@ -45,7 +45,7 @@ type ExcelOptions = {
|
|
|
45
45
|
valueGetter?: (value: any) => string;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
type CommonGridColumnProps<R> = {
|
|
48
|
+
type CommonGridColumnProps<R, T> = {
|
|
49
49
|
key: string;
|
|
50
50
|
component?: DataGridCellFC;
|
|
51
51
|
color?: ThemeColor;
|
|
@@ -57,44 +57,66 @@ type CommonGridColumnProps<R> = {
|
|
|
57
57
|
| Record<string, DataGridFooterFunction<R> | null>;
|
|
58
58
|
name: ReactNode;
|
|
59
59
|
order?: number;
|
|
60
|
+
getter: (row: R) => T;
|
|
60
61
|
render?: (row: R, column: DataGridColumn<R>) => ReactNode | string;
|
|
61
62
|
resizable?: boolean;
|
|
62
63
|
sortGetter?: (row: R) => string | number;
|
|
63
64
|
width?: number;
|
|
64
65
|
};
|
|
65
66
|
|
|
66
|
-
type
|
|
67
|
+
export type EditableDataGridColumn<R, T> = CommonGridColumnProps<R, T> & {
|
|
67
68
|
editable?: boolean;
|
|
68
69
|
editComponent?: DataGridEditableCellFC<R, T>;
|
|
70
|
+
partialRowGetter?: (row: R, value: T) => Partial<R>;
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
export type DataGridTextColumn<R> =
|
|
73
|
+
export type DataGridTextColumn<R> = EditableDataGridColumn<R, string> & {
|
|
72
74
|
type: 'text';
|
|
73
|
-
getter: (row: R) => string;
|
|
74
75
|
};
|
|
75
76
|
|
|
76
|
-
export type DataGridNumberColumn<R> =
|
|
77
|
+
export type DataGridNumberColumn<R> = EditableDataGridColumn<R, number> & {
|
|
77
78
|
type: 'number';
|
|
78
|
-
getter: (row: R) => number;
|
|
79
79
|
decimals?: number;
|
|
80
80
|
currency?: string | ((row: R) => string);
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
export type DataGridDateColumn<R> =
|
|
83
|
+
export type DataGridDateColumn<R> = EditableDataGridColumn<R, Date> & {
|
|
84
84
|
type: 'date';
|
|
85
|
-
getter: (row: R) => Date;
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
export type DataGridCheckboxColumn<R> =
|
|
87
|
+
export type DataGridCheckboxColumn<R> = EditableDataGridColumn<R, boolean> & {
|
|
89
88
|
type: 'checkbox';
|
|
90
|
-
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type DataGridSelectColumn<R, T = any> = EditableDataGridColumn<
|
|
92
|
+
R,
|
|
93
|
+
T | null
|
|
94
|
+
> & {
|
|
95
|
+
type: 'select';
|
|
96
|
+
items: T[];
|
|
97
|
+
itemKey: (item: T) => string;
|
|
98
|
+
itemLabel: (item: T) => string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type DataGridForeignListColumn<R> = EditableDataGridColumn<
|
|
102
|
+
R,
|
|
103
|
+
string | null
|
|
104
|
+
> & {
|
|
105
|
+
type: 'foreignList';
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type DataGridColorColumn<R> = EditableDataGridColumn<R, string> & {
|
|
109
|
+
type: 'color';
|
|
91
110
|
};
|
|
92
111
|
|
|
93
112
|
export type DataGridColumn<R> =
|
|
94
113
|
| DataGridTextColumn<R>
|
|
95
114
|
| DataGridNumberColumn<R>
|
|
96
115
|
| DataGridDateColumn<R>
|
|
97
|
-
| DataGridCheckboxColumn<R
|
|
116
|
+
| DataGridCheckboxColumn<R>
|
|
117
|
+
| DataGridSelectColumn<R>
|
|
118
|
+
| DataGridForeignListColumn<R>
|
|
119
|
+
| DataGridColorColumn<R>;
|
|
98
120
|
|
|
99
121
|
export type DataGridColumnWithFilter<R> = DataGridColumn<R> & {
|
|
100
122
|
filter: DataGridFilter;
|
|
@@ -233,6 +255,9 @@ export type DataGridCellProps<R> = {
|
|
|
233
255
|
userSelect?: boolean;
|
|
234
256
|
color?: ThemeColor;
|
|
235
257
|
};
|
|
258
|
+
export type EditableDataGridCellProps<R, T> = DataGridCellProps<R> & {
|
|
259
|
+
column: EditableDataGridColumn<R, T>;
|
|
260
|
+
};
|
|
236
261
|
|
|
237
262
|
export type DataGridHeaderCellProps<R> = {
|
|
238
263
|
columnKey: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ForwardedRef, forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { SqlRequestForeignList } from '../SqlRequestForeignList';
|
|
4
|
+
import { SqlRequestForeignListProps } from '../SqlRequestForeignList/types';
|
|
5
|
+
|
|
6
|
+
const SqlRequestForeignListEditableCellInner = <
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
R extends Record<string, any>
|
|
9
|
+
>(
|
|
10
|
+
props: SqlRequestForeignListProps<R>,
|
|
11
|
+
ref: ForwardedRef<HTMLDivElement>
|
|
12
|
+
) => <SqlRequestForeignList<R> {...props} ref={ref} />;
|
|
13
|
+
|
|
14
|
+
export const SqlRequestForeignListEditableCell = forwardRef(
|
|
15
|
+
SqlRequestForeignListEditableCellInner
|
|
16
|
+
);
|