@tsiky/components-r19 1.0.0 → 1.1.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/index.ts +35 -33
- package/package.json +1 -1
- package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +123 -89
- package/src/components/Charts/bar-chart/BarChart.tsx +167 -132
- package/src/components/Charts/mixed-chart/MixedChart.tsx +65 -9
- package/src/components/Charts/sankey-chart/SankeyChart.tsx +183 -155
- package/src/components/Confirmationpopup/ConfirmationPopup.module.css +88 -0
- package/src/components/Confirmationpopup/ConfirmationPopup.stories.tsx +94 -0
- package/src/components/Confirmationpopup/ConfirmationPopup.tsx +47 -0
- package/src/components/Confirmationpopup/index.ts +6 -0
- package/src/components/Confirmationpopup/useConfirmationPopup.ts +48 -0
- package/src/components/DayStatCard/DayStatCard.tsx +96 -69
- package/src/components/DynamicTable/AdvancedFilters.tsx +196 -196
- package/src/components/DynamicTable/ColumnSorter.tsx +185 -185
- package/src/components/DynamicTable/Pagination.tsx +115 -115
- package/src/components/DynamicTable/TableauDynamique.module.css +1287 -1287
- package/src/components/DynamicTable/filters/SelectFilter.tsx +69 -69
- package/src/components/EntryControl/EntryControl.tsx +117 -117
- package/src/components/Grid/Grid.tsx +5 -0
- package/src/components/Header/Header.tsx +4 -2
- package/src/components/Header/header.css +61 -31
- package/src/components/MetricsPanel/MetricsPanel.module.css +688 -636
- package/src/components/MetricsPanel/MetricsPanel.tsx +220 -282
- package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +148 -125
- package/src/components/NavBar/NavBar.tsx +1 -1
- package/src/components/SelectFilter/SelectFilter.module.css +249 -0
- package/src/components/SelectFilter/SelectFilter.stories.tsx +321 -0
- package/src/components/SelectFilter/SelectFilter.tsx +219 -0
- package/src/components/SelectFilter/index.ts +2 -0
- package/src/components/SelectFilter/types.ts +19 -0
- package/src/components/TranslationKey/TranslationKey.tsx +265 -245
- package/src/components/TrendList/TrendList.tsx +72 -45
|
@@ -1,282 +1,220 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
/* MetricsPanel.tsx (réorganisé — importe les sous-composants) */
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import styles from './MetricsPanel.module.css';
|
|
5
|
-
import MetricsItem from './MetricsItem';
|
|
6
|
-
import PanelHeader from './PanelHeader';
|
|
7
|
-
import chooseDefaultRender from './tools/chooseDefaultRender';
|
|
8
|
-
import SummaryCard from './SummaryCard';
|
|
9
|
-
import { hexToRgba as utilHexToRgba } from './tools/colorUtils';
|
|
10
|
-
import type { MetricsPanelProps, MetricsItem as ItemType } from './tools/MetricsPanelTypes';
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const gridStyle
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
<MetricsItem
|
|
223
|
-
item={item}
|
|
224
|
-
shape={shape}
|
|
225
|
-
onItemClick={onItemClick}
|
|
226
|
-
color={color}
|
|
227
|
-
renderItem={
|
|
228
|
-
effectiveRenderItem
|
|
229
|
-
? (it) => effectiveRenderItem(it, items.indexOf(it))
|
|
230
|
-
: undefined
|
|
231
|
-
}
|
|
232
|
-
/>
|
|
233
|
-
</div>
|
|
234
|
-
</Grid>
|
|
235
|
-
);
|
|
236
|
-
})
|
|
237
|
-
)}
|
|
238
|
-
</Grid>
|
|
239
|
-
) : (
|
|
240
|
-
<div className={styles.mpList} style={itemsContainerStyle}>
|
|
241
|
-
{loading ? (
|
|
242
|
-
<div className={styles.mpEmpty}>Chargement…</div>
|
|
243
|
-
) : items.length === 0 ? (
|
|
244
|
-
<div className={styles.mpEmpty}>{emptyMessage}</div>
|
|
245
|
-
) : (
|
|
246
|
-
items.map((item: ItemType) => {
|
|
247
|
-
const wrapperStyle: React.CSSProperties | undefined = compact
|
|
248
|
-
? {
|
|
249
|
-
width: compactItemWidth ?? undefined,
|
|
250
|
-
height: compactItemHeight ?? undefined,
|
|
251
|
-
boxSizing: 'border-box',
|
|
252
|
-
...(compactItemStyle ?? {}),
|
|
253
|
-
}
|
|
254
|
-
: undefined;
|
|
255
|
-
|
|
256
|
-
return (
|
|
257
|
-
<div
|
|
258
|
-
key={item.id}
|
|
259
|
-
className={compact ? styles.compactItemWrapper : undefined}
|
|
260
|
-
style={wrapperStyle}
|
|
261
|
-
>
|
|
262
|
-
<MetricsItem
|
|
263
|
-
item={item}
|
|
264
|
-
shape={shape}
|
|
265
|
-
onItemClick={onItemClick}
|
|
266
|
-
color={color}
|
|
267
|
-
renderItem={
|
|
268
|
-
effectiveRenderItem
|
|
269
|
-
? (it) => effectiveRenderItem(it, items.indexOf(it))
|
|
270
|
-
: undefined
|
|
271
|
-
}
|
|
272
|
-
/>
|
|
273
|
-
</div>
|
|
274
|
-
);
|
|
275
|
-
})
|
|
276
|
-
)}
|
|
277
|
-
</div>
|
|
278
|
-
)}
|
|
279
|
-
</div>
|
|
280
|
-
);
|
|
281
|
-
};
|
|
282
|
-
export default React.memo(MetricsPanel);
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* MetricsPanel.tsx (réorganisé — importe les sous-composants) */
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import styles from './MetricsPanel.module.css';
|
|
5
|
+
import MetricsItem from './MetricsItem';
|
|
6
|
+
import PanelHeader from './PanelHeader';
|
|
7
|
+
import chooseDefaultRender from './tools/chooseDefaultRender';
|
|
8
|
+
import SummaryCard from './SummaryCard';
|
|
9
|
+
import { hexToRgba as utilHexToRgba } from './tools/colorUtils';
|
|
10
|
+
import type { MetricsPanelProps, MetricsItem as ItemType } from './tools/MetricsPanelTypes';
|
|
11
|
+
const DEFAULT_SUMMARY_BG_COLORS = ['transparent', 'transparent', 'transparent', 'transparent'];
|
|
12
|
+
const DEFAULT_SUMMARY_BORDER_COLORS = ['transparent', 'transparent', 'transparent', 'transparent'];
|
|
13
|
+
const DEFAULT_SUMMARY_VALUE_COLORS = ['#059669', '#2563eb', '#b45309', '#7c3aed'];
|
|
14
|
+
|
|
15
|
+
const hexToRgba = (c: string | undefined | null, a = 1) => {
|
|
16
|
+
try {
|
|
17
|
+
return utilHexToRgba(c as any, a);
|
|
18
|
+
} catch {
|
|
19
|
+
return `rgba(124, 58, 237, ${a})`;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type LocalProps = {
|
|
24
|
+
itemsContainerStyle?: React.CSSProperties;
|
|
25
|
+
itemsContainerClassName?: string;
|
|
26
|
+
summaryGridColumns?: number;
|
|
27
|
+
|
|
28
|
+
compactItemWidth?: string | number;
|
|
29
|
+
compactItemHeight?: string | number;
|
|
30
|
+
compactItemStyle?: React.CSSProperties;
|
|
31
|
+
|
|
32
|
+
summaryCardWidth?: string | number;
|
|
33
|
+
summaryCardHeight?: string | number;
|
|
34
|
+
summaryCardStyle?: React.CSSProperties;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const MetricsPanel: React.FC<MetricsPanelProps & LocalProps> = (props) => {
|
|
38
|
+
const {
|
|
39
|
+
items = [],
|
|
40
|
+
layout = 'vertical',
|
|
41
|
+
orientation = 'auto',
|
|
42
|
+
shape = 'rounded',
|
|
43
|
+
color = '#7c3aed',
|
|
44
|
+
compact = false,
|
|
45
|
+
title,
|
|
46
|
+
onItemClick,
|
|
47
|
+
className = '',
|
|
48
|
+
loading = false,
|
|
49
|
+
emptyMessage = 'Aucun élément',
|
|
50
|
+
renderItem,
|
|
51
|
+
summary = false,
|
|
52
|
+
summaryBgColors = DEFAULT_SUMMARY_BG_COLORS,
|
|
53
|
+
summaryBorderColors = DEFAULT_SUMMARY_BORDER_COLORS,
|
|
54
|
+
summaryValueColors = DEFAULT_SUMMARY_VALUE_COLORS,
|
|
55
|
+
preset,
|
|
56
|
+
background,
|
|
57
|
+
} = props as any;
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
itemsContainerStyle,
|
|
61
|
+
itemsContainerClassName,
|
|
62
|
+
summaryGridColumns,
|
|
63
|
+
compactItemWidth,
|
|
64
|
+
compactItemHeight,
|
|
65
|
+
compactItemStyle,
|
|
66
|
+
summaryCardWidth,
|
|
67
|
+
summaryCardHeight,
|
|
68
|
+
summaryCardStyle,
|
|
69
|
+
} = props as LocalProps;
|
|
70
|
+
|
|
71
|
+
const isVertical = layout === 'vertical';
|
|
72
|
+
const rootStyle = {
|
|
73
|
+
['--mp-accent' as any]: color,
|
|
74
|
+
['--mp-accent-soft' as any]: hexToRgba(color, 0.08),
|
|
75
|
+
['--mp-bg-primary' as any]: background,
|
|
76
|
+
} as React.CSSProperties & Record<string, string>;
|
|
77
|
+
|
|
78
|
+
const panelClasses = [
|
|
79
|
+
styles.mpRoot,
|
|
80
|
+
isVertical ? styles.mpVertical : styles.mpHorizontal,
|
|
81
|
+
compact ? styles.mpCompact : '',
|
|
82
|
+
summary ? styles.mpSummaryRoot : '',
|
|
83
|
+
orientation !== 'auto'
|
|
84
|
+
? orientation === 'vertical'
|
|
85
|
+
? styles.mpOrientationVertical
|
|
86
|
+
: styles.mpOrientationHorizontal
|
|
87
|
+
: '',
|
|
88
|
+
className,
|
|
89
|
+
]
|
|
90
|
+
.filter(Boolean)
|
|
91
|
+
.join(' ');
|
|
92
|
+
|
|
93
|
+
const effectiveRenderItem = useMemo(() => {
|
|
94
|
+
if (renderItem) return renderItem;
|
|
95
|
+
const chosen = chooseDefaultRender(preset);
|
|
96
|
+
return chosen ?? undefined;
|
|
97
|
+
}, [renderItem, preset]);
|
|
98
|
+
|
|
99
|
+
if (summary) {
|
|
100
|
+
const summaryContainerClass =
|
|
101
|
+
orientation === 'horizontal' ? styles.mpSummaryFlex : styles.mpSummaryVertical;
|
|
102
|
+
|
|
103
|
+
const gridStyle: React.CSSProperties | undefined = summaryGridColumns
|
|
104
|
+
? {
|
|
105
|
+
display: 'grid',
|
|
106
|
+
gridTemplateColumns: `repeat(${summaryGridColumns}, 1fr)`,
|
|
107
|
+
gap: 18,
|
|
108
|
+
alignItems: 'stretch',
|
|
109
|
+
width: '100%',
|
|
110
|
+
}
|
|
111
|
+
: undefined;
|
|
112
|
+
|
|
113
|
+
const mergedStyle = { ...(gridStyle ?? {}), ...(itemsContainerStyle ?? {}) };
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div className={panelClasses} style={rootStyle} aria-busy={loading}>
|
|
117
|
+
{title && <PanelHeader title={title} />}
|
|
118
|
+
<div className={styles.mpSummaryInner}>
|
|
119
|
+
<div
|
|
120
|
+
className={`${summaryContainerClass} ${itemsContainerClassName ?? ''}`}
|
|
121
|
+
style={mergedStyle}
|
|
122
|
+
>
|
|
123
|
+
{items.length === 0 ? (
|
|
124
|
+
<div className={styles.mpEmpty}>{emptyMessage}</div>
|
|
125
|
+
) : (
|
|
126
|
+
items.map((item: ItemType, i: number) => {
|
|
127
|
+
const bg = item.bgColor ?? summaryBgColors[i % summaryBgColors.length];
|
|
128
|
+
const border =
|
|
129
|
+
item.borderColor ?? summaryBorderColors[i % summaryBorderColors.length];
|
|
130
|
+
const valueColor =
|
|
131
|
+
item.valueColor ?? summaryValueColors[i % summaryValueColors.length];
|
|
132
|
+
|
|
133
|
+
if (effectiveRenderItem) {
|
|
134
|
+
return (
|
|
135
|
+
<div
|
|
136
|
+
key={item.id}
|
|
137
|
+
className={
|
|
138
|
+
orientation === 'horizontal'
|
|
139
|
+
? styles.mpSummaryCardWrapperHorizontal
|
|
140
|
+
: styles.mpSummaryCardWrapper
|
|
141
|
+
}
|
|
142
|
+
style={{
|
|
143
|
+
width: summaryCardWidth ?? undefined,
|
|
144
|
+
height: summaryCardHeight ?? undefined,
|
|
145
|
+
...(summaryCardStyle ?? {}),
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
{effectiveRenderItem(item, i)}
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<SummaryCard
|
|
155
|
+
key={item.id}
|
|
156
|
+
item={item}
|
|
157
|
+
orientation={orientation === 'horizontal' ? 'horizontal' : 'vertical'}
|
|
158
|
+
bg={bg}
|
|
159
|
+
border={border}
|
|
160
|
+
valueColor={valueColor}
|
|
161
|
+
onClick={onItemClick}
|
|
162
|
+
width={summaryCardWidth ?? undefined}
|
|
163
|
+
height={summaryCardHeight ?? undefined}
|
|
164
|
+
extraStyle={summaryCardStyle}
|
|
165
|
+
/>
|
|
166
|
+
);
|
|
167
|
+
})
|
|
168
|
+
)}
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* non-summary list mode */
|
|
176
|
+
return (
|
|
177
|
+
<div className={panelClasses} style={rootStyle} aria-busy={loading}>
|
|
178
|
+
{title && <PanelHeader title={title} />}
|
|
179
|
+
<div className={styles.mpList} style={itemsContainerStyle}>
|
|
180
|
+
{loading ? (
|
|
181
|
+
<div className={styles.mpEmpty}>Chargement…</div>
|
|
182
|
+
) : items.length === 0 ? (
|
|
183
|
+
<div className={styles.mpEmpty}>{emptyMessage}</div>
|
|
184
|
+
) : (
|
|
185
|
+
items.map((item: ItemType) => {
|
|
186
|
+
const wrapperStyle: React.CSSProperties | undefined = compact
|
|
187
|
+
? {
|
|
188
|
+
width: compactItemWidth ?? undefined,
|
|
189
|
+
height: compactItemHeight ?? undefined,
|
|
190
|
+
boxSizing: 'border-box',
|
|
191
|
+
...(compactItemStyle ?? {}),
|
|
192
|
+
}
|
|
193
|
+
: undefined;
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<div
|
|
197
|
+
key={item.id}
|
|
198
|
+
className={compact ? styles.compactItemWrapper : undefined}
|
|
199
|
+
style={wrapperStyle}
|
|
200
|
+
>
|
|
201
|
+
<MetricsItem
|
|
202
|
+
item={item}
|
|
203
|
+
shape={shape}
|
|
204
|
+
onItemClick={onItemClick}
|
|
205
|
+
color={color}
|
|
206
|
+
renderItem={
|
|
207
|
+
effectiveRenderItem
|
|
208
|
+
? (it) => effectiveRenderItem(it, items.indexOf(it))
|
|
209
|
+
: undefined
|
|
210
|
+
}
|
|
211
|
+
/>
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
})
|
|
215
|
+
)}
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
export default React.memo(MetricsPanel);
|