@tsiky/components-r19 1.0.0 → 1.2.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.
Files changed (61) hide show
  1. package/index.ts +35 -33
  2. package/package.json +1 -1
  3. package/src/components/AnnouncementPanel/FlexRowContainer.css +17 -17
  4. package/src/components/AnnouncementPanel/FlexRowContainer.stories.tsx +329 -329
  5. package/src/components/AnnouncementPanel/FlexRowContainer.tsx +24 -24
  6. package/src/components/AnnouncementPanel/ListBox/CounterListBox.css +56 -56
  7. package/src/components/AnnouncementPanel/ListBox/CounterListBox.stories.tsx +292 -292
  8. package/src/components/AnnouncementPanel/ListBox/CounterListBox.tsx +106 -106
  9. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.css +57 -57
  10. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.stories.tsx +189 -189
  11. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.tsx +138 -138
  12. package/src/components/AnnouncementPanel/ListBox/TrendListBox.css +61 -61
  13. package/src/components/AnnouncementPanel/ListBox/TrendListBox.stories.tsx +257 -257
  14. package/src/components/AnnouncementPanel/ListBox/TrendListBox.tsx +90 -90
  15. package/src/components/AnnouncementPanel/ListBox/index.ts +3 -3
  16. package/src/components/AnnouncementPanel/ListContentContainer.css +23 -23
  17. package/src/components/AnnouncementPanel/ListContentContainer.stories.tsx +212 -212
  18. package/src/components/AnnouncementPanel/ListContentContainer.tsx +33 -33
  19. package/src/components/AnnouncementPanel/index.ts +3 -3
  20. package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +129 -89
  21. package/src/components/Charts/bar-chart/BarChart.tsx +171 -132
  22. package/src/components/Charts/boxplot-chart/BoxPlotChart.tsx +114 -114
  23. package/src/components/Charts/mixed-chart/MixedChart.tsx +65 -9
  24. package/src/components/Charts/sankey-adaptation/sankey.tsx +70 -70
  25. package/src/components/Charts/sankey-chart/SankeyChart.tsx +183 -155
  26. package/src/components/Confirmationpopup/ConfirmationPopup.module.css +88 -0
  27. package/src/components/Confirmationpopup/ConfirmationPopup.stories.tsx +94 -0
  28. package/src/components/Confirmationpopup/ConfirmationPopup.tsx +47 -0
  29. package/src/components/Confirmationpopup/index.ts +6 -0
  30. package/src/components/Confirmationpopup/useConfirmationPopup.ts +48 -0
  31. package/src/components/DayStatCard/DayStatCard.tsx +96 -69
  32. package/src/components/DraggableSwitcher/DraggableSwitcherButton.tsx +58 -58
  33. package/src/components/DraggableSwitcher/context/useDraggableSwitcher.tsx +45 -45
  34. package/src/components/DraggableSwitcher/index.ts +2 -2
  35. package/src/components/DynamicInput/input/SelectInput.tsx +75 -75
  36. package/src/components/DynamicInput/input/assets/SelectInput.module.css +95 -95
  37. package/src/components/DynamicTable/TableCell.tsx +38 -30
  38. package/src/components/DynamicTable/TableHeader.tsx +39 -34
  39. package/src/components/DynamicTable/TableauDynamique.module.css +1333 -1287
  40. package/src/components/DynamicTable/TableauDynamique.tsx +154 -154
  41. package/src/components/DynamicTable/tools/tableTypes.ts +63 -63
  42. package/src/components/Grid/Grid.tsx +5 -0
  43. package/src/components/Grid/grid.css +285 -285
  44. package/src/components/Header/Header.tsx +4 -2
  45. package/src/components/Header/header.css +61 -31
  46. package/src/components/MetricsPanel/MetricsPanel.module.css +688 -636
  47. package/src/components/MetricsPanel/MetricsPanel.tsx +220 -282
  48. package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +148 -125
  49. package/src/components/NavBar/NavBar.tsx +1 -1
  50. package/src/components/NavItem/NavItem.tsx +58 -58
  51. package/src/components/PeriodRange/PeriodRange.module.css +158 -158
  52. package/src/components/PeriodRange/PeriodRange.tsx +130 -130
  53. package/src/components/SearchBar/SearchBar.css +40 -40
  54. package/src/components/SelectFilter/SelectFilter.module.css +249 -0
  55. package/src/components/SelectFilter/SelectFilter.stories.tsx +321 -0
  56. package/src/components/SelectFilter/SelectFilter.tsx +219 -0
  57. package/src/components/SelectFilter/index.ts +2 -0
  58. package/src/components/SelectFilter/types.ts +19 -0
  59. package/src/components/TranslationKey/TranslationKey.css +272 -272
  60. package/src/components/TranslationKey/TranslationKey.tsx +266 -245
  61. 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
- import { Grid } from '../Grid';
12
- const DEFAULT_SUMMARY_BG_COLORS = ['transparent', 'transparent', 'transparent', 'transparent'];
13
- const DEFAULT_SUMMARY_BORDER_COLORS = ['transparent', 'transparent', 'transparent', 'transparent'];
14
- const DEFAULT_SUMMARY_VALUE_COLORS = ['#059669', '#2563eb', '#b45309', '#7c3aed'];
15
-
16
- const hexToRgba = (c: string | undefined | null, a = 1) => {
17
- try {
18
- return utilHexToRgba(c as any, a);
19
- } catch {
20
- return `rgba(124, 58, 237, ${a})`;
21
- }
22
- };
23
-
24
- type LocalProps = {
25
- itemsContainerStyle?: React.CSSProperties;
26
- itemsContainerClassName?: string;
27
- summaryGridColumns?: number;
28
-
29
- compactItemWidth?: string | number;
30
- compactItemHeight?: string | number;
31
- compactItemStyle?: React.CSSProperties;
32
-
33
- summaryCardWidth?: string | number;
34
- summaryCardHeight?: string | number;
35
- summaryCardStyle?: React.CSSProperties;
36
-
37
- grid?: boolean;
38
- orderGrid?: number[];
39
- draggableGrid?: boolean;
40
- onSwapGrid?: (dragIndex: number, dropIndex: number) => void;
41
- };
42
-
43
- export const MetricsPanel: React.FC<MetricsPanelProps & LocalProps> = (props) => {
44
- const {
45
- items = [],
46
- layout = 'vertical',
47
- orientation = 'auto',
48
- shape = 'rounded',
49
- color = '#7c3aed',
50
- compact = false,
51
- title,
52
- onItemClick,
53
- className = '',
54
- loading = false,
55
- emptyMessage = 'Aucun élément',
56
- renderItem,
57
- summary = false,
58
- summaryBgColors = DEFAULT_SUMMARY_BG_COLORS,
59
- summaryBorderColors = DEFAULT_SUMMARY_BORDER_COLORS,
60
- summaryValueColors = DEFAULT_SUMMARY_VALUE_COLORS,
61
- preset,
62
- background,
63
- grid = false,
64
- orderGrid = [],
65
- draggableGrid = false,
66
- onSwapGrid,
67
- } = props as any;
68
-
69
- const {
70
- itemsContainerStyle,
71
- itemsContainerClassName,
72
- summaryGridColumns,
73
- compactItemWidth,
74
- compactItemHeight,
75
- compactItemStyle,
76
- summaryCardWidth,
77
- summaryCardHeight,
78
- summaryCardStyle,
79
- } = props as LocalProps;
80
-
81
- const isVertical = layout === 'vertical';
82
- const rootStyle = {
83
- ['--mp-accent' as any]: color,
84
- ['--mp-accent-soft' as any]: hexToRgba(color, 0.08),
85
- ['--mp-bg-primary' as any]: background,
86
- } as React.CSSProperties & Record<string, string>;
87
-
88
- const panelClasses = [
89
- styles.mpRoot,
90
- isVertical ? styles.mpVertical : styles.mpHorizontal,
91
- compact ? styles.mpCompact : '',
92
- summary ? styles.mpSummaryRoot : '',
93
- orientation !== 'auto'
94
- ? orientation === 'vertical'
95
- ? styles.mpOrientationVertical
96
- : styles.mpOrientationHorizontal
97
- : '',
98
- className,
99
- ]
100
- .filter(Boolean)
101
- .join(' ');
102
-
103
- const effectiveRenderItem = useMemo(() => {
104
- if (renderItem) return renderItem;
105
- const chosen = chooseDefaultRender(preset);
106
- return chosen ?? undefined;
107
- }, [renderItem, preset]);
108
-
109
- if (summary) {
110
- const summaryContainerClass =
111
- orientation === 'horizontal' ? styles.mpSummaryFlex : styles.mpSummaryVertical;
112
-
113
- const gridStyle: React.CSSProperties | undefined = summaryGridColumns
114
- ? {
115
- display: 'grid',
116
- gridTemplateColumns: `repeat(${summaryGridColumns}, 1fr)`,
117
- gap: 18,
118
- alignItems: 'stretch',
119
- width: '100%',
120
- }
121
- : undefined;
122
-
123
- const mergedStyle = { ...(gridStyle ?? {}), ...(itemsContainerStyle ?? {}) };
124
-
125
- return (
126
- <div className={panelClasses} style={rootStyle} aria-busy={loading}>
127
- {title && <PanelHeader title={title} />}
128
- <div className={styles.mpSummaryInner}>
129
- <div
130
- className={`${summaryContainerClass} ${itemsContainerClassName ?? ''}`}
131
- style={mergedStyle}
132
- >
133
- {items.length === 0 ? (
134
- <div className={styles.mpEmpty}>{emptyMessage}</div>
135
- ) : (
136
- items.map((item: ItemType, i: number) => {
137
- const bg = item.bgColor ?? summaryBgColors[i % summaryBgColors.length];
138
- const border =
139
- item.borderColor ?? summaryBorderColors[i % summaryBorderColors.length];
140
- const valueColor =
141
- item.valueColor ?? summaryValueColors[i % summaryValueColors.length];
142
-
143
- if (effectiveRenderItem) {
144
- return (
145
- <div
146
- key={item.id}
147
- className={
148
- orientation === 'horizontal'
149
- ? styles.mpSummaryCardWrapperHorizontal
150
- : styles.mpSummaryCardWrapper
151
- }
152
- style={{
153
- width: summaryCardWidth ?? undefined,
154
- height: summaryCardHeight ?? undefined,
155
- ...(summaryCardStyle ?? {}),
156
- }}
157
- >
158
- {effectiveRenderItem(item, i)}
159
- </div>
160
- );
161
- }
162
-
163
- return (
164
- <SummaryCard
165
- key={item.id}
166
- item={item}
167
- orientation={orientation === 'horizontal' ? 'horizontal' : 'vertical'}
168
- bg={bg}
169
- border={border}
170
- valueColor={valueColor}
171
- onClick={onItemClick}
172
- width={summaryCardWidth ?? undefined}
173
- height={summaryCardHeight ?? undefined}
174
- extraStyle={summaryCardStyle}
175
- />
176
- );
177
- })
178
- )}
179
- </div>
180
- </div>
181
- </div>
182
- );
183
- }
184
-
185
- /* non-summary list mode */
186
- return (
187
- <div className={panelClasses} style={rootStyle} aria-busy={loading}>
188
- {title && <PanelHeader title={title} />}
189
-
190
- {grid ? (
191
- <Grid
192
- parent
193
- container
194
- order={orderGrid}
195
- draggable={draggableGrid}
196
- onSwap={onSwapGrid}
197
- xs={12}
198
- className={styles.mpList}
199
- style={{ alignItems: 'stretch', height: '100%', ...itemsContainerStyle }}
200
- >
201
- {loading ? (
202
- <div className={styles.mpEmpty}>Chargement…</div>
203
- ) : items.length === 0 ? (
204
- <div className={styles.mpEmpty}>{emptyMessage}</div>
205
- ) : (
206
- items.map((item: ItemType, index: number) => {
207
- const wrapperStyle: React.CSSProperties | undefined = compact
208
- ? {
209
- width: compactItemWidth,
210
- height: compactItemHeight,
211
- boxSizing: 'border-box',
212
- ...compactItemStyle,
213
- }
214
- : undefined;
215
-
216
- return (
217
- <Grid item xs={12} key={item.id} uniqueKey={index}>
218
- <div
219
- className={compact ? styles.compactItemWrapper : undefined}
220
- style={wrapperStyle}
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);