@addev-be/ui 0.2.5 → 0.2.7

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